Skip to content
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

database/sql/driver: unsupported data type: ARRAY: index: 0 #318

Closed
hellower opened this issue Nov 24, 2024 · 1 comment
Closed

database/sql/driver: unsupported data type: ARRAY: index: 0 #318

hellower opened this issue Nov 24, 2024 · 1 comment
Assignees

Comments

@hellower
Copy link
Contributor

hellower commented Nov 24, 2024

package main

import (
	"database/sql"
	"fmt"
	"log"

	_ "github.com/marcboeker/go-duckdb"
)

func main() {
	db, err := sql.Open("duckdb", "")
	if err != nil {
		log.Fatalf("Failed to connect to DuckDB: %v\n", err)
	}
	defer db.Close()

	_, err = db.Exec(`CREATE TABLE needle (vec FLOAT[3])`)        // FLOAT[3] not FLOAT[]
	if err != nil {
		log.Fatalf("Failed to create table: %v\n", err)
	}

	_, err = db.Exec(`INSERT INTO needle VALUES (array[5, 5, 5]), (array[1, 1, 1])`)
	if err != nil {
		log.Fatalf("Failed to insert data: %v\n", err)
	}
	fmt.Println("Data inserted successfully.")

	rows, err := db.Query(`SELECT * FROM needle`)
	if err != nil {
		log.Fatalf("Failed to query data: %v\n", err)
	}
	defer rows.Close()

	fmt.Println("Query results:")
	for rows.Next() {
		var searchVec []float64
		err := rows.Scan(&searchVec)
		if err != nil {
			log.Fatalf("Failed to scan row: %v\n", err)
		}
		fmt.Printf("vec: %v\n", searchVec)
	}

	if rows.Err() != nil {
		log.Fatalf("Error during row iteration: %v\n", rows.Err())
	}
}

go run main.go
Data inserted successfully.
Query results:
2024/11/24 10:58:57 Error during row iteration: database/sql/driver: unsupported data type: ARRAY: index: 0
exit status 1

================
Declaring table columns as float[] and float[3] results in different outcomes.

@taniabogatsch
Copy link
Collaborator

Hi, @hellower - is this happening with v1.8.3?
I recently added ARRAY type support in this PR: #306.
To double-check and include an example in the code base, I've opened this PR: #337.

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

No branches or pull requests

2 participants