Skip to content

Commit

Permalink
chore: Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
nj1973 committed Aug 7, 2023
1 parent 6323396 commit dc9fb56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
15 changes: 10 additions & 5 deletions tests/system/data_sources/common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.


def null_not_null_assertions(df):
"""Standard assertions for null_not_null integration test.
These tests use BigQuery as a set target with a mismatch of not null/nullable settings.
All other engines are validated against BigQuery to check we get the correct status."""
# Should be 4 columns in the Dataframe.
assert len(df) == 4
match_columns = ['col_nn', 'col_nullable']
mismatch_columns = ['col_src_nn_trg_n', 'col_src_n_trg_nn']
for column_name, status in zip(df['source_column_name'], df['validation_status']):
match_columns = ["col_nn", "col_nullable"]
mismatch_columns = ["col_src_nn_trg_n", "col_src_n_trg_nn"]
for column_name, status in zip(df["source_column_name"], df["validation_status"]):
assert column_name in (match_columns + mismatch_columns)
if column_name in match_columns:
# These columns are the same for all engines and should succeed.
assert status == 'success', f"Column: {column_name}, status: {status} != 'success'"
assert (
status == "success"
), f"Column: {column_name}, status: {status} != 'success'"
elif column_name in mismatch_columns:
# These columns are the different for source and target engines and should fail.
assert status == 'fail', f"Column: {column_name}, status: {status} != 'fail'"
assert (
status == "fail"
), f"Column: {column_name}, status: {status} != 'fail'"
22 changes: 12 additions & 10 deletions third_party/ibis/ibis_teradata/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ def __init__(self):

@classmethod
def _col_data_nullable(cls, col_data: dict) -> bool:
return bool(
col_data.get("Nullable", "Y ").startswith("Y")
)
return bool(col_data.get("Nullable", "Y ").startswith("Y"))

@classmethod
def to_ibis(cls, col_data):
Expand Down Expand Up @@ -92,12 +90,13 @@ def to_ibis_from_N(cls, col_data, return_ibis_type=True):
)
if return_ibis_type:
# No precision or scale specified
if precision == -128 or scale ==-128:
if precision == -128 or scale == -128:
return dt.Decimal()
return dt.Decimal(precision, scale,
nullable=cls._col_data_nullable(col_data))
return dt.Decimal(
precision, scale, nullable=cls._col_data_nullable(col_data)
)

if precision == -128 or scale ==-128:
if precision == -128 or scale == -128:
return "DECIMAL"

return "DECIMAL(%d, %d)" % (precision, scale)
Expand All @@ -113,8 +112,9 @@ def to_ibis_from_D(cls, col_data, return_ibis_type=True):
)
)
if return_ibis_type:
return dt.Decimal(precision, scale,
nullable=cls._col_data_nullable(col_data))
return dt.Decimal(
precision, scale, nullable=cls._col_data_nullable(col_data)
)
value_type = "DECIMAL(%d, %d)" % (precision, scale)
return value_type

Expand Down Expand Up @@ -165,7 +165,9 @@ def to_ibis_from_TS(cls, col_data, return_ibis_type=True):
@classmethod
def to_ibis_from_SZ(cls, col_data, return_ibis_type=True):
if return_ibis_type:
return dt.timestamp(timezone="UTC", nullable=cls._col_data_nullable(col_data))
return dt.timestamp(
timezone="UTC", nullable=cls._col_data_nullable(col_data)
)

return "TIMESTAMP"

Expand Down

0 comments on commit dc9fb56

Please sign in to comment.