iffyio commented on code in PR #2168:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2168#discussion_r2753381362
##########
src/parser/mod.rs:
##########
@@ -1822,7 +1818,14 @@ impl<'a> Parser<'a> {
} else if let Some(lambda) = self.try_parse_lambda()? {
return Ok(lambda);
} else {
- let exprs =
self.parse_comma_separated(Parser::parse_expr)?;
+ // Parentheses create a normal expression context.
Review Comment:
Can we incorporate this documentation from the previous function here? I
think that would be useful context to readers later on since this part of the
code might be a bit too abstract otherwise
```text
/// When parsing some column option expressions we need to revert to
[ParserState::Normal] since
/// `NOT NULL` is allowed as an alias for `IS NOT NULL`.
/// In those cases we use this helper instead of calling
[Parser::parse_expr] directly.
///
/// For example, consider these `CREATE TABLE` statements:
/// ```sql
/// CREATE TABLE foo (abc BOOL DEFAULT (42 NOT NULL) NOT NULL);
/// ```
/// vs
/// ```sql
/// CREATE TABLE foo (abc BOOL NOT NULL);
/// ```
///
/// In the first we should parse the inner portion of `(42 NOT NULL)` as
[Expr::IsNotNull],
/// whereas is both statements that trailing `NOT NULL` should only be
parsed as a
/// [ColumnOption::NotNull].
```
##########
tests/sqlparser_common.rs:
##########
@@ -17376,6 +17302,11 @@ fn test_parse_not_null_in_column_options() {
);
}
+#[test]
+fn test_parse_default_expr_with_operators() {
+ all_dialects().verified_stmt("CREATE TABLE t (c INT DEFAULT (1 + 2) + 3)");
+}
Review Comment:
Can we add or extend this to include the `NOT NULL` behavior? e.g.
```sql
CREATE TABLE t (c INT DEFAULT (1 + 2) + 3 NOT NULL)
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]