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
- Enable the 'null value to null' option in the SQL export dialog so empty cells are emitted as NULL.
- Set a default value for the column in the SQL export options.
- Fill or impute the empty cells in the project before exporting.
- 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
- Turn on 'null value to null' when your data may contain blank cells.
- Configure per-column defaults for NOT NULL columns.
- Audit for empty cells before export with a facet on blank values.
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
- is not compatible with column type
- ****NO COLUMNS SELECTED****
- ****NO OPTIONS PRESENT****
- is not compatible with column type
- Arrays and objects aren't comparable
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)