jiayuasu commented on code in PR #1229:
URL: https://github.com/apache/sedona-db/pull/1229#discussion_r3931183966
##########
python/sedonadb/python/sedonadb/expr/literal.py:
##########
@@ -191,15 +199,137 @@ def _lit_from_shapely(obj):
return _lit_from_wkb_and_crs(obj.wkb, None)
-def _lit_from_wkb_and_crs(wkb, crs):
+def _lit_from_wkb_and_crs(wkb, crs, edge_type=None):
Review Comment:
Done, it's `_lit_from_wkb` now (named for what it builds from rather than
its argument list, since the edge type joined the CRS).
##########
python/sedonadb/python/sedonadb/expr/literal.py:
##########
@@ -191,15 +199,137 @@ def _lit_from_shapely(obj):
return _lit_from_wkb_and_crs(obj.wkb, None)
-def _lit_from_wkb_and_crs(wkb, crs):
+def _lit_from_wkb_and_crs(wkb, crs, edge_type=None):
import geoarrow.pyarrow as ga
import pyarrow as pa
type = ga.wkb().with_crs(crs)
+ if edge_type is not None:
+ type = type.with_edge_type(edge_type)
storage = pa.array([wkb], type.storage_type)
return type.wrap_array(storage)
+def _lit_from_missing(obj):
+ # pandas.NA and numpy.ma.masked both mean "no value".
+ import pyarrow as pa
+
+ return pa.array([None])
+
+
+def _lit_from_nat(obj):
+ # NaT is a datetime missing value in pandas (assigning it yields a
+ # datetime64 column), so it resolves to a typed timestamp null rather
+ # than an untyped NULL.
+ import pyarrow as pa
+
+ return pa.array([None], pa.timestamp("ns"))
Review Comment:
Right on both counts. `NaT` itself carries no unit (it's a unit-less
singleton), so some unit has to be picked, and nanoseconds is where pandas
stores it and the finest one, so it can never be a lossy choice. And it does
coerce: `coalesce(us_col, lit(pd.NaT))` resolves to `timestamp(µs)` and
`coalesce(s_tz_col, lit(pd.NaT))` to `timestamp(s, UTC)`, so the null takes the
surrounding expression's unit and zone. Added that as a comment on the function.
--
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]