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

Cast INTERVAL and UUID to VARCHAR #12080

Closed
wants to merge 6 commits into from

Conversation

guenp
Copy link
Contributor

@guenp guenp commented May 15, 2024

Fixes MotherDuck-Open-Source/duckdb-power-query-connector#7.

Power Query/Power BI currently does not support INTERVAL and loading data with this type results in an error:

ODBC: ERROR [22007] ODBC_DuckDB->GetDataStmtResult Not implemented Error: Unimplemented type for cast (INTERVAL -> TIME)

Similarly, implementing a cast to TIME also won't work because in Power Query, valid values for TIME hours are 0-23.

UUID has a similar problem that it throws an "Unimplemented type for cast (UUID -> DOUBLE)` error.

This PR casts INTERVAL and UUID to VARCHAR by default. The INTERVAL value can be parsed separately in Power Query, for instance by using Duration.FromText (see docs).

image

@duckdb-draftbot duckdb-draftbot marked this pull request as draft May 16, 2024 00:11
@guenp guenp changed the title Cast INTERVAL to VARCHAR Cast INTERVAL and UUID to VARCHAR May 16, 2024
@guenp guenp marked this pull request as ready for review May 16, 2024 00:19
@guenp guenp marked this pull request as draft May 16, 2024 03:29
@Mytherin Mytherin requested a review from maiadegraaf May 16, 2024 07:00
@Mytherin
Copy link
Collaborator

Thanks for the PR! I wonder what the Postgres ODBC clients' behavior is, as they have the same interval type that we do. Do they just cast to VARCHAR as well or do something different? We should likely do what they do here.

@Mytherin
Copy link
Collaborator

Looks like they have an ifdef and likely turn it into varchar in regular releases as some applications don't handle the interval type correctly.

@guenp
Copy link
Contributor Author

guenp commented May 20, 2024

thanks @Mytherin for taking a look!
Indeed, it looks like Postgres doesn't offer interval support for the ODBC driver either:
https://github.com/hiinoue/psqlodbc/blob/f28b1dcc197c8775d6a34a419d73a0cfa97fa643/pgtypes.h#L82

/*
 *	SQL_INTERVAL support is disabled because I found
 *	some applications which are unhappy with it.
 *
#define	PG_INTERVAL_AS_SQL_INTERVAL
 */

I can't find anywhere in the code that they convert INTERVAL to VARCHAR so I wonder if it's simply not supported.

@guenp guenp marked this pull request as ready for review May 20, 2024 21:27
@duckdb-draftbot duckdb-draftbot marked this pull request as draft May 20, 2024 21:31
@maiadegraaf
Copy link
Contributor

Hi Guen, thanks for your PR, could you reopen it on the new ODBC repo?
Thanks!

@guenp
Copy link
Contributor Author

guenp commented May 22, 2024

@maiadegraaf yes of course! PR is open here

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

Successfully merging this pull request may close these issues.

Unimplemented type for cast (INTERVAL -> TIME)
3 participants