apache / apache/sedona-db

Integrate GEOMETRY and GEOGRAPHY type names with SQL

Open
#99 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
503
Forks
61
Avg merge
2d 5h
Merged PRs (30d)
91

Description

In the current SQL, the type names for GEOMETRY and GEOGRAPHY (or generally any extension type) are serialized to SQL as their storage type. For example, in the CLI:

```
> create or replace view test_view as SELECT ST_Point(1,2) as pt;
> select * from test_view;
┌─────────────────────────────┐
│ st_point(Int64(1),Int64(2)) │
│ geometry │
╞═════════════════════════════╡
│ POINT(1 2) │
└─────────────────────────────┘
> \d test_view
┌───────────────┬──────────────┬────────────┬─────────────┬───────────┬─────────────┐
│ table_catalog ┆ table_schema ┆ table_name ┆ column_name ┆ data_type ┆ is_nullable │
│ utf8 ┆ utf8 ┆ utf8 ┆ utf8 ┆ utf8 ┆ utf8 │
╞═══════════════╪══════════════╪════════════╪═════════════╪═══════════╪═════════════╡
│ datafusion ┆ public ┆ test_view ┆ pt ┆ Binary ┆ YES │
└───────────────┴──────────────┴────────────┴─────────────┴───────────┴─────────────┘
```

Luckily this doesn't come up very often...possibly the other place it might come up is casting (e.g., `'POINT (1 2)'::GEOMETRY`), which won't work in SQL either.

I haven't looked into exactly where in DataFusion we'd need to hook into the SQL parser to make this happen but I am guessing it will be somewhat involved.

Contributor guide

Open the contributing guide

Research direction

Start in the DataFusion SQL parser and trace how GEOMETRY, GEOGRAPHY, and other extension type names are represented and serialized, using the CLI examples as the expected behavior. Check both view metadata and cast syntax such as 'POINT (1 2)'::GEOMETRY; done means preserving the extension type names in SQL and supporting the stated cast case.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.