Skip to content

Introduce Geometry type and input some functions for this type - #83344

Merged
scanhex12 merged 11 commits into
ClickHouse:masterfrom
scanhex12:geom_type
Oct 23, 2025
Merged

scanhex12 merged 11 commits into
ClickHouse:masterfrom
scanhex12:geom_type

Conversation

@scanhex12

@scanhex12 scanhex12 commented Jul 5, 2025 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Introduce Geometry type. Support reading WKB and WKT formats for it. In previous versions, the Geometry type was aliased to String, but now it is a full-featured type.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickhouse-gh

clickhouse-gh Bot commented Jul 5, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [855e4be]

Summary: ⏳

job_name test_name status info comment
Stateless tests (amd_ubsan, parallel) failure
00900_long_parquet_load FAIL cidb
Integration tests (amd_tsan, 1/6) failure
test_storage_s3_queue/test_parallel_inserts.py::test_parallel_inserts_with_failures[1] FAIL cidb
Integration tests (amd_tsan, 5/6) failure
test_storage_nats/test_nats_core.py::test_nats_no_connection_at_startup_2 FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Jul 5, 2025
@nikitamikhaylov

nikitamikhaylov commented Jul 5, 2025 •

Copy link
Copy Markdown
Member

Related: #79493

We can also support other functions (area, perimeter, etc.) for the new unified Geometry type.

@scanhex12 scanhex12 changed the title Introduce Geometry type and input geometry functions for this type Introduce Geometry type and input some functions for this type Jul 5, 2025
@scanhex12
scanhex12 marked this pull request as draft July 5, 2025 16:59
@scanhex12
scanhex12 marked this pull request as ready for review July 5, 2025 19:31
@scanhex12

Copy link
Copy Markdown
Member Author

@nikitamikhaylov I would like to implement other functions in separate PRs to make code review process easier

Comment thread src/Functions/readWkb.cpp Resolved
@scanhex12

Copy link
Copy Markdown
Member Author

@alexey-milovidov could you please take a look once again?

@rschu1ze

rschu1ze commented Jul 9, 2025

Copy link
Copy Markdown
Member

Please add docs here - even if the geo type is preliminary/experimental for now (the docs should say so).

Comment thread src/DataTypes/DataTypeString.cpp Resolved
@alexey-milovidov alexey-milovidov self-assigned this Oct 17, 2025
@alexey-milovidov

Copy link
Copy Markdown
Member

@scanhex12, this is an amazing change, one of my dreams! Please add the documentation and resolve conflicts.

@clickhouse-gh clickhouse-gh Bot added pr-backward-incompatible Pull request with backwards incompatible changes and removed pr-feature Pull request with new product feature labels Oct 22, 2025
Comment thread src/Functions/readWkt.cpp Resolved

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Everything else LGTM.

@@ -0,0 +1,34 @@
SET allow_suspicious_variant_types = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why suspicious?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because Geometry uses POLYGON and MULTILINESTRING which are equals to each other

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then it makes the new Geometry data type unusable without the experimental setting.
Let's make sure the Variant data type accepts distinct aliases to the same type.

@scanhex12
scanhex12 added this pull request to the merge queue Oct 23, 2025
Merged via the queue into ClickHouse:master with commit 033ada2 Oct 23, 2025
@scanhex12
scanhex12 deleted the geom_type branch October 23, 2025 15:56
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 23, 2025
Comment thread src/Functions/readWkt.cpp
auto try_deserialize_type = [&] (const std::function<void()> & deserialize_func, const String & data, const String & target_prefix, WKTTypes type) -> bool
{
try
auto lower_data = boost::to_lower_copy(data);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There are three problems:

  1. We do lowercase many times instead of just one.
  2. We do it for all the string, which can be large, instead of just for the type name.
  3. We do string comparison multiple times, while we can do it in a single pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backward-incompatible Pull request with backwards incompatible changes pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants