hequn8128 commented on a change in pull request #11556: [FLINK-16847][python]
Support timestamp types in vectorized Python UDF
URL: https://github.com/apache/flink/pull/11556#discussion_r400002276
##########
File path: flink-python/pyflink/table/types.py
##########
@@ -2282,6 +2288,55 @@ def verify(obj):
return verify
+def to_arrow_type(data_type):
+ """
+ Converts the specified Flink data type to pyarrow data type.
+ """
+ import pyarrow as pa
+ if type(data_type) == TinyIntType:
+ return pa.int8()
+ elif type(data_type) == SmallIntType:
+ return pa.int16()
+ elif type(data_type) == IntType:
+ return pa.int32()
+ elif type(data_type) == BigIntType:
+ return pa.int64()
+ elif type(data_type) == BooleanType:
+ return pa.bool_()
+ elif type(data_type) == FloatType:
+ return pa.float32()
+ elif type(data_type) == DoubleType:
+ return pa.float64()
+ elif type(data_type) == VarCharType:
+ return pa.utf8()
+ elif type(data_type) == VarBinaryType:
+ return pa.binary()
+ elif type(data_type) == DecimalType:
+ return pa.decimal128(data_type.precision, data_type.scale)
+ elif type(data_type) == DateType:
+ return pa.date32()
+ elif type(data_type) == TimeType:
+ if data_type.precision == 0:
+ return pa.time32('s')
+ elif 1 <= data_type.precision <= 3:
+ return pa.time32('ms')
+ elif 4 <= data_type.precision <= 6:
+ return pa.time64('us')
+ else:
+ return pa.time64('ns')
+ elif type(data_type) == LocalZonedTimestampType or type(data_type) ==
TimestampType:
Review comment:
Maybe `type(data_type) in [LocalZonedTimestampType, TimestampType]:`
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services