{"record":{"id":"bdf98fe4090bf08f","repo":"apache/seatunnel","slug":"failed-to-get-index-info-for-table-returning-e","errorCode":null,"errorMessage":"Failed to get index info for table {}, returning empty constraint keys. Error: {}","messagePattern":"Failed to get index info for table (.+?), returning empty constraint keys\\. Error: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java","lineNumber":207,"sourceCode":"                                        }\n                                        return ConstraintKey.of(\n                                                constraintType, indexName, new ArrayList<>());\n                                    });\n\n                    ConstraintKey.ColumnSortType sortType =\n                            \"A\".equalsIgnoreCase(resultSet.getString(\"ASC_OR_DESC\"))\n                                    ? ConstraintKey.ColumnSortType.ASC\n                                    : ConstraintKey.ColumnSortType.DESC;\n                    ConstraintKey.ConstraintKeyColumn constraintKeyColumn =\n                            new ConstraintKey.ConstraintKeyColumn(columnName, sortType);\n                    constraintKey.getColumnNames().add(constraintKeyColumn);\n                }\n                return new ArrayList<>(constraintKeyMap.values());\n            }\n        } catch (SQLException e) {\n            // Some JDBC drivers (e.g., Hive/Inceptor) do not fully support getIndexInfo()\n            // Return empty list as index information is not mandatory for table schema\n            log.warn(\n                    \"Failed to get index info for table {}, returning empty constraint keys. Error: {}\",\n                    tablePath,\n                    e.getMessage());\n            return Collections.emptyList();\n        }\n    }\n\n    private static String cleanKeyName(String keyName) {\n        if (keyName != null) {\n            // only keep the characters that are valid in an index name\n            keyName = keyName.replaceAll(\"[^a-zA-Z0-9_]\", \"\");\n            keyName = keyName.replaceAll(\"^_+\", \"\");\n        }\n        return keyName;\n    }\n\n    public static TableSchema getTableSchema(\n            DatabaseMetaData metadata, TablePath tablePath, JdbcDialectTypeMapper typeMapper)","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java#L189-L225","documentation":"CatalogUtils.getConstraintKeys() inspects primary-key/index info via JDBC DatabaseMetaData.getIndexInfo(). Some drivers (notably Hive/Inceptor) throw SQLException from getIndexInfo(); since index data is optional for building the table schema, the method logs this warning and returns an empty constraint-key list rather than failing.","triggerScenarios":"Calling constraintKeys/getConstraintKeys on a table whose driver's getIndexInfo() throws SQLException — unsupported metadata call, transient connection issue, or table absent from the driver's metadata view.","commonSituations":"Reading Hive/Inceptor or other limited JDBC-driver tables where getIndexInfo is not implemented; building sink schemas without primary keys; connecting through gateway drivers with partial metadata support.","solutions":["Accept the empty constraint list — schema reading proceeds without PK info; add keys manually downstream if needed.","Upgrade or replace the JDBC driver with one implementing getIndexInfo().","If PK info is required, fetch keys from an alternate source (e.g., DESCRIBE FORMATTED for Hive) and inject them.","Wrap the call and treat empty constraintKeys as 'unknown', not 'no keys', in downstream logic."],"exampleFix":"// before (assuming keys exist)\nList<String> pks = CatalogUtils.getConstraintKeys(...).get(\"PRIMARY\");\n// after\nList<String> pks = Optional.ofNullable(CatalogUtils.getConstraintKeys(...).get(\"PRIMARY\"))\n        .orElse(Collections.emptyList());","handlingStrategy":"fallback","validationCode":"// Pre-check driver metadata support\nDatabaseMetaData md = connection.getMetaData();\ntry (ResultSet rs = md.getIndexInfo(null, null, tableName, false, false)) {\n    // supported if this executes without exception\n}","typeGuard":null,"tryCatchPattern":"Map<String,List<String>> keys = CatalogUtils.getConstraintKeys(...);\nif (keys.isEmpty()) {\n    LOG.info(\"No constraint keys available for {} — supplying PK manually\", tablePath);\n}\n","preventionTips":["Treat empty constraintKeys as 'unknown' rather than 'no primary key'","Use drivers that fully implement DatabaseMetaData.getIndexInfo()","For Hive, source PK info from DESCRIBE FORMATTED instead of JDBC metadata"],"tags":["jdbc","metadata","index","hive","driver-compatibility"],"backgroundTag":"unsupported-operation","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}