Skip to content

Commit

Permalink
Merge pull request #469 from basho/bch-handle-sql-creation-in-ttb
Browse files Browse the repository at this point in the history
Handle creation of tables via SQL
  • Loading branch information
lukebakken committed May 6, 2016
2 parents 46abb11 + d57eeb5 commit ea1d70e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions riak/codecs/ttb.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def decode_timeseries(self, resp_ttb, tsobj,

self.maybe_err_ttb(resp_ttb)

# NB: some queries return a BARE 'tsqueryresp' atom
# catch that here:
if resp_ttb == tsqueryresp_a:
return tsobj

# The response atom is the first element in the response tuple
resp_a = resp_ttb[0]
if resp_a == tsputresp_a:
return
Expand Down
16 changes: 16 additions & 0 deletions riak/tests/test_timeseries_ttb.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ class TimeseriesTtbTests(IntegrationTestBase, unittest.TestCase):
def setUpClass(cls):
super(TimeseriesTtbTests, cls).setUpClass()

def test_query_that_creates_table_using_interpolation(self):
table = self.randname()
query = """CREATE TABLE test-{table} (
geohash varchar not null,
user varchar not null,
time timestamp not null,
weather varchar not null,
temperature double,
PRIMARY KEY((geohash, user, quantum(time, 15, m)),
geohash, user, time))
"""
ts_obj = self.client.ts_query(table, query)
self.assertIsNotNone(ts_obj)
self.assertFalse(hasattr(ts_obj, 'ts_cols'))
self.assertIsNone(ts_obj.rows)

def test_query_that_returns_table_description(self):
fmt = 'DESCRIBE {table}'
query = fmt.format(table=table_name)
Expand Down

0 comments on commit ea1d70e

Please sign in to comment.