diff --git a/core/translate.rs b/core/translate.rs index bd7c103d4..82196d7f1 100644 --- a/core/translate.rs +++ b/core/translate.rs @@ -14,7 +14,7 @@ struct Select { columns: Vec, column_info: Vec, from: Option, - joins: Option>, + src_tables: Vec, limit: Option, exist_aggregation: bool, } @@ -38,9 +38,9 @@ struct SelectContext { loops: Vec, } -struct Join { +struct SrcTable { table: Table, - info: ast::JoinedSelectTable, // FIXME: preferably this should be a reference with lifetime == Select ast expr + join_info: Option, // FIXME: preferably this should be a reference with lifetime == Select ast expr } struct ColumnInfo { @@ -99,10 +99,14 @@ fn build_select(schema: &Schema, select: ast::Select) -> Result { Some(table) => table, None => anyhow::bail!("Parse error: no such table: {}", table_name), }; - res.push(Join { + joins.push(SrcTable { table: Table::BTree(table), - info: join.clone(), + join_info: Some(join.clone()), }); } - Some(res) } - None => None, + None => {} }; let table = Table::BTree(table); - let column_info = analyze_columns(&columns, Some(&table), &joins); + let column_info = analyze_columns(&columns, &joins); let exist_aggregation = column_info.iter().any(|info| info.func.is_some()); Ok(Select { columns, column_info, from: Some(table), - joins: joins, + src_tables: joins, limit: select.limit.clone(), exist_aggregation, }) @@ -139,13 +142,13 @@ fn build_select(schema: &Schema, select: ast::Select) -> Result