bitsail icon indicating copy to clipboard operation
bitsail copied to clipboard

[BitSail][Improve]Add more debugging log for the NativeFlinkTypeInfoUtil.

Open hk-lrzy opened this issue 2 years ago • 4 comments

Description

public class NativeFlinkTypeInfoUtil {
...
  public static RowTypeInfo getRowTypeInformation(List<ColumnInfo> columnInfos,
                                                  TypeInfoConverter typeInfoConverter) {

    String[] fieldNames = new String[columnInfos.size()];
    TypeInformation<?>[] fieldTypes = new TypeInformation[columnInfos.size()];

    for (int index = 0; index < columnInfos.size(); index++) {
      String type = StringUtils.lowerCase(columnInfos.get(index).getType());
      String name = columnInfos.get(index).getName();

      TypeInfo<?> typeInfo = typeInfoConverter.fromTypeString(type);

      fieldNames[index] = name;
      fieldTypes[index] = toNativeFlinkTypeInformation(typeInfo);
    }

    return new RowTypeInfo(fieldTypes, fieldNames);
  }
...
}

TypeInfo<?> typeInfo = typeInfoConverter.fromTypeString(type); and

public class ColumnFlinkTypeInfoUtil {
  public static RowTypeInfo getRowTypeInformation(TypeInfoConverter converter,
                                                  List<ColumnInfo> columnInfos) {

    String[] fieldNames = new String[columnInfos.size()];
    TypeInformation<?>[] fieldTypes = new TypeInformation[columnInfos.size()];
    for (int index = 0; index < columnInfos.size(); index++) {
      String type = StringUtils.lowerCase(columnInfos.get(index).getType());
      String name = columnInfos.get(index).getName();

      TypeInfo<?> typeInfo = converter.fromTypeString(type);
      fieldNames[index] = name;
      fieldTypes[index] = toColumnFlinkTypeInformation(typeInfo);
    }

    return new RowTypeInfo(fieldTypes, fieldNames);
  }
}

TypeInfo<?> typeInfo = converter.fromTypeString(type);

Both the classes have the same issue of lack the validation for the result of the converter.fromTypeString(type) and cause if there return null value the logic will throw NPE. IMO it is not clearly enough for all users to know what's hapened and how to solve it.

Your use scenarios

No response

Your alternatives

No response

Are you willing to submit PR?

  • [ ] Yes, I am willing to submit a PR!

Code of Conduct

hk-lrzy avatar Feb 24 '23 02:02 hk-lrzy

please assign this issue to me, thanks!

beyond-up avatar Feb 24 '23 07:02 beyond-up

@beyond-up Assigned it to you, look foward to your PR later~

hk-lrzy avatar Feb 24 '23 07:02 hk-lrzy

@hk-lrzy @lichang-bd This issue seems can be closed.

liuxiaocs7 avatar Mar 16 '23 04:03 liuxiaocs7