You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "cpcloud (via GitHub)" <gi...@apache.org> on 2023/11/15 15:56:46 UTC

[I] Coalesce seems broken when converting to pyarrow [arrow-datafusion-python]

cpcloud opened a new issue, #534:
URL: https://github.com/apache/arrow-datafusion-python/issues/534

   **Describe the bug**
   
   A SQL query with `coalesce` fails when converted to pyarrow
   
   **To Reproduce**
   
   ```
   In [1]: import datafusion as df
   
   In [2]: ctx = df.SessionContext()
   
   In [3]: ctx.sql
   Out[3]: <function SessionContext.sql(query)>
   
   In [4]: ctx.sql("select coalesce(null, 5)")
   Out[4]:
   DataFrame()
   +-------------------------+
   | coalesce(NULL,Int64(5)) |
   +-------------------------+
   | 5                       |
   +-------------------------+
   
   In [5]: ctx.sql("select coalesce(null, 5)").to_arrow_table()
   ---------------------------------------------------------------------------
   ArrowInvalid                              Traceback (most recent call last)
   Cell In[5], line 1
   ----> 1 ctx.sql("select coalesce(null, 5)").to_arrow_table()
   
   File /nix/store/nqcbgqab0slp4kx3ixk8225nwrzy5mbd-python3-3.10.13-env/lib/python3.10/site-packages/pyarrow/table.pxi:4057, in pyarrow.lib.Table.from_batches()
   
   File /nix/store/nqcbgqab0slp4kx3ixk8225nwrzy5mbd-python3-3.10.13-env/lib/python3.10/site-packages/pyarrow/error.pxi:154, in pyarrow.lib.pyarrow_internal_check_status()
   
   File /nix/store/nqcbgqab0slp4kx3ixk8225nwrzy5mbd-python3-3.10.13-env/lib/python3.10/site-packages/pyarrow/error.pxi:91, in pyarrow.lib.check_status()
   
   ArrowInvalid: Schema at index 0 was different:
   coalesce(NULL,Int64(5)): int64
   vs
   coalesce(NULL,Int64(5)): int64 not null
   ```
   
   **Expected behavior**
   
   I would expect the result to be a pyarrow table with `5` in it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org