Remove is_deterministic from function meta

It was removed in the final version of the server changes.

Also skipping legacy table test for 2.2, which does not have
cassandra-cli
This commit is contained in:
Adam Holmberg
2015-05-15 16:25:52 -05:00
parent 0dcfa5e24f
commit 0646d15fa1
3 changed files with 13 additions and 29 deletions

View File

@@ -250,7 +250,7 @@ class Metadata(object):
return Function(function_row['keyspace_name'], function_row['function_name'],
function_row['signature'], function_row['argument_names'],
return_type, function_row['language'], function_row['body'],
function_row['is_deterministic'], function_row['called_on_null_input'])
function_row['called_on_null_input'])
def _build_aggregate(self, keyspace, aggregate_row):
state_type = types.lookup_casstype(aggregate_row['state_type'])
@@ -977,8 +977,7 @@ class Aggregate(object):
state_type = None
"""
Flag indicating whether this function is deterministic
(required for functional indexes)
Type of the aggregate state
"""
def __init__(self, keyspace, name, type_signature, state_func,
@@ -1064,12 +1063,6 @@ class Function(object):
Function body string
"""
is_deterministic = None
"""
Flag indicating whether this function is deterministic
(required for functional indexes)
"""
called_on_null_input = None
"""
Flag indicating whether this function should be called for rows with null values
@@ -1077,7 +1070,7 @@ class Function(object):
"""
def __init__(self, keyspace, name, type_signature, argument_names,
return_type, language, body, is_deterministic, called_on_null_input):
return_type, language, body, called_on_null_input):
self.keyspace = keyspace
self.name = name
self.type_signature = type_signature
@@ -1085,7 +1078,6 @@ class Function(object):
self.return_type = return_type
self.language = language
self.body = body
self.is_deterministic = is_deterministic
self.called_on_null_input = called_on_null_input
def as_cql_query(self, formatted=False):
@@ -1099,13 +1091,12 @@ class Function(object):
name = protect_name(self.name)
arg_list = ', '.join(["%s %s" % (protect_name(n), t)
for n, t in zip(self.argument_names, self.type_signature)])
determ = '' if self.is_deterministic else 'NON DETERMINISTIC '
typ = self.return_type.cql_parameterized_type()
lang = self.language
body = protect_value(self.body)
on_null = "CALLED" if self.called_on_null_input else "RETURNS NULL"
return "CREATE %(determ)sFUNCTION %(keyspace)s.%(name)s(%(arg_list)s)%(sep)s" \
return "CREATE FUNCTION %(keyspace)s.%(name)s(%(arg_list)s)%(sep)s" \
"%(on_null)s ON NULL INPUT%(sep)s" \
"RETURNS %(typ)s%(sep)s" \
"LANGUAGE %(lang)s%(sep)s" \

View File

@@ -197,7 +197,8 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True):
except Exception:
log.debug("Creating new ccm %s cluster with %s", cluster_name, CCM_KWARGS)
cluster = CCMCluster(path, cluster_name, **CCM_KWARGS)
cluster.set_configuration_options({'start_native_transport': True})
cluster.set_configuration_options({'start_native_transport': True,
'enable_user_defined_functions': True})
common.switch_cluster(path, cluster_name)
cluster.populate(nodes, ipformat=ipformat)

View File

@@ -568,9 +568,14 @@ CREATE TABLE export_udts.users (
def test_legacy_tables(self):
if get_server_versions()[0] < (2, 1, 0):
cass_ver = get_server_versions()[0]
print cass_ver
if cass_ver < (2, 1, 0):
raise unittest.SkipTest('Test schema output assumes 2.1.0+ options')
if cass_ver >= (2, 2, 0):
raise unittest.SkipTest('Cannot test cli script on Cassandra 2.2.0+')
if sys.version_info[0:2] != (2, 7):
raise unittest.SkipTest('This test compares static strings generated from dict items, which may change orders. Test with 2.7.')
@@ -1075,7 +1080,7 @@ class FunctionTest(unittest.TestCase):
class FunctionMetadata(FunctionTest):
def make_function_kwargs(self, deterministic=True, called_on_null=True):
def make_function_kwargs(self, called_on_null=True):
return {'keyspace': self.keyspace_name,
'name': self.function_name,
'type_signature': ['double', 'int'],
@@ -1083,7 +1088,6 @@ class FunctionMetadata(FunctionTest):
'return_type': DoubleType,
'language': 'java',
'body': 'return new Double(0.0);',
'is_deterministic': deterministic,
'called_on_null_input': called_on_null}
def test_functions_after_udt(self):
@@ -1133,18 +1137,6 @@ class FunctionMetadata(FunctionTest):
finally:
self.session.execute('ALTER KEYSPACE %s WITH durable_writes = true' % self.keyspace_name)
def test_function_cql_determinism(self):
kwargs = self.make_function_kwargs()
kwargs['is_deterministic'] = True
with self.VerifiedFunction(self, **kwargs) as vf:
fn_meta = self.keyspace_function_meta[vf.signature]
self.assertRegexpMatches(fn_meta.as_cql_query(), "CREATE FUNCTION.*")
kwargs['is_deterministic'] = False
with self.VerifiedFunction(self, **kwargs) as vf:
fn_meta = self.keyspace_function_meta[vf.signature]
self.assertRegexpMatches(fn_meta.as_cql_query(), "CREATE NON DETERMINISTIC FUNCTION.*")
def test_function_cql_called_on_null(self):
kwargs = self.make_function_kwargs()
kwargs['called_on_null_input'] = True