feature: see Presto row and array data types (#7413)

* Merge lastest from master into lyft-release-sp8 (#7405)

* filter out all nan series (#7313)

* improve not rich tooltip (#7345)

* Create issue_label_bot.yaml (#7341)

* fix: do not save colors without a color scheme (#7347)

* [wtforms] Strip leading/trailing whitespace (#7084)

* [schema] Updating the datasources schema (#5451)

* limit tables/views returned if schema is not provided (#7358)

* limit tables/views returned if schema is not provided

* fix typo

* improve code performance

* handle the case when table name or view name does not present a schema

* Add type anno (#7342)

* Updated local dev instructions to include missing step

* First pass at type annotations

* [schema] Updating the base column schema (#5452)

* Update 937d04c16b64_update_datasources.py (#7361)

* Feature flag for client cache (#7348)

* Feature flag for client cache

* Fix integration test

* Revert "Fix integration test"

This reverts commit 58434ab98a.

* Feature flag for client cache

* Fix integration tests

* Add feature flag to config.py

* Add another feature check

* Fix more integration tests

* Fix raw HTML in SliceAdder (#7338)

* remove backendSync.json (#7331)

* [bubbles] issue when using duplicated metrics (#7087)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04 (#7359)

* SUPERSET-8: Update text in docs copyright footer (#7360)

* SUPERSET-7: Docker compose config version breaks on Ubuntu 16.04

* SUPERSET-8: Extra text in docs copyright footer

* [schema] Adding commits and removing unnecessary foreign-key definitions (#7371)

*  Store last selected dashboard in sessionStorage (#7181)

* Store last selected dashboard in sessionStorage

* Fix tests

* [schema] Updating the base metric schema (#5453)

* Fix NoneType bug & fill the test recipients with original recipients if empty (#7365)

* feat: see Presto row and array data types (#7391)

* feat: see Presto row and array data types

* fix: address PR comments

* fix: lint and build issues

* fix: add types

* add stronger type hints where possible

* fix: lint issues and add select_star func in Hive

* add missing pkg init

* fix: build issues

* fix: pylint issues

* fix: use logging instead of print
This commit is contained in:
Dave Smith
2019-05-01 09:17:34 -07:00
committed by Christine Chambers
parent 46579b1bd6
commit a6aabf8268
5 changed files with 384 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ from unittest import mock
from sqlalchemy import column, select, table
from sqlalchemy.dialects.mssql import pymssql
from sqlalchemy.engine.result import RowProxy
from sqlalchemy.types import String, UnicodeText
from superset import db_engine_specs
@@ -322,6 +323,66 @@ class DbEngineSpecsTestCase(SupersetTestCase):
def test_presto_get_view_names_return_empty_list(self):
self.assertEquals([], PrestoEngineSpec.get_view_names(mock.ANY, mock.ANY))
def verify_presto_column(self, column, expected_results):
inspector = mock.Mock()
inspector.engine.dialect.identifier_preparer.quote_identifier = mock.Mock()
keymap = {'Column': (None, None, 0),
'Type': (None, None, 1),
'Null': (None, None, 2)}
row = RowProxy(mock.Mock(), column, [None, None, None, None], keymap)
inspector.bind.execute = mock.Mock(return_value=[row])
results = PrestoEngineSpec.get_columns(inspector, '', '')
self.assertEqual(len(expected_results), len(results))
for expected_result, result in zip(expected_results, results):
self.assertEqual(expected_result[0], result['name'])
self.assertEqual(expected_result[1], str(result['type']))
def test_presto_get_column(self):
presto_column = ('column_name', 'boolean', '')
expected_results = [('column_name', 'BOOLEAN')]
self.verify_presto_column(presto_column, expected_results)
def test_presto_get_simple_row_column(self):
presto_column = ('column_name', 'row(nested_obj double)', '')
expected_results = [
('column_name', 'ROW'),
('column_name.nested_obj', 'FLOAT')]
self.verify_presto_column(presto_column, expected_results)
def test_presto_get_simple_row_column_with_tricky_name(self):
presto_column = ('column_name', 'row("Field Name(Tricky, Name)" double)', '')
expected_results = [
('column_name', 'ROW'),
('column_name."Field Name(Tricky, Name)"', 'FLOAT')]
self.verify_presto_column(presto_column, expected_results)
def test_presto_get_simple_array_column(self):
presto_column = ('column_name', 'array(double)', '')
expected_results = [('column_name', 'ARRAY')]
self.verify_presto_column(presto_column, expected_results)
def test_presto_get_row_within_array_within_row_column(self):
presto_column = (
'column_name',
'row(nested_array array(row(nested_row double)), nested_obj double)', '')
expected_results = [
('column_name', 'ROW'),
('column_name.nested_array', 'ARRAY'),
('column_name.nested_array.nested_row', 'FLOAT'),
('column_name.nested_obj', 'FLOAT'),
]
self.verify_presto_column(presto_column, expected_results)
def test_presto_get_array_within_row_within_array_column(self):
presto_column = (
'column_name',
'array(row(nested_array array(double), nested_obj double))', '')
expected_results = [
('column_name', 'ARRAY'),
('column_name.nested_array', 'ARRAY'),
('column_name.nested_obj', 'FLOAT')]
self.verify_presto_column(presto_column, expected_results)
def test_hive_get_view_names_return_empty_list(self):
self.assertEquals([], HiveEngineSpec.get_view_names(mock.ANY, mock.ANY))