You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org> on 2026/09/30 16:36:21 UTC
[I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
SEPURI-SAI-KRISHNA opened a new issue, #12571:
URL: https://github.com/apache/seatunnel/issues/12571
### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22) and found no similar issues.
### What happened
`CAST(bigint_col AS INT)` on a value above `Integer.MAX_VALUE` silently returns a wrapped negative number. `CAST('3000000000' AS INT)`, the same target type with a string source, raises an error instead.
So the same `CAST ... AS INT` either fails loudly or silently corrupts the value, depending only on whether the source column is a string or a number.
I measured this on `dev` at `53733a112c9e935c5d97f7f24be249caa43b4fd5` by running the SQL through `ZetaSQLEngine` rather than reading it off the source. Columns are `b BIGINT`, `i INT`, `s STRING`, `d DOUBLE`.
| expression | input | plan time | runtime result |
| --- | --- | --- | --- |
| `CAST(b AS INT)` | `3000000000` | allowed | **`-1294967296`** |
| `CAST(s AS INT)` | `'3000000000'` | allowed | error |
| `CAST(d AS FLOAT)` | `1.0e40` | allowed | **`Infinity`** |
| `CAST(s AS FLOAT)` | `'1e40'` | allowed | **`Infinity`** |
| `CAST(s AS TINYINT)` | `'300'` | allowed | error |
| `CAST(s AS SMALLINT)` | `'70000'` | allowed | error |
| `CAST(i AS SMALLINT)` | `70000` | **rejected** | n/a |
| `CAST(i AS TINYINT)` | `70000` | **rejected** | n/a |
| `CAST(b AS SMALLINT)` | `3000000000` | **rejected** | n/a |
| `CAST(b AS TINYINT)` | `3000000000` | **rejected** | n/a |
Controls behave correctly: `CAST(b AS INT)` on `5` gives `5`, `CAST(s AS TINYINT)` on `'5'` gives `5`, `CAST(s AS BIGINT)` on `'3000000000'` gives `3000000000`.
The plan-time refusals read `Unsupported CAST FROM INT AS type: SMALLINT`.
### Why the silent cases look like a gap rather than a decision
`TRY_CAST` already encodes the intended contract: a cast that cannot represent the value fails, and `TRY_CAST` turns that failure into null. It works on the paths that report failure and is defeated on the paths that do not.
| expression | input | result |
| --- | --- | --- |
| `TRY_CAST(s AS TINYINT)` | `'300'` | `null`, correct |
| `TRY_CAST(b AS INT)` | `3000000000` | **`-1294967296`** |
| `TRY_CAST(d AS FLOAT)` | `1.0e40` | **`Infinity`** |
`TRY_CAST` cannot return null for those two because nothing underneath ever signals that the value did not fit. That is why I read this as a path that never joined the contract, rather than a deliberate choice of wraparound semantics.
### Where it comes from
`CastFunction.getCastType` decides what is allowed at plan time. `INT_CAST_TYPE` contains `BIGINT` and `FLOAT_CAST_TYPES` contains `DOUBLE`, so those two narrowings pass. The `TINYINT` and `SMALLINT` branches accept only widening sources plus `STRING`, which is why the numeric narrowings into them are refused.
`SystemFunction.castAs` then converts. For `INT` a string goes through `Integer.parseInt`, which reports overflow, while a number goes through `((Number) v1).intValue()`, which truncates silently. That single difference is the inconsistency in the first table. For `FLOAT` both paths end at `Float.parseFloat`, which returns `Infinity` rather than reporting anything. `TINYINT` and `SMALLINT` use `Byte.parseByte` and `Short.parseShort`, which do report.
### Related but not the same
#12507 reports unsigned DuckDB integers silently wrapping in the JDBC source. Same class of problem, different code: that one is automatic type inference in `DuckDBTypeConverter` in the JDBC connector, this one is an explicit `CAST` in the Zeta SQL transform going through `CastFunction` and `SystemFunction`. Neither fix touches the other's path.
### What I expected
A value the target type cannot represent should fail the same way regardless of the source type, so `TRY_CAST` can return null for it.
### The part I would like a maintainer to decide
The diagnosis is measured, but the remedy is a compatibility call:
1. Range-check `BIGINT -> INT` and the `FLOAT` conversions so they fail like the string paths, which also makes `TRY_CAST` work for them. Most consistent, but a job relying on the current wraparound or `Infinity` would start failing.
2. Leave the values as they are and instead allow `INT -> SMALLINT` and `INT -> TINYINT` at plan time, removing only the surprise that some narrowings cannot be expressed.
3. Document the current behaviour and change nothing.
I lean towards 1, because `TRY_CAST` already implies out-of-range is meant to be a failure, and a silently wrapped integer in a data integration tool tends to be discovered long after the data has moved. Happy to be overruled, which is why I am asking before writing a patch.
### SeaTunnel Version
`dev` (3.0.0-SNAPSHOT), verified at `53733a112c9e935c5d97f7f24be249caa43b4fd5`.
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR, once the direction is settled.
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5975670599
@SEPURI-SAI-KRISHNA thanks for the detail on the direct `castAs` coverage.
`testCastAsTinyintAndSmallintAlreadyRejectOutOfRangeNumericInput` covering `TINYINT`, `BYTE` and `SMALLINT` with out-of-range input, plus the `5.7d` rejection, is the evidence needed to justify leaving those targets on their existing parsing paths, and `testCastAsIntRejectsOutOfRangeNumericInput` pins the `INT` numeric branch the PR changes. Keeping the change scoped to the `INT`/`INTEGER` numeric branch remains the right boundary for this issue.
One thing I'd like confirmed after the latest push: that the `COALESCE`/`IFNULL` regression test (the `-1294967296` case) and the incompatible-changes entry are still included, since they need to land together with the range check. I will continue the rest of the review on the PR.
<!-- streview-comment:1494 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5977425698
Both still present at head `c5b287cc5`, confirmed by reading the blobs at that commit rather than from memory.
**COALESCE / IFNULL regression test.** `ZetaSQLEngineTest.testCoalesceAndIfnullAlsoRejectAnOutOfRangeNarrowing`, which covers both `coalesce(c_int, c_bigint)` and `ifnull(c_int, c_bigint)`. Each one asserts a `TransformException` for the overflowing value `3000000000L`, and then re-runs the same SQL on a fresh engine with an in-range value to pin that the non-overflow path still returns normally. The comment above it records why the target is `INT`: `ZetaSQLType` infers the result type from the first non-null argument rather than the widest one, so `COALESCE(int, bigint)` targets `INT` and reached the same `castAs` boundary.
The `-1294967296` value you referenced is the pre-change truncation of `3000000000`, so the test pins the same case by asserting the error instead of that silently wrapped result.
**Incompatible-changes entry.** Present on both pages, `docs/en/introduction/concepts/incompatible-changes.md` and the zh equivalent, under "Zeta SQL Transform: CAST to INT rejects out-of-range numeric values". It carries the behaviour change, the reason, the migration guidance to use `TRY_CAST`, and the `BIGINT` gap tracked as #12612.
So the range check, the COALESCE regression test and the docs entry all land together in this PR as you asked.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5944267097
Thanks @SEPURI-SAI-KRISHNA — the matrix measured through `ZetaSQLEngine` on `dev` at `53733a112c9e935c5d97f7f24be249caa43b4fd5` is enough to proceed, and it matches what I see at `d7e9931bea0976547e9730675e7019bbef88ad83`. The scope stands as agreed: integral targets only, planner acceptance unchanged, `CAST` fails and `TRY_CAST` returns null on out-of-range numeric input at the shared cast boundary, floating point left for a separate decision.
Two small notes on the tables:
- Count: six cells change, not four. `-2147483649`, `2147483648` and `3000000000` each flip for both `CAST` and `TRY_CAST` (today `2147483647`, `-2147483648` and `-1294967296`). After the change all six become `CAST` error / `TRY_CAST` null, matching the STRING column. The exact-boundary rows and `0` stay as they are.
- Since the range check is going in at the shared boundary for `TINYINT` and `SMALLINT` as well, please test that code directly with out-of-range numeric inputs for those targets, not only via the STRING matrix. The planner does not route numeric narrowing to them today, so without a direct test the new check for those two targets would have no coverage.
Everything else from the earlier instructions stands; link the PR here once it is open.
<!-- streview-comment:1454 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5965121737
@SEPURI-SAI-KRISHNA thanks again for the detailed follow-up. Nothing further to add beyond my last comment: the `INT`-only numeric boundary, the `COALESCE` / `IFNULL` fix with its regression test and incompatible-changes entry, and the `CASE` widening test are all in scope and should stay in the PR.
One small confirmation: you mentioned adding direct `SystemFunction.castAs` coverage for `TINYINT` and `SMALLINT` in `SystemFunctionTest`. Could you confirm that is included in the PR as pushed?
I'll continue review on the PR; this issue stays open until CI and review complete there.
<!-- streview-comment:1486 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo closed issue #12571: [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING
URL: https://github.com/apache/seatunnel/issues/12571
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5924419217
Thanks @DanielLeens and @SEZ9. Taking option 1, scoped as Daniel described: integral targets only, the source types the planner already accepts, both `CAST` failing and `TRY_CAST` returning null, and floating point left out as a separate decision.
Here is the focused matrix before the PR. Everything below is measured on `dev` at `53733a112c9e935c5d97f7f24be249caa43b4fd5` by running the SQL through `ZetaSQLEngine`, not read off the source.
**Which sources the planner accepts per integral target.** I enumerated this rather than assuming it from `CastFunction`:
| target | TINYINT | SMALLINT | INT | BIGINT | STRING |
| --- | --- | --- | --- | --- | --- |
| `TINYINT` | accept | reject | reject | reject | accept |
| `SMALLINT` | accept | accept | reject | reject | accept |
| `INT` | accept | accept | accept | accept | accept |
So within the agreed scope there is exactly one numeric narrowing reachable today: `BIGINT -> INT`. Every other accepted numeric pair is widening or identity. I will still put the range check at the shared boundary for all three integral targets, so it is correct if the planner later accepts more sources, but only the `BIGINT -> INT` row changes behaviour now.
**`BIGINT -> INT` boundaries, current behaviour.** Sign flips at both ends:
| input | `CAST` today | `TRY_CAST` today | same value from STRING today |
| --- | --- | --- | --- |
| `-2147483649` | **`2147483647`** | **`2147483647`** | CAST error |
| `-2147483648` | `-2147483648` | `-2147483648` | `-2147483648` |
| `0` | `0` | `0` | `0` |
| `2147483647` | `2147483647` | `2147483647` | `2147483647` |
| `2147483648` | **`-2147483648`** | **`-2147483648`** | CAST error |
| `3000000000` | **`-1294967296`** | **`-1294967296`** | CAST error |
`INT_MIN - 1` becoming `+2147483647` is the one I would point at: the value is negative, the result is the largest positive int, and nothing reports it.
**After the change**, the four bold cells become `CAST` error and `TRY_CAST` null, matching the STRING column exactly. The two exact-boundary rows and the `0` row stay as they are.
**STRING boundaries, which already behave correctly and must not regress:**
| target | MIN-1 | MIN | MAX | MAX+1 |
| --- | --- | --- | --- | --- |
| `TINYINT` | error / null | `-128` | `127` | error / null |
| `SMALLINT` | error / null | `-32768` | `32767` | error / null |
| `INT` | error / null | `-2147483648` | `2147483647` | error / null |
Cells read `CAST` / `TRY_CAST`.
**Widening and identity, unchanged and asserted as controls:**
`TINYINT -> SMALLINT/INT/BIGINT`, `SMALLINT -> INT/BIGINT`, `INT -> BIGINT`, and the identity casts `TINYINT -> TINYINT`, `SMALLINT -> SMALLINT`, `INT -> INT`, `BIGINT -> BIGINT` all return their input today and will be pinned so they still do.
On @SEZ9's point about `INT -> SMALLINT` and `INT -> TINYINT` being refused at plan time while the same targets accept `STRING`: I agree it reads as a gap rather than deliberate protection, but Daniel asked to keep the first change to the sources the planner already accepts, so I am leaving it out of this PR. Happy to do it as a follow-up with the same range checks applied, if you both want it.
Two notes on scope, so the PR matches what you asked for. The implementation goes in `SystemFunction.castAs`, which is the shared cast boundary and not connector specific. The `FLOAT` cases returning `Infinity` are excluded; I will file them separately so the compatibility decision there is not buried in this one.
I will also update `docs/en` and `docs/zh` in the same PR, since this changes behaviour for jobs that rely on wraparound.
If that matrix looks right I will open the PR against it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5931141220
Classification: E / Transform-V2 integral CAST compatibility.
The matrix is sufficient to proceed. I rechecked current `dev` at `d7e9931bea0976547e9730675e7019bbef88ad83`: `CastFunction` presently admits `BIGINT -> INT`, and `SystemFunction.castAs` takes the numeric input through `Number.intValue()` while the string path uses `Integer.parseInt()`. Your enumeration correctly shows that `BIGINT -> INT` is the only numeric narrowing reachable by the current planner.
Please open one focused PR against `dev`. Keep planner acceptance unchanged in this first change; at the shared integral cast boundary, make out-of-range numeric input fail so `TRY_CAST` returns null. Include the complete MIN-1 / MIN / MAX / MAX+1 matrix for TINYINT, SMALLINT, and INT, the exact `BIGINT -> INT` boundary cases, and the widening and identity controls you listed. Keep FLOAT and `Infinity` out of this PR. Because this changes the behavior of jobs that relied on wraparound, document the compatibility impact in both language references and the incompatible-changes record. Link the PR here once opened; it should not be treated as fixed until the tests and review are complete.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5917741465
Classification: E / Transform-V2 numeric conversion compatibility.
I checked current `dev` (`53733a112c9e935c5d97f7f24be249caa43b4fd5`). `CastFunction` explicitly admits `BIGINT` to `INT`, while `SystemFunction.castAs` reaches `Number.intValue()` for numeric inputs and `Integer.parseInt()` for strings. That explains the observed inconsistency and means an out-of-range integral value can silently change before `TRY_CAST` has a failure to convert to null.
The direction is to make the integral narrowing path fail on out-of-range numeric input, matching the existing string behavior. Keep the first change focused on integral targets (`TINYINT`, `SMALLINT`, and `INT`) and the source types currently accepted by the planner. It must cover both `CAST` failure and `TRY_CAST` returning null, with exact boundary tests at each target minimum and maximum. Do not bundle floating-point `Infinity` semantics into this PR; that is a separate compatibility decision.
This is a behavior change for jobs that currently rely on wraparound, so document it in both language references and keep the implementation at the shared cast boundary rather than connector-specific code. Please post the focused test matrix before opening the PR so reviewers can confirm that valid in-range conversions and existing widening behavior remain unchanged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5951991556
Thanks for the careful follow-up and for calling out the deviation before asking for review.
I checked #12605. Keeping the implementation focused on the `INT`/`INTEGER` numeric branch is the right boundary: `TINYINT` and `SMALLINT` already use their parsing paths to reject overflow, and routing them through a shared numeric helper would risk changing the existing fractional-input behavior. `CAST(... AS FLOAT)` is still outside this change. The new `numberToInt` behavior is an integral-target rule; its handling of non-finite numeric inputs is necessary because they have no representable INT result.
`COALESCE` and `IFNULL` that infer an INT target reach the same conversion boundary, so they should not retain silent truncation as an exception. Please keep their regression coverage and the incompatible-change documentation with the PR. The current Build is still running, so the issue remains open and the change is not fixed in `dev` until CI and review finish.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5945212718
PR is up: #12605.
First, your count correction is right and mine was wrong: six cells change, not four. `-2147483649`, `2147483648` and `3000000000` each flip for both `CAST` and `TRY_CAST`, so three rows times two columns. The exact-boundary rows and `0` stay as they are.
One deviation from your wording that I want to put in front of you rather than bury in the diff. You asked for the range check at the shared integral cast boundary covering `TINYINT`, `SMALLINT` and `INT`. I built that first, then measured what it actually did and backed most of it out.
`TINYINT`, `SMALLINT` and `BYTE` convert with `Byte.parseByte` and `Short.parseShort`, which already reject an out-of-range value, so they never had the defect. Routing them through a shared numeric helper would have made them *looser*, not stricter:
| | before | with the shared helper |
| --- | --- | --- |
| `Double 5.7` to `TINYINT` | `NumberFormatException` | `5` |
| `Double 5.7` to `SMALLINT` | `NumberFormatException` | `5` |
| `Double 5.7` to `INT` | `5` | `5` |
So the PR changes one line: the numeric branch of the `INT` case. That is the only path that ever wrapped. If you would still rather see a single shared helper across all the integral targets, say so and I will add it with an explicit integrality check so the fractional behaviour above does not move.
Two other things worth knowing before review.
`COALESCE` and `IFNULL` reach the same `castAs` boundary, and `ZetaSQLType` infers their result type from the first non-null argument rather than the widest. So `COALESCE(int_col, bigint_col)` targets `INT`, and an out-of-range value from the `BIGINT` argument was truncated in exactly the same silent way. Measured on pristine `dev`: `-1294967296` before, `TransformException` after. It is the same defect in another expression, so I left it fixed and pinned it with a test rather than special-casing `castAs` to keep `COALESCE` wrapping. It is also recorded in the incompatible-changes entry.
`CASE` reaches that boundary too, but infers the widest branch type, so it cannot narrow. I checked both branch orders; both widen to `BIGINT`. There is a test pinning that so a later change to the inference does not quietly start failing `CASE`.
On your second note, direct numeric coverage for `TINYINT` and `SMALLINT`: that is a good catch and I have added it, though it ends up documenting why those two are left alone rather than covering a new check. `SystemFunctionTest` now calls `SystemFunction.castAs` directly with out-of-range numeric input for every integral target:
- `testCastAsIntRejectsOutOfRangeNumericInput` for the path this PR changes, including `Long.MAX_VALUE` and both exact boundaries.
- `testCastAsTinyintAndSmallintAlreadyRejectOutOfRangeNumericInput` for the two targets that already reject, with `300L`, `70000`, `Long.MAX_VALUE`, and the fractional case that a shared helper would have started accepting.
Everything else you asked for is in: the complete `MIN-1` / `MIN` / `MAX` / `MAX+1` matrix for all three integral targets, the exact `BIGINT -> INT` boundaries, the widening and identity controls, both language references, and the incompatible-changes record. `FLOAT` and `Infinity` are out, and I will file those separately.
`seatunnel-transforms-v2` is green at 1167 tests. Reverting the single changed line fails three of the new tests, including `TRY_CAST` returning `2147483647` where it should be null.
Agreed this should not be treated as fixed until tests and review are complete.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5924010986
Thanks for the detailed, reproducible report and result table. The inconsistency is clear: for `INT`, a string source goes through `Integer.parseInt`, which reports overflow, while a numeric source goes through `((Number) v1).intValue()`, which truncates silently. A consistent fix is to range-check the numeric narrowing path in `SystemFunction.castAs` for `INT` (and `SMALLINT`/`TINYINT` where the planner accepts the source) so numeric sources fail the same way string sources do, and `TRY_CAST` then yields null in both cases.
The `FLOAT` cases returning `Infinity` are worth tracking separately: both paths end at `Float.parseFloat`, which returns `Infinity` by design, so whether out-of-range float casts should error or keep returning `Infinity` is its own compatibility decision and should not be bundled into the first change.
The plan-time rejections (`Unsupported CAST FROM INT AS type: SMALLINT`) for `INT -> SMALLINT` and `INT -> TINYINT` look like a gap rather than overflow protection, since `CastFunction.getCastType` accepts the same targets from `STRING`. If you add those narrowing paths, please add them with the same range checks.
Since you have already offered a PR, option 1 is the direction to take. Unit tests covering each row of your table, including the exact minimum and maximum boundary for each integral target, would be a good starting point.
<!-- streview-comment:1446 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5987711312
Thanks @SEPURI-SAI-KRISHNA, that closes the loop on the coverage question.
What you describe at `c5b287cc5` matches what was asked for on this issue:
- `SystemFunctionTest.testCastAsTinyintAndSmallintAlreadyRejectOutOfRangeNumericInput` pinning the existing `TINYINT` / `BYTE` / `SMALLINT` parsing paths (out-of-range rejected, in-range still converts, fractional source such as `5.7d` still rejected) is exactly the justification needed for leaving them off the shared numeric helper. Good to have that written down as a test rather than as a comment.
- `testCastAsIntRejectsOutOfRangeNumericInput` covering the `INT` path directly, plus the correction so the range check compares the truncated value and `CAST(2147483647.5 AS INT)` is accepted, is the right fix for the first-version behaviour.
- `ZetaSQLEngineTest.testCoalesceAndIfnullAlsoRejectAnOutOfRangeNarrowing` asserting the error for `3000000000L` instead of the previously wrapped `-1294967296`, with the in-range re-run on a fresh engine, is what I wanted for the `COALESCE` / `IFNULL` boundary. The comment explaining that the result type is inferred from the first non-null argument is useful context for whoever touches that later.
- The incompatible-changes entry on both the en and zh pages, including the `TRY_CAST` migration guidance, covers the documentation ask.
Nothing further from me on this thread's scope. Remaining asks, all on the PR side:
1. Keep the three tests and the docs entry together in the same PR as they are now; please don't split them out if there is further rebasing.
2. Once the Build on the PR has finished, drop a note there so review can proceed on a green run. I'll keep this issue open until the PR is in `dev`.
<!-- streview-comment:1529 -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Bug][Transform-V2] CAST silently wraps BIGINT to INT but errors for the same conversion from STRING [seatunnel]
Posted by "SEPURI-SAI-KRISHNA (via GitHub)" <gi...@apache.org>.
SEPURI-SAI-KRISHNA commented on issue #12571:
URL: https://github.com/apache/seatunnel/issues/12571#issuecomment-5965994601
Confirmed, @SEZ9, it is in the PR as pushed.
`SystemFunctionTest.testCastAsTinyintAndSmallintAlreadyRejectOutOfRangeNumericInput` calls `SystemFunction.castAs` directly for `TINYINT`, `BYTE` and `SMALLINT` with out-of-range numeric input (`300L`, `-300L`, `70000`, `Long.MAX_VALUE`, and `70000L` / `-70000L` / `2147483647` for `SMALLINT`), asserts the in-range values still convert, and asserts that a fractional source such as `5.7d` is still rejected by those targets. That last pair is the coverage that justifies leaving them on their existing parsing paths rather than routing them through the numeric helper.
Alongside it, `testCastAsIntRejectsOutOfRangeNumericInput` does the same directly for the `INT` path this PR changes.
Both are at the pushed head, in `seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/zeta/functions/SystemFunctionTest.java`.
Since your last comment I also pushed the fix for the four findings in your review on the PR, including one you may want to look at specifically: the first version of the range check compared the raw value rather than the truncated one, which wrongly rejected `CAST(2147483647.5 AS INT)`. Details are on #12605.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org