Skip to contents

Builds a SELECT ... FROM `project`.`dataset`.`table` string with identifier validation and backtick-quoting. where is passed through unchanged; callers compose SQL fragments themselves and are responsible for not injecting hostile clauses (same contract as morie_ingest_bigquery_query).

Usage

morie_ingest_bigquery_build_sql(
  project,
  dataset,
  table,
  where = NULL,
  limit = NULL,
  select = "*"
)

Arguments

project, dataset, table

Fully-qualified BigQuery table reference, e.g. project "bigquery-public-data", dataset "chicago_crime", table "crime".

where

Optional raw SQL WHERE clause (no leading WHERE).

limit

Optional LIMIT.

select

Projection list (default "*").

Value

A SQL string.

Examples

if (requireNamespace("bigrquery", quietly = TRUE)) {
  morie_ingest_bigquery_build_sql(
    project = "bigquery-public-data",
    dataset = "chicago_crime",
    table   = "crime",
    where   = "year = 2024",
    limit   = 10000L
  )
}
#> [1] "SELECT * FROM `bigquery-public-data`.`chicago_crime`.`crime`\nWHERE year = 2024\nLIMIT 10000"