andygrove commented on code in PR #373:
URL: https://github.com/apache/datafusion-spark/pull/373#discussion_r4628642368
##########
crates/sqllogictest/test_files/string/find_in_set.slt:
##########
@@ -220,3 +220,54 @@ SELECT find_in_set(arrow_cast(a, 'LargeUtf8'),
arrow_cast('abc,b,ab,c,def', 'Lar
3
0
NULL
+
+# Spark implicitly casts both arguments to strings.
+query II
+SELECT find_in_set(2::INT, '1,2,3'), find_in_set('2', 2::INT);
Review Comment:
Nice coverage of the int and boolean casts. Binary and date go through
different branches of `implicit_cast`, so it might be worth pinning one of each
too. `find_in_set(X'62', 'a,b')` and `find_in_set(DATE '2020-01-01',
'x,2020-01-01')` both return 2 here and on Spark 4.2.0.
##########
crates/sqllogictest/test_files/string/find_in_set.slt:
##########
@@ -220,3 +220,54 @@ SELECT find_in_set(arrow_cast(a, 'LargeUtf8'),
arrow_cast('abc,b,ab,c,def', 'Lar
3
0
NULL
+
+# Spark implicitly casts both arguments to strings.
+query II
+SELECT find_in_set(2::INT, '1,2,3'), find_in_set('2', 2::INT);
+----
+2 1
+
+query I
+SELECT find_in_set(a, 'false,true')
+FROM (VALUES (true), (false), (NULL::BOOLEAN)) AS t(a);
+----
+2
+1
+NULL
+
+query III
+SELECT find_in_set(NULL, 'a'), find_in_set('a', NULL), find_in_set(NULL, NULL);
+----
+NULL NULL NULL
+
+query I
+SELECT find_in_set(arrow_cast(a, 'LargeUtf8'), arrow_cast(b, 'Utf8View'))
+FROM (VALUES ('b', 'a,b'), ('界', 'a,界'), (NULL::STRING, 'a,b')) AS t(a, b);
+----
+2
+2
+NULL
+
+query I
+SELECT find_in_set(arrow_cast(a, 'Dictionary(Int8, Utf8)'), b)
+FROM (VALUES ('b', 'a,b'), ('a', 'a,a'), (NULL::STRING, 'a,b')) AS t(a, b);
+----
+2
+1
+NULL
+
+query T
+SELECT arrow_typeof(find_in_set(arrow_cast('b', 'LargeUtf8'), 'a,b'));
+----
+Int32
+
+query T rowsort
+SELECT arrow_typeof(find_in_set(arrow_cast(a, 'LargeUtf8'), b))
+FROM (VALUES ('b', 'a,b'), (NULL::STRING, 'a,b')) AS t(a, b);
+----
+Int32
+Int32
+
+# xfail spark: DataFusion SQL does not support explicit collations.
Review Comment:
Could this marker link the collation tracking issue, so it gets cleaned up
when collations land? Something like `# xfail spark: collations are not
supported yet (https://github.com/apache/datafusion-spark/issues/299)`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]