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

Tiny Cleanup #267

Merged
merged 1 commit into from
Oct 31, 2022
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
4 changes: 2 additions & 2 deletions data_diff/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def __init__(self, **kwargs):
self.indent_increment = 6

def write_usage(self, prog: str, args: str = "", prefix: Optional[str] = None) -> None:
self.write(f"data-diff - efficiently diff rows across database tables.\n\n")
self.write(f"Usage:\n")
self.write("data-diff - efficiently diff rows across database tables.\n\n")
self.write("Usage:\n")
self.write(f" * In-db diff: {prog} <database1> <table1> <table2> [OPTIONS]\n")
self.write(f" * Cross-db diff: {prog} <database1> <table1> <database2> <table2> [OPTIONS]\n")
self.write(f" * Using config: {prog} --conf PATH [--run NAME] [OPTIONS]\n")
Expand Down
8 changes: 4 additions & 4 deletions data_diff/databases/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def query(self, sql_ast: Union[Expr, Generator], res_type: type = list):
(row,) = row
logger.debug("EXPLAIN: %s", row)
answer = input("Continue? [y/n] ")
if not answer.lower() in ["y", "yes"]:
if answer.lower() not in ["y", "yes"]:
sys.exit(1)

res = self._query(sql_code)
Expand Down Expand Up @@ -310,9 +310,9 @@ def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None

return f"LIMIT {limit}"

def concat(self, l: List[str]) -> str:
assert len(l) > 1
joined_exprs = ", ".join(l)
def concat(self, items: List[str]) -> str:
assert len(items) > 1
joined_exprs = ", ".join(items)
return f"concat({joined_exprs})"

def is_distinct_from(self, a: str, b: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion data_diff/databases/database_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def quote(self, s: str):
...

@abstractmethod
def concat(self, l: List[str]) -> str:
def concat(self, items: List[str]) -> str:
"Provide SQL for concatenating a bunch of columns into a string"
...

Expand Down
4 changes: 2 additions & 2 deletions data_diff/databases/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def offset_limit(self, offset: Optional[int] = None, limit: Optional[int] = None

return f"FETCH NEXT {limit} ROWS ONLY"

def concat(self, l: List[str]) -> str:
joined_exprs = " || ".join(l)
def concat(self, items: List[str]) -> str:
joined_exprs = " || ".join(items)
return f"({joined_exprs})"

def timestamp_value(self, t: DbTime) -> str:
Expand Down
4 changes: 2 additions & 2 deletions data_diff/databases/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def normalize_timestamp(self, value: str, coltype: TemporalType) -> str:
def normalize_number(self, value: str, coltype: FractionalType) -> str:
return self.to_string(f"{value}::decimal(38,{coltype.precision})")

def concat(self, l: List[str]) -> str:
joined_exprs = " || ".join(l)
def concat(self, items: List[str]) -> str:
joined_exprs = " || ".join(items)
return f"({joined_exprs})"

def select_table_schema(self, path: DbPath) -> str:
Expand Down
4 changes: 2 additions & 2 deletions data_diff/databases/vertica.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def select_table_schema(self, path: DbPath) -> str:
def quote(self, s: str):
return f'"{s}"'

def concat(self, l: List[str]) -> str:
return " || ".join(l)
def concat(self, items: List[str]) -> str:
return " || ".join(items)

def md5_to_int(self, s: str) -> str:
return f"CAST(HEX_TO_INTEGER(SUBSTRING(MD5({s}), {1 + MD5_HEXDIGITS - CHECKSUM_HEXDIGITS})) AS NUMERIC(38, 0))"
Expand Down
3 changes: 1 addition & 2 deletions data_diff/joindiff_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

"""

from contextlib import suppress
from decimal import Decimal
from functools import partial
import logging
Expand All @@ -21,7 +20,7 @@
from .diff_tables import TableDiffer, DiffResult
from .thread_utils import ThreadedYielder

from .queries import table, sum_, min_, max_, avg, commit
from .queries import table, sum_, min_, max_, avg
from .queries.api import and_, if_, or_, outerjoin, leftjoin, rightjoin, this, ITable
from .queries.ast_classes import Concat, Count, Expr, Random, TablePath
from .queries.compiler import Compiler
Expand Down
2 changes: 1 addition & 1 deletion data_diff/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import math
from typing import Iterable, Iterator, MutableMapping, Union, Any, Sequence, Dict
from typing import TypeVar
from abc import ABC, abstractmethod
from abc import abstractmethod
from urllib.parse import urlparse
from uuid import UUID
import operator
Expand Down