Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support for null decimal columns and TD access locks #976

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data_validation/cli_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
["user_name", "User used to connect"],
["password", "Password for supplied user"],
["logmech", "(Optional) Log on mechanism"],
["use_no_lock_tables", "Use an access lock for queries (defaults to False)"],
],
"Oracle": [
["host", "Desired Oracle host"],
Expand Down
7 changes: 6 additions & 1 deletion data_validation/combiner.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ def _calculate_difference(field_differences, datatype, validation, is_value_comp
target_value = field_differences["differences_target_value"]

# Does not calculate difference between agg values for row hash due to int64 overflow
if is_value_comparison or isinstance(datatype, ibis.expr.datatypes.String):
if (
is_value_comparison
or isinstance(datatype, ibis.expr.datatypes.String)
or isinstance(target_value, ibis.expr.types.generic.NullColumn)
or isinstance(source_value, ibis.expr.types.generic.NullColumn)
):
# String data types i.e "None" can be returned for NULL timestamp/datetime aggs
if is_value_comparison:
difference = pct_difference = ibis.null()
Expand Down
1 change: 1 addition & 0 deletions docs/connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ data-validation connections add
--user-name USER Teradata user
--password PASSWORD Teradata password
[--logmech LOGMECH] Teradata logmech, defaults to "TD2"
[--use-no-lock-tables USE_NO_LOCK_TABLES] Use access lock for queries, defaults to "False"
```

## Oracle
Expand Down
11 changes: 4 additions & 7 deletions third_party/ibis/ibis_teradata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def do_connect(
password: str = None,
port: int = 1025,
logmech: str = "TD2",
use_no_lock_tables: bool = False,
use_no_lock_tables: str = "False",
) -> None:
self.teradata_config = {
"host": host,
Expand All @@ -51,7 +51,7 @@ def do_connect(

self.client = teradatasql.connect(**self.teradata_config)
self.con = self.client.cursor()
self.use_no_lock_tables = use_no_lock_tables
self.use_no_lock_tables = True if use_no_lock_tables.casefold() == "True".casefold() else False

def close(self):
"""Close the connection."""
Expand Down Expand Up @@ -210,15 +210,12 @@ def execute(
kwargs.pop("timecontext", None)
query_ast = self.compiler.to_ast_ensure_limit(expr, limit, params=params)
sql = query_ast.compile()
self._log(sql)

schema = self.ast_schema(query_ast, **kwargs)

self._register_in_memory_tables(expr)

if self.use_no_lock_tables and sql.strip().startswith("SELECT"):
sql = self.NO_LOCK_SQL + self.compiled_sql
sql = self.NO_LOCK_SQL + sql

self._log(sql)
with warnings.catch_warnings():
# Suppress pandas warning of SQLAlchemy connectable DB support
warnings.simplefilter("ignore")
Expand Down
2 changes: 1 addition & 1 deletion third_party/ibis/ibis_teradata/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def teradata_connect(
password: str = None,
port: int = 1025,
logmech: str = "TD2",
use_no_lock_tables: bool = False,
use_no_lock_tables: str = "False",
):
backend = TeradataBackend()
backend.do_connect(
Expand Down