| 606 | } |
| 607 | |
| 608 | void ExpressionAnalyzer::checkSample(ASTPtr & ast, std::map<String, size_t> & sampled_table) |
| 609 | { |
| 610 | if (!ast) |
| 611 | return; |
| 612 | |
| 613 | if (ASTSelectQuery * select = typeid_cast<ASTSelectQuery *>(ast.get())) |
| 614 | { |
| 615 | if (select->sampleSize()) |
| 616 | { |
| 617 | auto db_and_table = getDatabaseAndTable(*select, 0); |
| 618 | if (!db_and_table.has_value()) |
| 619 | return; |
| 620 | auto select_database = db_and_table->database; |
| 621 | auto select_table = db_and_table->table; |
| 622 | String db_and_table_key = ""; |
| 623 | |
| 624 | if (!select_table.empty()) |
| 625 | { |
| 626 | String database = !select_database.empty() ? select_database : "default"; |
| 627 | db_and_table_key = database + ":" + select_table; |
| 628 | } |
| 629 | |
| 630 | if (!db_and_table_key.empty()) |
| 631 | { |
| 632 | sampled_table[db_and_table_key] += 1; |
| 633 | |
| 634 | // If offset is provided, disable sample optimization |
| 635 | if (select->sampleOffset()) |
| 636 | sampled_table[db_and_table_key] += 1; |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | for (auto & child : ast->children) |
| 642 | checkSample(child, sampled_table); |
| 643 | } |
| 644 | |
| 645 | bool ExpressionAnalyzer::hasByteMapColumn() const |
| 646 | { |
nothing calls this directly
no test coverage detected