Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f0b50add
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f0b50add
编写于
6月 25, 2022
作者:
wmmhello
提交者:
GitHub
6月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14184 from taosdata/feature/TD-13041
feat:sort table group if needed & optimize partition by tag
上级
31e53a2d
f3c29576
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
357 addition
and
291 deletion
+357
-291
include/common/tcommon.h
include/common/tcommon.h
+2
-0
include/libs/executor/executor.h
include/libs/executor/executor.h
+1
-1
source/common/src/tglobal.c
source/common/src/tglobal.c
+4
-0
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+1
-1
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+2
-2
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+1
-1
source/dnode/vnode/src/meta/metaTable.c
source/dnode/vnode/src/meta/metaTable.c
+4
-2
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+20
-21
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+8
-4
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+8
-2
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+142
-101
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+111
-112
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+1
-0
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+2
-1
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+48
-41
未找到文件。
include/common/tcommon.h
浏览文件 @
f0b50add
...
...
@@ -50,8 +50,10 @@ typedef enum EStreamType {
}
EStreamType
;
typedef
struct
{
SArray
*
pGroupList
;
SArray
*
pTableList
;
SHashObj
*
map
;
// speedup acquire the tableQueryInfo by table uid
bool
needSortTableByGroupId
;
void
*
pTagCond
;
void
*
pTagIndexCond
;
uint64_t
suid
;
...
...
include/libs/executor/executor.h
浏览文件 @
f0b50add
...
...
@@ -36,7 +36,7 @@ typedef struct SReadHandle {
void
*
vnode
;
void
*
mnd
;
SMsgCb
*
pMsgCb
;
int8_t
initTsdbReader
;
//
int8_t initTsdbReader;
}
SReadHandle
;
enum
{
...
...
source/common/src/tglobal.c
浏览文件 @
f0b50add
...
...
@@ -963,6 +963,10 @@ int32_t taosSetCfg(SConfig *pCfg, char* name) {
tsTelemPort
=
(
uint16_t
)
cfgGetItem
(
pCfg
,
"telemetryPort"
)
->
i32
;
}
else
if
(
strcasecmp
(
"transPullupInterval"
,
name
)
==
0
)
{
tsTransPullupInterval
=
cfgGetItem
(
pCfg
,
"transPullupInterval"
)
->
i32
;
}
else
if
(
strcasecmp
(
"ttlUnit"
,
name
)
==
0
)
{
tsTtlUnit
=
cfgGetItem
(
pCfg
,
"ttlUnit"
)
->
i32
;
}
else
if
(
strcasecmp
(
"ttlPushInterval"
,
name
)
==
0
)
{
tsTtlPushInterval
=
cfgGetItem
(
pCfg
,
"ttlPushInterval"
)
->
i32
;
}
else
if
(
strcasecmp
(
"tmrDebugFlag"
,
name
)
==
0
)
{
tmrDebugFlag
=
cfgGetItem
(
pCfg
,
"tmrDebugFlag"
)
->
i32
;
}
else
if
(
strcasecmp
(
"tsdbDebugFlag"
,
name
)
==
0
)
{
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
f0b50add
...
...
@@ -100,7 +100,7 @@ static void *mndThreadFp(void *param) {
taosMsleep
(
100
);
if
(
mndGetStop
(
pMnode
))
break
;
if
(
lastTime
%
(
tsT
ransPullup
Interval
*
10
)
==
1
)
{
if
(
lastTime
%
(
tsT
tlPush
Interval
*
10
)
==
1
)
{
mndTtlTimer
(
pMnode
);
}
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
f0b50add
...
...
@@ -116,7 +116,8 @@ typedef void *tsdbReaderT;
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
#define BLOCK_LOAD_TABLE_RR_ORDER 3
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableInfoGroup
,
uint64_t
qId
,
int32_t
tsdbSetTableList
(
tsdbReaderT
reader
,
SArray
*
tableList
);
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
SArray
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLast
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
...
...
@@ -195,7 +196,6 @@ struct SVnodeCfg {
typedef
struct
{
TSKEY
lastKey
;
uint64_t
uid
;
uint64_t
groupId
;
}
STableKeyInfo
;
struct
SMetaEntry
{
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
f0b50add
...
...
@@ -121,7 +121,7 @@ int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSub
int32_t
tsdbInsertTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitMsgIter
*
pMsgIter
,
SSubmitBlk
*
pBlock
,
SSubmitBlkRsp
*
pRsp
);
int32_t
tsdbDeleteTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
tb_uid_t
suid
,
tb_uid_t
uid
,
TSKEY
sKey
,
TSKEY
eKey
);
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
S
TableListInfo
*
tableList
,
uint64_t
qId
,
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
S
Array
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLastT
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
void
*
pMemRef
);
...
...
source/dnode/vnode/src/meta/metaTable.c
浏览文件 @
f0b50add
...
...
@@ -381,6 +381,7 @@ int metaTtlDropTable(SMeta *pMeta, int64_t ttl, SArray *tbUids) {
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
tbUids
);
++
i
)
{
tb_uid_t
*
uid
=
(
tb_uid_t
*
)
taosArrayGet
(
tbUids
,
i
);
metaDropTableByUid
(
pMeta
,
*
uid
,
NULL
);
metaDebug
(
"ttl drop table:%"
PRId64
,
*
uid
);
}
metaULock
(
pMeta
);
return
0
;
...
...
@@ -443,7 +444,6 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
// drop schema.db (todo)
}
metaError
(
"ttl drop table:%s"
,
e
.
name
);
tDecoderClear
(
&
dc
);
tdbFree
(
pData
);
...
...
@@ -976,7 +976,9 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) {
SDecoder
dc
=
{
0
};
// get super table
tdbTbGet
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
);
if
(
tdbTbGet
(
pMeta
->
pUidIdx
,
&
pCtbEntry
->
ctbEntry
.
suid
,
sizeof
(
tb_uid_t
),
&
pData
,
&
nData
)
!=
0
){
return
-
1
;
}
tbDbKey
.
uid
=
pCtbEntry
->
ctbEntry
.
suid
;
tbDbKey
.
version
=
*
(
int64_t
*
)
pData
;
tdbTbGet
(
pMeta
->
pTbDb
,
&
tbDbKey
,
sizeof
(
tbDbKey
),
&
pData
,
&
nData
);
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
f0b50add
...
...
@@ -403,7 +403,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
.
reader
=
pHandle
->
execHandle
.
pExecReader
[
i
],
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
vnode
=
pTq
->
pVnode
,
.
initTsdbReader
=
1
,
//
.initTsdbReader = 1,
};
pHandle
->
execHandle
.
execCol
.
task
[
i
]
=
qCreateStreamExecTaskInfo
(
pHandle
->
execHandle
.
execCol
.
qmsg
,
&
handle
);
ASSERT
(
pHandle
->
execHandle
.
execCol
.
task
[
i
]);
...
...
@@ -479,7 +479,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) {
.
reader
=
pStreamReader
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
vnode
=
pTq
->
pVnode
,
.
initTsdbReader
=
1
,
//
.initTsdbReader = 1,
};
/*pTask->exec.inputHandle = pStreamReader;*/
pTask
->
exec
.
executor
=
qCreateStreamExecTaskInfo
(
pTask
->
exec
.
qmsg
,
&
handle
);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
f0b50add
...
...
@@ -223,9 +223,8 @@ int64_t tsdbGetNumOfRowsInMemTable(tsdbReaderT* pHandle) {
return
rows
;
}
static
SArray
*
createCheckInfoFromTableGroup
(
STsdbReadHandle
*
pTsdbReadHandle
,
STableListInfo
*
pTableList
)
{
size_t
tableSize
=
taosArrayGetSize
(
pTableList
->
pTableList
);
assert
(
tableSize
>=
1
);
static
SArray
*
createCheckInfoFromTableGroup
(
STsdbReadHandle
*
pTsdbReadHandle
,
SArray
*
pTableList
)
{
size_t
tableSize
=
taosArrayGetSize
(
pTableList
);
// allocate buffer in order to load data blocks from file
SArray
*
pTableCheckInfo
=
taosArrayInit
(
tableSize
,
sizeof
(
STableCheckInfo
));
...
...
@@ -235,7 +234,7 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S
// todo apply the lastkey of table check to avoid to load header file
for
(
int32_t
j
=
0
;
j
<
tableSize
;
++
j
)
{
STableKeyInfo
*
pKeyInfo
=
(
STableKeyInfo
*
)
taosArrayGet
(
pTableList
->
pTableList
,
j
);
STableKeyInfo
*
pKeyInfo
=
(
STableKeyInfo
*
)
taosArrayGet
(
pTableList
,
j
);
STableCheckInfo
info
=
{.
lastKey
=
pKeyInfo
->
lastKey
,
.
tableId
=
pKeyInfo
->
uid
};
info
.
suid
=
pTsdbReadHandle
->
suid
;
...
...
@@ -254,8 +253,6 @@ static SArray* createCheckInfoFromTableGroup(STsdbReadHandle* pTsdbReadHandle, S
pTsdbReadHandle
->
idStr
);
}
// TODO group table according to the tag value.
taosArraySort
(
pTableCheckInfo
,
tsdbCheckInfoCompar
);
return
pTableCheckInfo
;
}
...
...
@@ -497,8 +494,21 @@ static int32_t setCurrentSchema(SVnode* pVnode, STsdbReadHandle* pTsdbReadHandle
return
TSDB_CODE_SUCCESS
;
}
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
int32_t
tsdbSetTableList
(
tsdbReaderT
reader
,
SArray
*
tableList
){
STsdbReadHandle
*
pTsdbReadHandle
=
reader
;
if
(
pTsdbReadHandle
->
pTableCheckInfo
)
taosArrayDestroy
(
pTsdbReadHandle
->
pTableCheckInfo
);
pTsdbReadHandle
->
pTableCheckInfo
=
createCheckInfoFromTableGroup
(
pTsdbReadHandle
,
tableList
);
if
(
pTsdbReadHandle
->
pTableCheckInfo
==
NULL
)
{
return
TSDB_CODE_TDB_OUT_OF_MEMORY
;
}
return
TDB_CODE_SUCCESS
;
}
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
SArray
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
)
{
if
(
taosArrayGetSize
(
tableList
)
==
0
){
return
NULL
;
}
STsdbReadHandle
*
pTsdbReadHandle
=
tsdbQueryTablesImpl
(
pVnode
,
pCond
,
qId
,
taskId
);
if
(
pTsdbReadHandle
==
NULL
)
{
return
NULL
;
...
...
@@ -543,7 +553,7 @@ tsdbReaderT tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableLis
}
tsdbDebug
(
"%p total numOfTable:%"
PRIzu
" in this query, table %"
PRIzu
" %s"
,
pTsdbReadHandle
,
taosArrayGetSize
(
pTsdbReadHandle
->
pTableCheckInfo
),
taosArrayGetSize
(
tableList
->
pTableList
),
taosArrayGetSize
(
pTsdbReadHandle
->
pTableCheckInfo
),
taosArrayGetSize
(
tableList
),
pTsdbReadHandle
->
idStr
);
return
(
tsdbReaderT
)
pTsdbReadHandle
;
...
...
@@ -639,7 +649,7 @@ tsdbReaderT tsdbQueryLastRow(SVnode* pVnode, SQueryTableDataCond* pCond, STableL
return
NULL
;
}
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
tsdbReaderOpen
(
pVnode
,
pCond
,
pList
,
qId
,
taskId
);
STsdbReadHandle
*
pTsdbReadHandle
=
(
STsdbReadHandle
*
)
tsdbReaderOpen
(
pVnode
,
pCond
,
pList
->
pTableList
,
qId
,
taskId
);
if
(
pTsdbReadHandle
==
NULL
)
{
return
NULL
;
}
...
...
@@ -2842,7 +2852,7 @@ int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) {
break
;
}
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
uid
=
id
,
.
groupId
=
0
};
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
uid
=
id
};
taosArrayPush
(
list
,
&
info
);
}
...
...
@@ -3644,17 +3654,6 @@ SArray* tsdbRetrieveDataBlock(tsdbReaderT* pTsdbReadHandle, SArray* pIdList) {
}
}
static
int
tsdbCheckInfoCompar
(
const
void
*
key1
,
const
void
*
key2
)
{
if
(((
STableCheckInfo
*
)
key1
)
->
tableId
<
((
STableCheckInfo
*
)
key2
)
->
tableId
)
{
return
-
1
;
}
else
if
(((
STableCheckInfo
*
)
key1
)
->
tableId
>
((
STableCheckInfo
*
)
key2
)
->
tableId
)
{
return
1
;
}
else
{
ASSERT
(
false
);
return
0
;
}
}
static
void
*
doFreeColumnInfoData
(
SArray
*
pColumnInfoData
)
{
if
(
pColumnInfoData
==
NULL
)
{
return
NULL
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
f0b50add
...
...
@@ -273,6 +273,10 @@ typedef struct STableScanInfo {
SSampleExecInfo
sample
;
// sample execution info
int32_t
curTWinIdx
;
int32_t
currentGroupId
;
uint64_t
queryId
;
uint64_t
taskId
;
}
STableScanInfo
;
typedef
struct
STagScanInfo
{
...
...
@@ -706,7 +710,7 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
SOperatorInfo
*
createExchangeOperatorInfo
(
void
*
pTransporter
,
SExchangePhysiNode
*
pExNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
tsdbReaderT
pDataReader
,
SReadHandle
*
pHandle
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
SExecTaskInfo
*
pTaskInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
SOperatorInfo
*
createTagScanOperatorInfo
(
SReadHandle
*
pReadHandle
,
STagScanPhysiNode
*
pPhyNode
,
STableListInfo
*
pTableListInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
readHandle
,
SSystemTableScanPhysiNode
*
pScanPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
...
...
@@ -749,8 +753,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
SOperatorInfo
*
createDataBlockInfoScanOperator
(
void
*
dataReader
,
SReadHandle
*
readHandle
,
uint64_t
uid
,
SBlockDistScanPhysiNode
*
pBlockScanNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
pDataReader
,
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
);
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
,
uint64_t
queryId
,
uint64_t
taskId
);
SOperatorInfo
*
createFillOperatorInfo
(
SOperatorInfo
*
downstream
,
SFillPhysiNode
*
pPhyFillNode
,
bool
multigroupResult
,
SExecTaskInfo
*
pTaskInfo
);
...
...
@@ -845,7 +849,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
void
copyUpdateDataBlock
(
SSDataBlock
*
pDest
,
SSDataBlock
*
pSource
,
int32_t
tsColIndex
);
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
S
Array
*
groupKey
);
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
S
NodeList
*
groupKey
);
#ifdef __cplusplus
}
...
...
source/libs/executor/src/executil.c
浏览文件 @
f0b50add
...
...
@@ -287,6 +287,7 @@ static bool isTableOk(STableKeyInfo* info, SNode *pTagCond, SMeta *metaHandle){
int32_t
getTableList
(
void
*
metaHandle
,
SScanPhysiNode
*
pScanNode
,
STableListInfo
*
pListInfo
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
pListInfo
->
pTableList
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
if
(
pListInfo
->
pTableList
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
uint64_t
tableUid
=
pScanNode
->
uid
;
...
...
@@ -314,7 +315,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
res
);
i
++
)
{
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
.
uid
=
*
(
uint64_t
*
)
taosArrayGet
(
res
,
i
)
,
.
groupId
=
0
};
STableKeyInfo
info
=
{.
lastKey
=
TSKEY_INITIAL_VAL
,
.
uid
=
*
(
uint64_t
*
)
taosArrayGet
(
res
,
i
)};
taosArrayPush
(
pListInfo
->
pTableList
,
&
info
);
}
taosArrayDestroy
(
res
);
...
...
@@ -335,9 +336,14 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
}
}
}
else
{
// Create one table group.
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
tableUid
,
.
groupId
=
0
};
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
tableUid
};
taosArrayPush
(
pListInfo
->
pTableList
,
&
info
);
}
pListInfo
->
pGroupList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
pListInfo
->
pGroupList
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
//put into list as default group, remove it if grouping sorting is required later
taosArrayPush
(
pListInfo
->
pGroupList
,
&
pListInfo
->
pTableList
);
return
code
;
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
f0b50add
...
...
@@ -3862,9 +3862,6 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
return
pTaskInfo
;
}
static
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
int32_t
extractTableSchemaVersion
(
SReadHandle
*
pHandle
,
uint64_t
uid
,
SExecTaskInfo
*
pTaskInfo
)
{
...
...
@@ -3895,8 +3892,67 @@ int32_t extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskI
return
TSDB_CODE_SUCCESS
;
}
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SArray
*
groupKey
)
{
if
(
groupKey
==
NULL
)
{
static
int32_t
sortTableGroup
(
STableListInfo
*
pTableListInfo
,
int32_t
groupNum
){
taosArrayClear
(
pTableListInfo
->
pGroupList
);
SArray
*
sortSupport
=
taosArrayInit
(
groupNum
,
sizeof
(
uint64_t
));
if
(
sortSupport
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
i
++
)
{
STableKeyInfo
*
info
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
uint64_t
*
groupId
=
taosHashGet
(
pTableListInfo
->
map
,
&
info
->
uid
,
sizeof
(
uint64_t
));
int32_t
index
=
taosArraySearchIdx
(
sortSupport
,
groupId
,
compareUint64Val
,
TD_EQ
);
if
(
index
==
-
1
){
void
*
p
=
taosArraySearch
(
sortSupport
,
groupId
,
compareUint64Val
,
TD_GT
);
SArray
*
tGroup
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
if
(
tGroup
==
NULL
)
{
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
taosArrayPush
(
tGroup
,
info
)
==
NULL
){
qError
(
"taos push info array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
p
==
NULL
){
if
(
taosArrayPush
(
sortSupport
,
groupId
)
!=
NULL
){
qError
(
"taos push support array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
taosArrayPush
(
pTableListInfo
->
pGroupList
,
&
tGroup
)
!=
NULL
){
qError
(
"taos push group array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
else
{
int32_t
pos
=
TARRAY_ELEM_IDX
(
sortSupport
,
p
);
if
(
taosArrayInsert
(
sortSupport
,
pos
,
groupId
)
==
NULL
){
qError
(
"taos insert support array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
taosArrayInsert
(
pTableListInfo
->
pGroupList
,
pos
,
&
tGroup
)
==
NULL
){
qError
(
"taos insert group array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
}
else
{
SArray
*
tGroup
=
(
SArray
*
)
taosArrayGetP
(
pTableListInfo
->
pGroupList
,
index
);
if
(
taosArrayPush
(
tGroup
,
info
)
==
NULL
){
qError
(
"taos push uid array error"
);
taosArrayDestroy
(
sortSupport
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
}
taosArrayDestroy
(
sortSupport
);
return
TDB_CODE_SUCCESS
;
}
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SNodeList
*
group
)
{
if
(
group
==
NULL
)
{
return
TDB_CODE_SUCCESS
;
}
...
...
@@ -3906,13 +3962,14 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
}
int32_t
keyLen
=
0
;
void
*
keyBuf
=
NULL
;
int32_t
numOfGroupCols
=
taosArrayGetSize
(
groupKey
);
for
(
int32_t
j
=
0
;
j
<
numOfGroupCols
;
++
j
)
{
SColumn
*
pCol
=
taosArrayGet
(
groupKey
,
j
);
keyLen
+=
pCol
->
bytes
;
// actual data + null_flag
SNode
*
node
;
FOREACH
(
node
,
group
)
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
node
;
keyLen
+=
pExpr
->
resType
.
bytes
;
}
int32_t
nullFlagSize
=
sizeof
(
int8_t
)
*
numOfGroupCols
;
int32_t
nullFlagSize
=
sizeof
(
int8_t
)
*
LIST_LENGTH
(
group
)
;
keyLen
+=
nullFlagSize
;
keyBuf
=
taosMemoryCalloc
(
1
,
keyLen
);
...
...
@@ -3920,59 +3977,68 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
groupNum
=
0
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
i
++
)
{
STableKeyInfo
*
info
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
pHandle
->
meta
,
0
);
metaGetTableEntryByUid
(
&
mr
,
info
->
uid
);
SNodeList
*
groupNew
=
nodesCloneList
(
group
);
nodesRewriteExprsPostOrder
(
groupNew
,
doTranslateTagExpr
,
&
mr
);
char
*
isNull
=
(
char
*
)
keyBuf
;
char
*
pStart
=
(
char
*
)
keyBuf
+
sizeof
(
int8_t
)
*
numOfGroupCols
;
for
(
int32_t
j
=
0
;
j
<
numOfGroupCols
;
++
j
)
{
SColumn
*
pCol
=
taosArrayGet
(
groupKey
,
j
);
if
(
strcmp
(
pCol
->
name
,
"tbname"
)
==
0
)
{
isNull
[
i
]
=
0
;
memcpy
(
pStart
,
mr
.
me
.
name
,
strlen
(
mr
.
me
.
name
));
pStart
+=
strlen
(
mr
.
me
.
name
);
char
*
pStart
=
(
char
*
)
keyBuf
+
nullFlagSize
;
SNode
*
pNode
;
int32_t
index
=
0
;
FOREACH
(
pNode
,
groupNew
){
SNode
*
pNew
=
NULL
;
int32_t
code
=
scalarCalculateConstants
(
pNode
,
&
pNew
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
REPLACE_NODE
(
pNew
);
}
else
{
STagVal
tagVal
=
{
0
};
tagVal
.
cid
=
pCol
->
colId
;
const
char
*
p
=
metaGetTableTagVal
(
&
mr
.
me
,
pCol
->
type
,
&
tagVal
);
if
(
p
==
NULL
)
{
isNull
[
j
]
=
1
;
continue
;
}
isNull
[
i
]
=
0
;
if
(
pCol
->
type
==
TSDB_DATA_TYPE_JSON
)
{
// int32_t dataLen = getJsonValueLen(pkey->pData);
// memcpy(pStart, (pkey->pData), dataLen);
// pStart += dataLen;
}
else
if
(
IS_VAR_DATA_TYPE
(
pCol
->
type
))
{
memcpy
(
pStart
,
tagVal
.
pData
,
tagVal
.
nData
);
pStart
+=
tagVal
.
nData
;
ASSERT
(
tagVal
.
nData
<=
pCol
->
bytes
);
}
else
{
memcpy
(
pStart
,
&
(
tagVal
.
i64
),
pCol
->
bytes
);
pStart
+=
pCol
->
bytes
;
}
taosMemoryFree
(
keyBuf
);
nodesClearList
(
groupNew
);
return
code
;
}
}
int32_t
len
=
(
int32_t
)(
pStart
-
(
char
*
)
keyBuf
);
uint64_t
*
pGroupId
=
taosHashGet
(
pTableListInfo
->
map
,
keyBuf
,
len
);
ASSERT
(
nodeType
(
pNew
)
==
QUERY_NODE_VALUE
);
SValueNode
*
pValue
=
(
SValueNode
*
)
pNew
;
if
(
!
pGroupId
)
{
uint64_t
tmpId
=
calcGroupId
(
keyBuf
,
len
);
info
->
groupId
=
tmpId
;
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
tmpId
,
sizeof
(
uint64_t
));
}
else
{
info
->
groupId
=
*
pGroupId
;
if
(
pValue
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_NULL
)
{
isNull
[
index
++
]
=
1
;
continue
;
}
else
{
isNull
[
index
++
]
=
0
;
char
*
data
=
nodesGetValueFromNode
(
pValue
);
if
(
pValue
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
){
int32_t
len
=
getJsonValueLen
(
data
);
memcpy
(
pStart
,
data
,
len
);
pStart
+=
len
;
}
else
if
(
IS_VAR_DATA_TYPE
(
pValue
->
node
.
resType
.
type
))
{
memcpy
(
pStart
,
data
,
varDataTLen
(
data
));
pStart
+=
varDataTLen
(
data
);
}
else
{
memcpy
(
pStart
,
data
,
pValue
->
node
.
resType
.
bytes
);
pStart
+=
pValue
->
node
.
resType
.
bytes
;
}
}
}
int32_t
len
=
(
int32_t
)(
pStart
-
(
char
*
)
keyBuf
);
uint64_t
groupId
=
calcGroupId
(
keyBuf
,
len
);
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
groupId
,
sizeof
(
uint64_t
));
groupNum
++
;
nodesClearList
(
groupNew
);
metaReaderClear
(
&
mr
);
}
taosMemoryFree
(
keyBuf
);
if
(
pTableListInfo
->
needSortTableByGroupId
){
return
sortTableGroup
(
pTableListInfo
,
groupNum
);
}
return
TDB_CODE_SUCCESS
;
}
...
...
@@ -3984,39 +4050,36 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
type
)
{
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
tsdbReaderT
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
if
(
pDataReader
==
NULL
&&
terrno
!=
0
)
{
pTaskInfo
->
code
=
terrno
;
return
NULL
;
}
int32_t
code
=
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
if
(
code
)
{
tsdbCleanupReadHandle
(
pDataReader
);
pTaskInfo
->
code
=
terrno
;
int32_t
code
=
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
if
(
code
){
pTaskInfo
->
code
=
code
;
return
NULL
;
}
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionTags
);
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
taosArrayDestroy
(
groupKeys
);
code
=
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
if
(
code
)
{
tsdbCleanupReadHandle
(
pDataReader
);
pTaskInfo
->
code
=
terrno
;
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
p
DataReader
,
pHandle
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
p
Handle
,
pTaskInfo
,
queryId
,
taskId
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
==
type
)
{
STableMergeScanPhysiNode
*
pTableScanNode
=
(
STableMergeScanPhysiNode
*
)
pPhyNode
;
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
pTableListInfo
,
pHandle
,
pTaskInfo
,
queryId
,
taskId
);
int32_t
code
=
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
if
(
code
){
return
NULL
;
}
code
=
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
if
(
code
)
{
pTaskInfo
->
code
=
terrno
;
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
pTableListInfo
,
pHandle
,
pTaskInfo
,
queryId
,
taskId
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
return
pOperator
;
...
...
@@ -4025,46 +4088,17 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return
createExchangeOperatorInfo
(
pHandle
->
pMsgCb
->
clientRpc
,
(
SExchangePhysiNode
*
)
pPhyNode
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN
==
type
)
{
SScanPhysiNode
*
pScanPhyNode
=
(
SScanPhysiNode
*
)
pPhyNode
;
// simple child table.
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
STimeWindowAggSupp
twSup
=
{
.
waterMark
=
pTableScanNode
->
watermark
,
.
calTrigger
=
pTableScanNode
->
triggerType
,
.
maxTs
=
INT64_MIN
,
};
tsdbReaderT
pDataReader
=
NULL
;
if
(
pHandle
)
{
if
(
pHandle
->
initTsdbReader
)
{
// for stream
ASSERT
(
pHandle
->
vnode
);
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
}
else
{
// for tq
ASSERT
(
pHandle
->
meta
);
getTableList
(
pHandle
->
meta
,
pScanPhyNode
,
pTableListInfo
);
}
}
#if 0
if (pDataReader == NULL && terrno != 0) {
qDebug("%s pDataReader is NULL", GET_TASKID(pTaskInfo));
// return NULL;
} else {
qDebug("%s pDataReader is not NULL", GET_TASKID(pTaskInfo));
createScanTableListInfo
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
queryId
,
taskId
);
}
#endif
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionTags
);
int32_t
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
taosArrayDestroy
(
groupKeys
);
if
(
code
)
{
tsdbCleanupReadHandle
(
pDataReader
);
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
pTableScanNode
,
pTaskInfo
,
&
twSup
);
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pHandle
,
pTableScanNode
,
pTaskInfo
,
&
twSup
,
queryId
,
taskId
);
return
pOperator
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN
==
type
)
{
...
...
@@ -4093,7 +4127,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return
NULL
;
}
}
else
{
// Create one table group.
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
pBlockNode
->
uid
,
.
groupId
=
0
};
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
pBlockNode
->
uid
};
taosArrayPush
(
pTableListInfo
->
pTableList
,
&
info
);
}
...
...
@@ -4118,7 +4152,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
cond
.
suid
=
pBlockNode
->
suid
;
cond
.
type
=
BLOCK_LOAD_OFFSET_SEQ_ORDER
;
}
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
,
queryId
,
taskId
);
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
->
pTableList
,
queryId
,
taskId
);
cleanupQueryTableDataCond
(
&
cond
);
return
createDataBlockInfoScanOperator
(
pReader
,
pHandle
,
cond
.
suid
,
pBlockNode
,
pTaskInfo
);
...
...
@@ -4355,7 +4389,7 @@ tsdbReaderT doCreateDataReader(STableScanPhysiNode* pTableScanNode, SReadHandle*
goto
_error
;
}
tsdbReaderT
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
,
queryId
,
taskId
);
tsdbReaderT
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
pTableListInfo
->
pTableList
,
queryId
,
taskId
);
cleanupQueryTableDataCond
(
&
cond
);
return
pReader
;
...
...
@@ -4584,6 +4618,13 @@ _complete:
static
void
doDestroyTableList
(
STableListInfo
*
pTableqinfoList
)
{
taosArrayDestroy
(
pTableqinfoList
->
pTableList
);
taosHashCleanup
(
pTableqinfoList
->
map
);
if
(
pTableqinfoList
->
needSortTableByGroupId
){
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableqinfoList
->
pGroupList
);
i
++
){
SArray
*
tmp
=
taosArrayGetP
(
pTableqinfoList
->
pGroupList
,
i
);
taosArrayDestroy
(
tmp
);
}
}
taosArrayDestroy
(
pTableqinfoList
->
pGroupList
);
pTableqinfoList
->
pTableList
=
NULL
;
pTableqinfoList
->
map
=
NULL
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
f0b50add
...
...
@@ -418,7 +418,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
return
NULL
;
}
static
SSDataBlock
*
doTableScan
(
SOperatorInfo
*
pOperator
)
{
static
SSDataBlock
*
doTableScan
Group
(
SOperatorInfo
*
pOperator
)
{
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
...
...
@@ -500,6 +500,48 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
}
}
return
NULL
;
}
static
SSDataBlock
*
doTableScan
(
SOperatorInfo
*
pOperator
)
{
STableScanInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
if
(
pInfo
->
currentGroupId
==
-
1
){
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pGroupList
))
{
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
return
NULL
;
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
tsdbCleanupReadHandle
(
pInfo
->
dataReader
);
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pInfo
->
readHandle
.
vnode
,
&
pInfo
->
cond
,
tableList
,
pInfo
->
queryId
,
pInfo
->
taskId
);
pInfo
->
dataReader
=
pReader
;
}
SSDataBlock
*
result
=
doTableScanGroup
(
pOperator
);
if
(
result
){
return
result
;
}
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pGroupList
))
{
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
return
NULL
;
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
tsdbSetTableList
(
pInfo
->
dataReader
,
tableList
);
tsdbResetReadHandle
(
pInfo
->
dataReader
,
&
pInfo
->
cond
,
0
);
pInfo
->
curTWinIdx
=
0
;
pInfo
->
scanTimes
=
0
;
result
=
doTableScanGroup
(
pOperator
);
if
(
result
){
return
result
;
}
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
return
NULL
;
}
...
...
@@ -525,8 +567,8 @@ static void destroyTableScanOperatorInfo(void* param, int32_t numOfOutput) {
}
}
SOperatorInfo
*
createTableScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
tsdbReaderT
pDataReader
,
S
ReadHandle
*
readHandle
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createTableScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
readHandle
,
S
ExecTaskInfo
*
pTaskInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
STableScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
@@ -561,10 +603,12 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
pInfo
->
dataBlockLoadFlag
=
pTableScanNode
->
dataRequired
;
pInfo
->
pResBlock
=
createResDataBlock
(
pDescNode
);
pInfo
->
pFilterNode
=
pTableScanNode
->
scan
.
node
.
pConditions
;
pInfo
->
dataReader
=
pDataReader
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
pInfo
->
pColMatchInfo
=
pColList
;
pInfo
->
curTWinIdx
=
0
;
pInfo
->
queryId
=
queryId
;
pInfo
->
taskId
=
taskId
;
pInfo
->
currentGroupId
=
-
1
;
pOperator
->
name
=
"TableScanOperator"
;
// for debug purpose
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
;
...
...
@@ -778,8 +822,9 @@ static bool prepareDataScan(SStreamBlockScanInfo* pInfo) {
STableScanInfo
*
pTableScanInfo
=
pInfo
->
pSnapshotReadOp
->
info
;
pTableScanInfo
->
cond
.
twindows
[
0
]
=
win
;
pTableScanInfo
->
curTWinIdx
=
0
;
tsdbResetReadHandle
(
pTableScanInfo
->
dataReader
,
&
pTableScanInfo
->
cond
,
0
);
//
tsdbResetReadHandle(pTableScanInfo->dataReader, &pTableScanInfo->cond, 0);
pTableScanInfo
->
scanTimes
=
0
;
pTableScanInfo
->
currentGroupId
=
-
1
;
return
true
;
}
...
...
@@ -1087,9 +1132,9 @@ static SArray* extractTableIdList(const STableListInfo* pTableGroupInfo) {
return
tableIdList
;
}
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
pDataReader
,
SReadHandle
*
pHandle
,
SOperatorInfo
*
createStreamScanOperatorInfo
(
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
)
{
STimeWindowAggSupp
*
pTwSup
,
uint64_t
queryId
,
uint64_t
taskId
)
{
SStreamBlockScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamBlockScanInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
...
...
@@ -1129,7 +1174,7 @@ SOperatorInfo* createStreamScanOperatorInfo(void* pDataReader, SReadHandle* pHan
}
if
(
pHandle
)
{
SOperatorInfo
*
pTableScanDummy
=
createTableScanOperatorInfo
(
pTableScanNode
,
p
DataReader
,
pHandle
,
pTaskInfo
);
SOperatorInfo
*
pTableScanDummy
=
createTableScanOperatorInfo
(
pTableScanNode
,
p
Handle
,
pTaskInfo
,
queryId
,
taskId
);
STableScanInfo
*
pSTInfo
=
(
STableScanInfo
*
)
pTableScanDummy
->
info
;
if
(
pSTInfo
->
interval
.
interval
>
0
)
{
pInfo
->
pUpdateInfo
=
updateInfoInitP
(
&
pSTInfo
->
interval
,
pTwSup
->
waterMark
);
...
...
@@ -1889,11 +1934,12 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
goto
_error
;
}
pInfo
->
pTableList
=
pTableListInfo
;
pInfo
->
pColMatchInfo
=
colList
;
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pInfo
->
pTableList
=
pTableListInfo
;
pInfo
->
pColMatchInfo
=
colList
;
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pOperator
->
name
=
"TagScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
;
...
...
@@ -1919,10 +1965,7 @@ _error:
typedef
struct
STableMergeScanInfo
{
STableListInfo
*
tableListInfo
;
int32_t
tableStartIndex
;
int32_t
tableEndIndex
;
bool
hasGroupId
;
uint64_t
groupId
;
int32_t
currentGroupId
;
SArray
*
dataReaders
;
// array of tsdbReaderT*
SReadHandle
readHandle
;
...
...
@@ -1968,12 +2011,6 @@ typedef struct STableMergeScanInfo {
SSampleExecInfo
sample
;
// sample execution info
}
STableMergeScanInfo
;
int32_t
compareTableKeyInfoByGid
(
const
void
*
p1
,
const
void
*
p2
)
{
const
STableKeyInfo
*
info1
=
p1
;
const
STableKeyInfo
*
info2
=
p2
;
return
info1
->
groupId
-
info2
->
groupId
;
}
int32_t
createScanTableListInfo
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
int32_t
code
=
getTableList
(
pHandle
->
meta
,
&
pTableScanNode
->
scan
,
pTableListInfo
);
...
...
@@ -1985,55 +2022,9 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle
qDebug
(
"no table qualified for query, TID:0x%"
PRIx64
", QID:0x%"
PRIx64
,
taskId
,
queryId
);
return
TSDB_CODE_SUCCESS
;
}
SArray
*
groupKeys
=
extractPartitionColInfo
(
pTableScanNode
->
pPartitionTags
);
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
groupKeys
);
// todo for json
if
(
groupKeys
)
{
taosArraySort
(
pTableListInfo
->
pTableList
,
compareTableKeyInfoByGid
);
}
taosArrayDestroy
(
groupKeys
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
doCreateMultipleDataReaders
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
)
{
SQueryTableDataCond
cond
=
{
0
};
int32_t
code
=
initQueryTableDataCond
(
&
cond
,
pTableScanNode
);
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
pPartitionTags
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
++
i
)
{
STableListInfo
*
subListInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
subListInfo
));
subListInfo
->
pTableList
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
subListInfo
->
pTableList
,
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
));
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
&
cond
,
subListInfo
,
queryId
,
taskId
);
taosArrayPush
(
arrayReader
,
&
pReader
);
taosArrayDestroy
(
subListInfo
->
pTableList
);
taosMemoryFree
(
subListInfo
);
}
cleanupQueryTableDataCond
(
&
cond
);
return
TSDB_CODE_SUCCESS
;
_error:
return
code
;
}
int32_t
createMultipleDataReaders
(
SQueryTableDataCond
*
pQueryCond
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
int32_t
tableStartIdx
,
int32_t
tableEndIdx
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
)
{
for
(
int32_t
i
=
tableStartIdx
;
i
<=
tableEndIdx
;
++
i
)
{
STableListInfo
*
subListInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
subListInfo
));
subListInfo
->
pTableList
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
subListInfo
->
pTableList
,
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
));
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
pQueryCond
,
subListInfo
,
queryId
,
taskId
);
taosArrayPush
(
arrayReader
,
&
pReader
);
taosArrayDestroy
(
subListInfo
->
pTableList
);
taosMemoryFree
(
subListInfo
);
return
code
;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2225,32 +2216,34 @@ SArray* generateSortByTsInfo(int32_t order) {
return
pList
;
}
static
int32_t
createMultipleDataReaders
(
SQueryTableDataCond
*
pQueryCond
,
SReadHandle
*
pHandle
,
SArray
*
tableList
,
SArray
*
arrayReader
,
uint64_t
queryId
,
uint64_t
taskId
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tableList
);
++
i
)
{
SArray
*
tmp
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
tmp
,
taosArrayGet
(
tableList
,
i
));
tsdbReaderT
*
pReader
=
tsdbReaderOpen
(
pHandle
->
vnode
,
pQueryCond
,
tmp
,
queryId
,
taskId
);
taosArrayPush
(
arrayReader
,
&
pReader
);
taosArrayDestroy
(
tmp
);
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
startGroupTableMergeScan
(
SOperatorInfo
*
pOperator
)
{
STableMergeScanInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
{
size_t
tableListSize
=
taosArrayGetSize
(
pInfo
->
tableListInfo
->
pTableList
);
int32_t
i
=
pInfo
->
tableStartIndex
+
1
;
for
(;
i
<
tableListSize
;
++
i
)
{
STableKeyInfo
*
tableKeyInfo
=
taosArrayGet
(
pInfo
->
tableListInfo
->
pTableList
,
i
);
if
(
tableKeyInfo
->
groupId
!=
pInfo
->
groupId
)
{
break
;
}
}
pInfo
->
tableEndIndex
=
i
-
1
;
}
SArray
*
tableList
=
taosArrayGetP
(
pInfo
->
tableListInfo
->
pGroupList
,
pInfo
->
currentGroupId
);
int32_t
tableStartIdx
=
pInfo
->
tableStartIndex
;
int32_t
tableEndIdx
=
pInfo
->
tableEndIndex
;
STableListInfo
*
tableListInfo
=
pInfo
->
tableListInfo
;
createMultipleDataReaders
(
&
pInfo
->
cond
,
&
pInfo
->
readHandle
,
tableListInfo
,
tableStartIdx
,
tableEndIdx
,
createMultipleDataReaders
(
&
pInfo
->
cond
,
&
pInfo
->
readHandle
,
tableList
,
pInfo
->
dataReaders
,
pInfo
->
queryId
,
pInfo
->
taskId
);
// todo the total available buffer should be determined by total capacity of buffer of this task.
// the additional one is reserved for merge result
pInfo
->
sortBufSize
=
pInfo
->
bufPageSize
*
(
tableEndIdx
-
tableStartIdx
+
1
+
1
);
int32_t
tableLen
=
taosArrayGetSize
(
tableList
);
pInfo
->
sortBufSize
=
pInfo
->
bufPageSize
*
((
tableLen
==
0
?
1
:
tableLen
)
+
1
);
int32_t
numOfBufPage
=
pInfo
->
sortBufSize
/
pInfo
->
bufPageSize
;
pInfo
->
pSortHandle
=
tsortCreateSortHandle
(
pInfo
->
pSortInfo
,
SORT_MULTISOURCE_MERGE
,
pInfo
->
bufPageSize
,
numOfBufPage
,
pInfo
->
pSortInputBlock
,
pTaskInfo
->
id
.
str
);
...
...
@@ -2337,38 +2330,43 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) {
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
size_t
tableListSize
=
taosArrayGetSize
(
pInfo
->
tableListInfo
->
pTableList
);
if
(
!
pInfo
->
hasGroupId
)
{
pInfo
->
hasGroupId
=
true
;
if
(
tableListSize
==
0
)
{
if
(
pInfo
->
currentGroupId
==
-
1
)
{
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pInfo
->
tableListInfo
->
pGroupList
))
{
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
}
pInfo
->
tableStartIndex
=
0
;
pInfo
->
groupId
=
((
STableKeyInfo
*
)
taosArrayGet
(
pInfo
->
tableListInfo
->
pTableList
,
pInfo
->
tableStartIndex
))
->
groupId
;
startGroupTableMergeScan
(
pOperator
);
}
SSDataBlock
*
pBlock
=
NULL
;
while
(
pInfo
->
tableStartIndex
<
tableListSize
)
{
pBlock
=
getSortedTableMergeScanBlockData
(
pInfo
->
pSortHandle
,
pOperator
->
resultInfo
.
capacity
,
pOperator
);
if
(
pBlock
!=
NULL
)
{
pBlock
->
info
.
groupId
=
pInfo
->
groupId
;
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
return
pBlock
;
}
else
{
stopGroupTableMergeScan
(
pOperator
);
if
(
pInfo
->
tableEndIndex
>=
tableListSize
-
1
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
pInfo
->
tableStartIndex
=
pInfo
->
tableEndIndex
+
1
;
pInfo
->
groupId
=
((
STableKeyInfo
*
)
taosArrayGet
(
pInfo
->
tableListInfo
->
pTableList
,
pInfo
->
tableStartIndex
))
->
groupId
;
startGroupTableMergeScan
(
pOperator
);
}
SSDataBlock
*
pBlock
=
getSortedTableMergeScanBlockData
(
pInfo
->
pSortHandle
,
pOperator
->
resultInfo
.
capacity
,
pOperator
);
if
(
pBlock
!=
NULL
)
{
uint64_t
*
groupId
=
taosHashGet
(
pInfo
->
tableListInfo
->
map
,
&
(
pBlock
->
info
.
uid
),
sizeof
(
uint64_t
));
if
(
groupId
)
pBlock
->
info
.
groupId
=
*
groupId
;
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
return
pBlock
;
}
stopGroupTableMergeScan
(
pOperator
);
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pInfo
->
tableListInfo
->
pGroupList
))
{
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
}
startGroupTableMergeScan
(
pOperator
);
pBlock
=
getSortedTableMergeScanBlockData
(
pInfo
->
pSortHandle
,
pOperator
->
resultInfo
.
capacity
,
pOperator
);
if
(
pBlock
!=
NULL
)
{
uint64_t
*
groupId
=
taosHashGet
(
pInfo
->
tableListInfo
->
map
,
&
(
pBlock
->
info
.
uid
),
sizeof
(
uint64_t
));
if
(
groupId
)
pBlock
->
info
.
groupId
=
*
groupId
;
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
return
pBlock
;
}
doSetOperatorCompleted
(
pOperator
);
return
pBlock
;
}
...
...
@@ -2445,6 +2443,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
pInfo
->
dataReaders
=
taosArrayInit
(
64
,
POINTER_BYTES
);
pInfo
->
queryId
=
queryId
;
pInfo
->
taskId
=
taskId
;
pInfo
->
currentGroupId
=
-
1
;
pInfo
->
sortSourceParams
=
taosArrayInit
(
64
,
sizeof
(
STableMergeScanSortSourceParam
));
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
f0b50add
...
...
@@ -1220,6 +1220,7 @@ int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_JSON
:
pNode
->
datum
.
p
=
(
char
*
)
value
;
break
;
default:
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
f0b50add
...
...
@@ -1061,6 +1061,7 @@ static EDealRes partTagsOptRebuildTbanmeImpl(SNode** pNode, void* pContext) {
}
strcpy
(
pFunc
->
functionName
,
"tbname"
);
pFunc
->
funcType
=
FUNCTION_TYPE_TBNAME
;
pFunc
->
node
.
resType
=
((
SColumnNode
*
)
*
pNode
)
->
node
.
resType
;
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
pFunc
;
return
DEAL_RES_IGNORE_CHILD
;
...
...
@@ -1188,7 +1189,7 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"ConditionPushDown"
,
.
optimizeFunc
=
cpdOptimize
},
{.
pName
=
"OrderByPrimaryKey"
,
.
optimizeFunc
=
opkOptimize
},
{.
pName
=
"SmaIndex"
,
.
optimizeFunc
=
smaOptimize
},
//
{.pName = "PartitionTags", .optimizeFunc = partTagsOptimize},
{.
pName
=
"PartitionTags"
,
.
optimizeFunc
=
partTagsOptimize
},
{.
pName
=
"EliminateProject"
,
.
optimizeFunc
=
eliminateProjOptimize
}
};
// clang-format on
...
...
tests/system-test/2-query/json_tag.py
浏览文件 @
f0b50add
...
...
@@ -412,52 +412,59 @@ class TDTestCase:
tdSql
.
checkColNameList
(
res
,
cname_list
)
#
# test group by & order by json tag
tdSql
.
query
(
"select ts,jtag->'tag1' from jsons1 partition by jtag->'tag1' order by jtag->'tag1' desc"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
0
,
1
,
'"femail"'
)
tdSql
.
checkData
(
2
,
1
,
'"收到货"'
)
tdSql
.
checkData
(
7
,
1
,
"false"
)
# tdSql.error("select count(*) from jsons1 group by jtag")
# tdSql.error("select count(*) from jsons1 partition by jtag")
# tdSql.error("select count(*) from jsons1 group by jtag order by jtag")
tdSql
.
error
(
"select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag2'"
)
tdSql
.
error
(
"select count(*) from jsons1 group by jtag->'tag1' order by jtag"
)
tdSql
.
query
(
"select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
checkData
(
0
,
1
,
'"femail"'
)
tdSql
.
checkData
(
1
,
0
,
2
)
tdSql
.
checkData
(
1
,
1
,
'"收到货"'
)
tdSql
.
checkData
(
2
,
0
,
1
)
tdSql
.
checkData
(
2
,
1
,
"11.000000000"
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
1
,
"false"
)
tdSql
.
checkData
(
6
,
0
,
1
)
tdSql
.
checkData
(
6
,
1
,
"null"
)
tdSql
.
checkData
(
7
,
0
,
2
)
tdSql
.
checkData
(
7
,
1
,
None
)
tdSql
.
query
(
"select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
2
,
0
,
1
)
tdSql
.
checkData
(
2
,
1
,
"false"
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
1
,
"11.000000000"
)
tdSql
.
checkData
(
7
,
0
,
2
)
tdSql
.
checkData
(
7
,
1
,
'"femail"'
)
#
tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc")
#
tdSql.checkRows(8)
#
tdSql.checkData(0, 0, 2)
#
tdSql.checkData(0, 1, '"femail"')
#
tdSql.checkData(1, 0, 2)
#
tdSql.checkData(1, 1, '"收到货"')
#
tdSql.checkData(2, 0, 1)
#
tdSql.checkData(2, 1, "11.000000000")
#
tdSql.checkData(5, 0, 1)
#
tdSql.checkData(5, 1, "false")
#
tdSql.checkData(6, 0, 1)
#
tdSql.checkData(6, 1, "null")
#
tdSql.checkData(7, 0, 2)
#
tdSql.checkData(7, 1, None)
#
tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc")
#
tdSql.checkRows(8)
#
tdSql.checkData(0, 0, 2)
#
tdSql.checkData(0, 1, None)
#
tdSql.checkData(2, 0, 1)
#
tdSql.checkData(2, 1, "false")
#
tdSql.checkData(5, 0, 1)
#
tdSql.checkData(5, 1, "11.000000000")
#
tdSql.checkData(7, 0, 2)
#
tdSql.checkData(7, 1, '"femail"')
#
# test stddev with group by json tag
tdSql
.
query
(
"select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
0
,
10
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
4
,
0
,
0
)
tdSql
.
checkData
(
4
,
1
,
"5.000000000"
)
tdSql
.
checkData
(
7
,
0
,
11
)
tdSql
.
checkData
(
7
,
1
,
'"femail"'
)
res
=
tdSql
.
getColNameList
(
"select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'"
)
cname_list
=
[]
cname_list
.
append
(
"stddev(dataint)"
)
cname_list
.
append
(
"jsons1.jtag->'tag1'"
)
tdSql
.
checkColNameList
(
res
,
cname_list
)
#
tdSql.query("select stddev(dataint),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'")
#
tdSql.checkRows(8)
#
tdSql.checkData(0, 0, 10)
#
tdSql.checkData(0, 1, None)
#
tdSql.checkData(4, 0, 0)
#
tdSql.checkData(4, 1, "5.000000000")
#
tdSql.checkData(7, 0, 11)
#
tdSql.checkData(7, 1, '"femail"')
#
#
res = tdSql.getColNameList("select stddev(dataint),jsons1.jtag->'tag1' from jsons1 group by jsons1.jtag->'tag1' order by jtag->'tag1'")
#
cname_list = []
#
cname_list.append("stddev(dataint)")
#
cname_list.append("jsons1.jtag->'tag1'")
#
tdSql.checkColNameList(res, cname_list)
# test top/bottom with group by json tag
# tdSql.query("select top(dataint,2),jtag->'tag1' from jsons1 group by jtag->'tag1' order by jtag->'tag1'")
...
...
@@ -470,8 +477,8 @@ class TDTestCase:
# tdSql.checkData(10, 1, '"femail"')
# test having
tdSql
.
query
(
"select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1"
)
tdSql
.
checkRows
(
3
)
#
tdSql.query("select count(*),jtag->'tag1' from jsons1 group by jtag->'tag1' having count(*) > 1")
#
tdSql.checkRows(3)
# subquery with json tag
tdSql
.
query
(
"select * from (select jtag, dataint from jsons1) order by dataint"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录