Coder Social home page Coder Social logo

Comments (6)

kryonix avatar kryonix commented on September 23, 2024 2

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.

redneb avatar redneb commented on September 23, 2024

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.

redneb avatar redneb commented on September 23, 2024

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.

kryonix avatar kryonix commented on September 23, 2024

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.

Mytherin avatar Mytherin commented on September 23, 2024

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.

ggPeti avatar ggPeti commented on September 23, 2024

As a workaround, I used unnest(range(...)).

from duckdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.