Skip to content

materialized view weird issue #448

Closed

Description

@bozerkins

i created first table:
CREATE TABLE test.a ( a UInt64, b UInt64) ENGINE = TinyLog;

then second one:
CREATE TABLE test.b ( b UInt64) ENGINE = TinyLog;

then a materialized view with some random SQL:

CREATE MATERIALIZED VIEW test.view_4 ( bb UInt64, cnt UInt64) POPULATE AS 
SELECT
   bb,
   count() AS cnt 
FROM
   (
      SELECT
         a,
         b AS j,
         b AS bb 
      FROM
         test.a ANY 
         INNER JOIN
            (
               SELECT
                  b AS j,
                  b AS bb 
               FROM
                  b 
            )
            USING (j)
   )
GROUP BY
   bb;

then i run an SQL to insert data into "a" table:
insert into a (a,b) values (1,2);

and got an error:
Received exception from server:
Code: 10. DB::Exception: Received from localhost:9000, 127.0.0.1. DB::Exception: Not found column bb in block. There are only columns: a, b.

That's probably bad.
Some thoughts:
apart from i cannot really understand why there's an error, it could be nice if materialized views didn't prevent from inserting data into original tables (when, for example, there's smth wrong with sql)

Activity

  1. hatarist commented on Feb 3, 2017

    @hatarist
    Contributor

    Perhaps related? #127

  2. bozerkins commented on Feb 3, 2017

    @bozerkins
    ContributorAuthor

    possible

  3. blinkov commented on Jul 13, 2018

    @blinkov
    Contributor

    Still reproducible with recent clickhouse-server.

  4. self-assigned this
    on Apr 9, 2019
  5. added
    comp-materialized-view
    on May 6, 2019
  6. deleted a comment from stale on Nov 25, 2019
  7. filimonov commented on Nov 25, 2019

    @filimonov
    Contributor

    Still here at 19.18.1-testing:

    CREATE TABLE test.a ( a UInt64, b UInt64) ENGINE = TinyLog;
    
    CREATE TABLE test.b ( b UInt64) ENGINE = TinyLog;
    
    CREATE MATERIALIZED VIEW test.view_4 ( bb UInt64, cnt UInt64) Engine=MergeTree ORDER BY bb POPULATE AS SELECT bb, count() AS cnt FROM (SELECT a, b AS j, b AS bb FROM test.a INNER JOIN (SELECT b AS j, b AS bb FROM test.b ) USING (j)) GROUP BY bb;
    
    insert into a (a,b) values (1,2);
    
    Received exception from server (version 19.18.1):
    Code: 16. DB::Exception: Received from localhost:9000. DB::Exception: No such column a in table a. Stack trace:
    
    0. 0x55768a673060 StackTrace::StackTrace() /build/obj-x86_64-linux-gnu/../dbms/src/Common/StackTrace.cpp:228
    1. 0x55768a672e35 DB::Exception::Exception(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) /build/obj-x86_64-linux-gnu/../dbms/src/Common/Exception.h:27
    2. 0x55768a39b02d DB::InterpreterInsertQuery::getSampleBlock(DB::ASTInsertQuery const&, std::shared_ptr<DB::IStorage> const&) [clone .cold] /usr/include/c++/9/bits/basic_string.h:222
    3. 0x55768dab3e85 DB::InterpreterInsertQuery::execute() /build/obj-x86_64-linux-gnu/../dbms/src/Interpreters/InterpreterInsertQuery.cpp:129
    4. 0x55768dbfb99e DB::executeQueryImpl(char const*, char const*, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool, DB::ReadBuffer*, bool) /build/obj-x86_64-linux-gnu/../dbms/src/Interpreters/executeQuery.cpp:319
    5. 0x55768dbfcdee DB::executeQuery(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool, bool) /usr/include/c++/9/bits/shared_ptr_base.h:1180
    6. 0x55768a6fbb64 DB::TCPHandler::runImpl() /build/obj-x86_64-linux-gnu/../dbms/programs/server/TCPHandler.cpp:247
    7. 0x55768a6fc59b DB::TCPHandler::run() /build/obj-x86_64-linux-gnu/../dbms/programs/server/TCPHandler.cpp:1239
    8. 0x55768e6a4fa0 Poco::Net::TCPServerConnection::start() /build/obj-x86_64-linux-gnu/../contrib/poco/Net/src/TCPServerConnection.cpp:57
    9. 0x55768e6a56bd Poco::Net::TCPServerDispatcher::run() /usr/include/c++/9/bits/atomic_base.h:327
    10. 0x55768fd7b831 Poco::PooledThread::run() /usr/include/x86_64-linux-gnu/c++/9/bits/gthr-default.h:748
    11. 0x55768fd795dc Poco::ThreadImpl::runnableEntry(void*) /build/obj-x86_64-linux-gnu/../contrib/poco/Foundation/include/Poco/AutoPtr.h:205
    12. 0x5576904ef740 execute_native_thread_routine /usr/lib/debug/usr/bin/clickhouse
    13. 0x7f965be676db start_thread /lib/x86_64-linux-gnu/libpthread-2.27.so
    14. 0x7f965b78488f clone /build/glibc-OTsEL5/glibc-2.27/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:97
    
  8. knoguchi commented on Mar 23, 2020

    @knoguchi
    Contributor

    It worked in 20.3.4.10. Btw table b needs data before insert into a to trigger the MV.

  9. removed their assignment
    on Oct 16, 2020
  10. added
    comp-joins
    unexpected behaviour
    on May 31, 2021
  11. JosephRedfern commented on Mar 17, 2024

    @JosephRedfern
    Contributor

    I think this issue has been resolved, I can't reproduce under ClickHouse server version 24.3.1.

  12. added a commit that references this issue on Apr 10, 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

    comp-joinscomp-materialized-viewunexpected behaviour

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions