Used to execute a SQL query against table(s) in Redivis, using the Redivis SQL query syntax, and read out the results.
Constructors
Examples
library("redivis")
# Execute any SQL query and read the results
query <- redivis$query("SELECT 1 + 1 AS two, 'foo' AS bar")
query$to_tibble()
# two bar
# 0 2 foo
# The query can reference any table on Redivis
query <- redivis$query("
SELECT *
FROM demo.iris_species.iris
WHERE SepalLengthCm > 5
")
query$to_tibble()
# Id SepalLengthCm SepalWidthCm PetalLengthCm PetalWidthCm Species
# 0 33 5.2 4.1 1.5 0.1 Iris-setosa
# ...
# Other methods to read data:
# query$to_arrow_batch_reader()
# query$to_arrow_dataset()
# query$to_arrow_dataset()
# query$to_data_frame()
# query$to_data_table()
# query$to_sf_tibble()
loadNamespace("redivis")
# To simplify table references, execute a query scoped to a dataset or workflow
dataset = redivis$organization("Demo").dataset("CMS 2014 Medicare Data")
query = dataset$query("""
SELECT
hospice_providers.name,
inpatient_charges.drg_definition
-- The tables inpatient_chargers, hospice_providers are assumed to be
-- within the scoped dataset
FROM inpatient_charges
INNER JOIN hospice_providers
ON hospice_providers.provider_id = inpatient_charges.provider_id
""")
# In a notebook, all queries are scoped to the current workflow.
# Additionally, the notebooks source table can simply be referenced as _source_
query = redivis$query("SELECT * FROM _source_ LIMIT 10")
Fields
properties
Methods
Download all files represented by a file_id variable in the query results to a local directory.
Fetch query metadata. Once called, the properties attribute on the query will be fully populated.
Execute a SQL query within the (either a dataset or workflow).
In a Redivis notebook, the default scope will always be the notebook's workflow, and the notebook's source table can be referenced via the _source_ identifier.
If no default scope is specified, all tables in the query must be fully qualified. Consult the documentation to learn more.
(query_string)
Execute a SQL query scoped to a specific . Tables referenced by the query do not need to be fully qualified, since the table lookup is already scoped to the dataset.
Consult the documentation to learn more.
(query_string)
Execute a SQL query scoped to a specific . Tables referenced by the query do not need to be fully qualified, since the table lookup is already scoped to the dataset.
Consult the documentation to learn more.
A named list containing the . This will always be populated after the query has been created, and can be refreshed by calling query.get()
([path, *, overwrite, ...])
()
([max_results, ...])
Return a list of instances for query results containing a file_id variable.
([...])
Returns a reader that mimics the , which can then be consumed to process batches of rows in a streaming fashion.
([max_results, ...])
Return an for the table. Data is backed by disk, allowing for larger-than-memory analysis.
([max_results, ...])
Return an with the table's data. This is the highest-performance option for loading data in-memory.
([max_results, ...])
Return a with the table's data.
([max_results, ...])
Return a with the table's data.
([max_results, variables, ...])
Return a with the table's data.
([max_results, ...])
Return a with a table's data. Used for tables that contain a geography variable.