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


##########
tests/sqlparser_snowflake.rs:
##########
@@ -2846,3 +2846,32 @@ fn test_parse_show_columns_sql() {
     snowflake().verified_stmt("SHOW COLUMNS IN TABLE abc");
     snowflake().verified_stmt("SHOW COLUMNS LIKE '%xyz%' IN TABLE abc");
 }
+
+#[test]
+fn test_sf_double_dot_notation() {
+    snowflake().verified_stmt("SELECT * FROM db_name..table_name");
+    snowflake().verified_stmt("SELECT * FROM x, y..z JOIN a..b AS b ON x.id = 
b.id");
+}
+
+#[test]
+fn test_sf_double_dot_notation_wrong_position() {}
+
+#[test]
+fn test_parse_double_dot_notation_wrong_position() {
+    assert_eq!(
+        snowflake()
+            .parse_sql_statements("SELECT * FROM X.Y..")
+            .unwrap_err()
+            .to_string(),
+        "sql parser error: Expected: identifier, found: ."
+    );
+
+    assert_eq!(
+        // Ensure we don't parse leading token
+        snowflake()
+            .parse_sql_statements("SELECT * FROM .X.Y")
+            .unwrap_err()
+            .to_string(),
+        "sql parser error: Expected: identifier, found: ."
+    );
+}

Review Comment:
   can we merge the methods into `test_sf_double_dot_notation()` so that the 
latter contains the different scenarios? thinking that would help keep the 
tests focused to the feature since the feature is limited enough in scope



##########
src/parser/mod.rs:
##########
@@ -8349,6 +8349,13 @@ impl<'a> Parser<'a> {
     pub fn parse_object_name(&mut self, in_table_clause: bool) -> 
Result<ObjectName, ParserError> {
         let mut idents = vec![];
         loop {
+            if self.dialect.supports_object_name_double_dot_notation()
+                && idents.len() == 1
+                && self.peek_token() == Token::Period
+            {
+                self.next_token();
+                idents.push(Ident::new(""));

Review Comment:
   Oh is this line correct, I imagined we would push `Ident::new(".")`?



##########
src/parser/mod.rs:
##########
@@ -8349,6 +8349,13 @@ impl<'a> Parser<'a> {
     pub fn parse_object_name(&mut self, in_table_clause: bool) -> 
Result<ObjectName, ParserError> {
         let mut idents = vec![];
         loop {
+            if self.dialect.supports_object_name_double_dot_notation()
+                && idents.len() == 1
+                && self.peek_token() == Token::Period
+            {
+                self.next_token();

Review Comment:
   ```suggestion
                   && self.consume_token(&Token::Period)
               {
   ```



##########
tests/sqlparser_snowflake.rs:
##########
@@ -2846,3 +2846,32 @@ fn test_parse_show_columns_sql() {
     snowflake().verified_stmt("SHOW COLUMNS IN TABLE abc");
     snowflake().verified_stmt("SHOW COLUMNS LIKE '%xyz%' IN TABLE abc");
 }
+
+#[test]
+fn test_sf_double_dot_notation() {

Review Comment:
   can we add a test case containing multiple double dots? e.g. `select * from 
x, y..z..w` 



##########
tests/sqlparser_snowflake.rs:
##########
@@ -2846,3 +2846,32 @@ fn test_parse_show_columns_sql() {
     snowflake().verified_stmt("SHOW COLUMNS IN TABLE abc");
     snowflake().verified_stmt("SHOW COLUMNS LIKE '%xyz%' IN TABLE abc");
 }
+
+#[test]
+fn test_sf_double_dot_notation() {
+    snowflake().verified_stmt("SELECT * FROM db_name..table_name");
+    snowflake().verified_stmt("SELECT * FROM x, y..z JOIN a..b AS b ON x.id = 
b.id");
+}
+
+#[test]
+fn test_sf_double_dot_notation_wrong_position() {}

Review Comment:
   ah did we plan to put in a test scenario for this behavior?



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