[FLINK-39812][table] Migrate FlinkTypeFactory to java#28284
Conversation
| String[] fieldNames, LogicalType[] fieldTypes, StructKind structKind) { | ||
| FieldInfoBuilder b = builder(); | ||
| b.kind(structKind); | ||
| // mirror Scala's `fieldNames.zip(fieldTypes)`, which truncates to the shorter sequence |
There was a problem hiding this comment.
Can be simplified. Remove comment and Math.min
| .map(PlannerTypeUtils::removeLegacyTypes) | ||
| .collect(Collectors.toList()); | ||
| .collect(Collectors.toList()) | ||
| .toArray(new LogicalType[0]); |
There was a problem hiding this comment.
nit: isn't List easier to handle than arrays?
There was a problem hiding this comment.
made using lists here
9a1c183 to
2c97164
Compare
fhueske
left a comment
There was a problem hiding this comment.
Thanks for porting the type factory @snuyanzin.
I've checked the ported code and didn't spot any correctness issues.
Left a few comments with minor improvement suggestions.
Maybe we can use Java lists rather than arrays where possible?
Cheers, Fabian
| .map(PlannerTypeUtils::removeLegacyTypes) | ||
| .collect(Collectors.toList()); | ||
| .collect(Collectors.toList()) | ||
| .toArray(new LogicalType[0]); |
| return createSqlType(SqlTypeName.TINYINT); | ||
| case SMALLINT: | ||
| return createSqlType(SqlTypeName.SMALLINT); | ||
|
|
| final Optional<RelDataType> resolved = resolveAllIdenticalTypes(types); | ||
| final RelDataType leastRestrictive = | ||
| resolved.isPresent() ? resolved.get() : super.leastRestrictive(types); |
There was a problem hiding this comment.
Nit:
Should be possible to simplified to something like
| final Optional<RelDataType> resolved = resolveAllIdenticalTypes(types); | |
| final RelDataType leastRestrictive = | |
| resolved.isPresent() ? resolved.get() : super.leastRestrictive(types); | |
| final RelDataType leastRestrictive = resolveAllIdenticalTypes(types) | |
| .getOrElse(super.leastRestrictive(types)); |
| case DECIMAL: | ||
| return new DecimalType(relDataType.getPrecision(), relDataType.getScale()); | ||
|
|
||
| // time indicators |
There was a problem hiding this comment.
nit:
the comment does not really apply anymore because the outer else branch of case TIMESTAMP does not handle a time indicator but a regular TIMESTAMP type.
| } | ||
| } | ||
| return new LocalZonedTimestampType(relDataType.getPrecision()); | ||
| // temporal types |
There was a problem hiding this comment.
TIMESTAMP and TIMESTAMP_WITH_LOCAL_TIME_ZONE are missing from the temporal types because they are handled above.
There was a problem hiding this comment.
removed, not sure we need it there...
| new String[] {"f1", "f2", "f3"}, | ||
| new LogicalType[] { | ||
| new IntType(), new BigIntType(), new VarCharType() |
There was a problem hiding this comment.
| new String[] {"f1", "f2", "f3"}, | |
| new LogicalType[] { | |
| new IntType(), new BigIntType(), new VarCharType() | |
| List.of("f1", "f2", "f3"), | |
| List.of(new IntType(), new BigIntType(), new VarCharType()) |
should work as well?
fhueske
left a comment
There was a problem hiding this comment.
+1 to merge.
Thank you, Fabian
What is the purpose of the change
This is a preliminary change before bumping Calcite to 1.39.0
The main reason here is that this class is relatively often a problem while Calcite upgrade if something is changed in interfaces (new default methods for instance)
maven just fails as
Brief change log
FlinkTypeFactory to java
Verifying this change
existing tests
Does this pull request potentially affect one of the following parts:
@Public(Evolving): ( no)Documentation
Was generative AI tooling used to co-author this PR?