Skip to content

feat: introduce type casting executors for Binary, Date, and Timestam…#101

Open
lszskye wants to merge 1 commit into
apache:mainfrom
lszskye:p10-13
Open

feat: introduce type casting executors for Binary, Date, and Timestam…#101
lszskye wants to merge 1 commit into
apache:mainfrom
lszskye:p10-13

Conversation

@lszskye

@lszskye lszskye commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Introduce Type Casting Executors for Binary, Date, and Timestamp Types

Summary

Add a set of CastExecutor implementations under src/paimon/core/casting/ to support type casting between binary, date, timestamp, string, and numeric types. These executors extend the casting framework to cover temporal and binary type conversions required for schema evolution scenarios.

Each executor supports two casting modes:

  • Literal casting: Converts a single Literal value to the target type (used during predicate rewriting).
  • Array casting: Converts an entire Arrow Array to the target type (used during batch data reading).

New Classes

BinaryToStringCastExecutor — Casts binary (byte array) values to string type by interpreting the raw bytes as a UTF-8 encoded string.

DateToStringCastExecutor — Casts date values (days since epoch) to their ISO-8601 string representation (e.g., "2024-01-15").

DateToTimestampCastExecutor — Casts date values to timestamp types with configurable time unit (seconds, milliseconds, microseconds, nanoseconds). Sets the time component to midnight (00:00:00). Note: C++ Paimon supports a narrower date range than Java Paimon when the target unit is nanoseconds, limited by int64 bounds.

NumericPrimitiveToTimestampCastExecutor — Casts numeric primitive values (interpreted as seconds since epoch) to timestamp types with the specified precision. Note: When the target type is nanosecond precision, the valid numeric range is narrower than Java Paimon due to int64 overflow constraints.

StringToBinaryCastExecutor — Casts string values to binary type by encoding the string content as raw bytes.

StringToDateCastExecutor — Casts string values in date format (e.g., "2024-01-15") to date type (days since epoch).

StringToTimestampCastExecutor — Casts string values in timestamp format to timestamp types. Supports ISO-8601 formats including "1970-01-01T00:00:00". Note: Differs from Java Paimon in that it does not support passing numeric values as timestamp strings, but additionally supports the T-separated format.

TimestampToDateCastExecutor — Casts timestamp values to date type by truncating the time component and retaining only the date part (days since epoch).

TimestampToNumericPrimitiveCastExecutor — Casts timestamp values to numeric primitive types by extracting the epoch seconds. When the source timestamp has sub-second precision, the fractional part is truncated.

TimestampToStringCastExecutor — Casts timestamp values to their ISO-8601 string representation with appropriate precision (e.g., "2024-01-15 12:30:45.123").

TimestampToTimestampCastExecutor — Converts between TIMESTAMP and TIMESTAMP_WITH_LOCAL_TIME_ZONE types, handling precision changes (e.g., milliseconds to nanoseconds) by scaling the underlying int64 value accordingly.

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