| 17 | } |
| 18 | |
| 19 | BlockIO InterpreterAlterDiskCacheQuery::execute() |
| 20 | { |
| 21 | const auto & query = query_ptr->as<ASTAlterDiskCacheQuery &>(); |
| 22 | /// apply settings |
| 23 | if (query.settings_ast) |
| 24 | { |
| 25 | InterpreterSetQuery(query.settings_ast, getContext()).executeForCurrentContext(); |
| 26 | } |
| 27 | |
| 28 | StoragePtr table = DatabaseCatalog::instance().getTable({query.database, query.table}, getContext()); |
| 29 | auto * storage = dynamic_cast<StorageCnchMergeTree *>(table.get()); |
| 30 | if (!storage) |
| 31 | throw Exception("Preload only support CnchMergeTree engine", ErrorCodes::LOGICAL_ERROR); |
| 32 | |
| 33 | ServerDataPartsVector parts; |
| 34 | if (query.partition) |
| 35 | { |
| 36 | String partition_id = storage->getPartitionIDFromQuery(query.partition, getContext()); |
| 37 | parts = getContext()->getCnchCatalog()->getServerDataPartsInPartitions(table, {partition_id}, getContext()->getTimestamp(), nullptr); |
| 38 | } |
| 39 | else |
| 40 | { |
| 41 | parts = storage->getAllPartsWithDBM(getContext()).first; |
| 42 | } |
| 43 | parts = CnchPartsHelper::calcVisibleParts(parts, false); |
| 44 | |
| 45 | if (query.type == ASTAlterDiskCacheQuery::Type::PRELOAD) |
| 46 | { |
| 47 | storage->sendPreloadTasks(getContext(), std::move(parts), query.sync, getContext()->getSettings().parts_preload_level, time(nullptr)); |
| 48 | } |
| 49 | else if (query.type == ASTAlterDiskCacheQuery::Type::DROP) |
| 50 | { |
| 51 | storage->sendDropDiskCacheTasks(getContext(), std::move(parts), query.sync, getContext()->getSettings().drop_vw_disk_cache); |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | throw Exception("Unknown alter disk cache query type", ErrorCodes::NOT_IMPLEMENTED); |
| 56 | } |
| 57 | |
| 58 | return {}; |
| 59 | } |
| 60 | } |
nothing calls this directly
no test coverage detected