Skip to content

Commit

Permalink
feat(PADW-78): Enable GO Function for BKC = 1, Hold for BKC ≠ 1
Browse files Browse the repository at this point in the history
  • Loading branch information
analyzer1 committed Oct 22, 2024
1 parent 36e96b2 commit 86d7338
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
1 change: 0 additions & 1 deletion extension/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use model::queries;
#[pg_extern(name="go")]
fn go_default() -> String {
let accepted_transformer_confidence_level: String =
// utility::guc::get_guc(guc::PgAutoDWGuc::AcceptedTransformerConfidenceLevel).unwrap();
utility::guc::get_guc(guc::PgAutoDWGuc::AcceptedTransformerConfidenceLevel)
.unwrap_or_else(|| {
error!("GUC: Unable to obtain parameter \"pg_auto_dw.accepted_transformer_confidence_level.\"");
Expand Down
2 changes: 1 addition & 1 deletion extension/src/model/prompt_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl PromptTemplate {
If the column is a primary key, as indicated in the comments or column details, assume it is a business key component. However, this does not exclude the possibility of other business key components within the table, but it may reduce the likelihood of the specified column being the only business key.
If the specified column could be categorized as an email, only consider it a business key component if there are no other attributes in the table that could reasonably serve as a business key component.
If the specified column could be categorized as an email or username, only consider it a business key component if there are no other attributes in the table that could reasonably serve as a business key component.
Confidence Value:
Expand Down
54 changes: 39 additions & 15 deletions extension/src/model/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,17 @@ pub fn insert_into_build_call(
t.category,
t.model_name,
MAX(
CASE
WHEN t.category = 'Business Key Part' AND t.confidence_score < cl.value THEN 1
ELSE 0
END
) OVER (PARTITION BY s.schema_name, s.table_name) AS bk_hold
CASE
WHEN t.category = 'Business Key Part' AND t.confidence_score < cl.value THEN 1
ELSE 0
END
) OVER (PARTITION BY s.schema_name, s.table_name) AS bk_hold,
SUM(
CASE
WHEN t.category = 'Business Key Part' THEN 1
ELSE 0
END
) OVER (PARTITION BY s.schema_name, s.table_name) AS bkp_cnt
FROM auto_dw.source_objects AS s
JOIN confidence_level AS cl ON true
LEFT JOIN source_object_transformation_latest AS t ON s.pk_source_objects = t.fk_source_objects
Expand All @@ -364,9 +370,15 @@ pub fn insert_into_build_call(
SELECT *,
CASE
WHEN confidence_score IS NULL THEN 'Queued for Processing'
WHEN category = 'Business Key Part' AND confidence_score >= cl.value THEN 'Ready to Deploy'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 0 THEN 'Ready to Deploy'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 1 THEN 'Ready to Deploy - Awaiting Business Key (BK)'
-- Links
WHEN category = 'Business Key Part' AND confidence_score >= cl.value AND bkp_cnt > 1 THEN 'Ready to Deploy - Awaiting Link Implementation'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 0 AND bkp_cnt > 1 THEN 'Ready to Deploy - Awaiting Link Implementation'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 1 AND bkp_cnt > 1 THEN 'Ready to Deploy - Awaiting Business Key (BK), Awaiting Link Implementation'
-- Hubs
WHEN category = 'Business Key Part' AND confidence_score >= cl.value THEN 'Ready to Deploy'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 0 THEN 'Ready to Deploy'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 1 THEN 'Ready to Deploy - Awaiting Business Key (BK)'
ELSE 'Requires Attention'
END AS status,
CASE
Expand Down Expand Up @@ -456,7 +468,13 @@ pub fn source_column(accepted_transformer_confidence_level: &str) -> String {
WHEN t.category = 'Business Key Part' AND t.confidence_score < cl.value THEN 1
ELSE 0
END
) OVER (PARTITION BY s.schema_name, s.table_name) AS bk_hold
) OVER (PARTITION BY s.schema_name, s.table_name) AS bk_hold,
SUM(
CASE
WHEN t.category = 'Business Key Part' THEN 1
ELSE 0
END
) OVER (PARTITION BY s.schema_name, s.table_name) AS bkp_cnt
FROM auto_dw.source_objects AS s
JOIN confidence_level AS cl ON true
LEFT JOIN source_object_transformation_latest AS t ON s.pk_source_objects = t.fk_source_objects
Expand All @@ -465,12 +483,18 @@ pub fn source_column(accepted_transformer_confidence_level: &str) -> String {
source_object AS (
SELECT *,
CASE
WHEN confidence_score IS NULL THEN 'Queued for Processing'
WHEN category = 'Business Key Part' AND confidence_score >= cl.value THEN 'Ready to Deploy'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 0 THEN 'Ready to Deploy'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 1 THEN 'Ready to Deploy - Awaiting Business Key (BK)'
ELSE 'Requires Attention'
END AS status,
WHEN confidence_score IS NULL THEN 'Queued for Processing'
-- Links
WHEN category = 'Business Key Part' AND confidence_score >= cl.value AND bkp_cnt > 1 THEN 'Ready to Deploy - Awaiting Link Implementation'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 0 AND bkp_cnt > 1 THEN 'Ready to Deploy - Awaiting Link Implementation'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 1 AND bkp_cnt > 1 THEN 'Ready to Deploy - Awaiting Business Key (BK), Awaiting Link Implementation'
-- Hubs
WHEN category = 'Business Key Part' AND confidence_score >= cl.value THEN 'Ready to Deploy'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 0 THEN 'Ready to Deploy'
WHEN category <> 'Business Key Part' AND confidence_score >= cl.value AND bk_hold = 1 THEN 'Ready to Deploy - Awaiting Business Key (BK)'
ELSE 'Requires Attention'
END AS status,
CASE
WHEN confidence_score IS NOT NULL THEN CONCAT((confidence_score * 100)::INT::TEXT, '%')
ELSE '-'
Expand Down

0 comments on commit 86d7338

Please sign in to comment.