cube-js/cube

Time dimension returns [object Object] values from mssql

Open

#9,488 opened on Apr 18, 2025

View on GitHub
 (20 comments) (4 reactions) (1 assignee)Rust (19,563 stars) (1,965 forks)batch import
driver:mssqlhelp wanted

Description

Problem I have a problem with time type with MSSQL source database. In playground I got [object Object] result instead of real dates values. I am using:

  • MSSQL 2019
  • Latests Cube Core Docker Image

Image

The generated script works fine and returns values.

Image

My cube yaml:

cubes:
  - name: cube_mes_supply
    sql_table: cube.v_mes_supply
    data_source: dwh_reporting_development

    joins: 
      - name: dim_document_status
        relationship: many_to_one
        sql: "{cube_mes_supply}.ATTB = {dim_document_status.operation_id}"

    dimensions:
      - name: id
        sql: id
        type: number
        primary_key: true      

      - name: company_guid
        sql: COMPANY
        type: string

      - name: mars_reason
        sql: mars_reason
        type: string

      - name: is_cross_docking
        sql: IS_CROSS_DOCKING
        type: boolean

      - name: create_date
        sql: create_datetime
        type: time
      
      - name: test_datetimeoffset
        sql: test_datetimeoffset
        type: time

    measures:
      - name: count
        type: count

      - name: quantity
        sql: Quantity
        type: sum

      - name: amount_rub
        sql: Amount_Rub
        type: sum

    pre_aggregations:
      - name: marsReasonIsCrossDockingMeasure
        measures:
          - amount_rub
          - quantity
        dimensions:
          - mars_reason
          - is_cross_docking
        refreshKey:
          every: 10 minute

I think that the problem is that MSSQL returns DATETIMEOFFSET type with nanoseconds. How can I fix that?

Contributor guide