Skip to content

Commit d8cfb72

Browse files
authored
Merge pull request #18 from Azure/export-1.1.0
Add export(), slice_sample(), $ for dynamic field access, default auth_type to authorization_code
2 parents a67cfcb + d65a9bb commit d8cfb72

File tree

17 files changed

+418
-25
lines changed

17 files changed

+418
-25
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ drat.sh
1212
cran-comments.md
1313
SECURITY.md
1414
^CRAN-SUBMISSION$
15+
^\.vscode$

.github/workflows/check-standard.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ jobs:
3939
xargs -L1 git config --unset-all
4040
git push --prune https://token:[email protected]/${CLOUDYR_REPO}.git +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*
4141
42-
- uses: r-lib/actions/setup-r@master
42+
- uses: r-lib/actions/setup-r@v2
4343
with:
4444
r-version: ${{ matrix.config.r }}
4545

46-
- uses: r-lib/actions/setup-pandoc@master
46+
- uses: r-lib/actions/setup-pandoc@v2
4747

4848
- name: Query dependencies
4949
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,5 @@ flycheck_*.el
315315
.env
316316
test-creds.*
317317
inst/doc
318+
.Renviron
319+
.vscode/**

CRAN-SUBMISSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 1.0.7
2-
Date: 2022-08-26 15:26:38 UTC
3-
SHA: f909d6d216d4b10be3fc955132522a4587d8197c
1+
Version: 1.1.0
2+
Date: 2022-12-20 21:59:53 UTC
3+
SHA: 8527843af417cafd880915b0b1ee63e52bb3ff0d

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: AzureKusto
22
Title: Interface to 'Kusto'/'Azure Data Explorer'
3-
Version: 1.0.7
3+
Version: 1.1.0
44
Authors@R: c(
55
person("Hong", "Ooi", , "[email protected]", role = "aut"),
66
person("Alex", "Kyllo", , "[email protected]", role = c("aut", "cre")),

NAMESPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ S3method(escape,integer64)
1919
S3method(escape,kql)
2020
S3method(escape,list)
2121
S3method(escape,logical)
22+
S3method(export,kusto_database_endpoint)
23+
S3method(export,tbl_kusto)
2224
S3method(filter,tbl_kusto_abstract)
2325
S3method(full_join,tbl_kusto_abstract)
2426
S3method(group_by,tbl_kusto_abstract)
@@ -38,6 +40,7 @@ S3method(kql_build,op_mutate)
3840
S3method(kql_build,op_rename)
3941
S3method(kql_build,op_select)
4042
S3method(kql_build,op_set_op)
43+
S3method(kql_build,op_slice_sample)
4144
S3method(kql_build,op_summarise)
4245
S3method(kql_build,op_ungroup)
4346
S3method(kql_build,op_unnest)
@@ -80,6 +83,7 @@ S3method(semi_join,tbl_kusto_abstract)
8083
S3method(setdiff,tbl_kusto_abstract)
8184
S3method(setequal,tbl_kusto_abstract)
8285
S3method(show_query,tbl_kusto_abstract)
86+
S3method(slice_sample,tbl_kusto_abstract)
8387
S3method(summarise,tbl_kusto_abstract)
8488
S3method(tbl_vars,tbl_kusto_abstract)
8589
S3method(ungroup,tbl_kusto_abstract)
@@ -97,6 +101,7 @@ export(base_window)
97101
export(build_kql)
98102
export(delete_kusto_token)
99103
export(escape)
104+
export(export)
100105
export(filter)
101106
export(flatten_query)
102107
export(get_kusto_token)

NEWS.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
# AzureKusto 1.1.0
2+
3+
* New function `export()` to export query results to Azure Storage.
4+
* `server` argument of `kusto_database_endpoint` can be just cluster name and no
5+
longer needs to be the fully qualified URI. E.g. can pass either
6+
`server = "help"` or `server = "https://help.kusto.windows.net"`
7+
* Changed default `get_kusto_token()` auth_type from "device_code" to
8+
"authorization_code" for easier to use sign-in flow.
9+
* Added `$` as an infix operator in a KQL expression now translates to `.` to
10+
enable nested dynamic field access.
11+
* Added `slice_sample` dplyr verb
12+
113
# AzureKusto 1.0.7
214

315
* Re-release to resolve "Version contains large components" note.
4-
*
16+
517
# AzureKusto 1.0.6.9001
618

719
* Regenerate .Rd files for R 4.2+ using updated Roxygen to fix HTML5 issues.

R/endpoint.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ kusto_database_endpoint <- function(..., .connection_string=NULL, .query_token=N
9393
# fix all property names to a given (sub)set, remove quotes from quoted values
9494
props <- normalize_connstring_properties(props)
9595

96+
# Make bare cluster name into FQDN for server if it's not already
97+
if (!startsWith(props$server, "https://"))
98+
{
99+
props$server <- paste0("https://", props$server)
100+
if (!endsWith(props$server, ".kusto.windows.net"))
101+
props$server <- paste0(props$server, ".kusto.windows.net")
102+
}
96103
props$token <- find_endpoint_token(props, .query_token)
97104

98105
props$use_integer64 <- .use_integer64
@@ -109,7 +116,7 @@ normalize_connstring_properties <- function(properties)
109116
property_list <- list(
110117
# general properties
111118
traceclientversion="traceclientversion",
112-
server=c("server", "addr", "address", "network address", "datasource", "host"),
119+
server=c("server", "addr", "address", "network address", "datasource", "host", "cluster"),
113120
database=c("database", "initialcatalog", "dbname"),
114121
tenantid=c("tenantid", "authority"),
115122
queryconsistency="queryconsistency",
@@ -182,7 +189,7 @@ find_endpoint_token <- function(properties, .query_token)
182189
{
183190
message("No app ID supplied; using KustoClient app")
184191
properties$appclientid <- .kusto_app_id
185-
auth_type <- "device_code"
192+
auth_type <- "authorization_code"
186193
}
187194
else auth_type <- NULL # KustoClient needs devicecode, otherwise let get_azure_token choose
188195

R/kql-build.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ kql_build.op_head <- function(op, ...)
197197
build_kql("take ", kql(escape(n, parens = FALSE)))
198198
}
199199

200+
#' @export
201+
kql_build.op_slice_sample <- function(op, ...)
202+
{
203+
n <- lapply(op$args$n, translate_kql)
204+
build_kql("sample ", kql(escape(n, parens = FALSE)))
205+
}
206+
200207
#' @export
201208
kql_build.op_join <- function(op, ...)
202209
{

R/kusto_token.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ get_kusto_token <- function(server=NULL, clustername, location=NULL, tenant=NULL
5555
if(version == 2 && httr::parse_url(server)$path == "")
5656
server <- c(paste0(sub("/$", "", server), "/.default"), "offline_access", "openid")
5757

58-
# KustoClient requires devicecode auth if username not supplied
58+
# Used to default to "device_code" but "authorization_code" has better ease of use
59+
# and also works with .kusto_app_id without supplying a username.
5960
if(is.null(auth_type) && app == .kusto_app_id && (!"username" %in% names(list(...))))
60-
auth_type <- "device_code"
61+
auth_type <- "authorization_code"
6162

6263
AzureAuth::get_azure_token(server, tenant, app, auth_type=auth_type, version=version, ...)
6364
}

0 commit comments

Comments
 (0)