aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/TableFunctions/TableFunctionHDFSCluster.cpp
blob: 0b531d913252f28e169413e3e77027a6e35834a0 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "clickhouse_config.h"

#if USE_HDFS

#include <TableFunctions/TableFunctionHDFSCluster.h>
#include <TableFunctions/TableFunctionFactory.h>

#include <Storages/HDFS/StorageHDFSCluster.h>
#include <Storages/HDFS/StorageHDFS.h>
#include "registerTableFunctions.h"

#include <memory>


namespace DB
{

StoragePtr TableFunctionHDFSCluster::getStorage(
    const String & /*source*/, const String & /*format_*/, const ColumnsDescription & columns, ContextPtr context,
    const std::string & table_name, const String & /*compression_method_*/) const
{
    StoragePtr storage;
    if (context->getClientInfo().query_kind == ClientInfo::QueryKind::SECONDARY_QUERY)
    {
        /// On worker node this uri won't contains globs
        storage = std::make_shared<StorageHDFS>(
            filename,
            StorageID(getDatabaseName(), table_name),
            format,
            columns,
            ConstraintsDescription{},
            String{},
            context,
            compression_method,
            /*distributed_processing=*/true,
            nullptr);
    }
    else
    {
        storage = std::make_shared<StorageHDFSCluster>(
            context,
            cluster_name,
            filename,
            StorageID(getDatabaseName(), table_name),
            format,
            columns,
            ConstraintsDescription{},
            compression_method,
            structure != "auto");
    }
    return storage;
}

void registerTableFunctionHDFSCluster(TableFunctionFactory & factory)
{
    factory.registerFunction<TableFunctionHDFSCluster>();
}

}

#endif