hequn8128 commented on a change in pull request #10086: [FLINK-14584][python]
Support complex data types in Python user-defined functions
URL: https://github.com/apache/flink/pull/10086#discussion_r354655595
##########
File path: flink-python/pyflink/table/tests/test_udf.py
##########
@@ -352,18 +376,42 @@ def date_func(date_param):
self.t_env.register_function(
"date_func", udf(date_func, [DataTypes.DATE()], DataTypes.DATE()))
+ self.t_env.register_function(
+ "array_func", udf(array_func,
[DataTypes.ARRAY(DataTypes.BIGINT())],
+ DataTypes.ARRAY(DataTypes.BIGINT())))
+
+ self.t_env.register_function(
+ "map_func", udf(map_func, [DataTypes.MAP(DataTypes.BIGINT(),
DataTypes.STRING())],
+ DataTypes.MAP(DataTypes.BIGINT(),
DataTypes.STRING())))
+
+ self.t_env.register_function(
+ "create_multiset_func", udf(
+ create_multiset_func, [],
DataTypes.MULTISET(DataTypes.BIGINT())))
+
+ self.t_env.register_function(
+ "multiset_func", udf(multiset_func,
[DataTypes.MULTISET(DataTypes.BIGINT())],
+ DataTypes.MULTISET(DataTypes.BIGINT())))
+
+ self.t_env.register_function(
+ "decimal_func", udf(decimal_func, [DataTypes.DECIMAL(38, 18)],
+ DataTypes.DECIMAL(38, 18)))
+
table_sink = source_sink_utils.TestAppendSink(
- ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],
+ ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o'],
[DataTypes.BIGINT(), DataTypes.BIGINT(), DataTypes.TINYINT(),
DataTypes.BOOLEAN(), DataTypes.SMALLINT(), DataTypes.INT(),
DataTypes.FLOAT(), DataTypes.DOUBLE(), DataTypes.BYTES(),
- DataTypes.STRING(), DataTypes.DATE()])
+ DataTypes.STRING(), DataTypes.DATE(),
DataTypes.ARRAY(DataTypes.BIGINT()),
+ DataTypes.MAP(DataTypes.BIGINT(), DataTypes.STRING()),
+ DataTypes.MULTISET(DataTypes.BIGINT()), DataTypes.DECIMAL(38,
18)])
self.t_env.register_table_sink("Results", table_sink)
import datetime
+ import decimal
t = self.t_env.from_elements(
[(1, None, 1, True, 32767, -2147483648, 1.23, 1.98932,
- bytearray(b'flink'), 'pyflink', datetime.date(2014, 9, 13))],
+ bytearray(b'flink'), 'pyflink', datetime.date(2014, 9, 13),
+ [1, 2, 3], {1: 'flink', 2: 'pyflink'},
decimal.Decimal('1000000000000000000.05'))],
Review comment:
Test decimal with (38,18)?
----------------------------------------------------------------
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