Repository navigation
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the defect?
A row source whose table schema contains a
DATE,TIMEorTIMESTAMPcolumn delivers no row at all.RowDeserializationSchemaderives the value type of each field from its conversion class(
RowDeserializationSchema.java:113):A
DATE,TIMEorTIMESTAMPcolumn is ajava.time.LocalDate,java.time.LocalTimeorjava.time.LocalDateTime, andByteSerializer.getTypeIndexmaps those toV_LocalDate,V_LocalTimeandV_LocalDateTime(ByteSerializer.java:115-126). The switch inStringSerializer.deserializehad cases only forthe legacy
java.sql.Date/Time/Timestampvalues, which a schema-driven source never produces, so everytemporal field fell through to
StringSerializer.java:142:That per-field exception is caught by
deserializeBytesMessage(RowDeserializationSchema.java:232) and routed tothe dirty-data strategy, which defaults to
SKIP, so the row is dropped and the job keeps running. The result is astream that connects, reports no error, and emits nothing.
The same
StringSerializerbacks the legacyRowKeyValueDeserializationSchema, so both entry points are affected.What does this change?
Three cases are added to the switch, returning the internal representation a
GenericRowDataexpects:V_LocalDatejava.time.LocalDateint)V_LocalTimejava.time.LocalTimeint)V_LocalDateTimejava.time.LocalDateTimeTimestampDataA timestamp written as a SQL literal (
2020-01-02 03:04:05.123, the natural CSV form) is normalised to2020-01-02T03:04:05.123before parsing; ISO-8601 input is unchanged. Leading/trailing blanks are trimmed.null(and a configured null literal) still maps tonull.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) andTIMESTAMP_LTZare untouched: their textual form is ambiguous(
TIMESTAMP_LTZis evenUnsupportedingetTypeIndex, since its conversion class isjava.time.Instant), sothey deserve their own change rather than a guess here.
Tests
New
RowDeserializationSchemaTemporalTypeTest(5 tests) builds aSTRING, STRING, DATE, TIME, TIMESTAMP(3)schema,pushes a comma delimited body through
RowDeserializationSchema.deserialize, and asserts:DATE/TIME/TIMESTAMPvalues equal the expected internal values;2020-13-45) is still dropped by the dirty-data strategy.Against the pristine
StringSerializer, the first four tests fail withExpected size: 1 but was: 0; with the fixall five pass. The whole module (
mvn -B -ntp -pl flink-connector-rocketmq clean test, JDK 11) is143 tests, 0 failures, 6 skipped, and the CI commandmvn -B -ntp clean packagesucceeds;spotless:checkisclean on the JDK 11 leg.
No issue tracks this defect, so nothing is linked.