apache/seatunnel · error · FileConnectorException

TABLE_SCHEMA_GET_FAILED

TABLE_SCHEMA_GET_FAILED

Error message

Get table schema from file [%s] failed

What it means

When the Hive table is PARQUET or ORC, the schema is inferred by reading the first data file via readStrategy.getSeaTunnelRowTypeInfo(). If that read raises FileConnectorException, it is wrapped as TABLE_SCHEMA_GET_FAILED with the offending file path in the message.

Source

Thrown at seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/source/config/HiveSourceConfig.java:333

            ReadonlyConfig readonlyConfig, Table table) {
        // Keep a stable schema even when directory is empty.
        return buildCatalogTableFromHiveMeta(readonlyConfig, table);
    }

    private CatalogTable parseCatalogTableFromRemotePath(
            ReadonlyConfig readonlyConfig,
            HadoopConf hadoopConf,
            List<String> filePaths,
            Table table) {
        CatalogTable catalogTable = buildEmptyCatalogTable(readonlyConfig, table);
        try {
            SeaTunnelRowType seaTunnelRowTypeInfo =
                    readStrategy.getSeaTunnelRowTypeInfo(filePaths.get(0));
            return CatalogTableUtil.newCatalogTable(catalogTable, seaTunnelRowTypeInfo);
        } catch (FileConnectorException e) {
            String errorMsg =
                    String.format("Get table schema from file [%s] failed", filePaths.get(0));
            throw new FileConnectorException(
                    CommonErrorCodeDeprecated.TABLE_SCHEMA_GET_FAILED, errorMsg, e);
        }
    }

    private CatalogTable parseCatalogTableFromTable(
            ReadonlyConfig readonlyConfig, ReadStrategy readStrategy, Table table) {
        SeaTunnelRowType seaTunnelRowType = buildRowTypeFromHiveMeta(table);
        readStrategy.setCatalogTable(
                CatalogTableUtil.getCatalogTable(
                        "hive", table.getDbName(), null, table.getTableName(), seaTunnelRowType));
        final SeaTunnelRowType finalSeatunnelRowType = readStrategy.getActualSeaTunnelRowTypeInfo();

        CatalogTable catalogTable = buildEmptyCatalogTable(readonlyConfig, table);
        return CatalogTableUtil.newCatalogTable(catalogTable, finalSeatunnelRowType);
    }

    /**
     * Build a {@link CatalogTable} based on Hive metastore schema (table columns + optional

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Open the reported file directly (e.g. `hdfs dfs -cat` / parquet-tools) to check it is readable and not corrupt
  2. Verify the job user has read permission on the file path; adjust HDFS permissions or run as the correct user/kerberos principal
  3. Delete or repair the corrupt file (or point table_paths at a healthy partition) so a good file becomes the schema source
  4. If the file's schema is intentionally unusual, upgrade/align the connector's parquet-orc library versions, or rewrite the data

Example fix

// before: corrupt or unreadable first file used for schema inference
// after: ensure healthy files
hdfs fsck /user/hive/warehouse/db.db/tbl -files -blocks
# remove/repair corrupt files, then rerun the SeaTunnel job
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify the schema source file is readable before running the job
org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
org.apache.hadoop.fs.Path p = new org.apache.hadoop.fs.Path(firstFilePath);
try (org.apache.hadoop.fs.FSDataInputStream in = p.getFileSystem(conf).open(p)) {
    in.read(); // probe read
}

Try / catch

try {
    // ... build/submit Hive source
} catch (org.apache.seatunnel.connectors.seatunnel.hive.exception.HiveConnectorException e) {
    if ("TABLE_SCHEMA_GET_FAILED".equals(e.getSeaTunnelErrorCode().getCode())) {
        LOG.error("Schema inference failed on file {} - verify it is readable/uncorrupt", e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: parseCatalogTableFromRemotePath() calls readStrategy.getSeaTunnelRowTypeInfo(filePaths.get(0)) and the underlying reader throws FileConnectorException — e.g. corrupt/inaccessible first file, checksum failure, unsupported schema in the file, or HDFS read IO error.

Common situations: First file under the table/partition is truncated or corrupted; permissions prevent reading the file as the job user; a parquet/orc file with an incompatible or empty schema; HDFS namenode unreachable during schema read.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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