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-23115][python] Expose new APIs about TableDescriptor in PyFlink #16516

Closed
wants to merge 7 commits into from

Conversation

HuangXingBo
Copy link
Contributor

What is the purpose of the change

This pull request will expose new APIs about TableDescriptor in PyFlink

Brief change log

  • Add ConfigOptions/TableDescriptor/FormatDescriptor/Schema
  • Expose create_table/create_temporary_table/from_descriptor of TableEnvironment
  • Expose Table#execute_insert and StatementSet#add_insert in Python Table API

Verifying this change

This change added tests and can be verified as follows:

  • test_schema.py , test_table_descriptor.py, test_table_environment_api.py

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

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

Documentation

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

@flinkbot
Copy link
Collaborator

flinkbot commented Jul 16, 2021

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 59da1ae (Thu Sep 23 18:07:16 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 Jul 16, 2021

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

@Airblader Airblader left a comment

Choose a reason for hiding this comment

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

Thank you @HuangXingBo for taking on this issue, I appreciate it. Will someone from your team review it? I'm not too familiar with PyFlink, but if needed I can also review this. Just let me know. Thanks!

@@ -733,9 +734,22 @@ def get_schema(self) -> TableSchema:
Get the schema of the table.

:return: Schema of the table/view.

. note:: Deprecated in 1.14. This method returns the deprecated ableSchema class. The old
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing "T" in TableSchema"

class ConfigOptions(object):
"""
{@code ConfigOptions} are used to build a :class:`~pyflink.table.ConfigOption`. The option is
typically built in one of the following pattern:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "pattern" → "patterns"

@HuangXingBo
Copy link
Contributor Author

Thanks @Airblader for the review. @dianfu is familiar with PyFlink and he will help review this PR too.

Copy link
Contributor

@dianfu dianfu left a comment

Choose a reason for hiding this comment

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

@HuangXingBo Thanks for the PR! Have left a few minor comments. Besides, is there any documentation needs to be updated?


class ConfigOptions(object):
"""
{@code ConfigOptions} are used to build a :class:`~pyflink.table.ConfigOption`. The option is
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{@code ConfigOptions} are used to build a :class:`~pyflink.table.ConfigOption`. The option is
{@code ConfigOptions} are used to build a :class:`~pyflink.common.ConfigOption`. The option is


T = TypeVar('T')

__all__ = ['ConfigOptions', 'ConfigOption']
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 also adding it in init.py? otherwise, I'm afraid that it will not appear in the Python doc

from pyflink.table.types import DataType, _to_java_data_type
from pyflink.util.java_utils import to_jarray

__all__ = ['Schema']
Copy link
Contributor

Choose a reason for hiding this comment

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

also added in init.py?

"""
Adopts all members from the given unresolved schema.
"""
self._j_builder.fromSchema(unresolved_schema)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self._j_builder.fromSchema(unresolved_schema)
self._j_builder.fromSchema(unresolved_schema._j_schema)

"""
Adopts all fields of the given row as physical columns of the schema.
"""
self._j_builder.fromRowDataType(data_type)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to improve the test case to also cover this method

Examples:
::

>>>stmt_set = table_env.create_statement_set()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
>>>stmt_set = table_env.create_statement_set()
>>> stmt_set = table_env.create_statement_set()

@HuangXingBo
Copy link
Contributor Author

@dianfu Thanks a lot for the review. I have addressed the comments at the corresponding commits. About the documentation part, I plan to add the content after the java doc has been updated in https://issues.apache.org/jira/browse/FLINK-23116

Copy link
Contributor

@dianfu dianfu left a comment

Choose a reason for hiding this comment

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

LGTM. Just two minor comments and +1 from my side.

"""
Defines that the value of the option should be of float type
(4-byte single precision floating point number).
:return:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
:return:

def add_insert(self, target_path: str, table, overwrite: bool = False) -> 'StatementSet':
def add_insert(self,
target_path_or_descriptor: Union[str, TableDescriptor],
table,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
table,
table: Table,

HuangXingBo added a commit that referenced this pull request Jul 20, 2021
…_descriptor of TableEnvironment in Python Table API

This closes #16516.
HuangXingBo added a commit that referenced this pull request Jul 20, 2021
srinipunuru pushed a commit to srinipunuru/flink that referenced this pull request Jul 21, 2021
srinipunuru pushed a commit to srinipunuru/flink that referenced this pull request Jul 21, 2021
…_descriptor of TableEnvironment in Python Table API

This closes apache#16516.
srinipunuru pushed a commit to srinipunuru/flink that referenced this pull request Jul 21, 2021
hhkkxxx133 pushed a commit to hhkkxxx133/flink that referenced this pull request Aug 25, 2021
hhkkxxx133 pushed a commit to hhkkxxx133/flink that referenced this pull request Aug 25, 2021
…_descriptor of TableEnvironment in Python Table API

This closes apache#16516.
hhkkxxx133 pushed a commit to hhkkxxx133/flink that referenced this pull request Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants