dcs-sdk 2.0.0__tar.gz → 2.2.0__tar.gz
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_sdk-2.0.0 → dcs_sdk-2.2.0}/PKG-INFO +2 -2
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/README.md +1 -1
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/abcs/database_types.py +11 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/base.py +20 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/bigquery.py +7 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/databricks.py +7 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/db2.py +9 -1
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/duckdb.py +8 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/mssql.py +74 -19
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/mysql.py +12 -2
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/oracle.py +14 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/postgresql.py +8 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/presto.py +8 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/sap_hana.py +9 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/snowflake.py +9 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/sybase.py +13 -2
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/vertica.py +15 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/errors.py +36 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/datasource/sql_datasource.py +60 -5
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/mssql.py +113 -37
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/__version__.py +1 -1
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/pyproject.toml +1 -1
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/__main__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/abcs/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/abcs/compiler.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/config.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/_connect.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/clickhouse.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/redis.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/redshift.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/databases/trino.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/diff_tables.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/errors.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/format.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/hashdiff_tables.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/info_tree.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/joindiff_tables.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/lexicographic_space.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/parse_time.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/py.typed +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/queries/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/queries/api.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/queries/ast_classes.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/queries/base.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/queries/extras.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/query_utils.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/schema.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/streaming.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/table_segment.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/thread_utils.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/utils.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/data_diff/version.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/__main__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/__version__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/cli/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/cli/cli.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/models/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/models/configuration.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/models/dashboard.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/models/data_source_resource.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/models/metric.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/models/profile.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/models/validation.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/common/models/widget.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/configuration/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/configuration/config_loader.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/configuration/configuration_parser.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/configuration/configuration_parser_arc.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/datasource/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/datasource/base.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/datasource/file_datasource.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/datasource/manager.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/datasource/search_datasource.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/inspect.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/logger/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/logger/base.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/logger/default_logger.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/metric/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/metric/base.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/metric/combined_metric.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/metric/custom_metric.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/metric/manager.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/metric/numeric_metric.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/metric/reliability_metric.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/observability/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/observability/connection_observer.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/profiling/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/profiling/datasource_profiling.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/profiling/numeric_field_profiling.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/profiling/text_field_profiling.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/repository/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/repository/metric_repository.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/utils/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/utils/log.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/utils/tracking.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/utils/utils.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/base.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/completeness_validation.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/custom_query_validation.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/manager.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/numeric_validation.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/reliability_validation.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/uniqueness_validation.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/core/validation/validity_validation.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/azure_blob.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/bigquery.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/clickhouse.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/databricks.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/db2.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/duck_db.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/elasticsearch.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/mysql.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/opensearch.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/oracle.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/postgres.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/presto.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/redshift.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/sap_hana.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/snowflake.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/spark_df.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/sybase.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/trino.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/databases/vertica.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/storage/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/storage/local_file.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/utils/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/integrations/utils/utils.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/dashboard.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/models.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/assets/fonts/DMSans-Bold.ttf +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/assets/fonts/DMSans-Medium.ttf +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/assets/fonts/DMSans-Regular.ttf +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/assets/fonts/DMSans-SemiBold.ttf +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/assets/images/docs.svg +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/assets/images/github.svg +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/assets/images/logo.svg +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/assets/images/slack.svg +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/index.js +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_core/report/static/index.js.LICENSE.txt +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/__main__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/cli/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/cli/cli.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/config/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/config/config_loader.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/data_diff/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/data_diff/data_differ.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/rules/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/rules/rules_mappping.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/rules/rules_repository.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/rules/schema_rules.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/serializer.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/similarity_score/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/similarity_score/base_provider.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/similarity_score/cosine_similarity_provider.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/similarity_score/jaccard_provider.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/similarity_score/levenshtein_distance_provider.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/table.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/themes.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/sdk/utils/utils.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/utils/__init__.py +0 -0
- {dcs_sdk-2.0.0 → dcs_sdk-2.2.0}/dcs_sdk/utils/temp_objects.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dcs-sdk
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: SDK for DataChecks
|
|
5
5
|
Author: Waterdip Labs
|
|
6
6
|
Author-email: hello@waterdip.ai
|
|
@@ -93,7 +93,7 @@ Requires-Dist: virtualenv (>=20.36.2,<21.0.0)
|
|
|
93
93
|
Description-Content-Type: text/markdown
|
|
94
94
|
|
|
95
95
|
<h1 align="center">
|
|
96
|
-
DCS SDK v2.
|
|
96
|
+
DCS SDK v2.1.0
|
|
97
97
|
</h1>
|
|
98
98
|
|
|
99
99
|
> SDK for DataChecks
|
|
@@ -363,6 +363,17 @@ class Text(ColType_Unicode, StringType):
|
|
|
363
363
|
return False
|
|
364
364
|
|
|
365
365
|
|
|
366
|
+
# Raw byte columns: bytea, varbinary, blob, raw, bytes, ... Every dialect renders these
|
|
367
|
+
# differently by default (Postgres '\\xdeadbeef', MSSQL mojibake, Oracle uppercase hex), so
|
|
368
|
+
# they get their own normalization hook rather than falling through to to_string().
|
|
369
|
+
@attrs.define(frozen=True)
|
|
370
|
+
class Binary(ColType):
|
|
371
|
+
# The engine's own spelling of the type ('bytea', 'BLOB', 'RAW', 'image', ...). Some
|
|
372
|
+
# dialects need it because one hex function does not cover every byte type they have:
|
|
373
|
+
# Oracle reads a RAW with RAWTOHEX but a BLOB only through DBMS_LOB.
|
|
374
|
+
data_type: str = ""
|
|
375
|
+
|
|
376
|
+
|
|
366
377
|
# In majority of DBMSes, it is called JSON/JSONB. Only in Snowflake, it is OBJECT.
|
|
367
378
|
@attrs.define(frozen=True)
|
|
368
379
|
class JSON(ColType):
|
|
@@ -54,6 +54,7 @@ from data_diff.abcs.database_types import (
|
|
|
54
54
|
ArithAlphanumeric,
|
|
55
55
|
ArithUnicodeString,
|
|
56
56
|
Array,
|
|
57
|
+
Binary,
|
|
57
58
|
Boolean,
|
|
58
59
|
ColType,
|
|
59
60
|
ColType_UUID,
|
|
@@ -840,6 +841,9 @@ class BaseDialect(abc.ABC):
|
|
|
840
841
|
)
|
|
841
842
|
)
|
|
842
843
|
|
|
844
|
+
elif issubclass(cls, Binary):
|
|
845
|
+
return cls(data_type=info.data_type or "")
|
|
846
|
+
|
|
843
847
|
elif issubclass(cls, (JSON, Array, Struct, Text, Native_UUID)):
|
|
844
848
|
return cls()
|
|
845
849
|
|
|
@@ -940,6 +944,20 @@ class BaseDialect(abc.ABC):
|
|
|
940
944
|
"""Creates an SQL expression, that serialized a typed struct into a JSON string."""
|
|
941
945
|
return self.to_string(value)
|
|
942
946
|
|
|
947
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
948
|
+
"""Creates an SQL expression, that renders raw bytes as uppercase hex, no prefix.
|
|
949
|
+
|
|
950
|
+
Uppercase-hex-without-prefix is the canonical form because it is what the majority
|
|
951
|
+
of engines already produce natively (Oracle RAWTOHEX, MySQL HEX, DB2 HEX, Trino
|
|
952
|
+
to_hex, Snowflake TO_VARCHAR(x,'HEX')). Dialects whose native rendering differs
|
|
953
|
+
(Postgres' '\\xdeadbeef', MSSQL's raw byte reinterpretation, BigQuery/Vertica's
|
|
954
|
+
lowercase) override this to match.
|
|
955
|
+
|
|
956
|
+
The default is to_string(), so a dialect that has not mapped its byte types to
|
|
957
|
+
Binary keeps whatever behavior it had before.
|
|
958
|
+
"""
|
|
959
|
+
return self.to_string(value)
|
|
960
|
+
|
|
943
961
|
def normalize_value_by_type(self, value: str, coltype: ColType) -> str:
|
|
944
962
|
"""Creates an SQL expression, that converts 'value' to a normalized representation.
|
|
945
963
|
|
|
@@ -970,6 +988,8 @@ class BaseDialect(abc.ABC):
|
|
|
970
988
|
return self.normalize_array(value, coltype)
|
|
971
989
|
elif isinstance(coltype, Struct):
|
|
972
990
|
return self.normalize_struct(value, coltype)
|
|
991
|
+
elif isinstance(coltype, Binary):
|
|
992
|
+
return self.normalize_binary(value, coltype)
|
|
973
993
|
return self.to_string(value)
|
|
974
994
|
|
|
975
995
|
def optimizer_hints(self, hints: str) -> str:
|
|
@@ -23,6 +23,7 @@ import attrs
|
|
|
23
23
|
from data_diff.abcs.database_types import (
|
|
24
24
|
JSON,
|
|
25
25
|
Array,
|
|
26
|
+
Binary,
|
|
26
27
|
Boolean,
|
|
27
28
|
ColType,
|
|
28
29
|
Date,
|
|
@@ -97,6 +98,8 @@ class Dialect(BaseDialect):
|
|
|
97
98
|
"FLOAT64": Float,
|
|
98
99
|
"FLOAT32": Float,
|
|
99
100
|
"STRING": Text,
|
|
101
|
+
# Bytes
|
|
102
|
+
"BYTES": Binary,
|
|
100
103
|
"BOOL": Boolean,
|
|
101
104
|
"JSON": JSON,
|
|
102
105
|
}
|
|
@@ -226,6 +229,10 @@ class Dialect(BaseDialect):
|
|
|
226
229
|
def normalize_number(self, value: str, coltype: FractionalType) -> str:
|
|
227
230
|
return f"format('%.{coltype.precision}f', {value})"
|
|
228
231
|
|
|
232
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
233
|
+
# BigQuery's TO_HEX is lowercase.
|
|
234
|
+
return f"UPPER(TO_HEX({value}))"
|
|
235
|
+
|
|
229
236
|
def normalize_boolean(self, value: str, _coltype: Boolean) -> str:
|
|
230
237
|
return self.to_string(f"cast({value} as int)")
|
|
231
238
|
|
|
@@ -19,6 +19,7 @@ from typing import Any, ClassVar, Dict, Sequence, Type
|
|
|
19
19
|
import attrs
|
|
20
20
|
|
|
21
21
|
from data_diff.abcs.database_types import (
|
|
22
|
+
Binary,
|
|
22
23
|
Boolean,
|
|
23
24
|
ColType,
|
|
24
25
|
Date,
|
|
@@ -71,6 +72,8 @@ class Dialect(BaseDialect):
|
|
|
71
72
|
# Text
|
|
72
73
|
"STRING": Text,
|
|
73
74
|
"VARCHAR": Text,
|
|
75
|
+
# Bytes
|
|
76
|
+
"BINARY": Binary,
|
|
74
77
|
# Boolean
|
|
75
78
|
"BOOLEAN": Boolean,
|
|
76
79
|
}
|
|
@@ -134,6 +137,10 @@ class Dialect(BaseDialect):
|
|
|
134
137
|
value = f"format_number({value}, {coltype.precision})"
|
|
135
138
|
return f"replace({self.to_string(value)}, ',', '')"
|
|
136
139
|
|
|
140
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
141
|
+
# Spark's hex() is already uppercase and unprefixed.
|
|
142
|
+
return f"hex({value})"
|
|
143
|
+
|
|
137
144
|
def normalize_boolean(self, value: str, _coltype: Boolean) -> str:
|
|
138
145
|
return self.to_string(f"cast ({value} as int)")
|
|
139
146
|
|
|
@@ -17,6 +17,7 @@ from typing import Any, ClassVar, Dict, Optional, Type
|
|
|
17
17
|
import attrs
|
|
18
18
|
|
|
19
19
|
from data_diff.abcs.database_types import (
|
|
20
|
+
Binary,
|
|
20
21
|
Boolean,
|
|
21
22
|
Date,
|
|
22
23
|
DbPath,
|
|
@@ -108,7 +109,8 @@ class Dialect(BaseDialect):
|
|
|
108
109
|
"LONG VARGRAPHIC": Text,
|
|
109
110
|
"DBCLOB": Text,
|
|
110
111
|
"XML": Text,
|
|
111
|
-
|
|
112
|
+
# Bytes
|
|
113
|
+
"BLOB": Binary,
|
|
112
114
|
# Bool (native BOOLEAN since DB2 11.1)
|
|
113
115
|
"BOOLEAN": Boolean,
|
|
114
116
|
}
|
|
@@ -211,6 +213,12 @@ class Dialect(BaseDialect):
|
|
|
211
213
|
# DB2's max DECIMAL precision is 31 (Oracle/MSSQL allow 38) - verified live.
|
|
212
214
|
return self.to_string(f"CAST({value} AS DECIMAL(31, {coltype.precision}))")
|
|
213
215
|
|
|
216
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
217
|
+
# DB2's HEX() is already uppercase and unprefixed. Note DB2 LUW reports CHAR/VARCHAR
|
|
218
|
+
# FOR BIT DATA under the plain CHARACTER/VARCHAR type names, so those stay Text -
|
|
219
|
+
# there is no TYPENAME that identifies them as binary.
|
|
220
|
+
return f"HEX({value})"
|
|
221
|
+
|
|
214
222
|
def generate_view_name(self, view_name: str | None = None) -> str:
|
|
215
223
|
if view_name is not None:
|
|
216
224
|
return ensure_temp_object_prefix(view_name, uppercase=True)
|
|
@@ -18,6 +18,7 @@ import attrs
|
|
|
18
18
|
from packaging.version import parse as parse_version
|
|
19
19
|
|
|
20
20
|
from data_diff.abcs.database_types import (
|
|
21
|
+
Binary,
|
|
21
22
|
Boolean,
|
|
22
23
|
ColType,
|
|
23
24
|
DbPath,
|
|
@@ -78,6 +79,8 @@ class Dialect(BaseDialect):
|
|
|
78
79
|
# Text
|
|
79
80
|
"VARCHAR": Text,
|
|
80
81
|
"TEXT": Text,
|
|
82
|
+
# Bytes
|
|
83
|
+
"BLOB": Binary,
|
|
81
84
|
# UUID
|
|
82
85
|
"UUID": Native_UUID,
|
|
83
86
|
# Bool
|
|
@@ -127,6 +130,11 @@ class Dialect(BaseDialect):
|
|
|
127
130
|
def normalize_number(self, value: str, coltype: FractionalType) -> str:
|
|
128
131
|
return self.to_string(f"{value}::DECIMAL(38, {coltype.precision})")
|
|
129
132
|
|
|
133
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
134
|
+
# DuckDB's hex() is already uppercase and unprefixed; casting a BLOB to VARCHAR
|
|
135
|
+
# would instead give the '\\xFB' escaped form.
|
|
136
|
+
return f"hex({value})"
|
|
137
|
+
|
|
130
138
|
def normalize_boolean(self, value: str, _coltype: Boolean) -> str:
|
|
131
139
|
return self.to_string(f"{value}::INTEGER")
|
|
132
140
|
|
|
@@ -22,6 +22,7 @@ from sqlglot import exp
|
|
|
22
22
|
|
|
23
23
|
from data_diff.abcs.database_types import (
|
|
24
24
|
JSON,
|
|
25
|
+
Binary,
|
|
25
26
|
Boolean,
|
|
26
27
|
Date,
|
|
27
28
|
Datetime,
|
|
@@ -41,6 +42,7 @@ from data_diff.abcs.database_types import (
|
|
|
41
42
|
from data_diff.databases.base import (
|
|
42
43
|
CHECKSUM_HEXDIGITS,
|
|
43
44
|
CHECKSUM_OFFSET,
|
|
45
|
+
TIMESTAMP_PRECISION_POS,
|
|
44
46
|
BaseDialect,
|
|
45
47
|
ConnectError,
|
|
46
48
|
QueryError,
|
|
@@ -101,8 +103,10 @@ class Dialect(BaseDialect):
|
|
|
101
103
|
"ntext": Text,
|
|
102
104
|
"nvarchar": Text,
|
|
103
105
|
"nchar": Text,
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
+
# Bytes - CONVERT to a character type reinterprets the bytes and yields mojibake
|
|
107
|
+
"binary": Binary,
|
|
108
|
+
"varbinary": Binary,
|
|
109
|
+
"image": Binary,
|
|
106
110
|
"xml": Text,
|
|
107
111
|
# UUID
|
|
108
112
|
"uniqueidentifier": Native_UUID,
|
|
@@ -142,13 +146,22 @@ class Dialect(BaseDialect):
|
|
|
142
146
|
else:
|
|
143
147
|
ch_len = min(ch_len, 8000)
|
|
144
148
|
|
|
145
|
-
|
|
149
|
+
data_type = col_info.data_type.lower().strip() if col_info else ""
|
|
150
|
+
|
|
151
|
+
if data_type in ("binary", "varbinary", "image"):
|
|
152
|
+
# A plain CONVERT reinterprets the bytes as characters and yields mojibake
|
|
153
|
+
# ('\xfbx\xb6%...'), which never matches another database. Byte columns reach
|
|
154
|
+
# normalize_binary() through normalize_value_by_type(), but to_string() is also
|
|
155
|
+
# called directly in a few places, so route both through the same expression.
|
|
156
|
+
return self.normalize_binary(s, Binary(data_type=data_type))
|
|
157
|
+
|
|
158
|
+
if data_type in ("nvarchar", "nchar"):
|
|
146
159
|
return f"CONVERT(NVARCHAR({ch_len}), {s})"
|
|
147
160
|
|
|
148
|
-
|
|
161
|
+
if data_type == "text":
|
|
149
162
|
return f"CONVERT(VARCHAR(MAX), {s})"
|
|
150
163
|
|
|
151
|
-
|
|
164
|
+
if data_type == "ntext":
|
|
152
165
|
return f"CONVERT(NVARCHAR(MAX), {s})"
|
|
153
166
|
|
|
154
167
|
return f"CONVERT(VARCHAR({ch_len}), {s})"
|
|
@@ -200,24 +213,66 @@ class Dialect(BaseDialect):
|
|
|
200
213
|
return f"VALUES {values}"
|
|
201
214
|
|
|
202
215
|
def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
"""Render any temporal value in the cross-dialect canonical form.
|
|
217
|
+
|
|
218
|
+
Every dialect must emit the exact same string for the same instant, because the
|
|
219
|
+
row checksum is computed over that string. The contract is:
|
|
220
|
+
|
|
221
|
+
Date -> 'YYYY-MM-DD'
|
|
222
|
+
Time -> 'HH:MM:SS.ffffff' (always 6 fractional digits)
|
|
223
|
+
Timestamp -> 'YYYY-MM-DD HH:MM:SS.ffffff' (always 6 fractional digits)
|
|
224
|
+
|
|
225
|
+
Digits past the column's own precision are cut, not rounded, and the result is
|
|
226
|
+
zero-padded back out to 6. Truncating matters: Snowflake's 'FF6' and Postgres'
|
|
227
|
+
LEFT()-based padding both truncate, so rounding here would disagree with them on
|
|
228
|
+
the 7th digit of a datetime2(7).
|
|
229
|
+
"""
|
|
230
|
+
try:
|
|
231
|
+
is_date = coltype.is_date
|
|
232
|
+
is_time = coltype.is_time
|
|
233
|
+
except AttributeError:
|
|
234
|
+
is_date = False
|
|
235
|
+
is_time = False
|
|
236
|
+
|
|
237
|
+
precision = min(getattr(coltype, "precision", 6) or 0, 6)
|
|
238
|
+
|
|
239
|
+
if isinstance(coltype, Date) or is_date:
|
|
240
|
+
return f"CONVERT(VARCHAR(10), {value}, 23)"
|
|
241
|
+
|
|
242
|
+
if isinstance(coltype, Time) or is_time:
|
|
243
|
+
# datetime2 carries a date part we do not want, so keep only the last 15
|
|
244
|
+
# characters of 'yyyy-mm-dd hh:mi:ss.ffffff', i.e. 'hh:mi:ss.ffffff'.
|
|
245
|
+
full = f"CONVERT(VARCHAR(27), CAST({value} AS datetime2(7)), 121)"
|
|
246
|
+
truncated = f"LEFT({full}, {TIMESTAMP_PRECISION_POS + precision})"
|
|
247
|
+
padded = f"LEFT({truncated} + '000000', {TIMESTAMP_PRECISION_POS + 6})"
|
|
248
|
+
return f"CASE WHEN {value} IS NULL THEN NULL ELSE RIGHT({padded}, 15) END"
|
|
249
|
+
|
|
250
|
+
if isinstance(coltype, TimestampTZ):
|
|
251
|
+
# Other dialects normalize to UTC before formatting, so shift the offset to
|
|
252
|
+
# zero here rather than comparing wall-clock times from different zones.
|
|
253
|
+
# SWITCHOFFSET is used instead of AT TIME ZONE 'UTC': it works on SQL Server
|
|
254
|
+
# 2008+, while AT TIME ZONE needs 2016+ and fails on Azure SQL Edge with
|
|
255
|
+
# "Common Language Runtime (CLR) is not enabled on this instance" (verified).
|
|
256
|
+
utc = f"CAST(SWITCHOFFSET({value}, 0) AS datetime2(7))"
|
|
257
|
+
else:
|
|
258
|
+
utc = f"CAST({value} AS datetime2(7))"
|
|
259
|
+
|
|
260
|
+
full = f"CONVERT(VARCHAR(27), {utc}, 121)"
|
|
261
|
+
truncated = f"LEFT({full}, {TIMESTAMP_PRECISION_POS + precision})"
|
|
262
|
+
padded = f"LEFT({truncated} + '000000', {TIMESTAMP_PRECISION_POS + 6})"
|
|
263
|
+
return f"CASE WHEN {value} IS NULL THEN NULL ELSE {padded} END"
|
|
217
264
|
|
|
218
265
|
def normalize_number(self, value: str, coltype: FractionalType) -> str:
|
|
219
266
|
return self.to_string(f"CAST({value} AS DECIMAL(38, {coltype.precision}))")
|
|
220
267
|
|
|
268
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
269
|
+
# Style 2 is uppercase hex with no '0x' prefix. VARCHAR(MAX) because hex is twice
|
|
270
|
+
# the byte length, so the column's own length would truncate it in half. The inner
|
|
271
|
+
# cast is for the legacy `image` type, which SQL Server refuses to convert to a
|
|
272
|
+
# character type directly ("Explicit conversion from data type image to
|
|
273
|
+
# varchar(max) is not allowed") but happily converts to varbinary first.
|
|
274
|
+
return f"CONVERT(VARCHAR(MAX), CONVERT(VARBINARY(MAX), {value}), 2)"
|
|
275
|
+
|
|
221
276
|
def md5_as_int(self, s: str) -> str:
|
|
222
277
|
return f"convert(bigint, convert(varbinary, '0x' + RIGHT(CONVERT(NVARCHAR(32), HashBytes('MD5', {s}), 2), {CHECKSUM_HEXDIGITS}), 1)) - {CHECKSUM_OFFSET}"
|
|
223
278
|
|
|
@@ -17,6 +17,7 @@ from typing import Any, ClassVar, Dict, Tuple, Type, Union
|
|
|
17
17
|
import attrs
|
|
18
18
|
|
|
19
19
|
from data_diff.abcs.database_types import (
|
|
20
|
+
Binary,
|
|
20
21
|
Boolean,
|
|
21
22
|
ColType_UUID,
|
|
22
23
|
Date,
|
|
@@ -73,12 +74,17 @@ class Dialect(BaseDialect):
|
|
|
73
74
|
# Text
|
|
74
75
|
"varchar": Text,
|
|
75
76
|
"char": Text,
|
|
76
|
-
"varbinary": Text,
|
|
77
|
-
"binary": Text,
|
|
78
77
|
"text": Text,
|
|
79
78
|
"mediumtext": Text,
|
|
80
79
|
"longtext": Text,
|
|
81
80
|
"tinytext": Text,
|
|
81
|
+
# Bytes - CAST(... AS char) mangles these into replacement characters
|
|
82
|
+
"binary": Binary,
|
|
83
|
+
"varbinary": Binary,
|
|
84
|
+
"blob": Binary,
|
|
85
|
+
"tinyblob": Binary,
|
|
86
|
+
"mediumblob": Binary,
|
|
87
|
+
"longblob": Binary,
|
|
82
88
|
# Boolean
|
|
83
89
|
"boolean": Boolean,
|
|
84
90
|
}
|
|
@@ -139,6 +145,10 @@ class Dialect(BaseDialect):
|
|
|
139
145
|
def normalize_number(self, value: str, coltype: FractionalType) -> str:
|
|
140
146
|
return self.to_string(f"cast({value} as decimal(38, {coltype.precision}))")
|
|
141
147
|
|
|
148
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
149
|
+
# MySQL's HEX() is already uppercase and unprefixed, i.e. the canonical form.
|
|
150
|
+
return f"HEX({value})"
|
|
151
|
+
|
|
142
152
|
def normalize_uuid(self, value: str, coltype: ColType_UUID) -> str:
|
|
143
153
|
return f"TRIM(CAST({value} AS char))"
|
|
144
154
|
|
|
@@ -17,6 +17,7 @@ from typing import Any, ClassVar, Dict, List, Optional, Type
|
|
|
17
17
|
import attrs
|
|
18
18
|
|
|
19
19
|
from data_diff.abcs.database_types import (
|
|
20
|
+
Binary,
|
|
20
21
|
ColType,
|
|
21
22
|
ColType_UUID,
|
|
22
23
|
DbPath,
|
|
@@ -73,6 +74,11 @@ class Dialect(
|
|
|
73
74
|
"NCHAR": Text,
|
|
74
75
|
"NVARCHAR2": Text,
|
|
75
76
|
"VARCHAR2": Text,
|
|
77
|
+
# Bytes. LONG RAW is deliberately absent: Oracle rejects it in any expression
|
|
78
|
+
# ("ORA-00997: illegal use of LONG datatype", verified live), so there is no
|
|
79
|
+
# normalization that could work and it stays an unsupported column.
|
|
80
|
+
"RAW": Binary,
|
|
81
|
+
"BLOB": Binary,
|
|
76
82
|
"DATE": Timestamp,
|
|
77
83
|
}
|
|
78
84
|
ROUNDS_ON_PREC_LOSS = True
|
|
@@ -175,6 +181,14 @@ class Dialect(
|
|
|
175
181
|
format_str += "0." + "9" * (coltype.precision - 1) + "0"
|
|
176
182
|
return f"to_char({value}, '{format_str}')"
|
|
177
183
|
|
|
184
|
+
def normalize_binary(self, value: str, coltype: Binary) -> str:
|
|
185
|
+
# RAWTOHEX is already uppercase and unprefixed, but it only accepts a RAW. A BLOB
|
|
186
|
+
# has to be read through DBMS_LOB.SUBSTR first, which caps at 2000 bytes per call,
|
|
187
|
+
# so blobs longer than that compare on their first 2000 bytes.
|
|
188
|
+
if "LOB" in (coltype.data_type or "").upper():
|
|
189
|
+
return f"RAWTOHEX(DBMS_LOB.SUBSTR({value}, 2000, 1))"
|
|
190
|
+
return f"RAWTOHEX({value})"
|
|
191
|
+
|
|
178
192
|
def generate_view_name(self, view_name: str | None = None) -> str:
|
|
179
193
|
if view_name is not None:
|
|
180
194
|
return ensure_temp_object_prefix(view_name, uppercase=True)
|
|
@@ -19,6 +19,7 @@ import attrs
|
|
|
19
19
|
|
|
20
20
|
from data_diff.abcs.database_types import (
|
|
21
21
|
JSON,
|
|
22
|
+
Binary,
|
|
22
23
|
Boolean,
|
|
23
24
|
ColType,
|
|
24
25
|
Date,
|
|
@@ -92,6 +93,8 @@ class PostgresqlDialect(BaseDialect):
|
|
|
92
93
|
"character varying": Text,
|
|
93
94
|
"varchar": Text,
|
|
94
95
|
"text": Text,
|
|
96
|
+
# Bytes
|
|
97
|
+
"bytea": Binary,
|
|
95
98
|
"json": JSON,
|
|
96
99
|
"jsonb": JSON,
|
|
97
100
|
"uuid": Native_UUID,
|
|
@@ -188,6 +191,11 @@ class PostgresqlDialect(BaseDialect):
|
|
|
188
191
|
precision = min(coltype.precision, 18)
|
|
189
192
|
return self.to_string(f"{value}::decimal(38, {precision})")
|
|
190
193
|
|
|
194
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
195
|
+
# Postgres renders bytea as '\\xdeadbeef' - a literal backslash-x prefix plus
|
|
196
|
+
# lowercase hex. encode() drops the prefix, UPPER() matches the canonical form.
|
|
197
|
+
return f"UPPER(encode({value}, 'hex'))"
|
|
198
|
+
|
|
191
199
|
def normalize_boolean(self, value: str, _coltype: Boolean) -> str:
|
|
192
200
|
return self.to_string(f"{value}::int")
|
|
193
201
|
|
|
@@ -18,6 +18,7 @@ from typing import Any, ClassVar, Type
|
|
|
18
18
|
import attrs
|
|
19
19
|
|
|
20
20
|
from data_diff.abcs.database_types import (
|
|
21
|
+
Binary,
|
|
21
22
|
Boolean,
|
|
22
23
|
ColType,
|
|
23
24
|
ColType_UUID,
|
|
@@ -103,6 +104,8 @@ class Dialect(BaseDialect):
|
|
|
103
104
|
# Text
|
|
104
105
|
"varchar": Text,
|
|
105
106
|
"char": Text,
|
|
107
|
+
# Bytes
|
|
108
|
+
"varbinary": Binary,
|
|
106
109
|
# Boolean
|
|
107
110
|
"boolean": Boolean,
|
|
108
111
|
# UUID
|
|
@@ -186,6 +189,11 @@ class Dialect(BaseDialect):
|
|
|
186
189
|
def normalize_number(self, value: str, coltype: FractionalType) -> str:
|
|
187
190
|
return self.to_string(f"cast({value} as decimal(38,{coltype.precision}))")
|
|
188
191
|
|
|
192
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
193
|
+
# to_hex() is already uppercase and unprefixed. Presto/Trino reject a direct
|
|
194
|
+
# CAST(varbinary AS varchar) outright.
|
|
195
|
+
return f"to_hex({value})"
|
|
196
|
+
|
|
189
197
|
def normalize_boolean(self, value: str, _coltype: Boolean) -> str:
|
|
190
198
|
return self.to_string(f"cast ({value} as int)")
|
|
191
199
|
|
|
@@ -17,6 +17,7 @@ from typing import Any, ClassVar, Dict, Tuple, Type, Union
|
|
|
17
17
|
import attrs
|
|
18
18
|
|
|
19
19
|
from data_diff.abcs.database_types import (
|
|
20
|
+
Binary,
|
|
20
21
|
Boolean,
|
|
21
22
|
ColType_UUID,
|
|
22
23
|
Date,
|
|
@@ -86,6 +87,10 @@ class Dialect(BaseDialect):
|
|
|
86
87
|
"text": Text,
|
|
87
88
|
"alphanum": Text,
|
|
88
89
|
"shorttext": Text,
|
|
90
|
+
# Bytes
|
|
91
|
+
"binary": Binary,
|
|
92
|
+
"varbinary": Binary,
|
|
93
|
+
"blob": Binary,
|
|
89
94
|
# Boolean
|
|
90
95
|
"boolean": Boolean,
|
|
91
96
|
}
|
|
@@ -179,6 +184,10 @@ class Dialect(BaseDialect):
|
|
|
179
184
|
precision = getattr(coltype, "precision", 0) or 0
|
|
180
185
|
return self.to_string(f"CAST({value} AS DECIMAL(38, {precision}))")
|
|
181
186
|
|
|
187
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
188
|
+
# HANA's BINTOHEX is already uppercase and unprefixed.
|
|
189
|
+
return f"BINTOHEX({value})"
|
|
190
|
+
|
|
182
191
|
def normalize_uuid(self, value: str, coltype: ColType_UUID) -> str:
|
|
183
192
|
if isinstance(coltype, String_UUID):
|
|
184
193
|
return f"TRIM(CAST({value} AS NVARCHAR))"
|
|
@@ -19,6 +19,7 @@ from typing import Any, ClassVar, List, Optional, Type, Union
|
|
|
19
19
|
import attrs
|
|
20
20
|
|
|
21
21
|
from data_diff.abcs.database_types import (
|
|
22
|
+
Binary,
|
|
22
23
|
Boolean,
|
|
23
24
|
Date,
|
|
24
25
|
DbPath,
|
|
@@ -93,6 +94,9 @@ class Dialect(BaseDialect):
|
|
|
93
94
|
"FLOAT": Float,
|
|
94
95
|
# Text
|
|
95
96
|
"TEXT": Text,
|
|
97
|
+
# Bytes
|
|
98
|
+
"BINARY": Binary,
|
|
99
|
+
"VARBINARY": Binary,
|
|
96
100
|
# Boolean
|
|
97
101
|
"BOOLEAN": Boolean,
|
|
98
102
|
}
|
|
@@ -171,6 +175,11 @@ class Dialect(BaseDialect):
|
|
|
171
175
|
def normalize_number(self, value: str, coltype: FractionalType) -> str:
|
|
172
176
|
return self.to_string(f"cast({value} as decimal(38, {coltype.precision}))")
|
|
173
177
|
|
|
178
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
179
|
+
# CAST(binary AS VARCHAR) would also render hex, but it follows the session's
|
|
180
|
+
# BINARY_OUTPUT_FORMAT, which can be BASE64. Naming 'HEX' pins the output.
|
|
181
|
+
return f"TO_VARCHAR({value}, 'HEX')"
|
|
182
|
+
|
|
174
183
|
def normalize_boolean(self, value: str, _coltype: Boolean) -> str:
|
|
175
184
|
return self.to_string(f"{value}::int")
|
|
176
185
|
|
|
@@ -21,6 +21,7 @@ from loguru import logger
|
|
|
21
21
|
|
|
22
22
|
from data_diff.abcs.database_types import (
|
|
23
23
|
JSON,
|
|
24
|
+
Binary,
|
|
24
25
|
Boolean,
|
|
25
26
|
ColType,
|
|
26
27
|
ColType_UUID,
|
|
@@ -112,8 +113,10 @@ class Dialect(BaseDialect):
|
|
|
112
113
|
"ntext": Text, # ASE only
|
|
113
114
|
"nvarchar": Text, # ASE only
|
|
114
115
|
"nchar": Text, # ASE only
|
|
115
|
-
|
|
116
|
-
"
|
|
116
|
+
# Bytes
|
|
117
|
+
"binary": Binary,
|
|
118
|
+
"varbinary": Binary,
|
|
119
|
+
"image": Binary,
|
|
117
120
|
"xml": Text,
|
|
118
121
|
# UUID
|
|
119
122
|
"uniqueidentifier": Native_UUID,
|
|
@@ -334,6 +337,14 @@ class Dialect(BaseDialect):
|
|
|
334
337
|
# f"), 16), 8)"
|
|
335
338
|
# )
|
|
336
339
|
|
|
340
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
341
|
+
# ASE is not MSSQL here: it accepts CONVERT(varchar, x, 2) but ignores the style and
|
|
342
|
+
# reinterprets the bytes as characters (verified live on ASE 16.0 SP02). bintostr()
|
|
343
|
+
# is ASE's actual binary-to-hex function, and it returns lowercase, so UPPER() is
|
|
344
|
+
# needed to reach the canonical form. The inner cast is for `image`, which bintostr
|
|
345
|
+
# does not take directly.
|
|
346
|
+
return f"UPPER(bintostr(CONVERT(VARBINARY(8192), {value})))"
|
|
347
|
+
|
|
337
348
|
def get_unique_prime_for_column(self, column_name: str) -> int:
|
|
338
349
|
if column_name in self.column_prime_map:
|
|
339
350
|
return self.column_prime_map[column_name]
|
|
@@ -17,6 +17,7 @@ from typing import Any, ClassVar, Dict, List, Type
|
|
|
17
17
|
import attrs
|
|
18
18
|
|
|
19
19
|
from data_diff.abcs.database_types import (
|
|
20
|
+
Binary,
|
|
20
21
|
Boolean,
|
|
21
22
|
ColType_UUID,
|
|
22
23
|
Date,
|
|
@@ -117,6 +118,16 @@ class Dialect(BaseDialect):
|
|
|
117
118
|
for m, n_cls in match_regexps(string_regexps, info.data_type):
|
|
118
119
|
return n_cls()
|
|
119
120
|
|
|
121
|
+
# V_CATALOG.COLUMNS reports byte columns with their length baked into data_type
|
|
122
|
+
# ('varbinary(64)'), so they never reach the plain TYPE_CLASSES lookup.
|
|
123
|
+
binary_regexps = {
|
|
124
|
+
r"long varbinary\((\d+)\)": Binary,
|
|
125
|
+
r"varbinary\((\d+)\)": Binary,
|
|
126
|
+
r"binary\((\d+)\)": Binary,
|
|
127
|
+
}
|
|
128
|
+
for m, n_cls in match_regexps(binary_regexps, info.data_type):
|
|
129
|
+
return n_cls(data_type=info.data_type)
|
|
130
|
+
|
|
120
131
|
return super().parse_type(table_path, info)
|
|
121
132
|
|
|
122
133
|
def set_timezone_to_utc(self) -> str:
|
|
@@ -143,6 +154,10 @@ class Dialect(BaseDialect):
|
|
|
143
154
|
def normalize_number(self, value: str, coltype: FractionalType) -> str:
|
|
144
155
|
return self.to_string(f"CAST({value} AS NUMERIC(38, {coltype.precision}))")
|
|
145
156
|
|
|
157
|
+
def normalize_binary(self, value: str, _coltype: Binary) -> str:
|
|
158
|
+
# Vertica's TO_HEX is lowercase.
|
|
159
|
+
return f"UPPER(TO_HEX({value}))"
|
|
160
|
+
|
|
146
161
|
def normalize_uuid(self, value: str, _coltype: ColType_UUID) -> str:
|
|
147
162
|
# Trim doesn't work on CHAR type
|
|
148
163
|
return f"TRIM(CAST({value} AS VARCHAR))"
|
|
@@ -79,6 +79,42 @@ class DependencyParseError(Exception):
|
|
|
79
79
|
self.sql_definition = sql_definition
|
|
80
80
|
|
|
81
81
|
|
|
82
|
+
class OdbcValueDecodeError(Exception):
|
|
83
|
+
"""Raised when an ODBC output converter cannot decode a driver buffer.
|
|
84
|
+
|
|
85
|
+
Deliberately *not* swallowed. These converters exist because pyodbc cannot
|
|
86
|
+
fetch certain SQL Server extended types natively, so they sit between the
|
|
87
|
+
wire and every consumer of a value. A converter that answers a buffer it did
|
|
88
|
+
not understand with a plausible-looking substitute -- ``raw.hex()``, say --
|
|
89
|
+
does not fail, it *lies*: the fetch succeeds, the row looks populated, and a
|
|
90
|
+
wrong value travels into profiling, sampling, seeding and diffing with
|
|
91
|
+
nothing anywhere marking it as suspect. That is how a 12-byte
|
|
92
|
+
``SQL_SS_TIME2_STRUCT`` unpacked with a 10-byte format spent its life
|
|
93
|
+
arriving as the 24-character string ``'000000000100000000000000'``.
|
|
94
|
+
|
|
95
|
+
A decode failure means the driver's layout is not the one we encode here,
|
|
96
|
+
which is a bug in this module or a driver change -- either way something a
|
|
97
|
+
human must look at, so it is raised with the evidence needed to fix it.
|
|
98
|
+
|
|
99
|
+
:param sql_type: the ODBC SQL type code, e.g. ``-154``.
|
|
100
|
+
:param type_name: its human name, e.g. ``"time"``.
|
|
101
|
+
:param reason: what specifically did not match.
|
|
102
|
+
:param raw: the buffer the driver handed over.
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
def __init__(self, sql_type: int, type_name: str, reason: str, raw=None):
|
|
106
|
+
hexdump = raw.hex() if isinstance(raw, (bytes, bytearray)) else repr(raw)
|
|
107
|
+
super().__init__(
|
|
108
|
+
f"Could not decode SQL Server {type_name} (ODBC SQL type {sql_type}): "
|
|
109
|
+
f"{reason}. Raw buffer ({len(raw) if isinstance(raw, (bytes, bytearray)) else '?'} bytes): {hexdump}"
|
|
110
|
+
)
|
|
111
|
+
self.error_code = "odbc_value_decode_error"
|
|
112
|
+
self.sql_type = sql_type
|
|
113
|
+
self.type_name = type_name
|
|
114
|
+
self.reason = reason
|
|
115
|
+
self.raw = raw
|
|
116
|
+
|
|
117
|
+
|
|
82
118
|
class EstateSurfaceUnavailableError(Exception):
|
|
83
119
|
"""Raised when an estate surface could not be read, so a caller can tell
|
|
84
120
|
"we looked and there is nothing" apart from "we could not look".
|