More...
TaQL is the query language for Casacore tables
See below for an overview of the classes in this module.
Intended use:
Public interface
Review Status
- Reviewed By:
- jhorstko
- Date Reviewed:
- 1994/08/30
Prerequisite
Etymology
"TaQL" is the Table Query Language. Its pronounciation rhymes with bagel.
Synopsis
TaQL is an SQL-like language to query a Casacore table. Amongst its options are row select, sort, update, and delete.
Some more information is given in the description of the Tables module. A detailed description is given in note 199.
The high-level interface is using a TaQL command as described in note 199. Such a command can be given in C++ (using TableParse.h), Python or the shell program 'taql'. The code for parsing and executing TaQL commands is quite complex. Processing a command consists of two steps.
-
First a command is parsed using 'flex' and 'bison'. The file TableGram.ll is used by 'flex' to recognize the tokens in the command. The file TableGram.yy defines the grammar which is used by bison to invoke actions on the recognized parts of the command. These actions consist of building a parse tree by means of class TaQLNode and associated classes. In this way the command is syntactically checked.
-
If the parsing is done successfully, the command is executed by walking through the parse tree using class TaQLNodeHandler. In its turn that class invokes functions in class TableParseQuery to check (semantically) and execute commands such as SELECT, UPDATE, etc.. Note that subqueries are executed before the entire parse tree has been walked through, thus before possible later semantic errors are detected.
Expressions in the parse tree are converted to expression trees using the various TableExprNode classes. Expression trees are evaluated for each row in a table. Note that expressions can be used in many parts of a TaQL command. Functions in a command are handled by TableParseFunc.
Expression trees can also be generated directly in C++ using class TableExprNode which is overloaded for many operators and functions (such as sin, max, etc.). In fact, TaQLNodeHandler uses this code. For example:
Example
Table tab("my.ms");
Table selection (tab(tab.col("ANTENNA1") == tab.col("ANTENNA2") &&
tab.col("SPECTRAL_WINDOW_ID") == 0));
creates a (reference) table containing the autocorrelations of the first spectral window in "my.ms".