You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/10/17 06:36:48 UTC

[GitHub] [flink] HuangXingBo commented on a diff in pull request #21079: [FLINK-29648][python] Fix "LocalTimeTypeInfo not supported" error

HuangXingBo commented on code in PR #21079:
URL: https://github.com/apache/flink/pull/21079#discussion_r996658315


##########
flink-python/pyflink/common/typeinfo.py:
##########
@@ -720,6 +720,39 @@ def __repr__(self) -> str:
         return 'MapTypeInfo<{}, {}>'.format(self._key_type_info, self._value_type_info)
 
 
+class LocalTimeTypeInfo(TypeInformation):
+
+    class TimeType(Enum):
+        LOCAL_DATE = 0
+        LOCAL_TIME = 1
+        LOCAL_DATE_TIME = 2
+
+    def __init__(self, time_type: TimeType):
+        super(LocalTimeTypeInfo, self).__init__()
+        self._time_type = time_type
+        self._j_typeinfo = None
+
+    def get_java_type_info(self) -> JavaObject:
+        if self._j_typeinfo is None:
+            jvm = get_gateway().jvm
+            if self._time_type == LocalTimeTypeInfo.TimeType.LOCAL_DATE:
+                self._j_typeinfo = \
+                    jvm.org.apache.flink.api.common.typeinfo.LocalTimeTypeInfo.LOCAL_DATE
+            elif self._time_type == LocalTimeTypeInfo.TimeType.LOCAL_TIME:
+                self._j_typeinfo = \
+                    jvm.org.apache.flink.api.common.typeinfo.LocalTimeTypeInfo.LOCAL_TIME
+            if self._time_type == LocalTimeTypeInfo.TimeType.LOCAL_DATE_TIME:

Review Comment:
   And raise an Exception when `self._time_type` is not a expected type



##########
flink-python/pyflink/common/typeinfo.py:
##########
@@ -720,6 +720,39 @@ def __repr__(self) -> str:
         return 'MapTypeInfo<{}, {}>'.format(self._key_type_info, self._value_type_info)
 
 
+class LocalTimeTypeInfo(TypeInformation):
+
+    class TimeType(Enum):
+        LOCAL_DATE = 0
+        LOCAL_TIME = 1
+        LOCAL_DATE_TIME = 2
+
+    def __init__(self, time_type: TimeType):
+        super(LocalTimeTypeInfo, self).__init__()
+        self._time_type = time_type
+        self._j_typeinfo = None

Review Comment:
   We have set `self._j_typeinfo = None` in the base class `TypeInformation`, so we can remove this line



##########
flink-python/pyflink/common/typeinfo.py:
##########
@@ -720,6 +720,39 @@ def __repr__(self) -> str:
         return 'MapTypeInfo<{}, {}>'.format(self._key_type_info, self._value_type_info)
 
 
+class LocalTimeTypeInfo(TypeInformation):
+
+    class TimeType(Enum):
+        LOCAL_DATE = 0
+        LOCAL_TIME = 1
+        LOCAL_DATE_TIME = 2
+
+    def __init__(self, time_type: TimeType):
+        super(LocalTimeTypeInfo, self).__init__()
+        self._time_type = time_type
+        self._j_typeinfo = None
+
+    def get_java_type_info(self) -> JavaObject:
+        if self._j_typeinfo is None:
+            jvm = get_gateway().jvm
+            if self._time_type == LocalTimeTypeInfo.TimeType.LOCAL_DATE:
+                self._j_typeinfo = \
+                    jvm.org.apache.flink.api.common.typeinfo.LocalTimeTypeInfo.LOCAL_DATE
+            elif self._time_type == LocalTimeTypeInfo.TimeType.LOCAL_TIME:
+                self._j_typeinfo = \
+                    jvm.org.apache.flink.api.common.typeinfo.LocalTimeTypeInfo.LOCAL_TIME
+            if self._time_type == LocalTimeTypeInfo.TimeType.LOCAL_DATE_TIME:

Review Comment:
   ```suggestion
               eif self._time_type == LocalTimeTypeInfo.TimeType.LOCAL_DATE_TIME:
   ```



-- 
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.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org