Skip to content

Commit 7b4cfe0

Browse files
committed
More tests
1 parent 3ee757b commit 7b4cfe0

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

tests/test_local/test_ddl.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import pytest
2-
from sqlalchemy import Column, MetaData, String, Table, create_engine
2+
from sqlalchemy import Column, MetaData, String, Table, Numeric, create_engine
33
from sqlalchemy.schema import (
44
CreateTable,
55
DropColumnComment,
66
DropTableComment,
77
SetColumnComment,
88
SetTableComment,
99
)
10-
10+
from databricks.sqlalchemy import DatabricksArray,DatabricksMap
1111

1212
class DDLTestBase:
1313
engine = create_engine(
@@ -94,3 +94,22 @@ def test_alter_table_drop_comment(self, table_with_comment):
9494
stmt = DropTableComment(table_with_comment)
9595
output = self.compile(stmt)
9696
assert output == "COMMENT ON TABLE martin IS NULL"
97+
98+
class TestTableComplexTypeDDL(DDLTestBase):
99+
@pytest.fixture
100+
def metadata(self) -> MetaData:
101+
metadata = MetaData()
102+
col1 = Column("array_array_string",DatabricksArray(DatabricksArray(String)))
103+
col2 = Column("map_string_string",DatabricksMap(String,String))
104+
col3 = Column("array_array_decimal",DatabricksArray(DatabricksArray(Numeric(10,2))))
105+
table = Table("complex_type", metadata, col1,col2,col3)
106+
return metadata
107+
108+
def test_create_table_with_complex_type(self, metadata):
109+
stmt = CreateTable(metadata.tables["complex_type"])
110+
output = self.compile(stmt)
111+
112+
print(output)
113+
assert "array_array_string ARRAY<ARRAY<STRING>>" in output
114+
assert "map_string_string MAP<STRING,STRING>" in output
115+
assert "array_array_decimal ARRAY<ARRAY<DECIMAL(10,2)>>" in output

0 commit comments

Comments
 (0)