@@ -96,6 +96,11 @@ Result<RowRanges> ColumnIndexFilter::VisitLeafPredicate(
9696 const auto & literals = leaf_predicate->Literals ();
9797 FieldType field_type = leaf_predicate->GetFieldType ();
9898
99+ if (function_type != Function::Type::IS_NULL && function_type != Function::Type::IS_NOT_NULL &&
100+ literals.empty ()) {
101+ return Status::Invalid (
102+ fmt::format (" predicate on column '{}' requires at least one literal" , field_name));
103+ }
99104 std::vector<int32_t > matching_pages;
100105
101106 switch (function_type) {
@@ -106,37 +111,22 @@ Result<RowRanges> ColumnIndexFilter::VisitLeafPredicate(
106111 matching_pages = FilterPagesByIsNotNull (column_index_ptr);
107112 break ;
108113 case Function::Type::EQUAL :
109- if (!literals.empty ()) {
110- matching_pages = FilterPagesByEqual (column_index_ptr, literals[0 ], field_type);
111- }
114+ matching_pages = FilterPagesByEqual (column_index_ptr, literals[0 ], field_type);
112115 break ;
113116 case Function::Type::NOT_EQUAL :
114- if (!literals.empty ()) {
115- matching_pages = FilterPagesByNotEqual (column_index_ptr, literals[0 ], field_type);
116- }
117+ matching_pages = FilterPagesByNotEqual (column_index_ptr, literals[0 ], field_type);
117118 break ;
118119 case Function::Type::LESS_THAN :
119- if (!literals.empty ()) {
120- matching_pages = FilterPagesByLessThan (column_index_ptr, literals[0 ], field_type);
121- }
120+ matching_pages = FilterPagesByLessThan (column_index_ptr, literals[0 ], field_type);
122121 break ;
123122 case Function::Type::LESS_OR_EQUAL :
124- if (!literals.empty ()) {
125- matching_pages =
126- FilterPagesByLessOrEqual (column_index_ptr, literals[0 ], field_type);
127- }
123+ matching_pages = FilterPagesByLessOrEqual (column_index_ptr, literals[0 ], field_type);
128124 break ;
129125 case Function::Type::GREATER_THAN :
130- if (!literals.empty ()) {
131- matching_pages =
132- FilterPagesByGreaterThan (column_index_ptr, literals[0 ], field_type);
133- }
126+ matching_pages = FilterPagesByGreaterThan (column_index_ptr, literals[0 ], field_type);
134127 break ;
135128 case Function::Type::GREATER_OR_EQUAL :
136- if (!literals.empty ()) {
137- matching_pages =
138- FilterPagesByGreaterOrEqual (column_index_ptr, literals[0 ], field_type);
139- }
129+ matching_pages = FilterPagesByGreaterOrEqual (column_index_ptr, literals[0 ], field_type);
140130 break ;
141131 case Function::Type::IN :
142132 matching_pages = FilterPagesByIn (column_index_ptr, literals, field_type);
0 commit comments