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 ALTER TABLE SET PROPERTIES statement #21495

Merged

Conversation

pratyakshsharma
Copy link
Contributor

@pratyakshsharma pratyakshsharma commented Dec 7, 2023

Cherry-pick of trinodb/trino#9401

Co-authored-by: ebyhr

Motivation and Context

Setting table properties can help in modifying critical table properties such as the one which controls concurrency behaviour for an iceberg table.

Impact

ALTER TABLE ... SET PROPERTIES

Test Plan

Manual testing
Unit testing

Contributor checklist

  • Please make sure your submission complies with our development, formatting, commit message, and attribution guidelines.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== RELEASE NOTES ==

General Changes
* Add :doc:`/sql/alter-table` SET PROPERTIES statement :pr:`21495`

Copy link

github-actions bot commented Dec 7, 2023

Codenotify: Notifying subscribers in CODENOTIFY files for diff ba2f731...4f826af.

Notify File(s)
@aditi-pandit presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4
@elharo presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4
@kaikalur presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4
@rschlussel presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4

@Akanksha-kedia
Copy link
Contributor

Akanksha-kedia commented Dec 7, 2023

single commit per PR and Can you update with [WIP] or draft if few changes are yet to be done.

I wanted to understand how existing properties are going to handled, can we add random values to existing properties? and also if we have alter table set properties, why not having alter schema/database and also as its taking random key = value wat value its adding and use case to it.

Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

@pratyakshsharma pratyakshsharma marked this pull request as draft December 7, 2023 18:28
@pratyakshsharma pratyakshsharma marked this pull request as ready for review December 25, 2023 18:04
@pratyakshsharma
Copy link
Contributor Author

pratyakshsharma commented Dec 25, 2023

@Akanksha-kedia

There are 2 separate cherry-picks which serve different purposes, hence 2 different commits.
I think verifications related to existing properties and what key value pairs are going to be set can be handled at connector level. Different table formats can have different key for possible table properties.
I am adding this syntax support because ALTER TABLE SET PROPERTIES is currently needed for iceberg to solve concurrency related issues. You can refer this for more details - #21251

@pratyakshsharma pratyakshsharma force-pushed the alter-tbl-properties-support branch 2 times, most recently from 577174d to 4d21e4b Compare December 25, 2023 19:54
@pratyakshsharma
Copy link
Contributor Author

This is ready for review now @yingsu00 @imjalpreet @agrawalreetika

@pratyakshsharma
Copy link
Contributor Author

After the recent push, build is failing. Working on this.

@pratyakshsharma
Copy link
Contributor Author

This is ready to be reviewed.

Map<String, Expression> sqlPropertyValues,
Session session,
Metadata metadata,
Map<NodeRef<Parameter>, Expression> parameters)
Copy link
Member

Choose a reason for hiding this comment

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

I see the boolean parameter setDefaultProperties missed here, which was introduced in trino commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not understand the use case of introducing that parameter, and hence skipped it.

ClickHouseTableHandle tableHandle = (ClickHouseTableHandle) table;
clickHouseClient.setTableProperties(ClickHouseIdentity.from(session), tableHandle, properties);
}

Copy link
Member

@agrawalreetika agrawalreetika Jan 3, 2024

Choose a reason for hiding this comment

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

Add Override annotation here.
Can we add some tests to test the feature support in the connector?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clickhouse server is spawned using docker in presto tests. I skipped the test on purpose as I am not sure how do I test it. cc @yingsu00

@agrawalreetika
Copy link
Member

@pratyakshsharma Should we include ALTER TABLE SET PROPERTIES support commit in this PR itself? WDYT

@pratyakshsharma pratyakshsharma force-pushed the alter-tbl-properties-support branch 3 times, most recently from 235c533 to 3853b50 Compare January 6, 2024 13:20
@pratyakshsharma
Copy link
Contributor Author

The test failures are related to the code changes from #21250. Once it gets merged into master, the failures should resolve

steveburnett
steveburnett previously approved these changes Feb 9, 2024
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

New review prompted by changes to https://github.com/prestodb/presto/blob/master/presto-docs/src/main/sphinx/sql/alter-table.rst. Pulled branch, new local build of docs, looks good. Thanks!

@pratyakshsharma
Copy link
Contributor Author

pratyakshsharma commented Feb 12, 2024

I see clickhouse tests are disabled in the pom.xml here -

<include>**/TestClickHouseDistributedQueries.java</include>
.
So should I still proceed with adding the clickhouse tests in this PR? @agrawalreetika @yingsu00

As per this comment - #21894 (comment), it looks like the existing tests are failing as well

@pratyakshsharma pratyakshsharma force-pushed the alter-tbl-properties-support branch 3 times, most recently from 5517bd7 to 7b234e9 Compare February 14, 2024 12:58
steveburnett
steveburnett previously approved these changes Sep 26, 2024
Copy link
Contributor

@steveburnett steveburnett left a comment

Choose a reason for hiding this comment

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

LGTM! (docs)

Pull branch, local doc build. Thanks!

@steveburnett
Copy link
Contributor

Nit to add PR number to release note entry.
Also suggest add a link to the ALTER TABLE documentation. I tested this link example in a local doc build.

== RELEASE NOTES ==

General Changes
* Add :doc:`/sql/alter-table` SET PROPERTIES statement :pr:`21495`

@pratyakshsharma
Copy link
Contributor Author

@yingsu00 this is good to take a pass.

@pratyakshsharma
Copy link
Contributor Author

Updated release notes, thank you @steveburnett

Copy link
Member

@agrawalreetika agrawalreetika left a comment

Choose a reason for hiding this comment

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

Overall looks good to me.
Left few commetns around adding tests, please check

@pratyakshsharma
Copy link
Contributor Author

@agrawalreetika @yingsu00 this is good for another pass

@pratyakshsharma pratyakshsharma force-pushed the alter-tbl-properties-support branch 2 times, most recently from 0831752 to deaa9e8 Compare November 13, 2024 07:22
agrawalreetika
agrawalreetika previously approved these changes Nov 13, 2024
Copy link
Member

@agrawalreetika agrawalreetika left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@hantangwangd hantangwangd left a comment

Choose a reason for hiding this comment

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

Thanks for this work, overall looks good to me! Some nits and little things.

Copy link
Contributor

@ZacBlanco ZacBlanco left a comment

Choose a reason for hiding this comment

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

Mostly nits. Otherwise LGTM. One question though - is there any way to "unset" a table property through this in order to take up the default value instead? Or would a user have to manually look up the default value and set it?

@pratyakshsharma
Copy link
Contributor Author

@ZacBlanco Currently there is no way to unset other than setting the default value manually.

@pratyakshsharma
Copy link
Contributor Author

@hantangwangd @ZacBlanco @yingsu00 this is good for another pass.

Copy link
Member

@hantangwangd hantangwangd left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, lgtm!

@yingsu00 yingsu00 merged commit b19167e into prestodb:master Nov 22, 2024
58 checks passed
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.

7 participants