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

Clickhouse refuse to execute sql with duplicated field: ... AS _snuba_rounded_timestamp_900), _snuba_rounded_timestamp_900, #6294

Open
yujiaao opened this issue Sep 12, 2024 · 1 comment

Comments

@yujiaao
Copy link

yujiaao commented Sep 12, 2024

Environment

self-hosted 24.8.0
clickhouse version: 24.6.1.4423

Steps to Reproduce

2024-09-11 17:28:22,892 Error running query: SELECT (toUInt32(multiply(intDiv(toUInt32((end_timestamp AS _snuba_end_timestamp)), 900.0), 900.0)) AS _snuba_rounded_timestamp_900), _snuba_rounded_timestamp_900, (groupArraySample(30, 1780965047)(((lower(hex(group)) AS _snuba_group), _snuba_end_timestamp, (lower(hex(span_id)) AS _snuba_span_id), (min AS _snuba_min), (max AS _snuba_max), (sum AS _snuba_sum), (count AS _snuba_count), (divide(_snuba_sum, _snuba_count) AS _snuba_avg_metric))) AS _snuba_examples) FROM metrics_summaries_local PREWHERE in((project_id AS _snuba_project_id), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 84, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) WHERE greaterOrEquals(_snuba_end_timestamp, toDateTime('2024-09-11T08:28:22', 'Universal')) AND less(_snuba_end_timestamp, toDateTime('2024-09-11T09:28:22', 'Universal')) AND equals((metric_mri AS _snuba_metric_mri), 'c:custom/autosentry.symbolicator.caches.file.miss@none') AND equals(cityHash64(_snuba_metric_mri), cityHash64('c:custom/autosentry.symbolicator.caches.file.miss@none')) GROUP BY _snuba_rounded_timestamp_900 LIMIT 21 OFFSET 0
DB::Exception: Unknown table expression identifier 'metrics_summaries_local' in scope SELECT toUInt32(intDiv(toUInt32(end_timestamp AS _snuba_end_timestamp), 900.) * 900.) AS _snuba_rounded_timestamp_900, _snuba_rounded_timestamp_900, groupArraySample(30, 1780965047)((lower(hex(group)) AS _snuba_group, _snuba_end_timestamp, lower(hex(span_id)) AS _snuba_span_id, min AS _snuba_min, max AS _snuba_max, sum AS _snuba_sum, count AS _snuba_count, _snuba_sum / _snuba_count AS _snuba_avg_metric)) AS _snuba_examples FROM metrics_summaries_local PREWHERE (project_id AS _snuba_project_id) IN [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 84, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100] WHERE (_snuba_end_timestamp >= toDateTime('2024-09-11T08:28:22', 'Universal')) AND (_snuba_end_timestamp < toDateTime('2024-09-11T09:28:22', 'Universal')) AND ((metric_mri AS _snuba_metric_mri) = 'c:custom/autosentry.symbolicator.caches.file.miss@none') AND (cityHash64(_snuba_metric_mri) = cityHash64('c:custom/autosentry.symbolicator.caches.file.miss@none')) GROUP BY _snuba_rounded_timestamp_900 LIMIT 0, 21. Stack trace:

0. DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x000000000cfc7c1b
1. DB::Exception::Exception(PreformattedMessage&&, int) @ 0x00000000078c70cc
2. DB::Exception::Exception<String const&, String>(int, FormatStringHelperImpl<std::type_identity<String const&>::type, std::type_identity<String>::type>, String const&, String&&) @ 0x0000000007f2aacb
3. DB::QueryAnalyzer::resolveQuery(std::shared_ptr<DB::IQueryTreeNode> const&, DB::IdentifierResolveScope&) @ 0x00000000113acbcf
4. DB::QueryAnalyzer::resolve(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::IQueryTreeNode> const&, std::shared_ptr<DB::Context const>) @ 0x00000000113a78ec
5. DB::QueryAnalysisPass::run(std::shared_ptr<DB::IQueryTreeNode>&, std::shared_ptr<DB::Context const>) @ 0x00000000113a7145
6. DB::QueryTreePassManager::run(std::shared_ptr<DB::IQueryTreeNode>) @ 0x00000000113a5df6
7. DB::(anonymous namespace)::buildQueryTreeAndRunPasses(std::shared_ptr<DB::IAST> const&, DB::SelectQueryOptions const&, std::shared_ptr<DB::Context const> const&, std::shared_ptr<DB::IStorage> const&) (.llvm.17364550013352150074) @ 0x000000001163b2bd
8. DB::InterpreterSelectQueryAnalyzer::InterpreterSelectQueryAnalyzer(std::shared_ptr<DB::IAST> const&, std::shared_ptr<DB::Context const> const&, DB::SelectQueryOptions const&, std::vector<String, std::allocator<String>> const&) @ 0x00000000116390dc
9. std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> std::__function::__policy_invoker<std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> (DB::InterpreterFactory::Arguments const&)>::__call_impl<std::__function::__default_alloc_func<DB::registerInterpreterSelectQueryAnalyzer(DB::InterpreterFactory&)::$_0, std::unique_ptr<DB::IInterpreter, std::default_delete<DB::IInterpreter>> (DB::InterpreterFactory::Arguments const&)>>(std::__function::__policy_storage const*, DB::InterpreterFactory::Arguments const&) (.llvm.17364550013352150074) @ 0x000000001163d0a2
10. DB::InterpreterFactory::get(std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::Context>, DB::SelectQueryOptions const&) @ 0x00000000115d100c
11. DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, DB::ReadBuffer*) @ 0x0000000011a23781
12. DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x0000000011a201da
13. DB::TCPHandler::runImpl() @ 0x0000000012a7dc8e
14. DB::TCPHandler::run() @ 0x0000000012a99678
15. Poco::Net::TCPServerConnection::start() @ 0x0000000015374bc7
16. Poco::Net::TCPServerDispatcher::run() @ 0x0000000015375059
17. Poco::PooledThread::run() @ 0x0000000015341d61
18. Poco::ThreadImpl::runnableEntry(void*) @ 0x000000001534031d
19. start_thread @ 0x0000000000007ea5
20. clone @ 0x00000000000fe96d
Traceback (most recent call last):
  File "/usr/src/snuba/snuba/clickhouse/native.py", line 200, in execute
    result_data = query_execute()
                  ^^^^^^^^^^^^^^^
  File "/usr/src/snuba/snuba/clickhouse/native.py", line 183, in query_execute
    return conn.execute(  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clickhouse_driver/client.py", line 373, in execute
    rv = self.process_ordinary_query(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clickhouse_driver/client.py", line 571, in process_ordinary_query
    return self.receive_result(with_column_types=with_column_types,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clickhouse_driver/client.py", line 204, in receive_result
    return result.get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clickhouse_driver/result.py", line 50, in get_result
    for packet in self.packet_generator:
  File "/usr/local/lib/python3.11/site-packages/clickhouse_driver/client.py", line 220, in packet_generator
    packet = self.receive_packet()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/clickhouse_driver/client.py", line 237, in receive_packet
    raise packet.exception
clickhouse_driver.errors.ServerException: Code: 60.
DB::Exception: Unknown table expression identifier 'metrics_summaries_local' in scope SELECT toUInt32(intDiv(toUInt32(end_timestamp AS _snuba_end_timestamp), 900.) * 900.) AS _snuba_rounded_timestamp_900, _snuba_rounded_timestamp_900, groupArraySample(30, 1780965047)((lower(hex(group)) AS _snuba_group, _snuba_end_timestamp, lower(hex(span_id)) AS _snuba_span_id, min AS _snuba_min, max AS _snuba_max, sum AS _snuba_sum, count AS _snuba_count, _snuba_sum / _snuba_count AS _snuba_avg_metric)) AS _snuba_examples FROM metrics_summaries_local PREWHERE (project_id AS _snuba_project_id) IN [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 84, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100] WHERE (_snuba_end_timestamp >= toDateTime('2024-09-11T08:28:22', 'Universal')) AND (_snuba_end_timestamp < toDateTime('2024-09-11T09:28:22', 'Universal')) AND ((metric_mri AS _snuba_metric_mri) = 'c:custom/autosentry.symbolicator.caches.file.miss@none') AND (cityHash64(_snuba_metric_mri) = cityHash64('c:custom/autosentry.symbolicator.caches.file.miss@none')) GROUP BY _snuba_rounded_timestamp_900 LIMIT 0, 21. Stack trace:

Expected Result

normal execute

Actual Result

error ocured

How to fix? please help

@mcannizz
Copy link
Member

Please provide steps to reproduce this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for: Community
Development

No branches or pull requests

2 participants