From dc2cdf629642bdaddbe94a2ed7d3a6ef9a17a52c Mon Sep 17 00:00:00 2001 From: Adam Holmberg Date: Wed, 8 Oct 2014 14:22:01 -0500 Subject: [PATCH 1/3] Handle CUSTOM index meta and string export --- cassandra/metadata.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/cassandra/metadata.py b/cassandra/metadata.py index 5a7e16c5..ec9062a7 100644 --- a/cassandra/metadata.py +++ b/cassandra/metadata.py @@ -339,7 +339,9 @@ class Metadata(object): index_name = row.get("index_name") index_type = row.get("index_type") if index_name or index_type: - return IndexMetadata(column_metadata, index_name, index_type) + options = row.get("index_options") + index_options = json.loads(options) if options else {} + return IndexMetadata(column_metadata, index_name, index_type, index_options) else: return None @@ -1058,21 +1060,33 @@ class IndexMetadata(object): index_type = None """ A string representing the type of index. """ - def __init__(self, column_metadata, index_name=None, index_type=None): + index_options = {} + """ A dict of index options. """ + + def __init__(self, column_metadata, index_name=None, index_type=None, index_options={}): self.column = column_metadata self.name = index_name self.index_type = index_type + self.index_options = index_options def as_cql_query(self): """ Returns a CQL query that can be used to recreate this index. """ table = self.column.table - return "CREATE INDEX %s ON %s.%s (%s)" % ( - self.name, # Cassandra doesn't like quoted index names for some reason - protect_name(table.keyspace.name), - protect_name(table.name), - protect_name(self.column.name)) + if self.index_type != "CUSTOM": + return "CREATE INDEX %s ON %s.%s (%s)" % ( + self.name, # Cassandra doesn't like quoted index names for some reason + protect_name(table.keyspace.name), + protect_name(table.name), + protect_name(self.column.name)) + else: + return "CREATE CUSTOM INDEX %s ON %s.%s (%s) USING '%s'" % ( + self.name, # Cassandra doesn't like quoted index names for some reason + protect_name(table.keyspace.name), + protect_name(table.name), + protect_name(self.column.name), + self.index_options["class_name"]) class TokenMap(object): @@ -1269,4 +1283,4 @@ class TriggerMetadata(object): protect_name(self.table.name), protect_value(self.options['class']) ) - return ret \ No newline at end of file + return ret From 9618dd984301553f3dac90d65ffb3ff2a36eca38 Mon Sep 17 00:00:00 2001 From: Adam Holmberg Date: Wed, 8 Oct 2014 14:29:39 -0500 Subject: [PATCH 2/3] Changelog catch-up --- CHANGELOG.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f2cebe97..500fbb62 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,14 @@ +2.1.2 +===== +In Progress + +Bug Fixes +--------- +* Handle Unauthorized message on schema_triggers query (PYTHON-155) +* Make execute_concurrent compatible with Python 2.6 (github-197) +* Pure Python sorted set in support of UDTs nested in collections (PYTON-167) +* Support CUSTOM index metadata and string export (PYTHON-165) + 2.1.1 ===== September 11, 2014 From a0ff7ff2727e3f60cdfbac67c7988068408e8372 Mon Sep 17 00:00:00 2001 From: Adam Holmberg Date: Thu, 9 Oct 2014 16:52:22 -0500 Subject: [PATCH 3/3] More changelog catch-up --- CHANGELOG.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 500fbb62..e349e82b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,13 @@ ===== In Progress +Features +-------- +* Allow DCAwareRoundRobinPolicy to be constructed without a local_dc, defaulting + instead to the DC of a contact_point (PYTHON-126) +* Set routing key in BatchStatement.add() if none specified in batch (PYTHON-148) +* Improved feedback on ValueError using named_tuple_factory with invalid column names (PYTHON-122) + Bug Fixes --------- * Handle Unauthorized message on schema_triggers query (PYTHON-155)