Apache DataFusion SQL Query Engine
test: improve `lpad` sqllogictest coverage (#23969)
Yongting You64bc392b52d7
diff --git a/datafusion/sqllogictest/test_files/string/string_literal.slt b/datafusion/sqllogictest/test_files/string/string_literal.sltindex 6962a6d337..06d8bf2a4c 100644--- a/datafusion/sqllogictest/test_files/string/string_literal.slt+++ b/datafusion/sqllogictest/test_files/string/string_literal.slt@@ -341,6 +341,64 @@ SELECT lpad('x', 5, 'e' || chr(769)) = 'e' || chr(769) || 'e' || chr(769) || 'x'----true 5+# lpad with string, length, and fill arrays in every string width+query BBB+SELECT+ lpad(arrow_cast(column1, 'Utf8'), column2, arrow_cast(column3, 'Utf8')) IS NOT DISTINCT FROM column4,+ lpad(arrow_cast(column1, 'LargeUtf8'), column2, arrow_cast(column3, 'LargeUtf8')) IS NOT DISTINCT FROM column4,+ lpad(arrow_cast(column1, 'Utf8View'), column2, arrow_cast(column3, 'Utf8View')) IS NOT DISTINCT FROM column4+FROM (VALUES+ ('hi', 5, 'xy', 'xyxhi'),+ ('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+true true true+true true true+true true true++# lpad array path with the default fill+query BBB+SELECT+ lpad(arrow_cast(column1, 'Utf8'), column2) IS NOT DISTINCT FROM column3,+ lpad(arrow_cast(column1, 'LargeUtf8'), column2) IS NOT DISTINCT FROM column3,+ lpad(arrow_cast(column1, 'Utf8View'), column2) IS NOT DISTINCT FROM column3+FROM (VALUES ('hi', 5, ' hi'), ('abcdef', 3, 'abc'), (NULL, 5, NULL)) AS t(column1, column2, column3);+----+true true true+true true true+true true true++# a large scalar target length skips the scalar fast path+query I+SELECT character_length(lpad('x', 16385, 'a'));+----+16385++# invalid argument count/type and excessive target length+query error 'lpad' does not support zero arguments+SELECT lpad();++query error Failed to coerce arguments to satisfy a call to 'lpad' function: coercion from Utf8 to the signature+SELECT lpad('x');++query error Failed to coerce arguments to satisfy a call to 'lpad' function: coercion from Utf8, Int64, Utf8, Utf8 to the signature+SELECT lpad('x', 2, 'y', 'z');++query error Failed to coerce arguments to satisfy a call to 'lpad' function: coercion from Utf8, Utf8 to the signature+SELECT lpad('x', 'bad');++query error lpad requested length 2147483648 too large+SELECT lpad('x', 2147483648, 'y');+query TSELECT regexp_replace('foobar', 'bar', 'xx', 'gi')----