diff --git a/rust/core/src/automatic_branching.rs b/rust/core/src/automatic_branching.rs index a338e375..2e80cb11 100644 --- a/rust/core/src/automatic_branching.rs +++ b/rust/core/src/automatic_branching.rs @@ -170,8 +170,8 @@ pub async fn derive_sha256_file_contents( Ok(HEXLOWER.encode(digest.as_ref())) } -/// derive_hash_views returns table names for every model -/// and seed inside of the project that is passed in. The returned type is a map from the model +/// derive_hash_views returns table names for every model/snapshot and seed inside +/// of the project that is passed in. The returned type is a map from the model /// to a tuple of the model hash and sql statements required to create the view. pub fn derive_hash_views<'a>( database: &impl DatabaseQueryGenerator, diff --git a/rust/core/src/automatic_branching_build_cached.rs b/rust/core/src/automatic_branching_build_cached.rs new file mode 100644 index 00000000..997b8cdb --- /dev/null +++ b/rust/core/src/automatic_branching_build_cached.rs @@ -0,0 +1,37 @@ +use crate::{ + automatic_branching::{derive_hash_views, is_cache_full_path}, + databases::DatabaseQueryGenerator, + file_system::FileSystem, + graph::project_to_graph, + project::project_and_fs_to_sql_for_views, +}; +use quary_proto::Project; +use std::collections::{BTreeMap, BTreeSet, HashSet}; + +fn build_only_non_cached_things( + project: &Project, + file_system: &impl FileSystem, + database: &impl DatabaseQueryGenerator, + view_paths_in_target: HashSet, +) -> Result>, String> { + let filtered_cache_views = view_paths_in_target + .into_iter() + .map(|name| { + let is_cache = is_cache_full_path(database, &name)?; + Ok((name, is_cache)) + }) + .collect::, String>>()? + .into_iter() + .filter(|(_, is_cache)| !is_cache) + .collect::>(); + + let views_to_create = + project_and_fs_to_sql_for_views(project, file_system, database, false, false); + + let graph = project_to_graph(project.clone()); + let hashed_views = derive_hash_views(database, project, graph); + + + + unimplemented!(); +} diff --git a/rust/core/src/lib.rs b/rust/core/src/lib.rs index 590e27a3..ddbdef9e 100644 --- a/rust/core/src/lib.rs +++ b/rust/core/src/lib.rs @@ -10,6 +10,7 @@ extern crate core; pub mod automatic_branching; +pub mod automatic_branching_build_cached; pub mod chart; pub mod config; pub mod database_bigquery;