Skip to content

Commit 1b9ee6c

Browse files
author
Brett Hazen
committed
Handle creation of tables via SQL
1 parent 46abb11 commit 1b9ee6c

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

riak/codecs/ttb.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ def decode_timeseries(self, resp_ttb, tsobj,
154154
self.maybe_err_ttb(resp_ttb)
155155

156156
resp_a = resp_ttb[0]
157-
if resp_a == tsputresp_a:
157+
158+
if resp_ttb == tsqueryresp_a:
159+
return tsobj
160+
elif resp_a == tsputresp_a:
158161
return
159162
elif resp_a == tsgetresp_a or resp_a == tsqueryresp_a:
160163
resp_data = resp_ttb[1]
@@ -175,7 +178,7 @@ def decode_timeseries(self, resp_ttb, tsobj,
175178
raise RiakError(
176179
"Expected 3-tuple in response, got: {}".format(resp_data))
177180
else:
178-
raise RiakError("Unknown TTB response type: {}".format(resp_a))
181+
raise RiakError("Unknown TTB response type: {}".format(resp_ttb))
179182

180183
def decode_timeseries_cols(self, cnames, ctypes):
181184
cnames = [bytes_to_str(cname) for cname in cnames]

riak/tests/test_timeseries_ttb.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8 -*-
22
import datetime
3+
import random
4+
import string
35
import logging
46
import six
57
import unittest
@@ -130,6 +132,24 @@ class TimeseriesTtbTests(IntegrationTestBase, unittest.TestCase):
130132
def setUpClass(cls):
131133
super(TimeseriesTtbTests, cls).setUpClass()
132134

135+
def test_query_that_creates_table_using_interpolation(self):
136+
table = ''.join(
137+
[random.choice(string.ascii_letters + string.digits)
138+
for n in range(32)])
139+
query = """CREATE TABLE test-{table} (
140+
geohash varchar not null,
141+
user varchar not null,
142+
time timestamp not null,
143+
weather varchar not null,
144+
temperature double,
145+
PRIMARY KEY((geohash, user, quantum(time, 15, m)),
146+
geohash, user, time))
147+
"""
148+
ts_obj = self.client.ts_query(table, query)
149+
self.assertIsNotNone(ts_obj)
150+
self.assertFalse(hasattr(ts_obj, 'ts_cols'))
151+
self.assertIsNone(ts_obj.rows)
152+
133153
def test_query_that_returns_table_description(self):
134154
fmt = 'DESCRIBE {table}'
135155
query = fmt.format(table=table_name)

0 commit comments

Comments
 (0)