feat(ibis): postgreSQL, PostGIS support for IBIS Server.
Inclusions
-
Added an
ExtensionHandlerclass to handle database extensions. Created thepostgis_handlermethod to define columns asgeometryorgeography. -
Added new column types
GEOMETRYandGEOGRAPHYto theRustWrenEngineColumnTypeenum to represent PostGIS-specific data types.
Proof of Work
Issue
When the frontend is asked to display the values, it obviously fails. I unfortunately don't know much about frontend development, ad cannot fix this issue.
Summary by CodeRabbit
- New Features
- Added support for recognizing and displaying PostGIS extension column types (GEOMETRY and GEOGRAPHY) in PostgreSQL metadata.
- Metadata extraction now includes extension-specific columns, providing more accurate information for tables using supported PostgreSQL extensions.
[!IMPORTANT]
Review skipped
Review was skipped due to path filters
:no_entry: Files ignored due to path filters (1)
ibis-server/poetry.lockis excluded by!**/*.lockCodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including
**/dist/**will override the default block on thedistdirectory, by removing the pattern from both the lists.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
"""
Walkthrough
The changes introduce support for PostgreSQL extensions, specifically PostGIS, in the metadata extraction process. This is achieved by extending the column type enum to include geometry types and adding an ExtensionHandler class that augments table metadata with extension-specific information during table list retrieval. Additionally, tests were added to validate PostGIS spatial queries. New dependencies for spatial data handling were also added.
Changes
| File(s) | Change Summary |
|---|---|
| ibis-server/app/model/metadata/dto.py | Extended the RustWrenEngineColumnType enum by adding two new members: GEOMETRY and GEOGRAPHY, representing PostGIS extension types. |
| ibis-server/app/model/metadata/postgres.py | Added the ExtensionHandler class to handle PostgreSQL extensions and augment table metadata. Integrated this handler into PostgresMetadata.get_table_list to support PostGIS by updating column types for geometry and geography columns. |
| ibis-server/tests/routers/v2/connector/test_postgres.py | Added a pytest fixture to start a PostGIS-enabled PostgreSQL container and load spatial data. Added an async test to query PostGIS geometry data and verify spatial calculations through the API. |
| ibis-server/pyproject.toml | Added new dependencies: geopandas and geoalchemy2 for spatial data support. |
Sequence Diagram(s)
sequenceDiagram
participant Client
participant PostgresMetadata
participant ExtensionHandler
participant Database
Client->>PostgresMetadata: get_table_list()
PostgresMetadata->>Database: Query standard table metadata
Database-->>PostgresMetadata: Return tables and columns
PostgresMetadata->>ExtensionHandler: augment(tables)
ExtensionHandler->>Database: get_extensions()
Database-->>ExtensionHandler: Return installed extensions
ExtensionHandler->>Database: Query PostGIS columns (if present)
Database-->>ExtensionHandler: Return geometry/geography columns
ExtensionHandler->>PostgresMetadata: Return augmented tables
PostgresMetadata-->>Client: Return final table list with extension types
Poem
In the warren of code, new tunnels appear,
PostGIS now whispers, "Geometry is here!"
Columns grow clever, with types fresh and bright,
Extensions now handled, metadata’s delight.
With paws on the schema and nose to the ground,
This rabbit ensures all the columns are found!
🐇✨ """
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
This is very interesting use case! @wwwy3y3 @andreashimin take a closer look!
Thanks @eren-ture for the contribution. It's awesome. 👍
However, it's better to add the corresponding test case for it.
You can add the test case in ibis-server/tests/routers/v2/connector/test_postgres.py
https://github.com/Canner/wren-engine/blob/c0f888d4e4b99003866ae212e7f5b9c9135992a0/ibis-server/tests/routers/v2/connector/test_postgres.py#L742
Maybe add a test case called test_metadata_list_tables_with_postgis.
I think you need to prepare the testing data by initializing the testing Postgres with PostGIS and try to list tables from it.
We use testcontainer to create the testing PG when testing. You can refer to postgres() to see how we initialize a testing database.
https://github.com/Canner/wren-engine/blob/c0f888d4e4b99003866ae212e7f5b9c9135992a0/ibis-server/tests/routers/v2/connector/test_postgres.py#L136
I expected you might implement another method called postgres_gis() for another instance.
Hi @goldmedal, I'm currently working on writing the tests. I'm more on the data side than software, but I'll probably get some commits out soon.
Hi @goldmedal, I'm currently working on writing the tests. I'm more on the data side than software, but I'll probably get some commits out soon.
Thanks. I'm looking forward to them. 👍
@eren-ture Thanks for all the hard work! Could you update the Poetry lock file? It looks like the CI failed because it needs to be updated. You can just run poetry lock.
@eren-ture Thanks for all the hard work! Could you update the Poetry lock file? It looks like the CI failed because it needs to be updated. You can just run poetry lock.
It's a pleasure. Thanks for the help.
I believe lock function added the packages "sqlalchemy" and "greenlet" to the main group. I don't know if that's intentional. Wanted to raise attention to it.
I rebased with main and ran poetry lock. Hopefully this should merge.