Weijun-H commented on code in PR #13356:
URL: https://github.com/apache/datafusion/pull/13356#discussion_r1843136626


##########
datafusion/sqllogictest/test_files/nullif.slt:
##########
@@ -97,11 +97,35 @@ SELECT NULLIF(1, 3);
 ----
 1
 
-query I
+query T
 SELECT NULLIF(NULL, NULL);
 ----
 NULL
 
+query R
+select nullif(1, 1.2);
+----
+1
+
+query R
+select nullif(1.0, 2);
+----
+1
+
+query error DataFusion error: Error during planning: Internal error: Failed to 
match any signature, errors: Error during planning: The signature expected 
NativeType::String but received NativeType::Int64
+select nullif(2, 'a');
+
+
+query T
+select nullif('2', '3');
+----
+2
+
+# TODO: support numeric string
+# This query success in Postgres and DuckDB
+query error DataFusion error: Error during planning: Internal error: Failed to 
match any signature, errors: Error during planning: The signature expected 
NativeType::String but received NativeType::Int64
+select nullif(2, '1');

Review Comment:
   I don't have strong opinions against this PR because it fixes 
`nullif('1'::varchar, 2)` and refines the `TypeSignature`. We could file a 
ticket for it and address it in a follow-up.



##########
datafusion/expr-common/src/signature.rs:
##########
@@ -284,11 +296,13 @@ impl TypeSignature {
                 .cloned()
                 .map(|numeric_type| vec![numeric_type; *arg_count])
                 .collect(),
-            TypeSignature::String(arg_count) => STRINGS
-                .iter()
-                .cloned()
-                .map(|string_type| vec![string_type; *arg_count])
-                .collect(),
+            TypeSignature::String(arg_count) => 
get_data_types(&NativeType::String)
+                .into_iter()
+                .map(|dt| vec![dt; *arg_count])
+                .collect::<Vec<_>>(),

Review Comment:
   👍 



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to