Sitelet https://github.com/apache/paimon/pull/10367
Skip to content

[core] Validate the timestamp field type for merge_map_with_keytime - #10367

Open
jackylee-ch wants to merge 1 commit into
apache:masterfrom
jackylee-ch:core-validate-keytime-ts-string-type
Open

jackylee-ch wants to merge 1 commit into
apache:masterfrom
jackylee-ch:core-validate-keytime-ts-string-type

Conversation

@jackylee-ch

Copy link
Copy Markdown
Contributor

Purpose

FieldMergeMapWithKeyTimeAggFactory validates that the aggregated field is a MAP
whose value is a ROW with at least two fields, and that the configured timestamp field
exists — but it never checks that field's type. The merge path
(FieldMergeMapWithKeyTimeAgg) reads the timestamp with InternalRow#getString and
compares it lexicographically, so a non-string timestamp field — declared BIGINT /
TIMESTAMP / INT, which is a natural choice for a "ts" field — is accepted at DDL and
only fails at the first merge/compaction with a ClassCastException that names neither
the field nor the function.

The aggregation docs already mandate a string timestamp field. This validates it is
CHAR / VARCHAR at factory creation, matching the type checks the other aggregate
factories (sum, product, …) already perform, so the misconfiguration fails fast with a
clear message.

Tests

FieldAggregatorTest#testFieldMergeMapWithKeyTimeAggFactoryRejectsNonStringTsField
asserts a BIGINT timestamp field is rejected; …AcceptsStringTsField asserts a string
field still builds.

API and Format

No change.

Documentation

No change.

FieldMergeMapWithKeyTimeAggFactory validated the MAP/ROW shape and that
the configured timestamp field exists, but never its type. The merge path
reads it with InternalRow#getString and compares lexicographically, so a
non-string timestamp field -- declared BIGINT/TIMESTAMP/INT, which is
natural for a "ts" field -- was accepted at DDL and only failed at the
first merge/compaction with a ClassCastException that names neither the
field nor the function. The aggregation docs already mandate a string
timestamp field. Validate it is CHAR/VARCHAR at factory creation, matching
the type checks the other aggregate factories already perform.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant