Skip to content

Cherry pick #105584 to 26.5: Honor cast_string_to_date_time_mode for hive partition values - #105730

Merged
robot-ch-test-poll merged 10 commits into
backport/26.5/105584from
cherrypick/26.5/105584
May 24, 2026
Merged

robot-ch-test-poll merged 10 commits into
backport/26.5/105584from
cherrypick/26.5/105584

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

Original pull-request #105584

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 10 commits May 21, 2026 20:00
Hive partition value extraction is conceptually a string-to-type cast,
but the code in `HivePartitioningUtils` was building a fresh
`FormatSettings` with only `allow_number_leading_zeros = true` and
ignoring the user's settings. As a result, parsing of `DateTime` and
`DateTime64` partition values defaulted to the strict `Basic` parser
and rejected ISO 8601 timestamps with timezone suffixes such as
`+0000`, `+00:00`, or `Z`. Setting either
`cast_string_to_date_time_mode = 'best_effort'` or
`date_time_input_format = 'best_effort'` had no effect.

Thread `format_settings` and the context through `addPartitionColumnsToChunk`,
and centralize the construction of hive-specific `FormatSettings` in a
helper that overrides `date_time_input_format` with
`cast_string_to_date_time_mode`. The setting defaults to `best_effort`,
so by default Hive-partitioned data lakes with ISO 8601 timestamp keys
(including Python `pandas` `isoformat` output and similar) now read
without an exception.

Fixes #105368.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The flaky check runs each query with a random `session_timezone` (e.g.
`Mexico/BajaSur`). For the inferred-type case the column type is
`DateTime` with no explicit timezone, so the displayed value depends on
the session timezone and the reference would not match when the
session timezone is shifted. Pin `session_timezone = 'UTC'` so the
output is deterministic across configurations.

See #105584 CI flaky-check
failures on commit be09afa.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Address review comment
#105584 (comment).

The previous commit made `HivePartitioningUtils` honour
`cast_string_to_date_time_mode` for schema-backed hive partition columns,
but the same invariant was still broken for hive keys materialized as
virtual columns. In `prepareReadingFromFormat`, missing schema columns
are classified as `requested_virtual_columns`, and then
`VirtualColumnUtils::addRequestedFileLikeStorageVirtualsToChunk` parsed
them with a fresh `FormatSettings` that only set
`allow_number_leading_zeros`. The path filter evaluation in
`addPathAndFileToVirtualColumns` had the same problem.

Expose `HivePartitioningUtils::buildHiveFormatSettings` as a public helper
and route both `addRequestedFileLikeStorageVirtualsToChunk` and
`getFilterByPathAndFileIndexes` through it, threading the storage's
`format_settings` from all call sites so all hive partition value
conversions honour `cast_string_to_date_time_mode` consistently.

Extend `04259_hive_partitioning_datetime_timezones.sh` with two new cases
covering the virtual-column path (schema declares only `id`) and a `WHERE`
filter on the virtual column.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…rtualsToChunk` loop

`buildHiveFormatSettings` was constructed once per matched hive virtual column,
but the result is identical for every iteration and the `getFormatSettings(context)`
fallback reads many settings.

This matches the hoisting pattern already used by `addPartitionColumnsToChunk` in
`HivePartitioningUtils.cpp` and `getFilterByPathAndFileIndexes` in
`VirtualColumnUtils.cpp`, and addresses the Cursor Bugbot review on commit
1b969c5.
… test

The PR description notes that prior to this fix, neither `cast_string_to_date_time_mode`
nor `date_time_input_format` had any effect on hive partition value parsing. Test
coverage existed for `cast_string_to_date_time_mode` but not for the
`date_time_input_format` variant referenced in the description.

Hive partition value extraction is conceptually a cast, so `cast_string_to_date_time_mode`
is the authoritative setting and overrides `date_time_input_format` inside
`buildHiveFormatSettings`. The new query exercises the setting referenced in the PR
description; since `cast_string_to_date_time_mode` defaults to `best_effort`, the
timezone-suffixed paths parse successfully.

Addresses review feedback from @Ergus on PR #105584.
…time-tz

Honor cast_string_to_date_time_mode for hive partition values
@robot-ch-test-poll robot-ch-test-poll added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels May 24, 2026
@robot-ch-test-poll
robot-ch-test-poll merged commit ecb3576 into backport/26.5/105584 May 24, 2026
@robot-ch-test-poll
robot-ch-test-poll deleted the cherrypick/26.5/105584 branch May 24, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants