Skip to content
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

[Enhancement] Support overflow mode for decimal type #30419

Merged
merged 3 commits into from
Sep 11, 2023

Conversation

liuyehcf
Copy link
Contributor

@liuyehcf liuyehcf commented Sep 5, 2023

Main work

Support error reporting when decimal overflow by introducing a OverflowMode, which has three different modes:

  • IGNORE
  • OUTPUT_NULL
  • REPORT_ERROR

This behavior can be enabled by setting session varaible set sql_mode='ERROR_IF_OVERFLOW'

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.1
    • 3.0
    • 2.5
    • 2.4

Signed-off-by: liuyehcf <[email protected]>
satanson
satanson previously approved these changes Sep 11, 2023
-- !result
select /*+ SET_VAR(sql_mode='ERROR_IF_OVERFLOW')*/ cast(c_d32 * c_d32 as decimal32) from t_decimal_overflow where c_id = 1;
-- result:
E: (1064, 'Expr evaluate meet error: Decimal overflow')
Copy link
Contributor

@fzhedu fzhedu Sep 11, 2023

Choose a reason for hiding this comment

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

from the error msg, we can't know which expr report this error, can the error specify the operator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add more precise information.

Signed-off-by: liuyehcf <[email protected]>
@sonarcloud
Copy link

sonarcloud bot commented Sep 11, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 6 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 2 Security Hotspots
Code Smell B 269 Code Smells

0.0% 0.0% Coverage
1.2% 1.2% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@wanpengfei-git
Copy link
Collaborator

[FE Incremental Coverage Report]

😍 pass : 3 / 3 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/qe/SessionVariable.java 2 2 100.00% []
🔵 com/starrocks/qe/SqlModeHelper.java 1 1 100.00% []

@wanpengfei-git
Copy link
Collaborator

[BE Incremental Coverage Report]

😞 fail : 54 / 112 (48.21%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 src/exprs/expr_context.cpp 0 2 00.00% [189, 190]
🔵 src/exprs/decimal_binary_function.h 0 17 00.00% [62, 68, 71, 84, 85, 86, 88, 89, 92, 93, 94, 96, 97, 98, 103, 107, 108]
🔵 src/exprs/function_context.cpp 0 2 00.00% [159, 160]
🔵 src/runtime/runtime_state.h 0 2 00.00% [342, 343]
🔵 src/exprs/arithmetic_expr.cpp 0 12 00.00% [109, 111, 114, 157, 158, 160, 174, 176, 179, 199, 201, 204]
🔵 src/exprs/math_functions.h 0 3 00.00% [376, 378, 381]
🔵 src/exprs/arithmetic_operation.h 0 6 00.00% [81, 83, 85, 91, 93, 97]
🔵 src/exprs/cast_expr.cpp 8 16 50.00% [1086, 1087, 1088, 1091, 1102, 1110, 1118, 1285]
🔵 src/exprs/decimal_cast_expr.h 46 52 88.46% [75, 94, 112, 212, 319, 366]

@fzhedu fzhedu merged commit 228c120 into StarRocks:main Sep 11, 2023
27 of 28 checks passed
@wanpengfei-git
Copy link
Collaborator

@Mergifyio backport branch-3.1

@github-actions github-actions bot removed the 3.1 label Sep 11, 2023
@wanpengfei-git
Copy link
Collaborator

@Mergifyio backport branch-3.0

@github-actions github-actions bot removed the 3.0 label Sep 11, 2023
@wanpengfei-git
Copy link
Collaborator

@Mergifyio backport branch-2.5

@github-actions github-actions bot removed the 2.5 label Sep 11, 2023
@mergify
Copy link
Contributor

mergify bot commented Sep 11, 2023

backport branch-3.1

✅ Backports have been created

@mergify
Copy link
Contributor

mergify bot commented Sep 11, 2023

backport branch-3.0

✅ Backports have been created

@mergify
Copy link
Contributor

mergify bot commented Sep 11, 2023

backport branch-2.5

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Sep 11, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 228c120)

# Conflicts:
#	gensrc/thrift/InternalService.thrift
mergify bot pushed a commit that referenced this pull request Sep 11, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 228c120)

# Conflicts:
#	be/src/exprs/function_context.cpp
#	be/src/exprs/function_context.h
#	be/src/exprs/vectorized/arithmetic_expr.cpp
#	be/src/exprs/vectorized/arithmetic_operation.h
#	be/src/exprs/vectorized/cast_expr.cpp
#	be/src/exprs/vectorized/decimal_binary_function.h
#	be/src/exprs/vectorized/decimal_cast_expr.h
#	be/test/exprs/vectorized/decimal_binary_function_test.cpp
#	fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java
#	gensrc/thrift/InternalService.thrift
mergify bot pushed a commit that referenced this pull request Sep 11, 2023
Signed-off-by: liuyehcf <[email protected]>
(cherry picked from commit 228c120)

# Conflicts:
#	be/test/exprs/decimal_binary_function_test.cpp
#	gensrc/thrift/InternalService.thrift
liuyehcf added a commit that referenced this pull request Sep 11, 2023
liuyehcf added a commit that referenced this pull request Sep 12, 2023
liuyehcf added a commit that referenced this pull request Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants