<code>
library(ggplot2)
library(dbplyr)
library(aitoolbox)
library(dplyr)
library(DBI)
<- aitoolbox::connect_to_azure()
pool
<- function(pool, my_variable_name, table1, table2){
auto_plot <- DBI::dbQuoteIdentifier(DBI::Id(schema = "BI_FLOAT_AY", table = table1), conn = pool)
a_float_table <- DBI::dbQuoteIdentifier(DBI::Id(schema = "BI_FLOAT_AY", table = table2), conn = pool)
another_float_table
<- "
my_sql_query SELECT DISTINCT
ROLLING_YEAR ,
{`my_variable_name`},
count(*) as count
FROM (
select ROLLING_YEAR, {`my_variable_name`} from {a_float_table}
union all
select ROLLING_YEAR, {`my_variable_name`} from {another_float_table}
) as combined
GROUP BY ROLLING_YEAR, {`my_variable_name`}
"
<- glue::glue_sql(my_sql_query, .con = pool)
updated_sql_query <- dbGetQuery(pool, updated_sql_query)
downloaded_data
%>%
downloaded_data ggplot(aes(x = factor(ROLLING_YEAR), y = count, fill = .data[[my_variable_name]])) +
geom_col()
}auto_plot(pool = pool ,
my_variable_name = "RISKPROVINCE",
table1 = "LC_A_240829_090557",
table2 = "LC_A_240829_090534")