зеркало из https://github.com/Azure/AzureKusto.git
condition a few tests on tidyr package version, remove some rlang functions that are deprecated in v 0.4.0
This commit is contained in:
Родитель
b695bf3197
Коммит
b89652b26b
|
@ -1,6 +1,6 @@
|
|||
Package: AzureKusto
|
||||
Title: Interface to 'Kusto'/'Azure Data Explorer'
|
||||
Version: 1.0.2
|
||||
Version: 1.0.3
|
||||
Authors@R: c(
|
||||
person("Hong", "Ooi", , "hongooi@microsoft.com", role = c("aut", "cre")),
|
||||
person("Alex", "Kyllo", , "jekyllo@microsoft.com", role = "aut"),
|
||||
|
|
|
@ -298,7 +298,7 @@ flatten_query <- function(op, ops=list())
|
|||
if (is_empty(ops))
|
||||
new_ops <- list(flat_op)
|
||||
else
|
||||
new_ops <- prepend(ops, list(flat_op))
|
||||
new_ops <- c(list(flat_op), ops)
|
||||
if (inherits(op, "op_base"))
|
||||
return(new_ops)
|
||||
else
|
||||
|
|
4
R/ops.R
4
R/ops.R
|
@ -152,7 +152,7 @@ add_suffixes <- function(x, y, suffix)
|
|||
{
|
||||
if (identical(suffix, "")) return(x)
|
||||
|
||||
out <- chr_along(x)
|
||||
out <- rep_len(na_chr, length(x))
|
||||
for (i in seq_along(x))
|
||||
{
|
||||
nm <- x[[i]]
|
||||
|
@ -244,7 +244,7 @@ op_vars.op_select <- function(op)
|
|||
#' @export
|
||||
op_vars.op_rename <- function(op)
|
||||
{
|
||||
names(rename_vars(op_vars(op$x), !!! op$dots))
|
||||
names(tidyselect::vars_rename(op_vars(op$x), !!! op$dots))
|
||||
}
|
||||
|
||||
#' @export
|
||||
|
|
|
@ -4,7 +4,8 @@ context("translate")
|
|||
tbl_iris <- tibble::as_tibble(iris)
|
||||
names(tbl_iris) <- c("SepalLength", "SepalWidth", "PetalLength", "PetalWidth", "Species")
|
||||
tbl_iris <- tbl_kusto_abstract(tbl_iris, "iris")
|
||||
|
||||
tidyr_version <- as.character(packageVersion("tidyr"))
|
||||
is_new_tidyr <- compareVersion(tidyr_version, '0.8.3') == 1
|
||||
|
||||
test_that("params to a function can be used inside a mutate expressions",
|
||||
{
|
||||
|
@ -578,38 +579,56 @@ test_that("unnest can handle multiple columns",
|
|||
|
||||
list_tbl <- tbl_kusto_abstract(list_df, table_name = "list_tbl")
|
||||
|
||||
q <- list_tbl %>%
|
||||
tidyr::unnest(y, z)
|
||||
if (is_new_tidyr)
|
||||
{
|
||||
q <- list_tbl %>%
|
||||
tidyr::unnest(c(y, z))
|
||||
}
|
||||
else
|
||||
{
|
||||
q <- list_tbl %>%
|
||||
tidyr::unnest(y, z)
|
||||
}
|
||||
|
||||
q_str <- show_query(q)
|
||||
expect_equal(q_str, kql("cluster('local_df').database('local_df').['list_tbl']\n| mv-expand ['y'], ['z']"))
|
||||
|
||||
})
|
||||
|
||||
test_that("unnest .id translates to with_itemindex",
|
||||
if (!is_new_tidyr)
|
||||
{
|
||||
test_that("unnest .id translates to with_itemindex",
|
||||
{
|
||||
|
||||
list_df <- tibble::tibble(
|
||||
x = 1:2,
|
||||
y = list(a = 1, b = 3:4)
|
||||
)
|
||||
list_df <- tibble::tibble(
|
||||
x = 1:2,
|
||||
y = list(a = 1, b = 3:4)
|
||||
)
|
||||
|
||||
list_tbl <- tbl_kusto_abstract(list_df, table_name = "list_tbl")
|
||||
list_tbl <- tbl_kusto_abstract(list_df, table_name = "list_tbl")
|
||||
|
||||
q <- list_tbl %>%
|
||||
tidyr::unnest(y, .id = "name")
|
||||
q <- list_tbl %>%
|
||||
tidyr::unnest(y, .id = "name")
|
||||
|
||||
q_str <- show_query(q)
|
||||
q_str <- show_query(q)
|
||||
|
||||
expect_equal(q_str, kql("cluster('local_df').database('local_df').['list_tbl']\n| mv-expand with_itemindex=['name'] ['y']"))
|
||||
|
||||
})
|
||||
expect_equal(q_str, kql("cluster('local_df').database('local_df').['list_tbl']\n| mv-expand with_itemindex=['name'] ['y']"))
|
||||
})
|
||||
}
|
||||
|
||||
test_that("nest translates to summarize makelist()",
|
||||
{
|
||||
if (is_new_tidyr)
|
||||
{
|
||||
q <- tbl_iris %>%
|
||||
tidyr::nest(data = c(SepalLength, SepalWidth, PetalLength, PetalWidth))
|
||||
}
|
||||
else
|
||||
{
|
||||
q <- tbl_iris %>%
|
||||
tidyr::nest(SepalLength, SepalWidth, PetalLength, PetalWidth)
|
||||
}
|
||||
|
||||
q <- tbl_iris %>%
|
||||
tidyr::nest(SepalLength, SepalWidth, PetalLength, PetalWidth)
|
||||
|
||||
q_str <- show_query(q)
|
||||
expect_equal(q_str, kql("cluster('local_df').database('local_df').['iris']\n| summarize ['SepalLength'] = make_list(['SepalLength']), ['SepalWidth'] = make_list(['SepalWidth']), ['PetalLength'] = make_list(['PetalLength']), ['PetalWidth'] = make_list(['PetalWidth']) by ['Species']"))
|
||||
|
@ -628,8 +647,16 @@ test_that("nest respects preceding group_by",
|
|||
|
||||
test_that("nest nests all non-provided columns",
|
||||
{
|
||||
q <- tbl_iris %>%
|
||||
if (is_new_tidyr)
|
||||
{
|
||||
q <- tbl_iris %>%
|
||||
tidyr::nest(data = c(-Species))
|
||||
}
|
||||
else
|
||||
{
|
||||
q <- tbl_iris %>%
|
||||
tidyr::nest(-Species)
|
||||
}
|
||||
|
||||
q_str <- show_query(q)
|
||||
expect_equal(q_str, kql("cluster('local_df').database('local_df').['iris']\n| summarize ['SepalLength'] = make_list(['SepalLength']), ['SepalWidth'] = make_list(['SepalWidth']), ['PetalLength'] = make_list(['PetalLength']), ['PetalWidth'] = make_list(['PetalWidth']) by ['Species']"))
|
||||
|
|
Загрузка…
Ссылка в новой задаче