-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(schema-compiler): Fix BigQuery DATETIME_TRUNC() week processing #9380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #9380 +/- ##
=======================================
Coverage 83.72% 83.72%
=======================================
Files 229 229
Lines 82574 82614 +40
=======================================
+ Hits 69138 69172 +34
- Misses 13436 13442 +6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @KSDaemon I've noticed this has been rectified in a significant number of queries generated by Cube within our instance (Thank you - this plagued us in tableau!). However, it appears that when queries are pushed down, the 'monday' parameter for the 'week()' function isn't included. My instance is hosted on Cube Cloud, so please don't hesitate to contact me on the Cube Slack channel if you require further details. Thank you! What is sent by tableau DATE_TRUNC(
'WEEK',
CAST(
CAST(
"CUBE_VIEW"."route_date" AS DATE
) AS TIMESTAMP
)
) AS "tiwk:route_date:ok"What is generated by cube: DATETIME_TRUNC(
CAST(
CAST(
CAST(
timestamp(`CUBE_VIEW`.route_date) AS DATE
) AS TIMESTAMP
) AS DATETIME
),
week
) `datetrunc_utf8__`,Thank you! |
|
Hi @tlangton3 ! Thank you :) |
|
Much appreciated @KSDaemon ! |
|
Hi @tlangton3! Here is my query: SELECT DATE_TRUNC(
'WEEK',
CAST(
CAST(
orders.order_date AS DATE
) AS TIMESTAMP
)
) AS result
FROM
orders
GROUP BY
1
LIMIT
10000;Simply request the time dimension with date trunc. And here is the generated SQL: SELECT `orders`.`datetrunc_utf8__` `result`
FROM (
SELECT
DATETIME_TRUNC(CAST(CAST(CAST(DATETIME(`orders`.order_date, 'UTC') AS DATE) AS TIMESTAMP) AS DATETIME), WEEK(MONDAY)) `datetrunc_utf8__`
FROM
(SELECT 1 AS id, 100 AS amount, 'new' status, CAST('2024-01-01' as timestamp) order_date UNION ALL SELECT 2 AS id, 200 AS amount, 'new' status, CAST('2024-01-02' as timestamp) order_date UNION ALL SELECT 3 AS id, 300 AS amount, 'processed' status, CAST('2024-01-03' as timestamp) order_date UNION ALL SELECT 4 AS id, 500 AS amount, 'processed' status, CAST('2024-01-04' as timestamp) order_date UNION ALL SELECT 5 AS id, 600 AS amount, 'shipped' status, CAST('2024-01-05' as timestamp) order_date
) AS `orders` GROUP BY 1
) AS `orders`
LIMIT 10000As you can see - it correctly produces Could you please provide a minimal reproducible data model (ideally just one self-sufficient cube) + REST/SQL Query? |
|
Hello @KSDaemon, thanks for looking into this. I've sent you a message on Slack, as I can provide a more detailed query there :) |
…ube-js#9380) * fix(schema-compiler): Fix BigQuery DATETIME_TRUNC() week processing * add tests
This PR fixes datetime WEEK truncing for BigQuery.
Closes #9330
Check List