HuangXingBo commented on a change in pull request #13491:
URL: https://github.com/apache/flink/pull/13491#discussion_r495563743
##########
File path: flink-python/pyflink/table/table_environment.py
##########
@@ -1770,11 +1771,19 @@ def from_data_stream(self, data_stream: DataStream,
fields: List[str] = None) ->
of the Table
:return: The converted Table.
"""
- if fields is not None:
- j_table = self._j_tenv.fromDataStream(data_stream._j_data_stream,
fields)
- else:
+ j_table = None
+ if len(fields) == 0:
j_table = self._j_tenv.fromDataStream(data_stream._j_data_stream)
- return Table(j_table=j_table, t_env=self._j_tenv)
+ elif len(fields) == 1 and isinstance(fields[0], str):
+ j_table = self._j_tenv.fromDataStream(data_stream._j_data_stream,
fields[0])
+ elif len(fields) > 0 and \
+ [isinstance(f, Expression) for f in fields] == [True] *
len(fields):
+ gateway = get_gateway()
+ j_table = self._j_tenv.fromDataStream(data_stream._j_data_stream,
+
to_jarray(gateway.jvm.Expression,
+
[_get_java_expression(f)
+ for f in fields]))
+ return None if j_table is None else Table(j_table=j_table, t_env=self)
Review comment:
What about raising an Exception to tell the user that the parameter is
wrong, instead of returning a None Table
##########
File path: flink-python/pyflink/table/table_environment.py
##########
@@ -1770,11 +1771,19 @@ def from_data_stream(self, data_stream: DataStream,
fields: List[str] = None) ->
of the Table
:return: The converted Table.
"""
- if fields is not None:
- j_table = self._j_tenv.fromDataStream(data_stream._j_data_stream,
fields)
- else:
+ j_table = None
+ if len(fields) == 0:
j_table = self._j_tenv.fromDataStream(data_stream._j_data_stream)
- return Table(j_table=j_table, t_env=self._j_tenv)
+ elif len(fields) == 1 and isinstance(fields[0], str):
+ j_table = self._j_tenv.fromDataStream(data_stream._j_data_stream,
fields[0])
Review comment:
What about adding a warn to tell the user that this method has been
deprecated
----------------------------------------------------------------
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]