{"record":{"id":"6c7e4e28c1d423f3","repo":"apache/beam","slug":"table-with-type-text-must-have-format-csv-or-lines-or-json","errorCode":null,"errorMessage":"Table with type 'text' must have format 'csv' or 'lines' or 'json'","messagePattern":"Table with type 'text' must have format 'csv' or 'lines' or 'json'","errorType":"validation","errorClass":"InvalidTableException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/text/TextTableProvider.java","lineNumber":127,"sourceCode":"                : (legacyCsvFormat != null\n                    ? CSVFormat.valueOf(legacyCsvFormat)\n                    : CSVFormat.DEFAULT);\n        return new TextTable(\n            schema, filePattern, new CsvToRow(schema, csvFormat), new RowToCsv(csvFormat));\n      case \"json\":\n        return new TextJsonTable(\n            schema, filePattern, JsonToRow.create(schema, deadLetterFile), RowToJson.create());\n      case \"lines\":\n        if (!(schema.getFieldCount() == 1\n            && schema.getField(0).getType().getTypeName().equals(TypeName.STRING))) {\n          throw new InvalidTableException(\n              \"Table with type 'text' and format 'lines' \"\n                  + \"must have exactly one STRING/VARCHAR/CHAR column \");\n        }\n        return new TextTable(\n            schema, filePattern, new LinesReadConverter(), new LinesWriteConverter());\n      default:\n        throw new InvalidTableException(\n            \"Table with type 'text' must have format 'csv' or 'lines' or 'json'\");\n    }\n  }\n\n  /** Write-side converter for for {@link TextTable} with format {@code 'lines'}. */\n  public static class LinesWriteConverter extends PTransform<PCollection<Row>, PCollection<String>>\n      implements Serializable {\n\n    public LinesWriteConverter() {}\n\n    @Override\n    public PCollection<String> expand(PCollection<Row> input) {\n      return input.apply(\n          \"rowsToLines\",\n          MapElements.into(TypeDescriptors.strings()).via((Row row) -> row.getString(0) + \"\\n\"));\n    }\n  }\n","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/text/TextTableProvider.java#L109-L145","documentation":"TextTableProvider.buildBeamSqlTable validates the 'format' table property when creating a Beam SQL table over text files. Only 'csv', 'lines', and 'json' formats are supported; any other value is rejected via InvalidTableException. This prevents silently misinterpreting file contents at read time.","triggerScenarios":"Calling createTable/BeamSqlEnv with a Table whose getType() is 'text' and whose properties map has a 'format' key with a value other than csv/lines/json (or a misspelled/uppercase value, since matching is on the switch of the format string).","commonSituations":"Typos like format='txt' or 'JSON' in a CREATE EXTERNAL TABLE DDL statement; copying config from another provider (e.g. parquet) into a text table; programmatic Table builders built with arbitrary property maps.","solutions":["Set the table property format to one of 'csv', 'lines', or 'json'.","Fix casing/typos in the DDL: FORMAT TYPE 'csv' (values are matched literally).","If the data is not line-delimited text, choose a different table provider type (e.g. parquet, avro) instead of 'text'."],"exampleFix":"// before\nCREATE EXTERNAL TABLE orders (id INT) TYPE 'text' LOCATION '/data/orders.txt' TBLPROPERTIES '{\"format\":\"txt\"}'\n// after\nCREATE EXTERNAL TABLE orders (id INT) TYPE 'text' LOCATION '/data/orders.txt' TBLPROPERTIES '{\"format\":\"csv\"}'","handlingStrategy":"validation","validationCode":"String fmt = (String) table.getProperties().get(\"format\");\nif (!\"csv\".equals(fmt) && !\"lines\".equals(fmt) && !\"json\".equals(fmt)) {\n  throw new IllegalArgumentException(\"text table format must be csv|lines|json, got: \" + fmt);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep table properties in constants/enums rather than raw strings.","Copy format values from working examples in Beam docs.","Validate DDL properties in CI with a table-creation smoke test."],"tags":["beam-sql","text-table","config-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}