You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2021/01/12 19:30:34 UTC
[cassandra] 02/02: Allow empty string in collections with COPY FROM
in cqlsh
This is an automated email from the ASF dual-hosted git repository.
brandonwilliams pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit a542b865047ad8cc3d9f64ab3c3a018ac069331e
Author: Aleksandr Sorokoumov <al...@gmail.com>
AuthorDate: Sat Jan 9 16:53:51 2021 +0100
Allow empty string in collections with COPY FROM in cqlsh
Patch by Aleksandr Soromoukov, reviewed by brandonwilliams for
CASSANDRA-16372
---
CHANGES.txt | 1 +
pylib/cqlshlib/copyutil.py | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/CHANGES.txt b/CHANGES.txt
index 75c478c..5cb4f1d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
3.0.24:
+ * Allow empty string in collections with COPY FROM in cqlsh (CASSANDRA-16372)
* Fix skipping on pre-3.0 created compact storage sstables due to missing primary key liveness (CASSANDRA-16226)
* Fix DecimalDeserializer#toString OOM (CASSANDRA-14925)
* Extend the exclusion of replica filtering protection to other indices instead of just SASI (CASSANDRA-16311)
diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py
index 3f7c091..987a125 100644
--- a/pylib/cqlshlib/copyutil.py
+++ b/pylib/cqlshlib/copyutil.py
@@ -45,7 +45,7 @@ from util import profile_on, profile_off
from cassandra import OperationTimedOut
from cassandra.cluster import Cluster, DefaultConnection
-from cassandra.cqltypes import ReversedType, UserType
+from cassandra.cqltypes import ReversedType, UserType, VarcharType
from cassandra.metadata import protect_name, protect_names, protect_value
from cassandra.policies import RetryPolicy, WhiteListRoundRobinPolicy, DCAwareRoundRobinPolicy, FallthroughRetryPolicy
from cassandra.query import BatchStatement, BatchType, SimpleStatement, tuple_factory
@@ -1841,7 +1841,9 @@ class ImportConversion(object):
def convert_mandatory(t, v):
v = unprotect(v)
- if v == self.nullval:
+ # 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)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org