Replace implicit output_schema in RelRoot with explicit ProjectRel for type enforcement #11278
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.
Summary
This refactors how output schema conformance (nullability and type casting) is enforced
for the ClickHouse backend. Previously, an output_schema field was added to the RelRoot
proto message, and the C++ parser would implicitly add a final projection step if types
didn't match. This approach was non-standard and made the type conversion invisible in
the plan.
Now, when the expected output schema differs from the child plan's output (e.g., in
union operations), an explicit ProjectRel with cast expressions is added to the
Substrait plan on the Spark side. This makes the type enforcement visible in the plan
and follows standard Substrait conventions.
Changes
Benefits
Test Plan