Skip to content

[Bug] [Transform-V2] Zeta SQL CEIL/FLOOR/ROUND/TRUNC/MOD silently corrupt BIGINT and DECIMAL values #11696

Description

@SEPURI-SAI-KRISHNA

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

NumericFunction in the Zeta SQL transform routes values through double and narrows CEIL/FLOOR results to int. No exception is raised — the job succeeds and writes wrong numbers to
the sink.

Expression Input Actual Expected
CEIL(long_v) 9007199254740993 1 9007199254740993
FLOOR(double_v) 1.0E18 2147483647 1.0E18
ROUND(decimal_v, 2) 12345678901234567890.987654321 12345678901234567000.00 12345678901234567890.99
MOD(long_v, 2) 9007199254740993 0 1
TRUNC(long_v) any declared DOUBLE, returns Long type matches value

This contradicts the shipped documentation. docs/en/transforms/sql-functions.md already specifies CEIL | CEILING (numeric) -> NUMERIC (same type, scale 0), FLOOR(numeric) ->
NUMERIC (same type, scale 0), ROUND(numeric[, digitsInt]) -> NUMERIC (same type), TRUNC | TRUNCATE(numeric[, digitsInt]) -> NUMERIC (same type) and MOD(dividendNumeric,
divisorNumeric) -> type(divisorNumeric).

Root causes: ceil()/floor() return int and ZetaSQLType declares INT_TYPE/DOUBLE_TYPE for them; round()'s BIGDECIMAL branch goes through BigDecimal.valueOf(v1.doubleValue()); mod()
converts both operands with doubleValue() (which also makes its divide-by-zero guard miss divisors that underflow to 0.0).

SeaTunnel Version

dev (2.3.13-SNAPSHOT)

SeaTunnel Config

hocon
  transform {
    Sql {
      source_table_name = "fake"
      result_table_name = "out"
      query = "select CEIL(long_v) as c, FLOOR(double_v) as f, ROUND(decimal_v, 2) as r, MOD(long_v, 2) as m from fake"
    }
  }

Running Command

./bin/seatunnel.sh --config ./config/repro.conf -e local

Error Exception

None — this is silent data corruption; the job reports success.

Zeta or Flink or Spark Version

Zeta (engine-independent — the bug is in the transform)

Java or Scala Version

Java 11 / Java 8

Screenshots

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. DanielLeens commented on Aug 8, 2026

    @DanielLeens
    Contributor

    I traced through the numeric-function path here. This is a real bug because these functions silently narrow through double / int conversions and can produce successful jobs with wrong sink values.

    Since you already opened PR #11697 on August 7, 2026, the next step is to continue review there rather than splitting the technical discussion across two threads. Keeping the fix, tests, and incompatible-change notes together in that PR is the right path. Thanks for driving it end to end.

  2. DanielLeens commented on Aug 8, 2026

    @DanielLeens
    Contributor

    I re-checked the issue state here. There are now multiple PRs linked to the same numeric-function corruption bug: #11697 and #11712.

    Because this is a silent-wrong-result problem, we should avoid splitting the fix discussion and regression coverage across parallel PRs. Please converge on one canonical PR for this issue and continue the detailed review there, including:

    1. exact numeric semantics for BIGINT / DECIMAL across CEIL / FLOOR / ROUND / TRUNC / MOD;
    2. regression tests that prove values are not narrowed through double / int on the affected execution path;
    3. and any incompatible-change note if the previous wrong results were already observable behavior for existing users.

    Once one PR is chosen as the primary fix path, closing or superseding the overlapping PR will make review much easier and avoid ending up with partial fixes for the same bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions