velesdb_core/velesql/ast/join.rs
1//! JOIN clause types for VelesQL.
2//!
3//! This module defines join types and conditions for cross-store queries.
4
5use serde::{Deserialize, Serialize};
6
7/// JOIN clause for cross-store queries (EPIC-031 US-004).
8#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
9pub struct JoinClause {
10 /// Type of join (INNER, LEFT, RIGHT, FULL).
11 pub join_type: JoinType,
12 /// Table/store name to join.
13 pub table: String,
14 /// Optional alias for the joined table.
15 pub alias: Option<String>,
16 /// Join condition (ON clause).
17 pub condition: Option<JoinCondition>,
18 /// USING clause columns.
19 pub using_columns: Option<Vec<String>>,
20}
21
22/// Type of SQL JOIN operation.
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
24#[non_exhaustive]
25pub enum JoinType {
26 /// INNER JOIN.
27 #[default]
28 Inner,
29 /// LEFT JOIN.
30 Left,
31 /// RIGHT JOIN.
32 Right,
33 /// FULL JOIN.
34 Full,
35}
36
37/// Join condition specifying how to link tables.
38#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
39pub struct JoinCondition {
40 /// Left side of the join.
41 pub left: ColumnRef,
42 /// Right side of the join.
43 pub right: ColumnRef,
44}
45
46/// Column reference with optional table/alias prefix.
47#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
48pub struct ColumnRef {
49 /// Optional table or alias prefix.
50 pub table: Option<String>,
51 /// Column or property name.
52 pub column: String,
53}