Skip to content

Commit 17d50e8

Browse files
committed
Schema meta types as CQL (WIP)
First pass at CASSANDRA-10365/PYTHON-422 Does not handle deserialization of system_schema.aggregates.initcond No testing outside of metadata integration.
1 parent 21ccd5c commit 17d50e8

4 files changed

Lines changed: 168 additions & 138 deletions

File tree

cassandra/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ class SchemaTargetType(object):
142142

143143
class SignatureDescriptor(object):
144144

145-
def __init__(self, name, type_signature):
145+
def __init__(self, name, argument_types):
146146
self.name = name
147-
self.type_signature = type_signature
147+
self.argument_types = argument_types
148148

149149
@property
150150
def signature(self):
@@ -153,14 +153,14 @@ def signature(self):
153153
154154
can be used to uniquely identify overloaded function names within a keyspace
155155
"""
156-
return self.format_signature(self.name, self.type_signature)
156+
return self.format_signature(self.name, self.argument_types)
157157

158158
@staticmethod
159-
def format_signature(name, type_signature):
160-
return "%s(%s)" % (name, ','.join(t for t in type_signature))
159+
def format_signature(name, argument_types):
160+
return "%s(%s)" % (name, ','.join(t for t in argument_types))
161161

162162
def __repr__(self):
163-
return "%s(%s, %s)" % (self.__class__.__name__, self.name, self.type_signature)
163+
return "%s(%s, %s)" % (self.__class__.__name__, self.name, self.argument_types)
164164

165165

166166
class UserFunctionDescriptor(SignatureDescriptor):
@@ -173,7 +173,7 @@ class UserFunctionDescriptor(SignatureDescriptor):
173173
name of the function
174174
"""
175175

176-
type_signature = None
176+
argument_types = None
177177
"""
178178
Ordered list of CQL argument type names comprising the type signature
179179
"""
@@ -189,7 +189,7 @@ class UserAggregateDescriptor(SignatureDescriptor):
189189
name of the aggregate
190190
"""
191191

192-
type_signature = None
192+
argument_types = None
193193
"""
194194
Ordered list of CQL argument type names comprising the type signature
195195
"""

cassandra/cqltypes.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
apache_cassandra_type_prefix = 'org.apache.cassandra.db.marshal.'
5555

5656
cassandra_empty_type = 'org.apache.cassandra.db.marshal.EmptyType'
57+
cql_empty_type = 'empty'
5758

5859
log = logging.getLogger(__name__)
5960

@@ -78,6 +79,17 @@ def trim_if_startswith(s, prefix):
7879
_casstypes = {}
7980

8081

82+
cql_type_scanner = re.Scanner((
83+
('frozen', None),
84+
(r'[a-zA-Z0-9_]+', lambda s, t: t),
85+
(r'[\s,<>]', None),
86+
))
87+
88+
89+
def cql_types_from_string(cql_type):
90+
return cql_type_scanner.scan(cql_type)[0]
91+
92+
8193
class CassandraTypeType(type):
8294
"""
8395
The CassandraType objects in this module will normally be used directly,

0 commit comments

Comments
 (0)