@@ -1211,6 +1211,52 @@ void check_multi_key_is_not_index_only(const PipelineContext& pipeline_context,
1211
1211
);
1212
1212
}
1213
1213
1214
+ void check_can_be_filtered (const std::shared_ptr<PipelineContext>& pipeline_context, const ReadQuery& read_query) {
1215
+ // To remain backward compatibility, pending new major release to merge into below section
1216
+ // Ticket: 18038782559
1217
+ bool is_pickled = pipeline_context->norm_meta_ && pipeline_context->is_pickled ();
1218
+ util::check (
1219
+ !is_pickled ||
1220
+ (!read_query.columns .has_value () && std::holds_alternative<std::monostate>(read_query.row_filter )),
1221
+ " The data for this symbol is pickled and does not support column stats, date_range, row_range, or column "
1222
+ " queries"
1223
+ );
1224
+ if (pipeline_context->multi_key_ ) {
1225
+ check_multi_key_is_not_index_only (*pipeline_context, read_query);
1226
+ }
1227
+
1228
+ // To keep
1229
+ if (pipeline_context->desc_ ) {
1230
+ util::check (
1231
+ pipeline_context->descriptor ().index ().type () == IndexDescriptor::Type::TIMESTAMP ||
1232
+ !std::holds_alternative<IndexRange>(read_query.row_filter ),
1233
+ " Cannot apply date range filter to symbol with non-timestamp index"
1234
+ );
1235
+ auto sorted_value = pipeline_context->descriptor ().sorted ();
1236
+ sorting::check<ErrorCode::E_UNSORTED_DATA>(
1237
+ sorted_value == SortedValue::UNKNOWN || sorted_value == SortedValue::ASCENDING ||
1238
+ !std::holds_alternative<IndexRange>(read_query.row_filter ),
1239
+ " When filtering data using date_range, the symbol must be sorted in ascending order. ArcticDB believes "
1240
+ " it "
1241
+ " is not sorted in ascending order and cannot therefore filter the data using date_range."
1242
+ );
1243
+ }
1244
+ bool is_query_empty =
1245
+ (!read_query.columns && !read_query.row_range &&
1246
+ std::holds_alternative<std::monostate>(read_query.row_filter ) && read_query.clauses_ .empty ());
1247
+ bool is_numpy_array = pipeline_context->norm_meta_ && pipeline_context->norm_meta_ ->has_np ();
1248
+ if (!is_query_empty) {
1249
+ // Exception for filterig pickled data is skipped for now for backward compatibility
1250
+ if (pipeline_context->multi_key_ ) {
1251
+ schema::raise<ErrorCode::E_OPERATION_NOT_SUPPORTED_WITH_RECURSIVE_NORMALIZED_DATA>(
1252
+ " Cannot filter recursively normalized data"
1253
+ );
1254
+ } else if (is_numpy_array) {
1255
+ schema::raise<ErrorCode::E_OPERATION_NOT_SUPPORTED_WITH_NUMPY_ARRAY>(" Cannot filter numpy array" );
1256
+ }
1257
+ }
1258
+ }
1259
+
1214
1260
static void read_indexed_keys_to_pipeline (
1215
1261
const std::shared_ptr<Store>& store, const std::shared_ptr<PipelineContext>& pipeline_context,
1216
1262
const VersionedItem& version_info, ReadQuery& read_query, const ReadOptions& read_options
@@ -1222,7 +1268,6 @@ static void read_indexed_keys_to_pipeline(
1222
1268
auto index_segment_reader = std::move (*maybe_reader);
1223
1269
ARCTICDB_DEBUG (log::version (), " Read index segment with {} keys" , index_segment_reader.size ());
1224
1270
check_can_read_index_only_if_required (index_segment_reader, read_query);
1225
- check_column_and_date_range_filterable (index_segment_reader, read_query);
1226
1271
add_index_columns_to_query (read_query, index_segment_reader.tsd ());
1227
1272
1228
1273
const auto & tsd = index_segment_reader.tsd ();
@@ -1245,6 +1290,7 @@ static void read_indexed_keys_to_pipeline(
1245
1290
std::move (*index_segment_reader.mutable_tsd ().mutable_proto ().mutable_user_meta ())
1246
1291
);
1247
1292
pipeline_context->bucketize_dynamic_ = bucketize_dynamic;
1293
+ check_can_be_filtered (pipeline_context, read_query);
1248
1294
ARCTICDB_DEBUG (
1249
1295
log::version (),
1250
1296
" read_indexed_keys_to_pipeline: Symbol {} Found {} keys with {} total rows" ,
@@ -2570,8 +2616,11 @@ folly::Future<ReadVersionOutput> read_frame_for_version(
2570
2616
) {
2571
2617
auto pipeline_context = setup_pipeline_context (store, version_info, *read_query, read_options);
2572
2618
auto res_versioned_item = generate_result_versioned_item (version_info);
2619
+
2573
2620
if (pipeline_context->multi_key_ ) {
2574
- check_multi_key_is_not_index_only (*pipeline_context, *read_query);
2621
+ if (read_query) {
2622
+ check_can_be_filtered (pipeline_context, *read_query);
2623
+ }
2575
2624
return read_multi_key (store, *pipeline_context->multi_key_ , handler_data, std::move (res_versioned_item.key_ ));
2576
2625
}
2577
2626
ARCTICDB_DEBUG (log::version (), " Fetching data to frame" );
0 commit comments