iffyio commented on code in PR #2375:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2375#discussion_r3681408182
##########
src/dialect/mod.rs:
##########
@@ -1267,6 +1267,16 @@ pub trait Dialect: Debug + Any {
false
}
+ /// Returns true if the dialect supports object-unpivot table factors in
the FROM clause.
+ ///
+ /// Syntax:
+ /// ```sql
+ /// UNPIVOT expression AS value_alias [AT attribute_alias]
Review Comment:
```suggestion
/// SELECT * FROM T UNPIVOT expression AS value_alias [AT
attribute_alias]
```
##########
src/parser/mod.rs:
##########
@@ -16575,6 +16581,10 @@ impl<'a> Parser<'a> {
with_offset_alias,
with_ordinality,
})
+ } else if self.dialect.supports_unpivot_expr_in_from()
+ && self.parse_keyword(Keyword::UNPIVOT)
Review Comment:
the parse_keyword still remains, the goal of introducing peek_keyword is
that parse_keyword moves into the parse_unpivot_expr_table_factor function as
an expect call instead
##########
tests/sqlparser_redshift.rs:
##########
@@ -542,3 +542,10 @@ fn test_partiql_from_alias_with_at_index() {
_ => panic!("expected table factor"),
}
}
+
+#[test]
+fn parse_unpivot_expression() {
+ redshift().verified_stmt("SELECT t.id, k, v FROM test_colors AS t, UNPIVOT
t.count_by_color AS v AT k",);
+ redshift().verified_stmt("SELECT t.id, k, v FROM test_colors AS t, UNPIVOT
t AS v AT k");
Review Comment:
can we change the dialect selection to use all_dialects_where(|d|
d.supports...)?
--
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]