Skip to content

Enable global WITH by default - #18705

Closed
alexey-milovidov wants to merge 1 commit into
masterfrom
global-with-by-default
Closed

alexey-milovidov wants to merge 1 commit into
masterfrom
global-with-by-default

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Backward Incompatible Change

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Set enable_global_with_statement setting to 1 by default. It is compatible with standard SQL.

Detailed description / Documentation draft:
It is so much better.

@robot-clickhouse robot-clickhouse added the pr-backward-incompatible Pull request with backwards incompatible changes label Jan 4, 2021
@alexey-milovidov

Copy link
Copy Markdown
Member Author

@amosbird Bug has been found:

2021-01-04 04:12:29 01556_explain_select_with_union_query:                                  [ FAIL ] - return code 49
2021-01-04 04:12:29 [c8983001e5f5] 2021.01.04 04:12:29.925229 [ 39807 ] {ebb034f1-3215-4cc1-855d-a3df990aedd2} <Error> executeQuery: Code: 49, e.displayText() = DB::Exception: Bad cast from type DB::ASTSelectWithUnionQuery to DB::ASTSelectQuery (version 20.13.1.1) (from [::1]:39880) (in query: EXPLAIN (SELECT 1 UNION ALL SELECT 1) UNION ALL SELECT 1; ), Stack trace (when copying this message, always include the lines below):
2021-01-04 04:12:29 
2021-01-04 04:12:29 0. /fasttest-workspace/build/../../ClickHouse/contrib/libcxx/include/exception:129: Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0xb04ba0c in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 1. /fasttest-workspace/build/../../ClickHouse/src/Common/Exception.cpp:55: DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x4e91e6d in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 2. /fasttest-workspace/build/../../ClickHouse/src/Common/typeid_cast.h:0: std::__1::enable_if<std::is_reference_v<DB::ASTSelectQuery&>, DB::ASTSelectQuery&>::type typeid_cast<DB::ASTSelectQuery&, DB::IAST>(DB::IAST&) @ 0x9e409cc in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 3. /fasttest-workspace/build/../../ClickHouse/contrib/libcxx/include/__hash_table:799: DB::ApplyWithGlobalVisitor::visit(std::__1::shared_ptr<DB::IAST>&) @ 0xa6c2a6c in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 4. /fasttest-workspace/build/../../ClickHouse/contrib/libcxx/include/iterator:1480: DB::ApplyWithGlobalVisitor::visit(std::__1::shared_ptr<DB::IAST>&) @ 0xa6c2b48 in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 5. /fasttest-workspace/build/../../ClickHouse/contrib/libcxx/include/memory:3824: DB::executeQueryImpl(char const*, char const*, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool, DB::ReadBuffer*) @ 0xa6b78fa in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 6. /fasttest-workspace/build/../../ClickHouse/src/Interpreters/executeQuery.cpp:868: DB::executeQuery(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, DB::Context&, bool, DB::QueryProcessingStage::Enum, bool) @ 0xa6b6df9 in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 7. /fasttest-workspace/build/../../ClickHouse/src/Server/TCPHandler.cpp:0: DB::TCPHandler::runImpl() @ 0xab97349 in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 8. /fasttest-workspace/build/../../ClickHouse/src/Server/TCPHandler.cpp:0: DB::TCPHandler::run() @ 0xaba0227 in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 9. /fasttest-workspace/build/../../ClickHouse/contrib/poco/Net/src/TCPServerConnection.cpp:57: Poco::Net::TCPServerConnection::start() @ 0xaf48cb7 in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 10. /fasttest-workspace/build/../../ClickHouse/contrib/libcxx/include/atomic:1036: Poco::Net::TCPServerDispatcher::run() @ 0xaf490d3 in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 11. /fasttest-workspace/build/../../ClickHouse/contrib/poco/Foundation/include/Poco/ScopedLock.h:36: Poco::PooledThread::run() @ 0xb0a3ae9 in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 12. /fasttest-workspace/build/../../ClickHouse/contrib/poco/Foundation/include/Poco/SharedPtr.h:156: Poco::ThreadImpl::runnableEntry(void*) @ 0xb0a1b96 in /fasttest-workspace/build/programs/clickhouse
2021-01-04 04:12:29 13. start_thread @ 0x9609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
2021-01-04 04:12:29 14. __clone @ 0x122293 in /usr/lib/x86_64-linux-gnu/libc-2.31.so
2021-01-04 04:12:29 
2021-01-04 04:12:29 Received exception from server (version 20.13.1):
2021-01-04 04:12:29 Code: 49. DB::Exception: Received from localhost:9000. DB::Exception: Bad cast from type DB::ASTSelectWithUnionQuery to DB::ASTSelectQuery. 

@amosbird

amosbird commented Jan 4, 2021

Copy link
Copy Markdown
Collaborator

How shall we handle cases like this:

WITH
    count() AS c,
    min(number) AS first,
    max(number) AS last
SELECT
    throwIf(first != if((97 < 79) AND (3 > 0), 97, 0)),
    throwIf(last != if((97 < 79) AND (3 > 0), least(79 - 1, (97 + 3) - 1), 0)),
    throwIf(((c != 0) OR (first != 0) OR (last != 0)) AND (c != ((last - first) + 1)))
FROM
(
    SELECT *
    FROM numbers(79)
    LIMIT 97, 3
)

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@amosbird

c, first, last will be substituted into outer side and inside the subquery.
But there are not usages of these names inside subquery, so the behaviour is not different than what we already have.

@amosbird

amosbird commented Jan 4, 2021

Copy link
Copy Markdown
Collaborator

@amosbird

c, first, last will be substituted into outer side and inside the subquery.
But there are not usages of these names inside subquery, so the behaviour is not different than what we already have.

But it will imply aggregation which breaks the inner query.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@amosbird But these names will not be substituted to the inner query, so no aggregation.

PS. I checked the example:

WITH sum(number) AS x SELECT * FROM numbers(10)

It gives:

DB::Exception: Column `number` is not under aggregate function and not in GROUP BY: While processing number.

It should not. I consider it as another bug.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Superseded by #18684.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backward-incompatible Pull request with backwards incompatible changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants