OtterMind/Chat2DB · error · IllegalArgumentException
Redshift table name must not be empty
Error message
Redshift table name must not be empty
What it means
Thrown by RedshiftMetaData.buildShowCreateTableSql when tableName is null or empty. This method constructs a SHOW CREATE TABLE SQL for Redshift (which inherits from PostgreSQL). A null or empty table name makes the qualified identifier invalid. Note: unlike PrestoMetaData which uses isBlank (also catches whitespace-only), this uses a simpler null-or-isEmpty check.
Source
Thrown at chat2db-community-server/chat2db-community-plugins/chat2db-community-redshift/src/main/java/ai/chat2db/plugin/redshift/RedshiftMetaData.java:42
@Override
public ISQLIdentifierProcessor getSQLIdentifierProcessor() {
return RedshiftIdentifierProcessor.INSTANCE;
}
@Override
public String tableDDL(Connection connection, String databaseName, String schemaName, String tableName) {
String sql = buildShowCreateTableSql(schemaName, tableName);
return DefaultSQLExecutor.getInstance().execute(connection, sql, resultSet -> {
if (resultSet.next()) {
return resultSet.getString(1);
}
return null;
});
}
static String buildShowCreateTableSql(String schemaName, String tableName) {
if (tableName == null || tableName.isEmpty()) {
throw new IllegalArgumentException("Redshift table name must not be empty");
}
String qualifiedName = schemaName == null || schemaName.isEmpty()
? RedshiftIdentifierProcessor.INSTANCE.quoteIdentifierAlways(tableName)
: RedshiftIdentifierProcessor.INSTANCE.quoteIdentifierAlways(schemaName) + "."
+ RedshiftIdentifierProcessor.INSTANCE.quoteIdentifierAlways(tableName);
return "SHOW CREATE TABLE " + qualifiedName;
}
@Override
public List<TableIndex> indexes(Connection connection, String databaseName, String schemaName, String tableName) {
return DefaultSQLExecutor.getInstance().indexes(connection, StringUtils.isEmpty(databaseName) ? null : databaseName, StringUtils.isEmpty(schemaName) ? null : schemaName, tableName);
}
@Override
public Function function(Connection connection, @NotEmpty String databaseName, String schemaName,
String functionName) {
return DefaultSQLExecutor.getInstance().preExecute(connection, FUNCTION_DEFINITION, new String[]{functionName,schemaName}, resultSet -> {
Function function = new Function();View on GitHub (pinned to 5ee1e990e7)
Solutions
- Validate that tableName is non-null and non-empty before calling tableDDL
- Guard the UI so tableDDL is only invoked with a concrete table selection
- Consider also checking isBlank to catch whitespace-only names that pass isEmpty
Example fix
// before
String ddl = metaData.tableDDL(conn, db, schema, "");
// after
if (tableName == null || tableName.trim().isEmpty()) {
throw new IllegalArgumentException("Table name required");
}
String ddl = metaData.tableDDL(conn, db, schema, tableName); Defensive patterns
Strategy: validation
Validate before calling
if (tableName == null || tableName.isEmpty()) {
throw new IllegalArgumentException("Redshift table name must not be empty");
}
// Also catch whitespace-only names that pass isEmpty but would fail downstream:
if (tableName.trim().isEmpty()) {
throw new IllegalArgumentException("Table name is whitespace-only");
}
String sql = RedshiftMetaData.buildShowCreateTableSql(schemaName, tableName); Prevention
- Validate tableName is non-null and non-empty before calling tableDDL
- Also check isBlank to catch whitespace-only names
- Guard the UI so tableDDL is only called with a concrete table selection
When it happens
Trigger: Calling RedshiftMetaData.tableDDL(connection, databaseName, schemaName, tableName) where tableName is null or has length 0. The validation runs in buildShowCreateTableSql at line 41.
Common situations: A UI selection event fired before a table node is chosen; a null table name from a metadata tree; programmatic callers passing an unvalidated identifier; a whitespace-only table name that passes this check but would fail downstream.
Related errors
- Presto table name must not be blank
- Presto schema name is required when catalog name is provided
- Invalid generic {what}: {value}
- Unsafe column type name from metadata: {typeName}
- Unsafe H2 column default from metadata: {columnDefault}
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/00d201ee36d45632.
Report an issue: GitHub.