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 1 commit
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
7 changes: 5 additions & 2 deletions riak/codecs/ttb.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ def decode_timeseries(self, resp_ttb, tsobj,
self.maybe_err_ttb(resp_ttb)

resp_a = resp_ttb[0]
if resp_a == tsputresp_a:

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
elif resp_a == tsputresp_a:
return
elif resp_a == tsgetresp_a or resp_a == tsqueryresp_a:
resp_data = resp_ttb[1]
Expand All @@ -175,7 +178,7 @@ def decode_timeseries(self, resp_ttb, tsobj,
raise RiakError(
"Expected 3-tuple in response, got: {}".format(resp_data))
else:
raise RiakError("Unknown TTB response type: {}".format(resp_a))
raise RiakError("Unknown TTB response type: {}".format(resp_ttb))

def decode_timeseries_cols(self, cnames, ctypes):
cnames = [bytes_to_str(cname) for cname in cnames]
Expand Down
20 changes: 20 additions & 0 deletions riak/tests/test_timeseries_ttb.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
import datetime
import random
import string
import logging
import six
import unittest
Expand Down Expand Up @@ -130,6 +132,24 @@ class TimeseriesTtbTests(IntegrationTestBase, unittest.TestCase):
def setUpClass(cls):
super(TimeseriesTtbTests, cls).setUpClass()

def test_query_that_creates_table_using_interpolation(self):
table = ''.join(
[random.choice(string.ascii_letters + string.digits)
for n in range(32)])
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