Skip to content

Read zero-padded and +-signed integers in the TSV family, as CSV already does - #113910

Merged
Avogar merged 13 commits into
ClickHouse:masterfrom
groeneai:tsv-int-leading-zeros-and-plus
Sep 15, 2026
Merged

Avogar merged 13 commits into
ClickHouse:masterfrom
groeneai:tsv-int-leading-zeros-and-plus

Conversation

@groeneai

@groeneai groeneai commented Aug 8, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Integers in the TSV, TSVRaw, TSKV and CustomSeparated formats can now be zero-padded (007) or carry a redundant leading + (+7), spellings that previously failed to parse but that CSV already accepted. The same reader serves other conversions from text to an integer, so WHERE i = '007' on a numeric column, query parameters and CAST('[007]' AS Array(Int64)) accept them too. A field that is a lone + remains an error, now reported as CANNOT_PARSE_NUMBER on every one of these routes instead of a route-specific code. Schema inference is unchanged: 007 still infers as String.

Description

Related: #5999 (closed in 2019, still reproducing)
Related: #113158 (same family)

readIntTextUnsafe short-circuited on the first 0, returning it as the whole value, and treated + as neither sign nor digit, so it reported success with zero and left unread bytes where a delimiter belonged. Its one call site, SerializationNumber<T>::deserializeText, is where the Escaped, Raw and Quoted rules and deserializeWholeText converge; CSV and JSON override it for the tolerant readIntText.

The reader now reads the whole field, leading zeros included, and accepts a redundant +; that branch requires a digit, or a lone + would read as 0. The - branch and inference's own first-character guard are untouched, so lone-minus spellings, TSVRaw included, and inferred types are unchanged.

The reader is shared, so the same spellings are now read by MySQLDump, Form, Regexp, the JSONStringsEachRow family, query parameters, a dictionary null_value, a cast such as CAST('[007]' AS Array(Int64)), a Map key named in a subcolumn, and WHERE i = '007' on a numeric column, which raised TYPE_MISMATCH and now converts, so the predicate also reaches primary-key and skip-index analysis. Unchanged: CSV and JSON, a lone - (read as 0, rejected in TSVRaw), inferred types, and Values at default settings; with input_format_values_deduce_templates_of_expressions = 0 a padded value that overflows the target now wraps like the unpadded spelling, instead of defaulting to 0, or failing with TYPE_MISMATCH under input_format_null_as_default = 0.

Most carriers pass the reader's error code through; one that wraps or retries the read reports its own, as Values and a Map subcolumn do in group 15. Groups 13 to 16 witness one route per mechanism.

Validation

Debug build of this branch against master at the merge base, the fixed binary's Build ID asserted against the running server before any verdict:

input, explicit a Int64 base fixed CSV oracle
007 / 00 / 03242 Code: 27 7 / 0 / 3242 7 / 0 / 3242
-007 / -0100 Code: 27 -7 / -100 -7 / -100
+7 / +007 Code: 27 7 / 7 7 / 7
+ (with a delimiter) Code: 27 Code: 72 Code: 72
- (with a delimiter) 0 0 (unchanged) Code: 72
-\t1, two columns 0 1 0 1 (unchanged) Code: 72
- in TSVRaw, any position Code: 32 Code: 32 (unchanged) Code: 72
-7 as UInt64 rejected rejected rejected
DESCRIBE of 007 String String (unchanged) Int64
WHERE i = '007' or '+7' Code: 53 7 toInt64: 7 on both
WHERE i = '+' / {p:Int64} '+' Code: 53 / 457 Code: 72 float: 72 on both
EXPLAIN indexes = 1, key = '007' Code: 53 id in [7, 7] n/a
JSONStringsEachRow / Form / Regexp Code: 632 7 n/a
CAST('[007]' AS Array(Int64)) / Tuple Code: 130 / 27 [7] / (7) n/a
m.key_007 of Map(Int64, String) Code: 47 resolves n/a

The - rows named without a format hold alike in TSV, TSKV and CustomSeparated, for Int8 through Int256; TSVRaw is the one format that rejects a lone -, identically on both sides, whichever delimiter or end of input follows, because the raw path hands the reader the field bytes alone. On base TSVRaw reports Code: 632 where the other three report Code: 27. Float spellings and every --first observation are byte-identical to base. 04648 and 02514 pass against the untouched inference guard, 04812 passes 20 randomized runs, and 49 of the 51 tests in the TSV, TSKV, CustomSeparated and hive slice pass (two need minio, absent here). Style legs run locally.


Workflow [PR]
Sync PR [sync-upstream/pr/113910]

Version info

  • Merged into: 26.9.1.1524 (included in 26.9 and later)

In the `Escaped` and `Raw` escaping-rule family (`TSV`, `TSVRaw`, `TSKV`, and
`CustomSeparated` at its default escaping rule) an integer column could not be
read for any zero-padded or `+`-signed spelling, while every other text format
reads the same bytes. Issue ClickHouse#5999, closed in 2019, still reproduced verbatim.

The most visible form is inference contradicting its own reader: `DESCRIBE` on
a file containing `-007` returns `Nullable(Int64)`, and `SELECT` on that same
file then throws `CANNOT_PARSE_INPUT_ASSERTION_FAILED`. Unsigned spellings were
shielded from the error only because inference demoted them to `String`, which
in turn made TSV header auto-detection consume the first data row as a column
name, so `007\n123\n456` counted 2 rows instead of 3.

`readIntTextUnsafe` consumed an optional `-`, then short-circuited on the first
`0` and returned that as the whole value, leaving the remaining digits in the
buffer; and `+` was neither `-` nor a digit, so the digit loop read nothing and
reported success with zero. Either way the caller found unread bytes where a
delimiter belonged. Its own doc comment listed both gaps.

The reader now skips a run of leading zeros and accepts a redundant `+`.
Because a `+` is newly consumed as a sign, the reader also requires a decimal
digit after one: without that, a field that is a lone `+` would read as the
value zero, a wrong result this change would itself have introduced. Before it,
the `+` was left unconsumed and the format layer refused the remainder, so end
to end this moves `CANNOT_PARSE_INPUT_ASSERTION_FAILED` to
`CANNOT_PARSE_NUMBER` for that one spelling.

The `-` branch is deliberately left exactly as it was, including its existing
end-of-input check. An earlier revision of this change required a digit after
either sign, which also rejected a field that is a lone `-`. That is documented
behaviour, not an accident: the `TabSeparated` format documentation states that
when reading it is allowed to parse "a string consisting of just a minus sign as
a zero" for signed types, and the generated page carries the same sentence. So
`-` still reads as zero, `-\t1` still reads as the two columns zero and one, and
`TSV` legitimately differs from `CSV` here, which never made that promise. All
thirty-one `-`-first observations across the format-level and reader-level
probes are byte-identical to master.

The reader has one call site, `SerializationNumber::deserializeText`, but that
is where many entry points converge, so the scope of the two halves differs.
`SerializationNumber` overrides only the JSON and CSV entry points, routing
those to the tolerant `readIntText` -- which is why they always worked and why
CSV is used here as the oracle for every expected value. It overrides neither
`deserializeTextQuoted` nor `deserializeTextRaw` nor `deserializeWholeText`, so
`SimpleTextSerialization` sends all of them to the same `deserializeText`. The
acceptance half is an improvement wherever it is reached. The lone-`+`
rejection, being a rejection, reaches all of them: beyond the four named formats
that is `Values` and `MySQLDump` through `deserializeTextQuoted`, and sixteen
external `deserializeWholeText` consumers including query parameters,
dictionary `null_value`, `Map` keys and bloom-filter keys.

With the reader repaired, the schema-inference guard that forced a zero-padded
integer to `String` had no premise left; its comment said it existed only
because of this reader. That guard is @Avogar's ClickHouse#44522, whose stated premise was
"Infer numbers starting from zero as strings in TSV as we cannot parse them as
integer" -- exactly what this change falsifies. Its regression test
`02514_tsv_zero_started_number` is re-baselined rather than deleted: `0123` now
reads as `Nullable(Int64)` `123`, which is what CSV has always answered, so the
test keeps asserting the same thing against the corrected expectation. Removing
the guard also closes the row-loss symptom in the same change.
`FormatSettings::allow_number_leading_zeros` and its single setter in hive
partitioning go with it: the flag was a private opt-in to what everybody now
gets, and hive behaviour is unchanged.

On cost. An earlier reader-level benchmark over unpadded integers found the
change free, but it structurally excluded the path this change lengthens, so it
was redone as a sweep over the density of single-`0` fields, each delta measured
against a same-binary control arm. That sweep found a real regression at every
density, including at zero density where neither a zero nor a sign exists --
which is what located the cause. It is neither parsing feature: constructing
`CANNOT_PARSE_NUMBER` inline for the digit-after-sign check grew the reader's
stack frame from 8 to 72 bytes and its body from 85 to 143 instructions on every
call. Throwing from an out-of-line `[[noreturn]]` helper, as this function's
neighbour `throwReadAfterEOF` already does, restores the 8-byte frame and leaves
+2.3% at 0% density rising to +6.8% at 50%, against a control-arm spread of 0.6%
-- about half to three quarters of the regression recovered. Marking the branch
`[[unlikely]]` on its own recovers nothing: measured, it emits the identical
72-byte frame. This deliberately does not route the caller to `readIntText`,
which is the slower variant the doc comment contrasts against, so the
specialized loop is kept.

Also corrected: `ReadHelpers.h`'s comment on why the date/time readers avoid
this function said it was because leading zeros were not supported. They now
are; the surviving reason is that `readIntTextUnsafe` cannot check for overflow,
which those call sites request explicitly.
@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

Reviewed at 1fff73fcab28e76 after five implementation rounds. An independent cold pass over the
resulting code came first, then a stateful re-review by a second model, then adjudication against the
recorded evidence. The reviewer never edits source.

Second-model re-review: 0 findings (--delta, focus diffstat 5 files, +88/-36, matching the
round-5 delta exactly; its own coverage note records that it read every changed function and test in
full and traced the serialization, inference, wrapper, format and Hive callers, but ran no tests).

Independent cold review: 0 blockers, 0 majors. Carriers were enumerated before reading the fix
plan and the two lists agreed. The reader has exactly one production call site, but it is a
convergence point: SerializationNumber overrides only the JSON and CSV entry points, so Escaped,
Raw, Quoted and deserializeWholeText all reach the changed code, which is why CSV is used as
the oracle for every expected value rather than as a second witness.

⚠️ Corrected before publication: the PR body claimed a compatibility break the code does not
make.
Round 4 deliberately scoped the new digit requirement to + only, and five sentences written
for the earlier +-and-- shape survived into the body. The changelog said a lone - is "now
rejected with CANNOT_PARSE_NUMBER"
, the description said the reader "requires a decimal digit
after either sign"
and claimed that fixed a pre-existing wrong result, and two validation rows showed
- and -\t1 moving to an error. All five are false of the shipped reader: the - branch carries no
digit test, the guard is has_plus && !is_digit(), and both the unit test and the recorded
both-directions run measure - as 0 and -\t1 as 0 1 on both binaries. The body now states
the measured behaviour and keeps the two - rows as labelled controls, with a + row as the witness
that replaces them. The commit message was checked separately and already worded the asymmetry
correctly, so nothing was corrected there.

⚠️ Two stale counts removed rather than restated. "A 151-test format slice" is 199/196 tests in
the round-5 logs, and "the 15 hive tests are identical" does not reproduce under any predicate
(13 / 16 / 19 depending on how hive tests are counted), with the hive run itself dating from round 1.
Both were replaced by figures re-derived here with the predicate stated: across the 196 format tests
both arms run, the same 24 fail for the same reasons and none only in the fixed arm; and
04040_hive_partitioning_leading_zeros, the test the removed flag existed for, passes on both. The
stale base Build ID was refreshed too, since the nightly snapshot moves it.

💡 Two citations had rotted on master and are now symbolic. SerializationNumber.cpp:106 and
:118 are :146 and :158 on current master, which added a 40-line function above them. The body
now names the functions instead, so the reference cannot rot again. Every remaining file:line pair
in the body and the validation-gate comment was verified by fragment match against origin/master
(the tree a reviewer greps), with a negative control at a deliberately wrong line.

💡 Noted, not blocking. The lone-+ rejection reaches every converging entry point, including
Values, MySQLDump, query parameters and dictionary defaults, but no committed test exercises a
non-Escaped/Raw one; the risk is bounded by construction, since CANNOT_PARSE_NUMBER is a parse
error and the Values streaming parser therefore falls back to the SQL parser instead of failing. The
TabSeparated lone-minus promise cited in the tests is real and stable, but it lives inside the format
documentation string embedded in that .cpp, not in an implementation comment.

💡 One of my own findings was withdrawn within the round. I read "thirty-one --first
observations"
as a claim about the test files and could not reproduce it there; it is a claim about
the round-4 probe artifacts, where it reproduces exactly: 31 labelled observations, all equal to
base, alongside three positive controls that do differ. Recorded rather than deleted.

Re-baselining a deliberately pinned behaviour was checked against its history: 02514 was added in
2022 by the commit "Infer numbers starting from zero as strings in TSV", whose in-code comment names
this reader as its only reason. This change removes that reason and re-baselines the test rather than
deleting it. A scan for other tests asserting the old behaviour returns only the three already in the
diff.

@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. printf -- '-007\n' | clickhouse local --input-format=TSV --structure="a Int64" -q "SELECT * FROM table" gives Code: 27 on every run; same for +7, for a bare - (which reads 0), and for count() of 007\n123\n456 (which reads 2). No randomized setting is involved.
b Root cause explained? readIntTextUnsafe (src/IO/readIntText.h:383) consumed an optional -, then short-circuited on the first 0 (:407) and returned that as the whole value, leaving the remaining digits in the buffer; + was neither - nor a digit, so the digit loop read nothing and reported success with 0. Either way the caller found unread bytes where a delimiter belonged. Its own doc comment at :377 listed both gaps. It has one production caller, SerializationNumber<T>::deserializeText (SerializationNumber.cpp:146 on current master), reached for the Escaped, Raw and Quoted rules; SerializationNumber overrides the CSV and JSON entry points to the tolerant readIntText, which is why those formats always worked.
c Fix matches root cause? Yes. The reader learns a run of leading zeros, a redundant +, and a required digit after a +. No widened bound, no no-random-* tag, no defensive check at the throw site. The inference guard at EscapingRuleUtils.cpp:346, whose own comment named this reader as its only reason, is removed along with FormatSettings::allow_number_leading_zeros and its single setter.
d Test intent preserved / new tests added? New 04812_tsv_int_leading_zeros (12 numbered groups; FAILs on the base binary, passes on the fixed one; the same holds for 02514 and 04648, all three measured against a server actually restarted on the base binary, since clickhouse-test --binary changes only which client runs) plus three gtest_read_int_text cases where readIntTextUnsafe previously had zero unit coverage (the file had one pre-existing case, for parseIntInBase). Every value assertion is paired with buf.eof(), which is what pins the defect: the old reader returned the correct value 0 for "00" while leaving the second 0 unread. 02514 and 04648 group 3 change by design, to values measured from CSV; all 17 changed 04648 value lines were checked positionally and every one is a zero-padded integer, with all float rows in the same groups untouched (the 18th changed line is a group label).
e Both directions demonstrated? Yes, on binaries whose identity is asserted per arm (SELECT lower(buildId()) vs readelf -n), with the server restarted per arm rather than only the client swapped. Base 0502ee8df849bfcb gives Code: 27 (-007) / Code: 27 (+7) / 2 (count() of 007\n123\n456); fixed b59f7bd6549abed3 gives -7 / 7 / 3, each matching the CSV oracle. The two CSV oracle arms are byte-identical on both, so the change did not leak into the CSV path. A lone - reads 0 on both binaries: that arm is a control for documented behaviour, not a witness; see row h.
f Fix is general across code paths? Fixed at the reader, not guarded at the crash site. All four formats of the Escaped/Raw family asserted (TSV, TSVRaw, TSKV, CustomSeparated), plus the Quoted rule that shares deserializeText; tryReadIntTextUnsafe is fixed by the shared body; the already-tolerant SerializationNumber<T>::tryDeserializeText sibling (SerializationNumber.cpp:158 on current master) is the behaviour the throwing path now converges on. CSV and JSON are deliberately unchanged and used as the oracle.
g Fix generalizes across inputs (params/datatypes/wrappers)? Padded, signed, +-signed, multi-zero runs, zero-run edges at both a delimiter and end of stream, and the sign-without-digit class including two-sign forms with a digit after them: 18 sign spellings at reader level and 26 end-to-end format rows, each compared against master. Targets Int64, UInt64, UInt32, Int128, Int256, UInt128, UInt256: 24 of 24 cells agree with CSV and every negative into an unsigned type stays rejected. Overflow/wrap parity pinned. Nineteen float spellings and Decimal(10,2) are byte-identical on both binaries.
h Backward compatible? (maintainer-approved exception only) No setting default changes and no new setting, so SettingsChangesHistory.cpp does not apply; allow_number_leading_zeros is a FormatSettings field and appears in no SettingsChangesHistory entry and no 03999_settings_history_baseline.tsv row (verified with a positive control). Hive partitioning keeps its behaviour because tolerance is now universal, proven by 04040_hive_partitioning_leading_zeros passing on both binaries. The one deliberate behaviour change is scoped to a lone +, which this change newly consumes as a sign and so must require a digit after it, or the field would read as the value 0. Master left the + unconsumed and the format layer refused the remainder, so end to end this moves Code: 27 to Code: 72. A lone - is unchanged from master and still reads as 0, which is what TabSeparatedRowInputFormat.cpp:500 documents; measured across both probe files, all 31 --first observations are equal to master, with 007 and +7 differing as positive controls. The sweep finding no stateless test that reads a bare - as an integer is now the evidence that keeping that behaviour breaks nothing.
i Invariants and contracts preserved? The reader's contract (consume exactly the number, leave the rest to the caller) holds on every path: the zeros run stops at the first non-digit, the + path throws rather than returning a value it never read, the - path is byte-identical to master, and x is assigned only on a success return. The follow-digit test is !buf.eof() && (byte - '0') < 10, so the !buf.eof() term keeps the reader from dereferencing past the working buffer at true end of stream. Ten of twelve mutants redden their own arms and nothing else, including one that keeps the digit-after-+ branch and removes only its out-of-line throw, and one that extends the requirement onto - as well; that last is what makes the +/- asymmetry a tested decision rather than an accident. The two that do not redden are reported rather than dropped: one is a read-past-end mutant no functional test can observe (it does redden a guard-page probe, not shipped because mprotect appears in no gtest in this repo) and the other is uncompilable because make_unsigned_t<T> rejects floats, which is itself the proof that the change cannot reach them.

Session id: cron:clickhouse-impl-slot-4:20260807-203700

@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator Author

cc @Avogar @al13n321, could you review this? readIntTextUnsafe short-circuited on the first 0 and never consumed a leading +, so the Escaped/Raw family could not read 007 or +7 while every other text format could, and inference contradicted its own reader on -007. With the reader fixed, the inference guard from #44522 has no premise left and is removed together with FormatSettings::allow_number_leading_zeros, so 02514 is re-baselined against the CSV answer rather than deleted.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bc11b04]

Summary: ✅


AI Review

Summary

This PR repairs readIntTextUnsafe so zero-padded and +-prefixed integers are consumed correctly on the Escaped / Raw / Quoted / deserializeWholeText surfaces that funnel through SerializationNumber::deserializeText. I re-checked the current diff together with the full review-thread history; the earlier contract and coverage gaps around inference, SQL comparison/planning, whole-text carriers, and the Values fallback are now reflected in the code and tests, and I did not find a remaining correctness or compatibility issue worth blocking.

Final Verdict

Status: ✅ Approve

LLVM Coverage Report

Measured on commit bc11b04.

Metric Baseline Current Δ
Lines 89.10% 89.10% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.50% 81.50% +0.00%

Changed lines: Changed C/C++ lines covered: 98/100 (98.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 8, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing bc11b041a with master de1224b14 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 28fd75867; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

1920 translation units recompiled, 12382 s compile time in total, 1920 of them have a recent master baseline.

Job report

@groeneai

groeneai commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 1fff73f

CI is fully finished on this head: 175 check-runs, 0 queued/in progress, Finish Workflow completed. Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stress test (arm_tsan) / Logical error: '(isConst() || isSparse() || isReplicated() || rhs...) ? getDataType() == rhs.getDataType() : typeid(*this) == typeid(rhs)' (STID 2508-30f6) pre-existing trunk abort: assertTypeEquality in HashJoin::buildAdditionalFilter on a mixed JOIN ON condition over mismatched column types; 122 rows / 101 PRs / 13 master in 30d #113534 (external, open)
Stress test (arm_asan_ubsan) / Sanitizer (STID: 2064-2dbf) pre-existing trunk leak: LeakSanitizer indirect leak (14872 bytes, 0 direct) from a Context retain cycle in the DatabaseReplicated digest finalizer. Frame-keyed to the DDL half (makeQueryContext / DDLWorker / DatabaseReplicated frames present, QueryTreeBuilder absent), which is exactly what #113953 fixes; 14 rows / 14 PRs / 0 master in 30d #113953 (mine, open)

Neither failure is caused by this PR. The diff touches integer/decimal text parsing (readIntText.h, ReadHelpers.*, SerializationNumber.cpp, EscapingRuleUtils.cpp, ValuesBlockInputFormat.cpp, HivePartitioningUtils.cpp); it does not reach the hash-join additional-filter path or the replicated-DDL context lifetime.

Session id: cron:our-pr-ci-monitor:20260809-023000

@Avogar Avogar self-assigned this Aug 10, 2026
@groeneai groeneai added the groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work label Aug 19, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). label Sep 4, 2026

@Avogar Avogar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's also check if the docs in TabSeparatedRowInputFormat.cpp are now correct and represent what code actually does

Comment thread src/IO/readIntText.h Outdated
Comment on lines +431 to +435
if (!is_digit())
{
x = 0;
return ReturnType(true);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This early return looks not needed. And for cases like 007 it will lead to just additional check or is_digit. The code below will do the same as this does,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, and I removed the whole if (*buf.position() == '0') block rather than only the early return: once the reader stops short-circuiting at the first zero, the digit loop covers a run of zeros by itself, because multiplying a zero accumulator by ten leaves it zero. Re-measured on the 18 sign spellings in the gtest and every 04812 group: 0, 00, 007, -007, +007, 0123 and 000000000000000000007 produce the same values and consume the same bytes as the version you reviewed, and the reference file did not move outside the two groups I edited for the inference revert.

One consequence to flag, since master put that branch there deliberately: it also drops master's dedicated return for a lone 0. In the reader-level release-build benchmark I ran earlier on this PR (2M values, minimum of 11 repetitions), master measured 1.03 ns/value on a column of nothing but 0 against 12.99 ns/value on multi-digit fields. What the loop costs for a single 0 is one iteration plus the final sign cast instead of an immediate return, and I have not timed that separately. If you would rather keep the fast path, I will put the single-zero return back and leave padded values to the loop.

Comment thread src/Formats/EscapingRuleUtils.cpp Resolved
Review decision on ClickHouse#113910: a leading zero carries information in the TSV
family (zip codes, phone numbers), so a zero-padded field must keep inferring
String. `EscapingRuleUtils.cpp`, `FormatSettings.h`, `HivePartitioningUtils.cpp`
and the two inference tests are restored to master, leaving only the value
reader and its tests. `DESCRIBE` on a file of `-007` still returns
`Nullable(Int64)`, and reading it is what this change repairs.

`readIntTextUnsafe` no longer special-cases a leading '0' at all. Once the
reader keeps reading past the first zero, the digit loop covers a run of them
by itself, because multiplying an accumulator of zero by ten leaves it zero:
`007` and `000000000000000000007` both read 7 through the loop. This also
removes the early return master had for a lone '0'.

The `TabSeparated` format documentation already promised that a `+` at the
beginning is ignored when parsing, which the family only now honours; leading
zeros join the same list of parsing leniencies.
@groeneai

groeneai commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

Docs check on TabSeparatedRowInputFormat.cpp

Checked the integer paragraph of the TabSeparated documentation string claim by claim, running each one on master and on this branch:

documented claim master this branch
an extra + at the beginning is ignored when parsing not honoured: +7 throws Code: 27 +7 reads 7
non-negative numbers cannot contain the negative sign -7 into UInt64 rejected unchanged
an empty string reads as zero reads 0 unchanged
for signed types, a field of just a minus sign reads as zero reads 0 unchanged
numbers that do not fit may be parsed as a different number wraps silently unchanged

So that paragraph was already documenting the + behaviour that only this PR implements, and every other sentence in it still describes the code. The one case it never mentioned is leading zeros, which are now accepted, so I added them to the same list of parsing leniencies in the same sentence. I did not touch docs/reference/formats/TabSeparated/TabSeparated.mdx: its copy of this text sits inside the generated region, which the docs check refuses direct edits to and the nightly docs job regenerates from this string.

Also in this push, with details in the two review threads: the schema-inference change is dropped and inference is byte-identical to master, the redundant zero block in readIntTextUnsafe is gone, and the description and changelog entry are rewritten for the narrower scope.

The leading-zero guard in `tryInferDataTypeByEscapingRule` fires only when the
field's first character is `0` and the inferred type is an integer, so it looks
past neither a sign nor a zero-leading float. `DESC format(TSV, '+007')` and
`DESC format(TSV, '-007')` return `Nullable(Int64)` here exactly as they do on
master, and the reader change then returns 7 and -7 for them where master threw
`Code: 27`. `CSV` returns those same values, and types a plain `007` as `Int64`
as well, so the padded-identifier protection is and always was `TSV`-family and
first-character only.

The comment, the test group and the changelog claimed the protection covered any
zero-padded field, which is more than the code does. Reword them to the rule the
guard implements, and pin `+007` next to the `-007` arm that already covered the
signed spelling.

Also trim the minus-branch comment in the gtest: the reason the sign branches
cannot both fire, and what the value would have been if they could, is history
for this message rather than an invariant the next reader of those assertions
needs, and the cited line number in another file rots.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 5df1d93

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Fast test (arm_darwin) / 05076_error_trace_file_offsets oracle column 2 is unsatisfiable on Darwin by construction: StackTrace::resolveAddress is compiled only under __ELF__, so Darwin stores raw runtime addresses, while the Mach-O collector extends each dyld image's last symbol to that image's max_addr, putting the bound above every captured frame. The test carries no Tags: line, so it runs on the darwin Fast test. Not caused by this PR; the test has never passed on this arm since my #117449 merged #119145 (mine, open) tags the test no-darwin
Bugfix validation (unit tests) job-level ERROR "Bugfix validation inconclusive: submodule state differs between the merge-base and the checkout, and the before-worktree cannot be populated at the merge-base submodule revisions". This PR touches no submodule and no .gitmodules entry, so the drift is the base branch moving submodules after the branch split, which the harness reports as a failure instead of as inconclusive #117948 (mine, open) stops reporting a base-branch submodule move as a bugfix-validation failure
Mergeable Check aggregator reflecting the two reds above #119145 and #117948 (both mine, open)
PR workflow aggregator reflecting the two reds above #119145 and #117948 (both mine, open)
Sync - CH Inc sync (private, not actionable by me)

Session id: cron:our-pr-ci-monitor:20260910-053056

`SerializationNumber<T>::deserializeText` is where the `Quoted` rule converges
with `Escaped` and `Raw`, and `SimpleTextSerialization` routes
`deserializeWholeText` into it as well, so the change reaches callers beyond the
four formats the test already covered. That reach was claimed in the PR text with
nothing asserting it.

Group 13 pins one end-to-end carrier per route: `MySQLDump` for `Quoted`, a query
parameter for `Escaped` (only `_request_body` takes the whole-text path), and a
dictionary `null_value` for whole text. On master those three fail with
CANNOT_PARSE_INPUT_ASSERTION_FAILED, BAD_QUERY_PARAMETER and
UNEXPECTED_DATA_AFTER_PARSED_VALUE.

`Values` reaches the same reader but its result is unchanged at default settings,
because a value the streaming parser rejects is re-read by the SQL expression
parser, which is also what reports the error there (a lone `+` fails as
SYNTAX_ERROR on both sides). One spelling does move: with
input_format_values_deduce_templates_of_expressions = 0, a padded or `+`-signed
value that overflows the target column used to reach that fallback and default to
0, or raise TYPE_MISMATCH under input_format_null_as_default = 0, and now wraps in
the reader exactly as the unpadded spelling always did. Both spellings are pinned
next to the unpadded control, since this reader has never checked overflow.
… string

`convertFieldToType` re-reads a string literal with `deserializeWholeText`
before comparing it with a numeric column, so the reader this PR changes is
reached from SQL and not only from a format. Measured against master at the
merge base: `WHERE v = '007'` and `WHERE v = '+7'` raised TYPE_MISMATCH
("Cannot convert string '007' to type Int64") and now return the row, and the
same conversion runs during planning, so `EXPLAIN indexes = 1` on a key
predicate moved from that exception to `Condition: (id in [7, 7])`. A
`bloom_filter` index over the compared column is reached the same way.

`toInt64('007')` already returned 7 on master, so the comparison was the
outlier and now agrees with the cast beside it, which is why the cast is the
oracle in this group the way `CSV` is in the earlier ones.

The two index assertions name the key condition and the index, not the part and
granule counts beside them, because those move with the `index_granularity` the
test runner randomizes over 1..65536. `use_skip_indexes` needs no pin: the
runner does not randomize it and its default is already 1.
Comment thread src/IO/readIntText.h Resolved
Review asked whether requiring a digit after the sign changes the public
error contract for the callers that reach this reader outside a format.
It does, for one input: `convertFieldToType` remaps only
UNEXPECTED_DATA_AFTER_PARSED_VALUE and ATTEMPT_TO_READ_AFTER_EOF to
TYPE_MISMATCH, and ReplaceQueryParameterVisitor raises
BAD_QUERY_PARAMETER only when a parse succeeds and leaves bytes behind,
so `WHERE i = '+'` moves from TYPE_MISMATCH to CANNOT_PARSE_NUMBER and
`{p:Int64}` = `'+'` from BAD_QUERY_PARAMETER to the same. Both spellings
already failed; only the code and message move.

Neither carrier normalises a reader error code, so this is not a new
class on either route. A Float64 target answers CANNOT_PARSE_NUMBER for
the identical value before and after this change, and an empty or
sign-only Int64 query parameter already propagated
ATTEMPT_TO_READ_AFTER_EOF. What changed is which branch the value takes:
the reader used to parse a lone `+` as zero and leave the sign for a
downstream leftover-byte check to reject, and now refuses it outright.

The float rows are the control and read identically on both sides, so
the group fails if either the integer rows stop reporting the reader
code or the float rows start disagreeing with them.
Group 14 read the `Condition:` and `Name:` rows straight out of
`EXPLAIN indexes = 1`, which only describes a local read. The
`ParallelReplicas` stateless lane enables parallel replicas in the
default profile and the runner randomizes
`parallel_replicas_local_plan` independently of that, so the same two
assertions met two different plans: with a local plan the rows are
nested under the remote step behind a box-drawing prefix that
`trimBoth` does not strip, and without one there is no local read to
analyse, so both rows are missing. Recapturing the reference would only
move the dependence, since the prefix width follows the nesting depth.

Pinning `enable_parallel_replicas = 0` on the two queries keeps the
assertion in the plan shape where the property it asserts exists. The
reference is unchanged, and the rows still disappear if the primary key
condition or the skip index name does.
…g rules

Group 13 named its carriers by format, which undercounts them, because the set is
open: `SimpleTextSerialization` funnels `deserializeWholeText` and the `Escaped`,
`Raw` and `Quoted` rules into one `deserializeText`, so a carrier moves exactly
when it uses one of those, and only the `CSV` and `JSON` overrides stay put.
Group 16 therefore pins one witness per mechanism rather than per format name.

Measured on a debug build of this branch against master at the merge base
c108e27, the server's Build ID asserted against the binary before every
verdict. Each target is `Int64`, master -> this branch:

  JSONStringsEachRow "007" / "+7" / "-007"     632 -> 7 / 7 / -7
  JSONCompactStringsEachRow ["007"] / ["+7"]   632 -> 7 / 7
  ...WithNamesAndTypes ["007"]                 632 -> 7
  Form a=007                                   632 -> 7
  Regexp capture group, Raw rule               632 -> 7
  CAST('[007]' AS Array(Int64))                130 -> [7]
  CAST('(007)' AS Tuple(Int64))                 27 -> (7)
  m.key_007 of Map(Int64, String)               47 -> resolves

`JSONStringsEachRow` and the three `JSONCompactStringsEachRow` spellings are the
complete set of input formats that set `yield_strings`; `JSONStrings` and
`JSONCompactStrings` are output-only, so they cannot carry this. Their unquoted
siblings are the control and read 7 on both sides, which is what makes the
discriminator `yield_strings` rather than JSON.

Five negative controls, one per new row, each pinning master's own code there,
each reddens the test and is restored byte-identical, so the assertions
discriminate the arms in both directions. 25 randomized runs green, plus
input_format_parallel_parsing, input_format_null_as_default,
input_format_json_empty_as_default and input_format_defaults_for_omitted_fields
pinned at both values.
`format(Values, ...)` with `input_format_values_deduce_templates_of_expressions = 0`
hands a value its streaming parser rejects to `parseExpression`, which defaults an
overflowing literal under `input_format_null_as_default = 1` and reports TYPE_MISMATCH
under `= 0`. The reader now consumes `(0128)` and `(+128)` itself, so both arms move,
and group 13 pinned only the first: measured on `Int8`, master answers 0 / 0 / -128 with
defaulting on and TYPE_MISMATCH / TYPE_MISMATCH / -128 with it off, this branch -128 for
all six.

The three existing rows name `input_format_null_as_default = 1` instead of inheriting it,
so the two arms read as a pair. `tests/clickhouse-test` randomizes neither setting, and a
query-level value wins over a session-level pin, checked in both directions; each new row
was also negative-controlled against master's own answer.

Group 15 gains two carriers that wrap the reader's error in a code of their own, so its
claim is witnessed rather than asserted: a lone `+` in `Values` is SYNTAX_ERROR from the SQL
parser it falls back to, and a `Map` subcolumn whose key does not read as a number is
UNKNOWN_IDENTIFIER from name resolution. Both are identical on master, which is what makes
them controls; the nine other carriers measured report the reader's CANNOT_PARSE_NUMBER. The
set of wrappers is not closed either: `RegExpTreeDictionary::parseStringToField` catches
everything and reports INCORRECT_DICTIONARY_DEFINITION, and a stateless test cannot reach it
without a YAML source, so neither the test nor the description claims an exhaustive list.

The unit test gains that boundary as a test of its own: `is_digit` calls `eof`, so the
digit a `+` requires can be the first byte of the next buffer. Every earlier plus assertion
used a single buffer, so an implementation checking only pending data would reject a valid
`+7` at a chunk boundary with all of them still green; measured, replacing that `eof` with
`hasPendingData` reddens the new test alone.

Reported by clickhouse-gh[bot] on ClickHouse#113910.

@Avogar Avogar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please update the changelog entry - it's too big and verbose. You can keep something as PR description, but changelog entry should be compact.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Done: the changelog entry is now four sentences (the format fix, the shared reader, the lone + error code, and inference staying unchanged). The route enumeration and the Values setting detail moved into ### Description. No code change, so the head is unchanged at 78c6c069774102.

One thing before merge: my own new test 04812_tsv_int_leading_zeros is failing deterministically (3 out of 3 reruns) in two amd_llvm_coverage flavours, Unknown column: m.key_007 under the old analyzer with DBReplicated and a reference diff under ParallelReplicas. Both are mine to fix, I am on it, and I will report here when they are green.

Group 16 read `m.key_007` off a subquery's own column, and the `old
analyzer` stateless lane resolves a subcolumn against a storage only, so
that row failed there with `Code: 47 Unknown column: m.key_007` on every
rerun. The plain spelling `m.key_7` fails identically in that lane, so
the gap is the fixture, not the key text this change teaches the reader
to parse.

The map now lives in a `Memory` table, which both analyzers resolve, and
the row selects the padded spelling beside the plain one so a single row
asserts that the two name the same key. Measured against the merge base
`c108e273b6087`: the row is `Code: 47` there at `enable_analyzer` 1 and
0, and answers `x` twice here at both, so it still witnesses the reader
change and now witnesses it in both lanes. Group 15's negative
`m.`key_+`` row moves to the same table and keeps `UNKNOWN_IDENTIFIER`
at both values.

Validated with 20 runs at the default analyzer, 10 at `enable_analyzer =
0`, and the two statements inside a real `Replicated` database at
`enable_analyzer = 0`, which is the other half of the failing lane. Four
negative controls redden the file: the subquery fixture restored (red at
`enable_analyzer = 0`, green at the default, which is the CI failure
exactly), each of the two columns pointed at an absent key, and a wrong
expected code on the group 15 row. The reference gains one field and no
line.
@groeneai

Copy link
Copy Markdown
Collaborator Author

Both 04812 flavours are addressed, head 745ed5ca76d8.

The old-analyzer failure was my test's fixture, not the parser: the row read the Map subcolumn off a subquery's own column, and enable_analyzer = 0 resolves a subcolumn against a storage only. The plain spelling m.key_7 fails the same way in that lane, which rules the padding out. The map now lives in a Memory table, and the row selects m.key_007 beside m.key_7 so one row asserts that the two name the same key. With the old fixture the test is red at enable_analyzer = 0 and green at the default, which is the CI failure exactly; with the new one it is green over 20 runs at the default, 10 at enable_analyzer = 0, and inside a real Replicated database at enable_analyzer = 0. Against the merge base the row is still Code: 47 at both analyzer values, so it keeps witnessing the reader change.

The ParallelReplicas reference diff was already fixed in cc48979, by pinning enable_parallel_replicas = 0 on the two EXPLAIN indexes = 1 rows: index analysis is rendered only for a local read.

I will report here once both flavours re-run green.

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 745ed5c

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Keeping the promise from my previous comment: both llvm-coverage flavours that carried
04812_tsv_int_leading_zeros re-ran green on this head (ParallelReplicas, s3 storage, parallel
and old analyzer, s3 storage, DBReplicated, parallel, 2/3), so the reference-rendering
fragility is closed. The two Bugfix validation (functional tests) checks are green as well:
the 04648_tsv_schema_inference_leading_zero_decimals row inside them is the intended
reproduction on the before-binary.

Check / test Reason Owner / fixing PR
Upgrade check (amd_release) / Logical error: Virtual row has different type for A. Expected B, got C (STID: 1637-309b) LOGICAL_ERROR aborting setVirtualRow: the planned virtual row is Nullable(String) while the delivered CAST(__table1.`json.b`, 'String'_String) column is String. Not caused by this PR, which touches no sorting-key, virtual-row or read-in-order code; 50 distinct pull requests and 2 true-master runs carry this signature within the last 30 days #119385 (mine, open) fixes the type divergence at its source
Bugfix validation (unit tests) job-level ERROR with no test-level rows: "Bugfix validation inconclusive: submodule state differs between the merge-base and the checkout" for contrib/NuRaft. This PR touches no submodule and no .gitmodules entry, so the drift is the base branch moving a submodule after the branch split, which the harness reports as a failure instead of as inconclusive #117948 (mine, open) stops reporting a base-branch submodule move as a bugfix-validation failure
Mergeable Check aggregator reflecting the two reds above #119385 and #117948 (both mine, open)
PR workflow aggregator reflecting the two reds above #119385 and #117948 (both mine, open)

Session id: cron:our-pr-ci-monitor:20260911-223036

@Avogar
Avogar added this pull request to the merge queue Sep 15, 2026
Merged via the queue into ClickHouse:master with commit 6621515 Sep 15, 2026
177 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 15, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Sep 16, 2026
…nditional merge

The branch carried a negative-integer provenance subsystem and an unconditional
escaped-rule merge override across seven files. Measured against master, neither
earns its place.

The unconditional override runs transformIntegers, which widens every unmarked
Int64 to UInt64. TSKV `x=-1` / `x=18446744073709551615` therefore went from a
readable Nullable(String) to an unreadable Nullable(UInt64) (Code 27). That
regression is self-inflicted: the provenance subsystem existed to undo it, not to
fix anything master gets wrong.

The provenance record also cannot reach the format the branch claimed it fixed.
TabSeparatedSchemaReader passes no JSONInferenceInfo and inherits the
no-provenance transform, so no marking made from a TSV field is ever consulted.
What the subsystem does reach - CustomSeparated, Regexp, Template - is a separate
defect with its own owner question, and its code stays in this branch's history.

The `+`-demotion half is removed too: merged ClickHouse#113910 fixed readIntTextUnsafe, so
master now reads `+007` and pins it as Nullable(Int64) in 04812. Keeping the
demotion would fail that test.

What remains is the defect itself, in two files. The schema reader reads the raw
field, so inference answers for the bytes readRow parses. Reading raw makes a
null-representation field infer Nullable(Nothing) rather than nothing at all, so a
null row now takes part in the cross-row merge, where a null and a container have
no plain supertype and this format's String default would discard the container
type. A merge override scoped to that pair keeps it: master's merger runs first
and its answer is kept whenever it resolves the pair, so only a pair it leaves
unequal with a null on one side is rescued.

Related: ClickHouse#113910

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

@Avogar The nightly SQLancer found two unexpected Code: 72 on master 112492e6, both carrying the message this PR introduced. One is a comparison:

SELECT '+kui' < 917426774
Code: 72. Cannot parse number without any digits: while converting '+kui' to UInt32

As e115f079 recorded here, that literal moved from TYPE_MISMATCH to CANNOT_PARSE_NUMBER, because convertFieldToType rewrites only UNEXPECTED_DATA_AFTER_PARSED_VALUE and ATTEMPT_TO_READ_AFTER_EOF (b6d5d946dec4). So for one integer target and one mistake, the code now depends on the literal's first character:

string literal, integer target code
'', 'abc', '1x', '1-1', '-kui' 53, Cannot convert string '<v>' to type <T>
'+', '+kui', '+-1' 72, Cannot parse number without any digits

A Decimal target answers 53 for '+kui'.

The fuzzer matches with message.contains(entry) and its entry for this shape is Cannot parse number with a sign character but without any numeric character, a wording that is not in the tree, so it never matches. That list needs the current text whatever is decided here: the second finding is accurateCastOrNull(c1, 'Int32') over a FixedString column throwing the same message from the conversion functions, where toUInt32('+kui') throwing 72 is correct and stays.

Two questions:

  1. May I add the current message to ClickHouse/sqlancer's ClickHouseErrors.java? It is needed either way.
  2. Do you want convertFieldToType to rewrite CANNOT_PARSE_NUMBER as well, so a string that is no number answers Cannot convert string '<v>' to type <T> for every numeric target? Two lines, plus the two expectations in 04812 group 15 and three cases in 05047. It moves a server-visible code, so I am not pushing it without your word.

I am not proposing to change the reader.

Reports: arm_asan_ubsan and arm_release.

@groeneai

Copy link
Copy Markdown
Collaborator Author

Second instance of question 1 above, different root cause, so a different remedy. Question 2 is untouched by this.

Tonight's NightlySQLancer on master de0be457 is red on two MaterializedCte findings, Code: 32 (ATTEMPT_TO_READ_AFTER_EOF) on arm_release and Code: 72 (CANNOT_PARSE_NUMBER) on arm_asan_ubsan, and the 2026-09-04 Code: 6 (CANNOT_PARSE_TEXT) row is the same thing. None of the three is a materialized-CTE bug and none of them reaches convertFieldToType. All three are the metadata versus on-disk type mismatch left by the generator's own DDL:

finding generated DDL value in the failing part code
09-22 arm_release ALTER TABLE t2 MODIFY COLUMN c0 UInt64, was String '' 32
09-22 arm_asan_ubsan ALTER TABLE t0 MODIFY COLUMN c0 UInt64, was String '-2057621192' 72
09-04 arm_release ALTER TABLE t0 MODIFY COLUMN c1 UInt8, was LowCardinality(String) ')7 ' 6

Each one throws from the same frame: _CAST(cN, '<new type>'), built by convertRequiredExpressions and executed by IMergeTreeReader::performRequiredConversions, whose catch adds the (while reading from part ...) suffix. The conversion mutation cannot succeed on those values, and the metadata commit is durable and happens before the mutation runs, so the column stays unreadable. That is the state #105947 describes, and whether such an ALTER should be rejected is #116182, still waiting on a remedy choice. So the server is not misbehaving here.

The oracle picks that column because the server now reports an exact integer type for it, which is true, and its expected-error set has no entry for this class. Note the failure is not in the CTE: the cast happens in the base table scan, so both sides of the enable_materialized_cte comparison hit it.

The fix I would make is fork-side, and it is a predicate rather than an error-list entry. Whitelisting CANNOT_PARSE_* in ClickHouseErrors.java would blind the Cast oracle, which fired on 09-19, to real cast bugs. ClickHouse/sqlancer#16 already put isStableForRepeatedReads() into ClickHouseSchema.getRandomTableNonEmptyTables() and covered all 26 schema-picking oracles from there; a sibling predicate at the same seam, skipping a table whose active parts carry a column type different from system.columns (or that has an unfinished MODIFY COLUMN in system.mutations), fixes them all at once.

@fm4v may I send that to ClickHouse/sqlancer? It is your seam and your oracle, so I am not pushing it without your word.

One separate note, since it is your script too: ci/jobs/scripts/sqlancer_failures.py maps every generated identifier to the single token id (line 75) and cuts the message at 200 characters (line 153). The arm_release row therefore reads as FROM mcte_x AS id JOIN mcte_x AS id over a table called id, and loses SETTINGS enable_materialized_cte = 1. The real query is ... AS x1 JOIN ... AS x2 over t2. That cost me two wrong hypotheses before I opened the reproducer. I can send a small PR for it if you want one.

Reports: arm_release and arm_asan_ubsan.

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

Labels

can be tested Allows running workflows for external contributors comp-formats Input/output formats (CSV/JSON/Parquet/ORC/Arrow/Protobuf/etc.). groeneai-origin-follow-up PR origin: groeneai's own out-of-scope finding during its PR work pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants