diff --git a/dbms/src/TableFunctions/ITableFunction.h b/dbms/src/TableFunctions/ITableFunction.h index d1d4e9be3c4543cf14f31b0b713f43508eddf27b..d9cf2f3507d027e9f4b4d6a8b5c393bdf1d54d51 100644 --- a/dbms/src/TableFunctions/ITableFunction.h +++ b/dbms/src/TableFunctions/ITableFunction.h @@ -32,7 +32,7 @@ public: virtual std::string getName() const = 0; /// Create storage according to the query - virtual StoragePtr execute(ASTPtr ast_function, Context & context) const = 0; + virtual StoragePtr execute(ASTPtr ast_function, const Context & context) const = 0; virtual ~ITableFunction() {}; }; diff --git a/dbms/src/TableFunctions/TableFunctionFactory.cpp b/dbms/src/TableFunctions/TableFunctionFactory.cpp index 9d1279090878c05c6e3b4acbfaba0d7ff53b12f2..2629773d5db9e7c4e423da2612b0a4d61f3343da 100644 --- a/dbms/src/TableFunctions/TableFunctionFactory.cpp +++ b/dbms/src/TableFunctions/TableFunctionFactory.cpp @@ -25,9 +25,9 @@ TableFunctionPtr TableFunctionFactory::get( if (context.getSettings().limits.readonly == 1) /** For example, for readonly = 2 - allowed. */ throw Exception("Table functions are forbidden in readonly mode", ErrorCodes::READONLY); - if (name == "merge") return std::make_shared(); - else if (name == "remote") return std::make_shared(); - else if (name == "shardByHash") return std::make_shared(); + if (name == "merge") return std::make_shared(); + else if (name == "remote") return std::make_shared(); + else if (name == "shardByHash") return std::make_shared(); else throw Exception("Unknown table function " + name, ErrorCodes::UNKNOWN_FUNCTION); } diff --git a/dbms/src/TableFunctions/TableFunctionMerge.cpp b/dbms/src/TableFunctions/TableFunctionMerge.cpp index 64521f96e577937c50173b26b7d4afad12374691..80102fbfbd9c7e5981a7cc62dc87c24f78ec6c12 100644 --- a/dbms/src/TableFunctions/TableFunctionMerge.cpp +++ b/dbms/src/TableFunctions/TableFunctionMerge.cpp @@ -53,7 +53,7 @@ static NamesAndTypesList chooseColumns(const String & source_database, const Str } -StoragePtr TableFunctionMerge::execute(ASTPtr ast_function, Context & context) const +StoragePtr TableFunctionMerge::execute(ASTPtr ast_function, const Context & context) const { ASTs & args_func = typeid_cast(*ast_function).children; diff --git a/dbms/src/TableFunctions/TableFunctionMerge.h b/dbms/src/TableFunctions/TableFunctionMerge.h index aa40a3e9beee2dd050a31207fd5a66e17fc4c58c..fd8ea29be149ccf86240154fd295b5d9a9cb4fd8 100644 --- a/dbms/src/TableFunctions/TableFunctionMerge.h +++ b/dbms/src/TableFunctions/TableFunctionMerge.h @@ -6,8 +6,7 @@ namespace DB { -/* - * merge (db_name, tables_regexp) - creates a temporary StorageMerge. +/* merge (db_name, tables_regexp) - creates a temporary StorageMerge. * The structure of the table is taken from the first table that came up, suitable for regexp. * If there is no such table, an exception is thrown. */ @@ -15,7 +14,7 @@ class TableFunctionMerge: public ITableFunction { public: std::string getName() const override { return "merge"; } - StoragePtr execute(ASTPtr ast_function, Context & context) const override; + StoragePtr execute(ASTPtr ast_function, const Context & context) const override; }; diff --git a/dbms/src/TableFunctions/TableFunctionRemote.cpp b/dbms/src/TableFunctions/TableFunctionRemote.cpp index ecfcd850c7ebc33cde131fe8bef582ef0d41a0c6..77bcb3aeae289edd4c051659fc82b166a185131d 100644 --- a/dbms/src/TableFunctions/TableFunctionRemote.cpp +++ b/dbms/src/TableFunctions/TableFunctionRemote.cpp @@ -146,7 +146,8 @@ static std::vector parseDescription(const String & description, size_t l } buffer.push_back(cur); } - } else if (have_splitter) /// If there is a current delimiter inside, then generate a set of resulting rows + } + else if (have_splitter) /// If there is a current delimiter inside, then generate a set of resulting rows buffer = parseDescription(description, i + 1, m, separator, max_addresses); else /// Otherwise just copy, spawn will occur when you call with the correct delimiter buffer.push_back(description.substr(i, m - i + 1)); @@ -168,15 +169,17 @@ static std::vector parseDescription(const String & description, size_t l append(cur, buffer, max_addresses); } } + res.insert(res.end(), cur.begin(), cur.end()); if (res.size() > max_addresses) throw Exception("Storage Distributed, first argument generates too many result addresses", - ErrorCodes::BAD_ARGUMENTS); + ErrorCodes::BAD_ARGUMENTS); + return res; } -StoragePtr TableFunctionRemote::execute(ASTPtr ast_function, Context & context) const +StoragePtr TableFunctionRemote::execute(ASTPtr ast_function, const Context & context) const { ASTs & args_func = typeid_cast(*ast_function).children; diff --git a/dbms/src/TableFunctions/TableFunctionRemote.h b/dbms/src/TableFunctions/TableFunctionRemote.h index 56a1b21e20dcaa1ec8a3edf9915f12136ac770d0..1efa423cf77ad6b0eb498378ddaf30fd4ad95e34 100644 --- a/dbms/src/TableFunctions/TableFunctionRemote.h +++ b/dbms/src/TableFunctions/TableFunctionRemote.h @@ -6,8 +6,7 @@ namespace DB { -/* - * remote ('address', db, table) - creates a temporary StorageDistributed. +/* remote ('address', db, table) - creates a temporary StorageDistributed. * To get the table structure, a DESC TABLE request is made to the remote server. * For example * SELECT count() FROM remote('example01-01-1', merge, hits) - go to `example01-01-1`, in the merge database, the hits table. @@ -17,7 +16,7 @@ class TableFunctionRemote : public ITableFunction { public: std::string getName() const override { return "remote"; } - StoragePtr execute(ASTPtr ast_function, Context & context) const override; + StoragePtr execute(ASTPtr ast_function, const Context & context) const override; }; } diff --git a/dbms/src/TableFunctions/TableFunctionShardByHash.cpp b/dbms/src/TableFunctions/TableFunctionShardByHash.cpp index d337bc0f03a23b49e8ed61b85f8ef1a9b349a850..9dc41977ea6d068b439d0247d0f9c162f83a2c35 100644 --- a/dbms/src/TableFunctions/TableFunctionShardByHash.cpp +++ b/dbms/src/TableFunctions/TableFunctionShardByHash.cpp @@ -20,7 +20,7 @@ namespace ErrorCodes extern const int BAD_ARGUMENTS; } -StoragePtr TableFunctionShardByHash::execute(ASTPtr ast_function, Context & context) const +StoragePtr TableFunctionShardByHash::execute(ASTPtr ast_function, const Context & context) const { ASTs & args_func = typeid_cast(*ast_function).children; diff --git a/dbms/src/TableFunctions/TableFunctionShardByHash.h b/dbms/src/TableFunctions/TableFunctionShardByHash.h index 64bc8531a5ac76f0b5d9c4fe134598f495c18c39..6436f87b0a3b71be0303b7e341b4ef5eb36d8424 100644 --- a/dbms/src/TableFunctions/TableFunctionShardByHash.h +++ b/dbms/src/TableFunctions/TableFunctionShardByHash.h @@ -15,7 +15,7 @@ class TableFunctionShardByHash : public ITableFunction { public: std::string getName() const override { return "shardByHash"; } - StoragePtr execute(ASTPtr ast_function, Context & context) const override; + StoragePtr execute(ASTPtr ast_function, const Context & context) const override; }; }