OpenRefine/OpenRefine · error · SqlExporterException

Null value not allowed for Field

Error message

Null value not allowed for Field :${col}

What it means

SqlInsertBuilder.handleNullField throws SqlExporterException when a cell is empty/null, the 'null value to null' option is off, and no usable default value exists for the column. The exporter refuses to emit an INSERT because it cannot produce a value for the NOT-DEFAULTED empty field.

Solutions

  1. Enable the 'null value to null' option in the SQL export dialog so empty cells are emitted as NULL.
  2. Set a default value for the column in the SQL export options.
  3. Fill or impute the empty cells in the project before exporting.
  4. Exclude columns with many empty cells from the export.

Example fix

// before (options)
{"nullValueNull":false}
// after
{"nullValueNull":true}
Defensive patterns

Strategy: validation

Validate before calling

// before export
boolean hasBlanks = project.rows.stream()
    .anyMatch(r -> r.getCellValue(col) == null || r.getCellValue(col).toString().isEmpty());
if (hasBlanks && !options.getBoolean("nullValueNull") && isEmpty(options.getDefaultValue(col))) {
    options.put("nullValueNull", true); // or set a default
}

Try / catch

try { insertBuilder.getInsertSQL(); } catch (SqlExporterException e) { if (e.getMessage().startsWith("Null value not allowed")) { options.put("nullValueNull", true); rebuildAndRetry(); } else { throw e; } }

Prevention

When it happens

Trigger: Exporting rows containing empty cells to SQL with 'nullValueNull' disabled and no default value configured for that column.

Common situations: Sparse datasets with blank cells exported with default options; users unaware that the SQL export options require either 'convert nulls to NULL' or a per-column default.

Related errors


AI-assisted analysis of OpenRefine/OpenRefine@a946177e04 (2026-09-08). Data as JSON: /api/errors/518083428fc83c35. Report an issue: GitHub.

Appendix: source

Thrown at main/src/com/google/refine/exporters/sql/SqlInsertBuilder.java:237

            boolean nullValueNull,
            String col,
            StringBuilder rowValue,
            boolean quote) {

        if (allowNullChkBox) {// cell nullable
            if (defaultValue != null && !defaultValue.isEmpty()) {
                if (quote) {
                    rowValue.append("'" + defaultValue + "'");
                } else {
                    rowValue.append(defaultValue);
                }

            } else {
                if (nullValueNull) {
                    rowValue.append("null");

                } else {
                    throw new SqlExporterException("Null value not allowed for Field :" + col);
                }

            }

        } else {
            if (defaultValue != null && !defaultValue.isEmpty()) {
                if (quote) {
                    rowValue.append("'" + defaultValue + "'");
                } else {
                    rowValue.append(defaultValue);
                }

            } else {
                throw new SqlExporterException("Null value not allowed for Field :" + col);
            }

        }

View on GitHub (pinned to a946177e04)