Skip to content

Commit

Permalink
add new etl_pipe() function replacing less generic pipe_table()
Browse files Browse the repository at this point in the history
  • Loading branch information
vh-d committed Oct 11, 2019
1 parent 12197ca commit 02fa20c
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: RETL
Type: Package
Title: Various tools for ETL
Version: 0.1.10.9004
Version: 0.1.10.9005
Author: Vaclav Hausenblas
Maintainer: Vaclav Hausenblas <vaclav.hausenblas@gmail.com>
Description: Provides function for ETL pipelines such as extraction, loading, tranformation, conversion...
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export(Date2Char)
export(add_diff_value)
export(convert_cols)
export(dtq)
export(etl_pipe)
export(etl_read)
export(etl_write)
export(excel_worksheets)
Expand Down
50 changes: 50 additions & 0 deletions R/pipes.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,56 @@ pipe_tables <- function(tables, ...) {
}


#' complete ETL pipe
#'
#' @param from DBI/R environment/file name/...
#' @param to DBI/R environment/file name/...
#' @param transform transformation function
#' @param read_args list of arguments passed to read/extract function
#' @param write_args list of arguments passed to write/load function
#' @param asDT logical; convert the data.frame to data.table during the etl?
#'
#' @rdname pipe_table
#' @export
etl_pipe <- function(
from,
to,
transform = NULL,
read_args = list(),
write_args = list(overwrite = TRUE),
asDT = TRUE,
lowercase = FALSE
) {

# EXTRACT/READ
DT <- do.call(
what = etl_read,
args = union.list(
list(
from = from,
asDT = asDT
),
read_args
)
)

# TRANFORM
if (!is.null(transform)) DT <- transform(DT)

# WRITE
do.call(
what = etl_write,
args = union.list(
list(
to = to,
x = DT
),
write_args
)
)

}

#' Read (extract) part of ETL
#' reading tables
#'
Expand Down
19 changes: 19 additions & 0 deletions man/pipe_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 02fa20c

Please sign in to comment.