{"record":{"id":"02aca78bdb0ac3a2","repo":"apache/seatunnel","slug":"get-column-index-failed","errorCode":"GET_COLUMN_INDEX_FAILED","errorMessage":"Get column index of query result exception","messagePattern":"Get column index of query result exception","errorType":"error_code","errorClass":"InfluxdbConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-influxdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/influxdb/source/InfluxDBSource.java","lineNumber":137,"sourceCode":"                log.warn(\n                        \"InfluxDB query returned empty results, using default column index mapping.\");\n                return buildDefaultColumnsIndex();\n            }\n\n            List<QueryResult.Series> serieList = results.get(0).getSeries();\n            if (CollectionUtils.isEmpty(serieList)) {\n                log.warn(\n                        \"InfluxDB query returned no series (empty data), using default column index mapping.\");\n                return buildDefaultColumnsIndex();\n            }\n\n            List<String> fieldNames = new ArrayList<>(serieList.get(0).getColumns());\n\n            return Arrays.stream(catalogTable.getSeaTunnelRowType().getFieldNames())\n                    .map(fieldNames::indexOf)\n                    .collect(Collectors.toList());\n        } catch (Exception e) {\n            throw new InfluxdbConnectorException(\n                    InfluxdbConnectorErrorCode.GET_COLUMN_INDEX_FAILED,\n                    \"Get column index of query result exception\",\n                    e);\n        }\n    }\n\n    /**\n     * Builds a default column index list based on the catalog table schema. Used when the query\n     * returns no data, where actual column indices are not needed since no rows will be read.\n     */\n    private List<Integer> buildDefaultColumnsIndex() {\n        int fieldCount = catalogTable.getSeaTunnelRowType().getTotalFields();\n        List<Integer> defaultIndexList = new ArrayList<>(fieldCount);\n        for (int i = 0; i < fieldCount; i++) {\n            defaultIndexList.add(i);\n        }\n        return defaultIndexList;\n    }","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-influxdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/influxdb/source/InfluxDBSource.java#L119-L155","documentation":"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.","triggerScenarios":"The InfluxQL query returns no series or different column names than the configured SeaTunnelRowType field names, so indexOf() mapping or serieList.get(0) fails.","commonSituations":"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.","solutions":["Ensure the SeaTunnel source schema field names exactly match the columns returned by the InfluxQL query.","Run the query manually in InfluxDB to confirm it returns data and the expected columns.","Align the SELECT list (fields and tags) with the declared catalog columns.","Add proper WHERE time-range conditions so the query returns at least one series."],"exampleFix":"// before\nquery = \"SELECT temperature FROM metrics\"\ncatalogColumns = [\"time\", \"temperature\"]\n// after\nquery = \"SELECT time, temperature FROM metrics\" // columns match catalog field names","handlingStrategy":"validation","validationCode":"// verify query columns cover schema before running\nList<String> fieldNames = /* from query result series */;\nfor (String col : catalogTable.getSeaTunnelRowType().getFieldNames()) {\n    if (!fieldNames.contains(col)) throw new IllegalStateException(\"Column missing in query result: \" + col);\n}","typeGuard":null,"tryCatchPattern":"try {\n    source.initColumnsIndex();\n} catch (InfluxdbConnectorException e) {\n    log.error(\"Column mapping failed; check schema vs InfluxQL result columns\", e);\n    throw e;\n}","preventionTips":["Keep the catalog schema and SELECT list in lockstep.","Test the InfluxQL query manually before configuring the job.","Avoid schema drift; version your measurement schemas."],"tags":["influxdb","schema","source"],"backgroundTag":"schema-validation-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}