diff --git a/NAMESPACE b/NAMESPACE index 5a6d8ad..f491d2b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -38,6 +38,7 @@ S3method(kql_build,op_mutate) S3method(kql_build,op_rename) S3method(kql_build,op_select) S3method(kql_build,op_set_op) +S3method(kql_build,op_slice_sample) S3method(kql_build,op_summarise) S3method(kql_build,op_ungroup) S3method(kql_build,op_unnest) @@ -80,6 +81,7 @@ S3method(semi_join,tbl_kusto_abstract) S3method(setdiff,tbl_kusto_abstract) S3method(setequal,tbl_kusto_abstract) S3method(show_query,tbl_kusto_abstract) +S3method(slice_sample,tbl_kusto_abstract) S3method(summarise,tbl_kusto_abstract) S3method(tbl_vars,tbl_kusto_abstract) S3method(ungroup,tbl_kusto_abstract) diff --git a/R/kql-build.R b/R/kql-build.R index ce9d8aa..5349fe4 100644 --- a/R/kql-build.R +++ b/R/kql-build.R @@ -197,6 +197,13 @@ kql_build.op_head <- function(op, ...) build_kql("take ", kql(escape(n, parens = FALSE))) } +#' @export +kql_build.op_slice_sample <- function(op, ...) +{ + n <- lapply(op$args$n, translate_kql) + build_kql("sample ", kql(escape(n, parens = FALSE))) +} + #' @export kql_build.op_join <- function(op, ...) { diff --git a/R/tbl.R b/R/tbl.R index 2607af6..479533c 100644 --- a/R/tbl.R +++ b/R/tbl.R @@ -182,6 +182,12 @@ head.tbl_kusto_abstract <- function(x, n = 6L, ...) add_op_single("head", x, args = list(n = n)) } +#' @export +slice_sample.tbl_kusto_abstract <- function(x, n = 6L, ...) +{ + add_op_single("slice_sample", x, args = list(n = n)) +} + #' Join methods for Kusto tables #' #' These methods are the same as other joining methods, with the exception of the `.strategy`, `.shufflekeys` and `.num_partitions` optional arguments. They provide hints to the Kusto engine on how to execute the join, and can sometimes be useful to speed up a query. See the Kusto documentation for more details.