Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 6da7db7

Browse files
authored
Merge branch 'master' into support-top-operator
2 parents 0bd24a3 + c8a598b commit 6da7db7

File tree

16 files changed

+32393
-5044
lines changed

16 files changed

+32393
-5044
lines changed

.github/workflows/formatter.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ jobs:
2121
uses: reviewdog/action-suggester@v1
2222
with:
2323
tool_name: blackfmt
24+
- name: Fail if there are formatting suggestions
25+
if: steps.black_formatter.outputs.is_formatted == 'true'
26+
run: exit 1

data_diff/__main__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,20 @@ def write_usage(self, prog: str, args: str = "", prefix: Optional[str] = None) -
267267
metavar="PATH",
268268
help="Specify manifest to utilize for 'prod' comparison paths instead of using configuration.",
269269
)
270+
@click.option(
271+
"-pd",
272+
"--prod-database",
273+
"prod_database",
274+
default=None,
275+
help="Override the dbt production database configuration within dbt_project.yml",
276+
)
277+
@click.option(
278+
"-ps",
279+
"--prod-schema",
280+
"prod_schema",
281+
default=None,
282+
help="Override the dbt production schema configuration within dbt_project.yml",
283+
)
270284
def main(conf, run, **kw):
271285
log_handlers = _get_log_handlers(kw["dbt"])
272286
if kw["table2"] is None and kw["database2"]:
@@ -323,6 +337,8 @@ def main(conf, run, **kw):
323337
where_flag=kw["where"],
324338
stats_flag=kw["stats"],
325339
columns_flag=kw["columns"],
340+
production_database_flag=kw["prod_database"],
341+
production_schema_flag=kw["prod_schema"],
326342
)
327343
else:
328344
return _data_diff(
@@ -366,6 +382,8 @@ def _data_diff(
366382
cloud,
367383
dbt_profiles_dir,
368384
dbt_project_dir,
385+
prod_database,
386+
prod_schema,
369387
select,
370388
state,
371389
threads1=None,

data_diff/databases/bigquery.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,18 @@ def __init__(self, project, *, dataset, bigquery_credentials=None, **kw):
193193
bigquery = import_bigquery()
194194

195195
keyfile = kw.pop("keyfile", None)
196+
impersonate_service_account = kw.pop("impersonate_service_account", None)
196197
if keyfile:
197198
bigquery_service_account = import_bigquery_service_account()
198199
credentials = bigquery_service_account.Credentials.from_service_account_file(
199200
keyfile,
200201
scopes=["https://www.googleapis.com/auth/cloud-platform"],
201202
)
202-
elif kw.get("impersonate_service_account"):
203+
elif impersonate_service_account:
203204
bigquery_service_account_impersonation = import_bigquery_service_account_impersonation()
204205
credentials = bigquery_service_account_impersonation.Credentials(
205206
source_credentials=credentials,
206-
target_principal=kw["impersonate_service_account"],
207+
target_principal=impersonate_service_account,
207208
target_scopes=["https://www.googleapis.com/auth/cloud-platform"],
208209
)
209210

data_diff/databases/databricks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class Dialect(BaseDialect):
5656
"BOOLEAN": Boolean,
5757
}
5858

59+
def type_repr(self, t) -> str:
60+
try:
61+
return {str: "STRING"}[t]
62+
except KeyError:
63+
return super().type_repr(t)
64+
5965
def quote(self, s: str):
6066
return f"`{s}`"
6167

data_diff/databases/mssql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def to_string(self, s: str):
9898

9999
def type_repr(self, t) -> str:
100100
try:
101-
return {bool: "bit"}[t]
101+
return {bool: "bit", str: "text"}[t]
102102
except KeyError:
103103
return super().type_repr(t)
104104

data_diff/dbt.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def dbt_diff(
7676
where_flag: Optional[str] = None,
7777
stats_flag: bool = False,
7878
columns_flag: Optional[Tuple[str]] = None,
79+
production_database_flag: Optional[str] = None,
80+
production_schema_flag: Optional[str] = None,
7981
) -> None:
8082
print_version_info()
8183
diff_threads = []
@@ -115,7 +117,16 @@ def dbt_diff(
115117
if log_status_handler:
116118
log_status_handler.set_prefix(f"Diffing {model.alias} \n")
117119

118-
diff_vars = _get_diff_vars(dbt_parser, config, model, where_flag, stats_flag, columns_flag)
120+
diff_vars = _get_diff_vars(
121+
dbt_parser,
122+
config,
123+
model,
124+
where_flag,
125+
stats_flag,
126+
columns_flag,
127+
production_database_flag,
128+
production_schema_flag,
129+
)
119130

120131
# we won't always have a prod path when using state
121132
# when the model DNE in prod manifest, skip the model diff
@@ -169,6 +180,8 @@ def _get_diff_vars(
169180
where_flag: Optional[str] = None,
170181
stats_flag: bool = False,
171182
columns_flag: Optional[Tuple[str]] = None,
183+
production_database_flag: Optional[str] = None,
184+
production_schema_flag: Optional[str] = None,
172185
) -> TDiffVars:
173186
cli_columns = list(columns_flag) if columns_flag else []
174187
dev_database = model.database
@@ -182,6 +195,10 @@ def _get_diff_vars(
182195
else:
183196
prod_database, prod_schema = _get_prod_path_from_config(config, model, dev_database, dev_schema)
184197

198+
# cli flags take precedence over any project level config
199+
prod_database = production_database_flag or prod_database
200+
prod_schema = production_schema_flag or prod_schema
201+
185202
if dbt_parser.requires_upper:
186203
dev_qualified_list = [x.upper() for x in [dev_database, dev_schema, dev_alias] if x]
187204
prod_qualified_list = [x.upper() for x in [prod_database, prod_schema, prod_alias] if x]

data_diff/dbt_config_validators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
class ManifestJsonConfig(BaseModel):
77
class Metadata(BaseModel):
88
dbt_version: str = Field(..., regex=r"^\d+\.\d+\.\d+([a-zA-Z0-9]+)?$")
9-
project_id: str
10-
user_id: str
9+
project_id: Optional[str]
10+
user_id: Optional[str]
1111

1212
class Nodes(BaseModel):
1313
class Config(BaseModel):

data_diff/dbt_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def try_set_dbt_flags():
6464
PROJECT_FILE = "dbt_project.yml"
6565
PROFILES_FILE = "profiles.yml"
6666
LOWER_DBT_V = "1.0.0"
67-
UPPER_DBT_V = "1.7.0"
67+
UPPER_DBT_V = "1.8.0"
6868

6969

7070
# https://github.com/dbt-labs/dbt-core/blob/c952d44ec5c2506995fbad75320acbae49125d3d/core/dbt/cli/resolvers.py#L6

data_diff/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.9.8"
1+
__version__ = "0.9.12"

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
[tool.poetry]
22
name = "data-diff"
3-
version = "0.9.8"
3+
version = "0.9.12"
44
description = "Command-line tool and Python library to efficiently diff rows across two different databases."
55
authors = ["Datafold <data-diff@datafold.com>"]
66
license = "MIT"
77
readme = "README.md"
88
repository = "https://github.com/datafold/data-diff"
9-
documentation = ""
109
classifiers = [
1110
"Intended Audience :: Developers",
1211
"Intended Audience :: Information Technology",
@@ -46,7 +45,7 @@ oracledb = {version = "*", optional=true}
4645
pyodbc = {version="^4.0.39", optional=true}
4746
typing-extensions = ">=4.0.1"
4847
attrs = "^23.1.0"
49-
mashumaro = {version = ">=3.8.1,<3.9.0", extras = ["msgpack"]}
48+
mashumaro = {version = ">=2.9,<3.11.0", extras = ["msgpack"]}
5049

5150
[tool.poetry.dev-dependencies]
5251
parameterized = "*"

0 commit comments

Comments
 (0)