Java Code Examples for org.apache.flink.table.types.logical.LocalZonedTimestampType#getPrecision()
The following examples show how to use
org.apache.flink.table.types.logical.LocalZonedTimestampType#getPrecision() .
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 | 5 votes |
@Override public ArrowType visit(LocalZonedTimestampType localZonedTimestampType) { if (localZonedTimestampType.getPrecision() == 0) { return new ArrowType.Timestamp(TimeUnit.SECOND, null); } else if (localZonedTimestampType.getPrecision() >= 1 && localZonedTimestampType.getPrecision() <= 3) { return new ArrowType.Timestamp(TimeUnit.MILLISECOND, null); } else if (localZonedTimestampType.getPrecision() >= 4 && localZonedTimestampType.getPrecision() <= 6) { return new ArrowType.Timestamp(TimeUnit.MICROSECOND, null); } else { return new ArrowType.Timestamp(TimeUnit.NANOSECOND, null); } }
Example 2
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
@Override public Integer visit(LocalZonedTimestampType localZonedTimestampType) { return localZonedTimestampType.getPrecision(); }
Example 3
Source File: LogicalTypeUtils.java From flink with Apache License 2.0 | 4 votes |
@Override public LogicalType visit(LocalZonedTimestampType localZonedTimestampType) { return new LocalZonedTimestampType( localZonedTimestampType.isNullable(), localZonedTimestampType.getPrecision()); }
Example 4
Source File: TypeInfoDataTypeConverter.java From flink with Apache License 2.0 | 4 votes |
public static TypeInformation<?> fromDataTypeToTypeInfo(DataType dataType) { Class<?> clazz = dataType.getConversionClass(); if (clazz.isPrimitive()) { final TypeInformation<?> foundTypeInfo = primitiveDataTypeTypeInfoMap.get(clazz.getName()); if (foundTypeInfo != null) { return foundTypeInfo; } } LogicalType logicalType = fromDataTypeToLogicalType(dataType); switch (logicalType.getTypeRoot()) { case TIMESTAMP_WITHOUT_TIME_ZONE: TimestampType timestampType = (TimestampType) logicalType; int precision = timestampType.getPrecision(); if (timestampType.getKind() == TimestampKind.REGULAR) { return clazz == TimestampData.class ? new TimestampDataTypeInfo(precision) : (clazz == LocalDateTime.class ? ((3 == precision) ? Types.LOCAL_DATE_TIME : new LegacyLocalDateTimeTypeInfo(precision)) : ((3 == precision) ? Types.SQL_TIMESTAMP : new LegacyTimestampTypeInfo(precision))); } else { return TypeConversions.fromDataTypeToLegacyInfo(dataType); } case TIMESTAMP_WITH_LOCAL_TIME_ZONE: LocalZonedTimestampType lzTs = (LocalZonedTimestampType) logicalType; int precisionLzTs = lzTs.getPrecision(); return clazz == TimestampData.class ? new TimestampDataTypeInfo(precisionLzTs) : (clazz == Instant.class ? ((3 == precisionLzTs) ? Types.INSTANT : new LegacyInstantTypeInfo(precisionLzTs)) : TypeConversions.fromDataTypeToLegacyInfo(dataType)); case DECIMAL: DecimalType decimalType = (DecimalType) logicalType; return clazz == DecimalData.class ? new DecimalDataTypeInfo(decimalType.getPrecision(), decimalType.getScale()) : new BigDecimalTypeInfo(decimalType.getPrecision(), decimalType.getScale()); case CHAR: case VARCHAR: // ignore precision return clazz == StringData.class ? StringDataTypeInfo.INSTANCE : BasicTypeInfo.STRING_TYPE_INFO; case BINARY: case VARBINARY: // ignore precision return PrimitiveArrayTypeInfo.BYTE_PRIMITIVE_ARRAY_TYPE_INFO; case INTERVAL_YEAR_MONTH: return TimeIntervalTypeInfo.INTERVAL_MONTHS; case INTERVAL_DAY_TIME: return TimeIntervalTypeInfo.INTERVAL_MILLIS; case ARRAY: if (dataType instanceof CollectionDataType && !isPrimitive(((CollectionDataType) dataType).getElementDataType().getLogicalType())) { return ObjectArrayTypeInfo.getInfoFor( fromDataTypeToTypeInfo(((CollectionDataType) dataType).getElementDataType())); } else { return TypeConversions.fromDataTypeToLegacyInfo(dataType); } case MAP: KeyValueDataType mapType = (KeyValueDataType) dataType; return new MapTypeInfo( fromDataTypeToTypeInfo(mapType.getKeyDataType()), fromDataTypeToTypeInfo(mapType.getValueDataType())); case MULTISET: return MultisetTypeInfo.getInfoFor( fromDataTypeToTypeInfo(((CollectionDataType) dataType).getElementDataType())); case ROW: if (RowData.class.isAssignableFrom(dataType.getConversionClass())) { return RowDataTypeInfo.of((RowType) fromDataTypeToLogicalType(dataType)); } else if (Row.class == dataType.getConversionClass()) { RowType logicalRowType = (RowType) logicalType; return new RowTypeInfo( dataType.getChildren() .stream() .map(TypeInfoDataTypeConverter::fromDataTypeToTypeInfo) .toArray(TypeInformation[]::new), logicalRowType.getFieldNames().toArray(new String[0])); } else { return TypeConversions.fromDataTypeToLegacyInfo(dataType); } case RAW: if (logicalType instanceof RawType) { final RawType<?> rawType = (RawType<?>) logicalType; return createWrapperTypeInfo(rawType); } return TypeConversions.fromDataTypeToLegacyInfo(dataType); default: return TypeConversions.fromDataTypeToLegacyInfo(dataType); } }
Example 5
Source File: LogicalTypeChecks.java From flink with Apache License 2.0 | 4 votes |
@Override public Integer visit(LocalZonedTimestampType localZonedTimestampType) { return localZonedTimestampType.getPrecision(); }
Example 6
Source File: LogicalTypeUtils.java From flink with Apache License 2.0 | 4 votes |
@Override public LogicalType visit(LocalZonedTimestampType localZonedTimestampType) { return new LocalZonedTimestampType( localZonedTimestampType.isNullable(), localZonedTimestampType.getPrecision()); }
Example 7
Source File: ParquetRowDataWriter.java From flink with Apache License 2.0 | 4 votes |
private FieldWriter createWriter(LogicalType t, Type type) { if (type.isPrimitive()) { switch (t.getTypeRoot()) { case CHAR: case VARCHAR: return new StringWriter(); case BOOLEAN: return new BooleanWriter(); case BINARY: case VARBINARY: return new BinaryWriter(); case DECIMAL: DecimalType decimalType = (DecimalType) t; return createDecimalWriter(decimalType.getPrecision(), decimalType.getScale()); case TINYINT: return new ByteWriter(); case SMALLINT: return new ShortWriter(); case DATE: case TIME_WITHOUT_TIME_ZONE: case INTEGER: return new IntWriter(); case BIGINT: return new LongWriter(); case FLOAT: return new FloatWriter(); case DOUBLE: return new DoubleWriter(); case TIMESTAMP_WITHOUT_TIME_ZONE: TimestampType timestampType = (TimestampType) t; return new TimestampWriter(timestampType.getPrecision()); case TIMESTAMP_WITH_LOCAL_TIME_ZONE: LocalZonedTimestampType localZonedTimestampType = (LocalZonedTimestampType) t; return new TimestampWriter(localZonedTimestampType.getPrecision()); default: throw new UnsupportedOperationException("Unsupported type: " + type); } } else { throw new IllegalArgumentException("Unsupported data type: " + t); } }
Example 8
Source File: PythonTypeUtils.java From flink with Apache License 2.0 | 4 votes |
@Override public TypeSerializer visit(LocalZonedTimestampType localZonedTimestampType) { return new TimestampDataSerializer(localZonedTimestampType.getPrecision()); }