8#ifndef MODEL_EXPRESSION_SQL_H
9#define MODEL_EXPRESSION_SQL_H
93 const string & i_accTableName,
const vector<string> & i_dimCols,
const vector<int> & i_accIds,
const vector<string> & i_accNames,
const vector<string> & i_accCols
132 const string translateAllSimpleFnc(
const string & i_srcMsg,
bool i_isSkipAggr,
const string & i_expr);
156 const string & i_accTableName,
157 const vector<string> & i_dimCols,
158 const vector<int> & i_accIds,
159 const vector<string> & i_accNames,
160 const vector<string> & i_accCols,
161 const vector<TableAccRow> & i_tableAcc
164 tableAccVec(i_tableAcc)
179 const string translateNativeAccExpr(
const string & i_outTableName,
const string & i_accName,
int i_accId);
191 const string translateDerivedAccExpr(
const string & i_outTableName,
const string & i_accName,
const string & i_expr,
const map<string, size_t> & i_nativeMap);
198 const vector<TableAccRow> & tableAccVec;
201 vector<bool> isAccUsedArr;
222 const string & i_accTableName,
223 const vector<string> & i_dimCols,
224 const vector<int> & i_accIds,
225 const vector<string> & i_accNames,
226 const vector<string> & i_accCols
244 const string translateAggregationExpr(
const string & i_outTableName,
const string & i_name,
const string & i_colName,
const string & i_expr);
251 vector<bool> isAccUsedArr;
254 vector<AggregationColumnExpr> nextExprArr;
257 const string translateAggregationFnc(
FncCode i_code,
const string & i_nextInnerAlias,
const string & i_arg);
260 const string translateArg(
const string & i_nextInnerAlias,
const string & i_arg);
263 const string processAccumulators(
const string & i_expr);
266 const string processAccumulators(
bool i_isTranslate,
int i_level,
const string & i_fromAlias,
const string & i_expr);
269 const string pushAvgToNextLevel(
const string & i_arg) {
return pushToNextLevel(
"OM_AVG(" + i_arg +
")"); }
272 const string pushToNextLevel(
const string & i_fncExpr);
275 bool isFirstUsedAcc(
int i_accPos,
const vector<bool> & i_accUsage)
const;
278 const string makeAccTableAlias(
int i_accPos,
const vector<bool> & i_accUsage,
int i_level,
const string i_firstAlias)
const;
class to produce accumulators sql subqueries for output table
Definition: modelExpressionSql.h:144
ModelAccumulatorSql(const string &i_accTableName, const vector< string > &i_dimCols, const vector< int > &i_accIds, const vector< string > &i_accNames, const vector< string > &i_accCols, const vector< TableAccRow > &i_tableAcc)
initialization: store output table definition parts.
Definition: modelExpressionSql.h:155
const string translateDerivedAccExpr(const string &i_outTableName, const string &i_accName, const string &i_expr, const map< string, size_t > &i_nativeMap)
translate output table derived accumulator into sql CTE subquery.
Definition: modelExpressionSql.cpp:851
~ModelAccumulatorSql() noexcept
release sql builder resources.
Definition: modelExpressionSql.h:168
const string translateNativeAccExpr(const string &i_outTableName, const string &i_accName, int i_accId)
translate output table "native" (non-derived) accumulator into sql CTE subquery.
Definition: modelExpressionSql.cpp:803
class to produce aggregation sql for otput table
Definition: modelExpressionSql.h:210
~ModelAggregationSql() noexcept
release sql builder resources.
Definition: modelExpressionSql.h:232
ModelAggregationSql(const string &i_accTableName, const vector< string > &i_dimCols, const vector< int > &i_accIds, const vector< string > &i_accNames, const vector< string > &i_accCols)
create aggregation sql builder for output table.
Definition: modelExpressionSql.h:221
const string translateAggregationExpr(const string &i_outTableName, const string &i_name, const string &i_colName, const string &i_expr)
translate output aggregation expression into sql.
Definition: modelExpressionSql.cpp:134
base class to produce sql expressions and subqueries for otput table
Definition: modelExpressionSql.h:81
const string accTableName
accumulator database table name
Definition: modelExpressionSql.h:109
const vector< int > accIds
ids of table accumulators
Definition: modelExpressionSql.h:115
~ModelBaseExpressionSql() noexcept
release sql builder resources.
Definition: modelExpressionSql.h:105
const vector< string > accNames
names of table accumulators: Acc0, Acc1
Definition: modelExpressionSql.h:118
const vector< string > dimCols
names of table dimensions
Definition: modelExpressionSql.h:112
int accCount
number of accumulators
Definition: modelExpressionSql.h:124
ModelBaseExpressionSql(const string &i_accTableName, const vector< string > &i_dimCols, const vector< int > &i_accIds, const vector< string > &i_accNames, const vector< string > &i_accCols)
initialization: store output table definition parts.
Definition: modelExpressionSql.h:92
const string translateAllSimpleFnc(const string &i_srcMsg, bool i_isSkipAggr, const string &i_expr)
translate (substitute) all non-aggregation functions
Definition: modelExpressionSql.cpp:366
static const string translateSimpleFnc(const string &i_srcMsg, FncCode i_code, const string &i_arg)
translate (substitute) non-aggregation function
Definition: modelExpressionSql.cpp:434
const vector< string > accCols
column names of table accumulators: acc0, acc1
Definition: modelExpressionSql.h:121
openM++ namespace
Definition: log.h:32
FncCode
aggregation and non-aggregation function code
Definition: modelExpressionSql.h:18
@ undefined
undefined function
@ div_by
divide by: wrap value as divisor
@ if_case
if condition then value else other value
@ cv
coefficient of variation
column aggregation expression
Definition: modelExpressionSql.h:58
string colName
column name, ie: ex2
Definition: modelExpressionSql.h:60
string sqlExpr
sql expresiion, ie: AVG(M2.acc0)
Definition: modelExpressionSql.h:66
string srcExpr
source expression, ie: OM_AVG(acc0)
Definition: modelExpressionSql.h:63
static int nextExprNumber
number of aggregation epxpressions
Definition: modelExpressionSql.h:69