LucaCappelletti94 commented on code in PR #2512:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2512#discussion_r4097817521
##########
src/ast/query.rs:
##########
@@ -298,19 +298,30 @@ impl fmt::Display for SetQuantifier {
/// A [`TABLE`
command](https://www.postgresql.org/docs/current/sql-select.html#SQL-TABLE)
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub struct Table {
+ /// `ONLY` modifier before the table name.
+ pub only: bool,
/// Optional table name (absent for e.g. `TABLE` command without argument).
pub table_name: Option<Ident>,
/// Optional schema/catalog name qualifying the table.
pub schema_name: Option<Ident>,
+ /// Trailing `*` modifier after the table name.
+ pub with_asterisk: bool,
}
impl fmt::Display for Table {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(ref table_name) = self.table_name {
+ write!(f, "TABLE ")?;
+ if self.only {
+ write!(f, "ONLY ")?;
+ }
if let Some(ref schema_name) = self.schema_name {
- write!(f, "TABLE {}.{}", schema_name, table_name,)?;
+ write!(f, "{}.{}", schema_name, table_name,)?;
} else {
- write!(f, "TABLE {}", table_name)?;
+ write!(f, "{}", table_name)?;
+ }
+ if self.with_asterisk {
Review Comment:
You should follow the `has_asterisk` rename here.
```suggestion
if self.has_asterisk {
```
##########
src/ast/query.rs:
##########
@@ -298,19 +298,30 @@ impl fmt::Display for SetQuantifier {
/// A [`TABLE`
command](https://www.postgresql.org/docs/current/sql-select.html#SQL-TABLE)
#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
pub struct Table {
+ /// `ONLY` modifier before the table name.
+ pub only: bool,
/// Optional table name (absent for e.g. `TABLE` command without argument).
pub table_name: Option<Ident>,
/// Optional schema/catalog name qualifying the table.
pub schema_name: Option<Ident>,
+ /// Trailing `*` modifier after the table name.
+ pub with_asterisk: bool,
Review Comment:
You should name this field `has_asterisk` to follow pre-existing standard.
```suggestion
pub has_asterisk: bool,
```
##########
src/parser/mod.rs:
##########
@@ -15625,17 +15637,22 @@ impl<'a> Parser<'a> {
/// Parse `CREATE TABLE x AS TABLE y`
pub fn parse_as_table(&mut self) -> Result<Table, ParserError> {
+ let only = self.parse_keyword(Keyword::ONLY);
let first_name = self.parse_identifier()?;
if self.consume_token(&Token::Period) {
let second_name = self.parse_identifier()?;
Ok(Table {
+ only,
table_name: Some(second_name),
schema_name: Some(first_name),
+ with_asterisk: self.consume_token(&Token::Mul),
})
} else {
Ok(Table {
+ only,
table_name: Some(first_name),
schema_name: None,
+ with_asterisk: self.consume_token(&Token::Mul),
Review Comment:
You should follow the `has_asterisk` rename here.
```suggestion
has_asterisk: self.consume_token(&Token::Mul),
```
##########
src/parser/mod.rs:
##########
@@ -15625,17 +15637,22 @@ impl<'a> Parser<'a> {
/// Parse `CREATE TABLE x AS TABLE y`
pub fn parse_as_table(&mut self) -> Result<Table, ParserError> {
+ let only = self.parse_keyword(Keyword::ONLY);
let first_name = self.parse_identifier()?;
if self.consume_token(&Token::Period) {
let second_name = self.parse_identifier()?;
Ok(Table {
+ only,
table_name: Some(second_name),
schema_name: Some(first_name),
+ with_asterisk: self.consume_token(&Token::Mul),
Review Comment:
You should follow the `has_asterisk` rename here.
```suggestion
has_asterisk: self.consume_token(&Token::Mul),
```
--
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]