11import pytest
2- from sqlalchemy import Column , MetaData , String , Table , create_engine
2+ from sqlalchemy import Column , MetaData , String , Table , Numeric , create_engine
33from sqlalchemy .schema import (
44 CreateTable ,
55 DropColumnComment ,
66 DropTableComment ,
77 SetColumnComment ,
88 SetTableComment ,
99)
10-
10+ from databricks . sqlalchemy import DatabricksArray , DatabricksMap
1111
1212class 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