{"record":{"id":"17623ab2d0d7b38e","repo":"spring-projects/spring-ai","slug":"table-s-does-not-exist-in-schema-s","errorCode":null,"errorMessage":"Table '%s' does not exist in schema '%s'","messagePattern":"Table '(.+?)' does not exist in schema '(.+?)'","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"critical","filePath":"vector-stores/spring-ai-mariadb-store/src/main/java/org/springframework/ai/vectorstore/mariadb/MariaDBSchemaValidator.java","lineNumber":66,"sourceCode":"\tprivate boolean isTableExists(@Nullable String schemaName, String tableName) {\n\t\t// schema and table are expected to be escaped\n\t\tString sql = \"SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?\";\n\t\ttry {\n\t\t\t// Query for a single integer value, if it exists, table exists\n\t\t\tthis.jdbcTemplate.queryForObject(sql, Integer.class, (schemaName == null) ? \"SCHEMA()\" : schemaName,\n\t\t\t\t\ttableName);\n\t\t\treturn true;\n\t\t}\n\t\tcatch (DataAccessException e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tvoid validateTableSchema(@Nullable String schemaName, String tableName, String idFieldName, String contentFieldName,\n\t\t\tString metadataFieldName, String embeddingFieldName, int embeddingDimensions) {\n\n\t\tif (!isTableExists(schemaName, tableName)) {\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\tString.format(\"Table '%s' does not exist in schema '%s'\", tableName, schemaName));\n\t\t}\n\n\t\t// ensure server support VECTORs\n\t\ttry {\n\t\t\t// Query for a single integer value, if it exists, database support vector\n\t\t\tthis.jdbcTemplate.queryForObject(\"SELECT vec_distance_euclidean(x'0000803f', x'0000803f')\", Integer.class,\n\t\t\t\t\tschemaName, tableName);\n\t\t}\n\t\tcatch (DataAccessException e) {\n\t\t\tif (logger.isErrorEnabled()) {\n\t\t\t\tlogger.error(\"Error while validating database vector support \" + e.getMessage());\n\t\t\t\tlogger.error(\"\"\"\n\t\t\t\t\t\tFailed to validate that database supports VECTOR.\n\t\t\t\t\t\tRun the following SQL commands:\n\t\t\t\t\t\t   SELECT @@version;\n\t\t\t\t\t\tAnd ensure that version is >= 11.7.1\"\"\");\n\t\t\t}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-mariadb-store/src/main/java/org/springframework/ai/vectorstore/mariadb/MariaDBSchemaValidator.java#L48-L84","documentation":"MariaDBSchemaValidator.validateTableSchema first checks that the configured vector store table exists via isTableExists. If it does not, it throws an IllegalStateException naming the missing table and schema. This fails fast during MariaDBVectorStore initialization before any query runs.","triggerScenarios":"Initializing MariaDBVectorStore (e.g. afterPropertiesSet calls validateTableSchema) when the configured table was never created or initializeSchema is disabled, the table lives in a different schema/database, or the configured table/schema names are wrong.","commonSituations":"Pointing the store at a fresh database without running schema initialization, typo in spring.ai.vectorstore.mariadb.table-name or schema config, connecting to wrong database instance/environment, table dropped by migrations.","solutions":["Set initialize-schema=true (spring.ai.vectorstore.mariadb.initialize-schema) so the store creates the table automatically.","Manually run the store's schema creation SQL (CREATE TABLE ... VECTOR column) in the target schema.","Verify the configured schema and table names match what exists in MariaDB (SHOW TABLES / SELECT from INFORMATION_SCHEMA).","Confirm the JDBC URL connects to the intended database instance."],"exampleFix":"// before\n// application.yml: spring.ai.vectorstore.mariadb.initialize-schema: false (table missing)\n// after\nspring:\n  ai:\n    vectorstore:\n      mariadb:\n        initialize-schema: true","handlingStrategy":"validation","validationCode":"boolean tableExists(JdbcTemplate jdbc, String schema, String table) {\n    Integer n = jdbc.queryForObject(\n        \"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=? AND TABLE_NAME=?\",\n        Integer.class, schema, table);\n    return n != null && n > 0;\n}\n// call before constructing the store; enable initialize-schema if false","typeGuard":null,"tryCatchPattern":"try {\n    vectorStore = new MariaDBVectorStore(...); // init validates schema\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"does not exist\")) {\n        // trigger schema creation or fail startup with clear message\n    }\n}","preventionTips":["Enable spring.ai.vectorstore.mariadb.initialize-schema=true in dev and staging.","Run schema migrations (Flyway/Liquibase) that create the vector table before app start.","Validate configured schema/table names against the target DB in CI.","Confirm JDBC URL points to the intended environment."],"tags":["mariadb","schema-validation","vector-store","database"],"backgroundTag":"schema-validation-failed","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}