A Basic RAQL Query
You use mashups in Business Analytics to access and work with small or large datasets. To work with large datasets, mashups use EMML extension statements specifically designed for MashZone NextGen Analytics and the RAQL query language.
Tip: | If you are not yet familiar with creating mashups or EMML, try the EMML in 15 Minutes tutorial for a brief introduction. |
To work with large datasets, a mashup must:
1. Load the dataset and give it a name.
This example loads the dataset directly from a file. You can also load data from URLs, databases, snapshots, any Business Analytics mashable or mashup or from datasets already stored in one of the MashZone NextGen Analytics In-Memory Stores.
This example also ensures that the data is loaded using a stream. Streaming helps performance and also prevents the dataset from being treated as a document. Only RAQL queries or other RAQL extensions to EMML can work with dataset streams. This also affects what data the mashup can return in results. We will cover this in more detail a little later in Getting Started.
2. Run a RAQL query to filter, sort and analyze the dataset stream.
The <raql> extension element runs the query. The syntax for RAQL looks very similar to SQL. The congress variable holds the dataset stream and the RAQL engine automatically determines which elements from this XML file represent the rows of this dataset.
The complete mashup for this example is:
<mashup name="BasicQuery"
xmlns="http://www.openmashup.org/schemas/v1.0/EMML"
xmlns:macro="http://www.openmashup.org/schemas/v1.0/EMMLMacro"
xmlns:presto="http://www.jackbe.com/v1.0/EMMLPrestoExtensions"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openmashup.org/schemas/v1.0/EMML/../schemas/EMMLPrestoSpec.xsd">
<operation name="Invoke">
<presto:presto-meta name="created-using">RUI</presto:presto-meta>
<presto:presto-meta name="alias">congress</presto:presto-meta>
<presto:presto-meta name="filename"> legislators.xml
</presto:presto-meta>
<output name="result" type="document"/>
<variable datafile="legislators.xml" name="congress" stream="true"
subType="xml" type="document"/>
<raql outputvariable="result">
select firstname, lastname, state, chamber from congress
</raql>
</operation>
</mashup>