MCPcopy Create free account
hub / github.com/alibaba/zvec / build_query_info

Method build_query_info

src/db/sqlengine/sqlengine_impl.cc:288–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288Result<QueryInfo::Ptr> SQLEngineImpl::build_query_info(
289 CollectionSchema::Ptr collection, const SearchQuery &request,
290 std::shared_ptr<GroupBy> group_by) {
291 ScopedProfilerStage stage_guard(profiler_, "build_sql_info");
292 Node::Ptr filter_node;
293 if (!request.filter_.empty()) {
294 ZVecParser::Ptr parser = ZVecParser::create();
295 filter_node = parser->parse_filter(request.filter_);
296 if (filter_node == nullptr) {
297 LOG_ERROR("parse filter failed. reason:[%s] filter:[%s]",
298 parser->err_msg().c_str(), request.filter_.c_str());
299 return tl::make_unexpected(Status::InvalidArgument(
300 "Invalid filter [", request.filter_, "]: ", parser->err_msg()));
301 }
302 }
303 FtsCondInfo::Ptr fts_cond_info;
304 if (const auto *fts_clause = request.target_.get_fts_clause()) {
305 auto fts_result =
306 parse_fts_query(collection, request.target_.field_name_, *fts_clause,
307 request.target_.query_params_);
308 if (!fts_result) {
309 return tl::make_unexpected(fts_result.error());
310 }
311 fts_cond_info = std::move(fts_result.value());
312 }
313
314 auto sql_info = sqlengine::SQLInfoHelper::BuildSQLInfoFromSearchQuery(
315 request, std::move(filter_node), std::move(group_by));
316 if (!sql_info) {
317 return tl::make_unexpected(sql_info.error());
318 }
319
320 // Attach FTS info to SelectInfo so query_analyzer can propagate it to
321 // QueryInfo.
322 if (fts_cond_info) {
323 auto select_info =
324 std::dynamic_pointer_cast<SelectInfo>(sql_info.value()->base_info());
325 if (!select_info) {
326 return tl::make_unexpected(Status::InternalError(
327 "BuildSQLInfoFromSearchQuery did not produce SelectInfo"));
328 }
329 select_info->set_fts_cond_info(std::move(fts_cond_info));
330 }
331
332 LOG_DEBUG("Sql info is %s", sql_info.value()->to_string().c_str());
333 stage_guard.close();
334 return parse_sql_info(*collection, std::move(sql_info.value()));
335}
336
337Result<std::unique_ptr<arrow::RecordBatchReader>>
338SQLEngineImpl::search_by_query_info(

Callers 4

TEST_FFunction · 0.80
TEST_FFunction · 0.80
parse_resultMethod · 0.80
TEST_FFunction · 0.80

Calls 12

make_unexpectedFunction · 0.85
InvalidArgumentFunction · 0.85
InternalErrorFunction · 0.85
c_strMethod · 0.80
createFunction · 0.50
emptyMethod · 0.45
parse_filterMethod · 0.45
errorMethod · 0.45
valueMethod · 0.45
set_fts_cond_infoMethod · 0.45
to_stringMethod · 0.45
closeMethod · 0.45

Tested by 4

TEST_FFunction · 0.64
TEST_FFunction · 0.64
parse_resultMethod · 0.64
TEST_FFunction · 0.64