Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
90128345
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
90128345
编写于
6月 23, 2022
作者:
wmmhello
提交者:
GitHub
6月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/3.0_wxy' into 3.0
上级
77f34c8f
4659a0a0
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
411 addition
and
242 deletion
+411
-242
include/common/tcommon.h
include/common/tcommon.h
+2
-0
include/common/tdatablock.h
include/common/tdatablock.h
+2
-1
include/common/tdataformat.h
include/common/tdataformat.h
+2
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+2
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+7
-6
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+2
-2
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+1
-1
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+12
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+0
-3
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+2
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+0
-1
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+103
-7
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+12
-11
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+9
-13
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+1
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+9
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+61
-7
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+2
-2
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+2
-2
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+2
-32
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+9
-0
source/libs/planner/test/planOptimizeTest.cpp
source/libs/planner/test/planOptimizeTest.cpp
+2
-0
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+31
-9
tests/system-test/2-query/json_tag.py
tests/system-test/2-query/json_tag.py
+136
-142
未找到文件。
include/common/tcommon.h
浏览文件 @
90128345
...
...
@@ -52,6 +52,8 @@ typedef enum EStreamType {
typedef
struct
{
SArray
*
pTableList
;
SHashObj
*
map
;
// speedup acquire the tableQueryInfo by table uid
void
*
pTagCond
;
void
*
pTagIndexCond
;
}
STableListInfo
;
typedef
struct
SColumnDataAgg
{
...
...
include/common/tdatablock.h
浏览文件 @
90128345
...
...
@@ -71,7 +71,8 @@ SEpSet getEpSet_s(SCorEpSet* pEpSet);
#define colDataGetData(p1_, r_) \
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? colDataGetVarData(p1_, r_) : colDataGetNumData(p1_, r_))
#define IS_JSON_NULL(type, data) ((type) == TSDB_DATA_TYPE_JSON && *(data) == TSDB_DATA_TYPE_NULL)
#define IS_JSON_NULL(type, data) ((type) == TSDB_DATA_TYPE_JSON && \
(*(data) == TSDB_DATA_TYPE_NULL || tTagIsJsonNull(data)))
static
FORCE_INLINE
bool
colDataIsNull_s
(
const
SColumnInfoData
*
pColumnInfoData
,
uint32_t
row
)
{
if
(
!
pColumnInfoData
->
hasNull
)
{
...
...
include/common/tdataformat.h
浏览文件 @
90128345
...
...
@@ -70,6 +70,8 @@ int32_t tGetTSRow(uint8_t *p, STSRow2 *pRow);
// STag
int32_t
tTagNew
(
SArray
*
pArray
,
int32_t
version
,
int8_t
isJson
,
STag
**
ppTag
);
void
tTagFree
(
STag
*
pTag
);
bool
tTagIsJson
(
const
void
*
pTag
);
bool
tTagIsJsonNull
(
void
*
tagVal
);
bool
tTagGet
(
const
STag
*
pTag
,
STagVal
*
pTagVal
);
char
*
tTagValToData
(
const
STagVal
*
pTagVal
,
bool
isJson
);
int32_t
tEncodeTag
(
SEncoder
*
pEncoder
,
const
STag
*
pTag
);
...
...
include/libs/nodes/plannodes.h
浏览文件 @
90128345
...
...
@@ -66,6 +66,7 @@ typedef struct SScanLogicNode {
int8_t
intervalUnit
;
int8_t
slidingUnit
;
SNode
*
pTagCond
;
SNode
*
pTagIndexCond
;
int8_t
triggerType
;
int64_t
watermark
;
int16_t
tsColId
;
...
...
@@ -468,6 +469,7 @@ typedef struct SSubplan {
SPhysiNode
*
pNode
;
// physical plan of current subplan
SDataSinkNode
*
pDataSink
;
// data of the subplan flow into the datasink
SNode
*
pTagCond
;
SNode
*
pTagIndexCond
;
}
SSubplan
;
typedef
enum
EExplainMode
{
EXPLAIN_MODE_DISABLE
=
1
,
EXPLAIN_MODE_STATIC
,
EXPLAIN_MODE_ANALYZE
}
EExplainMode
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
90128345
...
...
@@ -288,11 +288,11 @@ typedef enum ESqlClause {
}
ESqlClause
;
typedef
struct
SDeleteStmt
{
ENodeType
type
;
// QUERY_NODE_DELETE_STMT
SNode
*
pFromTable
;
// FROM clause
SNode
*
pWhere
;
// WHERE clause
SNode
*
pCountFunc
;
// count the number of rows affected
SNode
*
pTag
IndexCond
;
// pWhere divided into pTagIndex
Cond and timeRange
ENodeType
type
;
// QUERY_NODE_DELETE_STMT
SNode
*
pFromTable
;
// FROM clause
SNode
*
pWhere
;
// WHERE clause
SNode
*
pCountFunc
;
// count the number of rows affected
SNode
*
pTag
Cond
;
// pWhere divided into pTag
Cond and timeRange
STimeWindow
timeRange
;
uint8_t
precision
;
bool
deleteZeroRows
;
...
...
@@ -397,7 +397,8 @@ void nodesValueNodeToVariant(const SValueNode* pNode, SVariant* pVal);
char
*
nodesGetFillModeString
(
EFillMode
mode
);
int32_t
nodesMergeConds
(
SNode
**
pDst
,
SNodeList
**
pSrc
);
int32_t
nodesPartitionCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
);
int32_t
nodesPartitionCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagIndexCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
);
#ifdef __cplusplus
}
...
...
source/client/src/clientImpl.c
浏览文件 @
90128345
...
...
@@ -1507,7 +1507,7 @@ static int32_t estimateJsonLen(SReqResultInfo* pResultInfo, int32_t numOfCols, i
char
*
jsonInnerData
=
data
+
CHAR_BYTES
;
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NULL
)
{
len
+=
(
VARSTR_HEADER_SIZE
+
strlen
(
TSDB_DATA_NULL_STR_L
));
}
else
if
(
jsonInnerType
&
TD_TAG_JSON
)
{
}
else
if
(
tTagIsJson
(
data
)
)
{
len
+=
(
VARSTR_HEADER_SIZE
+
((
const
STag
*
)(
data
))
->
len
);
}
else
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NCHAR
)
{
// value -> "value"
len
+=
varDataTLen
(
jsonInnerData
)
+
CHAR_BYTES
*
2
;
...
...
@@ -1592,7 +1592,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
if
(
jsonInnerType
==
TSDB_DATA_TYPE_NULL
)
{
sprintf
(
varDataVal
(
dst
),
"%s"
,
TSDB_DATA_NULL_STR_L
);
varDataSetLen
(
dst
,
strlen
(
varDataVal
(
dst
)));
}
else
if
(
jsonInnerType
&
TD_TAG_JSON
)
{
}
else
if
(
tTagIsJson
(
data
)
)
{
char
*
jsonString
=
parseTagDatatoJson
(
data
);
STR_TO_VARSTR
(
dst
,
jsonString
);
taosMemoryFree
(
jsonString
);
...
...
source/common/src/tdatablock.c
浏览文件 @
90128345
...
...
@@ -110,7 +110,7 @@ int32_t getJsonValueLen(const char* data) {
dataLen
=
DOUBLE_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
data
==
TSDB_DATA_TYPE_BOOL
)
{
dataLen
=
CHAR_BYTES
+
CHAR_BYTES
;
}
else
if
(
*
data
&
TD_TAG_JSON
)
{
// json string
}
else
if
(
tTagIsJson
(
data
)
)
{
// json string
dataLen
=
((
STag
*
)(
data
))
->
len
;
}
else
{
ASSERT
(
0
);
...
...
source/common/src/tdataformat.c
浏览文件 @
90128345
...
...
@@ -924,6 +924,18 @@ static int32_t tGetTagVal(uint8_t *p, STagVal *pTagVal, int8_t isJson) {
return
n
;
}
bool
tTagIsJson
(
const
void
*
pTag
){
return
(((
const
STag
*
)
pTag
)
->
flags
&
TD_TAG_JSON
);
}
bool
tTagIsJsonNull
(
void
*
data
){
STag
*
pTag
=
(
STag
*
)
data
;
int8_t
isJson
=
tTagIsJson
(
pTag
);
if
(
!
isJson
)
return
false
;
return
((
STag
*
)
data
)
->
nTag
==
0
;
}
int32_t
tTagNew
(
SArray
*
pArray
,
int32_t
version
,
int8_t
isJson
,
STag
**
ppTag
)
{
int32_t
code
=
0
;
uint8_t
*
p
=
NULL
;
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
90128345
...
...
@@ -613,9 +613,6 @@ const void *metaGetTableTagVal(SMetaEntry *pEntry, int16_t type, STagVal *val) {
ASSERT
(
pEntry
->
type
==
TSDB_CHILD_TABLE
);
STag
*
tag
=
(
STag
*
)
pEntry
->
ctbEntry
.
pTags
;
if
(
type
==
TSDB_DATA_TYPE_JSON
)
{
if
(
tag
->
nTag
==
0
)
{
return
NULL
;
}
return
tag
;
}
bool
find
=
tTagGet
(
tag
,
val
);
...
...
source/libs/executor/inc/executil.h
浏览文件 @
90128345
...
...
@@ -106,7 +106,8 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo);
SSDataBlock
*
createResDataBlock
(
SDataBlockDescNode
*
pNode
);
int32_t
getTableList
(
void
*
metaHandle
,
SScanPhysiNode
*
pScanNode
,
STableListInfo
*
pListInfo
,
SNode
*
pTagCond
);
EDealRes
doTranslateTagExpr
(
SNode
**
pNode
,
void
*
pContext
);
int32_t
getTableList
(
void
*
metaHandle
,
SScanPhysiNode
*
pScanNode
,
STableListInfo
*
pListInfo
);
SArray
*
createSortInfo
(
SNodeList
*
pNodeList
);
SArray
*
extractPartitionColInfo
(
SNodeList
*
pNodeList
);
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
,
SDataBlockDescNode
*
pOutputNodeList
,
int32_t
*
numOfOutputCols
,
int32_t
type
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
90128345
...
...
@@ -282,7 +282,6 @@ typedef struct STagScanInfo {
int32_t
curPos
;
SReadHandle
readHandle
;
STableListInfo
*
pTableList
;
SNode
*
pFilterNode
;
// filter info,
}
STagScanInfo
;
typedef
enum
EStreamScanMode
{
...
...
source/libs/executor/src/executil.c
浏览文件 @
90128345
...
...
@@ -214,28 +214,111 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
return
pBlock
;
}
int32_t
getTableList
(
void
*
metaHandle
,
SScanPhysiNode
*
pScanNode
,
STableListInfo
*
pListInfo
,
SNode
*
pTagCond
)
{
EDealRes
doTranslateTagExpr
(
SNode
**
pNode
,
void
*
pContext
)
{
SMetaReader
*
mr
=
(
SMetaReader
*
)
pContext
;
if
(
nodeType
(
*
pNode
)
==
QUERY_NODE_COLUMN
){
SColumnNode
*
pSColumnNode
=
*
(
SColumnNode
**
)
pNode
;
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
res
)
{
return
DEAL_RES_ERROR
;
}
res
->
translate
=
true
;
res
->
node
.
resType
=
pSColumnNode
->
node
.
resType
;
STagVal
tagVal
=
{
0
};
tagVal
.
cid
=
pSColumnNode
->
colId
;
const
char
*
p
=
metaGetTableTagVal
(
&
mr
->
me
,
pSColumnNode
->
node
.
resType
.
type
,
&
tagVal
);
if
(
p
==
NULL
)
{
res
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_NULL
;
}
else
if
(
pSColumnNode
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
len
=
((
const
STag
*
)
p
)
->
len
;
res
->
datum
.
p
=
taosMemoryCalloc
(
len
+
1
,
1
);
memcpy
(
res
->
datum
.
p
,
p
,
len
);
}
else
if
(
IS_VAR_DATA_TYPE
(
pSColumnNode
->
node
.
resType
.
type
))
{
res
->
datum
.
p
=
taosMemoryCalloc
(
tagVal
.
nData
+
VARSTR_HEADER_SIZE
+
1
,
1
);
memcpy
(
varDataVal
(
res
->
datum
.
p
),
tagVal
.
pData
,
tagVal
.
nData
);
varDataSetLen
(
res
->
datum
.
p
,
tagVal
.
nData
);
}
else
{
nodesSetValueNodeValue
(
res
,
&
(
tagVal
.
i64
));
}
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
}
else
if
(
nodeType
(
*
pNode
)
==
QUERY_NODE_FUNCTION
){
SFunctionNode
*
pFuncNode
=
*
(
SFunctionNode
**
)
pNode
;
if
(
pFuncNode
->
funcType
==
FUNCTION_TYPE_TBNAME
){
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
res
)
{
return
DEAL_RES_ERROR
;
}
res
->
translate
=
true
;
res
->
node
.
resType
=
pFuncNode
->
node
.
resType
;
int32_t
len
=
strlen
(
mr
->
me
.
name
);
res
->
datum
.
p
=
taosMemoryCalloc
(
len
+
VARSTR_HEADER_SIZE
+
1
,
1
);
memcpy
(
varDataVal
(
res
->
datum
.
p
),
mr
->
me
.
name
,
len
);
varDataSetLen
(
res
->
datum
.
p
,
len
);
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
}
}
return
DEAL_RES_CONTINUE
;
}
static
bool
isTableOk
(
STableKeyInfo
*
info
,
SNode
*
pTagCond
,
SMeta
*
metaHandle
){
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
metaHandle
,
0
);
metaGetTableEntryByUid
(
&
mr
,
info
->
uid
);
SNode
*
pTagCondTmp
=
nodesCloneNode
(
pTagCond
);
nodesRewriteExprPostOrder
(
&
pTagCondTmp
,
doTranslateTagExpr
,
&
mr
);
metaReaderClear
(
&
mr
);
SNode
*
pNew
=
NULL
;
int32_t
code
=
scalarCalculateConstants
(
pTagCondTmp
,
&
pNew
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
(
pTagCondTmp
);
return
false
;
}
ASSERT
(
nodeType
(
pNew
)
==
QUERY_NODE_VALUE
);
SValueNode
*
pValue
=
(
SValueNode
*
)
pNew
;
ASSERT
(
pValue
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_BOOL
);
bool
result
=
pValue
->
datum
.
b
;
nodesDestroyNode
(
pNew
);
return
result
;
}
int32_t
getTableList
(
void
*
metaHandle
,
SScanPhysiNode
*
pScanNode
,
STableListInfo
*
pListInfo
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
pListInfo
->
pTableList
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
uint64_t
tableUid
=
pScanNode
->
uid
;
SNode
*
pTagCond
=
(
SNode
*
)
pListInfo
->
pTagCond
;
SNode
*
pTagIndexCond
=
(
SNode
*
)
pListInfo
->
pTagIndexCond
;
if
(
pScanNode
->
tableType
==
TSDB_SUPER_TABLE
)
{
if
(
pTagCond
)
{
if
(
pTag
Index
Cond
)
{
SIndexMetaArg
metaArg
=
{
.
metaEx
=
metaHandle
,
.
idx
=
tsdbGetIdx
(
metaHandle
),
.
ivtIdx
=
tsdbGetIvtIdx
(
metaHandle
),
.
suid
=
tableUid
};
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
uint64_t
));
code
=
doFilterTag
(
pTagCond
,
&
metaArg
,
res
);
if
(
code
==
TSDB_CODE_INDEX_REBUILDING
)
{
// todo
// doFilter();
//code = doFilterTag(pTagIndexCond, &metaArg, res);
code
=
TSDB_CODE_INDEX_REBUILDING
;
if
(
code
==
TSDB_CODE_INDEX_REBUILDING
)
{
code
=
tsdbGetAllTableList
(
metaHandle
,
tableUid
,
pListInfo
->
pTableList
);
}
else
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to get tableIds, reason: %s, suid: %"
PRIu64
""
,
tstrerror
(
code
),
tableUid
);
taosArrayDestroy
(
res
);
terrno
=
code
;
return
code
;
}
else
{
qDebug
(
"suc
c
ess to get tableIds, size: %d, suid: %"
PRIu64
""
,
(
int
)
taosArrayGetSize
(
res
),
tableUid
);
qDebug
(
"sucess to get tableIds, size: %d, suid: %"
PRIu64
""
,
(
int
)
taosArrayGetSize
(
res
),
tableUid
);
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
res
);
i
++
)
{
...
...
@@ -246,7 +329,20 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
}
else
{
code
=
tsdbGetAllTableList
(
metaHandle
,
tableUid
,
pListInfo
->
pTableList
);
}
}
else
{
// Create one table group.
if
(
pTagCond
){
int32_t
i
=
0
;
while
(
i
<
taosArrayGetSize
(
pListInfo
->
pTableList
))
{
STableKeyInfo
*
info
=
taosArrayGet
(
pListInfo
->
pTableList
,
i
);
bool
isOk
=
isTableOk
(
info
,
pTagCond
,
metaHandle
);
if
(
!
isOk
){
taosArrayRemove
(
pListInfo
->
pTableList
,
i
);
continue
;
}
i
++
;
}
}
}
else
{
// Create one table group.
STableKeyInfo
info
=
{.
lastKey
=
0
,
.
uid
=
tableUid
,
.
groupId
=
0
};
taosArrayPush
(
pListInfo
->
pTableList
,
&
info
);
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
90128345
...
...
@@ -3872,8 +3872,7 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
}
static
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
);
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
...
...
@@ -3987,7 +3986,7 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
}
SOperatorInfo
*
createOperatorTree
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableListInfo
*
pTableListInfo
,
SNode
*
pTagCond
)
{
uint64_t
queryId
,
uint64_t
taskId
,
STableListInfo
*
pTableListInfo
)
{
int32_t
type
=
nodeType
(
pPhyNode
);
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
...
...
@@ -3995,7 +3994,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
tsdbReaderT
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
,
pTagCond
);
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
if
(
pDataReader
==
NULL
&&
terrno
!=
0
)
{
pTaskInfo
->
code
=
terrno
;
return
NULL
;
...
...
@@ -4045,10 +4044,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
if
(
pHandle
->
vnode
)
{
// for stram
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
,
pTagCond
);
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
(
uint64_t
)
queryId
,
taskId
);
}
else
{
// for tq
getTableList
(
pHandle
->
meta
,
pScanPhyNode
,
pTableListInfo
,
pTagCond
);
getTableList
(
pHandle
->
meta
,
pScanPhyNode
,
pTableListInfo
);
}
}
...
...
@@ -4076,7 +4075,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
==
type
)
{
STagScanPhysiNode
*
pScanPhyNode
=
(
STagScanPhysiNode
*
)
pPhyNode
;
int32_t
code
=
getTableList
(
pHandle
->
meta
,
pScanPhyNode
,
pTableListInfo
,
pScanPhyNode
->
node
.
pConditions
);
int32_t
code
=
getTableList
(
pHandle
->
meta
,
pScanPhyNode
,
pTableListInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pTaskInfo
->
code
=
terrno
;
return
NULL
;
...
...
@@ -4134,7 +4133,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SOperatorInfo
**
ops
=
taosMemoryCalloc
(
size
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
i
);
ops
[
i
]
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableListInfo
,
pTagCond
);
ops
[
i
]
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableListInfo
);
if
(
ops
[
i
]
==
NULL
)
{
return
NULL
;
}
...
...
@@ -4338,8 +4337,8 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
}
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
)
{
int32_t
code
=
getTableList
(
pHandle
->
meta
,
&
pTableScanNode
->
scan
,
pTableListInfo
,
pTagCond
);
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
int32_t
code
=
getTableList
(
pHandle
->
meta
,
&
pTableScanNode
->
scan
,
pTableListInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -4497,8 +4496,10 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
}
(
*
pTaskInfo
)
->
sql
=
sql
;
(
*
pTaskInfo
)
->
tableqinfoList
.
pTagCond
=
pPlan
->
pTagCond
;
(
*
pTaskInfo
)
->
tableqinfoList
.
pTagIndexCond
=
pPlan
->
pTagIndexCond
;
(
*
pTaskInfo
)
->
pRoot
=
createOperatorTree
(
pPlan
->
pNode
,
*
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
&
(
*
pTaskInfo
)
->
tableqinfoList
,
pPlan
->
pTagCond
);
&
(
*
pTaskInfo
)
->
tableqinfoList
);
if
(
NULL
==
(
*
pTaskInfo
)
->
pRoot
)
{
code
=
(
*
pTaskInfo
)
->
code
;
goto
_complete
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
90128345
...
...
@@ -337,7 +337,7 @@ void addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_
}
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
colDataAppend
(
pColInfoData
,
i
,
data
,
(
data
==
NULL
));
colDataAppend
(
pColInfoData
,
i
,
data
,
(
data
==
NULL
)
||
(
pColInfoData
->
info
.
type
==
TSDB_DATA_TYPE_JSON
&&
tTagIsJsonNull
(
data
))
);
}
if
(
data
&&
(
pColInfoData
->
info
.
type
!=
TSDB_DATA_TYPE_JSON
)
&&
p
!=
NULL
&&
...
...
@@ -1829,7 +1829,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
}
else
{
data
=
(
char
*
)
p
;
}
colDataAppend
(
pDst
,
count
,
data
,
(
data
==
NULL
));
colDataAppend
(
pDst
,
count
,
data
,
(
data
==
NULL
)
||
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_JSON
&&
tTagIsJsonNull
(
data
))
);
if
(
pDst
->
info
.
type
!=
TSDB_DATA_TYPE_JSON
&&
p
!=
NULL
&&
IS_VAR_DATA_TYPE
(((
const
STagVal
*
)
p
)
->
type
)
&&
data
!=
NULL
)
{
...
...
@@ -1852,9 +1852,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) {
}
pRes
->
info
.
rows
=
count
;
doFilter
(
pInfo
->
pFilterNode
,
pRes
);
pOperator
->
resultInfo
.
totalRows
+=
pRes
->
info
.
rows
;
pOperator
->
resultInfo
.
totalRows
+=
count
;
return
(
pRes
->
info
.
rows
==
0
)
?
NULL
:
pInfo
->
pRes
;
}
...
...
@@ -1884,13 +1882,11 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
goto
_error
;
}
pInfo
->
pTableList
=
pTableListInfo
;
pInfo
->
pColMatchInfo
=
colList
;
pInfo
->
pRes
=
createResDataBlock
(
pDescNode
);
pInfo
->
readHandle
=
*
pReadHandle
;
pInfo
->
curPos
=
0
;
pInfo
->
pFilterNode
=
pPhyNode
->
node
.
pConditions
;
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
;
...
...
@@ -1973,7 +1969,7 @@ int32_t compareTableKeyInfoByGid(const void* p1, const void* p2) {
int32_t
createScanTableListInfo
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableListInfo
*
pTableListInfo
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
)
{
int32_t
code
=
getTableList
(
pHandle
->
meta
,
&
pTableScanNode
->
scan
,
pTableListInfo
,
pTagCond
);
int32_t
code
=
getTableList
(
pHandle
->
meta
,
&
pTableScanNode
->
scan
,
pTableListInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
90128345
...
...
@@ -351,6 +351,7 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
COPY_SCALAR_FIELD
(
intervalUnit
);
COPY_SCALAR_FIELD
(
slidingUnit
);
CLONE_NODE_FIELD
(
pTagCond
);
CLONE_NODE_FIELD
(
pTagIndexCond
);
COPY_SCALAR_FIELD
(
triggerType
);
COPY_SCALAR_FIELD
(
watermark
);
COPY_SCALAR_FIELD
(
tsColId
);
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
90128345
...
...
@@ -2326,6 +2326,7 @@ static const char* jkSubplanNodeAddr = "NodeAddr";
static
const
char
*
jkSubplanRootNode
=
"RootNode"
;
static
const
char
*
jkSubplanDataSink
=
"DataSink"
;
static
const
char
*
jkSubplanTagCond
=
"TagCond"
;
static
const
char
*
jkSubplanTagIndexCond
=
"TagIndexCond"
;
static
int32_t
subplanToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SSubplan
*
pNode
=
(
const
SSubplan
*
)
pObj
;
...
...
@@ -2355,6 +2356,9 @@ static int32_t subplanToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkSubplanTagCond
,
nodeToJson
,
pNode
->
pTagCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkSubplanTagIndexCond
,
nodeToJson
,
pNode
->
pTagIndexCond
);
}
return
code
;
}
...
...
@@ -2388,6 +2392,9 @@ static int32_t jsonToSubplan(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkSubplanTagCond
,
(
SNode
**
)
&
pNode
->
pTagCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkSubplanTagIndexCond
,
(
SNode
**
)
&
pNode
->
pTagIndexCond
);
}
return
code
;
}
...
...
@@ -3954,7 +3961,7 @@ static int32_t deleteStmtToJson(const void* pObj, SJson* pJson) {
code
=
tjsonAddObject
(
pJson
,
jkDeleteStmtCountFunc
,
nodeToJson
,
pNode
->
pCountFunc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkDeleteStmtTagIndexCond
,
nodeToJson
,
pNode
->
pTag
Index
Cond
);
code
=
tjsonAddObject
(
pJson
,
jkDeleteStmtTagIndexCond
,
nodeToJson
,
pNode
->
pTagCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkDeleteStmtTimeRangeStartKey
,
pNode
->
timeRange
.
skey
);
...
...
@@ -3983,7 +3990,7 @@ static int32_t jsonToDeleteStmt(const SJson* pJson, void* pObj) {
code
=
jsonToNodeObject
(
pJson
,
jkDeleteStmtCountFunc
,
&
pNode
->
pCountFunc
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkDeleteStmtTagIndexCond
,
&
pNode
->
pTag
Index
Cond
);
code
=
jsonToNodeObject
(
pJson
,
jkDeleteStmtTagIndexCond
,
&
pNode
->
pTagCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkDeleteStmtTimeRangeStartKey
,
&
pNode
->
timeRange
.
skey
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
90128345
...
...
@@ -669,7 +669,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pStmt
->
pFromTable
);
nodesDestroyNode
(
pStmt
->
pWhere
);
nodesDestroyNode
(
pStmt
->
pCountFunc
);
nodesDestroyNode
(
pStmt
->
pTag
Index
Cond
);
nodesDestroyNode
(
pStmt
->
pTagCond
);
break
;
}
case
QUERY_NODE_QUERY
:
{
...
...
@@ -688,7 +688,13 @@ void nodesDestroyNode(SNode* pNode) {
SScanLogicNode
*
pLogicNode
=
(
SScanLogicNode
*
)
pNode
;
destroyLogicNode
((
SLogicNode
*
)
pLogicNode
);
nodesDestroyList
(
pLogicNode
->
pScanCols
);
nodesDestroyList
(
pLogicNode
->
pScanPseudoCols
);
taosMemoryFreeClear
(
pLogicNode
->
pVgroupList
);
nodesDestroyList
(
pLogicNode
->
pDynamicScanFuncs
);
nodesDestroyNode
(
pLogicNode
->
pTagCond
);
nodesDestroyNode
(
pLogicNode
->
pTagIndexCond
);
taosArrayDestroy
(
pLogicNode
->
pSmaIndexes
);
nodesDestroyList
(
pLogicNode
->
pPartTags
);
break
;
}
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
{
...
...
@@ -897,6 +903,8 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyList
(
pSubplan
->
pChildren
);
nodesDestroyNode
((
SNode
*
)
pSubplan
->
pNode
);
nodesDestroyNode
((
SNode
*
)
pSubplan
->
pDataSink
);
nodesDestroyNode
((
SNode
*
)
pSubplan
->
pTagCond
);
nodesDestroyNode
((
SNode
*
)
pSubplan
->
pTagIndexCond
);
nodesClearList
(
pSubplan
->
pParents
);
break
;
}
...
...
@@ -1130,6 +1138,7 @@ void* nodesGetValueFromNode(SValueNode* pNode) {
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
case
TSDB_DATA_TYPE_JSON
:
return
(
void
*
)
pNode
->
datum
.
p
;
default:
break
;
...
...
@@ -1659,6 +1668,7 @@ int32_t nodesMergeConds(SNode** pDst, SNodeList** pSrc) {
typedef
struct
SClassifyConditionCxt
{
bool
hasPrimaryKey
;
bool
hasTagIndexCol
;
bool
hasTagCol
;
bool
hasOtherCol
;
}
SClassifyConditionCxt
;
...
...
@@ -1670,6 +1680,9 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
pCxt
->
hasPrimaryKey
=
true
;
}
else
if
(
pCol
->
hasIndex
)
{
pCxt
->
hasTagIndexCol
=
true
;
pCxt
->
hasTagCol
=
true
;
}
else
if
(
COLUMN_TYPE_TAG
==
pCol
->
colType
)
{
pCxt
->
hasTagCol
=
true
;
}
else
{
pCxt
->
hasOtherCol
=
true
;
}
...
...
@@ -1678,23 +1691,31 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
typedef
enum
EConditionType
{
COND_TYPE_PRIMARY_KEY
=
1
,
COND_TYPE_TAG_INDEX
,
COND_TYPE_NORMAL
}
EConditionType
;
typedef
enum
EConditionType
{
COND_TYPE_PRIMARY_KEY
=
1
,
COND_TYPE_TAG_INDEX
,
COND_TYPE_TAG
,
COND_TYPE_NORMAL
}
EConditionType
;
static
EConditionType
classifyCondition
(
SNode
*
pNode
)
{
SClassifyConditionCxt
cxt
=
{.
hasPrimaryKey
=
false
,
.
hasTagIndexCol
=
false
,
.
hasOtherCol
=
false
};
nodesWalkExpr
(
pNode
,
classifyConditionImpl
,
&
cxt
);
return
cxt
.
hasOtherCol
?
COND_TYPE_NORMAL
:
(
cxt
.
hasPrimaryKey
&&
cxt
.
hasTag
Index
Col
:
(
cxt
.
hasPrimaryKey
&&
cxt
.
hasTagCol
?
COND_TYPE_NORMAL
:
(
cxt
.
hasPrimaryKey
?
COND_TYPE_PRIMARY_KEY
:
COND_TYPE_TAG_INDEX
));
:
(
cxt
.
hasPrimaryKey
?
COND_TYPE_PRIMARY_KEY
:
(
cxt
.
hasTagIndexCol
?
COND_TYPE_TAG_INDEX
:
COND_TYPE_TAG
)));
}
static
int32_t
partitionLogicCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
static
int32_t
partitionLogicCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagIndexCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
SLogicConditionNode
*
pLogicCond
=
(
SLogicConditionNode
*
)(
*
pCondition
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNodeList
*
pPrimaryKeyConds
=
NULL
;
SNodeList
*
pTagIndexConds
=
NULL
;
SNodeList
*
pTagConds
=
NULL
;
SNodeList
*
pOtherConds
=
NULL
;
SNode
*
pCond
=
NULL
;
...
...
@@ -1706,6 +1727,14 @@ static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, S
}
break
;
case
COND_TYPE_TAG_INDEX
:
if
(
NULL
!=
pTagIndexCond
)
{
code
=
nodesListMakeAppend
(
&
pTagIndexConds
,
nodesCloneNode
(
pCond
));
}
if
(
NULL
!=
pTagCond
)
{
code
=
nodesListMakeAppend
(
&
pTagConds
,
nodesCloneNode
(
pCond
));
}
break
;
case
COND_TYPE_TAG
:
if
(
NULL
!=
pTagCond
)
{
code
=
nodesListMakeAppend
(
&
pTagConds
,
nodesCloneNode
(
pCond
));
}
...
...
@@ -1723,11 +1752,15 @@ static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, S
}
SNode
*
pTempPrimaryKeyCond
=
NULL
;
SNode
*
pTempTagIndexCond
=
NULL
;
SNode
*
pTempTagCond
=
NULL
;
SNode
*
pTempOtherCond
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesMergeConds
(
&
pTempPrimaryKeyCond
,
&
pPrimaryKeyConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesMergeConds
(
&
pTempTagIndexCond
,
&
pTagIndexConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesMergeConds
(
&
pTempTagCond
,
&
pTagConds
);
}
...
...
@@ -1739,6 +1772,9 @@ static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, S
if
(
NULL
!=
pPrimaryKeyCond
)
{
*
pPrimaryKeyCond
=
pTempPrimaryKeyCond
;
}
if
(
NULL
!=
pTagIndexCond
)
{
*
pTagIndexCond
=
pTempTagIndexCond
;
}
if
(
NULL
!=
pTagCond
)
{
*
pTagCond
=
pTempTagCond
;
}
...
...
@@ -1749,9 +1785,11 @@ static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, S
*
pCondition
=
NULL
;
}
else
{
nodesDestroyList
(
pPrimaryKeyConds
);
nodesDestroyList
(
pTagIndexConds
);
nodesDestroyList
(
pTagConds
);
nodesDestroyList
(
pOtherConds
);
nodesDestroyNode
(
pTempPrimaryKeyCond
);
nodesDestroyNode
(
pTempTagIndexCond
);
nodesDestroyNode
(
pTempTagCond
);
nodesDestroyNode
(
pTempOtherCond
);
}
...
...
@@ -1759,10 +1797,11 @@ static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, S
return
code
;
}
int32_t
nodesPartitionCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
int32_t
nodesPartitionCond
(
SNode
**
pCondition
,
SNode
**
pPrimaryKeyCond
,
SNode
**
pTagIndexCond
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
*
pCondition
)
&&
LOGIC_COND_TYPE_AND
==
((
SLogicConditionNode
*
)
*
pCondition
)
->
condType
)
{
return
partitionLogicCond
(
pCondition
,
pPrimaryKeyCond
,
pTagCond
,
pOtherCond
);
return
partitionLogicCond
(
pCondition
,
pPrimaryKeyCond
,
pTag
IndexCond
,
pTag
Cond
,
pOtherCond
);
}
switch
(
classifyCondition
(
*
pCondition
))
{
...
...
@@ -1772,6 +1811,21 @@ int32_t nodesPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode**
}
break
;
case
COND_TYPE_TAG_INDEX
:
if
(
NULL
!=
pTagIndexCond
)
{
*
pTagIndexCond
=
*
pCondition
;
}
if
(
NULL
!=
pTagCond
)
{
SNode
*
pTempCond
=
*
pCondition
;
if
(
NULL
!=
pTagIndexCond
)
{
pTempCond
=
nodesCloneNode
(
*
pCondition
);
if
(
NULL
==
pTempCond
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
*
pTagCond
=
pTempCond
;
}
break
;
case
COND_TYPE_TAG
:
if
(
NULL
!=
pTagCond
)
{
*
pTagCond
=
*
pCondition
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
90128345
...
...
@@ -2013,7 +2013,7 @@ static int32_t getFillTimeRange(STranslateContext* pCxt, SNode* pWhere, STimeWin
}
SNode
*
pPrimaryKeyCond
=
NULL
;
nodesPartitionCond
(
&
pCond
,
&
pPrimaryKeyCond
,
NULL
,
NULL
);
nodesPartitionCond
(
&
pCond
,
&
pPrimaryKeyCond
,
NULL
,
NULL
,
NULL
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
NULL
!=
pPrimaryKeyCond
)
{
...
...
@@ -2682,7 +2682,7 @@ static int32_t partitionDeleteWhere(STranslateContext* pCxt, SDeleteStmt* pDelet
SNode
*
pPrimaryKeyCond
=
NULL
;
SNode
*
pOtherCond
=
NULL
;
int32_t
code
=
nodesPartitionCond
(
&
pDelete
->
pWhere
,
&
pPrimaryKeyCond
,
&
pDelete
->
pTagIndex
Cond
,
&
pOtherCond
);
int32_t
code
=
nodesPartitionCond
(
&
pDelete
->
pWhere
,
&
pPrimaryKeyCond
,
NULL
,
&
pDelete
->
pTag
Cond
,
&
pOtherCond
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pOtherCond
)
{
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_DELETE_WHERE
);
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
90128345
...
...
@@ -1160,8 +1160,8 @@ static int32_t createDeleteScanLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* p
}
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pDelete
->
pTag
Index
Cond
)
{
pScan
->
pTagCond
=
nodesCloneNode
(
pDelete
->
pTag
Index
Cond
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pDelete
->
pTagCond
)
{
pScan
->
pTagCond
=
nodesCloneNode
(
pDelete
->
pTagCond
);
if
(
NULL
==
pScan
->
pTagCond
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
90128345
...
...
@@ -15,7 +15,6 @@
#include "filter.h"
#include "functionMgt.h"
#include "index.h"
#include "planInt.h"
#include "ttime.h"
...
...
@@ -309,32 +308,6 @@ static int32_t cpdCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, S
return
code
;
}
static
int32_t
cpdApplyTagIndex
(
SScanLogicNode
*
pScan
,
SNode
**
pTagCond
,
SNode
**
pOtherCond
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SIdxFltStatus
idxStatus
=
idxGetFltStatus
(
*
pTagCond
);
switch
(
idxStatus
)
{
case
SFLT_NOT_INDEX
:
code
=
cpdCondAppend
(
pOtherCond
,
pTagCond
);
break
;
case
SFLT_COARSE_INDEX
:
pScan
->
pTagCond
=
nodesCloneNode
(
*
pTagCond
);
if
(
NULL
==
pScan
->
pTagCond
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
break
;
}
code
=
cpdCondAppend
(
pOtherCond
,
pTagCond
);
break
;
case
SFLT_ACCURATE_INDEX
:
pScan
->
pTagCond
=
*
pTagCond
;
*
pTagCond
=
NULL
;
break
;
default:
code
=
TSDB_CODE_FAILED
;
break
;
}
return
code
;
}
static
int32_t
cpdOptimizeScanCondition
(
SOptimizeContext
*
pCxt
,
SScanLogicNode
*
pScan
)
{
if
(
NULL
==
pScan
->
node
.
pConditions
||
OPTIMIZE_FLAG_TEST_MASK
(
pScan
->
node
.
optimizedFlag
,
OPTIMIZE_FLAG_CPD
)
||
TSDB_SYSTEM_TABLE
==
pScan
->
tableType
)
{
...
...
@@ -342,15 +315,12 @@ static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode*
}
SNode
*
pPrimaryKeyCond
=
NULL
;
SNode
*
pTagCond
=
NULL
;
SNode
*
pOtherCond
=
NULL
;
int32_t
code
=
nodesPartitionCond
(
&
pScan
->
node
.
pConditions
,
&
pPrimaryKeyCond
,
&
pTagCond
,
&
pOtherCond
);
int32_t
code
=
nodesPartitionCond
(
&
pScan
->
node
.
pConditions
,
&
pPrimaryKeyCond
,
&
pScan
->
pTagIndexCond
,
&
pScan
->
pTagCond
,
&
pOtherCond
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pPrimaryKeyCond
)
{
code
=
cpdCalcTimeRange
(
pCxt
,
pScan
,
&
pPrimaryKeyCond
,
&
pOtherCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pTagCond
)
{
code
=
cpdApplyTagIndex
(
pScan
,
&
pTagCond
,
&
pOtherCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pScan
->
node
.
pConditions
=
pOtherCond
;
}
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
90128345
...
...
@@ -436,6 +436,15 @@ static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SSubplan* pS
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
NULL
!=
pScanLogicNode
->
pTagIndexCond
)
{
pSubplan
->
pTagIndexCond
=
nodesCloneNode
(
pScanLogicNode
->
pTagIndexCond
);
if
(
NULL
==
pSubplan
->
pTagIndexCond
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pPhyNode
=
(
SPhysiNode
*
)
pScanPhysiNode
;
}
else
{
...
...
source/libs/planner/test/planOptimizeTest.cpp
浏览文件 @
90128345
...
...
@@ -40,6 +40,8 @@ TEST_F(PlanOptimizeTest, ConditionPushDown) {
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 or tag1 < 2"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello'"
);
run
(
"SELECT ts, c1 FROM st1 WHERE tag1 > 4 AND tag2 = 'hello' AND c1 > 10"
);
}
TEST_F
(
PlanOptimizeTest
,
orderByPrimaryKey
)
{
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
90128345
...
...
@@ -23,6 +23,7 @@
#include "sclvector.h"
#include "tcompare.h"
#include "tdatablock.h"
#include "tdataformat.h"
#include "ttypes.h"
#include "ttime.h"
...
...
@@ -506,6 +507,16 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
}
}
// if types can not comparable
if
((
IS_NUMERIC_TYPE
(
typeLeft
)
&&
!
IS_NUMERIC_TYPE
(
typeRight
))
||
(
IS_NUMERIC_TYPE
(
typeRight
)
&&
!
IS_NUMERIC_TYPE
(
typeLeft
))
||
(
IS_VAR_DATA_TYPE
(
typeLeft
)
&&
!
IS_VAR_DATA_TYPE
(
typeRight
))
||
(
IS_VAR_DATA_TYPE
(
typeRight
)
&&
!
IS_VAR_DATA_TYPE
(
typeLeft
))
||
((
typeLeft
==
TSDB_DATA_TYPE_BOOL
)
&&
(
typeRight
!=
TSDB_DATA_TYPE_BOOL
))
||
((
typeRight
==
TSDB_DATA_TYPE_BOOL
)
&&
(
typeLeft
!=
TSDB_DATA_TYPE_BOOL
)))
return
false
;
if
(
typeLeft
==
TSDB_DATA_TYPE_NULL
||
typeRight
==
TSDB_DATA_TYPE_NULL
){
*
isNull
=
true
;
return
true
;
...
...
@@ -519,24 +530,28 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
*
fp
=
filterGetCompFunc
(
type
,
optr
);
if
(
IS_NUMERIC_TYPE
(
type
)
||
IS_FLOAT_TYPE
(
type
)
){
if
(
IS_NUMERIC_TYPE
(
type
)){
if
(
typeLeft
==
TSDB_DATA_TYPE_NCHAR
)
{
convertNcharToDouble
(
*
pLeftData
,
pLeftOut
);
*
pLeftData
=
pLeftOut
;
ASSERT
(
0
);
// convertNcharToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
}
else
if
(
typeLeft
==
TSDB_DATA_TYPE_BINARY
)
{
convertBinaryToDouble
(
*
pLeftData
,
pLeftOut
);
*
pLeftData
=
pLeftOut
;
ASSERT
(
0
);
// convertBinaryToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
}
else
if
(
typeLeft
!=
type
)
{
convertNumberToNumber
(
*
pLeftData
,
pLeftOut
,
typeLeft
,
type
);
*
pLeftData
=
pLeftOut
;
}
if
(
typeRight
==
TSDB_DATA_TYPE_NCHAR
)
{
convertNcharToDouble
(
*
pRightData
,
pRightOut
);
*
pRightData
=
pRightOut
;
ASSERT
(
0
);
// convertNcharToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
}
else
if
(
typeRight
==
TSDB_DATA_TYPE_BINARY
)
{
convertBinaryToDouble
(
*
pRightData
,
pRightOut
);
*
pRightData
=
pRightOut
;
ASSERT
(
0
);
// convertBinaryToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
}
else
if
(
typeRight
!=
type
)
{
convertNumberToNumber
(
*
pRightData
,
pRightOut
,
typeRight
,
type
);
*
pRightData
=
pRightOut
;
...
...
@@ -1693,6 +1708,13 @@ void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
STagVal
getJsonValue
(
char
*
json
,
char
*
key
,
bool
*
isExist
)
{
STagVal
val
=
{.
pKey
=
key
};
if
(
tTagIsJson
((
const
STag
*
)
json
)
==
false
){
if
(
isExist
){
*
isExist
=
false
;
}
return
val
;
}
bool
find
=
tTagGet
(((
const
STag
*
)
json
),
&
val
);
// json value is null and not exist is different
if
(
isExist
){
*
isExist
=
find
;
...
...
tests/system-test/2-query/json_tag.py
浏览文件 @
90128345
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录