Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions ggsql-R/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
^ggsql\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^\.vscode$
^src/\.cargo$
^src/rust/vendor$
^src/rust/target$
^src/Makevars$
^src/Makevars\.win$
13 changes: 13 additions & 0 deletions ggsql-R/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
.Rproj.user
src/rust/vendor
src/rust/target
src/Makevars
src/Makevars.win
src/*.o
src/*.so
src/*.dll
src/rust/test_files
# Bootstrapped workspace crates (generated by tools/bootstrap.R)
src/Cargo.toml
src/Cargo.lock
src/ggsql-lib
src/tree-sitter-ggsql
13 changes: 13 additions & 0 deletions ggsql-R/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"rust-analyzer.linkedProjects": [
"${workspaceFolder}/src/rust/Cargo.toml"
],
"files.associations": {
"Makevars.in": "makefile",
"Makevars.win": "makefile",
"configure": "shellscript",
"configure.win": "shellscript",
"cleanup": "shellscript",
"cleanup.win": "shellscript"
}
}
16 changes: 12 additions & 4 deletions ggsql-R/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ggsql
Title: A SQL extension for declarative data visualization based on the Grammar of Graphics
Version: 0.0.0.9000
Version: 0.1.9
Authors@R: c(
person("George", "Stagg", , "george.stagg@posit.co", role = c("aut", "cre"),
comment = c(ORCID = "0009-0006-3173-9846")),
Expand All @@ -15,17 +15,25 @@ Description: ggsql allows you to write queries that combine SQL data retrieval
with visualization specifications in a single, composable syntax.
License: MIT + file LICENSE
Encoding: UTF-8
SystemRequirements: ggsql
SystemRequirements: Cargo (Rust's package manager), rustc
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.3
Imports:
cli,
jsonlite,
knitr,
rlang,
vegawidget
nanoarrow,
R6,
rlang
Suggests:
png,
reticulate,
vegawidget,
rsvg,
testthat (>= 3.0.0),
V8,
withr
Config/testthat/edition: 3
Config/rextendr/version: 0.4.2.9000
Depends:
R (>= 4.2)
31 changes: 31 additions & 0 deletions ggsql-R/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
# Generated by roxygen2: do not edit by hand

S3method("$",GgsqlReader)
S3method("$",GgsqlSpec)
S3method("$",GgsqlWriter)
S3method("$",ggsql_tables)
S3method("[[",GgsqlReader)
S3method("[[",GgsqlSpec)
S3method("[[",GgsqlWriter)
S3method("[[",ggsql_tables)
S3method(names,ggsql_tables)
S3method(print,ggsql_tables)
S3method(print,ggsql_validated)
export(duckdb_reader)
export(ggsql_execute)
export(ggsql_execute_sql)
export(ggsql_has_visual)
export(ggsql_is_valid)
export(ggsql_layer_count)
export(ggsql_layer_data)
export(ggsql_layer_sql)
export(ggsql_metadata)
export(ggsql_register)
export(ggsql_render)
export(ggsql_sql)
export(ggsql_stat_data)
export(ggsql_stat_sql)
export(ggsql_unregister)
export(ggsql_validate)
export(ggsql_visual)
export(ggsql_warnings)
export(vegalite_writer)
importFrom(rlang,on_load)
importFrom(rlang,run_on_load)
useDynLib(ggsql, .registration = TRUE)
27 changes: 27 additions & 0 deletions ggsql-R/R/convert.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#' Convert a data.frame to Arrow IPC stream bytes
#' @param df A data.frame.
#' @return Raw vector of Arrow IPC stream bytes.
#' @noRd
df_to_ipc <- function(df) {
# Convert factors to character — nanoarrow doesn't support dictionary IPC encoding
factor_cols <- vapply(df, is.factor, logical(1))
if (any(factor_cols)) {
df[factor_cols] <- lapply(df[factor_cols], as.character)
}
stream <- nanoarrow::as_nanoarrow_array_stream(df)
con <- rawConnection(raw(0), "wb")
on.exit(close(con))
nanoarrow::write_nanoarrow(stream, con)
rawConnectionValue(con)
}

#' Convert Arrow IPC stream bytes to a data.frame
#' @param ipc_bytes Raw vector of Arrow IPC stream bytes.
#' @return A data.frame.
#' @noRd
ipc_to_df <- function(ipc_bytes) {
con <- rawConnection(ipc_bytes, "rb")
on.exit(close(con))
stream <- nanoarrow::read_nanoarrow(con)
as.data.frame(stream)
}
Loading
Loading