[SPARK-56638][SQL] Eliminate legacy error class for TABLESAMPLE fraction validation#55782
Open
XdithyX wants to merge 2 commits into
Open
[SPARK-56638][SQL] Eliminate legacy error class for TABLESAMPLE fraction validation#55782XdithyX wants to merge 2 commits into
XdithyX wants to merge 2 commits into
Conversation
Contributor
Author
|
Hi @cloud-fan and @sarutak, could you please take a look? Thanks. |
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.
What changes were proposed in this pull request?
This PR replaces the legacy parser error class used by invalid
TABLESAMPLEfractions with a named error class (SPARK-56638).Specifically, this PR:
INVALID_TABLESAMPLE_FRACTIONtoerror-conditions.jsonQueryParsingErrors.invalidTableSampleFractionErrorParserUtils.validate(...)call inAstBuilder.withSample(...)for TABLESAMPLE fraction validationPlanParserSuiteto assert the new error classThe validation logic is unchanged.
TABLESAMPLEfractions are still required to be in the[0, 1]interval, allowing the existing rounding epsilon.Why are the changes needed?
ParserUtils.validate(...)always throws_LEGACY_ERROR_TEMP_0064, which is a generic legacy error class.For invalid
TABLESAMPLEfractions, the parser already knows the specific failure: the computed sampling fraction is outside the allowed[0, 1]interval. Using a named error class makes the error condition explicit and continues the ongoing cleanup of legacy temporary error classes.This PR does not update
ParserUtils.validate(...)itself because that helper is shared by unrelated parser validations. Making it throwINVALID_TABLESAMPLE_FRACTIONwould incorrectly label non-TABLESAMPLE parser failures as TABLESAMPLE fraction errors.The new error uses SQLSTATE
22023because the statement is syntactically valid, but the supplied numeric value is invalid/out of range. This is consistent with existing Spark error conditions for invalid argument or range values, such asINVALID_NUMERIC_LITERAL_RANGEand other22023value-validation errors, rather than42601, which is used for syntax errors.Does this PR introduce any user-facing change?
Yes, for invalid
TABLESAMPLEfractions, the error class changes from_LEGACY_ERROR_TEMP_0064toINVALID_TABLESAMPLE_FRACTION.How was this patch tested?
Ran build/sbt 'catalyst / Test / testOnly org.apache.spark.sql.catalyst.parser.PlanParserSuite -- -z "sampled relations"'
Also regenerated and verified the affected SQL golden files:
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'sql / Test / testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z "tablesample-negative.sql"'
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'sql / Test / testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z "pipe-operators.sql"'
build/sbt 'sql / Test / testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z "tablesample-negative.sql"' 'sql / Test / testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z "pipe-operators.sql"'
Was this patch authored or co-authored using generative AI tooling?
Yes. Generated-by: OpenAI GPT-5.5 Codex