dcs-sdk 1.6.4__py3-none-any.whl → 1.6.6__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.
- dcs_core/__init__.py +13 -0
- dcs_core/__main__.py +17 -0
- dcs_core/__version__.py +15 -0
- dcs_core/cli/__init__.py +13 -0
- dcs_core/cli/cli.py +165 -0
- dcs_core/core/__init__.py +19 -0
- dcs_core/core/common/__init__.py +13 -0
- dcs_core/core/common/errors.py +50 -0
- dcs_core/core/common/models/__init__.py +13 -0
- dcs_core/core/common/models/configuration.py +284 -0
- dcs_core/core/common/models/dashboard.py +24 -0
- dcs_core/core/common/models/data_source_resource.py +75 -0
- dcs_core/core/common/models/metric.py +160 -0
- dcs_core/core/common/models/profile.py +75 -0
- dcs_core/core/common/models/validation.py +216 -0
- dcs_core/core/common/models/widget.py +44 -0
- dcs_core/core/configuration/__init__.py +13 -0
- dcs_core/core/configuration/config_loader.py +139 -0
- dcs_core/core/configuration/configuration_parser.py +262 -0
- dcs_core/core/configuration/configuration_parser_arc.py +328 -0
- dcs_core/core/datasource/__init__.py +13 -0
- dcs_core/core/datasource/base.py +62 -0
- dcs_core/core/datasource/manager.py +112 -0
- dcs_core/core/datasource/search_datasource.py +421 -0
- dcs_core/core/datasource/sql_datasource.py +1094 -0
- dcs_core/core/inspect.py +163 -0
- dcs_core/core/logger/__init__.py +13 -0
- dcs_core/core/logger/base.py +32 -0
- dcs_core/core/logger/default_logger.py +94 -0
- dcs_core/core/metric/__init__.py +13 -0
- dcs_core/core/metric/base.py +220 -0
- dcs_core/core/metric/combined_metric.py +98 -0
- dcs_core/core/metric/custom_metric.py +34 -0
- dcs_core/core/metric/manager.py +137 -0
- dcs_core/core/metric/numeric_metric.py +403 -0
- dcs_core/core/metric/reliability_metric.py +90 -0
- dcs_core/core/profiling/__init__.py +13 -0
- dcs_core/core/profiling/datasource_profiling.py +136 -0
- dcs_core/core/profiling/numeric_field_profiling.py +72 -0
- dcs_core/core/profiling/text_field_profiling.py +67 -0
- dcs_core/core/repository/__init__.py +13 -0
- dcs_core/core/repository/metric_repository.py +77 -0
- dcs_core/core/utils/__init__.py +13 -0
- dcs_core/core/utils/log.py +29 -0
- dcs_core/core/utils/tracking.py +105 -0
- dcs_core/core/utils/utils.py +44 -0
- dcs_core/core/validation/__init__.py +13 -0
- dcs_core/core/validation/base.py +230 -0
- dcs_core/core/validation/completeness_validation.py +153 -0
- dcs_core/core/validation/custom_query_validation.py +24 -0
- dcs_core/core/validation/manager.py +282 -0
- dcs_core/core/validation/numeric_validation.py +276 -0
- dcs_core/core/validation/reliability_validation.py +91 -0
- dcs_core/core/validation/uniqueness_validation.py +61 -0
- dcs_core/core/validation/validity_validation.py +738 -0
- dcs_core/integrations/__init__.py +13 -0
- dcs_core/integrations/databases/__init__.py +13 -0
- dcs_core/integrations/databases/bigquery.py +187 -0
- dcs_core/integrations/databases/databricks.py +51 -0
- dcs_core/integrations/databases/db2.py +652 -0
- dcs_core/integrations/databases/elasticsearch.py +61 -0
- dcs_core/integrations/databases/mssql.py +979 -0
- dcs_core/integrations/databases/mysql.py +409 -0
- dcs_core/integrations/databases/opensearch.py +64 -0
- dcs_core/integrations/databases/oracle.py +719 -0
- dcs_core/integrations/databases/postgres.py +570 -0
- dcs_core/integrations/databases/redshift.py +53 -0
- dcs_core/integrations/databases/snowflake.py +48 -0
- dcs_core/integrations/databases/spark_df.py +111 -0
- dcs_core/integrations/databases/sybase.py +1069 -0
- dcs_core/integrations/storage/__init__.py +13 -0
- dcs_core/integrations/storage/local_file.py +149 -0
- dcs_core/integrations/utils/__init__.py +13 -0
- dcs_core/integrations/utils/utils.py +36 -0
- dcs_core/report/__init__.py +13 -0
- dcs_core/report/dashboard.py +211 -0
- dcs_core/report/models.py +88 -0
- dcs_core/report/static/assets/fonts/DMSans-Bold.ttf +0 -0
- dcs_core/report/static/assets/fonts/DMSans-Medium.ttf +0 -0
- dcs_core/report/static/assets/fonts/DMSans-Regular.ttf +0 -0
- dcs_core/report/static/assets/fonts/DMSans-SemiBold.ttf +0 -0
- dcs_core/report/static/assets/images/docs.svg +6 -0
- dcs_core/report/static/assets/images/github.svg +4 -0
- dcs_core/report/static/assets/images/logo.svg +7 -0
- dcs_core/report/static/assets/images/slack.svg +13 -0
- dcs_core/report/static/index.js +2 -0
- dcs_core/report/static/index.js.LICENSE.txt +3971 -0
- dcs_sdk/__version__.py +1 -1
- dcs_sdk/cli/cli.py +3 -0
- {dcs_sdk-1.6.4.dist-info → dcs_sdk-1.6.6.dist-info}/METADATA +24 -2
- dcs_sdk-1.6.6.dist-info/RECORD +159 -0
- {dcs_sdk-1.6.4.dist-info → dcs_sdk-1.6.6.dist-info}/entry_points.txt +1 -0
- dcs_sdk-1.6.4.dist-info/RECORD +0 -72
- {dcs_sdk-1.6.4.dist-info → dcs_sdk-1.6.6.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Copyright 2022-present, the Waterdip Labs Pvt. Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from typing import Any, List, Union
|
|
15
|
+
|
|
16
|
+
from pyspark.sql import DataFrame
|
|
17
|
+
from pyspark.sql.session import SparkSession
|
|
18
|
+
from pyspark.sql.types import Row
|
|
19
|
+
|
|
20
|
+
from dcs_core.core.datasource.sql_datasource import SQLDataSource
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SparkDfCursor:
|
|
24
|
+
def __init__(self, spark_session: SparkSession):
|
|
25
|
+
self.spark_session = spark_session
|
|
26
|
+
self.df: Union[DataFrame, None] = None
|
|
27
|
+
self.description: Union[tuple[tuple], None] = None
|
|
28
|
+
self.rowcount: int = -1
|
|
29
|
+
self.cursor_index: int = -1
|
|
30
|
+
|
|
31
|
+
def execute(self, sql: str):
|
|
32
|
+
self.df = self.spark_session.sql(sqlQuery=sql)
|
|
33
|
+
self.description = self.convert_spark_df_schema_to_dbapi_description(self.df)
|
|
34
|
+
self.cursor_index = 0
|
|
35
|
+
|
|
36
|
+
def fetchall(self) -> tuple[List, ...]:
|
|
37
|
+
rows = []
|
|
38
|
+
spark_rows: list[Row] = self.df.collect()
|
|
39
|
+
self.rowcount = len(spark_rows)
|
|
40
|
+
for spark_row in spark_rows:
|
|
41
|
+
row = self.convert_spark_row_to_dbapi_row(spark_row)
|
|
42
|
+
rows.append(row)
|
|
43
|
+
return tuple(rows)
|
|
44
|
+
|
|
45
|
+
def fetchmany(self, size: int) -> tuple[List, ...]:
|
|
46
|
+
rows = []
|
|
47
|
+
self.rowcount = self.df.count()
|
|
48
|
+
spark_rows: list[Row] = self.df.limit(size).offset(self.cursor_index).collect()
|
|
49
|
+
self.cursor_index += len(spark_rows)
|
|
50
|
+
for spark_row in spark_rows:
|
|
51
|
+
row = self.convert_spark_row_to_dbapi_row(spark_row)
|
|
52
|
+
rows.append(row)
|
|
53
|
+
return tuple(rows)
|
|
54
|
+
|
|
55
|
+
def fetchone(self) -> tuple:
|
|
56
|
+
spark_rows: list[Row] = self.df.collect()
|
|
57
|
+
self.rowcount = len(spark_rows)
|
|
58
|
+
spark_row = spark_rows[0]
|
|
59
|
+
row = self.convert_spark_row_to_dbapi_row(spark_row)
|
|
60
|
+
return tuple(row)
|
|
61
|
+
|
|
62
|
+
@staticmethod
|
|
63
|
+
def convert_spark_row_to_dbapi_row(spark_row):
|
|
64
|
+
return [spark_row[field] for field in spark_row.__fields__]
|
|
65
|
+
|
|
66
|
+
def close(self):
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def convert_spark_df_schema_to_dbapi_description(df) -> tuple[tuple[Any, Any], ...]:
|
|
71
|
+
return tuple((field.name, type(field.dataType).__name__) for field in df.schema.fields)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class SparkDfConnection:
|
|
75
|
+
def __init__(self, spark_session: SparkSession):
|
|
76
|
+
self.spark_session = spark_session
|
|
77
|
+
|
|
78
|
+
def cursor(self) -> SparkDfCursor:
|
|
79
|
+
return SparkDfCursor(self.spark_session)
|
|
80
|
+
|
|
81
|
+
def close(self):
|
|
82
|
+
pass
|
|
83
|
+
|
|
84
|
+
def commit(self):
|
|
85
|
+
pass
|
|
86
|
+
|
|
87
|
+
def rollback(self):
|
|
88
|
+
pass
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class SparkDFDataSource(SQLDataSource):
|
|
92
|
+
def __init__(self, data_source_name: str, data_connection: dict):
|
|
93
|
+
super().__init__(data_source_name, data_connection)
|
|
94
|
+
self.spark_session = data_connection.get("spark_session")
|
|
95
|
+
self.use_sa_text_query = False
|
|
96
|
+
|
|
97
|
+
def connect(self):
|
|
98
|
+
self.connection = SparkDfConnection(self.spark_session)
|
|
99
|
+
|
|
100
|
+
def close(self):
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
def fetchone(self, query):
|
|
104
|
+
cursor = self.connection.cursor()
|
|
105
|
+
cursor.execute(query)
|
|
106
|
+
return cursor.fetchone()
|
|
107
|
+
|
|
108
|
+
def fetchall(self, query):
|
|
109
|
+
cursor = self.connection.cursor()
|
|
110
|
+
cursor.execute(query)
|
|
111
|
+
return cursor.fetchall()
|