SteNicholas commented on a change in pull request #13491:
URL: https://github.com/apache/flink/pull/13491#discussion_r495566680
##########
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:
@dianfu @HuangXingBo OK, I will modify this return value as you
mentioned.
----------------------------------------------------------------
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]