is_working_db: Rule check on the database

View source: R/is_working.R

is_working_dbR Documentation

Rule check on the database

Description

Get an indication of which R statement can be executed on the SQL database. dcmodifydb translates R statements into SQL statement. This works for many scenario's but not all R statements can be translated into SQL. This function checks whether a modification rule can be executed on the database.

Usage

is_working_db(m, tab, n = 2, warn = TRUE, sql_warn = FALSE)

Arguments

m

modifier() object

tab

tbl object

n

number of records to use in this check

warn

generate warnings for non-working rules

sql_warn

generate warnings with sql code for non-working rules

Value

logical with which statements are working

Examples

person <- dbplyr::memdb_frame(age = 12, salary = 3000)

library(dcmodify)

correction_rules <- modifier( if (age < 16) salary = 0
                            , if (retired == TRUE) salary = 0
                            )

# second rule is not working, because retired is not available
is_working_db(correction_rules, person, warn = FALSE)

# show warnings (default)
is_working_db(correction_rules, person, warn = TRUE)

# show the sql statements that are not working
is_working_db(correction_rules, person, warn = FALSE, sql_warn = TRUE)

dcmodifydb documentation built on June 17, 2022, 5:05 p.m.