Skip to content

Conversation

tswast
Copy link
Collaborator

@tswast tswast commented Apr 23, 2025

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Towards internal CL 750699441 🦕

@tswast tswast requested review from a team as code owners April 23, 2025 21:05
@tswast tswast requested a review from chelsea-lin April 23, 2025 21:05
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Apr 23, 2025
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. label Apr 23, 2025
@tswast tswast enabled auto-merge (squash) April 23, 2025 21:27
@tswast
Copy link
Collaborator Author

tswast commented Apr 23, 2025

"single point" test failures are real. Can't embed non-hashable objects in our expression trees.

_______________ test_geo_st_distance_with_single_geometry_object _______________
[gw16] linux -- Python 3.9.20 /tmpfs/src/github/python-bigquery-dataframes/.nox/system-3-9/bin/python

    def test_geo_st_distance_with_single_geometry_object():
        data1 = [
            # 0.00001 is approximately 1 meter.
            Polygon([(0, 0), (0.00001, 0), (0.00001, 0.00001), (0, 0.00001), (0, 0)]),
            Polygon(
                [
                    (0.00001, 0),
                    (0.00002, 0),
                    (0.00002, 0.00001),
                    (0.00001, 0.00001),
                    (0.00001, 0),
                ]
            ),
            Point(0, 0.00002),
        ]
    
        geobf_s1 = bigframes.geopandas.GeoSeries(data=data1)
>       geobf_s_result = bbq.st_distance(
            geobf_s1,
            Point(0, 0),
        ).to_pandas()

[tests/system/small/bigquery/test_geo.py:224](https://cs.corp.google.com/piper///depot/google3/tests/system/small/bigquery/test_geo.py?l=224): 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[bigframes/core/log_adapter.py:180](https://cs.corp.google.com/piper///depot/google3/bigframes/core/log_adapter.py?l=180): in wrapper
    raise e
[bigframes/core/log_adapter.py:164](https://cs.corp.google.com/piper///depot/google3/bigframes/core/log_adapter.py?l=164): in wrapper
    return method(self, *args, **kwargs)
[bigframes/series.py:503](https://cs.corp.google.com/piper///depot/google3/bigframes/series.py?l=503): in to_pandas
    df, query_job = self._block.to_pandas(
[bigframes/core/blocks.py:545](https://cs.corp.google.com/piper///depot/google3/bigframes/core/blocks.py?l=545): in to_pandas
    df, query_job = self._materialize_local(
[bigframes/core/blocks.py:634](https://cs.corp.google.com/piper///depot/google3/bigframes/core/blocks.py?l=634): in _materialize_local
    execute_result = self.session._executor.execute(
[bigframes/session/bq_caching_executor.py:120](https://cs.corp.google.com/piper///depot/google3/bigframes/session/bq_caching_executor.py?l=120): in execute
    plan = self.replace_cached_subtrees(array_value.node)
[bigframes/session/bq_caching_executor.py:357](https://cs.corp.google.com/piper///depot/google3/bigframes/session/bq_caching_executor.py?l=357): in replace_cached_subtrees
    return nodes.top_down(node, lambda x: self._cached_executions.get(x, x))
[bigframes/core/nodes.py:1659](https://cs.corp.google.com/piper///depot/google3/bigframes/core/nodes.py?l=1659): in top_down
    return root.top_down(transform)
[bigframes/core/bigframe_node.py:354](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=354): in top_down
    if item not in results.keys():
[bigframes/core/bigframe_node.py:137](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=137): in __hash__
    return self._cached_hash
/[usr/local/lib/python3.9/functools.py:993](https://cs.corp.google.com/piper///depot/google3/usr/local/lib/python3.9/functools.py?l=993): in __get__
    val = self.func(instance)
[bigframes/core/bigframe_node.py:154](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=154): in _cached_hash
    return hash(self._as_tuple())
[bigframes/core/bigframe_node.py:137](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=137): in __hash__
    return self._cached_hash
/[usr/local/lib/python3.9/functools.py:993](https://cs.corp.google.com/piper///depot/google3/usr/local/lib/python3.9/functools.py?l=993): in __get__
    val = self.func(instance)
[bigframes/core/bigframe_node.py:154](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=154): in _cached_hash
    return hash(self._as_tuple())
[bigframes/core/bigframe_node.py:137](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=137): in __hash__
    return self._cached_hash
/[usr/local/lib/python3.9/functools.py:993](https://cs.corp.google.com/piper///depot/google3/usr/local/lib/python3.9/functools.py?l=993): in __get__
    val = self.func(instance)
[bigframes/core/bigframe_node.py:154](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=154): in _cached_hash
    return hash(self._as_tuple())
[bigframes/core/bigframe_node.py:137](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=137): in __hash__
    return self._cached_hash
/[usr/local/lib/python3.9/functools.py:993](https://cs.corp.google.com/piper///depot/google3/usr/local/lib/python3.9/functools.py?l=993): in __get__
    val = self.func(instance)
[bigframes/core/bigframe_node.py:154](https://cs.corp.google.com/piper///depot/google3/bigframes/core/bigframe_node.py?l=154): in _cached_hash
    return hash(self._as_tuple())
<string>:3: in __hash__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = ScalarConstantExpression(value=<shapely.geometry.point.Point object at 0x146bb1abd610>, dtype=<geopandas.array.GeometryDtype object at 0x146bb6db5310>)

>   ???
E   TypeError: unhashable type: 'Point'

<string>:3: TypeError

I think maybe we just say this single point feature doesn't work with older shapely?

@tswast tswast merged commit ae83e61 into main Apr 23, 2025
19 of 24 checks passed
@tswast tswast deleted the tswast-shapely branch April 23, 2025 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants