-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(query): improve update handling about nondeterministic_update and add nullable columns #17586
base: main
Are you sure you want to change the base?
Conversation
b9db1db
to
82386a4
Compare
Thanks for contributing! |
Please provide some test cases to reproduce the bug you wish to fix |
Should the default field type of a temporary table created with a |
-- This sql is working fine.
with tbb as (select col0::string null col1,col1::string null col2,col2::string null col3 from (values ('1', 'add', '11'), ('4', 'add', '44')))
update test_merge tba set tba.col1 =tbb.col1, tba.col2 = 'update', tba.col3 = tbb.col3 from tbb where tba.col1 = tbb.col1;
-- But this one no work
with tbb("col1", "col2", "col3") as (values ('1', 'add', '11'), ('4', 'add', '44'))
update test_merge tba set tba.col1 =tbb.col1::string null, tba.col2 = 'update', tba.col3 = tbb.col3::string null from tbb where tba.col1 = tbb.col1::string null; My guess is that type_check is not handling the type correctly, so you can check it out. |
|
databend/src/query/sql/src/planner/binder/bind_mutation/update.rs Lines 169 to 180 in cd95677
If expr is a not null type, cast to a nullable type, because the following aggregation will converts the column to nullable |
![]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nesting level is too deep and is hard to understand. Please extract inner logic to some small function or use intermediate variable to improve the readability.
here 0638e0f Next you need to change the PR title and add some tests. |
45a65d8
to
3c02631
Compare
maybe also need change to:
|
… add nullable columns Added `replace_column_datatype_to_nullable` method to support updates involving nullable column types. Refactored `rewrite_nondeterministic_update` logic to use matcher-based pattern matching for enhanced clarity and maintainability. Updated tests to include scenarios with CTEs and nullable columns for improved test coverage. Handle non-nullable expressions in update bindings This update ensures non-nullable expressions are unified with nullable data types where required, maintaining consistency in type handling. Additionally, it includes error logging for cases when data type retrieval fails, improving debugging visibility.
Added
replace_column_datatype_to_nullable
method to support updates involving nullable column types. Refactoredrewrite_nondeterministic_update
logic to use matcher-based pattern matching for enhanced clarity and maintainability. Updated tests to include scenarios with CTEs and nullable columns for improved test coverage.I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
Tests
Type of change
This change is