Skip to content

cherry-pick branch4.0 : [fix](variant) Disable strict mode for variant internal cast to fix INSERT INTO SELECT returning all NULLs #60900

Open
eldenmoon wants to merge 1 commit intoapache:branch-4.0from
eldenmoon:pick-8cb5a42
Open

cherry-pick branch4.0 : [fix](variant) Disable strict mode for variant internal cast to fix INSERT INTO SELECT returning all NULLs #60900
eldenmoon wants to merge 1 commit intoapache:branch-4.0from
eldenmoon:pick-8cb5a42

Conversation

@eldenmoon
Copy link
Member

cherry-pick #60881

Copilot AI review requested due to automatic review settings February 28, 2026 02:55
@eldenmoon eldenmoon requested a review from yiguolei as a code owner February 28, 2026 02:55
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@eldenmoon
Copy link
Member Author

run buildall

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 FunctionContext used 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 (including LEFT JOIN CTE pattern) matches SELECT behavior.

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.

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 100.00% (1/1) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.99% (19133/36105)
Line Coverage 36.19% (178205/492434)
Region Coverage 32.77% (137983/421045)
Branch Coverage 33.74% (59925/177608)

@eldenmoon
Copy link
Member Author

run buildall

@yiguolei
Copy link
Contributor

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)
@yiguolei
Copy link
Contributor

run buildall

@hello-stephen
Copy link
Contributor

BE UT Coverage Report

Increment line coverage 100.00% (1/1) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.99% (19133/36105)
Line Coverage 36.19% (178214/492434)
Region Coverage 32.78% (138027/421045)
Branch Coverage 33.75% (59934/177608)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants