You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by al...@apache.org on 2024/10/04 20:07:32 UTC
(datafusion-sqlparser-rs) branch main updated: added ability to parse extension to parse_comment inside postgres dialect (#1451)
This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 8ccb87a8 added ability to parse extension to parse_comment inside postgres dialect (#1451)
8ccb87a8 is described below
commit 8ccb87a8355858ccb06ffc20484657cd7980d78c
Author: Maxwell Knight <10...@users.noreply.github.com>
AuthorDate: Fri Oct 4 23:07:26 2024 +0300
added ability to parse extension to parse_comment inside postgres dialect (#1451)
---
src/ast/mod.rs | 2 ++
src/dialect/postgresql.rs | 4 ++++
tests/sqlparser_postgres.rs | 15 +++++++++++++++
3 files changed, 21 insertions(+)
diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index 57cd401d..8c4bc25a 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -1855,6 +1855,7 @@ impl fmt::Display for ShowCreateObject {
pub enum CommentObject {
Column,
Table,
+ Extension,
}
impl fmt::Display for CommentObject {
@@ -1862,6 +1863,7 @@ impl fmt::Display for CommentObject {
match self {
CommentObject::Column => f.write_str("COLUMN"),
CommentObject::Table => f.write_str("TABLE"),
+ CommentObject::Extension => f.write_str("EXTENSION"),
}
}
}
diff --git a/src/dialect/postgresql.rs b/src/dialect/postgresql.rs
index 945c4fcc..2a66705b 100644
--- a/src/dialect/postgresql.rs
+++ b/src/dialect/postgresql.rs
@@ -205,6 +205,10 @@ pub fn parse_comment(parser: &mut Parser) -> Result<Statement, ParserError> {
let object_name = parser.parse_object_name(false)?;
(CommentObject::Table, object_name)
}
+ Token::Word(w) if w.keyword == Keyword::EXTENSION => {
+ let object_name = parser.parse_object_name(false)?;
+ (CommentObject::Extension, object_name)
+ }
_ => parser.expected("comment object_type", token)?,
};
diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs
index 9ba3e5db..735b87b5 100644
--- a/tests/sqlparser_postgres.rs
+++ b/tests/sqlparser_postgres.rs
@@ -2902,6 +2902,21 @@ fn parse_comments() {
_ => unreachable!(),
}
+ match pg().verified_stmt("COMMENT ON EXTENSION plpgsql IS 'comment'") {
+ Statement::Comment {
+ object_type,
+ object_name,
+ comment: Some(comment),
+ if_exists,
+ } => {
+ assert_eq!("comment", comment);
+ assert_eq!("plpgsql", object_name.to_string());
+ assert_eq!(CommentObject::Extension, object_type);
+ assert!(!if_exists);
+ }
+ _ => unreachable!(),
+ }
+
match pg().verified_stmt("COMMENT ON TABLE public.tab IS 'comment'") {
Statement::Comment {
object_type,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org