aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/TableFunctions/TableFunctionMeiliSearch.cpp
blob: 01840a80262e944682a5f1da6941b429e4c2e2a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <memory>
#include <Parsers/ASTFunction.h>
#include <Storages/MeiliSearch/StorageMeiliSearch.h>
#include <TableFunctions/TableFunctionFactory.h>
#include <TableFunctions/TableFunctionMeiliSearch.h>
#include <Common/Exception.h>

namespace DB
{
StoragePtr TableFunctionMeiliSearch::executeImpl(
    const ASTPtr & /* ast_function */, ContextPtr /*context*/, const String & table_name, ColumnsDescription /*cached_columns*/, bool /*is_insert_query*/) const
{
    return std::make_shared<StorageMeiliSearch>(
        StorageID(getDatabaseName(), table_name), configuration.value(), ColumnsDescription{}, ConstraintsDescription{}, String{});
}

ColumnsDescription TableFunctionMeiliSearch::getActualTableStructure(ContextPtr /* context */, bool /*is_insert_query*/) const
{
    return StorageMeiliSearch::getTableStructureFromData(configuration.value());
}


void TableFunctionMeiliSearch::parseArguments(const ASTPtr & ast_function, ContextPtr context)
{
    const auto & func_args = ast_function->as<ASTFunction &>();
    configuration = StorageMeiliSearch::getConfiguration(func_args.arguments->children, context);
}

void registerTableFunctionMeiliSearch(TableFunctionFactory & factory)
{
    factory.registerFunction<TableFunctionMeiliSearch>();
}

}