QueryBuilder Class
The QueryBuilder class provides methods for constructing well-formed SAQL queries to pass to CRM Analytics.
wave
Use QueryBuilder and its associated classes, Wave.ProjectionNode and Wave.QueryNode, to incrementally build your SAQL statement. For example:
QueryBuilder is the core of this first phase of the CRM Analytics Apex SDK, so let’s take a closer look. Here’s a simple count query.
The resulting SAQL query looks like this:
Here’s a more complex example that uses a union statement.
The resulting SAQL query has two projection streams, qa and qb.
The following are methods for QueryBuilder.
-
load(datasetID, datasetVersionID)
Load a stream from a dataset.
-
Calculate the number of rows that match the query criteria.
-
Query by selecting specific attributes.
-
Combine multiple result sets into one result set.
-
Cogrouping means that two input streams are grouped independently and arranged side by side. Only data that exists in both groups appears in the results.
Load a stream from a dataset.
public static wave.QueryNode load(String datasetID, String datasetVersionID)
-
datasetID:
Type: String
The ID of the dataset.
-
datasetVersionID:
Type: String
The ID identifying the version of the dataset.
Type: wave.QueryNode
Calculate the number of rows that match the query criteria.
public static wave.ProjectionNode count()
Type: wave.ProjectionNode
Query by selecting specific attributes.
public static wave.ProjectionNode get(String proj)
-
proj:
Type: String
The name of the column to query.
Type: wave.ProjectionNode
Combine multiple result sets into one result set.
global static Wave.QueryNode union(List<Wave.QueryNode> unionNodes)
-
unionNodes:
Type: List<wave.QueryNode>
List of nodes to combine.
Type: wave.QueryNode
Cogrouping means that two input streams are grouped independently and arranged side by side. Only data that exists in both groups appears in the results.
global static Wave.QueryNode cogroup(List<Wave.QueryNode> cogroupNodes, List<List<String>> groups)
-
cogroupNodes:
Type: wave.QueryNode
List of nodes to group.
-
groups:
Type: String
The type of grouping.
Type: wave.QueryNode