diff --git a/core/incremental/expr_compiler.rs b/core/incremental/expr_compiler.rs index 9ea22028a..f94d72a2a 100644 --- a/core/incremental/expr_compiler.rs +++ b/core/incremental/expr_compiler.rs @@ -14,7 +14,7 @@ use crate::SymbolTable; use crate::{CaptureDataChangesMode, Connection, QueryMode, Result, Value}; use std::rc::Rc; use std::sync::Arc; -use turso_sqlite3_parser::ast::{Expr, Literal, Operator}; +use turso_parser::ast::{Expr, Literal, Operator}; // Transform an expression to replace column references with Register expressions Why do we want to // do this? @@ -65,19 +65,17 @@ fn transform_expr_for_dbsp(expr: &Expr, input_column_names: &[String]) -> Expr { } => Expr::FunctionCall { name: name.clone(), distinctness: *distinctness, - args: args.as_ref().map(|args_vec| { - args_vec - .iter() - .map(|arg| transform_expr_for_dbsp(arg, input_column_names)) - .collect() - }), + args: args + .iter() + .map(|arg| Box::new(transform_expr_for_dbsp(arg, input_column_names))) + .collect(), order_by: order_by.clone(), filter_over: filter_over.clone(), }, Expr::Parenthesized(exprs) => Expr::Parenthesized( exprs .iter() - .map(|e| transform_expr_for_dbsp(e, input_column_names)) + .map(|e| Box::new(transform_expr_for_dbsp(e, input_column_names))) .collect(), ), // For other expression types, keep as is diff --git a/core/incremental/operator.rs b/core/incremental/operator.rs index 34f9b3ff0..0391e3c0a 100644 --- a/core/incremental/operator.rs +++ b/core/incremental/operator.rs @@ -10,7 +10,6 @@ use std::collections::{HashMap, HashSet}; use std::fmt::{self, Debug, Display}; use std::sync::Arc; use std::sync::Mutex; -use turso_sqlite3_parser::ast::*; /// Tracks computation counts to verify incremental behavior (for tests now), and in the future /// should be used to provide statistics. @@ -346,7 +345,7 @@ impl FilterPredicate { #[derive(Debug, Clone)] pub struct ProjectColumn { /// The original SQL expression (for debugging/fallback) - pub expr: turso_sqlite3_parser::ast::Expr, + pub expr: turso_parser::ast::Expr, /// Optional alias for the column pub alias: Option, /// Compiled expression (handles both trivial columns and complex expressions) @@ -620,11 +619,11 @@ impl std::fmt::Debug for ProjectOperator { impl ProjectOperator { /// Create a new ProjectOperator from a SELECT statement, extracting projection columns pub fn from_select( - select: &turso_sqlite3_parser::ast::Select, + select: &turso_parser::ast::Select, input_column_names: Vec, schema: &crate::schema::Schema, ) -> crate::Result { - use turso_sqlite3_parser::ast::*; + use turso_parser::ast::*; // Set up internal connection for expression evaluation let io = Arc::new(crate::MemoryIO::new()); @@ -640,9 +639,13 @@ impl ProjectOperator { let temp_syms = SymbolTable::new(); // Extract columns from SELECT statement - let columns = if let OneSelect::Select(ref select_stmt) = &*select.body.select { + let columns = if let OneSelect::Select { + columns: ref select_columns, + .. + } = &select.body.select + { let mut columns = Vec::new(); - for result_col in &select_stmt.columns { + for result_col in select_columns { match result_col { ResultColumn::Expr(expr, alias) => { let alias_str = if let Some(As::As(alias_name)) = alias { @@ -659,7 +662,7 @@ impl ProjectOperator { internal_conn.clone(), )?; columns.push(ProjectColumn { - expr: expr.clone(), + expr: (**expr).clone(), alias: alias_str, compiled, }); diff --git a/core/incremental/view.rs b/core/incremental/view.rs index 360eca7ce..4f4d4c6e6 100644 --- a/core/incremental/view.rs +++ b/core/incremental/view.rs @@ -96,9 +96,7 @@ pub struct IncrementalView { impl IncrementalView { /// Validate that a CREATE MATERIALIZED VIEW statement can be handled by IncrementalView /// This should be called early, before updating sqlite_master - pub fn can_create_view(select: &ast::Select, schema: &Schema) -> Result<()> { - // Check for aggregations - let (group_by_columns, aggregate_functions, _) = Self::extract_aggregation_info(select); + pub fn can_create_view(select: &ast::Select) -> Result<()> { // Check for JOINs let (join_tables, join_condition) = Self::extract_join_info(select); if join_tables.is_some() || join_condition.is_some() { @@ -346,7 +344,7 @@ impl IncrementalView { let mut columns = Vec::new(); for col in project_op.columns() { // Check if it's a simple column reference - if let turso_sqlite3_parser::ast::Expr::Id(name) = &col.expr { + if let turso_parser::ast::Expr::Id(name) = &col.expr { columns.push(name.as_str().to_string()); } else { // For expressions, we need all columns (for now)