Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SUPP: Improve geospatial literals and smoke tests #1928

Merged
merged 2 commits into from
Aug 26, 2019

Conversation

xmnlab
Copy link
Contributor

@xmnlab xmnlab commented Aug 19, 2019

Improves geo spatial literals and smoke tests:

Resolves #1929
Resolves #1931
Resolves partially #1930

@xmnlab xmnlab changed the title Fix smoke test for geospatial operations SUPP: Improve smoke test for geospatial operations Aug 19, 2019
@xmnlab xmnlab self-assigned this Aug 19, 2019
@xmnlab xmnlab added geospatial refactor Issues or PRs related to refactoring the codebase tests Issues or PRs related to tests bug Incorrect behavior inside of ibis labels Aug 19, 2019
@xmnlab xmnlab mentioned this pull request Aug 19, 2019
@xmnlab xmnlab changed the title SUPP: Improve smoke test for geospatial operations SUPP: Improve geospatial literals and smoke tests Aug 19, 2019
@xmnlab
Copy link
Contributor Author

xmnlab commented Aug 20, 2019

@ian-r-rose it seems there are operations available for omniscidb that postgis doesn't have.
so probably the best approach here is making tests for both omniscidb and postgis.

@xmnlab xmnlab requested a review from cpcloud August 20, 2019 16:15
@xmnlab
Copy link
Contributor Author

xmnlab commented Aug 20, 2019

@ian-r-rose it is done for review ... if you have time, some feedback would be awesome :)

@xmnlab
Copy link
Contributor Author

xmnlab commented Aug 20, 2019

@cpcloud it is done for review :) thanks!

Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small change request, otherwise LGTM.

.pre-commit-config.yaml Outdated Show resolved Hide resolved
ci/requirements-3.5-dev.yml Outdated Show resolved Hide resolved
ibis/expr/tests/test_geospatial.py Outdated Show resolved Hide resolved
Copy link
Contributor Author

@xmnlab xmnlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpcloud I applied the suggestion you made. it is done for review.

ci/requirements-3.5-dev.yml Outdated Show resolved Hide resolved
ibis/expr/tests/test_geospatial.py Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
.pre-commit-config.yaml Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 21, 2019

Codecov Report

Merging #1928 into master will decrease coverage by 1.62%.
The diff coverage is 63.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1928      +/-   ##
==========================================
- Coverage   87.57%   85.94%   -1.63%     
==========================================
  Files          93       93              
  Lines       16814    16837      +23     
  Branches     2138     2144       +6     
==========================================
- Hits        14725    14471     -254     
- Misses       1683     1959     +276     
- Partials      406      407       +1
Impacted Files Coverage Δ
ibis/common/geospatial.py 81.39% <62.5%> (+10.62%) ⬆️
ibis/sql/alchemy.py 92.52% <75%> (+0.28%) ⬆️
ibis/bigquery/client.py 41.1% <0%> (-53.39%) ⬇️
ibis/bigquery/compiler.py 59.92% <0%> (-37.5%) ⬇️
ibis/bigquery/udf/api.py 80.48% <0%> (-14.64%) ⬇️
ibis/impala/compiler.py 91.23% <0%> (-5.2%) ⬇️
ibis/pandas/dispatch.py 95.45% <0%> (-4.55%) ⬇️
ibis/pandas/client.py 85.54% <0%> (-3.47%) ⬇️
ibis/bigquery/api.py 63.33% <0%> (-3.34%) ⬇️
ibis/expr/schema.py 89.77% <0%> (-1.14%) ⬇️
... and 3 more

@xmnlab xmnlab requested a review from cpcloud August 21, 2019 01:09
@cpcloud
Copy link
Member

cpcloud commented Aug 22, 2019

@xmnlab I've temporarily pinned sqlalchemy in #1938. Can you remove the corresponding changes here? I'll let you know when I merge that so that you can rebase and get some passing builds.

@cpcloud
Copy link
Member

cpcloud commented Aug 22, 2019

@xmnlab Can you rebase? I merged #1938.

@xmnlab xmnlab force-pushed the change-geo-mock-test-backend branch from 3a65449 to f1ab6ba Compare August 22, 2019 14:35
Copy link
Contributor Author

@xmnlab xmnlab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebased!

ibis/expr/tests/conftest.py Show resolved Hide resolved
@xmnlab
Copy link
Contributor Author

xmnlab commented Aug 22, 2019

@cpcloud looks like the CI tests passed! :)

ibis/common/geospatial.py Show resolved Hide resolved
"""Convert a iterable with a linestring to text."""
return ', '.join(_format_point_value(point) for point in value)
template = '({})' if nested else '{}'
# fix wrong structure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate here? What exactly is wrong is about the structure if the first element is a tuple or list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for example this WKT POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))

if anyone tries that in python (((30, 10), (40, 40), (20, 40), (10, 20), (30, 10))) the outer parenthesis doesn't have any effect. the "correct" way to write that would be (((30, 10), (40, 40), (20, 40), (10, 20), (30, 10)),) (ensuring the tuple format on the outer parenthesis)

so this code is used to ensure the "correct" format of this data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should try to mirror the syntax of postgres/postgis types here with a Python equivalent. A sequence of pairs of numbers is the contract.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but it should be a tuple, another example shows that:

POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be second guessing user input types. Can you write down the type of the input expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anymore thoughts about that? should I change anything? or is it already OK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah and if I should raise an error .. what would be the best Exception to be used? IbisInputError?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good. I will change that! thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! let me know your thoughts about the message and the type hint.

ibis/common/geospatial.py Outdated Show resolved Hide resolved
ibis/expr/tests/conftest.py Show resolved Hide resolved
@xmnlab
Copy link
Contributor Author

xmnlab commented Aug 22, 2019

Can you import the one from tests/all here?

the current structure doesn't work with tests.all.conftest.pytest_pyfunc_call because I am not using an instance of Backend

trying to use 'Backend' it seems it is raising an error related to circular imports

ImportError while loading conftest '/mnt/sda1/dev/quansight/ibis-project/ibis/ibis/expr/tests/conftest.py'.
conftest.py:20: in <module>
    from ibis.expr.tests.mocks import (
mocks.py:23: in <module>
    from ibis.tests.backends import Backend
../../tests/backends.py:19: in <module>
    from ibis.impala.tests.conftest import IbisTestEnv as ImpalaEnv
../../impala/tests/conftest.py:10: in <module>
    from ibis.expr.tests.mocks import MockConnection
E   ImportError: cannot import name 'MockConnection' from 'ibis.expr.tests.mocks' (/mnt/sda1/dev/quansight/ibis-project/ibis/ibis/expr/tests/mocks.py)

the pytest_pyfunc_call I wrote is specifically for mock

@xmnlab xmnlab force-pushed the change-geo-mock-test-backend branch from f1ab6ba to 53eb12c Compare August 22, 2019 20:48
@cpcloud
Copy link
Member

cpcloud commented Aug 22, 2019

Ah, got it. Thanks for clarifying.

cpcloud pushed a commit that referenced this pull request Aug 22, 2019
In this PR:    - Fixes explain operation    Resolves #1921   Depends
on #1928
Author: Ivan Ogasawara <ivan.ogasawara@gmail.com>

Closes #1933 from xmnlab/fix-explain and squashes the following commits:

6ed5e5b [Ivan Ogasawara] refactoring
980fd4d [Ivan Ogasawara] Fixed explain method
ibis/common/geospatial.py Outdated Show resolved Hide resolved
@xmnlab xmnlab force-pushed the change-geo-mock-test-backend branch from 53eb12c to 33173b9 Compare August 23, 2019 21:37
@xmnlab xmnlab requested a review from cpcloud August 23, 2019 22:06
ibis/expr/tests/test_geospatial.py Outdated Show resolved Hide resolved
def test_geo_ops_smoke(backend, fn_expr):
"""Smoke tests for geo spatial operations."""
geo_table = backend.table('geo')
fn_expr(geo_table).compile()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's at least assert that the compiled result is not the empty string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good!

ibis/common/geospatial.py Outdated Show resolved Hide resolved
ibis/common/geospatial.py Outdated Show resolved Hide resolved
ibis/common/geospatial.py Outdated Show resolved Hide resolved
ibis/common/geospatial.py Outdated Show resolved Hide resolved
ibis/common/geospatial.py Outdated Show resolved Hide resolved
@cpcloud
Copy link
Member

cpcloud commented Aug 26, 2019

@xmnlab Can you resolve the merge conflicts here?

@cpcloud cpcloud added this to the Next Major Release milestone Aug 26, 2019
@xmnlab xmnlab force-pushed the change-geo-mock-test-backend branch from 33173b9 to 7acb69f Compare August 26, 2019 16:27
@xmnlab
Copy link
Contributor Author

xmnlab commented Aug 26, 2019

@cpcloud, rebased! :)

@xmnlab xmnlab requested a review from cpcloud August 26, 2019 17:05
@xmnlab
Copy link
Contributor Author

xmnlab commented Aug 26, 2019

it is done for a new review.

Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @xmnlab!

@cpcloud cpcloud merged commit 7c032e0 into ibis-project:master Aug 26, 2019
@xmnlab xmnlab deleted the change-geo-mock-test-backend branch August 26, 2019 18:23
@xmnlab
Copy link
Contributor Author

xmnlab commented Aug 26, 2019

thanks @cpcloud!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis refactor Issues or PRs related to refactoring the codebase tests Issues or PRs related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Black git pre-commit hook doesn't reformat the code SUPP: Fix smoke test for geo spatial operations
2 participants