Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-19417][python] Fix the bug of the method from_data_stream in table_environement #13491

Closed
wants to merge 3 commits into from
Closed

Conversation

SteNicholas
Copy link
Member

@SteNicholas SteNicholas commented Sep 27, 2020

What is the purpose of the change

The parameter of method from_data_stream in StreamTableEnvironment fields should be str or expression, not the current list [str]. And the table_env object passed to the Table object should be Python's TableEnvironment, not Java's TableEnvironment.

Brief change log

  • Modify the parameter type of method from_data_stream in StreamTableEnvironment fields to str or expression .

Verifying this change

  • Add the test case in test_from_data_stream in TableEnvironmentTest for the case that verifies the creation of data stream by from_data_stream with expression.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 27, 2020

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit f998eec (Fri Feb 19 07:28:29 UTC 2021)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Sep 27, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

Copy link
Contributor

@HuangXingBo HuangXingBo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SteNicholas Thanks a lot for the fix. Good Work. I only left a minor comments.

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])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding a warn to tell the user that this method has been deprecated

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HuangXingBo Yes, I would like to add warn log to tell users with this deprecated method.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about raising an Exception to tell the user that the parameter is wrong, instead of returning a None Table

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @HuangXingBo, could refer to Table.select as an example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dianfu @HuangXingBo OK, I will modify this return value as you mentioned.

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about all(isinstance(f, Expression) for f in fields)

[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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use to_expression_jarray

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @HuangXingBo, could refer to Table.select as an example.

@SteNicholas
Copy link
Member Author

@HuangXingBo @dianfu I have already followed up with your comments. Please review this again.

@dianfu
Copy link
Contributor

dianfu commented Sep 28, 2020

@SteNicholas Thanks for the update. LGTM. There are check style issues. Could you take a look at?

@HuangXingBo
Copy link
Contributor

@SteNicholas Thanks a lot for the update. LGTM.

@dianfu dianfu closed this in 900071b Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants