MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / executeImpl

Method executeImpl

src/TableFunctions/TableFunctionMergeTreeTextIndex.cpp:95–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95StoragePtr TableFunctionMergeTreeTextIndex::executeImpl(
96 const ASTPtr & /*ast_function*/,
97 ContextPtr context,
98 const std::string & table_name,
99 ColumnsDescription /*cached_columns*/,
100 bool is_insert_query) const
101{
102 auto source_table_ptr = DatabaseCatalog::instance().getTable(StorageID{source_database, source_table}, context);
103 auto metadata_snapshot = source_table_ptr->getInMemoryMetadataPtr(context, false);
104 const auto & index_desc = metadata_snapshot->getSecondaryIndices().getByName(source_index_name);
105
106 if (index_desc.type != "text")
107 throw Exception(
108 ErrorCodes::BAD_ARGUMENTS,
109 "Got index '{}' of type '{}', expected 'text'",
110 source_index_name, index_desc.type);
111
112 const auto * merge_tree = dynamic_cast<const MergeTreeData *>(source_table_ptr.get());
113 if (!merge_tree)
114 throw Exception(ErrorCodes::BAD_ARGUMENTS, "Storage MergeTreeTextIndex expected MergeTree table, got: {}", source_table_ptr->getName());
115
116 auto text_index = MergeTreeIndexFactory::instance().get(metadata_snapshot, index_desc, *merge_tree->getSettings());
117 auto columns = getActualTableStructure(context, is_insert_query);
118 StorageID storage_id(getDatabaseName(), table_name);
119
120 auto res = std::make_shared<StorageMergeTreeTextIndex>(
121 std::move(storage_id),
122 std::move(source_table_ptr),
123 std::move(text_index),
124 std::move(columns));
125
126 res->startup();
127 return res;
128}
129
130void registerTableFunctionMergeTreeTextIndex(TableFunctionFactory & factory);
131void registerTableFunctionMergeTreeTextIndex(TableFunctionFactory & factory)

Callers

nothing calls this directly

Calls 8

getByNameMethod · 0.80
ExceptionClass · 0.50
getTableMethod · 0.45
getMethod · 0.45
getNameMethod · 0.45
getSettingsMethod · 0.45
startupMethod · 0.45

Tested by

no test coverage detected