mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #29667 from ClickHouse/clickhouse-obfuscator-embedded-dictionaries
Fix issue: clickhouse-format --obfuscate cannot process queries with embedded dictionaries
This commit is contained in:
commit
59fdfd18db
@ -110,10 +110,6 @@ int mainEntryClickHouseFormat(int argc, char ** argv)
|
||||
hash_func.update(options["seed"].as<std::string>());
|
||||
}
|
||||
|
||||
SharedContextHolder shared_context = Context::createShared();
|
||||
auto context = Context::createGlobal(shared_context.get());
|
||||
context->makeGlobalContext();
|
||||
|
||||
registerFunctions();
|
||||
registerAggregateFunctions();
|
||||
registerTableFunctions();
|
||||
@ -131,7 +127,7 @@ int mainEntryClickHouseFormat(int argc, char ** argv)
|
||||
{
|
||||
std::string what(name);
|
||||
|
||||
return FunctionFactory::instance().tryGet(what, context) != nullptr
|
||||
return FunctionFactory::instance().has(what)
|
||||
|| AggregateFunctionFactory::instance().isAggregateFunctionName(what)
|
||||
|| TableFunctionFactory::instance().isTableFunctionName(what)
|
||||
|| additional_names.count(what);
|
||||
|
@ -87,6 +87,15 @@ FunctionOverloadResolverPtr FunctionFactory::get(
|
||||
return getImpl(name, context);
|
||||
}
|
||||
|
||||
bool FunctionFactory::has(const std::string & name) const
|
||||
{
|
||||
String canonical_name = getAliasToOrName(name);
|
||||
if (functions.contains(canonical_name))
|
||||
return true;
|
||||
canonical_name = Poco::toLower(canonical_name);
|
||||
return case_insensitive_functions.contains(canonical_name);
|
||||
}
|
||||
|
||||
FunctionOverloadResolverPtr FunctionFactory::tryGetImpl(
|
||||
const std::string & name_param,
|
||||
ContextPtr context) const
|
||||
|
@ -43,6 +43,8 @@ public:
|
||||
/// This function is used by YQL - internal Yandex product that depends on ClickHouse by source code.
|
||||
std::vector<std::string> getAllNames() const;
|
||||
|
||||
bool has(const std::string & name) const;
|
||||
|
||||
/// Throws an exception if not found.
|
||||
FunctionOverloadResolverPtr get(const std::string & name, ContextPtr context) const;
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
SELECT regionToName(203), regionToCountry(203)
|
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_FORMAT --seed Hello --obfuscate <<< "SELECT regionToName(213), regionToCountry(213)"
|
Loading…
Reference in New Issue
Block a user