cube icon indicating copy to clipboard operation
cube copied to clipboard

Pre-Aggregations missing data

Open esisilvestri opened this issue 4 months ago • 3 comments

I am running Cube Core with Oracle as a source database and Minio for pre-aggregation storage. I am running into an issue that causes pre-aggregations to not contain all data that they should. It seems ot be driven by the size of the partition.

Below is an example of a pre.aggregation. The below example works. However is I add another field that has a high cardinality like customer number then the resulting pre-aggregation starts to return wrong results. This seems ot happens because data is missing. I checked the query that is sent to the data source and that is correct. The issue is compounded the more fields I add to the pre-aggregation. It does not mater if they are from the same cube or from a different one.

    pre_aggregations:
      - name: invoices
        dimensions:
          - CUBE.price_condition_code
          - CUBE.sales_rep_code
          - product.section
          - product.family
          - product.product_name
        measures:
          - CUBE.sales_amount
          - CUBE.quantity
        refresh_key:
          every: 1 day
          incremental: true
          update_window: 4 weeks
        time_dimension: CUBE.invoice_date
        granularity: month
        partition_granularity: month
        type: rollup
        external: true
        build_range_start:
          sql: SELECT CURRENT_DATE - INTERVAL '2' month FROM DUAL
        build_range_end:
          sql: SELECT CURRENT_DATE FROM DUAL

Version: 1.6.65 CUBE and 1.6.54 Cubestore

esisilvestri avatar Jul 03 '26 19:07 esisilvestri

Could you share exact, reliably reproducible steps? A minimal model + query where the row count is consistently wrong would let us pin this down.

It'd also help to rule out the Oracle and Minio integrations as the cause — if you can reproduce it with another source database, or with S3 as pre-aggregation storage, that narrows it considerably.

igorlukanin avatar Jul 20 '26 13:07 igorlukanin

I switched to the trino connector with the same oracle database. Only difference is that the queries are executed trough trino instead of the oracle connector. This switch completely solved the problem. I am now getting correct results for all queries that target the pre-aggregations.

So it seems the issue is on the Oracle Connector side. When looking at the parquet files in minio I noticed that when using the trino connector I would get maximum three files per partition while when using the Oracle Connecotr I would get about 10 smaller files.

example Cube

  - name: invoices
    public: false
    sql_table: invoice_line
    data_source: default

    joins:
      - name: t_product
        sql: "{CUBE}.product_reference = {t_product.product_reference}"
        relationship: many_to_one

    dimensions:
      - name: customer_number
        sql: customer_number
        type: string

      - name: product_code
        sql: product_code
        type: string

      - name: sales_rep_code
        sql: sales_rep_code
        type: string

      - name: invoice_date
        sql: invoice_date
        type: time

      - name: invoice_number
        sql: invoice_number
        type: string
        primary_key: true

    measures:
      - name: sales_amount
        sql: sales_amount
        type: sum```

example Query:

`{
  "query": {
    "measures": [
      "invoice_view.sales_amount"
    ],
    "timeDimensions": [
      {
        "dimension": "invoice_view.invoice_date",
        "granularity": "month",
        "dateRange": [
          "2026-06-01",
          "2026-06-30"
        ]
      }
    ]
  },
  "limit": 100
}
`

esisilvestri avatar Jul 23 '26 15:07 esisilvestri

Still reproduces on v1.7.50 with Oracle 23ai and Cube Store: any pre-aggregation partition with more than 100,000 rows is silently cut at 100,000 rows. The Oracle driver sets node-oracledb maxRows = 100000 and fetches results without a ResultSet, so it stops at that limit without an error. That's why adding high-cardinality dimensions makes totals drop. Workaround: use a smaller partition_granularity (e.g. week or day) so each partition stays under 100k rows. Failing test: #12118.


Generated by Claude Code

paveltiunov avatar Oct 05 '26 16:10 paveltiunov