jiayuasu opened a new pull request, #1229:
URL: https://github.com/apache/sedona-db/pull/1229

   ## What changes
   
   Closes #1214.
   
   `lit()` resolves Python values through a class-name → handler table with a 
`pa.array([obj])` fallback. Two gaps in the GeoArrow handling and a set of 
common scalar values that the fallback rejects (or handles lossily) came up 
while building the `sedonadb-geopandas` assignment surface (#1195), where they 
are currently worked around before the value reaches `lit()`. Handling them 
here benefits every SedonaDB user, and lets that wrapper code shrink to a 
pass-through later.
   
   **GeoArrow scalars**
   
   - The type was rebuilt from the CRS alone, so a spherical (geography) WKB 
scalar came back as planar geometry. The edge type now travels with the CRS.
   - Only the WKB scalar class was registered; WKT and native-encoded (point, 
linestring, …) scalars fell through to `pa.array([obj])` and failed. Every 
GeoArrow scalar exposes its WKB, so one handler now serves them all, valid or 
null.
   
   **Scalar values**
   
   | value | before | after |
   |---|---|---|
   | `pandas.NA`, `numpy.ma.masked` | `ValueError` | NULL |
   | `pandas.NaT` | `ValueError` | timestamp NULL |
   | `pandas.Timestamp` / `Timedelta` | truncated to microseconds | own 
resolution, time zone kept |
   | `numpy.datetime64` / `timedelta64` in non-Arrow units (`D`, `W`, `Y`, …) | 
`ValueError` | lossless Arrow resolution; ambiguous or lossy units rejected the 
way pandas rejects them, with an overflow check |
   | 0-d `numpy.ndarray` | `ValueError` | its typed scalar (dtype kept) |
   | structured `numpy.void` | `ValueError` | typed struct |
   | null nested / extension Arrow scalar | `ValueError` | typed one-element 
array |
   
   pandas 3 renamed these classes (`pandas.api.typing.NAType`, 
`pandas.Timestamp`, …), so both sets are registered, the way the table already 
handles `DataFrame` and `Series`. Existing paths (valid Arrow scalars, arrays 
with dimensions, shapely, GeoSeries, pandas frames) are unchanged.
   
   ## Testing
   
   23 new tests in `tests/expr/test_literal.py`, run with warnings promoted to 
errors against pandas 2.3 / NumPy 2.3 and pandas 3.0 / NumPy 2.5. The full 
`expr/`, `test_dataframe.py`, and `test_context.py` suites pass unchanged.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to