{"record":{"id":"ca36cf986a3cd07f","repo":"cube-js/cube","slug":"index-sql-support-is-not-implemented","errorCode":null,"errorMessage":"Index SQL support is not implemented","messagePattern":"Index SQL support is not implemented","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-schema-compiler/src/adapter/BaseQuery.js","lineNumber":4410,"sourceCode":"  preAggregationLoadSql(cube, preAggregation, tableName) {\n    const sqlAndParams = this.preAggregationSql(cube, preAggregation);\n    return [`CREATE TABLE ${tableName} ${this.asSyntaxTable} ${sqlAndParams[0]}`, sqlAndParams[1]];\n  }\n\n  preAggregationPreviewSql(tableName) {\n    return this.paramAllocator.buildSqlAndParams(`SELECT * FROM ${tableName} LIMIT 1000`);\n  }\n\n  indexSql(cube, preAggregation, index, indexName, tableName) {\n    if (preAggregation.external && this.externalQueryClass) {\n      return this.externalQuery().indexSql(cube, preAggregation, index, indexName, tableName);\n    }\n\n    if (index.columns) {\n      const escapedColumns = this.evaluateIndexColumns(cube, index);\n      return this.paramAllocator.buildSqlAndParams(this.createIndexSql(indexName, tableName, escapedColumns));\n    } else {\n      throw new Error('Index SQL support is not implemented');\n    }\n  }\n\n  evaluateIndexColumns(cube, index) {\n    const columns = this.cubeEvaluator.evaluateReferences(cube, index.columns, { originalSorting: true });\n    return columns.map(column => {\n      const path = column.split('.');\n      if (path[0] &&\n        this.cubeEvaluator.cubeExists(path[0]) &&\n        (\n          this.cubeEvaluator.isMeasure(path) ||\n          this.cubeEvaluator.isDimension(path) ||\n          this.cubeEvaluator.isSegment(path)\n        )\n      ) {\n        if (path.length === 3 && this.cubeEvaluator.isDimension(path.slice(0, 2))) {\n          const dimensionDef = this.cubeEvaluator.dimensionByPath(path.slice(0, 2));\n          if (dimensionDef.type === 'time' &&","sourceCodeStart":4392,"sourceCodeEnd":4428,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-schema-compiler/src/adapter/BaseQuery.js#L4392-L4428","documentation":"When generating DDL for a pre-aggregation (create table), an index definition can specify either SQL (index.sql) or columns (index.columns). If neither is usable — here, index.columns was falsy so the SQL-building branch ran but createIndexSql path only supports explicit columns — BaseQuery throws 'Index SQL support is not implemented' because the generic adapter cannot render that index form.","triggerScenarios":"Defining a pre-aggregation index without a columns attribute (or with columns that evaluate to nothing), so index.columns is missing when Cube builds the CREATE INDEX statement.","commonSituations":"YAML/JS preAggregation indexes written with only a name or sql field instead of columns; renaming/refactoring index definitions so `columns:` was dropped.","solutions":["Add the `columns:` array (list of dimension/measure member names) to the index definition","Verify the index definition references valid member names so evaluateReferences yields columns","Remove the index from the pre-aggregation if not needed"],"exampleFix":"// before\nindexes:\n  main:\n    name: main_idx\n// after\nindexes:\n  main:\n    name: main_idx\n    columns:\n      - created_at\n      - city","handlingStrategy":"validation","validationCode":"for (const [name, idx] of Object.entries(cubeDef.preAggregations?.[0]?.indexes || {})) {\n  if (!idx.columns?.length && !idx.sql) throw new Error(`Index '${name}' must define columns (array of member names)`);\n}","typeGuard":"function indexHasColumns(index) {\n  return typeof index === 'object' && index !== null &&\n    Array.isArray(index.columns) && index.columns.length > 0;\n}","tryCatchPattern":"try { await compiler.compile(); } catch (e) {\n  if (/Index SQL support is not implemented/.test(e.message)) {\n    throw new Error('Pre-aggregation index must declare columns: [...]');\n  }\n  throw e;\n}","preventionTips":["Always provide columns when defining pre-aggregation indexes","Validate index definitions in a data-model unit test","Reference only existing members so evaluateReferences produces non-empty columns"],"tags":["schema-compiler","pre-aggregation","index-ddl","invalid-config"],"backgroundTag":"pre-aggregation-index-misconfigured","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}