pgduckdb_get_querydef() ignores certain type conversion
- Dominant language
- C++
- Stars
- 3.2k
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
### What happens?
Certain type conversions are ignored by `pgduckdb_get_querydef()`, resulting in the query not runnable by DuckDB
### To Reproduce
```sql
SET duckdb.force_execution TO true;
WITH t as (SELECT chr((126983+i)::int) FROM generate_series(0,26) t(i)) SELECT * FROM t; -- warning
```
throws warning
```
WARNING: (PGDuckDB/CreatePlan) Prepared query returned an error: 'Binder Error: No function matches the given name and argument types 'chr(BIGINT)'. You might need to add explicit type casts.
Candidate functions:
chr(INTEGER) -> VARCHAR
```
because `pgduckdb_get_querydef()` ignores the type conversion in `(126983+i)::int`
### OS:
Linux
### pg_duckdb Version (if built from source use commit hash):
0.2.0
### Postgres Version (if built from source use commit hash):
17.2
### Hardware:
_No response_
### Full Name:
Cheng Chen
### Affiliation:
Mooncake Labs
### 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?
Not applicable - the reproduction does not require a data set
### Did you include all code required to reproduce the issue?
- [x] Yes, I have
### Did you include all relevant configuration (e.g., CPU architecture, Linux distribution) to reproduce the issue?
- [x] Yes, I have
Contributor guide
Research direction
Start at pgduckdb_get_querydef() and reproduce the issue with the supplied SQL against the stated PostgreSQL and pg_duckdb versions. Trace how the explicit ::int conversion in (126983+i)::int is represented in the generated DuckDB query. Done means the query runs without the chr(BIGINT) binder warning and the conversion is preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100