iffyio commented on code in PR #2214:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2214#discussion_r2827208679


##########
src/parser/mod.rs:
##########
@@ -17133,12 +17139,26 @@ impl<'a> Parser<'a> {
             let table = self.parse_keyword(Keyword::TABLE);
             let table_object = self.parse_table_object()?;
 
-            let table_alias =
-                if dialect_of!(self is PostgreSqlDialect) && 
self.parse_keyword(Keyword::AS) {
-                    Some(self.parse_identifier()?)
+            let table_alias = if dialect_of!(self is OracleDialect) {

Review Comment:
   maybe we can use a dialect method for this since the macro is deprecated.



##########
src/parser/mod.rs:
##########
@@ -4543,7 +4543,13 @@ impl<'a> Parser<'a> {
     ///
     /// Returns true if the current token matches the expected keyword.
     pub fn peek_keyword(&self, expected: Keyword) -> bool {
-        matches!(&self.peek_token_ref().token, Token::Word(w) if expected == 
w.keyword)
+        self.peek_keyword_one_of(&[expected])
+    }
+
+    #[must_use]
+    /// Checks whether the current token is one of the expected keywords 
without consuming it.
+    fn peek_keyword_one_of(&self, expected: &[Keyword]) -> bool {
+        matches!(&self.peek_token_ref().token, Token::Word(w) if 
expected.contains(&w.keyword))

Review Comment:
   oh but the keyword is copy? so that no cloning should be involved - unless 
I'm misunderstanding



##########
src/parser/mod.rs:
##########
@@ -17133,12 +17139,26 @@ impl<'a> Parser<'a> {
             let table = self.parse_keyword(Keyword::TABLE);
             let table_object = self.parse_table_object()?;
 
-            let table_alias =
-                if dialect_of!(self is PostgreSqlDialect) && 
self.parse_keyword(Keyword::AS) {
-                    Some(self.parse_identifier()?)
+            let table_alias = if dialect_of!(self is OracleDialect) {
+                if !self.peek_sub_query()
+                    && !self.peek_keyword_one_of(&[Keyword::DEFAULT, 
Keyword::VALUES])

Review Comment:
   did we have existing test cases covering both conditions (subquey and 
default values)?



##########
src/ast/mod.rs:
##########
@@ -6451,6 +6451,17 @@ pub struct InsertAliases {
     pub col_aliases: Option<Vec<Ident>>,
 }
 
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+/// Optional alias for an `INSERT` table; i.e. the table to be inserted into
+pub struct InsertTableAlias {

Review Comment:
   ```suggestion
   pub struct TableAliasWithoutColumns {
   ```
   or something similar that isn't specific to the insert statement, in case   
the struct needs to be reused in other contexts?



-- 
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]

Reply via email to