Exemplo n.º 1
0
 def _to_data_type(cls, field_type):
     if field_type.type_name == flink_fn_execution_pb2.Schema.TINYINT:
         return TinyIntType(field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.SMALLINT:
         return SmallIntType(field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.INT:
         return IntType(field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.BIGINT:
         return BigIntType(field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.BOOLEAN:
         return BooleanType(field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.FLOAT:
         return FloatType(field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.DOUBLE:
         return DoubleType(field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.VARCHAR:
         return VarCharType(0x7fffffff, field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.VARBINARY:
         return VarBinaryType(0x7fffffff, field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.DECIMAL:
         return DecimalType(field_type.decimal_info.precision,
                            field_type.decimal_info.scale,
                            field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.DATE:
         return DateType(field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.TIME:
         return TimeType(field_type.time_info.precision,
                         field_type.nullable)
     elif field_type.type_name == \
             flink_fn_execution_pb2.Schema.LOCAL_ZONED_TIMESTAMP:
         return LocalZonedTimestampType(
             field_type.local_zoned_timestamp_info.precision,
             field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.TIMESTAMP:
         return TimestampType(field_type.timestamp_info.precision,
                              field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.BASIC_ARRAY:
         return ArrayType(
             cls._to_data_type(field_type.collection_element_type),
             field_type.nullable)
     elif field_type.type_name == flink_fn_execution_pb2.Schema.TypeName.ROW:
         return RowType([
             RowField(f.name, cls._to_data_type(f.type), f.description)
             for f in field_type.row_schema.fields
         ], field_type.nullable)
     else:
         raise ValueError("field_type %s is not supported." % field_type)
Exemplo n.º 2
0
 def _to_data_type(field):
     if field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.TINYINT:
         return TinyIntType(field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.SMALLINT:
         return SmallIntType(field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.INT:
         return IntType(field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.BIGINT:
         return BigIntType(field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.BOOLEAN:
         return BooleanType(field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.FLOAT:
         return FloatType(field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.DOUBLE:
         return DoubleType(field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.VARCHAR:
         return VarCharType(0x7fffffff, field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.VARBINARY:
         return VarBinaryType(0x7fffffff, field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.DECIMAL:
         return DecimalType(field.type.decimal_info.precision,
                            field.type.decimal_info.scale,
                            field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.DATE:
         return DateType(field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.TIME:
         return TimeType(field.type.time_info.precision,
                         field.type.nullable)
     elif field.type.type_name == \
             flink_fn_execution_pb2.Schema.TypeName.LOCAL_ZONED_TIMESTAMP:
         return LocalZonedTimestampType(
             field.type.local_zoned_timestamp_info.precision,
             field.type.nullable)
     elif field.type.type_name == flink_fn_execution_pb2.Schema.TypeName.TIMESTAMP:
         return TimestampType(field.type.timestamp_info.precision,
                              field.type.nullable)
     else:
         raise ValueError("field_type %s is not supported." %
                          field.type)