Skip to content

Handle creation of tables via SQL #469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I would argue the bug is in riak_kv, and the returned data should be {tsqueryresp, {[], [], []}}, but I guess this is simpler. I will re-work this since I misread that you were comparing the entire ttb message as the atom after the statement that extracts the first element from (what I expected to be) a tuple.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexmoore - we should make sure the Java client catches this. Some query responses are not a tuple but just the atom tsqueryresp

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