Comments (6)
I don't want to run the expensive computation multiple times. A CTE seemed like the right choice [...]
A non-materialized CTE will not do what you are trying to achieve. You will have to use a materialized CTE:
WITH t1(a) AS MATERIALIZED [...]
from duckdb.
An additional experiment: Since it is complaining that the second argument of generate_series
is a VARCHAR
, let's try to explicitly cast it to an int
:
> WITH t1(a) AS (SELECT 7) SELECT * FROM t1, generate_series(1, a::int);
Conversion Error: Could not convert string 'a' to INT32
LINE 1: ... SELECT * FROM t1, generate_series(1, a::int);
^
So it thinks that the column name, i.e. a
, is the string 'a'
!
from duckdb.
Also:
> SELECT * FROM (SELECT 7 AS a) t1, generate_series(1, a);
Binder Error: No function matches the given name and argument types 'generate_series(INTEGER, VARCHAR)'. You might need to add explicit type casts.
Candidate functions:
generate_series(BIGINT)
generate_series(BIGINT, BIGINT)
generate_series(BIGINT, BIGINT, BIGINT)
generate_series(TIMESTAMP, TIMESTAMP, INTERVAL)
generate_series(TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH TIME ZONE, INTERVAL)
LINE 1: SELECT * FROM (SELECT 7 AS a) t1, generate_series(1, a);
^
So it is not specific to CTEs as I originally thought.
from duckdb.
This is a known issue currently. See also: #10927. It is currently not possible to use columns of the (here: implicit) lateral join as input parameters.
from duckdb.
As mentioned this is currently an expected restriction - but the error message is very confusing. I've added a more clear error message in #11436.
from duckdb.
As a workaround, I used unnest(range(...))
.
from duckdb.
Related Issues (20)
- Signal 11 during tests
- CTE with "multiple recursive references" produces incomplete results. HOT 2
- Error when Merging Parquet Files with Nested Structs Containing Different Keys
- `replacement_scan` not working anymore after 1.1.0 HOT 3
- strptime function fails with the error "strptime format must be a constant" when format parameter is not provided as a constant
- Cannot reference user defined type across schemas
- CentOS install error HOT 1
- Cross schema TYPE reference broken HOT 2
- Unexpected values when using alias that happens to be a (joined) column name HOT 8
- Performance issue with SET VARIABLE HOT 5
- `ignore_errors` parameter is causing data loss during `TOO MANY COLUMNS` error type HOT 1
- JSON Import Error: Incorrect Parsing of ISO 8601 Date Strings with 'T' Separator HOT 2
- FROM generate_series(_,_) generates error in CASE statement because of deficient static type checking (generate_series() should probably in any case be more like range()) HOT 5
- Terminal UTF-8 display issues on Windows HOT 2
- Seeing a single value changed after inserting ~1.5million row polars df to duckdb and then querying back out HOT 4
- Unexpected result when casting `TIMESTAMP_S` to `TIME`
- CASE statements in TABLE MACRO HOT 2
- copy with read_csv produces syntax error HOT 3
- CASE checks non-switched expression HOT 1
- documentation about recursive functions (CREATE FUNCTION)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from duckdb.