if (FALSE) {
library(sparklyr)
sc <- spark_connect(master = "local", version = "2.2.0")
streaming_path <- tempfile("days_df_")
days_df <- tibble::tibble(
today = weekdays(as.Date(seq(7), origin = "1970-01-01"))
)
num_iters <- 7
stream_generate_test(
df = days_df,
path = streaming_path,
distribution = rep(nrow(days_df), num_iters),
iterations = num_iters
)
stream_read_csv(sc, streaming_path) %>%
stream_lag(cols = c(yesterday = today ~ 1, two_days_ago = today ~ 2)) %>%
collect() %>%
print(n = 10L)
}
Run the code above in your browser using DataLab