mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-21 09:10:48 +00:00
dbms: added function regionToPopulation; clickhouse-server, ███████████, ███████████, ███████████ needs to be released before regions_hierarchy.txt change [#METR-13326].
This commit is contained in:
parent
96ef141c8a
commit
c5635ce6d9
@ -63,6 +63,11 @@ struct RegionToContinentImpl
|
||||
static UInt32 apply(UInt32 x, const RegionsHierarchy & hierarchy) { return hierarchy.toContinent(x); }
|
||||
};
|
||||
|
||||
struct RegionToPopulationImpl
|
||||
{
|
||||
static UInt32 apply(UInt32 x, const RegionsHierarchy & hierarchy) { return hierarchy.getPopulation(x); }
|
||||
};
|
||||
|
||||
struct OSToRootImpl
|
||||
{
|
||||
static UInt8 apply(UInt8 x, const TechDataHierarchy & hierarchy) { return hierarchy.OSToMostAncestor(x); }
|
||||
@ -500,6 +505,7 @@ struct NameRegionToArea { static constexpr auto name = "regionToArea"; };
|
||||
struct NameRegionToDistrict { static constexpr auto name = "regionToDistrict"; };
|
||||
struct NameRegionToCountry { static constexpr auto name = "regionToCountry"; };
|
||||
struct NameRegionToContinent { static constexpr auto name = "regionToContient"; };
|
||||
struct NameRegionToPopulation { static constexpr auto name = "regionToPopulation"; };
|
||||
struct NameOSToRoot { static constexpr auto name = "OSToRoot"; };
|
||||
struct NameSEToRoot { static constexpr auto name = "SEToRoot"; };
|
||||
struct NameCategoryToRoot { static constexpr auto name = "categoryToRoot"; };
|
||||
@ -561,6 +567,15 @@ struct FunctionRegionToContinent :
|
||||
}
|
||||
};
|
||||
|
||||
struct FunctionRegionToPopulation :
|
||||
public FunctionTransformWithDictionary<UInt32, RegionToPopulationImpl, RegionsHierarchyGetter, NameRegionToPopulation>
|
||||
{
|
||||
static IFunction * create(const Context & context)
|
||||
{
|
||||
return new base_type{context.getDictionaries().getRegionsHierarchies()};
|
||||
}
|
||||
};
|
||||
|
||||
struct FunctionOSToRoot :
|
||||
public FunctionTransformWithDictionary<UInt8, OSToRootImpl, IdentityDictionaryGetter<TechDataHierarchy>, NameOSToRoot>
|
||||
{
|
||||
|
@ -5,7 +5,8 @@ use warnings;
|
||||
use geobase;
|
||||
|
||||
foreach my $key (keys %Region) {
|
||||
print $key . "\t"
|
||||
. ($Region{$key}->{parents}[-1] || 0) . "\t"
|
||||
. ($Region{$key}->{type} || 0) . "\n";
|
||||
print $key . "\t"
|
||||
. ($Region{$key}->{parents}[-1] || 0) . "\t"
|
||||
. ($Region{$key}->{type} || 0) . "\t"
|
||||
. (int($Region{$key}->{zip_old} || 0)) . "\n"; # zip_old, не смотря на название, содержит население региона.
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ void registerFunctionsDictionaries(FunctionFactory & factory)
|
||||
factory.registerFunction<FunctionRegionToDistrict>();
|
||||
factory.registerFunction<FunctionRegionToCountry>();
|
||||
factory.registerFunction<FunctionRegionToContinent>();
|
||||
factory.registerFunction<FunctionRegionToPopulation>();
|
||||
factory.registerFunction<FunctionOSToRoot>();
|
||||
factory.registerFunction<FunctionSEToRoot>();
|
||||
factory.registerFunction<FunctionCategoryToRoot>();
|
||||
|
Loading…
Reference in New Issue
Block a user