aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/TableFunctions/TableFunctionURLCluster.h
blob: be6992fcaaf119c232ee602872f6e90b664120ec (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
#pragma once

#include <TableFunctions/ITableFunctionFileLike.h>
#include <TableFunctions/TableFunctionURL.h>
#include <TableFunctions/ITableFunctionCluster.h>
#include <Storages/StorageURL.h>
#include <Storages/StorageURLCluster.h>
#include <IO/ReadWriteBufferFromHTTP.h>


namespace DB
{

class Context;

/**
 * urlCluster(cluster, URI, format, structure, compression_method)
 * A table function, which allows to process many files from url on a specific cluster
 * On initiator it creates a connection to _all_ nodes in cluster, discloses asterics
 * in url file path and dispatch each file dynamically.
 * On worker node it asks initiator about next task to process, processes it.
 * This is repeated until the tasks are finished.
 */
class TableFunctionURLCluster : public ITableFunctionCluster<TableFunctionURL>
{
public:
    static constexpr auto name = "urlCluster";
    static constexpr auto signature = " - cluster, uri\n"
                                      " - cluster, uri, format\n"
                                      " - cluster, uri, format, structure\n"
                                      " - cluster, uri, format, structure, compression_method\n"
                                      "All signatures supports optional headers (specified as `headers('name'='value', 'name2'='value2')`)";

    String getName() const override
    {
        return name;
    }

    String getSignature() const override
    {
        return signature;
    }

protected:
    StoragePtr getStorage(
        const String & source, const String & format_, const ColumnsDescription & columns, ContextPtr global_context,
        const std::string & table_name, const String & compression_method_) const override;

    const char * getStorageTypeName() const override { return "URLCluster"; }
};

}