Skip to content

Unimplemented type for cast (BLOB -> GEOMETRY) #277

@missinglink

Description

@missinglink

"@duckdb/node-api": "^1.3.2-alpha.25"

Hi,

I'm running into an issue reading a GEOMETRY field from one table and inserting it into another table using the appender api.

The error is: Unimplemented type for cast (BLOB -> GEOMETRY)

Below is a reproduction, I'm using app.appendValue(x, DuckDBBlobType.create('GEOMETRY')) without success.

Is this something which is currently possible?

import { DuckDBBlobType, DuckDBBlobValue, DuckDBInstance } from "@duckdb/node-api"

const instance = await DuckDBInstance.create(':memory:')
const conn = await instance.connect()

// install spatial extension
await conn.run('INSTALL spatial; LOAD spatial')

// create two tables, src & dst
await conn.run('CREATE TABLE src (geom GEOMETRY NOT NULL)')
await conn.run('CREATE TABLE dst (geom GEOMETRY NOT NULL)')

// insert into src
await conn.run('INSERT INTO src (geom) VALUES (ST_Point(1, 1))')

// read BLOB from src
const reader = await conn.runAndReadAll('SELECT geom FROM src')
const rows = reader.getRows() as DuckDBBlobValue[][]

// append BLOB to dst
const app = await conn.createAppender('dst')
// app.appendBlob(rows[0][0].bytes)
app.appendValue(rows[0][0], DuckDBBlobType.create('GEOMETRY'))
app.endRow()
app.closeSync()
node_bindings_1.default.append_value(this.appender, (0, createValue_1.createValue)(type ? type : (0, typeForValue_1.typeForValue)(value), value));
                                ^

Error: Failed to cast value: Unimplemented type for cast (BLOB -> GEOMETRY)

Ideally I would like to use the WKB_BLOB type for compatibility with external tables such as parquet and GEOMETRY for copying within DuckDB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions