| 65 | } |
| 66 | |
| 67 | QueryPipelineBuilder InterpreterWatchQuery::buildQueryPipeline() |
| 68 | { |
| 69 | const ASTWatchQuery & query = typeid_cast<const ASTWatchQuery &>(*query_ptr); |
| 70 | auto table_id = getContext()->resolveStorageID(query, Context::ResolveOrdinary); |
| 71 | |
| 72 | /// Get storage |
| 73 | storage = DatabaseCatalog::instance().tryGetTable(table_id, getContext()); |
| 74 | |
| 75 | if (!storage) |
| 76 | throw Exception(ErrorCodes::UNKNOWN_TABLE, "Table {} does not exist.", table_id.getNameForLogs()); |
| 77 | |
| 78 | auto storage_name = storage->getName(); |
| 79 | if (storage_name == "WindowView" && !getContext()->getSettingsRef()[Setting::allow_experimental_window_view]) |
| 80 | throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, |
| 81 | "Experimental WINDOW VIEW feature is not enabled (the setting 'allow_experimental_window_view')"); |
| 82 | |
| 83 | /// List of columns to read to execute the query. |
| 84 | auto metadata_snapshot = storage->getInMemoryMetadataPtr(getContext(), false); |
| 85 | Names required_columns = metadata_snapshot->getColumns().getNamesOfPhysical(); |
| 86 | getContext()->checkAccess(AccessType::SELECT, table_id, required_columns); |
| 87 | |
| 88 | /// Get context settings for this query |
| 89 | const Settings & settings = getContext()->getSettingsRef(); |
| 90 | |
| 91 | /// Limitation on the number of columns to read. |
| 92 | if (settings[Setting::max_columns_to_read] && required_columns.size() > settings[Setting::max_columns_to_read]) |
| 93 | throw Exception( |
| 94 | ErrorCodes::TOO_MANY_COLUMNS, |
| 95 | "Limit for number of columns to read exceeded. " |
| 96 | "Requested: {}, maximum: {}", |
| 97 | required_columns.size(), |
| 98 | settings[Setting::max_columns_to_read].toString()); |
| 99 | |
| 100 | size_t max_block_size = settings[Setting::max_block_size]; |
| 101 | size_t max_streams = 1; |
| 102 | |
| 103 | /// Define query info |
| 104 | SelectQueryInfo query_info; |
| 105 | query_info.query = query_ptr; |
| 106 | |
| 107 | /// From stage |
| 108 | QueryProcessingStage::Enum from_stage = QueryProcessingStage::FetchColumns; |
| 109 | |
| 110 | /// Watch storage |
| 111 | auto pipe = storage->watch(required_columns, query_info, getContext(), from_stage, max_block_size, max_streams); |
| 112 | |
| 113 | QueryPipelineBuilder pipeline; |
| 114 | pipeline.init(std::move(pipe)); |
| 115 | return pipeline; |
| 116 | } |
| 117 | |
| 118 | void registerInterpreterWatchQuery(InterpreterFactory & factory); |
| 119 | void registerInterpreterWatchQuery(InterpreterFactory & factory) |
no test coverage detected