{"record":{"id":"2bf2d4e89808dc5f","repo":"apache/seatunnel","slug":"influxdb-query-returned-empty-results-using-defau","errorCode":null,"errorMessage":"InfluxDB query returned empty results, using default column index mapping.","messagePattern":"InfluxDB query returned empty results, using default column index mapping\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-influxdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/influxdb/source/InfluxDBSource.java","lineNumber":119,"sourceCode":"\n    private List<Integer> initColumnsIndex(InfluxDB influxdb) {\n        // query one row to get column info\n        String sql = sourceConfig.getSql();\n        String query = sql + QUERY_LIMIT;\n        // if sql contains tz(), can't be append QUERY_LIMIT at last . see bug #4231\n        int start = containTzFunction(sql.toLowerCase());\n        if (start > 0) {\n            StringBuilder tmpSql = new StringBuilder(sql);\n            tmpSql.insert(start - 1, QUERY_LIMIT).append(\" \");\n            query = tmpSql.toString();\n        }\n\n        try {\n            QueryResult queryResult = influxdb.query(new Query(query, sourceConfig.getDatabase()));\n\n            List<QueryResult.Result> results = queryResult.getResults();\n            if (CollectionUtils.isEmpty(results)) {\n                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(","sourceCodeStart":101,"sourceCodeEnd":137,"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#L101-L137","documentation":"InfluxDBSource.initColumnsIndex issues a metadata query against InfluxDB to map field names to column indexes; when the query returns an empty result list, the connector falls back to a default column index mapping and logs this warning. Mapping may then not match the actual measurement schema, so downstream field ordering can be wrong.","triggerScenarios":"Calling columnsIndexList/initColumnsIndex where influxdb.query(new Query(query, database)) returns QueryResult with null/empty results — e.g. the database doesn't exist, the measurement has no data, the query/measurement name is wrong, or InfluxDB is unreachable in a way that yields empty results rather than an error.","commonSituations":"Typo in database or measurement name in source config; querying an empty database in a fresh test environment; SQL/query field misconfigured so the SHOW FIELD KEYS-style query matches nothing; wrong InfluxDB URL pointing at another instance.","solutions":["Verify the source config's database and measurement/query settings point at a database that exists and has data","Run the same query manually (via influx CLI or HTTP /query endpoint) to confirm it returns results","Check InfluxDB connectivity (URL, port, credentials) in the SeaTunnel config","If the default mapping is unacceptable, define the schema explicitly via the source's schema configuration instead of relying on metadata discovery"],"exampleFix":"// before\nurl = \"http://localhost:8086\"\ndatabase = \"metrics\"   // does not exist\n// after\nurl = \"http://influxdb:8086\"\ndatabase = \"prod_metrics\"  // existing database with data","handlingStrategy":"validation","validationCode":"QueryResult qr = influxdb.query(new Query(\"SHOW MEASUREMENTS\", database));\nboolean hasData = qr.getResults() != null\n    && qr.getResults().stream().anyMatch(r -> r.getSeries() != null && !r.getSeries().isEmpty());\nif (!hasData) throw new IllegalStateException(\"InfluxDB database '\" + database + \"' empty or unreachable\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify database and measurement names in the source config before launching","Pre-seed or confirm the measurement has data for the query's filters","Run the discovery query manually via the influx CLI first","Prefer explicit SeaTunnel schema configuration over automatic metadata discovery in prod"],"tags":["influxdb","source","metadata","empty-result"],"backgroundTag":"empty-result-set","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"}