{"record":{"id":"1ea9af03c4948b92","repo":"apache/cassandra","slug":"empty-values-are-not-allowed","errorCode":null,"errorMessage":"Empty values are not allowed","messagePattern":"Empty values are not allowed","errorType":"validation","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"pylib/cqlshlib/copyutil.py","lineNumber":1923,"sourceCode":"        \"\"\"\n        Return a function that converts a string into a value the can be passed\n        into BoundStatement.bind() for the given cql type. See cassandra.cqltypes\n        for more details.\n        \"\"\"\n        unprotect = self.unprotect\n\n        def convert(t, v):\n            v = unprotect(v)\n            if v == self.nullval:\n                return self.get_null_val()\n            return converters.get(t.typename, convert_unknown)(v, ct=t)\n\n        def convert_mandatory(t, v):\n            v = unprotect(v)\n            # we can't distinguish between empty strings and null values in csv. Null values are not supported in\n            # collections, so it must be an empty string.\n            if v == self.nullval and not issubclass(t, VarcharType):\n                raise ParseError('Empty values are not allowed')\n            return converters.get(t.typename, convert_unknown)(v, ct=t)\n\n        def convert_blob(v, **_):\n            if sys.version_info.major >= 3:\n                return bytes.fromhex(v[2:])\n            else:\n                return BlobType(v[2:].decode(\"hex\"))\n\n        def convert_text(v, **_):\n            return str(v)\n\n        def convert_uuid(v, **_):\n            return UUID(v)\n\n        def convert_bool(v, **_):\n            return True if v.lower() == self.boolean_styles[0].lower() else False\n\n        def get_convert_integer_fcn(adapter=int):","sourceCodeStart":1905,"sourceCodeEnd":1941,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/pylib/cqlshlib/copyutil.py#L1905-L1941","documentation":"During COPY FROM conversion, a mandatory (non-varchar) column value equals self.nullval (the marker for null, usually an empty string). Nulls are not representable in collections and non-varchar columns cannot receive the null marker, so a ParseError is raised.","triggerScenarios":"COPY FROM a CSV row where a column of a non-text type (int, timestamp, collection element, etc.) contains the nullval string (default '') — i.e. an empty CSV cell for a mandatory non-varchar column.","commonSituations":"Exported CSV with empty cells for numeric/date columns; NULLS= option set to a string that appears in the data; a collection element left empty in the CSV.","solutions":["Fix the CSV to supply valid values for non-varchar columns, or a proper null marker if the column type allows","Use the NULLS='<marker>' COPY option to distinguish empty string from null and make sure the marker does not collide with real data","Change the column type to text/varchar if empty strings are legitimately expected"],"exampleFix":"// before (CSV)\n1,,2026-01-01\n// after\n1,0,2026-01-01\n// or: COPY t FROM 'f.csv' WITH NULLS='__NULL__'","handlingStrategy":"validation","validationCode":"nullval = '__NULL__'  # choose marker via NULLS option\nfor row in csv_rows:\n    for i, v in enumerate(row):\n        if v == '' and col_types[i] not in ('text','varchar'):\n            raise ValueError(f\"row {row}: empty mandatory field {i}\")","typeGuard":null,"tryCatchPattern":"try:\n    session.execute(copy_from_import)\nexcept ParseError as e:\n    log.error(f\"Bad CSV value: {e}\")  # locate row and fix","preventionTips":["Pick a NULLS marker that never appears in real data","Sanitize CSVs: no empty cells for non-varchar columns","Validate CSV against schema before import"],"tags":["cqlsh","copy","csv","parsing"],"backgroundTag":"empty-required-field","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}