apache/cassandra · error · ParseError
Empty values are not allowed
Error message
Empty values are not allowed
What it means
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.
Source
Thrown at pylib/cqlshlib/copyutil.py:1923
"""
Return a function that converts a string into a value the can be passed
into BoundStatement.bind() for the given cql type. See cassandra.cqltypes
for more details.
"""
unprotect = self.unprotect
def convert(t, v):
v = unprotect(v)
if v == self.nullval:
return self.get_null_val()
return converters.get(t.typename, convert_unknown)(v, ct=t)
def convert_mandatory(t, v):
v = unprotect(v)
# we can't distinguish between empty strings and null values in csv. Null values are not supported in
# collections, so it must be an empty string.
if v == self.nullval and not issubclass(t, VarcharType):
raise ParseError('Empty values are not allowed')
return converters.get(t.typename, convert_unknown)(v, ct=t)
def convert_blob(v, **_):
if sys.version_info.major >= 3:
return bytes.fromhex(v[2:])
else:
return BlobType(v[2:].decode("hex"))
def convert_text(v, **_):
return str(v)
def convert_uuid(v, **_):
return UUID(v)
def convert_bool(v, **_):
return True if v.lower() == self.boolean_styles[0].lower() else False
def get_convert_integer_fcn(adapter=int):View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before (CSV) 1,,2026-01-01 // after 1,0,2026-01-01 // or: COPY t FROM 'f.csv' WITH NULLS='__NULL__'
Defensive patterns
Strategy: validation
Validate before calling
nullval = '__NULL__' # choose marker via NULLS option
for row in csv_rows:
for i, v in enumerate(row):
if v == '' and col_types[i] not in ('text','varchar'):
raise ValueError(f"row {row}: empty mandatory field {i}") Try / catch
try:
session.execute(copy_from_import)
except ParseError as e:
log.error(f"Bad CSV value: {e}") # locate row and fix Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Invalid row length %d should be %d
- Invalid composite string, it should start and end with match
- can't interpret %r as a date with format %s or as int
- Failed to parse %s : %s
- Invalid boolean styles %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/1ea9af03c4948b92.
Report an issue: GitHub.