Merge pull request #13483 from taosdata/feature/TD-13041
feat: add sort/group logic for json
This commit is contained in:
commit
10e4824194
|
@ -71,20 +71,14 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
|
|||
#define colDataGetData(p1_, r_) \
|
||||
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
|
||||
|
||||
static FORCE_INLINE bool colDataIsNull_s(const SColumnInfoData* pColumnInfoData, uint32_t row) {
|
||||
if (pColumnInfoData->info.type == TSDB_DATA_TYPE_JSON) {
|
||||
if (colDataIsNull_var(pColumnInfoData, row)) {
|
||||
return true;
|
||||
}
|
||||
char* data = colDataGetVarData(pColumnInfoData, row);
|
||||
return (*data == TSDB_DATA_TYPE_NULL);
|
||||
}
|
||||
#define IS_JSON_NULL(type,data) ((type) == TSDB_DATA_TYPE_JSON && *(data) == TSDB_DATA_TYPE_NULL)
|
||||
|
||||
static FORCE_INLINE bool colDataIsNull_s(const SColumnInfoData* pColumnInfoData, uint32_t row) {
|
||||
if (!pColumnInfoData->hasNull) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pColumnInfoData->info.type == TSDB_DATA_TYPE_VARCHAR || pColumnInfoData->info.type == TSDB_DATA_TYPE_NCHAR) {
|
||||
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||
return colDataIsNull_var(pColumnInfoData, row);
|
||||
} else {
|
||||
if (pColumnInfoData->nullbitmap == NULL) {
|
||||
|
|
|
@ -129,7 +129,7 @@ typedef enum EOperatorType {
|
|||
OP_TYPE_SUB,
|
||||
OP_TYPE_MULTI,
|
||||
OP_TYPE_DIV,
|
||||
OP_TYPE_MOD,
|
||||
OP_TYPE_REM,
|
||||
// unary arithmetic operator
|
||||
OP_TYPE_MINUS,
|
||||
OP_TYPE_ASSIGN,
|
||||
|
|
|
@ -109,7 +109,7 @@ int32_t getJsonValueLen(const char *data) {
|
|||
dataLen = DOUBLE_BYTES + CHAR_BYTES;
|
||||
} else if (*data == TSDB_DATA_TYPE_BOOL) {
|
||||
dataLen = CHAR_BYTES + CHAR_BYTES;
|
||||
} else if (*data == TD_TAG_JSON) { // json string
|
||||
} else if (*data & TD_TAG_JSON) { // json string
|
||||
dataLen = ((STag*)(data))->len;
|
||||
} else {
|
||||
ASSERT(0);
|
||||
|
|
|
@ -1096,7 +1096,7 @@ bool nodesIsArithmeticOp(const SOperatorNode* pOp) {
|
|||
case OP_TYPE_SUB:
|
||||
case OP_TYPE_MULTI:
|
||||
case OP_TYPE_DIV:
|
||||
case OP_TYPE_MOD:
|
||||
case OP_TYPE_REM:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -611,7 +611,7 @@ expression(A) ::= expression(B) NK_SLASH expression(C).
|
|||
expression(A) ::= expression(B) NK_REM expression(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, C);
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)));
|
||||
}
|
||||
expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C). {
|
||||
SToken s = getTokenFromRawExprNode(pCxt, B);
|
||||
|
|
|
@ -4079,7 +4079,7 @@ static YYACTIONTYPE yy_reduce(
|
|||
{
|
||||
SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172);
|
||||
SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172);
|
||||
yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172)));
|
||||
yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172)));
|
||||
}
|
||||
yymsp[-2].minor.yy172 = yylhsminor.yy172;
|
||||
break;
|
||||
|
|
|
@ -350,7 +350,7 @@ struct SFilterInfo {
|
|||
|
||||
extern bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right);
|
||||
extern __compar_fn_t filterGetCompFunc(int32_t type, int32_t optr);
|
||||
|
||||
extern OptrStr gOptrStr[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -29,8 +29,9 @@ OptrStr gOptrStr[] = {
|
|||
{OP_TYPE_SUB, "-"},
|
||||
{OP_TYPE_MULTI, "*"},
|
||||
{OP_TYPE_DIV, "/"},
|
||||
{OP_TYPE_MOD, "%"},
|
||||
|
||||
{OP_TYPE_REM, "%"},
|
||||
{OP_TYPE_MINUS, "minus"},
|
||||
{OP_TYPE_ASSIGN, "assign"},
|
||||
// bit operator
|
||||
{OP_TYPE_BIT_AND, "&"},
|
||||
{OP_TYPE_BIT_OR, "|"},
|
||||
|
|
|
@ -29,6 +29,12 @@
|
|||
#define LEFT_COL ((pLeftCol->info.type == TSDB_DATA_TYPE_JSON ? (void*)pLeftCol : pLeftCol->pData))
|
||||
#define RIGHT_COL ((pRightCol->info.type == TSDB_DATA_TYPE_JSON ? (void*)pRightCol : pRightCol->pData))
|
||||
|
||||
#define IS_NULL colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i) \
|
||||
|| IS_JSON_NULL(pLeft->columnData->info.type, colDataGetVarData(pLeft->columnData, i)) \
|
||||
|| IS_JSON_NULL(pRight->columnData->info.type, colDataGetVarData(pRight->columnData, i))
|
||||
|
||||
#define IS_HELPER_NULL(col,i) colDataIsNull_s(col, i) || IS_JSON_NULL(col->info.type, colDataGetVarData(col, i))
|
||||
|
||||
void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType){
|
||||
switch (outType) {
|
||||
case TSDB_DATA_TYPE_BOOL: {
|
||||
|
@ -387,7 +393,7 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
|
|||
|
||||
pOut->numOfRows = pIn->numOfRows;
|
||||
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pIn->columnData, i)) {
|
||||
if (IS_HELPER_NULL(pIn->columnData, i)) {
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -396,8 +402,7 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
|
|||
int32_t convertType = inType;
|
||||
if(inType == TSDB_DATA_TYPE_JSON){
|
||||
if(*data == TSDB_DATA_TYPE_NULL) {
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
continue;
|
||||
ASSERT(0);
|
||||
}
|
||||
else if(*data == TSDB_DATA_TYPE_NCHAR) {
|
||||
data += CHAR_BYTES;
|
||||
|
@ -447,13 +452,13 @@ double getVectorDoubleValue_JSON(void *src, int32_t index){
|
|||
return out;
|
||||
}
|
||||
|
||||
void convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t typeRight, char **pLeftData, char **pRightData, void *pLeftOut, void *pRightOut, bool *isNull){
|
||||
bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t typeRight, char **pLeftData, char **pRightData, void *pLeftOut, void *pRightOut, bool *isNull){
|
||||
if(optr == OP_TYPE_JSON_CONTAINS) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(typeLeft != TSDB_DATA_TYPE_JSON && typeRight != TSDB_DATA_TYPE_JSON){
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if(typeLeft == TSDB_DATA_TYPE_JSON){
|
||||
|
@ -464,15 +469,22 @@ void convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
|
|||
typeRight = **pRightData;
|
||||
(*pRightData) ++;
|
||||
}
|
||||
|
||||
if(optr == OP_TYPE_LIKE || optr == OP_TYPE_NOT_LIKE || optr == OP_TYPE_MATCH || optr == OP_TYPE_NMATCH){
|
||||
if(typeLeft != TSDB_DATA_TYPE_NCHAR && typeLeft != TSDB_DATA_TYPE_BINARY){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(typeLeft == TSDB_DATA_TYPE_NULL || typeRight == TSDB_DATA_TYPE_NULL){
|
||||
*isNull = true;
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
int8_t type = vectorGetConvertType(typeLeft, typeRight);
|
||||
|
||||
if(type == 0) {
|
||||
*fp = filterGetCompFunc(typeLeft, optr);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
*fp = filterGetCompFunc(type, optr);
|
||||
|
@ -492,6 +504,7 @@ void convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
|
|||
convertNumberToNumber(*pRightData, pRightOut, typeRight, type);
|
||||
*pRightData = pRightOut;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int16_t inType, int16_t outType) {
|
||||
|
@ -867,11 +880,11 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
|||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -887,11 +900,11 @@ static void vectorMathBigintAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData
|
|||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -982,7 +995,7 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
|||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
if (IS_NULL) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1000,7 +1013,7 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
|||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
if (IS_NULL){
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1024,11 +1037,11 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
|
|||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1044,11 +1057,11 @@ static void vectorMathBigintSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData
|
|||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1077,7 +1090,7 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
|||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
if (IS_NULL) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1095,7 +1108,7 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
|
|||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
if (IS_NULL) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1119,11 +1132,11 @@ static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData*
|
|||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1149,7 +1162,7 @@ void vectorMathMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
|
|||
double *output = (double *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
if (IS_NULL) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1182,7 +1195,7 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
|
|||
double *output = (double *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i) || (getVectorDoubleValueFnRight(RIGHT_COL, i) == 0)) { //divide by 0 check
|
||||
if (IS_NULL || (getVectorDoubleValueFnRight(RIGHT_COL, i) == 0)) { //divide by 0 check
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -1190,11 +1203,11 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
|
|||
/ getVectorDoubleValueFnRight(RIGHT_COL, i);
|
||||
}
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
if (colDataIsNull_s(pLeftCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pLeftCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, pRight->numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pRightCol, i) || (getVectorDoubleValueFnRight(RIGHT_COL, i) == 0)) { // divide by 0 check
|
||||
if (IS_HELPER_NULL(pRightCol, i) || (getVectorDoubleValueFnRight(RIGHT_COL, i) == 0)) { // divide by 0 check
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -1203,11 +1216,11 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
|
|||
}
|
||||
}
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
if (colDataIsNull_s(pRightCol, 0) || (getVectorDoubleValueFnRight(RIGHT_COL, 0) == 0)) { // Set pLeft->numOfRows NULL value (divde by 0 check)
|
||||
if (IS_HELPER_NULL(pRightCol, 0) || (getVectorDoubleValueFnRight(RIGHT_COL, 0) == 0)) { // Set pLeft->numOfRows NULL value (divde by 0 check)
|
||||
colDataAppendNNULL(pOutputCol, 0, pLeft->numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -1236,18 +1249,17 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
|
|||
_getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type);
|
||||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
double zero = 0.0;
|
||||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i) || colDataIsNull_s(pRightCol, i)) {
|
||||
if (IS_NULL) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
double lx = getVectorDoubleValueFnLeft(LEFT_COL, i);
|
||||
double rx = getVectorDoubleValueFnRight(RIGHT_COL, i);
|
||||
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx)) {
|
||||
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -1256,11 +1268,11 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
|
|||
}
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
double lx = getVectorDoubleValueFnLeft(LEFT_COL, 0);
|
||||
if (colDataIsNull_s(pLeftCol, 0) || isnan(lx) || isinf(lx)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pLeftCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, pRight->numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pRightCol, i)) {
|
||||
if (IS_HELPER_NULL(pRightCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -1276,11 +1288,11 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
|
|||
}
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
double rx = getVectorDoubleValueFnRight(RIGHT_COL, 0);
|
||||
if (colDataIsNull_s(pRightCol, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pRightCol, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, pLeft->numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -1315,7 +1327,7 @@ void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO
|
|||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
for (; i < pLeft->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
@ -1331,7 +1343,7 @@ void vectorAssign(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
|
|||
|
||||
pOut->numOfRows = pLeft->numOfRows;
|
||||
|
||||
if (colDataIsNull_s(pRight->columnData, 0)) {
|
||||
if (IS_HELPER_NULL(pRight->columnData, 0)) {
|
||||
for (int32_t i = 0; i < pOut->numOfRows; ++i) {
|
||||
colDataAppend(pOutputCol, i, NULL, true);
|
||||
}
|
||||
|
@ -1397,13 +1409,13 @@ static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRigh
|
|||
_getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type);
|
||||
_getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type);
|
||||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_s(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1429,7 +1441,7 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
|
|||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
if (IS_NULL) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1451,12 +1463,12 @@ static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRight
|
|||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
|
||||
if (colDataIsNull_s(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
||||
colDataAppendNNULL(pOutputCol, 0, numOfRows);
|
||||
} else {
|
||||
int64_t rx = getVectorBigintValueFnRight(RIGHT_COL, 0);
|
||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeftCol, i)) {
|
||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1482,7 +1494,7 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
|
|||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
if (IS_NULL) {
|
||||
colDataAppendNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
@ -1507,7 +1519,7 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
|
||||
if (pRight->pHashFilter != NULL) {
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i)) {
|
||||
if (IS_HELPER_NULL(pLeft->columnData, i)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
continue;
|
||||
|
@ -1522,7 +1534,7 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
if (IS_HELPER_NULL(pLeft->columnData, i) || IS_HELPER_NULL(pRight->columnData, i)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
continue; // TODO set null or ignore
|
||||
|
@ -1534,18 +1546,21 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
int64_t leftOut = 0;
|
||||
int64_t rightOut = 0;
|
||||
bool isJsonnull = false;
|
||||
convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull);
|
||||
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull);
|
||||
if(isJsonnull){
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
continue; // TODO set null or ignore
|
||||
ASSERT(0);
|
||||
}
|
||||
if(!result){
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&result);
|
||||
}else{
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
}
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
}
|
||||
} else if (pRight->numOfRows == 1) {
|
||||
ASSERT(pLeft->pHashFilter == NULL);
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, 0)) {
|
||||
if (IS_HELPER_NULL(pLeft->columnData, i) || IS_HELPER_NULL(pRight->columnData, 0)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
continue;
|
||||
|
@ -1556,17 +1571,20 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
int64_t leftOut = 0;
|
||||
int64_t rightOut = 0;
|
||||
bool isJsonnull = false;
|
||||
convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull);
|
||||
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull);
|
||||
if(isJsonnull){
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
continue; // TODO set null or ignore
|
||||
ASSERT(0);
|
||||
}
|
||||
if(!result){
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&result);
|
||||
}else{
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
}
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
}
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
for (; i >= 0 && i < pRight->numOfRows; i += step) {
|
||||
if (colDataIsNull_s(pRight->columnData, i) || colDataIsNull_s(pLeft->columnData, 0)) {
|
||||
if (IS_HELPER_NULL(pRight->columnData, i) || IS_HELPER_NULL(pLeft->columnData, 0)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
continue;
|
||||
|
@ -1577,13 +1595,16 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
int64_t leftOut = 0;
|
||||
int64_t rightOut = 0;
|
||||
bool isJsonnull = false;
|
||||
convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull);
|
||||
bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull);
|
||||
if(isJsonnull){
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
continue; // TODO set null or ignore
|
||||
ASSERT(0);
|
||||
}
|
||||
if(!result){
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&result);
|
||||
}else{
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
}
|
||||
bool res = filterDoCompare(fp, optr, pLeftData, pRightData);
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1668,7 +1689,7 @@ void vectorJsonContains(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
|
|||
|
||||
void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||
for(int32_t i = 0; i < pLeft->numOfRows; ++i) {
|
||||
int8_t v = colDataIsNull_s(pLeft->columnData, i)? 1:0;
|
||||
int8_t v = IS_HELPER_NULL(pLeft->columnData, i) ? 1 : 0;
|
||||
colDataAppendInt8(pOut->columnData, i, &v);
|
||||
}
|
||||
pOut->numOfRows = pLeft->numOfRows;
|
||||
|
@ -1676,7 +1697,7 @@ void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
|
|||
|
||||
void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
|
||||
for(int32_t i = 0; i < pLeft->numOfRows; ++i) {
|
||||
int8_t v = colDataIsNull_s(pLeft->columnData, i)? 0:1;
|
||||
int8_t v = IS_HELPER_NULL(pLeft->columnData, i) ? 0 : 1;
|
||||
colDataAppendInt8(pOut->columnData, i, &v);
|
||||
}
|
||||
pOut->numOfRows = pLeft->numOfRows;
|
||||
|
@ -1696,7 +1717,7 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
|
|||
return vectorMathMultiply;
|
||||
case OP_TYPE_DIV:
|
||||
return vectorMathDivide;
|
||||
case OP_TYPE_MOD:
|
||||
case OP_TYPE_REM:
|
||||
return vectorMathRemainder;
|
||||
case OP_TYPE_MINUS:
|
||||
return vectorMathMinus;
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nodes.h"
|
||||
#include "tlog.h"
|
||||
#include "parUtil.h"
|
||||
#include "filterInt.h"
|
||||
|
||||
#define _DEBUG_PRINT_ 0
|
||||
|
||||
|
@ -212,6 +213,24 @@ void scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in
|
|||
*pNode = (SNode *)rnode;
|
||||
}
|
||||
|
||||
void scltMakeOpNode2(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight, bool isReverse) {
|
||||
SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode *onode = (SOperatorNode *)node;
|
||||
onode->node.resType.type = resType;
|
||||
onode->node.resType.bytes = tDataTypes[resType].bytes;
|
||||
|
||||
onode->opType = opType;
|
||||
if(isReverse){
|
||||
onode->pLeft = pRight;
|
||||
onode->pRight = pLeft;
|
||||
}else{
|
||||
onode->pLeft = pLeft;
|
||||
onode->pRight = pRight;
|
||||
}
|
||||
|
||||
*pNode = (SNode *)onode;
|
||||
}
|
||||
|
||||
void scltMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight) {
|
||||
SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||
SOperatorNode *onode = (SOperatorNode *)node;
|
||||
|
@ -1039,10 +1058,10 @@ void makeJsonArrow(SSDataBlock **src, SNode **opNode, void *json, char *key){
|
|||
scltMakeOpNode(opNode, OP_TYPE_JSON_GET_VALUE, TSDB_DATA_TYPE_JSON, pLeft, pRight);
|
||||
}
|
||||
|
||||
void makeOperator(SNode **opNode, SArray *blockList, EOperatorType opType, int32_t rightType, void *rightData){
|
||||
void makeOperator(SNode **opNode, SArray *blockList, EOperatorType opType, int32_t rightType, void *rightData, bool isReverse){
|
||||
int32_t resType = TSDB_DATA_TYPE_NULL;
|
||||
if(opType == OP_TYPE_ADD || opType == OP_TYPE_SUB || opType == OP_TYPE_MULTI ||
|
||||
opType == OP_TYPE_DIV || opType == OP_TYPE_MOD || opType == OP_TYPE_MINUS){
|
||||
opType == OP_TYPE_DIV || opType == OP_TYPE_REM || opType == OP_TYPE_MINUS){
|
||||
resType = TSDB_DATA_TYPE_DOUBLE;
|
||||
}else if(opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR){
|
||||
resType = TSDB_DATA_TYPE_BIGINT;
|
||||
|
@ -1057,7 +1076,7 @@ void makeOperator(SNode **opNode, SArray *blockList, EOperatorType opType, int32
|
|||
|
||||
SNode *right = NULL;
|
||||
scltMakeValueNode(&right, rightType, rightData);
|
||||
scltMakeOpNode(opNode, opType, resType, *opNode, right);
|
||||
scltMakeOpNode2(opNode, opType, resType, *opNode, right, isReverse);
|
||||
|
||||
SColumnInfo colInfo = createColumnInfo(1, resType, tDataTypes[resType].bytes);
|
||||
int16_t dataBlockId = 0, slotId = 0;
|
||||
|
@ -1065,7 +1084,7 @@ void makeOperator(SNode **opNode, SArray *blockList, EOperatorType opType, int32
|
|||
scltMakeTargetNode(opNode, dataBlockId, slotId, *opNode);
|
||||
}
|
||||
|
||||
void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, double exceptValue, EOperatorType opType){
|
||||
void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, double exceptValue, EOperatorType opType, bool isReverse){
|
||||
SArray *blockList = taosArrayInit(2, POINTER_BYTES);
|
||||
SSDataBlock *src = NULL;
|
||||
SNode *opNode = NULL;
|
||||
|
@ -1073,7 +1092,7 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do
|
|||
makeJsonArrow(&src, &opNode, json, (char*)key);
|
||||
taosArrayPush(blockList, &src);
|
||||
|
||||
makeOperator(&opNode, blockList, opType, rightType, rightData);
|
||||
makeOperator(&opNode, blockList, opType, rightType, rightData, isReverse);
|
||||
|
||||
int32_t code = scalarCalculate(opNode, blockList, NULL);
|
||||
ASSERT_EQ(code, 0);
|
||||
|
@ -1087,17 +1106,17 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do
|
|||
printf("result:NULL\n");
|
||||
|
||||
}else if(opType == OP_TYPE_ADD || opType == OP_TYPE_SUB || opType == OP_TYPE_MULTI || opType == OP_TYPE_DIV ||
|
||||
opType == OP_TYPE_MOD || opType == OP_TYPE_MINUS){
|
||||
printf("1result:%f,except:%f\n", *((double *)colDataGetData(column, 0)), exceptValue);
|
||||
opType == OP_TYPE_REM || opType == OP_TYPE_MINUS){
|
||||
printf("op:%s,1result:%f,except:%f\n", gOptrStr[opType].str, *((double *)colDataGetData(column, 0)), exceptValue);
|
||||
ASSERT_TRUE(fabs(*((double *)colDataGetData(column, 0)) - exceptValue) < 0.0001);
|
||||
}else if(opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR){
|
||||
printf("2result:%ld,except:%f\n", *((int64_t *)colDataGetData(column, 0)), exceptValue);
|
||||
printf("op:%s,2result:%ld,except:%f\n", gOptrStr[opType].str, *((int64_t *)colDataGetData(column, 0)), exceptValue);
|
||||
ASSERT_EQ(*((int64_t *)colDataGetData(column, 0)), exceptValue);
|
||||
}else if(opType == OP_TYPE_GREATER_THAN || opType == OP_TYPE_GREATER_EQUAL || opType == OP_TYPE_LOWER_THAN ||
|
||||
opType == OP_TYPE_LOWER_EQUAL || opType == OP_TYPE_EQUAL || opType == OP_TYPE_NOT_EQUAL ||
|
||||
opType == OP_TYPE_IS_NULL || opType == OP_TYPE_IS_NOT_NULL || opType == OP_TYPE_IS_TRUE ||
|
||||
opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || opType == OP_TYPE_NMATCH){
|
||||
printf("3result:%d,except:%f\n", *((bool *)colDataGetData(column, 0)), exceptValue);
|
||||
printf("op:%s,3result:%d,except:%f\n", gOptrStr[opType].str, *((bool *)colDataGetData(column, 0)), exceptValue);
|
||||
ASSERT_EQ(*((bool *)colDataGetData(column, 0)), exceptValue);
|
||||
}
|
||||
|
||||
|
@ -1107,7 +1126,7 @@ void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, do
|
|||
|
||||
TEST(columnTest, json_column_arith_op) {
|
||||
scltInitLogFile();
|
||||
char *rightvTmp= "{\"k1\":4,\"k2\":\"hello\",\"k3\":null,\"k4\":true,\"k5\":5.44}";
|
||||
char *rightvTmp= "{\"k1\":4,\"k2\":\"hello\",\"k3\":null,\"k4\":true,\"k5\":5.44,\"k6\":-10,\"k7\":-9.8,\"k8\":false,\"k9\":\"8hel\"}";
|
||||
|
||||
char rightv[256] = {0};
|
||||
memcpy(rightv, rightvTmp, strlen(rightvTmp));
|
||||
|
@ -1117,54 +1136,126 @@ TEST(columnTest, json_column_arith_op) {
|
|||
|
||||
const int32_t len = 8;
|
||||
EOperatorType op[len] = {OP_TYPE_ADD, OP_TYPE_SUB, OP_TYPE_MULTI, OP_TYPE_DIV,
|
||||
OP_TYPE_MOD, OP_TYPE_MINUS, OP_TYPE_BIT_AND, OP_TYPE_BIT_OR};
|
||||
OP_TYPE_REM, OP_TYPE_MINUS, OP_TYPE_BIT_AND, OP_TYPE_BIT_OR};
|
||||
int32_t input[len] = {1, 8, 2, 2, 3, 0, -4, 9};
|
||||
|
||||
printf("--------------------json int---------------------\n");
|
||||
printf("--------------------json int-4 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n");
|
||||
char *key = "k1";
|
||||
double eRes[len] = {5.0, -4, 8.0, 2.0, 1.0, -4, 4&-4, 4|9};
|
||||
double eRes00[len] = {5.0, -4, 8.0, 2.0, 1.0, -4, 4&-4, 4|9};
|
||||
double eRes01[len] = {5.0, 4, 8.0, 0.5, 3, 0, 4&-4, 4|9};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes00[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes01[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("--------------------json string---------------------\n");
|
||||
printf("--------------------json string- 0 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n");
|
||||
|
||||
key = "k2";
|
||||
double eRes1[len] = {1.0, -8, 0, 0, 0, 0, 0, 9};
|
||||
double eRes10[len] = {1.0, -8, 0, 0, 0, 0, 0, 9};
|
||||
double eRes11[len] = {1.0, 8, 0, DBL_MAX, DBL_MAX, 0, 0, 9};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes1[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes10[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes11[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("---------------------json null--------------------\n");
|
||||
printf("---------------------json null- null op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n");
|
||||
|
||||
key = "k3";
|
||||
double eRes2[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX};
|
||||
double eRes20[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX};
|
||||
double eRes21[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, 0, DBL_MAX, DBL_MAX};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes2[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes20[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes21[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("---------------------json bool--------------------\n");
|
||||
printf("---------------------json bool- true op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n");
|
||||
|
||||
key = "k4";
|
||||
double eRes3[len] = {2.0, -7, 2, 0.5, 1, -1, 1&-4, 1|9};
|
||||
double eRes30[len] = {2.0, -7, 2, 0.5, 1, -1, 1&-4, 1|9};
|
||||
double eRes31[len] = {2.0, 7, 2, 2, 0, 0, 1&-4, 1|9};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes3[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes30[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes31[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("----------------------json double-------------------\n");
|
||||
printf("----------------------json double-- 5.44 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
|
||||
|
||||
key = "k5";
|
||||
double eRes4[len] = {6.44, -2.56, 10.88, 2.72, 2.44, -5.44, 5&-4, 5|9};
|
||||
double eRes40[len] = {6.44, -2.56, 10.88, 2.72, 2.44, -5.44, 5&-4, 5|9};
|
||||
double eRes41[len] = {6.44, 2.56, 10.88, 0.3676470588235294, 3, 0, 5&-4, 5|9};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes4[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes40[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes41[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("---------------------json not exist--------------------\n");
|
||||
printf("----------------------json int-- -10 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
|
||||
|
||||
key = "k6";
|
||||
double eRes50[len] = {-9, -18, -20, -5, -10%3, 10, -10&-4, -10|9};
|
||||
double eRes51[len] = {-9, 18, -20, -0.2, 3%-10, 0, -10&-4, -10|9};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes50[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes51[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("----------------------json double-- -9.8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
|
||||
|
||||
key = "k7";
|
||||
double eRes60[len] = {-8.8, -17.8, -19.6, -4.9, -0.8, 9.8, -9&-4, -9|9};
|
||||
double eRes61[len] = {-8.8, 17.8, -19.6, -0.2040816326530612, 3, 0, -9&-4, -9|9};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes60[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes61[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("----------------------json bool-- 0 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
|
||||
|
||||
key = "k8";
|
||||
double eRes70[len] = {1.0, -8, 0, 0, 0, 0, 0, 9};
|
||||
double eRes71[len] = {1.0, 8, 0, DBL_MAX, DBL_MAX, 0, 0, 9};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes70[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes71[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("----------------------json string-- 8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
|
||||
|
||||
key = "k9";
|
||||
double eRes80[len] = {9, 0, 16, 4, 8%3, -8, 8&-4, 8|9};
|
||||
double eRes81[len] = {9, 0, 16, 0.25, 3%8, 0, 8&-4, 8|9};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes80[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes81[i], op[i], true);
|
||||
}
|
||||
|
||||
printf("---------------------json not exist-- NULL op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
|
||||
|
||||
key = "k10";
|
||||
double eRes5[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX};
|
||||
double eRes90[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX};
|
||||
double eRes91[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, 0, DBL_MAX, DBL_MAX};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes5[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes90[i], op[i], false);
|
||||
}
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes91[i], op[i], true);
|
||||
}
|
||||
|
||||
taosArrayDestroy(tags);
|
||||
|
@ -1183,7 +1274,7 @@ void *prepareNchar(char* rightData){
|
|||
|
||||
TEST(columnTest, json_column_logic_op) {
|
||||
scltInitLogFile();
|
||||
char *rightvTmp= "{\"k1\":4,\"k2\":\"hello\",\"k3\":null,\"k4\":true,\"k5\":5.44,\"k6\":\"6.6hello\"}";
|
||||
char *rightvTmp= "{\"k1\":4,\"k2\":\"hello\",\"k3\":null,\"k4\":true,\"k5\":5.44,\"k6\":-10,\"k7\":-9.8,\"k8\":false,\"k9\":\"6.6hello\"}";
|
||||
|
||||
char rightv[256] = {0};
|
||||
memcpy(rightv, rightvTmp, strlen(rightvTmp));
|
||||
|
@ -1191,6 +1282,7 @@ TEST(columnTest, json_column_logic_op) {
|
|||
STag* row = NULL;
|
||||
parseJsontoTagData(rightv, tags, &row, NULL);
|
||||
|
||||
const int32_t len0 = 6;
|
||||
const int32_t len = 9;
|
||||
const int32_t len1 = 4;
|
||||
EOperatorType op[len+len1] = {OP_TYPE_GREATER_THAN, OP_TYPE_GREATER_EQUAL, OP_TYPE_LOWER_THAN, OP_TYPE_LOWER_EQUAL, OP_TYPE_EQUAL, OP_TYPE_NOT_EQUAL,
|
||||
|
@ -1199,93 +1291,183 @@ TEST(columnTest, json_column_logic_op) {
|
|||
int32_t input[len] = {1, 8, 2, 2, 3, 0, 0, 0, 0};
|
||||
char *inputNchar[len1] = {"hell_", "hel%", "hell", "llll"};
|
||||
|
||||
printf("--------------------json int---------------------\n");
|
||||
printf("--------------------json int---4 {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
|
||||
char *key = "k1";
|
||||
bool eRes[len+len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes[i], op[i], false);
|
||||
}
|
||||
bool eRes_0[len0] = {false, true, true, true, false, true};
|
||||
for(int i = 0; i < len0; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_0[i], op[i], true);
|
||||
}
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
printf("--------------------json string---------------------\n");
|
||||
printf("--------------------json string--0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
|
||||
|
||||
key = "k2";
|
||||
bool eRes1[len+len1] = {false, false, true, true, false, false, false, true, false, true, false, true, true};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes1[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes1[i], op[i], false);
|
||||
}
|
||||
bool eRes_1[len0] = {true, true, false, false, false, false};
|
||||
for(int i = 0; i < len0; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_1[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes1[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes1[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
printf("--------------------json null---------------------\n");
|
||||
printf("--------------------json null---null {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
|
||||
|
||||
key = "k3"; // (null is true) return NULL, so use DBL_MAX represent NULL
|
||||
double eRes2[len+len1] = {false, false, false, false, false, false, true, false, DBL_MAX, false, false, false, false};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes2[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes2[i], op[i], false);
|
||||
}
|
||||
bool eRes_2[len0] = {false, false, false, false, false, false};
|
||||
for(int i = 0; i < len0; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_2[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes2[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes2[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
printf("--------------------json bool---------------------\n");
|
||||
printf("--------------------json bool--1 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
|
||||
|
||||
key = "k4";
|
||||
bool eRes3[len+len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes3[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes3[i], op[i], false);
|
||||
}
|
||||
bool eRes_3[len0] = {false, true, false, false, false, true};
|
||||
for(int i = 0; i < len0; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_3[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes3[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes3[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
printf("--------------------json double---------------------\n");
|
||||
printf("--------------------json double--5.44 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
|
||||
|
||||
key = "k5";
|
||||
bool eRes4[len+len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes4[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes4[i], op[i], false);
|
||||
}
|
||||
bool eRes_4[len0] = {false, true, true, true, false, true};
|
||||
for(int i = 0; i < len0; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_4[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes4[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes4[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
printf("--------------------json double---------------------\n");
|
||||
printf("--------------------json int-- -10 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
|
||||
|
||||
key = "k6";
|
||||
bool eRes5[len+len1] = {true, false, false, false, false, true, false, true, true, false, true, false, true};
|
||||
bool eRes5[len+len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes5[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes5[i], op[i], false);
|
||||
}
|
||||
bool eRes_5[len0] = {true, true, false, false, false, true};
|
||||
for(int i = 0; i < len0; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_5[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes5[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes5[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
printf("---------------------json not exist--------------------\n");
|
||||
printf("--------------------json double-- -9.8 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
|
||||
|
||||
key = "k10"; // (NULL is true) return NULL, so use DBL_MAX represent NULL
|
||||
double eRes10[len+len1] = {false, false, false, false, false, false, true, false, DBL_MAX, false, false, false, false};
|
||||
key = "k7";
|
||||
bool eRes6[len+len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes10[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes6[i], op[i], false);
|
||||
}
|
||||
bool eRes_6[len0] = {true, true, false, false, false, true};
|
||||
for(int i = 0; i < len0; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_6[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes10[i], op[i]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes6[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
|
||||
printf("--------------------json bool-- 0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
|
||||
|
||||
key = "k8";
|
||||
bool eRes7[len+len1] = {false, false, true, true, false, false, false, true, false, false, false, false, false};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes7[i], op[i], false);
|
||||
}
|
||||
bool eRes_7[len0] = {true, true, false, false, false, false};
|
||||
for(int i = 0; i < len0; i++) {
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_7[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes7[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
|
||||
printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
|
||||
|
||||
key = "k9";
|
||||
bool eRes8[len+len1] = {true, false, false, false, false, true, false, true, true, false, true, false, true};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes8[i], op[i], false);
|
||||
}
|
||||
bool eRes_8[len0] = {false, true, true, true, false, true};
|
||||
for(int i = 0; i < len0; i++) {
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_8[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes8[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
printf("---------------------json not exist-- NULL {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
|
||||
|
||||
key = "k10"; // (NULL is true) return NULL, so use DBL_MAX represent NULL
|
||||
double eRes9[len+len1] = {false, false, false, false, false, false, true, false, DBL_MAX, false, false, false, false};
|
||||
for(int i = 0; i < len; i++){
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes9[i], op[i], false);
|
||||
}
|
||||
bool eRes_9[len0] = {false, false, false, false, false, false};
|
||||
for(int i = 0; i < len0; i++) {
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_9[i], op[i], true);
|
||||
}
|
||||
|
||||
for(int i = len; i < len + len1; i++){
|
||||
void* rightData = prepareNchar(inputNchar[i-len]);
|
||||
makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes9[i], op[i], false);
|
||||
taosMemoryFree(rightData);
|
||||
}
|
||||
|
||||
|
|
|
@ -137,9 +137,9 @@ class TDTestCase:
|
|||
tdSql.checkRows(9)
|
||||
tdSql.query("select jtag from jsons1")
|
||||
tdSql.checkRows(13)
|
||||
# tdSql.query("select jtag from jsons1 where jtag is null")
|
||||
tdSql.query("select jtag from jsons1 where jtag is null")
|
||||
# tdSql.checkRows(5)
|
||||
# tdSql.query("select jtag from jsons1 where jtag is not null")
|
||||
tdSql.query("select jtag from jsons1 where jtag is not null")
|
||||
# tdSql.checkRows(8)
|
||||
|
||||
# test jtag is NULL
|
||||
|
@ -260,9 +260,9 @@ class TDTestCase:
|
|||
# tdSql.checkRows(1)
|
||||
#
|
||||
# # where json is null
|
||||
# tdSql.query("select * from jsons1 where jtag is null")
|
||||
tdSql.query("select * from jsons1 where jtag is null")
|
||||
# tdSql.checkRows(1)
|
||||
# tdSql.query("select * from jsons1 where jtag is not null")
|
||||
tdSql.query("select * from jsons1 where jtag is not null")
|
||||
# tdSql.checkRows(8)
|
||||
#
|
||||
# # where json key is null
|
||||
|
@ -389,8 +389,8 @@ class TDTestCase:
|
|||
tdSql.checkData(2, 1, "11.000000000")
|
||||
tdSql.checkData(5, 0, 1)
|
||||
tdSql.checkData(5, 1, "false")
|
||||
# tdSql.checkData(6, 0, 1)
|
||||
# tdSql.checkData(6, 1, "null")
|
||||
tdSql.checkData(6, 0, 1)
|
||||
tdSql.checkData(6, 1, "null")
|
||||
tdSql.checkData(7, 0, 2)
|
||||
tdSql.checkData(7, 1, None)
|
||||
|
||||
|
@ -409,7 +409,7 @@ class TDTestCase:
|
|||
tdSql.query("select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'")
|
||||
tdSql.checkRows(8)
|
||||
tdSql.checkData(0, 0, 10)
|
||||
# tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(4, 0, 0)
|
||||
tdSql.checkData(4, 1, "5.000000000")
|
||||
tdSql.checkData(7, 0, 11)
|
||||
|
@ -424,10 +424,10 @@ class TDTestCase:
|
|||
# test top/bottom with group by json tag
|
||||
tdSql.query("select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'")
|
||||
tdSql.checkRows(11)
|
||||
tdSql.checkData(0, 1, None)
|
||||
tdSql.checkData(2, 0, 4)
|
||||
tdSql.checkData(3, 0, 3)
|
||||
tdSql.checkData(3, 1, "false")
|
||||
# tdSql.checkData(3, 0, 24)
|
||||
# tdSql.checkData(3, 1, None)
|
||||
tdSql.checkData(10, 0, 23)
|
||||
tdSql.checkData(10, 1, '"femail"')
|
||||
|
||||
|
@ -436,7 +436,7 @@ class TDTestCase:
|
|||
# tdSql.checkRows(2)
|
||||
|
||||
# subquery with json tag
|
||||
tdSql.query("select * from (select jtag, dataint from jsons1)")
|
||||
tdSql.query("select * from (select jtag, dataint from jsons1) order by dataint")
|
||||
tdSql.checkRows(11)
|
||||
tdSql.checkData(1, 1, 1)
|
||||
tdSql.checkData(2, 0, '{"tag1":5,"tag2":"beijing"}')
|
||||
|
|
Loading…
Reference in New Issue