mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix(db_engine_specs): improve Presto column type matching (#10658)
* fix: improve Presto column type matching * add optional callback to type map and add tests * lint * change private to public
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
from unittest import mock, skipUnless
|
||||
|
||||
import pandas as pd
|
||||
from sqlalchemy import types
|
||||
from sqlalchemy.engine.result import RowProxy
|
||||
from sqlalchemy.sql import select
|
||||
|
||||
@@ -490,3 +491,23 @@ class TestPrestoDbEngineSpec(TestDbEngineSpec):
|
||||
self.assertEqual(actual_cols, expected_cols)
|
||||
self.assertEqual(actual_data, expected_data)
|
||||
self.assertEqual(actual_expanded_cols, expected_expanded_cols)
|
||||
|
||||
def test_get_sqla_column_type(self):
|
||||
sqla_type = PrestoEngineSpec.get_sqla_column_type("varchar(255)")
|
||||
assert isinstance(sqla_type, types.VARCHAR)
|
||||
assert sqla_type.length == 255
|
||||
|
||||
sqla_type = PrestoEngineSpec.get_sqla_column_type("varchar")
|
||||
assert isinstance(sqla_type, types.String)
|
||||
assert sqla_type.length is None
|
||||
|
||||
sqla_type = PrestoEngineSpec.get_sqla_column_type("char(10)")
|
||||
assert isinstance(sqla_type, types.CHAR)
|
||||
assert sqla_type.length == 10
|
||||
|
||||
sqla_type = PrestoEngineSpec.get_sqla_column_type("char")
|
||||
assert isinstance(sqla_type, types.CHAR)
|
||||
assert sqla_type.length is None
|
||||
|
||||
sqla_type = PrestoEngineSpec.get_sqla_column_type("integer")
|
||||
assert isinstance(sqla_type, types.Integer)
|
||||
|
||||
Reference in New Issue
Block a user