-
Notifications
You must be signed in to change notification settings - Fork 82
feat(ibis): postgreSQL, PostGIS support for IBIS Server. #1188
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
Open
eren-ture
wants to merge
5
commits into
Canner:main
Choose a base branch
from
eren-ture:PostGIS-Support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+126
−0
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1da65b7
PostgreSQL, PostGIS support.
eren-ture 5c8957e
Added a test dataset for Geometry type, and added a test case to test…
eren-ture 4dc8002
Added missing assert
eren-ture d71e3e7
Accepted @goldmedal s suggestions.
eren-ture dea0da1
Fixed PostGIS Docker Image and test case.
eren-ture File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import base64 | ||
from urllib.parse import quote_plus, urlparse | ||
|
||
import geopandas as gpd | ||
import orjson | ||
import pandas as pd | ||
import psycopg | ||
|
@@ -149,6 +150,19 @@ def postgres(request) -> PostgresContainer: | |
return pg | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def postgis(request) -> PostgresContainer: | ||
pg = PostgresContainer("postgis/postgis:16-3.5-alpine").start() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because
I think it's better to add a comment to mention it. |
||
engine = sqlalchemy.create_engine(pg.get_connection_url()) | ||
with engine.begin() as conn: | ||
conn.execute(text("CREATE EXTENSION IF NOT EXISTS postgis")) | ||
gpd.read_parquet( | ||
file_path("resource/tpch/data/cities_geometry.parquet") | ||
).to_postgis("cities_geometry", engine, index=False) | ||
request.addfinalizer(pg.stop) | ||
return pg | ||
|
||
|
||
async def test_query(client, manifest_str, postgres: PostgresContainer): | ||
connection_info = _to_connection_info(postgres) | ||
response = await client.post( | ||
|
@@ -1050,6 +1064,25 @@ async def test_model_substitute_non_existent_column( | |
assert 'column "x" does not exist' in response.text | ||
|
||
|
||
async def test_postgis_geometry(client, manifest_str, postgis: PostgresContainer): | ||
connection_info = _to_connection_info(postgis) | ||
response = await client.post( | ||
url=f"{base_url}/query", | ||
json={ | ||
"connectionInfo": connection_info, | ||
"manifestStr": manifest_str, | ||
"sql": ( | ||
"SELECT ST_Distance(a.geometry, b.geometry) AS distance " | ||
"FROM cities_geometry a, cities_geometry b " | ||
"WHERE a.\"City\" = 'London' AND b.\"City\" = 'New York'" | ||
), | ||
}, | ||
) | ||
assert response.status_code == 200 | ||
result = response.json() | ||
assert result["data"][0] == ["74.6626535"] | ||
|
||
|
||
def _to_connection_info(pg: PostgresContainer): | ||
return { | ||
"host": pg.get_container_host_ip(), | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify extension handler augmentation behavior
The
augment
method signature returns a list of tables, but it's being used here to modify theunique_tables
dictionary. Since Python dictionaries are passed by reference, this likely works as intended, but it would be clearer if the method returned the modified dictionary or the variable assignment was removed.🏁 Script executed:
Length of output: 1566
🏁 Script executed:
Length of output: 3870
🏁 Script executed:
Length of output: 19056
Fix type annotations for ExtensionHandler.augment and handlers
The
augment
and related handler methods actually accept and return a mapping of table names toTable
objects (adict[str, Table]
), not alist[Table]
. Update the type signatures to reflect that, or else change the implementation to work with lists:• In ibis-server/app/model/metadata/postgres.py, adjust:
• Optionally remove the assignment
Since the handlers mutate the dict in place and then return it, you could also call:
without re-assigning
unique_tables
.These changes will make the code’s behavior and its annotations consistent.