Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Can't create table with GEOMETRY type using CTAS

Open
#311 0 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp, postgresql, sql
Domain
databases

Research direction

Start by reproducing the CTAS statement from the issue in the DuckDB CLI with PostgreSQL 14 and compare it with the explicit GEOMETRY table plus INSERT path. Trace how ST_Point's geometry type is handled during CTAS and insertion; done means the CTAS statement succeeds and the resulting geom column retains the expected geometry value.

Written by the indexing model from the issue text.

Description

What happens?

Original issue reported on discord.

This doesn't work.

CREATE TABLE postgres_db.my_schema.my_table AS 
    SELECT ST_Point (.22, 1.22) AS geom
-- Failed to copy data: ERROR:  Unknown WKB type (0)! Full WKB type number was (0)

But this does

CREATE TABLE postgres_db.my_schema.my_table (geom GEOMETRY);
INSERT INTO postgres_db.my_schema.my_table VALUES (ST_Point (.22, 1.22))

My guess is that during inserts we map the Postgres geometry type to WKB_BLOB, which spatial then auto-casts to from GEOMETRY. But this doesn't work during CTAS because no implicit cast get inserted.

To Reproduce

CREATE TABLE postgres_db.my_schema.my_table AS
SELECT ST_Point (.22, 1.22) AS geom

OS:

MacOS

PostgreSQL Version:

14

DuckDB Version:

1.2.0

DuckDB Client:

CLI

Full Name:

Max Gabrielsson

Affiliation:

DuckDB Labs

Have you tried this on the latest main branch?
  • I agree
Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?
  • I agree
Dominant language
C++
Stars
372
Forks
107
Avg merge
13h 55m
Merged PRs (30d)
13

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from duckdb/duckdb-postgres

All issues in duckdb/duckdb-postgres

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.