@@ -46,24 +46,20 @@ class SubstraitFunctionLookupTest : public ::testing::Test {
4646 std::make_shared<AggregateFunctionLookup>(extension_, mappings_);
4747 }
4848
49- void testScalarFunctionLookup (const std::string &name,
50- const std::vector<TypePtr> &arguments,
51- const TypePtr &returnType,
49+ void testScalarFunctionLookup (const FunctionSignature &inputSignature,
5250 const std::string &outputSignature) {
53- const auto &functionVariant = scalarFunctionLookup_-> lookupFunction (
54- FunctionSignature (name, arguments, returnType) );
51+ const auto &functionVariant =
52+ scalarFunctionLookup_-> lookupFunction (inputSignature );
5553
5654 ASSERT_TRUE (functionVariant != nullptr );
5755 ASSERT_EQ (functionVariant->signature (), outputSignature);
5856 }
5957
60- void testAggregateFunctionLookup (const std::string &name,
61- const std::vector<TypePtr> &arguments,
62- const TypePtr &returnType,
58+ void testAggregateFunctionLookup (const FunctionSignature &inputSignature,
6359 const std::string &outputSignature) {
6460
65- const auto &functionVariant = aggregateFunctionLookup_-> lookupFunction (
66- FunctionSignature (name, arguments, returnType) );
61+ const auto &functionVariant =
62+ aggregateFunctionLookup_-> lookupFunction (inputSignature );
6763
6864 ASSERT_TRUE (functionVariant != nullptr );
6965 ASSERT_EQ (functionVariant->signature (), outputSignature);
@@ -75,51 +71,55 @@ class SubstraitFunctionLookupTest : public ::testing::Test {
7571};
7672
7773TEST_F (SubstraitFunctionLookupTest, compare_function) {
78- testScalarFunctionLookup (" lt" , {kI8 (), kI8 ()}, kBool (), " lt:any1_any1" );
74+ testScalarFunctionLookup ({ " lt" , {kI8 (), kI8 ()}, kBool ()} , " lt:any1_any1" );
7975
80- testScalarFunctionLookup (" lt" , {kI16 (), kI16 ()}, kBool (), " lt:any1_any1" );
76+ testScalarFunctionLookup ({ " lt" , {kI16 (), kI16 ()}, kBool ()} , " lt:any1_any1" );
8177
82- testScalarFunctionLookup (" lt" , {kI32 (), kI32 ()}, kBool (), " lt:any1_any1" );
78+ testScalarFunctionLookup ({ " lt" , {kI32 (), kI32 ()}, kBool ()} , " lt:any1_any1" );
8379
84- testScalarFunctionLookup (" lt" , {kI64 (), kI64 ()}, kBool (), " lt:any1_any1" );
80+ testScalarFunctionLookup ({ " lt" , {kI64 (), kI64 ()}, kBool ()} , " lt:any1_any1" );
8581
86- testScalarFunctionLookup (" lt" , {kFp32 (), kFp32 ()}, kBool (), " lt:any1_any1" );
82+ testScalarFunctionLookup ({ " lt" , {kFp32 (), kFp32 ()}, kBool ()} , " lt:any1_any1" );
8783
88- testScalarFunctionLookup (" lt" , {kFp64 (), kFp64 ()}, kBool (), " lt:any1_any1" );
89- testScalarFunctionLookup (" between" , {kI8 (), kI8 (), kI8 ()}, kBool (),
84+ testScalarFunctionLookup ({ " lt" , {kFp64 (), kFp64 ()}, kBool ()} , " lt:any1_any1" );
85+ testScalarFunctionLookup ({ " between" , {kI8 (), kI8 (), kI8 ()}, kBool ()} ,
9086 " between:any1_any1_any1" );
9187}
9288
9389TEST_F (SubstraitFunctionLookupTest, arithmetic_function) {
94- testScalarFunctionLookup (" add" , {kI8 (), kI8 ()}, kI8 (), " add:opt_i8_i8" );
95-
96- testScalarFunctionLookup (" plus" , {kI8 (), kI8 ()}, kI8 (), " add:opt_i8_i8" );
97- testScalarFunctionLookup (" divide" ,
98- {
99- kFp32 (),
100- kFp32 (),
101- },
102- kFp32 (), " divide:opt_opt_opt_fp32_fp32" );
103-
104- testAggregateFunctionLookup (" avg" , {Type::decode (" struct<fp64,i64>" )},
105- kFp32 (), " avg:opt_fp32" );
90+ testScalarFunctionLookup ({" add" , {kI8 (), kI8 ()}, kI8 ()}, " add:opt_i8_i8" );
91+
92+ testScalarFunctionLookup ({" plus" , {kI8 (), kI8 ()}, kI8 ()}, " add:opt_i8_i8" );
93+ testScalarFunctionLookup ({" divide" ,
94+ {
95+ kFp32 (),
96+ kFp32 (),
97+ },
98+ kFp32 ()},
99+ " divide:opt_opt_opt_fp32_fp32" );
100+
101+ testAggregateFunctionLookup (
102+ {" avg" , {Type::decode (" struct<fp64,i64>" )}, kFp32 ()}, " avg:opt_fp32" );
106103}
107104
108105TEST_F (SubstraitFunctionLookupTest, avg) {}
109106
110107TEST_F (SubstraitFunctionLookupTest, logical) {
111- testScalarFunctionLookup (" and" , {kBool (), kBool ()}, kBool (), " and:bool" );
112- testScalarFunctionLookup (" or" , {kBool (), kBool ()}, kBool (), " or:bool" );
113- testScalarFunctionLookup (" not" , {kBool ()}, kBool (), " not:bool" );
114- testScalarFunctionLookup (" xor" , {kBool (), kBool ()}, kBool (), " xor:bool_bool" );
108+ testScalarFunctionLookup ({" and" , {kBool (), kBool ()}, kBool ()}, " and:bool" );
109+ testScalarFunctionLookup ({" or" , {kBool (), kBool ()}, kBool ()}, " or:bool" );
110+ testScalarFunctionLookup ({" not" , {kBool ()}, kBool ()}, " not:bool" );
111+ testScalarFunctionLookup ({" xor" , {kBool (), kBool ()}, kBool ()},
112+ " xor:bool_bool" );
115113}
116114
117115TEST_F (SubstraitFunctionLookupTest, string_function) {
118- testScalarFunctionLookup (" like" , {kString (), kString ()}, kBool (),
116+ testScalarFunctionLookup ({ " like" , {kString (), kString ()}, kBool ()} ,
119117 " like:opt_str_str" );
120118 testScalarFunctionLookup (
121- " like" , {Type::decode (" varchar<L1>" ), Type::decode (" varchar<L2>" )},
122- kBool (), " like:opt_vchar<L1>_vchar<L2>" );
123- testScalarFunctionLookup (" substr" , {kString (), kI32 (), kI32 ()}, kString (),
119+ {" like" ,
120+ {Type::decode (" varchar<L1>" ), Type::decode (" varchar<L2>" )},
121+ kBool ()},
122+ " like:opt_vchar<L1>_vchar<L2>" );
123+ testScalarFunctionLookup ({" substr" , {kString (), kI32 (), kI32 ()}, kString ()},
124124 " substring:str_i32_i32" );
125125}
0 commit comments