ClickHouse
71 строка · 2.5 Кб
1#include "GatherUtils.h"2#include "Selectors.h"3#include "Algorithms.h"4
5namespace DB::GatherUtils6{
7
8namespace
9{
10
11struct ArrayHasSubstrSelectArraySourcePair : public ArraySourcePairSelector<ArrayHasSubstrSelectArraySourcePair>12{
13template <typename FirstSource, typename SecondSource>14static void callFunction(FirstSource && first,15bool is_second_const, bool is_second_nullable, SecondSource && second,16ColumnUInt8 & result)17{18using SourceType = typename std::decay_t<SecondSource>;19
20if (is_second_nullable)21{22using NullableSource = NullableArraySource<SourceType>;23
24if (is_second_const)25arrayAllAny<ArraySearchType::Substr>(first, static_cast<ConstSource<NullableSource> &>(second), result);26else27arrayAllAny<ArraySearchType::Substr>(first, static_cast<NullableSource &>(second), result);28}29else30{31if (is_second_const)32arrayAllAny<ArraySearchType::Substr>(first, static_cast<ConstSource<SourceType> &>(second), result);33else34arrayAllAny<ArraySearchType::Substr>(first, second, result);35}36}37
38template <typename FirstSource, typename SecondSource>39static void selectSourcePair(bool is_first_const, bool is_first_nullable, FirstSource && first,40bool is_second_const, bool is_second_nullable, SecondSource && second,41ColumnUInt8 & result)42{43using SourceType = typename std::decay_t<FirstSource>;44
45if (is_first_nullable)46{47using NullableSource = NullableArraySource<SourceType>;48
49if (is_first_const)50callFunction(static_cast<ConstSource<NullableSource> &>(first), is_second_const, is_second_nullable, second, result);51else52callFunction(static_cast<NullableSource &>(first), is_second_const, is_second_nullable, second, result);53}54else55{56if (is_first_const)57callFunction(static_cast<ConstSource<SourceType> &>(first), is_second_const, is_second_nullable, second, result);58else59callFunction(first, is_second_const, is_second_nullable, second, result);60}61}62};63
64}
65
66void sliceHasSubstr(IArraySource & first, IArraySource & second, ColumnUInt8 & result)67{
68ArrayHasSubstrSelectArraySourcePair::select(first, second, result);69}
70
71}
72