apache/seatunnel · error · DatabendConnectorException

SCHEMA_NOT_FOUND

SCHEMA_NOT_FOUND

Error message

Source table schema is empty or null

What it means

Thrown by initTraditionalMode when the source CatalogTable's SeaTunnelRowType is null or has zero fields. The writer needs the source schema to generate the target-table DDL and INSERT SQL, so an empty schema is a hard stop.

Source

Thrown at seatunnel-connectors-v2/connector-databend/src/main/java/org/apache/seatunnel/connectors/seatunnel/databend/sink/DatabendSinkWriter.java:197

                    DatabendConnectorErrorCode.SQL_OPERATION_FAILED,
                    "Raw table name not set by AggregatedCommitter. Cannot initialize CDC PreparedStatement.");
        }

        // Generate insert SQL for raw table
        String insertRawSql = generateInsertRawSql(sinkTablePath.getDatabaseName());

        // Create the PreparedStatement
        this.cdcPreparedStatement = connection.prepareStatement(insertRawSql);
        this.cdcPreparedStatement.setQueryTimeout(executeTimeoutSec);

        log.info("CDC PreparedStatement created successfully with SQL: {}", insertRawSql);
    }

    private void initTraditionalMode(String database, String table) throws SQLException {
        // use the catalog table schema to create the target table
        SeaTunnelRowType rowType = catalogTable.getSeaTunnelRowType();
        if (rowType == null || rowType.getFieldNames().length == 0) {
            throw new DatabendConnectorException(
                    DatabendConnectorErrorCode.SCHEMA_NOT_FOUND,
                    "Source table schema is empty or null");
        }

        this.insertSql = generateInsertSql(database, table, rowType);
        log.info("Generated insert SQL: {}", insertSql);
        try {
            this.schemaChangeManager = new SchemaChangeManager(databendSinkConfig);
            this.preparedStatement = connection.prepareStatement(insertSql);
            this.preparedStatement.setQueryTimeout(executeTimeoutSec);
            log.info("PreparedStatement created successfully");
        } catch (SQLException e) {
            throw new DatabendConnectorException(
                    DatabendConnectorErrorCode.SQL_OPERATION_FAILED,
                    "Failed to prepare statement: " + e.getMessage(),
                    e);
        }
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Fix the upstream source configuration so it discovers/emits a real schema (e.g. correct table/query, metadata readable).
  2. Check for transforms between source and sink that remove all fields.
  3. Confirm source and sink plugin versions are compatible and the CatalogTable is populated.
  4. Add a pre-flight check in the job: print the resolved schema via the REST API/CLI before running.

Example fix

// before
Filter transform: sql = "SELECT 1 FROM source" // drops all columns
// after
Filter transform: sql = "SELECT id, name, ts FROM source" // schema preserved
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight:
SeaTunnelRowType rt = catalogTable.getSeaTunnelRowType();
if (rt == null || rt.getFieldNames().length == 0) throw new IllegalArgumentException("Upstream produced an empty schema — fix source/transform config");

Type guard

boolean hasSchema(CatalogTable t) { return t != null && t.getSeaTunnelRowType() != null && t.getSeaTunnelRowType().getFieldNames().length > 0; }

Prevention

When it happens

Trigger: catalogTable.getSeaTunnelRowType() returns null or fieldNames.length == 0 — the upstream produced a catalog table with no columns (bad source config, unsupported source type, or a transform stripped all fields).

Common situations: Source connector misconfigured so it emits no fields; fake/source with empty schema used in testing; a Filter/Transform projecting away all columns; API/connector version mismatch producing an unpopulated CatalogTable.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/ac9f3c260142e4f9. Report an issue: GitHub.