Skip to content

Commit 3ee94c5

Browse files
committed
move to _integraltype
1 parent 1be3e95 commit 3ee94c5

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

src/snowflake/snowpark/_internal/type_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def convert_sf_to_sp_type(
307307
if column_type_name == "REAL":
308308
return DoubleType()
309309
if (column_type_name == "FIXED" or column_type_name == "NUMBER") and scale == 0:
310-
return LongType(precision=precision, scale=scale)
310+
return LongType(precision=precision)
311311
raise NotImplementedError(
312312
"Unsupported type: {}, precision: {}, scale: {}".format(
313313
column_type_name, precision, scale

src/snowflake/snowpark/types.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,7 @@ def _fill_ast(self, ast: proto.DataType) -> None:
169169

170170

171171
class _NumericType(_AtomicType):
172-
def __init__(self, **kwargs) -> None:
173-
self._precision = kwargs.get("precision", None)
174-
self._scale = kwargs.get("scale", None)
175-
176-
def __eq__(self, other):
177-
def filtered(d: dict) -> dict:
178-
return {k: v for k, v in d.items() if k not in ("_precision", "_scale")}
179-
180-
return isinstance(other, self.__class__) and filtered(
181-
self.__dict__
182-
) == filtered(other.__dict__)
183-
184-
def __hash__(self):
185-
return hash(repr(self))
172+
pass
186173

187174

188175
class TimestampTimeZone(Enum):
@@ -383,7 +370,19 @@ def _fill_ast(self, ast: proto.DataType) -> None:
383370

384371
# Numeric types
385372
class _IntegralType(_NumericType):
386-
pass
373+
def __init__(self, **kwargs) -> None:
374+
self._precision = kwargs.get("precision", None)
375+
376+
def __eq__(self, other):
377+
def filtered(d: dict) -> dict:
378+
return {k: v for k, v in d.items() if k != "_precision"}
379+
380+
return isinstance(other, self.__class__) and filtered(
381+
self.__dict__
382+
) == filtered(other.__dict__)
383+
384+
def __hash__(self):
385+
return hash(repr(self))
387386

388387

389388
class _FractionalType(_NumericType):

tests/integ/test_datatypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def test_numeric_type_store_precision_and_scale(session, massive_number, precisi
433433
result = session.sql(f"select * from {table_name}")
434434
datatype = result.schema.fields[0].datatype
435435
assert isinstance(datatype, LongType)
436-
assert datatype._precision == 38 and datatype._scale == 0
436+
assert datatype._precision == 38
437437
finally:
438438
session.sql(f"drop table {table_name}").collect()
439439

@@ -484,7 +484,7 @@ def write_csv(data):
484484
df1 = constrained_reader.csv(f"@{stage_name}/")
485485
datatype = df1.schema.fields[0].datatype
486486
assert isinstance(datatype, LongType)
487-
assert datatype._precision == 38 and datatype._scale == 0
487+
assert datatype._precision == 38
488488

489489
finally:
490490
Utils.drop_stage(session, stage_name)

0 commit comments

Comments
 (0)