Skip to content

[ISSUE #N/A] fix: decode the DATE, TIME and TIMESTAMP columns of a row source - #150

Open
NUAAwqy wants to merge 1 commit into
apache:mainfrom
NUAAwqy:fix/string-serializer-temporal-columns
Open

NUAAwqy wants to merge 1 commit into
apache:mainfrom
NUAAwqy:fix/string-serializer-temporal-columns

Conversation

@NUAAwqy

@NUAAwqy NUAAwqy commented Oct 28, 2026

Copy link
Copy Markdown

What is the defect?

A row source whose table schema contains a DATE, TIME or TIMESTAMP column delivers no row at all.

RowDeserializationSchema derives the value type of each field from its conversion class
(RowDeserializationSchema.java:113):

ByteSerializer.getTypeIndex(tableSchema.getFieldTypes()[index].getTypeClass())

A DATE, TIME or TIMESTAMP column is a java.time.LocalDate, java.time.LocalTime or
java.time.LocalDateTime, and ByteSerializer.getTypeIndex maps those to V_LocalDate, V_LocalTime and
V_LocalDateTime (ByteSerializer.java:115-126). The switch in StringSerializer.deserialize had cases only for
the legacy java.sql.Date / Time / Timestamp values, which a schema-driven source never produces, so every
temporal field fell through to StringSerializer.java:142:

default:
    throw new IllegalArgumentException();

That per-field exception is caught by deserializeBytesMessage (RowDeserializationSchema.java:232) and routed to
the dirty-data strategy, which defaults to SKIP, so the row is dropped and the job keeps running. The result is a
stream that connects, reports no error, and emits nothing.

The same StringSerializer backs the legacy RowKeyValueDeserializationSchema, so both entry points are affected.

What does this change?

Three cases are added to the switch, returning the internal representation a GenericRowData expects:

type value internal form
V_LocalDate java.time.LocalDate days since epoch (int)
V_LocalTime java.time.LocalTime milliseconds of the day (int)
V_LocalDateTime java.time.LocalDateTime TimestampData

A timestamp written as a SQL literal (2020-01-02 03:04:05.123, the natural CSV form) is normalised to
2020-01-02T03:04:05.123 before parsing; ISO-8601 input is unchanged. Leading/trailing blanks are trimmed.
null (and a configured null literal) still maps to null.

A value that cannot be parsed still throws, so the configured dirty-data strategy keeps making the decision — this
change does not turn a malformed field into a row of garbage.

INTERVAL columns (V_Duration/V_Period) and TIMESTAMP_LTZ are untouched: their textual form is ambiguous
(TIMESTAMP_LTZ is even Unsupported in getTypeIndex, since its conversion class is java.time.Instant), so
they deserve their own change rather than a guess here.

Tests

New RowDeserializationSchemaTemporalTypeTest (5 tests) builds a STRING, STRING, DATE, TIME, TIMESTAMP(3) schema,
pushes a comma delimited body through RowDeserializationSchema.deserialize, and asserts:

  • the row is delivered and the DATE / TIME / TIMESTAMP values equal the expected internal values;
  • a two-line message delivers two rows (the row was dropped, not merely mis-decoded);
  • an unparsable date (2020-13-45) is still dropped by the dirty-data strategy.

Against the pristine StringSerializer, the first four tests fail with Expected size: 1 but was: 0; with the fix
all five pass. The whole module (mvn -B -ntp -pl flink-connector-rocketmq clean test, JDK 11) is
143 tests, 0 failures, 6 skipped, and the CI command mvn -B -ntp clean package succeeds; spotless:check is
clean on the JDK 11 leg.

No issue tracks this defect, so nothing is linked.

…w source

A table whose schema contains a temporal column delivers no row at all.

`ByteSerializer.getTypeIndex` maps the conversion class of such a field to
`V_LocalDate`, `V_LocalTime` and `V_LocalDateTime` — a `DATE`, `TIME` or
`TIMESTAMP` column is reported as `java.time.LocalDate`, `java.time.LocalTime`
or `java.time.LocalDateTime` — but the switch in `StringSerializer.deserialize`
had no case for any of them. Each value therefore fell into the final
`default: throw new IllegalArgumentException()`. `RowDeserializationSchema`
handles a per-field exception with the configured dirty data strategy, which
defaults to `SKIP`, so the row was dropped and the job kept running on an
empty stream.

Decode the three types in their internal representation: a `DATE` as the days
since epoch, a `TIME` as the milliseconds of the day, and a `TIMESTAMP` as
`TimestampData`. A value that cannot be parsed still throws, so a malformed
field keeps going through the dirty data strategy instead of producing a row
of garbage. The interval and `TIMESTAMP_LTZ` types are left untouched.
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