Skip to content
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

fix casting issue in bq for hour of day #233

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metrics_layer/core/model/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ def apply_dimension_group_time_sql(self, sql: str, query_type: str):
"fiscal_quarter_of_year": lambda s, qt: (
f"EXTRACT(QUARTER FROM {self._fiscal_offset_to_timestamp(s, qt)})"
),
"hour_of_day": lambda s, qt: f"CAST({s} AS STRING FORMAT 'HH24')",
"hour_of_day": lambda s, qt: f"CAST(CAST({s} AS STRING FORMAT 'HH24') AS INT64)",
"day_of_week": lambda s, qt: f"CAST({s} AS STRING FORMAT 'DAY')",
"day_of_month": lambda s, qt: f"EXTRACT(DAY FROM {s})",
"day_of_year": lambda s, qt: f"EXTRACT(DAYOFYEAR FROM {s})",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metrics_layer"
version = "0.12.36"
version = "0.12.37"
description = "The open source metrics layer."
authors = ["Paul Blankley <[email protected]>"]
keywords = ["Metrics Layer", "Business Intelligence", "Analytics"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_simple_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ def test_simple_query_dimension_group(connections, group: str, query_type: str):
"month_of_year_index": f"EXTRACT(MONTH FROM simple.order_date)",
"month_of_year": "FORMAT_DATETIME('%B', CAST(simple.order_date as DATETIME))",
"quarter_of_year": "EXTRACT(QUARTER FROM simple.order_date)",
"hour_of_day": f"CAST(simple.order_date AS STRING FORMAT 'HH24')",
"hour_of_day": f"CAST(CAST(simple.order_date AS STRING FORMAT 'HH24') AS INT64)",
"day_of_week": f"CAST(simple.order_date AS STRING FORMAT 'DAY')",
"day_of_month": "EXTRACT(DAY FROM simple.order_date)",
"day_of_year": "EXTRACT(DAYOFYEAR FROM simple.order_date)",
Expand Down
Loading