def test_tablename_to_dict(self): """Test identifying schema and table names from fully qualified table names""" # Format: <CATALOG>.<SCHEMA>.<TABLE> assert utils.tablename_to_dict('my_catalog.my_schema.my_table') == \ { 'catalog_name': 'my_catalog', 'schema_name': 'my_schema', 'table_name': 'my_table', 'temp_table_name': 'my_table_temp' } # Format: <SCHEMA>.<TABLE> assert utils.tablename_to_dict('my_schema.my_table') == \ { 'catalog_name': None, 'schema_name': 'my_schema', 'table_name': 'my_table', 'temp_table_name': 'my_table_temp' } # Format: <TABLE> assert utils.tablename_to_dict('my_table') == \ { 'catalog_name': None, 'schema_name': None, 'table_name': 'my_table', 'temp_table_name': 'my_table_temp' } # Format: <CATALOG>.<SCHEMA>.<TABLE>.<SOMETHING> assert utils.tablename_to_dict('my_catalog.my_schema.my_table.foo') == \ { 'catalog_name': 'my_catalog', 'schema_name': 'my_schema', 'table_name': 'my_table_foo', 'temp_table_name': 'my_table_foo_temp' } # Format: <CATALOG>.<SCHEMA>.<TABLE>.<SOMETHING> # Custom separator assert utils.tablename_to_dict('my_catalog-my_schema-my_table-foo', separator='-') == \ { 'catalog_name': 'my_catalog', 'schema_name': 'my_schema', 'table_name': 'my_table_foo', 'temp_table_name': 'my_table_foo_temp' }
def test_tablename_to_dict(): """Test identifying schema and table names from fully qualified table names""" # Format: <CATALOG>.<SCHEMA>.<TABLE> assert utils.tablename_to_dict('my_catalog.my_schema.my_table') == \ { "catalog_name": "my_catalog", "schema_name": "my_schema", "table_name": "my_table", "temp_table_name": "my_table_temp" } # Format: <SCHEMA>.<TABLE> assert utils.tablename_to_dict('my_schema.my_table') == \ { "catalog_name": None, "schema_name": "my_schema", "table_name": "my_table", "temp_table_name": "my_table_temp" } # Format: <TABLE> assert utils.tablename_to_dict('my_table') == \ { "catalog_name": None, "schema_name": None, "table_name": "my_table", "temp_table_name": "my_table_temp" } # Format: <CATALOG>.<SCHEMA>.<TABLE>.<SOMETHING> assert utils.tablename_to_dict('my_catalog.my_schema.my_table.foo') == \ { "catalog_name": "my_catalog", "schema_name": "my_schema", "table_name": "my_table_foo", "temp_table_name": "my_table_foo_temp" } # Format: <CATALOG>.<SCHEMA>.<TABLE>.<SOMETHING> # Custom separator assert utils.tablename_to_dict('my_catalog-my_schema-my_table-foo', separator='-') == \ { "catalog_name": "my_catalog", "schema_name": "my_schema", "table_name": "my_table_foo", "temp_table_name": "my_table_foo_temp" }