uqa_engine/capabilities/
partitions.rs1use crate::Engine;
10use uqa_core::Value;
11use uqa_sql::semantics::partition::{PartitionCatalog, PartitionContext, PartitionExpressions};
12use uqa_sql::{
13 ast::{ColumnDef, Expr, TableHierarchy},
14 RowSchema, SQLError, SQLParam,
15};
16
17impl Engine {
18 pub(crate) fn partition_context(&self) -> PartitionContext<'_> {
19 PartitionContext {
20 catalog: self,
21 expressions: self,
22 types: self,
23 assignment: self,
24 schema: self,
25 }
26 }
27}
28
29impl PartitionCatalog for Engine {
30 fn try_table_hierarchy(&self, table: &str) -> Result<TableHierarchy, String> {
31 Engine::try_table_hierarchy(self, table).map_err(|error| error.to_string())
32 }
33 fn direct_hierarchy_children(&self, parent: &str) -> Result<Vec<String>, SQLError> {
34 Engine::direct_hierarchy_children(self, parent)
35 }
36 fn try_resolve_table_name(&self, name: &str) -> Result<Option<String>, String> {
37 Engine::try_resolve_table_name(self, name).map_err(|error| error.to_string())
38 }
39 fn try_describe_table(&self, table: &str) -> Result<Option<Vec<ColumnDef>>, String> {
40 Engine::describe_table_in_execution(self, table).map_err(|error| error.to_string())
41 }
42 fn try_table_object_id(&self, table: &str) -> Result<Option<[u8; 16]>, String> {
43 Engine::try_table(self, table)
44 .map(|table| table.map(|table| table.object_id()))
45 .map_err(|error| error.to_string())
46 }
47}
48
49impl PartitionExpressions for Engine {
50 fn expression_text(&self, expression: &Expr) -> Result<String, SQLError> {
51 uqa_execution::catalog::projection::partition_key_expression(
52 &self.catalog_execution(),
53 expression,
54 )
55 }
56 fn evaluate_bound(&self, expression: &Expr, params: &[SQLParam]) -> Result<Value, SQLError> {
57 crate::capabilities::query_expressions::eval_lowered_expression(
58 self, expression, None, params,
59 )
60 }
61 fn evaluate_row(
62 &self,
63 expression: &Expr,
64 row: &dyn uqa_sql::expr::RowLookup,
65 schema: &RowSchema,
66 params: &[SQLParam],
67 ) -> Result<Value, SQLError> {
68 crate::capabilities::query_expressions::eval_lowered_expression_with_schema(
69 self, expression, row, schema, params,
70 )
71 }
72}