[cdc] Reject a non-positive width for the truncate computed column - #10360
Open
jackylee-ch wants to merge 1 commit into
Open
jackylee-ch wants to merge 1 commit into
jackylee-ch wants to merge 1 commit into
Conversation
jackylee-ch
force-pushed
the
cdc-validate-truncate-width
branch
from
October 3, 2026 18:13
6ca3ffb to
9301a4e
Compare
TruncateComputer parsed the width literal but never checked its sign. A non-positive width only failed later, at per-row eval: integer and decimal columns threw ArithmeticException (/ by zero) once the sync job was already running, while char/varchar columns silently produced an empty string. Validate width > 0 in the constructor so a bad computed-column definition fails fast with a clear message, mirroring the sibling substring expression that already validates its indices.
jackylee-ch
force-pushed
the
cdc-validate-truncate-width
branch
from
October 4, 2026 05:48
9301a4e to
b402dff
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
The
truncatecomputed column (Expression.TruncateComputer) parses itswidth literal but never checks the sign. A non-positive width is only caught
later, at per-row
eval, and inconsistently: integer andDECIMALcolumnsthrow
ArithmeticException: / by zeroonce the sync job is already running,while
CHAR/VARCHARcolumns silently produce an empty string. A width of0or a negative value is never meaningful for truncation.
This validates
width > 0in the constructor, so a bad definition such as--computed_column 'x=truncate(amount,0)'fails fast at job build time with aclear message, mirroring the sibling
substringexpression that alreadyvalidates its indices.
Tests
TruncateComputerTest#testTruncateRejectsNonPositiveWidthasserts theconstructor rejects width
0and negatives across int/bigint/decimal/varchar.Existing positive-width coverage is unaffected.
API and Format
No change.
Documentation
No change.