From 458f37a774419f51e9ed1252f438b188be658dad Mon Sep 17 00:00:00 2001 From: gccgdb1234 Date: Tue, 30 Aug 2022 08:48:57 +0800 Subject: [PATCH 01/72] doc: add explanation for dropped 2.x configuration variables --- docs/zh/14-reference/12-config/index.md | 358 ++++++++++++------------ 1 file changed, 181 insertions(+), 177 deletions(-) diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index 7b31e10572..ce07b6b757 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -70,11 +70,11 @@ taos --dump-config ### serverPort -| 属性 | 说明 | -| -------- | ----------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | taosd 启动后,对外服务的端口号 | -| 缺省值 | 6030 | +| 属性 | 说明 | +| -------- | ------------------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | taosd 启动后,对外服务的端口号 | +| 缺省值 | 6030 | :::note 确保集群中所有主机在端口 6030 上的 TCP 协议能够互通。(详细的端口情况请参见下表) @@ -173,11 +173,10 @@ taos --dump-config 1: 表示使用 sma index,对符合的语句,直接从预计算的结果进行查询 | - ### maxNumOfDistinctRes | 属性 | 说明 | -| -------- | -------------------------------- | --- | +| -------- | -------------------------------- | | 适用范围 | 仅服务端适用 | | 含义 | 允许返回的 distinct 结果最大行数 | | 取值范围 | 默认值为 10 万,最大值 1 亿 | @@ -616,7 +615,7 @@ charset 的有效值是 UTF-8。 | 适用范围 | 仅客户端适用 | | 含义 | schemaless tag 为空时默认的 tag 名字 | | 类型 | 字符串 | -| 缺省值 | _tag_null | +| 缺省值 | \_tag_null | ### smlDataFormat @@ -649,172 +648,177 @@ charset 的有效值是 UTF-8。 | 缺省值 | 1 | ## 2.X 与 3.0 配置参数对比 -| # | **参数** | **适用于 2.X 版本** | **适用于 3.0 版本** | -| --- | :-----------------: | --------------- | --------------- | -| 1 | firstEp | 是 | 是 | -| 2 | secondEp | 是 | 是 | -| 3 | fqdn | 是 | 是 | -| 4 | serverPort | 是 | 是 | -| 5 | maxShellConns | 是 | 是 | -| 6 | monitor | 是 | 是 | -| 7 | monitorFqdn | 否 | 是 | -| 8 | monitorPort | 否 | 是 | -| 9 | monitorInterval | 是 | 是 | -| 10 | monitorMaxLogs | 否 | 是 | -| 11 | monitorComp | 否 | 是 | -| 12 | telemetryReporting | 是 | 是 | -| 13 | telemetryInterval | 否 | 是 | -| 14 | telemetryServer | 否 | 是 | -| 15 | telemetryPort | 否 | 是 | -| 16 | queryPolicy | 否 | 是 | -| 17 | querySmaOptimize | 否 | 是 | -| 18 | queryBufferSize | 是 | 是 | -| 19 | maxNumOfDistinctRes | 是 | 是 | -| 20 | minSlidingTime | 是 | 是 | -| 21 | minIntervalTime | 是 | 是 | -| 22 | countAlwaysReturnValue | 是 | 是 | -| 23 | dataDir | 是 | 是 | -| 24 | minimalDataDirGB | 是 | 是 | -| 25 | supportVnodes | 否 | 是 | -| 26 | tempDir | 是 | 是 | -| 27 | minimalTmpDirGB | 是 | 是 | -| 28 | compressMsgSize | 是 | 是 | -| 29 | compressColData | 是 | 是 | -| 30 | smlChildTableName | 是 | 是 | -| 31 | smlTagName | 是 | 是 | -| 32 | smlDataFormat | 否 | 是 | -| 33 | statusInterval | 是 | 是 | -| 34 | shellActivityTimer | 是 | 是 | -| 35 | transPullupInterval | 否 | 是 | -| 36 | mqRebalanceInterval | 否 | 是 | -| 37 | ttlUnit | 否 | 是 | -| 38 | ttlPushInterval | 否 | 是 | -| 39 | numOfTaskQueueThreads | 否 | 是 | -| 40 | numOfRpcThreads | 否 | 是 | -| 41 | numOfCommitThreads | 是 | 是 | -| 42 | numOfMnodeReadThreads | 否 | 是 | -| 43 | numOfVnodeQueryThreads | 否 | 是 | -| 44 | numOfVnodeStreamThreads | 否 | 是 | -| 45 | numOfVnodeFetchThreads | 否 | 是 | -| 46 | numOfVnodeWriteThreads | 否 | 是 | -| 47 | numOfVnodeSyncThreads | 否 | 是 | -| 48 | numOfVnodeRsmaThreads | 否 | 是 | -| 49 | numOfQnodeQueryThreads | 否 | 是 | -| 50 | numOfQnodeFetchThreads | 否 | 是 | -| 51 | numOfSnodeSharedThreads | 否 | 是 | -| 52 | numOfSnodeUniqueThreads | 否 | 是 | -| 53 | rpcQueueMemoryAllowed | 否 | 是 | -| 54 | logDir | 是 | 是 | -| 55 | minimalLogDirGB | 是 | 是 | -| 56 | numOfLogLines | 是 | 是 | -| 57 | asyncLog | 是 | 是 | -| 58 | logKeepDays | 是 | 是 | -| 59 | debugFlag | 是 | 是 | -| 60 | tmrDebugFlag | 是 | 是 | -| 61 | uDebugFlag | 是 | 是 | -| 62 | rpcDebugFlag | 是 | 是 | -| 63 | jniDebugFlag | 是 | 是 | -| 64 | qDebugFlag | 是 | 是 | -| 65 | cDebugFlag | 是 | 是 | -| 66 | dDebugFlag | 是 | 是 | -| 67 | vDebugFlag | 是 | 是 | -| 68 | mDebugFlag | 是 | 是 | -| 69 | wDebugFlag | 是 | 是 | -| 70 | sDebugFlag | 是 | 是 | -| 71 | tsdbDebugFlag | 是 | 是 | -| 72 | tqDebugFlag | 否 | 是 | -| 73 | fsDebugFlag | 是 | 是 | -| 74 | udfDebugFlag | 否 | 是 | -| 75 | smaDebugFlag | 否 | 是 | -| 76 | idxDebugFlag | 否 | 是 | -| 77 | tdbDebugFlag | 否 | 是 | -| 78 | metaDebugFlag | 否 | 是 | -| 79 | timezone | 是 | 是 | -| 80 | locale | 是 | 是 | -| 81 | charset | 是 | 是 | -| 82 | udf | 是 | 是 | -| 83 | enableCoreFile | 是 | 是 | -| 84 | arbitrator | 是 | 否 | -| 85 | numOfThreadsPerCore | 是 | 否 | -| 86 | numOfMnodes | 是 | 否 | -| 87 | vnodeBak | 是 | 否 | -| 88 | balance | 是 | 否 | -| 89 | balanceInterval | 是 | 否 | -| 90 | offlineThreshold | 是 | 否 | -| 91 | role | 是 | 否 | -| 92 | dnodeNopLoop | 是 | 否 | -| 93 | keepTimeOffset | 是 | 否 | -| 94 | rpcTimer | 是 | 否 | -| 95 | rpcMaxTime | 是 | 否 | -| 96 | rpcForceTcp | 是 | 否 | -| 97 | tcpConnTimeout | 是 | 否 | -| 98 | syncCheckInterval | 是 | 否 | -| 99 | maxTmrCtrl | 是 | 否 | -| 100 | monitorReplica | 是 | 否 | -| 101 | smlTagNullName | 是 | 否 | -| 102 | keepColumnName | 是 | 否 | -| 103 | ratioOfQueryCores | 是 | 否 | -| 104 | maxStreamCompDelay | 是 | 否 | -| 105 | maxFirstStreamCompDelay | 是 | 否 | -| 106 | retryStreamCompDelay | 是 | 否 | -| 107 | streamCompDelayRatio | 是 | 否 | -| 108 | maxVgroupsPerDb | 是 | 否 | -| 109 | maxTablesPerVnode | 是 | 否 | -| 110 | minTablesPerVnode | 是 | 否 | -| 111 | tableIncStepPerVnode | 是 | 否 | -| 112 | cache | 是 | 否 | -| 113 | blocks | 是 | 否 | -| 114 | days | 是 | 否 | -| 115 | keep | 是 | 否 | -| 116 | minRows | 是 | 否 | -| 117 | maxRows | 是 | 否 | -| 118 | quorum | 是 | 否 | -| 119 | comp | 是 | 否 | -| 120 | walLevel | 是 | 否 | -| 121 | fsync | 是 | 否 | -| 122 | replica | 是 | 否 | -| 123 | partitions | 是 | 否 | -| 124 | quorum | 是 | 否 | -| 125 | update | 是 | 否 | -| 126 | cachelast | 是 | 否 | -| 127 | maxSQLLength | 是 | 否 | -| 128 | maxWildCardsLength | 是 | 否 | -| 129 | maxRegexStringLen | 是 | 否 | -| 130 | maxNumOfOrderedRes | 是 | 否 | -| 131 | maxConnections | 是 | 否 | -| 132 | mnodeEqualVnodeNum | 是 | 否 | -| 133 | http | 是 | 否 | -| 134 | httpEnableRecordSql | 是 | 否 | -| 135 | httpMaxThreads | 是 | 否 | -| 136 | restfulRowLimit | 是 | 否 | -| 137 | httpDbNameMandatory | 是 | 否 | -| 138 | httpKeepAlive | 是 | 否 | -| 139 | enableRecordSql | 是 | 否 | -| 140 | maxBinaryDisplayWidth | 是 | 否 | -| 141 | stream | 是 | 否 | -| 142 | retrieveBlockingModel | 是 | 否 | -| 143 | tsdbMetaCompactRatio | 是 | 否 | -| 144 | defaultJSONStrType | 是 | 否 | -| 145 | walFlushSize | 是 | 否 | -| 146 | keepTimeOffset | 是 | 否 | -| 147 | flowctrl | 是 | 否 | -| 148 | slaveQuery | 是 | 否 | -| 149 | adjustMaster | 是 | 否 | -| 150 | topicBinaryLen | 是 | 否 | -| 151 | telegrafUseFieldNum | 是 | 否 | -| 152 | deadLockKillQuery | 是 | 否 | -| 153 | clientMerge | 是 | 否 | -| 154 | sdbDebugFlag | 是 | 否 | -| 155 | odbcDebugFlag | 是 | 否 | -| 156 | httpDebugFlag | 是 | 否 | -| 157 | monDebugFlag | 是 | 否 | -| 158 | cqDebugFlag | 是 | 否 | -| 159 | shortcutFlag | 是 | 否 | -| 160 | probeSeconds | 是 | 否 | -| 161 | probeKillSeconds | 是 | 否 | -| 162 | probeInterval | 是 | 否 | -| 163 | lossyColumns | 是 | 否 | -| 164 | fPrecision | 是 | 否 | -| 165 | dPrecision | 是 | 否 | -| 166 | maxRange | 是 | 否 | -| 167 | range | 是 | 否 | + +:::note +对于 2.x 版本中适用但在 3.0 版本中废弃的参数,其当前行为会有特别说明 + +::: + +| # | **参数** | **适用于 2.X ** | **适用于 3.0 ** | 3.0 版本的当前行为 | +| --- | :---------------------: | --------------- | --------------- | ------------------ | +| 1 | firstEp | 是 | 是 | | +| 2 | secondEp | 是 | 是 | | +| 3 | fqdn | 是 | 是 | | +| 4 | serverPort | 是 | 是 | | +| 5 | maxShellConns | 是 | 是 | | +| 6 | monitor | 是 | 是 | | +| 7 | monitorFqdn | 否 | 是 | | +| 8 | monitorPort | 否 | 是 | | +| 9 | monitorInterval | 是 | 是 | | +| 10 | monitorMaxLogs | 否 | 是 | | +| 11 | monitorComp | 否 | 是 | | +| 12 | telemetryReporting | 是 | 是 | | +| 13 | telemetryInterval | 否 | 是 | | +| 14 | telemetryServer | 否 | 是 | | +| 15 | telemetryPort | 否 | 是 | | +| 16 | queryPolicy | 否 | 是 | | +| 17 | querySmaOptimize | 否 | 是 | | +| 18 | queryBufferSize | 是 | 是 | | +| 19 | maxNumOfDistinctRes | 是 | 是 | | +| 20 | minSlidingTime | 是 | 是 | | +| 21 | minIntervalTime | 是 | 是 | | +| 22 | countAlwaysReturnValue | 是 | 是 | | +| 23 | dataDir | 是 | 是 | | +| 24 | minimalDataDirGB | 是 | 是 | | +| 25 | supportVnodes | 否 | 是 | | +| 26 | tempDir | 是 | 是 | | +| 27 | minimalTmpDirGB | 是 | 是 | | +| 28 | compressMsgSize | 是 | 是 | | +| 29 | compressColData | 是 | 是 | | +| 30 | smlChildTableName | 是 | 是 | | +| 31 | smlTagName | 是 | 是 | | +| 32 | smlDataFormat | 否 | 是 | | +| 33 | statusInterval | 是 | 是 | | +| 34 | shellActivityTimer | 是 | 是 | | +| 35 | transPullupInterval | 否 | 是 | | +| 36 | mqRebalanceInterval | 否 | 是 | | +| 37 | ttlUnit | 否 | 是 | | +| 38 | ttlPushInterval | 否 | 是 | | +| 39 | numOfTaskQueueThreads | 否 | 是 | | +| 40 | numOfRpcThreads | 否 | 是 | | +| 41 | numOfCommitThreads | 是 | 是 | | +| 42 | numOfMnodeReadThreads | 否 | 是 | | +| 43 | numOfVnodeQueryThreads | 否 | 是 | | +| 44 | numOfVnodeStreamThreads | 否 | 是 | | +| 45 | numOfVnodeFetchThreads | 否 | 是 | | +| 46 | numOfVnodeWriteThreads | 否 | 是 | | +| 47 | numOfVnodeSyncThreads | 否 | 是 | | +| 48 | numOfVnodeRsmaThreads | 否 | 是 | | +| 49 | numOfQnodeQueryThreads | 否 | 是 | | +| 50 | numOfQnodeFetchThreads | 否 | 是 | | +| 51 | numOfSnodeSharedThreads | 否 | 是 | | +| 52 | numOfSnodeUniqueThreads | 否 | 是 | | +| 53 | rpcQueueMemoryAllowed | 否 | 是 | | +| 54 | logDir | 是 | 是 | | +| 55 | minimalLogDirGB | 是 | 是 | | +| 56 | numOfLogLines | 是 | 是 | | +| 57 | asyncLog | 是 | 是 | | +| 58 | logKeepDays | 是 | 是 | | +| 59 | debugFlag | 是 | 是 | | +| 60 | tmrDebugFlag | 是 | 是 | | +| 61 | uDebugFlag | 是 | 是 | | +| 62 | rpcDebugFlag | 是 | 是 | | +| 63 | jniDebugFlag | 是 | 是 | | +| 64 | qDebugFlag | 是 | 是 | | +| 65 | cDebugFlag | 是 | 是 | | +| 66 | dDebugFlag | 是 | 是 | | +| 67 | vDebugFlag | 是 | 是 | | +| 68 | mDebugFlag | 是 | 是 | | +| 69 | wDebugFlag | 是 | 是 | | +| 70 | sDebugFlag | 是 | 是 | | +| 71 | tsdbDebugFlag | 是 | 是 | | +| 72 | tqDebugFlag | 否 | 是 | | +| 73 | fsDebugFlag | 是 | 是 | | +| 74 | udfDebugFlag | 否 | 是 | | +| 75 | smaDebugFlag | 否 | 是 | | +| 76 | idxDebugFlag | 否 | 是 | | +| 77 | tdbDebugFlag | 否 | 是 | | +| 78 | metaDebugFlag | 否 | 是 | | +| 79 | timezone | 是 | 是 | | +| 80 | locale | 是 | 是 | | +| 81 | charset | 是 | 是 | | +| 82 | udf | 是 | 是 | | +| 83 | enableCoreFile | 是 | 是 | | +| 84 | arbitrator | 是 | 否 | 通过 RAFT 协议选主 | +| 85 | numOfThreadsPerCore | 是 | 否 | 有其它参数设置多种线程池的大小 | +| 86 | numOfMnodes | 是 | 否 | 通过 create mnode 命令动态创建 mnode | +| 87 | vnodeBak | 是 | 否 | 3.0 行为未知 | +| 88 | balance | 是 | 否 | 负载均衡功能由 split/merge vgroups 实现 | +| 89 | balanceInterval | 是 | 否 | 随着 balance 参数失效 | +| 90 | offlineThreshold | 是 | 否 | 3.0 行为未知 | +| 91 | role | 是 | 否 | 由 supportVnode 决定是否能够创建 | +| 92 | dnodeNopLoop | 是 | 否 | 2.6文档中未找到此参数 | +| 93 | keepTimeOffset | 是 | 否 | 2.6文档中未找到此参数 | +| 94 | rpcTimer | 是 | 否 | 3.0 行为未知 | +| 95 | rpcMaxTime | 是 | 否 | 3.0 行为未知 | +| 96 | rpcForceTcp | 是 | 否 | 默认为 TCP | +| 97 | tcpConnTimeout | 是 | 否 | 3.0 行为未知 | +| 98 | syncCheckInterval | 是 | 否 | 3.0 行为未知 | +| 99 | maxTmrCtrl | 是 | 否 | 3.0 行为未知 | +| 100 | monitorReplica | 是 | 否 | 由 RAFT 协议管理多副本 | +| 101 | smlTagNullName | 是 | 否 | 3.0 行为未知 | +| 102 | keepColumnName | 是 | 否 | 3.0 行为未知 | +| 103 | ratioOfQueryCores | 是 | 否 | 由 线程池 相关配置参数决定 | +| 104 | maxStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 105 | maxFirstStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 106 | retryStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 107 | streamCompDelayRatio | 是 | 否 | 3.0 行为未知 | +| 108 | maxVgroupsPerDb | 是 | 否 | 由 create db 的参数 vgroups 指定实际 vgroups 数量 | +| 109 | maxTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 110 | minTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 111 | tableIncStepPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 112 | cache | 是 | 否 | 由 buffer 代替 cache*blocks | +| 113 | blocks | 是 | 否 | 由 buffer 代替 cache*blocks | +| 114 | days | 是 | 否 | 由 create db 的参数 duration 取代 | +| 115 | keep | 是 | 否 | 由 create db 的参数 keep 取代 | +| 116 | minRows | 是 | 否 | 由 create db 的参数 minRows 取代 | +| 117 | maxRows | 是 | 否 | 由 create db 的参数 maxRows 取代 | +| 118 | quorum | 是 | 否 | 由 RAFT 协议决定 | +| 119 | comp | 是 | 否 | 由 create db 的参数 comp 取代 | +| 120 | walLevel | 是 | 否 | 由 create db 的参数 wal_level 取代 | +| 121 | fsync | 是 | 否 | 由 create db 的参数 wal_fsync_period 取代 | +| 122 | replica | 是 | 否 | 由 create db 的参数 replica 取代 | +| 123 | partitions | 是 | 否 | 3.0 行为未知 | +| 125 | update | 是 | 否 | 允许更新部分列 | +| 126 | cachelast | 是 | 否 | 由 create db 的参数 cacheModel 取代 | +| 127 | maxSQLLength | 是 | 否 | SQL 上限为 1MB,无需参数控制 | +| 128 | maxWildCardsLength | 是 | 否 | 3.0 行为未知 | +| 129 | maxRegexStringLen | 是 | 否 | 3.0 行为未知 | +| 130 | maxNumOfOrderedRes | 是 | 否 | 3.0 行为未知 | +| 131 | maxConnections | 是 | 否 | 取决于系统配置和系统处理能力,详见后面的 Note | +| 132 | mnodeEqualVnodeNum | 是 | 否 | 3.0 行为未知 | +| 133 | http | 是 | 否 | http 服务由 taosAdapter 提供 | +| 134 | httpEnableRecordSql | 是 | 否 | taosd 不提供 http 服务 | +| 135 | httpMaxThreads | 是 | 否 | taosd 不提供 http 服务 | +| 136 | restfulRowLimit | 是 | 否 | taosd 不提供 http 服务 | +| 137 | httpDbNameMandatory | 是 | 否 | taosd 不提供 http 服务 | +| 138 | httpKeepAlive | 是 | 否 | taosd 不提供 http 服务 | +| 139 | enableRecordSql | 是 | 否 | 3.0 行为未知 | +| 140 | maxBinaryDisplayWidth | 是 | 否 | 3.0 行为未知 | +| 141 | stream | 是 | 否 | 默认启用连续查询 | +| 142 | retrieveBlockingModel | 是 | 否 | 3.0 行为未知 | +| 143 | tsdbMetaCompactRatio | 是 | 否 | 3.0 行为未知 | +| 144 | defaultJSONStrType | 是 | 否 | 3.0 行为未知 | +| 145 | walFlushSize | 是 | 否 | 3.0 行为未知 | +| 146 | keepTimeOffset | 是 | 否 | 3.0 行为未知 | +| 147 | flowctrl | 是 | 否 | 3.0 行为未知 | +| 148 | slaveQuery | 是 | 否 | 3.0 行为未知: slave vnode 是否能够处理查询? | +| 149 | adjustMaster | 是 | 否 | 3.0 行为未知 | +| 150 | topicBinaryLen | 是 | 否 | 3.0 行为未知 | +| 151 | telegrafUseFieldNum | 是 | 否 | 3.0 行为未知 | +| 152 | deadLockKillQuery | 是 | 否 | 3.0 行为未知 | +| 153 | clientMerge | 是 | 否 | 3.0 行为未知 | +| 154 | sdbDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | +| 155 | odbcDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | +| 156 | httpDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | +| 157 | monDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | +| 158 | cqDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | +| 159 | shortcutFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | +| 160 | probeSeconds | 是 | 否 | 3.0 行为未知 | +| 161 | probeKillSeconds | 是 | 否 | 3.0 行为未知 | +| 162 | probeInterval | 是 | 否 | 3.0 行为未知 | +| 163 | lossyColumns | 是 | 否 | 3.0 行为未知 | +| 164 | fPrecision | 是 | 否 | 3.0 行为未知 | +| 165 | dPrecision | 是 | 否 | 3.0 行为未知 | +| 166 | maxRange | 是 | 否 | 3.0 行为未知 | +| 167 | range | 是 | 否 | 3.0 行为未知 | From 1a6f3dbd2c457e08ad4d6aad4254479d4631dc9d Mon Sep 17 00:00:00 2001 From: gccgdb1234 Date: Tue, 30 Aug 2022 08:51:17 +0800 Subject: [PATCH 02/72] doc: format --- docs/zh/14-reference/12-config/index.md | 334 ++++++++++++------------ 1 file changed, 167 insertions(+), 167 deletions(-) diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index ce07b6b757..18ee7af89a 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -654,171 +654,171 @@ charset 的有效值是 UTF-8。 ::: -| # | **参数** | **适用于 2.X ** | **适用于 3.0 ** | 3.0 版本的当前行为 | -| --- | :---------------------: | --------------- | --------------- | ------------------ | -| 1 | firstEp | 是 | 是 | | -| 2 | secondEp | 是 | 是 | | -| 3 | fqdn | 是 | 是 | | -| 4 | serverPort | 是 | 是 | | -| 5 | maxShellConns | 是 | 是 | | -| 6 | monitor | 是 | 是 | | -| 7 | monitorFqdn | 否 | 是 | | -| 8 | monitorPort | 否 | 是 | | -| 9 | monitorInterval | 是 | 是 | | -| 10 | monitorMaxLogs | 否 | 是 | | -| 11 | monitorComp | 否 | 是 | | -| 12 | telemetryReporting | 是 | 是 | | -| 13 | telemetryInterval | 否 | 是 | | -| 14 | telemetryServer | 否 | 是 | | -| 15 | telemetryPort | 否 | 是 | | -| 16 | queryPolicy | 否 | 是 | | -| 17 | querySmaOptimize | 否 | 是 | | -| 18 | queryBufferSize | 是 | 是 | | -| 19 | maxNumOfDistinctRes | 是 | 是 | | -| 20 | minSlidingTime | 是 | 是 | | -| 21 | minIntervalTime | 是 | 是 | | -| 22 | countAlwaysReturnValue | 是 | 是 | | -| 23 | dataDir | 是 | 是 | | -| 24 | minimalDataDirGB | 是 | 是 | | -| 25 | supportVnodes | 否 | 是 | | -| 26 | tempDir | 是 | 是 | | -| 27 | minimalTmpDirGB | 是 | 是 | | -| 28 | compressMsgSize | 是 | 是 | | -| 29 | compressColData | 是 | 是 | | -| 30 | smlChildTableName | 是 | 是 | | -| 31 | smlTagName | 是 | 是 | | -| 32 | smlDataFormat | 否 | 是 | | -| 33 | statusInterval | 是 | 是 | | -| 34 | shellActivityTimer | 是 | 是 | | -| 35 | transPullupInterval | 否 | 是 | | -| 36 | mqRebalanceInterval | 否 | 是 | | -| 37 | ttlUnit | 否 | 是 | | -| 38 | ttlPushInterval | 否 | 是 | | -| 39 | numOfTaskQueueThreads | 否 | 是 | | -| 40 | numOfRpcThreads | 否 | 是 | | -| 41 | numOfCommitThreads | 是 | 是 | | -| 42 | numOfMnodeReadThreads | 否 | 是 | | -| 43 | numOfVnodeQueryThreads | 否 | 是 | | -| 44 | numOfVnodeStreamThreads | 否 | 是 | | -| 45 | numOfVnodeFetchThreads | 否 | 是 | | -| 46 | numOfVnodeWriteThreads | 否 | 是 | | -| 47 | numOfVnodeSyncThreads | 否 | 是 | | -| 48 | numOfVnodeRsmaThreads | 否 | 是 | | -| 49 | numOfQnodeQueryThreads | 否 | 是 | | -| 50 | numOfQnodeFetchThreads | 否 | 是 | | -| 51 | numOfSnodeSharedThreads | 否 | 是 | | -| 52 | numOfSnodeUniqueThreads | 否 | 是 | | -| 53 | rpcQueueMemoryAllowed | 否 | 是 | | -| 54 | logDir | 是 | 是 | | -| 55 | minimalLogDirGB | 是 | 是 | | -| 56 | numOfLogLines | 是 | 是 | | -| 57 | asyncLog | 是 | 是 | | -| 58 | logKeepDays | 是 | 是 | | -| 59 | debugFlag | 是 | 是 | | -| 60 | tmrDebugFlag | 是 | 是 | | -| 61 | uDebugFlag | 是 | 是 | | -| 62 | rpcDebugFlag | 是 | 是 | | -| 63 | jniDebugFlag | 是 | 是 | | -| 64 | qDebugFlag | 是 | 是 | | -| 65 | cDebugFlag | 是 | 是 | | -| 66 | dDebugFlag | 是 | 是 | | -| 67 | vDebugFlag | 是 | 是 | | -| 68 | mDebugFlag | 是 | 是 | | -| 69 | wDebugFlag | 是 | 是 | | -| 70 | sDebugFlag | 是 | 是 | | -| 71 | tsdbDebugFlag | 是 | 是 | | -| 72 | tqDebugFlag | 否 | 是 | | -| 73 | fsDebugFlag | 是 | 是 | | -| 74 | udfDebugFlag | 否 | 是 | | -| 75 | smaDebugFlag | 否 | 是 | | -| 76 | idxDebugFlag | 否 | 是 | | -| 77 | tdbDebugFlag | 否 | 是 | | -| 78 | metaDebugFlag | 否 | 是 | | -| 79 | timezone | 是 | 是 | | -| 80 | locale | 是 | 是 | | -| 81 | charset | 是 | 是 | | -| 82 | udf | 是 | 是 | | -| 83 | enableCoreFile | 是 | 是 | | -| 84 | arbitrator | 是 | 否 | 通过 RAFT 协议选主 | -| 85 | numOfThreadsPerCore | 是 | 否 | 有其它参数设置多种线程池的大小 | -| 86 | numOfMnodes | 是 | 否 | 通过 create mnode 命令动态创建 mnode | -| 87 | vnodeBak | 是 | 否 | 3.0 行为未知 | -| 88 | balance | 是 | 否 | 负载均衡功能由 split/merge vgroups 实现 | -| 89 | balanceInterval | 是 | 否 | 随着 balance 参数失效 | -| 90 | offlineThreshold | 是 | 否 | 3.0 行为未知 | -| 91 | role | 是 | 否 | 由 supportVnode 决定是否能够创建 | -| 92 | dnodeNopLoop | 是 | 否 | 2.6文档中未找到此参数 | -| 93 | keepTimeOffset | 是 | 否 | 2.6文档中未找到此参数 | -| 94 | rpcTimer | 是 | 否 | 3.0 行为未知 | -| 95 | rpcMaxTime | 是 | 否 | 3.0 行为未知 | -| 96 | rpcForceTcp | 是 | 否 | 默认为 TCP | -| 97 | tcpConnTimeout | 是 | 否 | 3.0 行为未知 | -| 98 | syncCheckInterval | 是 | 否 | 3.0 行为未知 | -| 99 | maxTmrCtrl | 是 | 否 | 3.0 行为未知 | -| 100 | monitorReplica | 是 | 否 | 由 RAFT 协议管理多副本 | -| 101 | smlTagNullName | 是 | 否 | 3.0 行为未知 | -| 102 | keepColumnName | 是 | 否 | 3.0 行为未知 | -| 103 | ratioOfQueryCores | 是 | 否 | 由 线程池 相关配置参数决定 | -| 104 | maxStreamCompDelay | 是 | 否 | 3.0 行为未知 | -| 105 | maxFirstStreamCompDelay | 是 | 否 | 3.0 行为未知 | -| 106 | retryStreamCompDelay | 是 | 否 | 3.0 行为未知 | -| 107 | streamCompDelayRatio | 是 | 否 | 3.0 行为未知 | -| 108 | maxVgroupsPerDb | 是 | 否 | 由 create db 的参数 vgroups 指定实际 vgroups 数量 | -| 109 | maxTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | -| 110 | minTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | -| 111 | tableIncStepPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | -| 112 | cache | 是 | 否 | 由 buffer 代替 cache*blocks | -| 113 | blocks | 是 | 否 | 由 buffer 代替 cache*blocks | -| 114 | days | 是 | 否 | 由 create db 的参数 duration 取代 | -| 115 | keep | 是 | 否 | 由 create db 的参数 keep 取代 | +| # | **参数** | **适用于 2.X ** | **适用于 3.0 ** | 3.0 版本的当前行为 | +| --- | :---------------------: | --------------- | --------------- | ------------------------------------------------- | +| 1 | firstEp | 是 | 是 | | +| 2 | secondEp | 是 | 是 | | +| 3 | fqdn | 是 | 是 | | +| 4 | serverPort | 是 | 是 | | +| 5 | maxShellConns | 是 | 是 | | +| 6 | monitor | 是 | 是 | | +| 7 | monitorFqdn | 否 | 是 | | +| 8 | monitorPort | 否 | 是 | | +| 9 | monitorInterval | 是 | 是 | | +| 10 | monitorMaxLogs | 否 | 是 | | +| 11 | monitorComp | 否 | 是 | | +| 12 | telemetryReporting | 是 | 是 | | +| 13 | telemetryInterval | 否 | 是 | | +| 14 | telemetryServer | 否 | 是 | | +| 15 | telemetryPort | 否 | 是 | | +| 16 | queryPolicy | 否 | 是 | | +| 17 | querySmaOptimize | 否 | 是 | | +| 18 | queryBufferSize | 是 | 是 | | +| 19 | maxNumOfDistinctRes | 是 | 是 | | +| 20 | minSlidingTime | 是 | 是 | | +| 21 | minIntervalTime | 是 | 是 | | +| 22 | countAlwaysReturnValue | 是 | 是 | | +| 23 | dataDir | 是 | 是 | | +| 24 | minimalDataDirGB | 是 | 是 | | +| 25 | supportVnodes | 否 | 是 | | +| 26 | tempDir | 是 | 是 | | +| 27 | minimalTmpDirGB | 是 | 是 | | +| 28 | compressMsgSize | 是 | 是 | | +| 29 | compressColData | 是 | 是 | | +| 30 | smlChildTableName | 是 | 是 | | +| 31 | smlTagName | 是 | 是 | | +| 32 | smlDataFormat | 否 | 是 | | +| 33 | statusInterval | 是 | 是 | | +| 34 | shellActivityTimer | 是 | 是 | | +| 35 | transPullupInterval | 否 | 是 | | +| 36 | mqRebalanceInterval | 否 | 是 | | +| 37 | ttlUnit | 否 | 是 | | +| 38 | ttlPushInterval | 否 | 是 | | +| 39 | numOfTaskQueueThreads | 否 | 是 | | +| 40 | numOfRpcThreads | 否 | 是 | | +| 41 | numOfCommitThreads | 是 | 是 | | +| 42 | numOfMnodeReadThreads | 否 | 是 | | +| 43 | numOfVnodeQueryThreads | 否 | 是 | | +| 44 | numOfVnodeStreamThreads | 否 | 是 | | +| 45 | numOfVnodeFetchThreads | 否 | 是 | | +| 46 | numOfVnodeWriteThreads | 否 | 是 | | +| 47 | numOfVnodeSyncThreads | 否 | 是 | | +| 48 | numOfVnodeRsmaThreads | 否 | 是 | | +| 49 | numOfQnodeQueryThreads | 否 | 是 | | +| 50 | numOfQnodeFetchThreads | 否 | 是 | | +| 51 | numOfSnodeSharedThreads | 否 | 是 | | +| 52 | numOfSnodeUniqueThreads | 否 | 是 | | +| 53 | rpcQueueMemoryAllowed | 否 | 是 | | +| 54 | logDir | 是 | 是 | | +| 55 | minimalLogDirGB | 是 | 是 | | +| 56 | numOfLogLines | 是 | 是 | | +| 57 | asyncLog | 是 | 是 | | +| 58 | logKeepDays | 是 | 是 | | +| 59 | debugFlag | 是 | 是 | | +| 60 | tmrDebugFlag | 是 | 是 | | +| 61 | uDebugFlag | 是 | 是 | | +| 62 | rpcDebugFlag | 是 | 是 | | +| 63 | jniDebugFlag | 是 | 是 | | +| 64 | qDebugFlag | 是 | 是 | | +| 65 | cDebugFlag | 是 | 是 | | +| 66 | dDebugFlag | 是 | 是 | | +| 67 | vDebugFlag | 是 | 是 | | +| 68 | mDebugFlag | 是 | 是 | | +| 69 | wDebugFlag | 是 | 是 | | +| 70 | sDebugFlag | 是 | 是 | | +| 71 | tsdbDebugFlag | 是 | 是 | | +| 72 | tqDebugFlag | 否 | 是 | | +| 73 | fsDebugFlag | 是 | 是 | | +| 74 | udfDebugFlag | 否 | 是 | | +| 75 | smaDebugFlag | 否 | 是 | | +| 76 | idxDebugFlag | 否 | 是 | | +| 77 | tdbDebugFlag | 否 | 是 | | +| 78 | metaDebugFlag | 否 | 是 | | +| 79 | timezone | 是 | 是 | | +| 80 | locale | 是 | 是 | | +| 81 | charset | 是 | 是 | | +| 82 | udf | 是 | 是 | | +| 83 | enableCoreFile | 是 | 是 | | +| 84 | arbitrator | 是 | 否 | 通过 RAFT 协议选主 | +| 85 | numOfThreadsPerCore | 是 | 否 | 有其它参数设置多种线程池的大小 | +| 86 | numOfMnodes | 是 | 否 | 通过 create mnode 命令动态创建 mnode | +| 87 | vnodeBak | 是 | 否 | 3.0 行为未知 | +| 88 | balance | 是 | 否 | 负载均衡功能由 split/merge vgroups 实现 | +| 89 | balanceInterval | 是 | 否 | 随着 balance 参数失效 | +| 90 | offlineThreshold | 是 | 否 | 3.0 行为未知 | +| 91 | role | 是 | 否 | 由 supportVnode 决定是否能够创建 | +| 92 | dnodeNopLoop | 是 | 否 | 2.6 文档中未找到此参数 | +| 93 | keepTimeOffset | 是 | 否 | 2.6 文档中未找到此参数 | +| 94 | rpcTimer | 是 | 否 | 3.0 行为未知 | +| 95 | rpcMaxTime | 是 | 否 | 3.0 行为未知 | +| 96 | rpcForceTcp | 是 | 否 | 默认为 TCP | +| 97 | tcpConnTimeout | 是 | 否 | 3.0 行为未知 | +| 98 | syncCheckInterval | 是 | 否 | 3.0 行为未知 | +| 99 | maxTmrCtrl | 是 | 否 | 3.0 行为未知 | +| 100 | monitorReplica | 是 | 否 | 由 RAFT 协议管理多副本 | +| 101 | smlTagNullName | 是 | 否 | 3.0 行为未知 | +| 102 | keepColumnName | 是 | 否 | 3.0 行为未知 | +| 103 | ratioOfQueryCores | 是 | 否 | 由 线程池 相关配置参数决定 | +| 104 | maxStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 105 | maxFirstStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 106 | retryStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 107 | streamCompDelayRatio | 是 | 否 | 3.0 行为未知 | +| 108 | maxVgroupsPerDb | 是 | 否 | 由 create db 的参数 vgroups 指定实际 vgroups 数量 | +| 109 | maxTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 110 | minTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 111 | tableIncStepPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 112 | cache | 是 | 否 | 由 buffer 代替 cache\*blocks | +| 113 | blocks | 是 | 否 | 由 buffer 代替 cache\*blocks | +| 114 | days | 是 | 否 | 由 create db 的参数 duration 取代 | +| 115 | keep | 是 | 否 | 由 create db 的参数 keep 取代 | | 116 | minRows | 是 | 否 | 由 create db 的参数 minRows 取代 | -| 117 | maxRows | 是 | 否 | 由 create db 的参数 maxRows 取代 | -| 118 | quorum | 是 | 否 | 由 RAFT 协议决定 | -| 119 | comp | 是 | 否 | 由 create db 的参数 comp 取代 | -| 120 | walLevel | 是 | 否 | 由 create db 的参数 wal_level 取代 | -| 121 | fsync | 是 | 否 | 由 create db 的参数 wal_fsync_period 取代 | -| 122 | replica | 是 | 否 | 由 create db 的参数 replica 取代 | -| 123 | partitions | 是 | 否 | 3.0 行为未知 | -| 125 | update | 是 | 否 | 允许更新部分列 | -| 126 | cachelast | 是 | 否 | 由 create db 的参数 cacheModel 取代 | -| 127 | maxSQLLength | 是 | 否 | SQL 上限为 1MB,无需参数控制 | -| 128 | maxWildCardsLength | 是 | 否 | 3.0 行为未知 | -| 129 | maxRegexStringLen | 是 | 否 | 3.0 行为未知 | -| 130 | maxNumOfOrderedRes | 是 | 否 | 3.0 行为未知 | -| 131 | maxConnections | 是 | 否 | 取决于系统配置和系统处理能力,详见后面的 Note | -| 132 | mnodeEqualVnodeNum | 是 | 否 | 3.0 行为未知 | -| 133 | http | 是 | 否 | http 服务由 taosAdapter 提供 | -| 134 | httpEnableRecordSql | 是 | 否 | taosd 不提供 http 服务 | -| 135 | httpMaxThreads | 是 | 否 | taosd 不提供 http 服务 | -| 136 | restfulRowLimit | 是 | 否 | taosd 不提供 http 服务 | -| 137 | httpDbNameMandatory | 是 | 否 | taosd 不提供 http 服务 | -| 138 | httpKeepAlive | 是 | 否 | taosd 不提供 http 服务 | -| 139 | enableRecordSql | 是 | 否 | 3.0 行为未知 | -| 140 | maxBinaryDisplayWidth | 是 | 否 | 3.0 行为未知 | -| 141 | stream | 是 | 否 | 默认启用连续查询 | -| 142 | retrieveBlockingModel | 是 | 否 | 3.0 行为未知 | -| 143 | tsdbMetaCompactRatio | 是 | 否 | 3.0 行为未知 | -| 144 | defaultJSONStrType | 是 | 否 | 3.0 行为未知 | -| 145 | walFlushSize | 是 | 否 | 3.0 行为未知 | -| 146 | keepTimeOffset | 是 | 否 | 3.0 行为未知 | -| 147 | flowctrl | 是 | 否 | 3.0 行为未知 | -| 148 | slaveQuery | 是 | 否 | 3.0 行为未知: slave vnode 是否能够处理查询? | -| 149 | adjustMaster | 是 | 否 | 3.0 行为未知 | -| 150 | topicBinaryLen | 是 | 否 | 3.0 行为未知 | -| 151 | telegrafUseFieldNum | 是 | 否 | 3.0 行为未知 | -| 152 | deadLockKillQuery | 是 | 否 | 3.0 行为未知 | -| 153 | clientMerge | 是 | 否 | 3.0 行为未知 | -| 154 | sdbDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | -| 155 | odbcDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | -| 156 | httpDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | -| 157 | monDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | -| 158 | cqDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | -| 159 | shortcutFlag | 是 | 否 | 参考 3.0 的 DebugFlag系列参数 | -| 160 | probeSeconds | 是 | 否 | 3.0 行为未知 | -| 161 | probeKillSeconds | 是 | 否 | 3.0 行为未知 | -| 162 | probeInterval | 是 | 否 | 3.0 行为未知 | -| 163 | lossyColumns | 是 | 否 | 3.0 行为未知 | -| 164 | fPrecision | 是 | 否 | 3.0 行为未知 | -| 165 | dPrecision | 是 | 否 | 3.0 行为未知 | -| 166 | maxRange | 是 | 否 | 3.0 行为未知 | -| 167 | range | 是 | 否 | 3.0 行为未知 | +| 117 | maxRows | 是 | 否 | 由 create db 的参数 maxRows 取代 | +| 118 | quorum | 是 | 否 | 由 RAFT 协议决定 | +| 119 | comp | 是 | 否 | 由 create db 的参数 comp 取代 | +| 120 | walLevel | 是 | 否 | 由 create db 的参数 wal_level 取代 | +| 121 | fsync | 是 | 否 | 由 create db 的参数 wal_fsync_period 取代 | +| 122 | replica | 是 | 否 | 由 create db 的参数 replica 取代 | +| 123 | partitions | 是 | 否 | 3.0 行为未知 | +| 125 | update | 是 | 否 | 允许更新部分列 | +| 126 | cachelast | 是 | 否 | 由 create db 的参数 cacheModel 取代 | +| 127 | maxSQLLength | 是 | 否 | SQL 上限为 1MB,无需参数控制 | +| 128 | maxWildCardsLength | 是 | 否 | 3.0 行为未知 | +| 129 | maxRegexStringLen | 是 | 否 | 3.0 行为未知 | +| 130 | maxNumOfOrderedRes | 是 | 否 | 3.0 行为未知 | +| 131 | maxConnections | 是 | 否 | 取决于系统配置和系统处理能力,详见后面的 Note | +| 132 | mnodeEqualVnodeNum | 是 | 否 | 3.0 行为未知 | +| 133 | http | 是 | 否 | http 服务由 taosAdapter 提供 | +| 134 | httpEnableRecordSql | 是 | 否 | taosd 不提供 http 服务 | +| 135 | httpMaxThreads | 是 | 否 | taosd 不提供 http 服务 | +| 136 | restfulRowLimit | 是 | 否 | taosd 不提供 http 服务 | +| 137 | httpDbNameMandatory | 是 | 否 | taosd 不提供 http 服务 | +| 138 | httpKeepAlive | 是 | 否 | taosd 不提供 http 服务 | +| 139 | enableRecordSql | 是 | 否 | 3.0 行为未知 | +| 140 | maxBinaryDisplayWidth | 是 | 否 | 3.0 行为未知 | +| 141 | stream | 是 | 否 | 默认启用连续查询 | +| 142 | retrieveBlockingModel | 是 | 否 | 3.0 行为未知 | +| 143 | tsdbMetaCompactRatio | 是 | 否 | 3.0 行为未知 | +| 144 | defaultJSONStrType | 是 | 否 | 3.0 行为未知 | +| 145 | walFlushSize | 是 | 否 | 3.0 行为未知 | +| 146 | keepTimeOffset | 是 | 否 | 3.0 行为未知 | +| 147 | flowctrl | 是 | 否 | 3.0 行为未知 | +| 148 | slaveQuery | 是 | 否 | 3.0 行为未知: slave vnode 是否能够处理查询? | +| 149 | adjustMaster | 是 | 否 | 3.0 行为未知 | +| 150 | topicBinaryLen | 是 | 否 | 3.0 行为未知 | +| 151 | telegrafUseFieldNum | 是 | 否 | 3.0 行为未知 | +| 152 | deadLockKillQuery | 是 | 否 | 3.0 行为未知 | +| 153 | clientMerge | 是 | 否 | 3.0 行为未知 | +| 154 | sdbDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag 系列参数 | +| 155 | odbcDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag 系列参数 | +| 156 | httpDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag 系列参数 | +| 157 | monDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag 系列参数 | +| 158 | cqDebugFlag | 是 | 否 | 参考 3.0 的 DebugFlag 系列参数 | +| 159 | shortcutFlag | 是 | 否 | 参考 3.0 的 DebugFlag 系列参数 | +| 160 | probeSeconds | 是 | 否 | 3.0 行为未知 | +| 161 | probeKillSeconds | 是 | 否 | 3.0 行为未知 | +| 162 | probeInterval | 是 | 否 | 3.0 行为未知 | +| 163 | lossyColumns | 是 | 否 | 3.0 行为未知 | +| 164 | fPrecision | 是 | 否 | 3.0 行为未知 | +| 165 | dPrecision | 是 | 否 | 3.0 行为未知 | +| 166 | maxRange | 是 | 否 | 3.0 行为未知 | +| 167 | range | 是 | 否 | 3.0 行为未知 | From 564fd60bd9a805d534dd140e63513f44edfbfe77 Mon Sep 17 00:00:00 2001 From: Huo Linhe Date: Fri, 2 Sep 2022 14:47:37 +0800 Subject: [PATCH 03/72] test: build taosx and add test case of taosx Close [TD-18849](https://jira.taosdata.com:18080/browse/TD-18849) --- tests/docs-examples-test/taosx.sh | 18 ++++++++++++++++++ tests/parallel_test/container_build.sh | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/docs-examples-test/taosx.sh diff --git a/tests/docs-examples-test/taosx.sh b/tests/docs-examples-test/taosx.sh new file mode 100644 index 0000000000..5db2605bfd --- /dev/null +++ b/tests/docs-examples-test/taosx.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +taosd >>/dev/null 2>&1 & +taosadapter >>/dev/null 2>&1 & +sleep 5 + +taosBenchmark -y -n 10000 -t 1000 + +taosx run -f 'tmq:///test' -t 'taos:///test1' -y + +taos -s 'select count(*) from test1.meters' |grep 10000000 || (echo database sync failed!; exit 1) + +taosx run -f 'tmq:///test' -t 'local:./test-backup' -y +taosx run -f 'local:./test-backup' -t 'taos:///test2' -y + +rm -rf ./test-backup diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh index deaea4fa40..e88982aa80 100755 --- a/tests/parallel_test/container_build.sh +++ b/tests/parallel_test/container_build.sh @@ -52,7 +52,7 @@ fi docker run \ -v $REP_MOUNT_PARAM \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DWEBSOCKET=true;make -j $THREAD_COUNT" + --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DWEBSOCKET=true -DBUILD_TAOSX=true;make -j $THREAD_COUNT" ret=$? exit $ret From c401bf7ac13b142a088645a60f8dc0459d663d70 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Fri, 21 Oct 2022 15:02:58 +0800 Subject: [PATCH 04/72] test: modify timeout for tmq poll --- tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py | 6 +++--- tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py | 6 +++--- tests/system-test/7-tmq/tmqUdf.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py index 65515c4822..f70c6ad49b 100644 --- a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py +++ b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py @@ -104,7 +104,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} @@ -149,7 +149,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} @@ -251,7 +251,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} diff --git a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py index 1c999b86c7..58cdc775ee 100644 --- a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py +++ b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py @@ -104,7 +104,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} @@ -149,7 +149,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} @@ -251,7 +251,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} diff --git a/tests/system-test/7-tmq/tmqUdf.py b/tests/system-test/7-tmq/tmqUdf.py index 6e1843404e..5eac0ae69d 100644 --- a/tests/system-test/7-tmq/tmqUdf.py +++ b/tests/system-test/7-tmq/tmqUdf.py @@ -104,7 +104,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} @@ -149,7 +149,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} @@ -252,7 +252,7 @@ class TDTestCase: 'rowsPerTbl': 1000, 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 - 'pollDelay': 3, + 'pollDelay': 10, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} From 39c800da80593aa5f17d3c11754e1f130da5cbb8 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sat, 22 Oct 2022 15:41:37 +0800 Subject: [PATCH 05/72] fix(all): fixed coverity scan problems for second submiting --- source/os/src/osFile.c | 2 +- source/util/src/tcompression.c | 3 +++ source/util/src/tdigest.c | 2 +- source/util/src/tencode.c | 4 +++- source/util/src/tenv.c | 2 +- source/util/src/thash.c | 2 +- source/util/src/tlog.c | 5 ++++- source/util/src/tlrucache.c | 2 ++ source/util/src/tpagedbuf.c | 4 +++- tools/shell/src/shellAuto.c | 7 +++++-- tools/shell/src/shellTire.c | 17 +++++++---------- 11 files changed, 31 insertions(+), 19 deletions(-) diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index be862308f1..cea4d6882e 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -191,7 +191,7 @@ int32_t taosRenameFile(const char *oldName, const char *newName) { printf("failed to rename file %s to %s, reason:%s\n", oldName, newName, strerror(errno)); } - return !code; + return code ? 0 : 1; #else int32_t code = rename(oldName, newName); if (code < 0) { diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index be220c2585..fbbe970c74 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -2274,6 +2274,9 @@ int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t return tsCompressBoolImp(pIn, nEle, pOut); } else if (cmprAlg == TWO_STAGE_COMP) { int32_t len = tsCompressBoolImp(pIn, nEle, pBuf); + if (len < 0) { + return -1; + } return tsCompressStringImp(pBuf, len, pOut, nOut); } else { assert(0); diff --git a/source/util/src/tdigest.c b/source/util/src/tdigest.c index 067580708e..1b9edf79a0 100644 --- a/source/util/src/tdigest.c +++ b/source/util/src/tdigest.c @@ -263,7 +263,7 @@ double tdigestQuantile(TDigest *t, double q) { b = c; right = (b->weight * a->mean + a->weight * b->mean) / (a->weight + b->weight); if (idx < weight_so_far + a->weight) { - double p = (idx - weight_so_far) / a->weight; + double p = (idx - weight_so_far) / (a->weight == 0) ? 1 : a->weight; return left * (1 - p) + right * p; } weight_so_far += a->weight; diff --git a/source/util/src/tencode.c b/source/util/src/tencode.c index 2267c90783..a925d1fc5e 100644 --- a/source/util/src/tencode.c +++ b/source/util/src/tencode.c @@ -109,7 +109,9 @@ void tEndEncode(SEncoder* pCoder) { pCoder->size = pNode->size; pCoder->pos = pNode->pos; - tEncodeI32(pCoder, len); + if (tEncodeI32(pCoder, len) < 0) { + return; + } TD_CODER_MOVE_POS(pCoder, len); } diff --git a/source/util/src/tenv.c b/source/util/src/tenv.c index 027918f2c6..7fe079ada4 100644 --- a/source/util/src/tenv.c +++ b/source/util/src/tenv.c @@ -54,7 +54,7 @@ int32_t taosEnvNameToCfgName(const char *envNameStr, char *cfgNameStr, int32_t c } int32_t taosEnvToCfg(const char *envStr, char *cfgStr) { - if (envStr == NULL && cfgStr == NULL) { + if (envStr == NULL || cfgStr == NULL) { return -1; } if (cfgStr != envStr) strcpy(cfgStr, envStr); diff --git a/source/util/src/thash.c b/source/util/src/thash.c index e7b2d9638f..eb20024ff9 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -639,7 +639,7 @@ void taosHashTableResize(SHashObj *pHashObj) { } int64_t st = taosGetTimestampUs(); - void *pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(void *) * newCapacity); + SHashEntry **pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(SHashEntry *) * newCapacity); if (pNewEntryList == NULL) { // uDebug("cache resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity); return; diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 9d97cf7ab2..09d12029bc 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -207,7 +207,10 @@ static void taosKeepOldLog(char *oldName) { char fileName[LOG_FILE_NAME_LEN + 20]; snprintf(fileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64, tsLogObj.logName, fileSec); - taosRenameFile(oldName, fileName); + if (taosRenameFile(oldName, fileName) != 0) { + return; + } + if (tsLogKeepDays < 0) { char compressFileName[LOG_FILE_NAME_LEN + 20]; snprintf(compressFileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64 ".gz", tsLogObj.logName, fileSec); diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index 83cfbb2ad1..0ea7258828 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -337,6 +337,7 @@ static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool st taosThreadMutexInit(&shard->mutex, NULL); + taosThreadMutexLock(&shard->mutex); shard->capacity = 0; shard->highPriPoolUsage = 0; shard->strictCapacity = strict; @@ -349,6 +350,7 @@ static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool st shard->lru.next = &shard->lru; shard->lru.prev = &shard->lru; shard->lruLowPri = &shard->lru; + taosThreadMutexUnlock(&shard->mutex); taosLRUCacheShardSetCapacity(shard, capacity); diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index 94d90104aa..c81888eb95 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -534,7 +534,9 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { } } - taosRemoveFile(pBuf->path); + if (taosRemoveFile(pBuf->path) < 0) { + uDebug("WARNING tPage remove file failed. path=%s", pBuf->path); + } taosMemoryFreeClear(pBuf->path); size_t n = taosArrayGetSize(pBuf->pIdList); diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index e7dfd45c60..534ecf3c4d 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -564,6 +564,7 @@ void parseCommand(SWords* command, bool pattern) { // free SShellCmd void freeCommand(SWords* command) { SWord* item = command->head; + command->head = NULL; // loop while (item) { SWord* tmp = item; @@ -815,7 +816,9 @@ char* matchNextPrefix(STire* tire, char* pre) { match = enumAll(tire); } else { // NOT EMPTY - match = matchPrefix(tire, pre, NULL); + match = (SMatch*)taosMemoryMalloc(sizeof(SMatch)); + memset(match, 0, sizeof(SMatch)); + matchPrefix(tire, pre, match); } // save to lastMatch @@ -828,7 +831,7 @@ char* matchNextPrefix(STire* tire, char* pre) { // check valid if (match == NULL || match->head == NULL) { // no one matched - return false; + return NULL; } if (cursorVar == -1) { diff --git a/tools/shell/src/shellTire.c b/tools/shell/src/shellTire.c index 0628570904..25defbf9a8 100644 --- a/tools/shell/src/shellTire.c +++ b/tools/shell/src/shellTire.c @@ -308,25 +308,21 @@ void matchPrefixFromTree(STire* tire, char* prefix, SMatch* match) { } } -SMatch* matchPrefix(STire* tire, char* prefix, SMatch* match) { - SMatch* rMatch = match; // define return match - if (rMatch == NULL) { - rMatch = (SMatch*)taosMemoryMalloc(sizeof(SMatch)); - memset(rMatch, 0, sizeof(SMatch)); +void matchPrefix(STire* tire, char* prefix, SMatch* match) { + if (match == NULL) { + return; } switch (tire->type) { case TIRE_TREE: - matchPrefixFromTree(tire, prefix, rMatch); + matchPrefixFromTree(tire, prefix, match); break; case TIRE_LIST: - matchPrefixFromList(tire, prefix, rMatch); + matchPrefixFromList(tire, prefix, match); break; default: break; } - - return rMatch; } // get all items from tires tree @@ -362,8 +358,9 @@ void enumFromTree(STire* tire, SMatch* match) { // this branch have data if (c->end) addWordToMatch(match, pre); - else + else { matchPrefix(tire, pre, match); + } } } From 699b573b6f6130a792ebf08a78b368b882dd9376 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Sat, 22 Oct 2022 16:22:24 +0800 Subject: [PATCH 06/72] fix(all): fixed coverity scan problems for second submiting1 --- tools/shell/inc/shellTire.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/shell/inc/shellTire.h b/tools/shell/inc/shellTire.h index b262aa68d8..bdcf7bcfb3 100644 --- a/tools/shell/inc/shellTire.h +++ b/tools/shell/inc/shellTire.h @@ -78,7 +78,7 @@ bool insertWord(STire* tire, char* word); bool deleteWord(STire* tire, char* word); // match prefix words, if match is not NULL , put all item to match and return match -SMatch* matchPrefix(STire* tire, char* prefix, SMatch* match); +void matchPrefix(STire* tire, char* prefix, SMatch* match); // get all items from tires tree SMatch* enumAll(STire* tire); From 020b71515a171cf190cda419062ddc2839afe7d6 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 24 Oct 2022 09:09:45 +0800 Subject: [PATCH 07/72] fix: coverity scan --- source/dnode/vnode/src/meta/metaTable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index b6c4b35d9b..dfa23602e8 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -731,7 +731,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl SSchemaWrapper *pSchema; int c; - if (pAlterTbReq->colName == NULL) { + if (pAlterTbReq->colName == NULL || pAlterTbReq->colNewName == NULL) { terrno = TSDB_CODE_INVALID_MSG; return -1; } From 11f153cf1a8bb1dc784d178c9bc3321bdb6ff1bc Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Mon, 24 Oct 2022 09:18:35 +0800 Subject: [PATCH 08/72] fix(client): memory leak --- include/common/tmsg.h | 30 +++++++++++++++--------------- source/client/src/clientTmq.c | 3 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index c58cc3c7c5..a0f78d0d59 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1234,20 +1234,20 @@ int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq); typedef struct { - int32_t vgVersion; - int32_t buffer; - int32_t pageSize; - int32_t pages; - int32_t cacheLastSize; - int32_t daysPerFile; - int32_t daysToKeep0; - int32_t daysToKeep1; - int32_t daysToKeep2; - int32_t walFsyncPeriod; - int8_t walLevel; - int8_t strict; - int8_t cacheLast; - int64_t reserved[8]; + int32_t vgVersion; + int32_t buffer; + int32_t pageSize; + int32_t pages; + int32_t cacheLastSize; + int32_t daysPerFile; + int32_t daysToKeep0; + int32_t daysToKeep1; + int32_t daysToKeep2; + int32_t walFsyncPeriod; + int8_t walLevel; + int8_t strict; + int8_t cacheLast; + int64_t reserved[8]; } SAlterVnodeConfigReq; int32_t tSerializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq); @@ -3065,7 +3065,7 @@ static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) { } static FORCE_INLINE void tDeleteSMqAskEpRsp(SMqAskEpRsp* pRsp) { - taosArrayDestroyEx(pRsp->topics, (void (*)(void*))tDeleteSMqSubTopicEp); + taosArrayDestroyEx(pRsp->topics, (FDelete)tDeleteSMqSubTopicEp); } #define TD_AUTO_CREATE_TABLE 0x1 diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 0b7b80649e..6e3e274052 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -1206,7 +1206,7 @@ CREATE_MSG_FAIL: return -1; } -bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqAskEpRsp* pRsp) { +bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { bool set = false; int32_t topicNumGet = taosArrayGetSize(pRsp->topics); @@ -1599,6 +1599,7 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset) SMqAskEpRsp* rspMsg = &pEpRspWrapper->msg; tmqUpdateEp(tmq, rspWrapper->epoch, rspMsg); /*tmqClearUnhandleMsg(tmq);*/ + tDeleteSMqAskEpRsp(rspMsg); *pReset = true; } else { *pReset = false; From 2a214e3d25ed2be3c5a2bbfd760d858cf5d7552a Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Mon, 24 Oct 2022 09:30:59 +0800 Subject: [PATCH 09/72] fix:error in schemaless if error happens --- source/client/src/clientSml.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 2c48eae59f..5b8266b1cb 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -2394,7 +2394,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char* rawLine, char code = smlParseJSON(info, rawLine); } if (code != TSDB_CODE_SUCCESS) { - uError("SML:0x%" PRIx64 " smlParseJSON failed:%s", info->id, *lines); + uError("SML:0x%" PRIx64 " smlParseJSON failed:%s", info->id, lines?*lines:rawLine); return code; } return code; From 81be17458de9f814468bc3fcc47e603cb1505882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chappyguoxy=E2=80=9D?= <“happy_guoxy@163.com”> Date: Mon, 24 Oct 2022 09:44:33 +0800 Subject: [PATCH 10/72] test: refine query cases --- tests/system-test/2-query/timetruncate.py | 27 ++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/system-test/2-query/timetruncate.py b/tests/system-test/2-query/timetruncate.py index d773114c3c..8d1c9214e9 100644 --- a/tests/system-test/2-query/timetruncate.py +++ b/tests/system-test/2-query/timetruncate.py @@ -10,6 +10,9 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) + print(conn) + self.rest_tag = str(conn).lower().split('.')[0].replace(" Date: Mon, 24 Oct 2022 09:44:46 +0800 Subject: [PATCH 11/72] test: refine query cases --- tests/system-test/2-query/Today.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/system-test/2-query/Today.py b/tests/system-test/2-query/Today.py index 6887e73970..0124c5bbac 100644 --- a/tests/system-test/2-query/Today.py +++ b/tests/system-test/2-query/Today.py @@ -43,7 +43,13 @@ class TDTestCase: f'today(),3,3.333,333.333333,now()', f'today()-1d,10,11.11,99.999999,now()', f'today()+1d,1,1.55,100.555555,today()'] - self.db_percision = ['ms','us','ns'] + + self.rest_tag = str(conn).lower().split('.')[0].replace(" Date: Mon, 24 Oct 2022 09:58:19 +0800 Subject: [PATCH 12/72] fix(all): fixed coverity problem --- source/util/src/tdigest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/util/src/tdigest.c b/source/util/src/tdigest.c index 1b9edf79a0..dc2a943de9 100644 --- a/source/util/src/tdigest.c +++ b/source/util/src/tdigest.c @@ -263,7 +263,7 @@ double tdigestQuantile(TDigest *t, double q) { b = c; right = (b->weight * a->mean + a->weight * b->mean) / (a->weight + b->weight); if (idx < weight_so_far + a->weight) { - double p = (idx - weight_so_far) / (a->weight == 0) ? 1 : a->weight; + double p = (idx - weight_so_far) / ((a->weight == 0) ? 1 : a->weight); return left * (1 - p) + right * p; } weight_so_far += a->weight; From bbb0475d69d68ad2de14625e1406f3abb999dc73 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 24 Oct 2022 10:05:57 +0800 Subject: [PATCH 13/72] fix: alter replica one by one --- source/dnode/mnode/impl/src/mndVgroup.c | 3 ++- tests/script/tsim/db/alter_replica_13.sim | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index f46fc5d23e..9bd89c1983 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1586,10 +1586,11 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1; if (mndAddVnodeToVgroup(pMnode, &newVgroup, pArray) != 0) return -1; if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[1]) != 0) return -1; - if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1; if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; + if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1; + if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; } else if (newVgroup.replica == 3 && pNewDb->cfg.replications == 1) { mInfo("db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d", pVgroup->dbName, pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId, pVgroup->vnodeGid[1].dnodeId, pVgroup->vnodeGid[2].dnodeId); diff --git a/tests/script/tsim/db/alter_replica_13.sim b/tests/script/tsim/db/alter_replica_13.sim index db64d4ede3..ab4f349002 100644 --- a/tests/script/tsim/db/alter_replica_13.sim +++ b/tests/script/tsim/db/alter_replica_13.sim @@ -127,8 +127,27 @@ if $data[0][8] != follower then goto step4 endi -print ============= step5: stop dnode 2 +print ============= step5: result +$i = 0 +while $i < 1000 + $i = $i + 1 + sleep 1000 + sql show db.vgroups + print ===> loop: $i | v0: $data03 $data04 | v1: $data05 $data06 | v2: $data07 $data08 + if $data[0][4] != leader then + return -1 + endi + if $data[0][6] != follower then + return -1 + endi + if $data[0][8] != follower then + return -1 + endi +endw + + +print ============= step5: stop dnode 2 sql select * from db.stb if $rows != 1 then return -1 From bac0f359ee6e38783a3d5b934609b474cf25f319 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 24 Oct 2022 10:31:49 +0800 Subject: [PATCH 14/72] fix sys idx bug --- source/libs/executor/src/executil.c | 6 +-- source/libs/executor/src/scanoperator.c | 18 ++++++- tests/script/tsim/stable/metrics_idx.sim | 65 ++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 tests/script/tsim/stable/metrics_idx.sim diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index afec5896cd..11d6665614 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -122,7 +122,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in if (order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC) { __compar_fn_t fn = (order == TSDB_ORDER_ASC) ? resultrowComparAsc : resultrowComparDesc; - int32_t size = POINTER_BYTES; + int32_t size = POINTER_BYTES; taosSort(pGroupResInfo->pRows->pData, taosArrayGetSize(pGroupResInfo->pRows), size, fn); } @@ -752,8 +752,8 @@ end: } static int tableUidCompare(const void* a, const void* b) { - uint64_t u1 = *(uint64_t*)a; - uint64_t u2 = *(uint64_t*)b; + int64_t u1 = *(uint64_t*)a; + int64_t u2 = *(uint64_t*)b; if (u1 == u2) { return 0; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 115a6ab559..b782313688 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -3191,12 +3191,24 @@ static int32_t optSysCheckOper(SNode* pOpear) { } return 0; } + +static int tableUidCompare(const void* a, const void* b) { + int64_t u1 = *(int64_t*)a; + int64_t u2 = *(int64_t*)b; + if (u1 == u2) { + return 0; + } + return u1 < u2 ? -1 : 1; +} static int32_t optSysMergeRslt(SArray* mRslt, SArray* rslt) { // TODO, find comm mem from mRslt for (int i = 0; i < taosArrayGetSize(mRslt); i++) { SArray* aRslt = taosArrayGetP(mRslt, i); taosArrayAddAll(rslt, aRslt); } + taosArraySort(rslt, tableUidCompare); + taosArrayRemoveDuplicate(rslt, tableUidCompare, NULL); + return 0; } @@ -3455,7 +3467,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) { if (i >= taosArrayGetSize(pIdx->uids)) { doSetOperatorCompleted(pOperator); } else { - pIdx->lastIdx = i; + pIdx->lastIdx = i + 1; } blockDataDestroy(p); @@ -3464,7 +3476,9 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) { return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes; } static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) { - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + + qError("%p buildUserTable", pTaskInfo); SSysTableScanInfo* pInfo = pOperator->info; if (pInfo->pCur == NULL) { pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta); diff --git a/tests/script/tsim/stable/metrics_idx.sim b/tests/script/tsim/stable/metrics_idx.sim new file mode 100644 index 0000000000..844d41f3a8 --- /dev/null +++ b/tests/script/tsim/stable/metrics_idx.sim @@ -0,0 +1,65 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +$dbPrefix = m_me_db_idx +$tbPrefix = m_me_tb_idx +$mtPrefix = m_me_mt_idx + +print =============== step1 +$i = 0 +$db = $dbPrefix +$mt = $mtPrefix + +sql drop database if exists $db +sql create database $db + +sql use $db + +sql create table $mt (ts timestamp, speed int) TAGS(sp int) + +$tbNum = 10000 + +while $i < $tbNum + $tb = $tbPrefix . $i + sql insert into $tb using $mt tags( $i ) values(now, $i ) + $i = $i + 1 +endw + +sql use information_schema +sql select count(*) from ins_tables where db_name = "m_me_db_idx" and create_time > now() - 10m +if $data[0][0] != $tbNum then + return -1 +endi + +sql select count(*) from ins_tables where db_name = "m_me_db_idx" and create_time < now(); +if $data[0][0] != $tbNum then + return -1 +endi + +sleep 1000 + + +sql use $db +$doubletbNum = 20000 + +while $i < $doubletbNum + $tb = $tbPrefix . $i + sql insert into $tb using $mt tags( $i ) values(now, $i ) + $i = $i + 1 +endw + + +sql use information_schema + +sql select count(*) from ins_tables where db_name = "m_me_db_idx" and create_time < now(); +if $data[0][0] != $doubletbNum then + print ==== $data[0][0] + return -1 +endi + + + + + From 801dc53e43452336c40bd34bbc64018cba34c62c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 24 Oct 2022 10:51:10 +0800 Subject: [PATCH 15/72] more fix --- source/dnode/vnode/src/meta/metaTable.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index dfa23602e8..9974e22572 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -731,7 +731,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl SSchemaWrapper *pSchema; int c; - if (pAlterTbReq->colName == NULL || pAlterTbReq->colNewName == NULL) { + if (pAlterTbReq->colName == NULL) { terrno = TSDB_CODE_INVALID_MSG; return -1; } @@ -853,6 +853,10 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl pColumn->bytes = pAlterTbReq->colModBytes; break; case TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME: + if (pAlterTbReq->colNewName == NULL) { + terrno = TSDB_CODE_INVALID_MSG; + goto _err; + } if (pColumn == NULL) { terrno = TSDB_CODE_VND_TABLE_COL_NOT_EXISTS; goto _err; From 9a0c149fc770c652229ead469f24ebd9462fe788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chappyguoxy=E2=80=9D?= <“happy_guoxy@163.com”> Date: Mon, 24 Oct 2022 11:22:23 +0800 Subject: [PATCH 16/72] test: refine query cases --- tests/system-test/fulltest.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index a095bdf045..2c7848d505 100644 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -179,7 +179,7 @@ python3 ./test.py -f 2-query/tan.py -R python3 ./test.py -f 2-query/Timediff.py python3 ./test.py -f 2-query/Timediff.py -R python3 ./test.py -f 2-query/timetruncate.py -# python3 ./test.py -f 2-query/timetruncate.py -R +python3 ./test.py -f 2-query/timetruncate.py -R python3 ./test.py -f 2-query/timezone.py python3 ./test.py -f 2-query/timezone.py -R python3 ./test.py -f 2-query/To_iso8601.py @@ -187,7 +187,7 @@ python3 ./test.py -f 2-query/To_iso8601.py -R python3 ./test.py -f 2-query/To_unixtimestamp.py python3 ./test.py -f 2-query/To_unixtimestamp.py -R python3 ./test.py -f 2-query/Today.py -# python3 ./test.py -f 2-query/Today.py -R +python3 ./test.py -f 2-query/Today.py -R python3 ./test.py -f 2-query/top.py python3 ./test.py -f 2-query/top.py -R python3 ./test.py -f 2-query/tsbsQuery.py @@ -217,11 +217,12 @@ python3 ./test.py -f 2-query/concat2.py python3 ./test.py -f 2-query/json_tag.py -# python3 ./test.py -f 2-query/nestedQuery.py -# TD-15983 subquery output duplicate name column. -# Please Xiangyang Guo modify the following script -# python3 ./test.py -f 2-query/nestedQuery_str.py +python3 ./test.py -f 2-query/nestedQuery.py +python3 ./test.py -f 2-query/nestedQuery_str.py +python3 ./test.py -f 2-query/nestedQuery_math.py +python3 ./test.py -f 2-query/nestedQuery_time.py python3 ./test.py -f 2-query/stablity.py +python3 ./test.py -f 2-query/stablity_1.py python3 ./test.py -f 2-query/elapsed.py python3 ./test.py -f 2-query/csum.py From 62a896b1f6e4e94b35fe6a30fe07d1113f3fdd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chappyguoxy=E2=80=9D?= <“happy_guoxy@163.com”> Date: Mon, 24 Oct 2022 11:23:14 +0800 Subject: [PATCH 17/72] test: refine query cases --- tests/system-test/2-query/stablity_1.py | 73 +++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 tests/system-test/2-query/stablity_1.py diff --git a/tests/system-test/2-query/stablity_1.py b/tests/system-test/2-query/stablity_1.py new file mode 100755 index 0000000000..c1a5eea350 --- /dev/null +++ b/tests/system-test/2-query/stablity_1.py @@ -0,0 +1,73 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from util.cases import tdCases +from .stablity import * + +class TDTestCase(TDTestCase): + + def run(self): + tdSql.prepare() + + startTime = time.time() + + self.function_before_26() + + self.dropandcreateDB_random("%s" %self.db_nest, 1) + + # self.math_nest(['UNIQUE']) + # self.math_nest(['MODE']) + # self.math_nest(['SAMPLE']) + + # self.math_nest(['ABS','SQRT']) + # self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN']) + # self.math_nest(['POW','LOG']) + # self.math_nest(['FLOOR','CEIL','ROUND']) + # self.math_nest(['MAVG']) + # self.math_nest(['HYPERLOGLOG']) + # self.math_nest(['TAIL']) + # self.math_nest(['CSUM']) + # self.math_nest(['statecount','stateduration']) + # self.math_nest(['HISTOGRAM']) + + self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) + self.str_nest(['LENGTH','CHAR_LENGTH']) + self.str_nest(['SUBSTR']) + self.str_nest(['CONCAT']) + self.str_nest(['CONCAT_WS']) + self.time_nest(['CAST']) + self.time_nest(['CAST_1']) + self.time_nest(['CAST_2']) + self.time_nest(['CAST_3']) + self.time_nest(['CAST_4']) + + self.time_nest(['NOW','TODAY']) + self.time_nest(['TIMEZONE']) + self.time_nest(['TIMETRUNCATE']) + self.time_nest(['TO_ISO8601']) + self.time_nest(['TO_UNIXTIMESTAMP']) + self.time_nest(['ELAPSED']) + self.time_nest(['TIMEDIFF_1']) + self.time_nest(['TIMEDIFF_2']) + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From cd04565987a19860aa3d46d7f57ac0a13ebba0e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chappyguoxy=E2=80=9D?= <“happy_guoxy@163.com”> Date: Mon, 24 Oct 2022 11:23:25 +0800 Subject: [PATCH 18/72] test: refine query cases --- tests/system-test/2-query/stablity.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/system-test/2-query/stablity.py b/tests/system-test/2-query/stablity.py index 552eec643b..b434335970 100755 --- a/tests/system-test/2-query/stablity.py +++ b/tests/system-test/2-query/stablity.py @@ -39,7 +39,7 @@ class TDTestCase: self.num = 10 self.fornum = 5 - self.db_nest = "nest" + self.db_nest = "stab" self.dropandcreateDB_random("%s" %self.db_nest, 1) # regular column select @@ -780,7 +780,7 @@ class TDTestCase: print("==========%s===start=============" %mathlist) os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - self.dropandcreateDB_random("%s" %self.db_nest, 1) + #self.dropandcreateDB_random("%s" %self.db_nest, 1) if (mathlist == ['ABS','SQRT']) or (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['FLOOR','CEIL','ROUND']) \ or (mathlist == ['CSUM']) : @@ -842,7 +842,7 @@ class TDTestCase: elif (mathlist == ['POW','LOG']) or (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) : math_functions = mathlist - num = random.randint(0, 1000) + num = random.randint(1, 1000) fun_fix_column = ['(q_bigint,num)','(q_smallint,num)','(q_tinyint,num)','(q_int,num)','(q_float,num)','(q_double,num)', '(q_bigint_null,num)','(q_smallint_null,num)','(q_tinyint_null,num)','(q_int_null,num)','(q_float_null,num)','(q_double_null,num)'] fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) @@ -1470,7 +1470,7 @@ class TDTestCase: print("==========%s===start=============" %strlist) os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - self.dropandcreateDB_random("%s" %self.db_nest, 1) + #self.dropandcreateDB_random("%s" %self.db_nest, 1) if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['LENGTH','CHAR_LENGTH']) \ or (strlist == ['']): @@ -2206,7 +2206,7 @@ class TDTestCase: print("==========%s===start=============" %timelist) os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - self.dropandcreateDB_random("%s" %self.db_nest, 1) + #self.dropandcreateDB_random("%s" %self.db_nest, 1) if (timelist == ['NOW','TODAY']) or (timelist == ['TIMEZONE']): time_functions = timelist @@ -4881,7 +4881,9 @@ class TDTestCase: startTime = time.time() - self.function_before_26() + #self.function_before_26() + + self.dropandcreateDB_random("%s" %self.db_nest, 1) self.math_nest(['UNIQUE']) self.math_nest(['MODE']) From 3cdef2c6e165d7db23beb3268044d750e2c7aa76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chappyguoxy=E2=80=9D?= <“happy_guoxy@163.com”> Date: Mon, 24 Oct 2022 11:24:06 +0800 Subject: [PATCH 19/72] test: refine query cases --- tests/system-test/2-query/nestedQuery_time.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 tests/system-test/2-query/nestedQuery_time.py diff --git a/tests/system-test/2-query/nestedQuery_time.py b/tests/system-test/2-query/nestedQuery_time.py new file mode 100755 index 0000000000..65eab3436e --- /dev/null +++ b/tests/system-test/2-query/nestedQuery_time.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from util.cases import tdCases +from .nestedQuery import * + +class TDTestCase(TDTestCase): + + + def run(self): + tdSql.prepare() + + startTime = time.time() + + # self.function_before_26() + + # self.math_nest(['UNIQUE']) + # self.math_nest(['MODE']) + # self.math_nest(['SAMPLE']) + + # self.math_nest(['ABS','SQRT']) + # self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN']) + # self.math_nest(['POW','LOG']) + # self.math_nest(['FLOOR','CEIL','ROUND']) + # self.math_nest(['MAVG']) + # self.math_nest(['HYPERLOGLOG']) + # self.math_nest(['TAIL']) + # self.math_nest(['CSUM']) + # self.math_nest(['statecount','stateduration']) + # self.math_nest(['HISTOGRAM']) + + # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) + # self.str_nest(['LENGTH','CHAR_LENGTH']) + # self.str_nest(['SUBSTR']) + # self.str_nest(['CONCAT']) + # self.str_nest(['CONCAT_WS']) + # self.time_nest(['CAST']) #放到time里起来弄 + # self.time_nest(['CAST_1']) + # self.time_nest(['CAST_2']) + # self.time_nest(['CAST_3']) + # self.time_nest(['CAST_4']) + + + + self.time_nest(['NOW','TODAY']) + self.time_nest(['TIMEZONE']) + self.time_nest(['TIMETRUNCATE']) + self.time_nest(['TO_ISO8601']) + self.time_nest(['TO_UNIXTIMESTAMP']) + self.time_nest(['ELAPSED']) + #self.time_nest(['TIMEDIFF_1']) + #self.time_nest(['TIMEDIFF_2']) + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From 9721619b4565ab557a2ee97280efa65b424e0bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chappyguoxy=E2=80=9D?= <“happy_guoxy@163.com”> Date: Mon, 24 Oct 2022 11:24:33 +0800 Subject: [PATCH 20/72] test: refine query cases --- tests/system-test/2-query/nestedQuery_str.py | 5758 +----------------- 1 file changed, 42 insertions(+), 5716 deletions(-) diff --git a/tests/system-test/2-query/nestedQuery_str.py b/tests/system-test/2-query/nestedQuery_str.py index 931ff873dc..6492b3df3a 100755 --- a/tests/system-test/2-query/nestedQuery_str.py +++ b/tests/system-test/2-query/nestedQuery_str.py @@ -10,5735 +10,61 @@ ################################################################### # -*- coding: utf-8 -*- - -import random -import os -import time -import taos -import subprocess -from faker import Faker -from util.log import tdLog from util.cases import tdCases -from util.sql import tdSql -from util.dnodes import tdDnodes -from util.dnodes import * - -class TDTestCase: - - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - self.testcasePath = os.path.split(__file__)[0] - self.testcaseFilename = os.path.split(__file__)[-1] - os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - - self.num = 10 - self.fornum = 5 - - self.db_nest = "nest" - self.dropandcreateDB_random("%s" %self.db_nest, 1) - - # regular column select - #q_select= ['ts' , '*' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts '] - self.q_select= ['ts' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts ', 'q_int_null ', 'q_bigint_null ' , 'q_bigint_null ' , 'q_smallint_null ' , 'q_tinyint_null ' , 'q_bool_null ' , 'q_binary_null ' , 'q_nchar_null ' ,'q_float_null ' , 'q_double_null ' ,'q_ts_null '] - - # tag column select - #t_select= ['*' , 'loc' ,'t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts '] - self.t_select= ['loc','t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts '] - - # regular and tag column select - self.qt_select= self.q_select + self.t_select - - # distinct regular column select - self.dq_select= ['distinct q_int', 'distinct q_bigint' , 'distinct q_smallint' , 'distinct q_tinyint' , - 'distinct q_bool' , 'distinct q_binary' , 'distinct q_nchar' ,'distinct q_float' , 'distinct q_double' ,'distinct q_ts '] - - # distinct tag column select - self.dt_select= ['distinct loc', 'distinct t_int', 'distinct t_bigint' , 'distinct t_smallint' , 'distinct t_tinyint' , - 'distinct t_bool' , 'distinct t_binary' , 'distinct t_nchar' ,'distinct t_float' , 'distinct t_double' ,'distinct t_ts '] - - # distinct regular and tag column select - self.dqt_select= self.dq_select + self.dt_select - - # special column select - self.s_r_select= ['_c0', '_rowts' , '_C0' ] - self.s_s_select= ['tbname' , '_rowts' , '_c0', '_C0' ] - self.unionall_or_union= [ ' union ' , ' union all ' ] - - # regular column where - self.q_where = ['ts < now +1s','q_bigint >= -9223372036854775807 and q_bigint <= 9223372036854775807', 'q_int <= 2147483647 and q_int >= -2147483647', - 'q_smallint >= -32767 and q_smallint <= 32767','q_tinyint >= -127 and q_tinyint <= 127','q_float >= -1.7E308 and q_float <= 1.7E308', - 'q_double >= -1.7E308 and q_double <= 1.7E308', 'q_binary like \'binary%\' or q_binary = \'0\' ' , 'q_nchar like \'nchar%\' or q_nchar = \'0\' ' , - 'q_bool = true or q_bool = false' , 'q_bool in (0 , 1)' , 'q_bool in ( true , false)' , 'q_bool = 0 or q_bool = 1', - 'q_bigint between -9223372036854775807 and 9223372036854775807',' q_int between -2147483647 and 2147483647','q_smallint between -32767 and 32767', - 'q_bigint not between 9223372036854775807 and -9223372036854775807','q_int not between 2147483647 and -2147483647','q_smallint not between 32767 and -32767', - 'q_tinyint between -127 and 127 ','q_float >= -3.4E38 ','q_float <= 3.4E38 ','q_double >= -1.7E308 ', - 'q_double <= 1.7E308 ','q_float between -3.4E38 and 3.4E38 ','q_double between -1.7E308 and 1.7E308 ' ,'q_float not between 3.4E38 and -3.4E38 ','q_double not between 1.7E308 and -1.7E308 ', - 'q_float is not null ' ,'q_double is not null ' ,'q_binary match \'binary\' ','q_binary nmatch \'binarynchar\' ','q_nchar match \'nchar\' ','q_nchar nmatch \'binarynchar\' ', - 'q_binary like \'binary%\' ','(q_binary like \'binary%\' or q_nchar = \'0\' or q_binary = \'binary_\' ) ','q_nchar like \'nchar%\' ','(q_nchar like \'nchar%\' or q_binary = \'0\' or q_nchar = \'nchar_\' ) ',] - #TD-6201 ,'q_bool between 0 and 1' - - # regular column where for test union,join - self.q_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.q_bigint >= -9223372036854775807 and t1.q_bigint <= 9223372036854775807 and t2.q_bigint >= -9223372036854775807 and t2.q_bigint <= 9223372036854775807', - 't1.q_int <= 2147483647 and t1.q_int >= -2147483647 and t2.q_int <= 2147483647 and t2.q_int >= -2147483647', - 't1.q_smallint >= -32767 and t1.q_smallint <= 32767 and t2.q_smallint >= -32767 and t2.q_smallint <= 32767', - 't1.q_tinyint >= -127 and t1.q_tinyint <= 127 and t2.q_tinyint >= -127 and t2.q_tinyint <= 127', - 't1.q_float >= - 1.7E308 and t1.q_float <= 1.7E308 and t2.q_float >= - 1.7E308 and t2.q_float <= 1.7E308', - 't1.q_double >= - 1.7E308 and t1.q_double <= 1.7E308 and t2.q_double >= - 1.7E308 and t2.q_double <= 1.7E308', - 't1.q_binary like \'binary%\' and t2.q_binary like \'binary%\' ' , - 't1.q_nchar like \'nchar%\' and t2.q_nchar like \'nchar%\' ' , - 't1.q_bool in (0 , 1) and t2.q_bool in (0 , 1)' , 't1.q_bool in ( true , false) and t2.q_bool in ( true , false)' , - 't1.q_bigint between -9223372036854775807 and 9223372036854775807 and t2.q_bigint between -9223372036854775807 and 9223372036854775807', - 't1.q_int between -2147483647 and 2147483647 and t2.q_int between -2147483647 and 2147483647', - 't1.q_smallint between -32767 and 32767 and t2.q_smallint between -32767 and 32767', - 't1.q_tinyint between -127 and 127 and t2.q_tinyint between -127 and 127 ','t1.q_float between -1.7E308 and 1.7E308 and t2.q_float between -1.7E308 and 1.7E308', - 't1.q_double between -1.7E308 and 1.7E308 and t2.q_double between -1.7E308 and 1.7E308', - 't1.q_bigint not between 9223372036854775807 and -9223372036854775807 and t2.q_bigint not between 9223372036854775807 and -9223372036854775807', - 't1.q_int not between 2147483647 and -2147483647 and t2.q_int not between 2147483647 and -2147483647', - 't1.q_smallint not between 32767 and -32767 and t2.q_smallint not between 32767 and -32767', - 't1.q_tinyint not between 127 and -127 and t2.q_tinyint not between 127 and -127 ','t1.q_float not between -1.7E308 and -1.7E308 and t2.q_float not between 1.7E308 and -1.7E308', - 't1.q_double not between 1.7E308 and -1.7E308 and t2.q_double not between 1.7E308 and -1.7E308'] - #TD-6201 ,'t1.q_bool between 0 and 1 or t2.q_bool between 0 and 1'] - #'t1.q_bool = true and t1.q_bool = false and t2.q_bool = true and t2.q_bool = false' , 't1.q_bool = 0 and t1.q_bool = 1 and t2.q_bool = 0 and t2.q_bool = 1' , - - self.q_u_or_where = ['(t1.q_binary like \'binary%\' or t1.q_binary = \'0\' or t2.q_binary like \'binary%\' or t2.q_binary = \'0\' )' , - '(t1.q_nchar like \'nchar%\' or t1.q_nchar = \'0\' or t2.q_nchar like \'nchar%\' or t2.q_nchar = \'0\' )' , '(t1.q_bool = true or t1.q_bool = false or t2.q_bool = true or t2.q_bool = false)' , - '(t1.q_bool in (0 , 1) or t2.q_bool in (0 , 1))' , '(t1.q_bool in ( true , false) or t2.q_bool in ( true , false))' , '(t1.q_bool = 0 or t1.q_bool = 1 or t2.q_bool = 0 or t2.q_bool = 1)' , - '(t1.q_bigint between -9223372036854775807 and 9223372036854775807 or t2.q_bigint between -9223372036854775807 and 9223372036854775807)', - '(t1.q_int between -2147483647 and 2147483647 or t2.q_int between -2147483647 and 2147483647)', - '(t1.q_smallint between -32767 and 32767 or t2.q_smallint between -32767 and 32767)', - '(t1.q_tinyint between -127 and 127 or t2.q_tinyint between -127 and 127 )','(t1.q_float between -1.7E308 and 1.7E308 or t2.q_float between -1.7E308 and 1.7E308)', - '(t1.q_double between -1.7E308 and 1.7E308 or t2.q_double between -1.7E308 and 1.7E308)'] - - # tag column where - self.t_where = ['ts < now +1s','t_bigint >= -9223372036854775807 and t_bigint <= 9223372036854775807','t_int <= 2147483647 and t_int >= -2147483647', - 't_smallint >= -32767 and t_smallint <= 32767','q_tinyint >= -127 and t_tinyint <= 127','t_float >= -1.7E308 and t_float <= 1.7E308', - 't_double >= -1.7E308 and t_double <= 1.7E308', 't_binary like \'binary%\' or t_binary = \'0\' ' , 't_nchar like \'nchar%\' or t_nchar = \'0\'' , - 't_bool = true or t_bool = false' , 't_bool in (0 , 1)' , 't_bool in ( true , false)' , 't_bool = 0 or t_bool = 1', - 't_bigint between -9223372036854775807 and 9223372036854775807',' t_int between -2147483647 and 2147483647','t_smallint between -32767 and 32767', - 't_tinyint between -127 and 127 ','t_float between -1.7E308 and 1.7E308','t_double between -1.7E308 and 1.7E308', - 't_binary match \'binary\' ','t_binary nmatch \'binarynchar\' ','t_nchar match \'nchar\' ','t_nchar nmatch \'binarynchar\' ', - 't_binary like \'binary%\' ','t_nchar like \'nchar%\' ','(t_binary like \'binary%\' or t_nchar = \'0\' ) ','(t_nchar like \'nchar%\' or t_binary = \'0\' ) ',] - #TD-6201,'t_bool between 0 and 1' - - # tag column where for test union,join | this is not support - self.t_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.t_bigint >= -9223372036854775807 and t1.t_bigint <= 9223372036854775807 and t2.t_bigint >= -9223372036854775807 and t2.t_bigint <= 9223372036854775807', - 't1.t_int <= 2147483647 and t1.t_int >= -2147483647 and t2.t_int <= 2147483647 and t2.t_int >= -2147483647', - 't1.t_smallint >= -32767 and t1.t_smallint <= 32767 and t2.t_smallint >= -32767 and t2.t_smallint <= 32767', - 't1.t_tinyint >= -127 and t1.t_tinyint <= 127 and t2.t_tinyint >= -127 and t2.t_tinyint <= 127', - 't1.t_float >= -1.7E308 and t1.t_float <= 1.7E308 and t2.t_float >= -1.7E308 and t2.t_float <= 1.7E308', - 't1.t_double >= -1.7E308 and t1.t_double <= 1.7E308 and t2.t_double >= -1.7E308 and t2.t_double <= 1.7E308', - '(t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\') ' , - '(t1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' )' , '(t1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false)' , - 't1.t_bool in (0 , 1) and t2.t_bool in (0 , 1)' , 't1.t_bool in ( true , false) and t2.t_bool in ( true , false)' , '(t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1)', - 't1.t_bigint between -9223372036854775807 and 9223372036854775807 and t2.t_bigint between -9223372036854775807 and 9223372036854775807', - 't1.t_int between -2147483647 and 2147483647 and t2.t_int between -2147483647 and 2147483647', - 't1.t_smallint between -32767 and 32767 and t2.t_smallint between -32767 and 32767', - '(t1.t_tinyint between -127 and 127 and t2.t_tinyint between -127 and 127) ','t1.t_float between -1.7E308 and 1.7E308 and t2.t_float between -1.7E308 and 1.7E308', - '(t1.t_double between -1.7E308 and 1.7E308 and t2.t_double between -1.7E308 and 1.7E308)'] - #TD-6201,'t1.t_bool between 0 and 1 or t2.q_bool between 0 and 1'] - - self.t_u_or_where = ['(t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' )' , - '(t1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' )' , '(t1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false)' , - '(t1.t_bool in (0 , 1) or t2.t_bool in (0 , 1))' , '(t1.t_bool in ( true , false) or t2.t_bool in ( true , false))' , '(t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1)', - '(t1.t_bigint between -9223372036854775807 and 9223372036854775807 or t2.t_bigint between -9223372036854775807 and 9223372036854775807)', - '(t1.t_int between -2147483647 and 2147483647 or t2.t_int between -2147483647 and 2147483647)', - '(t1.t_smallint between -32767 and 32767 or t2.t_smallint between -32767 and 32767)', - '(t1.t_tinyint between -127 and 127 or t2.t_tinyint between -127 and 127 )','(t1.t_float between -1.7E308 and 1.7E308 or t2.t_float between -1.7E308 and 1.7E308)', - '(t1.t_double between -1.7E308 and 1.7E308 or t2.t_double between -1.7E308 and 1.7E308)'] - - # regular and tag column where - self.qt_where = self.q_where + self.t_where - self.qt_u_where = self.q_u_where + self.t_u_where - # now,qt_u_or_where is not support - self.qt_u_or_where = self.q_u_or_where + self.t_u_or_where - - # tag column where for test super join | this is support , 't1.t_bool = t2.t_bool ' ??? - self.t_join_where = ['t1.t_bigint = t2.t_bigint ', 't1.t_int = t2.t_int ', 't1.t_smallint = t2.t_smallint ', 't1.t_tinyint = t2.t_tinyint ', - 't1.t_float = t2.t_float ', 't1.t_double = t2.t_double ', 't1.t_binary = t2.t_binary ' , 't1.t_nchar = t2.t_nchar ' ] - - # session && fill - self.session_where = ['session(ts,10a)' , 'session(ts,10s)', 'session(ts,10m)' , 'session(ts,10h)','session(ts,10d)' , 'session(ts,10w)'] - self.session_u_where = ['session(t1.ts,10a)' , 'session(t1.ts,10s)', 'session(t1.ts,10m)' , 'session(t1.ts,10h)','session(t1.ts,10d)' , 'session(t1.ts,10w)', - 'session(t2.ts,10a)' , 'session(t2.ts,10s)', 'session(t2.ts,10m)' , 'session(t2.ts,10h)','session(t2.ts,10d)' , 'session(t2.ts,10w)'] - - self.fill_where = ['FILL(NONE)','FILL(PREV)','FILL(NULL)','FILL(LINEAR)','FILL(NEXT)','FILL(VALUE, 1.23)'] - - self.state_window = ['STATE_WINDOW(q_tinyint)','STATE_WINDOW(q_bigint)','STATE_WINDOW(q_int)','STATE_WINDOW(q_bool)','STATE_WINDOW(q_smallint)'] - self.state_u_window = ['STATE_WINDOW(t1.q_tinyint)','STATE_WINDOW(t1.q_bigint)','STATE_WINDOW(t1.q_int)','STATE_WINDOW(t1.q_bool)','STATE_WINDOW(t1.q_smallint)', - 'STATE_WINDOW(t2.q_tinyint)','STATE_WINDOW(t2.q_bigint)','STATE_WINDOW(t2.q_int)','STATE_WINDOW(t2.q_bool)','STATE_WINDOW(t2.q_smallint)'] - - # order by where - self.order_where = ['order by ts' , 'order by ts asc'] - self.order_u_where = ['order by t1.ts' , 'order by t1.ts asc' , 'order by t2.ts' , 'order by t2.ts asc'] - self.order_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' ] - self.orders_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' , 'order by loc' , 'order by loc asc' , 'order by loc desc'] - - self.group_where = ['group by tbname , loc' , 'group by tbname', 'group by tbname, t_bigint', 'group by tbname,t_int', 'group by tbname, t_smallint', 'group by tbname,t_tinyint', - 'group by tbname,t_float', 'group by tbname,t_double' , 'group by tbname,t_binary', 'group by tbname,t_nchar', 'group by tbname,t_bool' ,'group by tbname ,loc ,t_bigint', - 'group by tbname,t_binary ,t_nchar ,t_bool' , 'group by tbname,t_int ,t_smallint ,t_tinyint' , 'group by tbname,t_float ,t_double ' , - 'PARTITION BY tbname , loc' , 'PARTITION BY tbname', 'PARTITION BY tbname, t_bigint', 'PARTITION BY tbname,t_int', 'PARTITION BY tbname, t_smallint', 'PARTITION BY tbname,t_tinyint', - 'PARTITION BY tbname,t_float', 'PARTITION BY tbname,t_double' , 'PARTITION BY tbname,t_binary', 'PARTITION BY tbname,t_nchar', 'PARTITION BY tbname,t_bool' ,'PARTITION BY tbname ,loc ,t_bigint', - 'PARTITION BY tbname,t_binary ,t_nchar ,t_bool' , 'PARTITION BY tbname,t_int ,t_smallint ,t_tinyint' , 'PARTITION BY tbname,t_float ,t_double '] - self.group_where_j = ['group by t1.loc' , 'group by t1.t_bigint', 'group by t1.t_int', 'group by t1.t_smallint', 'group by t1.t_tinyint', - 'group by t1.t_float', 'group by t1.t_double' , 'group by t1.t_binary', 'group by t1.t_nchar', 'group by t1.t_bool' ,'group by t1.loc ,t1.t_bigint', - 'group by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'group by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'group by t1.t_float ,t1.t_double ' , - 'PARTITION BY t1.loc' , 'PARTITION by t1.t_bigint', 'PARTITION by t1.t_int', 'PARTITION by t1.t_smallint', 'PARTITION by t1.t_tinyint', - 'PARTITION by t1.t_float', 'PARTITION by t1.t_double' , 'PARTITION by t1.t_binary', 'PARTITION by t1.t_nchar', 'PARTITION by t1.t_bool' ,'PARTITION BY t1.loc ,t1.t_bigint', - 'PARTITION by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'PARTITION by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'PARTITION by t1.t_float ,t1.t_double ', - 'group by t2.loc' , 'group by t2.t_bigint', 'group by t2.t_int', 'group by t2.t_smallint', 'group by t2.t_tinyint', - 'group by t2.t_float', 'group by t2.t_double' , 'group by t2.t_binary', 'group by t2.t_nchar', 'group by t2.t_bool' ,'group by t2.loc ,t2.t_bigint', - 'group by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'group by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'group by t2.t_float ,t2.t_double ' , - 'PARTITION BY t2.loc' , 'PARTITION by t2.t_bigint', 'PARTITION by t2.t_int', 'PARTITION by t2.t_smallint', 'PARTITION by t2.t_tinyint', - 'PARTITION by t2.t_float', 'PARTITION by t2.t_double' , 'PARTITION by t2.t_binary', 'PARTITION by t2.t_nchar', 'PARTITION by t2.t_bool' ,'PARTITION BY t2.loc ,t2.t_bigint', - 'PARTITION by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'PARTITION by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'PARTITION by t2.t_float ,t2.t_double '] - - self.partiton_where = ['PARTITION BY tbname , loc' , 'PARTITION BY tbname', 'PARTITION BY tbname, t_bigint', 'PARTITION BY tbname,t_int', 'PARTITION BY tbname, t_smallint', 'PARTITION BY tbname,t_tinyint', - 'PARTITION BY tbname,t_float', 'PARTITION BY tbname,t_double' , 'PARTITION BY tbname,t_binary', 'PARTITION BY tbname,t_nchar', 'PARTITION BY tbname,t_bool' ,'PARTITION BY tbname ,loc ,t_bigint', - 'PARTITION BY tbname,t_binary ,t_nchar ,t_bool' , 'PARTITION BY tbname,t_int ,t_smallint ,t_tinyint' , 'PARTITION BY tbname,t_float ,t_double '] - self.partiton_where_j = ['PARTITION BY t1.loc' , 'PARTITION by t1.t_bigint', 'PARTITION by t1.t_int', 'PARTITION by t1.t_smallint', 'PARTITION by t1.t_tinyint', - 'PARTITION by t1.t_float', 'PARTITION by t1.t_double' , 'PARTITION by t1.t_binary', 'PARTITION by t1.t_nchar', 'PARTITION by t1.t_bool' ,'PARTITION BY t1.loc ,t1.t_bigint', - 'PARTITION by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'PARTITION by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'PARTITION by t1.t_float ,t1.t_double ', - 'PARTITION BY t2.loc' , 'PARTITION by t2.t_bigint', 'PARTITION by t2.t_int', 'PARTITION by t2.t_smallint', 'PARTITION by t2.t_tinyint', - 'PARTITION by t2.t_float', 'PARTITION by t2.t_double' , 'PARTITION by t2.t_binary', 'PARTITION by t2.t_nchar', 'PARTITION by t2.t_bool' ,'PARTITION BY t2.loc ,t2.t_bigint', - 'PARTITION by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'PARTITION by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'PARTITION by t2.t_float ,t2.t_double '] - - - self.group_where_regular = ['group by tbname ' , 'group by tbname', 'group by tbname, q_bigint', 'group by tbname,q_int', 'group by tbname, q_smallint', 'group by tbname,q_tinyint', - 'group by tbname,q_float', 'group by tbname,q_double' , 'group by tbname,q_binary', 'group by tbname,q_nchar', 'group by tbname,q_bool' ,'group by tbname ,q_bigint', - 'group by tbname,q_binary ,q_nchar ,q_bool' , 'group by tbname,q_int ,q_smallint ,q_tinyint' , 'group by tbname,q_float ,q_double ' , - 'PARTITION BY tbname ' , 'PARTITION BY tbname', 'PARTITION BY tbname, q_bigint', 'PARTITION BY tbname,q_int', 'PARTITION BY tbname, q_smallint', 'PARTITION BY tbname,q_tinyint', - 'PARTITION BY tbname,q_float', 'PARTITION BY tbname,q_double' , 'PARTITION BY tbname,q_binary', 'PARTITION BY tbname,q_nchar', 'PARTITION BY tbname,q_bool' ,'PARTITION BY tbname ,q_bigint', - 'PARTITION BY tbname,q_binary ,q_nchar ,q_bool' , 'PARTITION BY tbname,q_int ,q_smallint ,q_tinyint' , 'PARTITION BY tbname,q_float ,q_double '] - self.group_where_regular_j = ['group by t1.q_bigint', 'group by t1.q_int', 'group by t1.q_smallint', 'group by t1.q_tinyint', - 'group by t1.q_float', 'group by t1.q_double' , 'group by t1.q_binary', 'group by t1.q_nchar', 'group by t1.q_bool' ,'group by t1.q_bigint', - 'group by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'group by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'group by t1.q_float ,t1.q_double ' , - 'PARTITION by t1.q_bigint', 'PARTITION by t1.q_int', 'PARTITION by t1.q_smallint', 'PARTITION by t1.q_tinyint', - 'PARTITION by t1.q_float', 'PARTITION by t1.q_double' , 'PARTITION by t1.q_binary', 'PARTITION by t1.q_nchar', 'PARTITION by t1.q_bool' ,'PARTITION BY t1.q_bigint', - 'PARTITION by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'PARTITION by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'PARTITION by t1.q_float ,t1.q_double ', - 'group by t2.q_bigint', 'group by t2.q_int', 'group by t2.q_smallint', 'group by t2.q_tinyint', - 'group by t2.q_float', 'group by t2.q_double' , 'group by t2.q_binary', 'group by t2.q_nchar', 'group by t2.q_bool' ,'group by t2.q_bigint', - 'group by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'group by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'group by t2.q_float ,t2.q_double ' , - 'PARTITION by t2.q_bigint', 'PARTITION by t2.q_int', 'PARTITION by t2.q_smallint', 'PARTITION by t2.q_tinyint', - 'PARTITION by t2.q_float', 'PARTITION by t2.q_double' , 'PARTITION by t2.q_binary', 'PARTITION by t2.q_nchar', 'PARTITION by t2.q_bool' ,'PARTITION BY t2.q_bigint', - 'PARTITION by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'PARTITION by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'PARTITION by t2.q_float ,t2.q_double '] - - self.partiton_where_regular = ['PARTITION BY tbname ' , 'PARTITION BY tbname', 'PARTITION BY tbname, q_bigint', 'PARTITION BY tbname,q_int', 'PARTITION BY tbname, q_smallint', 'PARTITION BY tbname,q_tinyint', - 'PARTITION BY tbname,q_float', 'PARTITION BY tbname,q_double' , 'PARTITION BY tbname,q_binary', 'PARTITION BY tbname,q_nchar', 'PARTITION BY tbname,q_bool' ,'PARTITION BY tbname ,q_bigint', - 'PARTITION BY tbname,q_binary ,q_nchar ,q_bool' , 'PARTITION BY tbname,q_int ,q_smallint ,q_tinyint' , 'PARTITION BY tbname,q_float ,q_double '] - self.partiton_where_regular_j = ['PARTITION by t1.q_bigint', 'PARTITION by t1.q_int', 'PARTITION by t1.q_smallint', 'PARTITION by t1.q_tinyint', - 'PARTITION by t1.q_float', 'PARTITION by t1.q_double' , 'PARTITION by t1.q_binary', 'PARTITION by t1.q_nchar', 'PARTITION by t1.q_bool' ,'PARTITION BY t1.q_bigint', - 'PARTITION by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'PARTITION by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'PARTITION by t1.q_float ,t1.q_double ', - 'PARTITION by t2.q_bigint', 'PARTITION by t2.q_int', 'PARTITION by t2.q_smallint', 'PARTITION by t2.q_tinyint', - 'PARTITION by t2.q_float', 'PARTITION by t2.q_double' , 'PARTITION by t2.q_binary', 'PARTITION by t2.q_nchar', 'PARTITION by t2.q_bool' ,'PARTITION BY t2.q_bigint', - 'PARTITION by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'PARTITION by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'PARTITION by t2.q_float ,t2.q_double '] - - self.having_support = ['having count(q_int) > 0','having count(q_bigint) > 0','having count(q_smallint) > 0','having count(q_tinyint) > 0','having count(q_float) > 0','having count(q_double) > 0','having count(q_bool) > 0', - 'having avg(q_int) > 0','having avg(q_bigint) > 0','having avg(q_smallint) > 0','having avg(q_tinyint) > 0','having avg(q_float) > 0','having avg(q_double) > 0', - 'having sum(q_int) > 0','having sum(q_bigint) > 0','having sum(q_smallint) > 0','having sum(q_tinyint) > 0','having sum(q_float) > 0','having sum(q_double) > 0', - 'having STDDEV(q_int) > 0','having STDDEV(q_bigint) > 0','having STDDEV(q_smallint) > 0','having STDDEV(q_tinyint) > 0','having STDDEV(q_float) > 0','having STDDEV(q_double) > 0', - 'having TWA(q_int) > 0','having TWA(q_bigint) > 0','having TWA(q_smallint) > 0','having TWA(q_tinyint) > 0','having TWA(q_float) > 0','having TWA(q_double) > 0', - 'having IRATE(q_int) > 0','having IRATE(q_bigint) > 0','having IRATE(q_smallint) > 0','having IRATE(q_tinyint) > 0','having IRATE(q_float) > 0','having IRATE(q_double) > 0', - 'having MIN(q_int) > 0','having MIN(q_bigint) > 0','having MIN(q_smallint) > 0','having MIN(q_tinyint) > 0','having MIN(q_float) > 0','having MIN(q_double) > 0', - 'having MAX(q_int) > 0','having MAX(q_bigint) > 0','having MAX(q_smallint) > 0','having MAX(q_tinyint) > 0','having MAX(q_float) > 0','having MAX(q_double) > 0', - 'having FIRST(q_int) > 0','having FIRST(q_bigint) > 0','having FIRST(q_smallint) > 0','having FIRST(q_tinyint) > 0','having FIRST(q_float) > 0','having FIRST(q_double) > 0', - 'having LAST(q_int) > 0','having LAST(q_bigint) > 0','having LAST(q_smallint) > 0','having LAST(q_tinyint) > 0','having LAST(q_float) > 0','having LAST(q_double) > 0', - 'having APERCENTILE(q_int,10) > 0','having APERCENTILE(q_bigint,10) > 0','having APERCENTILE(q_smallint,10) > 0','having APERCENTILE(q_tinyint,10) > 0','having APERCENTILE(q_float,10) > 0','having APERCENTILE(q_double,10) > 0'] - self.having_not_support = ['having TOP(q_int,10) > 0','having TOP(q_bigint,10) > 0','having TOP(q_smallint,10) > 0','having TOP(q_tinyint,10) > 0','having TOP(q_float,10) > 0','having TOP(q_double,10) > 0','having TOP(q_bool,10) > 0', - 'having BOTTOM(q_int,10) > 0','having BOTTOM(q_bigint,10) > 0','having BOTTOM(q_smallint,10) > 0','having BOTTOM(q_tinyint,10) > 0','having BOTTOM(q_float,10) > 0','having BOTTOM(q_double,10) > 0','having BOTTOM(q_bool,10) > 0', - 'having LEASTSQUARES(q_int) > 0','having LEASTSQUARES(q_bigint) > 0','having LEASTSQUARES(q_smallint) > 0','having LEASTSQUARES(q_tinyint) > 0','having LEASTSQUARES(q_float) > 0','having LEASTSQUARES(q_double) > 0','having LEASTSQUARES(q_bool) > 0', - 'having FIRST(q_bool) > 0','having IRATE(q_bool) > 0','having PERCENTILE(q_bool,10) > 0','having avg(q_bool) > 0','having LAST_ROW(q_bool) > 0','having sum(q_bool) > 0','having STDDEV(q_bool) > 0','having APERCENTILE(q_bool,10) > 0','having TWA(q_bool) > 0','having LAST(q_bool) > 0', - 'having PERCENTILE(q_int,10) > 0','having PERCENTILE(q_bigint,10) > 0','having PERCENTILE(q_smallint,10) > 0','having PERCENTILE(q_tinyint,10) > 0','having PERCENTILE(q_float,10) > 0','having PERCENTILE(q_double,10) > 0'] - self.having_tagnot_support = ['having LAST_ROW(q_int) > 0','having LAST_ROW(q_bigint) > 0','having LAST_ROW(q_smallint) > 0','having LAST_ROW(q_tinyint) > 0','having LAST_ROW(q_float) > 0','having LAST_ROW(q_double) > 0'] - - self.having_support_j = ['having count(t1.q_int) > 0','having count(t1.q_bigint) > 0','having count(t1.q_smallint) > 0','having count(t1.q_tinyint) > 0','having count(t1.q_float) > 0','having count(t1.q_double) > 0','having count(t1.q_bool) > 0', - 'having avg(t1.q_int) > 0','having avg(t1.q_bigint) > 0','having avg(t1.q_smallint) > 0','having avg(t1.q_tinyint) > 0','having avg(t1.q_float) > 0','having avg(t1.q_double) > 0', - 'having sum(t1.q_int) > 0','having sum(t1.q_bigint) > 0','having sum(t1.q_smallint) > 0','having sum(t1.q_tinyint) > 0','having sum(t1.q_float) > 0','having sum(t1.q_double) > 0', - 'having STDDEV(t1.q_int) > 0','having STDDEV(t1.q_bigint) > 0','having STDDEV(t1.q_smallint) > 0','having STDDEV(t1.q_tinyint) > 0','having STDDEV(t1.q_float) > 0','having STDDEV(t1.q_double) > 0', - 'having TWA(t1.q_int) > 0','having TWA(t1.q_bigint) > 0','having TWA(t1.q_smallint) > 0','having TWA(t1.q_tinyint) > 0','having TWA(t1.q_float) > 0','having TWA(t1.q_double) > 0', - 'having IRATE(t1.q_int) > 0','having IRATE(t1.q_bigint) > 0','having IRATE(t1.q_smallint) > 0','having IRATE(t1.q_tinyint) > 0','having IRATE(t1.q_float) > 0','having IRATE(t1.q_double) > 0', - 'having MIN(t1.q_int) > 0','having MIN(t1.q_bigint) > 0','having MIN(t1.q_smallint) > 0','having MIN(t1.q_tinyint) > 0','having MIN(t1.q_float) > 0','having MIN(t1.q_double) > 0', - 'having MAX(t1.q_int) > 0','having MAX(t1.q_bigint) > 0','having MAX(t1.q_smallint) > 0','having MAX(t1.q_tinyint) > 0','having MAX(t1.q_float) > 0','having MAX(t1.q_double) > 0', - 'having FIRST(t1.q_int) > 0','having FIRST(t1.q_bigint) > 0','having FIRST(t1.q_smallint) > 0','having FIRST(t1.q_tinyint) > 0','having FIRST(t1.q_float) > 0','having FIRST(t1.q_double) > 0', - 'having LAST(t1.q_int) > 0','having LAST(t1.q_bigint) > 0','having LAST(t1.q_smallint) > 0','having LAST(t1.q_tinyint) > 0','having LAST(t1.q_float) > 0','having LAST(t1.q_double) > 0', - 'having APERCENTILE(t1.q_int,10) > 0','having APERCENTILE(t1.q_bigint,10) > 0','having APERCENTILE(t1.q_smallint,10) > 0','having APERCENTILE(t1.q_tinyint,10) > 0','having APERCENTILE(t1.q_float,10) > 0','having APERCENTILE(t1.q_double,10) > 0'] - - # limit offset where - self.limit_where = ['limit 1 offset 1' , 'limit 1' , 'limit 2 offset 1' , 'limit 2', 'limit 12 offset 1' , 'limit 20', 'limit 20 offset 10' , 'limit 200'] - self.limit1_where = ['limit 1 offset 1' , 'limit 1' ] - self.limit_u_where = ['limit 100 offset 10' , 'limit 50' , 'limit 100' , 'limit 10' ] - - # slimit soffset where - self.slimit_where = ['slimit 1 soffset 1' , 'slimit 1' , 'slimit 2 soffset 1' , 'slimit 2'] - self.slimit1_where = ['slimit 2 soffset 1' , 'slimit 1' ] - - # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] - # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] - # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] - # **_ns_** express is not support stable, therefore, separated from regular tables - # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval - # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname - # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname - - # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval - # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] - - self.calc_select_all = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , - 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , - 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , - 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , - 'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , - 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , - 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , - 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , - 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)'] - - self.calc_select_in_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , - 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , - 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , - 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' ] - - self.calc_select_in = ['min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , - 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , - 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , - 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , - 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)'] - - self.calc_select_not_support_ts = ['first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , - 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , - 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , - 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)', - 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)'] - - self.calc_select_support_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , - 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , - 'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , - 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' ] - - self.calc_select_regular = [ 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)'] - - - self.calc_select_fill = ['INTERP(q_int)' ,'INTERP(q_bigint)' ,'INTERP(q_smallint)' ,'INTERP(q_tinyint)', 'INTERP(q_float)' ,'INTERP(q_double)'] - self.interp_where = ['ts = now' , 'ts = \'2020-09-13 20:26:40.000\'' , 'ts = \'2020-09-13 20:26:40.009\'' ,'tbname in (\'table_1\') and ts = now' ,'tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and ts = \'2020-09-13 20:26:40.000\'','tbname like \'table%\' and ts = \'2020-09-13 20:26:40.002\''] - - #two table join - self.calc_select_in_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' , - 'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' , - 'first(t1.q_int)' , 'first(t1.q_bigint)' , 'first(t1.q_smallint)' , 'first(t1.q_tinyint)' , 'first(t1.q_float)' ,'first(t1.q_double)' ,'first(t1.q_binary)' ,'first(t1.q_nchar)' ,'first(t1.q_bool)' ,'first(t1.q_ts)' , - 'last(t1.q_int)' , 'last(t1.q_bigint)' , 'last(t1.q_smallint)' , 'last(t1.q_tinyint)' , 'last(t1.q_float)' ,'last(t1.q_double)' , 'last(t1.q_binary)' ,'last(t1.q_nchar)' ,'last(t1.q_bool)' ,'last(t1.q_ts)' , - 'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' , - 'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' , - 'first(t2.q_int)' , 'first(t2.q_bigint)' , 'first(t2.q_smallint)' , 'first(t2.q_tinyint)' , 'first(t2.q_float)' ,'first(t2.q_double)' ,'first(t2.q_binary)' ,'first(t2.q_nchar)' ,'first(t2.q_bool)' ,'first(t2.q_ts)' , - 'last(t2.q_int)' , 'last(t2.q_bigint)' , 'last(t2.q_smallint)' , 'last(t2.q_tinyint)' , 'last(t2.q_float)' ,'last(t2.q_double)' , 'last(t2.q_binary)' ,'last(t2.q_nchar)' ,'last(t2.q_bool)' ,'last(t2.q_ts)'] - - self.calc_select_in_support_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' , - 'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' , - 'min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' , - 'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' , - 'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' , - 'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' , - 'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' , - 'max(t2.q_int)' , 'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' , - ] - - self.calc_select_in_not_support_ts_j = ['apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' , - 'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' , - 'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' , - 'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' , - 'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' , - 'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)'] - - self.calc_select_in_j = ['min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' , - 'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' , - 'apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' , - 'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' , - 'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' , - 'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' , - 'max(t2.q_int)' , 'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' , - 'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' , - 'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' , - 'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)'] - self.calc_select_all_j = self.calc_select_in_ts_j + self.calc_select_in_j - - self.calc_select_regular_j = [ 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , - 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)'] - - - self.calc_select_fill_j = ['INTERP(t1.q_int)' ,'INTERP(t1.q_bigint)' ,'INTERP(t1.q_smallint)' ,'INTERP(t1.q_tinyint)', 'INTERP(t1.q_float)' ,'INTERP(t1.q_double)' , - 'INTERP(t2.q_int)' ,'INTERP(t2.q_bigint)' ,'INTERP(t2.q_smallint)' ,'INTERP(t2.q_tinyint)', 'INTERP(t2.q_float)' ,'INTERP(t2.q_double)'] - self.interp_where_j = ['t1.ts = now' , 't1.ts = \'2020-09-13 20:26:40.000\'' , 't1.ts = \'2020-09-13 20:26:40.009\'' ,'t2.ts = now' , 't2.ts = \'2020-09-13 20:26:40.000\'' , 't2.ts = \'2020-09-13 20:26:40.009\'' , - 't1.tbname in (\'table_1\') and t1.ts = now' ,'t1.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t1.ts = \'2020-09-13 20:26:40.000\'','t1.tbname like \'table%\' and t1.ts = \'2020-09-13 20:26:40.002\'', - 't2.tbname in (\'table_1\') and t2.ts = now' ,'t2.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t2.ts = \'2020-09-13 20:26:40.000\'','t2.tbname like \'table%\' and t2.ts = \'2020-09-13 20:26:40.002\''] - - # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname APERCENTILE\PERCENTILE - # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] - self.calc_aggregate_all = ['count(*)' , 'count(q_int)' ,'count(q_bigint)' , 'count(q_smallint)' ,'count(q_tinyint)' ,'count(q_float)' , - 'count(q_double)' ,'count(q_binary)' ,'count(q_nchar)' ,'count(q_bool)' ,'count(q_ts)' , - 'avg(q_int)' ,'avg(q_bigint)' , 'avg(q_smallint)' ,'avg(q_tinyint)' ,'avg(q_float)' ,'avg(q_double)' , - 'sum(q_int)' ,'sum(q_bigint)' , 'sum(q_smallint)' ,'sum(q_tinyint)' ,'sum(q_float)' ,'sum(q_double)' , - 'STDDEV(q_int)' ,'STDDEV(q_bigint)' , 'STDDEV(q_smallint)' ,'STDDEV(q_tinyint)' ,'STDDEV(q_float)' ,'STDDEV(q_double)', - 'APERCENTILE(q_int,10)' ,'APERCENTILE(q_bigint,20)' , 'APERCENTILE(q_smallint,30)' ,'APERCENTILE(q_tinyint,40)' ,'APERCENTILE(q_float,50)' ,'APERCENTILE(q_double,60)'] - - self.calc_aggregate_regular = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , - 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' , - 'LEASTSQUARES(q_int,15,3)' , 'LEASTSQUARES(q_bigint,10,1)' , 'LEASTSQUARES(q_smallint,20,3)' ,'LEASTSQUARES(q_tinyint,10,4)' ,'LEASTSQUARES(q_float,6,4)' ,'LEASTSQUARES(q_double,3,1)' , - 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)'] - - self.calc_aggregate_groupbytbname = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , - 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' ] - - #two table join - self.calc_aggregate_all_j = ['count(t1.*)' , 'count(t1.q_int)' ,'count(t1.q_bigint)' , 'count(t1.q_smallint)' ,'count(t1.q_tinyint)' ,'count(t1.q_float)' , - 'count(t1.q_double)' ,'count(t1.q_binary)' ,'count(t1.q_nchar)' ,'count(t1.q_bool)' ,'count(t1.q_ts)' , - 'avg(t1.q_int)' ,'avg(t1.q_bigint)' , 'avg(t1.q_smallint)' ,'avg(t1.q_tinyint)' ,'avg(t1.q_float)' ,'avg(t1.q_double)' , - 'sum(t1.q_int)' ,'sum(t1.q_bigint)' , 'sum(t1.q_smallint)' ,'sum(t1.q_tinyint)' ,'sum(t1.q_float)' ,'sum(t1.q_double)' , - 'STDDEV(t1.q_int)' ,'STDDEV(t1.q_bigint)' , 'STDDEV(t1.q_smallint)' ,'STDDEV(t1.q_tinyint)' ,'STDDEV(t1.q_float)' ,'STDDEV(t1.q_double)', - 'APERCENTILE(t1.q_int,10)' ,'APERCENTILE(t1.q_bigint,20)' , 'APERCENTILE(t1.q_smallint,30)' ,'APERCENTILE(t1.q_tinyint,40)' ,'APERCENTILE(t1.q_float,50)' ,'APERCENTILE(t1.q_double,60)' , - 'count(t2.*)' , 'count(t2.q_int)' ,'count(t2.q_bigint)' , 'count(t2.q_smallint)' ,'count(t2.q_tinyint)' ,'count(t2.q_float)' , - 'count(t2.q_double)' ,'count(t2.q_binary)' ,'count(t2.q_nchar)' ,'count(t2.q_bool)' ,'count(t2.q_ts)' , - 'avg(t2.q_int)' ,'avg(t2.q_bigint)' , 'avg(t2.q_smallint)' ,'avg(t2.q_tinyint)' ,'avg(t2.q_float)' ,'avg(t2.q_double)' , - 'sum(t2.q_int)' ,'sum(t2.q_bigint)' , 'sum(t2.q_smallint)' ,'sum(t2.q_tinyint)' ,'sum(t2.q_float)' ,'sum(t2.q_double)' , - 'STDDEV(t2.q_int)' ,'STDDEV(t2.q_bigint)' , 'STDDEV(t2.q_smallint)' ,'STDDEV(t2.q_tinyint)' ,'STDDEV(t2.q_float)' ,'STDDEV(t2.q_double)', - 'APERCENTILE(t2.q_int,10)' ,'APERCENTILE(t2.q_bigint,20)' , 'APERCENTILE(t2.q_smallint,30)' ,'APERCENTILE(t2.q_tinyint,40)' ,'APERCENTILE(t2.q_float,50)' ,'APERCENTILE(t2.q_double,60)'] - - self.calc_aggregate_regular_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , - 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , - 'LEASTSQUARES(t1.q_int,15,3)' , 'LEASTSQUARES(t1.q_bigint,10,1)' , 'LEASTSQUARES(t1.q_smallint,20,3)' ,'LEASTSQUARES(t1.q_tinyint,10,4)' ,'LEASTSQUARES(t1.q_float,6,4)' ,'LEASTSQUARES(t1.q_double,3,1)' , - 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , - 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , - 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)', - 'LEASTSQUARES(t2.q_int,15,3)' , 'LEASTSQUARES(t2.q_bigint,10,1)' , 'LEASTSQUARES(t2.q_smallint,20,3)' ,'LEASTSQUARES(t2.q_tinyint,10,4)' ,'LEASTSQUARES(t2.q_float,6,4)' ,'LEASTSQUARES(t2.q_double,3,1)' , - 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)'] - - self.calc_aggregate_groupbytbname_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , - 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , - 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , - 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)' ] - - # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname - # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] - self.calc_calculate_all = ['SPREAD(ts)' , 'SPREAD(q_ts)' , 'SPREAD(q_int)' ,'SPREAD(q_bigint)' , 'SPREAD(q_smallint)' ,'SPREAD(q_tinyint)' ,'SPREAD(q_float)' ,'SPREAD(q_double)' , - '(SPREAD(q_int) + SPREAD(q_bigint))' , '(SPREAD(q_smallint) - SPREAD(q_float))', '(SPREAD(q_double) * SPREAD(q_tinyint))' , '(SPREAD(q_double) / SPREAD(q_float))'] - self.calc_calculate_regular = ['DIFF(q_int)' ,'DIFF(q_bigint)' , 'DIFF(q_smallint)' ,'DIFF(q_tinyint)' ,'DIFF(q_float)' ,'DIFF(q_double)' , - 'DIFF(q_int,0)' ,'DIFF(q_bigint,0)' , 'DIFF(q_smallint,0)' ,'DIFF(q_tinyint,0)' ,'DIFF(q_float,0)' ,'DIFF(q_double,0)' , - 'DIFF(q_int,1)' ,'DIFF(q_bigint,1)' , 'DIFF(q_smallint,1)' ,'DIFF(q_tinyint,1)' ,'DIFF(q_float,1)' ,'DIFF(q_double,1)' , - 'DERIVATIVE(q_int,15s,0)' , 'DERIVATIVE(q_bigint,10s,1)' , 'DERIVATIVE(q_smallint,20s,0)' ,'DERIVATIVE(q_tinyint,10s,1)' ,'DERIVATIVE(q_float,6s,0)' ,'DERIVATIVE(q_double,3s,1)' ] - self.calc_calculate_groupbytbname = self.calc_calculate_regular - - #two table join - self.calc_calculate_all_j = ['SPREAD(t1.ts)' , 'SPREAD(t1.q_ts)' , 'SPREAD(t1.q_int)' ,'SPREAD(t1.q_bigint)' , 'SPREAD(t1.q_smallint)' ,'SPREAD(t1.q_tinyint)' ,'SPREAD(t1.q_float)' ,'SPREAD(t1.q_double)' , - 'SPREAD(t2.ts)' , 'SPREAD(t2.q_ts)' , 'SPREAD(t2.q_int)' ,'SPREAD(t2.q_bigint)' , 'SPREAD(t2.q_smallint)' ,'SPREAD(t2.q_tinyint)' ,'SPREAD(t2.q_float)' ,'SPREAD(t2.q_double)' , - '(SPREAD(t1.q_int) + SPREAD(t1.q_bigint))' , '(SPREAD(t1.q_tinyint) - SPREAD(t1.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_tinyint))', - '(SPREAD(t2.q_int) + SPREAD(t2.q_bigint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t2.q_double) * SPREAD(t2.q_tinyint))' , '(SPREAD(t2.q_double) / SPREAD(t2.q_tinyint))', - '(SPREAD(t1.q_int) + SPREAD(t1.q_smallint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_float))'] - self.calc_calculate_regular_j = ['DIFF(t1.q_int)' ,'DIFF(t1.q_bigint)' , 'DIFF(t1.q_smallint)' ,'DIFF(t1.q_tinyint)' ,'DIFF(t1.q_float)' ,'DIFF(t1.q_double)' , - 'DIFF(t1.q_int,0)' ,'DIFF(t1.q_bigint,0)' , 'DIFF(t1.q_smallint,0)' ,'DIFF(t1.q_tinyint,0)' ,'DIFF(t1.q_float,0)' ,'DIFF(t1.q_double,0)' , - 'DIFF(t1.q_int,1)' ,'DIFF(t1.q_bigint,1)' , 'DIFF(t1.q_smallint,1)' ,'DIFF(t1.q_tinyint,1)' ,'DIFF(t1.q_float,1)' ,'DIFF(t1.q_double,1)' , - 'DERIVATIVE(t1.q_int,15s,0)' , 'DERIVATIVE(t1.q_bigint,10s,1)' , 'DERIVATIVE(t1.q_smallint,20s,0)' ,'DERIVATIVE(t1.q_tinyint,10s,1)' ,'DERIVATIVE(t1.q_float,6s,0)' ,'DERIVATIVE(t1.q_double,3s,1)' , - 'DIFF(t2.q_int)' ,'DIFF(t2.q_bigint)' , 'DIFF(t2.q_smallint)' ,'DIFF(t2.q_tinyint)' ,'DIFF(t2.q_float)' ,'DIFF(t2.q_double)' , - 'DIFF(t2.q_int,0)' ,'DIFF(t2.q_bigint,0)' , 'DIFF(t2.q_smallint,0)' ,'DIFF(t2.q_tinyint,0)' ,'DIFF(t2.q_float,0)' ,'DIFF(t2.q_double,0)' , - 'DIFF(t2.q_int,1)' ,'DIFF(t2.q_bigint,1)' , 'DIFF(t2.q_smallint,1)' ,'DIFF(t2.q_tinyint,1)' ,'DIFF(t2.q_float,1)' ,'DIFF(t2.q_double,1)' , - 'DERIVATIVE(t2.q_int,15s,0)' , 'DERIVATIVE(t2.q_bigint,10s,1)' , 'DERIVATIVE(t2.q_smallint,20s,0)' ,'DERIVATIVE(t2.q_tinyint,10s,1)' ,'DERIVATIVE(t2.q_float,6s,0)' ,'DERIVATIVE(t2.q_double,3s,1)' ] - self.calc_calculate_groupbytbname_j = self.calc_calculate_regular_j - - #inter && calc_aggregate_all\calc_aggregate_regular\calc_select_all - self.interval_sliding = ['interval(4w) sliding(1w) ','interval(1w) sliding(1d) ','interval(1d) sliding(1h) ' , - 'interval(1h) sliding(1m) ','interval(1m) sliding(1s) ','interval(1s) sliding(10a) ', - 'interval(1y) ','interval(1n) ','interval(1w) ','interval(1d) ','interval(1h) ','interval(1m) ','interval(1s) ' ,'interval(10a)', - 'interval(1y,1n) ','interval(1n,1w) ','interval(1w,1d) ','interval(1d,1h) ','interval(1h,1m) ','interval(1m,1s) ','interval(1s,10a) ' ,'interval(100a,30a)'] - - self.conn1 = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos/") - self.cur1 = self.conn1.cursor() - print(self.cur1) - self.cur1.execute("use %s ;" %self.db_nest) - sql = 'select * from stable_1 limit 5;' - self.cur1.execute(sql) - - - def data_matrix_equal(self, sql1,row1_s,row1_e,col1_s,col1_e, sql2,row2_s,row2_e,col2_s,col2_e): - # ----row1_start----col1_start---- - # - - - - 是一个矩阵内的数据相等- - - - # - - - - - - - - - - - - - - - - - # ----row1_end------col1_end------ - self.sql1 = sql1 - list1 =[] - tdSql.query(sql1) - for i1 in range(row1_s-1,row1_e): - #print("iiii=%d"%i1) - for j1 in range(col1_s-1,col1_e): - #print("jjjj=%d"%j1) - #print("data=%s" %(tdSql.getData(i1,j1))) - list1.append(tdSql.getData(i1,j1)) - print("=====list1-------list1---=%s" %set(list1)) - - tdSql.execute("reset query cache;") - self.sql2 = sql2 - list2 =[] - tdSql.query(sql2) - for i2 in range(row2_s-1,row2_e): - #print("iiii222=%d"%i2) - for j2 in range(col2_s-1,col2_e): - #print("jjjj222=%d"%j2) - #print("data=%s" %(tdSql.getData(i2,j2))) - list2.append(tdSql.getData(i2,j2)) - print("=====list2-------list2---=%s" %set(list2)) - - if (list1 == list2) and len(list2)>0: - # print(("=====matrix===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2)) - tdLog.info(("===matrix===sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2)) - elif (set(list2)).issubset(set(list1)): - # 解决不同子表排列结果乱序 - # print(("=====list_issubset==matrix2in1-true===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2)) - tdLog.info(("===matrix_issubset===sql1:'%s' matrix_set_result = sql2:'%s' matrix_set_result") %(sql1,sql2)) - #elif abs(float(str(list1).replace("]","").replace("[","").replace("e+","")) - float(str(list2).replace("]","").replace("[","").replace("e+",""))) <= 0.0001: - elif abs(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace("e+","").replace(", ","").replace("(","").replace(")","").replace("-","")) - float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace("e+","").replace(", ","").replace("(","").replace(")","").replace("-",""))) <= 0.0001: - print(("=====matrix_abs+e+===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2)) - print(("=====matrix_abs+e+replace_after===sql1.list1:'%s',sql2.list2:'%s'") %(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace("e+","").replace(", ","").replace("(","").replace(")","").replace("-","")),float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace("e+","").replace(", ","").replace("(","").replace(")","").replace("-","")))) - tdLog.info(("===matrix_abs+e+===sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2)) - elif abs(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")) - float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-",""))) <= 0.1: - #{datetime.datetime(2021, 8, 27, 1, 46, 40), -441.46841430664057}replace - print(("=====matrix_abs+replace===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2)) - print(("=====matrix_abs+replace_after===sql1.list1:'%s',sql2.list2:'%s'") %(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")),float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")))) - tdLog.info(("===matrix_abs+replace===sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2)) - elif abs(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")) - float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-",""))) <= 0.5: - print(("=====matrix_abs===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2)) - print(("=====matrix_abs===sql1.list1:'%s',sql2.list2:'%s'") %(float(str(list1).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")),float(str(list2).replace("datetime.datetime","").replace("]","").replace("[","").replace(", ","").replace("(","").replace(")","").replace("-","")))) - tdLog.info(("===matrix_abs======sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2)) - else: - print(("=====matrix_error===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2)) - tdLog.info(("sql1:'%s' matrix_result != sql2:'%s' matrix_result") %(sql1,sql2)) - return tdSql.checkEqual(list1,list2) - - def restartDnodes(self): - pass - # tdDnodes.stop(1) - # tdDnodes.start(1) - - def dropandcreateDB_random(self,database,n): - ts = 1630000000000 - num_random = 100 - fake = Faker('zh_CN') - tdSql.execute('''drop database if exists %s ;''' %database) - tdSql.execute('''create database %s keep 36500;'''%database) - tdSql.execute('''use %s;'''%database) - - tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ - q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ - tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') - tdSql.execute('''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ - q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ - tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') - - tdSql.execute('''create stable stable_null_data (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ - q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ - tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') - - tdSql.execute('''create stable stable_null_childtable (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ - q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ - tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') - - #tdSql.execute('''create table stable_1_1 using stable_1 tags('stable_1_1', '0' , '0' , '0' , '0' , 0 , 'binary1' , 'nchar1' , '0' , '0' ,'0') ;''') - tdSql.execute('''create table stable_1_1 using stable_1 tags('stable_1_1', '%d' , '%d', '%d' , '%d' , 0 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' - %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) - tdSql.execute('''create table stable_1_2 using stable_1 tags('stable_1_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , \'1999-09-09 09:09:09.090\') ;''') - tdSql.execute('''create table stable_1_3 using stable_1 tags('stable_1_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , \'2099-09-09 09:09:09.090\') ;''') - #tdSql.execute('''create table stable_1_4 using stable_1 tags('stable_1_4', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') - tdSql.execute('''create table stable_1_4 using stable_1 tags('stable_1_4', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' - %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) - - # tdSql.execute('''create table stable_2_1 using stable_2 tags('stable_2_1' , '0' , '0' , '0' , '0' , 0 , 'binary21' , 'nchar21' , '0' , '0' ,'0') ;''') - # tdSql.execute('''create table stable_2_2 using stable_2 tags('stable_2_2' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') - - # tdSql.execute('''create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') - - tdSql.execute('''create table stable_2_1 using stable_2 tags('stable_2_1' , '0' , '0' , '0' , '0' , 0 , 'binary21' , 'nchar21' , '0' , '0' ,\'2099-09-09 09:09:09.090\') ;''') - tdSql.execute('''create table stable_2_2 using stable_2 tags('stable_2_2' , '%d' , '%d', '%d' , '%d' , 0 , 'binary2.%s' , 'nchar2.%s' , '%f', '%f' ,'%d') ;''' - %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) - - tdSql.execute('''create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' - %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) - - #regular table - tdSql.execute('''create table regular_table_1 \ - (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ - q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') - tdSql.execute('''create table regular_table_2 \ - (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ - q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') - tdSql.execute('''create table regular_table_3 \ - (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ - q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') - - tdSql.execute('''create table regular_table_null \ - (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ - q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ - q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ - q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') - - - for i in range(num_random*n): - tdSql.execute('''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ - values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1), - fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - tdSql.execute('''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ - values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1) , - fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1) , - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - - tdSql.execute('''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8)\ - values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), - fake.random_int(min=0, max=9223372036854775807, step=1), - fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ - values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), - fake.random_int(min=0, max=9223372036854775807, step=1), - fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - - tdSql.execute('''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ - values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000 +1, fake.random_int(min=-2147483647, max=0, step=1), - fake.random_int(min=-9223372036854775807, max=0, step=1), - fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i +1, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ - values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000 +1, fake.random_int(min=-2147483647, max=0, step=1), - fake.random_int(min=-9223372036854775807, max=0, step=1), - fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i +1, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - - tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ - values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000, fake.random_int(min=-0, max=2147483647, step=1), - fake.random_int(min=-0, max=9223372036854775807, step=1), - fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - - tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ - values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000 +1, fake.random_int(min=-0, max=2147483647, step=1), - fake.random_int(min=-0, max=9223372036854775807, step=1), - fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - - tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ - q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ - values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ - 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' - % (ts + i*1000 +10, fake.random_int(min=-0, max=2147483647, step=1), - fake.random_int(min=-0, max=9223372036854775807, step=1), - fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i, fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , - fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address() , fake.pystr() , fake.address())) - - tdSql.query("select count(*) from stable_1;") - tdSql.checkData(0,0,3*num_random*n) - tdSql.query("select count(*) from regular_table_1;") - tdSql.checkData(0,0,num_random*n) - - def math_nest(self,mathlist): - - print("==========%s===start=============" %mathlist) - os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - - self.dropandcreateDB_random("%s" %self.db_nest, 1) - - if (mathlist == ['ABS','SQRT']) or (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['FLOOR','CEIL','ROUND']) \ - or (mathlist == ['CSUM']) or (mathlist == ['']): - math_functions = mathlist - fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)'] - fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) - math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) - math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)', - '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)'] - fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) - math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) - math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - elif (mathlist == ['UNIQUE']) or (mathlist == ['HYPERLOGLOG']): - math_functions = mathlist - fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_binary)','(q_nchar)','(q_bool)','(q_ts)', - '(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)','(q_binary_null)','(q_nchar_null)','(q_bool_null)','(q_ts_null)'] - fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) - math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) - math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)', - '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)'] - fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) - math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) - math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - elif (mathlist == ['POW','LOG']) or (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']): - math_functions = mathlist - num = random.randint(0, 1000) - fun_fix_column = ['(q_bigint,num)','(q_smallint,num)','(q_tinyint,num)','(q_int,num)','(q_float,num)','(q_double,num)', - '(q_bigint_null,num)','(q_smallint_null,num)','(q_tinyint_null,num)','(q_int_null,num)','(q_float_null,num)','(q_double_null,num)'] - fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) - math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)) - fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) - math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)) - - fun_fix_column_j = ['(t1.q_bigint,num)','(t1.q_smallint,num)','(t1.q_tinyint,num)','(t1.q_int,num)','(t1.q_float,num)','(t1.q_double,num)', - '(t1.q_bigint_null,num)','(t1.q_smallint_null,num)','(t1.q_tinyint_null,num)','(t1.q_int_null,num)','(t1.q_float_null,num)','(t1.q_double_null,num)', - '(t2.q_bigint,num)','(t2.q_smallint,num)','(t2.q_tinyint,num)','(t2.q_int,num)','(t2.q_float,num)','(t2.q_double,num)', - '(t2.q_bigint_null,num)','(t2.q_smallint_null,num)','(t2.q_tinyint_null,num)','(t2.q_int_null,num)','(t2.q_float_null,num)','(t2.q_double_null,num)'] - fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) - math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)) - fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) - math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)) - - tdSql.query("select 1-1 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , floor(asct1) from ( select " - sql += "%s as asct1, " % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select floor(asct1) from ( select " - sql += "%s as asct1 " % math_fun_1 - # sql += "%s as asct2, " % math_fun_2 - # sql += "%s, " % random.choice(self.s_s_select) - # sql += "%s, " % random.choice(self.q_select) - sql += " from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - #sql += "%s " % random.choice(self.order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - #tdSql.checkRows(100) - self.cur1.execute(sql) - - tdSql.query("select 1-2 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , abs(asct1) from ( select " - sql += "%s as asct1, " % math_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s )" % random.choice(self.order_where) - sql += "%s " % random.choice(self.unionall_or_union) - sql += "select ts , asct2 from ( select " - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - #sql += "%s " % random.choice(having_support) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select abs(asct1) from ( select " - sql += "%s as asct1 " % math_fun_1 - # sql += "%s, " % random.choice(self.s_s_select) - # sql += "%s, " % random.choice(self.q_select) - sql += "from regular_table_1 where " - sql += "%s )" % random.choice(self.q_where) - #sql += "%s )" % random.choice(self.order_where) - sql += "%s " % random.choice(self.unionall_or_union) - sql += "select floor(asct2) from ( select " - sql += "%s as asct2 " % math_fun_2 - # sql += "%s, " % random.choice(self.s_s_select) - # sql += "%s, " % random.choice(self.q_select) - sql += " from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - #sql += "%s " % random.choice(having_support) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15473 tdSql.query(sql) - #TD-15473 self.cur1.execute(sql) - - tdSql.query("select 1-3 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , min(asct1) from ( select " - sql += "%s as asct1, ts ," % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s select " % random.choice(self.unionall_or_union) - sql += "%s as asct2, ts ," % math_fun_2 - sql += "%s as asct1, " % math_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15473 tdSql.query(sql) - #self.cur1.execute(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select ts , min(asct1) from ( select " - sql += "%s as asct1, ts ," % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s select " % random.choice(self.unionall_or_union) - sql += "%s as asct2, ts ," % math_fun_2 - sql += "%s as asct1, " % math_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15473 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 1-4 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , asct1 from ( select t1.ts as ts," - sql += "%s, " % math_fun_join_1 - sql += "%s as asct1, " % math_fun_join_2 - sql += "%s, " % math_fun_join_1 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select count(asct1) from ( select " - sql += "%s as asct1 " % math_fun_join_2 - sql += "from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-5 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts ," - sql += "%s, " % math_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % math_fun_2 - sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select " - # sql += "%s, " % math_fun_1 - # sql += "%s, " % random.choice(self.q_select) - # sql += "%s, " % random.choice(self.q_select) - sql += "%s " % math_fun_2 - sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(self.q_where) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15973 tdSql.query(sql) - #TD-15973 self.cur1.execute(sql) - - tdSql.query("select 1-6 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , max(asct1) from ( select t1.ts as ts," - sql += "%s, " % math_fun_join_1 - sql += "%s as asct1, " % math_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "%s, " % math_fun_join_1 - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s )" % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select max(asct1) from ( select " - #sql += "%s, " % math_fun_join_1 - sql += "%s as asct1 " % math_fun_join_2 - # sql += "t1.%s, " % random.choice(self.q_select) - # sql += "t2.%s, " % random.choice(self.q_select) - # sql += "%s, " % math_fun_join_1 - sql += "from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s )" % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-7 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , abs(asct1) from ( select " - sql += "%s as asct1, ts ," % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql)# TD-16039 - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select abs(asct1) from ( select " - sql += "%s as asct1 " % math_fun_1 - sql += "from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - - tdSql.query("select 1-8 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts,floor(asct1) " - sql += "from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s as asct1, ts ," % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql)# TD-16039 - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select floor(asct1) " - sql += "from ( select " - sql += "%s as asct1 " % math_fun_1 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - - tdSql.query("select 1-9 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , max(asct1) from ( select t1.ts as ts," - sql += "%s, " % math_fun_join_1 - sql += "%s as asct1, " % math_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "and %s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select max(asct1) from ( select " - sql += "%s as asct1 " % math_fun_join_2 - # sql += "t1.%s, " % random.choice(self.q_select) - # sql += "t1.%s, " % random.choice(self.q_select) - # sql += "t2.%s, " % random.choice(self.q_select) - # sql += "t2.%s, " % random.choice(self.q_select) - sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "and %s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql)# TD-16039 - # self.cur1.execute(sql) - - self.restartDnodes() - tdSql.query("select 1-10 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , min(asct1) from ( select " - sql += "%s as asct1, ts ," % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") %s " % random.choice(self.unionall_or_union) - sql += "select ts , max(asct2) from ( select " - sql += "%s as asct1, ts ," % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select min(asct1) from ( select " - sql += "%s as asct1 " % math_fun_1 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += ") %s " % random.choice(self.unionall_or_union) - sql += "select max(asct2) from ( select " - sql += "%s as asct2 " % math_fun_2 - sql += "from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - - #3 inter union not support - tdSql.query("select 1-11 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , min(asct1), max(asct2) from ( select " - sql += "%s as asct1, ts ," % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - #sql += "%s " % random.choice(limit1_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s as asct1, ts ," % math_fun_1 - sql += "%s as asct2, " % math_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15837 tdSql.query(sql) - # self.cur1.execute(sql) - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select min(asct1) from ( select " - sql += "%s as asct1 " % math_fun_1 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s as asct2 " % math_fun_2 - sql += " from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15837 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 1-12 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , max(asct1) from ( select t1.ts as ts," - sql += "%s, " % math_fun_join_1 - sql += "%s as asct1, " % math_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select max(asct1) from ( select " - sql += "%s as asct1 " % math_fun_join_2 - sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - - tdSql.query("select 1-13 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts ," - sql += "%s, " % math_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % math_fun_2 - sql += "%s " % random.choice(self.t_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql) # TD-16039 - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) \ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select " - sql += "%s " % math_fun_2 - sql += "%s " % random.choice(self.t_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD15973 tdSql.query(sql) - #TD15973 self.cur1.execute(sql) - - tdSql.query("select 1-14 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select avg(asct1),count(asct2) from ( select " - sql += "%s as asct1, " % math_fun_1 - sql += "%s as asct2" % math_fun_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ) ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select avg(asct1) from ( select " - sql += "%s as asct1 " % math_fun_1 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ) ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - - tdSql.query("select 1-15 as math_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ - or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : - sql = "select ts , max(asct1) from ( select t1.ts as ts," - sql += "%s, " % math_fun_join_1 - sql += "%s as asct1, " % math_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s " % random.choice(self.q_select) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM'])\ - or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']): - sql = "select max(asct1) from ( select " - sql += "%s as asct1 " % math_fun_join_2 - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - - #taos -f sql - startTime_taos_f = time.time() - print("taos -f %s sql start!" %mathlist) - taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) - _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") - print("taos -f %s sql over!" %mathlist) - endTime_taos_f = time.time() - print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) - - print("=========%s====over=============" %mathlist) - - - def str_nest(self,strlist): - - print("==========%s===start=============" %strlist) - os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - - self.dropandcreateDB_random("%s" %self.db_nest, 1) - - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['LENGTH','CHAR_LENGTH']) \ - or (strlist == ['']): - str_functions = strlist - fun_fix_column = ['(q_nchar)','(q_binary)','(q_nchar_null)','(q_binary_null)'] - fun_column_1 = random.sample(str_functions,1)+random.sample(fun_fix_column,1) - str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_2 = random.sample(str_functions,1)+random.sample(fun_fix_column,1) - str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_fix_column_j = ['(t1.q_nchar)','(t1.q_binary)','(t1.q_nchar_null)','(t1.q_binary_null)', - '(t2.q_nchar)','(t2.q_binary)','(t2.q_nchar_null)','(t2.q_binary_null)'] - fun_column_join_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) - str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_join_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) - str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_fix_column_s = ['(q_nchar)','(q_binary)','(q_nchar_null)','(q_binary_null)','(loc)','(tbname)'] - fun_column_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1) - str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1) - str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_binary)','(t1.q_nchar_null)','(t1.q_binary_null)','(t1.loc)','(t1.tbname)', - '(t2.q_nchar)','(t2.q_binary)','(t2.q_nchar_null)','(t2.q_binary_null)','(t2.loc)','(t2.tbname)'] - fun_column_join_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) - str_fun_join_s_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_join_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) - str_fun_join_s_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - elif (strlist == ['SUBSTR']) : - str_functions = strlist - pos = random.randint(1, 20) - sub_len = random.randint(1, 10) - fun_fix_column = ['(q_nchar,pos)','(q_binary,pos)','(q_nchar_null,pos)','(q_binary_null,pos)', - '(q_nchar,pos,sub_len)','(q_binary,pos,sub_len)','(q_nchar_null,pos,sub_len)','(q_binary_null,pos,sub_len)',] - fun_column_1 = random.sample(str_functions,1)+random.sample(fun_fix_column,1) - str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) - fun_column_2 = random.sample(str_functions,1)+random.sample(fun_fix_column,1) - str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) - - fun_fix_column_j = ['(t1.q_nchar,pos)','(t1.q_binary,pos)','(t1.q_nchar_null,pos)','(t1.q_binary_null,pos)', - '(t1.q_nchar,pos,sub_len)','(t1.q_binary,pos,sub_len)','(t1.q_nchar_null,pos,sub_len)','(t1.q_binary_null,pos,sub_len)', - '(t2.q_nchar,pos)','(t2.q_binary,pos)','(t2.q_nchar_null,pos)','(t2.q_binary_null,pos)', - '(t2.q_nchar,pos,sub_len)','(t2.q_binary,pos,sub_len)','(t2.q_nchar_null,pos,sub_len)','(t2.q_binary_null,pos,sub_len)'] - fun_column_join_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) - str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) - fun_column_join_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) - str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) - - fun_fix_column_s = ['(q_nchar,pos)','(q_binary,pos)','(q_nchar_null,pos)','(q_binary_null,pos)','(loc,pos)', - '(q_nchar,pos,sub_len)','(q_binary,pos,sub_len)','(q_nchar_null,pos,sub_len)','(q_binary_null,pos,sub_len)','(loc,pos,sub_len)',] - fun_column_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1) - str_fun_s_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) - fun_column_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1) - str_fun_s_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) - - fun_fix_column_s_j = ['(t1.q_nchar,pos)','(t1.q_binary,pos)','(t1.q_nchar_null,pos)','(t1.q_binary_null,pos)','(t1.loc,pos)', - '(t1.q_nchar,pos,sub_len)','(t1.q_binary,pos,sub_len)','(t1.q_nchar_null,pos,sub_len)','(t1.q_binary_null,pos,sub_len)','(t1.loc,pos,sub_len)', - '(t2.q_nchar,pos)','(t2.q_binary,pos)','(t2.q_nchar_null,pos)','(t2.q_binary_null,pos)','(t2.loc,pos)', - '(t2.q_nchar,pos,sub_len)','(t2.q_binary,pos,sub_len)','(t2.q_nchar_null,pos,sub_len)','(t2.q_binary_null,pos,sub_len)','(t2.loc,pos,sub_len)'] - fun_column_join_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s_j,1) - str_fun_join_s_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) - fun_column_join_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s_j,1) - str_fun_join_s_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) - - elif (strlist == ['CONCAT']) : - str_functions = strlist - i = random.randint(2,8) - fun_fix_column = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','q_nchar_null', - 'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null'] - - column1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+column1+')' - str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") - - column2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+column2+')' - str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)', - '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)', - '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)', - '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)'] - - column_j1 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+column_j1+')' - str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") - - column_j2 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+column_j2+')' - str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_s = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','loc','q_nchar_null', - 'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null'] - - column_s1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") - fun_column_s_1 = str(random.sample(str_functions,1))+'('+column_s1+')' - str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","") - - column_s2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") - fun_column_s_2 = str(random.sample(str_functions,1))+'('+column_s2+')' - str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)','(t1.loc)', - '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)','(t2.loc)', - '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)', - '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)'] - - column_j_s1 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","") - fun_column_join_s_1 = str(random.sample(str_functions,1))+'('+column_j_s1+')' - str_fun_join_s_1 = str(fun_column_join_s_1).replace("[","").replace("]","").replace("'","") - - column_j_s2 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","") - fun_column_join_s_2 = str(random.sample(str_functions,1))+'('+column_j_s2+')' - str_fun_join_s_2 = str(fun_column_join_s_2).replace("[","").replace("]","").replace("'","") - - elif (strlist == ['CONCAT_WS']): - str_functions = strlist - i = random.randint(2,8) - fun_fix_column = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','q_nchar_null', - 'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null'] - - separators = ['',' ','abc','123','!','@','#','$','%','^','&','*','(',')','-','_','+','=','{', - '[','}',']','|',';',':',',','.','<','>','?','/','~','`','taos','涛思'] - separator = str(random.sample(separators,i)).replace("[","").replace("]","") - - column1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column1+')' - str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") - - column2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column2+')' - str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)', - '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)', - '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)', - '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)'] - - column_j1 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j1+')' - str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") - - column_j2 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j2+')' - str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_s = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','loc','q_nchar_null', - 'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null'] - - column_s1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") - fun_column_s_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_s1+')' - str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","") - - column_s2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") - fun_column_s_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_s2+')' - str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)','(t1.loc)', - '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)','(t2.loc)', - '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)', - '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)'] - - column_j_s1 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","") - fun_column_join_s_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j_s1+')' - str_fun_join_s_1 = str(fun_column_join_s_1).replace("[","").replace("]","").replace("'","") - - column_j_s2 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","") - fun_column_join_s_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j_s2+')' - str_fun_join_s_2 = str(fun_column_join_s_2).replace("[","").replace("]","").replace("'","") - - - tdSql.query("select 1-1 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']) : - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " - sql += "%s as asct1, " % str_fun_1 - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " - sql += "%s as asct1, " % str_fun_1 - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-2 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']) : - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " - sql += "%s as asct1, " % str_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s )" % random.choice(self.order_where) - sql += "%s " % random.choice(self.unionall_or_union) - sql += "select ts , asct2 from ( select " - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - #sql += "%s " % random.choice(having_support) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " - sql += "%s as asct1, " % str_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s )" % random.choice(self.order_where) - sql += "%s " % random.choice(self.unionall_or_union) - sql += "select ts , asct2 from ( select " - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - #sql += "%s " % random.choice(having_support) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - - tdSql.query("select 1-3 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_1 - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s select " % random.choice(self.unionall_or_union) - sql += "%s as asct2, ts ," % str_fun_2 - sql += "%s as asct1, " % str_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15473 tdSql.query(sql) - #self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_1 - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s select " % random.choice(self.unionall_or_union) - sql += "%s as asct2, ts ," % str_fun_2 - sql += "%s as asct1, " % str_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15473 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 1-4 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_1 - sql += "%s as asct1, " % str_fun_join_2 - sql += "%s, " % str_fun_join_1 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_1 - sql += "%s as asct1, " % str_fun_join_2 - sql += "%s, " % str_fun_join_1 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-5 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts ," - sql += "%s, " % str_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % str_fun_2 - sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select ts ," - sql += "%s, " % str_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % str_fun_2 - sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - tdSql.query("select 1-6 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_1 - sql += "%s as asct1, " % str_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "%s, " % str_fun_join_1 - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s )" % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_1 - sql += "%s as asct1, " % str_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "%s, " % str_fun_join_1 - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s )" % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-7 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_s_1 - sql += "%s as asct2, " % str_fun_s_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql)# TD-16039 - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_s_1 - sql += "%s as asct2, " % str_fun_s_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - - tdSql.query("select 1-8 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts, LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) " - sql += "from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s as asct1, ts ," % str_fun_s_1 - sql += "%s as asct2, " % str_fun_s_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql)# TD-16039 - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) " - sql += "from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s as asct1, ts ," % str_fun_s_1 - sql += "%s as asct2, " % str_fun_s_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - - tdSql.query("select 1-9 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_s_1 - sql += "%s as asct1, " % str_fun_join_s_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "and %s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_s_1 - sql += "%s as asct1, " % str_fun_join_s_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "and %s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - - self.restartDnodes() - tdSql.query("select 1-10 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_s_1 - sql += "%s as asct2, " % str_fun_s_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") %s " % random.choice(self.unionall_or_union) - sql += "select ts , max(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_1 - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_s_1 - sql += "%s as asct2, " % str_fun_s_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") %s " % random.choice(self.unionall_or_union) - sql += "select ts , max(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_1 - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - - #3 inter union not support - tdSql.query("select 1-11 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_s_1 - sql += "%s as asct2, " % str_fun_s_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - #sql += "%s " % random.choice(limit1_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s as asct1, ts ," % str_fun_1 - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15837 tdSql.query(sql) - # self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " - sql += "%s as asct1, ts ," % str_fun_s_1 - sql += "%s as asct2, " % str_fun_s_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - #sql += "%s " % random.choice(limit1_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s as asct1, ts ," % str_fun_1 - sql += "%s as asct2, " % str_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15837 tdSql.query(sql) - # self.cur1.execute(sql) - - tdSql.query("select 1-12 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_s_1 - sql += "%s as asct1, " % str_fun_join_s_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_s_1 - sql += "%s as asct1, " % str_fun_join_s_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - - tdSql.query("select 1-13 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts ," - sql += "%s, " % str_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % str_fun_2 - sql += "%s " % random.choice(self.t_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql) # TD-16039 - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select ts ," - sql += "%s, " % str_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % str_fun_2 - sql += "%s " % random.choice(self.t_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql)# TD-16039 - - tdSql.query("select 1-14 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " - sql += "%s as asct1, " % str_fun_s_1 - sql += "%s as asct2" % str_fun_s_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ) ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " - sql += "%s as asct1, " % str_fun_s_1 - sql += "%s as asct2" % str_fun_s_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ) ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - - tdSql.query("select 1-15 as str_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): - sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_s_1 - sql += "%s as asct1, " % str_fun_join_s_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s " % random.choice(self.q_select) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15955 tdSql.query(sql) - #TD-15955 self.cur1.execute(sql) - elif (strlist == ['LENGTH','CHAR_LENGTH']): - sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % str_fun_join_s_1 - sql += "%s as asct1, " % str_fun_join_s_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s " % random.choice(self.q_select) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15955 tdSql.query(sql) - #TD-15955 self.cur1.execute(sql) - - #taos -f sql - startTime_taos_f = time.time() - print("taos -f %s sql start!" %strlist) - taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) - _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") - print("taos -f %s sql over!" %strlist) - endTime_taos_f = time.time() - print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) - - print("=========%s====over=============" %strlist) - - def time_nest(self,timelist): - - print("==========%s===start=============" %timelist) - os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - - self.dropandcreateDB_random("%s" %self.db_nest, 1) - - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMEZONE']): - time_functions = timelist - fun_fix_column = ['()'] - fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_fix_column_j = ['()'] - fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - elif (timelist == ['TIMETRUNCATE']): - time_functions = timelist - - t = time.time() - t_to_s = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t)) - fun_fix_column = ['q_ts','ts','_c0','_C0','_rowts','1600000000000','1600000000000000','1600000000000000000', - '%d' %t, '%d000' %t, '%d000000' %t,'t_to_s'] - - timeunits = ['1u' , '1a' ,'1s', '1m' ,'1h', '1d'] - timeunit = str(random.sample(timeunits,1)).replace("[","").replace("]","").replace("'","") - - column_1 = ['(%s,timeutil)'%(random.sample(fun_fix_column,1))] - fun_column_1 = random.sample(time_functions,1)+random.sample(column_1,1) - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") - time_fun_1 = str(time_fun_1).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s) - - column_2 = ['(%s,timeutil)'%(random.sample(fun_fix_column,1))] - fun_column_2 = random.sample(time_functions,1)+random.sample(column_2,1) - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") - time_fun_2 = str(time_fun_2).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s) - - - fun_fix_column_j = ['(t1.q_ts)','(t1.ts)', '(t2.q_ts)','(t2.ts)','(1600000000000)','(1600000000000000)','(1600000000000000000)', - '(%d)' %t, '(%d000)' %t, '(%d000000)' %t,'t_to_s'] - - column_j1 = ['(%s,timeutil)'%(random.sample(fun_fix_column_j,1))] - fun_column_join_1 = random.sample(time_functions,1)+random.sample(column_j1,1) - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") - time_fun_join_1 = str(time_fun_join_1).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s) - - column_j2 = ['(%s,timeutil)'%(random.sample(fun_fix_column_j,1))] - fun_column_join_2 = random.sample(time_functions,1)+random.sample(column_j2,1) - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") - time_fun_join_2 = str(time_fun_join_2).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s) - - elif (timelist == ['TO_ISO8601']): - time_functions = timelist - - t = time.time() - fun_fix_column = ['(now())','(ts)','(q_ts)','(_rowts)','(_c0)','(_C0)', - '(1600000000000)','(1600000000000000)','(1600000000000000000)', - '(%d)' %t, '(%d000)' %t, '(%d000000)' %t] - - fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_fix_column_j = ['(t1.q_ts)','(t1.ts)', '(t2.q_ts)','(t2.ts)','(1600000000000)','(1600000000000000)','(1600000000000000000)','(now())', - '(%d)' %t, '(%d000)' %t, '(%d000000)' %t] - - fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - elif (timelist == ['TO_UNIXTIMESTAMP']): - time_functions = timelist - - t = time.time() - t_to_s = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t)) - fun_fix_column = ['(q_nchar)','(q_nchar1)','(q_nchar2)','(q_nchar3)','(q_nchar4)','(q_nchar_null)','(q_binary)','(q_binary5)','(q_binary6)','(q_binary7)','(q_binary8)','(q_binary_null)','(t_to_s)'] - - fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") - time_fun_1 = str(time_fun_1).replace("t_to_s","%s" %t_to_s) - - fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") - time_fun_2 = str(time_fun_2).replace("t_to_s","%s" %t_to_s) - - fun_fix_column_j = ['(t1.q_nchar)','(t1.q_binary)', '(t2.q_nchar)','(t2.q_binary)','(t_to_s)'] - - fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") - time_fun_join_1 = str(time_fun_join_1).replace("t_to_s","%s" %t_to_s) - - fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") - time_fun_join_2 = str(time_fun_join_2).replace("t_to_s","%s" %t_to_s) - - elif (timelist == ['TIMEDIFF']): - time_functions = timelist - - t = time.time() - t_to_s = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t)) - fun_fix_column = ['(q_nchar)','(q_nchar1)','(q_nchar2)','(q_nchar3)','(q_nchar4)','(q_nchar_null)','(q_binary)','(q_binary5)','(q_binary6)','(q_binary7)','(q_binary8)','(q_binary_null)','(t_to_s)'] - - fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") - time_fun_1 = str(time_fun_1).replace("t_to_s","%s" %t_to_s) - - fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") - time_fun_2 = str(time_fun_2).replace("t_to_s","%s" %t_to_s) - - fun_fix_column_j = ['(t1.q_nchar)','(t1.q_binary)', '(t2.q_nchar)','(t2.q_binary)','(t_to_s)'] - - fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") - time_fun_join_1 = str(time_fun_join_1).replace("t_to_s","%s" %t_to_s) - - fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") - time_fun_join_2 = str(time_fun_join_2).replace("t_to_s","%s" %t_to_s) - - elif (timelist == ['ELAPSED']): - time_functions = timelist - - fun_fix_column = ['(ts)','(q_ts)','(_c0)','(_C0)','(_rowts)','(ts,time_unit)','(_c0,time_unit)','(_C0,time_unit)','(_rowts,time_unit)'] - - time_units = ['nums','numm','numh','numd','numa'] - time_unit = str(random.sample(time_units,1)).replace("[","").replace("]","").replace("'","") - time_num1 = random.randint(0, 1000) - time_unit1 = time_unit.replace("num","%d" %time_num1) - time_num2 = random.randint(0, 1000) - time_unit2 = time_unit.replace("num","%d" %time_num2) - - fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit1) - - fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit2) - - - fun_fix_column_j = ['(t1.ts)','(t1.q_ts)', '(t2.ts)','(t2.q_ts)','(t1.ts,time_unit)','(t1.q_ts,time_unit)','(t2.ts,time_unit)','(t2.q_ts,time_unit)'] - - fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit1) - - fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit2) - - - elif (timelist == ['CAST']) : - str_functions = timelist - #下面的4个是全的,这个只是1个 - i = random.randint(1,4) - if i ==1: - print('===========cast_1===========') - fun_fix_column = ['q_bool','q_bool_null','q_bigint','q_bigint_null','q_smallint','q_smallint_null', - 'q_tinyint','q_tinyint_null','q_int','q_int_null','q_float','q_float_null','q_double','q_double_null'] - type_names = ['BIGINT','BINARY(100)','TIMESTAMP','NCHAR(100)','BIGINT UNSIGNED'] - - type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") - - type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_j = ['t1.q_bool','t1.q_bool_null','t1.q_bigint','t1.q_bigint_null','t1.q_smallint','t1.q_smallint_null', - 't1.q_tinyint','t1.q_tinyint_null','t1.q_int','t1.q_int_null','t1.q_float','t1.q_float_null','t1.q_double','t1.q_double_null', - 't2.q_bool','t2.q_bool_null','t2.q_bigint','t2.q_bigint_null','t2.q_smallint','t2.q_smallint_null', - 't2.q_tinyint','t2.q_tinyint_null','t2.q_int','t2.q_int_null','t2.q_float','t2.q_float_null','t2.q_double','t2.q_double_null'] - - type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") - - type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") - - elif i==2: - print('===========cast_2===========') - fun_fix_column = ['q_binary','q_binary_null','q_binary1','q_binary2','q_binary3','q_binary4'] - type_names = ['BIGINT','BINARY(100)','NCHAR(100)','BIGINT UNSIGNED'] - - type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") - - type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_j = ['t1.q_binary','t1.q_binary_null','t1.q_binary1','t1.q_binary2','t1.q_binary3','t1.q_smallint_null','t1.q_binary4', - 't2.q_binary','t2.q_binary_null','t2.q_bigint','t2.q_binary1','t2.q_binary2','t2.q_binary3','t2.q_binary4'] - - type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") - - type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") - - elif i==3: - print('===========cast_3===========') - fun_fix_column = ['q_nchar','q_nchar_null','q_nchar5','q_nchar6','q_nchar7','q_nchar8'] - type_names = ['BIGINT','NCHAR(100)','BIGINT UNSIGNED'] - - type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") - - type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_j = ['t1.q_nchar','t1.q_nchar_null','t1.q_nchar5','t1.q_nchar6','t1.q_nchar7','t1.q_nchar8', - 't2.q_nchar','t2.q_nchar_null','t2.q_nchar5','t2.q_nchar6','t2.q_nchar7','t2.q_nchar8'] - - type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") - - type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") - - elif i==4: - print('===========cast_4===========') - fun_fix_column = ['q_ts','q_ts_null','_C0','_c0','ts','_rowts'] - type_names = ['BIGINT','TIMESTAMP','BIGINT UNSIGNED'] - - type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") - - type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") - - fun_fix_column_j = ['t1.q_ts','t1.q_ts_null','t1.ts','t2.q_ts','t2.q_ts_null','t2.ts'] - - type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") - - type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") - - elif (timelist == ['CAST_1']) : - str_functions = timelist - - print('===========cast_1===========') - fun_fix_column = ['q_bool','q_bool_null','q_bigint','q_bigint_null','q_smallint','q_smallint_null', - 'q_tinyint','q_tinyint_null','q_int','q_int_null','q_float','q_float_null','q_double','q_double_null'] - type_names = ['BIGINT','BINARY(100)','TIMESTAMP','NCHAR(100)','BIGINT UNSIGNED'] - - type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_1","") - - type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_1","") - - fun_fix_column_j = ['t1.q_bool','t1.q_bool_null','t1.q_bigint','t1.q_bigint_null','t1.q_smallint','t1.q_smallint_null', - 't1.q_tinyint','t1.q_tinyint_null','t1.q_int','t1.q_int_null','t1.q_float','t1.q_float_null','t1.q_double','t1.q_double_null', - 't2.q_bool','t2.q_bool_null','t2.q_bigint','t2.q_bigint_null','t2.q_smallint','t2.q_smallint_null', - 't2.q_tinyint','t2.q_tinyint_null','t2.q_int','t2.q_int_null','t2.q_float','t2.q_float_null','t2.q_double','t2.q_double_null'] - - type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_1","") - - type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_1","") - - elif (timelist == ['CAST_2']) : - str_functions = timelist - print('===========cast_2===========') - fun_fix_column = ['q_binary','q_binary_null','q_binary1','q_binary2','q_binary3','q_binary4'] - type_names = ['BIGINT','BINARY(100)','NCHAR(100)','BIGINT UNSIGNED'] - - type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_2","") - - type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_2","") - - fun_fix_column_j = ['t1.q_binary','t1.q_binary_null','t1.q_binary1','t1.q_binary2','t1.q_binary3','t1.q_smallint_null','t1.q_binary4', - 't2.q_binary','t2.q_binary_null','t2.q_bigint','t2.q_binary1','t2.q_binary2','t2.q_binary3','t2.q_binary4'] - - type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_2","") - - type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_2","") - - elif (timelist == ['CAST_3']) : - str_functions = timelist - print('===========cast_3===========') - fun_fix_column = ['q_nchar','q_nchar_null','q_nchar5','q_nchar6','q_nchar7','q_nchar8'] - type_names = ['BIGINT','NCHAR(100)','BIGINT UNSIGNED'] - - type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_3","") - - type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_3","") - - fun_fix_column_j = ['t1.q_nchar','t1.q_nchar_null','t1.q_nchar5','t1.q_nchar6','t1.q_nchar7','t1.q_nchar8', - 't2.q_nchar','t2.q_nchar_null','t2.q_nchar5','t2.q_nchar6','t2.q_nchar7','t2.q_nchar8'] - - type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_3","") - - type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_3","") - - elif (timelist == ['CAST_4']) : - str_functions = timelist - print('===========cast_4===========') - fun_fix_column = ['q_ts','q_ts_null','_C0','_c0','ts','_rowts'] - type_names = ['BIGINT','TIMESTAMP','BIGINT UNSIGNED'] - - type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' - time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_4","") - - type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' - time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_4","") - - fun_fix_column_j = ['t1.q_ts','t1.q_ts_null','t1.ts','t2.q_ts','t2.q_ts_null','t2.ts'] - - type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' - time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_4","") - - type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") - fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' - time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_4","") - - tdSql.query("select 1-1 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) from ( select " - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (timelist == ['TIMEZONE']) \ - or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , asct1,now(),today(),timezone() from ( select " - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (timelist == ['ELAPSED']) : - sql = "select max(asct1),now(),today(),timezone() from ( select " - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2 " % time_fun_2 - sql += "from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-2 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now),now(),today(),timezone() from ( select " - sql += "%s as asct1, " % time_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s )" % random.choice(self.order_where) - sql += "%s " % random.choice(self.unionall_or_union) - sql += "select ts , timediff(asct2,now),now(),today(),timezone() from ( select " - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - #sql += "%s " % random.choice(having_support) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1),now(),today(),timezone() from ( select " - sql += "%s as asct1, " % time_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s )" % random.choice(self.order_where) - sql += "%s " % random.choice(self.unionall_or_union) - sql += "select ts , asct2,now(),today(),timezone() from ( select " - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - elif (timelist == ['ELAPSED']) : - sql = "select min(asct1),now(),today(),timezone() from ( select " - sql += "%s as asct1 " % time_fun_1 - sql += " from regular_table_1 where " - sql += "%s )" % random.choice(self.q_where) - sql += "%s " % random.choice(self.unionall_or_union) - sql += "select avg(asct2),now(),today(),timezone() from ( select " - sql += "%s as asct2 " % time_fun_2 - sql += " from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-3 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s select " % random.choice(self.unionall_or_union) - sql += "%s as asct2, ts ," % time_fun_2 - sql += "%s as asct1, " % time_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15473 tdSql.query(sql) - #self.cur1.execute(sql) - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1),now(),today(),timezone() from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s select " % random.choice(self.unionall_or_union) - sql += "%s as asct2, ts ," % time_fun_2 - sql += "%s as asct1, " % time_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15473 tdSql.query(sql) - #self.cur1.execute(sql) - elif (timelist == ['ELAPSED']) : - sql = "select abs(asct1),now(),today(),timezone() from ( select " - sql += "%s as asct1," % time_fun_1 - sql += "%s as asct2 " % time_fun_2 - sql += "from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s select " % random.choice(self.unionall_or_union) - sql += "%s as asct2," % time_fun_2 - sql += "%s as asct1 " % time_fun_1 - sql += "from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-4 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) from ( select t1.ts as ts," - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "%s, " % time_fun_join_1 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1) from ( select t1.ts as ts," - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "%s, " % time_fun_join_1 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - elif (timelist == ['ELAPSED']) : - sql = "select floor(asct1) from ( select " - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "%s " % time_fun_join_1 - sql += " from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-5 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['ELAPSED']) : - sql = "select now(),today(),timezone(), " - sql += "%s, " % time_fun_1 - sql += "%s " % time_fun_2 - sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(self.q_where) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - else: - sql = "select ts ,now(),today(),timezone(), " - sql += "%s, " % time_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % time_fun_2 - sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - tdSql.query("select 1-6 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) from ( select t1.ts as ts," - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "%s, " % time_fun_join_1 - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s )" % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1) from ( select t1.ts as ts," - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "%s, " % time_fun_join_1 - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s )" % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - elif (timelist == ['ELAPSED']) : - sql = "select (asct1)*111 from ( select " - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "%s " % time_fun_join_1 - sql += " from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s )" % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-7 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) # TD-16039 - # tdSql.checkRows(300) - # self.cur1.execute(sql) - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1),now(),today(),timezone() from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) # TD-16039 - # tdSql.checkRows(300) - # self.cur1.execute(sql) - elif (timelist == ['ELAPSED']) : - sql = "select (asct1)/asct2 ,now(),today(),timezone() from ( select " - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2 " % time_fun_2 - sql += "from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) #同时出现core:TD-16095和TD-16042 - # self.cur1.execute(sql) - - tdSql.query("select 1-8 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) " - sql += "from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) # TD-16039 - # tdSql.checkRows(300) - # self.cur1.execute(sql) - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1),now(),today(),timezone() " - sql += "from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) # TD-16039 - # tdSql.checkRows(300) - # self.cur1.execute(sql) - elif (timelist == ['ELAPSED']) : - sql = "select floor(abs(asct1)),now(),today(),timezone() " - sql += "from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) # TD-16039 - # self.cur1.execute(sql) - - tdSql.query("select 1-9 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) from ( select t1.ts as ts," - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "and %s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) TD-16039 - # self.cur1.execute(sql) TD-16039 - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , asct1 from ( select t1.ts as ts," - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "and %s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (timelist == ['ELAPSED']) : - sql = "select min(asct1*110) from ( select " - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1 " % time_fun_join_2 - sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "and %s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - - self.restartDnodes() - tdSql.query("select 1-10 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") %s " % random.choice(self.unionall_or_union) - sql += "select ts , max(asct2) from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1),now(),today(),timezone() from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") %s " % random.choice(self.unionall_or_union) - sql += "select ts , max(asct2),now(),today(),timezone() from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - elif (timelist == ['ELAPSED']) : - sql = "select abs(asct1),now(),today(),timezone() from ( select " - sql += "%s as asct1 ," % time_fun_1 - sql += "%s as asct2 " % time_fun_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += ") %s " % random.choice(self.unionall_or_union) - sql += "select max(asct2),now(),today(),timezone() from ( select " - sql += "%s as asct1 ," % time_fun_1 - sql += "%s as asct2 " % time_fun_2 - sql += "from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - - #3 inter union not support - tdSql.query("select 1-11 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now), timediff(now,asct2) from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql)#TD-15473 - # self.cur1.execute(sql)#TD-15473 - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1,now()),(now(),asct2) from ( select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s as asct1, ts ," % time_fun_1 - sql += "%s as asct2, " % time_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql)#TD-15473 - # self.cur1.execute(sql)#TD-15473 - elif (timelist == ['ELAPSED']) : - sql = "select asct1+asct2,now(),today(),timezone() from ( select " - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2 " % time_fun_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s as asct1 ," % time_fun_1 - sql += "%s as asct2 " % time_fun_2 - sql += " from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql)#TD-15473 - self.cur1.execute(sql)#TD-15473 - - tdSql.query("select 1-12 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now) from ( select t1.ts as ts," - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , asct1,now() from ( select t1.ts as ts," - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - elif (timelist == ['ELAPSED']) : - sql = "select min(floor(asct1)),now() from ( select " - sql += "%s, " % time_fun_join_1 - sql += "%s as asct1 " % time_fun_join_2 - sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql)# TD-16039 - - tdSql.query("select 1-13 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(%s,now)," % time_fun_2 - sql += "%s as asct1, " % time_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % time_fun_2 - sql += "%s " % random.choice(self.t_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql) # TD-16039 - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts ,now(),today(),timezone(), " - sql += "%s as asct1, " % time_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % time_fun_2 - sql += "%s " % random.choice(self.t_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # tdSql.checkRows(300) - # self.cur1.execute(sql) # TD-16039 - elif (timelist == ['ELAPSED']) : - sql = "select now(),today(),timezone(), " - sql += "%s as asct1, " % time_fun_1 - sql += "%s " % time_fun_2 - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - - tdSql.query("select 1-14 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now),timediff(now,asct2) from ( select ts ts ," - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2" % time_fun_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ) ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , (asct1),now(),(now()),asct2 from ( select ts ts ," - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2" % time_fun_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ) ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (timelist == ['ELAPSED']) : - sql = "select ts , (asct1)*asct2,now(),(now()) from ( select " - sql += "%s as asct1, " % time_fun_1 - sql += "%s as asct2" % time_fun_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ) ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - - tdSql.query("select 1-15 as time_nest from stable_1 limit 1;") - for i in range(self.fornum): - if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ - or (timelist == ['TO_UNIXTIMESTAMP']): - sql = "select ts , timediff(asct1,now),timediff(now,asct2) from ( select t1.ts as ts," - sql += "%s as asct2, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s " % random.choice(self.q_select) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): - sql = "select ts , asct1,(now()),(now()),asct2 ,now(),today(),timezone() from ( select t1.ts as ts," - sql += "%s as asct2, " % time_fun_join_1 - sql += "%s as asct1, " % time_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s " % random.choice(self.q_select) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - # self.cur1.execute(sql) # TD-16039 - elif (timelist == ['ELAPSED']) : - sql = "select asct1,(now()),(now()),asct2 ,now(),today(),timezone() from ( select " - sql += "%s as asct2, " % time_fun_join_1 - sql += "%s as asct1 " % time_fun_join_2 - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) # TD-16039 - - #taos -f sql - startTime_taos_f = time.time() - print("taos -f %s sql start!" %timelist) - taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) - _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") - print("taos -f %s sql over!" %timelist) - endTime_taos_f = time.time() - print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) - - print("=========%s====over=============" %timelist) - - def base_nest(self,baselist): - - print("==========%s===start=============" %baselist) - os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - - self.dropandcreateDB_random("%s" %self.db_nest, 1) - - if (baselist == ['A']) or (baselist == ['S']) or (baselist == ['F']) \ - or (baselist == ['C']): - base_functions = baselist - fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)'] - fun_column_1 = random.sample(base_functions,1)+random.sample(fun_fix_column,1) - base_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_2 = random.sample(base_functions,1)+random.sample(fun_fix_column,1) - base_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)', - '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)'] - fun_column_join_1 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1) - base_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") - fun_column_join_2 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1) - base_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - - elif (baselist == ['P']) or (baselist == ['M']) or (baselist == ['S'])or (baselist == ['T']): - base_functions = baselist - num = random.randint(0, 1000) - fun_fix_column = ['(q_bigint,num)','(q_smallint,num)','(q_tinyint,num)','(q_int,num)','(q_float,num)','(q_double,num)', - '(q_bigint_null,num)','(q_smallint_null,num)','(q_tinyint_null,num)','(q_int_null,num)','(q_float_null,num)','(q_double_null,num)'] - fun_column_1 = random.sample(base_functions,1)+random.sample(fun_fix_column,1) - base_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num)) - fun_column_2 = random.sample(base_functions,1)+random.sample(fun_fix_column,1) - base_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num)) - - fun_fix_column_j = ['(t1.q_bigint,num)','(t1.q_smallint,num)','(t1.q_tinyint,num)','(t1.q_int,num)','(t1.q_float,num)','(t1.q_double,num)', - '(t1.q_bigint_null,num)','(t1.q_smallint_null,num)','(t1.q_tinyint_null,num)','(t1.q_int_null,num)','(t1.q_float_null,num)','(t1.q_double_null,num)', - '(t2.q_bigint,num)','(t2.q_smallint,num)','(t2.q_tinyint,num)','(t2.q_int,num)','(t2.q_float,num)','(t2.q_double,num)', - '(t2.q_bigint_null,num)','(t2.q_smallint_null,num)','(t2.q_tinyint_null,num)','(t2.q_int_null,num)','(t2.q_float_null,num)','(t2.q_double_null,num)'] - fun_column_join_1 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1) - base_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num)) - fun_column_join_2 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1) - base_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num)) - - tdSql.query("select 1-1 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , floor(asct1) from ( select " - sql += "%s as asct1, " % base_fun_1 - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - tdSql.query("select 1-2 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , abs(asct1) from ( select " - sql += "%s as asct1, " % base_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s )" % random.choice(self.order_where) - sql += "%s " % random.choice(self.unionall_or_union) - sql += "select ts , asct2 from ( select " - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - #sql += "%s " % random.choice(having_support) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - - tdSql.query("select 1-3 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , min(asct1) from ( select " - sql += "%s as asct1, ts ," % base_fun_1 - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s select " % random.choice(self.unionall_or_union) - sql += "%s as asct2, ts ," % base_fun_2 - sql += "%s as asct1, " % base_fun_1 - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15473 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 1-4 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , asct1 from ( select t1.ts as ts," - sql += "%s, " % base_fun_join_1 - sql += "%s as asct1, " % base_fun_join_2 - sql += "%s, " % base_fun_join_1 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - tdSql.query("select 1-5 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts ," - sql += "%s, " % base_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % base_fun_2 - sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - tdSql.query("select 1-6 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , max(asct1) from ( select t1.ts as ts," - sql += "%s, " % base_fun_join_1 - sql += "%s as asct1, " % base_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "%s, " % base_fun_join_1 - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s )" % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-7 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , abs(asct1) from ( select " - sql += "%s as asct1, ts ," % base_fun_1 - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(300) - self.cur1.execute(sql) - - tdSql.query("select 1-8 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts,floor(asct1) " - sql += "from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s as asct1, ts ," % base_fun_1 - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(300) - self.cur1.execute(sql) - - tdSql.query("select 1-9 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , max(asct1) from ( select t1.ts as ts," - sql += "%s, " % base_fun_join_1 - sql += "%s as asct1, " % base_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "and %s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - self.restartDnodes() - tdSql.query("select 1-10 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , min(asct1) from ( select " - sql += "%s as asct1, ts ," % base_fun_1 - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") %s " % random.choice(self.unionall_or_union) - sql += "select ts , max(asct2) from ( select " - sql += "%s as asct1, ts ," % base_fun_1 - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15437 tdSql.query(sql) - #TD-15437 self.cur1.execute(sql) - - #3 inter union not support - tdSql.query("select 1-11 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , min(asct1), max(asct2) from ( select " - sql += "%s as asct1, ts ," % base_fun_1 - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - #sql += "%s " % random.choice(limit1_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s as asct1, ts ," % base_fun_1 - sql += "%s as asct2, " % base_fun_2 - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15837 tdSql.query(sql) - # self.cur1.execute(sql) - - tdSql.query("select 1-12 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , max(asct1) from ( select t1.ts as ts," - sql += "%s, " % base_fun_join_1 - sql += "%s as asct1, " % base_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "and %s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-13 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts ," - sql += "%s, " % base_fun_1 - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % base_fun_2 - sql += "%s " % random.choice(self.t_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(300) - self.cur1.execute(sql) - - tdSql.query("select 1-14 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select avg(asct1),count(asct2) from ( select " - sql += "%s as asct1, " % base_fun_1 - sql += "%s as asct2" % base_fun_2 - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ) ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 1-15 as base_nest from stable_1 limit 1;") - for i in range(self.fornum): - sql = "select ts , max(asct1) from ( select t1.ts as ts," - sql += "%s, " % base_fun_join_1 - sql += "%s as asct1, " % base_fun_join_2 - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s " % random.choice(self.q_select) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - #taos -f sql - startTime_taos_f = time.time() - print("taos -f %s sql start!" %baselist) - taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) - _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") - print("taos -f %s sql over!" %baselist) - endTime_taos_f = time.time() - print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) - - print("=========%s====over=============" %baselist) - - def function_before_26(self): - - print('=====================2.6 old function start ===========') - os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) - - self.dropandcreateDB_random("%s" %self.db_nest, 1) - - #1 select * from (select column form regular_table where <\>\in\and\or order by) - tdSql.query("select 1-1 from stable_1;") - for i in range(self.fornum): - #sql = "select ts , * from ( select " ===暂时不支持select * ,用下面这一行 - sql = "select ts from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - #1 outer union not support - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 1-2 from stable_1;") - for i in range(self.fornum): - #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") union " - #sql += "select ts , * from ( select " - sql += "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 1-2 from stable_1;") - for i in range(self.fornum): - #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") union all " - #sql += "select ts , * from ( select " - sql += "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(200) - self.cur1.execute(sql) - - #1 inter union not support - tdSql.query("select 1-3 from stable_1;") - for i in range(self.fornum): - #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "" - sql += " union select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15607 tdSql.query(sql) - #tdSql.checkRows(200) - #self.cur1.execute(sql) - - tdSql.query("select 1-3 from stable_1;") - for i in range(self.fornum): - #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += " union all select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15607 tdSql.query(sql) - # tdSql.checkRows(300) - #self.cur1.execute(sql) - - #join:select * from (select column form regular_table1,regular_table2 where t1.ts=t2.ts and <\>\in\and\or order by) - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 1-4 from stable_1;") - for i in range(self.fornum): - #sql = "select ts , * from ( select t1.ts ," - sql = "select * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - - #2 select column from (select * form regular_table ) where <\>\in\and\or order by - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 2-1 from stable_1;") - for i in range(self.fornum): - sql = "select ts ," - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s " % random.choice(self.q_select) - sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(100) - self.cur1.execute(sql) - - #join: select column from (select column form regular_table1,regular_table2 )where t1.ts=t2.ts and <\>\in\and\or order by - #cross join not supported yet - tdSql.query("select 2-2 from stable_1;") - for i in range(self.fornum): - sql = "select ts , * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 ) where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.order_u_where) - #sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) - - #3 select * from (select column\tag form stable where <\>\in\and\or order by ) - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 3-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(300) - self.cur1.execute(sql) - tdSql.query("select 3-1 from stable_1;") - for i in range(self.fornum): - sql = "select ts, " - sql += "%s " % random.choice(self.s_r_select) - sql += "from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.t_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(300) - self.cur1.execute(sql) - - # select ts,* from (select column\tag form stable1,stable2 where t1.ts = t2.ts and <\>\in\and\or order by ) - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 3-2 from stable_1;") - for i in range(self.fornum): - sql = "select ts , * from ( select t1.ts , " - sql += "t1.%s, " % random.choice(self.s_s_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.s_s_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # TD-15609 tdSql.query(sql) - # tdSql.checkRows(100) - #self.cur1.execute(sql) - - #3 outer union not support - self.restartDnodes() - tdSql.query("select 3-3 from stable_1;") - for i in range(self.fornum): - #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") union " - sql += "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(300) - self.cur1.execute(sql) - for i in range(self.fornum): - #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ") union all " - sql += "select ts from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(600) - self.cur1.execute(sql) - - #3 inter union not support - tdSql.query("select 3-4 from stable_1;") - for i in range(self.fornum): - sql = "select ts , * from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += " %s " % random.choice(self.unionall_or_union) - sql += " select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15837 tdSql.query(sql) - # self.cur1.execute(sql) - - #join:select * from (select column form stable1,stable2 where t1.ts=t2.ts and <\>\in\and\or order by) - tdSql.query("select 3-5 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # TD-15609 tdSql.query(sql) - # tdSql.checkRows(100) - #self.cur1.execute(sql) - - tdSql.query("select 3-6 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t1.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.%s, " % random.choice(self.q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # TD-15609 同上 tdSql.query(sql) - # tdSql.checkRows(100) - #self.cur1.execute(sql) - - #4 select column from (select * form stable where <\>\in\and\or order by ) - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 4-1 from stable_1;") - for i in range(self.fornum): - sql = "select ts , " - sql += "%s, " % random.choice(self.q_select) - sql += "%s, " % random.choice(self.q_select) - sql += "%s " % random.choice(self.t_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(300) - self.cur1.execute(sql) - - #5 select distinct column\tag from (select * form stable where <\>\in\and\or order by limit offset ) - tdSql.query("select 5-1 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.dqt_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15500 tdSql.query(sql) - #self.cur1.execute(sql) - - #5-1 select distinct column\tag from (select calc form stable where <\>\in\and\or order by limit offset ) - tdSql.query("select 5-2 from stable_1;") - for i in range(self.fornum): - sql = "select distinct c5_1 " - sql += " from ( select " - sql += "%s " % random.choice(self.calc_select_in_ts) - sql += " as c5_1 from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - #sql += "%s " % random.choice(order_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - #tdSql.checkRows(1)有的函数还没有提交,会不返回结果,先忽略 - self.cur1.execute(sql) - - #6-error select * from (select distinct(tag) form stable where <\>\in\and\or order by limit ) - tdSql.query("select 6-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.dt_select) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) - tdSql.query("select 6-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.dt_select) - sql += " from stable_1 where " - sql += "%s ) ;" % random.choice(self.qt_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - #7-error select * from (select distinct(tag) form stable where <\>\in\and\or order by limit ) - tdSql.query("select 7-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.dq_select) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[0] , self.limit_where[1]] ) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) #distinct 和 order by 不能混合使用 - tdSql.query("select 7-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.dq_select) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - #sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice([self.limit_where[0] , self.limit_where[1]] ) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(1) - self.cur1.execute(sql) - - #calc_select,TWA/Diff/Derivative/Irate are not allowed to apply to super table directly - #8 select * from (select ts,calc form ragular_table where <\>\in\and\or order by ) - - # dcDB = self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 8-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select ts ," - sql += "%s " % random.choice(self.calc_select_support_ts) - sql += "from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) # 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function - self.cur1.execute(sql) - tdSql.query("select 8-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_select_not_support_ts) - sql += "from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) # 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function - #self.cur1.execute(sql) - - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_select_in_ts) - sql += "from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 8-2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select t1.ts, " - sql += "%s " % random.choice(self.calc_select_in_support_ts_j) - sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql)# 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function - self.cur1.execute(sql) - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_select_in_not_support_ts_j) - sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - ##top返回结果有问题 tdSql.checkRows(1) - #self.cur1.execute(sql) - - #9 select * from (select ts,calc form stable where <\>\in\and\or order by ) - # self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 9-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_select_not_support_ts) - sql += "from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - # self.cur1.execute(sql) - tdSql.query("select 9-2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select ts ," - sql += "%s " % random.choice(self.calc_select_support_ts) - sql += "from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 9-3 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_select_in_not_support_ts_j) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - #self.cur1.execute(sql) - tdSql.query("select 9-4 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select t1.ts," - sql += "%s " % random.choice(self.calc_select_in_support_ts_j) - sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += " and %s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - #10 select calc from (select * form regualr_table where <\>\in\and\or order by ) - tdSql.query("select 10-1 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_select_in_ts) - sql += "as calc10_1 from ( select * from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(1) - self.cur1.execute(sql) - - #10-1 select calc from (select * form regualr_table where <\>\in\and\or order by ) - # rsDn = self.restartDnodes() - # self.dropandcreateDB_random("%s" %db, 1) - # rsDn = self.restartDnodes() - tdSql.query("select 10-2 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_select_all) - sql += "as calc10_2 from ( select * from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - # tdSql.checkRows(1) - #self.cur1.execute(sql) - - #10-2 select calc from (select * form regualr_tables where <\>\in\and\or order by ) - tdSql.query("select 10-3 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s as calc10_3 " % random.choice(self.calc_select_all) - sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += " and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 10-4 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s as calc10_4 " % random.choice(self.calc_select_all) - sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += " and %s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - # tdSql.checkRows(1) - #self.cur1.execute(sql) - - #11 select calc from (select * form stable where <\>\in\and\or order by limit ) - tdSql.query("select 11-1 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_select_in_ts) - sql += "as calc11_1 from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - tdSql.checkRows(1) - self.cur1.execute(sql) - - #11-1 select calc from (select * form stable where <\>\in\and\or order by limit ) - tdSql.query("select 11-2 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_select_all) - sql += "as calc11_1 from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - #self.cur1.execute(sql) - #不好计算结果 tdSql.checkRows(1) - - #11-2 select calc from (select * form stables where <\>\in\and\or order by limit ) - tdSql.query("select 11-3 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_select_all) - sql += "as calc11_1 from ( select * from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 11-4 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_select_all) - sql += "as calc11_1 from ( select * from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - #self.cur1.execute(sql) - - #12 select calc-diff from (select * form regualr_table where <\>\in\and\or order by limit ) - ##self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 12-1 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_calculate_regular) - sql += " from ( select * from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - ##目前derivative不支持 tdSql.query(sql) - # tdSql.checkRows(1) - #self.cur1.execute(sql) - - tdSql.query("select 12-2 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_calculate_regular) - sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #目前derivative不支持 tdSql.query(sql) - # tdSql.checkRows(1) - #self.cur1.execute(sql) - - tdSql.query("select 12-2.2 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_calculate_regular) - sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #目前derivative不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - #12-1 select calc-diff from (select * form stable where <\>\in\and\or order by limit ) - tdSql.query("select 12-3 from stable_1;") - self.restartDnodes() - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_calculate_regular) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.group_where) - sql += ") " - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #目前derivative不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 12-4 from stable_1;") - #join query does not support group by - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_calculate_regular_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.group_where_j) - sql += ") " - #sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) 目前de函数不支持,另外看看需要不需要将group by和pari by分开 - #self.cur1.execute(sql) - - tdSql.query("select 12-5 from stable_1;") - #join query does not support group by - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_calculate_regular_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.group_where_j) - sql += ") " - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #derivative not support tdSql.query(sql) - #self.cur1.execute(sql) - - - #13 select calc-diff as diffns from (select * form stable where <\>\in\and\or order by limit ) - tdSql.query("select 13-1 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_calculate_regular) - sql += " as calc13_1 from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.orders_desc_where) - sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #derivative not support tdSql.query(sql) - #self.cur1.execute(sql) - - #14 select * from (select calc_aggregate_alls as agg from stable where <\>\in\and\or group by order by slimit soffset ) - # TD-5955 select * from ( select count (q_double) from stable_1 where t_bool = true or t_bool = false group by loc order by ts asc slimit 1 ) ; - tdSql.query("select 14-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all) - sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all) - sql += "%s " % random.choice(self.calc_aggregate_all) - sql += " as calc14_3 from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.group_where) - sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15678 tdSql.query(sql) - # tdSql.checkRows(1) - #self.cur1.execute(sql) - - # error group by in out query - tdSql.query("select 14-2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all) - sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all) - sql += "%s " % random.choice(self.calc_aggregate_all) - sql += " as calc14_3 from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.group_where) - sql += "%s " % random.choice(self.having_support) - sql += "%s " % random.choice(self.orders_desc_where) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s " % random.choice(self.group_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15678 tdSql.query(sql) - # tdSql.checkRows(1) - #self.cur1.execute(sql) - - #14-2 select * from (select calc_aggregate_all_js as agg from stables where <\>\in\and\or group by order by slimit soffset ) - tdSql.query("select 14-3 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all_j) - sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all_j) - sql += "%s " % random.choice(self.calc_aggregate_all_j) - sql += " as calc14_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 14-4 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all_j) - sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all_j) - sql += "%s " % random.choice(self.calc_aggregate_all_j) - sql += " as calc14_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.partiton_where_j) - sql += "%s " % random.choice(self.slimit1_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - #15 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by slimit soffset ) - tdSql.query("select 15-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_regular) - sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_regular) - sql += "%s " % random.choice(self.calc_aggregate_regular) - sql += " as calc15_3 from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.group_where_regular) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #Invalid function name: twa' - # tdSql.checkRows(1) - #self.cur1.execute(sql) - - tdSql.query("select 15-2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_regular_j) - sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_regular_j) - sql += "%s " % random.choice(self.calc_aggregate_regular_j) - sql += " as calc15_3 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.group_where_regular_j) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #Invalid function name: twa' - #self.cur1.execute(sql) - - tdSql.query("select 15-2.2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_regular_j) - sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_regular_j) - sql += "%s " % random.choice(self.calc_aggregate_regular_j) - sql += " as calc15_3 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.group_where_regular_j) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - sql += "%s ;" % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #Invalid function name: twa' - #self.cur1.execute(sql) - - self.restartDnodes() - tdSql.query("select 15-3 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname) - sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname) - sql += "%s " % random.choice(self.calc_aggregate_groupbytbname) - sql += " as calc15_3 from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.group_where) - sql += "%s " % random.choice(self.having_support) - sql += "%s " % random.choice(self.order_desc_where) - sql += ") " - sql += "order by calc15_1 " - sql += "%s " % random.choice(self.limit_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #Invalid function name: twa',可能还的去掉order by - #self.cur1.execute(sql) - - tdSql.query("select 15-4 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname_j) - sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname_j) - sql += "%s " % random.choice(self.calc_aggregate_groupbytbname_j) - sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.group_where_j) - sql += "%s " % random.choice(self.having_support_j) - #sql += "%s " % random.choice(orders_desc_where) - sql += ") " - sql += "order by calc15_1 " - sql += "%s " % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #'Invalid function name: irate' - #self.cur1.execute(sql) - - tdSql.query("select 15-4.2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname_j) - sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname_j) - sql += "%s " % random.choice(self.calc_aggregate_groupbytbname_j) - sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.group_where_j) - sql += "%s " % random.choice(self.having_support_j) - sql += "%s " % random.choice(self.orders_desc_where) - sql += ") " - sql += "order by calc15_1 " - sql += "%s " % random.choice(self.limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15678 #tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 15-5 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname) - sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname) - sql += "%s " % random.choice(self.calc_aggregate_groupbytbname) - sql += " as calc15_3 from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.group_where) - sql += ") " - sql += "order by calc15_1 " - sql += "%s " % random.choice(self.limit_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #'Invalid function name: irate' - #self.cur1.execute(sql) - - #16 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by limit offset ) - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 16-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_0 , " % random.choice(self.calc_calculate_all) - sql += "%s as calc16_1 , " % random.choice(self.calc_aggregate_all) - sql += "%s as calc16_2 " % random.choice(self.calc_select_in) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.group_where) - #sql += "%s " % random.choice(having_support)having和 partition不能混合使用 - sql += ") " - sql += "order by calc16_0 " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 16-2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_0 " % random.choice(self.calc_calculate_all_j) - sql += ", %s as calc16_1 " % random.choice(self.calc_aggregate_all_j) - #sql += ", %s as calc16_2 " % random.choice(self.calc_select_in_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += ") " - sql += "order by calc16_0 " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 16-2.2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_0 " % random.choice(self.calc_calculate_all_j) - sql += ", %s as calc16_1 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += ") " - sql += "order by calc16_0 " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 16-3 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(self.calc_calculate_regular) - sql += " from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "limit 2 ) " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql)#Invalid function name: derivative' - #self.cur1.execute(sql) - - tdSql.query("select 16-4 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(self.calc_calculate_regular_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "limit 2 ) " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql)#Invalid function name: derivative' - #self.cur1.execute(sql) - - tdSql.query("select 16-4.2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(self.calc_calculate_regular_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += "limit 2 ) " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql)#Invalid function name: derivative' - #self.cur1.execute(sql) - - tdSql.query("select 16-5 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 , " % random.choice(self.calc_calculate_all) - sql += "%s as calc16_1 , " % random.choice(self.calc_calculate_regular) - sql += "%s as calc16_2 " % random.choice(self.calc_select_all) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.group_where) - #sql += "%s " % random.choice(having_support) - sql += ") " - sql += "order by calc16_1 " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 16-6 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(self.calc_calculate_groupbytbname) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.group_where) - sql += "limit 2 ) " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #Invalid function name: derivative' tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 16-7 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(self.calc_calculate_groupbytbname_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "limit 2 ) " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #Invalid function name: derivative' tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 16-8 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(self.calc_calculate_groupbytbname_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += "limit 2 ) " - sql += "%s " % random.choice(self.limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #Invalid function name: derivative' tdSql.query(sql) - #self.cur1.execute(sql) - - #17 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or interval_sliding group by having order by limit offset )interval_sliding - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 17-1 from stable_1;") - for i in range(self.fornum): - #this is having_support , but tag-select cannot mix with last_row,other select can - sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(having_support) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-2 from stable_1;") - for i in range(self.fornum): - #this is having_support , but tag-select cannot mix with last_row,other select can - sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all_j) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.interval_sliding) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-2.2 from stable_1;") - for i in range(self.fornum): - #this is having_support , but tag-select cannot mix with last_row,other select can - sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all_j) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - self.restartDnodes() - tdSql.query("select 17-3 from stable_1;") - for i in range(self.fornum): - #this is having_tagnot_support , because tag-select cannot mix with last_row... - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.having_tagnot_support) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-4 from stable_1;") - for i in range(self.fornum): - #this is having_tagnot_support , because tag-select cannot mix with last_row... - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-4.2 from stable_1;") - for i in range(self.fornum): - #this is having_tagnot_support , because tag-select cannot mix with last_row... - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-5 from stable_1;") - for i in range(self.fornum): - #having_not_support - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.partiton_where) - sql += "%s " % random.choice(self.interval_sliding) - # sql += "%s " % random.choice(self.having_not_support) - # sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-6 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-7 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-7.2 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - self.restartDnodes() - tdSql.query("select 17-8 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) - sql += " from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-9 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 17-10 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.interval_sliding) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - #18 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or session order by limit )interval_sliding - tdSql.query("select 18-1 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all) - sql += " from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.session_where) - #sql += "%s " % random.choice(self.fill_where) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 18-2 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.session_u_where) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 18-2.2 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.session_u_where) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - self.restartDnodes() - tdSql.query("select 18-3 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all) - sql += " from stable_1_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.session_where) - #sql += "%s " % random.choice(self.fill_where) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 18-4 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.session_u_where) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 18-4.2 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.session_u_where) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 18-5 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.session_where) - #sql += "%s " % random.choice(self.fill_where) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 18-6 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.session_u_where) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 18-7 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.session_u_where) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - #19 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or session order by limit )interval_sliding - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 19-1 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all) - sql += " from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.state_window) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 19-2 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - sql += "%s " % random.choice(self.state_u_window) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 19-2.2 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - sql += "%s " % random.choice(self.state_u_window) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 19-3 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all) - sql += " from stable_1_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.state_window) - #sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 19-4 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - #sql += "%s " % random.choice(self.state_window) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 19-4.2 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_or_where) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 19-5 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += "%s " % random.choice(self.state_window) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit1_where) - sql += ") " - sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) #'STATE_WINDOW not support for super table query' - - tdSql.query("select 19-6 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.q_u_where) - #sql += "%s " % random.choice(self.state_window) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - tdSql.query("select 19-7 from stable_1;") - for i in range(self.fornum): - sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) - sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(self.qt_u_or_where) - #sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - #sql += "%s " % random.choice(self.interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - #20 select * from (select calc_select_fills form regualr_table or stable where <\>\in\and\or fill_where group by order by limit offset ) - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 20-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(self.calc_select_fill) - sql += "%s ," % random.choice(self.calc_select_fill) - sql += "%s " % random.choice(self.calc_select_fill) - sql += " from stable_1 where " - sql += "%s " % random.choice(self.interp_where) - sql += "%s " % random.choice(self.fill_where) - sql += "%s " % random.choice(self.group_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - #interp不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - rsDn = self.restartDnodes() - tdSql.query("select 20-2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(self.calc_select_fill_j) - sql += "%s ," % random.choice(self.calc_select_fill_j) - sql += "%s " % random.choice(self.calc_select_fill_j) - sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s and " % random.choice(self.t_join_where) - sql += "%s " % random.choice(self.interp_where_j) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - #interp不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 20-2.2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(self.calc_select_fill_j) - sql += "%s ," % random.choice(self.calc_select_fill_j) - sql += "%s " % random.choice(self.calc_select_fill_j) - sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s and " % random.choice(self.qt_u_or_where) - sql += "%s " % random.choice(self.interp_where_j) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - #interp不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 20-3 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(self.calc_select_fill) - sql += "%s ," % random.choice(self.calc_select_fill) - sql += "%s " % random.choice(self.calc_select_fill) - sql += " from stable_1 where " - sql += "%s " % self.interp_where[2] - sql += "%s " % random.choice(self.fill_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - #interp不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 20-4 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(self.calc_select_fill_j) - sql += "%s ," % random.choice(self.calc_select_fill_j) - sql += "%s " % random.choice(self.calc_select_fill_j) - sql += " from stable_1 t1, table_1 t2 where t1.ts = t2.ts and " - #sql += "%s and " % random.choice(self.t_join_where) - sql += "%s " % self.interp_where_j[random.randint(0,5)] - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - #interp不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 20-4.2 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(self.calc_select_fill_j) - sql += "%s ," % random.choice(self.calc_select_fill_j) - sql += "%s " % random.choice(self.calc_select_fill_j) - sql += " from stable_1 t1, stable_1_1 t2 where t1.ts = t2.ts and " - sql += "%s and " % random.choice(self.qt_u_or_where) - sql += "%s " % self.interp_where_j[random.randint(0,5)] - sql += "%s " % random.choice(self.fill_where) - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - ##interp不支持 tdSql.error(sql) - #self.cur1.execute(sql) - - tdSql.query("select 20-5 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(self.calc_select_fill) - sql += "%s ," % random.choice(self.calc_select_fill) - sql += "%s " % random.choice(self.calc_select_fill) - sql += " from regular_table_1 where " - sql += "%s " % self.interp_where[1] - sql += "%s " % random.choice(self.fill_where) - sql += "%s " % random.choice(self.order_where) - sql += "%s " % random.choice(self.limit_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - ##interp不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - tdSql.query("select 20-6 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(self.calc_select_fill_j) - sql += "%s ," % random.choice(self.calc_select_fill_j) - sql += "%s " % random.choice(self.calc_select_fill_j) - sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - #sql += "%s " % random.choice(self.interp_where_j) - sql += "%s " % self.interp_where_j[random.randint(0,5)] - sql += "%s " % random.choice(self.order_u_where) - sql += "%s " % random.choice(self.limit_u_where) - sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - ##interp不支持 tdSql.query(sql) - #self.cur1.execute(sql) - - #1 select * from (select * from (select * form regular_table where <\>\in\and\or order by limit )) - tdSql.query("select 1-1 from stable_1;") - for i in range(self.fornum): - # sql_start = "select * from ( " - # sql_end = ")" - for_num = random.randint(1, 15); - sql = "select * from (" * for_num - sql += "select * from ( select * from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += ")) " - sql += ")" * for_num - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - sql2 = "select * from ( select * from ( select " - sql2 += "%s, " % random.choice(self.s_r_select) - sql2 += "%s, " % random.choice(self.q_select) - sql2 += "ts from regular_table_1 where " - sql2 += "%s " % random.choice(self.q_where) - sql2 += ")) " - tdLog.info(sql2) - tdLog.info(len(sql2)) - tdSql.query(sql2) - self.cur1.execute(sql2) - - self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1) - self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql ,1,10,3,3) - self.data_matrix_equal('%s' %sql ,1,10,3,3,'%s' %sql2 ,1,10,3,3) - - for i in range(self.fornum): - for_num = random.randint(1, 15); - sql = "select ts from (" * for_num - sql += "select * from ( select * from ( select " - sql += "%s, " % random.choice(self.s_r_select) - sql += "%s, " % random.choice(self.q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(self.q_where) - sql += ")) " - sql += ")" * for_num - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - sql2 = "select * from ( select * from ( select " - sql2 += "%s, " % random.choice(self.s_r_select) - sql2 += "%s, " % random.choice(self.q_select) - sql2 += "ts from regular_table_1 where " - sql2 += "%s " % random.choice(self.q_where) - sql2 += ")) " - tdLog.info(sql2) - tdLog.info(len(sql2)) - tdSql.query(sql2) - self.cur1.execute(sql2) - - self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1) - - #2 select * from (select * from (select * form stable where <\>\in\and\or order by limit )) - tdSql.query("select 2-1 from stable_1;") - for i in range(self.fornum): - for_num = random.randint(1, 15); - sql = "select * from (" * for_num - sql += "select * from ( select * from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.qt_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += ")) " - sql += ")" * for_num - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - sql2 = "select * from ( select * from ( select " - sql2 += "%s, " % random.choice(self.s_s_select) - sql2 += "%s, " % random.choice(self.qt_select) - sql2 += "ts from stable_1 where " - sql2 += "%s " % random.choice(self.q_where) - sql2 += ")) " - tdLog.info(sql2) - tdLog.info(len(sql2)) - tdSql.query(sql2) - self.cur1.execute(sql2) - - self.data_matrix_equal('%s' %sql ,1,10,3,3,'%s' %sql2 ,1,10,3,3) - - for i in range(self.fornum): - for_num = random.randint(1, 15); - sql = "select ts from (" * for_num - sql += "select * from ( select * from ( select " - sql += "%s, " % random.choice(self.s_s_select) - sql += "%s, " % random.choice(self.qt_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(self.q_where) - sql += ")) " - sql += ")" * for_num - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - sql2 = "select ts from ( select * from ( select " - sql2 += "%s, " % random.choice(self.s_s_select) - sql2 += "%s, " % random.choice(self.qt_select) - sql2 += "ts from stable_1 where " - sql2 += "%s " % random.choice(self.q_where) - sql2 += ")) " - tdLog.info(sql2) - tdLog.info(len(sql2)) - tdSql.query(sql2) - self.cur1.execute(sql2) - - self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1) - - #3 select ts ,calc from (select * form stable where <\>\in\and\or order by limit ) - #self.dropandcreateDB_random("%s" %db, 1) - tdSql.query("select 3-1 from stable_1;") - for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(self.calc_calculate_regular) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.orders_desc_where) - sql += "%s " % random.choice(self.limit_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #'Invalid function name: derivative' tdSql.query(sql) - #self.cur1.execute(sql) - - #4 select * from (select calc form stable where <\>\in\and\or order by limit ) - tdSql.query("select 4-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s " % random.choice(self.calc_select_in_ts) - sql += "from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - #sql += "%s " % random.choice(self.order_desc_where) - sql += "%s " % random.choice(self.limit_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - self.cur1.execute(sql) - - #5 select ts ,tbname from (select * form stable where <\>\in\and\or order by limit ) - tdSql.query("select 5-1 from stable_1;") - for i in range(self.fornum): - sql = "select ts , tbname , " - sql += "%s ," % random.choice(self.calc_calculate_regular) - sql += "%s ," % random.choice(self.dqt_select) - sql += "%s " % random.choice(self.qt_select) - sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(self.qt_where) - sql += "%s " % random.choice(self.orders_desc_where) - sql += "%s " % random.choice(self.limit_where) - sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) - - #special sql - tdSql.query("select 6-1 from stable_1;") - for i in range(self.fornum): - sql = "select * from ( select _block_dist() from stable_1);" - # tdSql.query(sql) - # tdSql.checkRows(1) - sql = "select _block_dist() from (select * from stable_1);" - tdSql.error(sql) - sql = "select * from (select database());" - tdSql.error(sql) - sql = "select * from (select client_version());" - tdSql.error(sql) - sql = "select * from (select client_version() as version);" - tdSql.error(sql) - sql = "select * from (select server_version());" - tdSql.error(sql) - sql = "select * from (select server_version() as version);" - tdSql.error(sql) - sql = "select * from (select server_status());" - tdSql.error(sql) - sql = "select * from (select server_status() as status);" - tdSql.error(sql) - - #taos -f sql - startTime_taos_f = time.time() - print("taos -f sql start!") - taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) - _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") - print("taos -f sql over!") - endTime_taos_f = time.time() - print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) - - print('=====================2.6 old function end ===========') - +from .nestedQuery import * +class TDTestCase(TDTestCase): + def run(self): tdSql.prepare() + + startTime = time.time() - startTime = time.time() - - # - - - #self.math_nest(['TAIL']) #TD-16009 - # self.math_nest(['HYPERLOGLOG']) #TD-16038 + # self.function_before_26() + # self.math_nest(['UNIQUE']) - - - - # # - #self.function_before_26() #TD-16031 - - # self.math_nest(['ABS','SQRT']) #TD-16042 - # self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN']) - # self.math_nest(['POW','LOG']) #TD-16039 - # self.math_nest(['FLOOR','CEIL','ROUND']) - # #self.math_nest(['SAMPLE']) #TD-16017 - # #self.math_nest(['CSUM']) #TD-15936 crash - # self.math_nest(['MAVG']) - - self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) - self.str_nest(['LENGTH','CHAR_LENGTH']) - self.str_nest(['SUBSTR']) #TD-16042 - self.str_nest(['CONCAT']) #TD-16002 偶尔 - self.str_nest(['CONCAT_WS']) #TD-16002 偶尔 - # self.time_nest(['CAST']) #TD-16017偶尔,放到time里起来弄 - self.time_nest(['CAST_1']) - self.time_nest(['CAST_2']) - self.time_nest(['CAST_3']) - self.time_nest(['CAST_4']) - - - - # self.time_nest(['NOW','TODAY']) # - # self.time_nest(['TIMEZONE']) # - # self.time_nest(['TIMETRUNCATE']) #TD-16039 + # self.math_nest(['MODE']) + # self.math_nest(['SAMPLE']) + + # self.math_nest(['ABS','SQRT']) + # self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN']) + # self.math_nest(['POW','LOG']) + # self.math_nest(['FLOOR','CEIL','ROUND']) + # self.math_nest(['MAVG']) + # self.math_nest(['HYPERLOGLOG']) + # self.math_nest(['TAIL']) + # self.math_nest(['CSUM']) + # self.math_nest(['statecount','stateduration']) + # self.math_nest(['HISTOGRAM']) + + self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) + self.str_nest(['LENGTH','CHAR_LENGTH']) + self.str_nest(['SUBSTR']) + self.str_nest(['CONCAT']) + self.str_nest(['CONCAT_WS']) + # self.time_nest(['CAST']) #放到time里起来弄 + # self.time_nest(['CAST_1']) + # self.time_nest(['CAST_2']) + # self.time_nest(['CAST_3']) + # self.time_nest(['CAST_4']) + + + + # self.time_nest(['NOW','TODAY']) + # self.time_nest(['TIMEZONE']) + # self.time_nest(['TIMETRUNCATE']) # self.time_nest(['TO_ISO8601']) - # self.time_nest(['TO_UNIXTIMESTAMP'])#core多 + # self.time_nest(['TO_UNIXTIMESTAMP']) # self.time_nest(['ELAPSED']) - + # self.time_nest(['TIMEDIFF_1']) + # self.time_nest(['TIMEDIFF_2']) + endTime = time.time() print("total time %ds" % (endTime - startTime)) - + def stop(self): From 2b69cad1691a6bd0e4ab97b8622cf62a463fe72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chappyguoxy=E2=80=9D?= <“happy_guoxy@163.com”> Date: Mon, 24 Oct 2022 11:24:54 +0800 Subject: [PATCH 21/72] test: refine query cases --- tests/system-test/2-query/nestedQuery.py | 6958 ++++++++++++++++------ 1 file changed, 5291 insertions(+), 1667 deletions(-) diff --git a/tests/system-test/2-query/nestedQuery.py b/tests/system-test/2-query/nestedQuery.py index 757a75cf88..c6567a8e3b 100755 --- a/tests/system-test/2-query/nestedQuery.py +++ b/tests/system-test/2-query/nestedQuery.py @@ -15,6 +15,7 @@ import random import os import time import taos +import subprocess from faker import Faker from util.log import tdLog from util.cases import tdCases @@ -23,39 +24,589 @@ from util.dnodes import tdDnodes from util.dnodes import * class TDTestCase: - updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + updatecfgDict = {'maxSQLLength':1048576,'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"udfDebugFlag":143} - + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - testcasePath = os.path.split(__file__)[0] - testcaseFilename = os.path.split(__file__)[-1] - os.system("rm -rf %s/%s.sql" % (testcasePath,testcaseFilename)) - - now = time.time() - self.ts = int(round(now * 1000)) + self.testcasePath = os.path.split(__file__)[0] + self.testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + self.num = 10 - self.fornum = 5 + self.fornum = 15 + + self.db_nest = "nest" + self.dropandcreateDB_random("%s" %self.db_nest, 1) + + # regular column select + #q_select= ['ts' , '*' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts '] + self.q_select= ['q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts ', 'q_int_null ', 'q_bigint_null ' , 'q_bigint_null ' , 'q_smallint_null ' , 'q_tinyint_null ' , 'q_bool_null ' , 'q_binary_null ' , 'q_nchar_null ' ,'q_float_null ' , 'q_double_null ' ,'q_ts_null '] - # def case_common(self): - # db = "nested" - # self.dropandcreateDB("%s" % db, 1) + # tag column select + #t_select= ['*' , 'loc' ,'t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts '] + self.t_select= ['loc','t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts '] - # conn1 = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos/") - # cur1 = conn1.cursor() - # cur1.execute('use "%s";' %self.db) - # sql = 'select * from stable_1 limit 5;' - # cur1.execute(sql) + # regular and tag column select + self.qt_select= self.q_select + self.t_select - # return(conn1,cur1) + # distinct regular column select + self.dq_select= ['distinct q_int', 'distinct q_bigint' , 'distinct q_smallint' , 'distinct q_tinyint' , + 'distinct q_bool' , 'distinct q_binary' , 'distinct q_nchar' ,'distinct q_float' , 'distinct q_double' ,'distinct q_ts '] + # distinct tag column select + self.dt_select= ['distinct loc', 'distinct t_int', 'distinct t_bigint' , 'distinct t_smallint' , 'distinct t_tinyint' , + 'distinct t_bool' , 'distinct t_binary' , 'distinct t_nchar' ,'distinct t_float' , 'distinct t_double' ,'distinct t_ts '] + + # distinct regular and tag column select + self.dqt_select= self.dq_select + self.dt_select + + # special column select + self.s_r_select= ['_c0', '_rowts' , '_C0' ] + self.s_s_select= ['tbname' , '_rowts' , '_c0', '_C0' ] + self.unionall_or_union= [ ' union ' , ' union all ' ] + + # regular column where + self.q_where = ['ts < now +1s','q_bigint >= -9223372036854775807 and q_bigint <= 9223372036854775807', 'q_int <= 2147483647 and q_int >= -2147483647', + 'q_smallint >= -32767 and q_smallint <= 32767','q_tinyint >= -127 and q_tinyint <= 127','q_float >= -1.7E308 and q_float <= 1.7E308', + 'q_double >= -1.7E308 and q_double <= 1.7E308', 'q_binary like \'binary%\' or q_binary = \'0\' ' , 'q_nchar like \'nchar%\' or q_nchar = \'0\' ' , + 'q_bool = true or q_bool = false' , 'q_bool in (0 , 1)' , 'q_bool in ( true , false)' , 'q_bool = 0 or q_bool = 1', + 'q_bigint between -9223372036854775807 and 9223372036854775807',' q_int between -2147483647 and 2147483647','q_smallint between -32767 and 32767', + 'q_bigint not between 9223372036854775807 and -9223372036854775807','q_int not between 2147483647 and -2147483647','q_smallint not between 32767 and -32767', + 'q_tinyint between -127 and 127 ','q_float >= -3.4E38 ','q_float <= 3.4E38 ','q_double >= -1.7E308 ', + 'q_double <= 1.7E308 ','q_float between -3.4E38 and 3.4E38 ','q_double between -1.7E308 and 1.7E308 ' ,'q_float not between 3.4E38 and -3.4E38 ','q_double not between 1.7E308 and -1.7E308 ', + 'q_float is not null ' ,'q_double is not null ' ,'q_binary match \'binary\' ','q_binary nmatch \'binarynchar\' ','q_nchar match \'nchar\' ','q_nchar nmatch \'binarynchar\' ', + 'q_binary like \'binary%\' ','(q_binary like \'binary%\' or q_nchar = \'0\' or q_binary = \'binary_\' ) ','q_nchar like \'nchar%\' ','(q_nchar like \'nchar%\' or q_binary = \'0\' or q_nchar = \'nchar_\' ) ',] + #TD-6201 ,'q_bool between 0 and 1' + + # regular column where for test union,join + self.q_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.q_bigint >= -9223372036854775807 and t1.q_bigint <= 9223372036854775807 and t2.q_bigint >= -9223372036854775807 and t2.q_bigint <= 9223372036854775807', + 't1.q_int <= 2147483647 and t1.q_int >= -2147483647 and t2.q_int <= 2147483647 and t2.q_int >= -2147483647', + 't1.q_smallint >= -32767 and t1.q_smallint <= 32767 and t2.q_smallint >= -32767 and t2.q_smallint <= 32767', + 't1.q_tinyint >= -127 and t1.q_tinyint <= 127 and t2.q_tinyint >= -127 and t2.q_tinyint <= 127', + 't1.q_float >= - 1.7E308 and t1.q_float <= 1.7E308 and t2.q_float >= - 1.7E308 and t2.q_float <= 1.7E308', + 't1.q_double >= - 1.7E308 and t1.q_double <= 1.7E308 and t2.q_double >= - 1.7E308 and t2.q_double <= 1.7E308', + 't1.q_binary like \'binary%\' and t2.q_binary like \'binary%\' ' , + 't1.q_nchar like \'nchar%\' and t2.q_nchar like \'nchar%\' ' , + 't1.q_bool in (0 , 1) and t2.q_bool in (0 , 1)' , 't1.q_bool in ( true , false) and t2.q_bool in ( true , false)' , + 't1.q_bigint between -9223372036854775807 and 9223372036854775807 and t2.q_bigint between -9223372036854775807 and 9223372036854775807', + 't1.q_int between -2147483647 and 2147483647 and t2.q_int between -2147483647 and 2147483647', + 't1.q_smallint between -32767 and 32767 and t2.q_smallint between -32767 and 32767', + 't1.q_tinyint between -127 and 127 and t2.q_tinyint between -127 and 127 ','t1.q_float between -1.7E308 and 1.7E308 and t2.q_float between -1.7E308 and 1.7E308', + 't1.q_double between -1.7E308 and 1.7E308 and t2.q_double between -1.7E308 and 1.7E308', + 't1.q_bigint not between 9223372036854775807 and -9223372036854775807 and t2.q_bigint not between 9223372036854775807 and -9223372036854775807', + 't1.q_int not between 2147483647 and -2147483647 and t2.q_int not between 2147483647 and -2147483647', + 't1.q_smallint not between 32767 and -32767 and t2.q_smallint not between 32767 and -32767', + 't1.q_tinyint not between 127 and -127 and t2.q_tinyint not between 127 and -127 ','t1.q_float not between -1.7E308 and -1.7E308 and t2.q_float not between 1.7E308 and -1.7E308', + 't1.q_double not between 1.7E308 and -1.7E308 and t2.q_double not between 1.7E308 and -1.7E308'] + #TD-6201 ,'t1.q_bool between 0 and 1 or t2.q_bool between 0 and 1'] + #'t1.q_bool = true and t1.q_bool = false and t2.q_bool = true and t2.q_bool = false' , 't1.q_bool = 0 and t1.q_bool = 1 and t2.q_bool = 0 and t2.q_bool = 1' , + + self.q_u_or_where = ['(t1.q_binary like \'binary%\' or t1.q_binary = \'0\' or t2.q_binary like \'binary%\' or t2.q_binary = \'0\' )' , + '(t1.q_nchar like \'nchar%\' or t1.q_nchar = \'0\' or t2.q_nchar like \'nchar%\' or t2.q_nchar = \'0\' )' , '(t1.q_bool = true or t1.q_bool = false or t2.q_bool = true or t2.q_bool = false)' , + '(t1.q_bool in (0 , 1) or t2.q_bool in (0 , 1))' , '(t1.q_bool in ( true , false) or t2.q_bool in ( true , false))' , '(t1.q_bool = 0 or t1.q_bool = 1 or t2.q_bool = 0 or t2.q_bool = 1)' , + '(t1.q_bigint between -9223372036854775807 and 9223372036854775807 or t2.q_bigint between -9223372036854775807 and 9223372036854775807)', + '(t1.q_int between -2147483647 and 2147483647 or t2.q_int between -2147483647 and 2147483647)', + '(t1.q_smallint between -32767 and 32767 or t2.q_smallint between -32767 and 32767)', + '(t1.q_tinyint between -127 and 127 or t2.q_tinyint between -127 and 127 )','(t1.q_float between -1.7E308 and 1.7E308 or t2.q_float between -1.7E308 and 1.7E308)', + '(t1.q_double between -1.7E308 and 1.7E308 or t2.q_double between -1.7E308 and 1.7E308)'] + + # tag column where + self.t_where = ['ts < now +1s','t_bigint >= -9223372036854775807 and t_bigint <= 9223372036854775807','t_int <= 2147483647 and t_int >= -2147483647', + 't_smallint >= -32767 and t_smallint <= 32767','q_tinyint >= -127 and t_tinyint <= 127','t_float >= -1.7E308 and t_float <= 1.7E308', + 't_double >= -1.7E308 and t_double <= 1.7E308', 't_binary like \'binary%\' or t_binary = \'0\' ' , 't_nchar like \'nchar%\' or t_nchar = \'0\'' , + 't_bool = true or t_bool = false' , 't_bool in (0 , 1)' , 't_bool in ( true , false)' , 't_bool = 0 or t_bool = 1', + 't_bigint between -9223372036854775807 and 9223372036854775807',' t_int between -2147483647 and 2147483647','t_smallint between -32767 and 32767', + 't_tinyint between -127 and 127 ','t_float between -1.7E308 and 1.7E308','t_double between -1.7E308 and 1.7E308', + 't_binary match \'binary\' ','t_binary nmatch \'binarynchar\' ','t_nchar match \'nchar\' ','t_nchar nmatch \'binarynchar\' ', + 't_binary like \'binary%\' ','t_nchar like \'nchar%\' ','(t_binary like \'binary%\' or t_nchar = \'0\' ) ','(t_nchar like \'nchar%\' or t_binary = \'0\' ) ',] + #TD-6201,'t_bool between 0 and 1' + + # tag column where for test union,join | this is not support + self.t_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.t_bigint >= -9223372036854775807 and t1.t_bigint <= 9223372036854775807 and t2.t_bigint >= -9223372036854775807 and t2.t_bigint <= 9223372036854775807', + 't1.t_int <= 2147483647 and t1.t_int >= -2147483647 and t2.t_int <= 2147483647 and t2.t_int >= -2147483647', + 't1.t_smallint >= -32767 and t1.t_smallint <= 32767 and t2.t_smallint >= -32767 and t2.t_smallint <= 32767', + 't1.t_tinyint >= -127 and t1.t_tinyint <= 127 and t2.t_tinyint >= -127 and t2.t_tinyint <= 127', + 't1.t_float >= -1.7E308 and t1.t_float <= 1.7E308 and t2.t_float >= -1.7E308 and t2.t_float <= 1.7E308', + 't1.t_double >= -1.7E308 and t1.t_double <= 1.7E308 and t2.t_double >= -1.7E308 and t2.t_double <= 1.7E308', + '(t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\') ' , + '(t1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' )' , '(t1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false)' , + 't1.t_bool in (0 , 1) and t2.t_bool in (0 , 1)' , 't1.t_bool in ( true , false) and t2.t_bool in ( true , false)' , '(t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1)', + 't1.t_bigint between -9223372036854775807 and 9223372036854775807 and t2.t_bigint between -9223372036854775807 and 9223372036854775807', + 't1.t_int between -2147483647 and 2147483647 and t2.t_int between -2147483647 and 2147483647', + 't1.t_smallint between -32767 and 32767 and t2.t_smallint between -32767 and 32767', + '(t1.t_tinyint between -127 and 127 and t2.t_tinyint between -127 and 127) ','t1.t_float between -1.7E308 and 1.7E308 and t2.t_float between -1.7E308 and 1.7E308', + '(t1.t_double between -1.7E308 and 1.7E308 and t2.t_double between -1.7E308 and 1.7E308)'] + #TD-6201,'t1.t_bool between 0 and 1 or t2.q_bool between 0 and 1'] + + self.t_u_or_where = ['(t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' )' , + '(t1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' )' , '(t1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false)' , + '(t1.t_bool in (0 , 1) or t2.t_bool in (0 , 1))' , '(t1.t_bool in ( true , false) or t2.t_bool in ( true , false))' , '(t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1)', + '(t1.t_bigint between -9223372036854775807 and 9223372036854775807 or t2.t_bigint between -9223372036854775807 and 9223372036854775807)', + '(t1.t_int between -2147483647 and 2147483647 or t2.t_int between -2147483647 and 2147483647)', + '(t1.t_smallint between -32767 and 32767 or t2.t_smallint between -32767 and 32767)', + '(t1.t_tinyint between -127 and 127 or t2.t_tinyint between -127 and 127 )','(t1.t_float between -1.7E308 and 1.7E308 or t2.t_float between -1.7E308 and 1.7E308)', + '(t1.t_double between -1.7E308 and 1.7E308 or t2.t_double between -1.7E308 and 1.7E308)'] + + # self.t_u_where = ['t1.ts < now +1s'] # 超级表tag不支持,暂时注掉 + # self.t_u_or_where = ['(t1.q_bool in (0 , 1))'] #超级表tag不支持,暂时注掉 + + # regular and tag column where + self.qt_where = self.q_where + self.t_where + #self.qt_where = self.q_where #超级表tag不支持,暂时注掉 + self.qt_u_where = self.q_u_where + self.t_u_where + # now,qt_u_or_where is not support + self.qt_u_or_where = self.q_u_or_where + self.t_u_or_where + + # tag column where for test super join | this is support , 't1.t_bool = t2.t_bool ' ??? + self.t_join_where = ['t1.t_bigint = t2.t_bigint ', 't1.t_int = t2.t_int ', 't1.t_smallint = t2.t_smallint ', 't1.t_tinyint = t2.t_tinyint ', + 't1.t_float = t2.t_float ', 't1.t_double = t2.t_double ', 't1.t_binary = t2.t_binary ' , 't1.t_nchar = t2.t_nchar ' ] + #self.t_join_where = ['t1.ts = t2.ts'] # 超级表tag不支持,暂时注掉 + + # session && fill + self.session_where = ['session(ts,10a)' , 'session(ts,10s)', 'session(ts,10m)' , 'session(ts,10h)','session(ts,10d)' , 'session(ts,10w)'] + self.session_u_where = ['session(t1.ts,10a)' , 'session(t1.ts,10s)', 'session(t1.ts,10m)' , 'session(t1.ts,10h)','session(t1.ts,10d)' , 'session(t1.ts,10w)', + 'session(t2.ts,10a)' , 'session(t2.ts,10s)', 'session(t2.ts,10m)' , 'session(t2.ts,10h)','session(t2.ts,10d)' , 'session(t2.ts,10w)'] + + self.fill_where = ['FILL(NONE)','FILL(PREV)','FILL(NULL)','FILL(LINEAR)','FILL(NEXT)','FILL(VALUE, 1.23)'] + + self.state_window = ['STATE_WINDOW(q_tinyint)','STATE_WINDOW(q_bigint)','STATE_WINDOW(q_int)','STATE_WINDOW(q_bool)','STATE_WINDOW(q_smallint)'] + self.state_u_window = ['STATE_WINDOW(t1.q_tinyint)','STATE_WINDOW(t1.q_bigint)','STATE_WINDOW(t1.q_int)','STATE_WINDOW(t1.q_bool)','STATE_WINDOW(t1.q_smallint)', + 'STATE_WINDOW(t2.q_tinyint)','STATE_WINDOW(t2.q_bigint)','STATE_WINDOW(t2.q_int)','STATE_WINDOW(t2.q_bool)','STATE_WINDOW(t2.q_smallint)'] + + # order by where + self.order_where = ['order by ts' , 'order by ts asc'] + self.order_u_where = ['order by t1.ts' , 'order by t1.ts asc' , 'order by t2.ts' , 'order by t2.ts asc'] + self.order_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' ] + self.orders_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' , 'order by ts,loc' , 'order by ts,loc asc' , 'order by ts,loc desc'] + + self.group_where = ['group by tbname , loc' , 'group by tbname', 'group by tbname, t_bigint', 'group by tbname,t_int', 'group by tbname, t_smallint', 'group by tbname,t_tinyint', + 'group by tbname,t_float', 'group by tbname,t_double' , 'group by tbname,t_binary', 'group by tbname,t_nchar', 'group by tbname,t_bool' ,'group by tbname ,loc ,t_bigint', + 'group by tbname,t_binary ,t_nchar ,t_bool' , 'group by tbname,t_int ,t_smallint ,t_tinyint' , 'group by tbname,t_float ,t_double ' , + 'PARTITION BY tbname , loc' , 'PARTITION BY tbname', 'PARTITION BY tbname, t_bigint', 'PARTITION BY tbname,t_int', 'PARTITION BY tbname, t_smallint', 'PARTITION BY tbname,t_tinyint', + 'PARTITION BY tbname,t_float', 'PARTITION BY tbname,t_double' , 'PARTITION BY tbname,t_binary', 'PARTITION BY tbname,t_nchar', 'PARTITION BY tbname,t_bool' ,'PARTITION BY tbname ,loc ,t_bigint', + 'PARTITION BY tbname,t_binary ,t_nchar ,t_bool' , 'PARTITION BY tbname,t_int ,t_smallint ,t_tinyint' , 'PARTITION BY tbname,t_float ,t_double '] + self.group_where_j = ['group by t1.loc' , 'group by t1.t_bigint', 'group by t1.t_int', 'group by t1.t_smallint', 'group by t1.t_tinyint', + 'group by t1.t_float', 'group by t1.t_double' , 'group by t1.t_binary', 'group by t1.t_nchar', 'group by t1.t_bool' ,'group by t1.loc ,t1.t_bigint', + 'group by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'group by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'group by t1.t_float ,t1.t_double ' , + 'PARTITION BY t1.loc' , 'PARTITION by t1.t_bigint', 'PARTITION by t1.t_int', 'PARTITION by t1.t_smallint', 'PARTITION by t1.t_tinyint', + 'PARTITION by t1.t_float', 'PARTITION by t1.t_double' , 'PARTITION by t1.t_binary', 'PARTITION by t1.t_nchar', 'PARTITION by t1.t_bool' ,'PARTITION BY t1.loc ,t1.t_bigint', + 'PARTITION by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'PARTITION by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'PARTITION by t1.t_float ,t1.t_double ', + 'group by t2.loc' , 'group by t2.t_bigint', 'group by t2.t_int', 'group by t2.t_smallint', 'group by t2.t_tinyint', + 'group by t2.t_float', 'group by t2.t_double' , 'group by t2.t_binary', 'group by t2.t_nchar', 'group by t2.t_bool' ,'group by t2.loc ,t2.t_bigint', + 'group by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'group by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'group by t2.t_float ,t2.t_double ' , + 'PARTITION BY t2.loc' , 'PARTITION by t2.t_bigint', 'PARTITION by t2.t_int', 'PARTITION by t2.t_smallint', 'PARTITION by t2.t_tinyint', + 'PARTITION by t2.t_float', 'PARTITION by t2.t_double' , 'PARTITION by t2.t_binary', 'PARTITION by t2.t_nchar', 'PARTITION by t2.t_bool' ,'PARTITION BY t2.loc ,t2.t_bigint', + 'PARTITION by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'PARTITION by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'PARTITION by t2.t_float ,t2.t_double '] + + self.group_only_where = ['group by tbname , loc' , 'group by tbname', 'group by tbname, t_bigint', 'group by tbname,t_int', 'group by tbname, t_smallint', 'group by tbname,t_tinyint', + 'group by tbname,t_float', 'group by tbname,t_double' , 'group by tbname,t_binary', 'group by tbname,t_nchar', 'group by tbname,t_bool' ,'group by tbname ,loc ,t_bigint', + 'group by tbname,t_binary ,t_nchar ,t_bool' , 'group by tbname,t_int ,t_smallint ,t_tinyint' , 'group by tbname,t_float ,t_double ' ] + self.group_only_where_j = ['group by t1.loc' , 'group by t1.t_bigint', 'group by t1.t_int', 'group by t1.t_smallint', 'group by t1.t_tinyint', + 'group by t1.t_float', 'group by t1.t_double' , 'group by t1.t_binary', 'group by t1.t_nchar', 'group by t1.t_bool' ,'group by t1.loc ,t1.t_bigint', + 'group by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'group by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'group by t1.t_float ,t1.t_double ' , + 'group by t2.loc' , 'group by t2.t_bigint', 'group by t2.t_int', 'group by t2.t_smallint', 'group by t2.t_tinyint', + 'group by t2.t_float', 'group by t2.t_double' , 'group by t2.t_binary', 'group by t2.t_nchar', 'group by t2.t_bool' ,'group by t2.loc ,t2.t_bigint', + 'group by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'group by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'group by t2.t_float ,t2.t_double ' ] + + self.partiton_where = ['PARTITION BY tbname , loc' , 'PARTITION BY tbname', 'PARTITION BY tbname, t_bigint', 'PARTITION BY tbname,t_int', 'PARTITION BY tbname, t_smallint', 'PARTITION BY tbname,t_tinyint', + 'PARTITION BY tbname,t_float', 'PARTITION BY tbname,t_double' , 'PARTITION BY tbname,t_binary', 'PARTITION BY tbname,t_nchar', 'PARTITION BY tbname,t_bool' ,'PARTITION BY tbname ,loc ,t_bigint', + 'PARTITION BY tbname,t_binary ,t_nchar ,t_bool' , 'PARTITION BY tbname,t_int ,t_smallint ,t_tinyint' , 'PARTITION BY tbname,t_float ,t_double '] + self.partiton_where_j = ['PARTITION BY t1.loc' , 'PARTITION by t1.t_bigint', 'PARTITION by t1.t_int', 'PARTITION by t1.t_smallint', 'PARTITION by t1.t_tinyint', + 'PARTITION by t1.t_float', 'PARTITION by t1.t_double' , 'PARTITION by t1.t_binary', 'PARTITION by t1.t_nchar', 'PARTITION by t1.t_bool' ,'PARTITION BY t1.loc ,t1.t_bigint', + 'PARTITION by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'PARTITION by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'PARTITION by t1.t_float ,t1.t_double ', + 'PARTITION BY t2.loc' , 'PARTITION by t2.t_bigint', 'PARTITION by t2.t_int', 'PARTITION by t2.t_smallint', 'PARTITION by t2.t_tinyint', + 'PARTITION by t2.t_float', 'PARTITION by t2.t_double' , 'PARTITION by t2.t_binary', 'PARTITION by t2.t_nchar', 'PARTITION by t2.t_bool' ,'PARTITION BY t2.loc ,t2.t_bigint', + 'PARTITION by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'PARTITION by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'PARTITION by t2.t_float ,t2.t_double '] + + + self.group_where_regular = ['group by tbname ' , 'group by tbname', 'group by tbname, q_bigint', 'group by tbname,q_int', 'group by tbname, q_smallint', 'group by tbname,q_tinyint', + 'group by tbname,q_float', 'group by tbname,q_double' , 'group by tbname,q_binary', 'group by tbname,q_nchar', 'group by tbname,q_bool' ,'group by tbname ,q_bigint', + 'group by tbname,q_binary ,q_nchar ,q_bool' , 'group by tbname,q_int ,q_smallint ,q_tinyint' , 'group by tbname,q_float ,q_double ' , + 'PARTITION BY tbname ' , 'PARTITION BY tbname', 'PARTITION BY tbname, q_bigint', 'PARTITION BY tbname,q_int', 'PARTITION BY tbname, q_smallint', 'PARTITION BY tbname,q_tinyint', + 'PARTITION BY tbname,q_float', 'PARTITION BY tbname,q_double' , 'PARTITION BY tbname,q_binary', 'PARTITION BY tbname,q_nchar', 'PARTITION BY tbname,q_bool' ,'PARTITION BY tbname ,q_bigint', + 'PARTITION BY tbname,q_binary ,q_nchar ,q_bool' , 'PARTITION BY tbname,q_int ,q_smallint ,q_tinyint' , 'PARTITION BY tbname,q_float ,q_double '] + self.group_where_regular_j = ['group by t1.q_bigint', 'group by t1.q_int', 'group by t1.q_smallint', 'group by t1.q_tinyint', + 'group by t1.q_float', 'group by t1.q_double' , 'group by t1.q_binary', 'group by t1.q_nchar', 'group by t1.q_bool' ,'group by t1.q_bigint', + 'group by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'group by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'group by t1.q_float ,t1.q_double ' , + 'PARTITION by t1.q_bigint', 'PARTITION by t1.q_int', 'PARTITION by t1.q_smallint', 'PARTITION by t1.q_tinyint', + 'PARTITION by t1.q_float', 'PARTITION by t1.q_double' , 'PARTITION by t1.q_binary', 'PARTITION by t1.q_nchar', 'PARTITION by t1.q_bool' ,'PARTITION BY t1.q_bigint', + 'PARTITION by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'PARTITION by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'PARTITION by t1.q_float ,t1.q_double ', + 'group by t2.q_bigint', 'group by t2.q_int', 'group by t2.q_smallint', 'group by t2.q_tinyint', + 'group by t2.q_float', 'group by t2.q_double' , 'group by t2.q_binary', 'group by t2.q_nchar', 'group by t2.q_bool' ,'group by t2.q_bigint', + 'group by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'group by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'group by t2.q_float ,t2.q_double ' , + 'PARTITION by t2.q_bigint', 'PARTITION by t2.q_int', 'PARTITION by t2.q_smallint', 'PARTITION by t2.q_tinyint', + 'PARTITION by t2.q_float', 'PARTITION by t2.q_double' , 'PARTITION by t2.q_binary', 'PARTITION by t2.q_nchar', 'PARTITION by t2.q_bool' ,'PARTITION BY t2.q_bigint', + 'PARTITION by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'PARTITION by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'PARTITION by t2.q_float ,t2.q_double '] + + self.partiton_where_regular = ['PARTITION BY tbname ' , 'PARTITION BY tbname', 'PARTITION BY tbname, q_bigint', 'PARTITION BY tbname,q_int', 'PARTITION BY tbname, q_smallint', 'PARTITION BY tbname,q_tinyint', + 'PARTITION BY tbname,q_float', 'PARTITION BY tbname,q_double' , 'PARTITION BY tbname,q_binary', 'PARTITION BY tbname,q_nchar', 'PARTITION BY tbname,q_bool' ,'PARTITION BY tbname ,q_bigint', + 'PARTITION BY tbname,q_binary ,q_nchar ,q_bool' , 'PARTITION BY tbname,q_int ,q_smallint ,q_tinyint' , 'PARTITION BY tbname,q_float ,q_double '] + self.partiton_where_regular_j = ['PARTITION by t1.q_bigint', 'PARTITION by t1.q_int', 'PARTITION by t1.q_smallint', 'PARTITION by t1.q_tinyint', + 'PARTITION by t1.q_float', 'PARTITION by t1.q_double' , 'PARTITION by t1.q_binary', 'PARTITION by t1.q_nchar', 'PARTITION by t1.q_bool' ,'PARTITION BY t1.q_bigint', + 'PARTITION by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'PARTITION by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'PARTITION by t1.q_float ,t1.q_double ', + 'PARTITION by t2.q_bigint', 'PARTITION by t2.q_int', 'PARTITION by t2.q_smallint', 'PARTITION by t2.q_tinyint', + 'PARTITION by t2.q_float', 'PARTITION by t2.q_double' , 'PARTITION by t2.q_binary', 'PARTITION by t2.q_nchar', 'PARTITION by t2.q_bool' ,'PARTITION BY t2.q_bigint', + 'PARTITION by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'PARTITION by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'PARTITION by t2.q_float ,t2.q_double '] + + self.having_support = ['having count(q_int) > 0','having count(q_bigint) > 0','having count(q_smallint) > 0','having count(q_tinyint) > 0','having count(q_float) > 0','having count(q_double) > 0','having count(q_bool) > 0', + 'having avg(q_int) > 0','having avg(q_bigint) > 0','having avg(q_smallint) > 0','having avg(q_tinyint) > 0','having avg(q_float) > 0','having avg(q_double) > 0', + 'having sum(q_int) > 0','having sum(q_bigint) > 0','having sum(q_smallint) > 0','having sum(q_tinyint) > 0','having sum(q_float) > 0','having sum(q_double) > 0', + 'having STDDEV(q_int) > 0','having STDDEV(q_bigint) > 0','having STDDEV(q_smallint) > 0','having STDDEV(q_tinyint) > 0','having STDDEV(q_float) > 0','having STDDEV(q_double) > 0', + 'having TWA(q_int) > 0','having TWA(q_bigint) > 0','having TWA(q_smallint) > 0','having TWA(q_tinyint) > 0','having TWA(q_float) > 0','having TWA(q_double) > 0', + 'having IRATE(q_int) > 0','having IRATE(q_bigint) > 0','having IRATE(q_smallint) > 0','having IRATE(q_tinyint) > 0','having IRATE(q_float) > 0','having IRATE(q_double) > 0', + 'having MIN(q_int) > 0','having MIN(q_bigint) > 0','having MIN(q_smallint) > 0','having MIN(q_tinyint) > 0','having MIN(q_float) > 0','having MIN(q_double) > 0', + 'having MAX(q_int) > 0','having MAX(q_bigint) > 0','having MAX(q_smallint) > 0','having MAX(q_tinyint) > 0','having MAX(q_float) > 0','having MAX(q_double) > 0', + 'having FIRST(q_int) > 0','having FIRST(q_bigint) > 0','having FIRST(q_smallint) > 0','having FIRST(q_tinyint) > 0','having FIRST(q_float) > 0','having FIRST(q_double) > 0', + 'having LAST(q_int) > 0','having LAST(q_bigint) > 0','having LAST(q_smallint) > 0','having LAST(q_tinyint) > 0','having LAST(q_float) > 0','having LAST(q_double) > 0', + 'having APERCENTILE(q_int,10) > 0','having APERCENTILE(q_bigint,10) > 0','having APERCENTILE(q_smallint,10) > 0','having APERCENTILE(q_tinyint,10) > 0','having APERCENTILE(q_float,10) > 0','having APERCENTILE(q_double,10) > 0', + 'having count(q_int_null) > 0','having count(q_bigint_null) > 0','having count(q_smallint_null) > 0','having count(q_tinyint_null) > 0','having count(q_float_null) > 0','having count(q_double_null) > 0','having count(q_bool_null) > 0', + 'having avg(q_int_null) > 0','having avg(q_bigint_null) > 0','having avg(q_smallint_null) > 0','having avg(q_tinyint_null) > 0','having avg(q_float_null) > 0','having avg(q_double_null) > 0', + 'having sum(q_int_null) > 0','having sum(q_bigint_null) > 0','having sum(q_smallint_null) > 0','having sum(q_tinyint_null) > 0','having sum(q_float_null) > 0','having sum(q_double_null) > 0', + 'having STDDEV(q_int_null) > 0','having STDDEV(q_bigint_null) > 0','having STDDEV(q_smallint_null) > 0','having STDDEV(q_tinyint_null) > 0','having STDDEV(q_float_null) > 0','having STDDEV(q_double_null) > 0', + 'having TWA(q_int_null) > 0','having TWA(q_bigint_null) > 0','having TWA(q_smallint_null) > 0','having TWA(q_tinyint_null) > 0','having TWA(q_float_null) > 0','having TWA(q_double_null) > 0', + 'having IRATE(q_int_null) > 0','having IRATE(q_bigint_null) > 0','having IRATE(q_smallint_null) > 0','having IRATE(q_tinyint_null) > 0','having IRATE(q_float_null) > 0','having IRATE(q_double_null) > 0', + 'having MIN(q_int_null) > 0','having MIN(q_bigint_null) > 0','having MIN(q_smallint_null) > 0','having MIN(q_tinyint_null) > 0','having MIN(q_float_null) > 0','having MIN(q_double_null) > 0', + 'having MAX(q_int_null) > 0','having MAX(q_bigint_null) > 0','having MAX(q_smallint_null) > 0','having MAX(q_tinyint_null) > 0','having MAX(q_float_null) > 0','having MAX(q_double_null) > 0', + 'having FIRST(q_int_null) > 0','having FIRST(q_bigint_null) > 0','having FIRST(q_smallint_null) > 0','having FIRST(q_tinyint_null) > 0','having FIRST(q_float_null) > 0','having FIRST(q_double_null) > 0', + 'having LAST(q_int_null) > 0','having LAST(q_bigint_null) > 0','having LAST(q_smallint_null) > 0','having LAST(q_tinyint_null) > 0','having LAST(q_float_null) > 0','having LAST(q_double_null) > 0', + 'having APERCENTILE(q_int_null,10) > 0','having APERCENTILE(q_bigint_null,10) > 0','having APERCENTILE(q_smallint_null,10) > 0','having APERCENTILE(q_tinyint_null,10) > 0','having APERCENTILE(q_float_null,10) > 0','having APERCENTILE(q_double_null,10) > 0'] + self.having_not_support = ['having TOP(q_int,10) > 0','having TOP(q_bigint,10) > 0','having TOP(q_smallint,10) > 0','having TOP(q_tinyint,10) > 0','having TOP(q_float,10) > 0','having TOP(q_double,10) > 0','having TOP(q_bool,10) > 0', + 'having BOTTOM(q_int,10) > 0','having BOTTOM(q_bigint,10) > 0','having BOTTOM(q_smallint,10) > 0','having BOTTOM(q_tinyint,10) > 0','having BOTTOM(q_float,10) > 0','having BOTTOM(q_double,10) > 0','having BOTTOM(q_bool,10) > 0', + 'having LEASTSQUARES(q_int) > 0','having LEASTSQUARES(q_bigint) > 0','having LEASTSQUARES(q_smallint) > 0','having LEASTSQUARES(q_tinyint) > 0','having LEASTSQUARES(q_float) > 0','having LEASTSQUARES(q_double) > 0','having LEASTSQUARES(q_bool) > 0', + 'having FIRST(q_bool) > 0','having IRATE(q_bool) > 0','having PERCENTILE(q_bool,10) > 0','having avg(q_bool) > 0','having LAST_ROW(q_bool) > 0','having sum(q_bool) > 0','having STDDEV(q_bool) > 0','having APERCENTILE(q_bool,10) > 0','having TWA(q_bool) > 0','having LAST(q_bool) > 0', + 'having PERCENTILE(q_int,10) > 0','having PERCENTILE(q_bigint,10) > 0','having PERCENTILE(q_smallint,10) > 0','having PERCENTILE(q_tinyint,10) > 0','having PERCENTILE(q_float,10) > 0','having PERCENTILE(q_double,10) > 0', + 'having TOP(q_int_null,10) > 0','having TOP(q_bigint_null,10) > 0','having TOP(q_smallint_null,10) > 0','having TOP(q_tinyint_null,10) > 0','having TOP(q_float_null,10) > 0','having TOP(q_double_null,10) > 0','having TOP(q_bool_null,10) > 0', + 'having BOTTOM(q_int_null,10) > 0','having BOTTOM(q_bigint_null,10) > 0','having BOTTOM(q_smallint_null,10) > 0','having BOTTOM(q_tinyint_null,10) > 0','having BOTTOM(q_float_null,10) > 0','having BOTTOM(q_double_null,10) > 0','having BOTTOM(q_bool_null,10) > 0', + 'having LEASTSQUARES(q_int_null) > 0','having LEASTSQUARES(q_bigint_null) > 0','having LEASTSQUARES(q_smallint_null) > 0','having LEASTSQUARES(q_tinyint_null) > 0','having LEASTSQUARES(q_float_null) > 0','having LEASTSQUARES(q_double_null) > 0','having LEASTSQUARES(q_bool_null) > 0', + 'having FIRST(q_bool_null) > 0','having IRATE(q_bool_null) > 0','having PERCENTILE(q_bool_null,10) > 0','having avg(q_bool_null) > 0','having LAST_ROW(q_bool_null) > 0','having sum(q_bool_null) > 0','having STDDEV(q_bool_null) > 0','having APERCENTILE(q_bool_null,10) > 0','having TWA(q_bool_null) > 0','having LAST(q_bool_null) > 0', + 'having PERCENTILE(q_int_null,10) > 0','having PERCENTILE(q_bigint_null,10) > 0','having PERCENTILE(q_smallint_null,10) > 0','having PERCENTILE(q_tinyint_null,10) > 0','having PERCENTILE(q_float_null,10) > 0','having PERCENTILE(q_double_null,10) > 0'] + self.having_tagnot_support = ['having LAST_ROW(q_int) > 0','having LAST_ROW(q_bigint) > 0','having LAST_ROW(q_smallint) > 0','having LAST_ROW(q_tinyint) > 0','having LAST_ROW(q_float) > 0','having LAST_ROW(q_double) > 0', + 'having LAST_ROW(q_int_null) > 0','having LAST_ROW(q_bigint_null) > 0','having LAST_ROW(q_smallint_null) > 0','having LAST_ROW(q_tinyint_null) > 0','having LAST_ROW(q_float_null) > 0','having LAST_ROW(q_double_null) > 0'] + + self.having_support_j = ['having count(t1.q_int) > 0','having count(t1.q_bigint) > 0','having count(t1.q_smallint) > 0','having count(t1.q_tinyint) > 0','having count(t1.q_float) > 0','having count(t1.q_double) > 0','having count(t1.q_bool) > 0', + 'having avg(t1.q_int) > 0','having avg(t1.q_bigint) > 0','having avg(t1.q_smallint) > 0','having avg(t1.q_tinyint) > 0','having avg(t1.q_float) > 0','having avg(t1.q_double) > 0', + 'having sum(t1.q_int) > 0','having sum(t1.q_bigint) > 0','having sum(t1.q_smallint) > 0','having sum(t1.q_tinyint) > 0','having sum(t1.q_float) > 0','having sum(t1.q_double) > 0', + 'having STDDEV(t1.q_int) > 0','having STDDEV(t1.q_bigint) > 0','having STDDEV(t1.q_smallint) > 0','having STDDEV(t1.q_tinyint) > 0','having STDDEV(t1.q_float) > 0','having STDDEV(t1.q_double) > 0', + 'having TWA(t1.q_int) > 0','having TWA(t1.q_bigint) > 0','having TWA(t1.q_smallint) > 0','having TWA(t1.q_tinyint) > 0','having TWA(t1.q_float) > 0','having TWA(t1.q_double) > 0', + 'having IRATE(t1.q_int) > 0','having IRATE(t1.q_bigint) > 0','having IRATE(t1.q_smallint) > 0','having IRATE(t1.q_tinyint) > 0','having IRATE(t1.q_float) > 0','having IRATE(t1.q_double) > 0', + 'having MIN(t1.q_int) > 0','having MIN(t1.q_bigint) > 0','having MIN(t1.q_smallint) > 0','having MIN(t1.q_tinyint) > 0','having MIN(t1.q_float) > 0','having MIN(t1.q_double) > 0', + 'having MAX(t1.q_int) > 0','having MAX(t1.q_bigint) > 0','having MAX(t1.q_smallint) > 0','having MAX(t1.q_tinyint) > 0','having MAX(t1.q_float) > 0','having MAX(t1.q_double) > 0', + 'having FIRST(t1.q_int) > 0','having FIRST(t1.q_bigint) > 0','having FIRST(t1.q_smallint) > 0','having FIRST(t1.q_tinyint) > 0','having FIRST(t1.q_float) > 0','having FIRST(t1.q_double) > 0', + 'having LAST(t1.q_int) > 0','having LAST(t1.q_bigint) > 0','having LAST(t1.q_smallint) > 0','having LAST(t1.q_tinyint) > 0','having LAST(t1.q_float) > 0','having LAST(t1.q_double) > 0', + 'having APERCENTILE(t1.q_int,10) > 0','having APERCENTILE(t1.q_bigint,10) > 0','having APERCENTILE(t1.q_smallint,10) > 0','having APERCENTILE(t1.q_tinyint,10) > 0','having APERCENTILE(t1.q_float,10) > 0','having APERCENTILE(t1.q_double,10) > 0'] + + # limit offset where + self.limit_where = ['limit 1 offset 1' , 'limit 1' , 'limit 2 offset 1' , 'limit 2', 'limit 12 offset 1' , 'limit 20', 'limit 20 offset 10' , 'limit 200'] + self.limit1_where = ['limit 1 offset 1' , 'limit 1' ] + self.limit_u_where = ['limit 100 offset 10' , 'limit 50' , 'limit 100' , 'limit 10' ] + + # slimit soffset where + self.slimit_where = ['slimit 1 soffset 1' , 'slimit 1' , 'slimit 2 soffset 1' , 'slimit 2'] + self.slimit1_where = ['slimit 2 soffset 1' , 'slimit 1' ] + + # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] + # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] + # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] + # **_ns_** express is not support stable, therefore, separated from regular tables + # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval + # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname + # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname + + # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval + # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] + + self.calc_select_all = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , + 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , + 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , + 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , + 'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , + 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , + 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , + 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , + 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)', + 'bottom(q_int_null,20)' , 'bottom(q_bigint_null,20)' , 'bottom(q_smallint_null,20)' , 'bottom(q_tinyint_null,20)' ,'bottom(q_float_null,20)' , 'bottom(q_double_null,20)' , + 'top(q_int_null,20)' , 'top(q_bigint_null,20)' , 'top(q_smallint_null,20)' ,'top(q_tinyint_null,20)' ,'top(q_float_null,20)' ,'top(q_double_null,20)' , + 'first(q_int_null)' , 'first(q_bigint_null)' , 'first(q_smallint_null)' , 'first(q_tinyint_null)' , 'first(q_float_null)' ,'first(q_double_null)' ,'first(q_binary_null)' ,'first(q_nchar_null)' ,'first(q_bool_null)' ,'first(q_ts_null)' , + 'last(q_int_null)' , 'last(q_bigint_null)' , 'last(q_smallint_null)' , 'last(q_tinyint_null)' , 'last(q_float_null)' ,'last(q_double_null)' , 'last(q_binary_null)' ,'last(q_nchar_null)' ,'last(q_bool_null)' ,'last(q_ts_null)' , + 'min(q_int_null)' , 'min(q_bigint_null)' , 'min(q_smallint_null)' , 'min(q_tinyint_null)' , 'min(q_float_null)' ,'min(q_double_null)' , + 'max(q_int_null)' , 'max(q_bigint_null)' , 'max(q_smallint_null)' , 'max(q_tinyint_null)' ,'max(q_float_null)' ,'max(q_double_null)' , + 'last_row(q_int_null)' , 'last_row(q_bigint_null)' , 'last_row(q_smallint_null)' , 'last_row(q_tinyint_null)' , 'last_row(q_float_null)' , + 'last_row(q_double_null)' , 'last_row(q_bool_null)' ,'last_row(q_binary_null)' ,'last_row(q_nchar_null)' ,'last_row(q_ts_null)', + 'apercentile(q_int_null,20)' , 'apercentile(q_bigint_null,20)' ,'apercentile(q_smallint_null,20)' ,'apercentile(q_tinyint_null,20)' ,'apercentile(q_float_null,20)' ,'apercentile(q_double_null,20)' ,] + + self.calc_select_in_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , + 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , + 'bottom(q_int_null,20)' , 'bottom(q_bigint_null,20)' , 'bottom(q_smallint_null,20)' , 'bottom(q_tinyint_null,20)' ,'bottom(q_float_null,20)' , 'bottom(q_double_null,20)' , + 'top(q_int_null,20)' , 'top(q_bigint_null,20)' , 'top(q_smallint_null,20)' ,'top(q_tinyint_null,20)' ,'top(q_float_null,20)' ,'top(q_double_null,20)' , + 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , + 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , + 'first(q_int_null)' , 'first(q_bigint_null)' , 'first(q_smallint_null)' , 'first(q_tinyint_null)' , 'first(q_float_null)' ,'first(q_double_null)' ,'first(q_binary_null)' ,'first(q_nchar_null)' ,'first(q_bool_null)' ,'first(q_ts_null)' , + 'last(q_int_null)' , 'last(q_bigint_null)' , 'last(q_smallint_null)' , 'last(q_tinyint_null)' , 'last(q_float_null)' ,'last(q_double_null)' , 'last(q_binary_null)' ,'last(q_nchar_null)' ,'last(q_bool_null)' ,'last(q_ts_null)' ] + + self.calc_select_in = ['min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , + 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , + 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , + 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , + 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)', + 'min(q_int_null)' , 'min(q_bigint_null)' , 'min(q_smallint_null)' , 'min(q_tinyint_null)' , 'min(q_float_null)' ,'min(q_double_null)' , + 'max(q_int_null)' , 'max(q_bigint_null)' , 'max(q_smallint_null)' , 'max(q_tinyint_null)' ,'max(q_float_null)' ,'max(q_double_null)' , + 'apercentile(q_int_null,20)' , 'apercentile(q_bigint_null,20)' ,'apercentile(q_smallint_null,20)' ,'apercentile(q_tinyint_null,20)' ,'apercentile(q_float_null,20)' ,'apercentile(q_double_null,20)' , + 'last_row(q_int_null)' , 'last_row(q_bigint_null)' , 'last_row(q_smallint_null)' , 'last_row(q_tinyint_null)' , 'last_row(q_float_null)' , + 'last_row(q_double_null)' , 'last_row(q_bool_null)' ,'last_row(q_binary_null)' ,'last_row(q_nchar_null)' ,'last_row(q_ts_null)'] + + self.calc_select_not_support_ts = ['first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , + 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , + 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , + 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)', + 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)', + 'first(q_int_null)' , 'first(q_bigint_null)' , 'first(q_smallint_null)' , 'first(q_tinyint_null)' , 'first(q_float_null)' ,'first(q_double_null)' ,'first(q_binary_null)' ,'first(q_nchar_null)' ,'first(q_bool_null)' ,'first(q_ts_null)' , + 'last(q_int_null)' , 'last(q_bigint_null)' , 'last(q_smallint_null)' , 'last(q_tinyint_null)' , 'last(q_float_null)' ,'last(q_double_null)' , 'last(q_binary_null)' ,'last(q_nchar_null)' ,'last(q_bool_null)' ,'last(q_ts_null)' , + 'last_row(q_int_null)' , 'last_row(q_bigint_null)' , 'last_row(q_smallint_null)' , 'last_row(q_tinyint_null)' , 'last_row(q_float_null)' , + 'last_row(q_double_null)' , 'last_row(q_bool_null)' ,'last_row(q_binary_null)' ,'last_row(q_nchar_null)' ,'last_row(q_ts_null)', + 'apercentile(q_int_null,20)' , 'apercentile(q_bigint_null,20)' ,'apercentile(q_smallint_null,20)' ,'apercentile(q_tinyint_null,20)' ,'apercentile(q_float_null,20)' ,'apercentile(q_double_null,20)'] + + self.calc_select_support_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , + 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , + 'bottom(q_int_null,20)' , 'bottom(q_bigint_null,20)' , 'bottom(q_smallint_null,20)' , 'bottom(q_tinyint_null,20)' ,'bottom(q_float_null,20)' , 'bottom(q_double_null,20)' , + 'top(q_int_null,20)' , 'top(q_bigint_null,20)' , 'top(q_smallint_null,20)' ,'top(q_tinyint_null,20)' ,'top(q_float_null,20)' ,'top(q_double_null,20)' , + 'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , + 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , + 'min(q_int_null)' , 'min(q_bigint_null)' , 'min(q_smallint_null)' , 'min(q_tinyint_null)' , 'min(q_float_null)' ,'min(q_double_null)' , + 'max(q_int_null)' , 'max(q_bigint_null)' , 'max(q_smallint_null)' , 'max(q_tinyint_null)' ,'max(q_float_null)' ,'max(q_double_null)'] + + self.calc_select_regular = [ 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)', + 'PERCENTILE(q_int_null,10)' ,'PERCENTILE(q_bigint_null,20)' , 'PERCENTILE(q_smallint_null,30)' ,'PERCENTILE(q_tinyint_null,40)' ,'PERCENTILE(q_float_null,50)' ,'PERCENTILE(q_double_null,60)'] + + + self.calc_select_fill = ['INTERP(q_int)' ,'INTERP(q_bigint)' ,'INTERP(q_smallint)' ,'INTERP(q_tinyint)', 'INTERP(q_float)' ,'INTERP(q_double)'] + self.interp_where = ['ts = now' , 'ts = \'2020-09-13 20:26:40.000\'' , 'ts = \'2020-09-13 20:26:40.009\'' ,'tbname in (\'table_1\') and ts = now' ,'tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and ts = \'2020-09-13 20:26:40.000\'','tbname like \'table%\' and ts = \'2020-09-13 20:26:40.002\''] + + #two table join + self.calc_select_in_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' , + 'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' , + 'first(t1.q_int)' , 'first(t1.q_bigint)' , 'first(t1.q_smallint)' , 'first(t1.q_tinyint)' , 'first(t1.q_float)' ,'first(t1.q_double)' ,'first(t1.q_binary)' ,'first(t1.q_nchar)' ,'first(t1.q_bool)' ,'first(t1.q_ts)' , + 'last(t1.q_int)' , 'last(t1.q_bigint)' , 'last(t1.q_smallint)' , 'last(t1.q_tinyint)' , 'last(t1.q_float)' ,'last(t1.q_double)' , 'last(t1.q_binary)' ,'last(t1.q_nchar)' ,'last(t1.q_bool)' ,'last(t1.q_ts)' , + 'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' , + 'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' , + 'first(t2.q_int)' , 'first(t2.q_bigint)' , 'first(t2.q_smallint)' , 'first(t2.q_tinyint)' , 'first(t2.q_float)' ,'first(t2.q_double)' ,'first(t2.q_binary)' ,'first(t2.q_nchar)' ,'first(t2.q_bool)' ,'first(t2.q_ts)' , + 'last(t2.q_int)' , 'last(t2.q_bigint)' , 'last(t2.q_smallint)' , 'last(t2.q_tinyint)' , 'last(t2.q_float)' ,'last(t2.q_double)' , 'last(t2.q_binary)' ,'last(t2.q_nchar)' ,'last(t2.q_bool)' ,'last(t2.q_ts)', + 'bottom(t1.q_int_null,20)' , 'bottom(t1.q_bigint_null,20)' , 'bottom(t1.q_smallint_null,20)' , 'bottom(t1.q_tinyint_null,20)' ,'bottom(t1.q_float_null,20)' , 'bottom(t1.q_double_null,20)' , + 'top(t1.q_int_null,20)' , 'top(t1.q_bigint_null,20)' , 'top(t1.q_smallint_null,20)' ,'top(t1.q_tinyint_null,20)' ,'top(t1.q_float_null,20)' ,'top(t1.q_double_null,20)' , + 'first(t1.q_int_null)' , 'first(t1.q_bigint_null)' , 'first(t1.q_smallint_null)' , 'first(t1.q_tinyint_null)' , 'first(t1.q_float_null)' ,'first(t1.q_double_null)' ,'first(t1.q_binary_null)' ,'first(t1.q_nchar_null))' ,'first(t1.q_bool_null)' ,'first(t1.q_ts_null)' , + 'last(t1.q_int_null)' , 'last(t1.q_bigint_null)' , 'last(t1.q_smallint_null)' , 'last(t1.q_tinyint_null)' , 'last(t1.q_float_null)' ,'last(t1.q_double_null)' , 'last(t1.q_binary_null)' ,'last(t1.q_nchar_null))' ,'last(t1.q_bool_null)' ,'last(t1.q_ts_null)' , + 'bottom(t2.q_int_null,20)' , 'bottom(t2.q_bigint_null,20)' , 'bottom(t2.q_smallint_null,20)' , 'bottom(t2.q_tinyint_null,20)' ,'bottom(t2.q_float_null,20)' , 'bottom(t2.q_double_null,20)' , + 'top(t2.q_int_null,20)' , 'top(t2.q_bigint_null,20)' , 'top(t2.q_smallint_null,20)' ,'top(t2.q_tinyint_null,20)' ,'top(t2.q_float_null,20)' ,'top(t2.q_double_null,20)' , + 'first(t2.q_int_null)' , 'first(t2.q_bigint_null)' , 'first(t2.q_smallint_null)' , 'first(t2.q_tinyint_null)' , 'first(t2.q_float_null)' ,'first(t2.q_double_null)' ,'first(t2.q_binary_null)' ,'first(t2.q_nchar_null))' ,'first(t2.q_bool_null)' ,'first(t2.q_ts_null)' , + 'last(t2.q_int_null)' , 'last(t2.q_bigint_null)' , 'last(t2.q_smallint_null)' , 'last(t2.q_tinyint_null)' , 'last(t2.q_float_null)' ,'last(t2.q_double_null)' , 'last(t2.q_binary_null)' ,'last(t2.q_nchar_null))' ,'last(t2.q_bool_null)' ,'last(t2.q_ts_null)'] + + self.calc_select_in_support_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' , + 'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' , + 'min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' , + 'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' , + 'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' , + 'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' , + 'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' , + 'max(t2.q_int)' , 'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' , + 'bottom(t1.q_int_null,20)' , 'bottom(t1.q_bigint_null,20)' , 'bottom(t1.q_smallint_null,20)' , 'bottom(t1.q_tinyint_null,20)' ,'bottom(t1.q_float_null,20)' , 'bottom(t1.q_double_null,20)' , + 'top(t1.q_int_null,20)' , 'top(t1.q_bigint_null,20)' , 'top(t1.q_smallint_null,20)' ,'top(t1.q_tinyint_null,20)' ,'top(t1.q_float_null,20)' ,'top(t1.q_double_null,20)' , + 'bottom(t2.q_int_null,20)' , 'bottom(t2.q_bigint_null,20)' , 'bottom(t2.q_smallint_null,20)' , 'bottom(t2.q_tinyint_null,20)' ,'bottom(t2.q_float_null,20)' , 'bottom(t2.q_double_null,20)' , + 'top(t2.q_int_null,20)' , 'top(t2.q_bigint_null,20)' , 'top(t2.q_smallint_null,20)' ,'top(t2.q_tinyint_null,20)' ,'top(t2.q_float_null,20)' ,'top(t2.q_double_null,20)' , + 'min(t1.q_int_null)' , 'min(t1.q_bigint_null)' , 'min(t1.q_smallint_null)' , 'min(t1.q_tinyint_null)' , 'min(t1.q_float_null)' ,'min(t1.q_double_null)' , + 'max(t1.q_int_null)' , 'max(t1.q_bigint_null)' , 'max(t1.q_smallint_null)' , 'max(t1.q_tinyint_null)' ,'max(t1.q_float_null)' ,'max(t1.q_double_null)' , + 'min(t2.q_int_null)' , 'min(t2.q_bigint_null)' , 'min(t2.q_smallint_null)' , 'min(t2.q_tinyint_null)' , 'min(t2.q_float_null)' ,'min(t2.q_double_null)' , + 'max(t2.q_int_null)' , 'max(t2.q_bigint_null)' , 'max(t2.q_smallint_null)' , 'max(t2.q_tinyint_null)' ,'max(t2.q_float_null)' ,'max(t2.q_double_null)' ] + + self.calc_select_in_not_support_ts_j = ['apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' , + 'apercentile(t1.q_int_null,20)' , 'apercentile(t1.q_bigint_null,20)' ,'apercentile(t1.q_smallint_null,20)' ,'apercentile(t1.q_tinyint_null,20)' ,'apercentile(t1.q_float_null,20)' ,'apercentile(t1.q_double_null,20)' , + 'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' , + 'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' , + 'last_row(t1.q_int_null)' , 'last_row(t1.q_bigint_null)' , 'last_row(t1.q_smallint_null)' , 'last_row(t1.q_tinyint_null)' , 'last_row(t1.q_float_null)' , + 'last_row(t1.q_double_null)' , 'last_row(t1.q_bool_null)' ,'last_row(t1.q_binary_null)' ,'last_row(t1.q_nchar_null)' ,'last_row(t1.q_ts_null)' , + 'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' , + 'apercentile(t2.q_int_null,20)' , 'apercentile(t2.q_bigint_null,20)' ,'apercentile(t2.q_smallint_null,20)' ,'apercentile(t2.q_tinyint_null,20)' ,'apercentile(t2.q_float_null,20)' ,'apercentile(t2.q_double_null,20)' , + 'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' , + 'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)', + 'last_row(t2.q_int_null)' , 'last_row(t2.q_bigint_null)' , 'last_row(t2.q_smallint_null)' , 'last_row(t2.q_tinyint_null)' , 'last_row(t2.q_float_null)' , + 'last_row(t2.q_double_null)' , 'last_row(t2.q_bool_null)' ,'last_row(t2.q_binary_null)' ,'last_row(t2.q_nchar_null)' ,'last_row(t2.q_ts_null)'] + + self.calc_select_in_j = ['min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' , + 'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' , + 'apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' , + 'min(t1.q_int_null)' , 'min(t1.q_bigint_null)' , 'min(t1.q_smallint_null)' , 'min(t1.q_tinyint_null)' , 'min(t1.q_float_null)' ,'min(t1.q_double_null)' , + 'max(t1.q_int_null)' , 'max(t1.q_bigint_null)' , 'max(t1.q_smallint_null)' , 'max(t1.q_tinyint_null)' ,'max(t1.q_float_null)' ,'max(t1.q_double_null)' , + 'apercentile(t1.q_int_null,20)' , 'apercentile(t1.q_bigint_null,20)' ,'apercentile(t1.q_smallint_null,20)' ,'apercentile(t1.q_tinyint_null,20)' ,'apercentile(t1.q_float_null,20)' ,'apercentile(t1.q_double_null,20)' , + 'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' , + 'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' , + 'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' , + 'max(t2.q_int)' , 'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' , + 'last_row(t1.q_int_null)' , 'last_row(t1.q_bigint_null)' , 'last_row(t1.q_smallint_null)' , 'last_row(t1.q_tinyint_null)' , 'last_row(t1.q_float_null)' , + 'last_row(t1.q_double_null)' , 'last_row(t1.q_bool_null)' ,'last_row(t1.q_binary_null)' ,'last_row(t1.q_nchar_null)' ,'last_row(t1.q_ts_null)' , + 'min(t2.q_int_null)' , 'min(t2.q_bigint_null)' , 'min(t2.q_smallint_null)' , 'min(t2.q_tinyint_null)' , 'min(t2.q_float_null)' ,'min(t2.q_double_null)' , + 'max(t2.q_int_null)' , 'max(t2.q_bigint_null)' , 'max(t2.q_smallint_null)' , 'max(t2.q_tinyint_null)' ,'max(t2.q_float_null)' ,'max(t2.q_double_null)' , + 'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' , + 'apercentile(t2.q_int_null,20)' , 'apercentile(t2.q_bigint_null,20)' ,'apercentile(t2.q_smallint_null,20)' ,'apercentile(t2.q_tinyint_null,20)' ,'apercentile(t2.q_float_null,20)' ,'apercentile(t2.q_double_null,20)' , + 'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' , + 'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)', + 'last_row(t2.q_int_null)' , 'last_row(t2.q_bigint_null)' , 'last_row(t2.q_smallint_null)' , 'last_row(t2.q_tinyint_null)' , 'last_row(t2.q_float_null)' , + 'last_row(t2.q_double_null)' , 'last_row(t2.q_bool_null)' ,'last_row(t2.q_binary_null)' ,'last_row(t2.q_nchar_null)' ,'last_row(t2.q_ts_null)'] + self.calc_select_all_j = self.calc_select_in_ts_j + self.calc_select_in_j + + self.calc_select_regular_j = [ 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , + 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)', + 'PERCENTILE(t1.q_int_null,10)' ,'PERCENTILE(t1.q_bigint_null,20)' , 'PERCENTILE(t1.q_smallint_null,30)' ,'PERCENTILE(t1.q_tinyint_null,40)' ,'PERCENTILE(t1.q_float_null,50)' ,'PERCENTILE(t1.q_double_null,60)' , + 'PERCENTILE(t2.q_int_null,10)' ,'PERCENTILE(t2.q_bigint_null,20)' , 'PERCENTILE(t2.q_smallint_null,30)' ,'PERCENTILE(t2.q_tinyint_null,40)' ,'PERCENTILE(t2.q_float_null,50)' ,'PERCENTILE(t2.q_double_null,60)'] + + + self.calc_select_fill_j = ['INTERP(t1.q_int)' ,'INTERP(t1.q_bigint)' ,'INTERP(t1.q_smallint)' ,'INTERP(t1.q_tinyint)', 'INTERP(t1.q_float)' ,'INTERP(t1.q_double)' , + 'INTERP(t2.q_int)' ,'INTERP(t2.q_bigint)' ,'INTERP(t2.q_smallint)' ,'INTERP(t2.q_tinyint)', 'INTERP(t2.q_float)' ,'INTERP(t2.q_double)'] + self.interp_where_j = ['t1.ts = now' , 't1.ts = \'2020-09-13 20:26:40.000\'' , 't1.ts = \'2020-09-13 20:26:40.009\'' ,'t2.ts = now' , 't2.ts = \'2020-09-13 20:26:40.000\'' , 't2.ts = \'2020-09-13 20:26:40.009\'' , + 't1.tbname in (\'table_1\') and t1.ts = now' ,'t1.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t1.ts = \'2020-09-13 20:26:40.000\'','t1.tbname like \'table%\' and t1.ts = \'2020-09-13 20:26:40.002\'', + 't2.tbname in (\'table_1\') and t2.ts = now' ,'t2.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t2.ts = \'2020-09-13 20:26:40.000\'','t2.tbname like \'table%\' and t2.ts = \'2020-09-13 20:26:40.002\''] + + # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname APERCENTILE\PERCENTILE + # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] + self.calc_aggregate_all = ['count(*)' , 'count(q_int)' ,'count(q_bigint)' , 'count(q_smallint)' ,'count(q_tinyint)' ,'count(q_float)' , + 'count(q_double)' ,'count(q_binary)' ,'count(q_nchar)' ,'count(q_bool)' ,'count(q_ts)' , + 'avg(q_int)' ,'avg(q_bigint)' , 'avg(q_smallint)' ,'avg(q_tinyint)' ,'avg(q_float)' ,'avg(q_double)' , + 'sum(q_int)' ,'sum(q_bigint)' , 'sum(q_smallint)' ,'sum(q_tinyint)' ,'sum(q_float)' ,'sum(q_double)' , + 'STDDEV(q_int)' ,'STDDEV(q_bigint)' , 'STDDEV(q_smallint)' ,'STDDEV(q_tinyint)' ,'STDDEV(q_float)' ,'STDDEV(q_double)', + 'APERCENTILE(q_int,10)' ,'APERCENTILE(q_bigint,20)' , 'APERCENTILE(q_smallint,30)' ,'APERCENTILE(q_tinyint,40)' ,'APERCENTILE(q_float,50)' ,'APERCENTILE(q_double,60)', + 'count(q_int_null)' ,'count(q_bigint_null)' , 'count(q_smallint_null)' ,'count(q_tinyint_null)' ,'count(q_float_null)' , + 'count(q_double_null)' ,'count(q_binary_null)' ,'count(q_nchar_null)' ,'count(q_bool_null)' ,'count(q_ts_null)' , + 'avg(q_int_null)' ,'avg(q_bigint_null)' , 'avg(q_smallint_null)' ,'avg(q_tinyint_null)' ,'avg(q_float_null)' ,'avg(q_double_null)' , + 'sum(q_int_null)' ,'sum(q_bigint_null)' , 'sum(q_smallint_null)' ,'sum(q_tinyint_null)' ,'sum(q_float_null)' ,'sum(q_double_null)' , + 'STDDEV(q_int_null)' ,'STDDEV(q_bigint_null)' , 'STDDEV(q_smallint_null)' ,'STDDEV(q_tinyint_null)' ,'STDDEV(q_float_null)' ,'STDDEV(q_double_null)', + 'APERCENTILE(q_int_null,10)' ,'APERCENTILE(q_bigint_null,20)' , 'APERCENTILE(q_smallint_null,30)' ,'APERCENTILE(q_tinyint_null,40)' ,'APERCENTILE(q_float_null,50)' ,'APERCENTILE(q_double_null,60)'] + + self.calc_aggregate_regular = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , + 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' , + 'twa(q_int_null)' ,'twa(q_bigint_null)' , 'twa(q_smallint_null)' ,'twa(q_tinyint_null)' ,'twa (q_float_null)' ,'twa(q_double_null)' , + 'IRATE(q_int_null)' ,'IRATE(q_bigint_null)' , 'IRATE(q_smallint_null)' ,'IRATE(q_tinyint_null)' ,'IRATE (q_float_null)' ,'IRATE(q_double_null)' , + 'LEASTSQUARES(q_int,15,3)' , 'LEASTSQUARES(q_bigint,10,1)' , 'LEASTSQUARES(q_smallint,20,3)' ,'LEASTSQUARES(q_tinyint,10,4)' ,'LEASTSQUARES(q_float,6,4)' ,'LEASTSQUARES(q_double,3,1)' , + 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)', + 'LEASTSQUARES(q_int_null,15,3)' , 'LEASTSQUARES(q_bigint_null,10,1)' , 'LEASTSQUARES(q_smallint_null,20,3)' ,'LEASTSQUARES(q_tinyint_null,10,4)' ,'LEASTSQUARES(q_float_null,6,4)' ,'LEASTSQUARES(q_double_null,3,1)' , + 'PERCENTILE(q_int_null,10)' ,'PERCENTILE(q_bigint_null,20)' , 'PERCENTILE(q_smallint_null,30)' ,'PERCENTILE(q_tinyint_null,40)' ,'PERCENTILE(q_float_null,50)' ,'PERCENTILE(q_double_null,60)'] + + self.calc_aggregate_groupbytbname = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , + 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)', + 'twa(q_int_null)' ,'twa(q_bigint_null)' , 'twa(q_smallint_null)' ,'twa(q_tinyint_null)' ,'twa (q_float_null)' ,'twa(q_double_null)' , + 'IRATE(q_int_null)' ,'IRATE(q_bigint_null)' , 'IRATE(q_smallint_null)' ,'IRATE(q_tinyint_null)' ,'IRATE (q_float_null)' ,'IRATE(q_double_null)'] + + #two table join + self.calc_aggregate_all_j = ['count(t1.*)' , 'count(t1.q_int)' ,'count(t1.q_bigint)' , 'count(t1.q_smallint)' ,'count(t1.q_tinyint)' ,'count(t1.q_float)' , + 'count(t1.q_double)' ,'count(t1.q_binary)' ,'count(t1.q_nchar)' ,'count(t1.q_bool)' ,'count(t1.q_ts)' , + 'avg(t1.q_int)' ,'avg(t1.q_bigint)' , 'avg(t1.q_smallint)' ,'avg(t1.q_tinyint)' ,'avg(t1.q_float)' ,'avg(t1.q_double)' , + 'sum(t1.q_int)' ,'sum(t1.q_bigint)' , 'sum(t1.q_smallint)' ,'sum(t1.q_tinyint)' ,'sum(t1.q_float)' ,'sum(t1.q_double)' , + 'STDDEV(t1.q_int)' ,'STDDEV(t1.q_bigint)' , 'STDDEV(t1.q_smallint)' ,'STDDEV(t1.q_tinyint)' ,'STDDEV(t1.q_float)' ,'STDDEV(t1.q_double)', + 'APERCENTILE(t1.q_int,10)' ,'APERCENTILE(t1.q_bigint,20)' , 'APERCENTILE(t1.q_smallint,30)' ,'APERCENTILE(t1.q_tinyint,40)' ,'APERCENTILE(t1.q_float,50)' ,'APERCENTILE(t1.q_double,60)' , + 'count(t1.q_int_null)' ,'count(t1.q_bigint_null)' , 'count(t1.q_smallint_null)' ,'count(t1.q_tinyint_null)' ,'count(t1.q_float_null)' , + 'count(t1.q_double_null)' ,'count(t1.q_binary_null)' ,'count(t1.q_nchar_null)' ,'count(t1.q_bool_null)' ,'count(t1.q_ts_null)' , + 'avg(t1.q_int_null)' ,'avg(t1.q_bigint_null)' , 'avg(t1.q_smallint_null)' ,'avg(t1.q_tinyint_null)' ,'avg(t1.q_float_null)' ,'avg(t1.q_double_null)' , + 'sum(t1.q_int_null)' ,'sum(t1.q_bigint_null)' , 'sum(t1.q_smallint_null)' ,'sum(t1.q_tinyint_null)' ,'sum(t1.q_float_null)' ,'sum(t1.q_double_null)' , + 'STDDEV(t1.q_int_null)' ,'STDDEV(t1.q_bigint_null)' , 'STDDEV(t1.q_smallint_null)' ,'STDDEV(t1.q_tinyint_null)' ,'STDDEV(t1.q_float_null)' ,'STDDEV(t1.q_double_null)', + 'APERCENTILE(t1.q_int_null,10)' ,'APERCENTILE(t1.q_bigint_null,20)' , 'APERCENTILE(t1.q_smallint_null,30)' ,'APERCENTILE(t1.q_tinyint_null,40)' ,'APERCENTILE(t1.q_float_null,50)' ,'APERCENTILE(t1.q_double,60)' , + 'count(t2.*)' , 'count(t2.q_int)' ,'count(t2.q_bigint)' , 'count(t2.q_smallint)' ,'count(t2.q_tinyint)' ,'count(t2.q_float)' , + 'count(t2.q_double)' ,'count(t2.q_binary)' ,'count(t2.q_nchar)' ,'count(t2.q_bool)' ,'count(t2.q_ts)' , + 'avg(t2.q_int)' ,'avg(t2.q_bigint)' , 'avg(t2.q_smallint)' ,'avg(t2.q_tinyint)' ,'avg(t2.q_float)' ,'avg(t2.q_double)' , + 'sum(t2.q_int)' ,'sum(t2.q_bigint)' , 'sum(t2.q_smallint)' ,'sum(t2.q_tinyint)' ,'sum(t2.q_float)' ,'sum(t2.q_double)' , + 'STDDEV(t2.q_int)' ,'STDDEV(t2.q_bigint)' , 'STDDEV(t2.q_smallint)' ,'STDDEV(t2.q_tinyint)' ,'STDDEV(t2.q_float)' ,'STDDEV(t2.q_double)', + 'APERCENTILE(t2.q_int,10)' ,'APERCENTILE(t2.q_bigint,20)' , 'APERCENTILE(t2.q_smallint,30)' ,'APERCENTILE(t2.q_tinyint,40)' ,'APERCENTILE(t2.q_float,50)' ,'APERCENTILE(t2.q_double,60)', + 'count(t2.q_int_null)' ,'count(t2.q_bigint_null)' , 'count(t2.q_smallint_null)' ,'count(t2.q_tinyint_null)' ,'count(t2.q_float_null)' , + 'count(t2.q_double_null)' ,'count(t2.q_binary_null)' ,'count(t2.q_nchar_null)' ,'count(t2.q_bool_null)' ,'count(t2.q_ts_null)' , + 'avg(t2.q_int_null)' ,'avg(t2.q_bigint_null)' , 'avg(t2.q_smallint_null)' ,'avg(t2.q_tinyint_null)' ,'avg(t2.q_float_null)' ,'avg(t2.q_double_null)' , + 'sum(t2.q_int_null)' ,'sum(t2.q_bigint_null)' , 'sum(t2.q_smallint_null)' ,'sum(t2.q_tinyint_null)' ,'sum(t2.q_float_null)' ,'sum(t2.q_double_null)' , + 'STDDEV(t2.q_int_null)' ,'STDDEV(t2.q_bigint_null)' , 'STDDEV(t2.q_smallint_null)' ,'STDDEV(t2.q_tinyint_null)' ,'STDDEV(t2.q_float_null)' ,'STDDEV(t2.q_double_null)', + 'APERCENTILE(t2.q_int_null,10)' ,'APERCENTILE(t2.q_bigint_null,20)' , 'APERCENTILE(t2.q_smallint_null,30)' ,'APERCENTILE(t2.q_tinyint_null,40)' ,'APERCENTILE(t2.q_float_null,50)' ,'APERCENTILE(t2.q_double,60)'] + + self.calc_aggregate_regular_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , + 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , + 'LEASTSQUARES(t1.q_int,15,3)' , 'LEASTSQUARES(t1.q_bigint,10,1)' , 'LEASTSQUARES(t1.q_smallint,20,3)' ,'LEASTSQUARES(t1.q_tinyint,10,4)' ,'LEASTSQUARES(t1.q_float,6,4)' ,'LEASTSQUARES(t1.q_double,3,1)' , + 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , + 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)', + 'LEASTSQUARES(t2.q_int,15,3)' , 'LEASTSQUARES(t2.q_bigint,10,1)' , 'LEASTSQUARES(t2.q_smallint,20,3)' ,'LEASTSQUARES(t2.q_tinyint,10,4)' ,'LEASTSQUARES(t2.q_float,6,4)' ,'LEASTSQUARES(t2.q_double,3,1)' , + 'twa(t1.q_int_null)' ,'twa(t1.q_bigint_null)' , 'twa(t1.q_smallint_null)' ,'twa(t1.q_tinyint_null)' ,'twa (t1.q_float_null)' ,'twa(t1.q_double_null)' , + 'IRATE(t1.q_int_null)' ,'IRATE(t1.q_bigint_null)' , 'IRATE(t1.q_smallint_null)' ,'IRATE(t1.q_tinyint_null)' ,'IRATE (t1.q_float_null)' ,'IRATE(t1.q_double_null)' , + 'LEASTSQUARES(t1.q_int_null,15,3)' , 'LEASTSQUARES(t1.q_bigint_null,10,1)' , 'LEASTSQUARES(t1.q_smallint_null,20,3)' ,'LEASTSQUARES(t1.q_tinyint_null,10,4)' ,'LEASTSQUARES(t1.q_float_null,6,4)' ,'LEASTSQUARES(t1.q_double_null,3,1)' , + 'twa(t2.q_int_null)' ,'twa(t2.q_bigint_null)' , 'twa(t2.q_smallint_null)' ,'twa(t2.q_tinyint_null)' ,'twa (t2.q_float_null)' ,'twa(t2.q_double_null)' , + 'IRATE(t2.q_int_null)' ,'IRATE(t2.q_bigint_null)' , 'IRATE(t2.q_smallint_null)' ,'IRATE(t2.q_tinyint_null)' ,'IRATE (t2.q_float_null)' ,'IRATE(t2.q_double_null)', + 'LEASTSQUARES(t2.q_int_null,15,3)' , 'LEASTSQUARES(t2.q_bigint_null,10,1)' , 'LEASTSQUARES(t2.q_smallint_null,20,3)' ,'LEASTSQUARES(t2.q_tinyint_null,10,4)' ,'LEASTSQUARES(t2.q_float_null,6,4)' ,'LEASTSQUARES(t2.q_double_null,3,1)' ] + + self.calc_aggregate_groupbytbname_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , + 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , + 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , + 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)' , + 'twa(t1.q_int_null)' ,'twa(t1.q_bigint_null)' , 'twa(t1.q_smallint_null)' ,'twa(t1.q_tinyint_null)' ,'twa (t1.q_float_null)' ,'twa(t1.q_double_null)' , + 'IRATE(t1.q_int_null)' ,'IRATE(t1.q_bigint_null)' , 'IRATE(t1.q_smallint_null)' ,'IRATE(t1.q_tinyint_null)' ,'IRATE (t1.q_float_null)' ,'IRATE(t1.q_double_null)' , + 'twa(t2.q_int_null)' ,'twa(t2.q_bigint_null)' , 'twa(t2.q_smallint_null)' ,'twa(t2.q_tinyint_null)' ,'twa (t2.q_float_null)' ,'twa(t2.q_double_null)' , + 'IRATE(t2.q_int_null)' ,'IRATE(t2.q_bigint_null)' , 'IRATE(t2.q_smallint_null)' ,'IRATE(t2.q_tinyint_null)' ,'IRATE (t2.q_float_null)' ,'IRATE(t2.q_double_null)' ] + + # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname + # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] + self.calc_calculate_all = ['SPREAD(ts)' , 'SPREAD(q_ts)' , 'SPREAD(q_int)' ,'SPREAD(q_bigint)' , 'SPREAD(q_smallint)' ,'SPREAD(q_tinyint)' ,'SPREAD(q_float)' ,'SPREAD(q_double)' , + '(SPREAD(q_int) + SPREAD(q_bigint))' , '(SPREAD(q_smallint) - SPREAD(q_float))', '(SPREAD(q_double) * SPREAD(q_tinyint))' , '(SPREAD(q_double) / SPREAD(q_float))', + 'SPREAD(q_ts_null)' , 'SPREAD(q_int_null)' ,'SPREAD(q_bigint_null)' , 'SPREAD(q_smallint_null)' ,'SPREAD(q_tinyint_null)' ,'SPREAD(q_float_null)' ,'SPREAD(q_double_null)' , + '(SPREAD(q_int_null) + SPREAD(q_bigint_null))' , '(SPREAD(q_smallint_null) - SPREAD(q_float_null))', '(SPREAD(q_double_null) * SPREAD(q_tinyint_null))' , '(SPREAD(q_double_null) / SPREAD(q_float_null))'] + self.calc_calculate_regular = ['DIFF(q_int)' ,'DIFF(q_bigint)' , 'DIFF(q_smallint)' ,'DIFF(q_tinyint)' ,'DIFF(q_float)' ,'DIFF(q_double)' , + 'DIFF(q_int,0)' ,'DIFF(q_bigint,0)' , 'DIFF(q_smallint,0)' ,'DIFF(q_tinyint,0)' ,'DIFF(q_float,0)' ,'DIFF(q_double,0)' , + 'DIFF(q_int,1)' ,'DIFF(q_bigint,1)' , 'DIFF(q_smallint,1)' ,'DIFF(q_tinyint,1)' ,'DIFF(q_float,1)' ,'DIFF(q_double,1)' , + 'DERIVATIVE(q_int,15s,0)' , 'DERIVATIVE(q_bigint,10s,1)' , 'DERIVATIVE(q_smallint,20s,0)' ,'DERIVATIVE(q_tinyint,10s,1)' ,'DERIVATIVE(q_float,6s,0)' ,'DERIVATIVE(q_double,3s,1)', + 'DIFF(q_int_null)' ,'DIFF(q_bigint_null)' , 'DIFF(q_smallint_null)' ,'DIFF(q_tinyint_null)' ,'DIFF(q_float_null)' ,'DIFF(q_double_null)' , + 'DIFF(q_int_null,0)' ,'DIFF(q_bigint_null,0)' , 'DIFF(q_smallint_null,0)' ,'DIFF(q_tinyint_null,0)' ,'DIFF(q_float_null,0)' ,'DIFF(q_double_null,0)' , + 'DIFF(q_int_null,1)' ,'DIFF(q_bigint_null,1)' , 'DIFF(q_smallint_null,1)' ,'DIFF(q_tinyint_null,1)' ,'DIFF(q_float_null,1)' ,'DIFF(q_double_null,1)' , + 'DERIVATIVE(q_int_null,15s,0)' , 'DERIVATIVE(q_bigint_null,10s,1)' , 'DERIVATIVE(q_smallint_null,20s,0)' ,'DERIVATIVE(q_tinyint_null,10s,1)' ,'DERIVATIVE(q_float_null,6s,0)' ,'DERIVATIVE(q_double_null,3s,1)'] + self.calc_calculate_groupbytbname = self.calc_calculate_regular + + #two table join + self.calc_calculate_all_j = ['SPREAD(t1.ts)' , 'SPREAD(t1.q_ts)' , 'SPREAD(t1.q_int)' ,'SPREAD(t1.q_bigint)' , 'SPREAD(t1.q_smallint)' ,'SPREAD(t1.q_tinyint)' ,'SPREAD(t1.q_float)' ,'SPREAD(t1.q_double)' , + 'SPREAD(t2.ts)' , 'SPREAD(t2.q_ts)' , 'SPREAD(t2.q_int)' ,'SPREAD(t2.q_bigint)' , 'SPREAD(t2.q_smallint)' ,'SPREAD(t2.q_tinyint)' ,'SPREAD(t2.q_float)' ,'SPREAD(t2.q_double)' , + '(SPREAD(t1.q_int) + SPREAD(t1.q_bigint))' , '(SPREAD(t1.q_tinyint) - SPREAD(t1.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_tinyint))', + '(SPREAD(t2.q_int) + SPREAD(t2.q_bigint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t2.q_double) * SPREAD(t2.q_tinyint))' , '(SPREAD(t2.q_double) / SPREAD(t2.q_tinyint))', + '(SPREAD(t1.q_int) + SPREAD(t1.q_smallint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_float))', + 'SPREAD(t1.q_ts_null)' , 'SPREAD(t1.q_int_null)' ,'SPREAD(t1.q_bigint_null)' , 'SPREAD(t1.q_smallint_null)' ,'SPREAD(t1.q_tinyint_null)' ,'SPREAD(t1.q_float_null)' ,'SPREAD(t1.q_double_null)' , + 'SPREAD(t2.q_ts_null)' , 'SPREAD(t2.q_int_null)' ,'SPREAD(t2.q_bigint_null)' , 'SPREAD(t2.q_smallint_null)' ,'SPREAD(t2.q_tinyint_null)' ,'SPREAD(t2.q_float_null)' ,'SPREAD(t2.q_double_null)' , + '(SPREAD(t1.q_int_null) + SPREAD(t1.q_bigint_null))' , '(SPREAD(t1.q_tinyint_null) - SPREAD(t1.q_float_null))', '(SPREAD(t1.q_double_null) * SPREAD(t1.q_tinyint_null))' , '(SPREAD(t1.q_double_null) / SPREAD(t1.q_tinyint_null))', + '(SPREAD(t2.q_int_null) + SPREAD(t2.q_bigint_null))' , '(SPREAD(t2.q_smallint_null) - SPREAD(t2.q_float_null))', '(SPREAD(t2.q_double_null) * SPREAD(t2.q_tinyint_null))' , '(SPREAD(t2.q_double_null) / SPREAD(t2.q_tinyint_null))', + '(SPREAD(t1.q_int_null) + SPREAD(t1.q_smallint_null))' , '(SPREAD(t2.q_smallint_null) - SPREAD(t2.q_float_null))', '(SPREAD(t1.q_double_null) * SPREAD(t1.q_tinyint_null))' , '(SPREAD(t1.q_double_null) / SPREAD(t1.q_float_null))'] + self.calc_calculate_regular_j = ['DIFF(t1.q_int)' ,'DIFF(t1.q_bigint)' , 'DIFF(t1.q_smallint)' ,'DIFF(t1.q_tinyint)' ,'DIFF(t1.q_float)' ,'DIFF(t1.q_double)' , + 'DIFF(t1.q_int,0)' ,'DIFF(t1.q_bigint,0)' , 'DIFF(t1.q_smallint,0)' ,'DIFF(t1.q_tinyint,0)' ,'DIFF(t1.q_float,0)' ,'DIFF(t1.q_double,0)' , + 'DIFF(t1.q_int,1)' ,'DIFF(t1.q_bigint,1)' , 'DIFF(t1.q_smallint,1)' ,'DIFF(t1.q_tinyint,1)' ,'DIFF(t1.q_float,1)' ,'DIFF(t1.q_double,1)' , + 'DERIVATIVE(t1.q_int,15s,0)' , 'DERIVATIVE(t1.q_bigint,10s,1)' , 'DERIVATIVE(t1.q_smallint,20s,0)' ,'DERIVATIVE(t1.q_tinyint,10s,1)' ,'DERIVATIVE(t1.q_float,6s,0)' ,'DERIVATIVE(t1.q_double,3s,1)' , + 'DIFF(t2.q_int)' ,'DIFF(t2.q_bigint)' , 'DIFF(t2.q_smallint)' ,'DIFF(t2.q_tinyint)' ,'DIFF(t2.q_float)' ,'DIFF(t2.q_double)' , + 'DIFF(t2.q_int,0)' ,'DIFF(t2.q_bigint,0)' , 'DIFF(t2.q_smallint,0)' ,'DIFF(t2.q_tinyint,0)' ,'DIFF(t2.q_float,0)' ,'DIFF(t2.q_double,0)' , + 'DIFF(t2.q_int,1)' ,'DIFF(t2.q_bigint,1)' , 'DIFF(t2.q_smallint,1)' ,'DIFF(t2.q_tinyint,1)' ,'DIFF(t2.q_float,1)' ,'DIFF(t2.q_double,1)' , + 'DERIVATIVE(t2.q_int,15s,0)' , 'DERIVATIVE(t2.q_bigint,10s,1)' , 'DERIVATIVE(t2.q_smallint,20s,0)' ,'DERIVATIVE(t2.q_tinyint,10s,1)' ,'DERIVATIVE(t2.q_float,6s,0)' ,'DERIVATIVE(t2.q_double,3s,1)' , + 'DIFF(t1.q_int_null)' ,'DIFF(t1.q_bigint_null)' , 'DIFF(t1.q_smallint_null)' ,'DIFF(t1.q_tinyint_null)' ,'DIFF(t1.q_float_null)' ,'DIFF(t1.q_double_null)' , + 'DIFF(t1.q_int_null,0)' ,'DIFF(t1.q_bigint_null,0)' , 'DIFF(t1.q_smallint_null,0)' ,'DIFF(t1.q_tinyint_null,0)' ,'DIFF(t1.q_float_null,0)' ,'DIFF(t1.q_double_null,0)' , + 'DIFF(t1.q_int_null,1)' ,'DIFF(t1.q_bigint_null,1)' , 'DIFF(t1.q_smallint_null,1)' ,'DIFF(t1.q_tinyint_null,1)' ,'DIFF(t1.q_float_null,1)' ,'DIFF(t1.q_double_null,1)' , + 'DERIVATIVE(t1.q_int_null,15s,0)' , 'DERIVATIVE(t1.q_bigint_null,10s,1)' , 'DERIVATIVE(t1.q_smallint_null,20s,0)' ,'DERIVATIVE(t1.q_tinyint_null,10s,1)' ,'DERIVATIVE(t1.q_float_null,6s,0)' ,'DERIVATIVE(t1.q_double_null,3s,1)' , + 'DIFF(t2.q_int_null)' ,'DIFF(t2.q_bigint_null)' , 'DIFF(t2.q_smallint_null)' ,'DIFF(t2.q_tinyint_null)' ,'DIFF(t2.q_float_null)' ,'DIFF(t2.q_double_null)' , + 'DIFF(t2.q_int_null,0)' ,'DIFF(t2.q_bigint_null,0)' , 'DIFF(t2.q_smallint_null,0)' ,'DIFF(t2.q_tinyint_null,0)' ,'DIFF(t2.q_float_null,0)' ,'DIFF(t2.q_double_null,0)' , + 'DIFF(t2.q_int_null,1)' ,'DIFF(t2.q_bigint_null,1)' , 'DIFF(t2.q_smallint_null,1)' ,'DIFF(t2.q_tinyint_null,1)' ,'DIFF(t2.q_float_null,1)' ,'DIFF(t2.q_double_null,1)' , + 'DERIVATIVE(t2.q_int_null,15s,0)' , 'DERIVATIVE(t2.q_bigint_null,10s,1)' , 'DERIVATIVE(t2.q_smallint_null,20s,0)' ,'DERIVATIVE(t2.q_tinyint_null,10s,1)' ,'DERIVATIVE(t2.q_float_null,6s,0)' ,'DERIVATIVE(t2.q_double_null,3s,1)'] + self.calc_calculate_groupbytbname_j = self.calc_calculate_regular_j + + #inter && calc_aggregate_all\calc_aggregate_regular\calc_select_all + self.interval_sliding = ['interval(4w) sliding(1w) ','interval(1w) sliding(1d) ','interval(1d) sliding(1h) ' , + 'interval(1h) sliding(1m) ','interval(1m) sliding(1s) ','interval(1s) sliding(10a) ', + 'interval(1y) ','interval(1n) ','interval(1w) ','interval(1d) ','interval(1h) ','interval(1m) ','interval(1s) ' ,'interval(10a)', + 'interval(1y,1n) ','interval(1n,1w) ','interval(1w,1d) ','interval(1d,1h) ','interval(1h,1m) ','interval(1m,1s) ','interval(1s,10a) ' ,'interval(100a,30a)'] + + self.conn1 = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos/") + self.cur1 = self.conn1.cursor() + print(self.cur1) + self.cur1.execute("use %s ;" %self.db_nest) + sql = 'select * from stable_1 limit 5;' + self.cur1.execute(sql) + + def data_matrix_equal(self, sql1,row1_s,row1_e,col1_s,col1_e, sql2,row2_s,row2_e,col2_s,col2_e): # ----row1_start----col1_start---- - # - - - - 是一个矩阵内的数据相等- - - - # - - - - - - - - - - - - - - - - + # - - - - 是一个矩阵内的数据相等- - - + # - - - - - - - - - - - - - - - - # ----row1_end------col1_end------ self.sql1 = sql1 list1 =[] @@ -67,9 +618,9 @@ class TDTestCase: #print("data=%s" %(tdSql.getData(i1,j1))) list1.append(tdSql.getData(i1,j1)) print("=====list1-------list1---=%s" %set(list1)) - + tdSql.execute("reset query cache;") - self.sql2 = sql2 + self.sql2 = sql2 list2 =[] tdSql.query(sql2) for i2 in range(row2_s-1,row2_e): @@ -78,8 +629,8 @@ class TDTestCase: #print("jjjj222=%d"%j2) #print("data=%s" %(tdSql.getData(i2,j2))) list2.append(tdSql.getData(i2,j2)) - print("=====list2-------list2---=%s" %set(list2)) - + print("=====list2-------list2---=%s" %set(list2)) + if (list1 == list2) and len(list2)>0: # print(("=====matrix===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2)) tdLog.info(("===matrix===sql1:'%s' matrix_result = sql2:'%s' matrix_result") %(sql1,sql2)) @@ -105,7 +656,7 @@ class TDTestCase: print(("=====matrix_error===sql1.list1:'%s',sql2.list2:'%s'") %(list1,list2)) tdLog.info(("sql1:'%s' matrix_result != sql2:'%s' matrix_result") %(sql1,sql2)) return tdSql.checkEqual(list1,list2) - + def restartDnodes(self): pass # tdDnodes.stop(1) @@ -120,2457 +671,5530 @@ class TDTestCase: tdSql.execute('''use %s;'''%database) tdSql.execute('''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') tdSql.execute('''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') - + tdSql.execute('''create stable stable_null_data (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') tdSql.execute('''create stable stable_null_childtable (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) \ tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') - + #tdSql.execute('''create table stable_1_1 using stable_1 tags('stable_1_1', '0' , '0' , '0' , '0' , 0 , 'binary1' , 'nchar1' , '0' , '0' ,'0') ;''') - tdSql.execute('''create table stable_1_1 using stable_1 tags('stable_1_1', '%d' , '%d', '%d' , '%d' , 0 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' - %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_1 using stable_1 tags('stable_1_1', '%d' , '%d', '%d' , '%d' , 0 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) tdSql.execute('''create table stable_1_2 using stable_1 tags('stable_1_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , \'1999-09-09 09:09:09.090\') ;''') tdSql.execute('''create table stable_1_3 using stable_1 tags('stable_1_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , \'2099-09-09 09:09:09.090\') ;''') #tdSql.execute('''create table stable_1_4 using stable_1 tags('stable_1_4', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') - tdSql.execute('''create table stable_1_4 using stable_1 tags('stable_1_4', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' - %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_4 using stable_1 tags('stable_1_4', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) # tdSql.execute('''create table stable_2_1 using stable_2 tags('stable_2_1' , '0' , '0' , '0' , '0' , 0 , 'binary21' , 'nchar21' , '0' , '0' ,'0') ;''') # tdSql.execute('''create table stable_2_2 using stable_2 tags('stable_2_2' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') # tdSql.execute('''create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') - + tdSql.execute('''create table stable_2_1 using stable_2 tags('stable_2_1' , '0' , '0' , '0' , '0' , 0 , 'binary21' , 'nchar21' , '0' , '0' ,\'2099-09-09 09:09:09.090\') ;''') - tdSql.execute('''create table stable_2_2 using stable_2 tags('stable_2_2' , '%d' , '%d', '%d' , '%d' , 0 , 'binary2.%s' , 'nchar2.%s' , '%f', '%f' ,'%d') ;''' - %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_2_2 using stable_2 tags('stable_2_2' , '%d' , '%d', '%d' , '%d' , 0 , 'binary2.%s' , 'nchar2.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) - tdSql.execute('''create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' - %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '%d' , '%d', '%d' , '%d' , 1 , 'binary1.%s' , 'nchar1.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) #regular table tdSql.execute('''create table regular_table_1 \ (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') tdSql.execute('''create table regular_table_2 \ (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') tdSql.execute('''create table regular_table_3 \ (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') tdSql.execute('''create table regular_table_null \ (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , \ + q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) ,\ + q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) ,\ q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') - for i in range(num_random*n): - tdSql.execute('''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d) ;''' - % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1), - fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i)) - tdSql.execute('''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d) ;''' - % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1) , - fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1) , - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i)) + for i in range(num_random*n): + tdSql.execute('''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1), + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + tdSql.execute('''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1) , + fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1) , + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) - tdSql.execute('''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d) ;''' - % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), - fake.random_int(min=0, max=9223372036854775807, step=1), - fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i)) - tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d) ;''' - % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), - fake.random_int(min=0, max=9223372036854775807, step=1), - fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i)) + tdSql.execute('''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8)\ + values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=0, max=2147483647, step=1), + fake.random_int(min=0, max=9223372036854775807, step=1), + fake.random_int(min=0, max=32767, step=1) , fake.random_int(min=0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + + tdSql.execute('''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000 +1, fake.random_int(min=-2147483647, max=0, step=1), + fake.random_int(min=-9223372036854775807, max=0, step=1), + fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i +1, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) + tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000 +1, fake.random_int(min=-2147483647, max=0, step=1), + fake.random_int(min=-9223372036854775807, max=0, step=1), + fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i +1, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) - tdSql.execute('''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d) ;''' - % (ts + i*1000 +1, fake.random_int(min=-2147483647, max=0, step=1), - fake.random_int(min=-9223372036854775807, max=0, step=1), - fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i +1)) - tdSql.execute('''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d) ;''' - % (ts + i*1000 +1, fake.random_int(min=-2147483647, max=0, step=1), - fake.random_int(min=-9223372036854775807, max=0, step=1), - fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i +1)) + tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000, fake.random_int(min=-0, max=2147483647, step=1), + fake.random_int(min=-0, max=9223372036854775807, step=1), + fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) - tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d) ;''' - % (ts + i*1000, fake.random_int(min=-2147483647, max=2147483647, step=1), - fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), - fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , - fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i)) + tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000 +1, fake.random_int(min=-0, max=2147483647, step=1), + fake.random_int(min=-0, max=9223372036854775807, step=1), + fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) - # tdSql.execute('''insert into regular_table_3 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(%d, %d, %d, %d, %d, %f, %f, 1, 'binary.%s', 'nchar.%s', %d)''' - # % (ts + i*1000, fake.random_int(min=-2147483647, max=0, step=1), - # fake.random_int(min=-9223372036854775807, max=0, step=1), - # fake.random_int(min=-32767, max=0, step=1) , fake.random_int(min=-127, max=0, step=1) , - # fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.address() , ts + i)) + tdSql.execute('''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,\ + q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) \ + values(%d, %d, %d, %d, %d, %f, %f, 0, 'binary.%s', 'nchar.%s', %d, 'binary1.%s', 'nchar1.%s', 'binary2.%s', 'nchar2.%s', 'binary3.%s', 'nchar3.%s', \ + 'binary4.%s', 'nchar4.%s', 'binary5.%s', 'nchar5.%s', 'binary6.%s', 'nchar6.%s', 'binary7.%s', 'nchar7.%s', 'binary8.%s', 'nchar8.%s') ;''' + % (ts + i*1000 +10, fake.random_int(min=-0, max=2147483647, step=1), + fake.random_int(min=-0, max=9223372036854775807, step=1), + fake.random_int(min=-0, max=32767, step=1) , fake.random_int(min=-0, max=127, step=1) , + fake.pyfloat() , fake.pyfloat() , fake.pystr() , fake.pystr() , ts + i, fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , + fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr() , fake.pystr())) tdSql.query("select count(*) from stable_1;") tdSql.checkData(0,0,3*num_random*n) tdSql.query("select count(*) from regular_table_1;") tdSql.checkData(0,0,num_random*n) + + def explain_sql(self,sql): + # #执行sql解析 + sql = "explain " + sql + tdLog.info(sql) + tdSql.query(sql) + #pass + + def data_check(self,sql,mark='mark') : + tdLog.info("========mark==%s==="% mark); + try: + tdSql.query(sql,queryTimes=1) + except: + tdLog.info("sql is not support :=====%s; " %sql) + tdSql.error(sql) + + + def math_nest(self,mathlist): + + print("==========%s===start=============" %mathlist) + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.dropandcreateDB_random("%s" %self.db_nest, 1) + + if (mathlist == ['ABS','SQRT']) or (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['FLOOR','CEIL','ROUND']) \ + or (mathlist == ['CSUM']) : + math_functions = mathlist + fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)'] + fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) + math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) + math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)', + '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)'] + fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) + math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) + math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + elif (mathlist == ['UNIQUE']) or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['MODE']) : + math_functions = mathlist + fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_binary)','(q_nchar)','(q_bool)','(q_ts)', + '(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)','(q_binary_null)','(q_nchar_null)','(q_bool_null)','(q_ts_null)'] + fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) + math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) + math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)','(t1.q_ts)','(t1.q_ts_null)', + '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)','(t2.q_ts)','(t2.q_ts_null)'] + fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) + math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) + math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + elif (mathlist == ['TAIL']): + math_functions = mathlist + num = random.randint(1, 100) + offset_rows = random.randint(0, 100) + fun_fix_column = ['(q_bigint,num)','(q_smallint,num)','(q_tinyint,num)','(q_int,num)','(q_float,num)','(q_double,num)','(q_binary,num)','(q_nchar,num)','(q_bool,num)','(q_ts,num)', + '(q_bigint_null,num)','(q_smallint_null,num)','(q_tinyint_null,num)','(q_int_null,num)','(q_float_null,num)','(q_double_null,num)','(q_binary_null,num)','(q_nchar_null,num)','(q_bool_null,num)','(q_ts_null,num)', + '(q_bigint,num,offset_rows)','(q_smallint,num,offset_rows)','(q_tinyint,num,offset_rows)','(q_int,num,offset_rows)','(q_float,num,offset_rows)','(q_double,num,offset_rows)','(q_binary,num,offset_rows)','(q_nchar,num,offset_rows)','(q_bool,num,offset_rows)','(q_ts,num,offset_rows)', + '(q_bigint_null,num,offset_rows)','(q_smallint_null,num,offset_rows)','(q_tinyint_null,num,offset_rows)','(q_int_null,num,offset_rows)','(q_float_null,num,offset_rows)','(q_double_null,num,offset_rows)','(q_binary_null,num,offset_rows)','(q_nchar_null,num,offset_rows)','(q_bool_null,num,offset_rows)','(q_ts_null,num,offset_rows)'] + fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) + math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)).replace("offset_rows",str(offset_rows)) + fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) + math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)).replace("offset_rows",str(offset_rows)) + + fun_fix_column_j = ['(t1.q_bigint,num)','(t1.q_smallint,num)','(t1.q_tinyint,num)','(t1.q_int,num)','(t1.q_float,num)','(t1.q_double,num)','(t1.q_binary,num)','(t1.q_nchar,num)','(t1.q_bool,num)','(t1.q_ts,num)', + '(t1.q_bigint_null,num)','(t1.q_smallint_null,num)','(t1.q_tinyint_null,num)','(t1.q_int_null,num)','(t1.q_float_null,num)','(t1.q_double_null,num)','(t1.q_binary_null,num)','(t1.q_nchar_null,num)','(t1.q_bool_null,num)','(t1.q_ts_null,num)', + '(t2.q_bigint,num)','(t2.q_smallint,num)','(t2.q_tinyint,num)','(t2.q_int,num)','(t2.q_float,num)','(t2.q_double,num)','(t2.q_binary,num)','(t2.q_nchar,num)','(t2.q_bool,num)','(t2.q_ts,num)', + '(t2.q_bigint_null,num)','(t2.q_smallint_null,num)','(t2.q_tinyint_null,num)','(t2.q_int_null,num)','(t2.q_float_null,num)','(t2.q_double_null,num)','(t2.q_binary_null,num)','(t2.q_nchar_null,num)','(t2.q_bool_null,num)','(t2.q_ts_null,num)', + '(t1.q_bigint,num,offset_rows)','(t1.q_smallint,num,offset_rows)','(t1.q_tinyint,num,offset_rows)','(t1.q_int,num,offset_rows)','(t1.q_float,num,offset_rows)','(t1.q_double,num,offset_rows)','(t1.q_binary,num,offset_rows)','(t1.q_nchar,num,offset_rows)','(t1.q_bool,num,offset_rows)','(t1.q_ts,num,offset_rows)', + '(t1.q_bigint_null,num,offset_rows)','(t1.q_smallint_null,num,offset_rows)','(t1.q_tinyint_null,num,offset_rows)','(t1.q_int_null,num,offset_rows)','(t1.q_float_null,num,offset_rows)','(t1.q_double_null,num,offset_rows)','(t1.q_binary_null,num,offset_rows)','(t1.q_nchar_null,num,offset_rows)','(t1.q_bool_null,num,offset_rows)','(t1.q_ts_null,num,offset_rows)', + '(t2.q_bigint,num,offset_rows)','(t2.q_smallint,num,offset_rows)','(t2.q_tinyint,num,offset_rows)','(t2.q_int,num,offset_rows)','(t2.q_float,num,offset_rows)','(t2.q_double,num,offset_rows)','(t2.q_binary,num,offset_rows)','(t2.q_nchar,num,offset_rows)','(t2.q_bool,num,offset_rows)','(t2.q_ts,num,offset_rows)', + '(t2.q_bigint_null,num,offset_rows)','(t2.q_smallint_null,num,offset_rows)','(t2.q_tinyint_null,num,offset_rows)','(t2.q_int_null,num,offset_rows)','(t2.q_float_null,num,offset_rows)','(t2.q_double_null,num,offset_rows)','(t2.q_binary_null,num,offset_rows)','(t2.q_nchar_null,num,offset_rows)','(t2.q_bool_null,num,offset_rows)','(t2.q_ts_null,num,offset_rows)'] + fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) + math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)).replace("offset_rows",str(offset_rows)) + fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) + math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)).replace("offset_rows",str(offset_rows)) + + elif (mathlist == ['POW','LOG']) or (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) : + math_functions = mathlist + num = random.randint(1, 1000) + fun_fix_column = ['(q_bigint,num)','(q_smallint,num)','(q_tinyint,num)','(q_int,num)','(q_float,num)','(q_double,num)', + '(q_bigint_null,num)','(q_smallint_null,num)','(q_tinyint_null,num)','(q_int_null,num)','(q_float_null,num)','(q_double_null,num)'] + fun_column_1 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) + math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)) + fun_column_2 = random.sample(math_functions,1)+random.sample(fun_fix_column,1) + math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)) + + fun_fix_column_j = ['(t1.q_bigint,num)','(t1.q_smallint,num)','(t1.q_tinyint,num)','(t1.q_int,num)','(t1.q_float,num)','(t1.q_double,num)', + '(t1.q_bigint_null,num)','(t1.q_smallint_null,num)','(t1.q_tinyint_null,num)','(t1.q_int_null,num)','(t1.q_float_null,num)','(t1.q_double_null,num)', + '(t2.q_bigint,num)','(t2.q_smallint,num)','(t2.q_tinyint,num)','(t2.q_int,num)','(t2.q_float,num)','(t2.q_double,num)', + '(t2.q_bigint_null,num)','(t2.q_smallint_null,num)','(t2.q_tinyint_null,num)','(t2.q_int_null,num)','(t2.q_float_null,num)','(t2.q_double_null,num)'] + fun_column_join_1 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) + math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)) + fun_column_join_2 = random.sample(math_functions,1)+random.sample(fun_fix_column_j,1) + math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",str(num)) + + elif (mathlist == ['statecount','stateduration']): + math_functions = mathlist + num = random.randint(-1000, 1000) + + operator = ['LT' , 'GT' ,'GE','NE','EQ'] + oper = str(random.sample(operator,1)).replace("[","").replace("]","")#.replace("'","") + + fun_fix_column = ['(q_bigint,oper,num,time)','(q_smallint,oper,num,time)','(q_tinyint,oper,num,time)','(q_int,oper,num,time)','(q_float,oper,num,time)','(q_double,oper,num,time)', + '(q_bigint_null,oper,num,time)','(q_smallint_null,oper,num,time)','(q_tinyint_null,oper,num,time)','(q_int_null,oper,num,time)','(q_float_null,oper,num,time)','(q_double_null,oper,num,time)'] + + hanshu_select1 = random.sample(math_functions,1) + fun_column_1 = random.sample(hanshu_select1,1)+random.sample(fun_fix_column,1) + math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") + + if str(hanshu_select1).replace("[","").replace("]","").replace("'","") == 'statecount': + math_fun_1 = math_fun_1.replace("oper","%s" %oper).replace(",time","").replace("num",str(num)) + elif str(hanshu_select1).replace("[","").replace("]","").replace("'","") == 'stateduration': + timeunit = ['1s' , '1m' ,'1h'] + time = str(random.sample(timeunit,1)).replace("[","").replace("]","").replace("'","") + math_fun_1 = math_fun_1.replace("oper","%s" %oper).replace("time","%s" %time).replace("num",str(num)) + + hanshu_select2 = random.sample(math_functions,1) + fun_column_2 = random.sample(hanshu_select2,1)+random.sample(fun_fix_column,1) + math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + if str(hanshu_select2).replace("[","").replace("]","").replace("'","") == 'statecount': + math_fun_2 = math_fun_2.replace("oper","%s" %oper).replace(",time","").replace("num",str(num)) + elif str(hanshu_select2).replace("[","").replace("]","").replace("'","") == 'stateduration': + timeunit = ['1s' , '1m' ,'1h'] + time = str(random.sample(timeunit,1)).replace("[","").replace("]","").replace("'","") + math_fun_2 = math_fun_2.replace("oper","%s" %oper).replace("time","%s" %time).replace("num",str(num)) + + fun_fix_column_j = ['(t1.q_bigint,oper,num,time)','(t1.q_smallint,oper,num,time)','(t1.q_tinyint,oper,num,time)','(t1.q_int,oper,num,time)','(t1.q_float,oper,num,time)','(t1.q_double,oper,num,time)', + '(t1.q_bigint_null,oper,num,time)','(t1.q_smallint_null,oper,num,time)','(t1.q_tinyint_null,oper,num,time)','(t1.q_int_null,oper,num,time)','(t1.q_float_null,oper,num,time)','(t1.q_double_null,oper,num,time)', + '(t2.q_bigint,oper,num,time)','(t2.q_smallint,oper,num,time)','(t2.q_tinyint,oper,num,time)','(t2.q_int,oper,num,time)','(t2.q_float,oper,num,time)','(t2.q_double,oper,num,time)', + '(t2.q_bigint_null,oper,num,time)','(t2.q_smallint_null,oper,num,time)','(t2.q_tinyint_null,oper,num,time)','(t2.q_int_null,oper,num,time)','(t2.q_float_null,oper,num,time)','(t2.q_double_null,oper,num,time)'] + + hanshu_select_join_1 = random.sample(math_functions,1) + fun_column_join_1 = random.sample(hanshu_select_join_1,1)+random.sample(fun_fix_column_j,1) + math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") + + if str(hanshu_select_join_1).replace("[","").replace("]","").replace("'","") == 'statecount': + math_fun_join_1 = math_fun_join_1.replace("oper","%s" %oper).replace(",time","").replace("num",str(num)) + elif str(hanshu_select_join_1).replace("[","").replace("]","").replace("'","") == 'stateduration': + timeunit = ['1s' , '1m' ,'1h'] + time = str(random.sample(timeunit,1)).replace("[","").replace("]","").replace("'","") + math_fun_join_1 = math_fun_join_1.replace("oper","%s" %oper).replace("time","%s" %time).replace("num",str(num)) + + hanshu_select_join_2 = random.sample(math_functions,1) + fun_column_join_2 = random.sample(hanshu_select_join_2,1)+random.sample(fun_fix_column_j,1) + math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + if str(hanshu_select_join_2).replace("[","").replace("]","").replace("'","") == 'statecount': + math_fun_join_2 = math_fun_join_2.replace("oper","%s" %oper).replace(",time","").replace("num",str(num)) + elif str(hanshu_select_join_2).replace("[","").replace("]","").replace("'","") == 'stateduration': + timeunit = ['1s' , '1m' ,'1h'] + time = str(random.sample(timeunit,1)).replace("[","").replace("]","").replace("'","") + math_fun_join_2 = math_fun_join_2.replace("oper","%s" %oper).replace("time","%s" %time).replace("num",str(num)) + + elif(mathlist == ['HISTOGRAM']) : + math_functions = mathlist + fun_fix_column = ['(q_bigint','(q_smallint','(q_tinyint','(q_int','(q_float','(q_double','(q_bigint_null','(q_smallint_null','(q_tinyint_null','(q_int_null','(q_float_null','(q_double_null'] + + fun_fix_column_j = ['(t1.q_bigint','(t1.q_smallint','(t1.q_tinyint','(t1.q_int','(t1.q_float','(t1.q_double','(t1.q_bigint_null','(t1.q_smallint_null','(t1.q_tinyint_null','(t1.q_int_null','(t1.q_float_null','(t1.q_double_null', + '(t2.q_bigint','(t2.q_smallint','(t2.q_tinyint','(t2.q_int','(t2.q_float','(t2.q_double','(t2.q_bigint_null','(t2.q_smallint_null','(t2.q_tinyint_null','(t2.q_int_null','(t2.q_float_null','(t2.q_double_null'] + + normalized = random.randint(0, 1) + + i = random.randint(1,3) + if i == 1: + bin_type = 'user_input' + bin_description = {-11111119395555977777} #9一会转译成, + fun_column_1 = [math_functions , random.sample(fun_fix_column,1), ',',"'%s'" %bin_type, ',',"'%s'" % bin_description, ',', "%d" %normalized,')'] + math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("{","[").replace("}","]").replace("9",",") + + fun_column_2 = [math_functions , random.sample(fun_fix_column,1), ',',"'%s'" %bin_type, ',',"'%s'" % bin_description, ',', "%d" %normalized,')'] + math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("{","[").replace("}","]").replace("9",",") + + fun_column_join_1 = [math_functions , random.sample(fun_fix_column_j,1), ',',"'%s'" %bin_type, ',',"'%s'" % bin_description, ',', "%d" %normalized,')'] + math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("{","[").replace("}","]").replace("9",",") + + fun_column_join_2 = [math_functions , random.sample(fun_fix_column_j,1), ',',"'%s'" %bin_type, ',',"'%s'" % bin_description, ',', "%d" %normalized,')'] + math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("{","[").replace("}","]").replace("9",",") + + elif i == 2: + bin_type = 'linear_bin' + true_false = random.randint(10, 11) + bin_description = {"ZstartZ": -333339, "ZwidthZ":559, "ZcountZ":59, "ZinfinityZ":'%d' %true_false} #Z一会转译成" ,9一会转译成 , + fun_column_1 = [math_functions , random.sample(fun_fix_column,1), ',',"'%s'" %bin_type, ',','%s' % bin_description, ',', "%d" %normalized,')'] + math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("9",",").replace("Z","\"").replace("10","false").replace("11","true").replace("\"{","'{").replace("}\"","}'") + + fun_column_2 = [math_functions , random.sample(fun_fix_column,1), ',',"'%s'" %bin_type, ',','%s' % bin_description, ',', "%d" %normalized,')'] + math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("9",",").replace("Z","\"").replace("10","false").replace("11","true").replace("\"{","'{").replace("}\"","}'") + + fun_column_join_1 = [math_functions , random.sample(fun_fix_column_j,1), ',',"'%s'" %bin_type, ',','%s' % bin_description, ',', "%d" %normalized,')'] + math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("9",",").replace("Z","\"").replace("10","false").replace("11","true").replace("\"{","'{").replace("}\"","}'") + + fun_column_join_2 = [math_functions , random.sample(fun_fix_column_j,1), ',',"'%s'" %bin_type, ',','%s' % bin_description, ',', "%d" %normalized,')'] + math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("9",",").replace("Z","\"").replace("10","false").replace("11","true").replace("\"{","'{").replace("}\"","}'") + + elif i == 3: + bin_type = 'log_bin' + true_false = random.randint(10, 11) + bin_description = {"ZstartZ": -333339, "ZfactorZ":559, "ZcountZ":59, "ZinfinityZ":'%d' %true_false} #Z一会转译成" ,9一会转译成 , + fun_column_1 = [math_functions , random.sample(fun_fix_column,1), ',',"'%s'" %bin_type, ',','%s' % bin_description, ',', "%d" %normalized,')'] + math_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("9",",").replace("Z","\"").replace("10","false").replace("11","true").replace("\"{","'{").replace("}\"","}'") + + fun_column_2 = [math_functions , random.sample(fun_fix_column,1), ',',"'%s'" %bin_type, ',','%s' % bin_description, ',', "%d" %normalized,')'] + math_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("9",",").replace("Z","\"").replace("10","false").replace("11","true").replace("\"{","'{").replace("}\"","}'") + + fun_column_join_1 = [math_functions , random.sample(fun_fix_column_j,1), ',',"'%s'" %bin_type, ',','%s' % bin_description, ',', "%d" %normalized,')'] + math_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("9",",").replace("Z","\"").replace("10","false").replace("11","true").replace("\"{","'{").replace("}\"","}'") + + fun_column_join_2 = [math_functions , random.sample(fun_fix_column_j,1), ',',"'%s'" %bin_type, ',','%s' % bin_description, ',', "%d" %normalized,')'] + math_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("9",",").replace("Z","\"").replace("10","false").replace("11","true").replace("\"{","'{").replace("}\"","}'") + + tdSql.query("select 1-1 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']): + sql = "select ts1 , floor(asct1) from ( select " + sql += "%s as asct1, " % math_fun_1 + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ts1 from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_1 + sql += " from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-2 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts , abs(asct1) from ( select " + sql += "%s as asct1, " % math_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s )" % random.choice(self.order_where) + sql += "%s " % random.choice(self.unionall_or_union) + sql += "select ts , asct2 from ( select " + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']): + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_1 + sql += "from regular_table_1 where " + sql += "%s )" % random.choice(self.q_where) + sql += "%s " % random.choice(self.unionall_or_union) + sql += "select count(asct2) from ( select " + sql += "%s as asct2 " % math_fun_2 + sql += " from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-3 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts , min(asct1) from ( select " + sql += "%s as asct1, ts ," % math_fun_1 + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s " % random.choice(self.q_select) + sql += " from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2, ts ," % math_fun_2 + sql += "%s as asct1, " % math_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s " % random.choice(self.q_select) + sql += " from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MODE']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1," % math_fun_1 + sql += "%s as asct2 " % math_fun_2 + sql += " from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2 ," % math_fun_2 + sql += "%s as asct1 " % math_fun_1 + sql += " from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['statecount','stateduration']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['TAIL']) or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['SAMPLE']): + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_1 + sql += " from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2 " % math_fun_2 + sql += " from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += " order by asct1 asc " + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-4 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts1,ts2 ,timediff(ts1,ts2), asct1 from ( select t1.ts as ts1," + sql += "%s as asct0, " % math_fun_join_1 + sql += "%s as asct1, " % math_fun_join_2 + sql += "%s as asct2, " % math_fun_join_1 + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct22, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_join_2 + sql += "from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-5 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts ," + sql += "%s, " % math_fun_1 + sql += "%s as asct1, " % random.choice(self.q_select) + sql += "%s as asct2, " % random.choice(self.q_select) + sql += "%s " % math_fun_2 + sql += " from ( select * from regular_table_1 ) where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select " + sql += "%s " % math_fun_2 + sql += " from ( select * from regular_table_1 ) where " + sql += "%s " % random.choice(self.q_where) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-6 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts1 ,timediff(ts1,ts2), max(asct1) from ( select t1.ts,t1.ts as ts1," + sql += "%s as asct0, " % math_fun_join_1 + sql += "%s as asct1, " % math_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t2.%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % math_fun_join_1 + sql += "t2.ts as ts2 from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s )" % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_join_2 + sql += "from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s )" % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-7 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts1,ts2 , abs(asct1) from ( select " + sql += "%s as asct1, ts as ts1," % math_fun_1 + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) + sql += "ts as ts2 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_1 + sql += "from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-8 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts1,floor(asct1),ts2 " + sql += "from ( select " + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s as asct1, ts as ts1," % math_fun_1 + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) + sql += "ts as ts2 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) " + sql += "from ( select " + sql += "%s as asct1 " % math_fun_1 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-9 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts1,ts2 ,timediff(ts1,ts2) , max(asct1) from ( select t1.ts as ts1," + sql += "%s, " % math_fun_join_1 + sql += "%s as asct1, " % math_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct21, " % random.choice(self.q_select) + sql += "t2.%s as asct22, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_join_2 + sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + self.restartDnodes() + tdSql.query("select 1-10 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts , min(asct1) from ( select " + sql += "%s as asct1 ," % math_fun_1 + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ") %s " % random.choice(self.unionall_or_union) + sql += "select ts , max(asct2) from ( select " + sql += "%s as asct1 ," % math_fun_1 + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_1 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += ") %s " % random.choice(self.unionall_or_union) + sql += "select count(asct2) from ( select " + sql += "%s as asct2 " % math_fun_2 + sql += "from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + #3 inter union not support + tdSql.query("select 1-11 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select min(asct1), max(asct2) from ( select " + sql += "%s as asct1, ts ," % math_fun_1 + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as t2ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += " %s " % random.choice(self.unionall_or_union) + sql += " select " + sql += "%s as asct1, ts as t1ts," % math_fun_1 + sql += "%s as asct2, " % math_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as t2ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_1 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += " %s " % random.choice(self.unionall_or_union) + sql += " select " + sql += "%s as asct2 " % math_fun_2 + sql += " from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-12 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts1,ts2 ,timediff(ts1,ts2), max(asct1) from ( select t1.ts as ts1," + sql += "%s, " % math_fun_join_1 + sql += "%s as asct1, " % math_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct21, " % random.choice(self.q_select) + sql += "t2.%s as asct111, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_join_2 + sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-13 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts ," + sql += "%s as asct11, " % math_fun_1 + sql += "%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % random.choice(self.q_select) + sql += "%s as asct14, " % math_fun_2 + sql += "%s as asct15 " % random.choice(self.t_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select " + sql += "%s " % math_fun_2 + sql += "%s " % random.choice(self.t_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-14 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select avg(asct1),count(asct2) from ( select " + sql += "%s as asct1, " % math_fun_1 + sql += "%s as asct2" % math_fun_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) + sql += " ) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE'])or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_1 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) + sql += " ) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-15 as math_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (mathlist == ['SIN','COS','TAN','ASIN','ACOS','ATAN']) or (mathlist == ['ABS','SQRT']) \ + or (mathlist == ['POW','LOG']) or (mathlist == ['FLOOR','CEIL','ROUND']) : + sql = "select ts1,ts ,timediff(ts1,ts), max(asct1) from ( select t1.ts as ts1," + sql += "%s, " % math_fun_join_1 + sql += "%s as asct1, " % math_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14, " % random.choice(self.q_select) + sql += "t2.ts from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) + sql += ") " + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (mathlist == ['MAVG']) or (mathlist == ['SAMPLE']) or (mathlist == ['TAIL']) or (mathlist == ['CSUM']) or (mathlist == ['HISTOGRAM']) \ + or (mathlist == ['HYPERLOGLOG']) or (mathlist == ['UNIQUE']) or (mathlist == ['MODE']) or (mathlist == ['statecount','stateduration']) : + sql = "select count(asct1) from ( select " + sql += "%s as asct1 " % math_fun_join_2 + sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) + sql += ") " + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + #taos -f sql + # startTime_taosf = time.time() + print("taos -f %s sql start!" %mathlist) + taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) + #_ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") + _ = subprocess.check_output(taos_cmd1, shell=True) + print("taos -f %s sql over!" %mathlist) + # endTime_taosf = time.time() + # print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) + + print("=========%s====over=============" %mathlist) - def run(self): - tdSql.prepare() - os.system("rm -rf nestedQuery3.py.sql") + def str_nest(self,strlist): + + print("==========%s===start=============" %strlist) + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.dropandcreateDB_random("%s" %self.db_nest, 1) + + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['LENGTH','CHAR_LENGTH']) \ + or (strlist == ['']): + str_functions = strlist + fun_fix_column = ['(q_nchar)','(q_binary)','(q_nchar_null)','(q_binary_null)'] + fun_column_1 = random.sample(str_functions,1)+random.sample(fun_fix_column,1) + str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_2 = random.sample(str_functions,1)+random.sample(fun_fix_column,1) + str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_fix_column_j = ['(t1.q_nchar)','(t1.q_binary)','(t1.q_nchar_null)','(t1.q_binary_null)', + '(t2.q_nchar)','(t2.q_binary)','(t2.q_nchar_null)','(t2.q_binary_null)'] + fun_column_join_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) + str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_join_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) + str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_fix_column_s = ['(q_nchar)','(q_binary)','(q_nchar_null)','(q_binary_null)','(loc)','(tbname)'] + fun_column_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1) + str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1) + str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_binary)','(t1.q_nchar_null)','(t1.q_binary_null)','(t1.loc)','(t1.tbname)', + '(t2.q_nchar)','(t2.q_binary)','(t2.q_nchar_null)','(t2.q_binary_null)','(t2.loc)','(t2.tbname)'] + fun_column_join_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) + str_fun_join_s_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_join_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) + str_fun_join_s_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + elif (strlist == ['SUBSTR']) : + str_functions = strlist + pos = random.randint(1, 20) + sub_len = random.randint(1, 10) + fun_fix_column = ['(q_nchar,pos)','(q_binary,pos)','(q_nchar_null,pos)','(q_binary_null,pos)', + '(q_nchar,pos,sub_len)','(q_binary,pos,sub_len)','(q_nchar_null,pos,sub_len)','(q_binary_null,pos,sub_len)',] + fun_column_1 = random.sample(str_functions,1)+random.sample(fun_fix_column,1) + str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) + fun_column_2 = random.sample(str_functions,1)+random.sample(fun_fix_column,1) + str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) + + fun_fix_column_j = ['(t1.q_nchar,pos)','(t1.q_binary,pos)','(t1.q_nchar_null,pos)','(t1.q_binary_null,pos)', + '(t1.q_nchar,pos,sub_len)','(t1.q_binary,pos,sub_len)','(t1.q_nchar_null,pos,sub_len)','(t1.q_binary_null,pos,sub_len)', + '(t2.q_nchar,pos)','(t2.q_binary,pos)','(t2.q_nchar_null,pos)','(t2.q_binary_null,pos)', + '(t2.q_nchar,pos,sub_len)','(t2.q_binary,pos,sub_len)','(t2.q_nchar_null,pos,sub_len)','(t2.q_binary_null,pos,sub_len)'] + fun_column_join_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) + str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) + fun_column_join_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_j,1) + str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) + + fun_fix_column_s = ['(q_nchar,pos)','(q_binary,pos)','(q_nchar_null,pos)','(q_binary_null,pos)','(loc,pos)', + '(q_nchar,pos,sub_len)','(q_binary,pos,sub_len)','(q_nchar_null,pos,sub_len)','(q_binary_null,pos,sub_len)','(loc,pos,sub_len)',] + fun_column_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1) + str_fun_s_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) + fun_column_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s,1) + str_fun_s_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) + + fun_fix_column_s_j = ['(t1.q_nchar,pos)','(t1.q_binary,pos)','(t1.q_nchar_null,pos)','(t1.q_binary_null,pos)','(t1.loc,pos)', + '(t1.q_nchar,pos,sub_len)','(t1.q_binary,pos,sub_len)','(t1.q_nchar_null,pos,sub_len)','(t1.q_binary_null,pos,sub_len)','(t1.loc,pos,sub_len)', + '(t2.q_nchar,pos)','(t2.q_binary,pos)','(t2.q_nchar_null,pos)','(t2.q_binary_null,pos)','(t2.loc,pos)', + '(t2.q_nchar,pos,sub_len)','(t2.q_binary,pos,sub_len)','(t2.q_nchar_null,pos,sub_len)','(t2.q_binary_null,pos,sub_len)','(t2.loc,pos,sub_len)'] + fun_column_join_s_1 = random.sample(str_functions,1)+random.sample(fun_fix_column_s_j,1) + str_fun_join_s_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) + fun_column_join_s_2 = random.sample(str_functions,1)+random.sample(fun_fix_column_s_j,1) + str_fun_join_s_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("pos",str(pos)).replace("sub_len",str(sub_len)) + + elif (strlist == ['CONCAT']) : + str_functions = strlist + i = random.randint(2,4) + fun_fix_column = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','q_nchar_null', + 'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null'] + + column1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+column1+')' + str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") + + column2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+column2+')' + str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)', + '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)', + '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)', + '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)'] + + column_j1 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+column_j1+')' + str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") + + column_j2 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+column_j2+')' + str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_s = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','loc','q_nchar_null', + 'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null'] + + column_s1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") + fun_column_s_1 = str(random.sample(str_functions,1))+'('+column_s1+')' + str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","") + + column_s2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") + fun_column_s_2 = str(random.sample(str_functions,1))+'('+column_s2+')' + str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)','(t1.loc)', + '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)','(t2.loc)', + '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)', + '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)'] + + column_j_s1 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","") + fun_column_join_s_1 = str(random.sample(str_functions,1))+'('+column_j_s1+')' + str_fun_join_s_1 = str(fun_column_join_s_1).replace("[","").replace("]","").replace("'","") + + column_j_s2 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","") + fun_column_join_s_2 = str(random.sample(str_functions,1))+'('+column_j_s2+')' + str_fun_join_s_2 = str(fun_column_join_s_2).replace("[","").replace("]","").replace("'","") + + elif (strlist == ['CONCAT_WS']): + str_functions = strlist + i = random.randint(2,4) + fun_fix_column = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','q_nchar_null', + 'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null'] + + separators = ['',' ','abc','123','!','@','#','$','%','^','&','*','(',')','-','_','+','=','{', + '[','}',']','|',';',':',',','.','<','>','?','/','~','`','taos','涛思'] + separator = str(random.sample(separators,i)).replace("[","").replace("]","") + + column1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column1+')' + str_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") + + column2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column2+')' + str_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)', + '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)', + '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)', + '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)'] + + column_j1 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j1+')' + str_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") + + column_j2 = str(random.sample(fun_fix_column_j,i)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j2+')' + str_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_s = ['q_nchar','q_nchar1','q_nchar2','q_nchar3','q_nchar4','q_nchar5','q_nchar6','q_nchar7','q_nchar8','loc','q_nchar_null', + 'q_binary','q_binary1','q_binary2','q_binary3','q_binary4','q_binary5','q_binary6','q_binary7','q_binary8','q_binary_null'] + + column_s1 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") + fun_column_s_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_s1+')' + str_fun_s_1 = str(fun_column_s_1).replace("[","").replace("]","").replace("'","") + + column_s2 = str(random.sample(fun_fix_column,i)).replace("[","").replace("]","").replace("'","") + fun_column_s_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_s2+')' + str_fun_s_2 = str(fun_column_s_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_s_j = ['(t1.q_nchar)','(t1.q_nchar1)','(t1.q_nchar2)','(t1.q_nchar3)','(t1.q_nchar4)','(t1.q_nchar5)','(t1.q_nchar6)','(t1.q_nchar7)','(t1.q_nchar8)','(t1.q_nchar_null)','(t1.loc)', + '(t2.q_nchar)','(t2.q_nchar1)','(t2.q_nchar2)','(t2.q_nchar3)','(t2.q_nchar4)','(t2.q_nchar5)','(t2.q_nchar6)','(t2.q_nchar7)','(t2.q_nchar8)','(t2.q_nchar_null)','(t2.loc)', + '(t1.q_binary)','(t1.q_binary1)','(t1.q_binary2)','(t1.q_binary3)','(t1.q_binary4)','(t1.q_binary5)','(t1.q_binary6)','(t1.q_binary7)','(t1.q_binary8)','(t1.q_binary_null)', + '(t2.q_binary)','(t2.q_binary1)','(t2.q_binary2)','(t2.q_binary3)','(t2.q_binary4)','(t2.q_binary5)','(t2.q_binary6)','(t2.q_binary7)','(t2.q_binary8)','(t2.q_binary_null)'] + + column_j_s1 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","") + fun_column_join_s_1 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j_s1+')' + str_fun_join_s_1 = str(fun_column_join_s_1).replace("[","").replace("]","").replace("'","") + + column_j_s2 = str(random.sample(fun_fix_column_s_j,i)).replace("[","").replace("]","").replace("'","") + fun_column_join_s_2 = str(random.sample(str_functions,1))+'('+'\"'+separator+'\",'+column_j_s2+')' + str_fun_join_s_2 = str(fun_column_join_s_2).replace("[","").replace("]","").replace("'","") + + + tdSql.query("select 1-1 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']) : + sql = "select t1s , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " + sql += "%s as asct1, " % str_fun_1 + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as t1s from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " + sql += "%s as asct1, " % str_fun_1 + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-2 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']) : + sql = "select ts , asct1 from ( select " + sql += "%s as asct1, " % str_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s )" % random.choice(self.order_where) + sql += "%s " % random.choice(self.unionall_or_union) + sql += "select ts , asct2 from ( select " + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + #sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1) from ( select " + sql += "%s as asct1, " % str_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s )" % random.choice(self.order_where) + sql += "%s " % random.choice(self.unionall_or_union) + sql += "select sum(asct2), min(asct2) from ( select " + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-3 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " + sql += "%s as asct1 ," % str_fun_1 + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2 ," % str_fun_2 + sql += "%s as asct1, " % str_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + #tdSql.query(sql) #'unexpected end of data' + # self.cur1.execute(sql) + # self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " + sql += "%s as asct1 ," % str_fun_1 + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2 ," % str_fun_2 + sql += "%s as asct1, " % str_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-4 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_1 + sql += "%s as asct1, " % str_fun_join_2 + sql += "%s, " % str_fun_join_1 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t2.%s as asct12, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_1 + sql += "%s as asct1, " % str_fun_join_2 + sql += "%s, " % str_fun_join_1 + sql += "t1.%s as asct21, " % random.choice(self.q_select) + sql += "t2.%s as asct22, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-5 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts ," + sql += "%s, " % str_fun_1 + sql += "%s as asct21, " % random.choice(self.q_select) + sql += "%s as asct22, " % random.choice(self.q_select) + sql += "%s " % str_fun_2 + sql += " from ( select * from regular_table_1 ) where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select ts ," + sql += "%s, " % str_fun_1 + sql += "%s as asct22, " % random.choice(self.q_select) + sql += "%s as asct21, " % random.choice(self.q_select) + sql += "%s " % str_fun_2 + sql += " from ( select * from regular_table_1 ) where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) - startTime = time.time() + tdSql.query("select 1-6 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts1,ts ,timediff(ts1,ts), LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_1 + sql += "%s as asct1, " % str_fun_join_2 + sql += "t1.%s as asct22, " % random.choice(self.q_select) + sql += "t2.%s as asct21, " % random.choice(self.q_select) + sql += "%s, " % str_fun_join_1 + sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s )" % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_1 + sql += "%s as asct1, " % str_fun_join_2 + sql += "t1.%s as asct22, " % random.choice(self.q_select) + sql += "t2.%s as asct21, " % random.choice(self.q_select) + sql += "%s, " % str_fun_join_1 + sql += "t2.ts as ts2 from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s )" % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - db = "nest" - self.dropandcreateDB_random("%s" %db, 1) + tdSql.query("select 1-7 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select t1s ,ts1, LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " + sql += "%s as asct1, ts as t1s," % str_fun_s_1 + sql += "%s as asct2, " % str_fun_s_2 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) + sql += "ts as ts1 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " + sql += "%s as asct1, ts as ts1," % str_fun_s_1 + sql += "%s as asct2, " % str_fun_s_2 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) + sql += "ts as t1s from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-8 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts1,st1, LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) " + sql += "from ( select " + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s as asct1, ts as st1," % str_fun_s_1 + sql += "%s as asct2, " % str_fun_s_2 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) + sql += "ts as ts1 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) " + sql += "from ( select " + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s as asct1, ts as ts1," % str_fun_s_1 + sql += "%s as asct2, " % str_fun_s_2 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) + sql += "ts as st1 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - # regular column select - q_select= ['ts' , '*' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts '] - q_select= ['ts' , 'q_int', 'q_bigint' , 'q_bigint' , 'q_smallint' , 'q_tinyint' , 'q_bool' , 'q_binary' , 'q_nchar' ,'q_float' , 'q_double' ,'q_ts ', 'q_int_null ', 'q_bigint_null ' , 'q_bigint_null ' , 'q_smallint_null ' , 'q_tinyint_null ' , 'q_bool_null ' , 'q_binary_null ' , 'q_nchar_null ' ,'q_float_null ' , 'q_double_null ' ,'q_ts_null '] + tdSql.query("select 1-9 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_s_1 + sql += "%s as asct1, " % str_fun_join_s_2 + sql += "t1.%s as asct21, " % random.choice(self.q_select) + sql += "t1.%s as asct22, " % random.choice(self.q_select) + sql += "t2.%s as asct23, " % random.choice(self.q_select) + sql += "t2.%s as asct24, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_s_1 + sql += "%s as asct1, " % str_fun_join_s_2 + sql += "t1.%s as asct21, " % random.choice(self.q_select) + sql += "t1.%s as asct22, " % random.choice(self.q_select) + sql += "t2.%s as asct23, " % random.choice(self.q_select) + sql += "t2.%s as asct24, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + self.restartDnodes() + tdSql.query("select 1-10 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " + sql += "%s as asct1 ," % str_fun_s_1 + sql += "%s as asct2, " % str_fun_s_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ") %s " % random.choice(self.unionall_or_union) + sql += "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " + sql += "%s as asct1 ," % str_fun_1 + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " + sql += "%s as asct1 ," % str_fun_s_1 + sql += "%s as asct2, " % str_fun_s_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ") %s " % random.choice(self.unionall_or_union) + sql += "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " + sql += "%s as asct1 ," % str_fun_1 + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + #3 inter union not support + tdSql.query("select 1-11 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts , LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " + sql += "%s as asct1, ts ," % str_fun_s_1 + sql += "%s as asct2, " % str_fun_s_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s " % random.choice(self.q_select) + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += " %s " % random.choice(self.unionall_or_union) + sql += " select " + sql += "%s as asct1, ts ," % str_fun_1 + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s " % random.choice(self.q_select) + sql += " from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " + sql += "%s as asct1 ," % str_fun_s_1 + sql += "%s as asct2, " % str_fun_s_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += " %s " % random.choice(self.unionall_or_union) + sql += " select " + sql += "%s as asct1 ," % str_fun_1 + sql += "%s as asct2, " % str_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - # tag column select - t_select= ['*' , 'loc' ,'t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts '] - t_select= ['loc' ,'tbname','t_int', 't_bigint' , 't_bigint' , 't_smallint' , 't_tinyint' , 't_bool' , 't_binary' , 't_nchar' ,'t_float' , 't_double' ,'t_ts '] + tdSql.query("select 1-12 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_s_1 + sql += "%s as asct1, " % str_fun_join_s_2 + sql += "t1.%s as asct21, " % random.choice(self.q_select) + sql += "t1.%s as asct22, " % random.choice(self.q_select) + sql += "t2.%s as asct23, " % random.choice(self.q_select) + sql += "t2.%s as asct24, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_s_1 + sql += "%s as asct1, " % str_fun_join_s_2 + sql += "t1.%s as asct21, " % random.choice(self.q_select) + sql += "t1.%s as asct22, " % random.choice(self.q_select) + sql += "t2.%s as asct23, " % random.choice(self.q_select) + sql += "t2.%s as asct24, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-13 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts ," + sql += "%s as asct10, " % str_fun_1 + sql += "%s as asct1, " % random.choice(self.q_select) + sql += "%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % str_fun_2 + sql += "%s as asct14 " % random.choice(self.t_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select ts ," + sql += "%s as asct1, " % str_fun_1 + sql += "%s as asct11, " % random.choice(self.q_select) + sql += "%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % str_fun_2 + sql += "%s as asct14 " % random.choice(self.t_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-14 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select " + sql += "%s as asct1, " % str_fun_s_1 + sql += "%s as asct2" % str_fun_s_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) + sql += " ) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select " + sql += "%s as asct1, " % str_fun_s_1 + sql += "%s as asct2" % str_fun_s_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) + sql += " ) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-15 as str_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (strlist == ['LTRIM','RTRIM','LOWER','UPPER']) or (strlist == ['SUBSTR']) or (strlist == ['CONCAT']) or (strlist == ['CONCAT_WS']): + sql = "select ts,ts2 ,timediff(ts,ts2), LTRIM(asct1), LOWER(asct1), RTRIM(asct2), UPPER(asct2) from ( select t1.ts ," + sql += "%s as asct2, " % str_fun_join_s_1 + sql += "%s as asct1, " % str_fun_join_s_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) + sql += ") " + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (strlist == ['LENGTH','CHAR_LENGTH']): + sql = "select sum(asct1), min(asct1), max(asct2), avg(asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % str_fun_join_s_1 + sql += "%s as asct1, " % str_fun_join_s_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14 " % random.choice(self.q_select) + sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) + sql += ") " + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + #taos -f sql + startTime_taos_f = time.time() + print("taos -f %s sql start!" %strlist) + taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) + #_ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") + _ = subprocess.check_output(taos_cmd1, shell=True) + print("taos -f %s sql over!" %strlist) + endTime_taos_f = time.time() + print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) + + print("=========%s====over=============" %strlist) + + def time_nest(self,timelist): + + print("==========%s===start=============" %timelist) + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.dropandcreateDB_random("%s" %self.db_nest, 1) + + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMEZONE']): + time_functions = timelist + fun_fix_column = ['()'] + fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_fix_column_j = ['()'] + fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - # regular and tag column select - qt_select= q_select + t_select + elif (timelist == ['TIMETRUNCATE']): + time_functions = timelist + + t = time.time() + t_to_s = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t)) + fun_fix_column = ['q_ts','ts','_c0','_C0','_rowts','1600000000000','1600000000000000','1600000000000000000', + '%d' %t, '%d000' %t, '%d000000' %t,'t_to_s'] + + timeunits = ['1a' ,'1s', '1m' ,'1h', '1d'] + timeunit = str(random.sample(timeunits,1)).replace("[","").replace("]","").replace("'","") + + column_1 = ['(%s,timeutil)'%(random.sample(fun_fix_column,1))] + fun_column_1 = random.sample(time_functions,1)+random.sample(column_1,1) + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_1 = str(time_fun_1).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s) + + column_2 = ['(%s,timeutil)'%(random.sample(fun_fix_column,1))] + fun_column_2 = random.sample(time_functions,1)+random.sample(column_2,1) + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_2 = str(time_fun_2).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s) + + + fun_fix_column_j = ['(t1.q_ts)','(t1.ts)', '(t2.q_ts)','(t2.ts)','(1600000000000)','(1600000000000000)','(1600000000000000000)', + '(%d)' %t, '(%d000)' %t, '(%d000000)' %t,'t_to_s'] + + column_j1 = ['(%s,timeutil)'%(random.sample(fun_fix_column_j,1))] + fun_column_join_1 = random.sample(time_functions,1)+random.sample(column_j1,1) + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_join_1 = str(time_fun_join_1).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s) + + column_j2 = ['(%s,timeutil)'%(random.sample(fun_fix_column_j,1))] + fun_column_join_2 = random.sample(time_functions,1)+random.sample(column_j2,1) + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_join_2 = str(time_fun_join_2).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s) - # distinct regular column select - dq_select= ['distinct q_int', 'distinct q_bigint' , 'distinct q_smallint' , 'distinct q_tinyint' , - 'distinct q_bool' , 'distinct q_binary' , 'distinct q_nchar' ,'distinct q_float' , 'distinct q_double' ,'distinct q_ts '] + elif (timelist == ['TO_ISO8601']): + time_functions = timelist + + t = time.time() + fun_fix_column = ['(now())','(ts)','(q_ts)','(_rowts)','(_c0)','(_C0)', + '(1600000000000)','(1600000000000000)','(1600000000000000000)', + '(%d)' %t, '(%d000)' %t, '(%d000000)' %t] + + fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_fix_column_j = ['(t1.q_ts)','(t1.ts)', '(t2.q_ts)','(t2.ts)','(1600000000000)','(1600000000000000)','(1600000000000000000)','(now())', + '(%d)' %t, '(%d000)' %t, '(%d000000)' %t] + + fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - # distinct tag column select - dt_select= ['distinct loc', 'distinct t_int', 'distinct t_bigint' , 'distinct t_smallint' , 'distinct t_tinyint' , - 'distinct t_bool' , 'distinct t_binary' , 'distinct t_nchar' ,'distinct t_float' , 'distinct t_double' ,'distinct t_ts '] + elif (timelist == ['TO_UNIXTIMESTAMP']): + time_functions = timelist + + t = time.time() + t_to_s = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t)) + fun_fix_column = ['(q_nchar)','(q_nchar1)','(q_nchar2)','(q_nchar3)','(q_nchar4)','(q_nchar_null)','(q_binary)','(q_binary5)','(q_binary6)','(q_binary7)','(q_binary8)','(q_binary_null)','(t_to_s)'] + + fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") + time_fun_1 = str(time_fun_1).replace("t_to_s","%s" %t_to_s) + + fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") + time_fun_2 = str(time_fun_2).replace("t_to_s","%s" %t_to_s) + + fun_fix_column_j = ['(t1.q_nchar)','(t1.q_binary)', '(t2.q_nchar)','(t2.q_binary)','(t_to_s)'] + + fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") + time_fun_join_1 = str(time_fun_join_1).replace("t_to_s","%s" %t_to_s) + + fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("t_to_s","'t_to_s'") + time_fun_join_2 = str(time_fun_join_2).replace("t_to_s","%s" %t_to_s) - # distinct regular and tag column select - dqt_select= dq_select + dt_select + elif (timelist == ['TIMEDIFF_1']): + time_functions = timelist + + t = time.time() + t_to_s = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t)) + timeunits = [ '1a' ,'1s', '1m' ,'1h', '1d'] + timeunit = str(random.sample(timeunits,1)).replace("[","").replace("]","").replace("'","") + + fun_fix_column = ['q_ts','ts','_c0','_C0','_rowts','1600000000000','1600000000000000','1600000000000000000', + '%d' %t, '%d000' %t, '%d000000' %t,'t_to_s'] + + column_1,column_2 = random.sample(fun_fix_column,1),random.sample(fun_fix_column,1) + column_12 = ['(%s,%s,timeutil)'%(column_1,column_2)] + fun_column_1 = random.sample(time_functions,1)+random.sample(column_12,1) + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_1 = str(time_fun_1).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s).replace("_1","") + + column_3,column_4 = random.sample(fun_fix_column,1),random.sample(fun_fix_column,1) + column_34 = ['(%s,%s,timeutil)'%(column_3,column_4)] + fun_column_2 = random.sample(time_functions,1)+random.sample(column_34,1) + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_2 = str(time_fun_2).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s).replace("_1","") + + fun_fix_column_j = ['(t1.q_ts)','(t1.ts)', '(t2.q_ts)','(t2.ts)','1600000000000','1600000000000000','1600000000000000000', + '%d' %t, '%d000' %t, '%d000000' %t,'t_to_s'] + + column_j1,column_j2 = random.sample(fun_fix_column_j,1),random.sample(fun_fix_column_j,1) + column_j12 = ['(%s,%s,timeutil)'%(column_j1,column_j2)] + fun_column_join_1 = random.sample(time_functions,1)+random.sample(column_j12,1) + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_join_1 = str(time_fun_join_1).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s).replace("_1","") + + column_j3,column_j4 = random.sample(fun_fix_column_j,1),random.sample(fun_fix_column_j,1) + column_j34 = ['(%s,%s,timeutil)'%(column_j3,column_j4)] + fun_column_join_2 = random.sample(time_functions,1)+random.sample(column_j34,1) + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_join_2 = str(time_fun_join_2).replace("timeutil","%s" %timeunit).replace("t_to_s","%s" %t_to_s).replace("_1","") - # special column select - s_r_select= ['_c0', '_rowts' , '_C0' ] - s_s_select= ['tbname' , '_rowts' , '_c0', '_C0' ] - unionall_or_union= [ ' union ' , ' union all ' ] + elif (timelist == ['TIMEDIFF_2']): + time_functions = timelist + + t = time.time() + t_to_s = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(t)) + + fun_fix_column = ['q_ts','ts','_c0','_C0','_rowts','1600000000000','1600000000000000','1600000000000000000', + '%d' %t, '%d000' %t, '%d000000' %t,'t_to_s'] + + column_1,column_2 = random.sample(fun_fix_column,1),random.sample(fun_fix_column,1) + column_12 = ['(%s,%s)'%(column_1,column_2)] + fun_column_1 = random.sample(time_functions,1)+random.sample(column_12,1) + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_1 = str(time_fun_1).replace("t_to_s","%s" %t_to_s).replace("_2","") + + column_3,column_4 = random.sample(fun_fix_column,1),random.sample(fun_fix_column,1) + column_34 = ['(%s,%s)'%(column_3,column_4)] + fun_column_2 = random.sample(time_functions,1)+random.sample(column_34,1) + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_2 = str(time_fun_2).replace("t_to_s","%s" %t_to_s).replace("_2","") + + fun_fix_column_j = ['(t1.q_ts)','(t1.ts)', '(t2.q_ts)','(t2.ts)','1600000000000','1600000000000000','1600000000000000000', + '%d' %t, '%d000' %t, '%d000000' %t,'t_to_s'] + + column_j1,column_j2 = random.sample(fun_fix_column_j,1),random.sample(fun_fix_column_j,1) + column_j12 = ['(%s,%s)'%(column_j1,column_j2)] + fun_column_join_1 = random.sample(time_functions,1)+random.sample(column_j12,1) + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_join_1 = str(time_fun_join_1).replace("t_to_s","%s" %t_to_s).replace("_2","") + + column_j3,column_j4 = random.sample(fun_fix_column_j,1),random.sample(fun_fix_column_j,1) + column_j34 = ['(%s,%s)'%(column_j3,column_j4)] + fun_column_join_2 = random.sample(time_functions,1)+random.sample(column_j34,1) + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("\"","").replace("t_to_s","'t_to_s'") + time_fun_join_2 = str(time_fun_join_2).replace("t_to_s","%s" %t_to_s).replace("_2","") + + elif (timelist == ['ELAPSED']): + time_functions = timelist + + fun_fix_column = ['(ts)','(_c0)','(_C0)','(_rowts)','(ts,time_unit)','(_c0,time_unit)','(_C0,time_unit)','(_rowts,time_unit)'] + + time_units = ['1s','1m','1h','1d','1a'] + time_unit1 = str(random.sample(time_units,1)).replace("[","").replace("]","").replace("'","") + time_unit2 = str(random.sample(time_units,1)).replace("[","").replace("]","").replace("'","") + + fun_column_1 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit1) + + fun_column_2 = random.sample(time_functions,1)+random.sample(fun_fix_column,1) + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit2) + + + fun_fix_column_j = ['(t1.ts)', '(t2.ts)','(t1.ts,time_unit)','(t1.ts,time_unit)','(t2.ts,time_unit)','(t2.ts,time_unit)'] + + fun_column_join_1 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit1) + + fun_column_join_2 = random.sample(time_functions,1)+random.sample(fun_fix_column_j,1) + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("time_unit","%s" %time_unit2) + + + elif (timelist == ['CAST']) : + str_functions = timelist + #下面的4个是全的,这个只是1个 + i = random.randint(1,4) + if i ==1: + print('===========cast_1===========') + fun_fix_column = ['q_bool','q_bool_null','q_bigint','q_bigint_null','q_smallint','q_smallint_null', + 'q_tinyint','q_tinyint_null','q_int','q_int_null','q_float','q_float_null','q_double','q_double_null'] + type_names = ['BIGINT','BINARY(100)','TIMESTAMP','NCHAR(100)','BIGINT UNSIGNED'] + + type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") + + type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_j = ['t1.q_bool','t1.q_bool_null','t1.q_bigint','t1.q_bigint_null','t1.q_smallint','t1.q_smallint_null', + 't1.q_tinyint','t1.q_tinyint_null','t1.q_int','t1.q_int_null','t1.q_float','t1.q_float_null','t1.q_double','t1.q_double_null', + 't2.q_bool','t2.q_bool_null','t2.q_bigint','t2.q_bigint_null','t2.q_smallint','t2.q_smallint_null', + 't2.q_tinyint','t2.q_tinyint_null','t2.q_int','t2.q_int_null','t2.q_float','t2.q_float_null','t2.q_double','t2.q_double_null'] + + type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") + + type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") + + elif i==2: + print('===========cast_2===========') + fun_fix_column = ['q_binary','q_binary_null','q_binary1','q_binary2','q_binary3','q_binary4'] + type_names = ['BIGINT','BINARY(100)','NCHAR(100)','BIGINT UNSIGNED'] + + type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") - # regular column where - q_where = ['ts < now +1s','q_bigint >= -9223372036854775807 and q_bigint <= 9223372036854775807', 'q_int <= 2147483647 and q_int >= -2147483647', - 'q_smallint >= -32767 and q_smallint <= 32767','q_tinyint >= -127 and q_tinyint <= 127','q_float >= -1.7E308 and q_float <= 1.7E308', - 'q_double >= -1.7E308 and q_double <= 1.7E308', 'q_binary like \'binary%\' or q_binary = \'0\' ' , 'q_nchar like \'nchar%\' or q_nchar = \'0\' ' , - 'q_bool = true or q_bool = false' , 'q_bool in (0 , 1)' , 'q_bool in ( true , false)' , 'q_bool = 0 or q_bool = 1', - 'q_bigint between -9223372036854775807 and 9223372036854775807',' q_int between -2147483647 and 2147483647','q_smallint between -32767 and 32767', - 'q_tinyint between -127 and 127 ','q_float >= -3.4E38 ','q_float <= 3.4E38 ','q_double >= -1.7E308 ', - 'q_double <= 1.7E308 ','q_float between -3.4E38 and 3.4E38 ','q_double between -1.7E308 and 1.7E308 ' , - 'q_float is not null ' ,'q_double is not null ' ,] - #TD-6201 ,'q_bool between 0 and 1' + type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_j = ['t1.q_binary','t1.q_binary_null','t1.q_binary1','t1.q_binary2','t1.q_binary3','t1.q_binary4', + 't2.q_binary','t2.q_binary_null','t2.q_binary1','t2.q_binary2','t2.q_binary3','t2.q_binary4'] + + type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") + + type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") + + elif i==3: + print('===========cast_3===========') + fun_fix_column = ['q_nchar','q_nchar_null','q_nchar5','q_nchar6','q_nchar7','q_nchar8'] + type_names = ['BIGINT','NCHAR(100)','BIGINT UNSIGNED'] + + type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") - # regular column where for test union,join - q_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.q_bigint >= -9223372036854775807 and t1.q_bigint <= 9223372036854775807 and t2.q_bigint >= -9223372036854775807 and t2.q_bigint <= 9223372036854775807', - 't1.q_int <= 2147483647 and t1.q_int >= -2147483647 and t2.q_int <= 2147483647 and t2.q_int >= -2147483647', - 't1.q_smallint >= -32767 and t1.q_smallint <= 32767 and t2.q_smallint >= -32767 and t2.q_smallint <= 32767', - 't1.q_tinyint >= -127 and t1.q_tinyint <= 127 and t2.q_tinyint >= -127 and t2.q_tinyint <= 127', - 't1.q_float >= - 1.7E308 and t1.q_float <= 1.7E308 and t2.q_float >= - 1.7E308 and t2.q_float <= 1.7E308', - 't1.q_double >= - 1.7E308 and t1.q_double <= 1.7E308 and t2.q_double >= - 1.7E308 and t2.q_double <= 1.7E308', - 't1.q_binary like \'binary%\' and t2.q_binary like \'binary%\' ' , - 't1.q_nchar like \'nchar%\' and t2.q_nchar like \'nchar%\' ' , - 't1.q_bool in (0 , 1) and t2.q_bool in (0 , 1)' , 't1.q_bool in ( true , false) and t2.q_bool in ( true , false)' , - 't1.q_bigint between -9223372036854775807 and 9223372036854775807 and t2.q_bigint between -9223372036854775807 and 9223372036854775807', - 't1.q_int between -2147483647 and 2147483647 and t2.q_int between -2147483647 and 2147483647', - 't1.q_smallint between -32767 and 32767 and t2.q_smallint between -32767 and 32767', - 't1.q_tinyint between -127 and 127 and t2.q_tinyint between -127 and 127 ','t1.q_float between -1.7E308 and 1.7E308 and t2.q_float between -1.7E308 and 1.7E308', - 't1.q_double between -1.7E308 and 1.7E308 and t2.q_double between -1.7E308 and 1.7E308'] - #TD-6201 ,'t1.q_bool between 0 and 1 or t2.q_bool between 0 and 1'] - #'t1.q_bool = true and t1.q_bool = false and t2.q_bool = true and t2.q_bool = false' , 't1.q_bool = 0 and t1.q_bool = 1 and t2.q_bool = 0 and t2.q_bool = 1' , + type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_j = ['t1.q_nchar','t1.q_nchar_null','t1.q_nchar5','t1.q_nchar6','t1.q_nchar7','t1.q_nchar8', + 't2.q_nchar','t2.q_nchar_null','t2.q_nchar5','t2.q_nchar6','t2.q_nchar7','t2.q_nchar8'] + + type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") + + type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") + + elif i==4: + print('===========cast_4===========') + fun_fix_column = ['q_ts','q_ts_null','_C0','_c0','ts','_rowts'] + type_names = ['BIGINT','TIMESTAMP','BIGINT UNSIGNED'] + + type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","") + + type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","") + + fun_fix_column_j = ['t1.q_ts','t1.q_ts_null','t1.ts','t2.q_ts','t2.q_ts_null','t2.ts'] + + type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","") + + type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","") + + elif (timelist == ['CAST_1']) : + str_functions = timelist + + print('===========cast_1===========') + fun_fix_column = ['q_bool','q_bool_null','q_bigint','q_bigint_null','q_smallint','q_smallint_null', + 'q_tinyint','q_tinyint_null','q_int','q_int_null','q_float','q_float_null','q_double','q_double_null'] + type_names = ['BIGINT','BINARY(100)','TIMESTAMP','NCHAR(100)','BIGINT UNSIGNED'] + + type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_1","") + + type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_1","") + + fun_fix_column_j = ['t1.q_bool','t1.q_bool_null','t1.q_bigint','t1.q_bigint_null','t1.q_smallint','t1.q_smallint_null', + 't1.q_tinyint','t1.q_tinyint_null','t1.q_int','t1.q_int_null','t1.q_float','t1.q_float_null','t1.q_double','t1.q_double_null', + 't2.q_bool','t2.q_bool_null','t2.q_bigint','t2.q_bigint_null','t2.q_smallint','t2.q_smallint_null', + 't2.q_tinyint','t2.q_tinyint_null','t2.q_int','t2.q_int_null','t2.q_float','t2.q_float_null','t2.q_double','t2.q_double_null'] + + type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_1","") + + type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_1","") + + elif (timelist == ['CAST_2']) : + str_functions = timelist + print('===========cast_2===========') + fun_fix_column = ['q_binary','q_binary_null','q_binary1','q_binary2','q_binary3','q_binary4'] + type_names = ['BIGINT','BINARY(100)','NCHAR(100)','BIGINT UNSIGNED'] + + type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_2","") - q_u_or_where = ['(t1.q_binary like \'binary%\' or t1.q_binary = \'0\' or t2.q_binary like \'binary%\' or t2.q_binary = \'0\' )' , - '(t1.q_nchar like \'nchar%\' or t1.q_nchar = \'0\' or t2.q_nchar like \'nchar%\' or t2.q_nchar = \'0\' )' , '(t1.q_bool = true or t1.q_bool = false or t2.q_bool = true or t2.q_bool = false)' , - '(t1.q_bool in (0 , 1) or t2.q_bool in (0 , 1))' , '(t1.q_bool in ( true , false) or t2.q_bool in ( true , false))' , '(t1.q_bool = 0 or t1.q_bool = 1 or t2.q_bool = 0 or t2.q_bool = 1)' , - '(t1.q_bigint between -9223372036854775807 and 9223372036854775807 or t2.q_bigint between -9223372036854775807 and 9223372036854775807)', - '(t1.q_int between -2147483647 and 2147483647 or t2.q_int between -2147483647 and 2147483647)', - '(t1.q_smallint between -32767 and 32767 or t2.q_smallint between -32767 and 32767)', - '(t1.q_tinyint between -127 and 127 or t2.q_tinyint between -127 and 127 )','(t1.q_float between -1.7E308 and 1.7E308 or t2.q_float between -1.7E308 and 1.7E308)', - '(t1.q_double between -1.7E308 and 1.7E308 or t2.q_double between -1.7E308 and 1.7E308)'] + type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_2","") + + fun_fix_column_j = ['t1.q_binary','t1.q_binary_null','t1.q_binary1','t1.q_binary2','t1.q_binary3','t1.q_binary4', + 't2.q_binary','t2.q_binary_null','t2.q_binary1','t2.q_binary2','t2.q_binary3','t2.q_binary4'] + + type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_2","") + + type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_2","") + + elif (timelist == ['CAST_3']) : + str_functions = timelist + print('===========cast_3===========') + fun_fix_column = ['q_nchar','q_nchar_null','q_nchar5','q_nchar6','q_nchar7','q_nchar8'] + type_names = ['BIGINT','NCHAR(100)','BIGINT UNSIGNED'] + + type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_3","") - # tag column where - t_where = ['ts < now +1s','t_bigint >= -9223372036854775807 and t_bigint <= 9223372036854775807','t_int <= 2147483647 and t_int >= -2147483647', - 't_smallint >= -32767 and t_smallint <= 32767','q_tinyint >= -127 and t_tinyint <= 127','t_float >= -1.7E308 and t_float <= 1.7E308', - 't_double >= -1.7E308 and t_double <= 1.7E308', 't_binary like \'binary%\' or t_binary = \'0\' ' , 't_nchar like \'nchar%\' or t_nchar = \'0\'' , - 't_bool = true or t_bool = false' , 't_bool in (0 , 1)' , 't_bool in ( true , false)' , 't_bool = 0 or t_bool = 1', - 't_bigint between -9223372036854775807 and 9223372036854775807',' t_int between -2147483647 and 2147483647','t_smallint between -32767 and 32767', - 't_tinyint between -127 and 127 ','t_float between -1.7E308 and 1.7E308','t_double between -1.7E308 and 1.7E308'] - #TD-6201,'t_bool between 0 and 1' + type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_3","") + + fun_fix_column_j = ['t1.q_nchar','t1.q_nchar_null','t1.q_nchar5','t1.q_nchar6','t1.q_nchar7','t1.q_nchar8', + 't2.q_nchar','t2.q_nchar_null','t2.q_nchar5','t2.q_nchar6','t2.q_nchar7','t2.q_nchar8'] + + type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_3","") + + type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_3","") + + elif (timelist == ['CAST_4']) : + str_functions = timelist + print('===========cast_4===========') + fun_fix_column = ['q_ts','q_ts_null','_C0','_c0','ts','_rowts'] + type_names = ['BIGINT','TIMESTAMP','BIGINT UNSIGNED'] + + type_name1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name1+')' + time_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace("_4","") + + type_name2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column,1))+' AS '+type_name2+')' + time_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace("_4","") + + fun_fix_column_j = ['t1.q_ts','t1.q_ts_null','t1.ts','t2.q_ts','t2.q_ts_null','t2.ts'] + + type_name_j1 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_1 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j1+')' + time_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace("_4","") + + type_name_j2 = str(random.sample(type_names,1)).replace("[","").replace("]","").replace("'","") + fun_column_join_2 = str(random.sample(str_functions,1))+'('+str(random.sample(fun_fix_column_j,1))+' AS '+type_name_j2+')' + time_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace("_4","") + + tdSql.query("select 1-1 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts1 , timediff(asct1,now) from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ts1 from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) \ + or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts2 , asct1,now(),today(),timezone() from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ts2 from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select max(asct1),now(),today(),timezone() from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2 " % time_fun_2 + sql += "from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-2 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts , timediff(asct1,now),now(),today(),timezone() from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s )" % random.choice(self.order_where) + sql += "%s " % random.choice(self.unionall_or_union) + sql += "select ts , timediff(asct2,now),now(),today(),timezone() from ( select " + sql += "%s as asct2, " % time_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + #sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts , (asct1),now(),today(),timezone() from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s )" % random.choice(self.order_where) + sql += "%s " % random.choice(self.unionall_or_union) + sql += "select ts , asct2,now(),today(),timezone() from ( select " + sql += "%s as asct2, " % time_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select min(asct1),now(),today(),timezone() from ( select " + sql += "%s as asct1 " % time_fun_1 + sql += " from regular_table_1 where " + sql += "%s )" % random.choice(self.q_where) + sql += "%s " % random.choice(self.unionall_or_union) + sql += "select avg(asct2),now(),today(),timezone() from ( select " + sql += "%s as asct2 " % time_fun_2 + sql += " from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-3 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts , timediff(asct1,now) from ( select " + sql += "%s as asct1, ts ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s " % random.choice(self.q_select) + sql += "from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2, ts ," % time_fun_2 + sql += "%s as asct1, " % time_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s " % random.choice(self.q_select) + sql += "from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += " order by asct1 desc " + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts , (asct1),now(),today(),timezone() from ( select " + sql += "%s as asct1, ts ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s " % random.choice(self.q_select) + sql += " from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2, ts ," % time_fun_2 + sql += "%s as asct1, " % time_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s " % random.choice(self.q_select) + sql += "from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += " order by asct1 desc " + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select abs(asct1),now(),today(),timezone() from ( select " + sql += "%s as asct1," % time_fun_1 + sql += "%s as asct2 " % time_fun_2 + sql += "from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2," % time_fun_2 + sql += "%s as asct1 " % time_fun_1 + sql += "from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += " order by asct1 asc " + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-4 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), timediff(asct1,now) from ( select t1.ts as ts1," + sql += "%s as asct11, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "%s as asct12, " % time_fun_join_1 + sql += "t1.%s as asct111, " % random.choice(self.q_select) + sql += "t2.%s as asct121, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), (asct1) from ( select t1.ts as ts1," + sql += "%s as asct10, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "%s as asct11, " % time_fun_join_1 + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select floor(asct1) from ( select " + sql += "%s as asct10, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "%s as asct11" % time_fun_join_1 + sql += " from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-5 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['ELAPSED']) : + sql = "select now(),today(),timezone(), " + sql += "%s, " % time_fun_1 + sql += "%s " % time_fun_2 + sql += " from ( select * from regular_table_1 ) where " + sql += "%s " % random.choice(self.q_where) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + else: + sql = "select ts ,now(),today(),timezone(), " + sql += "%s as asct11, " % time_fun_1 + sql += "%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % random.choice(self.q_select) + sql += "%s as asct14 " % time_fun_2 + sql += " from ( select * from regular_table_1 ) where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) - # tag column where for test union,join | this is not support - t_u_where = ['t1.ts < now +1s' , 't2.ts < now +1s','t1.t_bigint >= -9223372036854775807 and t1.t_bigint <= 9223372036854775807 and t2.t_bigint >= -9223372036854775807 and t2.t_bigint <= 9223372036854775807', - 't1.t_int <= 2147483647 and t1.t_int >= -2147483647 and t2.t_int <= 2147483647 and t2.t_int >= -2147483647', - 't1.t_smallint >= -32767 and t1.t_smallint <= 32767 and t2.t_smallint >= -32767 and t2.t_smallint <= 32767', - 't1.t_tinyint >= -127 and t1.t_tinyint <= 127 and t2.t_tinyint >= -127 and t2.t_tinyint <= 127', - 't1.t_float >= -1.7E308 and t1.t_float <= 1.7E308 and t2.t_float >= -1.7E308 and t2.t_float <= 1.7E308', - 't1.t_double >= -1.7E308 and t1.t_double <= 1.7E308 and t2.t_double >= -1.7E308 and t2.t_double <= 1.7E308', - '(t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\') ' , - '(t1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' )' , '(t1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false)' , - 't1.t_bool in (0 , 1) and t2.t_bool in (0 , 1)' , 't1.t_bool in ( true , false) and t2.t_bool in ( true , false)' , '(t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1)', - 't1.t_bigint between -9223372036854775807 and 9223372036854775807 and t2.t_bigint between -9223372036854775807 and 9223372036854775807', - 't1.t_int between -2147483647 and 2147483647 and t2.t_int between -2147483647 and 2147483647', - 't1.t_smallint between -32767 and 32767 and t2.t_smallint between -32767 and 32767', - '(t1.t_tinyint between -127 and 127 and t2.t_tinyint between -127 and 127) ','t1.t_float between -1.7E308 and 1.7E308 and t2.t_float between -1.7E308 and 1.7E308', - '(t1.t_double between -1.7E308 and 1.7E308 and t2.t_double between -1.7E308 and 1.7E308)'] - #TD-6201,'t1.t_bool between 0 and 1 or t2.q_bool between 0 and 1'] + tdSql.query("select 1-6 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts1,ts ,timediff(ts1,ts), timediff(asct1,now) from ( select t1.ts as ts1," + sql += "%s as asct121, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t2.%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % time_fun_join_1 + sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s )" % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts1,ts ,timediff(ts1,ts), (asct1) from ( select t1.ts as ts1," + sql += "%s as asct121, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t2.%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % time_fun_join_1 + sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s )" % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select (asct1)*111 from ( select " + sql += "%s as asct121, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "%s as asct122 " % time_fun_join_1 + sql += " from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s )" % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - t_u_or_where = ['(t1.t_binary like \'binary%\' or t1.t_binary = \'0\' or t2.t_binary like \'binary%\' or t2.t_binary = \'0\' )' , - '(t1.t_nchar like \'nchar%\' or t1.t_nchar = \'0\' or t2.t_nchar like \'nchar%\' or t2.t_nchar = \'0\' )' , '(t1.t_bool = true or t1.t_bool = false or t2.t_bool = true or t2.t_bool = false)' , - '(t1.t_bool in (0 , 1) or t2.t_bool in (0 , 1))' , '(t1.t_bool in ( true , false) or t2.t_bool in ( true , false))' , '(t1.t_bool = 0 or t1.t_bool = 1 or t2.t_bool = 0 or t2.t_bool = 1)', - '(t1.t_bigint between -9223372036854775807 and 9223372036854775807 or t2.t_bigint between -9223372036854775807 and 9223372036854775807)', - '(t1.t_int between -2147483647 and 2147483647 or t2.t_int between -2147483647 and 2147483647)', - '(t1.t_smallint between -32767 and 32767 or t2.t_smallint between -32767 and 32767)', - '(t1.t_tinyint between -127 and 127 or t2.t_tinyint between -127 and 127 )','(t1.t_float between -1.7E308 and 1.7E308 or t2.t_float between -1.7E308 and 1.7E308)', - '(t1.t_double between -1.7E308 and 1.7E308 or t2.t_double between -1.7E308 and 1.7E308)'] + tdSql.query("select 1-7 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts1,m1 , timediff(asct1,now) from ( select " + sql += "%s as asct1, ts as m1," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct11, " % random.choice(self.q_select) + sql += "%s as asct12, " % random.choice(self.t_select) + sql += "ts as ts1 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select tm1,tm2 , (asct1),now(),today(),timezone() from ( select " + sql += "%s as asct1, ts as tm1," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct11, " % random.choice(self.q_select) + sql += "%s as asct12, " % random.choice(self.t_select) + sql += "ts as tm2 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select (asct1)/asct2 ,now(),today(),timezone() from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2 " % time_fun_2 + sql += "from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-8 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select tm1,tm2 , timediff(asct1,now) " + sql += "from ( select " + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s as asct1, ts as tm1," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct11, " % random.choice(self.q_select) + sql += "%s as asct12, " % random.choice(self.t_select) + sql += "ts as tm2 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts1,ts2 , (asct1),now(),today(),timezone() " + sql += "from ( select " + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s as asct1, ts as ts1," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct11, " % random.choice(self.q_select) + sql += "%s as asct12, " % random.choice(self.t_select) + sql += "ts as ts2 from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select floor(abs(asct1)),now(),today(),timezone() " + sql += "from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2 " % time_fun_2 + sql += "from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - # regular and tag column where - qt_where = q_where + t_where - qt_u_where = q_u_where + t_u_where - # now,qt_u_or_where is not support - qt_u_or_where = q_u_or_where + t_u_or_where + tdSql.query("select 1-9 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), timediff(asct1,now) from ( select t1.ts as ts1," + sql += "%s as asct121, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), asct1 from ( select t1.ts as ts1," + sql += "%s as asct121, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select min(asct1*110) from ( select " + sql += "%s as asct121, " % time_fun_join_1 + sql += "%s as asct1 " % time_fun_join_2 + sql += "from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + self.restartDnodes() + tdSql.query("select 1-10 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts , timediff(asct1,now) from ( select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct121, " % random.choice(self.s_r_select) + sql += "%s as asct122, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ") %s " % random.choice(self.unionall_or_union) + sql += "select ts , timediff(asct1,now) from ( select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct121, " % random.choice(self.s_r_select) + sql += "%s as asct122, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts , (asct1),now(),today(),timezone() from ( select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct121, " % random.choice(self.s_r_select) + sql += "%s as asct122, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ") %s " % random.choice(self.unionall_or_union) + sql += "select ts , (asct2),now(),today(),timezone() from ( select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct121, " % random.choice(self.s_r_select) + sql += "%s as asct122, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select abs(asct1),now(),today(),timezone() from ( select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2 " % time_fun_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += ") %s " % random.choice(self.unionall_or_union) + sql += "select max(asct2),now(),today(),timezone() from ( select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2 " % time_fun_2 + sql += "from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + #3 inter union not support + tdSql.query("select 1-11 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts , timediff(asct1,now), timediff(now,asct2) from ( select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct121, " % random.choice(self.s_r_select) + sql += "%s as asct122, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += " %s " % random.choice(self.unionall_or_union) + sql += " select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct121, " % random.choice(self.s_r_select) + sql += "%s as asct122, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts , asct1,now(),now(),asct2 from ( select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct121, " % random.choice(self.s_r_select) + sql += "%s as asct122, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += " %s " % random.choice(self.unionall_or_union) + sql += " select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2, " % time_fun_2 + sql += "%s as asct121, " % random.choice(self.s_r_select) + sql += "%s as asct122, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select asct1+asct2,now(),today(),timezone() from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2 " % time_fun_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += " %s " % random.choice(self.unionall_or_union) + sql += " select " + sql += "%s as asct1 ," % time_fun_1 + sql += "%s as asct2 " % time_fun_2 + sql += " from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "order by asct1 " + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - # tag column where for test super join | this is support , 't1.t_bool = t2.t_bool ' ??? - t_join_where = ['t1.t_bigint = t2.t_bigint ', 't1.t_int = t2.t_int ', 't1.t_smallint = t2.t_smallint ', 't1.t_tinyint = t2.t_tinyint ', - 't1.t_float = t2.t_float ', 't1.t_double = t2.t_double ', 't1.t_binary = t2.t_binary ' , 't1.t_nchar = t2.t_nchar ' ] + tdSql.query("select 1-12 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), timediff(asct1,now) from ( select t1.ts as ts1," + sql += "%s, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts1,ts2 ,timediff(ts1,ts2), asct1,now() from ( select t1.ts as ts1," + sql += "%s, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14, " % random.choice(self.q_select) + sql += "t2.ts as ts2 from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select min(floor(asct1)),now() from ( select " + sql += "%s as asct121, " % time_fun_join_1 + sql += "%s as asct1 " % time_fun_join_2 + sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-13 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts , timediff(%s,now)," % time_fun_2 + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct11, " % random.choice(self.q_select) + sql += "%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % time_fun_2 + sql += "%s as asct122 " % random.choice(self.t_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts ,now(),today(),timezone(), " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct11, " % random.choice(self.q_select) + sql += "%s as asct12, " % random.choice(self.q_select) + sql += "%s as asct13, " % time_fun_2 + sql += "%s as asct122 " % random.choice(self.t_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select now(),today(),timezone(), " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct12 " % time_fun_2 + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-14 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts , timediff(asct1,now),timediff(now,asct2) from ( select ts ts ," + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2" % time_fun_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) + sql += " ) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts , (asct1),now(),(now()),asct2 from ( select ts ts ," + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2" % time_fun_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) + sql += " ) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select (asct1)*asct2,now(),(now()) from ( select " + sql += "%s as asct1, " % time_fun_1 + sql += "%s as asct2" % time_fun_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) + sql += " ) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + tdSql.query("select 1-15 as time_nest from stable_1 limit 1;") + for i in range(self.fornum): + if (timelist == ['NOW','TODAY']) or (timelist == ['TIMETRUNCATE']) or (timelist == ['TO_ISO8601'])\ + or (timelist == ['TO_UNIXTIMESTAMP']) or (timelist == ['TIMEDIFF_1']) or (timelist == ['TIMEDIFF_2']): + sql = "select ts1,ts ,timediff(ts1,ts), timediff(asct1,now),timediff(now,asct2) from ( select t1.ts as ts1," + sql += "%s as asct2, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14, " % random.choice(self.q_select) + sql += "t2.ts from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) + sql += ") " + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['TIMEZONE']) or (timelist == ['CAST']) or (timelist == ['CAST_1']) or (timelist == ['CAST_2']) or (timelist == ['CAST_3']) or (timelist == ['CAST_4']): + sql = "select ts1,ts ,timediff(ts1,ts), asct1,(now()),(now()),asct2 ,now(),today(),timezone() from ( select t1.ts as ts1," + sql += "%s as asct2, " % time_fun_join_1 + sql += "%s as asct1, " % time_fun_join_2 + sql += "t1.%s as asct11, " % random.choice(self.q_select) + sql += "t1.%s as asct12, " % random.choice(self.q_select) + sql += "t2.%s as asct13, " % random.choice(self.q_select) + sql += "t2.%s as asct14, " % random.choice(self.q_select) + sql += "t2.ts from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) + sql += ") " + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + elif (timelist == ['ELAPSED']) : + sql = "select asct1,(now()),(now()),asct2 ,now(),today(),timezone() from ( select " + sql += "%s as asct2, " % time_fun_join_1 + sql += "%s as asct1 " % time_fun_join_2 + sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) + sql += ") " + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + #taos -f sql + startTime_taos_f = time.time() + print("taos -f %s sql start!" %timelist) + taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) + #_ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") + _ = subprocess.check_output(taos_cmd1, shell=True) + print("taos -f %s sql over!" %timelist) + endTime_taos_f = time.time() + print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) + + print("=========%s====over=============" %timelist) - # session && fill - session_where = ['session(ts,10a)' , 'session(ts,10s)', 'session(ts,10m)' , 'session(ts,10h)','session(ts,10d)' , 'session(ts,10w)'] - session_u_where = ['session(t1.ts,10a)' , 'session(t1.ts,10s)', 'session(t1.ts,10m)' , 'session(t1.ts,10h)','session(t1.ts,10d)' , 'session(t1.ts,10w)', - 'session(t2.ts,10a)' , 'session(t2.ts,10s)', 'session(t2.ts,10m)' , 'session(t2.ts,10h)','session(t2.ts,10d)' , 'session(t2.ts,10w)'] + def base_nest(self,baselist): + + print("==========%s===start=============" %baselist) + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.dropandcreateDB_random("%s" %self.db_nest, 1) + + if (baselist == ['A']) or (baselist == ['S']) or (baselist == ['F']) \ + or (baselist == ['C']): + base_functions = baselist + fun_fix_column = ['(q_bigint)','(q_smallint)','(q_tinyint)','(q_int)','(q_float)','(q_double)','(q_bigint_null)','(q_smallint_null)','(q_tinyint_null)','(q_int_null)','(q_float_null)','(q_double_null)'] + fun_column_1 = random.sample(base_functions,1)+random.sample(fun_fix_column,1) + base_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_2 = random.sample(base_functions,1)+random.sample(fun_fix_column,1) + base_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","") + + fun_fix_column_j = ['(t1.q_bigint)','(t1.q_smallint)','(t1.q_tinyint)','(t1.q_int)','(t1.q_float)','(t1.q_double)','(t1.q_bigint_null)','(t1.q_smallint_null)','(t1.q_tinyint_null)','(t1.q_int_null)','(t1.q_float_null)','(t1.q_double_null)', + '(t2.q_bigint)','(t2.q_smallint)','(t2.q_tinyint)','(t2.q_int)','(t2.q_float)','(t2.q_double)','(t2.q_bigint_null)','(t2.q_smallint_null)','(t2.q_tinyint_null)','(t2.q_int_null)','(t2.q_float_null)','(t2.q_double_null)'] + fun_column_join_1 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1) + base_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","") + fun_column_join_2 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1) + base_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","") - fill_where = ['FILL(NONE)','FILL(PREV)','FILL(NULL)','FILL(LINEAR)','FILL(NEXT)','FILL(VALUE, 1.23)'] + elif (baselist == ['P']) or (baselist == ['M']) or (baselist == ['S'])or (baselist == ['T']): + base_functions = baselist + num = random.randint(0, 1000) + fun_fix_column = ['(q_bigint,num)','(q_smallint,num)','(q_tinyint,num)','(q_int,num)','(q_float,num)','(q_double,num)', + '(q_bigint_null,num)','(q_smallint_null,num)','(q_tinyint_null,num)','(q_int_null,num)','(q_float_null,num)','(q_double_null,num)'] + fun_column_1 = random.sample(base_functions,1)+random.sample(fun_fix_column,1) + base_fun_1 = str(fun_column_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num)) + fun_column_2 = random.sample(base_functions,1)+random.sample(fun_fix_column,1) + base_fun_2 = str(fun_column_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num)) + + fun_fix_column_j = ['(t1.q_bigint,num)','(t1.q_smallint,num)','(t1.q_tinyint,num)','(t1.q_int,num)','(t1.q_float,num)','(t1.q_double,num)', + '(t1.q_bigint_null,num)','(t1.q_smallint_null,num)','(t1.q_tinyint_null,num)','(t1.q_int_null,num)','(t1.q_float_null,num)','(t1.q_double_null,num)', + '(t2.q_bigint,num)','(t2.q_smallint,num)','(t2.q_tinyint,num)','(t2.q_int,num)','(t2.q_float,num)','(t2.q_double,num)', + '(t2.q_bigint_null,num)','(t2.q_smallint_null,num)','(t2.q_tinyint_null,num)','(t2.q_int_null,num)','(t2.q_float_null,num)','(t2.q_double_null,num)'] + fun_column_join_1 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1) + base_fun_join_1 = str(fun_column_join_1).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num)) + fun_column_join_2 = random.sample(base_functions,1)+random.sample(fun_fix_column_j,1) + base_fun_join_2 = str(fun_column_join_2).replace("[","").replace("]","").replace("'","").replace(", ","").replace("num",base(num)) + + tdSql.query("select 1-1 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , floor(asct1) from ( select " + sql += "%s as asct1, " % base_fun_1 + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + + tdSql.query("select 1-2 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , abs(asct1) from ( select " + sql += "%s as asct1, " % base_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s )" % random.choice(self.order_where) + sql += "%s " % random.choice(self.unionall_or_union) + sql += "select ts , asct2 from ( select " + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + #sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + #tdSql.query(sql) + #self.cur1.execute(sql) + + tdSql.query("select 1-3 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , min(asct1) from ( select " + sql += "%s as asct1, ts ," % base_fun_1 + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s select " % random.choice(self.unionall_or_union) + sql += "%s as asct2, ts ," % base_fun_2 + sql += "%s as asct1, " % base_fun_1 + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from regular_table_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + #tdSql.query(sql) + #self.cur1.execute(sql) + + tdSql.query("select 1-4 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts1,ts2 ,timediff(ts1,ts2), asct1 from ( select t1.ts as ts1," + sql += "%s, " % base_fun_join_1 + sql += "%s as asct1, " % base_fun_join_2 + sql += "%s, " % base_fun_join_1 + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) + sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) + + tdSql.query("select 1-5 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts ," + sql += "%s, " % base_fun_1 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.q_select) + sql += "%s " % base_fun_2 + sql += " from ( select * from regular_table_1 ) where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += " ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(100) + self.cur1.execute(sql) - state_window = ['STATE_WINDOW(q_tinyint)','STATE_WINDOW(q_bigint)','STATE_WINDOW(q_int)','STATE_WINDOW(q_bool)','STATE_WINDOW(q_smallint)'] - state_u_window = ['STATE_WINDOW(t1.q_tinyint)','STATE_WINDOW(t1.q_bigint)','STATE_WINDOW(t1.q_int)','STATE_WINDOW(t1.q_bool)','STATE_WINDOW(t1.q_smallint)', - 'STATE_WINDOW(t2.q_tinyint)','STATE_WINDOW(t2.q_bigint)','STATE_WINDOW(t2.q_int)','STATE_WINDOW(t2.q_bool)','STATE_WINDOW(t2.q_smallint)'] + tdSql.query("select 1-6 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , max(asct1) from ( select t1.ts as ts1," + sql += "%s, " % base_fun_join_1 + sql += "%s as asct1, " % base_fun_join_2 + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) + sql += "%s, " % base_fun_join_1 + sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s )" % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) - # order by where - order_where = ['order by ts' , 'order by ts asc'] - order_u_where = ['order by t1.ts' , 'order by t1.ts asc' , 'order by t2.ts' , 'order by t2.ts asc'] - order_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' ] - orders_desc_where = ['order by ts' , 'order by ts asc' , 'order by ts desc' , 'order by loc' , 'order by loc asc' , 'order by loc desc'] + tdSql.query("select 1-7 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , abs(asct1) from ( select " + sql += "%s as asct1, ts ," % base_fun_1 + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + + tdSql.query("select 1-8 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts,floor(asct1) " + sql += "from ( select " + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s as asct1, ts ," % base_fun_1 + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) - group_where = ['group by tbname , loc' , 'group by tbname', 'group by tbname, t_bigint', 'group by tbname,t_int', 'group by tbname, t_smallint', 'group by tbname,t_tinyint', - 'group by tbname,t_float', 'group by tbname,t_double' , 'group by tbname,t_binary', 'group by tbname,t_nchar', 'group by tbname,t_bool' ,'group by tbname ,loc ,t_bigint', - 'group by tbname,t_binary ,t_nchar ,t_bool' , 'group by tbname,t_int ,t_smallint ,t_tinyint' , 'group by tbname,t_float ,t_double ' , - 'PARTITION BY tbname , loc' , 'PARTITION BY tbname', 'PARTITION BY tbname, t_bigint', 'PARTITION BY tbname,t_int', 'PARTITION BY tbname, t_smallint', 'PARTITION BY tbname,t_tinyint', - 'PARTITION BY tbname,t_float', 'PARTITION BY tbname,t_double' , 'PARTITION BY tbname,t_binary', 'PARTITION BY tbname,t_nchar', 'PARTITION BY tbname,t_bool' ,'PARTITION BY tbname ,loc ,t_bigint', - 'PARTITION BY tbname,t_binary ,t_nchar ,t_bool' , 'PARTITION BY tbname,t_int ,t_smallint ,t_tinyint' , 'PARTITION BY tbname,t_float ,t_double '] - group_where_j = ['group by t1.loc' , 'group by t1.t_bigint', 'group by t1.t_int', 'group by t1.t_smallint', 'group by t1.t_tinyint', - 'group by t1.t_float', 'group by t1.t_double' , 'group by t1.t_binary', 'group by t1.t_nchar', 'group by t1.t_bool' ,'group by t1.loc ,t1.t_bigint', - 'group by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'group by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'group by t1.t_float ,t1.t_double ' , - 'PARTITION BY t1.loc' , 'PARTITION by t1.t_bigint', 'PARTITION by t1.t_int', 'PARTITION by t1.t_smallint', 'PARTITION by t1.t_tinyint', - 'PARTITION by t1.t_float', 'PARTITION by t1.t_double' , 'PARTITION by t1.t_binary', 'PARTITION by t1.t_nchar', 'PARTITION by t1.t_bool' ,'PARTITION BY t1.loc ,t1.t_bigint', - 'PARTITION by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'PARTITION by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'PARTITION by t1.t_float ,t1.t_double ', - 'group by t2.loc' , 'group by t2.t_bigint', 'group by t2.t_int', 'group by t2.t_smallint', 'group by t2.t_tinyint', - 'group by t2.t_float', 'group by t2.t_double' , 'group by t2.t_binary', 'group by t2.t_nchar', 'group by t2.t_bool' ,'group by t2.loc ,t2.t_bigint', - 'group by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'group by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'group by t2.t_float ,t2.t_double ' , - 'PARTITION BY t2.loc' , 'PARTITION by t2.t_bigint', 'PARTITION by t2.t_int', 'PARTITION by t2.t_smallint', 'PARTITION by t2.t_tinyint', - 'PARTITION by t2.t_float', 'PARTITION by t2.t_double' , 'PARTITION by t2.t_binary', 'PARTITION by t2.t_nchar', 'PARTITION by t2.t_bool' ,'PARTITION BY t2.loc ,t2.t_bigint', - 'PARTITION by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'PARTITION by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'PARTITION by t2.t_float ,t2.t_double '] - - partiton_where = ['PARTITION BY tbname , loc' , 'PARTITION BY tbname', 'PARTITION BY tbname, t_bigint', 'PARTITION BY tbname,t_int', 'PARTITION BY tbname, t_smallint', 'PARTITION BY tbname,t_tinyint', - 'PARTITION BY tbname,t_float', 'PARTITION BY tbname,t_double' , 'PARTITION BY tbname,t_binary', 'PARTITION BY tbname,t_nchar', 'PARTITION BY tbname,t_bool' ,'PARTITION BY tbname ,loc ,t_bigint', - 'PARTITION BY tbname,t_binary ,t_nchar ,t_bool' , 'PARTITION BY tbname,t_int ,t_smallint ,t_tinyint' , 'PARTITION BY tbname,t_float ,t_double '] - partiton_where_j = ['PARTITION BY t1.loc' , 'PARTITION by t1.t_bigint', 'PARTITION by t1.t_int', 'PARTITION by t1.t_smallint', 'PARTITION by t1.t_tinyint', - 'PARTITION by t1.t_float', 'PARTITION by t1.t_double' , 'PARTITION by t1.t_binary', 'PARTITION by t1.t_nchar', 'PARTITION by t1.t_bool' ,'PARTITION BY t1.loc ,t1.t_bigint', - 'PARTITION by t1.t_binary ,t1.t_nchar ,t1.t_bool' , 'PARTITION by t1.t_int ,t1.t_smallint ,t1.t_tinyint' , 'PARTITION by t1.t_float ,t1.t_double ', - 'PARTITION BY t2.loc' , 'PARTITION by t2.t_bigint', 'PARTITION by t2.t_int', 'PARTITION by t2.t_smallint', 'PARTITION by t2.t_tinyint', - 'PARTITION by t2.t_float', 'PARTITION by t2.t_double' , 'PARTITION by t2.t_binary', 'PARTITION by t2.t_nchar', 'PARTITION by t2.t_bool' ,'PARTITION BY t2.loc ,t2.t_bigint', - 'PARTITION by t2.t_binary ,t2.t_nchar ,t2.t_bool' , 'PARTITION by t2.t_int ,t2.t_smallint ,t2.t_tinyint' , 'PARTITION by t2.t_float ,t2.t_double '] - - - group_where_regular = ['group by tbname ' , 'group by tbname', 'group by tbname, q_bigint', 'group by tbname,q_int', 'group by tbname, q_smallint', 'group by tbname,q_tinyint', - 'group by tbname,q_float', 'group by tbname,q_double' , 'group by tbname,q_binary', 'group by tbname,q_nchar', 'group by tbname,q_bool' ,'group by tbname ,q_bigint', - 'group by tbname,q_binary ,q_nchar ,q_bool' , 'group by tbname,q_int ,q_smallint ,q_tinyint' , 'group by tbname,q_float ,q_double ' , - 'PARTITION BY tbname ' , 'PARTITION BY tbname', 'PARTITION BY tbname, q_bigint', 'PARTITION BY tbname,q_int', 'PARTITION BY tbname, q_smallint', 'PARTITION BY tbname,q_tinyint', - 'PARTITION BY tbname,q_float', 'PARTITION BY tbname,q_double' , 'PARTITION BY tbname,q_binary', 'PARTITION BY tbname,q_nchar', 'PARTITION BY tbname,q_bool' ,'PARTITION BY tbname ,q_bigint', - 'PARTITION BY tbname,q_binary ,q_nchar ,q_bool' , 'PARTITION BY tbname,q_int ,q_smallint ,q_tinyint' , 'PARTITION BY tbname,q_float ,q_double '] - group_where_regular_j = ['group by t1.q_bigint', 'group by t1.q_int', 'group by t1.q_smallint', 'group by t1.q_tinyint', - 'group by t1.q_float', 'group by t1.q_double' , 'group by t1.q_binary', 'group by t1.q_nchar', 'group by t1.q_bool' ,'group by t1.q_bigint', - 'group by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'group by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'group by t1.q_float ,t1.q_double ' , - 'PARTITION by t1.q_bigint', 'PARTITION by t1.q_int', 'PARTITION by t1.q_smallint', 'PARTITION by t1.q_tinyint', - 'PARTITION by t1.q_float', 'PARTITION by t1.q_double' , 'PARTITION by t1.q_binary', 'PARTITION by t1.q_nchar', 'PARTITION by t1.q_bool' ,'PARTITION BY t1.q_bigint', - 'PARTITION by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'PARTITION by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'PARTITION by t1.q_float ,t1.q_double ', - 'group by t2.q_bigint', 'group by t2.q_int', 'group by t2.q_smallint', 'group by t2.q_tinyint', - 'group by t2.q_float', 'group by t2.q_double' , 'group by t2.q_binary', 'group by t2.q_nchar', 'group by t2.q_bool' ,'group by t2.q_bigint', - 'group by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'group by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'group by t2.q_float ,t2.q_double ' , - 'PARTITION by t2.q_bigint', 'PARTITION by t2.q_int', 'PARTITION by t2.q_smallint', 'PARTITION by t2.q_tinyint', - 'PARTITION by t2.q_float', 'PARTITION by t2.q_double' , 'PARTITION by t2.q_binary', 'PARTITION by t2.q_nchar', 'PARTITION by t2.q_bool' ,'PARTITION BY t2.q_bigint', - 'PARTITION by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'PARTITION by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'PARTITION by t2.q_float ,t2.q_double '] - - partiton_where_regular = ['PARTITION BY tbname ' , 'PARTITION BY tbname', 'PARTITION BY tbname, q_bigint', 'PARTITION BY tbname,q_int', 'PARTITION BY tbname, q_smallint', 'PARTITION BY tbname,q_tinyint', - 'PARTITION BY tbname,q_float', 'PARTITION BY tbname,q_double' , 'PARTITION BY tbname,q_binary', 'PARTITION BY tbname,q_nchar', 'PARTITION BY tbname,q_bool' ,'PARTITION BY tbname ,q_bigint', - 'PARTITION BY tbname,q_binary ,q_nchar ,q_bool' , 'PARTITION BY tbname,q_int ,q_smallint ,q_tinyint' , 'PARTITION BY tbname,q_float ,q_double '] - partiton_where_regular_j = ['PARTITION by t1.q_bigint', 'PARTITION by t1.q_int', 'PARTITION by t1.q_smallint', 'PARTITION by t1.q_tinyint', - 'PARTITION by t1.q_float', 'PARTITION by t1.q_double' , 'PARTITION by t1.q_binary', 'PARTITION by t1.q_nchar', 'PARTITION by t1.q_bool' ,'PARTITION BY t1.q_bigint', - 'PARTITION by t1.q_binary ,t1.q_nchar ,t1.q_bool' , 'PARTITION by t1.q_int ,t1.q_smallint ,t1.q_tinyint' , 'PARTITION by t1.q_float ,t1.q_double ', - 'PARTITION by t2.q_bigint', 'PARTITION by t2.q_int', 'PARTITION by t2.q_smallint', 'PARTITION by t2.q_tinyint', - 'PARTITION by t2.q_float', 'PARTITION by t2.q_double' , 'PARTITION by t2.q_binary', 'PARTITION by t2.q_nchar', 'PARTITION by t2.q_bool' ,'PARTITION BY t2.q_bigint', - 'PARTITION by t2.q_binary ,t2.q_nchar ,t2.q_bool' , 'PARTITION by t2.q_int ,t2.q_smallint ,t2.q_tinyint' , 'PARTITION by t2.q_float ,t2.q_double '] - - having_support = ['having count(q_int) > 0','having count(q_bigint) > 0','having count(q_smallint) > 0','having count(q_tinyint) > 0','having count(q_float) > 0','having count(q_double) > 0','having count(q_bool) > 0', - 'having avg(q_int) > 0','having avg(q_bigint) > 0','having avg(q_smallint) > 0','having avg(q_tinyint) > 0','having avg(q_float) > 0','having avg(q_double) > 0', - 'having sum(q_int) > 0','having sum(q_bigint) > 0','having sum(q_smallint) > 0','having sum(q_tinyint) > 0','having sum(q_float) > 0','having sum(q_double) > 0', - 'having STDDEV(q_int) > 0','having STDDEV(q_bigint) > 0','having STDDEV(q_smallint) > 0','having STDDEV(q_tinyint) > 0','having STDDEV(q_float) > 0','having STDDEV(q_double) > 0', - 'having TWA(q_int) > 0','having TWA(q_bigint) > 0','having TWA(q_smallint) > 0','having TWA(q_tinyint) > 0','having TWA(q_float) > 0','having TWA(q_double) > 0', - 'having IRATE(q_int) > 0','having IRATE(q_bigint) > 0','having IRATE(q_smallint) > 0','having IRATE(q_tinyint) > 0','having IRATE(q_float) > 0','having IRATE(q_double) > 0', - 'having MIN(q_int) > 0','having MIN(q_bigint) > 0','having MIN(q_smallint) > 0','having MIN(q_tinyint) > 0','having MIN(q_float) > 0','having MIN(q_double) > 0', - 'having MAX(q_int) > 0','having MAX(q_bigint) > 0','having MAX(q_smallint) > 0','having MAX(q_tinyint) > 0','having MAX(q_float) > 0','having MAX(q_double) > 0', - 'having FIRST(q_int) > 0','having FIRST(q_bigint) > 0','having FIRST(q_smallint) > 0','having FIRST(q_tinyint) > 0','having FIRST(q_float) > 0','having FIRST(q_double) > 0', - 'having LAST(q_int) > 0','having LAST(q_bigint) > 0','having LAST(q_smallint) > 0','having LAST(q_tinyint) > 0','having LAST(q_float) > 0','having LAST(q_double) > 0', - 'having APERCENTILE(q_int,10) > 0','having APERCENTILE(q_bigint,10) > 0','having APERCENTILE(q_smallint,10) > 0','having APERCENTILE(q_tinyint,10) > 0','having APERCENTILE(q_float,10) > 0','having APERCENTILE(q_double,10) > 0'] - having_not_support = ['having TOP(q_int,10) > 0','having TOP(q_bigint,10) > 0','having TOP(q_smallint,10) > 0','having TOP(q_tinyint,10) > 0','having TOP(q_float,10) > 0','having TOP(q_double,10) > 0','having TOP(q_bool,10) > 0', - 'having BOTTOM(q_int,10) > 0','having BOTTOM(q_bigint,10) > 0','having BOTTOM(q_smallint,10) > 0','having BOTTOM(q_tinyint,10) > 0','having BOTTOM(q_float,10) > 0','having BOTTOM(q_double,10) > 0','having BOTTOM(q_bool,10) > 0', - 'having LEASTSQUARES(q_int) > 0','having LEASTSQUARES(q_bigint) > 0','having LEASTSQUARES(q_smallint) > 0','having LEASTSQUARES(q_tinyint) > 0','having LEASTSQUARES(q_float) > 0','having LEASTSQUARES(q_double) > 0','having LEASTSQUARES(q_bool) > 0', - 'having FIRST(q_bool) > 0','having IRATE(q_bool) > 0','having PERCENTILE(q_bool,10) > 0','having avg(q_bool) > 0','having LAST_ROW(q_bool) > 0','having sum(q_bool) > 0','having STDDEV(q_bool) > 0','having APERCENTILE(q_bool,10) > 0','having TWA(q_bool) > 0','having LAST(q_bool) > 0', - 'having PERCENTILE(q_int,10) > 0','having PERCENTILE(q_bigint,10) > 0','having PERCENTILE(q_smallint,10) > 0','having PERCENTILE(q_tinyint,10) > 0','having PERCENTILE(q_float,10) > 0','having PERCENTILE(q_double,10) > 0'] - having_tagnot_support = ['having LAST_ROW(q_int) > 0','having LAST_ROW(q_bigint) > 0','having LAST_ROW(q_smallint) > 0','having LAST_ROW(q_tinyint) > 0','having LAST_ROW(q_float) > 0','having LAST_ROW(q_double) > 0'] - - having_support_j = ['having count(t1.q_int) > 0','having count(t1.q_bigint) > 0','having count(t1.q_smallint) > 0','having count(t1.q_tinyint) > 0','having count(t1.q_float) > 0','having count(t1.q_double) > 0','having count(t1.q_bool) > 0', - 'having avg(t1.q_int) > 0','having avg(t1.q_bigint) > 0','having avg(t1.q_smallint) > 0','having avg(t1.q_tinyint) > 0','having avg(t1.q_float) > 0','having avg(t1.q_double) > 0', - 'having sum(t1.q_int) > 0','having sum(t1.q_bigint) > 0','having sum(t1.q_smallint) > 0','having sum(t1.q_tinyint) > 0','having sum(t1.q_float) > 0','having sum(t1.q_double) > 0', - 'having STDDEV(t1.q_int) > 0','having STDDEV(t1.q_bigint) > 0','having STDDEV(t1.q_smallint) > 0','having STDDEV(t1.q_tinyint) > 0','having STDDEV(t1.q_float) > 0','having STDDEV(t1.q_double) > 0', - 'having TWA(t1.q_int) > 0','having TWA(t1.q_bigint) > 0','having TWA(t1.q_smallint) > 0','having TWA(t1.q_tinyint) > 0','having TWA(t1.q_float) > 0','having TWA(t1.q_double) > 0', - 'having IRATE(t1.q_int) > 0','having IRATE(t1.q_bigint) > 0','having IRATE(t1.q_smallint) > 0','having IRATE(t1.q_tinyint) > 0','having IRATE(t1.q_float) > 0','having IRATE(t1.q_double) > 0', - 'having MIN(t1.q_int) > 0','having MIN(t1.q_bigint) > 0','having MIN(t1.q_smallint) > 0','having MIN(t1.q_tinyint) > 0','having MIN(t1.q_float) > 0','having MIN(t1.q_double) > 0', - 'having MAX(t1.q_int) > 0','having MAX(t1.q_bigint) > 0','having MAX(t1.q_smallint) > 0','having MAX(t1.q_tinyint) > 0','having MAX(t1.q_float) > 0','having MAX(t1.q_double) > 0', - 'having FIRST(t1.q_int) > 0','having FIRST(t1.q_bigint) > 0','having FIRST(t1.q_smallint) > 0','having FIRST(t1.q_tinyint) > 0','having FIRST(t1.q_float) > 0','having FIRST(t1.q_double) > 0', - 'having LAST(t1.q_int) > 0','having LAST(t1.q_bigint) > 0','having LAST(t1.q_smallint) > 0','having LAST(t1.q_tinyint) > 0','having LAST(t1.q_float) > 0','having LAST(t1.q_double) > 0', - 'having APERCENTILE(t1.q_int,10) > 0','having APERCENTILE(t1.q_bigint,10) > 0','having APERCENTILE(t1.q_smallint,10) > 0','having APERCENTILE(t1.q_tinyint,10) > 0','having APERCENTILE(t1.q_float,10) > 0','having APERCENTILE(t1.q_double,10) > 0'] - - # limit offset where - limit_where = ['limit 1 offset 1' , 'limit 1' , 'limit 2 offset 1' , 'limit 2', 'limit 12 offset 1' , 'limit 20', 'limit 20 offset 10' , 'limit 200'] - limit1_where = ['limit 1 offset 1' , 'limit 1' ] - limit_u_where = ['limit 100 offset 10' , 'limit 50' , 'limit 100' , 'limit 10' ] - - # slimit soffset where - slimit_where = ['slimit 1 soffset 1' , 'slimit 1' , 'slimit 2 soffset 1' , 'slimit 2'] - slimit1_where = ['slimit 2 soffset 1' , 'slimit 1' ] - - # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] - # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] - # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] - # **_ns_** express is not support stable, therefore, separated from regular tables - # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval - # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname - # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname - - # calc_select_all calc_select_regular calc_select_in_ts calc_select_fill calc_select_not_interval - # select function include [all: min\max\first(*)\last(*)\top\bottom\apercentile\last_row(*)(not with interval)\interp(*)(FILL) ||regualr: percentile] - - calc_select_all = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , - 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , - 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , - 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , - 'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , - 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , - 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , - 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , - 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)'] - - calc_select_in_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , - 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , - 'first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , - 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' ] - - calc_select_in = ['min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , - 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' , - 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)' , - 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , - 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)'] - - calc_select_not_support_ts = ['first(q_int)' , 'first(q_bigint)' , 'first(q_smallint)' , 'first(q_tinyint)' , 'first(q_float)' ,'first(q_double)' ,'first(q_binary)' ,'first(q_nchar)' ,'first(q_bool)' ,'first(q_ts)' , - 'last(q_int)' , 'last(q_bigint)' , 'last(q_smallint)' , 'last(q_tinyint)' , 'last(q_float)' ,'last(q_double)' , 'last(q_binary)' ,'last(q_nchar)' ,'last(q_bool)' ,'last(q_ts)' , - 'last_row(q_int)' , 'last_row(q_bigint)' , 'last_row(q_smallint)' , 'last_row(q_tinyint)' , 'last_row(q_float)' , - 'last_row(q_double)' , 'last_row(q_bool)' ,'last_row(q_binary)' ,'last_row(q_nchar)' ,'last_row(q_ts)', - 'apercentile(q_int,20)' , 'apercentile(q_bigint,20)' ,'apercentile(q_smallint,20)' ,'apercentile(q_tinyint,20)' ,'apercentile(q_float,20)' ,'apercentile(q_double,20)'] - - calc_select_support_ts = ['bottom(q_int,20)' , 'bottom(q_bigint,20)' , 'bottom(q_smallint,20)' , 'bottom(q_tinyint,20)' ,'bottom(q_float,20)' , 'bottom(q_double,20)' , - 'top(q_int,20)' , 'top(q_bigint,20)' , 'top(q_smallint,20)' ,'top(q_tinyint,20)' ,'top(q_float,20)' ,'top(q_double,20)' , - 'min(q_int)' , 'min(q_bigint)' , 'min(q_smallint)' , 'min(q_tinyint)' , 'min(q_float)' ,'min(q_double)' , - 'max(q_int)' , 'max(q_bigint)' , 'max(q_smallint)' , 'max(q_tinyint)' ,'max(q_float)' ,'max(q_double)' ] - - calc_select_regular = [ 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)'] - - - calc_select_fill = ['INTERP(q_int)' ,'INTERP(q_bigint)' ,'INTERP(q_smallint)' ,'INTERP(q_tinyint)', 'INTERP(q_float)' ,'INTERP(q_double)'] - interp_where = ['ts = now' , 'ts = \'2020-09-13 20:26:40.000\'' , 'ts = \'2020-09-13 20:26:40.009\'' ,'tbname in (\'table_1\') and ts = now' ,'tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and ts = \'2020-09-13 20:26:40.000\'','tbname like \'table%\' and ts = \'2020-09-13 20:26:40.002\''] - - #two table join - calc_select_in_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' , - 'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' , - 'first(t1.q_int)' , 'first(t1.q_bigint)' , 'first(t1.q_smallint)' , 'first(t1.q_tinyint)' , 'first(t1.q_float)' ,'first(t1.q_double)' ,'first(t1.q_binary)' ,'first(t1.q_nchar)' ,'first(t1.q_bool)' ,'first(t1.q_ts)' , - 'last(t1.q_int)' , 'last(t1.q_bigint)' , 'last(t1.q_smallint)' , 'last(t1.q_tinyint)' , 'last(t1.q_float)' ,'last(t1.q_double)' , 'last(t1.q_binary)' ,'last(t1.q_nchar)' ,'last(t1.q_bool)' ,'last(t1.q_ts)' , - 'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' , - 'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' , - 'first(t2.q_int)' , 'first(t2.q_bigint)' , 'first(t2.q_smallint)' , 'first(t2.q_tinyint)' , 'first(t2.q_float)' ,'first(t2.q_double)' ,'first(t2.q_binary)' ,'first(t2.q_nchar)' ,'first(t2.q_bool)' ,'first(t2.q_ts)' , - 'last(t2.q_int)' , 'last(t2.q_bigint)' , 'last(t2.q_smallint)' , 'last(t2.q_tinyint)' , 'last(t2.q_float)' ,'last(t2.q_double)' , 'last(t2.q_binary)' ,'last(t2.q_nchar)' ,'last(t2.q_bool)' ,'last(t2.q_ts)'] - - calc_select_in_support_ts_j = ['bottom(t1.q_int,20)' , 'bottom(t1.q_bigint,20)' , 'bottom(t1.q_smallint,20)' , 'bottom(t1.q_tinyint,20)' ,'bottom(t1.q_float,20)' , 'bottom(t1.q_double,20)' , - 'top(t1.q_int,20)' , 'top(t1.q_bigint,20)' , 'top(t1.q_smallint,20)' ,'top(t1.q_tinyint,20)' ,'top(t1.q_float,20)' ,'top(t1.q_double,20)' , - 'min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' , - 'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' , - 'bottom(t2.q_int,20)' , 'bottom(t2.q_bigint,20)' , 'bottom(t2.q_smallint,20)' , 'bottom(t2.q_tinyint,20)' ,'bottom(t2.q_float,20)' , 'bottom(t2.q_double,20)' , - 'top(t2.q_int,20)' , 'top(t2.q_bigint,20)' , 'top(t2.q_smallint,20)' ,'top(t2.q_tinyint,20)' ,'top(t2.q_float,20)' ,'top(t2.q_double,20)' , - 'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' , - 'max(t2.q_int)' , 'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' , - ] - - calc_select_in_not_support_ts_j = ['apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' , - 'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' , - 'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' , - 'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' , - 'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' , - 'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)'] - - calc_select_in_j = ['min(t1.q_int)' , 'min(t1.q_bigint)' , 'min(t1.q_smallint)' , 'min(t1.q_tinyint)' , 'min(t1.q_float)' ,'min(t1.q_double)' , - 'max(t1.q_int)' , 'max(t1.q_bigint)' , 'max(t1.q_smallint)' , 'max(t1.q_tinyint)' ,'max(t1.q_float)' ,'max(t1.q_double)' , - 'apercentile(t1.q_int,20)' , 'apercentile(t1.q_bigint,20)' ,'apercentile(t1.q_smallint,20)' ,'apercentile(t1.q_tinyint,20)' ,'apercentile(t1.q_float,20)' ,'apercentile(t1.q_double,20)' , - 'last_row(t1.q_int)' , 'last_row(t1.q_bigint)' , 'last_row(t1.q_smallint)' , 'last_row(t1.q_tinyint)' , 'last_row(t1.q_float)' , - 'last_row(t1.q_double)' , 'last_row(t1.q_bool)' ,'last_row(t1.q_binary)' ,'last_row(t1.q_nchar)' ,'last_row(t1.q_ts)' , - 'min(t2.q_int)' , 'min(t2.q_bigint)' , 'min(t2.q_smallint)' , 'min(t2.q_tinyint)' , 'min(t2.q_float)' ,'min(t2.q_double)' , - 'max(t2.q_int)' , 'max(t2.q_bigint)' , 'max(t2.q_smallint)' , 'max(t2.q_tinyint)' ,'max(t2.q_float)' ,'max(t2.q_double)' , - 'apercentile(t2.q_int,20)' , 'apercentile(t2.q_bigint,20)' ,'apercentile(t2.q_smallint,20)' ,'apercentile(t2.q_tinyint,20)' ,'apercentile(t2.q_float,20)' ,'apercentile(t2.q_double,20)' , - 'last_row(t2.q_int)' , 'last_row(t2.q_bigint)' , 'last_row(t2.q_smallint)' , 'last_row(t2.q_tinyint)' , 'last_row(t2.q_float)' , - 'last_row(t2.q_double)' , 'last_row(t2.q_bool)' ,'last_row(t2.q_binary)' ,'last_row(t2.q_nchar)' ,'last_row(t2.q_ts)'] - calc_select_all_j = calc_select_in_ts_j + calc_select_in_j - - calc_select_regular_j = [ 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , - 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)'] - - - calc_select_fill_j = ['INTERP(t1.q_int)' ,'INTERP(t1.q_bigint)' ,'INTERP(t1.q_smallint)' ,'INTERP(t1.q_tinyint)', 'INTERP(t1.q_float)' ,'INTERP(t1.q_double)' , - 'INTERP(t2.q_int)' ,'INTERP(t2.q_bigint)' ,'INTERP(t2.q_smallint)' ,'INTERP(t2.q_tinyint)', 'INTERP(t2.q_float)' ,'INTERP(t2.q_double)'] - interp_where_j = ['t1.ts = now' , 't1.ts = \'2020-09-13 20:26:40.000\'' , 't1.ts = \'2020-09-13 20:26:40.009\'' ,'t2.ts = now' , 't2.ts = \'2020-09-13 20:26:40.000\'' , 't2.ts = \'2020-09-13 20:26:40.009\'' , - 't1.tbname in (\'table_1\') and t1.ts = now' ,'t1.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t1.ts = \'2020-09-13 20:26:40.000\'','t1.tbname like \'table%\' and t1.ts = \'2020-09-13 20:26:40.002\'', - 't2.tbname in (\'table_1\') and t2.ts = now' ,'t2.tbname in (\'table_0\' ,\'table_1\',\'table_2\',\'table_3\',\'table_4\',\'table_5\') and t2.ts = \'2020-09-13 20:26:40.000\'','t2.tbname like \'table%\' and t2.ts = \'2020-09-13 20:26:40.002\''] - - # calc_aggregate_all calc_aggregate_regular calc_aggregate_groupbytbname APERCENTILE\PERCENTILE - # aggregate function include [all:count(*)\avg\sum\stddev ||regualr:twa\irate\leastsquares ||group by tbname:twa\irate\] - calc_aggregate_all = ['count(*)' , 'count(q_int)' ,'count(q_bigint)' , 'count(q_smallint)' ,'count(q_tinyint)' ,'count(q_float)' , - 'count(q_double)' ,'count(q_binary)' ,'count(q_nchar)' ,'count(q_bool)' ,'count(q_ts)' , - 'avg(q_int)' ,'avg(q_bigint)' , 'avg(q_smallint)' ,'avg(q_tinyint)' ,'avg(q_float)' ,'avg(q_double)' , - 'sum(q_int)' ,'sum(q_bigint)' , 'sum(q_smallint)' ,'sum(q_tinyint)' ,'sum(q_float)' ,'sum(q_double)' , - 'STDDEV(q_int)' ,'STDDEV(q_bigint)' , 'STDDEV(q_smallint)' ,'STDDEV(q_tinyint)' ,'STDDEV(q_float)' ,'STDDEV(q_double)', - 'APERCENTILE(q_int,10)' ,'APERCENTILE(q_bigint,20)' , 'APERCENTILE(q_smallint,30)' ,'APERCENTILE(q_tinyint,40)' ,'APERCENTILE(q_float,50)' ,'APERCENTILE(q_double,60)'] - - calc_aggregate_regular = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , - 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' , - 'LEASTSQUARES(q_int,15,3)' , 'LEASTSQUARES(q_bigint,10,1)' , 'LEASTSQUARES(q_smallint,20,3)' ,'LEASTSQUARES(q_tinyint,10,4)' ,'LEASTSQUARES(q_float,6,4)' ,'LEASTSQUARES(q_double,3,1)' , - 'PERCENTILE(q_int,10)' ,'PERCENTILE(q_bigint,20)' , 'PERCENTILE(q_smallint,30)' ,'PERCENTILE(q_tinyint,40)' ,'PERCENTILE(q_float,50)' ,'PERCENTILE(q_double,60)'] - - calc_aggregate_groupbytbname = ['twa(q_int)' ,'twa(q_bigint)' , 'twa(q_smallint)' ,'twa(q_tinyint)' ,'twa (q_float)' ,'twa(q_double)' , - 'IRATE(q_int)' ,'IRATE(q_bigint)' , 'IRATE(q_smallint)' ,'IRATE(q_tinyint)' ,'IRATE (q_float)' ,'IRATE(q_double)' ] - - #two table join - calc_aggregate_all_j = ['count(t1.*)' , 'count(t1.q_int)' ,'count(t1.q_bigint)' , 'count(t1.q_smallint)' ,'count(t1.q_tinyint)' ,'count(t1.q_float)' , - 'count(t1.q_double)' ,'count(t1.q_binary)' ,'count(t1.q_nchar)' ,'count(t1.q_bool)' ,'count(t1.q_ts)' , - 'avg(t1.q_int)' ,'avg(t1.q_bigint)' , 'avg(t1.q_smallint)' ,'avg(t1.q_tinyint)' ,'avg(t1.q_float)' ,'avg(t1.q_double)' , - 'sum(t1.q_int)' ,'sum(t1.q_bigint)' , 'sum(t1.q_smallint)' ,'sum(t1.q_tinyint)' ,'sum(t1.q_float)' ,'sum(t1.q_double)' , - 'STDDEV(t1.q_int)' ,'STDDEV(t1.q_bigint)' , 'STDDEV(t1.q_smallint)' ,'STDDEV(t1.q_tinyint)' ,'STDDEV(t1.q_float)' ,'STDDEV(t1.q_double)', - 'APERCENTILE(t1.q_int,10)' ,'APERCENTILE(t1.q_bigint,20)' , 'APERCENTILE(t1.q_smallint,30)' ,'APERCENTILE(t1.q_tinyint,40)' ,'APERCENTILE(t1.q_float,50)' ,'APERCENTILE(t1.q_double,60)' , - 'count(t2.*)' , 'count(t2.q_int)' ,'count(t2.q_bigint)' , 'count(t2.q_smallint)' ,'count(t2.q_tinyint)' ,'count(t2.q_float)' , - 'count(t2.q_double)' ,'count(t2.q_binary)' ,'count(t2.q_nchar)' ,'count(t2.q_bool)' ,'count(t2.q_ts)' , - 'avg(t2.q_int)' ,'avg(t2.q_bigint)' , 'avg(t2.q_smallint)' ,'avg(t2.q_tinyint)' ,'avg(t2.q_float)' ,'avg(t2.q_double)' , - 'sum(t2.q_int)' ,'sum(t2.q_bigint)' , 'sum(t2.q_smallint)' ,'sum(t2.q_tinyint)' ,'sum(t2.q_float)' ,'sum(t2.q_double)' , - 'STDDEV(t2.q_int)' ,'STDDEV(t2.q_bigint)' , 'STDDEV(t2.q_smallint)' ,'STDDEV(t2.q_tinyint)' ,'STDDEV(t2.q_float)' ,'STDDEV(t2.q_double)', - 'APERCENTILE(t2.q_int,10)' ,'APERCENTILE(t2.q_bigint,20)' , 'APERCENTILE(t2.q_smallint,30)' ,'APERCENTILE(t2.q_tinyint,40)' ,'APERCENTILE(t2.q_float,50)' ,'APERCENTILE(t2.q_double,60)'] - - calc_aggregate_regular_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , - 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , - 'LEASTSQUARES(t1.q_int,15,3)' , 'LEASTSQUARES(t1.q_bigint,10,1)' , 'LEASTSQUARES(t1.q_smallint,20,3)' ,'LEASTSQUARES(t1.q_tinyint,10,4)' ,'LEASTSQUARES(t1.q_float,6,4)' ,'LEASTSQUARES(t1.q_double,3,1)' , - 'PERCENTILE(t1.q_int,10)' ,'PERCENTILE(t1.q_bigint,20)' , 'PERCENTILE(t1.q_smallint,30)' ,'PERCENTILE(t1.q_tinyint,40)' ,'PERCENTILE(t1.q_float,50)' ,'PERCENTILE(t1.q_double,60)' , - 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , - 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)', - 'LEASTSQUARES(t2.q_int,15,3)' , 'LEASTSQUARES(t2.q_bigint,10,1)' , 'LEASTSQUARES(t2.q_smallint,20,3)' ,'LEASTSQUARES(t2.q_tinyint,10,4)' ,'LEASTSQUARES(t2.q_float,6,4)' ,'LEASTSQUARES(t2.q_double,3,1)' , - 'PERCENTILE(t2.q_int,10)' ,'PERCENTILE(t2.q_bigint,20)' , 'PERCENTILE(t2.q_smallint,30)' ,'PERCENTILE(t2.q_tinyint,40)' ,'PERCENTILE(t2.q_float,50)' ,'PERCENTILE(t2.q_double,60)'] - - calc_aggregate_groupbytbname_j = ['twa(t1.q_int)' ,'twa(t1.q_bigint)' , 'twa(t1.q_smallint)' ,'twa(t1.q_tinyint)' ,'twa (t1.q_float)' ,'twa(t1.q_double)' , - 'IRATE(t1.q_int)' ,'IRATE(t1.q_bigint)' , 'IRATE(t1.q_smallint)' ,'IRATE(t1.q_tinyint)' ,'IRATE (t1.q_float)' ,'IRATE(t1.q_double)' , - 'twa(t2.q_int)' ,'twa(t2.q_bigint)' , 'twa(t2.q_smallint)' ,'twa(t2.q_tinyint)' ,'twa (t2.q_float)' ,'twa(t2.q_double)' , - 'IRATE(t2.q_int)' ,'IRATE(t2.q_bigint)' , 'IRATE(t2.q_smallint)' ,'IRATE(t2.q_tinyint)' ,'IRATE (t2.q_float)' ,'IRATE(t2.q_double)' ] - - # calc_calculate_all calc_calculate_regular calc_calculate_groupbytbname - # calculation function include [all:spread\+-*/ ||regualr:diff\derivative ||group by tbname:diff\derivative\] - calc_calculate_all = ['SPREAD(ts)' , 'SPREAD(q_ts)' , 'SPREAD(q_int)' ,'SPREAD(q_bigint)' , 'SPREAD(q_smallint)' ,'SPREAD(q_tinyint)' ,'SPREAD(q_float)' ,'SPREAD(q_double)' , - '(SPREAD(q_int) + SPREAD(q_bigint))' , '(SPREAD(q_smallint) - SPREAD(q_float))', '(SPREAD(q_double) * SPREAD(q_tinyint))' , '(SPREAD(q_double) / SPREAD(q_float))'] - calc_calculate_regular = ['DIFF(q_int)' ,'DIFF(q_bigint)' , 'DIFF(q_smallint)' ,'DIFF(q_tinyint)' ,'DIFF(q_float)' ,'DIFF(q_double)' , - 'DIFF(q_int,0)' ,'DIFF(q_bigint,0)' , 'DIFF(q_smallint,0)' ,'DIFF(q_tinyint,0)' ,'DIFF(q_float,0)' ,'DIFF(q_double,0)' , - 'DIFF(q_int,1)' ,'DIFF(q_bigint,1)' , 'DIFF(q_smallint,1)' ,'DIFF(q_tinyint,1)' ,'DIFF(q_float,1)' ,'DIFF(q_double,1)' , - 'DERIVATIVE(q_int,15s,0)' , 'DERIVATIVE(q_bigint,10s,1)' , 'DERIVATIVE(q_smallint,20s,0)' ,'DERIVATIVE(q_tinyint,10s,1)' ,'DERIVATIVE(q_float,6s,0)' ,'DERIVATIVE(q_double,3s,1)' ] - calc_calculate_groupbytbname = calc_calculate_regular - - #two table join - calc_calculate_all_j = ['SPREAD(t1.ts)' , 'SPREAD(t1.q_ts)' , 'SPREAD(t1.q_int)' ,'SPREAD(t1.q_bigint)' , 'SPREAD(t1.q_smallint)' ,'SPREAD(t1.q_tinyint)' ,'SPREAD(t1.q_float)' ,'SPREAD(t1.q_double)' , - 'SPREAD(t2.ts)' , 'SPREAD(t2.q_ts)' , 'SPREAD(t2.q_int)' ,'SPREAD(t2.q_bigint)' , 'SPREAD(t2.q_smallint)' ,'SPREAD(t2.q_tinyint)' ,'SPREAD(t2.q_float)' ,'SPREAD(t2.q_double)' , - '(SPREAD(t1.q_int) + SPREAD(t1.q_bigint))' , '(SPREAD(t1.q_tinyint) - SPREAD(t1.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_tinyint))', - '(SPREAD(t2.q_int) + SPREAD(t2.q_bigint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t2.q_double) * SPREAD(t2.q_tinyint))' , '(SPREAD(t2.q_double) / SPREAD(t2.q_tinyint))', - '(SPREAD(t1.q_int) + SPREAD(t1.q_smallint))' , '(SPREAD(t2.q_smallint) - SPREAD(t2.q_float))', '(SPREAD(t1.q_double) * SPREAD(t1.q_tinyint))' , '(SPREAD(t1.q_double) / SPREAD(t1.q_float))'] - calc_calculate_regular_j = ['DIFF(t1.q_int)' ,'DIFF(t1.q_bigint)' , 'DIFF(t1.q_smallint)' ,'DIFF(t1.q_tinyint)' ,'DIFF(t1.q_float)' ,'DIFF(t1.q_double)' , - 'DIFF(t1.q_int,0)' ,'DIFF(t1.q_bigint,0)' , 'DIFF(t1.q_smallint,0)' ,'DIFF(t1.q_tinyint,0)' ,'DIFF(t1.q_float,0)' ,'DIFF(t1.q_double,0)' , - 'DIFF(t1.q_int,1)' ,'DIFF(t1.q_bigint,1)' , 'DIFF(t1.q_smallint,1)' ,'DIFF(t1.q_tinyint,1)' ,'DIFF(t1.q_float,1)' ,'DIFF(t1.q_double,1)' , - 'DERIVATIVE(t1.q_int,15s,0)' , 'DERIVATIVE(t1.q_bigint,10s,1)' , 'DERIVATIVE(t1.q_smallint,20s,0)' ,'DERIVATIVE(t1.q_tinyint,10s,1)' ,'DERIVATIVE(t1.q_float,6s,0)' ,'DERIVATIVE(t1.q_double,3s,1)' , - 'DIFF(t2.q_int)' ,'DIFF(t2.q_bigint)' , 'DIFF(t2.q_smallint)' ,'DIFF(t2.q_tinyint)' ,'DIFF(t2.q_float)' ,'DIFF(t2.q_double)' , - 'DIFF(t2.q_int,0)' ,'DIFF(t2.q_bigint,0)' , 'DIFF(t2.q_smallint,0)' ,'DIFF(t2.q_tinyint,0)' ,'DIFF(t2.q_float,0)' ,'DIFF(t2.q_double,0)' , - 'DIFF(t2.q_int,1)' ,'DIFF(t2.q_bigint,1)' , 'DIFF(t2.q_smallint,1)' ,'DIFF(t2.q_tinyint,1)' ,'DIFF(t2.q_float,1)' ,'DIFF(t2.q_double,1)' , - 'DERIVATIVE(t2.q_int,15s,0)' , 'DERIVATIVE(t2.q_bigint,10s,1)' , 'DERIVATIVE(t2.q_smallint,20s,0)' ,'DERIVATIVE(t2.q_tinyint,10s,1)' ,'DERIVATIVE(t2.q_float,6s,0)' ,'DERIVATIVE(t2.q_double,3s,1)' ] - calc_calculate_groupbytbname_j = calc_calculate_regular_j - - #inter && calc_aggregate_all\calc_aggregate_regular\calc_select_all - interval_sliding = ['interval(4w) sliding(1w) ','interval(1w) sliding(1d) ','interval(1d) sliding(1h) ' , - 'interval(1h) sliding(1m) ','interval(1m) sliding(1s) ','interval(1s) sliding(10a) ', - 'interval(1y) ','interval(1n) ','interval(1w) ','interval(1d) ','interval(1h) ','interval(1m) ','interval(1s) ' ,'interval(10a)', - 'interval(1y,1n) ','interval(1n,1w) ','interval(1w,1d) ','interval(1d,1h) ','interval(1h,1m) ','interval(1m,1s) ','interval(1s,10a) ' ,'interval(100a,30a)'] + tdSql.query("select 1-9 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , max(asct1) from ( select t1.ts as ts1," + sql += "%s, " % base_fun_join_1 + sql += "%s as asct1, " % base_fun_join_2 + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) + sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "and %s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + + self.restartDnodes() + tdSql.query("select 1-10 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , min(asct1) from ( select " + sql += "%s as asct1, ts ," % base_fun_1 + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ") %s " % random.choice(self.unionall_or_union) + sql += "select ts , max(asct2) from ( select " + sql += "%s as asct1, ts ," % base_fun_1 + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + #tdSql.query(sql) + #self.cur1.execute(sql) + + #3 inter union not support + tdSql.query("select 1-11 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , min(asct1), max(asct2) from ( select " + sql += "%s as asct1, ts ," % base_fun_1 + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + #sql += "%s " % random.choice(limit1_where) + sql += " %s " % random.choice(self.unionall_or_union) + sql += " select " + sql += "%s as asct1, ts ," % base_fun_1 + sql += "%s as asct2, " % base_fun_2 + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ")" + tdLog.info(sql) + tdLog.info(len(sql)) + #TD-15837 tdSql.query(sql) + # self.cur1.execute(sql) + tdSql.query("select 1-12 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , max(asct1) from ( select t1.ts as ts1," + sql += "%s, " % base_fun_join_1 + sql += "%s as asct1, " % base_fun_join_2 + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) + sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "and %s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + + tdSql.query("select 1-13 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts ," + sql += "%s, " % base_fun_1 + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.q_select) + sql += "%s " % base_fun_2 + sql += "%s " % random.choice(self.t_select) + sql += " from ( select * from stable_1 where " + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += ") ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + + tdSql.query("select 1-14 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select avg(asct1),count(asct2) from ( select " + sql += "%s as asct1, " % base_fun_1 + sql += "%s as asct2" % base_fun_2 + sql += " from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) + sql += " ) ;" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + + tdSql.query("select 1-15 as base_nest from stable_1 limit 1;") + for i in range(self.fornum): + sql = "select ts , max(asct1) from ( select t1.ts as ts1," + sql += "%s, " % base_fun_join_1 + sql += "%s as asct1, " % base_fun_join_2 + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) + sql += "t2.%s " % random.choice(self.q_select) + sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) + sql += ") " + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + + #taos -f sql + startTime_taos_f = time.time() + print("taos -f %s sql start!" %baselist) + taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) + _ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") + print("taos -f %s sql over!" %baselist) + endTime_taos_f = time.time() + print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) + + print("=========%s====over=============" %baselist) + + def function_before_26(self): + + print('=====================2.6 old function start ===========') + os.system("rm -rf %s/%s.sql" % (self.testcasePath,self.testcaseFilename)) + + self.dropandcreateDB_random("%s" %self.db_nest, 1) + #1 select * from (select column form regular_table where <\>\in\and\or order by) tdSql.query("select 1-1 from stable_1;") for i in range(self.fornum): - #sql = "select ts , * from ( select " ===暂时不支持select * ,用下面这一行 - sql = "select ts from ( select " - sql += "%s, " % random.choice(s_s_select) - sql += "%s, " % random.choice(q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + sql = "select tas from ( select " + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as tas from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += ");" + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql,queryTimes=1) tdSql.checkRows(100) - - #1 outer union not support + self.cur1.execute(sql) + self.explain_sql(sql) + + #1 outer union not support #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 1-2 from stable_1;") for i in range(self.fornum): #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - #sql += "%s, " % q_select[len(q_select) -i-1] - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql = "select t1s from ( select " + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as t1s from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ") union " - #sql += "select ts , * from ( select " - sql += "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "select t2s from ( select " + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as t2s from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) tdSql.checkRows(100) - + self.cur1.execute(sql) + self.explain_sql(sql) + #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 1-2 from stable_1;") for i in range(self.fornum): - #sql = "select ts , * from ( select " sql = "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - #sql += "%s, " % q_select[len(q_select) -i-1] + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ") union all " - #sql += "select ts , * from ( select " sql += "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) tdSql.checkRows(200) - + self.cur1.execute(sql) + self.explain_sql(sql) + #1 inter union not support tdSql.query("select 1-3 from stable_1;") for i in range(self.fornum): #sql = "select ts , * from ( select " sql = "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "" - sql += " union select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) + sql += "%s " % random.choice(self.q_where) + sql += "" + sql += " union all select " + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15606 tdSql.query(sql) - # tdSql.checkRows(200) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 1-3 from stable_1;") for i in range(self.fornum): - #sql = "select ts , * from ( select " sql = "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(self.q_where) sql += " union all select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) sql += "ts from regular_table_2 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15607 tdSql.query(sql) - # tdSql.checkRows(300) - - #join:TD-6020\TD-6149 select * from (select column form regular_table1,regular_table2 where t1.ts=t2.ts and <\>\in\and\or order by) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) + + #join:select * from (select column form regular_table1,regular_table2 where t1.ts=t2.ts and <\>\in\and\or order by) #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 1-4 from stable_1;") for i in range(self.fornum): - #sql = "select ts , * from ( select t1.ts ," - sql = "select * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(q_select) - sql += "t1.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(order_u_where) + sql = "select * from ( select t1.ts as t1ts," + sql += "t1.%s as t11, " % random.choice(self.q_select) + sql += "t1.%s as t12, " % random.choice(self.q_select) + sql += "t2.%s as t21, " % random.choice(self.q_select) + sql += "t2.%s as t22, " % random.choice(self.q_select) + sql += "t2.ts as t2ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) - tdSql.query("select 1-5 from stable_1;") - for i in range(self.fornum): - sql = "select ts , * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(q_select) - sql += "t1.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(order_u_where) - sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) - # TD-15587 tdSql.query(sql) - # tdSql.checkRows(100) - #2 select column from (select * form regular_table ) where <\>\in\and\or order by + #2 select column from (select * form regular_table ) where <\>\in\and\or order by #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 2-1 from stable_1;") for i in range(self.fornum): sql = "select ts ," - sql += "%s, " % random.choice(s_r_select) - sql += "%s " % random.choice(q_select) + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s " % random.choice(self.q_select) sql += " from ( select * from regular_table_1 ) where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) tdSql.checkRows(100) + self.cur1.execute(sql) + self.explain_sql(sql) #join: select column from (select column form regular_table1,regular_table2 )where t1.ts=t2.ts and <\>\in\and\or order by #cross join not supported yet tdSql.query("select 2-2 from stable_1;") for i in range(self.fornum): sql = "select ts , * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(q_select) - sql += "t1.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t1.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) + sql += "t2.%s, " % random.choice(self.q_select) sql += "t2.ts from regular_table_1 t1 , regular_table_2 t2 ) where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(order_u_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.order_u_where) #sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) - #3 select * from (select column\tag form stable where <\>\in\and\or order by ) + #3 select * from (select column\tag form stable where <\>\in\and\or order by ) #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 3-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s, " % random.choice(s_s_select) - sql += "%s, " % random.choice(q_select) - sql += "%s, " % random.choice(t_select) + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) sql += "ts from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) sql += ") ;" - tdLog.info(sql) + tdLog.info(sql) tdLog.info(len(sql)) tdSql.query(sql) tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 3-1 from stable_1;") for i in range(self.fornum): sql = "select ts, " - sql += "%s " % random.choice(s_r_select) + sql += "%s " % random.choice(self.s_r_select) sql += "from ( select " - sql += "%s, " % random.choice(s_s_select) - sql += "%s, " % random.choice(q_select) - sql += "%s, " % random.choice(t_select) + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.q_select) + sql += "%s, " % random.choice(self.t_select) sql += "ts from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) sql += ") ;" - tdLog.info(sql) + tdLog.info(sql) tdLog.info(len(sql)) - tdSql.query(sql) + tdSql.query(sql) tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) - # select ts,* from (select column\tag form stable1,stable2 where t1.ts = t2.ts and <\>\in\and\or order by ) + # select ts,* from (select column\tag form stable1,stable2 where t1.ts = t2.ts and <\>\in\and\or order by ) #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 3-2 from stable_1;") for i in range(self.fornum): - sql = "select ts , * from ( select t1.ts , " - sql += "t1.%s, " % random.choice(s_s_select) - sql += "t1.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(s_s_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += "%s " % random.choice(order_u_where) + #sql = "select ts , * from ( select t1.ts as t1ts , " + sql = "select t1ts , t2ts from ( select t1.ts as t1ts , " + sql += "t1.%s as t11, " % random.choice(self.t_select) + sql += "t1.%s as t12, " % random.choice(self.q_select) + sql += "t2.%s as t13, " % random.choice(self.t_select) + sql += "t2.%s as t14, " % random.choice(self.q_select) + sql += "t2.ts as t2ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.order_u_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - # TD-15609 tdSql.query(sql) - # tdSql.checkRows(100) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + #3 outer union not support - rsDn = self.restartDnodes() + self.restartDnodes() tdSql.query("select 3-3 from stable_1;") for i in range(self.fornum): #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql = "select ts1 from ( select " + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ts1 from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ") union " - sql += "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "select ts2 from ( select " + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ts2 from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - tdSql.checkRows(200) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) for i in range(self.fornum): - #sql = "select ts , * from ( select " - sql = "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql = "select ts1 from ( select " + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ts1 from stable_1 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ") union all " - sql += "select ts from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - sql += "ts from stable_2 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "select ts2 from ( select " + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ts2 from stable_2 where " + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - tdSql.checkRows(400) - + tdSql.checkRows(600) + self.cur1.execute(sql) + self.explain_sql(sql) + #3 inter union not support tdSql.query("select 3-4 from stable_1;") for i in range(self.fornum): - sql = "select ts , * from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) + sql = "select * from ( select " + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) sql += "ts from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) - sql += " %s " % random.choice(unionall_or_union) + sql += "%s " % random.choice(self.q_where) + sql += " %s " % random.choice(self.unionall_or_union) sql += " select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) sql += "ts from stable_2 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) sql += ")" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) #join:select * from (select column form stable1,stable2 where t1.ts=t2.ts and <\>\in\and\or order by) tdSql.query("select 3-5 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(q_select) - sql += "t1.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_u_where) - sql += "%s " % random.choice(order_u_where) + sql = "select * from ( select t1.ts as t1ts," + sql += "t1.%s as t11, " % random.choice(self.q_select) + sql += "t1.%s as t12, " % random.choice(self.q_select) + sql += "t2.%s as t21, " % random.choice(self.q_select) + sql += "t2.%s as t22, " % random.choice(self.q_select) + sql += "t2.ts as t2ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_where) + sql += "%s " % random.choice(self.order_u_where) sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # TD-15609 tdSql.query(sql) - # tdSql.checkRows(100) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 3-6 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select t1.ts ," - sql += "t1.%s, " % random.choice(q_select) - sql += "t1.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.%s, " % random.choice(q_select) - sql += "t2.ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_u_or_where) - sql += "%s " % random.choice(order_u_where) + sql = "select * from ( select t1.ts as t1ts ," + sql += "t1.%s as t11, " % random.choice(self.q_select) + sql += "t1.%s as t12, " % random.choice(self.q_select) + sql += "t2.%s as t21, " % random.choice(self.q_select) + sql += "t2.%s as t22, " % random.choice(self.q_select) + sql += "t2.ts as t2ts from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.t_u_or_where) + sql += "%s " % random.choice(self.order_u_where) sql += ");" - tdLog.info(sql) - tdLog.info(len(sql)) - # TD-15609 同上 tdSql.query(sql) - # tdSql.checkRows(100) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) - #4 select column from (select * form stable where <\>\in\and\or order by ) + #4 select column from (select * form stable where <\>\in\and\or order by ) #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 4-1 from stable_1;") for i in range(self.fornum): sql = "select ts , " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - sql += "%s " % random.choice(t_select) + sql += "%s as t11, " % random.choice(self.q_select) + sql += "%s as t12, " % random.choice(self.q_select) + sql += "%s " % random.choice(self.t_select) sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15616 tdSql.query(sql) - # tdSql.checkRows(300) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + tdSql.checkRows(300) + self.cur1.execute(sql) + self.explain_sql(sql) #5 select distinct column\tag from (select * form stable where <\>\in\and\or order by limit offset ) tdSql.query("select 5-1 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(dqt_select) + sql += "%s " % random.choice(self.dqt_select) sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15500 tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) #5-1 select distinct column\tag from (select calc form stable where <\>\in\and\or order by limit offset ) tdSql.query("select 5-2 from stable_1;") for i in range(self.fornum): sql = "select distinct c5_1 " sql += " from ( select " - sql += "%s " % random.choice(calc_select_in_ts) + sql += "%s " % random.choice(self.calc_select_in_ts) sql += " as c5_1 from stable_1 where " - sql += "%s " % random.choice(qt_where) - #sql += "%s " % random.choice(order_where) + sql += "%s " % random.choice(self.qt_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - #tdSql.checkRows(1)有的函数还没有提交,会不返回结果,先忽略 + self.cur1.execute(sql) + self.explain_sql(sql) #6-error select * from (select distinct(tag) form stable where <\>\in\and\or order by limit ) tdSql.query("select 6-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(dt_select) + sql += "%s " % random.choice(self.dt_select) sql += " from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_desc_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.error(sql) tdSql.query("select 6-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(dt_select) + sql += "%s " % random.choice(self.dt_select) sql += " from stable_1 where " - sql += "%s ) ;" % random.choice(qt_where) - tdLog.info(sql) - tdLog.info(len(sql)) + sql += "%s ) ;" % random.choice(self.qt_where) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - #tdSql.checkRows(1)#数量不一致,不在校验 + self.cur1.execute(sql) + self.explain_sql(sql) #7-error select * from (select distinct(tag) form stable where <\>\in\and\or order by limit ) tdSql.query("select 7-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(dq_select) + sql += "%s " % random.choice(self.dq_select) sql += " from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice([limit_where[0] , limit_where[1]] ) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice([self.limit_where[0] , self.limit_where[1]] ) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) #distinct 和 order by 不能混合使用 + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) tdSql.query("select 7-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(dq_select) + sql += "%s " % random.choice(self.dq_select) sql += " from stable_1 where " - sql += "%s " % random.choice(qt_where) - #sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice([limit_where[0] , limit_where[1]] ) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice([self.limit_where[0] , self.limit_where[1]] ) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) tdSql.checkRows(1) + self.cur1.execute(sql) + self.explain_sql(sql) #calc_select,TWA/Diff/Derivative/Irate are not allowed to apply to super table directly #8 select * from (select ts,calc form ragular_table where <\>\in\and\or order by ) - + # dcDB = self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 8-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select ts ," - sql += "%s " % random.choice(calc_select_support_ts) + sql += "%s " % random.choice(self.calc_select_support_ts) sql += "from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) # 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 8-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_select_not_support_ts) + sql += "%s " % random.choice(self.calc_select_not_support_ts) sql += "from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) # 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_select_in_ts) + sql += "%s " % random.choice(self.calc_select_in_ts) sql += "from regular_table_1 where " - sql += "%s " % random.choice(q_where) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - ##top返回结果有问题nest.sql tdSql.checkRows(1) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 8-2 from stable_1;") for i in range(self.fornum): sql = "select * from ( select t1.ts, " - sql += "%s " % random.choice(calc_select_in_support_ts_j) + sql += "%s " % random.choice(self.calc_select_in_support_ts_j) sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql)# 聚合函数不在可以和ts一起使用了 DB error: Not a single-group group function + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_select_in_not_support_ts_j) + sql += "%s " % random.choice(self.calc_select_in_not_support_ts_j) sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - ##top返回结果有问题 tdSql.checkRows(1) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - #9 select * from (select ts,calc form stable where <\>\in\and\or order by ) + #9 select * from (select ts,calc form stable where <\>\in\and\or order by ) # self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 9-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_select_not_support_ts) + sql += "%s " % random.choice(self.calc_select_not_support_ts) sql += "from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 9-2 from stable_1;") for i in range(self.fornum): sql = "select * from ( select ts ," - sql += "%s " % random.choice(calc_select_support_ts) + sql += "%s " % random.choice(self.calc_select_support_ts) sql += "from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 9-3 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_select_in_not_support_ts_j) + sql += "%s " % random.choice(self.calc_select_in_not_support_ts_j) sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += " and %s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 9-4 from stable_1;") for i in range(self.fornum): sql = "select * from ( select t1.ts," - sql += "%s " % random.choice(calc_select_in_support_ts_j) + sql += "%s " % random.choice(self.calc_select_in_support_ts_j) sql += "from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += " and %s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.t_join_where) + sql += " and %s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - - #10 select calc from (select * form regualr_table where <\>\in\and\or order by ) + self.cur1.execute(sql) + self.explain_sql(sql) + + #10 select calc from (select * form regualr_table where <\>\in\and\or order by ) tdSql.query("select 10-1 from stable_1;") for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(calc_select_in_ts) + sql = "select " + sql += "%s " % random.choice(self.calc_select_in_ts) sql += "as calc10_1 from ( select * from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - tdSql.checkRows(1) - + self.cur1.execute(sql) + self.explain_sql(sql) + #10-1 select calc from (select * form regualr_table where <\>\in\and\or order by ) - # rsDn = self.restartDnodes() + # rsDn = self.restartDnodes() # self.dropandcreateDB_random("%s" %db, 1) # rsDn = self.restartDnodes() tdSql.query("select 10-2 from stable_1;") for i in range(self.fornum): - sql = "select " - sql += "%s " % random.choice(calc_select_all) + sql = "select " + sql += "%s " % random.choice(self.calc_select_all) sql += "as calc10_2 from ( select * from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - # tdSql.checkRows(1) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - #10-2 select calc from (select * form regualr_tables where <\>\in\and\or order by ) + #10-2 select calc from (select * form regualr_tables where <\>\in\and\or order by ) tdSql.query("select 10-3 from stable_1;") for i in range(self.fornum): - sql = "select " - sql += "%s as calc10_3 " % random.choice(calc_select_all) - sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += " and %s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql = "select " + sql += "count(*) as calc10_3 " + sql += " from ( select t1.ts as t11, t2.ts as t22 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += " and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - sql += "%s ;" % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) + sql += "%s ;" % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 10-4 from stable_1;") for i in range(self.fornum): - sql = "select " - sql += "%s as calc10_4 " % random.choice(calc_select_all) + sql = "select " + sql += "%s as calc10_4 " % random.choice(self.calc_select_all) sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += " and %s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_or_where) + sql += " and %s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - sql += "%s ;" % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - # tdSql.checkRows(1) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) - #11 select calc from (select * form stable where <\>\in\and\or order by limit ) + #11 select calc from (select * form stable where <\>\in\and\or order by limit ) tdSql.query("select 11-1 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_select_in_ts) + sql += "%s " % random.choice(self.calc_select_in_ts) sql += "as calc11_1 from ( select * from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - tdSql.checkRows(1) + self.cur1.execute(sql) + self.explain_sql(sql) - #11-1 select calc from (select * form stable where <\>\in\and\or order by limit ) + #11-1 select calc from (select * form stable where <\>\in\and\or order by limit ) tdSql.query("select 11-2 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_select_all) + sql += "%s " % random.choice(self.calc_select_all) sql += "as calc11_1 from ( select * from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) - #不好计算结果 tdSql.checkRows(1) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + #11-2 select calc from (select * form stables where <\>\in\and\or order by limit ) tdSql.query("select 11-3 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_select_all) + sql += "%s " % random.choice(self.calc_select_all) sql += "as calc11_1 from ( select * from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - sql += "%s ;" % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) tdSql.query("select 11-4 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_select_all) + sql += "%s " % random.choice(self.calc_select_all) sql += "as calc11_1 from ( select * from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - sql += "%s ;" % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) - #12 select calc-diff from (select * form regualr_table where <\>\in\and\or order by limit ) + #12 select calc-diff from (select * form regualr_table where <\>\in\and\or order by limit ) ##self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 12-1 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_calculate_regular) + sql += "%s " % random.choice(self.calc_calculate_regular) sql += " from ( select * from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - ##目前derivative不支持 tdSql.query(sql) - # tdSql.checkRows(1) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 12-2 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_calculate_regular) + sql += "%s " % random.choice(self.calc_calculate_regular) sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #目前derivative不支持 tdSql.query(sql) - # tdSql.checkRows(1) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) tdSql.query("select 12-2.2 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_calculate_regular) + sql += "%s " % random.choice(self.calc_calculate_regular) sql += " from ( select * from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += "%s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #目前derivative不支持 tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) #12-1 select calc-diff from (select * form stable where <\>\in\and\or order by limit ) tdSql.query("select 12-3 from stable_1;") - rsDn = self.restartDnodes() + self.restartDnodes() for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_calculate_regular) + sql += "%s " % random.choice(self.calc_calculate_regular) sql += " from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) sql += ") " - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #目前derivative不支持 tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 12-4 from stable_1;") #join query does not support group by for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_calculate_regular_j) + sql += "%s " % random.choice(self.calc_calculate_regular_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += "%s " % random.choice(group_where_j) + sql += "%s " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.partiton_where_j) sql += ") " - #sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) 目前de函数不支持,另外看看需要不需要将group by和pari by分开 + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 12-5 from stable_1;") #join query does not support group by for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_calculate_regular_j) + sql += "%s " % random.choice(self.calc_calculate_regular_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(group_where_j) + sql += "%s " % random.choice(self.qt_u_or_where) sql += ") " - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) sql += " ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #derivative not support tdSql.query(sql) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + #13 select calc-diff as diffns from (select * form stable where <\>\in\and\or order by limit ) tdSql.query("select 13-1 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_calculate_regular) + sql += "%s " % random.choice(self.calc_calculate_regular) sql += " as calc13_1 from ( select * from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(orders_desc_where) - sql += "%s " % random.choice([limit_where[2] , limit_where[3]] ) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.orders_desc_where) + sql += "%s " % random.choice([self.limit_where[2] , self.limit_where[3]] ) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #derivative not support tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) #14 select * from (select calc_aggregate_alls as agg from stable where <\>\in\and\or group by order by slimit soffset ) - # TD-5955 select * from ( select count (q_double) from stable_1 where t_bool = true or t_bool = false group by loc order by ts asc slimit 1 ) ; tdSql.query("select 14-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc14_1, " % random.choice(calc_aggregate_all) - sql += "%s as calc14_2, " % random.choice(calc_aggregate_all) - sql += "%s " % random.choice(calc_aggregate_all) + sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all) + sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all) + sql += "%s " % random.choice(self.calc_aggregate_all) sql += " as calc14_3 from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(group_where) - sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice(slimit1_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.group_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15678 tdSql.query(sql) - # tdSql.checkRows(1) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) # error group by in out query tdSql.query("select 14-2 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc14_1, " % random.choice(calc_aggregate_all) - sql += "%s as calc14_2, " % random.choice(calc_aggregate_all) - sql += "%s " % random.choice(calc_aggregate_all) + sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all) + sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all) + sql += "%s " % random.choice(self.calc_aggregate_all) sql += " as calc14_3 from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(group_where) - sql += "%s " % random.choice(having_support) - sql += "%s " % random.choice(orders_desc_where) - sql += "%s " % random.choice(slimit1_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.partiton_where_regular) + sql += "%s " % random.choice(self.slimit1_where) sql += ") " - sql += "%s " % random.choice(group_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15678 tdSql.query(sql) - # tdSql.checkRows(1) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) #14-2 select * from (select calc_aggregate_all_js as agg from stables where <\>\in\and\or group by order by slimit soffset ) tdSql.query("select 14-3 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc14_1, " % random.choice(calc_aggregate_all_j) - sql += "%s as calc14_2, " % random.choice(calc_aggregate_all_j) - sql += "%s " % random.choice(calc_aggregate_all_j) + sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all_j) + sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all_j) + sql += "%s " % random.choice(self.calc_aggregate_all_j) sql += " as calc14_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += "%s " % random.choice(partiton_where_j) - sql += "%s " % random.choice(slimit1_where) + sql += "%s " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) sql += ") " - sql += "%s ;" % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 14-4 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc14_1, " % random.choice(calc_aggregate_all_j) - sql += "%s as calc14_2, " % random.choice(calc_aggregate_all_j) - sql += "%s " % random.choice(calc_aggregate_all_j) + sql += "%s as calc14_1, " % random.choice(self.calc_aggregate_all_j) + sql += "%s as calc14_2, " % random.choice(self.calc_aggregate_all_j) + sql += "%s " % random.choice(self.calc_aggregate_all_j) sql += " as calc14_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(partiton_where_j) - sql += "%s " % random.choice(slimit1_where) + sql += "%s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.partiton_where_j) + sql += "%s " % random.choice(self.slimit1_where) sql += ") " - sql += "%s ;" % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - #15 TD-6320 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by slimit soffset ) + #15 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by slimit soffset ) tdSql.query("select 15-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(calc_aggregate_regular) - sql += "%s as calc15_2, " % random.choice(calc_aggregate_regular) - sql += "%s " % random.choice(calc_aggregate_regular) + sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_regular) + sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_regular) + sql += "%s " % random.choice(self.calc_aggregate_regular) sql += " as calc15_3 from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(group_where_regular) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.group_where_regular) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #Invalid function name: twa' - # tdSql.checkRows(1) - + tdLog.info(sql) + tdLog.info(len(sql)) + self.data_check(sql,mark='15-1') + tdSql.query("select 15-2 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(calc_aggregate_regular_j) - sql += "%s as calc15_2, " % random.choice(calc_aggregate_regular_j) - sql += "%s " % random.choice(calc_aggregate_regular_j) - sql += " as calc15_3 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(group_where_regular_j) - sql += "%s " % random.choice(limit_u_where) + sql += "%s as calc15_2 " % random.choice(self.calc_aggregate_regular_j) + sql += "from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.group_where_regular_j) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - sql += "%s ;" % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #Invalid function name: twa' + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 15-2.2 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(calc_aggregate_regular_j) - sql += "%s as calc15_2, " % random.choice(calc_aggregate_regular_j) - sql += "%s " % random.choice(calc_aggregate_regular_j) + sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_regular_j) + sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_regular_j) + sql += "%s " % random.choice(self.calc_aggregate_regular_j) sql += " as calc15_3 from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(group_where_regular_j) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.group_where_regular_j) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - sql += "%s ;" % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #Invalid function name: twa' + sql += "%s ;" % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - rsDn = self.restartDnodes() + self.restartDnodes() tdSql.query("select 15-3 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(calc_aggregate_groupbytbname) - sql += "%s as calc15_2, " % random.choice(calc_aggregate_groupbytbname) - sql += "%s " % random.choice(calc_aggregate_groupbytbname) + sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname) + sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname) + sql += "%s " % random.choice(self.calc_aggregate_groupbytbname) sql += " as calc15_3 from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(group_where) - sql += "%s " % random.choice(having_support) - sql += "%s " % random.choice(order_desc_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.group_only_where) + sql += "%s " % random.choice(self.having_support) sql += ") " - sql += "order by calc15_1 " - sql += "%s " % random.choice(limit_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #Invalid function name: twa',可能还的去掉order by + sql += "order by calc15_1 " + sql += "%s " % random.choice(self.limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 15-4 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(calc_aggregate_groupbytbname_j) - sql += "%s as calc15_2, " % random.choice(calc_aggregate_groupbytbname_j) - sql += "%s " % random.choice(calc_aggregate_groupbytbname_j) + sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname_j) + sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname_j) + sql += "%s " % random.choice(self.calc_aggregate_groupbytbname_j) sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += "%s " % random.choice(group_where_j) - sql += "%s " % random.choice(having_support_j) - #sql += "%s " % random.choice(orders_desc_where) + sql += "%s " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.group_only_where_j) + sql += "%s " % random.choice(self.having_support_j) sql += ") " - sql += "order by calc15_1 " - sql += "%s " % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #'Invalid function name: irate' + sql += "order by calc15_1 " + sql += "%s " % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 15-4.2 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(calc_aggregate_groupbytbname_j) - sql += "%s as calc15_2, " % random.choice(calc_aggregate_groupbytbname_j) - sql += "%s " % random.choice(calc_aggregate_groupbytbname_j) + sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname_j) + sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname_j) + sql += "%s " % random.choice(self.calc_aggregate_groupbytbname_j) sql += " as calc15_3 from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(group_where_j) - sql += "%s " % random.choice(having_support_j) - sql += "%s " % random.choice(orders_desc_where) + sql += "%s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.group_where_j) sql += ") " - sql += "order by calc15_1 " - sql += "%s " % random.choice(limit_u_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15678 #tdSql.query(sql) + sql += "order by calc15_1 " + sql += "%s " % random.choice(self.limit_u_where) + tdLog.info(sql) + tdLog.info(len(sql)) + self.data_check(sql,mark='15-4.2') tdSql.query("select 15-5 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s as calc15_1, " % random.choice(calc_aggregate_groupbytbname) - sql += "%s as calc15_2, " % random.choice(calc_aggregate_groupbytbname) - sql += "%s " % random.choice(calc_aggregate_groupbytbname) + sql += "%s as calc15_1, " % random.choice(self.calc_aggregate_groupbytbname) + sql += "%s as calc15_2, " % random.choice(self.calc_aggregate_groupbytbname) + sql += "%s " % random.choice(self.calc_aggregate_groupbytbname) sql += " as calc15_3 from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.group_where) sql += ") " - sql += "order by calc15_1 " - sql += "%s " % random.choice(limit_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql) #'Invalid function name: irate' + sql += "order by calc15_1 " + sql += "%s " % random.choice(self.limit_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - #16 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by limit offset ) + #16 select * from (select calc_aggregate_regulars as agg from regular_table where <\>\in\and\or order by limit offset ) #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 16-1 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_0 , " % random.choice(calc_calculate_all) - sql += "%s as calc16_1 , " % random.choice(calc_aggregate_all) - sql += "%s as calc16_2 " % random.choice(calc_select_in) + sql = "select * from ( select " + sql += "%s as calc16_0 , " % random.choice(self.calc_calculate_all) + sql += "%s as calc16_1 , " % random.choice(self.calc_aggregate_all) + sql += "%s as calc16_2 " % random.choice(self.calc_select_in) sql += " from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(group_where) - #sql += "%s " % random.choice(having_support)having和 partition不能混合使用 + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.group_where) sql += ") " - sql += "order by calc16_0 " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15651 tdSql.query(sql) + sql += "order by calc16_0 " + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 16-2 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_0 " % random.choice(calc_calculate_all_j) - sql += ", %s as calc16_1 " % random.choice(calc_aggregate_all_j) - #sql += ", %s as calc16_2 " % random.choice(calc_select_in_j) + sql = "select * from ( select " + sql += "%s as calc16_0 " % random.choice(self.calc_calculate_all_j) + sql += ", %s as calc16_1 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(self.t_join_where) sql += ") " - sql += "order by calc16_0 " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) + sql += "order by calc16_0 " + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 16-2.2 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_0 " % random.choice(calc_calculate_all_j) - sql += ", %s as calc16_1 " % random.choice(calc_aggregate_all_j) + sql = "select * from ( select " + sql += "%s as calc16_0 " % random.choice(self.calc_calculate_all_j) + sql += ", %s as calc16_1 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(self.qt_u_or_where) sql += ") " - sql += "order by calc16_0 " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) + sql += "order by calc16_0 " + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 16-3 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(calc_calculate_regular) + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(self.calc_calculate_regular) sql += " from regular_table_1 where " - sql += "%s " % random.choice(q_where) + sql += "%s " % random.choice(self.q_where) sql += "limit 2 ) " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql)#Invalid function name: derivative' + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 16-4 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(calc_calculate_regular_j) + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(self.calc_calculate_regular_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) + sql += "%s " % random.choice(self.q_u_where) sql += "limit 2 ) " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql)#Invalid function name: derivative' + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 16-4.2 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(calc_calculate_regular_j) + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(self.calc_calculate_regular_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) + sql += "%s " % random.choice(self.q_u_or_where) sql += "limit 2 ) " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #tdSql.query(sql)#Invalid function name: derivative' - + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 16-5 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 , " % random.choice(calc_calculate_all) - sql += "%s as calc16_1 , " % random.choice(calc_calculate_regular) - sql += "%s as calc16_2 " % random.choice(calc_select_all) + sql = "select * from ( select " + sql += "%s as calc16_1 , " % random.choice(self.calc_calculate_all) + sql += "%s as calc16_2 , " % random.choice(self.calc_calculate_all) + sql += "%s as calc16_3 " % random.choice(self.calc_calculate_all) sql += " from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(group_where) - #sql += "%s " % random.choice(having_support) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.group_where) sql += ") " - sql += "order by calc16_1 " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - # tdSql.query(sql) - + sql += "order by calc16_1 " + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 16-6 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(calc_calculate_groupbytbname) + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(self.calc_calculate_groupbytbname) sql += " from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(group_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) sql += "limit 2 ) " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #Invalid function name: derivative' tdSql.query(sql) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 16-7 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(calc_calculate_groupbytbname_j) + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(self.calc_calculate_groupbytbname_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) + sql += "%s " % random.choice(self.t_join_where) sql += "limit 2 ) " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #Invalid function name: derivative' tdSql.query(sql) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 16-8 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s as calc16_1 " % random.choice(calc_calculate_groupbytbname_j) + sql = "select * from ( select " + sql += "%s as calc16_1 " % random.choice(self.calc_calculate_groupbytbname_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) + sql += "%s " % random.choice(self.qt_u_or_where) sql += "limit 2 ) " - sql += "%s " % random.choice(limit1_where) - tdLog.info(sql) - tdLog.info(len(sql)) - #Invalid function name: derivative' tdSql.query(sql) + sql += "%s " % random.choice(self.limit1_where) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) #17 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or interval_sliding group by having order by limit offset )interval_sliding #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 17-1 from stable_1;") for i in range(self.fornum): - #this is having_support , but tag-select cannot mix with last_row,other select can + #this is having_support , but tag-select cannot mix with last_row,other select can sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_0 , " % random.choice(calc_calculate_all) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) sql += " from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(partiton_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(having_support) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15719 tdSql.query(sql) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 17-2 from stable_1;") for i in range(self.fornum): - #this is having_support , but tag-select cannot mix with last_row,other select can + #this is having_support , but tag-select cannot mix with last_row,other select can sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_0 , " % random.choice(calc_calculate_all_j) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all_j) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 17-2.2 from stable_1;") for i in range(self.fornum): - #this is having_support , but tag-select cannot mix with last_row,other select can + #this is having_support , but tag-select cannot mix with last_row,other select can sql = "select apercentile(cal17_0, %d)/10 ,apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_0 , " % random.choice(calc_calculate_all_j) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_0 , " % random.choice(self.calc_calculate_all_j) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) self.restartDnodes() tdSql.query("select 17-3 from stable_1;") for i in range(self.fornum): #this is having_tagnot_support , because tag-select cannot mix with last_row... sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) sql += " from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(partiton_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(having_tagnot_support) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15770 tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 17-4 from stable_1;") for i in range(self.fornum): #this is having_tagnot_support , because tag-select cannot mix with last_row... sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 17-4.2 from stable_1;") for i in range(self.fornum): #this is having_tagnot_support , because tag-select cannot mix with last_row... sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 17-5 from stable_1;") for i in range(self.fornum): - #having_not_support + #having_not_support sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) sql += " from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(partiton_where) - sql += "%s " % random.choice(interval_sliding) - # sql += "%s " % random.choice(having_not_support) - # sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.partiton_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15719 tdSql.query(sql) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 17-6 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) sql += " from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15770 tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 17-7 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 17-7.2 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) self.restartDnodes() tdSql.query("select 17-8 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all) sql += " from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 17-9 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 17-10 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal17_1, %d)/1000 ,apercentile(cal17_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal17_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal17_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal17_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal17_2 " % random.choice(self.calc_aggregate_all_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(interval_sliding) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.interval_sliding) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) #18 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or session order by limit )interval_sliding tdSql.query("select 18-1 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all) sql += " from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(session_where) - #sql += "%s " % random.choice(fill_where) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.session_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 18-2 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(session_u_where) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.session_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 18-2.2 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(session_u_where) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.session_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) self.restartDnodes() tdSql.query("select 18-3 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all) sql += " from stable_1_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(session_where) - #sql += "%s " % random.choice(fill_where) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.session_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 18-4 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(session_u_where) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.session_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 18-4.2 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(session_u_where) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.session_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 18-5 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all) sql += " from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(session_where) - #sql += "%s " % random.choice(fill_where) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.session_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - #TD-15770 tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 18-6 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(t_join_where) - sql += "%s " % random.choice(session_u_where) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.session_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 18-7 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal18_1, %d)/1000 ,apercentile(cal18_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal18_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal18_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal18_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal18_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1, stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(session_u_where) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.session_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - #19 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or session order by limit )interval_sliding + #19 select apercentile from (select calc_aggregate_alls form regualr_table or stable where <\>\in\and\or session order by limit )interval_sliding #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 19-1 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all) sql += " from regular_table_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(state_window) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.state_window) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 19-2 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - sql += "%s " % random.choice(state_u_window) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.state_u_window) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 19-2.2 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - sql += "%s " % random.choice(state_u_window) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.state_u_window) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + tdSql.query("select 19-3 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all) sql += " from stable_1_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(state_window) - #sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.state_window) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 19-4 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - #sql += "%s " % random.choice(state_window) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 19-4.2 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1_1 t1, stable_1_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_or_where) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_or_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 19-5 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all) sql += " from stable_1 where " - sql += "%s " % random.choice(q_where) - sql += "%s " % random.choice(state_window) - sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit1_where) + sql += "%s " % random.choice(self.q_where) + sql += "%s " % random.choice(self.state_window) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit1_where) sql += ") " - sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) #'STATE_WINDOW not support for super table query' - + sql += "%s " % random.choice(self.interval_sliding) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) + tdSql.query("select 19-6 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(q_u_where) - #sql += "%s " % random.choice(state_window) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.q_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) tdSql.query("select 19-7 from stable_1;") for i in range(self.fornum): sql = "select apercentile(cal19_1, %d)/1000 ,apercentile(cal19_2, %d)*10+%d from ( select " %(random.randint(0,100) , random.randint(0,100) ,random.randint(-1000,1000)) - sql += "%s as cal19_1 ," % random.choice(calc_aggregate_all_j) - sql += "%s as cal19_2 " % random.choice(calc_aggregate_all_j) + sql += "%s as cal19_1 ," % random.choice(self.calc_aggregate_all_j) + sql += "%s as cal19_2 " % random.choice(self.calc_aggregate_all_j) sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s " % random.choice(qt_u_or_where) - #sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - #sql += "%s " % random.choice(interval_sliding) - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) - #20 select * from (select calc_select_fills form regualr_table or stable where <\>\in\and\or fill_where group by order by limit offset ) + #20 select * from (select calc_select_fills form regualr_table or stable where <\>\in\and\or fill_where group by order by limit offset ) #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 20-1 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(calc_select_fill) - sql += "%s ," % random.choice(calc_select_fill) - sql += "%s " % random.choice(calc_select_fill) + sql = "select * from ( select " + sql += "%s , " % random.choice(self.calc_select_fill) + sql += "%s ," % random.choice(self.calc_select_fill) + sql += "%s " % random.choice(self.calc_select_fill) sql += " from stable_1 where " - sql += "%s " % random.choice(interp_where) - sql += "%s " % random.choice(fill_where) - sql += "%s " % random.choice(group_where) - sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit_where) + sql += "%s " % random.choice(self.interp_where) + sql += "%s " % random.choice(self.fill_where) + sql += "%s " % random.choice(self.group_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) #interp不支持 tdSql.query(sql) + #self.cur1.execute(sql) + #self.explain_sql(sql) rsDn = self.restartDnodes() tdSql.query("select 20-2 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(calc_select_fill_j) - sql += "%s ," % random.choice(calc_select_fill_j) - sql += "%s " % random.choice(calc_select_fill_j) + sql = "select * from ( select " + sql += "%s , " % random.choice(self.calc_select_fill_j) + sql += "%s ," % random.choice(self.calc_select_fill_j) + sql += "%s " % random.choice(self.calc_select_fill_j) sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s and " % random.choice(t_join_where) - sql += "%s " % random.choice(interp_where_j) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s and " % random.choice(self.t_join_where) + sql += "%s " % random.choice(self.interp_where_j) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) #interp不支持 tdSql.query(sql) + #self.cur1.execute(sql) + #self.explain_sql(sql) tdSql.query("select 20-2.2 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(calc_select_fill_j) - sql += "%s ," % random.choice(calc_select_fill_j) - sql += "%s " % random.choice(calc_select_fill_j) + sql = "select * from ( select " + sql += "%s , " % random.choice(self.calc_select_fill_j) + sql += "%s ," % random.choice(self.calc_select_fill_j) + sql += "%s " % random.choice(self.calc_select_fill_j) sql += " from stable_1 t1 , stable_2 t2 where t1.ts = t2.ts and " - sql += "%s and " % random.choice(qt_u_or_where) - sql += "%s " % random.choice(interp_where_j) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql += "%s and " % random.choice(self.qt_u_or_where) + sql += "%s " % random.choice(self.interp_where_j) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) #interp不支持 tdSql.query(sql) + #self.cur1.execute(sql) + #self.explain_sql(sql) tdSql.query("select 20-3 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(calc_select_fill) - sql += "%s ," % random.choice(calc_select_fill) - sql += "%s " % random.choice(calc_select_fill) + sql = "select * from ( select " + sql += "%s , " % random.choice(self.calc_select_fill) + sql += "%s ," % random.choice(self.calc_select_fill) + sql += "%s " % random.choice(self.calc_select_fill) sql += " from stable_1 where " - sql += "%s " % interp_where[2] - sql += "%s " % random.choice(fill_where) - sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit_where) + sql += "%s " % self.interp_where[2] + sql += "%s " % random.choice(self.fill_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) #interp不支持 tdSql.query(sql) - + #self.cur1.execute(sql) + #self.explain_sql(sql) + tdSql.query("select 20-4 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(calc_select_fill_j) - sql += "%s ," % random.choice(calc_select_fill_j) - sql += "%s " % random.choice(calc_select_fill_j) - sql += " from stable_1 t1, table_1 t2 where t1.ts = t2.ts and " - #sql += "%s and " % random.choice(t_join_where) - sql += "%s " % interp_where_j[random.randint(0,5)] - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql = "select * from ( select " + sql += "%s , " % random.choice(self.calc_select_fill_j) + sql += "%s ," % random.choice(self.calc_select_fill_j) + sql += "%s " % random.choice(self.calc_select_fill_j) + sql += " from stable_1 t1, table_1 t2 where t1.ts = t2.ts and " + #sql += "%s and " % random.choice(self.t_join_where) + sql += "%s " % self.interp_where_j[random.randint(0,5)] + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) #interp不支持 tdSql.query(sql) + #self.cur1.execute(sql) + #self.explain_sql(sql) tdSql.query("select 20-4.2 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(calc_select_fill_j) - sql += "%s ," % random.choice(calc_select_fill_j) - sql += "%s " % random.choice(calc_select_fill_j) - sql += " from stable_1 t1, stable_1_1 t2 where t1.ts = t2.ts and " - sql += "%s and " % random.choice(qt_u_or_where) - sql += "%s " % interp_where_j[random.randint(0,5)] - sql += "%s " % random.choice(fill_where) - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + sql = "select * from ( select " + sql += "%s , " % random.choice(self.calc_select_fill_j) + sql += "%s ," % random.choice(self.calc_select_fill_j) + sql += "%s " % random.choice(self.calc_select_fill_j) + sql += " from stable_1 t1, stable_1_1 t2 where t1.ts = t2.ts and " + sql += "%s and " % random.choice(self.qt_u_or_where) + sql += "%s " % self.interp_where_j[random.randint(0,5)] + sql += "%s " % random.choice(self.fill_where) + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) ##interp不支持 tdSql.error(sql) - + #self.cur1.execute(sql) + #self.explain_sql(sql) + tdSql.query("select 20-5 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(calc_select_fill) - sql += "%s ," % random.choice(calc_select_fill) - sql += "%s " % random.choice(calc_select_fill) + sql = "select * from ( select " + sql += "%s , " % random.choice(self.calc_select_fill) + sql += "%s ," % random.choice(self.calc_select_fill) + sql += "%s " % random.choice(self.calc_select_fill) sql += " from regular_table_1 where " - sql += "%s " % interp_where[1] - sql += "%s " % random.choice(fill_where) - sql += "%s " % random.choice(order_where) - sql += "%s " % random.choice(limit_where) + sql += "%s " % self.interp_where[1] + sql += "%s " % random.choice(self.fill_where) + sql += "%s " % random.choice(self.order_where) + sql += "%s " % random.choice(self.limit_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) ##interp不支持 tdSql.query(sql) + #self.cur1.execute(sql) + #self.explain_sql(sql) tdSql.query("select 20-6 from stable_1;") for i in range(self.fornum): - sql = "select * from ( select " - sql += "%s , " % random.choice(calc_select_fill_j) - sql += "%s ," % random.choice(calc_select_fill_j) - sql += "%s " % random.choice(calc_select_fill_j) + sql = "select * from ( select " + sql += "%s , " % random.choice(self.calc_select_fill_j) + sql += "%s ," % random.choice(self.calc_select_fill_j) + sql += "%s " % random.choice(self.calc_select_fill_j) sql += " from regular_table_1 t1, regular_table_2 t2 where t1.ts = t2.ts and " - #sql += "%s " % random.choice(interp_where_j) - sql += "%s " % interp_where_j[random.randint(0,5)] - sql += "%s " % random.choice(order_u_where) - sql += "%s " % random.choice(limit_u_where) + #sql += "%s " % random.choice(self.interp_where_j) + sql += "%s " % self.interp_where_j[random.randint(0,5)] + sql += "%s " % random.choice(self.order_u_where) + sql += "%s " % random.choice(self.limit_u_where) sql += ") " - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) ##interp不支持 tdSql.query(sql) + #self.cur1.execute(sql) + #self.explain_sql(sql) #1 select * from (select * from (select * form regular_table where <\>\in\and\or order by limit )) tdSql.query("select 1-1 from stable_1;") - for i in range(self.fornum): + for i in range(self.fornum): # sql_start = "select * from ( " # sql_end = ")" for_num = random.randint(1, 15); - sql = "select * from (" * for_num + sql = "select * from (" * for_num sql += "select * from ( select * from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ttt from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) sql += ")) " - sql += ")" * for_num - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + sql += ")" * for_num + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + sql2 = "select * from ( select * from ( select " - sql2 += "%s, " % random.choice(s_r_select) - sql2 += "%s, " % random.choice(q_select) - sql2 += "ts from regular_table_1 where " - sql2 += "%s " % random.choice(q_where) - sql2 += ")) " - tdLog.info(sql2) - tdLog.info(len(sql2)) - + sql2 += "%s, " % random.choice(self.s_r_select) + sql2 += "%s, " % random.choice(self.q_select) + sql2 += "ts as tin from regular_table_1 where " + sql2 += "%s " % random.choice(self.q_where) + sql2 += ")) " + tdLog.info(sql2) + tdLog.info(len(sql2)) + tdSql.query(sql2) + self.cur1.execute(sql2) + self.explain_sql(sql2) + self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1) self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql ,1,10,3,3) self.data_matrix_equal('%s' %sql ,1,10,3,3,'%s' %sql2 ,1,10,3,3) - + + tdLog.info("=====1-1==over=========") + for i in range(self.fornum): for_num = random.randint(1, 15); - sql = "select ts from (" * for_num + sql = "select ts2 from (" * for_num sql += "select * from ( select * from ( select " - sql += "%s, " % random.choice(s_r_select) - sql += "%s, " % random.choice(q_select) - sql += "ts from regular_table_1 where " - sql += "%s " % random.choice(q_where) + sql += "%s, " % random.choice(self.s_r_select) + sql += "%s, " % random.choice(self.q_select) + sql += "ts as ts2 from regular_table_1 where " + sql += "%s " % random.choice(self.q_where) sql += ")) " - sql += ")" * for_num - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + sql += ")" * for_num + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + sql2 = "select * from ( select * from ( select " - sql2 += "%s, " % random.choice(s_r_select) - sql2 += "%s, " % random.choice(q_select) - sql2 += "ts from regular_table_1 where " - sql2 += "%s " % random.choice(q_where) - sql2 += ")) " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + sql2 += "%s, " % random.choice(self.s_r_select) + sql2 += "%s, " % random.choice(self.q_select) + sql2 += "ts as tt from regular_table_1 where " + sql2 += "%s " % random.choice(self.q_where) + sql2 += ")) " + tdLog.info(sql2) + tdLog.info(len(sql2)) + tdSql.query(sql2) + self.cur1.execute(sql2) + self.explain_sql(sql2) + self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1) - + tdLog.info("=====1-2==over=========") + #2 select * from (select * from (select * form stable where <\>\in\and\or order by limit )) tdSql.query("select 2-1 from stable_1;") for i in range(self.fornum): for_num = random.randint(1, 15); - sql = "select * from (" * for_num + sql = "select * from (" * for_num sql += "select * from ( select * from ( select " - sql += "%s, " % random.choice(s_s_select) - sql += "%s, " % random.choice(qt_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(q_where) + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.qt_select) + sql += "ts as tss from stable_1 where " + sql += "%s " % random.choice(self.q_where) sql += ")) " - sql += ")" * for_num - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + sql += ")" * for_num + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + sql2 = "select * from ( select * from ( select " - sql2 += "%s, " % random.choice(s_s_select) - sql2 += "%s, " % random.choice(qt_select) - sql2 += "ts from stable_1 where " - sql2 += "%s " % random.choice(q_where) - sql2 += ")) " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + sql2 += "%s, " % random.choice(self.s_s_select) + sql2 += "%s, " % random.choice(self.qt_select) + sql2 += "ts as tst from stable_1 where " + sql2 += "%s " % random.choice(self.q_where) + sql2 += ")) " + tdLog.info(sql2) + tdLog.info(len(sql2)) + tdSql.query(sql2) + self.cur1.execute(sql2) + self.explain_sql(sql2) + self.data_matrix_equal('%s' %sql ,1,10,3,3,'%s' %sql2 ,1,10,3,3) - + + tdLog.info("=====2-1==over=========") + for i in range(self.fornum): for_num = random.randint(1, 15); - sql = "select ts from (" * for_num + sql = "select tsn from (" * for_num sql += "select * from ( select * from ( select " - sql += "%s, " % random.choice(s_s_select) - sql += "%s, " % random.choice(qt_select) - sql += "ts from stable_1 where " - sql += "%s " % random.choice(q_where) + sql += "%s, " % random.choice(self.s_s_select) + sql += "%s, " % random.choice(self.qt_select) + sql += "ts as tsn from stable_1 where " + sql += "%s " % random.choice(self.q_where) sql += ")) " - sql += ")" * for_num - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - - sql2 = "select ts from ( select * from ( select " - sql2 += "%s, " % random.choice(s_s_select) - sql2 += "%s, " % random.choice(qt_select) - sql2 += "ts from stable_1 where " - sql2 += "%s " % random.choice(q_where) - sql2 += ")) " - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.query(sql) - + sql += ")" * for_num + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + sql2 = "select ts1 from ( select * from ( select " + sql2 += "%s, " % random.choice(self.s_s_select) + sql2 += "%s, " % random.choice(self.qt_select) + sql2 += "ts as ts1 from stable_1 where " + sql2 += "%s " % random.choice(self.q_where) + sql2 += ")) " + tdLog.info(sql2) + tdLog.info(len(sql2)) + tdSql.query(sql2) + self.cur1.execute(sql2) + self.explain_sql(sql2) + self.data_matrix_equal('%s' %sql ,1,10,1,1,'%s' %sql2 ,1,10,1,1) - - #3 select ts ,calc from (select * form stable where <\>\in\and\or order by limit ) + tdLog.info("=====2-2==over=========") + + #3 select ts ,calc from (select * form stable where <\>\in\and\or order by limit ) #self.dropandcreateDB_random("%s" %db, 1) tdSql.query("select 3-1 from stable_1;") for i in range(self.fornum): sql = "select " - sql += "%s " % random.choice(calc_calculate_regular) + sql += "%s " % random.choice(self.calc_calculate_regular) sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(orders_desc_where) - sql += "%s " % random.choice(limit_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.orders_desc_where) + sql += "%s " % random.choice(self.limit_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - #'Invalid function name: derivative' tdSql.query(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) #4 select * from (select calc form stable where <\>\in\and\or order by limit ) tdSql.query("select 4-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select " - sql += "%s " % random.choice(calc_select_in_ts) + sql += "%s " % random.choice(self.calc_select_in_ts) sql += "from stable_1 where " - sql += "%s " % random.choice(qt_where) - #sql += "%s " % random.choice(order_desc_where) - sql += "%s " % random.choice(limit_where) + sql += "%s " % random.choice(self.qt_where) + #sql += "%s " % random.choice(self.order_desc_where) + sql += "%s " % random.choice(self.limit_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) + tdLog.info(sql) + tdLog.info(len(sql)) tdSql.query(sql) - + self.cur1.execute(sql) + self.explain_sql(sql) + #5 select ts ,tbname from (select * form stable where <\>\in\and\or order by limit ) tdSql.query("select 5-1 from stable_1;") for i in range(self.fornum): sql = "select ts , tbname , " - sql += "%s ," % random.choice(calc_calculate_regular) - sql += "%s ," % random.choice(dqt_select) - sql += "%s " % random.choice(qt_select) + sql += "%s ," % random.choice(self.calc_calculate_regular) + sql += "%s ," % random.choice(self.dqt_select) + sql += "%s " % random.choice(self.qt_select) sql += " from ( select * from stable_1 where " - sql += "%s " % random.choice(qt_where) - sql += "%s " % random.choice(orders_desc_where) - sql += "%s " % random.choice(limit_where) + sql += "%s " % random.choice(self.qt_where) + sql += "%s " % random.choice(self.orders_desc_where) + sql += "%s " % random.choice(self.limit_where) sql += ") ;" - tdLog.info(sql) - tdLog.info(len(sql)) - tdSql.error(sql) + tdLog.info(sql) + tdLog.info(len(sql)) + tdSql.error(sql) #special sql tdSql.query("select 6-1 from stable_1;") for i in range(self.fornum): sql = "select * from ( select _block_dist() from stable_1);" - # tdSql.query(sql) - # tdSql.checkRows(1) + tdSql.error(sql) sql = "select _block_dist() from (select * from stable_1);" tdSql.error(sql) sql = "select * from (select database());" - tdSql.error(sql) + tdLog.info(sql) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) sql = "select * from (select client_version());" - tdSql.error(sql) + tdLog.info(sql) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) sql = "select * from (select client_version() as version);" - tdSql.error(sql) + tdLog.info(sql) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) sql = "select * from (select server_version());" - tdSql.error(sql) + tdLog.info(sql) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) sql = "select * from (select server_version() as version);" - tdSql.error(sql) + tdLog.info(sql) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) sql = "select * from (select server_status());" - tdSql.error(sql) + tdLog.info(sql) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) sql = "select * from (select server_status() as status);" - tdSql.error(sql) + tdLog.info(sql) + tdSql.query(sql) + self.cur1.execute(sql) + self.explain_sql(sql) + + #taos -f sql + startTime_taos_f = time.time() + print("taos -f sql start!") + taos_cmd1 = "taos -f %s/%s.sql" % (self.testcasePath,self.testcaseFilename) + #_ = subprocess.check_output(taos_cmd1, shell=True).decode("utf-8") + _ = subprocess.check_output(taos_cmd1, shell=True) + print("taos -f sql over!") + endTime_taos_f = time.time() + print("taos_f total time %ds" % (endTime_taos_f - startTime_taos_f)) + print('=====================2.6 old function end ===========') + + + + def run(self): + tdSql.prepare() + + startTime = time.time() + + self.function_before_26() + + self.math_nest(['UNIQUE']) + self.math_nest(['MODE']) + self.math_nest(['SAMPLE']) + + # self.math_nest(['ABS','SQRT']) + # self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN']) + # self.math_nest(['POW','LOG']) + # self.math_nest(['FLOOR','CEIL','ROUND']) + # self.math_nest(['MAVG']) + # self.math_nest(['HYPERLOGLOG']) + # self.math_nest(['TAIL']) + # self.math_nest(['CSUM']) + # self.math_nest(['statecount','stateduration']) + # self.math_nest(['HISTOGRAM']) + + # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) + # self.str_nest(['LENGTH','CHAR_LENGTH']) + # self.str_nest(['SUBSTR']) + # self.str_nest(['CONCAT']) + # self.str_nest(['CONCAT_WS']) + # self.time_nest(['CAST']) #放到time里起来弄 + # self.time_nest(['CAST_1']) + # self.time_nest(['CAST_2']) + # self.time_nest(['CAST_3']) + # self.time_nest(['CAST_4']) + + + + # self.time_nest(['NOW','TODAY']) + # self.time_nest(['TIMEZONE']) + # self.time_nest(['TIMETRUNCATE']) + # self.time_nest(['TO_ISO8601']) + # self.time_nest(['TO_UNIXTIMESTAMP']) + # self.time_nest(['ELAPSED']) + self.time_nest(['TIMEDIFF_1']) + self.time_nest(['TIMEDIFF_2']) + endTime = time.time() print("total time %ds" % (endTime - startTime)) - + def stop(self): From 2b641af4b8c930687c0f7107acad30d7a72e9f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chappyguoxy=E2=80=9D?= <“happy_guoxy@163.com”> Date: Mon, 24 Oct 2022 11:25:34 +0800 Subject: [PATCH 22/72] test: refine query cases --- tests/system-test/2-query/nestedQuery_math.py | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 tests/system-test/2-query/nestedQuery_math.py diff --git a/tests/system-test/2-query/nestedQuery_math.py b/tests/system-test/2-query/nestedQuery_math.py new file mode 100755 index 0000000000..2d0bbcb352 --- /dev/null +++ b/tests/system-test/2-query/nestedQuery_math.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from util.cases import tdCases +from .nestedQuery import * + +class TDTestCase(TDTestCase): + + + def run(self): + tdSql.prepare() + + startTime = time.time() + + #self.function_before_26() + + # self.math_nest(['UNIQUE']) + # self.math_nest(['MODE']) + # self.math_nest(['SAMPLE']) + + self.math_nest(['ABS','SQRT']) + self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN']) + self.math_nest(['POW','LOG']) + self.math_nest(['FLOOR','CEIL','ROUND']) + self.math_nest(['MAVG']) + self.math_nest(['HYPERLOGLOG']) + self.math_nest(['TAIL']) + self.math_nest(['CSUM']) + self.math_nest(['statecount','stateduration']) + self.math_nest(['HISTOGRAM']) + + # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) + # self.str_nest(['LENGTH','CHAR_LENGTH']) + # self.str_nest(['SUBSTR']) + # self.str_nest(['CONCAT']) + # self.str_nest(['CONCAT_WS']) + # self.time_nest(['CAST']) #放到time里起来弄 + # self.time_nest(['CAST_1']) + # self.time_nest(['CAST_2']) + # self.time_nest(['CAST_3']) + # self.time_nest(['CAST_4']) + + + + # self.time_nest(['NOW','TODAY']) + # self.time_nest(['TIMEZONE']) + # self.time_nest(['TIMETRUNCATE']) + # self.time_nest(['TO_ISO8601']) + # self.time_nest(['TO_UNIXTIMESTAMP']) + # self.time_nest(['ELAPSED']) + # self.time_nest(['TIMEDIFF_1']) + # self.time_nest(['TIMEDIFF_2']) + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From ec786b9d78669ddde356e76c8f5bdba995feb14d Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 24 Oct 2022 11:57:26 +0800 Subject: [PATCH 23/72] fix: alter replica one by one --- source/dnode/mnode/impl/src/mndSync.c | 20 +++++++---- source/dnode/mnode/impl/src/mndVgroup.c | 1 + source/dnode/vnode/src/vnd/vnodeCommit.c | 2 +- source/dnode/vnode/src/vnd/vnodeOpen.c | 7 ++++ source/dnode/vnode/src/vnd/vnodeSync.c | 33 +++++++++++------- source/libs/sync/src/syncMain.c | 44 ++++++++++++++---------- 6 files changed, 70 insertions(+), 37 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index cd6fe380e1..df4b526775 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -204,13 +204,21 @@ int32_t mndInitSync(SMnode *pMnode) { taosInitRWLatch(&pMgmt->lock); pMgmt->transId = 0; - SSyncInfo syncInfo = {.vgId = 1, .FpSendMsg = mndSyncSendMsg, .FpEqMsg = mndSyncEqMsg}; - snprintf(syncInfo.path, sizeof(syncInfo.path), "%s%ssync", pMnode->path, TD_DIRSEP); - syncInfo.pWal = pMnode->pWal; - syncInfo.pFsm = mndSyncMakeFsm(pMnode); - syncInfo.snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT; + SSyncInfo syncInfo = { + .snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT, + .batchSize = 1, + .vgId = 1, + .pWal = pMnode->pWal, + .msgcb = NULL, + .FpSendMsg = mndSyncSendMsg, + .FpEqMsg = mndSyncEqMsg, + .FpEqCtrlMsg = NULL, + }; - mInfo("vgId:1, start to open sync, selfIndex:%d replica:%d", pMgmt->selfIndex, pMgmt->numOfReplicas); + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s%ssync", pMnode->path, TD_DIRSEP); + syncInfo.pFsm = mndSyncMakeFsm(pMnode); + + mInfo("vgId:1, start to open sync, replica:%d selfIndex:%d", pMgmt->numOfReplicas, pMgmt->selfIndex); SSyncCfg *pCfg = &syncInfo.syncCfg; pCfg->replicaNum = pMgmt->numOfReplicas; pCfg->myIndex = pMgmt->selfIndex; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 9bd89c1983..3f2c6ac2a8 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1600,6 +1600,7 @@ int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del1) != 0) return -1; if (mndRemoveVnodeFromVgroup(pMnode, &newVgroup, pArray, &del2) != 0) return -1; if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del1, true) != 0) return -1; + if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del2, true) != 0) return -1; if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0) return -1; diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 63a576f1a2..e593bbd602 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -107,7 +107,7 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) { // free info binary taosMemoryFree(data); - vInfo("vgId:%d, vnode info is saved, fname:%s", pInfo->config.vgId, fname); + vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d", pInfo->config.vgId, fname, pInfo->config.syncCfg.replicaNum); return 0; diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 57fdb77533..0696ec0901 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -87,12 +87,19 @@ int32_t vnodeAlter(const char *path, SAlterVnodeReplicaReq *pReq, STfs *pTfs) { vInfo("vgId:%d, save config, replica:%d ep:%s:%u", pReq->vgId, i, pNode->nodeFqdn, pNode->nodePort); } + info.config.syncCfg = *pCfg; ret = vnodeSaveInfo(dir, &info); if (ret < 0) { vError("vgId:%d, failed to save vnode config since %s", pReq->vgId, tstrerror(terrno)); return -1; } + ret = vnodeCommitInfo(dir, &info); + if (ret < 0) { + vError("vgId:%d, failed to commit vnode config since %s", pReq->vgId, tstrerror(terrno)); + return -1; + } + vInfo("vgId:%d, vnode config is saved", info.config.vgId); return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 1863203f4a..d3ae1015d0 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -563,9 +563,7 @@ static int32_t vnodeSnapshotDoWrite(struct SSyncFSM *pFsm, void *pWriter, void * #endif } -static void vnodeLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) { - SVnode *pVnode = pFsm->data; -} +static void vnodeLeaderTransfer(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbMeta) {} static void vnodeRestoreFinish(struct SSyncFSM *pFsm) { SVnode *pVnode = pFsm->data; @@ -605,12 +603,14 @@ static void vnodeBecomeLeader(struct SSyncFSM *pFsm) { SVnode *pVnode = pFsm->data; vDebug("vgId:%d, become leader", pVnode->config.vgId); - // taosThreadMutexLock(&pVnode->lock); - // if (pVnode->blocked) { - // pVnode->blocked = false; - // tsem_post(&pVnode->syncSem); - // } - // taosThreadMutexUnlock(&pVnode->lock); +#if 0 + taosThreadMutexLock(&pVnode->lock); + if (pVnode->blocked) { + pVnode->blocked = false; + tsem_post(&pVnode->syncSem); + } + taosThreadMutexUnlock(&pVnode->lock); +#endif } static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { @@ -638,10 +638,8 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { SSyncInfo syncInfo = { .snapshotStrategy = SYNC_STRATEGY_WAL_FIRST, - //.snapshotStrategy = SYNC_STRATEGY_NO_SNAPSHOT, .batchSize = 1, .vgId = pVnode->config.vgId, - .isStandBy = pVnode->config.standby, .syncCfg = pVnode->config.syncCfg, .pWal = pVnode->pWal, .msgcb = NULL, @@ -653,6 +651,13 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { snprintf(syncInfo.path, sizeof(syncInfo.path), "%s%ssync", path, TD_DIRSEP); syncInfo.pFsm = vnodeSyncMakeFsm(pVnode); + SSyncCfg *pCfg = &syncInfo.syncCfg; + vInfo("vgId:%d, start to open sync, replica:%d selfIndex:%d", pVnode->config.vgId, pCfg->replicaNum, pCfg->myIndex); + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + SNodeInfo *pNode = &pCfg->nodeInfo[i]; + vInfo("vgId:%d, index:%d ep:%s:%u", pVnode->config.vgId, i, pNode->nodeFqdn, pNode->nodePort); + } + pVnode->sync = syncOpen(&syncInfo); if (pVnode->sync <= 0) { vError("vgId:%d, failed to open sync since %s", pVnode->config.vgId, terrstr()); @@ -666,11 +671,15 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { } void vnodeSyncStart(SVnode *pVnode) { + vDebug("vgId:%d, start sync", pVnode->config.vgId); syncSetMsgCb(pVnode->sync, &pVnode->msgCb); syncStart(pVnode->sync); } -void vnodeSyncClose(SVnode *pVnode) { syncStop(pVnode->sync); } +void vnodeSyncClose(SVnode *pVnode) { + vDebug("vgId:%d, close sync", pVnode->config.vgId); + syncStop(pVnode->sync); +} bool vnodeIsRoleLeader(SVnode *pVnode) { return syncGetMyRole(pVnode->sync) == TAOS_SYNC_STATE_LEADER; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 00c4ea76aa..b350f0925e 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -90,7 +90,7 @@ void syncCleanUp() { int64_t syncOpen(SSyncInfo* pSyncInfo) { SSyncNode* pSyncNode = syncNodeOpen(pSyncInfo); if (pSyncNode == NULL) { - sError("failed to open sync node. vgId:%d", pSyncInfo->vgId); + sError("vgId:%d, failed to open sync node", pSyncInfo->vgId); return -1; } @@ -106,7 +106,7 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) { } void syncStart(int64_t rid) { - SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { return; } @@ -121,7 +121,7 @@ void syncStart(int64_t rid) { } void syncStartNormal(int64_t rid) { - SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { return; } @@ -131,7 +131,7 @@ void syncStartNormal(int64_t rid) { } void syncStartStandBy(int64_t rid) { - SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { return; } @@ -141,7 +141,7 @@ void syncStartStandBy(int64_t rid) { } void syncStop(int64_t rid) { - SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) return; int32_t vgId = pSyncNode->vgId; taosReleaseRef(tsNodeRefId, pSyncNode->rid); @@ -151,7 +151,7 @@ void syncStop(int64_t rid) { } int32_t syncSetStandby(int64_t rid) { - SSyncNode* pSyncNode = (SSyncNode*)taosAcquireRef(tsNodeRefId, rid); + SSyncNode* pSyncNode = taosAcquireRef(tsNodeRefId, rid); if (pSyncNode == NULL) { terrno = TSDB_CODE_SYN_INTERNAL_ERROR; sError("failed to set standby since accquire ref error, rid:%" PRId64, rid); @@ -1089,17 +1089,13 @@ int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { return ret; } -// open/close -------------- -SSyncNode* syncNodeOpen(SSyncInfo* pOldSyncInfo) { - SSyncInfo* pSyncInfo = (SSyncInfo*)pOldSyncInfo; - - SSyncNode* pSyncNode = (SSyncNode*)taosMemoryCalloc(1, sizeof(SSyncNode)); +SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { + SSyncNode* pSyncNode = taosMemoryCalloc(1, sizeof(SSyncNode)); if (pSyncNode == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto _error; } - int32_t ret = 0; if (!taosDirExist((char*)(pSyncInfo->path))) { if (taosMkDir(pSyncInfo->path) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); @@ -1111,32 +1107,44 @@ SSyncNode* syncNodeOpen(SSyncInfo* pOldSyncInfo) { snprintf(pSyncNode->configPath, sizeof(pSyncNode->configPath), "%s%sraft_config.json", pSyncInfo->path, TD_DIRSEP); if (!taosCheckExistFile(pSyncNode->configPath)) { // create a new raft config file - SRaftCfgMeta meta; + SRaftCfgMeta meta = {0}; meta.isStandBy = pSyncInfo->isStandBy; meta.snapshotStrategy = pSyncInfo->snapshotStrategy; meta.lastConfigIndex = SYNC_INDEX_INVALID; meta.batchSize = pSyncInfo->batchSize; - ret = raftCfgCreateFile((SSyncCfg*)&(pSyncInfo->syncCfg), meta, pSyncNode->configPath); - if (ret != 0) { - sError("failed to create raft cfg file. configPath: %s", pSyncNode->configPath); + if (raftCfgCreateFile(&pSyncInfo->syncCfg, meta, pSyncNode->configPath) != 0) { + sError("vgId:%d, failed to create raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); goto _error; } if (pSyncInfo->syncCfg.replicaNum == 0) { + sInfo("vgId:%d, sync config not input", pSyncNode->vgId); pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; } } else { // update syncCfg by raft_config.json pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); if (pSyncNode->pRaftCfg == NULL) { - sError("failed to open raft cfg file. path:%s", pSyncNode->configPath); + sError("vgId:%d, failed to open raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); goto _error; } - pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; + if (pSyncInfo->syncCfg.replicaNum > 0 && pSyncInfo->syncCfg.replicaNum != pSyncNode->pRaftCfg->cfg.replicaNum) { + sInfo("vgId:%d, use sync config from input options", pSyncNode->vgId); + } else { + sInfo("vgId:%d, use sync config from raft cfg file", pSyncNode->vgId); + pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; + } raftCfgClose(pSyncNode->pRaftCfg); pSyncNode->pRaftCfg = NULL; } + SSyncCfg* pCfg = &pSyncInfo->syncCfg; + sDebug("vgId:%d, replica:%d selfIndex:%d", pSyncNode->vgId, pCfg->replicaNum, pCfg->myIndex); + for (int32_t i = 0; i < pCfg->replicaNum; ++i) { + SNodeInfo* pNode = &pCfg->nodeInfo[i]; + sDebug("vgId:%d, index:%d ep:%s:%u", pSyncNode->vgId, i, pNode->nodeFqdn, pNode->nodePort); + } + // init by SSyncInfo pSyncNode->vgId = pSyncInfo->vgId; memcpy(pSyncNode->path, pSyncInfo->path, sizeof(pSyncNode->path)); From 6d1bf00ceeff646ce1f7043c60d4acd8a2ebe826 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 24 Oct 2022 12:42:18 +0800 Subject: [PATCH 24/72] fix: use sync cfg from vnode --- source/libs/sync/src/syncMain.c | 33 +++++++++++++---------- source/libs/sync/src/syncRaftCfg.c | 2 -- tests/script/tsim/db/alter_replica_13.sim | 2 +- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index b350f0925e..fd2a1b22b4 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -1128,7 +1128,12 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { goto _error; } if (pSyncInfo->syncCfg.replicaNum > 0 && pSyncInfo->syncCfg.replicaNum != pSyncNode->pRaftCfg->cfg.replicaNum) { - sInfo("vgId:%d, use sync config from input options", pSyncNode->vgId); + sInfo("vgId:%d, use sync config from input options and write to cfg file", pSyncNode->vgId); + pSyncNode->pRaftCfg->cfg = pSyncInfo->syncCfg; + if (raftCfgPersist(pSyncNode->pRaftCfg) != 0) { + sError("vgId:%d, failed to persist raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); + goto _error; + } } else { sInfo("vgId:%d, use sync config from raft cfg file", pSyncNode->vgId); pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; @@ -1161,14 +1166,14 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { // init raft config pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); if (pSyncNode->pRaftCfg == NULL) { - sError("failed to open raft cfg file. path:%s", pSyncNode->configPath); + sError("vgId:%d, failed to open raft cfg file at %s", pSyncNode->vgId, pSyncNode->configPath); goto _error; } // init internal pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; if (!syncUtilnodeInfo2raftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)) { - sError("failed to determine my raft member id. vgId:%d", pSyncNode->vgId); + sError("vgId:%d, failed to determine my raft member id", pSyncNode->vgId); goto _error; } @@ -1183,7 +1188,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { } for (int i = 0; i < pSyncNode->peersNum; ++i) { if (!syncUtilnodeInfo2raftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i])) { - sError("failed to determine raft member id. vgId:%d, peer:%d", pSyncNode->vgId, i); + sError("vgId:%d, failed to determine raft member id, peer:%d", pSyncNode->vgId, i); goto _error; } } @@ -1192,7 +1197,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { pSyncNode->replicaNum = pSyncNode->pRaftCfg->cfg.replicaNum; for (int i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { if (!syncUtilnodeInfo2raftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { - sError("failed to determine raft member id. vgId:%d, replica:%d", pSyncNode->vgId, i); + sError("vgId:%d, failed to determine raft member id, replica:%d", pSyncNode->vgId, i); goto _error; } } @@ -1233,38 +1238,38 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; pSyncNode->pRaftStore = raftStoreOpen(pSyncNode->raftStorePath); if (pSyncNode->pRaftStore == NULL) { - sError("failed to open raft store. path: %s", pSyncNode->raftStorePath); + sError("vgId:%d, failed to open raft store at path %s", pSyncNode->vgId, pSyncNode->raftStorePath); goto _error; } // init TLA+ candidate vars pSyncNode->pVotesGranted = voteGrantedCreate(pSyncNode); if (pSyncNode->pVotesGranted == NULL) { - sError("failed to create VotesGranted. vgId:%d", pSyncNode->vgId); + sError("vgId:%d, failed to create VotesGranted", pSyncNode->vgId); goto _error; } pSyncNode->pVotesRespond = votesRespondCreate(pSyncNode); if (pSyncNode->pVotesRespond == NULL) { - sError("failed to create VotesRespond. vgId:%d", pSyncNode->vgId); + sError("vgId:%d, failed to create VotesRespond", pSyncNode->vgId); goto _error; } // init TLA+ leader vars pSyncNode->pNextIndex = syncIndexMgrCreate(pSyncNode); if (pSyncNode->pNextIndex == NULL) { - sError("failed to create SyncIndexMgr. vgId:%d", pSyncNode->vgId); + sError("vgId:%d, failed to create SyncIndexMgr", pSyncNode->vgId); goto _error; } pSyncNode->pMatchIndex = syncIndexMgrCreate(pSyncNode); if (pSyncNode->pMatchIndex == NULL) { - sError("failed to create SyncIndexMgr. vgId:%d", pSyncNode->vgId); + sError("vgId:%d, failed to create SyncIndexMgr", pSyncNode->vgId); goto _error; } // init TLA+ log vars pSyncNode->pLogStore = logStoreCreate(pSyncNode); if (pSyncNode->pLogStore == NULL) { - sError("failed to create SyncLogStore. vgId:%d", pSyncNode->vgId); + sError("vgId:%d, failed to create SyncLogStore", pSyncNode->vgId); goto _error; } @@ -1273,7 +1278,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { SSnapshot snapshot = {0}; int32_t code = pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); if (code != 0) { - sError("failed to get snapshot info. vgId:%d, code:%d", pSyncNode->vgId, code); + sError("vgId:%d, failed to get snapshot info, code:%d", pSyncNode->vgId, code); goto _error; } if (snapshot.lastApplyIndex > commitIndex) { @@ -1332,7 +1337,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { // tools pSyncNode->pSyncRespMgr = syncRespMgrCreate(pSyncNode, SYNC_RESP_TTL_MS); if (pSyncNode->pSyncRespMgr == NULL) { - sError("failed to create SyncRespMgr. vgId:%d", pSyncNode->vgId); + sError("vgId:%d, failed to create SyncRespMgr", pSyncNode->vgId); goto _error; } @@ -2854,7 +2859,7 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) { return; } - //syncNodeEventLog(pSyncNode, "eq peer hb timer"); + // syncNodeEventLog(pSyncNode, "eq peer hb timer"); int64_t timerLogicClock = atomic_load_64(&pSyncTimer->logicClock); int64_t msgLogicClock = atomic_load_64(&pData->logicClock); diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index bac4825c50..7c8f503de6 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -355,8 +355,6 @@ char *raftCfg2Str(SRaftCfg *pRaftCfg) { } int32_t raftCfgCreateFile(SSyncCfg *pCfg, SRaftCfgMeta meta, const char *path) { - ASSERT(pCfg != NULL); - TdFilePtr pFile = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE); if (pFile == NULL) { int32_t err = terrno; diff --git a/tests/script/tsim/db/alter_replica_13.sim b/tests/script/tsim/db/alter_replica_13.sim index ab4f349002..007bb00f07 100644 --- a/tests/script/tsim/db/alter_replica_13.sim +++ b/tests/script/tsim/db/alter_replica_13.sim @@ -129,7 +129,7 @@ endi print ============= step5: result $i = 0 -while $i < 1000 +while $i < 10 $i = $i + 1 sleep 1000 From 826dbafdce317b0742540ee7674b9a010c8358f4 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 24 Oct 2022 12:44:56 +0800 Subject: [PATCH 25/72] test: restore unsupport case --- tests/script/jenkins/basic.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index e07ec54182..72e6c0f705 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -9,8 +9,8 @@ # ---- db ---- ./test.sh -f tsim/db/alter_option.sim -# unsupport ./test.sh -f tsim/db/alter_replica_13.sim -# unsupport ./test.sh -f tsim/db/alter_replica_31.sim +./test.sh -f tsim/db/alter_replica_13.sim +./test.sh -f tsim/db/alter_replica_31.sim ./test.sh -f tsim/db/basic1.sim ./test.sh -f tsim/db/basic2.sim ./test.sh -f tsim/db/basic3.sim From 309fecba8771c692c7a5d1c19a72b0671062f095 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 24 Oct 2022 12:45:31 +0800 Subject: [PATCH 26/72] fix sys idx bug --- tests/script/jenkins/basic.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index e07ec54182..e92b50ce85 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -298,6 +298,7 @@ ./test.sh -f tsim/stable/tag_rename.sim ./test.sh -f tsim/stable/values.sim ./test.sh -f tsim/stable/vnode3.sim +./test.sh -f tsim/stable/metrics_idx.sim # --- sma ./test.sh -f tsim/sma/drop_sma.sim From 2f5ed16cb801fee91709c203656c6e42bcdafb7b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 24 Oct 2022 13:26:54 +0800 Subject: [PATCH 27/72] fix(query): remove redundant ts cols in cache scan. --- source/dnode/vnode/src/tsdb/tsdbCacheRead.c | 11 +++- source/libs/executor/inc/executorimpl.h | 3 +- source/libs/executor/src/cachescanoperator.c | 61 ++++++++++++++----- source/libs/executor/src/executorimpl.c | 11 ++-- source/libs/executor/src/groupoperator.c | 6 +- source/libs/executor/src/joinoperator.c | 2 +- source/libs/executor/src/projectoperator.c | 4 +- source/libs/executor/src/scanoperator.c | 19 +++--- source/libs/executor/src/sortoperator.c | 6 +- source/libs/executor/src/tfill.c | 2 +- source/libs/executor/src/timewindowoperator.c | 25 ++++---- 11 files changed, 89 insertions(+), 61 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index 83dcbc60c7..905150cab0 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -37,6 +37,8 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea int32_t numOfRows = pBlock->info.rows; if (HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST)) { + bool allNullRow = true; + for (int32_t i = 0; i < pReader->numOfCols; ++i) { SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); SFirstLastRes* p = (SFirstLastRes*)varDataVal(pRes[i]); @@ -46,12 +48,15 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea p->ts = pColVal->ts; p->bytes = TSDB_KEYSIZE; *(int64_t*)p->buf = pColVal->ts; + allNullRow = false; } else { int32_t slotId = slotIds[i]; SLastCol* pColVal = (SLastCol*)taosArrayGet(pRow, slotId); p->ts = pColVal->ts; p->isNull = !COL_VAL_IS_VALUE(&pColVal->colVal); + allNullRow = p->isNull & allNullRow; + if (!p->isNull) { if (IS_VAR_DATA_TYPE(pColVal->colVal.type)) { varDataSetLen(p->buf, pColVal->colVal.value.nData); @@ -69,6 +74,8 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea varDataSetLen(pRes[i], pColInfoData->info.bytes - VARSTR_HEADER_SIZE); colDataAppend(pColInfoData, numOfRows, (const char*)pRes[i], false); } + + pBlock->info.rows += allNullRow? 0:1; } else { ASSERT(HASTYPE(pReader->type, CACHESCAN_RETRIEVE_LAST_ROW)); @@ -96,9 +103,9 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea } } } - } - pBlock->info.rows += 1; + pBlock->info.rows += 1; + } } int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, SArray* pTableIdList, int32_t numOfCols, void** pReader) { diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 0237f64ecb..0aab75c655 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -889,8 +889,7 @@ typedef struct SJoinOperatorInfo { void doDestroyExchangeOperatorInfo(void* param); SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn, - __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode, - __optr_decode_fn_t decode, __optr_explain_fn_t explain); + __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_explain_fn_t explain); int32_t operatorDummyOpenFn(SOperatorInfo* pOperator); int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num); diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index 8c76a3f69b..00a338cc41 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -27,7 +27,8 @@ static SSDataBlock* doScanCache(SOperatorInfo* pOperator); static void destroyLastrowScanOperator(void* param); -static int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds); +static int32_t extractCacheScanSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds); +static SArray* removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SArray* pColMatchInfo); SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) { @@ -40,12 +41,15 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe } pInfo->readHandle = *readHandle; - pInfo->pRes = createResDataBlock(pScanNode->scan.node.pOutputDataBlockDesc); + + SDataBlockDescNode* pDescNode = pScanNode->scan.node.pOutputDataBlockDesc; + pInfo->pRes = createResDataBlock(pDescNode); int32_t numOfCols = 0; - pInfo->pColMatchInfo = extractColMatchInfo(pScanNode->scan.pScanCols, pScanNode->scan.node.pOutputDataBlockDesc, - &numOfCols, COL_MATCH_FROM_COL_ID); - code = extractTargetSlotId(pInfo->pColMatchInfo, pTaskInfo, &pInfo->pSlotIds); + SArray* pColMatchInfo = extractColMatchInfo(pScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID); + pInfo->pColMatchInfo = removeRedundantTsCol(pScanNode, pColMatchInfo); + + code = extractCacheScanSlotId(pInfo->pColMatchInfo, pTaskInfo, &pInfo->pSlotIds); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -72,11 +76,9 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe } if (pScanNode->scan.pScanPseudoCols != NULL) { - SExprSupp* pPseudoExpr = &pInfo->pseudoExprSup; - - pPseudoExpr->pExprInfo = createExprInfo(pScanNode->scan.pScanPseudoCols, NULL, &pPseudoExpr->numOfExprs); - pPseudoExpr->pCtx = - createSqlFunctionCtx(pPseudoExpr->pExprInfo, pPseudoExpr->numOfExprs, &pPseudoExpr->rowEntryInfoOffset); + SExprSupp* p = &pInfo->pseudoExprSup; + p->pExprInfo = createExprInfo(pScanNode->scan.pScanPseudoCols, NULL, &p->numOfExprs); + p->pCtx = createSqlFunctionCtx(p->pExprInfo, p->numOfExprs, &p->rowEntryInfoOffset); } pOperator->name = "LastrowScanOperator"; @@ -88,7 +90,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doScanCache, NULL, NULL, destroyLastrowScanOperator, NULL, NULL, NULL); + createOperatorFpSet(operatorDummyOpenFn, doScanCache, NULL, NULL, destroyLastrowScanOperator, NULL); pOperator->cost.openCost = 0; return pOperator; @@ -130,7 +132,9 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { // check for tag values int32_t resultRows = pInfo->pBufferredRes->info.rows; - ASSERT(resultRows == taosArrayGetSize(pInfo->pUidList)); + + // the results may be null, if last values are all null + ASSERT(resultRows == 0 || resultRows == taosArrayGetSize(pInfo->pUidList)); pInfo->indexOfBufferedRes = 0; } @@ -240,7 +244,7 @@ void destroyLastrowScanOperator(void* param) { taosMemoryFreeClear(param); } -int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds) { +int32_t extractCacheScanSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds) { size_t numOfCols = taosArrayGetSize(pColMatchInfo); *pSlotIds = taosMemoryMalloc(numOfCols * sizeof(int32_t)); @@ -248,16 +252,18 @@ int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInf return TSDB_CODE_OUT_OF_MEMORY; } + SSchemaWrapper* pWrapper = pTaskInfo->schemaInfo.sw; + for (int32_t i = 0; i < numOfCols; ++i) { SColMatchInfo* pColMatch = taosArrayGet(pColMatchInfo, i); - for (int32_t j = 0; j < pTaskInfo->schemaInfo.sw->nCols; ++j) { - if (pColMatch->colId == pTaskInfo->schemaInfo.sw->pSchema[j].colId && + for (int32_t j = 0; j < pWrapper->nCols; ++j) { + if (pColMatch->colId == pWrapper->pSchema[j].colId && pColMatch->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { (*pSlotIds)[pColMatch->targetSlotId] = -1; break; } - if (pColMatch->colId == pTaskInfo->schemaInfo.sw->pSchema[j].colId) { + if (pColMatch->colId == pWrapper->pSchema[j].colId) { (*pSlotIds)[pColMatch->targetSlotId] = j; break; } @@ -265,4 +271,27 @@ int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInf } return TSDB_CODE_SUCCESS; +} + +SArray* removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SArray* pColMatchInfo) { + if (!pScanNode->ignoreNull) { // retrieve cached last value + return pColMatchInfo; + } + + SArray* pMatchInfo = taosArrayInit(taosArrayGetSize(pColMatchInfo), sizeof(SColMatchInfo)); + + for (int32_t i = 0; i < taosArrayGetSize(pColMatchInfo); ++i) { + SColMatchInfo* pColInfo = taosArrayGet(pColMatchInfo, i); + + int32_t slotId = pColInfo->targetSlotId; + SNodeList* pList = pScanNode->scan.node.pOutputDataBlockDesc->pSlots; + + SSlotDescNode* pDesc = (SSlotDescNode*)nodesListGetNode(pList, slotId); + if (pDesc->dataType.type != TSDB_DATA_TYPE_TIMESTAMP) { + taosArrayPush(pMatchInfo, pColInfo); + } + } + + taosArrayDestroy(pColMatchInfo); + return pMatchInfo; } \ No newline at end of file diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index e55404935c..a1f7b700a4 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -110,16 +110,13 @@ int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) { } SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn, - __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode, - __optr_decode_fn_t decode, __optr_explain_fn_t explain) { + __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_explain_fn_t explain) { SOperatorFpSet fpSet = { ._openFn = openFn, .getNextFn = nextFn, .getStreamResFn = streamFn, .cleanupFn = cleanup, .closeFn = closeFn, - .encodeResultRow = encode, - .decodeResultRow = decode, .getExplainFn = explain, }; @@ -2305,7 +2302,7 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL, - destroyExchangeOperatorInfo, NULL, NULL, NULL); + destroyExchangeOperatorInfo, NULL); return pOperator; _error: @@ -3081,7 +3078,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, NULL, destroyAggOperatorInfo, - aggEncodeResultRow, aggDecodeResultRow, NULL); + NULL); if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { STableScanInfo* pTableScanInfo = downstream->info; @@ -3306,7 +3303,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroyFillOperatorInfo, NULL, NULL, NULL); + createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroyFillOperatorInfo, NULL); code = appendDownstream(pOperator, &downstream, 1); return pOperator; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 60794fc22a..644f02f60d 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -443,7 +443,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, hashGroupbyAggregate, NULL, NULL, - destroyGroupOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); + destroyGroupOperatorInfo, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -820,7 +820,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, hashPartition, NULL, NULL, destroyPartitionOperatorInfo, - NULL, NULL, NULL); + NULL); code = appendDownstream(pOperator, &downstream, 1); return pOperator; @@ -1095,7 +1095,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamHashPartition, NULL, NULL, - destroyStreamPartitionOperatorInfo, NULL, NULL, NULL); + destroyStreamPartitionOperatorInfo, NULL); initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup); code = appendDownstream(pOperator, &downstream, 1); diff --git a/source/libs/executor/src/joinoperator.c b/source/libs/executor/src/joinoperator.c index eab0307e01..8dac44684f 100644 --- a/source/libs/executor/src/joinoperator.c +++ b/source/libs/executor/src/joinoperator.c @@ -116,7 +116,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t } pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyMergeJoinOperator, NULL, NULL, NULL); + createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, NULL, destroyMergeJoinOperator, NULL); code = appendDownstream(pOperator, pDownstream, numOfDownstream); if (code != TSDB_CODE_SUCCESS) { goto _error; diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index 56fd6a99ef..b3ea7a5573 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -105,7 +105,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys pOperator->info = pInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL, NULL, - destroyProjectOperatorInfo, NULL, NULL, NULL); + destroyProjectOperatorInfo, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -405,7 +405,7 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy pOperator->info = pInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doApplyIndefinitFunction, NULL, NULL, - destroyIndefinitOperatorInfo, NULL, NULL, NULL); + destroyIndefinitOperatorInfo, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 4e1b07e662..5659b0354b 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -781,7 +781,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, NULL, destroyTableScanOperatorInfo, - NULL, NULL, getTableScannerExecInfo); + getTableScannerExecInfo); // for non-blocking operator, the open cost is always 0 pOperator->cost.openCost = 0; @@ -809,7 +809,7 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScanImpl, NULL, NULL, NULL, NULL, NULL, NULL); + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScanImpl, NULL, NULL, NULL, NULL); return pOperator; } @@ -930,7 +930,7 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* re pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, NULL, - destroyBlockDistScanOperatorInfo, NULL, NULL, NULL); + destroyBlockDistScanOperatorInfo, NULL); return pOperator; _error: @@ -2115,7 +2115,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, NULL, destroyRawScanOperatorInfo, NULL, NULL, NULL); + pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, NULL, destroyRawScanOperatorInfo, NULL); return pOperator; _end: @@ -2295,7 +2295,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys __optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan; pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, nextFn, NULL, NULL, destroyStreamScanOperatorInfo, NULL, NULL, NULL); + createOperatorFpSet(operatorDummyOpenFn, nextFn, NULL, NULL, destroyStreamScanOperatorInfo, NULL); return pOperator; @@ -3201,7 +3201,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doSysTableScan, NULL, NULL, destroySysScanOperator, NULL, NULL, NULL); + createOperatorFpSet(operatorDummyOpenFn, doSysTableScan, NULL, NULL, destroySysScanOperator, NULL); return pOperator; @@ -3338,7 +3338,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doTagScan, NULL, NULL, destroyTagScanOperatorInfo, NULL, NULL, NULL); + createOperatorFpSet(operatorDummyOpenFn, doTagScan, NULL, NULL, destroyTagScanOperatorInfo, NULL); return pOperator; @@ -3878,9 +3878,8 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN pOperator->pTaskInfo = pTaskInfo; initResultSizeInfo(&pOperator->resultInfo, 1024); - pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doTableMergeScan, NULL, NULL, destroyTableMergeScanOperatorInfo, NULL, - NULL, getTableMergeScanExplainExecInfo); + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableMergeScan, NULL, NULL, + destroyTableMergeScanOperatorInfo, getTableMergeScanExplainExecInfo); pOperator->cost.openCost = 0; return pOperator; diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index c00b5c4802..39987d4501 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -64,7 +64,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* // there are headers, so pageSize = rowSize + header pInfo->sortBufSize = pInfo->bufPageSize * 16; // TODO dynamic set the available sort buffer - pOperator->fpSet = createOperatorFpSet(doOpenSortOperator, doSort, NULL, NULL, destroyOrderOperatorInfo, NULL, NULL, + pOperator->fpSet = createOperatorFpSet(doOpenSortOperator, doSort, NULL, NULL, destroyOrderOperatorInfo, getExplainExecInfo); int32_t code = appendDownstream(pOperator, &downstream, 1); @@ -515,7 +515,7 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, NULL, destroyGroupSortOperatorInfo, - NULL, NULL, getGroupSortExplainExecInfo); + getGroupSortExplainExecInfo); int32_t code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -752,7 +752,7 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(doOpenMultiwayMergeOperator, doMultiwayMerge, NULL, NULL, - destroyMultiwayMergeOperatorInfo, NULL, NULL, getMultiwayMergeExplainExecInfo); + destroyMultiwayMergeOperatorInfo, getMultiwayMergeExplainExecInfo); code = appendDownstream(pOperator, downStreams, numStreams); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index d1d22dc3e5..99267e55e6 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -1694,7 +1694,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamFill, NULL, NULL, destroyStreamFillOperatorInfo, - NULL, NULL, NULL); + NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 6dda6488a0..8e5f03c4ac 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1831,8 +1831,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; - pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, NULL, - destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); + pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, NULL, destroyIntervalOperatorInfo, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -2638,8 +2637,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, NULL, destroyTimeSliceOperatorInfo, NULL, NULL, NULL); + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, NULL, destroyTimeSliceOperatorInfo, NULL); blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); @@ -2710,7 +2708,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi pOperator->info = pInfo; pOperator->fpSet = createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, NULL, - destroyStateWindowOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); + destroyStateWindowOperatorInfo, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -2784,7 +2782,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW pOperator->info = pInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, NULL, - destroySWindowOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); + destroySWindowOperatorInfo, NULL); pOperator->pTaskInfo = pTaskInfo; code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -3465,8 +3463,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pOperator->info = pInfo; pOperator->fpSet = - createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, NULL, destroyStreamFinalIntervalOperatorInfo, - aggEncodeResultRow, aggDecodeResultRow, NULL); + createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, NULL, destroyStreamFinalIntervalOperatorInfo, NULL); if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup); } @@ -4261,7 +4258,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh pOperator->info = pInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, NULL, destroyStreamSessionAggOperatorInfo, - aggEncodeResultRow, aggDecodeResultRow, NULL); + NULL); if (downstream) { initDownStream(downstream, &pInfo->streamAggSup, pInfo->twAggSup.waterMark, pOperator->operatorType, pInfo->primaryTsIndex); @@ -4408,7 +4405,7 @@ SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream pOperator->name = "StreamSessionSemiAggOperator"; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionSemiAgg, NULL, NULL, - destroyStreamSessionAggOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); + destroyStreamSessionAggOperatorInfo, NULL); } pInfo->pGroupIdTbNameMap = @@ -4777,7 +4774,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys pOperator->pTaskInfo = pTaskInfo; pOperator->info = pInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL, NULL, - destroyStreamStateOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); + destroyStreamStateOperatorInfo, NULL); initDownStream(downstream, &pInfo->streamAggSup, pInfo->twAggSup.waterMark, pOperator->operatorType, pInfo->primaryTsIndex); code = appendDownstream(pOperator, &downstream, 1); @@ -5054,7 +5051,7 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, pOperator->info = miaInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, mergeAlignedIntervalAgg, NULL, NULL, - destroyMAIOperatorInfo, NULL, NULL, NULL); + destroyMAIOperatorInfo, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -5366,7 +5363,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge pOperator->info = pMergeIntervalInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeIntervalAgg, NULL, NULL, - destroyMergeIntervalOperatorInfo, NULL, NULL, NULL); + destroyMergeIntervalOperatorInfo, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -5599,7 +5596,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys pOperator->info = pInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, NULL, destroyStreamFinalIntervalOperatorInfo, - aggEncodeResultRow, aggDecodeResultRow, NULL); + NULL); initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup); code = appendDownstream(pOperator, &downstream, 1); From 5cee271cbcaad23ec40e80e7f12cf731dad954e2 Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Mon, 24 Oct 2022 10:44:21 +0800 Subject: [PATCH 28/72] fix(stream): stream state invalid cur --- source/libs/stream/src/streamState.c | 9 +++-- tests/script/tsim/stream/state0.sim | 53 +++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 1c44af49b7..ea429a76b0 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -650,10 +650,10 @@ int32_t streamStateSessionGetKey(SStreamState* pState, const SSessionKey* key, S if (code == 0 && sessionKeyCmpr(key, &tmpKey) == 0) { res = 0; resKey = tmpKey; + streamStateCurPrev(pState, pCur); } else { break; } - streamStateCurPrev(pState, pCur); } *curKey = resKey; streamStateFreeCur(pCur); @@ -700,9 +700,14 @@ int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, ch memcpy(tmp, *pVal, valSize); goto _end; } + + streamStateCurNext(pState, pCur); + } else { + *key = tmpKey; + streamStateFreeCur(pCur); + pCur = streamStateSessionSeekKeyNext(pState, key); } - streamStateCurNext(pState, pCur); code = streamStateSessionGetKVByCur(pCur, key, (const void**)pVal, pVLen); if (code == 0) { void* stateKey = (char*)(*pVal) + (valSize - keyDataLen); diff --git a/tests/script/tsim/stream/state0.sim b/tests/script/tsim/stream/state0.sim index 60a50f9560..dc7d9bc407 100644 --- a/tests/script/tsim/stream/state0.sim +++ b/tests/script/tsim/stream/state0.sim @@ -449,12 +449,12 @@ if $data26 != 14 then return -1 endi -sql create database test1 vgroups 1 -sql select * from information_schema.ins_databases +sql create database test1 vgroups 1; +sql select * from information_schema.ins_databases; print $data00 $data01 $data02 -sql use test1 +sql use test1; sql create table t1(ts timestamp, a int, b int , c int, d double, id int); sql create stream streams2 trigger at_once into streamt1 as select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(a) c4, min(c) c5, max(id) c from t1 state_window(a); @@ -498,7 +498,50 @@ if $data15 != 3 then goto loop5 endi -sql drop database test; -sql drop database test1; +sql create database test3 vgroups 1; +sql use test3; + +sql create table t1(ts timestamp, a int, b int , c int, d double, id int); +sql create stream streams3 trigger at_once into streamt3 as select _wstart, count(*) c1, sum(b) c3 from t1 state_window(a); +sql insert into t1 values(1648791212000,1,2,3,1.0,1); +sql insert into t1 values(1648791213000,2,2,3,1.0,1); +sql insert into t1 values(1648791214000,3,2,4,1.0,2); +sql insert into t1 values(1648791215000,4,2,3,1.0,1); +sql insert into t1 values(1648791211000,5,2,3,1.0,1); +sql insert into t1 values(1648791210000,6,2,4,1.0,2); +sql insert into t1 values(1648791217000,7,2,3,1.0,1); +sql insert into t1 values(1648791219000,8,2,3,1.0,1); +sql insert into t1 values(1648791209000,9,2,4,1.0,2); +sql insert into t1 values(1648791220000,10,2,4,1.0,2); + +sql insert into t1 values(1648791212000,1,2,3,1.0,1); +sql insert into t1 values(1648791213000,2,2,3,1.0,1); +sql insert into t1 values(1648791214000,3,2,4,1.0,2); +sql insert into t1 values(1648791215000,4,2,3,1.0,1); +sql insert into t1 values(1648791211000,5,2,3,1.0,1); +sql insert into t1 values(1648791210000,6,2,4,1.0,2); +sql insert into t1 values(1648791217000,7,2,3,1.0,1); +sql insert into t1 values(1648791219000,8,2,3,1.0,1); +sql insert into t1 values(1648791209000,9,2,4,1.0,2); +sql insert into t1 values(1648791220000,10,2,4,1.0,2); + + +$loop_count = 0 +loop6: + +sleep 300 + +sql select * from streamt3; + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 10 then + print =====rows=$rows + goto loop6 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT From 9f722438d2d814e8954d02aeb930875ae6c69afb Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 24 Oct 2022 13:30:04 +0800 Subject: [PATCH 29/72] fix(query): remove redundant codes. --- source/libs/executor/src/tfill.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 99267e55e6..5d3f5e07d3 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -1624,7 +1624,6 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi goto _error; } - SResultInfo* pResultInfo = &pOperator->resultInfo; initResultSizeInfo(&pOperator->resultInfo, 4096); pInfo->pRes = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc); pInfo->pSrcBlock = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc); From a228d5ecb9f882a422ac548e612131c64e4db084 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 24 Oct 2022 14:09:12 +0800 Subject: [PATCH 30/72] fix(sync): break when pState is NULL --- source/libs/sync/src/syncMain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index fd2a1b22b4..dcc9e2ee2f 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -336,7 +336,9 @@ char* syncNodePeerState2Str(const SSyncNode* pSyncNode) { for (int32_t i = 0; i < pSyncNode->replicaNum; ++i) { SPeerState* pState = syncNodeGetPeerState((SSyncNode*)pSyncNode, &(pSyncNode->replicasId[i])); - ASSERT(pState != NULL); + if (pState == NULL) { + break; + } p = pStr + useLen; use = snprintf(p, leftLen, "%d:%" PRId64 " ,%" PRId64, i, pState->lastSendIndex, pState->lastSendTime); From f1dc1d63f7bcc2c48c61c2fe7e28f4150f5aa1e8 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 31/72] fix: coverity issues CID: 399714 --- source/common/src/tmsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 1f0023278f..94483b8a64 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5124,7 +5124,7 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) { char name[TSDB_COL_NAME_LEN] = {0}; char *tmp = NULL; if (tDecodeCStr(pCoder, &tmp) < 0) return -1; - strcpy(name, tmp); + strncpy(name, tmp, TSDB_COL_NAME_LEN - 1); taosArrayPush(pReq->ctb.tagName, name); } } else if (pReq->type == TSDB_NORMAL_TABLE) { From 10b4b68535c85afb2518120a03f31ac7adb698cc Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 24 Oct 2022 14:16:31 +0800 Subject: [PATCH 32/72] docs: fix conflict --- docs/zh/14-reference/12-config/index.md | 213 ++++++++++++------------ 1 file changed, 107 insertions(+), 106 deletions(-) diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index 7c4b6c0e31..74af793f9f 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -682,112 +682,113 @@ charset 的有效值是 UTF-8。 | 15 | telemetryPort | 否 | 是 | | | 16 | queryPolicy | 否 | 是 | | | 17 | querySmaOptimize | 否 | 是 | | -| 18 | queryBufferSize | 是 | 是 | | -| 19 | maxNumOfDistinctRes | 是 | 是 | | -| 20 | minSlidingTime | 是 | 是 | | -| 21 | minIntervalTime | 是 | 是 | | -| 22 | countAlwaysReturnValue | 是 | 是 | | -| 23 | dataDir | 是 | 是 | | -| 24 | minimalDataDirGB | 是 | 是 | | -| 25 | supportVnodes | 否 | 是 | | -| 26 | tempDir | 是 | 是 | | -| 27 | minimalTmpDirGB | 是 | 是 | | -| 28 | compressMsgSize | 是 | 是 | | -| 29 | compressColData | 是 | 是 | | -| 30 | smlChildTableName | 是 | 是 | | -| 31 | smlTagName | 是 | 是 | | -| 32 | smlDataFormat | 否 | 是 | | -| 33 | statusInterval | 是 | 是 | | -| 34 | shellActivityTimer | 是 | 是 | | -| 35 | transPullupInterval | 否 | 是 | | -| 36 | mqRebalanceInterval | 否 | 是 | | -| 37 | ttlUnit | 否 | 是 | | -| 38 | ttlPushInterval | 否 | 是 | | -| 39 | numOfTaskQueueThreads | 否 | 是 | | -| 40 | numOfRpcThreads | 否 | 是 | | -| 41 | numOfCommitThreads | 是 | 是 | | -| 42 | numOfMnodeReadThreads | 否 | 是 | | -| 43 | numOfVnodeQueryThreads | 否 | 是 | | -| 44 | numOfVnodeStreamThreads | 否 | 是 | | -| 45 | numOfVnodeFetchThreads | 否 | 是 | | -| 46 | numOfVnodeWriteThreads | 否 | 是 | | -| 47 | numOfVnodeSyncThreads | 否 | 是 | | -| 48 | numOfVnodeRsmaThreads | 否 | 是 | | -| 49 | numOfQnodeQueryThreads | 否 | 是 | | -| 50 | numOfQnodeFetchThreads | 否 | 是 | | -| 51 | numOfSnodeSharedThreads | 否 | 是 | | -| 52 | numOfSnodeUniqueThreads | 否 | 是 | | -| 53 | rpcQueueMemoryAllowed | 否 | 是 | | -| 54 | logDir | 是 | 是 | | -| 55 | minimalLogDirGB | 是 | 是 | | -| 56 | numOfLogLines | 是 | 是 | | -| 57 | asyncLog | 是 | 是 | | -| 58 | logKeepDays | 是 | 是 | | -| 59 | debugFlag | 是 | 是 | | -| 60 | tmrDebugFlag | 是 | 是 | | -| 61 | uDebugFlag | 是 | 是 | | -| 62 | rpcDebugFlag | 是 | 是 | | -| 63 | jniDebugFlag | 是 | 是 | | -| 64 | qDebugFlag | 是 | 是 | | -| 65 | cDebugFlag | 是 | 是 | | -| 66 | dDebugFlag | 是 | 是 | | -| 67 | vDebugFlag | 是 | 是 | | -| 68 | mDebugFlag | 是 | 是 | | -| 69 | wDebugFlag | 是 | 是 | | -| 70 | sDebugFlag | 是 | 是 | | -| 71 | tsdbDebugFlag | 是 | 是 | | -| 72 | tqDebugFlag | 否 | 是 | | -| 73 | fsDebugFlag | 是 | 是 | | -| 74 | udfDebugFlag | 否 | 是 | | -| 75 | smaDebugFlag | 否 | 是 | | -| 76 | idxDebugFlag | 否 | 是 | | -| 77 | tdbDebugFlag | 否 | 是 | | -| 78 | metaDebugFlag | 否 | 是 | | -| 79 | timezone | 是 | 是 | | -| 80 | locale | 是 | 是 | | -| 81 | charset | 是 | 是 | | -| 82 | udf | 是 | 是 | | -| 83 | enableCoreFile | 是 | 是 | | -| 84 | arbitrator | 是 | 否 | 通过 RAFT 协议选主 | -| 85 | numOfThreadsPerCore | 是 | 否 | 有其它参数设置多种线程池的大小 | -| 86 | numOfMnodes | 是 | 否 | 通过 create mnode 命令动态创建 mnode | -| 87 | vnodeBak | 是 | 否 | 3.0 行为未知 | -| 88 | balance | 是 | 否 | 负载均衡功能由 split/merge vgroups 实现 | -| 89 | balanceInterval | 是 | 否 | 随着 balance 参数失效 | -| 90 | offlineThreshold | 是 | 否 | 3.0 行为未知 | -| 91 | role | 是 | 否 | 由 supportVnode 决定是否能够创建 | -| 92 | dnodeNopLoop | 是 | 否 | 2.6 文档中未找到此参数 | -| 93 | keepTimeOffset | 是 | 否 | 2.6 文档中未找到此参数 | -| 94 | rpcTimer | 是 | 否 | 3.0 行为未知 | -| 95 | rpcMaxTime | 是 | 否 | 3.0 行为未知 | -| 96 | rpcForceTcp | 是 | 否 | 默认为 TCP | -| 97 | tcpConnTimeout | 是 | 否 | 3.0 行为未知 | -| 98 | syncCheckInterval | 是 | 否 | 3.0 行为未知 | -| 99 | maxTmrCtrl | 是 | 否 | 3.0 行为未知 | -| 100 | monitorReplica | 是 | 否 | 由 RAFT 协议管理多副本 | -| 101 | smlTagNullName | 是 | 否 | 3.0 行为未知 | -| 102 | keepColumnName | 是 | 否 | 3.0 行为未知 | -| 103 | ratioOfQueryCores | 是 | 否 | 由 线程池 相关配置参数决定 | -| 104 | maxStreamCompDelay | 是 | 否 | 3.0 行为未知 | -| 105 | maxFirstStreamCompDelay | 是 | 否 | 3.0 行为未知 | -| 106 | retryStreamCompDelay | 是 | 否 | 3.0 行为未知 | -| 107 | streamCompDelayRatio | 是 | 否 | 3.0 行为未知 | -| 108 | maxVgroupsPerDb | 是 | 否 | 由 create db 的参数 vgroups 指定实际 vgroups 数量 | -| 109 | maxTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | -| 110 | minTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | -| 111 | tableIncStepPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | -| 112 | cache | 是 | 否 | 由 buffer 代替 cache\*blocks | -| 113 | blocks | 是 | 否 | 由 buffer 代替 cache\*blocks | -| 114 | days | 是 | 否 | 由 create db 的参数 duration 取代 | -| 115 | keep | 是 | 否 | 由 create db 的参数 keep 取代 | -| 116 | minRows | 是 | 否 | 由 create db 的参数 minRows 取代 | -| 117 | maxRows | 是 | 否 | 由 create db 的参数 maxRows 取代 | -| 118 | quorum | 是 | 否 | 由 RAFT 协议决定 | -| 119 | comp | 是 | 否 | 由 create db 的参数 comp 取代 | -| 120 | walLevel | 是 | 否 | 由 create db 的参数 wal_level 取代 | -| 121 | fsync | 是 | 否 | 由 create db 的参数 wal_fsync_period 取代 | -| 122 | replica | 是 | 否 | 由 create db 的参数 replica 取代 | -| 123 | partitions | 是 | 否 | 3.0 行为未知 | +| 18 | queryRsmaTolerance | 否 | 是 | | +| 19 | queryBufferSize | 是 | 是 | | +| 20 | maxNumOfDistinctRes | 是 | 是 | | +| 21 | minSlidingTime | 是 | 是 | | +| 22 | minIntervalTime | 是 | 是 | | +| 23 | countAlwaysReturnValue | 是 | 是 | | +| 24 | dataDir | 是 | 是 | | +| 25 | minimalDataDirGB | 是 | 是 | | +| 26 | supportVnodes | 否 | 是 | | +| 27 | tempDir | 是 | 是 | | +| 28 | minimalTmpDirGB | 是 | 是 | | +| 29 | compressMsgSize | 是 | 是 | | +| 30 | compressColData | 是 | 是 | | +| 31 | smlChildTableName | 是 | 是 | | +| 32 | smlTagName | 是 | 是 | | +| 33 | smlDataFormat | 否 | 是 | | +| 34 | statusInterval | 是 | 是 | | +| 35 | shellActivityTimer | 是 | 是 | | +| 36 | transPullupInterval | 否 | 是 | | +| 37 | mqRebalanceInterval | 否 | 是 | | +| 38 | ttlUnit | 否 | 是 | | +| 39 | ttlPushInterval | 否 | 是 | | +| 40 | numOfTaskQueueThreads | 否 | 是 | | +| 41 | numOfRpcThreads | 否 | 是 | | +| 42 | numOfCommitThreads | 是 | 是 | | +| 43 | numOfMnodeReadThreads | 否 | 是 | | +| 44 | numOfVnodeQueryThreads | 否 | 是 | | +| 45 | numOfVnodeStreamThreads | 否 | 是 | | +| 46 | numOfVnodeFetchThreads | 否 | 是 | | +| 47 | numOfVnodeWriteThreads | 否 | 是 | | +| 48 | numOfVnodeSyncThreads | 否 | 是 | | +| 49 | numOfVnodeRsmaThreads | 否 | 是 | | +| 50 | numOfQnodeQueryThreads | 否 | 是 | | +| 51 | numOfQnodeFetchThreads | 否 | 是 | | +| 52 | numOfSnodeSharedThreads | 否 | 是 | | +| 53 | numOfSnodeUniqueThreads | 否 | 是 | | +| 54 | rpcQueueMemoryAllowed | 否 | 是 | | +| 55 | logDir | 是 | 是 | | +| 56 | minimalLogDirGB | 是 | 是 | | +| 57 | numOfLogLines | 是 | 是 | | +| 58 | asyncLog | 是 | 是 | | +| 59 | logKeepDays | 是 | 是 | | +| 60 | debugFlag | 是 | 是 | | +| 61 | tmrDebugFlag | 是 | 是 | | +| 62 | uDebugFlag | 是 | 是 | | +| 63 | rpcDebugFlag | 是 | 是 | | +| 64 | jniDebugFlag | 是 | 是 | | +| 65 | qDebugFlag | 是 | 是 | | +| 66 | cDebugFlag | 是 | 是 | | +| 67 | dDebugFlag | 是 | 是 | | +| 68 | vDebugFlag | 是 | 是 | | +| 69 | mDebugFlag | 是 | 是 | | +| 70 | wDebugFlag | 是 | 是 | | +| 71 | sDebugFlag | 是 | 是 | | +| 72 | tsdbDebugFlag | 是 | 是 | | +| 73 | tqDebugFlag | 否 | 是 | | +| 74 | fsDebugFlag | 是 | 是 | | +| 75 | udfDebugFlag | 否 | 是 | | +| 76 | smaDebugFlag | 否 | 是 | | +| 77 | idxDebugFlag | 否 | 是 | | +| 78 | tdbDebugFlag | 否 | 是 | | +| 79 | metaDebugFlag | 否 | 是 | | +| 80 | timezone | 是 | 是 | | +| 81 | locale | 是 | 是 | | +| 82 | charset | 是 | 是 | | +| 83 | udf | 是 | 是 | | +| 84 | enableCoreFile | 是 | 是 | | +| 85 | arbitrator | 是 | 否 | 通过 RAFT 协议选主 | +| 86 | numOfThreadsPerCore | 是 | 否 | 有其它参数设置多种线程池的大小 | +| 87 | numOfMnodes | 是 | 否 | 通过 create mnode 命令动态创建 mnode | +| 88 | vnodeBak | 是 | 否 | 3.0 行为未知 | +| 89 | balance | 是 | 否 | 负载均衡功能由 split/merge vgroups 实现 | +| 90 | balanceInterval | 是 | 否 | 随着 balance 参数失效 | +| 91 | offlineThreshold | 是 | 否 | 3.0 行为未知 | +| 92 | role | 是 | 否 | 由 supportVnode 决定是否能够创建 | +| 93 | dnodeNopLoop | 是 | 否 | 2.6 文档中未找到此参数 | +| 94 | keepTimeOffset | 是 | 否 | 2.6 文档中未找到此参数 | +| 95 | rpcTimer | 是 | 否 | 3.0 行为未知 | +| 96 | rpcMaxTime | 是 | 否 | 3.0 行为未知 | +| 97 | rpcForceTcp | 是 | 否 | 默认为 TCP | +| 98 | tcpConnTimeout | 是 | 否 | 3.0 行为未知 | +| 99 | syncCheckInterval | 是 | 否 | 3.0 行为未知 | +| 100 | maxTmrCtrl | 是 | 否 | 3.0 行为未知 | +| 101 | monitorReplica | 是 | 否 | 由 RAFT 协议管理多副本 | +| 102 | smlTagNullName | 是 | 否 | 3.0 行为未知 | +| 103 | keepColumnName | 是 | 否 | 3.0 行为未知 | +| 104 | ratioOfQueryCores | 是 | 否 | 由 线程池 相关配置参数决定 | +| 105 | maxStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 106 | maxFirstStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 107 | retryStreamCompDelay | 是 | 否 | 3.0 行为未知 | +| 108 | streamCompDelayRatio | 是 | 否 | 3.0 行为未知 | +| 109 | maxVgroupsPerDb | 是 | 否 | 由 create db 的参数 vgroups 指定实际 vgroups 数量 | +| 110 | maxTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 111 | minTablesPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 112 | tableIncStepPerVnode | 是 | 否 | DB 中的所有表近似平均分配到各个 vgroup | +| 113 | cache | 是 | 否 | 由 buffer 代替 cache\*blocks | +| 114 | blocks | 是 | 否 | 由 buffer 代替 cache\*blocks | +| 115 | days | 是 | 否 | 由 create db 的参数 duration 取代 | +| 116 | keep | 是 | 否 | 由 create db 的参数 keep 取代 | +| 117 | minRows | 是 | 否 | 由 create db 的参数 minRows 取代 | +| 118 | maxRows | 是 | 否 | 由 create db 的参数 maxRows 取代 | +| 119 | quorum | 是 | 否 | 由 RAFT 协议决定 | +| 120 | comp | 是 | 否 | 由 create db 的参数 comp 取代 | +| 121 | walLevel | 是 | 否 | 由 create db 的参数 wal_level 取代 | +| 122 | fsync | 是 | 否 | 由 create db 的参数 wal_fsync_period 取代 | +| 123 | replica | 是 | 否 | 由 create db 的参数 replica 取代 | +| 124 | partitions | 是 | 否 | 3.0 行为未知 | | 125 | update | 是 | 否 | 允许更新部分列 | | 126 | cachelast | 是 | 否 | 由 create db 的参数 cacheModel 取代 | | 127 | maxSQLLength | 是 | 否 | SQL 上限为 1MB,无需参数控制 | From 623581a51dd6ae619f71521c5ebbe8afc895c9a5 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 33/72] fix: coverity issues CID: 399721 --- source/libs/scalar/src/filter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index a04d5a3a3a..9e49ae1e03 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -3712,7 +3712,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) { SListCell *cell = node->pParameterList->pHead; for (int32_t i = 0; i < node->pParameterList->length; ++i) { if (NULL == cell || NULL == cell->pNode) { - fltError("invalid cell, cell:%p, pNode:%p", cell, cell->pNode); + fltError("invalid cell"); stat->code = TSDB_CODE_QRY_INVALID_INPUT; return DEAL_RES_ERROR; } From f4c290d545b3ddc376af3a3a3e6bf0889a9ab3ab Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 34/72] fix: coverity issues CID: 399791 --- source/common/src/ttszip.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/common/src/ttszip.c b/source/common/src/ttszip.c index aeb9292b41..fe5c599d53 100644 --- a/source/common/src/ttszip.c +++ b/source/common/src/ttszip.c @@ -187,7 +187,9 @@ void* tsBufDestroy(STSBuf* pTSBuf) { if (pTSBuf->autoDelete) { // ("tsBuf %p destroyed, delete tmp file:%s", pTSBuf, pTSBuf->path); - taosRemoveFile(pTSBuf->path); + if (taosRemoveFile(pTSBuf->path) != 0) { + // tscError("tsBuf %p destroyed, failed to remove tmp file:%s", pTSBuf, pTSBuf->path); + } } else { // tscDebug("tsBuf %p destroyed, tmp file:%s, remains", pTSBuf, pTSBuf->path); } From fddd6657bc1ce9731c613f60ee7779a41339dca4 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 24 Oct 2022 14:51:45 +0800 Subject: [PATCH 35/72] fix(sync): add error log when pState is NULL --- source/libs/sync/src/syncMain.c | 2 ++ source/libs/sync/src/syncReplication.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index dcc9e2ee2f..1f24c7c403 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -337,6 +337,7 @@ char* syncNodePeerState2Str(const SSyncNode* pSyncNode) { for (int32_t i = 0; i < pSyncNode->replicaNum; ++i) { SPeerState* pState = syncNodeGetPeerState((SSyncNode*)pSyncNode, &(pSyncNode->replicasId[i])); if (pState == NULL) { + sError("vgId:%d, replica maybe dropped", pSyncNode->vgId); break; } @@ -3497,6 +3498,7 @@ SPeerState* syncNodeGetPeerState(SSyncNode* ths, const SRaftId* pDestId) { bool syncNodeNeedSendAppendEntries(SSyncNode* ths, const SRaftId* pDestId, const SyncAppendEntries* pMsg) { SPeerState* pState = syncNodeGetPeerState(ths, pDestId); if (pState == NULL) { + sError("vgId:%d, replica maybe dropped", ths->vgId); return false; } diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index e040310e15..7296e30e02 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -163,7 +163,10 @@ int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftI syncNodeSendMsgById(destRaftId, pSyncNode, &rpcMsg); SPeerState* pState = syncNodeGetPeerState(pSyncNode, destRaftId); - ASSERT(pState != NULL); + if (pState == NULL) { + sError("vgId:%d, replica maybe dropped", pSyncNode->vgId); + return 0; + } if (pMsg->dataLen > 0) { pState->lastSendIndex = pMsg->prevLogIndex + 1; From c12f1b6e6a53a147c505b461eac1ca84b339b742 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 36/72] fix: coverity issues CID: 399890 --- source/libs/scalar/src/filter.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 9e49ae1e03..6f96f6f715 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1135,7 +1135,12 @@ int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFi int32_t filterAddUnitToGroup(SFilterGroup *group, uint32_t unitIdx) { if (group->unitNum >= group->unitSize) { group->unitSize += FILTER_DEFAULT_UNIT_SIZE; - group->unitIdxs = taosMemoryRealloc(group->unitIdxs, group->unitSize * sizeof(*group->unitIdxs)); + + void *tmp = taosMemoryRealloc(group->unitIdxs, group->unitSize * sizeof(*group->unitIdxs)); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + group->unitIdxs = tmp; } group->unitIdxs[group->unitNum++] = unitIdx; From 5728685772344da7104fcedc8c160d5025e8c024 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 37/72] fix: coverity issues CID: 399907 --- source/libs/scalar/src/filter.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 6f96f6f715..3ef32a303e 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -1082,7 +1082,12 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, if (info->unitNum >= info->unitSize) { uint32_t psize = info->unitSize; info->unitSize += FILTER_DEFAULT_UNIT_SIZE; - info->units = taosMemoryRealloc(info->units, info->unitSize * sizeof(SFilterUnit)); + + void *tmp = taosMemoryRealloc(info->units, info->unitSize * sizeof(SFilterUnit)); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + info->units = tmp; memset(info->units + psize, 0, sizeof(*info->units) * FILTER_DEFAULT_UNIT_SIZE); } From aa4daf1770366d00dc35f36a6a6eedb1433458cd Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 38/72] fix: coverity issues CID: 399914 --- source/common/src/tmsg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 94483b8a64..44a3f27983 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5954,6 +5954,7 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { if (pSW == NULL) return -1; if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) return -1; taosArrayPush(pRsp->blockSchema, &pSW); + taosMemoryFree(pSW); } if (pRsp->withTbName) { From 319cd8af85a606ebca3680415bd2ab2210276b3a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 24 Oct 2022 15:02:17 +0800 Subject: [PATCH 39/72] fix(query): refactor and fix some coverity issues. --- source/dnode/vnode/src/tsdb/tsdbRead.c | 17 ++++++-- source/libs/executor/src/executorimpl.c | 57 ++----------------------- 2 files changed, 18 insertions(+), 56 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 257a7d0baa..ca877f599f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -1910,6 +1910,10 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == k.ts) { if (init) { + if (merge.pTSchema == NULL) { + return code; + } + tRowMerge(&merge, pRow); } else { STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); @@ -1964,7 +1968,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* tRowMerge(&merge, &fRow1); } else { init = true; - int32_t code = tRowMergerInit(&merge, &fRow1, pReader->pSchema); + code = tRowMergerInit(&merge, &fRow1, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1975,17 +1979,24 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* if (minKey == key) { TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); if (!init) { - int32_t code = tRowMergerInit(&merge, &fRow, pReader->pSchema); + code = tRowMergerInit(&merge, &fRow, pReader->pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } } else { + if (merge.pTSchema == NULL) { + return code; + } tRowMerge(&merge, &fRow); } doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge); } } + if (merge.pTSchema == NULL) { + return code; + } + code = tRowMergerGetRow(&merge, &pTSRow); if (code != TSDB_CODE_SUCCESS) { return code; @@ -3232,7 +3243,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); int32_t code = tRowMergerInit(&merge, pRow, pSchema); - if (code != TSDB_CODE_SUCCESS) { + if (code != TSDB_CODE_SUCCESS || merge.pTSchema == NULL) { return code; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index a1f7b700a4..c484a852b9 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -2560,57 +2560,6 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len return TDB_CODE_SUCCESS; } -int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result) { - if (result == NULL) { - return TSDB_CODE_TSC_INVALID_INPUT; - } - SOptrBasicInfo* pInfo = (SOptrBasicInfo*)(pOperator->info); - SAggSupporter* pSup = (SAggSupporter*)POINTER_SHIFT(pOperator->info, sizeof(SOptrBasicInfo)); - - // int32_t size = taosHashGetSize(pSup->pResultRowHashTable); - int32_t length = *(int32_t*)(result); - int32_t offset = sizeof(int32_t); - - int32_t count = *(int32_t*)(result + offset); - offset += sizeof(int32_t); - - while (count-- > 0 && length > offset) { - int32_t keyLen = *(int32_t*)(result + offset); - offset += sizeof(int32_t); - - uint64_t tableGroupId = *(uint64_t*)(result + offset); - SResultRow* resultRow = getNewResultRow(pSup->pResultBuf, &pSup->currentPageId, pSup->resultRowSize); - if (!resultRow) { - return TSDB_CODE_TSC_INVALID_INPUT; - } - - // add a new result set for a new group - SResultRowPosition pos = {.pageId = resultRow->pageId, .offset = resultRow->offset}; - tSimpleHashPut(pSup->pResultRowHashTable, result + offset, keyLen, &pos, sizeof(SResultRowPosition)); - - offset += keyLen; - int32_t valueLen = *(int32_t*)(result + offset); - if (valueLen != pSup->resultRowSize) { - return TSDB_CODE_TSC_INVALID_INPUT; - } - offset += sizeof(int32_t); - int32_t pageId = resultRow->pageId; - int32_t pOffset = resultRow->offset; - memcpy(resultRow, result + offset, valueLen); - resultRow->pageId = pageId; - resultRow->offset = pOffset; - offset += valueLen; - - pInfo->resultRowInfo.cur = (SResultRowPosition){.pageId = resultRow->pageId, .offset = resultRow->offset}; - // releaseBufPage(pSup->pResultBuf, getBufPage(pSup->pResultBuf, pageId)); - } - - if (offset != length) { - return TSDB_CODE_TSC_INVALID_INPUT; - } - return TDB_CODE_SUCCESS; -} - int32_t handleLimitOffset(SOperatorInfo* pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf) { if (pLimitInfo->remainGroupOffset > 0) { if (pLimitInfo->currentGroupId == 0) { // it is the first group @@ -3098,9 +3047,11 @@ _error: destroyAggOperatorInfo(pInfo); } - cleanupExprSupp(&pOperator->exprSupp); - taosMemoryFreeClear(pOperator); + if (pOperator != NULL) { + cleanupExprSupp(&pOperator->exprSupp); + } + taosMemoryFreeClear(pOperator); pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; return NULL; } From c2bff98311a1977a58d350506a0e91c815cc7912 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 40/72] fix: coverity issues CID: 399945 --- source/common/src/trow.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/common/src/trow.c b/source/common/src/trow.c index e1085ce5d8..08a601909e 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -948,8 +948,10 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp #ifdef TD_SUPPORT_BITMAP if (valType == TD_VTYPE_NORM) { terrno = TSDB_CODE_INVALID_PTR; - return terrno; + } else { + terrno = TSDB_CODE_INVALID_PARA; } + return terrno; #else TASSERT(0); terrno = TSDB_CODE_INVALID_PARA; @@ -1361,4 +1363,4 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, value); } -} \ No newline at end of file +} From 120a3ca4b922f6fde65d1558ba6d001cdbaf7bd9 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 41/72] fix: coverity issues CID: 400059 --- source/libs/scalar/src/sclvector.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index f089bad04e..e2c26c32e0 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -344,8 +344,11 @@ static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIn int32_t outputMaxLen = (inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; char *t = taosMemoryCalloc(1, outputMaxLen); - /*int32_t resLen = */ taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4 *)varDataVal(t), - outputMaxLen - VARSTR_HEADER_SIZE, &len); + int32_t ret = taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4 *)varDataVal(t), + outputMaxLen - VARSTR_HEADER_SIZE, &len); + if (!ret) { + sclError("failed to convert to NCHAR"); + } varDataSetLen(t, len); colDataAppend(pOut->columnData, rowIndex, t, false); From 4780e88ce92799245a9840ca0943601a7ff4be7c Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 42/72] fix: coverity issues CID: 400330 --- source/libs/scalar/src/filter.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 3ef32a303e..e7f3fe7b49 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -4076,6 +4076,10 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SC *p = output.columnData; output.numOfRows = pSrc->info.rows; + if (*p == NULL) { + return false; + } + bool keep = (*info->func)(info, pSrc->info.rows, *p, statis, numOfCols, &output.numOfQualified); // todo this should be return during filter procedure From 68e274eba21318a3c654deabad64e5f3b26a51d5 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 43/72] fix: coverity issues CID: 399665 --- source/libs/scalar/src/scalar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index cc1949f17d..26adad27bc 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -331,7 +331,10 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t ASSERT(param->columnData == NULL); param->numOfRows = 1; - /*int32_t code = */ sclCreateColumnInfoData(&valueNode->node.resType, 1, param); + int32_t code = sclCreateColumnInfoData(&valueNode->node.resType, 1, param); + if (code != TSDB_CODE_SUCCESS) { + SCL_RET(TSDB_CODE_OUT_OF_MEMORY); + } if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type || valueNode->isNull) { colDataAppendNULL(param->columnData, 0); } else { From 94a3d32ca50839b6e938f4b0392c34d79d4865af Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Mon, 24 Oct 2022 16:27:32 +0800 Subject: [PATCH 44/72] avoid invalid read/write --- source/libs/transport/src/thttp.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index a583632765..92989a45f5 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -148,14 +148,22 @@ static FORCE_INLINE void clientRecvCb(uv_stream_t* handle, ssize_t nread, const } else { uTrace("http-report succ to recv %d bytes", (int32_t)nread); } - uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + if (!uv_is_closing((uv_handle_t*)&cli->tcp)) { + uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + } else { + destroyHttpClient(cli); + } } static void clientSentCb(uv_write_t* req, int32_t status) { SHttpClient* cli = req->data; if (status != 0) { terrno = TAOS_SYSTEM_ERROR(status); uError("http-report failed to send data %s", uv_strerror(status)); - uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + if (!uv_is_closing((uv_handle_t*)&cli->tcp)) { + uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + } else { + destroyHttpClient(cli); + } return; } else { uTrace("http-report succ to send data"); @@ -176,7 +184,11 @@ static void clientConnCb(uv_connect_t* req, int32_t status) { if (status != 0) { terrno = TAOS_SYSTEM_ERROR(status); uError("http-report failed to conn to server, reason:%s, dst:%s:%d", uv_strerror(status), cli->addr, cli->port); - uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + if (!uv_is_closing((uv_handle_t*)&cli->tcp)) { + uv_close((uv_handle_t*)&cli->tcp, clientCloseCb); + } else { + destroyHttpClient(cli); + } return; } status = uv_write(&cli->req, (uv_stream_t*)&cli->tcp, cli->wbuf, 2, clientSentCb); From 64cf24830e221e145444ba970b65e724d62e7305 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 24 Oct 2022 16:38:16 +0800 Subject: [PATCH 45/72] enh: insert parser refactor --- include/common/trow.h | 2 +- source/libs/parser/inc/parInsertData.h | 148 --- source/libs/parser/inc/parInsertUtil.h | 167 +++ source/libs/parser/src/parInsertSml.c | 363 ++++++ .../src/{parInsert.c => parInsertSql.c} | 1097 ++--------------- source/libs/parser/src/parInsertStmt.c | 486 ++++++++ .../src/{parInsertData.c => parInsertUtil.c} | 411 +++--- 7 files changed, 1361 insertions(+), 1313 deletions(-) delete mode 100644 source/libs/parser/inc/parInsertData.h create mode 100644 source/libs/parser/inc/parInsertUtil.h create mode 100644 source/libs/parser/src/parInsertSml.c rename source/libs/parser/src/{parInsert.c => parInsertSql.c} (60%) create mode 100644 source/libs/parser/src/parInsertStmt.c rename source/libs/parser/src/{parInsertData.c => parInsertUtil.c} (69%) diff --git a/include/common/trow.h b/include/common/trow.h index c5293fa45f..9d183c8f80 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -169,7 +169,7 @@ typedef struct { // #define TD_ROW_VER(r) ((r)->ver) #define TD_ROW_KEY_ADDR(r) (r) -// N.B. If without STSchema, getExtendedRowSize() is used to get the rowMaxBytes and +// N.B. If without STSchema, insGetExtendedRowSize() is used to get the rowMaxBytes and // (int32_t)ceil((double)nCols/TD_VTYPE_PARTS) should be added if TD_SUPPORT_BITMAP defined. #define TD_ROW_MAX_BYTES_FROM_SCHEMA(s) ((s)->tlen + TD_ROW_HEAD_LEN) diff --git a/source/libs/parser/inc/parInsertData.h b/source/libs/parser/inc/parInsertData.h deleted file mode 100644 index 6d0ba29eb7..0000000000 --- a/source/libs/parser/inc/parInsertData.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * 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 . - */ - -#ifndef TDENGINE_DATABLOCKMGT_H -#define TDENGINE_DATABLOCKMGT_H - -#include "catalog.h" -#include "os.h" -#include "query.h" -#include "tname.h" -#include "ttypes.h" - -#define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED) - -typedef enum EOrderStatus { - ORDER_STATUS_UNKNOWN = 0, - ORDER_STATUS_ORDERED = 1, - ORDER_STATUS_DISORDERED = 2, -} EOrderStatus; - -typedef enum EValStat { - VAL_STAT_HAS = 0x0, // 0 means has val - VAL_STAT_NONE = 0x01, // 1 means no val -} EValStat; - -typedef struct SBoundColumn { - int32_t offset; // all column offset value - int32_t toffset; // first part offset for SDataRow TODO: get offset from STSchema on future - uint8_t valStat; // EValStat. denote if current column bound or not(0 means has val, 1 means no val) -} SBoundColumn; - -typedef struct { - col_id_t schemaColIdx; - col_id_t boundIdx; - col_id_t finalIdx; -} SBoundIdxInfo; - -typedef struct SParsedDataColInfo { - col_id_t numOfCols; - col_id_t numOfBound; - uint16_t flen; // TODO: get from STSchema - uint16_t allNullLen; // TODO: get from STSchema(base on SDataRow) - uint16_t extendedVarLen; - uint16_t boundNullLen; // bound column len with all NULL value(without VarDataOffsetT/SColIdx part) - col_id_t *boundColumns; // bound column idx according to schema - SBoundColumn *cols; - SBoundIdxInfo *colIdxInfo; - int8_t orderStatus; // bound columns -} SParsedDataColInfo; - -typedef struct { - uint8_t rowType; // default is 0, that is SDataRow - int32_t rowSize; -} SMemRowBuilder; - -typedef struct STableDataBlocks { - int8_t tsSource; // where does the UNIX timestamp come from, server or client - bool ordered; // if current rows are ordered or not - int32_t vgId; // virtual group id - int64_t prevTS; // previous timestamp, recorded to decide if the records array is ts ascending - int32_t numOfTables; // number of tables in current submit block - int32_t rowSize; // row size for current table - uint32_t nAllocSize; - uint32_t headerSize; // header for table info (uid, tid, submit metadata) - uint32_t size; - STableMeta *pTableMeta; // the tableMeta of current table, the table meta will be used during submit, keep a ref to - // avoid to be removed from cache - char *pData; - bool cloned; - int32_t createTbReqLen; - SParsedDataColInfo boundColumnInfo; - SRowBuilder rowBuilder; -} STableDataBlocks; - -static FORCE_INLINE int32_t getExtendedRowSize(STableDataBlocks *pBlock) { - STableComInfo *pTableInfo = &pBlock->pTableMeta->tableInfo; - ASSERT(pBlock->rowSize == pTableInfo->rowSize); - return pBlock->rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + pBlock->boundColumnInfo.extendedVarLen + - (int32_t)TD_BITMAP_BYTES(pTableInfo->numOfColumns - 1); -} - -static FORCE_INLINE void getSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo *spd, col_id_t idx, int32_t *toffset, - col_id_t *colIdx) { - col_id_t schemaIdx = 0; - if (IS_DATA_COL_ORDERED(spd)) { - schemaIdx = spd->boundColumns[idx]; - if (TD_IS_TP_ROW_T(rowType)) { - *toffset = (spd->cols + schemaIdx)->toffset; // the offset of firstPart - *colIdx = schemaIdx; - } else { - *toffset = idx * sizeof(SKvRowIdx); // the offset of SKvRowIdx - *colIdx = idx; - } - } else { - ASSERT(idx == (spd->colIdxInfo + idx)->boundIdx); - schemaIdx = (spd->colIdxInfo + idx)->schemaColIdx; - if (TD_IS_TP_ROW_T(rowType)) { - *toffset = (spd->cols + schemaIdx)->toffset; - *colIdx = schemaIdx; - } else { - *toffset = ((spd->colIdxInfo + idx)->finalIdx) * sizeof(SKvRowIdx); - *colIdx = (spd->colIdxInfo + idx)->finalIdx; - } - } -} - -static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks *dataBuf, int32_t numOfRows) { - pBlocks->suid = (TSDB_NORMAL_TABLE == dataBuf->pTableMeta->tableType ? 0 : dataBuf->pTableMeta->suid); - pBlocks->uid = dataBuf->pTableMeta->uid; - pBlocks->sversion = dataBuf->pTableMeta->sversion; - pBlocks->schemaLen = dataBuf->createTbReqLen; - - if (pBlocks->numOfRows + numOfRows >= INT32_MAX) { - return TSDB_CODE_TSC_INVALID_OPERATION; - } else { - pBlocks->numOfRows += numOfRows; - return TSDB_CODE_SUCCESS; - } -} - -int32_t schemaIdxCompar(const void *lhs, const void *rhs); -int32_t boundIdxCompar(const void *lhs, const void *rhs); -void setBoundColumnInfo(SParsedDataColInfo *pColList, SSchema *pSchema, col_id_t numOfCols); -void destroyBlockArrayList(SArray *pDataBlockList); -void destroyBlockHashmap(SHashObj *pDataBlockHash); -int initRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo *pColInfo); -int32_t allocateMemIfNeed(STableDataBlocks *pDataBlock, int32_t rowSize, int32_t *numOfRows); -int32_t getDataBlockFromList(SHashObj *pHashList, void *id, int32_t idLen, int32_t size, int32_t startOffset, - int32_t rowSize, STableMeta *pTableMeta, STableDataBlocks **dataBlocks, SArray *pBlockList, - SVCreateTbReq *pCreateTbReq); -int32_t mergeTableDataBlocks(SHashObj *pHashObj, uint8_t payloadType, SArray **pVgDataBlocks); -int32_t buildCreateTbMsg(STableDataBlocks *pBlocks, SVCreateTbReq *pCreateTbReq); - -int32_t allocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize); - -#endif // TDENGINE_DATABLOCKMGT_H diff --git a/source/libs/parser/inc/parInsertUtil.h b/source/libs/parser/inc/parInsertUtil.h new file mode 100644 index 0000000000..78e87d847c --- /dev/null +++ b/source/libs/parser/inc/parInsertUtil.h @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#ifndef TDENGINE_PAR_INSERT_UTIL_H +#define TDENGINE_PAR_INSERT_UTIL_H + +#include "parUtil.h" + +struct SToken; + +#define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED) + +#define NEXT_TOKEN(pSql, sToken) \ + do { \ + int32_t index = 0; \ + sToken = tStrGetToken(pSql, &index, false); \ + pSql += index; \ + } while (0) + +#define CHECK_CODE(expr) \ + do { \ + int32_t code = expr; \ + if (TSDB_CODE_SUCCESS != code) { \ + return code; \ + } \ + } while (0) + +typedef enum EOrderStatus { + ORDER_STATUS_UNKNOWN = 0, + ORDER_STATUS_ORDERED = 1, + ORDER_STATUS_DISORDERED = 2, +} EOrderStatus; + +typedef enum EValStat { + VAL_STAT_HAS = 0x0, // 0 means has val + VAL_STAT_NONE = 0x01, // 1 means no val +} EValStat; + +typedef struct SBoundColumn { + int32_t offset; // all column offset value + int32_t toffset; // first part offset for SDataRow TODO: get offset from STSchema on future + uint8_t valStat; // EValStat. denote if current column bound or not(0 means has val, 1 means no val) +} SBoundColumn; + +typedef struct { + col_id_t schemaColIdx; + col_id_t boundIdx; + col_id_t finalIdx; +} SBoundIdxInfo; + +typedef struct SParsedDataColInfo { + col_id_t numOfCols; + col_id_t numOfBound; + uint16_t flen; // TODO: get from STSchema + uint16_t allNullLen; // TODO: get from STSchema(base on SDataRow) + uint16_t extendedVarLen; + uint16_t boundNullLen; // bound column len with all NULL value(without VarDataOffsetT/SColIdx part) + col_id_t *boundColumns; // bound column idx according to schema + SBoundColumn *cols; + SBoundIdxInfo *colIdxInfo; + int8_t orderStatus; // bound columns +} SParsedDataColInfo; + +typedef struct SInsertParseBaseContext { + SParseContext *pComCxt; + char *pSql; + SMsgBuf msg; +} SInsertParseBaseContext; + +typedef struct SInsertParseContext { + SParseContext *pComCxt; // input + char *pSql; // input + SMsgBuf msg; // input + STableMeta *pTableMeta; // each table + SParsedDataColInfo tags; // each table + SVCreateTbReq createTblReq; // each table + SHashObj *pVgroupsHashObj; // global + SHashObj *pTableBlockHashObj; // global + SHashObj *pSubTableHashObj; // global + SArray *pVgDataBlocks; // global + SHashObj *pTableNameHashObj; // global + SHashObj *pDbFNameHashObj; // global + int32_t totalNum; + SVnodeModifOpStmt *pOutput; + SStmtCallback *pStmtCb; + SParseMetaCache *pMetaCache; + char sTableName[TSDB_TABLE_NAME_LEN]; + char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW]; + int64_t memElapsed; + int64_t parRowElapsed; +} SInsertParseContext; + +typedef struct SInsertParseSyntaxCxt { + SParseContext *pComCxt; + char *pSql; + SMsgBuf msg; + SParseMetaCache *pMetaCache; +} SInsertParseSyntaxCxt; + +typedef struct SMemParam { + SRowBuilder *rb; + SSchema *schema; + int32_t toffset; + col_id_t colIdx; +} SMemParam; + +typedef struct { + uint8_t rowType; // default is 0, that is SDataRow + int32_t rowSize; +} SMemRowBuilder; + +typedef struct STableDataBlocks { + int8_t tsSource; // where does the UNIX timestamp come from, server or client + bool ordered; // if current rows are ordered or not + int32_t vgId; // virtual group id + int64_t prevTS; // previous timestamp, recorded to decide if the records array is ts ascending + int32_t numOfTables; // number of tables in current submit block + int32_t rowSize; // row size for current table + uint32_t nAllocSize; + uint32_t headerSize; // header for table info (uid, tid, submit metadata) + uint32_t size; + STableMeta *pTableMeta; // the tableMeta of current table, the table meta will be used during submit, keep a ref to + // avoid to be removed from cache + char *pData; + bool cloned; + int32_t createTbReqLen; + SParsedDataColInfo boundColumnInfo; + SRowBuilder rowBuilder; +} STableDataBlocks; + +int32_t insGetExtendedRowSize(STableDataBlocks *pBlock); +void insGetSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo *spd, col_id_t idx, int32_t *toffset, col_id_t *colIdx); +int32_t insSetBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks *dataBuf, int32_t numOfRows); +int32_t insSchemaIdxCompar(const void *lhs, const void *rhs); +int32_t insBoundIdxCompar(const void *lhs, const void *rhs); +void insSetBoundColumnInfo(SParsedDataColInfo *pColList, SSchema *pSchema, col_id_t numOfCols); +void insDestroyBlockArrayList(SArray *pDataBlockList); +void insDestroyBlockHashmap(SHashObj *pDataBlockHash); +int32_t insInitRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataColInfo *pColInfo); +int32_t insGetDataBlockFromList(SHashObj *pHashList, void *id, int32_t idLen, int32_t size, int32_t startOffset, + int32_t rowSize, STableMeta *pTableMeta, STableDataBlocks **dataBlocks, + SArray *pBlockList, SVCreateTbReq *pCreateTbReq); +int32_t insMergeTableDataBlocks(SHashObj *pHashObj, uint8_t payloadType, SArray **pVgDataBlocks); +int32_t insBuildCreateTbMsg(STableDataBlocks *pBlocks, SVCreateTbReq *pCreateTbReq); +int32_t insAllocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize); +int32_t insCreateSName(SName *pName, struct SToken *pTableName, int32_t acctId, const char *dbName, SMsgBuf *pMsgBuf); +int32_t insFindCol(struct SToken *pColname, int32_t start, int32_t end, SSchema *pSchema); +void insBuildCreateTbReq(SVCreateTbReq *pTbReq, const char *tname, STag *pTag, int64_t suid, const char *sname, + SArray *tagName, uint8_t tagNum); +int32_t insMemRowAppend(SMsgBuf *pMsgBuf, const void *value, int32_t len, void *param); +int32_t insCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start); +int32_t insBuildOutput(SInsertParseContext *pCxt); +void insDestroyDataBlock(STableDataBlocks *pDataBlock); + +#endif // TDENGINE_PAR_INSERT_UTIL_H diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c new file mode 100644 index 0000000000..8be5b86b37 --- /dev/null +++ b/source/libs/parser/src/parInsertSml.c @@ -0,0 +1,363 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#include "parInsertUtil.h" +#include "parInt.h" +#include "parToken.h" +#include "ttime.h" + +int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf, + int32_t msgBufLen) { + SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen}; + SToken sToken; + int32_t code = 0; + char* tbName = NULL; + + NEXT_TOKEN(pTableName, sToken); + + if (sToken.n == 0) { + return buildInvalidOperationMsg(&msg, "empty table name"); + } + + code = insCreateSName(pName, &sToken, acctId, dbName, &msg); + if (code) { + return code; + } + + NEXT_TOKEN(pTableName, sToken); + + if (sToken.n > 0) { + return buildInvalidOperationMsg(&msg, "table name format is wrong"); + } + + return TSDB_CODE_SUCCESS; +} + +typedef struct SmlExecTableHandle { + SParsedDataColInfo tags; // each table + SVCreateTbReq createTblReq; // each table +} SmlExecTableHandle; + +typedef struct SmlExecHandle { + SHashObj* pBlockHash; + SmlExecTableHandle tableExecHandle; + SQuery* pQuery; +} SSmlExecHandle; + +static void smlDestroyTableHandle(void* pHandle) { + SmlExecTableHandle* handle = (SmlExecTableHandle*)pHandle; + destroyBoundColumnInfo(&handle->tags); + tdDestroySVCreateTbReq(&handle->createTblReq); +} + +static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SSchema* pSchema, bool isTag) { + col_id_t nCols = pColList->numOfCols; + + pColList->numOfBound = 0; + pColList->boundNullLen = 0; + memset(pColList->boundColumns, 0, sizeof(col_id_t) * nCols); + for (col_id_t i = 0; i < nCols; ++i) { + pColList->cols[i].valStat = VAL_STAT_NONE; + } + + bool isOrdered = true; + col_id_t lastColIdx = -1; // last column found + for (int i = 0; i < taosArrayGetSize(cols); ++i) { + SSmlKv* kv = taosArrayGetP(cols, i); + SToken sToken = {.n = kv->keyLen, .z = (char*)kv->key}; + col_id_t t = lastColIdx + 1; + col_id_t index = ((t == 0 && !isTag) ? 0 : insFindCol(&sToken, t, nCols, pSchema)); + uDebug("SML, index:%d, t:%d, ncols:%d", index, t, nCols); + if (index < 0 && t > 0) { + index = insFindCol(&sToken, 0, t, pSchema); + isOrdered = false; + } + if (index < 0) { + uError("smlBoundColumnData. index:%d", index); + return TSDB_CODE_SML_INVALID_DATA; + } + if (pColList->cols[index].valStat == VAL_STAT_HAS) { + uError("smlBoundColumnData. already set. index:%d", index); + return TSDB_CODE_SML_INVALID_DATA; + } + lastColIdx = index; + pColList->cols[index].valStat = VAL_STAT_HAS; + pColList->boundColumns[pColList->numOfBound] = index; + ++pColList->numOfBound; + switch (pSchema[t].type) { + case TSDB_DATA_TYPE_BINARY: + pColList->boundNullLen += (sizeof(VarDataOffsetT) + VARSTR_HEADER_SIZE + CHAR_BYTES); + break; + case TSDB_DATA_TYPE_NCHAR: + pColList->boundNullLen += (sizeof(VarDataOffsetT) + VARSTR_HEADER_SIZE + TSDB_NCHAR_SIZE); + break; + default: + pColList->boundNullLen += TYPE_BYTES[pSchema[t].type]; + break; + } + } + + pColList->orderStatus = isOrdered ? ORDER_STATUS_ORDERED : ORDER_STATUS_DISORDERED; + + if (!isOrdered) { + pColList->colIdxInfo = taosMemoryCalloc(pColList->numOfBound, sizeof(SBoundIdxInfo)); + if (NULL == pColList->colIdxInfo) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + SBoundIdxInfo* pColIdx = pColList->colIdxInfo; + for (col_id_t i = 0; i < pColList->numOfBound; ++i) { + pColIdx[i].schemaColIdx = pColList->boundColumns[i]; + pColIdx[i].boundIdx = i; + } + taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), insSchemaIdxCompar); + for (col_id_t i = 0; i < pColList->numOfBound; ++i) { + pColIdx[i].finalIdx = i; + } + taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), insBoundIdxCompar); + } + + if (pColList->numOfCols > pColList->numOfBound) { + memset(&pColList->boundColumns[pColList->numOfBound], 0, + sizeof(col_id_t) * (pColList->numOfCols - pColList->numOfBound)); + } + + return TSDB_CODE_SUCCESS; +} + +/** + * @brief No json tag for schemaless + * + * @param cols + * @param tags + * @param pSchema + * @param ppTag + * @param msg + * @return int32_t + */ +static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName, + SMsgBuf* msg) { + SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal)); + if (!pTagArray) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + *tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); + if (!*tagName) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + int32_t code = TSDB_CODE_SUCCESS; + for (int i = 0; i < tags->numOfBound; ++i) { + SSchema* pTagSchema = &pSchema[tags->boundColumns[i]]; + SSmlKv* kv = taosArrayGetP(cols, i); + + taosArrayPush(*tagName, pTagSchema->name); + STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; + // strcpy(val.colName, pTagSchema->name); + if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { + val.pData = (uint8_t*)kv->value; + val.nData = kv->length; + } else if (pTagSchema->type == TSDB_DATA_TYPE_NCHAR) { + int32_t output = 0; + void* p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE); + if (p == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)(p), kv->length * TSDB_NCHAR_SIZE, &output)) { + if (errno == E2BIG) { + taosMemoryFree(p); + code = generateSyntaxErrMsg(msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pTagSchema->name); + goto end; + } + char buf[512] = {0}; + snprintf(buf, tListLen(buf), " taosMbsToUcs4 error:%s", strerror(errno)); + taosMemoryFree(p); + code = buildSyntaxErrMsg(msg, buf, kv->value); + goto end; + } + val.pData = p; + val.nData = output; + } else { + memcpy(&val.i64, &(kv->value), kv->length); + } + taosArrayPush(pTagArray, &val); + } + + code = tTagNew(pTagArray, 1, false, ppTag); +end: + for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) { + STagVal* p = (STagVal*)taosArrayGet(pTagArray, i); + if (p->type == TSDB_DATA_TYPE_NCHAR) { + taosMemoryFree(p->pData); + } + } + taosArrayDestroy(pTagArray); + return code; +} + +int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta, + char* tableName, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen) { + SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; + + SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle; + smlDestroyTableHandle(&smlHandle->tableExecHandle); // free for each table + SSchema* pTagsSchema = getTableTagSchema(pTableMeta); + insSetBoundColumnInfo(&smlHandle->tableExecHandle.tags, pTagsSchema, getNumOfTags(pTableMeta)); + int ret = smlBoundColumnData(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, true); + if (ret != TSDB_CODE_SUCCESS) { + buildInvalidOperationMsg(&pBuf, "bound tags error"); + return ret; + } + STag* pTag = NULL; + SArray* tagName = NULL; + ret = smlBuildTagRow(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, &pTag, &tagName, &pBuf); + if (ret != TSDB_CODE_SUCCESS) { + taosArrayDestroy(tagName); + return ret; + } + + insBuildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName, + pTableMeta->tableInfo.numOfTags); + taosArrayDestroy(tagName); + + smlHandle->tableExecHandle.createTblReq.ctb.stbName = taosMemoryMalloc(sTableNameLen + 1); + memcpy(smlHandle->tableExecHandle.createTblReq.ctb.stbName, sTableName, sTableNameLen); + smlHandle->tableExecHandle.createTblReq.ctb.stbName[sTableNameLen] = 0; + + STableDataBlocks* pDataBlock = NULL; + ret = insGetDataBlockFromList(smlHandle->pBlockHash, &pTableMeta->uid, sizeof(pTableMeta->uid), + TSDB_DEFAULT_PAYLOAD_SIZE, sizeof(SSubmitBlk), getTableInfo(pTableMeta).rowSize, + pTableMeta, &pDataBlock, NULL, &smlHandle->tableExecHandle.createTblReq); + if (ret != TSDB_CODE_SUCCESS) { + buildInvalidOperationMsg(&pBuf, "create data block error"); + return ret; + } + + SSchema* pSchema = getTableColumnSchema(pTableMeta); + + ret = smlBoundColumnData(colsSchema, &pDataBlock->boundColumnInfo, pSchema, false); + if (ret != TSDB_CODE_SUCCESS) { + buildInvalidOperationMsg(&pBuf, "bound cols error"); + return ret; + } + int32_t extendedRowSize = insGetExtendedRowSize(pDataBlock); + SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo; + SRowBuilder* pBuilder = &pDataBlock->rowBuilder; + SMemParam param = {.rb = pBuilder}; + + insInitRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo); + + int32_t rowNum = taosArrayGetSize(cols); + if (rowNum <= 0) { + return buildInvalidOperationMsg(&pBuf, "cols size <= 0"); + } + ret = insAllocateMemForSize(pDataBlock, extendedRowSize * rowNum); + if (ret != TSDB_CODE_SUCCESS) { + buildInvalidOperationMsg(&pBuf, "allocate memory error"); + return ret; + } + for (int32_t r = 0; r < rowNum; ++r) { + STSRow* row = (STSRow*)(pDataBlock->pData + pDataBlock->size); // skip the SSubmitBlk header + tdSRowResetBuf(pBuilder, row); + void* rowData = taosArrayGetP(cols, r); + size_t rowDataSize = 0; + if (format) { + rowDataSize = taosArrayGetSize(rowData); + } + + // 1. set the parsed value from sql string + for (int c = 0, j = 0; c < spd->numOfBound; ++c) { + SSchema* pColSchema = &pSchema[spd->boundColumns[c]]; + + param.schema = pColSchema; + insGetSTSRowAppendInfo(pBuilder->rowType, spd, c, ¶m.toffset, ¶m.colIdx); + + SSmlKv* kv = NULL; + if (format) { + if (j < rowDataSize) { + kv = taosArrayGetP(rowData, j); + if (rowDataSize != spd->numOfBound && j != 0 && + (kv->keyLen != strlen(pColSchema->name) || strncmp(kv->key, pColSchema->name, kv->keyLen) != 0)) { + kv = NULL; + } else { + j++; + } + } + } else { + void** p = taosHashGet(rowData, pColSchema->name, strlen(pColSchema->name)); + if (p) kv = *p; + } + + if (kv) { + int32_t colLen = kv->length; + if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { + // uError("SML:data before:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision); + kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision); + // uError("SML:data after:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision); + } + + if (IS_VAR_DATA_TYPE(kv->type)) { + insMemRowAppend(&pBuf, kv->value, colLen, ¶m); + } else { + insMemRowAppend(&pBuf, &(kv->value), colLen, ¶m); + } + } else { + pBuilder->hasNone = true; + } + + if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) { + TSKEY tsKey = TD_ROW_KEY(row); + insCheckTimestamp(pDataBlock, (const char*)&tsKey); + } + } + + // set the null value for the columns that do not assign values + if ((spd->numOfBound < spd->numOfCols) && TD_IS_TP_ROW(row)) { + pBuilder->hasNone = true; + } + + tdSRowEnd(pBuilder); + pDataBlock->size += extendedRowSize; + } + + SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData); + if (TSDB_CODE_SUCCESS != insSetBlockInfo(pBlocks, pDataBlock, rowNum)) { + return buildInvalidOperationMsg(&pBuf, "too many rows in sql, total number of rows should be less than INT32_MAX"); + } + + return TSDB_CODE_SUCCESS; +} + +void* smlInitHandle(SQuery* pQuery) { + SSmlExecHandle* handle = taosMemoryCalloc(1, sizeof(SSmlExecHandle)); + if (!handle) return NULL; + handle->pBlockHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); + handle->pQuery = pQuery; + + return handle; +} + +void smlDestroyHandle(void* pHandle) { + if (!pHandle) return; + SSmlExecHandle* handle = (SSmlExecHandle*)pHandle; + insDestroyBlockHashmap(handle->pBlockHash); + smlDestroyTableHandle(&handle->tableExecHandle); + taosMemoryFree(handle); +} + +int32_t smlBuildOutput(void* handle, SHashObj* pVgHash) { + SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle; + return qBuildStmtOutput(smlHandle->pQuery, pVgHash, smlHandle->pBlockHash); +} diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsertSql.c similarity index 60% rename from source/libs/parser/src/parInsert.c rename to source/libs/parser/src/parInsertSql.c index 65cc44b1e9..84c9664fa9 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsertSql.c @@ -13,22 +13,10 @@ * along with this program. If not, see . */ -#include "os.h" -#include "parInsertData.h" -#include "parInt.h" +#include "parInsertUtil.h" #include "parToken.h" -#include "parUtil.h" -#include "query.h" #include "tglobal.h" #include "ttime.h" -#include "ttypes.h" - -#define NEXT_TOKEN(pSql, sToken) \ - do { \ - int32_t index = 0; \ - sToken = tStrGetToken(pSql, &index, false); \ - pSql += index; \ - } while (0) #define NEXT_TOKEN_WITH_PREV(pSql, sToken) \ do { \ @@ -49,69 +37,11 @@ pSql += sToken.n; \ } while (TK_NK_SPACE == sToken.type) -typedef struct SInsertParseBaseContext { - SParseContext* pComCxt; - char* pSql; - SMsgBuf msg; -} SInsertParseBaseContext; - -typedef struct SInsertParseContext { - SParseContext* pComCxt; // input - char* pSql; // input - SMsgBuf msg; // input - STableMeta* pTableMeta; // each table - SParsedDataColInfo tags; // each table - SVCreateTbReq createTblReq; // each table - SHashObj* pVgroupsHashObj; // global - SHashObj* pTableBlockHashObj; // global - SHashObj* pSubTableHashObj; // global - SArray* pVgDataBlocks; // global - SHashObj* pTableNameHashObj; // global - SHashObj* pDbFNameHashObj; // global - int32_t totalNum; - SVnodeModifOpStmt* pOutput; - SStmtCallback* pStmtCb; - SParseMetaCache* pMetaCache; - char sTableName[TSDB_TABLE_NAME_LEN]; - char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW]; - int64_t memElapsed; - int64_t parRowElapsed; -} SInsertParseContext; - -typedef struct SInsertParseSyntaxCxt { - SParseContext* pComCxt; - char* pSql; - SMsgBuf msg; - SParseMetaCache* pMetaCache; -} SInsertParseSyntaxCxt; - typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param); static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE; -typedef struct SKvParam { - int16_t pos; - SArray* pTagVals; - SSchema* schema; - char buf[TSDB_MAX_TAGS_LEN]; -} SKvParam; - -typedef struct SMemParam { - SRowBuilder* rb; - SSchema* schema; - int32_t toffset; - col_id_t colIdx; -} SMemParam; - -#define CHECK_CODE(expr) \ - do { \ - int32_t code = expr; \ - if (TSDB_CODE_SUCCESS != code) { \ - return code; \ - } \ - } while (0) - static int32_t skipInsertInto(char** pSql, SMsgBuf* pMsg) { SToken sToken; NEXT_TOKEN(*pSql, sToken); @@ -125,105 +55,6 @@ static int32_t skipInsertInto(char** pSql, SMsgBuf* pMsg) { return TSDB_CODE_SUCCESS; } -static char* tableNameGetPosition(SToken* pToken, char target) { - bool inEscape = false; - bool inQuote = false; - char quotaStr = 0; - - for (uint32_t i = 0; i < pToken->n; ++i) { - if (*(pToken->z + i) == target && (!inEscape) && (!inQuote)) { - return pToken->z + i; - } - - if (*(pToken->z + i) == TS_ESCAPE_CHAR) { - if (!inQuote) { - inEscape = !inEscape; - } - } - - if (*(pToken->z + i) == '\'' || *(pToken->z + i) == '"') { - if (!inEscape) { - if (!inQuote) { - quotaStr = *(pToken->z + i); - inQuote = !inQuote; - } else if (quotaStr == *(pToken->z + i)) { - inQuote = !inQuote; - } - } - } - } - - return NULL; -} - -static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, const char* dbName, SMsgBuf* pMsgBuf) { - const char* msg1 = "name too long"; - const char* msg2 = "invalid database name"; - const char* msg3 = "db is not specified"; - const char* msg4 = "invalid table name"; - - int32_t code = TSDB_CODE_SUCCESS; - char* p = tableNameGetPosition(pTableName, TS_PATH_DELIMITER[0]); - - if (p != NULL) { // db has been specified in sql string so we ignore current db path - assert(*p == TS_PATH_DELIMITER[0]); - - int32_t dbLen = p - pTableName->z; - if (dbLen <= 0) { - return buildInvalidOperationMsg(pMsgBuf, msg2); - } - char name[TSDB_DB_FNAME_LEN] = {0}; - strncpy(name, pTableName->z, dbLen); - int32_t actualDbLen = strdequote(name); - - code = tNameSetDbName(pName, acctId, name, actualDbLen); - if (code != TSDB_CODE_SUCCESS) { - return buildInvalidOperationMsg(pMsgBuf, msg1); - } - - int32_t tbLen = pTableName->n - dbLen - 1; - if (tbLen <= 0) { - return buildInvalidOperationMsg(pMsgBuf, msg4); - } - - char tbname[TSDB_TABLE_FNAME_LEN] = {0}; - strncpy(tbname, p + 1, tbLen); - /*tbLen = */ strdequote(tbname); - - code = tNameFromString(pName, tbname, T_NAME_TABLE); - if (code != 0) { - return buildInvalidOperationMsg(pMsgBuf, msg1); - } - } else { // get current DB name first, and then set it into path - if (pTableName->n >= TSDB_TABLE_NAME_LEN) { - return buildInvalidOperationMsg(pMsgBuf, msg1); - } - - assert(pTableName->n < TSDB_TABLE_FNAME_LEN); - - char name[TSDB_TABLE_FNAME_LEN] = {0}; - strncpy(name, pTableName->z, pTableName->n); - strdequote(name); - - if (dbName == NULL) { - return buildInvalidOperationMsg(pMsgBuf, msg3); - } - - code = tNameSetDbName(pName, acctId, dbName, strlen(dbName)); - if (code != TSDB_CODE_SUCCESS) { - code = buildInvalidOperationMsg(pMsgBuf, msg2); - return code; - } - - code = tNameFromString(pName, name, T_NAME_TABLE); - if (code != 0) { - code = buildInvalidOperationMsg(pMsgBuf, msg1); - } - } - - return code; -} - static int32_t checkAuth(SInsertParseContext* pCxt, char* pDbFname, bool* pPass) { SParseContext* pBasicCtx = pCxt->pComCxt; if (pBasicCtx->async) { @@ -298,74 +129,6 @@ static int32_t getDBCfg(SInsertParseContext* pCxt, const char* pDbFName, SDbCfgI return TSDB_CODE_SUCCESS; } -static int32_t findCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchema) { - while (start < end) { - if (strlen(pSchema[start].name) == pColname->n && strncmp(pColname->z, pSchema[start].name, pColname->n) == 0) { - return start; - } - ++start; - } - return -1; -} - -static void buildMsgHeader(STableDataBlocks* src, SVgDataBlocks* blocks) { - SSubmitReq* submit = (SSubmitReq*)blocks->pData; - submit->header.vgId = htonl(blocks->vg.vgId); - submit->header.contLen = htonl(blocks->size); - submit->length = submit->header.contLen; - submit->numOfBlocks = htonl(blocks->numOfTables); - SSubmitBlk* blk = (SSubmitBlk*)(submit + 1); - int32_t numOfBlocks = blocks->numOfTables; - while (numOfBlocks--) { - int32_t dataLen = blk->dataLen; - int32_t schemaLen = blk->schemaLen; - blk->uid = htobe64(blk->uid); - blk->suid = htobe64(blk->suid); - blk->sversion = htonl(blk->sversion); - blk->dataLen = htonl(blk->dataLen); - blk->schemaLen = htonl(blk->schemaLen); - blk->numOfRows = htonl(blk->numOfRows); - blk = (SSubmitBlk*)(blk->data + schemaLen + dataLen); - } -} - -static int32_t buildOutput(SInsertParseContext* pCxt) { - size_t numOfVg = taosArrayGetSize(pCxt->pVgDataBlocks); - pCxt->pOutput->pDataBlocks = taosArrayInit(numOfVg, POINTER_BYTES); - if (NULL == pCxt->pOutput->pDataBlocks) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - for (size_t i = 0; i < numOfVg; ++i) { - STableDataBlocks* src = taosArrayGetP(pCxt->pVgDataBlocks, i); - SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); - if (NULL == dst) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - taosHashGetDup(pCxt->pVgroupsHashObj, (const char*)&src->vgId, sizeof(src->vgId), &dst->vg); - dst->numOfTables = src->numOfTables; - dst->size = src->size; - TSWAP(dst->pData, src->pData); - buildMsgHeader(src, dst); - taosArrayPush(pCxt->pOutput->pDataBlocks, &dst); - } - return TSDB_CODE_SUCCESS; -} - -int32_t checkTimestamp(STableDataBlocks* pDataBlocks, const char* start) { - // once the data block is disordered, we do NOT keep previous timestamp any more - if (!pDataBlocks->ordered) { - return TSDB_CODE_SUCCESS; - } - - TSKEY k = *(TSKEY*)start; - if (k <= pDataBlocks->prevTS) { - pDataBlocks->ordered = false; - } - - pDataBlocks->prevTS = k; - return TSDB_CODE_SUCCESS; -} - static int parseTime(char** end, SToken* pToken, int16_t timePrec, int64_t* time, SMsgBuf* pMsgBuf) { int32_t index = 0; SToken sToken; @@ -659,40 +422,6 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int return TSDB_CODE_FAILED; } -static FORCE_INLINE int32_t MemRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param) { - SMemParam* pa = (SMemParam*)param; - SRowBuilder* rb = pa->rb; - - if (value == NULL) { // it is a null data - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NULL, value, false, pa->toffset, pa->colIdx); - return TSDB_CODE_SUCCESS; - } - - if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { - const char* rowEnd = tdRowEnd(rb->pBuf); - STR_WITH_SIZE_TO_VARSTR(rowEnd, value, len); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); - } else if (TSDB_DATA_TYPE_NCHAR == pa->schema->type) { - // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' - int32_t output = 0; - const char* rowEnd = tdRowEnd(rb->pBuf); - if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(rowEnd), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { - if (errno == E2BIG) { - return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pa->schema->name); - } - char buf[512] = {0}; - snprintf(buf, tListLen(buf), "%s", strerror(errno)); - return buildSyntaxErrMsg(pMsgBuf, buf, value); - } - varDataSetLen(rowEnd, output); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); - } else { - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, false, pa->toffset, pa->colIdx); - } - - return TSDB_CODE_SUCCESS; -} - // pSql -> tag1_name, ...) static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* pColList, SSchema* pSchema) { col_id_t nCols = pColList->numOfCols; @@ -720,9 +449,9 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* sToken.n = strdequote(sToken.z); col_id_t t = lastColIdx + 1; - col_id_t index = findCol(&sToken, t, nCols, pSchema); + col_id_t index = insFindCol(&sToken, t, nCols, pSchema); if (index < 0 && t > 0) { - index = findCol(&sToken, 0, t, pSchema); + index = insFindCol(&sToken, 0, t, pSchema); isOrdered = false; } if (index < 0) { @@ -760,11 +489,11 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* pColIdx[i].schemaColIdx = pColList->boundColumns[i]; pColIdx[i].boundIdx = i; } - taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar); + taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), insSchemaIdxCompar); for (col_id_t i = 0; i < pColList->numOfBound; ++i) { pColIdx[i].finalIdx = i; } - taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar); + taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), insBoundIdxCompar); } if (pColList->numOfCols > pColList->numOfBound) { @@ -775,21 +504,6 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo* return TSDB_CODE_SUCCESS; } -static void buildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname, - SArray* tagName, uint8_t tagNum) { - pTbReq->type = TD_CHILD_TABLE; - pTbReq->name = strdup(tname); - pTbReq->ctb.suid = suid; - pTbReq->ctb.tagNum = tagNum; - if (sname) pTbReq->ctb.stbName = strdup(sname); - pTbReq->ctb.pTag = (uint8_t*)pTag; - pTbReq->ctb.tagName = taosArrayDup(tagName); - pTbReq->ttl = TSDB_DEFAULT_TABLE_TTL; - pTbReq->commentLen = -1; - - return; -} - static int32_t parseTagToken(char** end, SToken* pToken, SSchema* pSchema, int16_t timePrec, STagVal* val, SMsgBuf* pMsgBuf) { int64_t iv; @@ -1037,8 +751,8 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pSchema, uint } if (TSDB_CODE_SUCCESS == code && !isParseBindParam) { - buildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName, tagName, - pCxt->pTableMeta->tableInfo.numOfTags); + insBuildCreateTbReq(&pCxt->createTblReq, tName, pTag, pCxt->pTableMeta->suid, pCxt->sTableName, tagName, + pCxt->pTableMeta->tableInfo.numOfTags); pTag = NULL; } @@ -1160,7 +874,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, int32_t tbNo, SName* NEXT_TOKEN(pCxt->pSql, sToken); SName sname; - CHECK_CODE(createSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg)); + CHECK_CODE(insCreateSName(&sname, &sToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg)); char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(&sname, dbFName); strcpy(pCxt->sTableName, sname.tname); @@ -1172,7 +886,7 @@ static int32_t parseUsingClause(SInsertParseContext* pCxt, int32_t tbNo, SName* CHECK_CODE(storeTableMeta(pCxt, pCxt->pSubTableHashObj, tbNo, name, tbFName, len, pCxt->pTableMeta)); SSchema* pTagsSchema = getTableTagSchema(pCxt->pTableMeta); - setBoundColumnInfo(&pCxt->tags, pTagsSchema, getNumOfTags(pCxt->pTableMeta)); + insSetBoundColumnInfo(&pCxt->tags, pTagsSchema, getNumOfTags(pCxt->pTableMeta)); // pSql -> [(tag1_name, ...)] TAGS (tag1_value, ...) NEXT_TOKEN(pCxt->pSql, sToken); @@ -1235,8 +949,9 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, } param.schema = pSchema; - getSTSRowAppendInfo(pBuilder->rowType, spd, i, ¶m.toffset, ¶m.colIdx); - CHECK_CODE(parseValueToken(&pCxt->pSql, &sToken, pSchema, timePrec, tmpTokenBuf, MemRowAppend, ¶m, &pCxt->msg)); + insGetSTSRowAppendInfo(pBuilder->rowType, spd, i, ¶m.toffset, ¶m.colIdx); + CHECK_CODE( + parseValueToken(&pCxt->pSql, &sToken, pSchema, timePrec, tmpTokenBuf, insMemRowAppend, ¶m, &pCxt->msg)); if (i < spd->numOfBound - 1) { NEXT_VALID_TOKEN(pCxt->pSql, sToken); @@ -1247,7 +962,7 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, } TSKEY tsKey = TD_ROW_KEY(row); - checkTimestamp(pDataBlocks, (const char*)&tsKey); + insCheckTimestamp(pDataBlocks, (const char*)&tsKey); if (!isParseBindParam) { // set the null value for the columns that do not assign values @@ -1270,11 +985,40 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks, return TSDB_CODE_SUCCESS; } +static int32_t allocateMemIfNeed(STableDataBlocks* pDataBlock, int32_t rowSize, int32_t* numOfRows) { + size_t remain = pDataBlock->nAllocSize - pDataBlock->size; + const int factor = 5; + uint32_t nAllocSizeOld = pDataBlock->nAllocSize; + + // expand the allocated size + if (remain < rowSize * factor) { + while (remain < rowSize * factor) { + pDataBlock->nAllocSize = (uint32_t)(pDataBlock->nAllocSize * 1.5); + remain = pDataBlock->nAllocSize - pDataBlock->size; + } + + char* tmp = taosMemoryRealloc(pDataBlock->pData, (size_t)pDataBlock->nAllocSize); + if (tmp != NULL) { + pDataBlock->pData = tmp; + memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size); + } else { + // do nothing, if allocate more memory failed + pDataBlock->nAllocSize = nAllocSizeOld; + *numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize; + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + } + + *numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize; + return TSDB_CODE_SUCCESS; +} + // pSql -> (field1_value, ...) [(field1_value2, ...) ...] static int32_t parseValues(SInsertParseContext* pCxt, STableDataBlocks* pDataBlock, int maxRows, int32_t* numOfRows) { STableComInfo tinfo = getTableInfo(pDataBlock->pTableMeta); - int32_t extendedRowSize = getExtendedRowSize(pDataBlock); - CHECK_CODE(initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); + int32_t extendedRowSize = insGetExtendedRowSize(pDataBlock); + CHECK_CODE( + insInitRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); (*numOfRows) = 0; // char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // used for deleting Escape character: \\, \', \" @@ -1320,13 +1064,13 @@ static int32_t parseValues(SInsertParseContext* pCxt, STableDataBlocks* pDataBlo static int32_t parseValuesClause(SInsertParseContext* pCxt, STableDataBlocks* dataBuf) { int32_t maxNumOfRows; - CHECK_CODE(allocateMemIfNeed(dataBuf, getExtendedRowSize(dataBuf), &maxNumOfRows)); + CHECK_CODE(allocateMemIfNeed(dataBuf, insGetExtendedRowSize(dataBuf), &maxNumOfRows)); int32_t numOfRows = 0; CHECK_CODE(parseValues(pCxt, dataBuf, maxNumOfRows, &numOfRows)); SSubmitBlk* pBlocks = (SSubmitBlk*)(dataBuf->pData); - if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, dataBuf, numOfRows)) { + if (TSDB_CODE_SUCCESS != insSetBlockInfo(pBlocks, dataBuf, numOfRows)) { return buildInvalidOperationMsg(&pCxt->msg, "too many rows in sql, total number of rows should be less than INT32_MAX"); } @@ -1339,8 +1083,9 @@ static int32_t parseValuesClause(SInsertParseContext* pCxt, STableDataBlocks* da static int32_t parseCsvFile(SInsertParseContext* pCxt, TdFilePtr fp, STableDataBlocks* pDataBlock, int maxRows, int32_t* numOfRows) { STableComInfo tinfo = getTableInfo(pDataBlock->pTableMeta); - int32_t extendedRowSize = getExtendedRowSize(pDataBlock); - CHECK_CODE(initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); + int32_t extendedRowSize = insGetExtendedRowSize(pDataBlock); + CHECK_CODE( + insInitRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); (*numOfRows) = 0; char tmpTokenBuf[TSDB_MAX_BYTES_PER_ROW] = {0}; // used for deleting Escape character: \\, \', \" @@ -1391,13 +1136,13 @@ static int32_t parseCsvFile(SInsertParseContext* pCxt, TdFilePtr fp, STableDataB static int32_t parseDataFromFileAgain(SInsertParseContext* pCxt, int16_t tableNo, const SName* pTableName, STableDataBlocks* dataBuf) { int32_t maxNumOfRows; - CHECK_CODE(allocateMemIfNeed(dataBuf, getExtendedRowSize(dataBuf), &maxNumOfRows)); + CHECK_CODE(allocateMemIfNeed(dataBuf, insGetExtendedRowSize(dataBuf), &maxNumOfRows)); int32_t numOfRows = 0; CHECK_CODE(parseCsvFile(pCxt, pCxt->pComCxt->csvCxt.fp, dataBuf, maxNumOfRows, &numOfRows)); SSubmitBlk* pBlocks = (SSubmitBlk*)(dataBuf->pData); - if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, dataBuf, numOfRows)) { + if (TSDB_CODE_SUCCESS != insSetBlockInfo(pBlocks, dataBuf, numOfRows)) { return buildInvalidOperationMsg(&pCxt->msg, "too many rows in sql, total number of rows should be less than INT32_MAX"); } @@ -1448,13 +1193,13 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) { taosHashCleanup(pCxt->pTableNameHashObj); taosHashCleanup(pCxt->pDbFNameHashObj); - destroyBlockHashmap(pCxt->pTableBlockHashObj); - destroyBlockArrayList(pCxt->pVgDataBlocks); + insDestroyBlockHashmap(pCxt->pTableBlockHashObj); + insDestroyBlockArrayList(pCxt->pVgDataBlocks); } static int32_t parseTableName(SInsertParseContext* pCxt, SToken* pTbnameToken, SName* pName, char* pDbFName, char* pTbFName) { - int32_t code = createSName(pName, pTbnameToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg); + int32_t code = insCreateSName(pName, pTbnameToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg); if (TSDB_CODE_SUCCESS == code) { tNameExtractFullName(pName, pTbFName); code = taosHashPut(pCxt->pTableNameHashObj, pTbFName, strlen(pTbFName), pName, sizeof(SName)); @@ -1556,14 +1301,14 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { STableDataBlocks* dataBuf = NULL; if (pCxt->pComCxt->async) { - CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, &pCxt->pTableMeta->uid, sizeof(pCxt->pTableMeta->uid), - TSDB_DEFAULT_PAYLOAD_SIZE, sizeof(SSubmitBlk), - getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL, - &pCxt->createTblReq)); + CHECK_CODE(insGetDataBlockFromList(pCxt->pTableBlockHashObj, &pCxt->pTableMeta->uid, + sizeof(pCxt->pTableMeta->uid), TSDB_DEFAULT_PAYLOAD_SIZE, sizeof(SSubmitBlk), + getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL, + &pCxt->createTblReq)); } else { - CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, tbFName, strlen(tbFName), TSDB_DEFAULT_PAYLOAD_SIZE, - sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, - &dataBuf, NULL, &pCxt->createTblReq)); + CHECK_CODE(insGetDataBlockFromList(pCxt->pTableBlockHashObj, tbFName, strlen(tbFName), TSDB_DEFAULT_PAYLOAD_SIZE, + sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, + &dataBuf, NULL, &pCxt->createTblReq)); } if (NULL != pBoundColsStart) { @@ -1624,17 +1369,18 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { // merge according to vgId if (taosHashGetSize(pCxt->pTableBlockHashObj) > 0) { - CHECK_CODE(mergeTableDataBlocks(pCxt->pTableBlockHashObj, pCxt->pOutput->payloadType, &pCxt->pVgDataBlocks)); + CHECK_CODE(insMergeTableDataBlocks(pCxt->pTableBlockHashObj, pCxt->pOutput->payloadType, &pCxt->pVgDataBlocks)); } - return buildOutput(pCxt); + return insBuildOutput(pCxt); } static int32_t parseInsertBodyAgain(SInsertParseContext* pCxt) { STableDataBlocks* dataBuf = NULL; CHECK_CODE(getTableMeta(pCxt, pCxt->pComCxt->csvCxt.tableNo, &pCxt->pComCxt->csvCxt.tableName)); - CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, &pCxt->pTableMeta->uid, sizeof(pCxt->pTableMeta->uid), - TSDB_DEFAULT_PAYLOAD_SIZE, sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, - pCxt->pTableMeta, &dataBuf, NULL, &pCxt->createTblReq)); + CHECK_CODE(insGetDataBlockFromList(pCxt->pTableBlockHashObj, &pCxt->pTableMeta->uid, sizeof(pCxt->pTableMeta->uid), + TSDB_DEFAULT_PAYLOAD_SIZE, sizeof(SSubmitBlk), + getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL, + &pCxt->createTblReq)); CHECK_CODE(parseDataFromFileAgain(pCxt, pCxt->pComCxt->csvCxt.tableNo, &pCxt->pComCxt->csvCxt.tableName, dataBuf)); if (taosEOFFile(pCxt->pComCxt->csvCxt.fp)) { CHECK_CODE(parseInsertBody(pCxt)); @@ -1644,9 +1390,9 @@ static int32_t parseInsertBodyAgain(SInsertParseContext* pCxt) { parserDebug("0x%" PRIx64 " insert again input rows: %d", pCxt->pComCxt->requestId, pCxt->totalNum); // merge according to vgId if (taosHashGetSize(pCxt->pTableBlockHashObj) > 0) { - CHECK_CODE(mergeTableDataBlocks(pCxt->pTableBlockHashObj, pCxt->pOutput->payloadType, &pCxt->pVgDataBlocks)); + CHECK_CODE(insMergeTableDataBlocks(pCxt->pTableBlockHashObj, pCxt->pOutput->payloadType, &pCxt->pVgDataBlocks)); } - return buildOutput(pCxt); + return insBuildOutput(pCxt); } // INSERT INTO @@ -1822,7 +1568,7 @@ static int32_t skipUsingClause(SInsertParseSyntaxCxt* pCxt) { static int32_t collectTableMetaKey(SInsertParseSyntaxCxt* pCxt, bool isStable, int32_t tableNo, SToken* pTbToken) { SName name = {0}; - CHECK_CODE(createSName(&name, pTbToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg)); + CHECK_CODE(insCreateSName(&name, pTbToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg)); CHECK_CODE(reserveTableMetaInCacheForInsert(&name, isStable ? CATALOG_REQ_TYPE_META : CATALOG_REQ_TYPE_BOTH, tableNo, pCxt->pMetaCache)); return TSDB_CODE_SUCCESS; @@ -1837,7 +1583,7 @@ static int32_t checkTableName(const char* pTableName, SMsgBuf* pMsgBuf) { static int32_t collectAutoCreateTableMetaKey(SInsertParseSyntaxCxt* pCxt, int32_t tableNo, SToken* pTbToken) { SName name = {0}; - CHECK_CODE(createSName(&name, pTbToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg)); + CHECK_CODE(insCreateSName(&name, pTbToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg)); CHECK_CODE(checkTableName(name.tname, &pCxt->msg)); CHECK_CODE(reserveTableMetaInCacheForInsert(&name, CATALOG_REQ_TYPE_VGROUP, tableNo, pCxt->pMetaCache)); return TSDB_CODE_SUCCESS; @@ -1941,704 +1687,3 @@ int32_t parseInsertSyntax(SParseContext* pContext, SQuery** pQuery, SParseMetaCa } return code; } - -int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf, - int32_t msgBufLen) { - SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen}; - SToken sToken; - int32_t code = 0; - char* tbName = NULL; - - NEXT_TOKEN(pTableName, sToken); - - if (sToken.n == 0) { - return buildInvalidOperationMsg(&msg, "empty table name"); - } - - code = createSName(pName, &sToken, acctId, dbName, &msg); - if (code) { - return code; - } - - NEXT_TOKEN(pTableName, sToken); - - if (sToken.n > 0) { - return buildInvalidOperationMsg(&msg, "table name format is wrong"); - } - - return TSDB_CODE_SUCCESS; -} - -int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash) { - SVnodeModifOpStmt* modifyNode = (SVnodeModifOpStmt*)pQuery->pRoot; - int32_t code = 0; - SInsertParseContext insertCtx = { - .pVgroupsHashObj = pVgHash, - .pTableBlockHashObj = pBlockHash, - .pOutput = (SVnodeModifOpStmt*)pQuery->pRoot, - }; - - // merge according to vgId - if (taosHashGetSize(insertCtx.pTableBlockHashObj) > 0) { - CHECK_CODE(mergeTableDataBlocks(insertCtx.pTableBlockHashObj, modifyNode->payloadType, &insertCtx.pVgDataBlocks)); - } - - CHECK_CODE(buildOutput(&insertCtx)); - - destroyBlockArrayList(insertCtx.pVgDataBlocks); - return TSDB_CODE_SUCCESS; -} - -int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName, - TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen) { - STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; - SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; - SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags; - if (NULL == tags) { - return TSDB_CODE_QRY_APP_ERROR; - } - - SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal)); - if (!pTagArray) { - return buildInvalidOperationMsg(&pBuf, "out of memory"); - } - - SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); - if (!tagName) { - return buildInvalidOperationMsg(&pBuf, "out of memory"); - } - - int32_t code = TSDB_CODE_SUCCESS; - SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta); - - bool isJson = false; - STag* pTag = NULL; - - for (int c = 0; c < tags->numOfBound; ++c) { - if (bind[c].is_null && bind[c].is_null[0]) { - continue; - } - - SSchema* pTagSchema = &pSchema[tags->boundColumns[c]]; - int32_t colLen = pTagSchema->bytes; - if (IS_VAR_DATA_TYPE(pTagSchema->type)) { - colLen = bind[c].length[0]; - } - taosArrayPush(tagName, pTagSchema->name); - if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { - if (colLen > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - code = buildSyntaxErrMsg(&pBuf, "json string too long than 4095", bind[c].buffer); - goto end; - } - - isJson = true; - char* tmp = taosMemoryCalloc(1, colLen + 1); - memcpy(tmp, bind[c].buffer, colLen); - code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf); - taosMemoryFree(tmp); - if (code != TSDB_CODE_SUCCESS) { - goto end; - } - } else { - STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - // strcpy(val.colName, pTagSchema->name); - if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { - val.pData = (uint8_t*)bind[c].buffer; - val.nData = colLen; - } else if (pTagSchema->type == TSDB_DATA_TYPE_NCHAR) { - int32_t output = 0; - void* p = taosMemoryCalloc(1, colLen * TSDB_NCHAR_SIZE); - if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto end; - } - if (!taosMbsToUcs4(bind[c].buffer, colLen, (TdUcs4*)(p), colLen * TSDB_NCHAR_SIZE, &output)) { - if (errno == E2BIG) { - taosMemoryFree(p); - code = generateSyntaxErrMsg(&pBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pTagSchema->name); - goto end; - } - char buf[512] = {0}; - snprintf(buf, tListLen(buf), " taosMbsToUcs4 error:%s", strerror(errno)); - taosMemoryFree(p); - code = buildSyntaxErrMsg(&pBuf, buf, bind[c].buffer); - goto end; - } - val.pData = p; - val.nData = output; - } else { - memcpy(&val.i64, bind[c].buffer, colLen); - } - taosArrayPush(pTagArray, &val); - } - } - - if (!isJson && (code = tTagNew(pTagArray, 1, false, &pTag)) != TSDB_CODE_SUCCESS) { - goto end; - } - - SVCreateTbReq tbReq = {0}; - buildCreateTbReq(&tbReq, tName, pTag, suid, sTableName, tagName, pDataBlock->pTableMeta->tableInfo.numOfTags); - code = buildCreateTbMsg(pDataBlock, &tbReq); - tdDestroySVCreateTbReq(&tbReq); - -end: - for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) { - STagVal* p = (STagVal*)taosArrayGet(pTagArray, i); - if (p->type == TSDB_DATA_TYPE_NCHAR) { - taosMemoryFreeClear(p->pData); - } - } - taosArrayDestroy(pTagArray); - taosArrayDestroy(tagName); - - return code; -} - -int32_t qBindStmtColsValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen) { - STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; - SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta); - int32_t extendedRowSize = getExtendedRowSize(pDataBlock); - SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo; - SRowBuilder* pBuilder = &pDataBlock->rowBuilder; - SMemParam param = {.rb = pBuilder}; - SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; - int32_t rowNum = bind->num; - - CHECK_CODE(initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); - - CHECK_CODE(allocateMemForSize(pDataBlock, extendedRowSize * bind->num)); - - for (int32_t r = 0; r < bind->num; ++r) { - STSRow* row = (STSRow*)(pDataBlock->pData + pDataBlock->size); // skip the SSubmitBlk header - tdSRowResetBuf(pBuilder, row); - - for (int c = 0; c < spd->numOfBound; ++c) { - SSchema* pColSchema = &pSchema[spd->boundColumns[c]]; - - if (bind[c].num != rowNum) { - return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same"); - } - - param.schema = pColSchema; - getSTSRowAppendInfo(pBuilder->rowType, spd, c, ¶m.toffset, ¶m.colIdx); - - if (bind[c].is_null && bind[c].is_null[r]) { - if (pColSchema->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - return buildInvalidOperationMsg(&pBuf, "primary timestamp should not be NULL"); - } - - CHECK_CODE(MemRowAppend(&pBuf, NULL, 0, ¶m)); - } else { - if (bind[c].buffer_type != pColSchema->type) { - return buildInvalidOperationMsg(&pBuf, "column type mis-match with buffer type"); - } - - int32_t colLen = pColSchema->bytes; - if (IS_VAR_DATA_TYPE(pColSchema->type)) { - colLen = bind[c].length[r]; - } - - CHECK_CODE(MemRowAppend(&pBuf, (char*)bind[c].buffer + bind[c].buffer_length * r, colLen, ¶m)); - } - - if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) { - TSKEY tsKey = TD_ROW_KEY(row); - checkTimestamp(pDataBlock, (const char*)&tsKey); - } - } - // set the null value for the columns that do not assign values - if ((spd->numOfBound < spd->numOfCols) && TD_IS_TP_ROW(row)) { - pBuilder->hasNone = true; - } - tdSRowEnd(pBuilder); -#ifdef TD_DEBUG_PRINT_ROW - STSchema* pSTSchema = tdGetSTSChemaFromSSChema(pSchema, spd->numOfCols, 1); - tdSRowPrint(row, pSTSchema, __func__); - taosMemoryFree(pSTSchema); -#endif - pDataBlock->size += extendedRowSize; - } - - SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData); - if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, bind->num)) { - return buildInvalidOperationMsg(&pBuf, "too many rows in sql, total number of rows should be less than INT32_MAX"); - } - - return TSDB_CODE_SUCCESS; -} - -int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen, int32_t colIdx, - int32_t rowNum) { - STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; - SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta); - int32_t extendedRowSize = getExtendedRowSize(pDataBlock); - SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo; - SRowBuilder* pBuilder = &pDataBlock->rowBuilder; - SMemParam param = {.rb = pBuilder}; - SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; - bool rowStart = (0 == colIdx); - bool rowEnd = ((colIdx + 1) == spd->numOfBound); - - if (rowStart) { - CHECK_CODE(initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); - CHECK_CODE(allocateMemForSize(pDataBlock, extendedRowSize * bind->num)); - } - - for (int32_t r = 0; r < bind->num; ++r) { - STSRow* row = (STSRow*)(pDataBlock->pData + pDataBlock->size + extendedRowSize * r); // skip the SSubmitBlk header - if (rowStart) { - tdSRowResetBuf(pBuilder, row); - } else { - tdSRowGetBuf(pBuilder, row); - } - - SSchema* pColSchema = &pSchema[spd->boundColumns[colIdx]]; - - if (bind->num != rowNum) { - return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same"); - } - - param.schema = pColSchema; - getSTSRowAppendInfo(pBuilder->rowType, spd, colIdx, ¶m.toffset, ¶m.colIdx); - - if (bind->is_null && bind->is_null[r]) { - if (pColSchema->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - return buildInvalidOperationMsg(&pBuf, "primary timestamp should not be NULL"); - } - - CHECK_CODE(MemRowAppend(&pBuf, NULL, 0, ¶m)); - } else { - if (bind->buffer_type != pColSchema->type) { - return buildInvalidOperationMsg(&pBuf, "column type mis-match with buffer type"); - } - - int32_t colLen = pColSchema->bytes; - if (IS_VAR_DATA_TYPE(pColSchema->type)) { - colLen = bind->length[r]; - } - - CHECK_CODE(MemRowAppend(&pBuf, (char*)bind->buffer + bind->buffer_length * r, colLen, ¶m)); - } - - if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) { - TSKEY tsKey = TD_ROW_KEY(row); - checkTimestamp(pDataBlock, (const char*)&tsKey); - } - - // set the null value for the columns that do not assign values - if (rowEnd && (spd->numOfBound < spd->numOfCols) && TD_IS_TP_ROW(row)) { - pBuilder->hasNone = true; - } - if (rowEnd) { - tdSRowEnd(pBuilder); - } -#ifdef TD_DEBUG_PRINT_ROW - if (rowEnd) { - STSchema* pSTSchema = tdGetSTSChemaFromSSChema(pSchema, spd->numOfCols, 1); - tdSRowPrint(row, pSTSchema, __func__); - taosMemoryFree(pSTSchema); - } -#endif - } - - if (rowEnd) { - pDataBlock->size += extendedRowSize * bind->num; - - SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData); - if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, bind->num)) { - return buildInvalidOperationMsg(&pBuf, - "too many rows in sql, total number of rows should be less than INT32_MAX"); - } - } - - return TSDB_CODE_SUCCESS; -} - -int32_t buildBoundFields(SParsedDataColInfo* boundInfo, SSchema* pSchema, int32_t* fieldNum, TAOS_FIELD_E** fields, - uint8_t timePrec) { - if (fields) { - *fields = taosMemoryCalloc(boundInfo->numOfBound, sizeof(TAOS_FIELD)); - if (NULL == *fields) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - SSchema* schema = &pSchema[boundInfo->boundColumns[0]]; - if (TSDB_DATA_TYPE_TIMESTAMP == schema->type) { - (*fields)[0].precision = timePrec; - } - - for (int32_t i = 0; i < boundInfo->numOfBound; ++i) { - schema = &pSchema[boundInfo->boundColumns[i]]; - strcpy((*fields)[i].name, schema->name); - (*fields)[i].type = schema->type; - (*fields)[i].bytes = schema->bytes; - } - } - - *fieldNum = boundInfo->numOfBound; - - return TSDB_CODE_SUCCESS; -} - -int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields) { - STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; - SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags; - if (NULL == tags) { - return TSDB_CODE_QRY_APP_ERROR; - } - - if (pDataBlock->pTableMeta->tableType != TSDB_SUPER_TABLE && pDataBlock->pTableMeta->tableType != TSDB_CHILD_TABLE) { - return TSDB_CODE_TSC_STMT_API_ERROR; - } - - SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta); - if (tags->numOfBound <= 0) { - *fieldNum = 0; - *fields = NULL; - - return TSDB_CODE_SUCCESS; - } - - CHECK_CODE(buildBoundFields(tags, pSchema, fieldNum, fields, 0)); - - return TSDB_CODE_SUCCESS; -} - -int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD_E** fields) { - STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; - SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta); - if (pDataBlock->boundColumnInfo.numOfBound <= 0) { - *fieldNum = 0; - if (fields) { - *fields = NULL; - } - - return TSDB_CODE_SUCCESS; - } - - CHECK_CODE(buildBoundFields(&pDataBlock->boundColumnInfo, pSchema, fieldNum, fields, - pDataBlock->pTableMeta->tableInfo.precision)); - - return TSDB_CODE_SUCCESS; -} - -// schemaless logic start - -typedef struct SmlExecTableHandle { - SParsedDataColInfo tags; // each table - SVCreateTbReq createTblReq; // each table -} SmlExecTableHandle; - -typedef struct SmlExecHandle { - SHashObj* pBlockHash; - SmlExecTableHandle tableExecHandle; - SQuery* pQuery; -} SSmlExecHandle; - -static void smlDestroyTableHandle(void* pHandle) { - SmlExecTableHandle* handle = (SmlExecTableHandle*)pHandle; - destroyBoundColumnInfo(&handle->tags); - tdDestroySVCreateTbReq(&handle->createTblReq); -} - -static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SSchema* pSchema, bool isTag) { - col_id_t nCols = pColList->numOfCols; - - pColList->numOfBound = 0; - pColList->boundNullLen = 0; - memset(pColList->boundColumns, 0, sizeof(col_id_t) * nCols); - for (col_id_t i = 0; i < nCols; ++i) { - pColList->cols[i].valStat = VAL_STAT_NONE; - } - - bool isOrdered = true; - col_id_t lastColIdx = -1; // last column found - for (int i = 0; i < taosArrayGetSize(cols); ++i) { - SSmlKv* kv = taosArrayGetP(cols, i); - SToken sToken = {.n = kv->keyLen, .z = (char*)kv->key}; - col_id_t t = lastColIdx + 1; - col_id_t index = ((t == 0 && !isTag) ? 0 : findCol(&sToken, t, nCols, pSchema)); - uDebug("SML, index:%d, t:%d, ncols:%d", index, t, nCols); - if (index < 0 && t > 0) { - index = findCol(&sToken, 0, t, pSchema); - isOrdered = false; - } - if (index < 0) { - uError("smlBoundColumnData. index:%d", index); - return TSDB_CODE_SML_INVALID_DATA; - } - if (pColList->cols[index].valStat == VAL_STAT_HAS) { - uError("smlBoundColumnData. already set. index:%d", index); - return TSDB_CODE_SML_INVALID_DATA; - } - lastColIdx = index; - pColList->cols[index].valStat = VAL_STAT_HAS; - pColList->boundColumns[pColList->numOfBound] = index; - ++pColList->numOfBound; - switch (pSchema[t].type) { - case TSDB_DATA_TYPE_BINARY: - pColList->boundNullLen += (sizeof(VarDataOffsetT) + VARSTR_HEADER_SIZE + CHAR_BYTES); - break; - case TSDB_DATA_TYPE_NCHAR: - pColList->boundNullLen += (sizeof(VarDataOffsetT) + VARSTR_HEADER_SIZE + TSDB_NCHAR_SIZE); - break; - default: - pColList->boundNullLen += TYPE_BYTES[pSchema[t].type]; - break; - } - } - - pColList->orderStatus = isOrdered ? ORDER_STATUS_ORDERED : ORDER_STATUS_DISORDERED; - - if (!isOrdered) { - pColList->colIdxInfo = taosMemoryCalloc(pColList->numOfBound, sizeof(SBoundIdxInfo)); - if (NULL == pColList->colIdxInfo) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - SBoundIdxInfo* pColIdx = pColList->colIdxInfo; - for (col_id_t i = 0; i < pColList->numOfBound; ++i) { - pColIdx[i].schemaColIdx = pColList->boundColumns[i]; - pColIdx[i].boundIdx = i; - } - taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), schemaIdxCompar); - for (col_id_t i = 0; i < pColList->numOfBound; ++i) { - pColIdx[i].finalIdx = i; - } - taosSort(pColIdx, pColList->numOfBound, sizeof(SBoundIdxInfo), boundIdxCompar); - } - - if (pColList->numOfCols > pColList->numOfBound) { - memset(&pColList->boundColumns[pColList->numOfBound], 0, - sizeof(col_id_t) * (pColList->numOfCols - pColList->numOfBound)); - } - - return TSDB_CODE_SUCCESS; -} - -/** - * @brief No json tag for schemaless - * - * @param cols - * @param tags - * @param pSchema - * @param ppTag - * @param msg - * @return int32_t - */ -static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName, - SMsgBuf* msg) { - SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal)); - if (!pTagArray) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - *tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); - if (!*tagName) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - - int32_t code = TSDB_CODE_SUCCESS; - for (int i = 0; i < tags->numOfBound; ++i) { - SSchema* pTagSchema = &pSchema[tags->boundColumns[i]]; - SSmlKv* kv = taosArrayGetP(cols, i); - - taosArrayPush(*tagName, pTagSchema->name); - STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - // strcpy(val.colName, pTagSchema->name); - if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { - val.pData = (uint8_t*)kv->value; - val.nData = kv->length; - } else if (pTagSchema->type == TSDB_DATA_TYPE_NCHAR) { - int32_t output = 0; - void* p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE); - if (p == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - goto end; - } - if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)(p), kv->length * TSDB_NCHAR_SIZE, &output)) { - if (errno == E2BIG) { - taosMemoryFree(p); - code = generateSyntaxErrMsg(msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pTagSchema->name); - goto end; - } - char buf[512] = {0}; - snprintf(buf, tListLen(buf), " taosMbsToUcs4 error:%s", strerror(errno)); - taosMemoryFree(p); - code = buildSyntaxErrMsg(msg, buf, kv->value); - goto end; - } - val.pData = p; - val.nData = output; - } else { - memcpy(&val.i64, &(kv->value), kv->length); - } - taosArrayPush(pTagArray, &val); - } - - code = tTagNew(pTagArray, 1, false, ppTag); -end: - for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) { - STagVal* p = (STagVal*)taosArrayGet(pTagArray, i); - if (p->type == TSDB_DATA_TYPE_NCHAR) { - taosMemoryFree(p->pData); - } - } - taosArrayDestroy(pTagArray); - return code; -} - -int32_t smlBindData(void* handle, SArray* tags, SArray* colsSchema, SArray* cols, bool format, STableMeta* pTableMeta, - char* tableName, const char* sTableName, int32_t sTableNameLen, char* msgBuf, int16_t msgBufLen) { - SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; - - SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle; - smlDestroyTableHandle(&smlHandle->tableExecHandle); // free for each table - SSchema* pTagsSchema = getTableTagSchema(pTableMeta); - setBoundColumnInfo(&smlHandle->tableExecHandle.tags, pTagsSchema, getNumOfTags(pTableMeta)); - int ret = smlBoundColumnData(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, true); - if (ret != TSDB_CODE_SUCCESS) { - buildInvalidOperationMsg(&pBuf, "bound tags error"); - return ret; - } - STag* pTag = NULL; - SArray* tagName = NULL; - ret = smlBuildTagRow(tags, &smlHandle->tableExecHandle.tags, pTagsSchema, &pTag, &tagName, &pBuf); - if (ret != TSDB_CODE_SUCCESS) { - taosArrayDestroy(tagName); - return ret; - } - - buildCreateTbReq(&smlHandle->tableExecHandle.createTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName, - pTableMeta->tableInfo.numOfTags); - taosArrayDestroy(tagName); - - smlHandle->tableExecHandle.createTblReq.ctb.stbName = taosMemoryMalloc(sTableNameLen + 1); - memcpy(smlHandle->tableExecHandle.createTblReq.ctb.stbName, sTableName, sTableNameLen); - smlHandle->tableExecHandle.createTblReq.ctb.stbName[sTableNameLen] = 0; - - STableDataBlocks* pDataBlock = NULL; - ret = getDataBlockFromList(smlHandle->pBlockHash, &pTableMeta->uid, sizeof(pTableMeta->uid), - TSDB_DEFAULT_PAYLOAD_SIZE, sizeof(SSubmitBlk), getTableInfo(pTableMeta).rowSize, - pTableMeta, &pDataBlock, NULL, &smlHandle->tableExecHandle.createTblReq); - if (ret != TSDB_CODE_SUCCESS) { - buildInvalidOperationMsg(&pBuf, "create data block error"); - return ret; - } - - SSchema* pSchema = getTableColumnSchema(pTableMeta); - - ret = smlBoundColumnData(colsSchema, &pDataBlock->boundColumnInfo, pSchema, false); - if (ret != TSDB_CODE_SUCCESS) { - buildInvalidOperationMsg(&pBuf, "bound cols error"); - return ret; - } - int32_t extendedRowSize = getExtendedRowSize(pDataBlock); - SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo; - SRowBuilder* pBuilder = &pDataBlock->rowBuilder; - SMemParam param = {.rb = pBuilder}; - - initRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo); - - int32_t rowNum = taosArrayGetSize(cols); - if (rowNum <= 0) { - return buildInvalidOperationMsg(&pBuf, "cols size <= 0"); - } - ret = allocateMemForSize(pDataBlock, extendedRowSize * rowNum); - if (ret != TSDB_CODE_SUCCESS) { - buildInvalidOperationMsg(&pBuf, "allocate memory error"); - return ret; - } - for (int32_t r = 0; r < rowNum; ++r) { - STSRow* row = (STSRow*)(pDataBlock->pData + pDataBlock->size); // skip the SSubmitBlk header - tdSRowResetBuf(pBuilder, row); - void* rowData = taosArrayGetP(cols, r); - size_t rowDataSize = 0; - if (format) { - rowDataSize = taosArrayGetSize(rowData); - } - - // 1. set the parsed value from sql string - for (int c = 0, j = 0; c < spd->numOfBound; ++c) { - SSchema* pColSchema = &pSchema[spd->boundColumns[c]]; - - param.schema = pColSchema; - getSTSRowAppendInfo(pBuilder->rowType, spd, c, ¶m.toffset, ¶m.colIdx); - - SSmlKv* kv = NULL; - if (format) { - if (j < rowDataSize) { - kv = taosArrayGetP(rowData, j); - if (rowDataSize != spd->numOfBound && j != 0 && - (kv->keyLen != strlen(pColSchema->name) || strncmp(kv->key, pColSchema->name, kv->keyLen) != 0)) { - kv = NULL; - } else { - j++; - } - } - } else { - void** p = taosHashGet(rowData, pColSchema->name, strlen(pColSchema->name)); - if (p) kv = *p; - } - - if (kv) { - int32_t colLen = kv->length; - if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) { - // uError("SML:data before:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision); - kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision); - // uError("SML:data after:%" PRId64 ", precision:%d", kv->i, pTableMeta->tableInfo.precision); - } - - if (IS_VAR_DATA_TYPE(kv->type)) { - MemRowAppend(&pBuf, kv->value, colLen, ¶m); - } else { - MemRowAppend(&pBuf, &(kv->value), colLen, ¶m); - } - } else { - pBuilder->hasNone = true; - } - - if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) { - TSKEY tsKey = TD_ROW_KEY(row); - checkTimestamp(pDataBlock, (const char*)&tsKey); - } - } - - // set the null value for the columns that do not assign values - if ((spd->numOfBound < spd->numOfCols) && TD_IS_TP_ROW(row)) { - pBuilder->hasNone = true; - } - - tdSRowEnd(pBuilder); - pDataBlock->size += extendedRowSize; - } - - SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData); - if (TSDB_CODE_SUCCESS != setBlockInfo(pBlocks, pDataBlock, rowNum)) { - return buildInvalidOperationMsg(&pBuf, "too many rows in sql, total number of rows should be less than INT32_MAX"); - } - - return TSDB_CODE_SUCCESS; -} - -void* smlInitHandle(SQuery* pQuery) { - SSmlExecHandle* handle = taosMemoryCalloc(1, sizeof(SSmlExecHandle)); - if (!handle) return NULL; - handle->pBlockHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, false); - handle->pQuery = pQuery; - - return handle; -} - -void smlDestroyHandle(void* pHandle) { - if (!pHandle) return; - SSmlExecHandle* handle = (SSmlExecHandle*)pHandle; - destroyBlockHashmap(handle->pBlockHash); - smlDestroyTableHandle(&handle->tableExecHandle); - taosMemoryFree(handle); -} - -int32_t smlBuildOutput(void* handle, SHashObj* pVgHash) { - SSmlExecHandle* smlHandle = (SSmlExecHandle*)handle; - return qBuildStmtOutput(smlHandle->pQuery, pVgHash, smlHandle->pBlockHash); -} -// schemaless logic end diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c new file mode 100644 index 0000000000..fda3e0866d --- /dev/null +++ b/source/libs/parser/src/parInsertStmt.c @@ -0,0 +1,486 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * 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 . + */ + +#include "os.h" +#include "parInsertUtil.h" +#include "parInt.h" +#include "parToken.h" +#include "query.h" +#include "tglobal.h" +#include "ttime.h" +#include "ttypes.h" + +typedef struct SKvParam { + int16_t pos; + SArray* pTagVals; + SSchema* schema; + char buf[TSDB_MAX_TAGS_LEN]; +} SKvParam; + +int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash) { + SVnodeModifOpStmt* modifyNode = (SVnodeModifOpStmt*)pQuery->pRoot; + int32_t code = 0; + SInsertParseContext insertCtx = { + .pVgroupsHashObj = pVgHash, + .pTableBlockHashObj = pBlockHash, + .pOutput = (SVnodeModifOpStmt*)pQuery->pRoot, + }; + + // merge according to vgId + if (taosHashGetSize(insertCtx.pTableBlockHashObj) > 0) { + CHECK_CODE( + insMergeTableDataBlocks(insertCtx.pTableBlockHashObj, modifyNode->payloadType, &insertCtx.pVgDataBlocks)); + } + + CHECK_CODE(insBuildOutput(&insertCtx)); + + insDestroyBlockArrayList(insertCtx.pVgDataBlocks); + return TSDB_CODE_SUCCESS; +} + +int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const char* sTableName, char* tName, + TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen) { + STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; + SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; + SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags; + if (NULL == tags) { + return TSDB_CODE_QRY_APP_ERROR; + } + + SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal)); + if (!pTagArray) { + return buildInvalidOperationMsg(&pBuf, "out of memory"); + } + + SArray* tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); + if (!tagName) { + return buildInvalidOperationMsg(&pBuf, "out of memory"); + } + + int32_t code = TSDB_CODE_SUCCESS; + SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta); + + bool isJson = false; + STag* pTag = NULL; + + for (int c = 0; c < tags->numOfBound; ++c) { + if (bind[c].is_null && bind[c].is_null[0]) { + continue; + } + + SSchema* pTagSchema = &pSchema[tags->boundColumns[c]]; + int32_t colLen = pTagSchema->bytes; + if (IS_VAR_DATA_TYPE(pTagSchema->type)) { + colLen = bind[c].length[0]; + } + taosArrayPush(tagName, pTagSchema->name); + if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { + if (colLen > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { + code = buildSyntaxErrMsg(&pBuf, "json string too long than 4095", bind[c].buffer); + goto end; + } + + isJson = true; + char* tmp = taosMemoryCalloc(1, colLen + 1); + memcpy(tmp, bind[c].buffer, colLen); + code = parseJsontoTagData(tmp, pTagArray, &pTag, &pBuf); + taosMemoryFree(tmp); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + } else { + STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; + // strcpy(val.colName, pTagSchema->name); + if (pTagSchema->type == TSDB_DATA_TYPE_BINARY) { + val.pData = (uint8_t*)bind[c].buffer; + val.nData = colLen; + } else if (pTagSchema->type == TSDB_DATA_TYPE_NCHAR) { + int32_t output = 0; + void* p = taosMemoryCalloc(1, colLen * TSDB_NCHAR_SIZE); + if (p == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + if (!taosMbsToUcs4(bind[c].buffer, colLen, (TdUcs4*)(p), colLen * TSDB_NCHAR_SIZE, &output)) { + if (errno == E2BIG) { + taosMemoryFree(p); + code = generateSyntaxErrMsg(&pBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pTagSchema->name); + goto end; + } + char buf[512] = {0}; + snprintf(buf, tListLen(buf), " taosMbsToUcs4 error:%s", strerror(errno)); + taosMemoryFree(p); + code = buildSyntaxErrMsg(&pBuf, buf, bind[c].buffer); + goto end; + } + val.pData = p; + val.nData = output; + } else { + memcpy(&val.i64, bind[c].buffer, colLen); + } + taosArrayPush(pTagArray, &val); + } + } + + if (!isJson && (code = tTagNew(pTagArray, 1, false, &pTag)) != TSDB_CODE_SUCCESS) { + goto end; + } + + SVCreateTbReq tbReq = {0}; + insBuildCreateTbReq(&tbReq, tName, pTag, suid, sTableName, tagName, pDataBlock->pTableMeta->tableInfo.numOfTags); + code = insBuildCreateTbMsg(pDataBlock, &tbReq); + tdDestroySVCreateTbReq(&tbReq); + +end: + for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) { + STagVal* p = (STagVal*)taosArrayGet(pTagArray, i); + if (p->type == TSDB_DATA_TYPE_NCHAR) { + taosMemoryFreeClear(p->pData); + } + } + taosArrayDestroy(pTagArray); + taosArrayDestroy(tagName); + + return code; +} + +int32_t qBindStmtColsValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen) { + STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; + SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta); + int32_t extendedRowSize = insGetExtendedRowSize(pDataBlock); + SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo; + SRowBuilder* pBuilder = &pDataBlock->rowBuilder; + SMemParam param = {.rb = pBuilder}; + SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; + int32_t rowNum = bind->num; + + CHECK_CODE( + insInitRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); + + CHECK_CODE(insAllocateMemForSize(pDataBlock, extendedRowSize * bind->num)); + + for (int32_t r = 0; r < bind->num; ++r) { + STSRow* row = (STSRow*)(pDataBlock->pData + pDataBlock->size); // skip the SSubmitBlk header + tdSRowResetBuf(pBuilder, row); + + for (int c = 0; c < spd->numOfBound; ++c) { + SSchema* pColSchema = &pSchema[spd->boundColumns[c]]; + + if (bind[c].num != rowNum) { + return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same"); + } + + param.schema = pColSchema; + insGetSTSRowAppendInfo(pBuilder->rowType, spd, c, ¶m.toffset, ¶m.colIdx); + + if (bind[c].is_null && bind[c].is_null[r]) { + if (pColSchema->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + return buildInvalidOperationMsg(&pBuf, "primary timestamp should not be NULL"); + } + + CHECK_CODE(insMemRowAppend(&pBuf, NULL, 0, ¶m)); + } else { + if (bind[c].buffer_type != pColSchema->type) { + return buildInvalidOperationMsg(&pBuf, "column type mis-match with buffer type"); + } + + int32_t colLen = pColSchema->bytes; + if (IS_VAR_DATA_TYPE(pColSchema->type)) { + colLen = bind[c].length[r]; + } + + CHECK_CODE(insMemRowAppend(&pBuf, (char*)bind[c].buffer + bind[c].buffer_length * r, colLen, ¶m)); + } + + if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) { + TSKEY tsKey = TD_ROW_KEY(row); + insCheckTimestamp(pDataBlock, (const char*)&tsKey); + } + } + // set the null value for the columns that do not assign values + if ((spd->numOfBound < spd->numOfCols) && TD_IS_TP_ROW(row)) { + pBuilder->hasNone = true; + } + tdSRowEnd(pBuilder); +#ifdef TD_DEBUG_PRINT_ROW + STSchema* pSTSchema = tdGetSTSChemaFromSSChema(pSchema, spd->numOfCols, 1); + tdSRowPrint(row, pSTSchema, __func__); + taosMemoryFree(pSTSchema); +#endif + pDataBlock->size += extendedRowSize; + } + + SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData); + if (TSDB_CODE_SUCCESS != insSetBlockInfo(pBlocks, pDataBlock, bind->num)) { + return buildInvalidOperationMsg(&pBuf, "too many rows in sql, total number of rows should be less than INT32_MAX"); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t qBindStmtSingleColValue(void* pBlock, TAOS_MULTI_BIND* bind, char* msgBuf, int32_t msgBufLen, int32_t colIdx, + int32_t rowNum) { + STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; + SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta); + int32_t extendedRowSize = insGetExtendedRowSize(pDataBlock); + SParsedDataColInfo* spd = &pDataBlock->boundColumnInfo; + SRowBuilder* pBuilder = &pDataBlock->rowBuilder; + SMemParam param = {.rb = pBuilder}; + SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen}; + bool rowStart = (0 == colIdx); + bool rowEnd = ((colIdx + 1) == spd->numOfBound); + + if (rowStart) { + CHECK_CODE( + insInitRowBuilder(&pDataBlock->rowBuilder, pDataBlock->pTableMeta->sversion, &pDataBlock->boundColumnInfo)); + CHECK_CODE(insAllocateMemForSize(pDataBlock, extendedRowSize * bind->num)); + } + + for (int32_t r = 0; r < bind->num; ++r) { + STSRow* row = (STSRow*)(pDataBlock->pData + pDataBlock->size + extendedRowSize * r); // skip the SSubmitBlk header + if (rowStart) { + tdSRowResetBuf(pBuilder, row); + } else { + tdSRowGetBuf(pBuilder, row); + } + + SSchema* pColSchema = &pSchema[spd->boundColumns[colIdx]]; + + if (bind->num != rowNum) { + return buildInvalidOperationMsg(&pBuf, "row number in each bind param should be the same"); + } + + param.schema = pColSchema; + insGetSTSRowAppendInfo(pBuilder->rowType, spd, colIdx, ¶m.toffset, ¶m.colIdx); + + if (bind->is_null && bind->is_null[r]) { + if (pColSchema->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + return buildInvalidOperationMsg(&pBuf, "primary timestamp should not be NULL"); + } + + CHECK_CODE(insMemRowAppend(&pBuf, NULL, 0, ¶m)); + } else { + if (bind->buffer_type != pColSchema->type) { + return buildInvalidOperationMsg(&pBuf, "column type mis-match with buffer type"); + } + + int32_t colLen = pColSchema->bytes; + if (IS_VAR_DATA_TYPE(pColSchema->type)) { + colLen = bind->length[r]; + } + + CHECK_CODE(insMemRowAppend(&pBuf, (char*)bind->buffer + bind->buffer_length * r, colLen, ¶m)); + } + + if (PRIMARYKEY_TIMESTAMP_COL_ID == pColSchema->colId) { + TSKEY tsKey = TD_ROW_KEY(row); + insCheckTimestamp(pDataBlock, (const char*)&tsKey); + } + + // set the null value for the columns that do not assign values + if (rowEnd && (spd->numOfBound < spd->numOfCols) && TD_IS_TP_ROW(row)) { + pBuilder->hasNone = true; + } + if (rowEnd) { + tdSRowEnd(pBuilder); + } +#ifdef TD_DEBUG_PRINT_ROW + if (rowEnd) { + STSchema* pSTSchema = tdGetSTSChemaFromSSChema(pSchema, spd->numOfCols, 1); + tdSRowPrint(row, pSTSchema, __func__); + taosMemoryFree(pSTSchema); + } +#endif + } + + if (rowEnd) { + pDataBlock->size += extendedRowSize * bind->num; + + SSubmitBlk* pBlocks = (SSubmitBlk*)(pDataBlock->pData); + if (TSDB_CODE_SUCCESS != insSetBlockInfo(pBlocks, pDataBlock, bind->num)) { + return buildInvalidOperationMsg(&pBuf, + "too many rows in sql, total number of rows should be less than INT32_MAX"); + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t buildBoundFields(SParsedDataColInfo* boundInfo, SSchema* pSchema, int32_t* fieldNum, TAOS_FIELD_E** fields, + uint8_t timePrec) { + if (fields) { + *fields = taosMemoryCalloc(boundInfo->numOfBound, sizeof(TAOS_FIELD)); + if (NULL == *fields) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SSchema* schema = &pSchema[boundInfo->boundColumns[0]]; + if (TSDB_DATA_TYPE_TIMESTAMP == schema->type) { + (*fields)[0].precision = timePrec; + } + + for (int32_t i = 0; i < boundInfo->numOfBound; ++i) { + schema = &pSchema[boundInfo->boundColumns[i]]; + strcpy((*fields)[i].name, schema->name); + (*fields)[i].type = schema->type; + (*fields)[i].bytes = schema->bytes; + } + } + + *fieldNum = boundInfo->numOfBound; + + return TSDB_CODE_SUCCESS; +} + +int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TAOS_FIELD_E** fields) { + STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; + SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags; + if (NULL == tags) { + return TSDB_CODE_QRY_APP_ERROR; + } + + if (pDataBlock->pTableMeta->tableType != TSDB_SUPER_TABLE && pDataBlock->pTableMeta->tableType != TSDB_CHILD_TABLE) { + return TSDB_CODE_TSC_STMT_API_ERROR; + } + + SSchema* pSchema = getTableTagSchema(pDataBlock->pTableMeta); + if (tags->numOfBound <= 0) { + *fieldNum = 0; + *fields = NULL; + + return TSDB_CODE_SUCCESS; + } + + CHECK_CODE(buildBoundFields(tags, pSchema, fieldNum, fields, 0)); + + return TSDB_CODE_SUCCESS; +} + +int32_t qBuildStmtColFields(void* pBlock, int32_t* fieldNum, TAOS_FIELD_E** fields) { + STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; + SSchema* pSchema = getTableColumnSchema(pDataBlock->pTableMeta); + if (pDataBlock->boundColumnInfo.numOfBound <= 0) { + *fieldNum = 0; + if (fields) { + *fields = NULL; + } + + return TSDB_CODE_SUCCESS; + } + + CHECK_CODE(buildBoundFields(&pDataBlock->boundColumnInfo, pSchema, fieldNum, fields, + pDataBlock->pTableMeta->tableInfo.precision)); + + return TSDB_CODE_SUCCESS; +} + +int32_t qResetStmtDataBlock(void* block, bool keepBuf) { + STableDataBlocks* pBlock = (STableDataBlocks*)block; + + if (keepBuf) { + taosMemoryFreeClear(pBlock->pData); + pBlock->pData = taosMemoryMalloc(TSDB_PAYLOAD_SIZE); + if (NULL == pBlock->pData) { + return TSDB_CODE_OUT_OF_MEMORY; + } + memset(pBlock->pData, 0, sizeof(SSubmitBlk)); + } else { + pBlock->pData = NULL; + } + + pBlock->ordered = true; + pBlock->prevTS = INT64_MIN; + pBlock->size = sizeof(SSubmitBlk); + pBlock->tsSource = -1; + pBlock->numOfTables = 1; + pBlock->nAllocSize = TSDB_PAYLOAD_SIZE; + pBlock->headerSize = pBlock->size; + pBlock->createTbReqLen = 0; + + memset(&pBlock->rowBuilder, 0, sizeof(pBlock->rowBuilder)); + + return TSDB_CODE_SUCCESS; +} + +int32_t qCloneStmtDataBlock(void** pDst, void* pSrc) { + *pDst = taosMemoryMalloc(sizeof(STableDataBlocks)); + if (NULL == *pDst) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + memcpy(*pDst, pSrc, sizeof(STableDataBlocks)); + ((STableDataBlocks*)(*pDst))->cloned = true; + + STableDataBlocks* pBlock = (STableDataBlocks*)(*pDst); + if (pBlock->pTableMeta) { + void* pNewMeta = taosMemoryMalloc(TABLE_META_SIZE(pBlock->pTableMeta)); + if (NULL == pNewMeta) { + taosMemoryFreeClear(*pDst); + return TSDB_CODE_OUT_OF_MEMORY; + } + memcpy(pNewMeta, pBlock->pTableMeta, TABLE_META_SIZE(pBlock->pTableMeta)); + pBlock->pTableMeta = pNewMeta; + } + + return qResetStmtDataBlock(*pDst, false); +} + +int32_t qRebuildStmtDataBlock(void** pDst, void* pSrc, uint64_t uid, int32_t vgId) { + int32_t code = qCloneStmtDataBlock(pDst, pSrc); + if (code) { + return code; + } + + STableDataBlocks* pBlock = (STableDataBlocks*)*pDst; + pBlock->pData = taosMemoryMalloc(pBlock->nAllocSize); + if (NULL == pBlock->pData) { + qFreeStmtDataBlock(pBlock); + return TSDB_CODE_OUT_OF_MEMORY; + } + + pBlock->vgId = vgId; + + if (pBlock->pTableMeta) { + pBlock->pTableMeta->uid = uid; + pBlock->pTableMeta->vgId = vgId; + } + + memset(pBlock->pData, 0, sizeof(SSubmitBlk)); + + return TSDB_CODE_SUCCESS; +} + +STableMeta* qGetTableMetaInDataBlock(void* pDataBlock) { return ((STableDataBlocks*)pDataBlock)->pTableMeta; } + +void qFreeStmtDataBlock(void* pDataBlock) { + if (pDataBlock == NULL) { + return; + } + + taosMemoryFreeClear(((STableDataBlocks*)pDataBlock)->pTableMeta); + taosMemoryFreeClear(((STableDataBlocks*)pDataBlock)->pData); + taosMemoryFreeClear(pDataBlock); +} + +void qDestroyStmtDataBlock(void* pBlock) { + if (pBlock == NULL) { + return; + } + + STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; + + pDataBlock->cloned = false; + insDestroyDataBlock(pDataBlock); +} diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertUtil.c similarity index 69% rename from source/libs/parser/src/parInsertData.c rename to source/libs/parser/src/parInsertUtil.c index 954c1b332a..e921cfe997 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -#include "parInsertData.h" +#include "parInsertUtil.h" #include "catalog.h" #include "parInt.h" @@ -81,7 +81,53 @@ static int32_t rowDataComparStable(const void* lhs, const void* rhs) { } } -void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t numOfCols) { +int32_t insGetExtendedRowSize(STableDataBlocks* pBlock) { + STableComInfo* pTableInfo = &pBlock->pTableMeta->tableInfo; + ASSERT(pBlock->rowSize == pTableInfo->rowSize); + return pBlock->rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + pBlock->boundColumnInfo.extendedVarLen + + (int32_t)TD_BITMAP_BYTES(pTableInfo->numOfColumns - 1); +} + +void insGetSTSRowAppendInfo(uint8_t rowType, SParsedDataColInfo* spd, col_id_t idx, int32_t* toffset, + col_id_t* colIdx) { + col_id_t schemaIdx = 0; + if (IS_DATA_COL_ORDERED(spd)) { + schemaIdx = spd->boundColumns[idx]; + if (TD_IS_TP_ROW_T(rowType)) { + *toffset = (spd->cols + schemaIdx)->toffset; // the offset of firstPart + *colIdx = schemaIdx; + } else { + *toffset = idx * sizeof(SKvRowIdx); // the offset of SKvRowIdx + *colIdx = idx; + } + } else { + ASSERT(idx == (spd->colIdxInfo + idx)->boundIdx); + schemaIdx = (spd->colIdxInfo + idx)->schemaColIdx; + if (TD_IS_TP_ROW_T(rowType)) { + *toffset = (spd->cols + schemaIdx)->toffset; + *colIdx = schemaIdx; + } else { + *toffset = ((spd->colIdxInfo + idx)->finalIdx) * sizeof(SKvRowIdx); + *colIdx = (spd->colIdxInfo + idx)->finalIdx; + } + } +} + +int32_t insSetBlockInfo(SSubmitBlk* pBlocks, STableDataBlocks* dataBuf, int32_t numOfRows) { + pBlocks->suid = (TSDB_NORMAL_TABLE == dataBuf->pTableMeta->tableType ? 0 : dataBuf->pTableMeta->suid); + pBlocks->uid = dataBuf->pTableMeta->uid; + pBlocks->sversion = dataBuf->pTableMeta->sversion; + pBlocks->schemaLen = dataBuf->createTbReqLen; + + if (pBlocks->numOfRows + numOfRows >= INT32_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } else { + pBlocks->numOfRows += numOfRows; + return TSDB_CODE_SUCCESS; + } +} + +void insSetBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t numOfCols) { pColList->numOfCols = numOfCols; pColList->numOfBound = numOfCols; pColList->orderStatus = ORDER_STATUS_ORDERED; // default is ORDERED for non-bound mode @@ -118,7 +164,7 @@ void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, col_id_t pColList->extendedVarLen = (uint16_t)(nVar * sizeof(VarDataOffsetT)); } -int32_t schemaIdxCompar(const void* lhs, const void* rhs) { +int32_t insSchemaIdxCompar(const void* lhs, const void* rhs) { uint16_t left = *(uint16_t*)lhs; uint16_t right = *(uint16_t*)rhs; @@ -129,7 +175,7 @@ int32_t schemaIdxCompar(const void* lhs, const void* rhs) { } } -int32_t boundIdxCompar(const void* lhs, const void* rhs) { +int32_t insBoundIdxCompar(const void* lhs, const void* rhs) { uint16_t left = *(uint16_t*)POINTER_SHIFT(lhs, sizeof(uint16_t)); uint16_t right = *(uint16_t*)POINTER_SHIFT(rhs, sizeof(uint16_t)); @@ -178,7 +224,7 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star SParsedDataColInfo* pColInfo = &dataBuf->boundColumnInfo; SSchema* pSchema = getTableColumnSchema(dataBuf->pTableMeta); - setBoundColumnInfo(pColInfo, pSchema, dataBuf->pTableMeta->tableInfo.numOfColumns); + insSetBoundColumnInfo(pColInfo, pSchema, dataBuf->pTableMeta->tableInfo.numOfColumns); dataBuf->ordered = true; dataBuf->prevTS = INT64_MIN; @@ -192,7 +238,7 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star return TSDB_CODE_SUCCESS; } -int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) { +int32_t insBuildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) { SEncoder coder = {0}; char* pBuf; int32_t len; @@ -222,7 +268,7 @@ int32_t buildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbReq) return code; } -static void destroyDataBlock(STableDataBlocks* pDataBlock) { +void insDestroyDataBlock(STableDataBlocks* pDataBlock) { if (pDataBlock == NULL) { return; } @@ -237,9 +283,9 @@ static void destroyDataBlock(STableDataBlocks* pDataBlock) { taosMemoryFreeClear(pDataBlock); } -int32_t getDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32_t size, int32_t startOffset, - int32_t rowSize, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, SArray* pBlockList, - SVCreateTbReq* pCreateTbReq) { +int32_t insGetDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32_t size, int32_t startOffset, + int32_t rowSize, STableMeta* pTableMeta, STableDataBlocks** dataBlocks, + SArray* pBlockList, SVCreateTbReq* pCreateTbReq) { *dataBlocks = NULL; STableDataBlocks** t1 = (STableDataBlocks**)taosHashGet(pHashList, (const char*)id, idLen); if (t1 != NULL) { @@ -253,9 +299,9 @@ int32_t getDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, int32 } if (NULL != pCreateTbReq && NULL != pCreateTbReq->ctb.pTag) { - ret = buildCreateTbMsg(*dataBlocks, pCreateTbReq); + ret = insBuildCreateTbMsg(*dataBlocks, pCreateTbReq); if (ret != TSDB_CODE_SUCCESS) { - destroyDataBlock(*dataBlocks); + insDestroyDataBlock(*dataBlocks); return ret; } } @@ -283,7 +329,7 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) { return result; } -void destroyBlockArrayList(SArray* pDataBlockList) { +void insDestroyBlockArrayList(SArray* pDataBlockList) { if (pDataBlockList == NULL) { return; } @@ -291,13 +337,13 @@ void destroyBlockArrayList(SArray* pDataBlockList) { size_t size = taosArrayGetSize(pDataBlockList); for (int32_t i = 0; i < size; i++) { void* p = taosArrayGetP(pDataBlockList, i); - destroyDataBlock(p); + insDestroyDataBlock(p); } taosArrayDestroy(pDataBlockList); } -void destroyBlockHashmap(SHashObj* pDataBlockHash) { +void insDestroyBlockHashmap(SHashObj* pDataBlockHash) { if (pDataBlockHash == NULL) { return; } @@ -305,7 +351,7 @@ void destroyBlockHashmap(SHashObj* pDataBlockHash) { void** p1 = taosHashIterate(pDataBlockHash, NULL); while (p1) { STableDataBlocks* pBlocks = *p1; - destroyDataBlock(pBlocks); + insDestroyDataBlock(pBlocks); p1 = taosHashIterate(pDataBlockHash, p1); } @@ -375,7 +421,7 @@ static int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* } memset(pBlkKeyInfo->pKeyTuple, 0, nAlloc); - int32_t extendedRowSize = getExtendedRowSize(dataBuf); + int32_t extendedRowSize = insGetExtendedRowSize(dataBuf); SBlockKeyTuple* pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; char* pBlockData = pBlocks->data + pBlocks->schemaLen; int n = 0; @@ -545,7 +591,7 @@ static int sortMergeDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* p tdResetSBlockRowMerger(*ppBlkRowMerger); - int32_t extendedRowSize = getExtendedRowSize(dataBuf); + int32_t extendedRowSize = insGetExtendedRowSize(dataBuf); SBlockKeyTuple* pBlkKeyTuple = pBlkKeyInfo->pKeyTuple; char* pBlockData = pBlocks->data + pBlocks->schemaLen; int32_t n = 0; @@ -679,7 +725,7 @@ static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, SB return pBlock->dataLen + pBlock->schemaLen; } -int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** pVgDataBlocks) { +int32_t insMergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** pVgDataBlocks) { const int INSERT_HEAD_SIZE = sizeof(SSubmitReq); int code = 0; bool isRawPayload = IS_RAW_PAYLOAD(payloadType); @@ -696,13 +742,13 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p if (pBlocks->numOfRows > 0) { STableDataBlocks* dataBuf = NULL; pOneTableBlock->pTableMeta->vgId = pOneTableBlock->vgId; // for schemaless, restore origin vgId - int32_t ret = getDataBlockFromList(pVnodeDataBlockHashList, &pOneTableBlock->vgId, sizeof(pOneTableBlock->vgId), - TSDB_PAYLOAD_SIZE, INSERT_HEAD_SIZE, 0, pOneTableBlock->pTableMeta, &dataBuf, - pVnodeDataBlockList, NULL); + int32_t ret = insGetDataBlockFromList(pVnodeDataBlockHashList, &pOneTableBlock->vgId, + sizeof(pOneTableBlock->vgId), TSDB_PAYLOAD_SIZE, INSERT_HEAD_SIZE, 0, + pOneTableBlock->pTableMeta, &dataBuf, pVnodeDataBlockList, NULL); if (ret != TSDB_CODE_SUCCESS) { tdFreeSBlockRowMerger(pBlkRowMerger); taosHashCleanup(pVnodeDataBlockHashList); - destroyBlockArrayList(pVnodeDataBlockList); + insDestroyBlockArrayList(pVnodeDataBlockList); taosMemoryFreeClear(blkKeyInfo.pKeyTuple); return ret; } @@ -721,7 +767,7 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p } else { // failed to allocate memory, free already allocated memory and return error code tdFreeSBlockRowMerger(pBlkRowMerger); taosHashCleanup(pVnodeDataBlockHashList); - destroyBlockArrayList(pVnodeDataBlockList); + insDestroyBlockArrayList(pVnodeDataBlockList); taosMemoryFreeClear(dataBuf->pData); taosMemoryFreeClear(blkKeyInfo.pKeyTuple); return TSDB_CODE_TSC_OUT_OF_MEMORY; @@ -734,7 +780,7 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p if ((code = sortMergeDataBlockDupRows(pOneTableBlock, &blkKeyInfo, &pBlkRowMerger)) != 0) { tdFreeSBlockRowMerger(pBlkRowMerger); taosHashCleanup(pVnodeDataBlockHashList); - destroyBlockArrayList(pVnodeDataBlockList); + insDestroyBlockArrayList(pVnodeDataBlockList); taosMemoryFreeClear(dataBuf->pData); taosMemoryFreeClear(blkKeyInfo.pKeyTuple); return code; @@ -767,7 +813,7 @@ int32_t mergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** p return TSDB_CODE_SUCCESS; } -int32_t allocateMemForSize(STableDataBlocks* pDataBlock, int32_t allSize) { +int32_t insAllocateMemForSize(STableDataBlocks* pDataBlock, int32_t allSize) { size_t remain = pDataBlock->nAllocSize - pDataBlock->size; uint32_t nAllocSizeOld = pDataBlock->nAllocSize; @@ -789,35 +835,7 @@ int32_t allocateMemForSize(STableDataBlocks* pDataBlock, int32_t allSize) { return TSDB_CODE_SUCCESS; } -int32_t allocateMemIfNeed(STableDataBlocks* pDataBlock, int32_t rowSize, int32_t* numOfRows) { - size_t remain = pDataBlock->nAllocSize - pDataBlock->size; - const int factor = 5; - uint32_t nAllocSizeOld = pDataBlock->nAllocSize; - - // expand the allocated size - if (remain < rowSize * factor) { - while (remain < rowSize * factor) { - pDataBlock->nAllocSize = (uint32_t)(pDataBlock->nAllocSize * 1.5); - remain = pDataBlock->nAllocSize - pDataBlock->size; - } - - char* tmp = taosMemoryRealloc(pDataBlock->pData, (size_t)pDataBlock->nAllocSize); - if (tmp != NULL) { - pDataBlock->pData = tmp; - memset(pDataBlock->pData + pDataBlock->size, 0, pDataBlock->nAllocSize - pDataBlock->size); - } else { - // do nothing, if allocate more memory failed - pDataBlock->nAllocSize = nAllocSizeOld; - *numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize; - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - } - - *numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize; - return TSDB_CODE_SUCCESS; -} - -int initRowBuilder(SRowBuilder* pBuilder, int16_t schemaVer, SParsedDataColInfo* pColInfo) { +int32_t insInitRowBuilder(SRowBuilder* pBuilder, int16_t schemaVer, SParsedDataColInfo* pColInfo) { ASSERT(pColInfo->numOfCols > 0 && (pColInfo->numOfBound <= pColInfo->numOfCols)); tdSRowInit(pBuilder, schemaVer); tdSRowSetExtendedInfo(pBuilder, pColInfo->numOfCols, pColInfo->numOfBound, pColInfo->flen, pColInfo->allNullLen, @@ -825,101 +843,218 @@ int initRowBuilder(SRowBuilder* pBuilder, int16_t schemaVer, SParsedDataColInfo* return TSDB_CODE_SUCCESS; } -int32_t qResetStmtDataBlock(void* block, bool keepBuf) { - STableDataBlocks* pBlock = (STableDataBlocks*)block; +static char* tableNameGetPosition(SToken* pToken, char target) { + bool inEscape = false; + bool inQuote = false; + char quotaStr = 0; - if (keepBuf) { - taosMemoryFreeClear(pBlock->pData); - pBlock->pData = taosMemoryMalloc(TSDB_PAYLOAD_SIZE); - if (NULL == pBlock->pData) { - return TSDB_CODE_OUT_OF_MEMORY; + for (uint32_t i = 0; i < pToken->n; ++i) { + if (*(pToken->z + i) == target && (!inEscape) && (!inQuote)) { + return pToken->z + i; } - memset(pBlock->pData, 0, sizeof(SSubmitBlk)); + + if (*(pToken->z + i) == TS_ESCAPE_CHAR) { + if (!inQuote) { + inEscape = !inEscape; + } + } + + if (*(pToken->z + i) == '\'' || *(pToken->z + i) == '"') { + if (!inEscape) { + if (!inQuote) { + quotaStr = *(pToken->z + i); + inQuote = !inQuote; + } else if (quotaStr == *(pToken->z + i)) { + inQuote = !inQuote; + } + } + } + } + + return NULL; +} + +int32_t insCreateSName(SName* pName, SToken* pTableName, int32_t acctId, const char* dbName, SMsgBuf* pMsgBuf) { + const char* msg1 = "name too long"; + const char* msg2 = "invalid database name"; + const char* msg3 = "db is not specified"; + const char* msg4 = "invalid table name"; + + int32_t code = TSDB_CODE_SUCCESS; + char* p = tableNameGetPosition(pTableName, TS_PATH_DELIMITER[0]); + + if (p != NULL) { // db has been specified in sql string so we ignore current db path + assert(*p == TS_PATH_DELIMITER[0]); + + int32_t dbLen = p - pTableName->z; + if (dbLen <= 0) { + return buildInvalidOperationMsg(pMsgBuf, msg2); + } + char name[TSDB_DB_FNAME_LEN] = {0}; + strncpy(name, pTableName->z, dbLen); + int32_t actualDbLen = strdequote(name); + + code = tNameSetDbName(pName, acctId, name, actualDbLen); + if (code != TSDB_CODE_SUCCESS) { + return buildInvalidOperationMsg(pMsgBuf, msg1); + } + + int32_t tbLen = pTableName->n - dbLen - 1; + if (tbLen <= 0) { + return buildInvalidOperationMsg(pMsgBuf, msg4); + } + + char tbname[TSDB_TABLE_FNAME_LEN] = {0}; + strncpy(tbname, p + 1, tbLen); + /*tbLen = */ strdequote(tbname); + + code = tNameFromString(pName, tbname, T_NAME_TABLE); + if (code != 0) { + return buildInvalidOperationMsg(pMsgBuf, msg1); + } + } else { // get current DB name first, and then set it into path + if (pTableName->n >= TSDB_TABLE_NAME_LEN) { + return buildInvalidOperationMsg(pMsgBuf, msg1); + } + + assert(pTableName->n < TSDB_TABLE_FNAME_LEN); + + char name[TSDB_TABLE_FNAME_LEN] = {0}; + strncpy(name, pTableName->z, pTableName->n); + strdequote(name); + + if (dbName == NULL) { + return buildInvalidOperationMsg(pMsgBuf, msg3); + } + + code = tNameSetDbName(pName, acctId, dbName, strlen(dbName)); + if (code != TSDB_CODE_SUCCESS) { + code = buildInvalidOperationMsg(pMsgBuf, msg2); + return code; + } + + code = tNameFromString(pName, name, T_NAME_TABLE); + if (code != 0) { + code = buildInvalidOperationMsg(pMsgBuf, msg1); + } + } + + return code; +} + +int32_t insFindCol(SToken* pColname, int32_t start, int32_t end, SSchema* pSchema) { + while (start < end) { + if (strlen(pSchema[start].name) == pColname->n && strncmp(pColname->z, pSchema[start].name, pColname->n) == 0) { + return start; + } + ++start; + } + return -1; +} + +void insBuildCreateTbReq(SVCreateTbReq* pTbReq, const char* tname, STag* pTag, int64_t suid, const char* sname, + SArray* tagName, uint8_t tagNum) { + pTbReq->type = TD_CHILD_TABLE; + pTbReq->name = strdup(tname); + pTbReq->ctb.suid = suid; + pTbReq->ctb.tagNum = tagNum; + if (sname) pTbReq->ctb.stbName = strdup(sname); + pTbReq->ctb.pTag = (uint8_t*)pTag; + pTbReq->ctb.tagName = taosArrayDup(tagName); + pTbReq->ttl = TSDB_DEFAULT_TABLE_TTL; + pTbReq->commentLen = -1; + + return; +} + +int32_t insMemRowAppend(SMsgBuf* pMsgBuf, const void* value, int32_t len, void* param) { + SMemParam* pa = (SMemParam*)param; + SRowBuilder* rb = pa->rb; + + if (value == NULL) { // it is a null data + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NULL, value, false, pa->toffset, pa->colIdx); + return TSDB_CODE_SUCCESS; + } + + if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { + const char* rowEnd = tdRowEnd(rb->pBuf); + STR_WITH_SIZE_TO_VARSTR(rowEnd, value, len); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); + } else if (TSDB_DATA_TYPE_NCHAR == pa->schema->type) { + // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' + int32_t output = 0; + const char* rowEnd = tdRowEnd(rb->pBuf); + if (!taosMbsToUcs4(value, len, (TdUcs4*)varDataVal(rowEnd), pa->schema->bytes - VARSTR_HEADER_SIZE, &output)) { + if (errno == E2BIG) { + return generateSyntaxErrMsg(pMsgBuf, TSDB_CODE_PAR_VALUE_TOO_LONG, pa->schema->name); + } + char buf[512] = {0}; + snprintf(buf, tListLen(buf), "%s", strerror(errno)); + return buildSyntaxErrMsg(pMsgBuf, buf, value); + } + varDataSetLen(rowEnd, output); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); } else { - pBlock->pData = NULL; + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, false, pa->toffset, pa->colIdx); } - pBlock->ordered = true; - pBlock->prevTS = INT64_MIN; - pBlock->size = sizeof(SSubmitBlk); - pBlock->tsSource = -1; - pBlock->numOfTables = 1; - pBlock->nAllocSize = TSDB_PAYLOAD_SIZE; - pBlock->headerSize = pBlock->size; - pBlock->createTbReqLen = 0; - - memset(&pBlock->rowBuilder, 0, sizeof(pBlock->rowBuilder)); - return TSDB_CODE_SUCCESS; } -int32_t qCloneStmtDataBlock(void** pDst, void* pSrc) { - *pDst = taosMemoryMalloc(sizeof(STableDataBlocks)); - if (NULL == *pDst) { - return TSDB_CODE_OUT_OF_MEMORY; +int32_t insCheckTimestamp(STableDataBlocks* pDataBlocks, const char* start) { + // once the data block is disordered, we do NOT keep previous timestamp any more + if (!pDataBlocks->ordered) { + return TSDB_CODE_SUCCESS; } - memcpy(*pDst, pSrc, sizeof(STableDataBlocks)); - ((STableDataBlocks*)(*pDst))->cloned = true; + TSKEY k = *(TSKEY*)start; + if (k <= pDataBlocks->prevTS) { + pDataBlocks->ordered = false; + } - STableDataBlocks* pBlock = (STableDataBlocks*)(*pDst); - if (pBlock->pTableMeta) { - void* pNewMeta = taosMemoryMalloc(TABLE_META_SIZE(pBlock->pTableMeta)); - if (NULL == pNewMeta) { - taosMemoryFreeClear(*pDst); - return TSDB_CODE_OUT_OF_MEMORY; + pDataBlocks->prevTS = k; + return TSDB_CODE_SUCCESS; +} + +static void buildMsgHeader(STableDataBlocks* src, SVgDataBlocks* blocks) { + SSubmitReq* submit = (SSubmitReq*)blocks->pData; + submit->header.vgId = htonl(blocks->vg.vgId); + submit->header.contLen = htonl(blocks->size); + submit->length = submit->header.contLen; + submit->numOfBlocks = htonl(blocks->numOfTables); + SSubmitBlk* blk = (SSubmitBlk*)(submit + 1); + int32_t numOfBlocks = blocks->numOfTables; + while (numOfBlocks--) { + int32_t dataLen = blk->dataLen; + int32_t schemaLen = blk->schemaLen; + blk->uid = htobe64(blk->uid); + blk->suid = htobe64(blk->suid); + blk->sversion = htonl(blk->sversion); + blk->dataLen = htonl(blk->dataLen); + blk->schemaLen = htonl(blk->schemaLen); + blk->numOfRows = htonl(blk->numOfRows); + blk = (SSubmitBlk*)(blk->data + schemaLen + dataLen); + } +} + +int32_t insBuildOutput(SInsertParseContext* pCxt) { + size_t numOfVg = taosArrayGetSize(pCxt->pVgDataBlocks); + pCxt->pOutput->pDataBlocks = taosArrayInit(numOfVg, POINTER_BYTES); + if (NULL == pCxt->pOutput->pDataBlocks) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + for (size_t i = 0; i < numOfVg; ++i) { + STableDataBlocks* src = taosArrayGetP(pCxt->pVgDataBlocks, i); + SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); + if (NULL == dst) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; } - memcpy(pNewMeta, pBlock->pTableMeta, TABLE_META_SIZE(pBlock->pTableMeta)); - pBlock->pTableMeta = pNewMeta; + taosHashGetDup(pCxt->pVgroupsHashObj, (const char*)&src->vgId, sizeof(src->vgId), &dst->vg); + dst->numOfTables = src->numOfTables; + dst->size = src->size; + TSWAP(dst->pData, src->pData); + buildMsgHeader(src, dst); + taosArrayPush(pCxt->pOutput->pDataBlocks, &dst); } - - return qResetStmtDataBlock(*pDst, false); -} - -int32_t qRebuildStmtDataBlock(void** pDst, void* pSrc, uint64_t uid, int32_t vgId) { - int32_t code = qCloneStmtDataBlock(pDst, pSrc); - if (code) { - return code; - } - - STableDataBlocks* pBlock = (STableDataBlocks*)*pDst; - pBlock->pData = taosMemoryMalloc(pBlock->nAllocSize); - if (NULL == pBlock->pData) { - qFreeStmtDataBlock(pBlock); - return TSDB_CODE_OUT_OF_MEMORY; - } - - pBlock->vgId = vgId; - - if (pBlock->pTableMeta) { - pBlock->pTableMeta->uid = uid; - pBlock->pTableMeta->vgId = vgId; - } - - memset(pBlock->pData, 0, sizeof(SSubmitBlk)); - return TSDB_CODE_SUCCESS; } - -STableMeta* qGetTableMetaInDataBlock(void* pDataBlock) { return ((STableDataBlocks*)pDataBlock)->pTableMeta; } - -void qFreeStmtDataBlock(void* pDataBlock) { - if (pDataBlock == NULL) { - return; - } - - taosMemoryFreeClear(((STableDataBlocks*)pDataBlock)->pTableMeta); - taosMemoryFreeClear(((STableDataBlocks*)pDataBlock)->pData); - taosMemoryFreeClear(pDataBlock); -} - -void qDestroyStmtDataBlock(void* pBlock) { - if (pBlock == NULL) { - return; - } - - STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; - - pDataBlock->cloned = false; - destroyDataBlock(pDataBlock); -} From e654f3f92c50dd8ef8b446c9f556c143c36506df Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 24 Oct 2022 16:44:44 +0800 Subject: [PATCH 46/72] refactor: do some internal refactor. --- source/libs/executor/inc/executil.h | 17 ++- source/libs/executor/inc/executorimpl.h | 122 ++++++++----------- source/libs/executor/src/cachescanoperator.c | 44 +++---- source/libs/executor/src/dataDeleter.c | 16 --- source/libs/executor/src/dataDispatcher.c | 18 +-- source/libs/executor/src/executil.c | 36 +++--- source/libs/executor/src/executorimpl.c | 18 +-- source/libs/executor/src/scanoperator.c | 98 ++++++++------- source/libs/executor/src/sortoperator.c | 95 +++++++-------- source/libs/executor/src/tfill.c | 11 +- 10 files changed, 214 insertions(+), 261 deletions(-) diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 4e960afdb1..0cfef7dc24 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -74,7 +74,6 @@ typedef struct SResultRowPosition { typedef struct SResKeyPos { SResultRowPosition pos; uint64_t groupId; - // char parTbName[TSDB_TABLE_NAME_LEN]; char key[]; } SResKeyPos; @@ -84,6 +83,18 @@ typedef struct SResultRowInfo { SList* openWindow; } SResultRowInfo; +typedef struct SColMatchItem { + int32_t colId; + int32_t srcSlotId; + int32_t dstSlotId; + bool needOutput; +} SColMatchItem; + +typedef struct SColMatchInfo { + SArray* pList; // SArray + int32_t matchType; // determinate the source according to col id or slot id +} SColMatchInfo; + struct SqlFunctionCtx; size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput); @@ -121,8 +132,8 @@ size_t getTableTagsBufLen(const SNodeList* pGroups); SArray* createSortInfo(SNodeList* pNodeList); SArray* extractPartitionColInfo(SNodeList* pNodeList); -SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, - int32_t type); +int32_t extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, + int32_t type, SColMatchInfo* pMatchInfo); void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId); void createExprFromTargetNode(SExprInfo* pExp, STargetNode* pTargetNode); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 5e387d2bd3..7755bd88db 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -47,12 +47,7 @@ extern "C" { typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order); -#define IS_QUERY_KILLED(_q) ((_q)->code == TSDB_CODE_TSC_QUERY_CANCELLED) #define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0u) -#define QUERY_IS_ASC_QUERY(q) (GET_FORWARD_DIRECTION_FACTOR((q)->order.order) == QUERY_ASC_FORWARD_STEP) - -#define NEEDTO_COMPRESS_QUERY(size) ((size) > tsCompressColData ? 1 : 0) - #define IS_VALID_SESSION_WIN(winInfo) ((winInfo).sessionWin.win.skey > 0) #define SET_SESSION_WIN_INVALID(winInfo) ((winInfo).sessionWin.win.skey = INT64_MIN) #define IS_INVALID_SESSION_WIN_KEY(winKey) ((winKey).win.skey <= 0) @@ -240,7 +235,7 @@ typedef struct SOperatorInfo { typedef enum { EX_SOURCE_DATA_NOT_READY = 0x1, - EX_SOURCE_DATA_READY = 0x2, + EX_SOURCE_DATA_READY = 0x2, EX_SOURCE_DATA_EXHAUSTED = 0x3, } EX_SOURCE_STATUS; @@ -289,15 +284,6 @@ typedef struct SExchangeInfo { SLimitInfo limitInfo; } SExchangeInfo; -typedef struct SColMatchInfo { - int32_t srcSlotId; // source slot id - int32_t colId; - int32_t targetSlotId; - bool output; // todo remove this? - bool reserved; - int32_t matchType; // determinate the source according to col id or slot id -} SColMatchInfo; - typedef struct SScanInfo { int32_t numOfAsc; int32_t numOfDesc; @@ -339,7 +325,7 @@ typedef struct STableScanInfo { SNode* pFilterNode; // filter info, which is push down by optimizer SSDataBlock* pResBlock; - SArray* pColMatchInfo; + SColMatchInfo matchInfo; SExprSupp pseudoSup; SQueryTableDataCond cond; int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan @@ -365,10 +351,9 @@ typedef struct STableMergeScanInfo { uint32_t sortBufSize; // max buffer size for in-memory sort SArray* pSortInfo; SSortHandle* pSortHandle; - - SSDataBlock* pSortInputBlock; - int64_t startTs; // sort start time - SArray* sortSourceParams; + SSDataBlock* pSortInputBlock; + int64_t startTs; // sort start time + SArray* sortSourceParams; SFileBlockLoadRecorder readRecorder; int64_t numOfRows; @@ -380,43 +365,40 @@ typedef struct STableMergeScanInfo { int32_t* rowEntryInfoOffset; SExprInfo* pExpr; SSDataBlock* pResBlock; - SArray* pColMatchInfo; + SColMatchInfo matchInfo; int32_t numOfOutput; - - SExprSupp pseudoSup; - - SQueryTableDataCond cond; - int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan - int32_t dataBlockLoadFlag; + SExprSupp pseudoSup; + SQueryTableDataCond cond; + int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan + int32_t dataBlockLoadFlag; // if the upstream is an interval operator, the interval info is also kept here to get the time // window to check if current data block needs to be loaded. - SInterval interval; - SSampleExecInfo sample; // sample execution info - - SSortExecInfo sortExecInfo; + SInterval interval; + SSampleExecInfo sample; // sample execution info + SSortExecInfo sortExecInfo; } STableMergeScanInfo; typedef struct STagScanInfo { SColumnInfo* pCols; SSDataBlock* pRes; - SArray* pColMatchInfo; + SColMatchInfo matchInfo; int32_t curPos; SReadHandle readHandle; STableListInfo* pTableList; } STagScanInfo; typedef struct SLastrowScanInfo { - SSDataBlock* pRes; - SReadHandle readHandle; - void* pLastrowReader; - SArray* pColMatchInfo; - int32_t* pSlotIds; - SExprSupp pseudoExprSup; - int32_t retrieveType; - int32_t currentGroupIndex; - SSDataBlock* pBufferredRes; - SArray* pUidList; - int32_t indexOfBufferedRes; + SSDataBlock* pRes; + SReadHandle readHandle; + void* pLastrowReader; + SColMatchInfo matchInfo; + int32_t* pSlotIds; + SExprSupp pseudoExprSup; + int32_t retrieveType; + int32_t currentGroupIndex; + SSDataBlock* pBufferredRes; + SArray* pUidList; + int32_t indexOfBufferedRes; } SLastrowScanInfo; typedef enum EStreamScanMode { @@ -483,28 +465,28 @@ typedef struct STimeWindowAggSupp { } STimeWindowAggSupp; typedef struct SStreamScanInfo { - uint64_t tableUid; // queried super table uid - SExprInfo* pPseudoExpr; - int32_t numOfPseudoExpr; - SExprSupp tbnameCalSup; - SExprSupp tagCalSup; - int32_t primaryTsIndex; // primary time stamp slot id - SReadHandle readHandle; - SInterval interval; // if the upstream is an interval operator, the interval info is also kept here. - SArray* pColMatchInfo; // - SNode* pCondition; + uint64_t tableUid; // queried super table uid + SExprInfo* pPseudoExpr; + int32_t numOfPseudoExpr; + SExprSupp tbnameCalSup; + SExprSupp tagCalSup; + int32_t primaryTsIndex; // primary time stamp slot id + SReadHandle readHandle; + SInterval interval; // if the upstream is an interval operator, the interval info is also kept here. + SColMatchInfo matchInfo; + SNode* pCondition; + + SArray* pBlockLists; // multiple SSDatablock. + SSDataBlock* pRes; // result SSDataBlock + SSDataBlock* pUpdateRes; // update SSDataBlock + int32_t updateResIndex; + int32_t blockType; // current block type + int32_t validBlockIndex; // Is current data has returned? + uint64_t numOfExec; // execution times + STqReader* tqReader; - SArray* pBlockLists; // multiple SSDatablock. - SSDataBlock* pRes; // result SSDataBlock - SSDataBlock* pUpdateRes; // update SSDataBlock - int32_t updateResIndex; - int32_t blockType; // current block type - int32_t validBlockIndex; // Is current data has returned? - uint64_t numOfExec; // execution times - STqReader* tqReader; - - uint64_t groupId; - SUpdateInfo* pUpdateInfo; + uint64_t groupId; + SUpdateInfo* pUpdateInfo; EStreamScanMode scanMode; SOperatorInfo* pStreamScanOp; @@ -559,8 +541,8 @@ typedef struct SSysTableScanInfo { bool showRewrite; SNode* pCondition; // db_name filter condition, to discard data that are not in current database SMTbCursor* pCur; // cursor for iterate the local table meta store. - SSysTableIndex* pIdx; // idx for local table meta - SArray* scanCols; // SArray scan column id list + SSysTableIndex* pIdx; // idx for local table meta + SColMatchInfo matchInfo; SName name; SSDataBlock* pRes; int64_t numOfBlocks; // extract basic running information. @@ -680,7 +662,7 @@ typedef struct SFillOperatorInfo { SSDataBlock* existNewGroupBlock; STimeWindow win; SNode* pCondition; - SArray* pColMatchColInfo; + SColMatchInfo matchInfo; int32_t primaryTsCol; int32_t primarySrcSlotId; uint64_t curGroupId; // current handled group id @@ -819,7 +801,7 @@ typedef struct SStreamFillOperatorInfo { int32_t srcDelRowIndex; SSDataBlock* pDelRes; SNode* pCondition; - SArray* pColMatchColInfo; + SColMatchInfo matchInfo; int32_t primaryTsCol; int32_t primarySrcSlotId; SStreamFillInfo* pFillInfo; @@ -863,7 +845,7 @@ typedef struct SSortOperatorInfo { uint32_t sortBufSize; // max buffer size for in-memory sort SArray* pSortInfo; SSortHandle* pSortHandle; - SArray* pColMatchInfo; // for index map from table scan output + SColMatchInfo matchInfo; int32_t bufPageSize; int64_t startTs; // sort start time uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included. @@ -932,7 +914,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz); void doSetOperatorCompleted(SOperatorInfo* pOperator); -void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo, SFilterInfo* pFilterInfo); +void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, SColMatchInfo* pColMatchInfo, SFilterInfo* pFilterInfo); int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr, SSDataBlock* pBlock, const char* idStr); diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index 00a338cc41..22a685230a 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -28,7 +28,7 @@ static SSDataBlock* doScanCache(SOperatorInfo* pOperator); static void destroyLastrowScanOperator(void* param); static int32_t extractCacheScanSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds); -static SArray* removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SArray* pColMatchInfo); +static int32_t removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SColMatchInfo* pColMatchInfo); SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) { @@ -46,10 +46,10 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe pInfo->pRes = createResDataBlock(pDescNode); int32_t numOfCols = 0; - SArray* pColMatchInfo = extractColMatchInfo(pScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID); - pInfo->pColMatchInfo = removeRedundantTsCol(pScanNode, pColMatchInfo); + code = extractColMatchInfo(pScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); + removeRedundantTsCol(pScanNode, &pInfo->matchInfo); - code = extractCacheScanSlotId(pInfo->pColMatchInfo, pTaskInfo, &pInfo->pSlotIds); + code = extractCacheScanSlotId(pInfo->matchInfo.pList, pTaskInfo, &pInfo->pSlotIds); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -64,7 +64,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe if (taosArrayGetSize(pTableList->pGroupList) == taosArrayGetSize(pTableList->pTableList)) { pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_ALL|(pScanNode->ignoreNull? CACHESCAN_RETRIEVE_LAST:CACHESCAN_RETRIEVE_LAST_ROW); code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pTableList->pTableList, - taosArrayGetSize(pInfo->pColMatchInfo), &pInfo->pLastrowReader); + taosArrayGetSize(pInfo->matchInfo.pList), &pInfo->pLastrowReader); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -139,9 +139,9 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { } if (pInfo->indexOfBufferedRes < pInfo->pBufferredRes->info.rows) { - for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) { - SColMatchInfo* pMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i); - int32_t slotId = pMatchInfo->targetSlotId; + for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) { + SColMatchItem* pMatchInfo = taosArrayGet(pInfo->matchInfo.pList, i); + int32_t slotId = pMatchInfo->dstSlotId; SColumnInfoData* pSrc = taosArrayGet(pInfo->pBufferredRes->pDataBlock, slotId); SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, slotId); @@ -188,7 +188,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { SArray* pGroupTableList = taosArrayGetP(pTableList->pGroupList, pInfo->currentGroupIndex); tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pGroupTableList, - taosArrayGetSize(pInfo->pColMatchInfo), &pInfo->pLastrowReader); + taosArrayGetSize(pInfo->matchInfo.pList), &pInfo->pLastrowReader); taosArrayClear(pInfo->pUidList); int32_t code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList); @@ -235,7 +235,7 @@ void destroyLastrowScanOperator(void* param) { blockDataDestroy(pInfo->pBufferredRes); taosMemoryFree(pInfo->pSlotIds); taosArrayDestroy(pInfo->pUidList); - taosArrayDestroy(pInfo->pColMatchInfo); + taosArrayDestroy(pInfo->matchInfo.pList); if (pInfo->pLastrowReader != NULL) { pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader); @@ -255,16 +255,16 @@ int32_t extractCacheScanSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTask SSchemaWrapper* pWrapper = pTaskInfo->schemaInfo.sw; for (int32_t i = 0; i < numOfCols; ++i) { - SColMatchInfo* pColMatch = taosArrayGet(pColMatchInfo, i); + SColMatchItem* pColMatch = taosArrayGet(pColMatchInfo, i); for (int32_t j = 0; j < pWrapper->nCols; ++j) { if (pColMatch->colId == pWrapper->pSchema[j].colId && pColMatch->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - (*pSlotIds)[pColMatch->targetSlotId] = -1; + (*pSlotIds)[pColMatch->dstSlotId] = -1; break; } if (pColMatch->colId == pWrapper->pSchema[j].colId) { - (*pSlotIds)[pColMatch->targetSlotId] = j; + (*pSlotIds)[pColMatch->dstSlotId] = j; break; } } @@ -273,17 +273,18 @@ int32_t extractCacheScanSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTask return TSDB_CODE_SUCCESS; } -SArray* removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SArray* pColMatchInfo) { +int32_t removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SColMatchInfo* pColMatchInfo) { if (!pScanNode->ignoreNull) { // retrieve cached last value - return pColMatchInfo; + return TSDB_CODE_SUCCESS; } - SArray* pMatchInfo = taosArrayInit(taosArrayGetSize(pColMatchInfo), sizeof(SColMatchInfo)); + size_t size = taosArrayGetSize(pColMatchInfo->pList); + SArray* pMatchInfo = taosArrayInit(size, sizeof(SColMatchInfo)); - for (int32_t i = 0; i < taosArrayGetSize(pColMatchInfo); ++i) { - SColMatchInfo* pColInfo = taosArrayGet(pColMatchInfo, i); + for (int32_t i = 0; i < size; ++i) { + SColMatchItem* pColInfo = taosArrayGet(pColMatchInfo->pList, i); - int32_t slotId = pColInfo->targetSlotId; + int32_t slotId = pColInfo->dstSlotId; SNodeList* pList = pScanNode->scan.node.pOutputDataBlockDesc->pSlots; SSlotDescNode* pDesc = (SSlotDescNode*)nodesListGetNode(pList, slotId); @@ -292,6 +293,7 @@ SArray* removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SArray* pColMatch } } - taosArrayDestroy(pColMatchInfo); - return pMatchInfo; + taosArrayDestroy(pColMatchInfo->pList); + pColMatchInfo->pList = pMatchInfo; + return TSDB_CODE_SUCCESS; } \ No newline at end of file diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index 2ed83a6469..c7a2480204 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -53,22 +53,6 @@ typedef struct SDataDeleterHandle { TdThreadMutex mutex; } SDataDeleterHandle; -static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) { - if (tsCompressColData < 0 || 0 == pData->info.rows) { - return false; - } - - for (int32_t col = 0; col < numOfCols; ++col) { - SColumnInfoData* pColRes = taosArrayGet(pData->pDataBlock, col); - int32_t colSize = pColRes->info.bytes * pData->info.rows; - if (NEEDTO_COMPRESS_QUERY(colSize)) { - return true; - } - } - - return false; -} - static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInput, SDataDeleterBuf* pBuf) { int32_t numOfCols = LIST_LENGTH(pHandle->pSchema->pSlots); diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index b758e4b1dd..bc4ab9c468 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -51,22 +51,6 @@ typedef struct SDataDispatchHandle { TdThreadMutex mutex; } SDataDispatchHandle; -static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) { - if (tsCompressColData < 0 || 0 == pData->info.rows) { - return false; - } - - for (int32_t col = 0; col < numOfCols; ++col) { - SColumnInfoData* pColRes = taosArrayGet(pData->pDataBlock, col); - int32_t colSize = pColRes->info.bytes * pData->info.rows; - if (NEEDTO_COMPRESS_QUERY(colSize)) { - return true; - } - } - - return false; -} - // clang-format off // data format: // +----------------+------------------+--------------+--------------+------------------+--------------------------------------------+------------------------------------+-------------+-----------+-------------+-----------+ @@ -86,7 +70,7 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn } } SDataCacheEntry* pEntry = (SDataCacheEntry*)pBuf->pData; - pEntry->compressed = (int8_t)needCompress(pInput->pData, numOfCols); + pEntry->compressed = 0; pEntry->numOfRows = pInput->pData->info.rows; pEntry->numOfCols = numOfCols; pEntry->dataLen = 0; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 11d6665614..506033b3b6 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1066,13 +1066,17 @@ SArray* extractPartitionColInfo(SNodeList* pNodeList) { return pList; } -SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, - int32_t type) { - size_t numOfCols = LIST_LENGTH(pNodeList); +int32_t extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols, + int32_t type, SColMatchInfo* pMatchInfo) { + size_t numOfCols = LIST_LENGTH(pNodeList); + int32_t code = 0; + + pMatchInfo->matchType = type; + SArray* pList = taosArrayInit(numOfCols, sizeof(SColMatchInfo)); if (pList == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + code = TSDB_CODE_OUT_OF_MEMORY; + return code; } for (int32_t i = 0; i < numOfCols; ++i) { @@ -1080,12 +1084,10 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod if (nodeType(pNode->pExpr) == QUERY_NODE_COLUMN) { SColumnNode* pColNode = (SColumnNode*)pNode->pExpr; - SColMatchInfo c = {0}; - c.output = true; + SColMatchItem c = {.needOutput = true}; c.colId = pColNode->colId; c.srcSlotId = pColNode->slotId; - c.matchType = type; - c.targetSlotId = pNode->slotId; + c.dstSlotId = pNode->slotId; taosArrayPush(pList, &c); } } @@ -1102,10 +1104,10 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod continue; } - SColMatchInfo* info = NULL; + SColMatchItem* info = NULL; for (int32_t j = 0; j < taosArrayGetSize(pList); ++j) { info = taosArrayGet(pList, j); - if (info->targetSlotId == pNode->slotId) { + if (info->dstSlotId == pNode->slotId) { break; } } @@ -1114,11 +1116,11 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod (*numOfOutputCols) += 1; } else if (info != NULL) { // select distinct tbname from stb where tbname='abc'; - info->output = false; + info->needOutput = false; } } - return pList; + return code; } static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, int32_t scale, int32_t precision, @@ -1407,14 +1409,14 @@ void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray int32_t i = 0, j = 0; while (i < numOfSrcCols && j < taosArrayGetSize(pColMatchInfo)) { SColumnInfoData* p = taosArrayGet(pCols, i); - SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, j); - if (!outputEveryColumn && pmInfo->reserved) { + SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, j); +/* if (!outputEveryColumn && pmInfo->reserved) { j++; continue; - } + }*/ if (p->info.colId == pmInfo->colId) { - SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, pmInfo->targetSlotId); + SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, pmInfo->dstSlotId); colDataAssign(pDst, p, pBlock->info.rows, &pBlock->info); i++; j++; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index c484a852b9..2432944928 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1086,7 +1086,7 @@ void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numO static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status); -void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColMatchInfo, SFilterInfo* pFilterInfo) { +void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, SColMatchInfo* pColMatchInfo, SFilterInfo* pFilterInfo) { if (pFilterNode == NULL || pBlock->info.rows == 0) { return; } @@ -1120,12 +1120,12 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pColM extractQualifiedTupleByFilterResult(pBlock, p, keep, status); if (pColMatchInfo != NULL) { - for (int32_t i = 0; i < taosArrayGetSize(pColMatchInfo); ++i) { - SColMatchInfo* pInfo = taosArrayGet(pColMatchInfo, i); + for (int32_t i = 0; i < taosArrayGetSize(pColMatchInfo->pList); ++i) { + SColMatchItem* pInfo = taosArrayGet(pColMatchInfo->pList, i); if (pInfo->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, pInfo->targetSlotId); + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, pInfo->dstSlotId); if (pColData->info.type == TSDB_DATA_TYPE_TIMESTAMP) { - blockDataUpdateTsWindow(pBlock, pInfo->targetSlotId); + blockDataUpdateTsWindow(pBlock, pInfo->dstSlotId); break; } } @@ -2799,7 +2799,7 @@ static SSDataBlock* doFill(SOperatorInfo* pOperator) { break; } - doFilter(pInfo->pCondition, fillResult, pInfo->pColMatchColInfo, NULL); + doFilter(pInfo->pCondition, fillResult, &pInfo->matchInfo, NULL); if (fillResult->info.rows > 0) { break; } @@ -3087,7 +3087,7 @@ void destroyFillOperatorInfo(void* param) { cleanupExprSupp(&pInfo->noFillExprSupp); taosMemoryFreeClear(pInfo->p); - taosArrayDestroy(pInfo->pColMatchColInfo); + taosArrayDestroy(pInfo->matchInfo.pList); taosMemoryFreeClear(param); } @@ -3231,8 +3231,8 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pInfo->primarySrcSlotId = ((SColumnNode*)((STargetNode*)pPhyFillNode->pWStartTs)->pExpr)->slotId; int32_t numOfOutputCols = 0; - pInfo->pColMatchColInfo = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, - &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + code = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, &numOfOutputCols, + COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo); code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pNoFillSupp->pExprInfo, pNoFillSupp->numOfExprs, (SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity, diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index f24c782a9e..75abd22e46 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -331,12 +331,13 @@ static bool doLoadBlockSMA(STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, } } - for (int32_t i = 0; i < taosArrayGetSize(pTableScanInfo->pColMatchInfo); ++i) { - SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i); - if (!pColMatchInfo->output) { + for (int32_t i = 0; i < taosArrayGetSize(pTableScanInfo->matchInfo.pList); ++i) { + SColMatchItem* pColMatchInfo = taosArrayGet(pTableScanInfo->matchInfo.pList, i); + if (!pColMatchInfo->needOutput) { continue; } - pBlock->pBlockAgg[pColMatchInfo->targetSlotId] = pColAgg[i]; + + pBlock->pBlockAgg[pColMatchInfo->dstSlotId] = pColAgg[i]; } return true; @@ -442,12 +443,12 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca return terrno; } - relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols, true); + relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true); doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo); if (pTableScanInfo->pFilterNode != NULL) { int64_t st = taosGetTimestampUs(); - doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo, pOperator->exprSupp.pFilterInfo); + doFilter(pTableScanInfo->pFilterNode, pBlock, &pTableScanInfo->matchInfo, pOperator->exprSupp.pFilterInfo); double el = (taosGetTimestampUs() - st) / 1000.0; pTableScanInfo->readRecorder.filterTime += el; @@ -780,8 +781,8 @@ static void destroyTableScanOperatorInfo(void* param) { tsdbReaderClose(pTableScanInfo->dataReader); pTableScanInfo->dataReader = NULL; - if (pTableScanInfo->pColMatchInfo != NULL) { - taosArrayDestroy(pTableScanInfo->pColMatchInfo); + if (pTableScanInfo->matchInfo.pList != NULL) { + taosArrayDestroy(pTableScanInfo->matchInfo.pList); } cleanupExprSupp(&pTableScanInfo->pseudoSup); @@ -798,10 +799,10 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc; int32_t numOfCols = 0; - pInfo->pColMatchInfo = - extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID); + int32_t code = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, + &pInfo->matchInfo); - int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode); + code = initQueryTableDataCond(&pInfo->cond, pTableScanNode); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -1512,9 +1513,9 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock } // todo extract method - for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) { - SColMatchInfo* pColMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i); - if (!pColMatchInfo->output) { + for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) { + SColMatchItem* pColMatchInfo = taosArrayGet(pInfo->matchInfo.pList, i); + if (!pColMatchInfo->needOutput) { continue; } @@ -1522,7 +1523,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock for (int32_t j = 0; j < blockDataGetNumOfCols(pBlock); ++j) { SColumnInfoData* pResCol = bdGetColumnInfoData(pBlock, j); if (pResCol->info.colId == pColMatchInfo->colId) { - SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId); + SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->dstSlotId); colDataAssign(pDst, pResCol, pBlock->info.rows, &pInfo->pRes->info); colExists = true; break; @@ -1531,7 +1532,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock // the required column does not exists in submit block, let's set it to be all null value if (!colExists) { - SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->targetSlotId); + SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, pColMatchInfo->dstSlotId); colDataAppendNNULL(pDst, 0, pBlockInfo->rows); } } @@ -2193,8 +2194,8 @@ static void destroyStreamScanOperatorInfo(void* param) { if (pStreamScan->tqReader) { tqCloseReader(pStreamScan->tqReader); } - if (pStreamScan->pColMatchInfo) { - taosArrayDestroy(pStreamScan->pColMatchInfo); + if (pStreamScan->matchInfo.pList) { + taosArrayDestroy(pStreamScan->matchInfo.pList); } if (pStreamScan->pPseudoExpr) { destroyExprInfo(pStreamScan->pPseudoExpr, pStreamScan->numOfPseudoExpr); @@ -2228,17 +2229,17 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pGroupTags = pTableScanNode->pGroupTags; int32_t numOfCols = 0; - pInfo->pColMatchInfo = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID); + int32_t code = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); - int32_t numOfOutput = taosArrayGetSize(pInfo->pColMatchInfo); + int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList); SArray* pColIds = taosArrayInit(numOfOutput, sizeof(int16_t)); for (int32_t i = 0; i < numOfOutput; ++i) { - SColMatchInfo* id = taosArrayGet(pInfo->pColMatchInfo, i); + SColMatchItem* id = taosArrayGet(pInfo->matchInfo.pList, i); int16_t colId = id->colId; taosArrayPush(pColIds, &colId); if (id->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - pInfo->primaryTsIndex = id->targetSlotId; + pInfo->primaryTsIndex = id->dstSlotId; } } @@ -2387,7 +2388,7 @@ static void destroySysScanOperator(void* param) { pInfo->pIdx = NULL; } - taosArrayDestroy(pInfo->scanCols); + taosArrayDestroy(pInfo->matchInfo.pList); taosMemoryFreeClear(pInfo->pUser); taosMemoryFreeClear(param); @@ -2752,7 +2753,7 @@ static void relocateAndFilterSysTagsScanResult(SSysTableScanInfo* pInfo, int32_t dataBlock->info.rows = numOfRows; pInfo->pRes->info.rows = numOfRows; - relocateColumnData(pInfo->pRes, pInfo->scanCols, dataBlock->pDataBlock, false); + relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, dataBlock->pDataBlock, false); doFilterResult(pInfo); blockDataCleanup(dataBlock); @@ -3441,7 +3442,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) { p->info.rows = numOfRows; pInfo->pRes->info.rows = numOfRows; - relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); + relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false); doFilterResult(pInfo); blockDataCleanup(p); @@ -3457,7 +3458,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) { p->info.rows = numOfRows; pInfo->pRes->info.rows = numOfRows; - relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); + relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false); doFilterResult(pInfo); blockDataCleanup(p); @@ -3618,7 +3619,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) { p->info.rows = numOfRows; pInfo->pRes->info.rows = numOfRows; - relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); + relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false); doFilterResult(pInfo); blockDataCleanup(p); @@ -3634,7 +3635,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) { p->info.rows = numOfRows; pInfo->pRes->info.rows = numOfRows; - relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); + relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false); doFilterResult(pInfo); blockDataCleanup(p); @@ -3798,7 +3799,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) { } char* pStart = pRsp->data; - extractDataBlockFromFetchRsp(pInfo->pRes, pRsp->data, pInfo->scanCols, &pStart); + extractDataBlockFromFetchRsp(pInfo->pRes, pRsp->data, pInfo->matchInfo.pList, &pStart); updateLoadRemoteInfo(&pInfo->loadInfo, pRsp->numOfRows, pRsp->compLen, startTs, pOperator); // todo log the filter info @@ -3827,7 +3828,7 @@ int32_t buildSysDbTableInfo(const SSysTableScanInfo* pInfo, int32_t capacity) { p->info.rows = buildDbTableInfoBlock(pInfo->sysInfo, p, pSysDbTableMeta, size, TSDB_PERFORMANCE_SCHEMA_DB); pInfo->pRes->info.rows = p->info.rows; - relocateColumnData(pInfo->pRes, pInfo->scanCols, p->pDataBlock, false); + relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false); blockDataDestroy(p); return pInfo->pRes->info.rows; @@ -3892,7 +3893,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan SSDataBlock* pResBlock = createResDataBlock(pDescNode); int32_t num = 0; - SArray* colList = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &num, COL_MATCH_FROM_COL_ID); + int32_t code = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &num, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); pInfo->accountId = pScanPhyNode->accountId; pInfo->pUser = taosMemoryStrDup((void*)pUser); @@ -3900,7 +3901,6 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan pInfo->showRewrite = pScanPhyNode->showRewrite; pInfo->pRes = pResBlock; pInfo->pCondition = pScanNode->node.pConditions; - pInfo->scanCols = colList; initResultSizeInfo(&pOperator->resultInfo, 4096); @@ -4021,7 +4021,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { static void destroyTagScanOperatorInfo(void* param) { STagScanInfo* pInfo = (STagScanInfo*)param; pInfo->pRes = blockDataDestroy(pInfo->pRes); - taosArrayDestroy(pInfo->pColMatchInfo); + taosArrayDestroy(pInfo->matchInfo.pList); taosMemoryFreeClear(param); } @@ -4038,15 +4038,14 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi int32_t num = 0; int32_t numOfExprs = 0; SExprInfo* pExprInfo = createExprInfo(pPhyNode->pScanPseudoCols, NULL, &numOfExprs); - SArray* colList = extractColMatchInfo(pPhyNode->pScanPseudoCols, pDescNode, &num, COL_MATCH_FROM_COL_ID); + int32_t code = extractColMatchInfo(pPhyNode->pScanPseudoCols, pDescNode, &num, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); - int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfExprs); + code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfExprs); if (code != TSDB_CODE_SUCCESS) { goto _error; } pInfo->pTableList = pTableListInfo; - pInfo->pColMatchInfo = colList; pInfo->pRes = createResDataBlock(pDescNode); pInfo->readHandle = *pReadHandle; pInfo->curPos = 0; @@ -4180,11 +4179,11 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc } for (int32_t i = 0; i < numOfCols; ++i) { - SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i); - if (!pColMatchInfo->output) { + SColMatchItem* pColMatchInfo = taosArrayGet(pTableScanInfo->matchInfo.pList, i); + if (!pColMatchInfo->needOutput) { continue; } - pBlock->pBlockAgg[pColMatchInfo->targetSlotId] = pColAgg[i]; + pBlock->pBlockAgg[pColMatchInfo->dstSlotId] = pColAgg[i]; } return TSDB_CODE_SUCCESS; @@ -4215,7 +4214,7 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc return terrno; } - relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols, true); + relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true); // currently only the tbname pseudo column if (pTableScanInfo->pseudoSup.numOfExprs > 0) { @@ -4228,7 +4227,7 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc if (pTableScanInfo->pFilterNode != NULL) { int64_t st = taosGetTimestampMs(); - doFilter(pTableScanInfo->pFilterNode, pBlock, pTableScanInfo->pColMatchInfo, NULL); + doFilter(pTableScanInfo->pFilterNode, pBlock, &pTableScanInfo->matchInfo, NULL); double el = (taosGetTimestampUs() - st) / 1000.0; pTableScanInfo->readRecorder.filterTime += el; @@ -4312,9 +4311,9 @@ static SSDataBlock* getTableDataBlock(void* param) { SArray* generateSortByTsInfo(SArray* colMatchInfo, int32_t order) { int32_t tsTargetSlotId = 0; for (int32_t i = 0; i < taosArrayGetSize(colMatchInfo); ++i) { - SColMatchInfo* colInfo = taosArrayGet(colMatchInfo, i); + SColMatchItem* colInfo = taosArrayGet(colMatchInfo, i); if (colInfo->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - tsTargetSlotId = colInfo->targetSlotId; + tsTargetSlotId = colInfo->dstSlotId; } } @@ -4500,8 +4499,8 @@ void destroyTableMergeScanOperatorInfo(void* param) { } taosArrayDestroy(pTableScanInfo->dataReaders); - if (pTableScanInfo->pColMatchInfo != NULL) { - taosArrayDestroy(pTableScanInfo->pColMatchInfo); + if (pTableScanInfo->matchInfo.pList != NULL) { + taosArrayDestroy(pTableScanInfo->matchInfo.pList); } pTableScanInfo->pResBlock = blockDataDestroy(pTableScanInfo->pResBlock); @@ -4559,11 +4558,11 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc; int32_t numOfCols = 0; - SArray* pColList = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID); + int32_t code = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); - int32_t code = initQueryTableDataCond(&pInfo->cond, pTableScanNode); + code = initQueryTableDataCond(&pInfo->cond, pTableScanNode); if (code != TSDB_CODE_SUCCESS) { - taosArrayDestroy(pColList); + taosArrayDestroy(pInfo->matchInfo.pList); goto _error; } @@ -4583,12 +4582,11 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN pInfo->pFilterNode = pTableScanNode->scan.node.pConditions; pInfo->tableListInfo = pTableListInfo; pInfo->scanFlag = MAIN_SCAN; - pInfo->pColMatchInfo = pColList; pInfo->pResBlock = createResDataBlock(pDescNode); pInfo->sortSourceParams = taosArrayInit(64, sizeof(STableMergeScanSortSourceParam)); - pInfo->pSortInfo = generateSortByTsInfo(pInfo->pColMatchInfo, pInfo->cond.order); + pInfo->pSortInfo = generateSortByTsInfo(pInfo->matchInfo.pList, pInfo->cond.order); pInfo->pSortInputBlock = createOneDataBlock(pInfo->pResBlock, false); int32_t rowSize = pInfo->pResBlock->info.rowSize; diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 39987d4501..04f86d90d5 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -38,8 +38,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* SExprInfo* pExprInfo = createExprInfo(pSortNode->pExprs, NULL, &numOfCols); int32_t numOfOutputCols = 0; - SArray* pColMatchColInfo = - extractColMatchInfo(pSortNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + int32_t code = extractColMatchInfo(pSortNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo); pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset); @@ -48,7 +47,6 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pInfo->binfo.pRes = pResBlock; pInfo->pSortInfo = createSortInfo(pSortNode->pSortKeys); pInfo->pCondition = pSortNode->node.pConditions; - pInfo->pColMatchInfo = pColMatchColInfo; initLimitInfo(pSortNode->node.pLimit, pSortNode->node.pSlimit, &pInfo->limitInfo); pOperator->name = "SortOperator"; @@ -67,7 +65,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pOperator->fpSet = createOperatorFpSet(doOpenSortOperator, doSort, NULL, NULL, destroyOrderOperatorInfo, getExplainExecInfo); - int32_t code = appendDownstream(pOperator, &downstream, 1); + code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -127,11 +125,11 @@ SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, i // todo extract function to handle this int32_t numOfCols = taosArrayGetSize(pColMatchInfo); for (int32_t i = 0; i < numOfCols; ++i) { - SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i); - ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID); + SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i); +// ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID); SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId); - SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->targetSlotId); + SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId); colDataAssign(pDst, pSrc, p->info.rows, &pDataBlock->info); } @@ -210,13 +208,13 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) { SSDataBlock* pBlock = NULL; while (1) { pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, - pInfo->pColMatchInfo, pInfo); + pInfo->matchInfo.pList, pInfo); if (pBlock == NULL) { doSetOperatorCompleted(pOperator); return NULL; } - doFilter(pInfo->pCondition, pBlock, pInfo->pColMatchInfo, NULL); + doFilter(pInfo->pCondition, pBlock, &pInfo->matchInfo, NULL); if (blockDataGetNumOfRows(pBlock) == 0) { continue; } @@ -256,7 +254,7 @@ void destroyOrderOperatorInfo(void* param) { tsortDestroySortHandle(pInfo->pSortHandle); taosArrayDestroy(pInfo->pSortInfo); - taosArrayDestroy(pInfo->pColMatchInfo); + taosArrayDestroy(pInfo->matchInfo.pList); taosMemoryFreeClear(param); } @@ -277,20 +275,17 @@ int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* typedef enum EChildOperatorStatus { CHILD_OP_NEW_GROUP, CHILD_OP_SAME_GROUP, CHILD_OP_FINISHED } EChildOperatorStatus; typedef struct SGroupSortOperatorInfo { - SOptrBasicInfo binfo; - SArray* pSortInfo; - SArray* pColMatchInfo; - - int64_t startTs; - uint64_t sortElapsed; - bool hasGroupId; - uint64_t currGroupId; - + SOptrBasicInfo binfo; + SArray* pSortInfo; + SColMatchInfo matchInfo; + int64_t startTs; + uint64_t sortElapsed; + bool hasGroupId; + uint64_t currGroupId; SSDataBlock* prefetchedSortInput; SSortHandle* pCurrSortHandle; EChildOperatorStatus childOpStatus; - - SSortExecInfo sortExecInfo; + SSortExecInfo sortExecInfo; } SGroupSortOperatorInfo; SSDataBlock* getGroupSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity, @@ -320,11 +315,11 @@ SSDataBlock* getGroupSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlo if (p->info.rows > 0) { int32_t numOfCols = taosArrayGetSize(pColMatchInfo); for (int32_t i = 0; i < numOfCols; ++i) { - SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i); - ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID); + SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i); +// ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID); SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId); - SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->targetSlotId); + SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId); colDataAssign(pDst, pSrc, p->info.rows, &pDataBlock->info); } @@ -442,7 +437,7 @@ SSDataBlock* doGroupSort(SOperatorInfo* pOperator) { // beginSortGroup would fetch all child blocks of pInfo->currGroupId; ASSERT(pInfo->childOpStatus != CHILD_OP_SAME_GROUP); pBlock = getGroupSortedBlockData(pInfo->pCurrSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, - pInfo->pColMatchInfo, pInfo); + pInfo->matchInfo.pList, pInfo); if (pBlock != NULL) { pBlock->info.groupId = pInfo->currGroupId; pOperator->resultInfo.totalRows += pBlock->info.rows; @@ -474,7 +469,7 @@ void destroyGroupSortOperatorInfo(void* param) { pInfo->binfo.pRes = blockDataDestroy(pInfo->binfo.pRes); taosArrayDestroy(pInfo->pSortInfo); - taosArrayDestroy(pInfo->pColMatchInfo); + taosArrayDestroy(pInfo->matchInfo.pList); taosMemoryFreeClear(param); } @@ -494,8 +489,8 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort SExprInfo* pExprInfo = createExprInfo(pSortPhyNode->pExprs, NULL, &numOfCols); int32_t numOfOutputCols = 0; - SArray* pColMatchColInfo = - extractColMatchInfo(pSortPhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + int32_t code = extractColMatchInfo(pSortPhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, + &pInfo->matchInfo); pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset); pInfo->binfo.pRes = pResBlock; @@ -503,8 +498,7 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort initResultSizeInfo(&pOperator->resultInfo, 1024); pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys); - ; - pInfo->pColMatchInfo = pColMatchColInfo; + pOperator->name = "GroupSortOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT; pOperator->blocking = false; @@ -517,7 +511,7 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, NULL, destroyGroupSortOperatorInfo, getGroupSortExplainExecInfo); - int32_t code = appendDownstream(pOperator, &downstream, 1); + code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -535,20 +529,18 @@ _error: // Multiway Sort Merge operator typedef struct SMultiwayMergeOperatorInfo { SOptrBasicInfo binfo; + int32_t bufPageSize; + uint32_t sortBufSize; // max buffer size for in-memory sort - int32_t bufPageSize; - uint32_t sortBufSize; // max buffer size for in-memory sort - - SArray* pSortInfo; - SSortHandle* pSortHandle; - SArray* pColMatchInfo; // for index map from table scan output - - SSDataBlock* pInputBlock; - int64_t startTs; // sort start time - bool groupSort; - bool hasGroupId; - uint64_t groupId; - STupleHandle* prefetchedTuple; + SArray* pSortInfo; + SSortHandle* pSortHandle; + SColMatchInfo matchInfo; + SSDataBlock* pInputBlock; + int64_t startTs; // sort start time + bool groupSort; + bool hasGroupId; + uint64_t groupId; + STupleHandle* prefetchedTuple; } SMultiwayMergeOperatorInfo; int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) { @@ -645,11 +637,11 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData blockDataEnsureCapacity(pDataBlock, p->info.rows); int32_t numOfCols = taosArrayGetSize(pColMatchInfo); for (int32_t i = 0; i < numOfCols; ++i) { - SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i); - ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID); + SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, i); +// ASSERT(pColMatchInfo-> == COL_MATCH_FROM_SLOT_ID); SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId); - SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->targetSlotId); + SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->dstSlotId); colDataAssign(pDst, pSrc, p->info.rows, &pDataBlock->info); } @@ -678,7 +670,7 @@ SSDataBlock* doMultiwayMerge(SOperatorInfo* pOperator) { } SSDataBlock* pBlock = getMultiwaySortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, - pOperator->resultInfo.capacity, pInfo->pColMatchInfo, pOperator); + pOperator->resultInfo.capacity, pInfo->matchInfo.pList, pOperator); if (pBlock != NULL) { pOperator->resultInfo.totalRows += pBlock->info.rows; } else { @@ -694,7 +686,7 @@ void destroyMultiwayMergeOperatorInfo(void* param) { tsortDestroySortHandle(pInfo->pSortHandle); taosArrayDestroy(pInfo->pSortInfo); - taosArrayDestroy(pInfo->pColMatchInfo); + taosArrayDestroy(pInfo->matchInfo.pList); taosMemoryFreeClear(param); } @@ -731,15 +723,14 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size SArray* pSortInfo = createSortInfo(pMergePhyNode->pMergeKeys); int32_t numOfOutputCols = 0; - SArray* pColMatchColInfo = - extractColMatchInfo(pMergePhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + + code = extractColMatchInfo(pMergePhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo); SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0); SSDataBlock* pInputBlock = createResDataBlock(pChildNode->pOutputDataBlockDesc); initResultSizeInfo(&pOperator->resultInfo, 1024); pInfo->groupSort = pMergePhyNode->groupSort; pInfo->pSortInfo = pSortInfo; - pInfo->pColMatchInfo = pColMatchColInfo; pInfo->pInputBlock = pInputBlock; pInfo->bufPageSize = getProperSortPageSize(rowSize); pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); // one additional is reserved for merged result. diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 5d3f5e07d3..23847928da 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -722,7 +722,7 @@ void destroyStreamFillOperatorInfo(void* param) { pInfo->pSrcBlock = blockDataDestroy(pInfo->pSrcBlock); pInfo->pPrevSrcBlock = blockDataDestroy(pInfo->pPrevSrcBlock); pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes); - pInfo->pColMatchColInfo = taosArrayDestroy(pInfo->pColMatchColInfo); + pInfo->matchInfo.pList = taosArrayDestroy(pInfo->matchInfo.pList); taosMemoryFree(pInfo); } @@ -1499,7 +1499,7 @@ static SSDataBlock* doStreamFill(SOperatorInfo* pOperator) { } doStreamFillImpl(pOperator); - doFilter(pInfo->pCondition, pInfo->pRes, pInfo->pColMatchColInfo, NULL); + doFilter(pInfo->pCondition, pInfo->pRes, &pInfo->matchInfo, NULL); memcpy(pInfo->pRes->info.parTbName, pInfo->pSrcBlock->info.parTbName, TSDB_TABLE_NAME_LEN); pOperator->resultInfo.totalRows += pInfo->pRes->info.rows; if (pInfo->pRes->info.rows > 0) { @@ -1675,11 +1675,10 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi pInfo->primarySrcSlotId = ((SColumnNode*)((STargetNode*)pPhyFillNode->pWStartTs)->pExpr)->slotId; int32_t numOfOutputCols = 0; - SArray* pColMatchColInfo = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, - &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + int32_t code = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc, + &numOfOutputCols, COL_MATCH_FROM_SLOT_ID, &pInfo->matchInfo); pInfo->pCondition = pPhyFillNode->node.pConditions; - pInfo->pColMatchColInfo = pColMatchColInfo; - int32_t code = initExprSupp(&pOperator->exprSupp, pFillExprInfo, numOfFillCols); + code = initExprSupp(&pOperator->exprSupp, pFillExprInfo, numOfFillCols); if (code != TSDB_CODE_SUCCESS) { goto _error; } From 292f0c6db7bc98ad5de8a680bfbef14446f09534 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Mon, 24 Oct 2022 16:58:45 +0800 Subject: [PATCH 47/72] enh: insert parser refactor --- source/client/inc/clientInt.h | 8 ++--- source/client/src/clientImpl.c | 60 ---------------------------------- source/client/src/clientMain.c | 39 ++++++++-------------- 3 files changed, 15 insertions(+), 92 deletions(-) diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index f815adfeaa..cf8b0babdd 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -46,7 +46,6 @@ extern "C" { #define ERROR_MSG_BUF_DEFAULT_SIZE 512 #define HEARTBEAT_INTERVAL 1500 // ms -#define SYNC_ON_TOP_OF_ASYNC 1 enum { RES_TYPE__QUERY = 1, @@ -271,9 +270,8 @@ void doFreeReqResultInfo(SReqResultInfo* pResInfo); int32_t transferTableNameList(const char* tbList, int32_t acctId, char* dbName, SArray** pReq); void syncCatalogFn(SMetaData* pResult, void* param, int32_t code); -SRequestObj* execQuery(uint64_t connId, const char* sql, int sqlLen, bool validateOnly); -TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly); -void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly); +TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly); +void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly); int32_t getVersion1BlockMetaSize(const char* p, int32_t numOfCols); @@ -349,8 +347,6 @@ void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet); STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db, uint16_t port, int connType); -SRequestObj* launchQuery(uint64_t connId, const char* sql, int sqlLen, bool validateOnly, bool inRetry); - int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtCallback* pStmtCb); int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 0bf254e455..0c12d78c18 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1013,28 +1013,6 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue return pRequest; } -SRequestObj* launchQuery(uint64_t connId, const char* sql, int sqlLen, bool validateOnly, bool inRetry) { - SRequestObj* pRequest = NULL; - SQuery* pQuery = NULL; - - int32_t code = buildRequest(connId, sql, sqlLen, NULL, validateOnly, &pRequest); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - return NULL; - } - - code = parseSql(pRequest, false, &pQuery, NULL); - if (code != TSDB_CODE_SUCCESS) { - pRequest->code = code; - return pRequest; - } - - pRequest->inRetry = inRetry; - pRequest->stableQuery = pQuery->stableQuery; - - return launchQueryImpl(pRequest, pQuery, false, NULL); -} - static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta, SSqlCallbackWrapper* pWrapper) { pRequest->type = pQuery->msgType; @@ -1197,32 +1175,6 @@ int32_t removeMeta(STscObj* pTscObj, SArray* tbList) { return TSDB_CODE_SUCCESS; } -// todo remove it soon -SRequestObj* execQuery(uint64_t connId, const char* sql, int sqlLen, bool validateOnly) { - SRequestObj* pRequest = NULL; - int32_t retryNum = 0; - int32_t code = 0; - bool inRetry = false; - - do { - destroyRequest(pRequest); - pRequest = launchQuery(connId, sql, sqlLen, validateOnly, inRetry); - if (pRequest == NULL || TSDB_CODE_SUCCESS == pRequest->code || !NEED_CLIENT_HANDLE_ERROR(pRequest->code)) { - break; - } - - code = refreshMeta(pRequest->pTscObj, pRequest); - if (code) { - pRequest->code = code; - break; - } - - inRetry = true; - } while (retryNum++ < REQUEST_TOTAL_EXEC_TIMES); - - return pRequest; -} - int initEpSetFromCfg(const char* firstEp, const char* secondEp, SCorEpSet* pEpSet) { pEpSet->version = 0; @@ -2291,7 +2243,6 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { return NULL; } -#if SYNC_ON_TOP_OF_ASYNC SSyncQueryParam* param = taosMemoryCalloc(1, sizeof(SSyncQueryParam)); tsem_init(¶m->sem, 0, 0); @@ -2301,15 +2252,4 @@ TAOS_RES* taosQueryImpl(TAOS* taos, const char* sql, bool validateOnly) { param->pRequest->syncQuery = true; } return param->pRequest; -#else - size_t sqlLen = strlen(sql); - if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { - tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); - terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; - return NULL; - } - - TAOS_RES* pRes = execQuery(*(int64_t*)taos, sql, sqlLen, validateOnly); - return pRes; -#endif } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 8036e50545..b03576ff01 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -261,12 +261,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { return NULL; } -#if SYNC_ON_TOP_OF_ASYNC return doAsyncFetchRows(pRequest, true, true); -#else - return doFetchRows(pRequest, true, true); -#endif - } else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) { SMqRspObj *msg = ((SMqRspObj *)res); SReqResultInfo *pResultInfo; @@ -549,11 +544,7 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) { return 0; } -#if SYNC_ON_TOP_OF_ASYNC doAsyncFetchRows(pRequest, false, true); -#else - doFetchRows(pRequest, true, true); -#endif // TODO refactor SReqResultInfo *pResultInfo = &pRequest->body.resInfo; @@ -601,11 +592,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) { return 0; } -#if SYNC_ON_TOP_OF_ASYNC doAsyncFetchRows(pRequest, false, false); -#else - doFetchRows(pRequest, false, false); -#endif SReqResultInfo *pResultInfo = &pRequest->body.resInfo; @@ -989,7 +976,7 @@ const void *taos_get_raw_block(TAOS_RES *res) { return pRequest->body.resInfo.pData; } -int taos_get_db_route_info(TAOS* taos, const char* db, TAOS_DB_ROUTE_INFO* dbInfo) { +int taos_get_db_route_info(TAOS *taos, const char *db, TAOS_DB_ROUTE_INFO *dbInfo) { if (NULL == taos) { terrno = TSDB_CODE_TSC_DISCONNECTED; return terrno; @@ -1001,16 +988,16 @@ int taos_get_db_route_info(TAOS* taos, const char* db, TAOS_DB_ROUTE_INFO* dbInf return terrno; } - int64_t connId = *(int64_t *)taos; - SRequestObj *pRequest = NULL; - char *sql = "taos_get_db_route_info"; - int32_t code = buildRequest(connId, sql, strlen(sql), NULL, false, &pRequest); + int64_t connId = *(int64_t *)taos; + SRequestObj *pRequest = NULL; + char *sql = "taos_get_db_route_info"; + int32_t code = buildRequest(connId, sql, strlen(sql), NULL, false, &pRequest); if (code != TSDB_CODE_SUCCESS) { terrno = code; return terrno; } - STscObj *pTscObj = pRequest->pTscObj; + STscObj *pTscObj = pRequest->pTscObj; SCatalog *pCtg = NULL; code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCtg); if (code != TSDB_CODE_SUCCESS) { @@ -1024,7 +1011,7 @@ int taos_get_db_route_info(TAOS* taos, const char* db, TAOS_DB_ROUTE_INFO* dbInf char dbFName[TSDB_DB_FNAME_LEN] = {0}; snprintf(dbFName, sizeof(dbFName), "%d.%s", pTscObj->acctId, db); - + code = catalogGetDBVgInfo(pCtg, &conn, dbFName, dbInfo); if (code) { goto _return; @@ -1038,7 +1025,7 @@ _return: return code; } -int taos_get_table_vgId(TAOS* taos, const char* db, const char* table, int* vgId) { +int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId) { if (NULL == taos) { terrno = TSDB_CODE_TSC_DISCONNECTED; return terrno; @@ -1050,15 +1037,15 @@ int taos_get_table_vgId(TAOS* taos, const char* db, const char* table, int* vgId return terrno; } - int64_t connId = *(int64_t *)taos; - SRequestObj *pRequest = NULL; - char *sql = "taos_get_table_vgId"; - int32_t code = buildRequest(connId, sql, strlen(sql), NULL, false, &pRequest); + int64_t connId = *(int64_t *)taos; + SRequestObj *pRequest = NULL; + char *sql = "taos_get_table_vgId"; + int32_t code = buildRequest(connId, sql, strlen(sql), NULL, false, &pRequest); if (code != TSDB_CODE_SUCCESS) { return terrno; } - STscObj *pTscObj = pRequest->pTscObj; + STscObj *pTscObj = pRequest->pTscObj; SCatalog *pCtg = NULL; code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCtg); if (code != TSDB_CODE_SUCCESS) { From 992a130860eb43f58531e5e09743ef0f8bf3b049 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 24 Oct 2022 17:24:20 +0800 Subject: [PATCH 48/72] refactor: do some internal refactor. --- source/dnode/mnode/impl/src/mndGrant.c | 2 -- source/libs/executor/src/executil.c | 1 + source/libs/executor/src/scanoperator.c | 5 ++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndGrant.c b/source/dnode/mnode/impl/src/mndGrant.c index 7262f23657..396de7eed3 100644 --- a/source/dnode/mnode/impl/src/mndGrant.c +++ b/source/dnode/mnode/impl/src/mndGrant.c @@ -21,10 +21,8 @@ static int32_t mndRetrieveGrant(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { int32_t numOfRows = 0; - char *pWrite; int32_t cols = 0; char tmp[32]; - char tmp1[32]; if (pShow->numOfRows < 1) { cols = 0; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 506033b3b6..f58c2a0e34 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1120,6 +1120,7 @@ int32_t extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod } } + pMatchInfo->pList = pList; return code; } diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 75abd22e46..9773a0c8e7 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -3890,7 +3890,6 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan SScanPhysiNode* pScanNode = &pScanPhyNode->scan; SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc; - SSDataBlock* pResBlock = createResDataBlock(pDescNode); int32_t num = 0; int32_t code = extractColMatchInfo(pScanNode->pScanCols, pDescNode, &num, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); @@ -3899,7 +3898,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan pInfo->pUser = taosMemoryStrDup((void*)pUser); pInfo->sysInfo = pScanPhyNode->sysInfo; pInfo->showRewrite = pScanPhyNode->showRewrite; - pInfo->pRes = pResBlock; + pInfo->pRes = createResDataBlock(pDescNode); pInfo->pCondition = pScanNode->node.pConditions; initResultSizeInfo(&pOperator->resultInfo, 4096); @@ -3922,7 +3921,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan pOperator->blocking = false; pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; - pOperator->exprSupp.numOfExprs = taosArrayGetSize(pResBlock->pDataBlock); + pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = From 1935d349d4dfe3ba16a6a29c2a80cd0b873aff72 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 49/72] fix: coverity issues CID: 399493 --- source/libs/function/src/builtins.c | 49 +++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 49facfdd14..cffe1700ed 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -209,7 +209,7 @@ static int32_t countTrailingSpaces(const SValueNode* pVal, bool isLtrim) { return numOfSpaces; } -void static addTimezoneParam(SNodeList* pList) { +static int32_t addTimezoneParam(SNodeList* pList) { char buf[6] = {0}; time_t t = taosTime(NULL); struct tm tmInfo; @@ -218,6 +218,10 @@ void static addTimezoneParam(SNodeList* pList) { int32_t len = (int32_t)strlen(buf); SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + if (pVal == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pVal->literal = strndup(buf, len); pVal->isDuration = false; pVal->translate = true; @@ -229,10 +233,15 @@ void static addTimezoneParam(SNodeList* pList) { strncpy(varDataVal(pVal->datum.p), pVal->literal, len); nodesListAppend(pList, (SNode*)pVal); + return TSDB_CODE_SUCCESS; } -void static addDbPrecisonParam(SNodeList** pList, uint8_t precision) { +static int32_t addDbPrecisonParam(SNodeList** pList, uint8_t precision) { SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + if (pVal == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pVal->literal = NULL; pVal->isDuration = false; pVal->translate = true; @@ -244,6 +253,7 @@ void static addDbPrecisonParam(SNodeList** pList, uint8_t precision) { pVal->typeData = (int64_t)precision; nodesListMakeAppend(pList, (SNode*)pVal); + return TSDB_CODE_SUCCESS; } // There is only one parameter of numeric type, and the return type is parameter type @@ -465,7 +475,10 @@ static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t le // add database precision as param uint8_t dbPrec = pFunc->node.resType.precision; - addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pFunc->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_TIMESTAMP}; return TSDB_CODE_SUCCESS; @@ -1487,7 +1500,10 @@ static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len) // add database precision as param uint8_t dbPrec = pFunc->node.resType.precision; - addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE}; return TSDB_CODE_SUCCESS; @@ -1810,7 +1826,10 @@ static int32_t translateCast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // add database precision as param uint8_t dbPrec = pFunc->node.resType.precision; - addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + if (code != TSDB_CODE_SUCCESS) { + return code; + } return TSDB_CODE_SUCCESS; } @@ -1844,7 +1863,10 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR, "Invalid timzone format"); } } else { // add default client timezone - addTimezoneParam(pFunc->pParameterList); + int32_t code = addTimezoneParam(pFunc->pParameterList); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } // set result type @@ -1863,7 +1885,10 @@ static int32_t translateToUnixtimestamp(SFunctionNode* pFunc, char* pErrBuf, int // add database precision as param uint8_t dbPrec = pFunc->node.resType.precision; - addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; return TSDB_CODE_SUCCESS; @@ -1894,7 +1919,10 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_ "TIMETRUNCATE function time unit parameter should be one of the following: [1b, 1u, 1a, 1s, 1m, 1h, 1d, 1w]"); } - addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; @@ -1935,7 +1963,10 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le } } - addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + int32_t code = addDbPrecisonParam(&pFunc->pParameterList, dbPrec); + if (code != TSDB_CODE_SUCCESS) { + return code; + } pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; return TSDB_CODE_SUCCESS; From 3196ee5755bdc40deb0c9f68957357bb46042650 Mon Sep 17 00:00:00 2001 From: haoranchen Date: Mon, 24 Oct 2022 18:00:36 +0800 Subject: [PATCH 50/72] Revert "test: build taosx and add test case of taosx" --- tests/docs-examples-test/taosx.sh | 18 ------------------ tests/parallel_test/container_build.sh | 2 +- 2 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 tests/docs-examples-test/taosx.sh diff --git a/tests/docs-examples-test/taosx.sh b/tests/docs-examples-test/taosx.sh deleted file mode 100644 index 5db2605bfd..0000000000 --- a/tests/docs-examples-test/taosx.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -e - -taosd >>/dev/null 2>&1 & -taosadapter >>/dev/null 2>&1 & -sleep 5 - -taosBenchmark -y -n 10000 -t 1000 - -taosx run -f 'tmq:///test' -t 'taos:///test1' -y - -taos -s 'select count(*) from test1.meters' |grep 10000000 || (echo database sync failed!; exit 1) - -taosx run -f 'tmq:///test' -t 'local:./test-backup' -y -taosx run -f 'local:./test-backup' -t 'taos:///test2' -y - -rm -rf ./test-backup diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh index e88982aa80..deaea4fa40 100755 --- a/tests/parallel_test/container_build.sh +++ b/tests/parallel_test/container_build.sh @@ -52,7 +52,7 @@ fi docker run \ -v $REP_MOUNT_PARAM \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DWEBSOCKET=true -DBUILD_TAOSX=true;make -j $THREAD_COUNT" + --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DWEBSOCKET=true;make -j $THREAD_COUNT" ret=$? exit $ret From 8082b71cce74a5ba06e94e75c99bdef8d17bc31a Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Mon, 24 Oct 2022 18:05:14 +0800 Subject: [PATCH 51/72] fix(sync): free pLocalEntry --- source/libs/sync/src/syncAppendEntries.c | 33 +++++++----------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 170a57a7a9..80e0cbbf99 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -383,6 +383,8 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg) { snprintf(logBuf, sizeof(logBuf), "ignore, truncate error, append-index:%" PRId64, appendIndex); syncLogRecvAppendEntries(ths, pMsg, logBuf); + syncEntryDestory(pLocalEntry); + syncEntryDestory(pAppendEntry); goto _IGNORE; } @@ -393,6 +395,8 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg) { snprintf(logBuf, sizeof(logBuf), "ignore, append error, append-index:%" PRId64, appendIndex); syncLogRecvAppendEntries(ths, pMsg, logBuf); + syncEntryDestory(pLocalEntry); + syncEntryDestory(pAppendEntry); goto _IGNORE; } } @@ -408,6 +412,8 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg) { snprintf(logBuf, sizeof(logBuf), "ignore, log not exist, truncate error, append-index:%" PRId64, appendIndex); syncLogRecvAppendEntries(ths, pMsg, logBuf); + syncEntryDestory(pLocalEntry); + syncEntryDestory(pAppendEntry); goto _IGNORE; } @@ -418,6 +424,8 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg) { snprintf(logBuf, sizeof(logBuf), "ignore, log not exist, append error, append-index:%" PRId64, appendIndex); syncLogRecvAppendEntries(ths, pMsg, logBuf); + syncEntryDestory(pLocalEntry); + syncEntryDestory(pAppendEntry); goto _IGNORE; } @@ -427,33 +435,12 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg) { snprintf(logBuf, sizeof(logBuf), "ignore, get local entry error, append-index:%" PRId64, appendIndex); syncLogRecvAppendEntries(ths, pMsg, logBuf); + syncEntryDestory(pLocalEntry); + syncEntryDestory(pAppendEntry); goto _IGNORE; } } -#if 0 - if (code != 0 && terrno == TSDB_CODE_WAL_LOG_NOT_EXIST) { - code = ths->pLogStore->syncLogTruncate(ths->pLogStore, appendIndex); - ASSERT(code == 0); - - code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry); - ASSERT(code == 0); - - } else { - ASSERT(code == 0); - - if (pLocalEntry->term == pAppendEntry->term) { - // do nothing - } else { - code = ths->pLogStore->syncLogTruncate(ths->pLogStore, appendIndex); - ASSERT(code == 0); - - code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry); - ASSERT(code == 0); - } - } -#endif - // update match index pReply->matchIndex = pAppendEntry->index; From 97e70e8f2750a6938423490b696c63133b0c9d26 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 24 Oct 2022 18:41:39 +0800 Subject: [PATCH 52/72] fix(all): coverity scan problem fixed --- source/os/src/osFile.c | 2 +- source/util/src/tcompression.c | 1 + source/util/src/tencode.c | 4 +--- source/util/src/tlog.c | 4 +--- tools/shell/src/shellTire.c | 4 ++-- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index cea4d6882e..94a10322ed 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -191,7 +191,7 @@ int32_t taosRenameFile(const char *oldName, const char *newName) { printf("failed to rename file %s to %s, reason:%s\n", oldName, newName, strerror(errno)); } - return code ? 0 : 1; + return code ? 0 : -1; #else int32_t code = rename(oldName, newName); if (code < 0) { diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index fbbe970c74..72b31fa238 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -2275,6 +2275,7 @@ int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t } else if (cmprAlg == TWO_STAGE_COMP) { int32_t len = tsCompressBoolImp(pIn, nEle, pBuf); if (len < 0) { + strerror(errno)); return -1; } return tsCompressStringImp(pBuf, len, pOut, nOut); diff --git a/source/util/src/tencode.c b/source/util/src/tencode.c index a925d1fc5e..7f8a0edfdd 100644 --- a/source/util/src/tencode.c +++ b/source/util/src/tencode.c @@ -109,9 +109,7 @@ void tEndEncode(SEncoder* pCoder) { pCoder->size = pNode->size; pCoder->pos = pNode->pos; - if (tEncodeI32(pCoder, len) < 0) { - return; - } + (void)tEncodeI32(pCoder, len); TD_CODER_MOVE_POS(pCoder, len); } diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 09d12029bc..618b80760f 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -207,9 +207,7 @@ static void taosKeepOldLog(char *oldName) { char fileName[LOG_FILE_NAME_LEN + 20]; snprintf(fileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64, tsLogObj.logName, fileSec); - if (taosRenameFile(oldName, fileName) != 0) { - return; - } + (void)taosRenameFile(oldName, fileName); if (tsLogKeepDays < 0) { char compressFileName[LOG_FILE_NAME_LEN + 20]; diff --git a/tools/shell/src/shellTire.c b/tools/shell/src/shellTire.c index 25defbf9a8..0ce0588cce 100644 --- a/tools/shell/src/shellTire.c +++ b/tools/shell/src/shellTire.c @@ -356,9 +356,9 @@ void enumFromTree(STire* tire, SMatch* match) { } // this branch have data - if (c->end) + if (c->end) { addWordToMatch(match, pre); - else { + } else { matchPrefix(tire, pre, match); } } From d54ed458223720d3112b7dabf0fe92ce8aff9e1e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 24 Oct 2022 18:49:48 +0800 Subject: [PATCH 53/72] fix(all): remove seterror, no use --- source/util/src/tcompression.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 72b31fa238..fbbe970c74 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -2275,7 +2275,6 @@ int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t } else if (cmprAlg == TWO_STAGE_COMP) { int32_t len = tsCompressBoolImp(pIn, nEle, pBuf); if (len < 0) { - strerror(errno)); return -1; } return tsCompressStringImp(pBuf, len, pOut, nOut); From 42dfe03e7d3d29b4fa08ca462c978419d4f46ad3 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 54/72] fix: coverity issues CID: 399518 --- source/libs/function/src/tpercentile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/function/src/tpercentile.c b/source/libs/function/src/tpercentile.c index 62c5e4b28b..c25d2d4a27 100644 --- a/source/libs/function/src/tpercentile.c +++ b/source/libs/function/src/tpercentile.c @@ -492,7 +492,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times - 1); SIDList list = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); - assert(list->size > 0); + ASSERT(list != NULL && list->size > 0); for (int32_t f = 0; f < list->size; ++f) { SPageInfo *pgInfo = *(SPageInfo **)taosArrayGet(list, f); From e0d72e474985411ed916b09f359feaab3d226b3c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 24 Oct 2022 19:10:50 +0800 Subject: [PATCH 55/72] refactor: do some internal refactor, and reduce the number of bufferred intermediate blocks. --- source/libs/executor/src/executor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index fb4248e886..0312105ca8 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -355,7 +355,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, goto _error; } - SDataSinkMgtCfg cfg = {.maxDataBlockNum = 10000, .maxDataBlockNumPerQuery = 5000}; + SDataSinkMgtCfg cfg = {.maxDataBlockNum = 500, .maxDataBlockNumPerQuery = 50}; code = dsDataSinkMgtInit(&cfg); if (code != TSDB_CODE_SUCCESS) { qError("failed to dsDataSinkMgtInit, code:%s, %s", tstrerror(code), (*pTask)->id.str); From 4fe6da69f567c16b988408d9f75036b4a7479ea6 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 24 Oct 2022 19:14:11 +0800 Subject: [PATCH 56/72] refactor: reduce the buffered blocks in sink node. --- source/libs/executor/src/executor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 0d861c1fb9..b05534efb2 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -354,7 +354,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, goto _error; } - SDataSinkMgtCfg cfg = {.maxDataBlockNum = 10000, .maxDataBlockNumPerQuery = 5000}; + SDataSinkMgtCfg cfg = {.maxDataBlockNum = 500, .maxDataBlockNumPerQuery = 50}; code = dsDataSinkMgtInit(&cfg); if (code != TSDB_CODE_SUCCESS) { qError("failed to dsDataSinkMgtInit, code: %s", tstrerror(code)); From cd0a051157a1df695146511f2cafcceb31a4d1b9 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 57/72] fix: coverity issues CID: 399671 --- source/libs/function/src/builtinsimpl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 874822106e..d3120c52e9 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -5371,7 +5371,7 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); int32_t currentRow = pBlock->info.rows; - int32_t resIndex; + int32_t resIndex = -1; int32_t maxCount = 0; for (int32_t i = 0; i < pInfo->numOfPoints; ++i) { SModeItem* pItem = (SModeItem*)(pInfo->pItems + i * (sizeof(SModeItem) + pInfo->colBytes)); @@ -5381,6 +5381,7 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } } + ASSERT(resIndex >= 0); SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes)); colDataAppend(pCol, currentRow, pResItem->data, (maxCount == 0) ? true : false); From 23b7150deee004bc428baeaa9be25d1a6c02dc04 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 58/72] fix: coverity issues CID: 399845 --- source/libs/scalar/src/sclfunc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 339065633b..c20ff06c16 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1420,7 +1420,7 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p } else if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) { timeVal[k] = timeVal[k] * 1000; } else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) { - timeVal[k] = timeVal[k]; + timeVal[k] = timeVal[k] * 1; } else { hasNull = true; break; From 585577cef33f5a1fe312a17c4b2a1ae57f8e69b4 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 59/72] fix: coverity issues CID: 399989 --- source/libs/function/src/builtinsimpl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index d3120c52e9..3ed894fe8d 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -1872,7 +1872,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) { numOfElem += 1; pStddevRes->count += 1; pStddevRes->usum += plist[i]; - pStddevRes->quadraticISum += plist[i] * plist[i]; + pStddevRes->quadraticUSum += plist[i] * plist[i]; } break; @@ -1888,7 +1888,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) { numOfElem += 1; pStddevRes->count += 1; pStddevRes->usum += plist[i]; - pStddevRes->quadraticISum += plist[i] * plist[i]; + pStddevRes->quadraticUSum += plist[i] * plist[i]; } break; } @@ -1903,7 +1903,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) { numOfElem += 1; pStddevRes->count += 1; pStddevRes->usum += plist[i]; - pStddevRes->quadraticISum += plist[i] * plist[i]; + pStddevRes->quadraticUSum += plist[i] * plist[i]; } break; @@ -1919,7 +1919,7 @@ int32_t stddevFunction(SqlFunctionCtx* pCtx) { numOfElem += 1; pStddevRes->count += 1; pStddevRes->usum += plist[i]; - pStddevRes->quadraticISum += plist[i] * plist[i]; + pStddevRes->quadraticUSum += plist[i] * plist[i]; } break; } From c04ade786741b6d746e07a8e3132e9575010081a Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Mon, 24 Oct 2022 14:16:17 +0800 Subject: [PATCH 60/72] fix: coverity issues CID: 400109 --- source/libs/scalar/src/scalar.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 26adad27bc..37949d0ff0 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -1488,8 +1488,13 @@ static int32_t sclGetMinusOperatorResType(SOperatorNode *pOp) { } static int32_t sclGetMathOperatorResType(SOperatorNode *pOp) { + if (pOp == NULL || pOp->pLeft == NULL || pOp->pRight == NULL) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType; SDataType rdt = ((SExprNode *)(pOp->pRight))->resType; + if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) || (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) || (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) { @@ -1510,7 +1515,12 @@ static int32_t sclGetMathOperatorResType(SOperatorNode *pOp) { } static int32_t sclGetCompOperatorResType(SOperatorNode *pOp) { + if (pOp == NULL || pOp->pLeft == NULL || pOp->pRight == NULL) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType; + if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) { ((SExprNode *)(pOp->pRight))->resType = ldt; } else if (nodesIsRegularOp(pOp)) { @@ -1526,8 +1536,13 @@ static int32_t sclGetCompOperatorResType(SOperatorNode *pOp) { } static int32_t sclGetJsonOperatorResType(SOperatorNode *pOp) { + if (pOp == NULL || pOp->pLeft == NULL || pOp->pRight == NULL) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType; SDataType rdt = ((SExprNode *)(pOp->pRight))->resType; + if (TSDB_DATA_TYPE_JSON != ldt.type || !IS_STR_DATA_TYPE(rdt.type)) { return TSDB_CODE_TSC_INVALID_OPERATION; } From caa88bc54d50ceb89762e2e3851fabe8da777350 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 25 Oct 2022 09:39:17 +0800 Subject: [PATCH 61/72] Revert "fix: coverity issues" This reverts commit aa4daf1770366d00dc35f36a6a6eedb1433458cd. --- source/common/src/tmsg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 44a3f27983..94483b8a64 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5954,7 +5954,6 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { if (pSW == NULL) return -1; if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) return -1; taosArrayPush(pRsp->blockSchema, &pSW); - taosMemoryFree(pSW); } if (pRsp->withTbName) { From 35b78f596ed823ce7efd60f640f9e07c8821e4fb Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 25 Oct 2022 09:42:26 +0800 Subject: [PATCH 62/72] Revert "Revert "fix: coverity issues"" This reverts commit caa88bc54d50ceb89762e2e3851fabe8da777350. --- source/common/src/tmsg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 94483b8a64..44a3f27983 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5954,6 +5954,7 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { if (pSW == NULL) return -1; if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) return -1; taosArrayPush(pRsp->blockSchema, &pSW); + taosMemoryFree(pSW); } if (pRsp->withTbName) { From 78d3a32f506f6ae21be0af5c43fd5884f8aef6e5 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 25 Oct 2022 09:43:25 +0800 Subject: [PATCH 63/72] Revert "fix: coverity issues" This reverts commit c2bff98311a1977a58d350506a0e91c815cc7912. --- source/common/src/trow.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 08a601909e..e1085ce5d8 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -948,10 +948,8 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp #ifdef TD_SUPPORT_BITMAP if (valType == TD_VTYPE_NORM) { terrno = TSDB_CODE_INVALID_PTR; - } else { - terrno = TSDB_CODE_INVALID_PARA; + return terrno; } - return terrno; #else TASSERT(0); terrno = TSDB_CODE_INVALID_PARA; @@ -1363,4 +1361,4 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV *pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, value); } -} +} \ No newline at end of file From 31ab529a5eab5f2b6939194e255b560f6daed303 Mon Sep 17 00:00:00 2001 From: jiajingbin Date: Tue, 25 Oct 2022 09:47:45 +0800 Subject: [PATCH 64/72] test: add keep expired cases --- tests/system-test/1-insert/keep_expired.py | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/system-test/1-insert/keep_expired.py diff --git a/tests/system-test/1-insert/keep_expired.py b/tests/system-test/1-insert/keep_expired.py new file mode 100644 index 0000000000..09db1e45ba --- /dev/null +++ b/tests/system-test/1-insert/keep_expired.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +from util.log import * +from util.cases import * +from util.sql import * +import time + + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.dbname = "test" + self.stbname = "stb" + self.ctbname = "ctb" + self.keep_value = "2d,2d,2d" + self.duration_value = "1d" + self.offset_time = 5 + self.sleep_time = self.offset_time*2 + + def run(self): + tdSql.execute(f'create database if not exists {self.dbname} duration {self.duration_value} keep {self.keep_value};') + tdSql.execute(f'create table {self.dbname}.{self.stbname} (ts timestamp, c11 int) TAGS(t11 int, t12 int );') + tdSql.execute(f'create table {self.dbname}.{self.ctbname} using {self.dbname}.{self.stbname} TAGS (1, 1);') + expired_row_ts = f'now-{int(self.keep_value.split(",")[0].replace("d", "")) * 86400 - self.offset_time}s' + tdSql.execute(f'insert into {self.dbname}.{self.ctbname} values ({expired_row_ts}, 1);') + tdSql.query(f'select * from {self.dbname}.{self.ctbname}') + tdSql.checkEqual(tdSql.queryRows, 1) + time.sleep(self.offset_time * 2) + tdSql.query(f'select * from {self.dbname}.{self.ctbname}') + tdSql.checkEqual(tdSql.queryRows, 0) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From 6547219c443530b31a327ad2bad1da3fcd0a5202 Mon Sep 17 00:00:00 2001 From: jiajingbin Date: Tue, 25 Oct 2022 09:50:56 +0800 Subject: [PATCH 65/72] test: add keep expired cases --- tests/system-test/fulltest.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 2c7848d505..b895a1bf19 100644 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -209,6 +209,7 @@ python3 ./test.py -f 2-query/varchar.py -R python3 ./test.py -f 1-insert/update_data.py python3 ./test.py -f 1-insert/delete_data.py +python3 ./test.py -f 1-insert/keep_expired.py python3 ./test.py -f 2-query/join2.py python3 ./test.py -f 2-query/union1.py From 847e351b92353842a2e779bff4fbad461ab96655 Mon Sep 17 00:00:00 2001 From: gccgdb1234 Date: Tue, 25 Oct 2022 10:11:02 +0800 Subject: [PATCH 66/72] doc: correct alter debugFlag syntax error --- docs/en/12-taos-sql/21-node.md | 48 +++++++++++++++++----------------- docs/en/27-train-faq/01-faq.md | 10 +++---- docs/zh/12-taos-sql/21-node.md | 48 +++++++++++++++++----------------- docs/zh/27-train-faq/01-faq.md | 10 +++---- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/docs/en/12-taos-sql/21-node.md b/docs/en/12-taos-sql/21-node.md index d9d06a00a4..a0d49ab208 100644 --- a/docs/en/12-taos-sql/21-node.md +++ b/docs/en/12-taos-sql/21-node.md @@ -40,25 +40,25 @@ ALTER ALL DNODES dnode_option dnode_option: { 'resetLog' - | 'balance' value - | 'monitor' value - | 'debugFlag' value - | 'monDebugFlag' value - | 'vDebugFlag' value - | 'mDebugFlag' value - | 'cDebugFlag' value - | 'httpDebugFlag' value - | 'qDebugflag' value - | 'sdbDebugFlag' value - | 'uDebugFlag' value - | 'tsdbDebugFlag' value - | 'sDebugflag' value - | 'rpcDebugFlag' value - | 'dDebugFlag' value - | 'mqttDebugFlag' value - | 'wDebugFlag' value - | 'tmrDebugFlag' value - | 'cqDebugFlag' value + | 'balance' 'value' + | 'monitor' 'value' + | 'debugFlag' 'value' + | 'monDebugFlag' 'value' + | 'vDebugFlag' 'value' + | 'mDebugFlag' 'value' + | 'cDebugFlag' 'value' + | 'httpDebugFlag' 'value' + | 'qDebugflag' 'value' + | 'sdbDebugFlag' 'value' + | 'uDebugFlag' 'value' + | 'tsdbDebugFlag' 'value' + | 'sDebugflag' 'value' + | 'rpcDebugFlag' 'value' + | 'dDebugFlag' 'value' + | 'mqttDebugFlag' 'value' + | 'wDebugFlag' 'value' + | 'tmrDebugFlag' 'value' + | 'cqDebugFlag' 'value' } ``` @@ -127,11 +127,11 @@ ALTER LOCAL local_option local_option: { 'resetLog' - | 'rpcDebugFlag' value - | 'tmrDebugFlag' value - | 'cDebugFlag' value - | 'uDebugFlag' value - | 'debugFlag' value + | 'rpcDebugFlag' 'value' + | 'tmrDebugFlag' 'value' + | 'cDebugFlag' 'value' + | 'uDebugFlag' 'value' + | 'debugFlag' 'value' } ``` diff --git a/docs/en/27-train-faq/01-faq.md b/docs/en/27-train-faq/01-faq.md index 78794c1ca3..82e98b0d98 100644 --- a/docs/en/27-train-faq/01-faq.md +++ b/docs/en/27-train-faq/01-faq.md @@ -106,11 +106,11 @@ ALTER LOCAL local_option local_option: { 'resetLog' - | 'rpcDebugFlag' value - | 'tmrDebugFlag' value - | 'cDebugFlag' value - | 'uDebugFlag' value - | 'debugFlag' value + | 'rpcDebugFlag' 'value' + | 'tmrDebugFlag' 'value' + | 'cDebugFlag' 'value' + | 'uDebugFlag' 'value' + | 'debugFlag' 'value' } ``` diff --git a/docs/zh/12-taos-sql/21-node.md b/docs/zh/12-taos-sql/21-node.md index 5b9279406a..4116343730 100644 --- a/docs/zh/12-taos-sql/21-node.md +++ b/docs/zh/12-taos-sql/21-node.md @@ -41,25 +41,25 @@ ALTER ALL DNODES dnode_option dnode_option: { 'resetLog' - | 'balance' value - | 'monitor' value - | 'debugFlag' value - | 'monDebugFlag' value - | 'vDebugFlag' value - | 'mDebugFlag' value - | 'cDebugFlag' value - | 'httpDebugFlag' value - | 'qDebugflag' value - | 'sdbDebugFlag' value - | 'uDebugFlag' value - | 'tsdbDebugFlag' value - | 'sDebugflag' value - | 'rpcDebugFlag' value - | 'dDebugFlag' value - | 'mqttDebugFlag' value - | 'wDebugFlag' value - | 'tmrDebugFlag' value - | 'cqDebugFlag' value + | 'balance' 'value' + | 'monitor' 'value' + | 'debugFlag' 'value' + | 'monDebugFlag' 'value' + | 'vDebugFlag' 'value' + | 'mDebugFlag' 'value' + | 'cDebugFlag' 'value' + | 'httpDebugFlag' 'value' + | 'qDebugflag' 'value' + | 'sdbDebugFlag' 'value' + | 'uDebugFlag' 'value' + | 'tsdbDebugFlag' 'value' + | 'sDebugflag' 'value' + | 'rpcDebugFlag' 'value' + | 'dDebugFlag' 'value' + | 'mqttDebugFlag' 'value' + | 'wDebugFlag' 'value' + | 'tmrDebugFlag' 'value' + | 'cqDebugFlag' 'value' } ``` @@ -128,11 +128,11 @@ ALTER LOCAL local_option local_option: { 'resetLog' - | 'rpcDebugFlag' value - | 'tmrDebugFlag' value - | 'cDebugFlag' value - | 'uDebugFlag' value - | 'debugFlag' value + | 'rpcDebugFlag' 'value' + | 'tmrDebugFlag' 'value' + | 'cDebugFlag' 'value' + | 'uDebugFlag' 'value' + | 'debugFlag' 'value' } ``` diff --git a/docs/zh/27-train-faq/01-faq.md b/docs/zh/27-train-faq/01-faq.md index c84cda81a7..9c2f1e790c 100644 --- a/docs/zh/27-train-faq/01-faq.md +++ b/docs/zh/27-train-faq/01-faq.md @@ -135,11 +135,11 @@ ALTER LOCAL local_option local_option: { 'resetLog' - | 'rpcDebugFlag' value - | 'tmrDebugFlag' value - | 'cDebugFlag' value - | 'uDebugFlag' value - | 'debugFlag' value + | 'rpcDebugFlag' 'value' + | 'tmrDebugFlag' 'value' + | 'cDebugFlag' 'value' + | 'uDebugFlag' 'value' + | 'debugFlag' 'value' } ``` From b53a51e5e7371132a47b4799f395fbb42ee7cd64 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 25 Oct 2022 11:11:17 +0800 Subject: [PATCH 67/72] fix coverity --- source/libs/scalar/src/scalar.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 37949d0ff0..7c59c70f30 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -1515,15 +1515,21 @@ static int32_t sclGetMathOperatorResType(SOperatorNode *pOp) { } static int32_t sclGetCompOperatorResType(SOperatorNode *pOp) { - if (pOp == NULL || pOp->pLeft == NULL || pOp->pRight == NULL) { + if (pOp == NULL || pOp->pLeft == NULL) { return TSDB_CODE_TSC_INVALID_OPERATION; } SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType; if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) { + if (pOp->pRight == NULL) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } ((SExprNode *)(pOp->pRight))->resType = ldt; } else if (nodesIsRegularOp(pOp)) { + if (pOp->pRight == NULL) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } SDataType rdt = ((SExprNode *)(pOp->pRight))->resType; if (!IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) || (!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) { From 6d0d42569add2dfa8f289724ca3239e567a65e1d Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Tue, 25 Oct 2022 11:30:57 +0800 Subject: [PATCH 68/72] enh: remove obsolete codes for raw data row --- include/common/ttypes.h | 2 + include/libs/nodes/querynodes.h | 6 -- source/client/src/clientRawBlockWrite.c | 3 - source/client/src/clientSml.c | 1 - source/libs/parser/inc/parInsertUtil.h | 2 +- source/libs/parser/src/parInsertSql.c | 6 +- source/libs/parser/src/parInsertStmt.c | 3 +- source/libs/parser/src/parInsertUtil.c | 89 +++++++------------------ 8 files changed, 29 insertions(+), 83 deletions(-) diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 9ff315fc2e..bfd6a75c3a 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -290,6 +290,7 @@ typedef struct { (IS_SIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP)) #define IS_CONVERT_AS_UNSIGNED(_t) (IS_UNSIGNED_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL)) +#if 0 // TODO remove this function static FORCE_INLINE bool isNull(const void *val, int32_t type) { switch (type) { @@ -325,6 +326,7 @@ static FORCE_INLINE bool isNull(const void *val, int32_t type) { return false; }; } +#endif typedef struct tDataTypeDescriptor { int16_t type; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 5f2ce66f25..837834f795 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -347,11 +347,6 @@ typedef struct SInsertStmt { uint8_t precision; } SInsertStmt; -typedef enum { - PAYLOAD_TYPE_KV = 0, - PAYLOAD_TYPE_RAW = 1, -} EPayloadType; - typedef struct SVgDataBlocks { SVgroupInfo vg; int32_t numOfTables; // number of tables in current submit block @@ -363,7 +358,6 @@ typedef struct SVnodeModifOpStmt { ENodeType nodeType; ENodeType sqlNodeType; SArray* pDataBlocks; // data block for each vgroup, SArray. - uint8_t payloadType; // EPayloadType. 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert uint32_t insertType; // insert data from [file|sql statement| bound statement] const char* sql; // current sql statement position } SVnodeModifOpStmt; diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index dfcd8c4a79..f05d37765d 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -1369,7 +1369,6 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname) goto end; } SVnodeModifOpStmt* nodeStmt = (SVnodeModifOpStmt*)(pQuery->pRoot); - nodeStmt->payloadType = PAYLOAD_TYPE_KV; nodeStmt->pDataBlocks = taosArrayInit(1, POINTER_BYTES); SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); @@ -1625,7 +1624,6 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { goto end; } SVnodeModifOpStmt* nodeStmt = (SVnodeModifOpStmt*)(pQuery->pRoot); - nodeStmt->payloadType = PAYLOAD_TYPE_KV; int32_t numOfVg = taosHashGetSize(pVgHash); nodeStmt->pDataBlocks = taosArrayInit(numOfVg, POINTER_BYTES); @@ -1929,7 +1927,6 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) goto end; } SVnodeModifOpStmt* nodeStmt = (SVnodeModifOpStmt*)(pQuery->pRoot); - nodeStmt->payloadType = PAYLOAD_TYPE_KV; int32_t numOfVg = taosHashGetSize(pVgHash); nodeStmt->pDataBlocks = taosArrayInit(numOfVg, POINTER_BYTES); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 5b8266b1cb..5da7bebf2a 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -1531,7 +1531,6 @@ static SSmlHandle *smlBuildSmlInfo(STscObj *pTscObj, SRequestObj *request, SMLPr uError("SML:0x%" PRIx64 " create info->pQuery->pRoot error", info->id); goto cleanup; } - ((SVnodeModifOpStmt *)(info->pQuery->pRoot))->payloadType = PAYLOAD_TYPE_KV; if (pTscObj) { info->taos = pTscObj; diff --git a/source/libs/parser/inc/parInsertUtil.h b/source/libs/parser/inc/parInsertUtil.h index 78e87d847c..1e941632e7 100644 --- a/source/libs/parser/inc/parInsertUtil.h +++ b/source/libs/parser/inc/parInsertUtil.h @@ -152,7 +152,7 @@ int32_t insInitRowBuilder(SRowBuilder *pBuilder, int16_t schemaVer, SParsedDataC int32_t insGetDataBlockFromList(SHashObj *pHashList, void *id, int32_t idLen, int32_t size, int32_t startOffset, int32_t rowSize, STableMeta *pTableMeta, STableDataBlocks **dataBlocks, SArray *pBlockList, SVCreateTbReq *pCreateTbReq); -int32_t insMergeTableDataBlocks(SHashObj *pHashObj, uint8_t payloadType, SArray **pVgDataBlocks); +int32_t insMergeTableDataBlocks(SHashObj *pHashObj, SArray **pVgDataBlocks); int32_t insBuildCreateTbMsg(STableDataBlocks *pBlocks, SVCreateTbReq *pCreateTbReq); int32_t insAllocateMemForSize(STableDataBlocks *pDataBlock, int32_t allSize); int32_t insCreateSName(SName *pName, struct SToken *pTableName, int32_t acctId, const char *dbName, SMsgBuf *pMsgBuf); diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 84c9664fa9..1ccb34cd1f 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -1369,7 +1369,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { // merge according to vgId if (taosHashGetSize(pCxt->pTableBlockHashObj) > 0) { - CHECK_CODE(insMergeTableDataBlocks(pCxt->pTableBlockHashObj, pCxt->pOutput->payloadType, &pCxt->pVgDataBlocks)); + CHECK_CODE(insMergeTableDataBlocks(pCxt->pTableBlockHashObj, &pCxt->pVgDataBlocks)); } return insBuildOutput(pCxt); } @@ -1390,7 +1390,7 @@ static int32_t parseInsertBodyAgain(SInsertParseContext* pCxt) { parserDebug("0x%" PRIx64 " insert again input rows: %d", pCxt->pComCxt->requestId, pCxt->totalNum); // merge according to vgId if (taosHashGetSize(pCxt->pTableBlockHashObj) > 0) { - CHECK_CODE(insMergeTableDataBlocks(pCxt->pTableBlockHashObj, pCxt->pOutput->payloadType, &pCxt->pVgDataBlocks)); + CHECK_CODE(insMergeTableDataBlocks(pCxt->pTableBlockHashObj, &pCxt->pVgDataBlocks)); } return insBuildOutput(pCxt); } @@ -1472,8 +1472,6 @@ int32_t parseInsertSql(SParseContext* pContext, SQuery** pQuery, SParseMetaCache } } - context.pOutput->payloadType = PAYLOAD_TYPE_KV; - int32_t code = TSDB_CODE_SUCCESS; if (!context.pComCxt->needMultiParse) { code = skipInsertInto(&context.pSql, &context.msg); diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index fda3e0866d..f85ceccf6e 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -40,8 +40,7 @@ int32_t qBuildStmtOutput(SQuery* pQuery, SHashObj* pVgHash, SHashObj* pBlockHash // merge according to vgId if (taosHashGetSize(insertCtx.pTableBlockHashObj) > 0) { - CHECK_CODE( - insMergeTableDataBlocks(insertCtx.pTableBlockHashObj, modifyNode->payloadType, &insertCtx.pVgDataBlocks)); + CHECK_CODE(insMergeTableDataBlocks(insertCtx.pTableBlockHashObj, &insertCtx.pVgDataBlocks)); } CHECK_CODE(insBuildOutput(&insertCtx)); diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index e921cfe997..570a6f9859 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -21,9 +21,6 @@ #include "querynodes.h" #include "tRealloc.h" -#define IS_RAW_PAYLOAD(t) \ - (((int)(t)) == PAYLOAD_TYPE_RAW) // 0: K-V payload for non-prepare insert, 1: rawPayload for prepare insert - typedef struct SBlockKeyTuple { TSKEY skey; void* payloadAddr; @@ -315,7 +312,7 @@ int32_t insGetDataBlockFromList(SHashObj* pHashList, void* id, int32_t idLen, in return TSDB_CODE_SUCCESS; } - +#if 0 static int32_t getRowExpandSize(STableMeta* pTableMeta) { int32_t result = TD_ROW_HEAD_LEN - sizeof(TSKEY); int32_t columns = getNumOfColumns(pTableMeta); @@ -328,6 +325,7 @@ static int32_t getRowExpandSize(STableMeta* pTableMeta) { result += (int32_t)TD_BITMAP_BYTES(columns - 1); return result; } +#endif void insDestroyBlockArrayList(SArray* pDataBlockList) { if (pDataBlockList == NULL) { @@ -359,6 +357,7 @@ void insDestroyBlockHashmap(SHashObj* pDataBlockHash) { taosHashCleanup(pDataBlockHash); } +#if 0 // data block is disordered, sort it in ascending order void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) { SSubmitBlk* pBlocks = (SSubmitBlk*)dataBuf->pData; @@ -401,6 +400,7 @@ void sortRemoveDataBlockDupRowsRaw(STableDataBlocks* dataBuf) { dataBuf->prevTS = INT64_MIN; } +#endif // data block is disordered, sort it in ascending order static int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* pBlkKeyInfo) { @@ -667,68 +667,31 @@ static int sortMergeDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* p } // Erase the empty space reserved for binary data -static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, SBlockKeyTuple* blkKeyTuple, - bool isRawPayload) { +static int trimDataBlock(void* pDataBlock, STableDataBlocks* pTableDataBlock, SBlockKeyTuple* blkKeyTuple) { // TODO: optimize this function, handle the case while binary is not presented - STableMeta* pTableMeta = pTableDataBlock->pTableMeta; - STableComInfo tinfo = getTableInfo(pTableMeta); - SSchema* pSchema = getTableColumnSchema(pTableMeta); - int32_t nonDataLen = sizeof(SSubmitBlk) + pTableDataBlock->createTbReqLen; SSubmitBlk* pBlock = pDataBlock; memcpy(pDataBlock, pTableDataBlock->pData, nonDataLen); pDataBlock = (char*)pDataBlock + nonDataLen; - int32_t flen = 0; // original total length of row - if (isRawPayload) { - for (int32_t j = 0; j < tinfo.numOfColumns; ++j) { - flen += TYPE_BYTES[pSchema[j].type]; - } - } pBlock->schemaLen = pTableDataBlock->createTbReqLen; - - char* p = pTableDataBlock->pData + nonDataLen; pBlock->dataLen = 0; + int32_t numOfRows = pBlock->numOfRows; - - if (isRawPayload) { - SRowBuilder builder = {0}; - - tdSRowInit(&builder, pTableMeta->sversion); - tdSRowSetInfo(&builder, getNumOfColumns(pTableMeta), -1, flen); - - for (int32_t i = 0; i < numOfRows; ++i) { - tdSRowResetBuf(&builder, pDataBlock); - int toffset = 0; - for (int32_t j = 0; j < tinfo.numOfColumns; ++j) { - int8_t colType = pSchema[j].type; - uint8_t valType = isNull(p, colType) ? TD_VTYPE_NULL : TD_VTYPE_NORM; - tdAppendColValToRow(&builder, pSchema[j].colId, colType, valType, p, true, toffset, j); - toffset += TYPE_BYTES[colType]; - p += pSchema[j].bytes; - } - tdSRowEnd(&builder); - int32_t rowLen = TD_ROW_LEN((STSRow*)pDataBlock); - pDataBlock = (char*)pDataBlock + rowLen; - pBlock->dataLen += rowLen; - } - } else { - for (int32_t i = 0; i < numOfRows; ++i) { - void* payload = (blkKeyTuple + i)->payloadAddr; - TDRowLenT rowTLen = TD_ROW_LEN((STSRow*)payload); - memcpy(pDataBlock, payload, rowTLen); - pDataBlock = POINTER_SHIFT(pDataBlock, rowTLen); - pBlock->dataLen += rowTLen; - } + for (int32_t i = 0; i < numOfRows; ++i) { + void* payload = (blkKeyTuple + i)->payloadAddr; + TDRowLenT rowTLen = TD_ROW_LEN((STSRow*)payload); + memcpy(pDataBlock, payload, rowTLen); + pDataBlock = POINTER_SHIFT(pDataBlock, rowTLen); + pBlock->dataLen += rowTLen; } return pBlock->dataLen + pBlock->schemaLen; } -int32_t insMergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray** pVgDataBlocks) { +int32_t insMergeTableDataBlocks(SHashObj* pHashObj, SArray** pVgDataBlocks) { const int INSERT_HEAD_SIZE = sizeof(SSubmitReq); int code = 0; - bool isRawPayload = IS_RAW_PAYLOAD(payloadType); SHashObj* pVnodeDataBlockHashList = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, false); SArray* pVnodeDataBlockList = taosArrayInit(8, POINTER_BYTES); @@ -754,8 +717,7 @@ int32_t insMergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray* } ASSERT(pOneTableBlock->pTableMeta->tableInfo.rowSize > 0); // the maximum expanded size in byte when a row-wise data is converted to SDataRow format - int32_t expandSize = isRawPayload ? getRowExpandSize(pOneTableBlock->pTableMeta) : 0; - int64_t destSize = dataBuf->size + pOneTableBlock->size + pBlocks->numOfRows * expandSize + + int64_t destSize = dataBuf->size + pOneTableBlock->size + sizeof(STColumn) * getNumOfColumns(pOneTableBlock->pTableMeta) + pOneTableBlock->createTbReqLen; @@ -774,23 +736,18 @@ int32_t insMergeTableDataBlocks(SHashObj* pHashObj, uint8_t payloadType, SArray* } } - if (isRawPayload) { - sortRemoveDataBlockDupRowsRaw(pOneTableBlock); - } else { - if ((code = sortMergeDataBlockDupRows(pOneTableBlock, &blkKeyInfo, &pBlkRowMerger)) != 0) { - tdFreeSBlockRowMerger(pBlkRowMerger); - taosHashCleanup(pVnodeDataBlockHashList); - insDestroyBlockArrayList(pVnodeDataBlockList); - taosMemoryFreeClear(dataBuf->pData); - taosMemoryFreeClear(blkKeyInfo.pKeyTuple); - return code; - } - ASSERT(blkKeyInfo.pKeyTuple != NULL && pBlocks->numOfRows > 0); + if ((code = sortMergeDataBlockDupRows(pOneTableBlock, &blkKeyInfo, &pBlkRowMerger)) != 0) { + tdFreeSBlockRowMerger(pBlkRowMerger); + taosHashCleanup(pVnodeDataBlockHashList); + insDestroyBlockArrayList(pVnodeDataBlockList); + taosMemoryFreeClear(dataBuf->pData); + taosMemoryFreeClear(blkKeyInfo.pKeyTuple); + return code; } + ASSERT(blkKeyInfo.pKeyTuple != NULL && pBlocks->numOfRows > 0); // erase the empty space reserved for binary data - int32_t finalLen = - trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, blkKeyInfo.pKeyTuple, isRawPayload); + int32_t finalLen = trimDataBlock(dataBuf->pData + dataBuf->size, pOneTableBlock, blkKeyInfo.pKeyTuple); dataBuf->size += (finalLen + sizeof(SSubmitBlk)); assert(dataBuf->size <= dataBuf->nAllocSize); From df7cb2e85a4e77353ca3d598969c1dd226ff195d Mon Sep 17 00:00:00 2001 From: Xuefeng Tan <1172915550@qq.com> Date: Tue, 25 Oct 2022 11:45:16 +0800 Subject: [PATCH 69/72] doc : taosadapter support user specify timezone and return corresponding time (#17400) --- docs/en/14-reference/02-rest-api/02-rest-api.mdx | 7 ++++--- docs/zh/08-connector/02-rest-api.mdx | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/en/14-reference/02-rest-api/02-rest-api.mdx b/docs/en/14-reference/02-rest-api/02-rest-api.mdx index da26b34c6f..09e40b956f 100644 --- a/docs/en/14-reference/02-rest-api/02-rest-api.mdx +++ b/docs/en/14-reference/02-rest-api/02-rest-api.mdx @@ -67,7 +67,7 @@ The following return value results indicate that the verification passed. ## HTTP request URL format ```text -http://:/rest/sql/[db_name] +http://:/rest/sql/[db_name][?tz=timezone] ``` Parameter Description: @@ -75,6 +75,7 @@ Parameter Description: - fqnd: FQDN or IP address of any host in the cluster. - port: httpPort configuration item in the configuration file, default is 6041. - db_name: Optional parameter that specifies the default database name for the executed SQL command. +- tz: Optional parameter that specifies the timezone of the returned time, following the IANA Time Zone rules, e.g. `America/New_York`. For example, `http://h1.taos.com:6041/rest/sql/test` is a URL to `h1.taos.com:6041` and sets the default database name to `test`. @@ -97,13 +98,13 @@ The HTTP request's BODY is a complete SQL command, and the data table in the SQL Use `curl` to initiate an HTTP request with a custom authentication method, with the following syntax. ```bash -curl -L -H "Authorization: Basic " -d "" :/rest/sql/[db_name] +curl -L -H "Authorization: Basic " -d "" :/rest/sql/[db_name][?tz=timezone] ``` or ```bash -curl -L -u username:password -d "" :/rest/sql/[db_name] +curl -L -u username:password -d "" :/rest/sql/[db_name][?tz=timezone] ``` where `TOKEN` is the string after Base64 encoding of `{username}:{password}`, e.g. `root:taosdata` is encoded as `cm9vdDp0YW9zZGF0YQ==`.. diff --git a/docs/zh/08-connector/02-rest-api.mdx b/docs/zh/08-connector/02-rest-api.mdx index 68d73ff32f..af2ec1b1c2 100644 --- a/docs/zh/08-connector/02-rest-api.mdx +++ b/docs/zh/08-connector/02-rest-api.mdx @@ -69,7 +69,7 @@ curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" \ ## HTTP 请求格式 ```text -http://:/rest/sql/[db_name] +http://:/rest/sql/[db_name][?tz=timezone] ``` 参数说明: @@ -77,6 +77,7 @@ http://:/rest/sql/[db_name] - fqdn: 集群中的任一台主机 FQDN 或 IP 地址。 - port: 配置文件中 httpPort 配置项,缺省为 6041。 - db_name: 可选参数,指定本次所执行的 SQL 语句的默认数据库库名。 +- tz: 可选参数,指定返回时间的时区,遵照 IANA Time Zone 规则,如 `America/New_York`。 例如:`http://h1.taos.com:6041/rest/sql/test` 是指向地址为 `h1.taos.com:6041` 的 URL,并将默认使用的数据库库名设置为 `test`。 @@ -99,13 +100,13 @@ HTTP 请求的 BODY 里就是一个完整的 SQL 语句,SQL 语句中的数据 使用 `curl` 通过自定义身份认证方式来发起一个 HTTP Request,语法如下: ```bash -curl -L -H "Authorization: Basic " -d "" :/rest/sql/[db_name] +curl -L -H "Authorization: Basic " -d "" :/rest/sql/[db_name][?tz=timezone] ``` 或者, ```bash -curl -L -u username:password -d "" :/rest/sql/[db_name] +curl -L -u username:password -d "" :/rest/sql/[db_name][?tz=timezone] ``` 其中,`TOKEN` 为 `{username}:{password}` 经过 Base64 编码之后的字符串,例如 `root:taosdata` 编码后为 `cm9vdDp0YW9zZGF0YQ==`。 From d03058aff84f071c86a0aea751b478b7223bbd84 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 25 Oct 2022 11:11:17 +0800 Subject: [PATCH 70/72] fix coverity --- source/libs/function/src/builtinsimpl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 88d820bc93..a093fe5116 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -5369,9 +5369,12 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { } } - ASSERT(resIndex >= 0); - SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes)); - colDataAppend(pCol, currentRow, pResItem->data, (maxCount == 0) ? true : false); + if (maxCount != 0) { + SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes)); + colDataAppend(pCol, currentRow, pResItem->data, false); + } else { + colDataAppendNULL(pCol, currentRow); + } return pResInfo->numOfRes; } From 600bb6ee77f3ca6dfd142f3f1b87ae41c26f438d Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Tue, 25 Oct 2022 11:11:17 +0800 Subject: [PATCH 71/72] fix coverity --- source/common/src/tmsg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 6784b05e84..47a260c147 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -5988,7 +5988,6 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { if (pSW == NULL) return -1; if (tDecodeSSchemaWrapper(pDecoder, pSW) < 0) return -1; taosArrayPush(pRsp->blockSchema, &pSW); - taosMemoryFree(pSW); } if (pRsp->withTbName) { From 0a0833920fe9b79c7856e9b2e4e6a64fe0840764 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 25 Oct 2022 15:33:20 +0800 Subject: [PATCH 72/72] chore: fix taos tools mac install script for3.0 (#17619) * chore(release): make get_os.sh works on mac * chore(tools): update taos-tools * chore: update taos-tools for 3.0 --- cmake/taostools_CMakeLists.txt.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index c19928c7a9..7a03fc9b76 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG cc973e0 + GIT_TAG bc99376 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE