Skip to content

Indexing external pre-aggregation table doesn't works for timeDimensionReference #1781

@contxtsio-jetson

Description

@contxtsio-jetson

Describe the bug
I'd tried to create indexes for columns including timeDimensionReference and I found the timeDimensionReference get suffix when the pre-aggregation table is created.

Schema:

wk: {
  type: `rollup`,
  measureReferences: [m_exchange_rate],
  dimensionReferences: [
    token_address,
    currency,
    vs_currency,
    exchange_rate,
  ],
  timeDimensionReference: block_date,
  granularity: `week`,
  scheduledRefresh: !isPerUser,
  external: true,
  indexes: {
    cidx_token_address_vs_currency_block_date: {
      // FIXME: Jetson
      columns: [token_address, vs_currency, block_date],
    },
  },
},

Error log:

{
  "processingId": "21",
  "queueSize": 1,
  "queryKey": [
    [
      "SELECT\n      `erc20`.currency `erc20__currency`, `erc20`.exchange_rate `erc20__exchange_rate`, `erc20`.token_address `erc20__token_address`, `erc20`.vs_currency `erc20__vs_currency`, DATETIME_TRUNC(DATETIME(cast(block_date as timestamp), 'UTC'), WEEK(MONDAY)) `erc20__block_date_week`, avg(exchange_rate) `erc20__m_exchange_rate`\n    FROM\n      (\n    select\n      token_address,\n      currency,\n      lower(vs_currency) as vs_currency,\n      block_date,\n      exchange_rate,\n    from `contxtsio-nftbank.data_mart_by_game.erc20_exchange_rates`\n    order by token_address, vs_currency, block_date\n  ) AS `erc20`  GROUP BY 1, 2, 3, 4, 5",
      []
    ],
    [
      [
        {
          "f0_": "2021-01-14T14:22:29.660Z"
        }
      ]
    ]
  ],
  "queuePrefix": "SQL_PRE_AGGREGATIONS_cubejs-serverless-dev_default",
  "timeInQueue": 2
}
error: column "erc20__block_date" does not exist
    at Parser.parseErrorMessage (/Users/jisunglim/development/contxts-io/nftbank-cubejs-serverless/example/node_modules/pg-protocol/src/parser.ts:357:11)
    at Parser.handlePacket (/Users/jisunglim/development/contxts-io/nftbank-cubejs-serverless/example/node_modules/pg-protocol/src/parser.ts:186:21)
    at Parser.parse (/Users/jisunglim/development/contxts-io/nftbank-cubejs-serverless/example/node_modules/pg-protocol/src/parser.ts:101:30)
    at Socket.stream.on (/Users/jisunglim/development/contxts-io/nftbank-cubejs-serverless/example/node_modules/pg-protocol/src/index.ts:7:48)

Expected behavior
It should create an index for the column no matter it is timeDimension or simple dimension.

Version:

"@cubejs-backend/bigquery-driver": "^0.25.4",
"@cubejs-backend/postgres-driver": "^0.25.4",
"@cubejs-backend/server": "^0.25.4",
"@cubejs-backend/serverless": "^0.25.4",
"@cubejs-backend/serverless-google": "^0.25.4",

Additional context
Using bigquery for data source, postgres for external pre-aggregation db. Deployed on GCP cloud function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    data modelingquestionThe issue is a question. Please use Stack Overflow for questions.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions