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

CURRENT_TIMESTAMP + INTERVAL 1 DAY fails #11949

Closed
2 tasks done
ankrgyl opened this issue May 5, 2024 · 5 comments
Closed
2 tasks done

CURRENT_TIMESTAMP + INTERVAL 1 DAY fails #11949

ankrgyl opened this issue May 5, 2024 · 5 comments

Comments

@ankrgyl
Copy link
Contributor

ankrgyl commented May 5, 2024

What happens?

In DuckDB wasm, which maps to

library_version
: 
"v0.10.2"
source_id
: 
"1601d94f94"

(this maps to duckdb-wasm 1.28.1-dev190.0. I've also tested 1.28.1-dev181.0, which fails the same way).

SELECT CURRENT_TIMESTAMP + INTERVAL 1 DAY

returns

Error: Binder Error: No function matches the given name and argument types '+(TIMESTAMP WITH TIME ZONE, INTERVAL)'. You might need to add explicit type casts.
	Candidate functions:
	+(TINYINT) -> TINYINT
	+(TINYINT, TINYINT) -> TINYINT
	+(SMALLINT) -> SMALLINT
	+(SMALLINT, SMALLINT) -> SMALLINT
	+(INTEGER) -> INTEGER
	+(INTEGER, INTEGER) -> INTEGER
	+(BIGINT) -> BIGINT
	+(BIGINT, BIGINT) -> BIGINT
	+(HUGEINT) -> HUGEINT
	+(HUGEINT, HUGEINT) -> HUGEINT
	+(FLOAT) -> FLOAT
	+(FLOAT, FLOAT) -> FLOAT
	+(DOUBLE) -> DOUBLE
	+(DOUBLE, DOUBLE) -> DOUBLE
	+(DECIMAL) -> DECIMAL
	+(DECIMAL, DECIMAL) -> DECIMAL
	+(UTINYINT) -> UTINYINT
	+(UTINYINT, UTINYINT) -> UTINYINT
	+(USMALLINT) -> USMALLINT
	+(USMALLINT, USMALLINT) -> USMALLINT
	+(UINTEGER) -> UINTEGER
	+(UINTEGER, UINTEGER) -> UINTEGER
	+(UBIGINT) -> UBIGINT
	+(UBIGINT, UBIGINT) -> UBIGINT
	+(UHUGEINT) -> UHUGEINT
	+(UHUGEINT, UHUGEINT) -> UHUGEINT
	+(DATE, INTEGER) -> DATE
	+(INTEGER, DATE) -> DATE
	+(INTERVAL, INTERVAL) -> INTERVAL
	+(DATE, INTERVAL) -> TIMESTAMP
	+(INTERVAL, DATE) -> TIMESTAMP
	+(TIME, INTERVAL) -> TIME
	+(INTERVAL, TIME) -> TIME
	+(TIMESTAMP, INTERVAL) -> TIMESTAMP
	+(INTERVAL, TIMESTAMP) -> TIMESTAMP
	+(TIME WITH TIME ZONE, INTERVAL) -> TIME WITH TIME ZONE
	+(INTERVAL, TIME WITH TIME ZONE) -> TIME WITH TIME ZONE
	+(TIME, DATE) -> TIMESTAMP
	+(DATE, TIME) -> TIMESTAMP
	+(TIME WITH TIME ZONE, DATE) -> TIMESTAMP WITH TIME ZONE
	+(DATE, TIME WITH TIME ZONE) -> TIMESTAMP WITH TIME ZONE
	+(ANY[], ANY[]) -> ANY[]

This does not repro with the DuckDB cli, however.

v0.10.2 1601d94f94
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D SELECT CURRENT_TIMESTAMP + INTERVAL 1 DAY;
┌──────────────────────────────────────────────────────────────────────────┐
│ (CURRENT_TIMESTAMP + to_days(CAST(trunc(CAST(1 AS DOUBLE)) AS INTEGER))) │
│                         timestamp with time zone                         │
├──────────────────────────────────────────────────────────────────────────┤
│ 2024-05-06 11:37:45.643-07                                               │
└──────────────────────────────────────────────────────────────────────────┘

To Reproduce

See repro above

OS:

mac os x

DuckDB Version:

library_version : "v0.10.2" source_id : "1601d94f94"

DuckDB Client:

wasm

Full Name:

Ankur Goyal

Affiliation:

Braintrust Data Inc

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

Did you include all relevant data sets for reproducing the issue?

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

  • Yes, I have
@hawkfish
Copy link
Contributor

hawkfish commented May 5, 2024

Ah you probably need to load the ICU extension. It works from the command line (which loads ICU and parquet by default):

(.venv) hawkfish@Richards-MacBook-Pro-5 duckdb % duckdb  
v0.10.2 1601d94f94
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
D SELECT CURRENT_TIMESTAMP + INTERVAL 1 DAY;
┌──────────────────────────────────────────────────────────────────────────┐
│ (CURRENT_TIMESTAMP + to_days(CAST(trunc(CAST(1 AS DOUBLE)) AS INTEGER))) │
│                         timestamp with time zone                         │
├──────────────────────────────────────────────────────────────────────────┤
│ 2024-05-06 11:54:28.147-07                                               │
└──────────────────────────────────────────────────────────────────────────┘

@ankrgyl
Copy link
Contributor Author

ankrgyl commented May 5, 2024

Interesting, that does appear to fix it. @carlopi is there any reason not to include this by default in duckdb-wasm?

@szarnyasg szarnyasg transferred this issue from duckdb/duckdb May 6, 2024
@szarnyasg szarnyasg transferred this issue from duckdb/duckdb-wasm May 6, 2024
@szarnyasg
Copy link
Collaborator

szarnyasg commented May 6, 2024

Thanks, this is an auto-loading issue with the icu library - we'll take a look. For now, you can run:

LOAD icu;
SELECT CURRENT_TIMESTAMP + INTERVAL 1 DAY;

@carlopi
Copy link
Contributor

carlopi commented May 6, 2024

Hi! This problem is connected to a limitation of autoloading when dealing with functions overloads.

duckdb-wasm do not bundle the ICU extension (and there is a chance that even the CLI or other clients will eventually stop bundling it by default).
User side the second-best way to mimic library being bundled in is explicitly load it, possibly during initialization.

@ankrgyl
Copy link
Contributor Author

ankrgyl commented May 6, 2024

User side the second-best way to mimic library being bundled in is explicitly load it, possibly during initialization.

Got it. We are just doing LOAD and INSTALL client-side (in the user's browser). Does that make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants