julianhyde commented on code in PR #3258:
URL: https://github.com/apache/calcite/pull/3258#discussion_r1232532361


##########
core/src/test/resources/sql/functions.iq:
##########
@@ -499,6 +510,144 @@ select CONVERT(DATE, '05/01/2000', 103);
 !ok
 !}
 
+# [CALCITE-5771] Apply two different NULL semantics for CONCAT 
function(enabled in MySQL, Postgresql, BigQuery and MSSQL)
+select concat(null);
++--------+
+| EXPR$0 |
++--------+
+|        |
++--------+
+(1 row)
+
+!ok
+
+select concat(null, '');
++--------+
+| EXPR$0 |
++--------+
+|        |
++--------+
+(1 row)
+
+!ok
+
+select concat('', '');
++--------+
+| EXPR$0 |
++--------+
+|        |
++--------+
+(1 row)
+
+!ok
+
+select concat('a', null, 'b');
++--------+
+| EXPR$0 |
++--------+
+| ab     |
++--------+
+(1 row)
+
+!ok
+
+select concat('a', cast(null as varchar), 'b');
++--------+
+| EXPR$0 |
++--------+
+| ab     |
++--------+
+(1 row)
+
+!ok
+
+select concat(cast(null as varchar), 'a', 'b');
++--------+
+| EXPR$0 |
++--------+
+| ab     |
++--------+
+(1 row)
+
+!ok
+
+select concat(null, null, null);
++--------+
+| EXPR$0 |
++--------+
+|        |
++--------+
+(1 row)
+
+!ok
+
+# test that col1 is empty string rather than NULL
+with v as (select concat(null, '') as col1, 'b' as col2)
+select col2 from v where col1='';
++------+
+| COL2 |
++------+
+| b    |
++------+
+(1 row)
+
+!ok
+
+# concat in BigQuery
+!use post-big-query
+
+select concat('a');
++--------+
+| EXPR$0 |
++--------+
+| a      |
++--------+
+(1 row)
+
+!ok
+
+select concat('a', 'b');
++--------+
+| EXPR$0 |
++--------+
+| ab     |
++--------+
+(1 row)
+
+!ok
+
+select concat('a', cast(null as varchar), 'b');
++--------+
+| EXPR$0 |
++--------+
+|        |
++--------+
+(1 row)
+
+!ok
+
+select concat(null, null, null);
++--------+
+| EXPR$0 |
++--------+
+|        |
++--------+
+(1 row)
+
+!ok
+

Review Comment:
   Quidem's output format isn't helpful here, because it prints empty strings 
the same as null.
   
   May I suggest that you make each test print the value and also print whether 
that value is null, e.g.
   ```
   with t as (select concat(null, null, null) as c)
   select c, c is null as c_is_null
   from t;
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to