Skip to content

Enforcing procedure name args only#10545

Merged
kokosing merged 2 commits intotrinodb:masterfrom
aczajkowski:acz/enforcing_procedure_name_args_only
Sep 23, 2022
Merged

Enforcing procedure name args only#10545
kokosing merged 2 commits intotrinodb:masterfrom
aczajkowski:acz/enforcing_procedure_name_args_only

Conversation

@aczajkowski
Copy link
Copy Markdown
Member

@aczajkowski aczajkowski commented Jan 11, 2022

Enforcing using named arguments when calling procedure

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe this is a departure from the SQL spec, but I'd need to check the document.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok Thx, let me know can we proceed with that. This is limiting spec, but i think in resonable way within its boundries.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the motivation for this? Why would we ever need it?

Copy link
Copy Markdown
Member Author

@aczajkowski aczajkowski Jan 15, 2022

Choose a reason for hiding this comment

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

In case when we have all arguments optional and logic is dependent on set non-required arguments.
This would not cause backward compatibility issues if we will ever decide some new argument is added or required. Only documentation would need to be update.

Perfect example is current flush_metadata_cache procedure.
For now we allow below use cases

USE example_catalog.some_schema;

# Clear all caches in catalog 'example_catalog' for all schema
system.flush_metadata_cache(); 

# Clear all caches for specific partition 'partition_column=partition_value'
# in table 'example_catalog.example_schema.example_table'
system.flush_metadata_cache(
  schema_name => 'example_schema',
  table_name => 'example_table',
  partition_columns => ARRAY['partition_column'],
  partition_values => ARRAY['partition_value']
);

But at some point we might extend scope to

USE example_catalog.some_schema;

# Clear all caches for specific schema 'example_catalog.example_schema'
system.flush_metadata_cache(
  schema_name => 'example_schema'
);

# Clear all caches for specific table 'example_catalog.example_schema.example_table'
system.flush_metadata_cache(
  schema_name => 'example_schema',
  table_name => 'example_table'
);

Maybe even other use cases which are hard to predict at the moment.

CC: @findepi

@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch from 82016c9 to d22613a Compare January 13, 2022 11:41
@aczajkowski aczajkowski requested a review from martint January 13, 2022 11:44
@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch 2 times, most recently from 2633e67 to a7aa8bc Compare January 15, 2022 13:56
@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch from a7aa8bc to 5a309c1 Compare January 17, 2022 10:44
@aczajkowski aczajkowski requested a review from electrum January 17, 2022 13:59
@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch from 1645d56 to 15f3170 Compare January 17, 2022 20:42
@aczajkowski
Copy link
Copy Markdown
Member Author

@martint @electrum applied requested changes + added background on this change motivation.
Let me know if this is ok to proceed ?

@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch from 15f3170 to c05afbd Compare January 24, 2022 17:46
@aczajkowski
Copy link
Copy Markdown
Member Author

@martint @electrum Rebased on top of master due to conflicts.

@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch from c05afbd to 0cebc5d Compare March 21, 2022 14:51
@aczajkowski
Copy link
Copy Markdown
Member Author

@martint is there any update on this. Should i close this PR ?

@losipiuk
Copy link
Copy Markdown
Member

@martint is there any update on this. Should i close this PR ?

@martint bump

@aczajkowski
Copy link
Copy Markdown
Member Author

@martint is there any update on this. Should i close this PR ?

@martint bump

@martint any update around your concern here #10545 (comment)

@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch from 0cebc5d to 0130296 Compare September 20, 2022 15:21
@aczajkowski
Copy link
Copy Markdown
Member Author

@martint @electrum @losipiuk bump

@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch 2 times, most recently from ce40322 to f67cb85 Compare September 21, 2022 13:10
Copy link
Copy Markdown
Contributor

@ksobolew ksobolew left a comment

Choose a reason for hiding this comment

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

I like it. As @martint says it may be deviating from the SQL spec, but it makes sense in certain situations. In fact, there are entire languages which don't have positional arguments, only named ones.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wow, that was a clever workaround. Glad that it's gone :D

@aczajkowski
Copy link
Copy Markdown
Member Author

I like it. As @martint says it may be deviating from the SQL spec, but it makes sense in certain situations. In fact, there are entire languages which don't have positional arguments, only named ones.

Also we are not disallowing using positional arguments at all. It's just one procedure definition that disallows it's usage.
So our spec is compatible but in some cases we just limit it for a specific use case.

@kokosing
Copy link
Copy Markdown
Member

It's just one procedure definition that disallows it's usage.

From what I see the given procedure was already like that, it already required named arguments. We just remove hack and have dedicated support for such procedures.

@martint let me know if you have any more comments, otherwise I would like to merge it

Copy link
Copy Markdown
Member

@martint martint left a comment

Choose a reason for hiding this comment

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

One minor comment. Otherwise it looks good, and I'm ok with the change.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rename to requiresNamedArguments

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied.

@aczajkowski aczajkowski force-pushed the acz/enforcing_procedure_name_args_only branch 2 times, most recently from 376f2b0 to 4c1cc99 Compare September 23, 2022 09:30
@kokosing kokosing merged commit 5450325 into trinodb:master Sep 23, 2022
@kokosing
Copy link
Copy Markdown
Member

Merged, thanks!

@github-actions github-actions bot added this to the 398 milestone Sep 23, 2022
@aczajkowski aczajkowski deleted the acz/enforcing_procedure_name_args_only branch September 23, 2022 12:55
@colebow
Copy link
Copy Markdown
Member

colebow commented Sep 27, 2022

Hey, do we think this needs a release note, or is it just better and more clear error handling?

cc @kokosing

@aczajkowski
Copy link
Copy Markdown
Member Author

@colebow my opinion is that is just internal mechanics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

8 participants