duckdb_spatial icon indicating copy to clipboard operation
duckdb_spatial copied to clipboard

`st_read` can't find an existent column in non spatial table in GPKG.

Open ar-siddiqui opened this issue 7 months ago • 2 comments

What happens?

st_read throwing Binder Error: Referenced column not found when the column is present as confirmed by sqlite_scan().

To Reproduce

To reproduce:

D:\Users\abdul.siddiqui>duckdb
v1.2.2 7c039464e4
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D INSTALL spatial; LOAD spatial;
D SELECT *
┬╖ FROM st_read('D:\Users\abdul.siddiqui\Downloads\lowercolorado\processing.gpkg', layer='processing')
┬╖ WHERE reach_id IS NOT NULL
┬╖ LIMIT 1;
Binder Error:
Referenced column "reach_id" not found in FROM clause!
Candidate bindings: "model_id", "eclipsed", "collection_id"

LINE 3: WHERE reach_id IS NOT NULL
              ^
D .mode line
D SELECT *
┬╖ FROM st_read('D:\Users\abdul.siddiqui\Downloads\lowercolorado\processing.gpkg', layer='processing')
┬╖ LIMIT 1;
collection_id = NULL
     model_id = NULL
     eclipsed = NULL
D INSTALL sqlite; LOAD sqlite;
100% ?████████████████████████████████████████████████████████████?
D SELECT *
┬╖ FROM sqlite_scan('D:\Users\abdul.siddiqui\Downloads\lowercolorado\processing.gpkg', 'processing')
┬╖ WHERE reach_id IS NOT NULL
┬╖ LIMIT 1;
     reach_id = 274982
collection_id = NULL
     model_id = NULL
     eclipsed = NULL
D

duckdb_issue.zip

OS:

Windows x86_64

DuckDB Version:

1.2.2

DuckDB Client:

CLI and Python

Hardware:

No response

Full Name:

Abdul Raheem Siddiqui

Affiliation:

ERT Inc.

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • [x] Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • [x] Yes, I have

ar-siddiqui avatar Apr 28 '25 02:04 ar-siddiqui

Hello!

reach_id seems to be the FID column, which DuckDB doesn't output, see #213. Although we should probably revisit this soon as there really isn't a good reason anymore why it doesn't.

Maxxen avatar Apr 28 '25 13:04 Maxxen

Okay, that makes sense. I have had my fair share of troubles with fid and ogr. At minimum, I think we should raise a helpful message saying something like "Is your column PRIMARY KEY?" or maybe include it in the st_read documentation.

ar-siddiqui avatar Apr 28 '25 15:04 ar-siddiqui

Will revisit this soon!

Maxxen avatar Oct 24 '25 11:10 Maxxen