Skip to content

Commit

Permalink
CBQE-3094:test_interesect_covering
Browse files Browse the repository at this point in the history
Change-Id: I902bc7f936a815aca62b4242b34fe72e44a6c177
Reviewed-on: http://review.couchbase.org/55442
Reviewed-by: Ketaki Gangal <ketaki@couchbase.com>
Tested-by: Ketaki Gangal <ketaki@couchbase.com>
  • Loading branch information
Ketaki authored and Ketaki Gangal committed Sep 22, 2015
1 parent 26673b2 commit e76706f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions conf/tuq/py-covering-index.conf
@@ -1,6 +1,7 @@
tuqquery.tuq.QueryTests:
test_union_where_covering,covering_index=true,doc-per-day=1,skip_index=True
test_union_aggr_fns_covering,covering_index=true,doc-per-day=1,skip_index=True
test_intersect_covering,covering_index=true,doc-per-day=1,skip_index=True
tuqquery.tuq_join.JoinTests:
test_unnest_covering,covering_index=true,doc-per-day=1,skip_index=True
test_where_join_keys_covering,covering_index=true,doc-per-day=1,skip_index=True
Expand Down
34 changes: 34 additions & 0 deletions pytests/tuqquery/tuq.py
Expand Up @@ -2485,6 +2485,40 @@ def test_intersect(self):
expected_result = sorted([dict(y) for y in set(tuple(x.items()) for x in expected_result)])
self._verify_results(actual_result, expected_result)

def test_intersect_covering(self):
created_indexes = []
ind_list = ["one", "two"]
index_name="one"
for bucket in self.buckets:
for ind in ind_list:
index_name = "coveringindex%s" % ind
if ind =="one":
self.query = "CREATE INDEX %s ON %s(job_title, name) USING GSI" % (index_name, bucket.name)
elif ind =="two":
self.query = "CREATE INDEX %s ON %s(join_day, name) USING GSI" % (index_name, bucket.name)
self.run_cbq_query()
self._wait_for_index_online(bucket, index_name)
created_indexes.append(index_name)
for bucket in self.buckets:
self.query = "explain select name from %s where job_title='Engineer' intersect select name from %s s where s.join_day>5" % (bucket.name, bucket.name)
if self.covering_index:
self.test_explain_covering_index(index_name)
self.query = "select name from %s where job_title='Engineer' intersect select name from %s s where s.join_day>5" % (bucket.name, bucket.name)
actual_list = self.run_cbq_query()
actual_result = sorted(actual_list['results'])
expected_result = [{"name" : doc["name"]}
for doc in self.full_list if doc['join_day'] > 5]
expected_result = sorted([dict(y) for y in set(tuple(x.items()) for x in expected_result)])
self._verify_results(actual_result, expected_result)

for ind in ind_list:
index_name = "coveringindex%s" % ind
if ind =="one":
self.query = "DROP INDEX %s.%s USING GSI" % (bucket.name, index_name)
elif ind =="two":
self.query = "DROP INDEX %s.%s USING GSI" % (bucket.name, index_name)
self.run_cbq_query()

def test_intersect_all(self):
for bucket in self.buckets:
self.query = "select name from %s intersect all select name from %s s where s.join_day>5" % (bucket.name, bucket.name)
Expand Down

0 comments on commit e76706f

Please sign in to comment.