test: Add SQL file tests for left and right expressions#3463
Merged
andygrove merged 3 commits intoapache:mainfrom Feb 11, 2026
Merged
test: Add SQL file tests for left and right expressions#3463andygrove merged 3 commits intoapache:mainfrom
andygrove merged 3 commits intoapache:mainfrom
Conversation
Enhance left.sql with additional edge case coverage (column + literal for len=0, len=-1, len>length) and unicode tests. Add right.sql with comprehensive coverage including null propagation with non-positive length, substring equivalence, unicode, and mixed null/non-null values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
comphead
reviewed
Feb 10, 2026
| SELECT left(s, -1) FROM test_str_left | ||
|
|
||
| query | ||
| SELECT left(s, 10) FROM test_str_left |
Contributor
There was a problem hiding this comment.
would prob nice to mention why 10 is the edge case? I assume it is related to s length?
Member
Author
There was a problem hiding this comment.
Thanks for the review @comphead. I added comments as requested. I'll merge this once CI is green.
comphead
approved these changes
Feb 10, 2026
Contributor
comphead
left a comment
There was a problem hiding this comment.
Thanks @andygrove appreciate if test description can be added
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?
Follow-up to #3207. Migrates left/right expression tests to the SQL file test framework and adds additional coverage.
Rationale for this change
The SQL file test framework is the recommended approach for expression testing — no Scala code to write, no recompilation needed when tests change, and automatic constant folding disablement.
What changes are included in this PR?
left.sql — Enhanced with additional test cases:
left(s, 0),left(s, -1),left(s, 10)(len exceeds string length)right.sql — New file with comprehensive coverage:
right(NULL, 0)must return NULL not empty stringsubstring(s, -3, 3)Note:
rightusesspark_answer_onlybecauseRightis aRuntimeReplaceableexpression — Spark's optimizer replaces it withIf(IsNull, null, If(len<=0, "", Substring))before Comet's serde layer sees it.How are these changes tested?
All tests run via
CometSqlFileTestSuitewithConfigMatrix: parquet.enable.dictionary=false,true.🤖 Generated with Claude Code