Skip to content

Not found column in block error in array join #37729

Closed

Description

@mofei920

Describe what's wrong
join non first column of nest show Not found column in block error

How to reproduce
version: 22.3.2.1

CREATE TABLE nested_test
(
    s String,
    nest Nested
    (
        x UInt64,
        y UInt64
    )
) ENGINE = MergeTree
ORDER BY s;

CREATE TABLE join_test
(
    id Int64,
    y UInt64
)
ENGINE = MergeTree
ORDER BY id;

INSERT INTO nested_test
VALUES ('Hello', [1,2], [10,20]), ('World', [3,4,5], [30,40,50]), ('Goodbye', [], []);

INSERT INTO join_test
VALUES (1,1),(2,4),(3,20),(4,40);

when run the sql below, join on the first column of nest, there is no problem.

SELECT s
FROM nested_test t1 array join nest
  inner join join_test t2 on nest.x=t2.y;
┌─s─────┐
│ Hello │
│ World │
└───────┘

but when join on the second column of nest, show error as blow.

SELECT s
FROM nested_test t1 array join nest
  inner join join_test t2 on nest.y=t2.y;
Code: 10. DB::Exception: Received from host01:9000. DB::Exception: Not found column nest.y in block. There are only columns: s. (NOT_FOUND_COLUMN_IN_BLOCK)

Activity

  1. added
    potential bug
    on Jun 1, 2022
  2. added
    bug
    and removed
    potential bug
    on Jun 2, 2022
  3. novikd commented on Jun 2, 2022

    @novikd
    Member

    At the same moment this query works:

    SELECT *
    FROM nested_test AS t1
    ARRAY JOIN nest
    INNER JOIN join_test AS t2 ON nest.y = join_test.y
  4. self-assigned this
    on Jun 3, 2022
  5. mofei920 commented on Jun 6, 2022

    @mofei920
    Author

    yes, but we just want to select the only one column.

    actually, SELECT s,nest.y also works.

    SELECT s,nest.y
    FROM nested_test t1 array join nest
    inner join join_test t2 on nest.y=t2.y;
    ┌─s─────┬─nest.y─┐
    │ Hello │ 20 │
    │ World │ 40 │
    └───────┴────────┘

  6. alexey-milovidov commented on Mar 1, 2023

    @alexey-milovidov
    Member

    Does not work with analyzer (yet):

    milovidov-desktop :) SET allow_experimental_analyzer = 1
    
    SET allow_experimental_analyzer = 1
    
    Query id: 447e6686-689f-4978-a182-c1f6404d08bd
    
    Ok.
    
    0 rows in set. Elapsed: 0.000 sec. 
    
    milovidov-desktop :) SELECT s
                         FROM nested_test t1 array join nest
                           inner join join_test t2 on nest.y=t2.y;
    
    SELECT s
    FROM nested_test AS t1
    ARRAY JOIN nest
    INNER JOIN join_test AS t2 ON nest.y = t2.y
    
    Query id: c6c5c481-7552-40d3-9b1a-d7c1facde4f3
    
    
    0 rows in set. Elapsed: 0.026 sec. 
    
    Received exception:
    Code: 49. DB::Exception: Bad cast from type DB::FunctionNode to DB::ColumnNode. (LOGICAL_ERROR)
    
  7. added a commit that references this issue on Apr 2, 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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions