MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / extract_equi_keys

Function extract_equi_keys

nodedb-sql/src/planner/join/constraint.rs:95–125  ·  view source on GitHub ↗
(
    expr: &ast::Expr,
    keys: &mut Vec<(String, String)>,
    non_equi: &mut Vec<ast::Expr>,
)

Source from the content-addressed store, hash-verified

93}
94
95fn extract_equi_keys(
96 expr: &ast::Expr,
97 keys: &mut Vec<(String, String)>,
98 non_equi: &mut Vec<ast::Expr>,
99) -> Result<()> {
100 match expr {
101 ast::Expr::BinaryOp {
102 left,
103 op: ast::BinaryOperator::And,
104 right,
105 } => {
106 extract_equi_keys(left, keys, non_equi)?;
107 extract_equi_keys(right, keys, non_equi)?;
108 }
109 ast::Expr::BinaryOp {
110 left,
111 op: ast::BinaryOperator::Eq,
112 right,
113 } => {
114 if let (Some(l), Some(r)) = (extract_col_ref(left), extract_col_ref(right)) {
115 keys.push((l, r));
116 } else {
117 non_equi.push(expr.clone());
118 }
119 }
120 _ => {
121 non_equi.push(expr.clone());
122 }
123 }
124 Ok(())
125}
126
127fn extract_col_ref(expr: &ast::Expr) -> Option<String> {
128 match expr {

Callers 1

extract_join_constraintFunction · 0.85

Calls 3

extract_col_refFunction · 0.85
pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected