git-hulk commented on code in PR #1487:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/1487#discussion_r1821907147
##########
src/ast/mod.rs:
##########
@@ -4376,7 +4410,31 @@ impl fmt::Display for Statement {
full = if *full { "FULL " } else { "" },
)?;
if let Some(db_name) = db_name {
- write!(f, " FROM {db_name}")?;
+ let keyword = match &db_name_keyword {
+ Some(Keyword::FROM) => "FROM",
+ Some(Keyword::IN) => "IN",
+ _ => "", // unexpected
Review Comment:
Can use `unreachable!()` to panic if it's an unexpected condition.
##########
tests/sqlparser_hive.rs:
##########
@@ -534,6 +534,20 @@ fn parse_use() {
);
}
+#[test]
+fn test_show() {
+ hive().verified_stmt("SHOW DATABASES");
Review Comment:
It would be better to use `hive_and_generic` since it also works for generic
dialects.
##########
src/ast/mod.rs:
##########
@@ -4376,7 +4410,31 @@ impl fmt::Display for Statement {
full = if *full { "FULL " } else { "" },
)?;
if let Some(db_name) = db_name {
- write!(f, " FROM {db_name}")?;
+ let keyword = match &db_name_keyword {
+ Some(Keyword::FROM) => "FROM",
+ Some(Keyword::IN) => "IN",
+ _ => "", // unexpected
+ };
+ write!(f, " {} {db_name}", keyword)?;
+ }
+ if let Some(filter) = filter {
+ write!(f, " {filter}")?;
+ }
+ Ok(())
+ }
+ Statement::ShowViews {
+ db_name_keyword,
+ db_name,
+ filter
+ } => {
+ write!(f, "SHOW VIEWS")?;
+ if let Some(db_name) = db_name {
+ let keyword = match &db_name_keyword {
+ Some(Keyword::FROM) => "FROM",
+ Some(Keyword::IN) => "IN",
+ _ => "", // unexpected
Review Comment:
Same as the above comment.
--
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]