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

Add support for new Flink table creation API #277

Merged

Conversation

jjaakola-aiven
Copy link
Contributor

@jjaakola-aiven jjaakola-aiven commented Mar 4, 2022

About this change: What it does, why it matters

This PR adds the support of new table creation API for Aiven for Apache Flink service.
Command line has new parameter --table-properties which takes a JSON string or a path to JSON file.

Old API is removed.

@jjaakola-aiven jjaakola-aiven requested a review from a team as a code owner March 4, 2022 08:49
Copy link
Contributor

@juha-aiven juha-aiven left a comment

Choose a reason for hiding this comment

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

make validate-style is failing.

Why not remove the old API?

@jjaakola-aiven
Copy link
Contributor Author

jjaakola-aiven commented Mar 4, 2022

make validate-style is failing.

Fails in code that is not touched. I'll add a cleanup commit.

Why not remove the old API?

Later PR, this is for having the support for the new API.

@jjaakola-aiven jjaakola-aiven force-pushed the jjaakola-aiven-add-new-flink-table-creation-api-support branch from 2cdf74b to a99d7ea Compare March 4, 2022 09:14
Copy link
Contributor

@juha-aiven juha-aiven left a comment

Choose a reason for hiding this comment

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

Left few comments.


@wraps(fun)
def wrapped(self):
sanitized_param_name = param_name.replace("--", "").replace("-", "_")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this replace("-", "_") needed? For example if the param name in the request is schema_sql, is the idea here that schema-sql gets converted into schema_sql? Why wouldn't the caller have schema_sql in the first place. That's the name of the parameter that can be seen in the API docs.

What I think that could be the idea is that before this PR the switch to use is --schema-sql and thus it's kind of logical to support schema-sql in the JSON.

But I don't this should be done, since the name of the parameter in the API is not schema-sql.

And why replace("--", "")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The - to _ is replaced as it will be the name of the member in the self.args.

The replace for -- is the same as in the user_config_json but with different flavor as the parameter name is known there. In here the parameter name is not known and sanitazion is done programmatically.
See here:

setattr(
self.args,
"user_config_json",
get_json_config(self.args.user_config_json),

What could be done is to move the logic when calling arg on line 50. Or change have specialized function for --table-properties like what is done with --user-config-json.

)
@arg("-s", "--schema-sql", required=True, help="Source/Sink table schema")
@arg("-s", "--schema-sql", required=False, help="Source/Sink table schema (deprecated)")
@arg.json_path_or_string_parameter("--table-properties")
Copy link
Contributor

Choose a reason for hiding this comment

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

Mo hint of the format for the JSON? Should there be - it's pretty complex.

And no client side validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing apart of valid JSON check.

@jjaakola-aiven jjaakola-aiven force-pushed the jjaakola-aiven-add-new-flink-table-creation-api-support branch 6 times, most recently from 15f8430 to 0f6977b Compare March 17, 2022 12:27
@jjaakola-aiven jjaakola-aiven dismissed juha-aiven’s stale review March 17, 2022 12:31

Removed deprecated API

juha-aiven
juha-aiven previously approved these changes Mar 18, 2022
Copy link
Contributor

@juha-aiven juha-aiven left a comment

Choose a reason for hiding this comment

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

LGTM

rominf
rominf previously requested changes Mar 18, 2022
aiven/client/client.py Outdated Show resolved Hide resolved
@jjaakola-aiven jjaakola-aiven force-pushed the jjaakola-aiven-add-new-flink-table-creation-api-support branch from 782c809 to 8bceb92 Compare March 21, 2022 15:43
Copy link
Contributor

@juha-aiven juha-aiven left a comment

Choose a reason for hiding this comment

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

Looks good.

This is a breaking change in the sense that existing functionality is removed - "Old API". This needs to be mentioned in the release notes.

@juha-aiven juha-aiven merged commit 371f5ea into main Apr 25, 2022
@juha-aiven juha-aiven deleted the jjaakola-aiven-add-new-flink-table-creation-api-support branch April 25, 2022 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants