dianfu commented on a change in pull request #13278:
URL: https://github.com/apache/flink/pull/13278#discussion_r481549748



##########
File path: flink-python/pyflink/table/expressions.py
##########
@@ -0,0 +1,535 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+from typing import Union
+
+from pyflink import add_version_doc
+from pyflink.java_gateway import get_gateway
+from pyflink.table.expression import Expression, _get_java_expression, 
TimePointUnit
+from pyflink.table.types import _to_java_data_type, DataType
+from pyflink.table.udf import UserDefinedFunctionWrapper
+from pyflink.util.utils import to_jarray
+
+
+__all__ = ['if_then_else', 'lit', 'col', 'range_', 'and_', 'or_', 
'UNBOUNDED_ROW',
+           'UNBOUNDED_RANGE', 'CURRENT_ROW', 'CURRENT_RANGE', 'current_date', 
'current_time',
+           'current_timestamp', 'local_time', 'local_timestamp', 
'temporal_overlaps',
+           'date_format', 'timestamp_diff', 'array', 'row', 'map_', 
'row_interval', 'pi', 'e',
+           'rand', 'rand_integer', 'atan2', 'negative', 'concat', 'concat_ws', 
'uuid', 'null_of',
+           'log', 'with_columns', 'without_columns', 'call']
+
+
+def _leaf_op(op_name: str):
+    gateway = get_gateway()
+    return Expression(getattr(gateway.jvm.Expressions, op_name)())
+
+
+def _unary_op(op_name: str, arg):
+    gateway = get_gateway()
+    return Expression(getattr(gateway.jvm.Expressions, 
op_name)(_get_java_expression(arg)))
+
+
+def _binary_op(op_name: str, first, second):
+    gateway = get_gateway()
+    return Expression(getattr(gateway.jvm.Expressions, op_name)(
+        _get_java_expression(first),
+        _get_java_expression(second)))
+
+
+def _ternary_op(op_name: str, first, second, third):
+    gateway = get_gateway()
+    return Expression(getattr(gateway.jvm.Expressions, op_name)(
+        _get_java_expression(first),
+        _get_java_expression(second),
+        _get_java_expression(third)))
+
+
+def _quaternion_op(op_name: str, first, second, third, forth):
+    gateway = get_gateway()
+    return Expression(getattr(gateway.jvm.Expressions, op_name)(
+        _get_java_expression(first),
+        _get_java_expression(second),
+        _get_java_expression(third),
+        _get_java_expression(forth)))
+
+
+def _add_version_doc():
+    from inspect import getmembers, isfunction
+    from pyflink.table import expressions
+    for o in getmembers(expressions):
+        if isfunction(o[1]) and not o[0].startswith('_'):
+            add_version_doc(o[1], "1.12.0")
+
+
+def col(name: str):
+    """
+    Creates an expression which refers to a table's field.
+
+    Example:
+    ::
+
+        >>> tab.select(col("key"), col("value"))
+
+    :param name: the field name to refer to
+    """
+    return _unary_op("$", name)
+
+
+def lit(v, data_type: DataType = None):

Review comment:
       Good suggestion. I have created a separate JIRA to track this: 
https://issues.apache.org/jira/browse/FLINK-19116




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


Reply via email to