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

No results for UNION type #305

Open
jorinvo opened this issue Nov 7, 2024 · 7 comments
Open

No results for UNION type #305

jorinvo opened this issue Nov 7, 2024 · 7 comments
Labels
bug Something isn't working feature [feature] request or PR

Comments

@jorinvo
Copy link

jorinvo commented Nov 7, 2024

Hi and thanks for this driver. It works really well until I ran into the following:

A query that contains a union type doesn't return any rows.

In the CLI I can do this:

$ duckdb 
v1.1.2 f680b7d08f
Enter ".help" for usage hints.
D CREATE TYPE MYUNION AS UNION(s VARCHAR);
D SELECT 'test'::MYUNION;
┌─────────────────────────┐
│ CAST('test' AS MYUNION) │
│    union(s varchar)     │
├─────────────────────────┤
│ test                    │
└─────────────────────────┘

But in Go the second fmt will never show up:

func main() {
	db, err := sql.Open("duckdb", "")
	if err != nil {
		panic(err)
	}
	_, err = db.Exec("CREATE TYPE MYUNION AS UNION(s VARCHAR);")
	if err != nil {
		panic(err)
	}
	rows, err := db.Query("SELECT 'test';")
	for rows.Next() {
		var s string
		rows.Scan(&s)
		fmt.Println("this works: ", s)
	}
	rows, err = db.Query("SELECT 'test'::MYUNION;")
	for rows.Next() {
		var s string
		rows.Scan(&s)
		fmt.Println("this does not: ", s)
	}
	defer db.Close()
}

I originally ran into this in a project and could replicate it isolated like this.
Any ideas what is going on here?
Thanks a lot!

@taniabogatsch
Copy link
Collaborator

Hi @jorinvo! This is likely because we do not yet support the UNION type in this driver. However, I would have expected an error (unsupported type) message instead of an empty result.

In https://github.com/marcboeker/go-duckdb/blob/a32843693a7b014008d6514a13dcda3e13dccb99/type.go#L51C1-L60C2.

// FIXME: Implement support for these types.
var unsupportedTypeToStringMap = map[Type]string{
	TYPE_INVALID:  "INVALID",
	TYPE_UHUGEINT: "UHUGEINT",
	TYPE_ARRAY:    "ARRAY",
	TYPE_UNION:    "UNION",
	TYPE_BIT:      "BIT",
	TYPE_ANY:      "ANY",
	TYPE_VARINT:   "VARINT",
}

I'm currently implementing the ARRAY type. I can look afterward and either add the expected error or implement UNION support (if you don't want to pick that up yourself 😄 ).

@taniabogatsch taniabogatsch added bug Something isn't working feature [feature] request or PR labels Nov 7, 2024
@taniabogatsch taniabogatsch changed the title Now results for union type No results for UNION type Nov 7, 2024
@jorinvo
Copy link
Author

jorinvo commented Nov 7, 2024

@taniabogatsch thanks for the fast reply! Good to know it's simply not supported yet.
I don't have time at the moment, but I could look at it in a couple of weeks. I am not familiar with the codebase yet though. I would appreciate it a lot if you get around to implement UNION types, but understand if it's not a focus for you :)

@taniabogatsch
Copy link
Collaborator

Fair, sounds good :) - I'll let you know here if I find the time to pick it up. 👍

@jorinvo
Copy link
Author

jorinvo commented Nov 7, 2024

Thank you 👍

@NewtonVan
Copy link

Hi @jorinvo! This is likely because we do not yet support the UNION type in this driver. However, I would have expected an error (unsupported type) message instead of an empty result.

In https://github.com/marcboeker/go-duckdb/blob/a32843693a7b014008d6514a13dcda3e13dccb99/type.go#L51C1-L60C2.

// FIXME: Implement support for these types.
var unsupportedTypeToStringMap = map[Type]string{
	TYPE_INVALID:  "INVALID",
	TYPE_UHUGEINT: "UHUGEINT",
	TYPE_ARRAY:    "ARRAY",
	TYPE_UNION:    "UNION",
	TYPE_BIT:      "BIT",
	TYPE_ANY:      "ANY",
	TYPE_VARINT:   "VARINT",
}

I'm currently implementing the ARRAY type. I can look afterward and either add the expected error or implement UNION support (if you don't want to pick that up yourself 😄 ).

Hi @taniabogatsch,
Thank you so much for your ongoing work on go-duckdb, especially for implementing support for VSS operations. I noticed that go-duckdb currently doesn't support the ARRAY type, but I understand that you're working on adding this functionality.

I just wanted to express my gratitude for your efforts and let you know that once the Array type support is available, I'd really appreciate it if you could let me know here in this issue. If it's possible, I would be happy to contribute and help with resolving this issue.

Looking forward to the update, and thanks again for all your hard work!

@taniabogatsch
Copy link
Collaborator

Hi @NewtonVan - thank you for your kind words! I have already merged ARRAY type support; this is the PR: #306. I haven't worked on the UNION type yet. If anything happens there, then I'll drop a comment here.

We have yet to release a new tagged go-duckdb version, including that ARRAY PR. We usually try to align go-duckdb releases with duckdb releases to some extent. Until then, you could try out the ARRAY type on the latest main branch - maybe there are some bugs that we can fix until the next release. 😄

@NewtonVan
Copy link

Hi @taniabogatsch,

Thank you so much for the update and for merging the ARRAY type support! I'm really excited to try it out. Thanks again for your efforts ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature [feature] request or PR
Projects
None yet
Development

No branches or pull requests

3 participants