dcs-sdk 1.6.5__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.
- data_diff/__init__.py +221 -0
- data_diff/__main__.py +517 -0
- data_diff/abcs/__init__.py +13 -0
- data_diff/abcs/compiler.py +27 -0
- data_diff/abcs/database_types.py +402 -0
- data_diff/config.py +141 -0
- data_diff/databases/__init__.py +38 -0
- data_diff/databases/_connect.py +323 -0
- data_diff/databases/base.py +1417 -0
- data_diff/databases/bigquery.py +376 -0
- data_diff/databases/clickhouse.py +217 -0
- data_diff/databases/databricks.py +262 -0
- data_diff/databases/duckdb.py +207 -0
- data_diff/databases/mssql.py +343 -0
- data_diff/databases/mysql.py +189 -0
- data_diff/databases/oracle.py +238 -0
- data_diff/databases/postgresql.py +293 -0
- data_diff/databases/presto.py +222 -0
- data_diff/databases/redis.py +93 -0
- data_diff/databases/redshift.py +233 -0
- data_diff/databases/snowflake.py +222 -0
- data_diff/databases/sybase.py +720 -0
- data_diff/databases/trino.py +73 -0
- data_diff/databases/vertica.py +174 -0
- data_diff/diff_tables.py +489 -0
- data_diff/errors.py +17 -0
- data_diff/format.py +369 -0
- data_diff/hashdiff_tables.py +1026 -0
- data_diff/info_tree.py +76 -0
- data_diff/joindiff_tables.py +434 -0
- data_diff/lexicographic_space.py +253 -0
- data_diff/parse_time.py +88 -0
- data_diff/py.typed +0 -0
- data_diff/queries/__init__.py +13 -0
- data_diff/queries/api.py +213 -0
- data_diff/queries/ast_classes.py +811 -0
- data_diff/queries/base.py +38 -0
- data_diff/queries/extras.py +43 -0
- data_diff/query_utils.py +70 -0
- data_diff/schema.py +67 -0
- data_diff/table_segment.py +583 -0
- data_diff/thread_utils.py +112 -0
- data_diff/utils.py +1022 -0
- data_diff/version.py +15 -0
- 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 +829 -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 +482 -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/__init__.py +13 -0
- dcs_sdk/__main__.py +18 -0
- dcs_sdk/__version__.py +15 -0
- dcs_sdk/cli/__init__.py +13 -0
- dcs_sdk/cli/cli.py +163 -0
- dcs_sdk/sdk/__init__.py +58 -0
- dcs_sdk/sdk/config/__init__.py +13 -0
- dcs_sdk/sdk/config/config_loader.py +491 -0
- dcs_sdk/sdk/data_diff/__init__.py +13 -0
- dcs_sdk/sdk/data_diff/data_differ.py +821 -0
- dcs_sdk/sdk/rules/__init__.py +15 -0
- dcs_sdk/sdk/rules/rules_mappping.py +31 -0
- dcs_sdk/sdk/rules/rules_repository.py +214 -0
- dcs_sdk/sdk/rules/schema_rules.py +65 -0
- dcs_sdk/sdk/utils/__init__.py +13 -0
- dcs_sdk/sdk/utils/serializer.py +25 -0
- dcs_sdk/sdk/utils/similarity_score/__init__.py +13 -0
- dcs_sdk/sdk/utils/similarity_score/base_provider.py +153 -0
- dcs_sdk/sdk/utils/similarity_score/cosine_similarity_provider.py +39 -0
- dcs_sdk/sdk/utils/similarity_score/jaccard_provider.py +24 -0
- dcs_sdk/sdk/utils/similarity_score/levenshtein_distance_provider.py +31 -0
- dcs_sdk/sdk/utils/table.py +475 -0
- dcs_sdk/sdk/utils/themes.py +40 -0
- dcs_sdk/sdk/utils/utils.py +349 -0
- dcs_sdk-1.6.5.dist-info/METADATA +150 -0
- dcs_sdk-1.6.5.dist-info/RECORD +159 -0
- dcs_sdk-1.6.5.dist-info/WHEEL +4 -0
- dcs_sdk-1.6.5.dist-info/entry_points.txt +4 -0
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
|
|
15
|
+
from typing import Generator
|
|
16
|
+
|
|
17
|
+
import attrs
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@attrs.define(frozen=True)
|
|
21
|
+
class _SKIP:
|
|
22
|
+
def __repr__(self) -> str:
|
|
23
|
+
return "SKIP"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
SKIP = _SKIP()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class SqeletonError(Exception):
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def args_as_tuple(exprs):
|
|
34
|
+
if len(exprs) == 1:
|
|
35
|
+
(e,) = exprs
|
|
36
|
+
if isinstance(e, Generator):
|
|
37
|
+
return tuple(e)
|
|
38
|
+
return exprs
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
|
|
15
|
+
"Useful AST classes that don't quite fall within the scope of regular SQL"
|
|
16
|
+
|
|
17
|
+
from typing import Callable, Optional, Sequence
|
|
18
|
+
|
|
19
|
+
import attrs
|
|
20
|
+
|
|
21
|
+
from data_diff.abcs.database_types import ColType
|
|
22
|
+
from data_diff.queries.ast_classes import Expr, ExprNode
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@attrs.define(frozen=True)
|
|
26
|
+
class NormalizeAsString(ExprNode):
|
|
27
|
+
expr: ExprNode
|
|
28
|
+
expr_type: Optional[ColType] = None
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def type(self) -> Optional[type]:
|
|
32
|
+
return str
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@attrs.define(frozen=True)
|
|
36
|
+
class ApplyFuncAndNormalizeAsString(ExprNode):
|
|
37
|
+
expr: ExprNode
|
|
38
|
+
apply_func: Optional[Callable] = None
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@attrs.define(frozen=True)
|
|
42
|
+
class Checksum(ExprNode):
|
|
43
|
+
exprs: Sequence[Expr]
|
data_diff/query_utils.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
|
|
15
|
+
"Module for query utilities that didn't make it into the query-builder (yet)"
|
|
16
|
+
|
|
17
|
+
from contextlib import suppress
|
|
18
|
+
|
|
19
|
+
from data_diff.abcs.database_types import DbPath
|
|
20
|
+
from data_diff.databases.base import QueryError
|
|
21
|
+
from data_diff.databases.oracle import Oracle
|
|
22
|
+
from data_diff.queries.api import Expr, commit, table
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _drop_table_oracle(name: DbPath):
|
|
26
|
+
t = table(name)
|
|
27
|
+
# Experience shows double drop is necessary
|
|
28
|
+
with suppress(QueryError):
|
|
29
|
+
yield t.drop()
|
|
30
|
+
yield t.drop()
|
|
31
|
+
yield commit
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _drop_table(name: DbPath):
|
|
35
|
+
t = table(name)
|
|
36
|
+
yield t.drop(if_exists=True)
|
|
37
|
+
yield commit
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def drop_table(db, tbl) -> None:
|
|
41
|
+
if isinstance(db, Oracle):
|
|
42
|
+
db.query(_drop_table_oracle(tbl))
|
|
43
|
+
else:
|
|
44
|
+
db.query(_drop_table(tbl))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _append_to_table_oracle(path: DbPath, expr: Expr):
|
|
48
|
+
"""See append_to_table"""
|
|
49
|
+
assert expr.schema, expr
|
|
50
|
+
t = table(path, schema=expr.schema)
|
|
51
|
+
with suppress(QueryError):
|
|
52
|
+
yield t.create() # uses expr.schema
|
|
53
|
+
yield commit
|
|
54
|
+
yield t.insert_expr(expr)
|
|
55
|
+
yield commit
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _append_to_table(path: DbPath, expr: Expr):
|
|
59
|
+
"""Append to table"""
|
|
60
|
+
assert expr.schema, expr
|
|
61
|
+
t = table(path, schema=expr.schema)
|
|
62
|
+
yield t.create(if_not_exists=True) # uses expr.schema
|
|
63
|
+
yield commit
|
|
64
|
+
yield t.insert_expr(expr)
|
|
65
|
+
yield commit
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def append_to_table(db, path, expr) -> None:
|
|
69
|
+
f = _append_to_table_oracle if isinstance(db, Oracle) else _append_to_table
|
|
70
|
+
db.query(f(path, expr))
|
data_diff/schema.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
|
|
15
|
+
import logging
|
|
16
|
+
from typing import Any, Collection, Iterator, Optional
|
|
17
|
+
|
|
18
|
+
import attrs
|
|
19
|
+
|
|
20
|
+
from data_diff.abcs.database_types import DbPath
|
|
21
|
+
from data_diff.utils import CaseAwareMapping, CaseInsensitiveDict, CaseSensitiveDict
|
|
22
|
+
|
|
23
|
+
logger = logging.getLogger("schema")
|
|
24
|
+
|
|
25
|
+
Schema = CaseAwareMapping
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@attrs.frozen(kw_only=True)
|
|
29
|
+
class RawColumnInfo(Collection[Any]):
|
|
30
|
+
"""
|
|
31
|
+
A raw row representing the schema info about a column.
|
|
32
|
+
|
|
33
|
+
Do not rely on this class too much, it will be removed soon when the schema
|
|
34
|
+
selecting & parsing methods are united into one overrideable method.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
column_name: str
|
|
38
|
+
data_type: str
|
|
39
|
+
datetime_precision: Optional[int] = None
|
|
40
|
+
numeric_precision: Optional[int] = None
|
|
41
|
+
numeric_scale: Optional[int] = None
|
|
42
|
+
collation_name: Optional[str] = None
|
|
43
|
+
character_maximum_length: Optional[int] = None
|
|
44
|
+
|
|
45
|
+
# It was a tuple once, so we keep it backward compatible temporarily, until remade to classes.
|
|
46
|
+
def __iter__(self) -> Iterator[Any]:
|
|
47
|
+
return iter(
|
|
48
|
+
(self.column_name, self.data_type, self.datetime_precision, self.numeric_precision, self.numeric_scale)
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def __len__(self) -> int:
|
|
52
|
+
return 5
|
|
53
|
+
|
|
54
|
+
def __contains__(self, item: Any) -> bool:
|
|
55
|
+
return False # that was not used
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def create_schema(db_name: str, table_path: DbPath, schema: dict, case_sensitive: bool) -> CaseAwareMapping:
|
|
59
|
+
logger.info(f"[{db_name}] Schema = {schema}")
|
|
60
|
+
|
|
61
|
+
if case_sensitive:
|
|
62
|
+
return CaseSensitiveDict(schema)
|
|
63
|
+
|
|
64
|
+
if len({k.lower() for k in schema}) < len(schema):
|
|
65
|
+
logger.warning(f'Ambiguous schema for {db_name}:{".".join(table_path)} | Columns = {", ".join(list(schema))}')
|
|
66
|
+
logger.warning("We recommend to disable case-insensitivity (set --case-sensitive).")
|
|
67
|
+
return CaseInsensitiveDict(schema)
|