SET allow_experimental_statistics=1, optimize_move_to_prewhere=1, move_all_conditions_to_prewhere=1, enable_multiple_prewhere_read_steps=1, move_primary_key_columns_to_end_of_prewhere=1, allow_reorder_prewhere_conditions=1, allow_statistics_optimize=1, allow_suspicious_low_cardinality_types=1;
CREATE TABLE test_improve_prewhere__fuzz_19 (`primary_key` String STATISTICS(CountMin), `normal_column` String STATISTICS(CountMin), `value` LowCardinality(UInt32) STATISTICS(TDigest), `date` LowCardinality(Nullable(Date)) STATISTICS(CountMin)) ENGINE = MergeTree ORDER BY primary_key;
INSERT INTO test_improve_prewhere__fuzz_19 SELECT hex(number % 100) AS primary_key, ['hello', 'world', 'test', 'example', 'sample'][(number % 5) + 1] AS normal_column, (number % 1000) + 1 AS value, toDate('2025-08-01') + number AS date FROM numbers(10);
EXPLAIN SELECT * FROM test_improve_prewhere__fuzz_19 WHERE (date = '2025-08-05') AND (lower(primary_key) = '00') AND (normal_column != 'hello') AND (value < 100);
2025.09.30 07:39:03.559910 [ 2740919 ] {7595f875-0c2c-4a0a-8ad9-9d9a72e0f1b2} <Fatal> : Logical error: 'Statistics 'countmin' does not support estimate data type of LowCardinality(Nullable(Date))'.
2025.09.30 07:39:03.737766 [ 2740919 ] {7595f875-0c2c-4a0a-8ad9-9d9a72e0f1b2} <Fatal> : Stack trace (when copying this message, always include the lines below):
0. /home/avogar/ClickHouse/contrib/llvm-project/libcxx/include/__exception/exception.h:113: Poco::Exception::Exception(String const&, int) @ 0x00000000251c2e32
1. /home/avogar/ClickHouse/src/Common/Exception.cpp:128: DB::Exception::Exception(DB::Exception::MessageMasked&&, int, bool) @ 0x00000000127ba45e
2. /home/avogar/ClickHouse/src/Common/Exception.h:123: DB::Exception::Exception(String&&, int, String, bool) @ 0x000000000b505d4e
3. /home/avogar/ClickHouse/src/Common/Exception.h:58: DB::Exception::Exception(PreformattedMessage&&, int) @ 0x000000000b505785
4. /home/avogar/ClickHouse/src/Common/Exception.h:141: DB::Exception::Exception<String>(int, FormatStringHelperImpl<std::type_identity<String>::type>, String&&) @ 0x000000000b5053ab
5. /home/avogar/ClickHouse/src/Storages/Statistics/StatisticsCountMinSketch.cpp:52: DB::StatisticsCountMinSketch::estimateEqual(DB::Field const&) const @ 0x000000001d00d2c3
6. /home/avogar/ClickHouse/src/Storages/Statistics/ConditionSelectivityEstimator.cpp:279: DB::ConditionSelectivityEstimator::RPNElement::finalize(std::unordered_map<String, DB::ConditionSelectivityEstimator::ColumnEstimator, std::hash<String>, std::equal_to<String>, std::allocator<std::pair<String const, DB::ConditionSelectivityEstimator::ColumnEstimator>>> const&) @ 0x000000001cffe3cc
7. /home/avogar/ClickHouse/src/Storages/Statistics/ConditionSelectivityEstimator.cpp:123: DB::ConditionSelectivityEstimator::estimateRelationProfileImpl(std::vector<DB::ConditionSelectivityEstimator::RPNElement, std::allocator<DB::ConditionSelectivityEstimator::RPNElement>>&) const @ 0x000000001cffdea1
8. /home/avogar/ClickHouse/src/Storages/Statistics/ConditionSelectivityEstimator.cpp:52: DB::ConditionSelectivityEstimator::estimateRelationProfile(DB::RPNBuilderTreeNode const&) const @ 0x000000001cffe120
9. /home/avogar/ClickHouse/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp:357: DB::MergeTreeWhereOptimizer::analyzeImpl(std::list<DB::MergeTreeWhereOptimizer::Condition, std::allocator<DB::MergeTreeWhereOptimizer::Condition>>&, DB::RPNBuilderTreeNode const&, DB::MergeTreeWhereOptimizer::WhereOptimizerContext const&, std::set<long, std::less<long>, std::allocator<long>>&) const @ 0x000000001ce77bd2
10. /home/avogar/ClickHouse/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp:324: DB::MergeTreeWhereOptimizer::analyzeImpl(std::list<DB::MergeTreeWhereOptimizer::Condition, std::allocator<DB::MergeTreeWhereOptimizer::Condition>>&, DB::RPNBuilderTreeNode const&, DB::MergeTreeWhereOptimizer::WhereOptimizerContext const&, std::set<long, std::less<long>, std::allocator<long>>&) const @ 0x000000001ce77a1a
11. /home/avogar/ClickHouse/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp:388: DB::MergeTreeWhereOptimizer::analyze(DB::RPNBuilderTreeNode const&, DB::MergeTreeWhereOptimizer::WhereOptimizerContext const&) const @ 0x000000001ce79417
12. /home/avogar/ClickHouse/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp:437: DB::MergeTreeWhereOptimizer::optimizeImpl(DB::RPNBuilderTreeNode const&, DB::MergeTreeWhereOptimizer::WhereOptimizerContext const&) const @ 0x000000001ce76276
13. /home/avogar/ClickHouse/src/Storages/MergeTree/MergeTreeWhereOptimizer.cpp:169: DB::MergeTreeWhereOptimizer::optimize(DB::ActionsDAG const&, String const&, std::shared_ptr<DB::Context const> const&, bool) @ 0x000000001ce773f1
14. /home/avogar/ClickHouse/src/Processors/QueryPlan/Optimizations/optimizePrewhere.cpp:189: DB::QueryPlanOptimizations::optimizePrewhere(std::vector<DB::QueryPlanOptimizations::Frame, std::allocator<DB::QueryPlanOptimizations::Frame>>&, std::list<DB::QueryPlan::Node, std::allocator<DB::QueryPlan::Node>>&) @ 0x000000001d9fbc9e
15. /home/avogar/ClickHouse/src/Processors/QueryPlan/Optimizations/optimizeTree.cpp:195: DB::QueryPlanOptimizations::optimizeTreeSecondPass(DB::QueryPlanOptimizationSettings const&, DB::QueryPlan::Node&, std::list<DB::QueryPlan::Node, std::allocator<DB::QueryPlan::Node>>&, DB::QueryPlan&) @ 0x000000001d9f50d3
16. /home/avogar/ClickHouse/src/Processors/QueryPlan/QueryPlan.cpp:499: DB::QueryPlan::optimize(DB::QueryPlanOptimizationSettings const&) @ 0x000000001d90f208
17. /home/avogar/ClickHouse/src/Interpreters/InterpreterExplainQuery.cpp:577: DB::InterpreterExplainQuery::executeImpl() @ 0x0000000019655c55
18. /home/avogar/ClickHouse/src/Interpreters/InterpreterExplainQuery.cpp:143: DB::InterpreterExplainQuery::execute() @ 0x0000000019653de9
19. /home/avogar/ClickHouse/src/Interpreters/executeQuery.cpp:1594: DB::executeQueryImpl(char const*, char const*, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum, std::unique_ptr<DB::ReadBuffer, std::default_delete<DB::ReadBuffer>>&, std::shared_ptr<DB::IAST>&, std::shared_ptr<DB::ImplicitTransactionControlExecutor>) @ 0x00000000199e44f6
20. /home/avogar/ClickHouse/src/Interpreters/executeQuery.cpp:1803: DB::executeQuery(String const&, std::shared_ptr<DB::Context>, DB::QueryFlags, DB::QueryProcessingStage::Enum) @ 0x00000000199de2bc
21. /home/avogar/ClickHouse/src/Client/LocalConnection.cpp:271: DB::LocalConnection::sendQuery(DB::ConnectionTimeouts const&, String const&, std::unordered_map<String, String, std::hash<String>, std::equal_to<String>, std::allocator<std::pair<String const, String>>> const&, String const&, unsigned long, DB::Settings const*, DB::ClientInfo const*, bool, std::vector<String, std::allocator<String>> const&, std::function<void (DB::Progress const&)>) @ 0x000000001d1edc67
22. /home/avogar/ClickHouse/src/Client/ClientBase.cpp:1262: DB::ClientBase::processOrdinaryQuery(String, std::shared_ptr<DB::IAST>) @ 0x000000001d17583b
23. /home/avogar/ClickHouse/src/Client/ClientBase.cpp:2305: DB::ClientBase::processParsedSingleQuery(std::basic_string_view<char, std::char_traits<char>>, std::shared_ptr<DB::IAST>, bool&, unsigned long) @ 0x000000001d173d9d
24. /home/avogar/ClickHouse/src/Client/ClientBase.cpp:2680: DB::ClientBase::executeMultiQuery(String const&) @ 0x000000001d17f271
25. /home/avogar/ClickHouse/src/Client/ClientBase.cpp:2921: DB::ClientBase::processQueryText(String const&) @ 0x000000001d1805d2
26. /home/avogar/ClickHouse/src/Client/ClientBase.cpp:3625: DB::ClientBase::runInteractive() @ 0x000000001d188e2b
27. /home/avogar/ClickHouse/programs/local/LocalServer.cpp:0: DB::LocalServer::main(std::vector<String, std::allocator<String>> const&) @ 0x0000000012a878ea
28. /home/avogar/ClickHouse/base/poco/Util/src/Application.cpp:315: Poco::Util::Application::run() @ 0x000000002529aee6
29. /home/avogar/ClickHouse/programs/local/LocalServer.cpp:1178: mainEntryClickHouseLocal(int, char**) @ 0x0000000012a94b21
30. /home/avogar/ClickHouse/programs/main.cpp:380: main @ 0x000000000b4f90a7
31. __ieee754_pow_ifunc @ 0x0000000000029d90