This is an automated email from the ASF dual-hosted git repository.
jonah pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 545976f194 Minor: Document how to test for trailing whitespace in
`slt` / sqllogictests (#13215)
545976f194 is described below
commit 545976f1941c1822b21a8be3effcc4d873735138
Author: Andrew Lamb <[email protected]>
AuthorDate: Thu Nov 7 20:42:51 2024 -0500
Minor: Document how to test for trailing whitespace in `slt` /
sqllogictests (#13215)
* Minor: Document how to test for trailing whitespace
* Apply suggestions from code review
Co-authored-by: Piotr Findeisen <[email protected]>
* Use `|` for consistency
---------
Co-authored-by: Piotr Findeisen <[email protected]>
---
datafusion/sqllogictest/README.md | 33 ++++++++++++++++++++++++
datafusion/sqllogictest/test_files/functions.slt | 21 +++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/datafusion/sqllogictest/README.md
b/datafusion/sqllogictest/README.md
index 5becc75c98..885e92fee2 100644
--- a/datafusion/sqllogictest/README.md
+++ b/datafusion/sqllogictest/README.md
@@ -102,6 +102,39 @@ SELECT * from foo;
Assuming it looks good, check it in!
+## Cookbook: Testing for whitespace
+
+The `sqllogictest` runner will automatically strip trailing whitespace, meaning
+it requires an additional effort to verify that trailing whitespace is
correctly produced
+
+For example, the following test can't distinguish between `Andrew` and `Andrew
`
+(with trailing space):
+
+```text
+query T
+select substr('Andrew Lamb', 1, 7)
+----
+Andrew
+```
+
+To test trailing whitespace, project additional non-whitespace column on the
+right. For example, by selecting `'|'` after the column of interest, the test
+can distinguish between `Andrew` and `Andrew `:
+
+```text
+# Note two spaces between `Andrew` and `|`
+query TT
+select substr('Andrew Lamb', 1, 7), '|'
+----
+Andrew |
+
+# Note only one space between `Andrew` and `|`
+query TT
+select substr('Andrew Lamb', 1, 6), '|'
+----
+Andrew |
+```
+
# Reference
## Running tests: Validation Mode
diff --git a/datafusion/sqllogictest/test_files/functions.slt
b/datafusion/sqllogictest/test_files/functions.slt
index 5b6017b08a..a7568d88f7 100644
--- a/datafusion/sqllogictest/test_files/functions.slt
+++ b/datafusion/sqllogictest/test_files/functions.slt
@@ -735,3 +735,24 @@ query B
select contains('', '');
----
true
+
+
+## Demonstrate how to test for trailing whitespace
+
+# Note no trailing whitespace
+query T
+select substr('Andrew Lamb', 1, 7)
+----
+Andrew
+
+# Note two spaces between `Andrew` and `|`
+query TT
+select substr('Andrew Lamb', 1, 7), '|'
+----
+Andrew |
+
+# Note only one space between `Andrew` and `|`
+query TT
+select substr('Andrew Lamb', 1, 6), '|'
+----
+Andrew |
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]