Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We will use the same setting as in Tutorial: Simple Query Processing. So you should follow steps 1-4.

Selection

With the selection operator you can filter out elements that are not relevant for further processing. Create a new Odysseus Script file with the PQL template and name it query2.

...

Execute the script and show the output as table. After some time, you should see only auctions opened by the seller with the id 1

Image RemovedImage Added

In this script you define a SELECT-Operator. In Procedural Query Language (PQL) each operator is identified by a name. Inside the operator there are two parts. The first part is the configuration inbetween "{" and "}". The seconds part is the source part, i.e. here the sources are listed that should deliver the input.

...

If you look at the query plan, you will see, the following

Image RemovedImage Added

The filter step is done by the top most operator Select.

...

Remove the old query and execute the new script. The output should look like in the following.

Image RemovedImage Added

More complex predicates can be defined. See MEP: Functions and Operators for further information.

Project

With the SELECT-Operator you choose which events you will see in the output, with the PROJECT you will choose, which attributes should be in the output.

Create a new Odysseus Script file with the PQL template and name it query3.

Code Block
out = PROJECT({ATTRIBUTES=['id', 'initialbid', 'seller']},nexmark:auction)

After translating the following output will be displayed. You can see, that only the selected attributes are printed.

Image Added

Although, the examples only contain one operator, the operators can be connected. E.g. first a selection and than a projection:

Code Block
selected = SELECT({predicate='seller=1 || seller=2'}, nexmark:auction)
out = PROJECT({ATTRIBUTES=['id', 'initialbid', 'seller']},selected)

Map

PROJECT only allow the selection of attributes. With the MAP-Operator calculations can be done on the input. The simpliest calculation is the output of an input attribute, so Map is more general than Project. (Warning: You should not use Map instead of Project, because it requires more processing capabilties).

Create a new Odysseus Script file with the PQL template and name it query4.

Code Block
out = MAP({EXPRESSIONS=['id','id+id','dolToEur(initialbid)']},nexmark:auction)

Image Added

As you can see, the output is the printed expression. Sometimes (especially when the output should be processed by another operator) this names should be more handy. You could use the RENAME Operator or an additional feature of Map. Instead of giving an expression, there can be a pair of expression and output name.

Code Block
out = MAP({EXPRESSIONS=['id',['id+id','DoubleId'],['dolToEur(initialbid)','Bid €']]},nexmark:auction)


Image Added