You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-08-01 06:46:55 +03:00
MCOL-1535 caseOperationType adjusted for new simple case order
This commit is contained in:
@ -259,17 +259,10 @@ CalpontSystemCatalog::ColType caseOperationType(FunctionParm& fp,
|
|||||||
CalpontSystemCatalog::ColType& resultType,
|
CalpontSystemCatalog::ColType& resultType,
|
||||||
bool simpleCase)
|
bool simpleCase)
|
||||||
{
|
{
|
||||||
FunctionParm::size_type n = fp.size();
|
uint64_t simple = simpleCase ? 1 : 0;
|
||||||
|
bool hasElse = (((fp.size()-simple) % 2) != 0); // if 1, then ELSE exist
|
||||||
if (simpleCase) // simple case has an expression
|
|
||||||
n -= 1; // remove expression from count of expression_i + result_i
|
|
||||||
bool hasElse = ((n % 2) != 0); // if 1, then ELSE exist
|
|
||||||
if (hasElse)
|
|
||||||
--n; // n now is an even number
|
|
||||||
uint64_t parmCount = hasElse ? (fp.size() - 2) : (fp.size() - 1);
|
uint64_t parmCount = hasElse ? (fp.size() - 2) : (fp.size() - 1);
|
||||||
uint64_t whereCount = hasElse ? (fp.size() - 2 + simpleCase) / 2 : (fp.size() - 1) / 2 + simpleCase;
|
uint64_t whereCount = hasElse ? (fp.size() - 2 + simple) / 2 : (fp.size() - 1) / 2 + simple;
|
||||||
|
|
||||||
idbassert((n % 2) == 0);
|
|
||||||
|
|
||||||
bool allStringO = true;
|
bool allStringO = true;
|
||||||
bool allStringR = true;
|
bool allStringR = true;
|
||||||
@ -281,18 +274,10 @@ CalpontSystemCatalog::ColType caseOperationType(FunctionParm& fp,
|
|||||||
bool operation = true;
|
bool operation = true;
|
||||||
for (uint64_t i = 0; i <= parmCount; i++)
|
for (uint64_t i = 0; i <= parmCount; i++)
|
||||||
{
|
{
|
||||||
// operation or result type
|
// for SimpleCase, we return the type of the case expression,
|
||||||
operation = ((i > 0) && (i <= whereCount));
|
// which will always be in position 0.
|
||||||
|
if (i == 0 && simpleCase)
|
||||||
// the result type of ELSE, if exists.
|
|
||||||
if (i == n)
|
|
||||||
{
|
{
|
||||||
if (!hasElse)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (simpleCase)
|
|
||||||
{
|
|
||||||
// the case expression
|
|
||||||
if (fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::CHAR &&
|
if (fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::CHAR &&
|
||||||
fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::TEXT &&
|
fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::TEXT &&
|
||||||
fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::VARCHAR)
|
fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::VARCHAR)
|
||||||
@ -302,12 +287,11 @@ CalpontSystemCatalog::ColType caseOperationType(FunctionParm& fp,
|
|||||||
allStringO = false;
|
allStringO = false;
|
||||||
oct = op.operationType();
|
oct = op.operationType();
|
||||||
}
|
}
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
operation = false;
|
// operation or result type
|
||||||
}
|
operation = ((i > 0+simple) && (i <= whereCount));
|
||||||
|
|
||||||
if (fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::CHAR &&
|
if (fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::CHAR &&
|
||||||
fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::TEXT &&
|
fp[i]->data()->resultType().colDataType != CalpontSystemCatalog::TEXT &&
|
||||||
@ -317,9 +301,12 @@ CalpontSystemCatalog::ColType caseOperationType(FunctionParm& fp,
|
|||||||
PredicateOperator op;
|
PredicateOperator op;
|
||||||
if (operation)
|
if (operation)
|
||||||
{
|
{
|
||||||
|
if (!simpleCase)
|
||||||
|
{
|
||||||
op.setOpType(oct, fp[i]->data()->resultType());
|
op.setOpType(oct, fp[i]->data()->resultType());
|
||||||
allStringO = false;
|
allStringO = false;
|
||||||
oct = op.operationType();
|
oct = op.operationType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If any parm is of string type, the result type should be string. (same as if)
|
// If any parm is of string type, the result type should be string. (same as if)
|
||||||
@ -395,6 +382,13 @@ bool Func_simple_case::getBoolVal(Row& row,
|
|||||||
if (isNull)
|
if (isNull)
|
||||||
return joblist::BIGINTNULL;
|
return joblist::BIGINTNULL;
|
||||||
|
|
||||||
|
ParseTree* lop = parm[i]->left();
|
||||||
|
ParseTree* rop = parm[i]->right();
|
||||||
|
if (lop && rop)
|
||||||
|
{
|
||||||
|
return (reinterpret_cast<Operator*>(parm[i]->data()))->getBoolVal(row, isNull, lop, rop);
|
||||||
|
}
|
||||||
|
|
||||||
return parm[i]->data()->getBoolVal(row, isNull);
|
return parm[i]->data()->getBoolVal(row, isNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user