marcboeker / go-duckdb

go-duckdb provides a database/sql driver for the DuckDB database engine.
MIT License
623 stars 97 forks source link

"unsupported type 17" on duckdb > 0.10.0 #185

Closed elise-prequel closed 2 months ago

elise-prequel commented 5 months ago

Hi! I am running DuckDB compiled against (commit hash 21475f18837bb1b213ccc891bf8c32d8f1872b9f) which is the present head.

If I run the following SQL to create a table:

CREATE OR REPLACE VIEW test_schema.test_table AS
SELECT 
    md5(CAST(range AS TEXT)) as id
FROM range(10);

And the following to read:

SELECT
    column_name,
    data_type
FROM information_schema.columns
WHERE
LOWER(table_schema) = LOWER('test_schema')

Iterating rows fails with unsupported type: 17. It is similar to https://github.com/marcboeker/go-duckdb/issues/172 except the types in my table don't matter, and I think type 17 is the new UHUGEINT.

taniabogatsch commented 2 months ago

Hi @elise-prequel, I just checked your reproduction with the latest version of go-duckdb. The following test succeeds.

func TestUnsupportedType(t *testing.T) {
    db := openDB(t)

    _, err := db.Exec(`CREATE SCHEMA test_schema`)
    require.NoError(t, err)

    _, err = db.Exec(`
    CREATE OR REPLACE VIEW test_schema.test_table AS
    SELECT md5(CAST(range AS TEXT)) as id FROM range(10)`)
    require.NoError(t, err)

    res, err := db.Query(`
    SELECT column_name AS Col1, data_type AS Col2
    FROM information_schema.columns
    WHERE LOWER(table_schema) = LOWER('test_schema')`)
    require.NoError(t, err)

    type row struct {
        Col1 string
        Col2 string
    }
    for res.Next() {
        var r row
        err = res.Scan(&r.Col1, &r.Col2)
        require.NoError(t, err)
        expected := row{Col1: "id", Col2: "VARCHAR"}
        require.Equal(t, expected, r)
    }
}

Please feel free to reopen this issue with a detailed reproduction if the error continues to reproduce for you.

elise-prequel commented 2 months ago

Thank you so much @taniabogatsch !