def test_basic_flow(self): dbs = self.db.get_databases() assert_true('_impala_builtins' in dbs, dbs) assert_true(self.DATABASE in dbs, dbs) tables = self.db.get_tables(database=self.DATABASE) assert_true('tweets' in tables, tables) QUERY = """ SELECT * FROM tweets ORDER BY row_num; """ response = _make_query(self.client, QUERY, database=self.DATABASE, local=False, server_name='impala') response = wait_for_query_to_finish(self.client, response, max=180.0) results = [] # Check that we multiple fetches get all the result set while len(results) < 5: content = fetch_query_result_data(self.client, response, n=len(results), server_name='impala') # We get less than 5 results most of the time, so increase offset results += content['results'] assert_equal([1, 2, 3, 4, 5], [col[0] for col in results]) # Check start over results_start_over = [] while len(results_start_over) < 5: content = fetch_query_result_data(self.client, response, n=len(results_start_over), server_name='impala') results_start_over += content['results'] assert_equal(results_start_over, results)
def test_basic_flow(self): dbs = self.db.get_databases() assert_true('_impala_builtins' in dbs, dbs) assert_true(self.DATABASE in dbs, dbs) tables = self.db.get_tables(database=self.DATABASE) assert_true('tweets' in tables, tables) QUERY = """ SELECT * FROM tweets ORDER BY row_num; """ response = _make_query(self.client, QUERY, database=self.DATABASE, local=False, server_name='impala') content = json.loads(response.content) query_history = QueryHistory.get(content['id']) response = wait_for_query_to_finish(self.client, response, max=180.0) results = [] # Check that we multiple fetches get all the result set while len(results) < 5: # We get less than 5 results most of the time, so increase offset content = fetch_query_result_data(self.client, response, n=len(results), server_name='impala') results += content['results'] assert_equal([1, 2, 3, 4, 5], [col[0] for col in results]) # Check start over results_start_over = [] while len(results_start_over) < 5: content = fetch_query_result_data(self.client, response, n=len(results_start_over), server_name='impala') results_start_over += content['results'] assert_equal(results_start_over, results) # Check cancel query resp = self.client.post( reverse('impala:api_cancel_query', kwargs={'query_history_id': query_history.id})) content = json.loads(resp.content) assert_equal(0, content['status'])
def test_basic_flow(self): # Default database should exist response = self.client.get("/metastore/databases") assert_true("default" in response.context["databases"]) # Table should have been created response = self.client.get("/metastore/tables/") assert_true("test" in response.context["tables"]) # Switch databases response = self.client.get("/metastore/tables/default") assert_true("test" in response.context["tables"]) # Should default to "default" database response = self.client.get("/metastore/tables/not_there") assert_true("test" in response.context["tables"]) # And have detail response = self.client.get("/metastore/table/default/test") assert_true("foo" in response.content) assert_true("SerDe Library" in response.content, response.content) # Remember the number of history items. Use a generic fragment 'test' to pass verification. history_cnt = verify_history(self.client, fragment='test') # Show table data. response = self.client.get("/metastore/table/default/test/read", follow=True) response = self.client.get(reverse("beeswax:api_watch_query_refresh_json", kwargs={'id': response.context['query'].id}), follow=True) response = wait_for_query_to_finish(self.client, response, max=30.0) # Note that it may not return all rows at once. But we expect at least 10. results = fetch_query_result_data(self.client, response) assert_true(len(results['results']) > 0) # This should NOT go into the query history. assert_equal(verify_history(self.client, fragment='test'), history_cnt, 'Implicit queries should not be saved in the history')
def test_read_partitions(self): partition_spec = "baz='baz_one',boom='boom_two'" response = self.client.get("/metastore/table/%s/test_partitions/partitions/%s/read" % (self.db_name, partition_spec), follow=True) response = self.client.get(reverse("beeswax:api_watch_query_refresh_json", kwargs={'id': response.context['query'].id}), follow=True) response = wait_for_query_to_finish(self.client, response, max=30.0) results = fetch_query_result_data(self.client, response) assert_true(len(results['results']) > 0, results)
def test_basic_flow(self): # Default database should exist response = self.client.get("/metastore/databases") assert_true(self.db_name in response.context["databases"]) # Table should have been created response = self.client.get("/metastore/tables/") assert_equal(200, response.status_code) # Switch databases response = self.client.get("/metastore/tables/%s" % self.db_name) assert_true('name' in response.context["tables"][0]) assert_true("test" in response.context["table_names"]) # Should default to "default" database response = self.client.get("/metastore/tables/not_there") assert_equal(200, response.status_code) # And have detail response = self.client.get("/metastore/table/%s/test" % self.db_name) assert_true("foo" in response.content) assert_true("SerDe Library" in response.content, response.content) # Remember the number of history items. Use a generic fragment 'test' to pass verification. history_cnt = verify_history(self.client, fragment='test') # Show table data. response = self.client.get("/metastore/table/%s/test/read" % self.db_name, follow=True) response = self.client.get(reverse("beeswax:api_watch_query_refresh_json", kwargs={'id': response.context['query'].id}), follow=True) response = wait_for_query_to_finish(self.client, response, max=30.0) # Note that it may not return all rows at once. But we expect at least 10. results = fetch_query_result_data(self.client, response) assert_true(len(results['results']) > 0) # This should NOT go into the query history. assert_equal(verify_history(self.client, fragment='test'), history_cnt, 'Implicit queries should not be saved in the history')
def test_browse_partitions(self): response = self.client.get( "/metastore/table/default/test_partitions/partitions/0", follow=True) response = self.client.get(reverse( "beeswax:api_watch_query_refresh_json", kwargs={'id': response.context['query'].id}), follow=True) response = wait_for_query_to_finish(self.client, response, max=30.0) results = fetch_query_result_data(self.client, response) assert_true(len(results['results']) > 0, results)
def test_basic_flow(self): dbs = self.db.get_databases() assert_true("_impala_builtins" in dbs, dbs) assert_true(self.DATABASE in dbs, dbs) tables = self.db.get_tables(database=self.DATABASE) assert_true("tweets" in tables, tables) QUERY = """ SELECT * FROM tweets ORDER BY row_num; """ response = _make_query(self.client, QUERY, database=self.DATABASE, local=False, server_name="impala") content = json.loads(response.content) query_history = QueryHistory.get(content["id"]) response = wait_for_query_to_finish(self.client, response, max=180.0) results = [] # Check that we multiple fetches get all the result set while len(results) < 5: content = fetch_query_result_data( self.client, response, n=len(results), server_name="impala" ) # We get less than 5 results most of the time, so increase offset results += content["results"] assert_equal([1, 2, 3, 4, 5], [col[0] for col in results]) # Check start over results_start_over = [] while len(results_start_over) < 5: content = fetch_query_result_data(self.client, response, n=len(results_start_over), server_name="impala") results_start_over += content["results"] assert_equal(results_start_over, results) # Check cancel query resp = self.client.post(reverse("impala:api_cancel_query", kwargs={"query_history_id": query_history.id})) content = json.loads(resp.content) assert_equal(0, content["status"])
def test_basic_flow(self): # Default database should exist response = self.client.get("/metastore/databases") assert_true(self.db_name in response.context[0]["databases"]) # Table should have been created response = self.client.get("/metastore/tables/") assert_equal(200, response.status_code) # Switch databases response = self.client.get("/metastore/tables/%s?format=json" % self.db_name) data = json.loads(response.content) assert_true('name' in data["tables"][0]) assert_true("test" in data["table_names"]) # Should default to "default" database response = self.client.get("/metastore/tables/not_there") assert_equal(200, response.status_code) # And have detail response = self.client.post("/metastore/table/%s/test/?format=json" % self.db_name, {'format': 'json'}) data = json.loads(response.content) assert_true("foo" in [col['name'] for col in data['cols']]) assert_true("SerDe Library:" in [prop['col_name'] for prop in data['properties']], data) # Remember the number of history items. Use a generic fragment 'test' to pass verification. history_cnt = verify_history(self.client, fragment='test') # Show table data. response = self.client.get("/metastore/table/%s/test/read" % self.db_name, follow=True) response = self.client.get(reverse("beeswax:api_watch_query_refresh_json", kwargs={'id': response.context[0]['query'].id}), follow=True) response = wait_for_query_to_finish(self.client, response, max=30.0) # Note that it may not return all rows at once. But we expect at least 10. results = fetch_query_result_data(self.client, response) assert_true(len(results['results']) > 0) # This should NOT go into the query history. assert_equal(verify_history(self.client, fragment='test'), history_cnt, 'Implicit queries should not be saved in the history')
def test_browse_partitions(self): response = self.client.get("/metastore/table/default/test_partitions/partitions/0", follow=True) response = self.client.get(reverse("beeswax:api_watch_query_refresh_json", kwargs={'id': response.context['query'].id}), follow=True) response = wait_for_query_to_finish(self.client, response, max=30.0) results = fetch_query_result_data(self.client, response) assert_true(len(results['results']) > 0, results)