linkrs_query/optimizer/cost_based/join_order/
condition.rs1use crate::optimizer::cost_based::ndv::DEFAULT_JOIN_SELECTIVITY;
4use linkrs_core::types::ContextualExpression;
5
6#[derive(Debug, Clone)]
8pub struct JoinCondition {
9 pub left_table: String,
11 pub right_table: String,
13 pub selectivity: f64,
15 pub expression: Option<ContextualExpression>,
17}
18
19impl JoinCondition {
20 pub fn new(left_table: String, right_table: String) -> Self {
22 Self {
23 left_table,
24 right_table,
25 selectivity: DEFAULT_JOIN_SELECTIVITY,
26 expression: None,
27 }
28 }
29
30 pub fn with_selectivity(mut self, selectivity: f64) -> Self {
32 self.selectivity = selectivity.clamp(0.0, 1.0);
33 self
34 }
35
36 pub fn with_expression(mut self, expression: ContextualExpression) -> Self {
38 self.expression = Some(expression);
39 self
40 }
41}