Permalink
Browse files

CBQE-2298: tuq: add split test

Change-Id: I736d79b33af79d9291b74dd96f40111905ed85c2
Reviewed-on: http://review.couchbase.org/39209
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Iryna Mironava <irynamironava@yandex.ru>
  • Loading branch information...
1 parent 2eb2766 commit 47649b9d1da7e6688290b309235ab38f8b7facec @IrynaMironava IrynaMironava committed with IrynaMironava Jul 8, 2014
Showing with 30 additions and 0 deletions.
  1. +2 −0 conf/py-tuq.conf
  2. +28 −0 pytests/tuqquery/tuq.py
View
@@ -72,6 +72,8 @@ tuqquery.tuq.QueryTests:
test_where_millis,GROUP=DATE;P0
test_order_by_dates,GROUP=DATE;P0
test_escaped_identifiers,GROUP=P0
+ test_select_split_fn,GROUP=P0
+ test_split_where,GROUP=P0
tuqquery.tuq_precedence.PrecedenceTests:
test_case_and_like,GROUP=PRECEDENCE;P0
test_case_and_logic_exp,GROUP=PRECEDENCE;P0
View
@@ -1864,7 +1864,35 @@ def test_concatenation_where(self):
if doc["skills"][0] == 'skill2010']
expected_result = sorted(expected_result)
self._verify_results(actual_result, expected_result)
+##############################################################################################
+#
+# SPLIT
+##############################################################################################
+ def test_select_split_fn(self):
+ for bucket in self.buckets:
+ self.query = "SELECT SPLIT(email, '@')[0] as login" +\
+ " FROM %s" % (bucket.name)
+ full_list = self._generate_full_docs_list(self.gens_load)
+ actual_list = self.run_cbq_query()
+ actual_result = sorted(actual_list['resultset'])
+ expected_result = [{"login" : doc["email"].split('@')[0]}
+ for doc in full_list]
+ expected_result = sorted(expected_result)
+ self._verify_results(actual_result, expected_result)
+
+ def test_split_where(self):
+ for bucket in self.buckets:
+ self.query = 'SELECT name' +\
+ ' FROM %s WHERE SPLIT(email, \'-\')[0] = SPLIT(name, \'-\')[1]' % (bucket.name)
+ full_list = self._generate_full_docs_list(self.gens_load)
+ actual_list = self.run_cbq_query()
+ actual_result = sorted(actual_list['resultset'])
+ expected_result = [{"name" : doc["name"]}
+ for doc in full_list
+ if doc["email"].split[0] == doc["name"].split[1]]
+ expected_result = sorted(expected_result)
+ self._verify_results(actual_result, expected_result)
##############################################################################################
#
# COMMON FUNCTIONS

0 comments on commit 47649b9

Please sign in to comment.