paleolimbot commented on code in PR #1767: URL: https://github.com/apache/sedona/pull/1767#discussion_r1927640042
########## python/sedona/utils/geoarrow.py: ########## @@ -0,0 +1,127 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# We may be able to achieve streaming rather than complete materialization by using +# with the ArrowStreamSerializer (instead of the ArrowCollectSerializer) + +import pyarrow as pa +import geoarrow.types as gat +from sedona.sql.types import GeometryType + + +def dataframe_to_arrow(df): + spark_schema = df.schema + table = dataframe_to_arrow_raw(df, spark_schema) + + col_is_geometry = [ + isinstance(f.dataType, GeometryType) for f in spark_schema.fields + ] Review Comment: Got it! I may defer to a follow-up since that's a bit of a learning curve for me. I think I can figure out how to walk the PySpark schema to get the nested paths corresponding to the Geometry nodes, and I think I can figure out how to do the node search/replace from the pyarrow side. For conversion, we can either: - Go back to the version here where we transform the result on the Python side in C - Figure out how to replace the `FieldSerializer`/`ArrowSerializer` on the Scala side to do what we need it to do there (basically: write WKB and add field metadata) - Figure out how to issue a `select()` call in pyspark that does the transformation using the pyspark dataframe API -- 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: issues-unsubscr...@sedona.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org