dagster-snowflake 0.22.5__py3-none-any.whl → 0.22.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dagster-snowflake might be problematic. Click here for more details.
- dagster_snowflake/__init__.py +1 -0
- dagster_snowflake/resources.py +47 -0
- dagster_snowflake/version.py +1 -1
- {dagster_snowflake-0.22.5.dist-info → dagster_snowflake-0.22.7.dist-info}/METADATA +4 -2
- dagster_snowflake-0.22.7.dist-info/RECORD +10 -0
- dagster_snowflake-0.22.5.dist-info/RECORD +0 -10
- {dagster_snowflake-0.22.5.dist-info → dagster_snowflake-0.22.7.dist-info}/LICENSE +0 -0
- {dagster_snowflake-0.22.5.dist-info → dagster_snowflake-0.22.7.dist-info}/WHEEL +0 -0
- {dagster_snowflake-0.22.5.dist-info → dagster_snowflake-0.22.7.dist-info}/top_level.txt +0 -0
dagster_snowflake/__init__.py
CHANGED
|
@@ -4,6 +4,7 @@ from .ops import snowflake_op_for_query as snowflake_op_for_query
|
|
|
4
4
|
from .resources import (
|
|
5
5
|
SnowflakeConnection as SnowflakeConnection,
|
|
6
6
|
SnowflakeResource as SnowflakeResource,
|
|
7
|
+
fetch_last_updated_timestamps as fetch_last_updated_timestamps,
|
|
7
8
|
snowflake_resource as snowflake_resource,
|
|
8
9
|
)
|
|
9
10
|
from .snowflake_io_manager import (
|
dagster_snowflake/resources.py
CHANGED
|
@@ -2,6 +2,7 @@ import base64
|
|
|
2
2
|
import sys
|
|
3
3
|
import warnings
|
|
4
4
|
from contextlib import closing, contextmanager
|
|
5
|
+
from datetime import datetime
|
|
5
6
|
from typing import Any, Dict, Iterator, List, Mapping, Optional, Sequence, Union
|
|
6
7
|
|
|
7
8
|
import dagster._check as check
|
|
@@ -713,3 +714,49 @@ def snowflake_resource(context) -> SnowflakeConnection:
|
|
|
713
714
|
return SnowflakeConnection(
|
|
714
715
|
config=context, log=context.log, snowflake_connection_resource=snowflake_resource
|
|
715
716
|
)
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
def fetch_last_updated_timestamps(
|
|
720
|
+
*,
|
|
721
|
+
snowflake_connection: Union[SqlDbConnection, snowflake.connector.SnowflakeConnection],
|
|
722
|
+
schema: str,
|
|
723
|
+
tables: Sequence[str],
|
|
724
|
+
) -> Mapping[str, datetime]:
|
|
725
|
+
"""Fetch the last updated times of a list of tables in Snowflake.
|
|
726
|
+
|
|
727
|
+
If the underlying query to fetch the last updated time returns no results, a ValueError will be raised.
|
|
728
|
+
|
|
729
|
+
Args:
|
|
730
|
+
snowflake_connection (Union[SqlDbConnection, SnowflakeConnection]): A connection to Snowflake.
|
|
731
|
+
Accepts either a SnowflakeConnection or a sqlalchemy connection object,
|
|
732
|
+
which are the two types of connections emittable from the snowflake resource.
|
|
733
|
+
schema (str): The schema of the table.
|
|
734
|
+
tables (Sequence[str]): A list of table names to fetch the last updated time for.
|
|
735
|
+
|
|
736
|
+
Returns:
|
|
737
|
+
Mapping[str, datetime]: A dictionary of table names to their last updated time in UTC.
|
|
738
|
+
"""
|
|
739
|
+
check.invariant(len(tables) > 0, "Must provide at least one table name to query upon.")
|
|
740
|
+
tables_str = ", ".join([f"'{table_name}'" for table_name in tables])
|
|
741
|
+
query = f"""
|
|
742
|
+
SELECT table_name, CONVERT_TIMEZONE('UTC', last_altered) AS last_altered
|
|
743
|
+
FROM information_schema.tables
|
|
744
|
+
WHERE table_schema = '{schema}' AND table_name IN ({tables_str});
|
|
745
|
+
"""
|
|
746
|
+
result = snowflake_connection.cursor().execute(query)
|
|
747
|
+
if not result:
|
|
748
|
+
raise ValueError("No results returned from Snowflake update time query.")
|
|
749
|
+
|
|
750
|
+
last_updated_times = {}
|
|
751
|
+
for table_name, last_altered in result:
|
|
752
|
+
check.invariant(
|
|
753
|
+
isinstance(last_altered, datetime),
|
|
754
|
+
"Expected last_altered to be a datetime, but it was not.",
|
|
755
|
+
)
|
|
756
|
+
last_updated_times[table_name] = last_altered
|
|
757
|
+
|
|
758
|
+
for table_name in tables:
|
|
759
|
+
if table_name not in last_updated_times:
|
|
760
|
+
raise ValueError(f"Table {table_name} does not exist in Snowflake.")
|
|
761
|
+
|
|
762
|
+
return last_updated_times
|
dagster_snowflake/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.22.
|
|
1
|
+
__version__ = "0.22.7"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dagster-snowflake
|
|
3
|
-
Version: 0.22.
|
|
3
|
+
Version: 0.22.7
|
|
4
4
|
Summary: Package for Snowflake Dagster framework components.
|
|
5
5
|
Home-page: https://github.com/dagster-io/dagster/tree/master/python_modules/libraries/dagster-snowflake
|
|
6
6
|
Author: Dagster Labs
|
|
@@ -10,10 +10,12 @@ Classifier: Programming Language :: Python :: 3.8
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.9
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.10
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
14
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
15
|
Classifier: Operating System :: OS Independent
|
|
16
|
+
Requires-Python: >=3.8,<3.13
|
|
15
17
|
License-File: LICENSE
|
|
16
|
-
Requires-Dist: dagster ==1.6.
|
|
18
|
+
Requires-Dist: dagster ==1.6.7
|
|
17
19
|
Requires-Dist: snowflake-connector-python >=2.1.0
|
|
18
20
|
Provides-Extra: pandas
|
|
19
21
|
Requires-Dist: pandas ; extra == 'pandas'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
dagster_snowflake/__init__.py,sha256=hPi8JkjApGPlu4ClTzx0BikfxMf440yW7jsRYZCkGcs,605
|
|
2
|
+
dagster_snowflake/ops.py,sha256=cxCMvbzsELa62ax3AWodKSpmad3Kb6NLcZlj6SW2KVg,2159
|
|
3
|
+
dagster_snowflake/resources.py,sha256=3lVsag1BiDWLo_hBA-85P3aOZKpOiYbFi7N50zim3FY,30301
|
|
4
|
+
dagster_snowflake/snowflake_io_manager.py,sha256=cM828EzKsWk2Si_CyXIqNcZqeXuZ6OfiHFVBgLkMRNw,17197
|
|
5
|
+
dagster_snowflake/version.py,sha256=A-PCmnFCMZxIhCv-dXpG9uKeIOhjJzgJKVRpj3pY5Ys,23
|
|
6
|
+
dagster_snowflake-0.22.7.dist-info/LICENSE,sha256=TMatHW4_G9ldRdodEAp-l2Xa2WvsdeOh60E3v1R2jis,11349
|
|
7
|
+
dagster_snowflake-0.22.7.dist-info/METADATA,sha256=6FUY9ZsOKpvufziM3GZgVV0Zl2od7WWTtgxZgk8rShc,1119
|
|
8
|
+
dagster_snowflake-0.22.7.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
9
|
+
dagster_snowflake-0.22.7.dist-info/top_level.txt,sha256=uECYCiluOxLQ996SCUPBBwdK0CTyz45FjWqf7WDqMMc,18
|
|
10
|
+
dagster_snowflake-0.22.7.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
dagster_snowflake/__init__.py,sha256=svCkKOLfCh3_1DBoTtrEa8Hu7puNB4c7JX4FvIGbUf0,537
|
|
2
|
-
dagster_snowflake/ops.py,sha256=cxCMvbzsELa62ax3AWodKSpmad3Kb6NLcZlj6SW2KVg,2159
|
|
3
|
-
dagster_snowflake/resources.py,sha256=ATW__nAcep_t7muqylM6Ux5jxVCgSM9uz7tpjpLx-jU,28337
|
|
4
|
-
dagster_snowflake/snowflake_io_manager.py,sha256=cM828EzKsWk2Si_CyXIqNcZqeXuZ6OfiHFVBgLkMRNw,17197
|
|
5
|
-
dagster_snowflake/version.py,sha256=Sla3CcceziWbgaJkgCohWsMhPzRMI4713Xej2gutG_k,23
|
|
6
|
-
dagster_snowflake-0.22.5.dist-info/LICENSE,sha256=TMatHW4_G9ldRdodEAp-l2Xa2WvsdeOh60E3v1R2jis,11349
|
|
7
|
-
dagster_snowflake-0.22.5.dist-info/METADATA,sha256=7vu4tzZjSJBW-o_EvLPARJs9iQ4w0jeefiANfdxyuKI,1039
|
|
8
|
-
dagster_snowflake-0.22.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
9
|
-
dagster_snowflake-0.22.5.dist-info/top_level.txt,sha256=uECYCiluOxLQ996SCUPBBwdK0CTyz45FjWqf7WDqMMc,18
|
|
10
|
-
dagster_snowflake-0.22.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|