|
|
@@ -31,7 +31,10 @@ from desktop.lib.test_utils import add_to_group
|
|
|
from desktop.models import Document
|
|
|
from hadoop.pseudo_hdfs4 import get_db_prefix, is_live_cluster
|
|
|
|
|
|
+from beeswax import data_export
|
|
|
from beeswax.design import hql_query
|
|
|
+
|
|
|
+from beeswax.data_export import download
|
|
|
from beeswax.models import SavedQuery, QueryHistory
|
|
|
from beeswax.server import dbms
|
|
|
from beeswax.test_base import get_query_server_config, wait_for_query_to_finish, fetch_query_result_data
|
|
|
@@ -209,6 +212,47 @@ class TestImpalaIntegration:
|
|
|
content = json.loads(resp.content)
|
|
|
assert_equal(0, content['status'])
|
|
|
|
|
|
+
|
|
|
+ def test_data_download(self):
|
|
|
+ hql = 'SELECT * FROM tweets %(limit)s'
|
|
|
+
|
|
|
+ FETCH_SIZE = data_export.FETCH_SIZE
|
|
|
+ data_export.FETCH_SIZE = 2 # Decrease fetch size to validate last fetch logic
|
|
|
+
|
|
|
+ try:
|
|
|
+ query = hql_query(hql % {'limit': ''})
|
|
|
+
|
|
|
+ handle = self.db.execute_and_wait(query)
|
|
|
+ # Get the result in csv. Should have 5 + 1 header row.
|
|
|
+ csv_resp = download(handle, 'csv', self.db)
|
|
|
+ csv_content = ''.join(csv_resp.streaming_content)
|
|
|
+ assert_equal(len(csv_content.strip().split('\n')), 5 + 1)
|
|
|
+
|
|
|
+
|
|
|
+ query = hql_query(hql % {'limit': 'LIMIT 0'})
|
|
|
+
|
|
|
+ handle = self.db.execute_and_wait(query)
|
|
|
+ csv_resp = download(handle, 'csv', self.db)
|
|
|
+ csv_content = ''.join(csv_resp.streaming_content)
|
|
|
+ assert_equal(len(csv_content.strip().split('\n')), 1)
|
|
|
+
|
|
|
+ query = hql_query(hql % {'limit': 'LIMIT 1'})
|
|
|
+
|
|
|
+ handle = self.db.execute_and_wait(query)
|
|
|
+ csv_resp = download(handle, 'csv', self.db)
|
|
|
+ csv_content = ''.join(csv_resp.streaming_content)
|
|
|
+ assert_equal(len(csv_content.strip().split('\n')), 1 + 1)
|
|
|
+
|
|
|
+ query = hql_query(hql % {'limit': 'LIMIT 2'})
|
|
|
+
|
|
|
+ handle = self.db.execute_and_wait(query)
|
|
|
+ csv_resp = download(handle, 'csv', self.db)
|
|
|
+ csv_content = ''.join(csv_resp.streaming_content)
|
|
|
+ assert_equal(len(csv_content.strip().split('\n')), 1 + 2)
|
|
|
+ finally:
|
|
|
+ data_export.FETCH_SIZE = FETCH_SIZE
|
|
|
+
|
|
|
+
|
|
|
def test_explain(self):
|
|
|
QUERY = """
|
|
|
SELECT * FROM tweets ORDER BY row_num;
|