Replace empty strings with null values if they cannot be converted patch by Stefania Alborghetti; reviewed by Tyler Hobbs for CASSANDRA-12794
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/65bd4552 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/65bd4552 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/65bd4552 Branch: refs/heads/trunk Commit: 65bd45523584302572782c45b352bbd2bbd3c558 Parents: 6e716c6 Author: Stefania Alborghetti <stefania.alborghe...@datastax.com> Authored: Fri Dec 23 15:12:14 2016 +0800 Committer: Stefania Alborghetti <stefania.alborghe...@datastax.com> Committed: Fri Jan 6 10:03:11 2017 +0100 ---------------------------------------------------------------------- CHANGES.txt | 1 + pylib/cqlshlib/copyutil.py | 7 +++++++ 2 files changed, 8 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/65bd4552/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 77a310d..11b0482 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.11 + * Replace empty strings with null values if they cannot be converted (CASSANDRA-12794) * Fixed flacky SSTableRewriterTest: check file counts before calling validateCFS (CASSANDRA-12348) * Fix deserialization of 2.x DeletedCells (CASSANDRA-12620) * Add parent repair session id to anticompaction log message (CASSANDRA-12186) http://git-wip-us.apache.org/repos/asf/cassandra/blob/65bd4552/pylib/cqlshlib/copyutil.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py index b474f3e..facf9dd 100644 --- a/pylib/cqlshlib/copyutil.py +++ b/pylib/cqlshlib/copyutil.py @@ -2054,6 +2054,13 @@ class ImportConversion(object): try: return c(v) if v != self.nullval else self.get_null_val() except Exception, e: + # if we could not convert an empty string, then self.nullval has been set to a marker + # because the user needs to import empty strings, except that the converters for some types + # will fail to convert an empty string, in this case the null value should be inserted + # see CASSANDRA-12794 + if v == '': + return self.get_null_val() + if self.debug: traceback.print_exc() raise ParseError("Failed to parse %s : %s" % (val, e.message))