Skip to content

Commit

Permalink
Fix dask COUNT queries on windows (#2210)
Browse files Browse the repository at this point in the history
This commit fixes an issue in the dask cursor that would cause it to
return `None` instead of `0` when performing a COUNT() query on Windows.
`dask-sql` returns an empty data frame when there are no matches. This
is normally translated to 0 in the DaskCursor class when using fetchone
with a numeric result.

Unfortunately the logic to detect a numeric result did not behave
correctly on Windows. The dtype used is int64, which on linux appears to
compare equal to int but does not compare equal on Windows.

This commit uses `np.issubdtype` to have a more robust check for integer
types.
  • Loading branch information
mivds authored Feb 20, 2025
1 parent 7df8e84 commit 08e9ef8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion soda/dask/soda/data_sources/dask_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def fetchone(self) -> tuple:
if self.df.empty:
row_value = []
for col_dtype in self.df.dtypes:
if col_dtype in ["int", "float"]:
if np.issubdtype(col_dtype, np.number):
row_value.append(0)
else:
row_value.append(None)
Expand Down

0 comments on commit 08e9ef8

Please sign in to comment.