{"record":{"id":"7790df3c5bbc8c49","repo":"risingwavelabs/risingwave","slug":"should-be-set-for-vector-index","errorCode":null,"errorMessage":"should be set for vector index","messagePattern":"should be set for vector index","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/handler/create_index.rs","lineNumber":399,"sourceCode":"            \"inner_product\" => PbDistanceType::InnerProduct,\n            \"cosine\" => PbDistanceType::Cosine,\n            other => {\n                return Err(ErrorCode::InvalidInputSyntax(format!(\n                    \"unsupported vector index distance type: {}\",\n                    other\n                ))\n                .into());\n            }\n        };\n\n        let vector_index_write = input.gen_vector_index_plan(\n            index_table_name.clone(),\n            index_database_id,\n            index_schema_id,\n            definition,\n            retention_seconds,\n            PbVectorIndexInfo {\n                dimension: dimension.expect(\"should be set for vector index\") as _,\n                config: Some(vector_index_config),\n                distance_type: distance_type as _,\n            },\n        )?;\n        let index_table = vector_index_write.table().clone();\n        let plan: PlanRef = ensure_sync_log_store_fragment_root(vector_index_write.into());\n        (plan, index_table)\n    } else {\n        // Manually assemble the materialization plan for the index MV.\n        let materialize = assemble_materialize(\n            index_database_id,\n            index_schema_id,\n            table.clone(),\n            context.clone(),\n            index_table_name.clone(),\n            &index_columns_ordered_expr,\n            &include_columns_expr,\n            // We use the first index column as distributed key by default if users","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/handler/create_index.rs#L381-L417","documentation":"A `VecDimensionError`/panic-style assertion in `gen_create_index_plan` (create_index.rs:399) fired while building the `PbVectorIndexInfo` for a vector index. The parsed AST carried an optional HNSW dimension (`dimension: Option<i32>`), and it was `None` at plan time. RisingWave requires an explicit `DIMENSION` option on `CREATE INDEX ... USING HNSW` because the vector column type must have a fixed, known dimension to build the index table and the protobuf vector index info.","triggerScenarios":"Calling the create-index handler with `vector_index_mode = VectorIndexMode::Hnsw` but a dimension that could not be derived — e.g. `CREATE INDEX ... USING HNSW ON t (ORDER BY vec ASC)` where `vec`'s declared type is not a fixed-dimension vector type, or internal callers constructing a vector index plan without setting the dimension field in the binder/planner.","commonSituations":"Indexing a column whose type is `BYTEA`/JSON instead of `VECTOR(n)`; the column being declared `VECTOR` without a dimension (`VECTOR` with no length, if allowed by the create-table statement); SQL passed through from tools that omit the dimension; bugs in internal table-creation flows (e.g. iceberg engine tables) that build vector indexes on untyped columns.","solutions":["Ensure the indexed column is declared with a fixed dimension, e.g. `ALTER`/recreate the table with `vec VECTOR(3)` instead of an untyped or wrong-typed column.","Verify the CREATE INDEX statement targets a `VECTOR(n)` column and specifies `DISTANCE TYPE` options correctly.","If hit internally, fix upstream code to always set the dimension before calling `gen_create_index_plan` instead of relying on `expect`.","Check the table's schema via `\\d t` / `information_schema.columns` to confirm the column type carries a dimension."],"exampleFix":"// before\nCREATE INDEX idx ON t USING HNSW (vec ascii_cosine_ops); -- vec is not VECTOR(n)\n// after\nALTER TABLE t ADD vec3 VECTOR(3);\nCREATE INDEX idx ON t USING HNSW (vec3 ascii_cosine_ops);","handlingStrategy":"validation","validationCode":"-- before CREATE INDEX, confirm the column type has a fixed dimension\nSELECT data_type FROM information_schema.columns\nWHERE table_name = 't' AND column_name = 'vec';\n-- must look like: VECTOR(3), not BYTEA/JSON or dimensionless VECTOR","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare vector columns with an explicit dimension: VECTOR(n).","Only create HNSW indexes on VECTOR(n) columns.","Validate DDL against a schema linter before running in production."],"tags":["vector-index","missing-argument","sql","frontend"],"backgroundTag":"missing-required-argument","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}