You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/07/30 11:16:56 UTC
(datafusion) 01/01: test: improve `lpad` sqllogictest coverage (#23969)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-23969-0bcbe40024f9405abfc60b945206997a93d1e3e4
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit 64bc392b52d7ab5ca1407040f06d159325af51cc
Author: Yongting You <20...@gmail.com>
AuthorDate: Thu Jul 30 19:16:38 2026 +0800
test: improve `lpad` sqllogictest coverage (#23969)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Closes #.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
Codecov reports low test coverage for this function, so this PR adds
more SLT tests for it.
The tests were AI-generated, and I manually verified that the results
are correct.
See `Codecov` bot comment -> `☔ View full report in Codecov by Harness`
-> `Indirect Changes` for the updated test coverage.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
## Are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
## Are there any user-facing changes?
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
---
.../test_files/string/string_literal.slt | 58 ++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/datafusion/sqllogictest/test_files/string/string_literal.slt b/datafusion/sqllogictest/test_files/string/string_literal.slt
index 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 T
SELECT regexp_replace('foobar', 'bar', 'xx', 'gi')
----
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org