uqa_execution/query/block/
mod.rs1pub mod context;
10mod execution;
11mod facets;
12pub mod foreign;
13mod table;
14pub mod where_filter;
15use crate::query::privileges::ensure_select_privileges_for_query_block;
16use crate::query::{
17 binding::{
18 bind_query_block_for_execution, binding_context, validate_query_block_expression_types,
19 validate_query_block_references,
20 },
21 consumer::QueryOutputMode,
22 output::{QueryOutput, QueryRows},
23 projection::{expand_from_star_columns, physical_work_mem_bytes},
24 relational::output::execute_query_block_operator_output,
25 scored_input::{ScoredDocumentSource, ScoredInput},
26 sources::SourceContext,
27 CteScope,
28};
29use facets::{
30 build_facet_output, facet_projection_fields, post_retrieval_score_top_k,
31 score_limited_text_filter, score_order_top_k, FacetExecution,
32};
33use foreign::run_single_foreign_select_output;
34use table::run_single_table_select_output;
35use uqa_core::{ScoredEntry, Value};
36use uqa_sql::{
37 binding::{overlay_outer_schema, with_query_table_pseudo_columns},
38 plan::{
39 source_projection::SourceProjection, AccessPathPlan, ComputePlan, ProjectionPlan,
40 QueryBlockPlan, SourcePlan,
41 },
42 semantics::sets::validation::{
43 validate_query_set_contexts, validate_source_set_contexts_before_build,
44 },
45 semantics::{
46 expect_column_name, flatten_and_filter_parts, projection_columns,
47 source_filters::combine_filters as combine_filter_parts, SCORE_COLUMN, TABLE_OID_COLUMN,
48 },
49 SQLError, SQLParam, ScalarExpr,
50};
51use where_filter::execute_mixed_where;
52
53pub struct SingleRelation<'a> {
54 pub reference_name: &'a str,
55 pub relation_name: &'a str,
56 pub qualifier: &'a str,
57}
58
59pub struct BoundSingleRelation<'a> {
60 pub relation: SingleRelation<'a>,
61 pub schema: &'a crate::RowSchema,
62}
63
64pub use execution::execute_query_block_output;
65
66fn run_select_without_from_output<'a, S: Clone + 'static>(
67 context: &SourceContext<'a, S>,
68 original: &'a QueryBlockPlan,
69 statement: &'a QueryBlockPlan,
70 params: &'a [SQLParam],
71 ctes: &'a CteScope<S>,
72 output: QueryOutputMode<'a>,
73) -> Result<QueryOutput, SQLError> {
74 let columns = projection_columns(&statement.projections);
75 let operator = Box::new(crate::TableScan::from_physical_rows(
76 crate::RowSchema::default(),
77 vec![crate::PhysicalRow::default()],
78 ));
79 execute_query_block_operator_output(
80 context.relational,
81 operator,
82 statement.r#where.clone(),
83 statement,
84 original,
85 params,
86 ctes,
87 columns,
88 output,
89 )
90}
91
92fn expr_contains_jsonpath_fts_match(expr: &ScalarExpr) -> bool {
93 let mut found = false;
94 expr.visit(&mut |part| {
95 if expr_is_jsonpath_fts_match(part) {
96 found = true;
97 }
98 });
99 found
100}
101fn expr_is_jsonpath_fts_match(expr: &ScalarExpr) -> bool {
102 matches!(expr, ScalarExpr::Func { name, args, .. } if name.eq_ignore_ascii_case("fts_match")
103 && matches!(args.get(1), Some(ScalarExpr::Literal(Value::Str(path))) if path.trim_start().starts_with('$')))
104}