sunjincheng121 commented on a change in pull request #8420:
[FLINK-12408][python] Allow to define the data types in Python
URL: https://github.com/apache/flink/pull/8420#discussion_r286752931
##########
File path: flink-python/pyflink/table/types.py
##########
@@ -16,171 +16,1811 @@
# limitations under the License.
################################################################################
+import calendar
+import ctypes
+import datetime
+import decimal
import sys
+import time
+from array import array
+from copy import copy
+from functools import reduce
+from threading import RLock
-if sys.version > '3':
- xrange = range
+from pyflink.util.utils import to_jarray
+from pyflink.java_gateway import get_gateway
-__all__ = ['DataTypes']
+if sys.version >= '3':
+ long = int
+ basestring = unicode = str
+
+__all__ = ['DataTypes', 'UserDefinedType', 'Row']
class DataType(object):
"""
Base class for data types.
+
+ :param nullable: boolean, whether the type can be null (None) or not.
"""
- @classmethod
- def type_name(cls):
- return cls.__name__[:-4].lower()
+
+ def __init__(self, nullable=True):
+ self.nullable = nullable
+ self.conversion_cls = ''
+
+ def __repr__(self):
+ return '%s(%s)' % (self.__class__.__name__, str(self.nullable).lower())
Review comment:
Can we add ` def __str__(self, *args, **kwargs)` as well?
----------------------------------------------------------------
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