{"record":{"id":"4e083a25874689b7","repo":"apache/flink","slug":"table-options-do-not-contain-an-option-key-s-fo","errorCode":null,"errorMessage":"Table options do not contain an option key '%s' for discovering a format.","messagePattern":"Table options do not contain an option key '(.+?)' for discovering a format\\.","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileSystemTableFactory.java","lineNumber":191,"sourceCode":"    private <I, F extends EncodingFormatFactory<I>> EncodingFormat<I> discoverEncodingFormat(\n            Context context, Class<F> formatFactoryClass) {\n        FactoryUtil.TableFactoryHelper helper = FactoryUtil.createTableFactoryHelper(this, context);\n        if (formatFactoryExists(context, formatFactoryClass)) {\n            return helper.discoverEncodingFormat(formatFactoryClass, FactoryUtil.FORMAT);\n        } else {\n            return null;\n        }\n    }\n\n    /**\n     * Returns true if the format factory can be found using the given factory base class and\n     * identifier.\n     */\n    private boolean formatFactoryExists(Context context, Class<?> factoryClass) {\n        Configuration options = Configuration.fromMap(context.getCatalogTable().getOptions());\n        String identifier = options.get(FactoryUtil.FORMAT);\n        if (identifier == null) {\n            throw new ValidationException(\n                    String.format(\n                            \"Table options do not contain an option key '%s' for discovering a format.\",\n                            FactoryUtil.FORMAT.key()));\n        }\n\n        final List<Factory> factories = new LinkedList<>();\n        ServiceLoader.load(Factory.class, context.getClassLoader())\n                .iterator()\n                .forEachRemaining(factories::add);\n\n        final List<Factory> foundFactories =\n                factories.stream()\n                        .filter(f -> factoryClass.isAssignableFrom(f.getClass()))\n                        .collect(Collectors.toList());\n\n        final List<Factory> matchingFactories =\n                foundFactories.stream()\n                        .filter(f -> f.factoryIdentifier().equals(identifier))","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-connector-files/src/main/java/org/apache/flink/connector/file/table/FileSystemTableFactory.java#L173-L209","documentation":"FileSystemTableFactory.formatFactoryExists checks whether a format factory is available for a given format identifier. It first reads the 'format' option (FactoryUtil.FORMAT) from the table options. If the option is absent (null), it throws a ValidationException indicating the required 'format' key is missing. This is a table-creation-time validation.","triggerScenarios":"A CREATE TABLE statement with a filesystem connector does not include the 'format' option. For example: CREATE TABLE t (...) WITH ('connector'='filesystem', 'path'='...') without specifying 'format'='parquet' or 'format'='csv'.","commonSituations":"Omitting the 'format' option in a filesystem table DDL. Typo in the option key (e.g. 'formats' instead of 'format'). Migrating a table definition and forgetting to carry over the format option.","solutions":["Add the 'format' option to the table DDL: 'format'='parquet' (or csv, json, orc, avto, etc.).","Verify the option key is exactly 'format' (not 'file-format', 'formats', or other variants).","Ensure the format identifier matches a supported format (parquet, csv, json, orc, avro, etc.)."],"exampleFix":"-- before\nCREATE TABLE t (a INT, b STRING) WITH (\n  'connector'='filesystem',\n  'path'='file:///data'\n);\n\n-- after\nCREATE TABLE t (a INT, b STRING) WITH (\n  'connector'='filesystem',\n  'path'='file:///data',\n  'format'='parquet'\n);","handlingStrategy":"validation","validationCode":"// Validate table options before creating the table\nMap<String, String> options = catalogTable.getOptions();\nif (!options.containsKey(\"format\")) {\n    throw new ValidationException(\n        \"Filesystem connector requires the 'format' option. \"\n        + \"Supported: parquet, csv, json, orc, avro.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include 'format' in filesystem table DDLs.","Use a DDL template or linter that checks for required options.","Document supported format identifiers in your project's table creation guide."],"tags":["table-factory","format-option","validation","ddl","flink"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}