Skip to content

Commit ea59ba7

Browse files
ai: apply changes for #1005 (1 review thread)
Addresses: - #4418224915 at src/databricks/sql/result_set.py:147 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 3e2fad4 commit ea59ba7

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

‎src/databricks/sql/result_set.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
try:
1010
import pyarrow
11+
import pyarrow.compute as pc
1112
except ImportError:
1213
pyarrow = None
14+
pc = None
1315

1416
if TYPE_CHECKING:
1517
from databricks.sql.backend.thrift_backend import ThriftDatabricksClient
@@ -131,8 +133,6 @@ def _convert_arrow_table(self, table):
131133

132134
res = df.to_numpy(na_value=None, dtype="object")
133135

134-
import pyarrow.compute as pc
135-
136136
# Pandas' nullable Float dtypes treat IEEE NaN as missing (pd.NA), which
137137
# to_numpy(na_value=None) turns into None, making NaN indistinguishable
138138
# from SQL NULL. Restore NaN from the Arrow column so results match the
@@ -142,10 +142,7 @@ def _convert_arrow_table(self, table):
142142
if not pyarrow.types.is_floating(column.type):
143143
continue
144144
nan_mask = pc.fill_null(pc.is_nan(column), False)
145-
if not pc.any(nan_mask).as_py():
146-
continue
147-
for row_idx in nan_mask.to_numpy().nonzero()[0]:
148-
res[row_idx, col_idx] = float("nan")
145+
res[nan_mask.to_numpy(), col_idx] = float("nan")
149146

150147
return [ResultRow(*v) for v in res]
151148

0 commit comments

Comments
 (0)