Copilot commented on code in PR #3159:
URL: https://github.com/apache/sedona/pull/3159#discussion_r3647432304


##########
python/sedona/spark/geopandas/geoseries.py:
##########
@@ -692,6 +715,98 @@ def _query_geometry_column(
         result = GeoSeries(ps_series) if returns_geom else ps_series
         return result
 
+    def _expand_geometry_array(
+        self,
+        array_builder,
+        ignore_index: bool,
+        index_parts: bool,
+        temp_prefix: str,
+    ):
+        """Expand a geometry-array expression while preserving index 
metadata."""
+        internal = self._internal.resolved_copy
+        source_sdf = internal.spark_frame
+        reserved_names = set(source_sdf.columns)
+
+        def temp_column_name(base: str) -> str:
+            suffix = 0
+            candidate = f"__{temp_prefix}_{base}__"
+            while candidate in reserved_names:
+                suffix += 1
+                candidate = f"__{temp_prefix}_{base}_{suffix}__"
+            reserved_names.add(candidate)
+            return typing.cast(str, verify_temp_column_name(source_sdf, 
candidate))
+
+        index_column_names = [
+            temp_column_name(f"index_{level}")
+            for level in range(len(internal.index_spark_columns))
+        ]
+        parent_order_col = temp_column_name("parent_order")
+        position_col = temp_column_name("position")
+        value_col = temp_column_name("value")
+        sequence_col = temp_column_name("sequence")
+
+        expanded_sdf = source_sdf.select(
+            *[
+                column.alias(name)
+                for column, name in zip(
+                    internal.index_spark_columns, index_column_names
+                )
+            ],
+            scol_for(source_sdf, 
NATURAL_ORDER_COLUMN_NAME).alias(parent_order_col),
+            F.posexplode(array_builder(internal.data_spark_columns[0])).alias(
+                position_col, value_col
+            ),
+        ).orderBy(parent_order_col, position_col)
+
+        # The distributed sequence supplies both ignore_index and a stable
+        # natural-order column without a single-partition row-number window.
+        expanded_sdf = InternalFrame.attach_distributed_sequence_column(
+            expanded_sdf, sequence_col
+        )
+
+        if ignore_index:
+            output_index_cols = [SPARK_DEFAULT_INDEX_NAME]
+            index_names = [None]
+            index_fields = None
+            index_expressions = [
+                scol_for(expanded_sdf, 
sequence_col).alias(SPARK_DEFAULT_INDEX_NAME)
+            ]

Review Comment:
   In `_expand_geometry_array`, the `ignore_index` branch sets `index_fields = 
None` even though an index column is being created. Downstream `InternalFrame` 
construction/copy calls expect `index_fields` to describe the index columns; 
leaving it as `None` can lead to incorrect/inferred index metadata or runtime 
errors.
   
   This issue also appears on line 785 of the same file.



##########
docs/api/flink/Predicates/ST_EqualsExact.md:
##########
@@ -0,0 +1,62 @@
+<!--
+ 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.
+ -->
+
+# ST_EqualsExact
+
+Introduction: Return true if A and B have the same structure and their 
corresponding coordinates are equal within a tolerance.
+
+Unlike `ST_Equals`, this predicate requires geometry types, component order, 
ring order, and vertex order to match. The tolerance is the maximum distance 
allowed between each pair of corresponding coordinates. The comparison uses x 
and y coordinates and ignores z and m coordinates.

Review Comment:
   Minor doc consistency: this page uses "Return true" and lowercases Z/M. 
Other SQL predicate docs use "Returns true" and refer to "Z"/"M" coordinates; 
aligning wording/capitalization helps keep the docs consistent.



##########
docs/api/snowflake/vector-data/Predicates/ST_EqualsExact.md:
##########
@@ -0,0 +1,60 @@
+<!--
+ 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.
+ -->
+
+# ST_EqualsExact
+
+Introduction: Return true if A and B have the same structure and their 
corresponding coordinates are equal within a tolerance.
+
+Unlike `ST_Equals`, this predicate requires geometry types, component order, 
ring order, and vertex order to match. The tolerance is the maximum distance 
allowed between each pair of corresponding coordinates. The comparison uses x 
and y coordinates and ignores z and m coordinates.

Review Comment:
   Minor doc consistency: this page uses "Return true" and lowercases Z/M. 
Other SQL predicate docs use "Returns true" and refer to "Z"/"M" coordinates; 
aligning wording/capitalization helps keep the docs consistent.



-- 
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