Normalize NUL to \0 in sqllogictests#17181
Merged
Merged
Conversation
alamb
reviewed
Aug 13, 2025
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Jefffrey
marked this pull request as ready for review
August 13, 2025 20:34
alamb
reviewed
Aug 13, 2025
alamb
left a comment
Contributor
There was a problem hiding this comment.
It is strange that Github still renders this as binary for me
🤷
Looks like git still treats them as binary too 🤔
diff --git a/datafusion/sqllogictest/src/engines/conversion.rs b/datafusion/sqllogictest/src/engines/conversion.rs
index 92ab64059..de3acbee9 100644
--- a/datafusion/sqllogictest/src/engines/conversion.rs
+++ b/datafusion/sqllogictest/src/engines/conversion.rs
@@ -35,7 +35,8 @@ pub(crate) fn varchar_to_str(value: &str) -> String {
if value.is_empty() {
"(empty)".to_string()
} else {
- value.trim_end_matches('\n').to_string()
+ // Escape nulls so that github renders them correctly in the webui
+ value.trim_end_matches('\n').replace("\u{0000}", "\\0")
}
}
diff --git a/datafusion/sqllogictest/test_files/expr.slt b/datafusion/sqllogictest/test_files/expr.slt
index f0bf5d76e..eeea3cd39 100644
Binary files a/datafusion/sqllogictest/test_files/expr.slt and b/datafusion/sqllogictest/test_files/expr.slt differ
diff --git a/datafusion/sqllogictest/test_files/spark/string/char.slt b/datafusion/sqllogictest/test_files/spark/string/char.slt
index abf0c7076..299e2a041 100644
Binary files a/datafusion/sqllogictest/test_files/spark/string/char.slt and b/datafusion/sqllogictest/test_files/spark/string/char.slt differ
Contributor
Author
alamb
approved these changes
Aug 14, 2025
alamb
left a comment
Contributor
There was a problem hiding this comment.
Thank you @Jefffrey
In case anyone else is interested, here is the actua diff of the files, as expected:
(venv) andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ git diff --text 3b8fabdefd0ad0087fc93f727a8f582e1d74f0c5
diff --git a/datafusion/sqllogictest/src/engines/conversion.rs b/datafusion/sqllogictest/src/engines/conversion.rs
index 92ab64059..de3acbee9 100644
--- a/datafusion/sqllogictest/src/engines/conversion.rs
+++ b/datafusion/sqllogictest/src/engines/conversion.rs
@@ -35,7 +35,8 @@ pub(crate) fn varchar_to_str(value: &str) -> String {
if value.is_empty() {
"(empty)".to_string()
} else {
- value.trim_end_matches('\n').to_string()
+ // Escape nulls so that github renders them correctly in the webui
+ value.trim_end_matches('\n').replace("\u{0000}", "\\0")
}
}
diff --git a/datafusion/sqllogictest/test_files/expr.slt b/datafusion/sqllogictest/test_files/expr.slt
index f0bf5d76e..eeea3cd39 100644
--- a/datafusion/sqllogictest/test_files/expr.slt
+++ b/datafusion/sqllogictest/test_files/expr.slt
@@ -427,7 +427,7 @@ NULL
query T
SELECT chr(CAST(0 AS int))
----
-^@
+\0
statement error DataFusion error: Execution error: invalid Unicode scalar value: 9223372036854775807
SELECT chr(CAST(9223372036854775807 AS bigint))
diff --git a/datafusion/sqllogictest/test_files/spark/string/char.slt b/datafusion/sqllogictest/test_files/spark/string/char.slt
index abf0c7076..299e2a041 100644
--- a/datafusion/sqllogictest/test_files/spark/string/char.slt
+++ b/datafusion/sqllogictest/test_files/spark/string/char.slt
@@ -29,6 +29,6 @@ query T
SELECT char(a) FROM (VALUES (-1::INT), (0::INT), (65::INT), (321::INT)) AS t(a);
----
(empty)
-^@
+\0
A
A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Which issue does this PR close?
Rationale for this change
What changes are included in this PR?
In the SLT files, change
NULcharacter to\0string (apparently we already had this forchar.sltAre these changes tested?
Are there any user-facing changes?