sql_build

0th

Percentile

Build and render SQL from a sequence of lazy operations

sql_build() creates a select_query S3 object, that is rendered to a SQL string by sql_render(). The output from sql_build() is designed to be easy to test, as it's database agnostic, and has a hierarchical structure.

Keywords
internal
Usage
sql_build(op, con = NULL, ...)

sql_optimise(x, con = NULL, ...)

select_query(from, select = sql("*"), where = character(), group_by = character(), having = character(), order_by = character(), limit = NULL, distinct = FALSE)

join_query(x, y, vars, type = "inner", by = NULL, suffix = c(".x", ".y"))

semi_join_query(x, y, anti = FALSE, by = NULL)

set_op_query(x, y, type = type)

sql_render(query, con = NULL, ...)

Arguments
op

A sequence of lazy operations

con

A database connection. The default NULL uses a set of rules that should be very similar to ANSI 92, and allows for testing without an active database connection.

...

Other arguments passed on to the methods. Not currently used.

Details

sql_build() is generic over the lazy operations, lazy_ops, and generates an S3 object that represents the query. sql_render() takes a query object and then calls a function that is generic over the database. For example, sql_build.op_mutate() generates a select_query, and sql_render.select_query() calls sql_select(), which has different methods for different databases. The default methods should generate ANSI 92 SQL where possible, so you backends only need to override the methods if the backend is not ANSI compliant.

Aliases
  • sql_build
  • sql_optimise
  • select_query
  • join_query
  • semi_join_query
  • set_op_query
  • sql_render
Documentation reproduced from package dbplyr, version 1.2.1, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.