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

Support for NOT NULL column constraints #22064

Merged

Conversation

ClarenceThreepwood
Copy link
Contributor

@ClarenceThreepwood ClarenceThreepwood commented Mar 2, 2024

Follow up to #20384

Adds support for NOT NULL column constraints in the create table statement (for the Hive connector)
Adds support for ALTER TABLE ALTER COLUMN set/drop NOT NULL

== RELEASE NOTES ==
General Changes

  • Add framework to add and drop not null column constraints

Hive Connector Changes

  • Add support for not null constraints for tables in the Hive Metastore. Other systems that support table constraints may extend this framework in their respective connectors to add support.

@ClarenceThreepwood ClarenceThreepwood force-pushed the inlinecolumnconstraints branch 3 times, most recently from e1ad2e5 to 626e051 Compare March 5, 2024 22:49
@ClarenceThreepwood ClarenceThreepwood force-pushed the inlinecolumnconstraints branch 8 times, most recently from a3c6f0e to 532038d Compare April 2, 2024 05:36
@ClarenceThreepwood ClarenceThreepwood changed the title Inline column constraints Support for NOT NULL column constraints Apr 2, 2024
@ClarenceThreepwood ClarenceThreepwood marked this pull request as ready for review April 2, 2024 05:40
Copy link

github-actions bot commented Apr 2, 2024

Codenotify: Notifying subscribers in CODENOTIFY files for diff be20d29...79dc2b8.

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
@steveburnett presto-docs/src/main/sphinx/sql/alter-table.rst
presto-docs/src/main/sphinx/sql/create-table.rst

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.

Thanks for the docs! Looks good: a few nits, nothing else.

presto-docs/src/main/sphinx/sql/alter-table.rst Outdated Show resolved Hide resolved
presto-docs/src/main/sphinx/sql/alter-table.rst Outdated Show resolved Hide resolved
presto-docs/src/main/sphinx/sql/create-table.rst Outdated Show resolved Hide resolved
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.

Thanks for the update! Found one final nit on formatting.

presto-docs/src/main/sphinx/sql/alter-table.rst Outdated Show resolved Hide resolved
steveburnett
steveburnett previously approved these changes Apr 2, 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 updated branch, new local build, no concerns. Thanks for the quick revisions!

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.

Just a few questions on the API and the grammar

aaneja
aaneja previously approved these changes Apr 22, 2024
ZacBlanco
ZacBlanco previously approved these changes Apr 24, 2024
Copy link
Contributor

@tdcmeehan tdcmeehan 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

.filter(constraint -> constraint instanceof PrimaryKeyConstraint)
.collect(toList());

constraints.addAll(rawConstraints.stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

For this method, should we just use imperative code and populate various builders? I'm wondering if we should throw an error if we encounter a constraint which is not among the subclasses of TableConstraint (to prevent future errors).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a validate method to TableConstraintsHolder to perform this check in one place

Copy link
Contributor

@rschlussel rschlussel left a comment

Choose a reason for hiding this comment

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

I have a concern about the alter column support. NOT NULL constraints are being treated differently (with different syntax) compared to all other constraints, but I think we should be consistent across all our constraints.

nit: noticed some of your commit titles are too long.

@ClarenceThreepwood ClarenceThreepwood dismissed stale reviews from ZacBlanco and aaneja via bd8b3ef May 3, 2024 04:23
@ClarenceThreepwood ClarenceThreepwood force-pushed the inlinecolumnconstraints branch 3 times, most recently from 73f5696 to 0ac7b9b Compare May 3, 2024 05:00
@ClarenceThreepwood
Copy link
Contributor Author

Thanks @rschlussel. I've also pushed the final change you suggested

@ClarenceThreepwood ClarenceThreepwood merged commit 12a6e44 into prestodb:master May 6, 2024
57 checks passed
@ClarenceThreepwood ClarenceThreepwood deleted the inlinecolumnconstraints branch May 6, 2024 17:20
@wanglinsong wanglinsong mentioned this pull request Jun 25, 2024
36 tasks
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