Skip to content

Oracle timestamp parsing mismatch (TO_DATE vs ISO string with .000Z) #9971

@Tankilevitch

Description

@Tankilevitch

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.

Screenshot 2025-09-13 at 22 19 14

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)

Screenshot 2025-09-13 at 22 20 10

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions