Skip to content

Commit ea1d70e

Browse files
committed
Merge pull request #469 from basho/bch-handle-sql-creation-in-ttb
Handle creation of tables via SQL
2 parents 46abb11 + d57eeb5 commit ea1d70e

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

riak/codecs/ttb.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ def decode_timeseries(self, resp_ttb, tsobj,
153153

154154
self.maybe_err_ttb(resp_ttb)
155155

156+
# NB: some queries return a BARE 'tsqueryresp' atom
157+
# catch that here:
158+
if resp_ttb == tsqueryresp_a:
159+
return tsobj
160+
161+
# The response atom is the first element in the response tuple
156162
resp_a = resp_ttb[0]
157163
if resp_a == tsputresp_a:
158164
return

riak/tests/test_timeseries_ttb.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,22 @@ class TimeseriesTtbTests(IntegrationTestBase, unittest.TestCase):
130130
def setUpClass(cls):
131131
super(TimeseriesTtbTests, cls).setUpClass()
132132

133+
def test_query_that_creates_table_using_interpolation(self):
134+
table = self.randname()
135+
query = """CREATE TABLE test-{table} (
136+
geohash varchar not null,
137+
user varchar not null,
138+
time timestamp not null,
139+
weather varchar not null,
140+
temperature double,
141+
PRIMARY KEY((geohash, user, quantum(time, 15, m)),
142+
geohash, user, time))
143+
"""
144+
ts_obj = self.client.ts_query(table, query)
145+
self.assertIsNotNone(ts_obj)
146+
self.assertFalse(hasattr(ts_obj, 'ts_cols'))
147+
self.assertIsNone(ts_obj.rows)
148+
133149
def test_query_that_returns_table_description(self):
134150
fmt = 'DESCRIBE {table}'
135151
query = fmt.format(table=table_name)

0 commit comments

Comments
 (0)