Skip to content

Unable to use CTE scalar as numbers() argument #8259

Closed

Description

@pablote

This is a simplification of what I'm trying to achieve:

with
    (select 25) as something
select *, something
from numbers(toUInt64(something));

It fails with error: Code: 47, e.displayText() = DB::Exception: Missing columns: 'something' while processing query: 'toUInt64(something)', required columns: 'something', source columns: '_dummy' (version 19.17.5.18 (official build))

Replace last line with a fixed value, and the query works fine. Is it not possible to use a CTE value as input to numbers()? Any workaround?

thanks!

Activity

  1. added
    bug
    on Dec 18, 2019
  2. lopn commented on Mar 15, 2020

    @lopn
      with
        (select 25) as something
    select toUInt64(something)
    
  3. amosbird commented on Sep 13, 2020

    @amosbird
    Collaborator

    It's because table functions are evaluated earlier than scalar subqueries, and in fact they don't take subqueries into account at all. However it's still a valid use case. You can switch it to a feature request and it might work in near future.

  4. added and removed
    bug
    on Sep 13, 2020
  5. andrewzolotukhin commented on Mar 7, 2022

    @andrewzolotukhin
    Contributor

    Would be great to have that...

  6. azat commented on Jan 23, 2024

    @azat
    Member

    This had been fixed in analyzer - #56337 (comment)

  7. added a commit that references this issue on Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions