cherry-pick branch4.0 : [fix](variant) Disable strict mode for variant internal cast to fix INSERT INTO SELECT returning all NULLs #60900
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
There was a problem hiding this comment.
Pull request overview
Cherry-picks upstream fix #60881 to prevent INSERT INTO SELECT involving variant subcolumn casts (e.g., cast(content['val'] as decimal)) from incorrectly returning all NULL values due to strict-mode propagation into internal variant casting.
Changes:
- Disable strict mode in the cloned
FunctionContextused by variant internal cast-from-root conversion. - Add BE unit test coverage for strict-mode variant casting regression.
- Add a regression test suite + golden output validating
INSERT INTO SELECT(includingLEFT JOINCTE pattern) matchesSELECTbehavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
be/src/vec/functions/cast/cast_to_variant.h |
Disables strict mode on the cloned context for variant internal cast-from-root conversion. |
be/test/vec/function/cast/function_variant_cast_test.cpp |
Adds a regression unit test ensuring strict mode does not force all-NULL results for variant casts. |
regression-test/suites/variant_p0/test_variant_cast_strict_mode.groovy |
Adds end-to-end regression coverage for INSERT INTO SELECT + LEFT JOIN scenario. |
regression-test/data/variant_p0/test_variant_cast_strict_mode.out |
Golden output for the new regression test queries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
48542bd to
e411c1d
Compare
|
run buildall |
|
skip buildall |
…NSERT INTO SELECT returning all NULLs (apache#60881) INSERT INTO SELECT with LEFT JOIN on CTE that casts variant subcolumns (e.g., cast(content['val'] as decimal)) returns all NULLs for the right-side CTE fields, while a direct SELECT produces correct results. In INSERT context, strict mode is enabled. When cast_from_variant_impl clones the FunctionContext, it inherits strict mode. The variant root column may contain null/empty JSONB entries for rows where the subcolumn doesn't exist (mixed-schema variant data). In strict mode, these null entries cause the ENTIRE cast to fail and return all NULLs. Explicitly disable strict mode in the cloned FunctionContext inside cast_from_variant_impl, since this is an internal type conversion within variant processing, not user-provided INSERT data validation. - BE unit test: CastFromVariantStrictModeRegression (variant→Int32, string→Int32 with strict mode enabled) - Regression test: test_variant_cast_strict_mode (INSERT INTO SELECT with LEFT JOIN on CTE with variant subcolumn casts, verifying results match SELECT)
e411c1d to
48cd026
Compare
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
cherry-pick #60881