Skip to content

Commit

Permalink
fix for maybe_parse preventing parser from erroring on recursion limit (
Browse files Browse the repository at this point in the history
  • Loading branch information
tomershaniii authored Oct 21, 2024
1 parent 38f1e57 commit 8e0d26a
Show file tree
Hide file tree
Showing 19 changed files with 423 additions and 571 deletions.
4 changes: 2 additions & 2 deletions src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ pub enum Statement {
/// Table confs
options: Vec<SqlOption>,
/// Cache table as a Query
query: Option<Query>,
query: Option<Box<Query>>,
},
/// ```sql
/// UNCACHE TABLE [ IF EXISTS ] <table_name>
Expand Down Expand Up @@ -6883,7 +6883,7 @@ impl fmt::Display for MacroArg {
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub enum MacroDefinition {
Expr(Expr),
Table(Query),
Table(Box<Query>),
}

impl fmt::Display for MacroDefinition {
Expand Down
2 changes: 1 addition & 1 deletion src/ast/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ pub enum PivotValueSource {
/// Pivot on all values returned by a subquery.
///
/// See <https://docs.snowflake.com/en/sql-reference/constructs/pivot#pivot-on-column-values-using-a-subquery-with-dynamic-pivot>.
Subquery(Query),
Subquery(Box<Query>),
}

impl fmt::Display for PivotValueSource {
Expand Down
4 changes: 2 additions & 2 deletions src/dialect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,9 @@ pub trait Dialect: Debug + Any {
fn parse_column_option(
&self,
_parser: &mut Parser,
) -> Option<Result<Option<ColumnOption>, ParserError>> {
) -> Result<Option<Result<Option<ColumnOption>, ParserError>>, ParserError> {
// return None to fall back to the default behavior
None
Ok(None)
}

/// Decide the lexical Precedence of operators.
Expand Down
4 changes: 2 additions & 2 deletions src/dialect/snowflake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl Dialect for SnowflakeDialect {
fn parse_column_option(
&self,
parser: &mut Parser,
) -> Option<Result<Option<ColumnOption>, ParserError>> {
) -> Result<Option<Result<Option<ColumnOption>, ParserError>>, ParserError> {
parser.maybe_parse(|parser| {
let with = parser.parse_keyword(Keyword::WITH);

Expand Down Expand Up @@ -247,7 +247,7 @@ pub fn parse_create_table(
builder = builder.comment(parser.parse_optional_inline_comment()?);
}
Keyword::AS => {
let query = parser.parse_boxed_query()?;
let query = parser.parse_query()?;
builder = builder.query(Some(query));
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/parser/alter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<'a> Parser<'a> {
let _ = self.parse_keyword(Keyword::WITH);
// option
let mut options = vec![];
while let Some(opt) = self.maybe_parse(|parser| parser.parse_pg_role_option()) {
while let Some(opt) = self.maybe_parse(|parser| parser.parse_pg_role_option())? {
options.push(opt);
}
// check option
Expand Down
Loading

0 comments on commit 8e0d26a

Please sign in to comment.