neilconway commented on code in PR #21238:
URL: https://github.com/apache/datafusion/pull/21238#discussion_r3030926416
##########
datafusion/sqllogictest/test_files/expr.slt:
##########
@@ -724,6 +724,72 @@ SELECT split_part('a,b', '', -2)
statement error DataFusion error: Execution error: field position must not be
zero
SELECT split_part('abc~@~def~@~ghi', '~@~', 0)
+# Position 0 with column input errors even for empty/null inputs
+statement error DataFusion error: Execution error: field position must not be
zero
+SELECT split_part(column1, '.', 0) FROM (VALUES (NULL::text)) AS t(column1)
+
+# split_part with column input (exercises the scalar-delimiter fast path)
+query TTT
+SELECT
+ split_part(column1, '.', 1),
+ split_part(column1, '.', 2),
+ split_part(column1, '.', 3)
+FROM (VALUES ('a.b.c'), ('d.e.f'), ('x.y')) AS t(column1)
+----
+a b c
+d e f
+x y (empty)
+
+# Multi-char delimiter with column input
+query TT
+SELECT
+ split_part(column1, '~@~', 2),
+ split_part(column1, '~@~', 3)
+FROM (VALUES ('abc~@~def~@~ghi'), ('one~@~two')) AS t(column1)
+----
+def ghi
+two (empty)
+
+# Negative position with column input
+query TT
+SELECT
+ split_part(column1, '.', -1),
+ split_part(column1, '.', -2)
+FROM (VALUES ('a.b.c'), ('x.y')) AS t(column1)
+----
+c b
+y x
+
+# Empty delimiter with column input
+query TT
+SELECT
+ split_part(column1, '', 1),
+ split_part(column1, '', 2)
+FROM (VALUES ('abc'), ('xyz')) AS t(column1)
+----
+abc (empty)
+xyz (empty)
+
+# NULL column values with scalar delimiter
+query T
+SELECT split_part(column1, '.', 2)
+FROM (VALUES ('a.b'), (NULL), ('c.d')) AS t(column1)
+----
+b
+NULL
+d
+
+# Utf8View column with scalar delimiter
+query TT
+SELECT
+ split_part(column1, '.', 1),
+ split_part(column1, '.', 2)
+FROM (SELECT arrow_cast(column1, 'Utf8View') AS column1
+ FROM (VALUES ('a.b.c'), ('x.y.z')) AS t(column1))
+----
+a b
+x y
+
Review Comment:
Thanks, done.
--
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]