chenkovsky commented on code in PR #1971:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1971#discussion_r2226952924


##########
tests/sqlparser_bigquery.rs:
##########
@@ -2566,3 +2566,101 @@ fn test_struct_trailing_and_nested_bracket() {
         )
     );
 }
+
+#[test]
+fn test_datetime_granularity() {
+    let stmt = bigquery().verified_stmt(concat!(
+        "SELECT ",
+        "DATE_TRUNC(CURRENT_DATE, DAY), ",
+        "DATE_TRUNC(CURRENT_DATE, WEEK(MONDAY)) ",
+        "FROM my_table",
+    ));

Review Comment:
   currently,  DAY will be parsed as ident, week will be parsed as function. I 
think this is flawed.
   1. when transpiling bigquery sql to another dialect, 
`DATE_TRUNC(CURRENT_DATE, DAY)` should be transpiled to 
`DATE_TRUNC(CURRENT_DATE,'day')`, but currently, it will be transpiled into 
`DATE_TRUNC(CURRENT_DATE, DAY)`.
   2. when compiling sql to logical plan, planner will try to find column 
called DAY, MONDAY, and function called WEEK. we should tell planner this is 
not function or column.



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