executorTests.cpp 59.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtest/gtest.h>
#include <iostream>

S
Shengliang Guan 已提交
19 20
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
21 22 23 24 25
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "os.h"

26
#include "executor.h"
27 28
#include "executorimpl.h"
#include "function.h"
29
#include "stub.h"
30
#include "taos.h"
H
Haojun Liao 已提交
31
#include "tdatablock.h"
32 33
#include "tdef.h"
#include "tglobal.h"
D
dapan1121 已提交
34 35
#include "tmsg.h"
#include "tname.h"
36 37
#include "trpc.h"
#include "tvariant.h"
38

H
Haojun Liao 已提交
39 40
namespace {

H
Haojun Liao 已提交
41 42
enum {
  data_rand = 0x1,
43
  data_asc = 0x2,
H
Haojun Liao 已提交
44 45 46
  data_desc = 0x3,
};

H
Haojun Liao 已提交
47
typedef struct SDummyInputInfo {
48
  int32_t      totalPages;  // numOfPages
49 50 51 52
  int32_t      current;
  int32_t      startVal;
  int32_t      type;
  int32_t      numOfRowsPerPage;
53
  int32_t      numOfCols;  // number of columns
H
Haojun Liao 已提交
54
  int64_t      tsStart;
H
Haojun Liao 已提交
55 56 57
  SSDataBlock* pBlock;
} SDummyInputInfo;

58
SSDataBlock* getDummyBlock(SOperatorInfo* pOperator) {
H
Haojun Liao 已提交
59
  SDummyInputInfo* pInfo = static_cast<SDummyInputInfo*>(pOperator->info);
60
  if (pInfo->current >= pInfo->totalPages) {
H
Haojun Liao 已提交
61 62 63 64
    return NULL;
  }

  if (pInfo->pBlock == NULL) {
wafwerar's avatar
wafwerar 已提交
65
    pInfo->pBlock = static_cast<SSDataBlock*>(taosMemoryCalloc(1, sizeof(SSDataBlock)));
H
Haojun Liao 已提交
66 67 68 69 70 71 72

    pInfo->pBlock->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));

    SColumnInfoData colInfo = {0};
    colInfo.info.type = TSDB_DATA_TYPE_INT;
    colInfo.info.bytes = sizeof(int32_t);
    colInfo.info.colId = 1;
wafwerar's avatar
wafwerar 已提交
73 74
    colInfo.pData = static_cast<char*>(taosMemoryCalloc(pInfo->numOfRowsPerPage, sizeof(int32_t)));
    colInfo.nullbitmap = static_cast<char*>(taosMemoryCalloc(1, (pInfo->numOfRowsPerPage + 7) / 8));
H
Haojun Liao 已提交
75 76 77

    taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo);

78 79 80 81 82 83 84 85 86 87
    //    SColumnInfoData colInfo1 = {0};
    //    colInfo1.info.type = TSDB_DATA_TYPE_BINARY;
    //    colInfo1.info.bytes = 40;
    //    colInfo1.info.colId = 2;
    //
    //    colInfo1.varmeta.allocLen = 0;//numOfRows * sizeof(int32_t);
    //    colInfo1.varmeta.length = 0;
    //    colInfo1.varmeta.offset = static_cast<int32_t*>(taosMemoryCalloc(1, numOfRows * sizeof(int32_t)));
    //
    //    taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1);
H
Haojun Liao 已提交
88
  } else {
H
Haojun Liao 已提交
89
    blockDataCleanup(pInfo->pBlock);
H
Haojun Liao 已提交
90 91 92 93
  }

  SSDataBlock* pBlock = pInfo->pBlock;

94 95
  char    buf[128] = {0};
  char    b1[128] = {0};
H
Haojun Liao 已提交
96
  int32_t v = 0;
97
  for (int32_t i = 0; i < pInfo->numOfRowsPerPage; ++i) {
H
Haojun Liao 已提交
98 99
    SColumnInfoData* pColInfo = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 0));

H
Haojun Liao 已提交
100 101 102 103 104
    if (pInfo->type == data_desc) {
      v = (--pInfo->startVal);
    } else if (pInfo->type == data_asc) {
      v = ++pInfo->startVal;
    } else if (pInfo->type == data_rand) {
wafwerar's avatar
wafwerar 已提交
105
      v = taosRand();
H
Haojun Liao 已提交
106 107
    }

H
Haojun Liao 已提交
108 109
    colDataAppend(pColInfo, i, reinterpret_cast<const char*>(&v), false);

110 111 112 113 114
    //    sprintf(buf, "this is %d row", i);
    //    STR_TO_VARSTR(b1, buf);
    //
    //    SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
    //    colDataAppend(pColInfo2, i, b1, false);
H
Haojun Liao 已提交
115 116
  }

117
  pBlock->info.rows = pInfo->numOfRowsPerPage;
H
Haojun Liao 已提交
118 119 120 121
  pBlock->info.numOfCols = 1;

  pInfo->current += 1;
  return pBlock;
122 123
}

124
SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator) {
H
Haojun Liao 已提交
125 126 127 128 129 130
  SDummyInputInfo* pInfo = static_cast<SDummyInputInfo*>(pOperator->info);
  if (pInfo->current >= pInfo->totalPages) {
    return NULL;
  }

  if (pInfo->pBlock == NULL) {
wafwerar's avatar
wafwerar 已提交
131
    pInfo->pBlock = static_cast<SSDataBlock*>(taosMemoryCalloc(1, sizeof(SSDataBlock)));
H
Haojun Liao 已提交
132 133 134 135 136 137 138

    pInfo->pBlock->pDataBlock = taosArrayInit(4, sizeof(SColumnInfoData));

    SColumnInfoData colInfo = {0};
    colInfo.info.type = TSDB_DATA_TYPE_TIMESTAMP;
    colInfo.info.bytes = sizeof(int64_t);
    colInfo.info.colId = 1;
wafwerar's avatar
wafwerar 已提交
139
    colInfo.pData = static_cast<char*>(taosMemoryCalloc(pInfo->numOfRowsPerPage, sizeof(int64_t)));
140
    //    colInfo.nullbitmap = static_cast<char*>(taosMemoryCalloc(1, (pInfo->numOfRowsPerPage + 7) / 8));
H
Haojun Liao 已提交
141 142 143 144 145 146 147 148

    taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo);

    SColumnInfoData colInfo1 = {0};
    colInfo1.info.type = TSDB_DATA_TYPE_INT;
    colInfo1.info.bytes = 4;
    colInfo1.info.colId = 2;

wafwerar's avatar
wafwerar 已提交
149 150
    colInfo1.pData = static_cast<char*>(taosMemoryCalloc(pInfo->numOfRowsPerPage, sizeof(int32_t)));
    colInfo1.nullbitmap = static_cast<char*>(taosMemoryCalloc(1, (pInfo->numOfRowsPerPage + 7) / 8));
H
Haojun Liao 已提交
151 152 153

    taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1);
  } else {
H
Haojun Liao 已提交
154
    blockDataCleanup(pInfo->pBlock);
H
Haojun Liao 已提交
155 156 157 158
  }

  SSDataBlock* pBlock = pInfo->pBlock;

159 160
  char    buf[128] = {0};
  char    b1[128] = {0};
H
Haojun Liao 已提交
161
  int64_t ts = 0;
162 163
  int32_t v = 0;
  for (int32_t i = 0; i < pInfo->numOfRowsPerPage; ++i) {
H
Haojun Liao 已提交
164 165 166 167 168 169 170 171 172 173 174
    SColumnInfoData* pColInfo = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 0));

    ts = (++pInfo->tsStart);
    colDataAppend(pColInfo, i, reinterpret_cast<const char*>(&ts), false);

    SColumnInfoData* pColInfo1 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
    if (pInfo->type == data_desc) {
      v = (--pInfo->startVal);
    } else if (pInfo->type == data_asc) {
      v = ++pInfo->startVal;
    } else if (pInfo->type == data_rand) {
wafwerar's avatar
wafwerar 已提交
175
      v = taosRand();
H
Haojun Liao 已提交
176 177 178 179
    }

    colDataAppend(pColInfo1, i, reinterpret_cast<const char*>(&v), false);

180 181 182 183 184
    //    sprintf(buf, "this is %d row", i);
    //    STR_TO_VARSTR(b1, buf);
    //
    //    SColumnInfoData* pColInfo2 = static_cast<SColumnInfoData*>(TARRAY_GET_ELEM(pBlock->pDataBlock, 1));
    //    colDataAppend(pColInfo2, i, b1, false);
H
Haojun Liao 已提交
185 186 187 188 189 190 191
  }

  pBlock->info.rows = pInfo->numOfRowsPerPage;
  pBlock->info.numOfCols = 1;

  pInfo->current += 1;

192
  blockDataUpdateTsWindow(pBlock, 0);
H
Haojun Liao 已提交
193 194 195
  return pBlock;
}

196 197
SOperatorInfo* createDummyOperator(int32_t startVal, int32_t numOfBlocks, int32_t rowsPerPage, int32_t type,
                                   int32_t numOfCols) {
wafwerar's avatar
wafwerar 已提交
198
  SOperatorInfo* pOperator = static_cast<SOperatorInfo*>(taosMemoryCalloc(1, sizeof(SOperatorInfo)));
H
Haojun Liao 已提交
199
  pOperator->name = "dummyInputOpertor4Test";
H
Haojun Liao 已提交
200 201

  if (numOfCols == 1) {
202
    pOperator->fpSet.getNextFn = getDummyBlock;
H
Haojun Liao 已提交
203
  } else {
204
    pOperator->fpSet.getNextFn = get2ColsDummyBlock;
H
Haojun Liao 已提交
205
  }
H
Haojun Liao 已提交
206

207
  SDummyInputInfo* pInfo = (SDummyInputInfo*)taosMemoryCalloc(1, sizeof(SDummyInputInfo));
208
  pInfo->totalPages = numOfBlocks;
209
  pInfo->startVal = startVal;
210
  pInfo->numOfRowsPerPage = rowsPerPage;
211 212
  pInfo->type = type;
  pInfo->tsStart = 1620000000000;
H
Haojun Liao 已提交
213 214 215 216

  pOperator->info = pInfo;
  return pOperator;
}
217
}  // namespace
218 219 220 221 222 223
int main(int argc, char** argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

TEST(testCase, build_executor_tree_Test) {
224 225
  const char* msg =
      "{\n"
H
Haojun Liao 已提交
226
      "    \"NodeType\": \"48\",\n"
H
Haojun Liao 已提交
227 228 229 230 231 232 233 234
      "    \"Name\": \"PhysiSubplan\",\n"
      "    \"PhysiSubplan\": {\n"
      "        \"Id\": {\n"
      "            \"QueryId\": \"0\",\n"
      "            \"TemplateId\": \"0\",\n"
      "            \"SubplanId\": \"0\"\n"
      "        },\n"
      "        \"SubplanType\": \"0\",\n"
H
Haojun Liao 已提交
235
      "        \"MsgType\": \"515\",\n"
H
Haojun Liao 已提交
236 237
      "        \"Level\": \"0\",\n"
      "        \"NodeAddr\": {\n"
H
Haojun Liao 已提交
238
      "            \"Id\": \"1\",\n"
H
Haojun Liao 已提交
239
      "            \"InUse\": \"0\",\n"
H
Haojun Liao 已提交
240 241 242 243 244 245 246
      "            \"NumOfEps\": \"1\",\n"
      "            \"Eps\": [\n"
      "                {\n"
      "                    \"Fqdn\": \"node1\",\n"
      "                    \"Port\": \"6030\"\n"
      "                }\n"
      "            ]\n"
H
Haojun Liao 已提交
247 248
      "        },\n"
      "        \"RootNode\": {\n"
H
Haojun Liao 已提交
249
      "            \"NodeType\": \"41\",\n"
H
Haojun Liao 已提交
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
      "            \"Name\": \"PhysiProject\",\n"
      "            \"PhysiProject\": {\n"
      "                \"OutputDataBlockDesc\": {\n"
      "                    \"NodeType\": \"19\",\n"
      "                    \"Name\": \"TupleDesc\",\n"
      "                    \"TupleDesc\": {\n"
      "                        \"DataBlockId\": \"1\",\n"
      "                        \"Slots\": [\n"
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"0\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"9\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
272
      "                            },\n"
H
Haojun Liao 已提交
273 274 275 276 277 278 279 280 281 282 283 284 285 286
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"1\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"4\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"4\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
287
      "                            },\n"
H
Haojun Liao 已提交
288 289 290 291 292 293 294 295 296 297 298 299 300 301
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"2\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"8\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"20\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
302
      "                            },\n"
H
Haojun Liao 已提交
303 304 305 306 307 308 309 310 311 312 313 314 315 316
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"3\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"5\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
317
      "                            },\n"
H
Haojun Liao 已提交
318 319 320 321 322 323 324 325 326 327 328 329 330 331
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"4\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"7\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
332
      "                            },\n"
H
Haojun Liao 已提交
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"5\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"7\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
      "                            }\n"
      "                        ]\n"
      "                    }\n"
      "                },\n"
      "                \"Children\": [\n"
H
Haojun Liao 已提交
352
      "                    {\n"
H
Haojun Liao 已提交
353
      "                        \"NodeType\": \"38\",\n"
H
Haojun Liao 已提交
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
      "                        \"Name\": \"PhysiTableScan\",\n"
      "                        \"PhysiTableScan\": {\n"
      "                            \"OutputDataBlockDesc\": {\n"
      "                                \"NodeType\": \"19\",\n"
      "                                \"Name\": \"TupleDesc\",\n"
      "                                \"TupleDesc\": {\n"
      "                                    \"DataBlockId\": \"0\",\n"
      "                                    \"Slots\": [\n"
      "                                        {\n"
      "                                            \"NodeType\": \"20\",\n"
      "                                            \"Name\": \"SlotDesc\",\n"
      "                                            \"SlotDesc\": {\n"
      "                                                \"SlotId\": \"0\",\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"9\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"8\"\n"
      "                                                },\n"
      "                                                \"Reserve\": false,\n"
      "                                                \"Output\": true\n"
      "                                            }\n"
      "                                        },\n"
      "                                        {\n"
      "                                            \"NodeType\": \"20\",\n"
      "                                            \"Name\": \"SlotDesc\",\n"
      "                                            \"SlotDesc\": {\n"
      "                                                \"SlotId\": \"1\",\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"4\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"4\"\n"
      "                                                },\n"
      "                                                \"Reserve\": false,\n"
      "                                                \"Output\": true\n"
      "                                            }\n"
      "                                        },\n"
      "                                        {\n"
      "                                            \"NodeType\": \"20\",\n"
      "                                            \"Name\": \"SlotDesc\",\n"
      "                                            \"SlotDesc\": {\n"
      "                                                \"SlotId\": \"2\",\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"8\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"20\"\n"
      "                                                },\n"
      "                                                \"Reserve\": false,\n"
      "                                                \"Output\": true\n"
      "                                            }\n"
      "                                        },\n"
      "                                        {\n"
      "                                            \"NodeType\": \"20\",\n"
      "                                            \"Name\": \"SlotDesc\",\n"
      "                                            \"SlotDesc\": {\n"
      "                                                \"SlotId\": \"3\",\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"5\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"8\"\n"
      "                                                },\n"
      "                                                \"Reserve\": false,\n"
      "                                                \"Output\": true\n"
      "                                            }\n"
      "                                        },\n"
      "                                        {\n"
      "                                            \"NodeType\": \"20\",\n"
      "                                            \"Name\": \"SlotDesc\",\n"
      "                                            \"SlotDesc\": {\n"
      "                                                \"SlotId\": \"4\",\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"7\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"8\"\n"
      "                                                },\n"
      "                                                \"Reserve\": false,\n"
      "                                                \"Output\": true\n"
      "                                            }\n"
      "                                        },\n"
      "                                        {\n"
      "                                            \"NodeType\": \"20\",\n"
      "                                            \"Name\": \"SlotDesc\",\n"
      "                                            \"SlotDesc\": {\n"
      "                                                \"SlotId\": \"5\",\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"7\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"8\"\n"
      "                                                },\n"
      "                                                \"Reserve\": false,\n"
      "                                                \"Output\": true\n"
      "                                            }\n"
      "                                        }\n"
      "                                    ]\n"
      "                                }\n"
H
Haojun Liao 已提交
454
      "                            },\n"
H
Haojun Liao 已提交
455
      "                            \"ScanCols\": [\n"
H
Haojun Liao 已提交
456
      "                                {\n"
H
Haojun Liao 已提交
457 458 459 460
      "                                    \"NodeType\": \"18\",\n"
      "                                    \"Name\": \"Target\",\n"
      "                                    \"Target\": {\n"
      "                                        \"DataBlockId\": \"0\",\n"
H
Haojun Liao 已提交
461
      "                                        \"SlotId\": \"0\",\n"
H
Haojun Liao 已提交
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
      "                                        \"Expr\": {\n"
      "                                            \"NodeType\": \"1\",\n"
      "                                            \"Name\": \"Column\",\n"
      "                                            \"Column\": {\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"9\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"8\"\n"
      "                                                },\n"
      "                                                \"AliasName\": \"ts\",\n"
      "                                                \"TableId\": \"0\",\n"
      "                                                \"ColId\": \"1\",\n"
      "                                                \"ColType\": \"1\",\n"
      "                                                \"DbName\": \"test\",\n"
      "                                                \"TableName\": \"t1\",\n"
      "                                                \"TableAlias\": \"t1\",\n"
      "                                                \"ColName\": \"ts\",\n"
      "                                                \"DataBlockId\": \"0\",\n"
      "                                                \"SlotId\": \"0\"\n"
      "                                            }\n"
      "                                        }\n"
H
Haojun Liao 已提交
484 485 486
      "                                    }\n"
      "                                },\n"
      "                                {\n"
H
Haojun Liao 已提交
487 488 489 490
      "                                    \"NodeType\": \"18\",\n"
      "                                    \"Name\": \"Target\",\n"
      "                                    \"Target\": {\n"
      "                                        \"DataBlockId\": \"0\",\n"
H
Haojun Liao 已提交
491
      "                                        \"SlotId\": \"1\",\n"
H
Haojun Liao 已提交
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
      "                                        \"Expr\": {\n"
      "                                            \"NodeType\": \"1\",\n"
      "                                            \"Name\": \"Column\",\n"
      "                                            \"Column\": {\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"4\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"4\"\n"
      "                                                },\n"
      "                                                \"AliasName\": \"c1\",\n"
      "                                                \"TableId\": \"0\",\n"
      "                                                \"ColId\": \"2\",\n"
      "                                                \"ColType\": \"1\",\n"
      "                                                \"DbName\": \"test\",\n"
      "                                                \"TableName\": \"t1\",\n"
      "                                                \"TableAlias\": \"t1\",\n"
      "                                                \"ColName\": \"c1\",\n"
      "                                                \"DataBlockId\": \"0\",\n"
      "                                                \"SlotId\": \"0\"\n"
      "                                            }\n"
      "                                        }\n"
H
Haojun Liao 已提交
514 515 516
      "                                    }\n"
      "                                },\n"
      "                                {\n"
H
Haojun Liao 已提交
517 518 519 520
      "                                    \"NodeType\": \"18\",\n"
      "                                    \"Name\": \"Target\",\n"
      "                                    \"Target\": {\n"
      "                                        \"DataBlockId\": \"0\",\n"
H
Haojun Liao 已提交
521
      "                                        \"SlotId\": \"2\",\n"
H
Haojun Liao 已提交
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543
      "                                        \"Expr\": {\n"
      "                                            \"NodeType\": \"1\",\n"
      "                                            \"Name\": \"Column\",\n"
      "                                            \"Column\": {\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"8\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"20\"\n"
      "                                                },\n"
      "                                                \"AliasName\": \"c2\",\n"
      "                                                \"TableId\": \"0\",\n"
      "                                                \"ColId\": \"3\",\n"
      "                                                \"ColType\": \"1\",\n"
      "                                                \"DbName\": \"test\",\n"
      "                                                \"TableName\": \"t1\",\n"
      "                                                \"TableAlias\": \"t1\",\n"
      "                                                \"ColName\": \"c2\",\n"
      "                                                \"DataBlockId\": \"0\",\n"
      "                                                \"SlotId\": \"0\"\n"
      "                                            }\n"
      "                                        }\n"
H
Haojun Liao 已提交
544 545 546
      "                                    }\n"
      "                                },\n"
      "                                {\n"
H
Haojun Liao 已提交
547 548 549 550
      "                                    \"NodeType\": \"18\",\n"
      "                                    \"Name\": \"Target\",\n"
      "                                    \"Target\": {\n"
      "                                        \"DataBlockId\": \"0\",\n"
H
Haojun Liao 已提交
551
      "                                        \"SlotId\": \"3\",\n"
H
Haojun Liao 已提交
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
      "                                        \"Expr\": {\n"
      "                                            \"NodeType\": \"1\",\n"
      "                                            \"Name\": \"Column\",\n"
      "                                            \"Column\": {\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"5\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"8\"\n"
      "                                                },\n"
      "                                                \"AliasName\": \"c3\",\n"
      "                                                \"TableId\": \"0\",\n"
      "                                                \"ColId\": \"4\",\n"
      "                                                \"ColType\": \"1\",\n"
      "                                                \"DbName\": \"test\",\n"
      "                                                \"TableName\": \"t1\",\n"
      "                                                \"TableAlias\": \"t1\",\n"
      "                                                \"ColName\": \"c3\",\n"
      "                                                \"DataBlockId\": \"0\",\n"
      "                                                \"SlotId\": \"0\"\n"
      "                                            }\n"
      "                                        }\n"
H
Haojun Liao 已提交
574 575 576
      "                                    }\n"
      "                                },\n"
      "                                {\n"
H
Haojun Liao 已提交
577 578 579 580
      "                                    \"NodeType\": \"18\",\n"
      "                                    \"Name\": \"Target\",\n"
      "                                    \"Target\": {\n"
      "                                        \"DataBlockId\": \"0\",\n"
H
Haojun Liao 已提交
581
      "                                        \"SlotId\": \"4\",\n"
H
Haojun Liao 已提交
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
      "                                        \"Expr\": {\n"
      "                                            \"NodeType\": \"1\",\n"
      "                                            \"Name\": \"Column\",\n"
      "                                            \"Column\": {\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"7\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"8\"\n"
      "                                                },\n"
      "                                                \"AliasName\": \"c4\",\n"
      "                                                \"TableId\": \"0\",\n"
      "                                                \"ColId\": \"5\",\n"
      "                                                \"ColType\": \"1\",\n"
      "                                                \"DbName\": \"test\",\n"
      "                                                \"TableName\": \"t1\",\n"
      "                                                \"TableAlias\": \"t1\",\n"
      "                                                \"ColName\": \"c4\",\n"
      "                                                \"DataBlockId\": \"0\",\n"
      "                                                \"SlotId\": \"0\"\n"
      "                                            }\n"
      "                                        }\n"
H
Haojun Liao 已提交
604 605 606
      "                                    }\n"
      "                                },\n"
      "                                {\n"
H
Haojun Liao 已提交
607 608 609 610
      "                                    \"NodeType\": \"18\",\n"
      "                                    \"Name\": \"Target\",\n"
      "                                    \"Target\": {\n"
      "                                        \"DataBlockId\": \"0\",\n"
H
Haojun Liao 已提交
611
      "                                        \"SlotId\": \"5\",\n"
H
Haojun Liao 已提交
612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
      "                                        \"Expr\": {\n"
      "                                            \"NodeType\": \"1\",\n"
      "                                            \"Name\": \"Column\",\n"
      "                                            \"Column\": {\n"
      "                                                \"DataType\": {\n"
      "                                                    \"Type\": \"7\",\n"
      "                                                    \"Precision\": \"0\",\n"
      "                                                    \"Scale\": \"0\",\n"
      "                                                    \"Bytes\": \"8\"\n"
      "                                                },\n"
      "                                                \"AliasName\": \"c5\",\n"
      "                                                \"TableId\": \"0\",\n"
      "                                                \"ColId\": \"6\",\n"
      "                                                \"ColType\": \"1\",\n"
      "                                                \"DbName\": \"test\",\n"
      "                                                \"TableName\": \"t1\",\n"
      "                                                \"TableAlias\": \"t1\",\n"
      "                                                \"ColName\": \"c5\",\n"
      "                                                \"DataBlockId\": \"0\",\n"
      "                                                \"SlotId\": \"0\"\n"
      "                                            }\n"
      "                                        }\n"
H
Haojun Liao 已提交
634 635
      "                                    }\n"
      "                                }\n"
H
Haojun Liao 已提交
636 637 638 639 640 641 642 643 644
      "                            ],\n"
      "                            \"TableId\": \"1\",\n"
      "                            \"TableType\": \"3\",\n"
      "                            \"ScanOrder\": \"1\",\n"
      "                            \"ScanCount\": \"1\",\n"
      "                            \"ReverseScanCount\": \"0\",\n"
      "                            \"ScanFlag\": \"0\",\n"
      "                            \"StartKey\": \"-9223372036854775808\",\n"
      "                            \"EndKey\": \"9223372036854775807\"\n"
H
Haojun Liao 已提交
645
      "                        }\n"
H
Haojun Liao 已提交
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674
      "                    }\n"
      "                ],\n"
      "                \"Projections\": [\n"
      "                    {\n"
      "                        \"NodeType\": \"18\",\n"
      "                        \"Name\": \"Target\",\n"
      "                        \"Target\": {\n"
      "                            \"DataBlockId\": \"1\",\n"
      "                            \"SlotId\": \"0\",\n"
      "                            \"Expr\": {\n"
      "                                \"NodeType\": \"1\",\n"
      "                                \"Name\": \"Column\",\n"
      "                                \"Column\": {\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"9\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"AliasName\": \"ts\",\n"
      "                                    \"TableId\": \"0\",\n"
      "                                    \"ColId\": \"1\",\n"
      "                                    \"ColType\": \"1\",\n"
      "                                    \"DbName\": \"test\",\n"
      "                                    \"TableName\": \"t1\",\n"
      "                                    \"TableAlias\": \"t1\",\n"
      "                                    \"ColName\": \"ts\",\n"
      "                                    \"DataBlockId\": \"0\",\n"
      "                                    \"SlotId\": \"0\"\n"
H
Haojun Liao 已提交
675 676
      "                                }\n"
      "                            }\n"
H
Haojun Liao 已提交
677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
      "                        }\n"
      "                    },\n"
      "                    {\n"
      "                        \"NodeType\": \"18\",\n"
      "                        \"Name\": \"Target\",\n"
      "                        \"Target\": {\n"
      "                            \"DataBlockId\": \"1\",\n"
      "                            \"SlotId\": \"1\",\n"
      "                            \"Expr\": {\n"
      "                                \"NodeType\": \"1\",\n"
      "                                \"Name\": \"Column\",\n"
      "                                \"Column\": {\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"4\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"4\"\n"
      "                                    },\n"
      "                                    \"AliasName\": \"c1\",\n"
      "                                    \"TableId\": \"0\",\n"
      "                                    \"ColId\": \"2\",\n"
      "                                    \"ColType\": \"1\",\n"
      "                                    \"DbName\": \"test\",\n"
      "                                    \"TableName\": \"t1\",\n"
      "                                    \"TableAlias\": \"t1\",\n"
      "                                    \"ColName\": \"c1\",\n"
      "                                    \"DataBlockId\": \"0\",\n"
      "                                    \"SlotId\": \"1\"\n"
H
Haojun Liao 已提交
705 706
      "                                }\n"
      "                            }\n"
H
Haojun Liao 已提交
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
      "                        }\n"
      "                    },\n"
      "                    {\n"
      "                        \"NodeType\": \"18\",\n"
      "                        \"Name\": \"Target\",\n"
      "                        \"Target\": {\n"
      "                            \"DataBlockId\": \"1\",\n"
      "                            \"SlotId\": \"2\",\n"
      "                            \"Expr\": {\n"
      "                                \"NodeType\": \"1\",\n"
      "                                \"Name\": \"Column\",\n"
      "                                \"Column\": {\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"8\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"20\"\n"
      "                                    },\n"
      "                                    \"AliasName\": \"c2\",\n"
      "                                    \"TableId\": \"0\",\n"
      "                                    \"ColId\": \"3\",\n"
      "                                    \"ColType\": \"1\",\n"
      "                                    \"DbName\": \"test\",\n"
      "                                    \"TableName\": \"t1\",\n"
      "                                    \"TableAlias\": \"t1\",\n"
      "                                    \"ColName\": \"c2\",\n"
      "                                    \"DataBlockId\": \"0\",\n"
      "                                    \"SlotId\": \"2\"\n"
H
Haojun Liao 已提交
735 736
      "                                }\n"
      "                            }\n"
H
Haojun Liao 已提交
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764
      "                        }\n"
      "                    },\n"
      "                    {\n"
      "                        \"NodeType\": \"18\",\n"
      "                        \"Name\": \"Target\",\n"
      "                        \"Target\": {\n"
      "                            \"DataBlockId\": \"1\",\n"
      "                            \"SlotId\": \"3\",\n"
      "                            \"Expr\": {\n"
      "                                \"NodeType\": \"1\",\n"
      "                                \"Name\": \"Column\",\n"
      "                                \"Column\": {\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"5\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"AliasName\": \"c3\",\n"
      "                                    \"TableId\": \"0\",\n"
      "                                    \"ColId\": \"4\",\n"
      "                                    \"ColType\": \"1\",\n"
      "                                    \"DbName\": \"test\",\n"
      "                                    \"TableName\": \"t1\",\n"
      "                                    \"TableAlias\": \"t1\",\n"
      "                                    \"ColName\": \"c3\",\n"
      "                                    \"DataBlockId\": \"0\",\n"
      "                                    \"SlotId\": \"3\"\n"
H
Haojun Liao 已提交
765 766
      "                                }\n"
      "                            }\n"
H
Haojun Liao 已提交
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794
      "                        }\n"
      "                    },\n"
      "                    {\n"
      "                        \"NodeType\": \"18\",\n"
      "                        \"Name\": \"Target\",\n"
      "                        \"Target\": {\n"
      "                            \"DataBlockId\": \"1\",\n"
      "                            \"SlotId\": \"4\",\n"
      "                            \"Expr\": {\n"
      "                                \"NodeType\": \"1\",\n"
      "                                \"Name\": \"Column\",\n"
      "                                \"Column\": {\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"7\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"AliasName\": \"c4\",\n"
      "                                    \"TableId\": \"0\",\n"
      "                                    \"ColId\": \"5\",\n"
      "                                    \"ColType\": \"1\",\n"
      "                                    \"DbName\": \"test\",\n"
      "                                    \"TableName\": \"t1\",\n"
      "                                    \"TableAlias\": \"t1\",\n"
      "                                    \"ColName\": \"c4\",\n"
      "                                    \"DataBlockId\": \"0\",\n"
      "                                    \"SlotId\": \"4\"\n"
H
Haojun Liao 已提交
795 796
      "                                }\n"
      "                            }\n"
H
Haojun Liao 已提交
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824
      "                        }\n"
      "                    },\n"
      "                    {\n"
      "                        \"NodeType\": \"18\",\n"
      "                        \"Name\": \"Target\",\n"
      "                        \"Target\": {\n"
      "                            \"DataBlockId\": \"1\",\n"
      "                            \"SlotId\": \"5\",\n"
      "                            \"Expr\": {\n"
      "                                \"NodeType\": \"1\",\n"
      "                                \"Name\": \"Column\",\n"
      "                                \"Column\": {\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"7\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"AliasName\": \"c5\",\n"
      "                                    \"TableId\": \"0\",\n"
      "                                    \"ColId\": \"6\",\n"
      "                                    \"ColType\": \"1\",\n"
      "                                    \"DbName\": \"test\",\n"
      "                                    \"TableName\": \"t1\",\n"
      "                                    \"TableAlias\": \"t1\",\n"
      "                                    \"ColName\": \"c5\",\n"
      "                                    \"DataBlockId\": \"0\",\n"
      "                                    \"SlotId\": \"5\"\n"
H
Haojun Liao 已提交
825 826 827 828
      "                                }\n"
      "                            }\n"
      "                        }\n"
      "                    }\n"
H
Haojun Liao 已提交
829 830 831 832
      "                ]\n"
      "            }\n"
      "        },\n"
      "        \"DataSink\": {\n"
H
Haojun Liao 已提交
833
      "            \"NodeType\": \"46\",\n"
H
Haojun Liao 已提交
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855
      "            \"Name\": \"PhysiDispatch\",\n"
      "            \"PhysiDispatch\": {\n"
      "                \"InputDataBlockDesc\": {\n"
      "                    \"NodeType\": \"19\",\n"
      "                    \"Name\": \"TupleDesc\",\n"
      "                    \"TupleDesc\": {\n"
      "                        \"DataBlockId\": \"1\",\n"
      "                        \"Slots\": [\n"
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"0\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"9\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
856
      "                            },\n"
H
Haojun Liao 已提交
857 858 859 860 861 862 863 864 865 866 867 868 869 870
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"1\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"4\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"4\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
871
      "                            },\n"
H
Haojun Liao 已提交
872 873 874 875 876 877 878 879 880 881 882 883 884 885
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"2\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"8\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"20\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
886
      "                            },\n"
H
Haojun Liao 已提交
887 888 889 890 891 892 893 894 895 896 897 898 899 900
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"3\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"5\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
901
      "                            },\n"
H
Haojun Liao 已提交
902 903 904 905 906 907 908 909 910 911 912 913 914 915
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"4\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"7\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
H
Haojun Liao 已提交
916
      "                            },\n"
H
Haojun Liao 已提交
917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932
      "                            {\n"
      "                                \"NodeType\": \"20\",\n"
      "                                \"Name\": \"SlotDesc\",\n"
      "                                \"SlotDesc\": {\n"
      "                                    \"SlotId\": \"5\",\n"
      "                                    \"DataType\": {\n"
      "                                        \"Type\": \"7\",\n"
      "                                        \"Precision\": \"0\",\n"
      "                                        \"Scale\": \"0\",\n"
      "                                        \"Bytes\": \"8\"\n"
      "                                    },\n"
      "                                    \"Reserve\": false,\n"
      "                                    \"Output\": false\n"
      "                                }\n"
      "                            }\n"
      "                        ]\n"
H
Haojun Liao 已提交
933 934 935
      "                    }\n"
      "                }\n"
      "            }\n"
H
Haojun Liao 已提交
936
      "        }\n"
H
Haojun Liao 已提交
937 938
      "    }\n"
      "}";
939 940

  SExecTaskInfo* pTaskInfo = nullptr;
D
dapan1121 已提交
941
  DataSinkHandle sinkHandle = nullptr;
942
  SReadHandle    handle = {reinterpret_cast<void*>(0x1), reinterpret_cast<void*>(0x1), NULL};
H
Haojun Liao 已提交
943

944 945
  struct SSubplan* plan = NULL;
  int32_t          code = qStringToSubplan(msg, &plan);
H
Haojun Liao 已提交
946
  ASSERT_EQ(code, 0);
H
Haojun Liao 已提交
947

948
  code = qCreateExecTask(&handle, 2, 1, plan, (void**)&pTaskInfo, &sinkHandle, NULL, OPTR_EXEC_MODEL_BATCH);
H
Haojun Liao 已提交
949
  ASSERT_EQ(code, 0);
S
Shengliang Guan 已提交
950
}
H
Haojun Liao 已提交
951
#if 0
X
Xiaoyu Wang 已提交
952

H
Haojun Liao 已提交
953 954 955 956 957 958 959 960
TEST(testCase, inMem_sort_Test) {
  SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
  SOrder o = {.order = TSDB_ORDER_ASC};
  o.col.info.colId = 1;
  o.col.info.type = TSDB_DATA_TYPE_INT;
  taosArrayPush(pOrderVal, &o);

  SArray* pExprInfo = taosArrayInit(4, sizeof(SExprInfo));
wafwerar's avatar
wafwerar 已提交
961
  SExprInfo *exp = static_cast<SExprInfo*>(taosMemoryCalloc(1, sizeof(SExprInfo)));
H
Haojun Liao 已提交
962 963 964
  exp->base.resSchema = createSchema(TSDB_DATA_TYPE_INT, sizeof(int32_t), 1, "res");
  taosArrayPush(pExprInfo, &exp);

wafwerar's avatar
wafwerar 已提交
965
  SExprInfo *exp1 = static_cast<SExprInfo*>(taosMemoryCalloc(1, sizeof(SExprInfo)));
H
Haojun Liao 已提交
966 967 968
  exp1->base.resSchema = createSchema(TSDB_DATA_TYPE_BINARY, 40, 2, "res1");
  taosArrayPush(pExprInfo, &exp1);

H
Haojun Liao 已提交
969
  SOperatorInfo* pOperator = createSortOperatorInfo(createDummyOperator(10000, 5, 1000, data_asc, 1), pExprInfo, pOrderVal, NULL);
H
Haojun Liao 已提交
970 971

  bool newgroup = false;
H
Haojun Liao 已提交
972
  SSDataBlock* pRes = pOperator->getNextFn(pOperator, &newgroup);
H
Haojun Liao 已提交
973 974 975 976

  SColumnInfoData* pCol1 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 0));
  SColumnInfoData* pCol2 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 1));
  for(int32_t i = 0; i < pRes->info.rows; ++i) {
977
    char* p = colDataGetData(pCol2, i);
H
Haojun Liao 已提交
978 979 980
    printf("%d: %d, %s\n", i, ((int32_t*)pCol1->pData)[i], (char*)varDataVal(p));
  }
}
H
Haojun Liao 已提交
981

H
Haojun Liao 已提交
982
#endif
H
Haojun Liao 已提交
983 984 985

typedef struct su {
  int32_t v;
986
  char*   c;
H
Haojun Liao 已提交
987 988 989
} su;

int32_t cmp(const void* p1, const void* p2) {
990 991
  su* v1 = (su*)p1;
  su* v2 = (su*)p2;
H
Haojun Liao 已提交
992

993 994
  int32_t x1 = *(int32_t*)v1->c;
  int32_t x2 = *(int32_t*)v2->c;
H
Haojun Liao 已提交
995 996 997
  if (x1 == x2) {
    return 0;
  } else {
998
    return x1 < x2 ? -1 : 1;
H
Haojun Liao 已提交
999 1000 1001
  }
}

X
Xiaoyu Wang 已提交
1002
#if 0
H
Haojun Liao 已提交
1003 1004
TEST(testCase, external_sort_Test) {
#if 0
wafwerar's avatar
wafwerar 已提交
1005
  su* v = static_cast<su*>(taosMemoryCalloc(1000000, sizeof(su)));
H
Haojun Liao 已提交
1006
  for(int32_t i = 0; i < 1000000; ++i) {
wafwerar's avatar
wafwerar 已提交
1007
    v[i].v = taosRand();
wafwerar's avatar
wafwerar 已提交
1008
    v[i].c = static_cast<char*>(taosMemoryMalloc(4));
H
Haojun Liao 已提交
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019
    *(int32_t*) v[i].c = i;
  }

  qsort(v, 1000000, sizeof(su), cmp);
//  for(int32_t i = 0; i < 1000; ++i) {
//    printf("%d ", v[i]);
//  }
//  printf("\n");
  return;
#endif

wafwerar's avatar
wafwerar 已提交
1020
  taosSeedRand(taosGetTimestampSec());
H
Haojun Liao 已提交
1021 1022 1023 1024 1025 1026 1027 1028 1029

  SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
  SOrder o = {0};
  o.order = TSDB_ORDER_ASC;
  o.col.info.colId = 1;
  o.col.info.type = TSDB_DATA_TYPE_INT;
  taosArrayPush(pOrderVal, &o);

  SArray* pExprInfo = taosArrayInit(4, sizeof(SExprInfo));
wafwerar's avatar
wafwerar 已提交
1030
  SExprInfo *exp = static_cast<SExprInfo*>(taosMemoryCalloc(1, sizeof(SExprInfo)));
H
Haojun Liao 已提交
1031 1032 1033
  exp->base.resSchema = createSchema(TSDB_DATA_TYPE_INT, sizeof(int32_t), 1, "res");
  taosArrayPush(pExprInfo, &exp);

wafwerar's avatar
wafwerar 已提交
1034
  SExprInfo *exp1 = static_cast<SExprInfo*>(taosMemoryCalloc(1, sizeof(SExprInfo)));
H
Haojun Liao 已提交
1035 1036 1037
  exp1->base.resSchema = createSchema(TSDB_DATA_TYPE_BINARY, 40, 2, "res1");
//  taosArrayPush(pExprInfo, &exp1);

H
Haojun Liao 已提交
1038
  SOperatorInfo* pOperator = createSortOperatorInfo(createDummyOperator(10000, 1500, 1000, data_desc, 1), pExprInfo, pOrderVal, NULL);
H
Haojun Liao 已提交
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049

  bool newgroup = false;
  SSDataBlock* pRes = NULL;

  int32_t total = 1;

  int64_t s1 = taosGetTimestampUs();
  int32_t t = 1;

  while(1) {
    int64_t s = taosGetTimestampUs();
H
Haojun Liao 已提交
1050
    pRes = pOperator->getNextFn(pOperator, &newgroup);
H
Haojun Liao 已提交
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060

    int64_t e = taosGetTimestampUs();
    if (t++ == 1) {
      printf("---------------elapsed:%ld\n", e - s);
    }

    if (pRes == NULL) {
      break;
    }

H
Haojun Liao 已提交
1061
    SColumnInfoData* pCol1 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 0));
H
Haojun Liao 已提交
1062
//    SColumnInfoData* pCol2 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 1));
H
Haojun Liao 已提交
1063
    for (int32_t i = 0; i < pRes->info.rows; ++i) {
1064
//      char* p = colDataGetData(pCol2, i);
H
Haojun Liao 已提交
1065
      printf("%d: %d\n", total++, ((int32_t*)pCol1->pData)[i]);
H
Haojun Liao 已提交
1066
//      printf("%d: %d, %s\n", total++, ((int32_t*)pCol1->pData)[i], (char*)varDataVal(p));
H
Haojun Liao 已提交
1067
    }
H
Haojun Liao 已提交
1068 1069 1070 1071 1072
  }

  int64_t s2 = taosGetTimestampUs();
  printf("total:%ld\n", s2 - s1);

H
Haojun Liao 已提交
1073
  pOperator->closeFn(pOperator->info, 2);
wafwerar's avatar
wafwerar 已提交
1074 1075
  taosMemoryFreeClear(exp);
  taosMemoryFreeClear(exp1);
H
Haojun Liao 已提交
1076 1077 1078
  taosArrayDestroy(pExprInfo);
  taosArrayDestroy(pOrderVal);
}
H
Haojun Liao 已提交
1079

H
Haojun Liao 已提交
1080
TEST(testCase, sorted_merge_Test) {
wafwerar's avatar
wafwerar 已提交
1081
  taosSeedRand(taosGetTimestampSec());
H
Haojun Liao 已提交
1082 1083 1084 1085 1086 1087 1088 1089 1090

  SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
  SOrder o = {0};
  o.order = TSDB_ORDER_ASC;
  o.col.info.colId = 1;
  o.col.info.type = TSDB_DATA_TYPE_INT;
  taosArrayPush(pOrderVal, &o);

  SArray* pExprInfo = taosArrayInit(4, sizeof(SExprInfo));
wafwerar's avatar
wafwerar 已提交
1091
  SExprInfo *exp = static_cast<SExprInfo*>(taosMemoryCalloc(1, sizeof(SExprInfo)));
1092
  exp->base.resSchema = createSchema(TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 1, "count_result");
wafwerar's avatar
wafwerar 已提交
1093
  exp->base.pColumns = static_cast<SColumn*>(taosMemoryCalloc(1, sizeof(SColumn)));
1094 1095 1096 1097
  exp->base.pColumns->flag = TSDB_COL_NORMAL;
  exp->base.pColumns->info = (SColumnInfo) {.colId = 1, .type = TSDB_DATA_TYPE_INT, .bytes = 4};
  exp->base.numOfCols = 1;

H
Haojun Liao 已提交
1098 1099
  taosArrayPush(pExprInfo, &exp);

wafwerar's avatar
wafwerar 已提交
1100
  SExprInfo *exp1 = static_cast<SExprInfo*>(taosMemoryCalloc(1, sizeof(SExprInfo)));
H
Haojun Liao 已提交
1101 1102 1103
  exp1->base.resSchema = createSchema(TSDB_DATA_TYPE_BINARY, 40, 2, "res1");
//  taosArrayPush(pExprInfo, &exp1);

H
Haojun Liao 已提交
1104
  int32_t numOfSources = 10;
wafwerar's avatar
wafwerar 已提交
1105
  SOperatorInfo** plist = (SOperatorInfo**) taosMemoryCalloc(numOfSources, sizeof(void*));
H
Haojun Liao 已提交
1106
  for(int32_t i = 0; i < numOfSources; ++i) {
H
Haojun Liao 已提交
1107
    plist[i] = createDummyOperator(1, 1, 1, data_asc, 1);
H
Haojun Liao 已提交
1108 1109
  }

1110
  SOperatorInfo* pOperator = createSortedMergeOperatorInfo(plist, numOfSources, pExprInfo, pOrderVal, NULL, NULL);
H
Haojun Liao 已提交
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121

  bool newgroup = false;
  SSDataBlock* pRes = NULL;

  int32_t total = 1;

  int64_t s1 = taosGetTimestampUs();
  int32_t t = 1;

  while(1) {
    int64_t s = taosGetTimestampUs();
H
Haojun Liao 已提交
1122
    pRes = pOperator->getNextFn(pOperator, &newgroup);
H
Haojun Liao 已提交
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135

    int64_t e = taosGetTimestampUs();
    if (t++ == 1) {
      printf("---------------elapsed:%ld\n", e - s);
    }

    if (pRes == NULL) {
      break;
    }

    SColumnInfoData* pCol1 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 0));
//    SColumnInfoData* pCol2 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 1));
    for (int32_t i = 0; i < pRes->info.rows; ++i) {
1136 1137
//      char* p = colDataGetData(pCol2, i);
      printf("%d: %ld\n", total++, ((int64_t*)pCol1->pData)[i]);
H
Haojun Liao 已提交
1138 1139 1140 1141 1142 1143 1144
//      printf("%d: %d, %s\n", total++, ((int32_t*)pCol1->pData)[i], (char*)varDataVal(p));
    }
  }

  int64_t s2 = taosGetTimestampUs();
  printf("total:%ld\n", s2 - s1);

H
Haojun Liao 已提交
1145
  pOperator->closeFn(pOperator->info, 2);
wafwerar's avatar
wafwerar 已提交
1146 1147
  taosMemoryFreeClear(exp);
  taosMemoryFreeClear(exp1);
H
Haojun Liao 已提交
1148 1149 1150
  taosArrayDestroy(pExprInfo);
  taosArrayDestroy(pOrderVal);
}
H
Haojun Liao 已提交
1151

H
Haojun Liao 已提交
1152
TEST(testCase, time_interval_Operator_Test) {
wafwerar's avatar
wafwerar 已提交
1153
  taosSeedRand(taosGetTimestampSec());
H
Haojun Liao 已提交
1154 1155 1156 1157 1158 1159 1160 1161 1162

  SArray* pOrderVal = taosArrayInit(4, sizeof(SOrder));
  SOrder o = {0};
  o.order = TSDB_ORDER_ASC;
  o.col.info.colId = 1;
  o.col.info.type = TSDB_DATA_TYPE_INT;
  taosArrayPush(pOrderVal, &o);

  SArray* pExprInfo = taosArrayInit(4, sizeof(SExprInfo));
wafwerar's avatar
wafwerar 已提交
1163
  SExprInfo *exp = static_cast<SExprInfo*>(taosMemoryCalloc(1, sizeof(SExprInfo)));
H
Haojun Liao 已提交
1164
  exp->base.resSchema = createSchema(TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 1, "ts");
wafwerar's avatar
wafwerar 已提交
1165
  exp->base.pColumns = static_cast<SColumn*>(taosMemoryCalloc(1, sizeof(SColumn)));
H
Haojun Liao 已提交
1166 1167 1168 1169 1170 1171
  exp->base.pColumns->flag = TSDB_COL_NORMAL;
  exp->base.pColumns->info = (SColumnInfo) {.colId = 1, .type = TSDB_DATA_TYPE_TIMESTAMP, .bytes = 8};
  exp->base.numOfCols = 1;

  taosArrayPush(pExprInfo, &exp);

wafwerar's avatar
wafwerar 已提交
1172
  SExprInfo *exp1 = static_cast<SExprInfo*>(taosMemoryCalloc(1, sizeof(SExprInfo)));
H
Haojun Liao 已提交
1173
  exp1->base.resSchema = createSchema(TSDB_DATA_TYPE_BIGINT, 8, 2, "res1");
wafwerar's avatar
wafwerar 已提交
1174
  exp1->base.pColumns = static_cast<SColumn*>(taosMemoryCalloc(1, sizeof(SColumn)));
H
Haojun Liao 已提交
1175 1176 1177 1178 1179 1180 1181 1182 1183
  exp1->base.pColumns->flag = TSDB_COL_NORMAL;
  exp1->base.pColumns->info = (SColumnInfo) {.colId = 1, .type = TSDB_DATA_TYPE_INT, .bytes = 4};
  exp1->base.numOfCols = 1;

  taosArrayPush(pExprInfo, &exp1);

  SOperatorInfo* p = createDummyOperator(1, 1, 2000, data_asc, 2);

  SExecTaskInfo ti = {0};
1184 1185 1186 1187 1188
  SInterval interval = {0};
  interval.sliding = interval.interval = 1000;
  interval.slidingUnit = interval.intervalUnit = 'a';

  SOperatorInfo* pOperator = createIntervalOperatorInfo(p, pExprInfo, &interval, &ti);
H
Haojun Liao 已提交
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199

  bool newgroup = false;
  SSDataBlock* pRes = NULL;

  int32_t total = 1;

  int64_t s1 = taosGetTimestampUs();
  int32_t t = 1;

  while(1) {
    int64_t s = taosGetTimestampUs();
H
Haojun Liao 已提交
1200
    pRes = pOperator->getNextFn(pOperator, &newgroup);
H
Haojun Liao 已提交
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222

    int64_t e = taosGetTimestampUs();
    if (t++ == 1) {
      printf("---------------elapsed:%ld\n", e - s);
    }

    if (pRes == NULL) {
      break;
    }

    SColumnInfoData* pCol1 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 0));
//    SColumnInfoData* pCol2 = static_cast<SColumnInfoData*>(taosArrayGet(pRes->pDataBlock, 1));
    for (int32_t i = 0; i < pRes->info.rows; ++i) {
//      char* p = colDataGetData(pCol2, i);
      printf("%d: %ld\n", total++, ((int64_t*)pCol1->pData)[i]);
//      printf("%d: %d, %s\n", total++, ((int32_t*)pCol1->pData)[i], (char*)varDataVal(p));
    }
  }

  int64_t s2 = taosGetTimestampUs();
  printf("total:%ld\n", s2 - s1);

H
Haojun Liao 已提交
1223
  pOperator->closeFn(pOperator->info, 2);
wafwerar's avatar
wafwerar 已提交
1224 1225
  taosMemoryFreeClear(exp);
  taosMemoryFreeClear(exp1);
H
Haojun Liao 已提交
1226 1227 1228
  taosArrayDestroy(pExprInfo);
  taosArrayDestroy(pOrderVal);
}
X
Xiaoyu Wang 已提交
1229
#endif
H
Haojun Liao 已提交
1230

1231
#pragma GCC diagnosti