Merge pull request #19205 from taosdata/szhou/cenc
fix: covert scalar param to data block
This commit is contained in:
commit
8b8acdc2d7
|
@ -841,36 +841,42 @@ int32_t convertScalarParamToDataBlock(SScalarParam *input, int32_t numOfCols, SS
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
numOfRows = (input[i].numOfRows > numOfRows) ? input[i].numOfRows : numOfRows;
|
numOfRows = (input[i].numOfRows > numOfRows) ? input[i].numOfRows : numOfRows;
|
||||||
}
|
}
|
||||||
output->info.rows = numOfRows;
|
|
||||||
output->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData));
|
// create the basic block info structure
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
if ((input+i)->numOfRows < numOfRows) {
|
SColumnInfoData* pInfo = input[i].columnData;
|
||||||
SColumnInfoData* pColInfoData = (input+i)->columnData;
|
SColumnInfoData d = {0};
|
||||||
int32_t startRow = (input+i)->numOfRows;
|
d.info = pInfo->info;
|
||||||
int32_t expandRows = numOfRows - startRow;
|
|
||||||
colInfoDataEnsureCapacity(pColInfoData, numOfRows, false);
|
blockDataAppendColInfo(output, &d);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockDataEnsureCapacity(output, numOfRows);
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < numOfCols; ++i) {
|
||||||
|
SColumnInfoData* pDest = taosArrayGet(output->pDataBlock, i);
|
||||||
|
|
||||||
|
SColumnInfoData* pColInfoData = input[i].columnData;
|
||||||
|
colDataAssign(pDest, pColInfoData, input[i].numOfRows, &output->info);
|
||||||
|
|
||||||
|
if (input[i].numOfRows < numOfRows) {
|
||||||
|
int32_t startRow = input[i].numOfRows;
|
||||||
|
int expandRows = numOfRows - startRow;
|
||||||
bool isNull = colDataIsNull_s(pColInfoData, (input+i)->numOfRows - 1);
|
bool isNull = colDataIsNull_s(pColInfoData, (input+i)->numOfRows - 1);
|
||||||
if (isNull) {
|
if (isNull) {
|
||||||
colDataAppendNNULL(pColInfoData, startRow, expandRows);
|
colDataAppendNNULL(pDest, startRow, expandRows);
|
||||||
} else {
|
} else {
|
||||||
char* src = colDataGetData(pColInfoData, (input + i)->numOfRows - 1);
|
char* src = colDataGetData(pColInfoData, (input + i)->numOfRows - 1);
|
||||||
int32_t bytes = pColInfoData->info.bytes;
|
|
||||||
char* data = taosMemoryMalloc(bytes);
|
|
||||||
memcpy(data, src, bytes);
|
|
||||||
for (int j = 0; j < expandRows; ++j) {
|
for (int j = 0; j < expandRows; ++j) {
|
||||||
colDataAppend(pColInfoData, startRow+j, data, false);
|
colDataAppend(pDest, startRow+j, src, false);
|
||||||
}
|
}
|
||||||
//colDataAppendNItems(pColInfoData, startRow, data, expandRows);
|
//colDataAppendNItems(pColInfoData, startRow, data, expandRows);
|
||||||
taosMemoryFree(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(output->pDataBlock, (input + i)->columnData);
|
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE((input + i)->columnData->info.type)) {
|
|
||||||
output->info.hasVarCol = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output->info.rows = numOfRows;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1825,7 +1831,7 @@ int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t
|
||||||
taosArrayDestroy(resultBlock.pDataBlock);
|
taosArrayDestroy(resultBlock.pDataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(inputBlock.pDataBlock);
|
blockDataFreeRes(&inputBlock);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue