Query: Build queries to extract data from Causata.

Description Usage Arguments Details Value Author(s) See Also Examples

Description

The Query class is used to generate SQL queries for Causata. The queries are built with the helper objects WithVariables, Where and Limit. SQL is generated when as.character() is invoked on the query object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
Query()

## S3 method for class 'Query'
Limit(this, ...)

## S3 replacement method for class 'Query'
Limit(this) <- value

## S3 method for class 'Query'
Variables(this, ...)

## S3 replacement method for class 'Query'
Variables(this) <- value


WithVariables(...)

Arguments

this

A query object.

value

For Query this is a number indicating the maximum number of records to return. For Variables this is one or more variable names in a list.

...

For WithVariables this is a single variable, or a list of variables. For Query and Variables this is unused extra arguments.

Details

The Query object builds a query for customer data, a blank Query corresponds to

SELECT * FROM Customers variable

This query can be made more specific by adding variables with WithVariables, adding where clauses with Where or setting a row limit with Limit. The actual SQL query can be generated with as.character, e.g. as.character(Query()).

The variables and limit can be retrieved and modified with Variables(query) and Limit(query) respectively.

Value

Query returns a blank Query object.

Author(s)

David Barker, Justin Hemann (support@causata.com)

See Also

FocalPointQuery, Connect, Variables, Where, CausataData, is.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
q <- Query()
q <- q + WithVariables(c("var1", "var2"))
q <- q + Where("variable-one", GreaterThan(30))
Variables(q) # returns c("var1", "var2")
Variables(q) <- c("var2", "var3") # set the variables for this query
Limit(q) # since the limit has not been set this returns NULL
Limit(q) <- 1000 # Sets the limit to 1000
as.character(q)

q <- Query() + WithVariables("variable-one", "variable-two") + 
  Where("variable-one", GreaterThan(5))
# The example below is commented out since it requires a server connection.
# With a connection this would retrieve data and return it in a dataframe df.
## Not run: 
conn <- Connect(hostname, port, username, password)
data <- GetData(conn, q)

## End(Not run)

Causata documentation built on May 2, 2019, 3:26 a.m.

Related to Query in Causata...