{"record":{"id":"f16704638ddf2f72","repo":"apache/seatunnel","slug":"seatunnelapierrorcode-config-validation-failed-f16704","errorCode":"SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED","errorMessage":"When reading csv files, if user has not specified schema information, SeaTunnel will not support column projection","messagePattern":"When reading csv files, if user has not specified schema information, SeaTunnel will not support column projection","errorType":"error_code","errorClass":"FileConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/CsvReadStrategy.java","lineNumber":249,"sourceCode":"        if (firstLineAsHeader && (!useSplitRead || split.getStart() == 0)) {\n            headers = new ArrayList<>(csvParser.getHeaderNames());\n        } else {\n            headers =\n                    inputCatalogTable.getTableSchema().getColumns().stream()\n                            .map(Column::getName)\n                            .collect(Collectors.toList());\n        }\n        return headers;\n    }\n\n    @Override\n    public SeaTunnelRowType getSeaTunnelRowTypeInfo(String path) {\n        this.seaTunnelRowType = CatalogTableUtil.buildSimpleTextSchema();\n        this.seaTunnelRowTypeWithPartition =\n                mergePartitionTypes(getPathForPartitionInference(path), seaTunnelRowType);\n        initFormatter();\n        if (pluginConfig.hasPath(FileBaseSourceOptions.READ_COLUMNS.key())) {\n            throw new FileConnectorException(\n                    SeaTunnelAPIErrorCode.CONFIG_VALIDATION_FAILED,\n                    \"When reading csv files, if user has not specified schema information, \"\n                            + \"SeaTunnel will not support column projection\");\n        }\n        CsvDeserializationSchema.Builder builder =\n                CsvDeserializationSchema.builder()\n                        .delimiter(getDelimiter())\n                        .csvLineProcessor(processor)\n                        .nullFormat(\n                                readonlyConfig\n                                        .getOptional(FileBaseSourceOptions.NULL_FORMAT)\n                                        .orElse(null));\n        if (isMergePartition) {\n            deserializationSchema =\n                    builder.seaTunnelRowType(this.seaTunnelRowTypeWithPartition).build();\n        } else {\n            deserializationSchema = builder.seaTunnelRowType(this.seaTunnelRowType).build();\n        }","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/source/reader/CsvReadStrategy.java#L231-L267","documentation":"When no schema is specified, CsvReadStrategy.getSeaTunnelRowTypeInfo builds a simple default text schema and cannot honor column projection. If read_columns is configured together with the default schema, it throws FileConnectorException (CONFIG_VALIDATION_FAILED) because column projection is unsupported in that combination.","triggerScenarios":"Using a CSV file source without schema info (default built-in schema) while setting read_columns = [\"a\",\"b\"] in the config — raised when the row type info is initialized.","commonSituations":"Users adding read_columns for performance on schema-less CSV sources; configs migrated from Parquet/JSON sources where projection works; not realizing schema must be declared for projection.","solutions":["Remove the read_columns option when using the default CSV schema.","Specify an explicit schema for the CSV source (e.g. via schema option/catalog table) so projection is supported, then keep read_columns.","Use a transform (Filter/Sql) after the source to drop unwanted columns instead."],"exampleFix":"// before (schema-less CSV)\nread_columns = [\"name\", \"age\"]\n// after\n# remove read_columns, or declare a schema first:\nschema = { fields { name = \"string\", age = \"int\" } }\nread_columns = [\"name\", \"age\"]","handlingStrategy":"validation","validationCode":"// Java\nif (!hasExplicitSchema(config) && config.hasPath(\"read_columns\")) {\n    throw new IllegalArgumentException(\n        \"read_columns requires an explicit schema for CSV sources\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare a schema for CSV sources whenever you need column projection.","Do not copy read_columns configs from Parquet/JSON sources to schema-less CSV.","Prefer a downstream transform to drop columns when no schema is declared."],"tags":["csv","column-projection","unsupported-feature"],"backgroundTag":"conflicting-config-options","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}