Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply some more optimizations to NO_QUERY ast. #32751

Merged
merged 4 commits into from
Dec 20, 2021
Merged

Conversation

KochetovNicolai
Copy link
Member

@KochetovNicolai KochetovNicolai commented Dec 14, 2021

Changelog category (leave one):

  • Bug Fix (user-visible misbehaviour in official stable or prestable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix error Column is not under aggregate function in case of MV with GROUP BY (list of columns) (which is pared as GROUP BY tuple(...)) over Kafka/RabbitMQ. Fixes #32668 and #32744

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Dec 14, 2021
@alexey-milovidov alexey-milovidov changed the title Allpy some more optimizations to NO_QUERY ast. Apply some more optimizations to NO_QUERY ast. Dec 14, 2021
@KochetovNicolai
Copy link
Member Author

@Mergifyio update

@mergify
Copy link
Contributor

mergify bot commented Dec 15, 2021

update

✅ Branch has been successfully updated

@KochetovNicolai
Copy link
Member Author

Looks like all test failures are temporary ci issues.

@loyd
Copy link
Contributor

loyd commented Jan 12, 2022

When will this be released?

@alexey-milovidov
Copy link
Member

@loyd

It is already available. You can install the latest version:

curl https://clickhouse.com/ | sh

@BhavyaRajSharma
Copy link

Tried below query with ch version 22.2 and 22.4. It still not working

SELECT
    a.spid,
    lat,
    lon,
    unc
FROM Staypoint AS a
where 
	spid in( 
	select distinct spid from
	(
		SELECT DISTINCT spid
		FROM
		(
			SELECT spid
			FROM Visit AS VIT
			WHERE (imsi IN (422030200099999)) AND (((visitstartdate <= '2020-11-01 00:18:19') OR (visitstartdate <= '2021-01-31 18:17:09')) AND ((visitenddate >= '2020-11-01 00:18:19') OR (visitenddate >= '2021-01-31 18:17:09')))
		)
		
		UNION ALL
		
		SELECT sspid
		FROM Trip AS TRIP1
		WHERE (imsi IN (422030200099999)) AND (((tripstartdate <= '2020-11-01 00:18:19') OR (tripstartdate <= '2021-01-31 18:17:09')) AND ((tripenddate >= '2020-11-01 00:18:19') OR (tripenddate >= '2021-01-31 18:17:09')))
		GROUP BY (tripstartdate, tripenddate, sspid, dspid)
		
	
	))
AND (imsi IN (422030200099999))
ORDER BY
    staypointstartdate DESC,
    staypointenddate DESC

Getting below exception

[DEV-BDSP-Worker-09] 2021.12.20 03:56:43.421801 [ 29503 ] {72a757f0-ae22-482b-8cd4-5dc90265c3b8} <Error> executeQuery: Code: 215. DB::Exception: Column `sspid` is not under aggregate function and not in GROUP BY: While processing sspid. (NOT_AN_AGGREGATE) (version 21.12.2.17 (official build)) (from [::ffff:10.49.3.111]:44374) (in query: SELECT a.spid, lat, lon, unc FROM dbpolaris1.Staypoint_local AS a WHERE (spid IN ((SELECT DISTINCT spid FROM (SELECT DISTINCT spid FROM (SELECT spid FROM Visit AS VIT WHERE (imsi IN (422030200099999)) AND (((visitstartdate <= '2020-11-01 00:18:19') OR (visitstartdate <= '2021-01-31 18:17:09')) AND ((visitenddate >= '2020-11-01 00:18:19') OR (visitenddate >= '2021-01-31 18:17:09')))) UNION ALL SELECT sspid FROM Trip AS TRIP1 WHERE (imsi IN (422030200099999)) AND (((tripstartdate <= '2020-11-01 00:18:19') OR (tripstartdate <= '2021-01-31 18:17:09')) AND ((tripenddate >= '2020-11-01 00:18:19') OR (tripenddate >= '2021-01-31 18:17:09'))) GROUP BY (tripstartdate, tripenddate, sspid, dspid))) AS _subquery16)) AND (imsi IN (422030200099999)) ORDER BY staypointstartdate DESC, staypointenddate DESC), Stack trace (when copying this message, always include the lines below):

0. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0xa20d85a in ?
1. DB::ActionsMatcher::visit(DB::ASTIdentifier const&, std::__1::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0x12f8e051 in ?
2. DB::ActionsMatcher::visit(DB::ASTExpressionList&, std::__1::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0x12f95f78 in ?
3. DB::InDepthNodeVisitor<DB::ActionsMatcher, true, false, std::__1::shared_ptr<DB::IAST> const>::visit(std::__1::shared_ptr<DB::IAST> const&) @ 0x12f64337 in ?
4. DB::ExpressionAnalyzer::getRootActions(std::__1::shared_ptr<DB::IAST> const&, bool, std::__1::shared_ptr<DB::ActionsDAG>&, bool) @ 0x12f64138 in ?
5. DB::SelectQueryExpressionAnalyzer::appendSelect(DB::ExpressionActionsChain&, bool) @ 0x12f6fa29 in ?
6. DB::ExpressionAnalysisResult::ExpressionAnalysisResult(DB::SelectQueryExpressionAnalyzer&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, bool, bool, bool, std::__1::shared_ptr<DB::FilterDAGInfo> const&, DB::Block const&) @ 0x12f746fd in ?
7. DB::InterpreterSelectQuery::getSampleBlockImpl() @ 0x132331a6 in ?
8. ? @ 0x1322bb0a in ?
9. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::unordered_map<DB::PreparedSetKey, std::__1::shared_ptr<DB::Set>, DB::PreparedSetKey::Hash, std::__1::equal_to<DB::PreparedSetKey>, std::__1::allocator<std::__1::pair<DB::PreparedSetKey const, std::__1::shared_ptr<DB::Set> > > >) @ 0x1322665a in ?
10. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x13224f14 in ?
11. DB::InterpreterSelectWithUnionQuery::buildCurrentChildInterpreter(std::__1::shared_ptr<DB::IAST> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327e282 in ?
12. DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327ca90 in ?
13. DB::InterpreterSelectWithUnionQuery::getSampleBlock(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, bool) @ 0x1327f01f in ?
14. DB::getDatabaseAndTablesWithColumns(std::__1::vector<DB::ASTTableExpression const*, std::__1::allocator<DB::ASTTableExpression const*> > const&, std::__1::shared_ptr<DB::Context const>, bool, bool) @ 0x134e5f47 in ?
15. DB::JoinedTables::resolveTables() @ 0x132a8b9f in ?
16. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::unordered_map<DB::PreparedSetKey, std::__1::shared_ptr<DB::Set>, DB::PreparedSetKey::Hash, std::__1::equal_to<DB::PreparedSetKey>, std::__1::allocator<std::__1::pair<DB::PreparedSetKey const, std::__1::shared_ptr<DB::Set> > > >) @ 0x13225c23 in ?
17. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x13224f14 in ?
18. DB::InterpreterSelectWithUnionQuery::buildCurrentChildInterpreter(std::__1::shared_ptr<DB::IAST> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327e282 in ?
19. DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327ca90 in ?
20. DB::interpretSubquery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, DB::SelectQueryOptions const&) @ 0x134eb975 in ?
21. DB::ExpressionAnalyzer::tryMakeSetForIndexFromSubquery(std::__1::shared_ptr<DB::IAST> const&, DB::SelectQueryOptions const&) @ 0x12f6334f in ?
22. DB::SelectQueryExpressionAnalyzer::makeSetsForIndex(std::__1::shared_ptr<DB::IAST> const&) @ 0x12f63d8b in ?
23. DB::SelectQueryExpressionAnalyzer::makeSetsForIndex(std::__1::shared_ptr<DB::IAST> const&) @ 0x12f63d8b in ?
24. DB::InterpreterSelectQuery::getSampleBlockImpl() @ 0x13233008 in ?
25. ? @ 0x1322bb0a in ?
26. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::unordered_map<DB::PreparedSetKey, std::__1::shared_ptr<DB::Set>, DB::PreparedSetKey::Hash, std::__1::equal_to<DB::PreparedSetKey>, std::__1::allocator<std::__1::pair<DB::PreparedSetKey const, std::__1::shared_ptr<DB::Set> > > >) @ 0x1322665a in ?
27. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x13224f14 in ?
28. DB::InterpreterSelectWithUnionQuery::buildCurrentChildInterpreter(std::__1::shared_ptr<DB::IAST> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327e282 in ?
29. DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327ca90 in ?
30. DB::InterpreterFactory::get(std::__1::shared_ptr<DB::IAST>&, std::__1::shared_ptr<DB::Context>, DB::SelectQueryOptions const&) @ 0x131c3056 in ?
31. ? @ 0x134cfb8d in ?

[DEV-BDSP-Worker-11] 2021.12.20 03:57:44.448404 [ 19548 ] {cae40ed1-fecf-4d2e-ad7f-ab4e28bec91e} <Error> executeQuery: Code: 215. DB::Exception: Received from 10.49.3.109:9100. DB::Exception: Column `sspid` is not under aggregate function and not in GROUP BY: While processing sspid. Stack trace:

0. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0xa20d85a in ?
1. DB::ActionsMatcher::visit(DB::ASTIdentifier const&, std::__1::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0x12f8e051 in ?
2. DB::ActionsMatcher::visit(DB::ASTExpressionList&, std::__1::shared_ptr<DB::IAST> const&, DB::ActionsMatcher::Data&) @ 0x12f95f78 in ?
3. DB::InDepthNodeVisitor<DB::ActionsMatcher, true, false, std::__1::shared_ptr<DB::IAST> const>::visit(std::__1::shared_ptr<DB::IAST> const&) @ 0x12f64337 in ?
4. DB::ExpressionAnalyzer::getRootActions(std::__1::shared_ptr<DB::IAST> const&, bool, std::__1::shared_ptr<DB::ActionsDAG>&, bool) @ 0x12f64138 in ?
5. DB::SelectQueryExpressionAnalyzer::appendSelect(DB::ExpressionActionsChain&, bool) @ 0x12f6fa29 in ?
6. DB::ExpressionAnalysisResult::ExpressionAnalysisResult(DB::SelectQueryExpressionAnalyzer&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, bool, bool, bool, std::__1::shared_ptr<DB::FilterDAGInfo> const&, DB::Block const&) @ 0x12f746fd in ?
7. DB::InterpreterSelectQuery::getSampleBlockImpl() @ 0x132331a6 in ?
8. ? @ 0x1322bb0a in ?
9. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::unordered_map<DB::PreparedSetKey, std::__1::shared_ptr<DB::Set>, DB::PreparedSetKey::Hash, std::__1::equal_to<DB::PreparedSetKey>, std::__1::allocator<std::__1::pair<DB::PreparedSetKey const, std::__1::shared_ptr<DB::Set> > > >) @ 0x1322665a in ?
10. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x13224f14 in ?
11. DB::InterpreterSelectWithUnionQuery::buildCurrentChildInterpreter(std::__1::shared_ptr<DB::IAST> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327e282 in ?
12. DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327ca90 in ?
13. DB::InterpreterSelectWithUnionQuery::getSampleBlock(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, bool) @ 0x1327f01f in ?
14. DB::getDatabaseAndTablesWithColumns(std::__1::vector<DB::ASTTableExpression const*, std::__1::allocator<DB::ASTTableExpression const*> > const&, std::__1::shared_ptr<DB::Context const>, bool, bool) @ 0x134e5f47 in ?
15. DB::JoinedTables::resolveTables() @ 0x132a8b9f in ?
16. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::unordered_map<DB::PreparedSetKey, std::__1::shared_ptr<DB::Set>, DB::PreparedSetKey::Hash, std::__1::equal_to<DB::PreparedSetKey>, std::__1::allocator<std::__1::pair<DB::PreparedSetKey const, std::__1::shared_ptr<DB::Set> > > >) @ 0x13225c23 in ?
17. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x13224f14 in ?
18. DB::InterpreterSelectWithUnionQuery::buildCurrentChildInterpreter(std::__1::shared_ptr<DB::IAST> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327e282 in ?
19. DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327ca90 in ?
20. DB::interpretSubquery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, DB::SelectQueryOptions const&) @ 0x134eb975 in ?
21. DB::ExpressionAnalyzer::tryMakeSetForIndexFromSubquery(std::__1::shared_ptr<DB::IAST> const&, DB::SelectQueryOptions const&) @ 0x12f6334f in ?
22. DB::SelectQueryExpressionAnalyzer::makeSetsForIndex(std::__1::shared_ptr<DB::IAST> const&) @ 0x12f63d8b in ?
23. DB::SelectQueryExpressionAnalyzer::makeSetsForIndex(std::__1::shared_ptr<DB::IAST> const&) @ 0x12f63d8b in ?
24. DB::InterpreterSelectQuery::getSampleBlockImpl() @ 0x13233008 in ?
25. ? @ 0x1322bb0a in ?
26. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, std::__1::optional<DB::Pipe>, std::__1::shared_ptr<DB::IStorage> const&, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, std::__1::shared_ptr<DB::StorageInMemoryMetadata const> const&, std::__1::unordered_map<DB::PreparedSetKey, std::__1::shared_ptr<DB::Set>, DB::PreparedSetKey::Hash, std::__1::equal_to<DB::PreparedSetKey>, std::__1::allocator<std::__1::pair<DB::PreparedSetKey const, std::__1::shared_ptr<DB::Set> > > >) @ 0x1322665a in ?
27. DB::InterpreterSelectQuery::InterpreterSelectQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x13224f14 in ?
28. DB::InterpreterSelectWithUnionQuery::buildCurrentChildInterpreter(std::__1::shared_ptr<DB::IAST> const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327e282 in ?
29. DB::InterpreterSelectWithUnionQuery::InterpreterSelectWithUnionQuery(std::__1::shared_ptr<DB::IAST> const&, std::__1::shared_ptr<DB::Context const>, DB::SelectQueryOptions const&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) @ 0x1327ca90 in ?
30. DB::InterpreterFactory::get(std::__1::shared_ptr<DB::IAST>&, std::__1::shared_ptr<DB::Context>, DB::SelectQueryOptions const&) @ 0x131c3056 in ?
31. ? @ 0x134cfb8d in ?
: While executing Remote. (NOT_AN_AGGREGATE) (version 21.9.2.17 (official build)) (from [::ffff:10.49.3.111]:60934) (in query: SELECT a.spid, lat, lon, unc FROM Staypoint AS a where spid in( select distinct spid from ( SELECT DISTINCT spid FROM ( SELECT spid FROM Visit AS VIT WHERE (imsi IN (422030200099999)) AND (((visitstartdate <= '2020-11-01 00:18:19') OR (visitstartdate <= '2021-01-31 18:17:09')) AND ((visitenddate >= '2020-11-01 00:18:19') OR (visitenddate >= '2021-01-31 18:17:09'))) ) UNION ALL SELECT sspid FROM Trip AS TRIP1 WHERE (imsi IN (422030200099999)) AND (((tripstartdate <= '2020-11-01 00:18:19') OR (tripstartdate <= '2021-01-31 18:17:09')) AND ((tripenddate >= '2020-11-01 00:18:19') OR (tripenddate >= '2021-01-31 18:17:09'))) GROUP BY (tripstartdate, tripenddate, sspid, dspid) )) AND (imsi IN (422030200099999)) ORDER BY staypointstartdate DESC, staypointenddate DESC ;), Stack trace (when copying this message, always include the lines below):

0. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int, bool) @ 0x9366e7a in ?
1. DB::readException(DB::ReadBuffer&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) @ 0x93c77f4 in ?
2. DB::Connection::receiveException() const @ 0x116cd6e2 in ?
3. DB::Connection::receivePacket() @ 0x116d7429 in ?
4. DB::PacketReceiver::Routine::operator()(boost::context::fiber&&) @ 0x116f033b in ?
5. void boost::context::detail::fiber_entry<boost::context::detail::fiber_record<boost::context::fiber, FiberStack&, DB::PacketReceiver::Routine> >(boost::context::detail::transfer_t) @ 0x116f014e in ?


0 rows in set. Elapsed: 0.081 sec.

Received exception from server (version 21.9.2):
Code: 215. DB::Exception: Received from 10.49.3.111:9100. DB::Exception: Received from 10.49.3.109:9100. DB::Exception: Column `sspid` is not under aggregate function and not in GROUP BY: While processing sspid. (NOT_AN_AGGREGATE)

@matiasdominguez
Copy link

The error is still happening to me in 22.8.2.11. Fixed it by removing the parens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix Pull request with bugfix, not backported by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReplacingMergeTree Materialized view based on kafka topics becoming empty after migrating to 21.11
6 participants