aharpervc commented on code in PR #1949:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1949#discussion_r2248445838


##########
src/dialect/mod.rs:
##########
@@ -1036,8 +1036,14 @@ pub trait Dialect: Debug + Any {
     /// Returns true if the specified keyword should be parsed as a table 
factor alias.
     /// When explicit is true, the keyword is preceded by an `AS` word. Parser 
is provided
     /// to enable looking ahead if needed.
-    fn is_table_factor_alias(&self, explicit: bool, kw: &Keyword, parser: &mut 
Parser) -> bool {
-        explicit || self.is_table_alias(kw, parser)
+    ///
+    /// When the dialect supports statements without semicolon delimiter, 
actual keywords aren't parsed as aliases.
+    fn is_table_factor_alias(&self, explicit: bool, kw: &Keyword, _parser: 
&mut Parser) -> bool {
+        if self.supports_statements_without_semicolon_delimiter() {
+            kw == &Keyword::NoKeyword
+        } else {
+            explicit || self.is_table_alias(kw, _parser)
+        }

Review Comment:
   Yes, the example sql is from the sqlparse_common test case 
`parse_select_with_table_alias_keyword` & `parse_invalid_limit_by`, such as 
`SELECT a FROM lineitem DECLARE`. Commenting out the new logic and running the 
tests shows the difficulty. My thinking here is that if semicolons are 
optional, we can forbid keywords as table aliases. Folks who use this option 
are going to be opting in to a certain level of ambiguity regardless, but 
having the parser do reasonable things (with test coverage) is my objective 
here.
   
   Looking at this code again I think this should be checking the actual 
configured parser option rather than the dialect's capability, similar to the 
other feedback comment. I will change it.



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to