casacore
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
casacore::TableParseSelect Class Reference

Select-class for flex/bison scanner/parser for TableParse. More...

#include <TableParse.h>

Public Types

enum  CommandType {
  PSELECT ,
  PUPDATE ,
  PINSERT ,
  PDELETE ,
  PCOUNT ,
  PCALC ,
  PCRETAB ,
  PALTTAB ,
  PDROPTAB ,
  PSHOW
}
 
enum  GroupAggrType {
  GROUPBY ,
  AGGR_FUNCS ,
  ONLY_COUNTALL
}
 

Public Member Functions

 TableParseSelect (CommandType type)
 Construct. More...
 
 ~TableParseSelect ()
 Destructor. More...
 
CommandType commandType () const
 Return the command type. More...
 
TableExprNode getNode () const
 Return the expression node. More...
 
void makeTableNoFrom (const std::vector< TableParseSelect * > &stack)
 Create a temporary table if no tables are given in FROM. More...
 
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< TableParseSelect * > &stack=std::vector< TableParseSelect * >())
 Execute the select command (select/sort/projection/groupby/having/giving). More...
 
Table doFromQuery (Bool showTimings)
 Execute a query in a from clause resulting in a Table. More...
 
TableExprNode doSubQuery (Bool showTimings)
 Execute a subquery and create an appropriate node for the result. More...
 
TableExprNode doExists (Bool noexists, Bool showTimings)
 Test if a subquery has sufficient elements. More...
 
void show (ostream &os) const
 Show the expression tree. More...
 
void handleWhere (const TableExprNode &)
 Keep the selection expression. More...
 
void handleGroupby (const std::vector< TableExprNode > &, Bool rollup)
 Keep the groupby expressions. More...
 
void handleHaving (const TableExprNode &)
 Keep the having expression. More...
 
void handleCalcComm (const TableExprNode &)
 Keep the expression of a calculate command. More...
 
void handleDropTab (const std::vector< const Table * > &tempTables, const std::vector< TableParseSelect * > &stack)
 Handle the DROP TABLE command. More...
 
void handleCreTab (const Record &dmInfo, const std::vector< const Table * > &tempTables, const std::vector< TableParseSelect * > &stack)
 Keep the create table command. More...
 
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. More...
 
void handleAltTab ()
 Reopen the table (for update) used in the ALTER TABLE command. More...
 
void handleAddCol (const Record &dmInfo)
 Add columns to the table of ALTER TABLE. More...
 
void initDescriptions (const TableDesc &, const Record &dminfo)
 Initialize the table and data manager descriptions. More...
 
ValueHolder getRecFld (const String &name)
 Add a keyword or replace a keyword with the value of another keyword. More...
 
void handleCopyCol (Bool showTimings)
 Handle copying of columns. More...
 
void handleSetKey (const String &name, const String &dtype, const ValueHolder &value)
 Add a keyword or replace a keyword with a value. More...
 
void handleRenameKey (const String &oldName, const String &newName)
 Rename a table or column keyword. More...
 
void handleRemoveKey (const String &name)
 Remove a table or column keyword. More...
 
TableRecordfindKeyword (const String &name, String &keyName, Bool update=True)
 Split the given name into optional shorthand, column and fields. More...
 
void addUpdate (const CountedPtr< TableParseUpdate > &upd)
 Add an update object. More...
 
void setInsertExprs (const std::vector< TableExprNode > exprs)
 Set the insert expressions for all rows. More...
 
void handleUpdate ()
 Keep the update expressions. More...
 
void handleInsert ()
 Make ready for the insert expression. More...
 
void handleInsert (TableParseSelect *sel)
 
void handleCount ()
 Make ready for a COUNT command. More...
 
void handleSort (const std::vector< TableParseSort > &sortList, Bool noDuplicates, Sort::Order defaultSortOrder)
 Keep the sort expressions. More...
 
void handleLimit (const TableExprNodeSetElem &expr)
 Evaluate and keep limit/offset/stride given as start:end:incr. More...
 
void handleLimit (const TableExprNode &expr)
 Evaluate and keep the limit value. More...
 
void handleOffset (const TableExprNode &expr)
 Evaluate and keep the offset value. More...
 
void handleAddRow (const TableExprNode &expr)
 Evaluate and add the rows. More...
 
Table addTable (Int tabnr, const String &name, const Table &table, const String &shorthand, Bool addToFromList, const std::vector< const Table * > &tempTables, const std::vector< TableParseSelect * > &stack)
 Add a table nr, name, or object to the container. More...
 
Table getTable (Int tabnr, const String &name, const Table &ftab, const std::vector< const Table * > &tempTables, const std::vector< TableParseSelect * > &stack, Bool alwaysOpen=True)
 Make a Table object for given name, seqnr or so. More...
 
void replaceTable (const Table &table)
 Replace the first table (used by CALC command). More...
 
TableExprNode handleKeyCol (const String &name, Bool tryProj)
 Find the keyword or column name and create a TableExprNode from it. More...
 
TableExprNode handleFunc (const String &name, const TableExprNodeSet &arguments, const TaQLStyle &)
 Handle a function. More...
 
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. More...
 
void handleColumnFinish (Bool distinct)
 Finish the addition of columns to the list of column names. More...
 
void setDMInfo (const Record &dminfo)
 Set the DataManager info for a new table. More...
 
void handleGiving (const String &name, const Record &type)
 Handle the name and type given in a GIVING clause. More...
 
void handleGiving (const TableExprNodeSet &)
 Handle the set given in a GIVING clause. More...
 
const Block< String > & getColumnNames () const
 Get the projected column names. More...
 
const TablegetTable () const
 Get the resulting table. More...
 
String getTableInfo (const Vector< String > &parts, const TaQLStyle &style)
 Show the structure of fromTables_p[0] using the options given in parts[2:]. More...
 

Static Public Member Functions

static void setRecFld (RecordInterface &rec, const String &name, const String &dtype, const ValueHolder &vh)
 Define a field with the given data type in the Record. More...
 
static String getTypeString (const String &typeStr, DataType type)
 Get the type string. More...
 
static TableExprNode handleSlice (const TableExprNode &array, const TableExprNodeSet &indices, const TaQLStyle &)
 Handle a slice operator. More...
 
static TableExprNode makeFuncNode (TableParseSelect *, const String &name, const TableExprNodeSet &arguments, const Vector< int > &ignoreFuncs, const Table &table, const TaQLStyle &)
 Make a function object node for the given function name and arguments. More...
 
static void checkAggrFuncs (const TableExprNode &node)
 An exception is thrown if the node uses an aggregate function. More...
 
static Bool splitName (String &shorthand, String &columnName, Vector< String > &fieldNames, const String &name, Bool checkError, Bool isKeyword, Bool allowNoKey)
 Split a name into its parts (shorthand, column and field names). More...
 

Private Member Functions

Int testGroupAggr (std::vector< TableExprNodeRep * > &aggr) const
 Test if groupby or aggregate functions are given. More...
 
std::vector< TableExprNodeRep * > getAggrNodes () const
 Get the aggregate functions used in SELECT and HAVING. More...
 
void doUpdate (Bool showTimings, const Table &origTable, Table &updTable, const Vector< rownr_t > &rownrs, const CountedPtr< TableExprGroupResult > &groups=CountedPtr< TableExprGroupResult >())
 Do the update step. More...
 
Table doInsert (Bool showTimings, Table &table)
 Do the insert step and return a selection containing the new rows. More...
 
void doDelete (Bool showTimings, Table &table)
 Do the delete step. More...
 
Table doCount (Bool showTimings, const Table &)
 Do the count step returning a memory table containing the unique column values and the counts of the column values. More...
 
Table doProject (Bool showTimings, const Table &, const CountedPtr< TableExprGroupResult > &groups=CountedPtr< TableExprGroupResult >())
 Do the projection step returning a table containing the projection. More...
 
Table doProjectExpr (Bool useSel, const CountedPtr< TableExprGroupResult > &groups)
 Do the projection containing column expressions. More...
 
Table createTable (const TableDesc &td, Int64 nrow, const Record &dmInfo, const std::vector< const Table * > &tempTables, const std::vector< TableParseSelect * > &stack)
 Create a table using the given parameters. More...
 
Table createSubTable (const String &subtableName, const TableDesc &td, Int64 nrow, const Record &dmInfo, const std::vector< const Table * > &tempTables, const std::vector< TableParseSelect * > &stack)
 
Table openParentTable (const String &fullName, const String &subTableName, const std::vector< const Table * > &tempTables, const std::vector< TableParseSelect * > &stack)
 Open the parent table of a subtable. More...
 
void makeProjectExprTable ()
 Make the (empty) table for the epxression in the SELECT clause. More...
 
void makeProjectExprSel ()
 Fill projectExprSelColumn_p telling the columns to be projected at the first stage. More...
 
void addApplySelNode (const TableExprNode &node)
 Add a column node to applySelNodes_p. More...
 
Table adjustApplySelNodes (const Table &)
 Set the selected rows for the column objects in applySelNodes_p. More...
 
CountedPtr< TableExprGroupResultdoGroupby (bool showTimings, const std::vector< TableExprNodeRep * > aggrNodes, Int groupAggrUsed)
 Do the groupby/aggregate step and return its result. More...
 
void doHaving (Bool showTimings, const CountedPtr< TableExprGroupResult > &groups)
 Do the HAVING step. More...
 
CountedPtr< TableExprGroupResultdoOnlyCountAll (TableExprNodeRep *aggrNode)
 Do a groupby/aggregate step that only does a 'select count(*)'. More...
 
CountedPtr< TableExprGroupResultdoGroupByAggr (const std::vector< TableExprNodeRep * > &aggrNodes)
 Do a full groupby/aggregate step. More...
 
void doSort (Bool showTimings)
 Do the sort step. More...
 
void doLimOff (Bool showTimings)
 Do the limit/offset step. More...
 
Table doLimOff (Bool showTimings, const Table &table)
 
Table doDistinct (Bool showTimings, const Table &table)
 Do the 'select distinct' step. More...
 
Table doFinish (Bool showTimings, Table &table, const std::vector< const Table * > &tempTables, const std::vector< TableParseSelect * > &stack)
 Finish the table (rename, copy, and/or flush). More...
 
template<typename TCOL , typename TNODE >
void updateValue (rownr_t row, const TableExprId &rowid, Bool isScalarCol, const TableExprNode &node, const Array< Bool > &mask, Bool maskFirst, TableColumn &col, const Slicer *slicerPtr, ArrayColumn< Bool > &maskCol)
 Update the values in the columns (helpers of doUpdate). More...
 
template<typename TCOL , typename TNODE >
void updateScalar (rownr_t row, const TableExprId &rowid, const TableExprNode &node, TableColumn &col)
 
template<typename TCOL , typename TNODE >
void updateArray (rownr_t row, const TableExprId &rowid, const TableExprNode &node, const Array< TNODE > &res, ArrayColumn< TCOL > &col)
 
template<typename TCOL , typename TNODE >
void updateSlice (rownr_t row, const TableExprId &rowid, const TableExprNode &node, const Array< TNODE > &res, const Slicer &slice, ArrayColumn< TCOL > &col)
 
template<typename TCOL , typename TNODE >
void copyMaskedValue (rownr_t row, ArrayColumn< TCOL > &acol, const Slicer *slicerPtr, const TNODE *val, size_t incr, const Array< Bool > &mask)
 
Array< BoolmakeMaskSlice (const Array< Bool > &mask, Bool maskFirst, const IPosition &shapeCol, const Slicer *slicerPtr)
 
void checkMaskColumn (Bool hasMask, const ArrayColumn< Bool > &maskCol, const TableColumn &col)
 
DataType makeDataType (DataType dtype, const String &dtstr, const String &colName)
 Make a data type from the string. More...
 
Sort::Order getOrder (const TableParseSort &key) const
 Get the order for this key. More...
 
TableExprNode getColSet ()
 Make an array from the contents of a column in a subquery. More...
 
TableExprNode makeSubSet () const
 Make a set from the results of the subquery. More...
 
Int64 evalIntScaExpr (const TableExprNode &expr) const
 Evaluate an int scalar expression. More...
 
Table findTable (const String &shorthand, Bool doWith) const
 Find a table for the given shorthand. More...
 
Table findTable (const String &shorthand, Bool doWith, const std::vector< TableParseSelect * > &stack) const
 
void handleWildColumn (Int stringType, const String &name)
 Handle the selection of a wildcarded column name. More...
 
void addColumnDesc (TableDesc &td, DataType dtype, const String &colName, Int options, Int ndim, const IPosition &shape, const String &dmType, const String &dmGroup, const String &comment, const TableRecord &keywordSet, const Vector< String > &unitName, const Record &attributes)
 Add the description of a column to the table description. More...
 
std::pair< ColumnDesc, RecordfindColumnInfo (const String &colName, const String &newColName) const
 Find the ColumnDesc and data manager info of another column (a LIKE column). More...
 
Block< StringgetStoredColumns (const Table &tab) const
 Find the names of all stored columns in a table. More...
 
void checkTableProjSizes () const
 Check if the tables used in selection columns have the same size as the first table given in FROM. More...
 
template<typename T >
std::vector< CountedPtr< TableExprGroupFuncSet > > doGroupByAggrSingleKey (const std::vector< TableExprNodeRep * > &aggrNodes)
 Create the set of aggregate functions and groupby keys in case a single groupby key is given. More...
 
std::vector< CountedPtr< TableExprGroupFuncSet > > doGroupByAggrMultipleKeys (const std::vector< TableExprNodeRep * > &aggrNodes)
 Create the set of aggregate functions and groupby keys in case multiple keys are given. More...
 

Static Private Member Functions

static TableExprNode makeUDFNode (TableParseSelect *, const String &name, const TableExprNodeSet &arguments, const Table &table, const TaQLStyle &)
 Try to make a UDF function node for the given function name and arguments. More...
 
static TableExprFuncNode::FunctionType findFunc (const String &name, uInt narguments, const Vector< Int > &ignoreFuncs)
 Find the function code belonging to a function name. More...
 

Private Attributes

CommandType commandType_p
 
std::shared_ptr< TableDesctableDesc_p
 
Record dminfo_p
 
std::vector< TableParsewithTables_p
 
std::vector< TableParsefromTables_p
 
Block< StringcolumnNames_p
 
Block< StringcolumnNameMasks_p
 
Block< TableExprNodecolumnExpr_p
 
Block< StringcolumnOldNames_p
 
Block< StringcolumnDtypes_p
 
Block< TableRecordcolumnKeywords_p
 
uInt nrSelExprUsed_p
 
Bool distinct_p
 
String resultName_p
 
uInt resultType_p
 
Bool resultCreated_p
 
StorageOption storageOption_p
 
Table::EndianFormat endianFormat_p
 
Bool overwrite_p
 
TableExprNodeSetresultSet_p
 
TableExprNode node_p
 
std::vector< TableExprNodegroupbyNodes_p
 
Bool groupbyRollup_p
 
TableExprNode havingNode_p
 
Int64 limit_p
 
Int64 endrow_p
 
Int64 offset_p
 
Int64 stride_p
 
std::vector< CountedPtr< TableParseUpdate > > update_p
 
std::vector< TableExprNodeinsertExprs_p
 
TableParseSelectinsSel_p
 
std::vector< TableParseSortsort_p
 
Bool noDupl_p
 
Sort::Order order_p
 
std::vector< TableExprNodeapplySelNodes_p
 
Table table_p
 
Table firstColTable_p
 
String firstColName_p
 
Table projectExprTable_p
 
Block< uIntprojectExprSubset_p
 
Block< BoolprojectExprSelColumn_p
 
Vector< rownr_trownrs_p
 

Detailed Description

Select-class for flex/bison scanner/parser for TableParse.

Intended use:

Internal

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Synopsis

This class is needed for the the actions in the flex scanner and bison parser. This stores the information by constructing TableParse objects as needed and storing them in a vector.

Motivation

It is necessary to be able to give a table select command in ASCII. This can be used in a CLI or in the table browser to get a subset of a table or to sort a table.

Definition at line 388 of file TableParse.h.

Member Enumeration Documentation

◆ CommandType

Enumerator
PSELECT 
PUPDATE 
PINSERT 
PDELETE 
PCOUNT 
PCALC 
PCRETAB 
PALTTAB 
PDROPTAB 
PSHOW 

Definition at line 391 of file TableParse.h.

◆ GroupAggrType

Enumerator
GROUPBY 
AGGR_FUNCS 
ONLY_COUNTALL 

Definition at line 404 of file TableParse.h.

Constructor & Destructor Documentation

◆ TableParseSelect()

casacore::TableParseSelect::TableParseSelect ( CommandType  type)

Construct.

◆ ~TableParseSelect()

casacore::TableParseSelect::~TableParseSelect ( )

Destructor.

Member Function Documentation

◆ addApplySelNode()

void casacore::TableParseSelect::addApplySelNode ( const TableExprNode node)
inlineprivate

Add a column node to applySelNodes_p.

Definition at line 732 of file TableParse.h.

References applySelNodes_p.

◆ addColumnDesc()

void casacore::TableParseSelect::addColumnDesc ( TableDesc td,
DataType  dtype,
const String colName,
Int  options,
Int  ndim,
const IPosition shape,
const String dmType,
const String dmGroup,
const String comment,
const TableRecord keywordSet,
const Vector< String > &  unitName,
const Record attributes 
)
private

Add the description of a column to the table description.

ndim < 0 means a scalar column.

◆ addTable()

Table casacore::TableParseSelect::addTable ( Int  tabnr,
const String name,
const Table table,
const String shorthand,
Bool  addToFromList,
const std::vector< const Table * > &  tempTables,
const std::vector< TableParseSelect * > &  stack 
)

Add a table nr, name, or object to the container.

◆ addUpdate()

void casacore::TableParseSelect::addUpdate ( const CountedPtr< TableParseUpdate > &  upd)
inline

Add an update object.

Definition at line 1049 of file TableParse.h.

References update_p.

◆ adjustApplySelNodes()

Table casacore::TableParseSelect::adjustApplySelNodes ( const Table )
private

Set the selected rows for the column objects in applySelNodes_p.

These nodes refer the original table. They requires different row numbers than the selected groups and projected columns. rownrs_p is changed to use row 0..n. It returns the Table containing the subset of rows in the input Table.

◆ checkAggrFuncs()

static void casacore::TableParseSelect::checkAggrFuncs ( const TableExprNode node)
static

An exception is thrown if the node uses an aggregate function.

◆ checkMaskColumn()

void casacore::TableParseSelect::checkMaskColumn ( Bool  hasMask,
const ArrayColumn< Bool > &  maskCol,
const TableColumn col 
)
private

◆ checkTableProjSizes()

void casacore::TableParseSelect::checkTableProjSizes ( ) const
private

Check if the tables used in selection columns have the same size as the first table given in FROM.

◆ commandType()

CommandType casacore::TableParseSelect::commandType ( ) const
inline

Return the command type.

Definition at line 417 of file TableParse.h.

References commandType_p.

◆ copyMaskedValue()

template<typename TCOL , typename TNODE >
void casacore::TableParseSelect::copyMaskedValue ( rownr_t  row,
ArrayColumn< TCOL > &  acol,
const Slicer slicerPtr,
const TNODE *  val,
size_t  incr,
const Array< Bool > &  mask 
)
private

◆ createSubTable()

Table casacore::TableParseSelect::createSubTable ( const String subtableName,
const TableDesc td,
Int64  nrow,
const Record dmInfo,
const std::vector< const Table * > &  tempTables,
const std::vector< TableParseSelect * > &  stack 
)
private

◆ createTable()

Table casacore::TableParseSelect::createTable ( const TableDesc td,
Int64  nrow,
const Record dmInfo,
const std::vector< const Table * > &  tempTables,
const std::vector< TableParseSelect * > &  stack 
)
private

Create a table using the given parameters.

The variables set by handleGiven are used for name and type.

◆ doCount()

Table casacore::TableParseSelect::doCount ( Bool  showTimings,
const Table  
)
private

Do the count step returning a memory table containing the unique column values and the counts of the column values.

◆ doDelete()

void casacore::TableParseSelect::doDelete ( Bool  showTimings,
Table table 
)
private

Do the delete step.

◆ doDistinct()

Table casacore::TableParseSelect::doDistinct ( Bool  showTimings,
const Table table 
)
private

Do the 'select distinct' step.

◆ doExists()

TableExprNode casacore::TableParseSelect::doExists ( Bool  noexists,
Bool  showTimings 
)

Test if a subquery has sufficient elements.

It uses default LIMIT=1, but that can be overidden in the subquery. The flag tells if NOT EXISTS or EXISTS was given.

◆ doFinish()

Table casacore::TableParseSelect::doFinish ( Bool  showTimings,
Table table,
const std::vector< const Table * > &  tempTables,
const std::vector< TableParseSelect * > &  stack 
)
private

Finish the table (rename, copy, and/or flush).

◆ doFromQuery()

Table casacore::TableParseSelect::doFromQuery ( Bool  showTimings)

Execute a query in a from clause resulting in a Table.

◆ doGroupby()

CountedPtr<TableExprGroupResult> casacore::TableParseSelect::doGroupby ( bool  showTimings,
const std::vector< TableExprNodeRep * >  aggrNodes,
Int  groupAggrUsed 
)
private

Do the groupby/aggregate step and return its result.

◆ doGroupByAggr()

CountedPtr<TableExprGroupResult> casacore::TableParseSelect::doGroupByAggr ( const std::vector< TableExprNodeRep * > &  aggrNodes)
private

Do a full groupby/aggregate step.

◆ doGroupByAggrMultipleKeys()

std::vector<CountedPtr<TableExprGroupFuncSet> > casacore::TableParseSelect::doGroupByAggrMultipleKeys ( const std::vector< TableExprNodeRep * > &  aggrNodes)
private

Create the set of aggregate functions and groupby keys in case multiple keys are given.

◆ doGroupByAggrSingleKey()

template<typename T >
std::vector<CountedPtr<TableExprGroupFuncSet> > casacore::TableParseSelect::doGroupByAggrSingleKey ( const std::vector< TableExprNodeRep * > &  aggrNodes)
inlineprivate

Create the set of aggregate functions and groupby keys in case a single groupby key is given.

This offers much faster map access then doGroupByAggrMultiple.

We have to group the data according to the (possibly empty) groupby. We step through the table in the normal order which may not be the groupby order. A map<key,int> is used to keep track of the results where the int is the index in a vector of a set of aggregate function objects.

Loop through all rows. For each row generate the key to get the right entry.

Definition at line 868 of file TableParse.h.

References groupbyNodes_p, casacore::max(), rownrs_p, casacore::TableExprId::setRownr(), and casacore::ArrayBase::size().

◆ doHaving()

void casacore::TableParseSelect::doHaving ( Bool  showTimings,
const CountedPtr< TableExprGroupResult > &  groups 
)
private

Do the HAVING step.

◆ doInsert()

Table casacore::TableParseSelect::doInsert ( Bool  showTimings,
Table table 
)
private

Do the insert step and return a selection containing the new rows.

◆ doLimOff() [1/2]

void casacore::TableParseSelect::doLimOff ( Bool  showTimings)
private

Do the limit/offset step.

◆ doLimOff() [2/2]

Table casacore::TableParseSelect::doLimOff ( Bool  showTimings,
const Table table 
)
private

◆ doOnlyCountAll()

CountedPtr<TableExprGroupResult> casacore::TableParseSelect::doOnlyCountAll ( TableExprNodeRep aggrNode)
private

Do a groupby/aggregate step that only does a 'select count(*)'.

◆ doProject()

Table casacore::TableParseSelect::doProject ( Bool  showTimings,
const Table ,
const CountedPtr< TableExprGroupResult > &  groups = CountedPtrTableExprGroupResult >() 
)
private

Do the projection step returning a table containing the projection.

◆ doProjectExpr()

Table casacore::TableParseSelect::doProjectExpr ( Bool  useSel,
const CountedPtr< TableExprGroupResult > &  groups 
)
private

Do the projection containing column expressions.

Use the selected or unselected columns depending on useSel.

◆ doSort()

void casacore::TableParseSelect::doSort ( Bool  showTimings)
private

Do the sort step.

◆ doSubQuery()

TableExprNode casacore::TableParseSelect::doSubQuery ( Bool  showTimings)

Execute a subquery and create an appropriate node for the result.

◆ doUpdate()

void casacore::TableParseSelect::doUpdate ( Bool  showTimings,
const Table origTable,
Table updTable,
const Vector< rownr_t > &  rownrs,
const CountedPtr< TableExprGroupResult > &  groups = CountedPtrTableExprGroupResult >() 
)
private

Do the update step.

Rows 0,1,2,.. in UpdTable are updated from the expression result for the rows in the given rownrs vector.

◆ evalIntScaExpr()

Int64 casacore::TableParseSelect::evalIntScaExpr ( const TableExprNode expr) const
private

Evaluate an int scalar expression.

◆ execute()

void casacore::TableParseSelect::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< TableParseSelect * > &  stack = std::vector< TableParseSelect * >() 
)

Execute the select command (select/sort/projection/groupby/having/giving).

The setInGiving flag tells if a set in the GIVING part is allowed. The mustSelect flag tells if a SELECT command must do something. Usually that is required, but not for a SELECT in an INSERT command. Optionally the maximum nr of rows to be selected can be given. It will be used as the default value for the LIMIT clause. 0 = no maximum.

◆ findColumnInfo()

std::pair<ColumnDesc,Record> casacore::TableParseSelect::findColumnInfo ( const String colName,
const String newColName 
) const
private

Find the ColumnDesc and data manager info of another column (a LIKE column).

The LIKE column name can be qualified to use another table. It sets the new column name in the data manager info. An exception is thrown if colName is invalid or unknown.

◆ findFunc()

static TableExprFuncNode::FunctionType casacore::TableParseSelect::findFunc ( const String name,
uInt  narguments,
const Vector< Int > &  ignoreFuncs 
)
staticprivate

Find the function code belonging to a function name.

Functions to be ignored can be given (as function type values). If the function name is unknown, NRFUNC is returned.

◆ findKeyword()

TableRecord& casacore::TableParseSelect::findKeyword ( const String name,
String keyName,
Bool  update = True 
)

Split the given name into optional shorthand, column and fields.

Find the keywordset for it and fill in the final keyword name. It is a helper function for handleSetKey, etc. If update=True, rwKeywordSet() is used to ensure the table is updated.

◆ findTable() [1/2]

Table casacore::TableParseSelect::findTable ( const String shorthand,
Bool  doWith 
) const
private

Find a table for the given shorthand.

Optionally the WITH tables are searched as well. If no shorthand is given, the first table is returned (if there). If not found, a null Table object is returned.

◆ findTable() [2/2]

Table casacore::TableParseSelect::findTable ( const String shorthand,
Bool  doWith,
const std::vector< TableParseSelect * > &  stack 
) const
private

◆ getAggrNodes()

std::vector<TableExprNodeRep*> casacore::TableParseSelect::getAggrNodes ( ) const
private

Get the aggregate functions used in SELECT and HAVING.

◆ getColSet()

TableExprNode casacore::TableParseSelect::getColSet ( )
private

Make an array from the contents of a column in a subquery.

◆ getColumnNames()

const Block< String > & casacore::TableParseSelect::getColumnNames ( ) const
inline

Get the projected column names.

Definition at line 1043 of file TableParse.h.

References columnNames_p.

◆ getNode()

TableExprNode casacore::TableParseSelect::getNode ( ) const
inline

Return the expression node.

Definition at line 421 of file TableParse.h.

References node_p.

◆ getOrder()

Sort::Order casacore::TableParseSelect::getOrder ( const TableParseSort key) const
inlineprivate

Get the order for this key.

Use the default order_p if not explicitly given with the key.

Definition at line 1052 of file TableParse.h.

References casacore::TableParseSort::order(), order_p, and casacore::TableParseSort::orderGiven().

◆ getRecFld()

ValueHolder casacore::TableParseSelect::getRecFld ( const String name)

Add a keyword or replace a keyword with the value of another keyword.

The keywords can be table or column keywords (col::key).

◆ getStoredColumns()

Block<String> casacore::TableParseSelect::getStoredColumns ( const Table tab) const
private

Find the names of all stored columns in a table.

◆ getTable() [1/2]

const Table & casacore::TableParseSelect::getTable ( ) const
inline

Get the resulting table.

Definition at line 1046 of file TableParse.h.

References table_p.

◆ getTable() [2/2]

Table casacore::TableParseSelect::getTable ( Int  tabnr,
const String name,
const Table ftab,
const std::vector< const Table * > &  tempTables,
const std::vector< TableParseSelect * > &  stack,
Bool  alwaysOpen = True 
)

Make a Table object for given name, seqnr or so.

If alwaysOpen=False the table will only be looked up, but not opened if not found. This is meant for concatenated tables in TaQLNodeHandler.

◆ getTableInfo()

String casacore::TableParseSelect::getTableInfo ( const Vector< String > &  parts,
const TaQLStyle style 
)

Show the structure of fromTables_p[0] using the options given in parts[2:].

◆ getTypeString()

static String casacore::TableParseSelect::getTypeString ( const String typeStr,
DataType  type 
)
static

Get the type string.

If empty, it is made from the given data type.

◆ handleAddCol()

void casacore::TableParseSelect::handleAddCol ( const Record dmInfo)

Add columns to the table of ALTER TABLE.

The column descriptions have already been added to tableDesc_p.

◆ handleAddRow()

void casacore::TableParseSelect::handleAddRow ( const TableExprNode expr)

Evaluate and add the rows.

◆ handleAltTab()

void casacore::TableParseSelect::handleAltTab ( )

Reopen the table (for update) used in the ALTER TABLE command.

◆ handleCalcComm()

void casacore::TableParseSelect::handleCalcComm ( const TableExprNode )

Keep the expression of a calculate command.

◆ handleColSpec()

void casacore::TableParseSelect::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.

◆ handleColumn()

void casacore::TableParseSelect::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.

◆ handleColumnFinish()

void casacore::TableParseSelect::handleColumnFinish ( Bool  distinct)

Finish the addition of columns to the list of column names.

◆ handleCopyCol()

void casacore::TableParseSelect::handleCopyCol ( Bool  showTimings)

Handle copying of columns.

◆ handleCount()

void casacore::TableParseSelect::handleCount ( )

Make ready for a COUNT command.

It checks if all column expressions are scalar.

◆ handleCreTab()

void casacore::TableParseSelect::handleCreTab ( const Record dmInfo,
const std::vector< const Table * > &  tempTables,
const std::vector< TableParseSelect * > &  stack 
)

Keep the create table command.

◆ handleDropTab()

void casacore::TableParseSelect::handleDropTab ( const std::vector< const Table * > &  tempTables,
const std::vector< TableParseSelect * > &  stack 
)

Handle the DROP TABLE command.

◆ handleFunc()

TableExprNode casacore::TableParseSelect::handleFunc ( const String name,
const TableExprNodeSet arguments,
const TaQLStyle  
)

Handle a function.

◆ handleGiving() [1/2]

void casacore::TableParseSelect::handleGiving ( const String name,
const Record type 
)

Handle the name and type given in a GIVING clause.

◆ handleGiving() [2/2]

void casacore::TableParseSelect::handleGiving ( const TableExprNodeSet )

Handle the set given in a GIVING clause.

◆ handleGroupby()

void casacore::TableParseSelect::handleGroupby ( const std::vector< TableExprNode > &  ,
Bool  rollup 
)

Keep the groupby expressions.

It checks if they are all scalar expressions.

◆ handleHaving()

void casacore::TableParseSelect::handleHaving ( const TableExprNode )

Keep the having expression.

◆ handleInsert() [1/2]

void casacore::TableParseSelect::handleInsert ( )

Make ready for the insert expression.

The first one uses values (added via addUpdate), the second one a subquery.

◆ handleInsert() [2/2]

void casacore::TableParseSelect::handleInsert ( TableParseSelect sel)

◆ handleKeyCol()

TableExprNode casacore::TableParseSelect::handleKeyCol ( const String name,
Bool  tryProj 
)

Find the keyword or column name and create a TableExprNode from it.

If tryProj=True it is first tried if the column is a coluymn in the projected table (i.e., result from the SELECT part).

◆ handleLimit() [1/2]

void casacore::TableParseSelect::handleLimit ( const TableExprNode expr)

Evaluate and keep the limit value.

◆ handleLimit() [2/2]

void casacore::TableParseSelect::handleLimit ( const TableExprNodeSetElem expr)

Evaluate and keep limit/offset/stride given as start:end:incr.

◆ handleOffset()

void casacore::TableParseSelect::handleOffset ( const TableExprNode expr)

Evaluate and keep the offset value.

◆ handleRemoveKey()

void casacore::TableParseSelect::handleRemoveKey ( const String name)

Remove a table or column keyword.

◆ handleRenameKey()

void casacore::TableParseSelect::handleRenameKey ( const String oldName,
const String newName 
)

Rename a table or column keyword.

◆ handleSetKey()

void casacore::TableParseSelect::handleSetKey ( const String name,
const String dtype,
const ValueHolder value 
)

Add a keyword or replace a keyword with a value.

The keyword can be a table or column keyword (col::key). The data type string can be empty leaving the data type unchanged.

◆ handleSlice()

static TableExprNode casacore::TableParseSelect::handleSlice ( const TableExprNode array,
const TableExprNodeSet indices,
const TaQLStyle  
)
static

Handle a slice operator.

◆ handleSort()

void casacore::TableParseSelect::handleSort ( const std::vector< TableParseSort > &  sortList,
Bool  noDuplicates,
Sort::Order  defaultSortOrder 
)

Keep the sort expressions.

◆ handleUpdate()

void casacore::TableParseSelect::handleUpdate ( )

Keep the update expressions.

◆ handleWhere()

void casacore::TableParseSelect::handleWhere ( const TableExprNode )

Keep the selection expression.

◆ handleWildColumn()

void casacore::TableParseSelect::handleWildColumn ( Int  stringType,
const String name 
)
private

Handle the selection of a wildcarded column name.

◆ initDescriptions()

void casacore::TableParseSelect::initDescriptions ( const TableDesc ,
const Record dminfo 
)

Initialize the table and data manager descriptions.

◆ makeDataType()

DataType casacore::TableParseSelect::makeDataType ( DataType  dtype,
const String dtstr,
const String colName 
)
private

Make a data type from the string.

It checks if it is compatible with the given (expression) data type.

◆ makeFuncNode()

static TableExprNode casacore::TableParseSelect::makeFuncNode ( TableParseSelect ,
const String name,
const TableExprNodeSet arguments,
const Vector< int > &  ignoreFuncs,
const Table table,
const TaQLStyle  
)
static

Make a function object node for the given function name and arguments.

The ignoreFuncs vector contains invalid function codes.

◆ makeMaskSlice()

Array<Bool> casacore::TableParseSelect::makeMaskSlice ( const Array< Bool > &  mask,
Bool  maskFirst,
const IPosition shapeCol,
const Slicer slicerPtr 
)
private

◆ makeProjectExprSel()

void casacore::TableParseSelect::makeProjectExprSel ( )
private

Fill projectExprSelColumn_p telling the columns to be projected at the first stage.

◆ makeProjectExprTable()

void casacore::TableParseSelect::makeProjectExprTable ( )
private

Make the (empty) table for the epxression in the SELECT clause.

◆ makeSubSet()

TableExprNode casacore::TableParseSelect::makeSubSet ( ) const
private

Make a set from the results of the subquery.

◆ makeTableNoFrom()

void casacore::TableParseSelect::makeTableNoFrom ( const std::vector< TableParseSelect * > &  stack)

Create a temporary table if no tables are given in FROM.

◆ makeUDFNode()

static TableExprNode casacore::TableParseSelect::makeUDFNode ( TableParseSelect ,
const String name,
const TableExprNodeSet arguments,
const Table table,
const TaQLStyle  
)
staticprivate

Try to make a UDF function node for the given function name and arguments.

◆ openParentTable()

Table casacore::TableParseSelect::openParentTable ( const String fullName,
const String subTableName,
const std::vector< const Table * > &  tempTables,
const std::vector< TableParseSelect * > &  stack 
)
private

Open the parent table of a subtable.

◆ replaceTable()

void casacore::TableParseSelect::replaceTable ( const Table table)

Replace the first table (used by CALC command).

◆ setDMInfo()

void casacore::TableParseSelect::setDMInfo ( const Record dminfo)
inline

Set the DataManager info for a new table.

Definition at line 618 of file TableParse.h.

References dminfo_p.

◆ setInsertExprs()

void casacore::TableParseSelect::setInsertExprs ( const std::vector< TableExprNode exprs)
inline

Set the insert expressions for all rows.

Definition at line 530 of file TableParse.h.

References insertExprs_p.

◆ setRecFld()

static void casacore::TableParseSelect::setRecFld ( RecordInterface rec,
const String name,
const String dtype,
const ValueHolder vh 
)
static

Define a field with the given data type in the Record.

◆ show()

void casacore::TableParseSelect::show ( ostream &  os) const

Show the expression tree.

◆ splitName()

static Bool casacore::TableParseSelect::splitName ( String shorthand,
String columnName,
Vector< String > &  fieldNames,
const String name,
Bool  checkError,
Bool  isKeyword,
Bool  allowNoKey 
)
static

Split a name into its parts (shorthand, column and field names).

If isKeyword is True, the first part of name is a keyword, even if no :: is given. True is returned if the name contains a keyword part. In that case fieldNames contains the keyword name and the possible subfields. The possible shorthand and the column name are filled in if it is a column keyword. If the name represents a column, fieldNames contains the subfields of the column (for the case where the column contains records). If allowNoKey is True, a single :: is allowed, otherwise the name is invalid. If the name is invalid, exceptions are only thrown if checkError=True. Otherwise the name is treated as a normal name without keyword.

◆ testGroupAggr()

Int casacore::TableParseSelect::testGroupAggr ( std::vector< TableExprNodeRep * > &  aggr) const
private

Test if groupby or aggregate functions are given.


bit 0: on = groupby is given
bit 1: on = aggregate functions are given
bit 2: on = only select count(*) aggregate function is given

◆ updateArray()

template<typename TCOL , typename TNODE >
void casacore::TableParseSelect::updateArray ( rownr_t  row,
const TableExprId rowid,
const TableExprNode node,
const Array< TNODE > &  res,
ArrayColumn< TCOL > &  col 
)
private

◆ updateScalar()

template<typename TCOL , typename TNODE >
void casacore::TableParseSelect::updateScalar ( rownr_t  row,
const TableExprId rowid,
const TableExprNode node,
TableColumn col 
)
private

◆ updateSlice()

template<typename TCOL , typename TNODE >
void casacore::TableParseSelect::updateSlice ( rownr_t  row,
const TableExprId rowid,
const TableExprNode node,
const Array< TNODE > &  res,
const Slicer slice,
ArrayColumn< TCOL > &  col 
)
private

◆ updateValue()

template<typename TCOL , typename TNODE >
void casacore::TableParseSelect::updateValue ( rownr_t  row,
const TableExprId rowid,
Bool  isScalarCol,
const TableExprNode node,
const Array< Bool > &  mask,
Bool  maskFirst,
TableColumn col,
const Slicer slicerPtr,
ArrayColumn< Bool > &  maskCol 
)
private

Update the values in the columns (helpers of doUpdate).

Member Data Documentation

◆ applySelNodes_p

std::vector<TableExprNode> casacore::TableParseSelect::applySelNodes_p
private

Definition at line 975 of file TableParse.h.

Referenced by addApplySelNode().

◆ columnDtypes_p

Block<String> casacore::TableParseSelect::columnDtypes_p
private

Definition at line 928 of file TableParse.h.

◆ columnExpr_p

Block<TableExprNode> casacore::TableParseSelect::columnExpr_p
private

Definition at line 924 of file TableParse.h.

◆ columnKeywords_p

Block<TableRecord> casacore::TableParseSelect::columnKeywords_p
private

Definition at line 930 of file TableParse.h.

◆ columnNameMasks_p

Block<String> casacore::TableParseSelect::columnNameMasks_p
private

Definition at line 922 of file TableParse.h.

◆ columnNames_p

Block<String> casacore::TableParseSelect::columnNames_p
private

Definition at line 920 of file TableParse.h.

Referenced by getColumnNames().

◆ columnOldNames_p

Block<String> casacore::TableParseSelect::columnOldNames_p
private

Definition at line 926 of file TableParse.h.

◆ commandType_p

CommandType casacore::TableParseSelect::commandType_p
private

Definition at line 909 of file TableParse.h.

Referenced by commandType().

◆ distinct_p

Bool casacore::TableParseSelect::distinct_p
private

Definition at line 934 of file TableParse.h.

◆ dminfo_p

Record casacore::TableParseSelect::dminfo_p
private

Definition at line 913 of file TableParse.h.

Referenced by setDMInfo().

◆ endianFormat_p

Table::EndianFormat casacore::TableParseSelect::endianFormat_p
private

Definition at line 940 of file TableParse.h.

◆ endrow_p

Int64 casacore::TableParseSelect::endrow_p
private

Definition at line 955 of file TableParse.h.

◆ firstColName_p

String casacore::TableParseSelect::firstColName_p
private

Definition at line 981 of file TableParse.h.

◆ firstColTable_p

Table casacore::TableParseSelect::firstColTable_p
private

Definition at line 980 of file TableParse.h.

◆ fromTables_p

std::vector<TableParse> casacore::TableParseSelect::fromTables_p
private

Definition at line 918 of file TableParse.h.

◆ groupbyNodes_p

std::vector<TableExprNode> casacore::TableParseSelect::groupbyNodes_p
private

Definition at line 947 of file TableParse.h.

Referenced by doGroupByAggrSingleKey().

◆ groupbyRollup_p

Bool casacore::TableParseSelect::groupbyRollup_p
private

Definition at line 948 of file TableParse.h.

◆ havingNode_p

TableExprNode casacore::TableParseSelect::havingNode_p
private

Definition at line 950 of file TableParse.h.

◆ insertExprs_p

std::vector<TableExprNode> casacore::TableParseSelect::insertExprs_p
private

Definition at line 963 of file TableParse.h.

Referenced by setInsertExprs().

◆ insSel_p

TableParseSelect* casacore::TableParseSelect::insSel_p
private

Definition at line 965 of file TableParse.h.

◆ limit_p

Int64 casacore::TableParseSelect::limit_p
private

Definition at line 952 of file TableParse.h.

◆ node_p

TableExprNode casacore::TableParseSelect::node_p
private

Definition at line 945 of file TableParse.h.

Referenced by getNode().

◆ noDupl_p

Bool casacore::TableParseSelect::noDupl_p
private

Definition at line 969 of file TableParse.h.

◆ nrSelExprUsed_p

uInt casacore::TableParseSelect::nrSelExprUsed_p
private

Definition at line 932 of file TableParse.h.

◆ offset_p

Int64 casacore::TableParseSelect::offset_p
private

Definition at line 957 of file TableParse.h.

◆ order_p

Sort::Order casacore::TableParseSelect::order_p
private

Definition at line 971 of file TableParse.h.

Referenced by getOrder().

◆ overwrite_p

Bool casacore::TableParseSelect::overwrite_p
private

Definition at line 941 of file TableParse.h.

◆ projectExprSelColumn_p

Block<Bool> casacore::TableParseSelect::projectExprSelColumn_p
private

Definition at line 986 of file TableParse.h.

◆ projectExprSubset_p

Block<uInt> casacore::TableParseSelect::projectExprSubset_p
private

Definition at line 985 of file TableParse.h.

◆ projectExprTable_p

Table casacore::TableParseSelect::projectExprTable_p
private

Definition at line 983 of file TableParse.h.

◆ resultCreated_p

Bool casacore::TableParseSelect::resultCreated_p
private

Definition at line 938 of file TableParse.h.

◆ resultName_p

String casacore::TableParseSelect::resultName_p
private

Definition at line 936 of file TableParse.h.

◆ resultSet_p

TableExprNodeSet* casacore::TableParseSelect::resultSet_p
private

Definition at line 943 of file TableParse.h.

◆ resultType_p

uInt casacore::TableParseSelect::resultType_p
private

Definition at line 937 of file TableParse.h.

◆ rownrs_p

Vector<rownr_t> casacore::TableParseSelect::rownrs_p
private

Definition at line 988 of file TableParse.h.

Referenced by doGroupByAggrSingleKey().

◆ sort_p

std::vector<TableParseSort> casacore::TableParseSelect::sort_p
private

Definition at line 967 of file TableParse.h.

◆ storageOption_p

StorageOption casacore::TableParseSelect::storageOption_p
private

Definition at line 939 of file TableParse.h.

◆ stride_p

Int64 casacore::TableParseSelect::stride_p
private

Definition at line 959 of file TableParse.h.

◆ table_p

Table casacore::TableParseSelect::table_p
private

Definition at line 977 of file TableParse.h.

Referenced by getTable().

◆ tableDesc_p

std::shared_ptr<TableDesc> casacore::TableParseSelect::tableDesc_p
private

Definition at line 912 of file TableParse.h.

◆ update_p

std::vector<CountedPtr<TableParseUpdate> > casacore::TableParseSelect::update_p
private

Definition at line 961 of file TableParse.h.

Referenced by addUpdate().

◆ withTables_p

std::vector<TableParse> casacore::TableParseSelect::withTables_p
private

Definition at line 917 of file TableParse.h.


The documentation for this class was generated from the following file: