Learn R Programming

Causata (version 4.2-0)

FocalPointQuery: Build a focal point query.

Description

The FocalPointQuery class is used to generate SQL queries for Causata. The data in a focal point query is built around a particular event in a customer profile.

Usage

FocalPointQuery(focalpoint.event, cardinality=if (length(event.attribute)) {"using.all.values"} else {"using.all.events"}, event.attribute=NULL)

Arguments

focalpoint.event
The event to be used as a focal point.
cardinality
This controls which records are returned when there are multiple events in a profile. The default settings will return one or more records for a profile. See the Details section below.
event.attribute
If supplied, the focal point will be at the time given on this event attribute of the given event.

Value

A FocalPointQuery object based on the supplied event (and optional event attribute).

Details

The FocalPointQuery object builds a focal point query for profile records. A blank FocalPointQuery translates to the following:

"SELECT * FROM Scenarios variable, `focalpoint.event` WHERE variable.focal_point = `focalpoint.event`.timestamp"

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

When a customer event stream is loaded, there may be multple events that match the focal point event and where clauses. In this case one or more profile records (rows) may be returned for a single customer. The cardinality argument defines how which records are output.

When there is no event.attribute specified, the legal values for this argument and their meanings are:

  • "using.all.events" For each occurance of the focal point event (that match the where clauses) there will be a customer record with the timestamp of that event as the focal point.
  • "using.oldest.event" When multiple events match the focal point query, the event with the smallest (oldest) timestamp is used to build the customer record.
  • "using.newest.event" When multiple events match the focal point query, the event with the largest (newest) timestamp is used to build the customer record.

When an event.attribute is specified, then the legal values for this argument and thier meanings are:

  • "using.all.values" All values for the attribute on all match focal point events are used to build customer records, with the value of those attributes as the focal point point for the record.
  • "using.earliest.value" The value of the attribute on the event with the smallest (earliest) timestamp is used as the focal point time.
  • "using.most.recent.value" The value of the attribute on the event with the largest (most recent) timestamp is used as the focal point time.

See Also

FocalPointQuery, Connect, WithVariables, Variables, Where, Limit, CausataData.

Examples

Run this code
# This example builds a query returning a profile at each purchase event 
# with a price greater than $30
query <- FocalPointQuery("purchase") + WithVariables(c("some", "variables")) + 
  Where("purchase-price$Same Session", GreaterThan(30)) + Limit(1000)
as.character(query)

Run the code above in your browser using DataLab