Skip to content

Commit

Permalink
feat (PADW-111): Add SQL function build (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
analyzer1 authored Dec 12, 2024
1 parent 9e32166 commit 50c0a03
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
5 changes: 3 additions & 2 deletions extension/src/controller/dv_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::model::dv_schema::{

use super::dv_loader::*;

pub fn build_dv(build_id: &String, dv_objects_query: &str) {
pub fn build_dv(build_id: &String, dv_objects_query: &str, load_data: bool) {

let mut dv_objects_hm: HashMap<u32, Vec<TransformerObject>> = HashMap::new();

Expand Down Expand Up @@ -316,7 +316,8 @@ pub fn build_dv(build_id: &String, dv_objects_query: &str) {
}
};

dv_data_loader(&dv_schema);
if load_data {dv_data_loader(&dv_schema);}

}


Expand Down
27 changes: 26 additions & 1 deletion extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,36 @@ fn go_default() -> String {
&build_id, &build_flag, &build_status, &status, &accepted_transformer_confidence_level);
_ = Spi::run(query_insert);
let query_build_pull = &queries::build_object_pull(&build_id);
controller::dv_builder::build_dv(&build_id, query_build_pull);
let load_data = true;
controller::dv_builder::build_dv(&build_id, query_build_pull, load_data);

message
}

#[pg_extern(name="build")]
fn build_default() -> String {
let accepted_transformer_confidence_level: String =
utility::guc::get_guc(guc::PgAutoDWGuc::AcceptedTransformerConfidenceLevel)
.unwrap_or_else(|| {
error!("GUC: Unable to obtain parameter \"pg_auto_dw.accepted_transformer_confidence_level.\"");
});
let build_id = Uuid::new_v4();
let message = format!("Build ID: {} | Data warehouse tables are currently being built.", build_id);
info!("{}", message);
let build_id = build_id.to_string();
let build_flag = "Build";
let build_status = "RTD";
let status = "Ready to Deploy";
let query_insert = &queries::insert_into_build_call(
&build_id, &build_flag, &build_status, &status, &accepted_transformer_confidence_level);
_ = Spi::run(query_insert);
let query_build_pull = &queries::build_object_pull(&build_id);
let load_data = false;
controller::dv_builder::build_dv(&build_id, query_build_pull, load_data);
message
}


#[pg_extern]
fn source_include( schema_pattern_include: &str,
table_pattern_include: default!(Option<&str>, "NULL"),
Expand Down

0 comments on commit 50c0a03

Please sign in to comment.