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

Commit f9bf8a7

Browse files
author
Sergey Vasilyev
committed
Rename JSONType → Type for brevity
We know that all these classes are column types, there is no need to specify that. Also to consistency with other column types.
1 parent 3c18507 commit f9bf8a7

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

data_diff/hashdiff_tables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from runtype import dataclass
99

10-
from data_diff.sqeleton.abcs import ColType_UUID, NumericType, PrecisionType, StringType, Boolean, JSONType
10+
from data_diff.sqeleton.abcs import ColType_UUID, NumericType, PrecisionType, StringType, Boolean, JSON
1111

1212
from .info_tree import InfoTree
1313
from .utils import safezip, diffs_are_equiv_jsons
@@ -205,7 +205,7 @@ def _bisect_and_diff_segments(
205205
if max_rows < self.bisection_threshold or max_space_size < self.bisection_factor * 2:
206206
rows1, rows2 = self._threaded_call("get_values", [table1, table2])
207207
json_cols = {i: colname for i, colname in enumerate(table1.extra_columns)
208-
if isinstance(table1._schema[colname], JSONType)}
208+
if isinstance(table1._schema[colname], JSON)}
209209
diff = list(diff_sets(rows1, rows2, json_cols))
210210

211211
info_tree.info.set_diff(diff)

data_diff/sqeleton/abcs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
PrecisionType,
1111
StringType,
1212
Boolean,
13-
JSONType,
13+
JSON,
1414
)
1515
from .compiler import AbstractCompiler, Compilable

data_diff/sqeleton/abcs/database_types.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,19 @@ class Text(StringType):
134134
supported = False
135135

136136

137-
class JSONType(ColType):
137+
class JSON(ColType):
138138
pass
139139

140140

141-
class RedShiftSuper(JSONType):
141+
class RedShiftSuper(JSON):
142142
pass
143143

144144

145-
class PostgresqlJSON(JSONType):
145+
class PostgresqlJSON(JSON):
146146
pass
147147

148148

149-
class PostgresqlJSONB(JSONType):
149+
class PostgresqlJSONB(JSON):
150150
pass
151151

152152

data_diff/sqeleton/abcs/mixins.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from abc import ABC, abstractmethod
2-
from .database_types import TemporalType, FractionalType, ColType_UUID, Boolean, ColType, String_UUID, JSONType
2+
from .database_types import TemporalType, FractionalType, ColType_UUID, Boolean, ColType, String_UUID, JSON
33
from .compiler import Compilable
44

55

@@ -49,7 +49,7 @@ def normalize_uuid(self, value: str, coltype: ColType_UUID) -> str:
4949
return f"TRIM({value})"
5050
return self.to_string(value)
5151

52-
def normalize_json(self, value: str, _coltype: JSONType) -> str:
52+
def normalize_json(self, value: str, _coltype: JSON) -> str:
5353
"""Creates an SQL expression, that converts 'value' to its minified json string representation."""
5454
raise NotImplementedError()
5555

@@ -77,7 +77,7 @@ def normalize_value_by_type(self, value: str, coltype: ColType) -> str:
7777
return self.normalize_uuid(value, coltype)
7878
elif isinstance(coltype, Boolean):
7979
return self.normalize_boolean(value, coltype)
80-
elif isinstance(coltype, JSONType):
80+
elif isinstance(coltype, JSON):
8181
return self.normalize_json(value, coltype)
8282
return self.to_string(value)
8383

data_diff/sqeleton/databases/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
DbTime,
3636
DbPath,
3737
Boolean,
38-
JSONType
38+
JSON
3939
)
4040
from ..abcs.mixins import Compilable
4141
from ..abcs.mixins import (
@@ -260,7 +260,7 @@ def parse_type(
260260
elif issubclass(cls, (Text, Native_UUID)):
261261
return cls()
262262

263-
elif issubclass(cls, JSONType):
263+
elif issubclass(cls, JSON):
264264
return cls()
265265

266266
raise TypeError(f"Parsing {type_repr} returned an unknown type '{cls}'.")

data_diff/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def diffs_are_equiv_jsons(diff: list, json_cols: dict):
160160
return False, overriden_diff_cols
161161
match = True
162162
for i, (col_a, col_b) in enumerate(safezip(diff[0][1][1:], diff[1][1][1:])): # index 0 is extra_columns first elem
163-
# we only attempt to parse columns of JSONType, but we still need to check if non-json columns don't match
163+
# we only attempt to parse columns of JSON type, but we still need to check if non-json columns don't match
164164
match = col_a == col_b
165165
if not match and (i in json_cols):
166166
if _jsons_equiv(col_a, col_b):

0 commit comments

Comments
 (0)