Skip to content

Commit

Permalink
Dealing with null values in decimal column types
Browse files Browse the repository at this point in the history
  • Loading branch information
Boaz Shalom committed Aug 20, 2019
1 parent 6bf07c3 commit e626d40
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions azure-kusto-data/azure/kusto/data/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, columns, row):
self._hidden_values.append(value)
continue

if column_type in ["datetime", "timespan"]:
if column_type in ["datetime", "timespan", "decimal"]:
if value is None:
typed_value = None
if HAS_PANDAS:
Expand All @@ -67,10 +67,8 @@ def __init__(self, columns, row):
self._hidden_values.append(to_pandas_datetime(value))
if column_type == "timespan":
self._hidden_values.append(to_pandas_timedelta(value, typed_value))
elif column_type in KustoResultRow.convertion_funcs:
typed_value = KustoResultRow.convertion_funcs[column_type](value)
if HAS_PANDAS:
self._hidden_values.append(value)
if column_type == "decimal":
self._hidden_values.append(value)
else:
typed_value = value
if HAS_PANDAS:
Expand Down

3 comments on commit e626d40

@danield137
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boazsha can you please explain the logic behind the change? decimals should fall trough to line 77 in original code (e626d40#diff-81b09c4ad099e18e6810ef8bac645cf2L77)

@justinclift
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danield137 Does this help: #157? 😄

@danield137
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinclift that is the reason for the change, I am trying to understand the logic here.

_hidden_values are used for our support of high precision types for pandas.
So the entire if/else block is just about how to pick what we store for later use in pandas (should probably clean code up a bit here)

Anyway, I think I understand the fix, but it is done in a way that is much harder to read, I would rather a proper one.

The appropriate fix would be to handle non null-able types that are returned as null separately, either by a proper conversion function or by a separate if block.

Please sign in to comment.