{"record":{"id":"518083428fc83c35","repo":"OpenRefine/OpenRefine","slug":"null-value-not-allowed-for-field-col","errorCode":null,"errorMessage":"Null value not allowed for Field :${col}","messagePattern":"Null value not allowed for Field :(.+?)","errorType":"exception","errorClass":"SqlExporterException","httpStatus":null,"severity":"error","filePath":"main/src/com/google/refine/exporters/sql/SqlInsertBuilder.java","lineNumber":237,"sourceCode":"            boolean nullValueNull,\n            String col,\n            StringBuilder rowValue,\n            boolean quote) {\n\n        if (allowNullChkBox) {// cell nullable\n            if (defaultValue != null && !defaultValue.isEmpty()) {\n                if (quote) {\n                    rowValue.append(\"'\" + defaultValue + \"'\");\n                } else {\n                    rowValue.append(defaultValue);\n                }\n\n            } else {\n                if (nullValueNull) {\n                    rowValue.append(\"null\");\n\n                } else {\n                    throw new SqlExporterException(\"Null value not allowed for Field :\" + col);\n                }\n\n            }\n\n        } else {\n            if (defaultValue != null && !defaultValue.isEmpty()) {\n                if (quote) {\n                    rowValue.append(\"'\" + defaultValue + \"'\");\n                } else {\n                    rowValue.append(defaultValue);\n                }\n\n            } else {\n                throw new SqlExporterException(\"Null value not allowed for Field :\" + col);\n            }\n\n        }\n","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/OpenRefine/OpenRefine/blob/a946177e049f3b0644261661db36cbb0c81ccf8a/main/src/com/google/refine/exporters/sql/SqlInsertBuilder.java#L219-L255","documentation":"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.","triggerScenarios":"Exporting rows containing empty cells to SQL with 'nullValueNull' disabled and no default value configured for that column.","commonSituations":"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.","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."],"exampleFix":"// before (options)\n{\"nullValueNull\":false}\n// after\n{\"nullValueNull\":true}","handlingStrategy":"validation","validationCode":"// before export\nboolean hasBlanks = project.rows.stream()\n    .anyMatch(r -> r.getCellValue(col) == null || r.getCellValue(col).toString().isEmpty());\nif (hasBlanks && !options.getBoolean(\"nullValueNull\") && isEmpty(options.getDefaultValue(col))) {\n    options.put(\"nullValueNull\", true); // or set a default\n}","typeGuard":null,"tryCatchPattern":"try { insertBuilder.getInsertSQL(); } catch (SqlExporterException e) { if (e.getMessage().startsWith(\"Null value not allowed\")) { options.put(\"nullValueNull\", true); rebuildAndRetry(); } else { throw e; } }","preventionTips":["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."],"tags":["sql-exporter","null-value","export-options","java"],"backgroundTag":"null-argument","analyzedSha":"a946177e049f3b0644261661db36cbb0c81ccf8a","analyzedAt":"2026-09-08T10:21:27.735Z","contentChangedAt":"2026-09-08T10:21:27.735Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}