diff --git a/tests/__snapshots__/test_structured_datatypes.ambr b/tests/__snapshots__/test_structured_datatypes.ambr index 56ecf23f..318b653f 100644 --- a/tests/__snapshots__/test_structured_datatypes.ambr +++ b/tests/__snapshots__/test_structured_datatypes.ambr @@ -69,8 +69,8 @@ ]) # --- # name: test_reflect_structured_data_types[MAP(NUMBER(10, 0), MAP(NUMBER(10, 0), VARCHAR))] - "CREATE ICEBERG TABLE test_reflect_st_types (\tid DECIMAL(38, 0), \tmap_id MAP(DECIMAL(10, 0), MAP(DECIMAL(10, 0), VARCHAR(16777216))) NOT NULL)\tCATALOG = 'SNOWFLAKE'" + 'CREATE ICEBERG TABLE test_reflect_st_types (\tid DECIMAL(38, 0) NOT NULL, \tmap_id MAP(DECIMAL(10, 0), MAP(DECIMAL(10, 0), VARCHAR(16777216))) NOT NULL, \tCONSTRAINT "SYS_CONSTRAINT_98dc7df8-0a51-4b69-a974-55c656fb6543" PRIMARY KEY (id))\tCATALOG = \'SNOWFLAKE\'' # --- # name: test_reflect_structured_data_types[MAP(NUMBER(10, 0), VARCHAR)] - "CREATE ICEBERG TABLE test_reflect_st_types (\tid DECIMAL(38, 0), \tmap_id MAP(DECIMAL(10, 0), VARCHAR(16777216)) NOT NULL)\tCATALOG = 'SNOWFLAKE'" + 'CREATE ICEBERG TABLE test_reflect_st_types (\tid DECIMAL(38, 0) NOT NULL, \tmap_id MAP(DECIMAL(10, 0), VARCHAR(16777216)) NOT NULL, \tCONSTRAINT "SYS_CONSTRAINT_2b003f01-6ab6-4c30-a12d-191973a1cf14" PRIMARY KEY (id))\tCATALOG = \'SNOWFLAKE\'' # --- diff --git a/tests/custom_tables/__snapshots__/test_reflect_snowflake_table.ambr b/tests/custom_tables/__snapshots__/test_reflect_snowflake_table.ambr index 6ef09ff7..7e85841a 100644 --- a/tests/custom_tables/__snapshots__/test_reflect_snowflake_table.ambr +++ b/tests/custom_tables/__snapshots__/test_reflect_snowflake_table.ambr @@ -1,4 +1,26 @@ # serializer version: 1 +# name: test_inspect_snowflake_table + list([ + dict({ + 'autoincrement': False, + 'comment': None, + 'default': None, + 'name': 'id', + 'nullable': False, + 'primary_key': True, + 'type': _CUSTOM_DECIMAL(precision=38, scale=0), + }), + dict({ + 'autoincrement': False, + 'comment': None, + 'default': None, + 'name': 'name', + 'nullable': True, + 'primary_key': False, + 'type': VARCHAR(length=16777216), + }), + ]) +# --- # name: test_simple_reflection_of_table_as_snowflake_table 'CREATE TABLE test_snowflake_table_reflection (\tid DECIMAL(38, 0) NOT NULL, \tname VARCHAR(16777216), \tCONSTRAINT demo_name PRIMARY KEY (id))' # --- diff --git a/tests/custom_tables/test_reflect_snowflake_table.py b/tests/custom_tables/test_reflect_snowflake_table.py index 282e83b2..603b6187 100644 --- a/tests/custom_tables/test_reflect_snowflake_table.py +++ b/tests/custom_tables/test_reflect_snowflake_table.py @@ -1,7 +1,7 @@ # # Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved. # -from sqlalchemy import MetaData, Table +from sqlalchemy import MetaData, Table, inspect from sqlalchemy.sql.ddl import CreateTable from snowflake.sqlalchemy import SnowflakeTable @@ -67,3 +67,26 @@ def test_simple_reflection_of_table_as_snowflake_table( finally: metadata.drop_all(engine_testaccount) + + +def test_inspect_snowflake_table( + engine_testaccount, db_parameters, sql_compiler, snapshot +): + metadata = MetaData() + table_name = "test_snowflake_table_inspect" + + create_table_sql = f""" + CREATE TABLE {table_name} (id INT primary key, name VARCHAR); + """ + + with engine_testaccount.connect() as connection: + connection.exec_driver_sql(create_table_sql) + + try: + with engine_testaccount.connect() as conn: + insp = inspect(conn) + table = insp.get_columns(table_name) + assert table == snapshot + + finally: + metadata.drop_all(engine_testaccount) diff --git a/tests/test_structured_datatypes.py b/tests/test_structured_datatypes.py index 08677d77..2acd73ee 100644 --- a/tests/test_structured_datatypes.py +++ b/tests/test_structured_datatypes.py @@ -146,7 +146,7 @@ def test_reflect_structured_data_types( table_name = "test_reflect_st_types" create_table_sql = f""" CREATE OR REPLACE ICEBERG TABLE {table_name} ( - id number(38,0), + id number(38,0) primary key, map_id {structured_type}) CATALOG = 'SNOWFLAKE' EXTERNAL_VOLUME = '{external_volume}'