neilconway commented on code in PR #23968:
URL: https://github.com/apache/datafusion/pull/23968#discussion_r3675402453
##########
datafusion/sqllogictest/test_files/string/string_literal.slt:
##########
@@ -664,6 +664,64 @@ SELECT rpad('x', 5, 'e' || chr(769)) = 'x' || 'e' ||
chr(769) || 'e' || chr(769)
----
true 5
+# rpad with string, length, and fill arrays in every string width
+query BBB
+SELECT
+ rpad(arrow_cast(column1, 'Utf8'), column2, arrow_cast(column3, 'Utf8')) =
column4,
+ rpad(arrow_cast(column1, 'LargeUtf8'), column2, arrow_cast(column3,
'LargeUtf8')) = column4,
+ rpad(arrow_cast(column1, 'Utf8View'), column2, arrow_cast(column3,
'Utf8View')) = column4
+FROM (VALUES
+ ('hi', 5, 'xy', 'hixyx'),
+ ('abcdef', 3, 'z', 'abc'),
+ ('é', 4, '好', 'é好好好'),
+ ('hi', 5, '', 'hi'),
+ (NULL, 5, 'x', NULL),
+ ('hi', NULL, 'x', NULL),
+ ('hi', 5, NULL, NULL)
+) AS t(column1, column2, column3, column4);
Review Comment:
Checking `NULL = NULL` is probably not doing what we intend; would be better
to do `IS DISTINCT FROM`.
##########
datafusion/sqllogictest/test_files/string/string_literal.slt:
##########
@@ -664,6 +664,64 @@ SELECT rpad('x', 5, 'e' || chr(769)) = 'x' || 'e' ||
chr(769) || 'e' || chr(769)
----
true 5
+# rpad with string, length, and fill arrays in every string width
+query BBB
+SELECT
+ rpad(arrow_cast(column1, 'Utf8'), column2, arrow_cast(column3, 'Utf8')) =
column4,
+ rpad(arrow_cast(column1, 'LargeUtf8'), column2, arrow_cast(column3,
'LargeUtf8')) = column4,
+ rpad(arrow_cast(column1, 'Utf8View'), column2, arrow_cast(column3,
'Utf8View')) = column4
+FROM (VALUES
+ ('hi', 5, 'xy', 'hixyx'),
+ ('abcdef', 3, 'z', 'abc'),
+ ('é', 4, '好', 'é好好好'),
+ ('hi', 5, '', 'hi'),
+ (NULL, 5, 'x', NULL),
+ ('hi', NULL, 'x', NULL),
+ ('hi', 5, NULL, NULL)
+) AS t(column1, column2, column3, column4);
+----
+true true true
+true true true
+true true true
+true true true
+NULL NULL NULL
+NULL NULL NULL
+NULL NULL NULL
+
+# rpad array path with the default fill
+query BBB
+SELECT
+ rpad(arrow_cast(column1, 'Utf8'), column2) = column3,
+ rpad(arrow_cast(column1, 'LargeUtf8'), column2) = column3,
+ rpad(arrow_cast(column1, 'Utf8View'), column2) = column3
+FROM (VALUES ('hi', 5, 'hi '), ('abcdef', 3, 'abc'), (NULL, 5, NULL)) AS
t(column1, column2, column3);
+----
+true true true
+true true true
+NULL NULL NULL
+
+# a large scalar target length skips the scalar fast path
+query I
+SELECT character_length(rpad('x', 16385, 'a'));
+----
+16385
+
+# invalid argument count/type and excessive target length
+query error DataFusion error:
+SELECT rpad();
+
+query error DataFusion error:
+SELECT rpad('x');
+
+query error DataFusion error:
+SELECT rpad('x', 2, 'y', 'z');
+
+query error DataFusion error:
+SELECT rpad('x', 'bad');
Review Comment:
Can we tighten these error matches?
--
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]