Repository navigation
Conversation
ISODate and new ISODate as mongodb shell syntaxt
|
Workflow [PR], commit [d0478a5] Summary: ✅
AI ReviewSummaryAdds MongoDB shell Final VerdictStatus: ✅ Approve |
|
Updating the branch to fix the |
new ISODate in json. Add stateless test to check.
…sodate-json-parsing
…PeekableReadBuffer` A non-quoted JSON number never starts with `I` or `n`, so such a token can only be the wrapper and the checkpoint/rollback to numeric parsing was dead code. Matching the prefix directly keeps a near-miss like `ISODate123` rejected (now with `CANNOT_PARSE_INPUT_ASSERTION_FAILED`, naming the expected prefix) and leaves no private `PeekableReadBuffer` memory that could hold unread delimiter bytes.
Merge the 17 one-case tests into `05296_json_isodate_declared_datetime64` (declared `DateTime64`, `Nullable`, `Variant`, `INSERT`), `05297_json_isodate_basic_input_format` (`date_time_input_format = 'basic'`) and `05298_json_isodate_malformed`, all with a non-UTC time zone so the `Z` handling is visible. The removed split-buffer tests used `format` and inline `INSERT` data, which are read from a single in-memory buffer, so `max_read_buffer_size` never split anything. `05299_json_isodate_small_read_buffer` reads a multi-row stream through `file` with `max_read_buffer_size` from 1 to 16 instead.
…date-json-parsing
…`DateTime64` variants
`Variant` enabled `allow_mongodb_isodate_wrapper` unconditionally before choosing a variant, so
an object or an array containing `ISODate(...)` survived tokenization and could then be taken by a
`String` variant through `read_objects_as_strings` / `read_arrays_as_strings`, e.g.
`format(JSONEachRow, 'v Variant(String, DateTime64(3))', '{"v": {"x": ISODate("...")}}')`.
Now the wrapper is tokenized only when some variant contains `DateTime64`, and a value which is
not valid JSON without the wrapper is deserialized with `read_objects_as_strings` and
`read_arrays_as_strings` disabled, so it either reaches a `DateTime64` or is rejected.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
`readability-container-contains` and `bugprone-return-const-ref-from-parameter` fired on `getSettingsForDeserializingJSONField`. Replace it with `tryDeserializeTextJSONField`, which picks the settings and deserializes the field itself, so no reference to a parameter is returned. https://s3.amazonaws.com/clickhouse-test-reports/PRs/107650/34992e03a1bf3b106a4a61295c54d1efe93bcb6d/pr/build_arm_tidy_1_4/build_clickhouse/build_clickhouse.log PR: ClickHouse#107650 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=107650&sha=caab293f8809c99d1d7fed3d4d80a3c5eb56fb72&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29 ( The other failures on this commit are not related to this PR's
|
|
The fix is #125126 (mine), merged today at 15:34 UTC, after this run. The failed query (from I ran the query in |
|
🕵 Thanks @groeneai. I merged the latest The open |
…t` and skipped fields - `skipJSONField`: choose between `null` and `new ISODate(` by the character after the leading `n`, so a failed probe of one alternative no longer consumes a prefix of the other (`neull` and `new ISODateull` were accepted as `null`). - `Variant`: for a value that is valid JSON only with the `ISODate` wrapper, do not disable `read_objects_as_strings` / `read_arrays_as_strings` for the whole value. Instead, a new internal flag `reject_mongodb_isodate_wrapper_in_strings` makes `String` validate an object or array it reads as a raw string, so sibling objects and arrays keep these conversions, while a `String` still does not take a value containing the wrapper. - JSON input formats tolerate the wrapper when skipping a field (`JSONEachRow`, `JSONCompactEachRow`, the `count()` path of `JSONColumns`): the format cannot distinguish an unknown field from a declared `DateTime64` column pruned from the requested header, and `SELECT id FROM file(...)` or `SELECT count()` must not fail on input that `SELECT *` reads. Schema inference, `Dynamic`, `JSON` and `JSONExtract` stay strict. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `input_format_json_ignore_unknown_keys_in_named_tuple`, an unknown key of a
named `Tuple` is now skipped with the same wrapper-aware settings as an unknown
top-level field (`JSONUtils::getJSONSettingsForSkippingField`), so removing an
unused `ISODate("...")` timestamp from a tuple schema no longer makes the input
unreadable. `Variant` now also tokenizes the wrapper when a variant contains a
named `Tuple` and the setting is enabled; a `String` variant still rejects it.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/PRs/107650/57a9d9f4d2f3e03e1011585a7c16e4f8c21239a3/pr/ast_fuzzer_amd_release_oracle/fatal.log ( |
|
The fix is in progress in #107127. This is the same bug as #118986: Measured on the fuzzer's query (
#107127 is open and waiting for review. |
Conflicts: `FormatSettings::JSON` became `JSONFormatSettings` on master, so the `ISODate` fields moved there; `deserializeTextJSONImpl` keeps the PR's buffer-boundary-safe null check and now forwards master's `nested_type` to every `deserializeImpl` call.
…JSON` escaping rule
`CustomSeparated` and `Template` read a declared `DateTime64` through
`deserializeFieldByEscapingRule`, which accepts the MongoDB shell `ISODate("...")`
wrapper, but skipped fields went through `skipFieldByEscapingRule` -> `skipJSONField`
with the strict settings. So an unknown field, `${:JSON}` in `Template`, and the
optimized `count()` failed with `INCORRECT_DATA` on input that reads fine when
the column is declared.
`skipFieldByEscapingRule` now skips `JSON` fields with
`JSONUtils::getJSONSettingsForSkippingField`, like the JSON input formats. The copy
of the settings lives in an out-of-line helper so it does not put a stack canary on
the hot `skipFieldByEscapingRule`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Thanks @groeneai for tracking the |
Closes: #65850
Changelog category:
Changelog entry
Added support for parsing the MongoDB shell's
ISODate("...")andnew ISODate("...")datetime constructor syntax into
DateTime64columns in JSON-based formats such asJSONEachRow.The wrapper is accepted only where the target type is already known to be
DateTime64(a declared column, or a
DateTime64arm ofNullable/Variant); it is deliberately notpart of JSON schema inference, so schema inference, the
DynamicandJSONdata types andJSONExtractkeep rejecting it. A field that is skipped while reading (an unknown field, or adeclared column that the query does not read) may contain it.
This is the MongoDB shell display syntax, not the output of the official export tools:
mongodumpwrites BSON (read byBSONEachRow) andmongoexportwrites Extended JSON,where a datetime is an object such as
{"$date": "..."}, which is not handled here.Whether Extended JSON should also be supported is being discussed in the issue.
This PR implements the specific use case described in the issue (parsing
ISODate/new ISODateintoDateTime64). The more generalnew TypeName(...)constructor-to-type mapping mentioned as an alternative in the issue is left as
future work, as it would need a broader design discussion (constructor registry,
argument parsing for arbitrary types, a new format setting, etc.).
Tests
Stateless tests covering:
ISODate(...)andnew ISODate(...), with and without aZsuffixNullableandVariantnested types, including thetryparsing pathdate_time_input_format = 'basic'behavior:Zforces UTC, no suffix stays local, a doubleZand a numeric offset are rejectedISODate123, both inside one buffer chunk and split across a tiny read bufferinput_format_read_datetime_number_as_raw_valueWorkflow [PR]
Sync PR [sync-upstream/pr/107650]