[SPARK-57762][SQL] Add missing error class COLUMN_IS_NOT_VARIANT_TYPE#56872
[SPARK-57762][SQL] Add missing error class COLUMN_IS_NOT_VARIANT_TYPE#56872szehon-ho wants to merge 2 commits into
Conversation
|
cc @haoyangeng-db @cloud-fan @dongjoon-hyun could you please help review? Thanks! |
dongjoon-hyun
left a comment
There was a problem hiding this comment.
+1, LGTM. Thank you, @szehon-ho .
MaxGekk
left a comment
There was a problem hiding this comment.
1 blocking, 0 non-blocking, 0 nits.
The error class registration is correct, but the CI failure needs a golden file fix before merging.
Correctness (1)
error-conditions.json:1032: registering this class changes the observed output forSELECT NULL:a AS b;intype-coercion-edge-cases.sqlfromINTERNAL_ERRORtoAnalysisException(COLUMN_IS_NOT_VARIANT_TYPE)-- the golden file still records the old output and must be regenerated. See inline.
| ], | ||
| "sqlState" : "0A000" | ||
| }, | ||
| "COLUMN_IS_NOT_VARIANT_TYPE" : { |
There was a problem hiding this comment.
Registering this error class causes the sql - extended tests CI job to fail with 2 tests:
type-coercion-edge-cases.sqltype-coercion-edge-cases.sql_analyzer_test
The input file contains SELECT NULL:a AS b;, which hits this error path. Before this PR the golden file recorded the old output:
"errorClass" : "INTERNAL_ERROR",
"message" : "Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'"
Now that the class is registered the actual output changes to a proper AnalysisException with errorClass: COLUMN_IS_NOT_VARIANT_TYPE, but sql/core/src/test/resources/sql-tests/results/type-coercion-edge-cases.sql.out (line 53) still records the old text.
Please regenerate the golden files:
SPARK_GENERATE_GOLDEN_FILES=1 build/sbt 'sql/testOnly *SQLQueryTestSuite -- -z type-coercion-edge-cases'
and include the updated type-coercion-edge-cases.sql.out (and the matching analyzer-results/type-coercion-edge-cases.sql.out) in this PR.
dongjoon-hyun
left a comment
There was a problem hiding this comment.
Could you make a CI happy to make it sure, @szehon-ho ?
|
I revisited this in order to merge Today, but it seems that we have no CI success until now. |
### What changes were proposed in this pull request?
The semi-structured extraction operator (`:`) throws the `COLUMN_IS_NOT_VARIANT_TYPE` error class (from `ExtractSemiStructuredFields` and `SemiStructuredExtractResolver`) when applied to a column that is not of the VARIANT type, but the error class was never registered in `error-conditions.json`. This registers the error condition so it resolves correctly through the error framework, and adds a test.
### Why are the changes needed?
The error class was used but not declared. Hitting this path raised `INTERNAL_ERROR` ("Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'") instead of the intended error.
### Does this PR introduce _any_ user-facing change?
No. Previously this code path raised an `INTERNAL_ERROR` because the error class was unregistered; now the intended error message is produced.
### How was this patch tested?
Added a unit test in `QueryCompilationErrorsSuite`. Also ran `SparkThrowableSuite`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)
Regenerate type-coercion-edge-cases.sql golden files so SELECT NULL:a expects AnalysisException(COLUMN_IS_NOT_VARIANT_TYPE) instead of INTERNAL_ERROR.
|
Thanks @dongjoon-hyun. I've rebased onto the latest master to re-trigger CI. I looked into the earlier failures and they appear unrelated to this change (which only adds the |
### What changes were proposed in this pull request?
The semi-structured extraction operator (`:`) throws the `COLUMN_IS_NOT_VARIANT_TYPE` error class (from `ExtractSemiStructuredFields` and `SemiStructuredExtractResolver`) when applied to a column that is not of the VARIANT type, but the error class was never registered in `error-conditions.json`. This registers the error condition so it resolves correctly through the error framework, and adds a test.
### Why are the changes needed?
The error class was used but not declared. Hitting this path raised `INTERNAL_ERROR` ("Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'") instead of the intended error.
### Does this PR introduce _any_ user-facing change?
No. Previously this code path raised an `INTERNAL_ERROR` because the error class was unregistered; now the intended error message is produced.
### How was this patch tested?
Added a unit test in `QueryCompilationErrorsSuite`. Also ran `SparkThrowableSuite`.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)
Closes #56872 from szehon-ho/SPARK-57762.
Authored-by: Szehon Ho <szehon.apache@gmail.com>
Signed-off-by: Szehon Ho <szehon.apache@gmail.com>
(cherry picked from commit aec7c17)
Signed-off-by: Szehon Ho <szehon.apache@gmail.com>
What changes were proposed in this pull request?
The semi-structured extraction operator (
:) throws theCOLUMN_IS_NOT_VARIANT_TYPEerror class (fromExtractSemiStructuredFieldsandSemiStructuredExtractResolver) when applied to a column that is not of the VARIANT type, but the error class was never registered inerror-conditions.json. This registers the error condition so it resolves correctly through the error framework, and adds a test.Why are the changes needed?
The error class was used but not declared. Hitting this path raised
INTERNAL_ERROR("Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'") instead of the intended error.Does this PR introduce any user-facing change?
No. Previously this code path raised an
INTERNAL_ERRORbecause the error class was unregistered; now the intended error message is produced.How was this patch tested?
Added a unit test in
QueryCompilationErrorsSuite. Also ranSparkThrowableSuite.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)