-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Describe the bug
Cube generates an Oracle query using TO_DATE with a format mask that does not match the actual ISO-8601 timestamp emitted by the backend (2024-02-01T00:00:00.000Z). This causes Oracle errors, while Postgres accepts the same value.
To Reproduce
Input Query
{
"query": {
"measures": ["mortgage.total_mortgage_amount"],
"filters": [
{
"member": "mortgage.mortgage_taken_at",
"operator": "afterDate",
"values": ["2024-02-01"]
}
]
}
}
Generated SQL (Oracle)
WHERE "mortgage".MORTGAGE_TAKEN_DATE >
to_date(:"?", 'YYYY-MM-DD"T"HH24:MI:SS"Z"')
Bind value passed
2024-02-01T00:00:00.000Z
Problem
The format 'YYYY-MM-DD"T"HH24:MI:SS"Z"'
does not handle:Fractional seconds (.000)
Oracle raises ORA-01821: date format not recognized.

Expected behavior
Oracle should parse the backend’s ISO string correctly, including fractional seconds and UTC Z.
Suggested fix
Use TO_TIMESTAMP_TZ
with a matching format mask:
to_timestamp_tz(:"?", 'YYYY-MM-DD"T"HH24:MI:SS.FF"Z"')
and
CAST(TO_TIMESTAMP_TZ(:"?", 'YYYY-MM-DD"T"HH24:MI:SS.FF"Z"') AS DATE)

Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Minimally reproducible Cube Schema
In case your bug report is data modelling related please put your minimally reproducible Cube Schema here.
You can use selects without tables in order to achieve that as follows.
cubes:
- name: mortgage
sql_table: MORTGAGE
dimensions:
# Keys & identifiers
- name: mortgage_generated_key
sql: MORTGAGE_GENERATED_KEY
type: number
primary_key: true
format: id
- name: mortgage_case_identifier
sql: MORTGAGE_CASE_IDENTIFIER
type: number
format: id
- name: mortgage_taken_at
sql: "{CUBE}.MORTGAGE_TAKEN_DATE"
type: time
measures:
# Row counts
- name: count
type: count
drill_members:
- mortgage_generated_key
- mortgage_case_identifier
- mortgage_taken_at
- borrower_generated_key
- branch.branch_name
- customer.full_name
- name: cumulative_count
type: count
rolling_window:
trailing: unbounded
# Monetary measures
- name: total_mortgage_amount
sql: MORTGAGE_AMOUNT
type: sum
# format: currency
- name: total_mortgage_balance
sql: MORTGAGE_BALANCE
type: sum
# format: currency
# Helpful canned rollups for performance
pre_aggregations:
# Pre-aggregation definitions go here.
Version:
[e.g. 0.4.5]
Additional context
Add any other context about the problem here.