MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / parse_join

Method parse_join

crates/sql-parser/src/parser/mod.rs:50–77  ·  view source on GitHub ↗

Parse a single JOIN clause

(join: Join)

Source from the content-addressed store, hash-verified

48
49 /// Parse a single JOIN clause
50 fn parse_join(join: Join) -> SqlParseResult<SqlJoin> {
51 let (var, alias) = Self::parse_relvar(join.relation)?;
52 match join.join_operator {
53 JoinOperator::CrossJoin => Ok(SqlJoin { var, alias, on: None }),
54 JoinOperator::Inner(JoinConstraint::None) => Ok(SqlJoin { var, alias, on: None }),
55 JoinOperator::Inner(JoinConstraint::On(Expr::BinaryOp {
56 left,
57 op: BinaryOperator::Eq,
58 right,
59 })) if matches!(*left, Expr::Identifier(..) | Expr::CompoundIdentifier(..))
60 && matches!(*right, Expr::Identifier(..) | Expr::CompoundIdentifier(..)) =>
61 {
62 Ok(SqlJoin {
63 var,
64 alias,
65 on: Some(parse_expr(
66 Expr::BinaryOp {
67 left,
68 op: BinaryOperator::Eq,
69 right,
70 },
71 0,
72 )?),
73 })
74 }
75 _ => Err(SqlUnsupported::JoinType.into()),
76 }
77 }
78
79 /// Parse a table reference in a FROM clause
80 fn parse_relvar(expr: TableFactor) -> SqlParseResult<(SqlIdent, SqlIdent)> {

Callers

nothing calls this directly

Implementers 2

sql.rscrates/sql-parser/src/parser/sql.rs
sub.rscrates/sql-parser/src/parser/sub.rs

Calls 3

parse_exprFunction · 0.85
OkFunction · 0.50
ErrFunction · 0.50

Tested by

no test coverage detected