提交 b03b139b 编写于 作者: D dapan1121

feat: support case when clause

上级 2d3992b7
...@@ -602,6 +602,10 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe ...@@ -602,6 +602,10 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe
if (*whenValue) { if (*whenValue) {
colDataAppend(output->columnData, rowIdx, colDataGetData(pThen, (pThen->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pThen, (pThen->numOfRows > 1 ? rowIdx : 0))); colDataAppend(output->columnData, rowIdx, colDataGetData(pThen, (pThen->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pThen, (pThen->numOfRows > 1 ? rowIdx : 0)));
if (0 == rowIdx && 1 == pWhen->numOfRows) {
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
}
goto _return; goto _return;
} }
...@@ -611,12 +615,20 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe ...@@ -611,12 +615,20 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe
if (pElse) { if (pElse) {
colDataAppend(output->columnData, rowIdx, colDataGetData(pElse, (pElse->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pElse, (pElse->numOfRows > 1 ? rowIdx : 0))); colDataAppend(output->columnData, rowIdx, colDataGetData(pElse, (pElse->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pElse, (pElse->numOfRows > 1 ? rowIdx : 0)));
if (0 == rowIdx && 1 == pElse->numOfRows) {
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
}
goto _return; goto _return;
} }
colDataAppend(output->columnData, rowIdx, NULL, true); colDataAppend(output->columnData, rowIdx, NULL, true);
if (0 == rowIdx) {
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
}
_return: _return:
sclFreeParam(pWhen); sclFreeParam(pWhen);
...@@ -832,9 +844,10 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp ...@@ -832,9 +844,10 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
} }
} else { } else {
for (int32_t i = 0; i < rowNum; ++i) { for (int32_t i = 0; i < rowNum; ++i) {
bool *equal = colDataGetData(pWhen->columnData, i); bool *equal = colDataGetData(pWhen->columnData, (pThen->numOfRows > 1 ? i : 0));
if (*equal) { if (*equal) {
colDataAppend(output->columnData, i, colDataGetData(pThen, (pThen->numOfRows > 1 ? i : 0)), colDataIsNull_s(pThen, (pThen->numOfRows > 1 ? i : 0))); colDataAppend(output->columnData, i, colDataGetData(pThen, (pThen->numOfRows > 1 ? i : 0)), colDataIsNull_s(pThen, (pThen->numOfRows > 1 ? i : 0)));
SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList));
} else { } else {
SCL_ERR_JRET(sclWalkWhenList(ctx, node->pWhenThenList, node->pWhenThenList->pHead->pNext, pElse, output, i)); SCL_ERR_JRET(sclWalkWhenList(ctx, node->pWhenThenList, node->pWhenThenList->pHead->pNext, pElse, output, i));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册