You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "LucaCappelletti94 (via GitHub)" <gi...@apache.org> on 2025/10/03 09:56:23 UTC

[PR] Moved constraint variant outside of `TableConstraint` enum [datafusion-sqlparser-rs]

LucaCappelletti94 opened a new pull request, #2054:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2054

   As per title, this PR moved all of the struct variants out of the `TableConstraint` enum. This is done to allow for implementing traits in dependent crates which only apply to some of the variants and not all of them.
   
   Furthermore it:
   
   - Implemented `Display` and `Spanned` for each of the new structs
   - Implemented `From<variant> for TableConstraint` for all variants
   - Documented the variants and updated tests
   
   This PR closes issue #2053
   
   Ciao,
   Luca


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Moved constraint variant outside of `TableConstraint` enum [datafusion-sqlparser-rs]

Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 commented on code in PR #2054:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2054#discussion_r2403807532


##########
src/ast/table_constraints/check_constraint.rs:
##########
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   Ok - should the table_constraints.rs file contain the `TableConstraint` enum itself?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Moved constraint variant outside of `TableConstraint` enum [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio commented on code in PR #2054:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2054#discussion_r2403806157


##########
src/ast/table_constraints/check_constraint.rs:
##########
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   I think we can use a single file `table_constraints.rs` to contain the new structs, vs having one struct per file. So that we don't end up accumulating a lot of small files which would be the other extreme of where we are today



##########
src/ast/ddl.rs:
##########
@@ -2065,7 +1902,7 @@ pub enum GeneratedExpressionMode {
 }
 
 #[must_use]
-fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ {
+pub fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ {

Review Comment:
   ```suggestion
   pub(crate) fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ {
   ```



##########
src/ast/ddl.rs:
##########
@@ -2082,7 +1919,7 @@ fn display_constraint_name(name: &'_ Option<Ident>) -> impl fmt::Display + '_ {
 /// * `Some(inner)` => create display struct for `"{prefix}{inner}{postfix}"`
 /// * `_` => do nothing
 #[must_use]
-fn display_option<'a, T: fmt::Display>(
+pub fn display_option<'a, T: fmt::Display>(

Review Comment:
   ```suggestion
   pub(crate) fn display_option<'a, T: fmt::Display>(
   ```



##########
src/ast/ddl.rs:
##########
@@ -2104,7 +1941,7 @@ fn display_option<'a, T: fmt::Display>(
 /// * `Some(inner)` => create display struct for `" {inner}"`
 /// * `_` => do nothing
 #[must_use]
-fn display_option_spaced<T: fmt::Display>(option: &Option<T>) -> impl fmt::Display + '_ {
+pub fn display_option_spaced<T: fmt::Display>(option: &Option<T>) -> impl fmt::Display + '_ {

Review Comment:
   ```suggestion
   pub(crate) fn display_option_spaced<T: fmt::Display>(option: &Option<T>) -> impl fmt::Display + '_ {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Moved constraint variant outside of `TableConstraint` enum [datafusion-sqlparser-rs]

Posted by "iffyio (via GitHub)" <gi...@apache.org>.
iffyio merged PR #2054:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2054


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [PR] Moved constraint variant outside of `TableConstraint` enum [datafusion-sqlparser-rs]

Posted by "LucaCappelletti94 (via GitHub)" <gi...@apache.org>.
LucaCappelletti94 commented on code in PR #2054:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2054#discussion_r2404374924


##########
src/ast/table_constraints/check_constraint.rs:
##########
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one

Review Comment:
   Done in commit [258cc8c](https://github.com/apache/datafusion-sqlparser-rs/pull/2054/commits/258cc8cb65603824c86a7e21089a426e021abcf8)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org