-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feat](nereids) Add session variable enable_insert_value_auto_cast for insert value truncate long string #55325
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
[feat](nereids) Add session variable enable_insert_value_auto_cast for insert value truncate long string #55325
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
3699698 to
f20d26e
Compare
| } else if (needTruncateStringWhenInsert && sourceLength > targetLength && targetLength >= 0) { | ||
| } else if (needTruncateStringWhenInsert | ||
| && sourceLength > targetLength && targetLength >= 0 | ||
| && ConnectContext.get() != null |
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.
don't compute ConnectContext.get() in loop
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.
don't compute
ConnectContext.get()in loop
fix
|
run buildall |
|
run buildall |
TPC-H: Total hot run time: 34238 ms |
TPC-DS: Total hot run time: 187675 ms |
ClickBench: Total hot run time: 32.72 s |
FE UT Coverage ReportIncrement line coverage |
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
|
run p0 |
1 similar comment
|
run p0 |
|
run external |
|
run p0 |
1 similar comment
|
run p0 |
|
run external |
…r insert value truncate long string (#55325) for below sql: ```sql create table t(a int, b varchar(2)); insert into t values(1, 'abcde'); ``` for doris 2.0, the insert command will throw error 'Insert has filtered data in strict mode', because length of value 'abcde' is bigger than varchar(2). for mysql, pg, the above sql will also throw error for the same reason. for doris version >= 2.1.0, it will not throw error, and just truncate 'abcde' to 'ab'. what's more, for stream load, no matter 2.0, or 2.1, ..., doris will stream load fail. but considering 2.1 have released for 1.5+ year, we don't want to make a behaviour change for 2.1, so add a session variable enable_insert_value_auto_cast, when insert value with longer string value, then will have: - if enable_insert_value_auto_cast = true (default), the longer string will be truncate and insert succ; - if enable_insert_value_auto_cast = false, enable_insert_strict = true(default), will throw exception 'Insert has filtered data in strict mode'; - if enable_insert_value_auto_cast = false, enable_insert_strict = false, then the longer string will be filtered, other rows will insert succ. relate PR: #52802
…r insert value truncate long string (apache#55325) for below sql: ```sql create table t(a int, b varchar(2)); insert into t values(1, 'abcde'); ``` for doris 2.0, the insert command will throw error 'Insert has filtered data in strict mode', because length of value 'abcde' is bigger than varchar(2). for mysql, pg, the above sql will also throw error for the same reason. for doris version >= 2.1.0, it will not throw error, and just truncate 'abcde' to 'ab'. what's more, for stream load, no matter 2.0, or 2.1, ..., doris will stream load fail. but considering 2.1 have released for 1.5+ year, we don't want to make a behaviour change for 2.1, so add a session variable enable_insert_value_auto_cast, when insert value with longer string value, then will have: - if enable_insert_value_auto_cast = true (default), the longer string will be truncate and insert succ; - if enable_insert_value_auto_cast = false, enable_insert_strict = true(default), will throw exception 'Insert has filtered data in strict mode'; - if enable_insert_value_auto_cast = false, enable_insert_strict = false, then the longer string will be filtered, other rows will insert succ. relate PR: apache#52802
What problem does this PR solve?
for below sql:
for doris 2.0, the insert command will throw error 'Insert has filtered data in strict mode', because length of value 'abcde' is bigger than varchar(2).
for mysql, pg, the above sql will also throw error for the same reason.
for doris version >= 2.1.0, it will not throw error, and just truncate 'abcde' to 'ab'.
what's more, for stream load, no matter 2.0, or 2.1, ..., doris will stream load fail.
so doris >= 2.1 may need throw exception for insert value with longer string, but considering 2.1 have released for 1.5+ year, we don't want to make a behaviour change for 2.1, so add a session variable enable_insert_value_auto_cast, when insert value with longer string value, then will have:
relate PR: #52802
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)