Skip to content

ST_Hilbert throws Attempted to access index 3 within vector of size 3 #546

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

Closed
Alex-Monahan opened this issue Apr 18, 2025 · 3 comments · Fixed by #549
Closed

ST_Hilbert throws Attempted to access index 3 within vector of size 3 #546

Alex-Monahan opened this issue Apr 18, 2025 · 3 comments · Fixed by #549

Comments

@Alex-Monahan
Copy link

Howdy!

I was giving ST_Hilbert a try for the zonemaps blog, and I ran into an internal error when trying to use it. It could be user error!

Thank you as always!

When I run this SQL script, I get the error below. I get a similar error in 1.2.2 and in v1.3.0-dev2617. Both are on MacOS on an ARM M1.

For 1.2.2, I used the CLI:

install spatial;
load spatial;
with example_floats as (
  from range(10) t(i)
  select 
    (i+0.01)::double as lat,
    (i+0.02)::double as long
)
from example_floats 
select
  lat,
  long,
  st_hilbert(lat,long, {min_x: 0, min_y: 0, max_x: 11, max_y: 11}::BOX_2D);
INTERNAL Error:
Attempted to access index 3 within vector of size 3

Stack Trace:

0        _ZN6duckdb9ExceptionC2ENS_13ExceptionTypeERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 64
1        _ZN6duckdb17InternalExceptionC1ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 20
2        _ZN6duckdb17InternalExceptionC1IJyyEEERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEDpT_ + 140
3        _ZN6duckdb6vectorINS_6VectorELb1EEixEm + 188
4        _ZN6duckdb12_GLOBAL__N_110ST_Hilbert13ExecuteLonlatERNS_9DataChunkERNS_15ExpressionStateERNS_6VectorE + 76
5        duckdb::ExpressionExecutor::Execute(duckdb::Expression const&, duckdb::ExpressionState*, duckdb::SelectionVector const*, unsigned long long, duckdb::Vector&) + 376
6        duckdb::ExpressionExecutor::Execute(duckdb::DataChunk*, duckdb::DataChunk&) + 76
7        duckdb::PhysicalProjection::Execute(duckdb::ExecutionContext&, duckdb::DataChunk&, duckdb::DataChunk&, duckdb::GlobalOperatorState&, duckdb::OperatorState&) const + 24
8        duckdb::PipelineExecutor::Execute(duckdb::DataChunk&, duckdb::DataChunk&, unsigned long long) + 404
9        duckdb::PipelineExecutor::ExecutePushInternal(duckdb::DataChunk&, duckdb::ExecutionBudget&, unsigned long long) + 108
10       duckdb::PipelineExecutor::Execute(unsigned long long) + 336
11       duckdb::PipelineTask::ExecuteTask(duckdb::TaskExecutionMode) + 236
12       duckdb::ExecutorTask::Execute(duckdb::TaskExecutionMode) + 192
13       duckdb::Executor::ExecuteTask(bool) + 252
14       duckdb::ClientContext::ExecuteTaskInternal(duckdb::ClientContextLock&, duckdb::BaseQueryResult&, bool) + 64
15       duckdb::PendingQueryResult::ExecuteInternal(duckdb::ClientContextLock&) + 60
16       duckdb::PendingQueryResult::Execute() + 56
17       duckdb_shell_sqlite3_print_duckbox + 368
18       duckdb_shell::ShellState::ExecutePreparedStatement(sqlite3_stmt*) + 932
19       duckdb_shell::ShellState::ExecuteSQL(char const*, char**) + 452
20       duckdb_shell::ShellState::RunOneSqlLine(char*) + 104
21       duckdb_shell::ShellState::ProcessInput() + 916
22       main + 3140
23       start + 2840

This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/dev/internal_errors

I used this Python script to test the dev version.

import duckdb

duckdb.sql('select version()').show()

duckdb.sql("""install spatial; load spatial;""")

duckdb.sql("""
  with example_floats as (
  from range(10) t(i)
  select 
    (i+0.01)::double as lat,
    (i+0.02)::double as long
)
from example_floats 
select
  lat,
  long,
  st_hilbert(lat,long, {min_x: 0, min_y: 0, max_x: 11, max_y: 11}::BOX_2D)""").show()

I also tested in Wasm with similar outcomes.

@Maxxen
Copy link
Member

Maxxen commented Apr 18, 2025

Ah shit, that looks like a regression! Ill give it a look!

@Maxxen Maxxen mentioned this issue Apr 22, 2025
@Maxxen Maxxen linked a pull request Apr 22, 2025 that will close this issue
@Maxxen Maxxen closed this as completed Apr 22, 2025
@Alex-Monahan
Copy link
Author

Working like a charm on core_nightly! Thanks Max! I think we will put this to good use in MD land. Sorting is winning! :-)

@Maxxen
Copy link
Member

Maxxen commented Apr 27, 2025

cool! Im sure a general multi-dimensional space filling curve func will make it into core at some point once we get more sort-awarness going in the execution engine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants