cloudos.query: Execute SQL Query (Orchestrator)

View source: R/query.R

cloudos.queryR Documentation

Execute SQL Query (Orchestrator)

Description

High-level function that orchestrates the full query lifecycle: submit -> poll status -> fetch results as dataframe.

Usage

cloudos.query(
  profilename = "",
  cohort_id = "",
  sql = "",
  poll_interval = 2,
  max_wait = 600,
  page_size = 1000,
  all_pages = TRUE
)

Arguments

profilename

Character. Name of the configured profile to use. If empty or NULL, uses the default profile.

cohort_id

Character. ID of the cohort to query.

sql

Character. SQL query to execute.

poll_interval

Integer. Seconds between status checks (default: 2).

max_wait

Integer. Maximum seconds to wait for completion (default: 600).

page_size

Integer. Number of rows per page (default: 1000).

all_pages

Logical. Fetch all result pages automatically (default: TRUE). When TRUE, submits multiple async tasks (one per page) to fetch complete results.

Details

IMPORTANT: Pagination works by submitting separate tasks for each page. When all_pages=TRUE, this function submits multiple async tasks (one per page), waits for all to complete, and combines the results. This may take longer for large result sets.

Value

Data frame with query results.

Examples

## Not run: 
  # Fetch all results
  results <- cloudos.query(
    profilename = "production",
    cohort_id = "699edb4380a6867895f0c9e1",
    sql = "SELECT person_id, gender_concept_id FROM person LIMIT 500"
  )
  
  # Fetch only first page
  results_page1 <- cloudos.query(
    profilename = "production",
    cohort_id = "699edb4380a6867895f0c9e1",
    sql = "SELECT person_id FROM person",
    all_pages = FALSE,
    page_size = 100
  )

## End(Not run)

cloudosR documentation built on June 1, 2026, 5:07 p.m.