Java Code Examples for org.apache.flink.table.types.logical.LogicalType#accept()
The following examples show how to use
org.apache.flink.table.types.logical.LogicalType#accept() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrowUtils.java From flink with Apache License 2.0 | 6 votes |
private static Field toArrowField(String fieldName, LogicalType logicalType) { FieldType fieldType = new FieldType( logicalType.isNullable(), logicalType.accept(LogicalTypeToArrowTypeConverter.INSTANCE), null); List<Field> children = null; if (logicalType instanceof ArrayType) { children = Collections.singletonList(toArrowField( "element", ((ArrayType) logicalType).getElementType())); } else if (logicalType instanceof RowType) { RowType rowType = (RowType) logicalType; children = new ArrayList<>(rowType.getFieldCount()); for (RowType.RowField field : rowType.getFields()) { children.add(toArrowField(field.getName(), field.getType())); } } return new Field(fieldName, fieldType, children); }
Example 2
Source File: PythonTypeUtils.java From flink with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public TypeSerializer visit(ArrayType arrayType) { LogicalType elementType = arrayType.getElementType(); TypeSerializer<?> elementTypeSerializer = elementType.accept(this); Class<?> elementClass = elementType.accept(LogicalTypeToConversionClassConverter.INSTANCE); return new GenericArraySerializer(elementClass, elementTypeSerializer); }
Example 3
Source File: HiveTypeUtil.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeInfo visit(MapType mapType) { LogicalType keyType = mapType.getKeyType(); LogicalType valueType = mapType.getValueType(); TypeInfo keyTypeInfo = keyType.accept(this); TypeInfo valueTypeInfo = valueType.accept(this); if (null == keyTypeInfo || null == valueTypeInfo) { return defaultMethod(mapType); } else { return TypeInfoFactory.getMapTypeInfo(keyTypeInfo, valueTypeInfo); } }
Example 4
Source File: HiveTypeUtil.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeInfo visit(MapType mapType) { LogicalType keyType = mapType.getKeyType(); LogicalType valueType = mapType.getValueType(); TypeInfo keyTypeInfo = keyType.accept(new TypeInfoLogicalTypeVisitor(dataType)); TypeInfo valueTypeInfo = valueType.accept(new TypeInfoLogicalTypeVisitor(dataType)); if (null == keyTypeInfo || null == valueTypeInfo) { return defaultMethod(mapType); } else { return TypeInfoFactory.getMapTypeInfo(keyTypeInfo, valueTypeInfo); } }
Example 5
Source File: HiveTypeUtil.java From flink with Apache License 2.0 | 5 votes |
@Override public TypeInfo visit(ArrayType arrayType) { LogicalType elementType = arrayType.getElementType(); TypeInfo elementTypeInfo = elementType.accept(this); if (null != elementTypeInfo) { return TypeInfoFactory.getListTypeInfo(elementTypeInfo); } else { return defaultMethod(arrayType); } }
Example 6
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 5 votes |
@Override protected Optional<LogicalType> defaultMethod(LogicalType logicalType) { if (predicate.test(logicalType)) { return Optional.of(logicalType); } for (LogicalType child : logicalType.getChildren()) { final Optional<LogicalType> foundType = child.accept(this); if (foundType.isPresent()) { return foundType; } } return Optional.empty(); }
Example 7
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
public static boolean isProctimeAttribute(LogicalType logicalType) { return logicalType.accept(TIMESTAMP_KIND_EXTRACTOR) == TimestampKind.PROCTIME; }
Example 8
Source File: KuduTypeUtils.java From bahir-flink with Apache License 2.0 | 4 votes |
public static Type toKuduType(DataType dataType) { checkNotNull(dataType, "type cannot be null"); LogicalType logicalType = dataType.getLogicalType(); return logicalType.accept(new KuduTypeLogicalTypeVisitor(dataType)); }
Example 9
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
public static boolean isSingleFieldInterval(LogicalType logicalType) { return logicalType.accept(SINGLE_FIELD_INTERVAL_EXTRACTOR); }
Example 10
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
public static int getFractionalPrecision(LogicalType logicalType) { return logicalType.accept(FRACTIONAL_PRECISION_EXTRACTOR); }
Example 11
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
public static int getDayPrecision(LogicalType logicalType) { return logicalType.accept(DAY_PRECISION_EXTRACTOR); }
Example 12
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
/** * Returns the scale of all types that define a scale implicitly or explicitly. */ public static int getScale(LogicalType logicalType) { return logicalType.accept(SCALE_EXTRACTOR); }
Example 13
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
/** * Returns the field names of row and structured types. */ public static List<String> getFieldNames(LogicalType logicalType) { return logicalType.accept(FIELD_NAMES_EXTRACTOR); }
Example 14
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
public static int getLength(LogicalType logicalType) { return logicalType.accept(LENGTH_EXTRACTOR); }
Example 15
Source File: DataTypeFactoryImpl.java From flink with Apache License 2.0 | 4 votes |
@Override public DataType createDataType(String name) { final LogicalType parsedType = LogicalTypeParser.parse(name, classLoader); final LogicalType resolvedType = parsedType.accept(resolver); return fromLogicalToDataType(resolvedType); }
Example 16
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
public static boolean isRowtimeAttribute(LogicalType logicalType) { return logicalType.accept(TIMESTAMP_KIND_EXTRACTOR) == TimestampKind.ROWTIME; }
Example 17
Source File: PlannerTypeUtils.java From flink with Apache License 2.0 | 4 votes |
/** * A conversion that removes all {@link LegacyTypeInformationType}s by mapping to corresponding new types. */ public static LogicalType removeLegacyTypes(LogicalType t) { return t.accept(new LegacyTypeToPlannerTypeConverter()); }
Example 18
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
public static boolean isSingleFieldInterval(LogicalType logicalType) { return logicalType.accept(SINGLE_FIELD_INTERVAL_EXTRACTOR); }
Example 19
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
/** * Returns the precision of all types that define a precision implicitly or explicitly. */ public static int getPrecision(LogicalType logicalType) { return logicalType.accept(PRECISION_EXTRACTOR); }
Example 20
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 3 votes |
/** * Returns true if the two given types are compatible. Types are compatible is for atomic types * (VARCHAR, INT, BOOLEAN, etc..), they must be fully equal (i.e. {@link LogicalType#equals(Object)}), * for complex types (ARRAY, ROW, MAP, etc..), they must be in the same type but ignore field * names and other logical attributes, and all the children types ({@link LogicalType#getChildren()}) * must be compatible too. */ public static boolean areTypesCompatible(LogicalType thisType, LogicalType thatType) { checkNotNull(thisType); checkNotNull(thatType); TypeCompatibleVisitor visitor = new TypeCompatibleVisitor(thisType); return thatType.accept(visitor); }