-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added the NamedResourceTrait to support qualified naming of resources, eg `Table(name="db.schema.my_tbl") * fixed a bug with dangling schemas not being connected to the resource tree * misc other bugfixes --------- Co-authored-by: TJ Murphy <[email protected]>
- Loading branch information
Showing
67 changed files
with
1,116 additions
and
640 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
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
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,5 @@ | ||
CREATE SESSION POLICY session_policy_prod_1 | ||
SESSION_IDLE_TIMEOUT_MINS = 60 | ||
SESSION_UI_IDLE_TIMEOUT_MINS = 30 | ||
COMMENT = 'session policy for use in the prod_1 environment' | ||
; |
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,76 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from titan import data_provider | ||
from titan import resources as res | ||
from titan.client import reset_cache | ||
|
||
|
||
pytestmark = pytest.mark.requires_snowflake | ||
|
||
TEST_ROLE = os.environ.get("TEST_SNOWFLAKE_ROLE") | ||
TEST_USER = os.environ.get("TEST_SNOWFLAKE_USER") | ||
|
||
|
||
def safe_fetch(cursor, urn): | ||
reset_cache() | ||
return data_provider.fetch_resource(cursor, urn) | ||
|
||
|
||
def test_fetch_table_clustered(cursor, test_db, suffix): | ||
cursor.execute(f"USE DATABASE {test_db}") | ||
cursor.execute(f"USE SCHEMA PUBLIC") | ||
|
||
table = res.Table( | ||
name=f"TABLE_{suffix}", | ||
database=test_db, | ||
schema="PUBLIC", | ||
owner=TEST_ROLE, | ||
enable_schema_evolution=True, | ||
cluster_by=["ID"], | ||
columns=[res.Column(name="ID", data_type="NUMBER(38,0)")], | ||
) | ||
cursor.execute(table.create_sql(if_not_exists=True)) | ||
result = safe_fetch(cursor, table.urn) | ||
assert result is not None | ||
result = data_provider.remove_none_values(result) | ||
assert result == data_provider.remove_none_values(table.to_dict()) | ||
cursor.execute(table.drop_sql(if_exists=True)) | ||
|
||
|
||
def test_fetch_table_simple(cursor, test_db, suffix): | ||
cursor.execute(f"USE DATABASE {test_db}") | ||
cursor.execute(f"USE SCHEMA PUBLIC") | ||
table = res.Table( | ||
name=f"TABLE_{suffix}", | ||
database=test_db, | ||
schema="PUBLIC", | ||
owner=TEST_ROLE, | ||
columns=[res.Column(name="ID", data_type="NUMBER(38,0)")], | ||
) | ||
cursor.execute(table.create_sql(if_not_exists=True)) | ||
result = safe_fetch(cursor, table.urn) | ||
assert result is not None | ||
result = data_provider.remove_none_values(result) | ||
assert result == data_provider.remove_none_values(table.to_dict()) | ||
cursor.execute(table.drop_sql(if_exists=True)) | ||
|
||
|
||
def test_fetch_table_transient(cursor, test_db, suffix): | ||
cursor.execute(f"USE DATABASE {test_db}") | ||
cursor.execute(f"USE SCHEMA PUBLIC") | ||
table = res.Table( | ||
name=f"TABLE_{suffix}", | ||
database=test_db, | ||
schema="PUBLIC", | ||
owner=TEST_ROLE, | ||
columns=[res.Column(name="ID", data_type="NUMBER(38,0)")], | ||
transient=True, | ||
) | ||
cursor.execute(table.create_sql(if_not_exists=True)) | ||
result = safe_fetch(cursor, table.urn) | ||
assert result is not None | ||
result = data_provider.remove_none_values(result) | ||
assert result == data_provider.remove_none_values(table.to_dict()) | ||
cursor.execute(table.drop_sql(if_exists=True)) |
Oops, something went wrong.