-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved test function into tests folder and renamed test file
- Loading branch information
Jorrit Sandbrink
committed
Jan 26, 2024
1 parent
7868ca6
commit b4cdd36
Showing
3 changed files
with
30 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import cast | ||
from textwrap import dedent | ||
|
||
from dlt.destinations.impl.synapse.sql_client import SynapseSqlClient | ||
from dlt.destinations.impl.synapse.synapse_adapter import TTableIndexType | ||
|
||
|
||
def get_storage_table_index_type(sql_client: SynapseSqlClient, table_name: str) -> TTableIndexType: | ||
"""Returns table index type of table in storage destination.""" | ||
with sql_client: | ||
schema_name = sql_client.fully_qualified_dataset_name(escape=False) | ||
sql = dedent(f""" | ||
SELECT | ||
CASE i.type_desc | ||
WHEN 'HEAP' THEN 'heap' | ||
WHEN 'CLUSTERED COLUMNSTORE' THEN 'clustered_columnstore_index' | ||
END AS table_index_type | ||
FROM sys.indexes i | ||
INNER JOIN sys.tables t ON t.object_id = i.object_id | ||
INNER JOIN sys.schemas s ON s.schema_id = t.schema_id | ||
WHERE s.name = '{schema_name}' AND t.name = '{table_name}' | ||
""") | ||
table_index_type = sql_client.execute_sql(sql)[0][0] | ||
return cast(TTableIndexType, table_index_type) |