26#ifndef TABLES_TABLEPARSEQUERY_H
27#define TABLES_TABLEPARSEQUERY_H
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/TableParseTableList.h>
32#include <casacore/tables/TaQL/TableParseJoin.h>
33#include <casacore/tables/TaQL/TableParseProject.h>
34#include <casacore/tables/TaQL/TableParseUpdate.h>
35#include <casacore/tables/TaQL/TableParseSortKey.h>
36#include <casacore/tables/TaQL/TableParseGroupby.h>
37#include <casacore/tables/Tables/Table.h>
38#include <casacore/tables/TaQL/ExprNode.h>
39#include <casacore/tables/TaQL/ExprGroup.h>
40#include <casacore/casa/Arrays/ArrayFwd.h>
41#include <casacore/casa/BasicSL/String.h>
42#include <casacore/casa/Utilities/Sort.h>
43#include <casacore/casa/Containers/Block.h>
49 class TableExprNodeSet;
50 class TableExprNodeSetElem;
51 class TableExprNodeIndex;
57 template<
class T>
class ArrayColumn;
140 const std::vector<const Table*>& tempTables = std::vector<const Table*>(),
141 const std::vector<TableParseQuery*>& stack = std::vector<TableParseQuery*>());
175 const std::vector<TableParseQuery*>& stack);
179 const std::vector<const Table*>& tempTables,
180 const std::vector<TableParseQuery*>& stack);
225 void handleSort (
const std::vector<TableParseSortKey>& sortList,
273 const std::vector<TableParseJoin>&
joins()
const
291 void addUpdate (
const std::shared_ptr<TableParseUpdate>& upd)
324 const std::vector<const Table*>& tempTables,
325 const std::vector<TableParseQuery*>& stack);
332 const std::shared_ptr<TableExprGroupResult>& groups =
333 std::shared_ptr<TableExprGroupResult>());
347 const std::shared_ptr<TableExprGroupResult>& groups =
348 std::shared_ptr<TableExprGroupResult>());
353 const std::shared_ptr<TableExprGroupResult>& groups);
359 const std::vector<const Table*>& tempTables,
360 const std::vector<TableParseQuery*>& stack);
370 std::shared_ptr<TableExprGroupResult>
doGroupby (
bool showTimings);
375 const std::shared_ptr<TableExprGroupResult>& groups);
389 const std::vector<const Table*>& tempTables,
390 const std::vector<TableParseQuery*>& stack);
435 std::vector<std::shared_ptr<TableParseUpdate>>
update_p;
Order
Enumerate the sort order:
String: the storage and methods of handling collections of characters.
Class to hold the table expression nodes for an element in a set.
void setDMInfo(const Record &dminfo)
Set the DataManager info for a new table.
const Block< String > & getColumnNames() const
Get the projected column names.
void handleOffset(const TableExprNode &expr)
Evaluate and keep the offset value.
void handleCount()
Make ready for a COUNT command.
const Table & getTable() const
Get the resulting table.
Table::EndianFormat endianFormat_p
const std::vector< TableParseJoin > & joins() const
Get the TableParseJoin objects.
void setInsertExprs(const std::vector< TableExprNode > exprs)
Set the insert expressions for all rows.
TableParseQuery * insSel_p
TableParseTableList & tableList()
Return the table name list.
TableExprNode getNode() const
Return the expression node.
std::vector< TableExprNode > applySelNodes_p
void handleLimit(const TableExprNode &expr)
Evaluate and keep the limit value.
Table doFinish(Bool showTimings, Table &table, const std::vector< const Table * > &tempTables, const std::vector< TableParseQuery * > &stack)
Finish the table (rename, copy, and/or flush).
std::vector< TableParseJoin > joins_p
void handleLimit(const TableExprNodeSetElem &expr)
Evaluate and keep limit/offset/stride given as start:end:incr.
TableExprNode doExists(Bool noexists, Bool showTimings)
Test if a subquery has sufficient elements.
Table doLimOff(Bool showTimings, const Table &table)
TableParseProject tableProject_p
Table doDistinct(Bool showTimings, const Table &table)
Do the 'select distinct' step.
void handleColSpec(const String &columnName, const String &likeColName, const String &dataType, const Record &spec, Bool isCOrder=False)
Keep the column specification in a create table command.
Table doCount(Bool showTimings, const Table &)
Do the count step returning a memory table containing the unique column values and the counts of the ...
void handleCalcComm(const TableExprNode &)
Keep the expression of a calculate command.
void doLimOff(Bool showTimings)
Do the limit/offset step.
TableExprNode handleKeyCol(const String &name, Bool tryProj)
Find the keyword or column name and create a TableExprNode from it.
void doSort(Bool showTimings)
Do the sort step.
TableExprNode makeSubSet() const
Make a set from the results of the subquery.
void handleInsert(TableParseQuery *sel)
TableRecord & findKeyword(const String &name, String &keyName, Bool update=True)
Split the given name into optional shorthand, column and fields.
TableParseJoin & addJoin()
Add a join object.
void handleGiving(const String &name, const Record &type)
Handle the name and type given in a GIVING clause.
Table createSubTable(const String &subtableName, const TableDesc &td, Int64 nrow, const Record &dmInfo, const std::vector< const Table * > &tempTables, const std::vector< TableParseQuery * > &stack)
Create a subtable (used by createTable).
void handleUpdate()
Keep the update expressions.
StorageOption storageOption_p
Int64 evalIntScaExpr(const TableExprNode &expr) const
Evaluate an int scalar expression.
std::vector< std::shared_ptr< TableParseUpdate > > update_p
void initDescriptions(const TableDesc &, const Record &dminfo)
Initialize the table and data manager descriptions.
Table & projectExprTable()
void doDelete(Bool showTimings, Table &table)
Do the delete step.
void addUpdate(const std::shared_ptr< TableParseUpdate > &upd)
Add an update object.
std::vector< TableParseSortKey > sort_p
Bool doHaving(Bool showTimings, const std::shared_ptr< TableExprGroupResult > &groups)
Do the HAVING step.
TableParseGroupby groupby_p
std::shared_ptr< TableExprGroupResult > doGroupby(bool showTimings)
Do the groupby/aggregate step and return its result.
void handleSort(const std::vector< TableParseSortKey > &sortList, Bool noDuplicates, Sort::Order defaultSortOrder)
Keep the sort expressions.
TableExprNode doSubQuery(Bool showTimings)
Execute a subquery and create an appropriate node for the result.
void handleDropTab(const std::vector< const Table * > &tempTables, const std::vector< TableParseQuery * > &stack)
Handle the DROP TABLE command.
void handleGroupby(const std::vector< TableExprNode > &, Bool rollup)
Keep the groupby expressions.
std::vector< TableExprNode > insertExprs_p
Table doProject(Bool showTimings, const Table &, const std::shared_ptr< TableExprGroupResult > &groups=std::shared_ptr< TableExprGroupResult >())
Do the projection step returning a table containing the projection.
CommandType commandType() const
Return the command type.
void replaceTable(const Table &table)
Replace the first table (used by CALC command).
void setDMInfo(const Record &dminfo)
Set the DataManager info for a new table.
TableParseTableList tableList_p
TableExprNodeSet * resultSet_p
void handleColumn(Int type, const String &name, const TableExprNode &expr, const String &newName, const String &nameMask, const String &newDtype)
Add a column to the list of column names.
Table adjustApplySelNodes(const Table &)
Set the selected rows for the column objects in applySelNodes_p.
void handleRenameKey(const String &oldName, const String &newName)
Rename a table or column keyword.
void handleWhere(const TableExprNode &)
Keep the selection expression.
Vector< rownr_t > rownrs_p
void addApplySelNode(const TableExprNode &node)
Add a column node to applySelNodes_p.
void handleGiving(const TableExprNodeSet &)
Handle the set given in a GIVING clause.
const Block< String > & getColumnNames() const
Get the projected column names.
static TableExprNode handleSlice(const TableExprNode &array, const TableExprNodeSet &indices, const TaQLStyle &)
Handle a slice operator.
void handleHaving(const TableExprNode &)
Keep the having expression.
TableExprNode handleFunc(const String &name, const TableExprNodeSet &arguments, const TaQLStyle &)
Handle a function.
Table createTable(const TableDesc &td, Int64 nrow, const Record &dmInfo, const std::vector< const Table * > &tempTables, const std::vector< TableParseQuery * > &stack)
Create a table using the given parameters.
CommandType commandType_p
void handleAltTab()
Reopen the table (for update) used in the ALTER TABLE command.
Table doInsert(Bool showTimings, Table &table)
Do the insert step and return a selection containing the new rows.
~TableParseQuery()
Destructor.
String getTableStructure(const Vector< String > &parts, const TaQLStyle &style)
Show the structure of fromTables_p[0] using the options given in parts[2:].
void handleTableNoFrom()
Create a temporary table if no tables are given in FROM.
void show(ostream &os) const
Show the expression tree.
void handleAddRow(const TableExprNode &expr)
Evaluate and add the rows.
TableExprNode getColSet()
Make an array from the contents of a column in a subquery.
ValueHolder getRecFld(const String &name)
Add a keyword or replace a keyword with the value of another keyword.
void handleInsert()
Make ready for the insert expression.
TableParseQuery(CommandType type)
Construct.
void handleSetKey(const String &name, const String &dtype, const ValueHolder &value)
Add a keyword or replace a keyword with a value.
void handleRemoveKey(const String &name)
Remove a table or column keyword.
void doUpdate(Bool showTimings, const Table &origTable, Table &updTable, const Vector< rownr_t > &rownrs, const std::shared_ptr< TableExprGroupResult > &groups=std::shared_ptr< TableExprGroupResult >())
Do the update step.
void handleAddCol(const Record &dmInfo)
Add columns to the table of ALTER TABLE.
Table doProjectExpr(Bool useSel, const std::shared_ptr< TableExprGroupResult > &groups)
Do the projection containing column expressions.
void handleCopyCol(Bool showTimings)
Handle copying of columns.
void execute(Bool showTimings, Bool setInGiving, Bool mustSelect, rownr_t maxRow, Bool doTracing=False, const std::vector< const Table * > &tempTables=std::vector< const Table * >(), const std::vector< TableParseQuery * > &stack=std::vector< TableParseQuery * >())
Execute the select command (select/sort/projection/groupby/having/giving).
void handleColumnFinish(Bool distinct)
Finish the addition of columns to the list of column names.
Table doFromQuery(Bool showTimings)
Execute a query in a FROM clause resulting in a Table.
void handleCreTab(const Record &dmInfo, const std::vector< const Table * > &tempTables, const std::vector< TableParseQuery * > &stack)
Keep the create table command.
Class containing two lists of TableParsePair objects.
EndianFormat
Define the possible endian formats in which table data can be stored.
this file contains all the compiler specific defines
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
bool Bool
Define the standard types used by Casacore.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
uInt64 rownr_t
Define the type of a row number in a table.