apache/seatunnel · error · InfluxdbConnectorException

GET_COLUMN_INDEX_FAILED

GET_COLUMN_INDEX_FAILED

Error message

Get column index of query result exception

What it means

InfluxDBSource.initColumnsIndex() maps each SeaTunnel catalog column name to its index in the first InfluxDB query series' columns. Any exception during this mapping (e.g., empty serieList, missing column names) is wrapped in a GET_COLUMN_INDEX_FAILED exception.

Source

Thrown at seatunnel-connectors-v2/connector-influxdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/influxdb/source/InfluxDBSource.java:137

                log.warn(
                        "InfluxDB query returned empty results, using default column index mapping.");
                return buildDefaultColumnsIndex();
            }

            List<QueryResult.Series> serieList = results.get(0).getSeries();
            if (CollectionUtils.isEmpty(serieList)) {
                log.warn(
                        "InfluxDB query returned no series (empty data), using default column index mapping.");
                return buildDefaultColumnsIndex();
            }

            List<String> fieldNames = new ArrayList<>(serieList.get(0).getColumns());

            return Arrays.stream(catalogTable.getSeaTunnelRowType().getFieldNames())
                    .map(fieldNames::indexOf)
                    .collect(Collectors.toList());
        } catch (Exception e) {
            throw new InfluxdbConnectorException(
                    InfluxdbConnectorErrorCode.GET_COLUMN_INDEX_FAILED,
                    "Get column index of query result exception",
                    e);
        }
    }

    /**
     * Builds a default column index list based on the catalog table schema. Used when the query
     * returns no data, where actual column indices are not needed since no rows will be read.
     */
    private List<Integer> buildDefaultColumnsIndex() {
        int fieldCount = catalogTable.getSeaTunnelRowType().getTotalFields();
        List<Integer> defaultIndexList = new ArrayList<>(fieldCount);
        for (int i = 0; i < fieldCount; i++) {
            defaultIndexList.add(i);
        }
        return defaultIndexList;
    }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Ensure the SeaTunnel source schema field names exactly match the columns returned by the InfluxQL query.
  2. Run the query manually in InfluxDB to confirm it returns data and the expected columns.
  3. Align the SELECT list (fields and tags) with the declared catalog columns.
  4. Add proper WHERE time-range conditions so the query returns at least one series.

Example fix

// before
query = "SELECT temperature FROM metrics"
catalogColumns = ["time", "temperature"]
// after
query = "SELECT time, temperature FROM metrics" // columns match catalog field names
Defensive patterns

Strategy: validation

Validate before calling

// verify query columns cover schema before running
List<String> fieldNames = /* from query result series */;
for (String col : catalogTable.getSeaTunnelRowType().getFieldNames()) {
    if (!fieldNames.contains(col)) throw new IllegalStateException("Column missing in query result: " + col);
}

Try / catch

try {
    source.initColumnsIndex();
} catch (InfluxdbConnectorException e) {
    log.error("Column mapping failed; check schema vs InfluxQL result columns", e);
    throw e;
}

Prevention

When it happens

Trigger: The InfluxQL query returns no series or different column names than the configured SeaTunnelRowType field names, so indexOf() mapping or serieList.get(0) fails.

Common situations: Schema drift in InfluxDB measurement (renamed/dropped fields), catalog table columns not matching the query's SELECT list, or query returning empty results for the given time range/where clause.

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/02aca78bdb0ac3a2. Report an issue: GitHub.