You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by di...@apache.org on 2023/01/10 01:40:22 UTC

[flink] branch master updated: [FLINK-28742][python] Fix ArrowUtils to support CHAR type

This is an automated email from the ASF dual-hosted git repository.

dianfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f14f13122e [FLINK-28742][python] Fix ArrowUtils to support CHAR type
0f14f13122e is described below

commit 0f14f13122e2df5e4a2396871936a5b6ff47cd12
Author: Dian Fu <di...@apache.org>
AuthorDate: Mon Jan 9 19:41:05 2023 +0800

    [FLINK-28742][python] Fix ArrowUtils to support CHAR type
    
    This closes #21627.
---
 flink-python/pyflink/table/types.py                                 | 2 +-
 .../main/java/org/apache/flink/table/runtime/arrow/ArrowUtils.java  | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/flink-python/pyflink/table/types.py b/flink-python/pyflink/table/types.py
index 3c3d2a33b02..b3aac1d3525 100644
--- a/flink-python/pyflink/table/types.py
+++ b/flink-python/pyflink/table/types.py
@@ -2275,7 +2275,7 @@ def to_arrow_type(data_type: DataType):
         return pa.float32()
     elif isinstance(data_type, DoubleType):
         return pa.float64()
-    elif isinstance(data_type, VarCharType):
+    elif isinstance(data_type, (CharType, VarCharType)):
         return pa.utf8()
     elif isinstance(data_type, VarBinaryType):
         return pa.binary()
diff --git a/flink-python/src/main/java/org/apache/flink/table/runtime/arrow/ArrowUtils.java b/flink-python/src/main/java/org/apache/flink/table/runtime/arrow/ArrowUtils.java
index 5e8b09fc425..28f0a74e51d 100644
--- a/flink-python/src/main/java/org/apache/flink/table/runtime/arrow/ArrowUtils.java
+++ b/flink-python/src/main/java/org/apache/flink/table/runtime/arrow/ArrowUtils.java
@@ -68,6 +68,7 @@ import org.apache.flink.table.types.DataType;
 import org.apache.flink.table.types.logical.ArrayType;
 import org.apache.flink.table.types.logical.BigIntType;
 import org.apache.flink.table.types.logical.BooleanType;
+import org.apache.flink.table.types.logical.CharType;
 import org.apache.flink.table.types.logical.DateType;
 import org.apache.flink.table.types.logical.DecimalType;
 import org.apache.flink.table.types.logical.DoubleType;
@@ -655,6 +656,11 @@ public final class ArrowUtils {
             return new ArrowType.FloatingPoint(FloatingPointPrecision.DOUBLE);
         }
 
+        @Override
+        public ArrowType visit(CharType varCharType) {
+            return ArrowType.Utf8.INSTANCE;
+        }
+
         @Override
         public ArrowType visit(VarCharType varCharType) {
             return ArrowType.Utf8.INSTANCE;