apache/seatunnel · warning
Failed to get index info for table
Error message
Failed to get index info for table {}, returning empty constraint keys. Error: {} What it means
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.
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.
Example fix
// before (assuming keys exist)
List<String> pks = CatalogUtils.getConstraintKeys(...).get("PRIMARY");
// after
List<String> pks = Optional.ofNullable(CatalogUtils.getConstraintKeys(...).get("PRIMARY"))
.orElse(Collections.emptyList()); Defensive patterns
Strategy: fallback
Validate before calling
// Pre-check driver metadata support
DatabaseMetaData md = connection.getMetaData();
try (ResultSet rs = md.getIndexInfo(null, null, tableName, false, false)) {
// supported if this executes without exception
} Try / catch
Map<String,List<String>> keys = CatalogUtils.getConstraintKeys(...);
if (keys.isEmpty()) {
LOG.info("No constraint keys available for {} — supplying PK manually", tablePath);
}
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- Can't create JdbcDialect without compatible mode for Hive
- Column not found in table
- Column ' ' not found in .COLUMNS for table ; assuming NOT…
- COMMON-17
- DATABASE_NOT_EXISTED
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/bdf98fe4090bf08f.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:207
}
return ConstraintKey.of(
constraintType, indexName, new ArrayList<>());
});
ConstraintKey.ColumnSortType sortType =
"A".equalsIgnoreCase(resultSet.getString("ASC_OR_DESC"))
? ConstraintKey.ColumnSortType.ASC
: ConstraintKey.ColumnSortType.DESC;
ConstraintKey.ConstraintKeyColumn constraintKeyColumn =
new ConstraintKey.ConstraintKeyColumn(columnName, sortType);
constraintKey.getColumnNames().add(constraintKeyColumn);
}
return new ArrayList<>(constraintKeyMap.values());
}
} catch (SQLException e) {
// Some JDBC drivers (e.g., Hive/Inceptor) do not fully support getIndexInfo()
// Return empty list as index information is not mandatory for table schema
log.warn(
"Failed to get index info for table {}, returning empty constraint keys. Error: {}",
tablePath,
e.getMessage());
return Collections.emptyList();
}
}
private static String cleanKeyName(String keyName) {
if (keyName != null) {
// only keep the characters that are valid in an index name
keyName = keyName.replaceAll("[^a-zA-Z0-9_]", "");
keyName = keyName.replaceAll("^_+", "");
}
return keyName;
}
public static TableSchema getTableSchema(
DatabaseMetaData metadata, TablePath tablePath, JdbcDialectTypeMapper typeMapper)View on GitHub (pinned to cf67b549a7)