apache/flink · error · ValidationException

Format cannot define a quote character and disabled quote ch

Error message

Format cannot define a quote character and disabled quote character at the same time.

What it means

Validation error from CsvCommons.validateFormatOptions(): the CSV format options simultaneously specify a 'csv.quote-character' value and set 'csv.disable-quote-character' to true. These are contradictory — one demands a specific quote char, the other disables quoting entirely — so table creation fails fast with ValidationException before any job runs.

Source

Thrown at flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvCommons.java:58

import static org.apache.flink.formats.csv.CsvFormatOptions.NULL_LITERAL;
import static org.apache.flink.formats.csv.CsvFormatOptions.QUOTE_CHARACTER;
import static org.apache.flink.formats.csv.CsvFormatOptions.TRIM_SPACES;
import static org.apache.flink.formats.csv.CsvFormatOptions.WRITE_BIGDECIMAL_IN_SCIENTIFIC_NOTATION;

/** A class with common CSV format constants and utility methods. */
class CsvCommons {

    public static final String IDENTIFIER = "csv";

    // ------------------------------------------------------------------------
    //  Validation
    // ------------------------------------------------------------------------

    static void validateFormatOptions(ReadableConfig tableOptions) {
        final boolean hasQuoteCharacter = tableOptions.getOptional(QUOTE_CHARACTER).isPresent();
        final boolean isDisabledQuoteCharacter = tableOptions.get(DISABLE_QUOTE_CHARACTER);
        if (isDisabledQuoteCharacter && hasQuoteCharacter) {
            throw new ValidationException(
                    "Format cannot define a quote character and disabled quote character at the same time.");
        }
        // Validate the option value must be a single char.
        validateCharacterVal(tableOptions, FIELD_DELIMITER, true);
        validateCharacterVal(tableOptions, ARRAY_ELEMENT_DELIMITER);
        validateCharacterVal(tableOptions, QUOTE_CHARACTER);
        validateCharacterVal(tableOptions, ESCAPE_CHARACTER);
    }

    /** Validates the option {@code option} value must be a Character. */
    private static void validateCharacterVal(
            ReadableConfig tableOptions, ConfigOption<String> option) {
        validateCharacterVal(tableOptions, option, false);
    }

    /**
     * Validates the option {@code option} value must be a Character.
     *

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. If quoted CSV is desired, remove 'csv.disable-quote-character'.
  2. If unquoted CSV is desired, remove 'csv.quote-character' and keep 'csv.disable-quote-character'='true'.
  3. Lint DDLs that combine csv.* options before submission.

Example fix

-- before
'format'='csv',
'csv.quote-character'='|',
'csv.disable-quote-character'='true'

-- after
'format'='csv',
'csv.quote-character'='|'
Defensive patterns

Strategy: validation

Validate before calling

// Lint options before table creation:
boolean hasQuote = options.toMap().containsKey("csv.quote-character");
boolean disableQuote = "true"
    .equalsIgnoreCase(options.toMap().getOrDefault("csv.disable-quote-character", "false"));
if (hasQuote && disableQuote) {
    throw new ValidationException("Remove one of csv.quote-character / csv.disable-quote-character");
}

Prevention

When it happens

Trigger: A WITH clause containing both 'csv.quote-character'='"' (or any char) and 'csv.disable-quote-character'='true'. Raised during FactoryUtil option validation when the Csv format factory creates either a source or sink.

Common situations: Copy-pasted format option blocks where users append disable-quote-character to an existing template that already sets a quote character; YAML/SQL templating that merges option maps; intent to switch to unquoted CSV without removing the old option.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/d014a8773e7c2f20. Report an issue: GitHub.