You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/06/24 11:58:54 UTC
[GitHub] [flink] aljoscha commented on a change in pull request #12765: [FLINK-18417][table] Support List as a conversion class for ARRAY
aljoscha commented on a change in pull request #12765:
URL: https://github.com/apache/flink/pull/12765#discussion_r444836420
##########
File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/extraction/DataTypeExtractor.java
##########
@@ -429,11 +449,15 @@ else if (clazz == java.time.Period.class) {
private @Nullable DataType extractMapType(DataTypeTemplate template, List<Type> typeHierarchy, Type type) {
final Class<?> clazz = toClass(type);
+ // we require only Map here (not a subclass) because we cannot guarantee more specific
Review comment:
```suggestion
// we only allow Map here (not a subclass) because we cannot guarantee more specific
```
##########
File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/ArrayType.java
##########
@@ -42,6 +42,7 @@
public static final String FORMAT = "ARRAY<%s>";
private static final Set<String> INPUT_OUTPUT_CONVERSION = conversionSet(
+ List.class.getName(),
Review comment:
Why add it here when we anyways have the explicit check for `List` later. Ahh, it's because in input conversions we allow subtypes but not for output conversions, right?
##########
File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/extraction/DataTypeExtractor.java
##########
@@ -314,15 +314,35 @@ else if (type instanceof GenericArrayType) {
return DataTypes.ARRAY(
extractDataTypeOrRaw(template, typeHierarchy, genericArray.getGenericComponentType()));
}
+
+ final Class<?> clazz = toClass(type);
+ if (clazz == null) {
+ return null;
+ }
+
// for my.custom.Pojo[][]
- else if (type instanceof Class) {
- final Class<?> clazz = (Class<?>) type;
- if (clazz.isArray()) {
- return DataTypes.ARRAY(
- extractDataTypeOrRaw(template, typeHierarchy, clazz.getComponentType()));
- }
+ if (clazz.isArray()) {
+ return DataTypes.ARRAY(
+ extractDataTypeOrRaw(template, typeHierarchy, clazz.getComponentType()));
}
- return null;
+
+ // for List<T>
+ // we require only List here (not a subclass) because we cannot guarantee more specific
Review comment:
```suggestion
// we only allow List here (not a subclass) because we cannot guarantee more specific
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org