Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
60e9fe1f
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看板
提交
60e9fe1f
编写于
10月 28, 2021
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support join for json tag
上级
80837f39
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
27 deletion
+29
-27
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+19
-18
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+8
-8
src/util/src/tcompare.c
src/util/src/tcompare.c
+2
-1
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
60e9fe1f
...
...
@@ -620,16 +620,21 @@ static int32_t tscLaunchRealSubqueries(SSqlObj* pSql) {
// set the join condition tag column info, todo extract method
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
assert
(
pQueryInfo
->
tagCond
.
joinInfo
.
hasJoin
);
pExpr
->
base
.
numOfParams
=
0
;
// the value is 0 by default. just make sure.
// add json tag key, if there is no json tag key, just hold place.
tVariantCreateFromBinary
(
&
(
pExpr
->
base
.
param
[
pExpr
->
base
.
numOfParams
]),
pQueryInfo
->
tagCond
.
joinInfo
.
joinTables
[
0
]
->
tagJsonKeyName
,
strlen
(
pQueryInfo
->
tagCond
.
joinInfo
.
joinTables
[
0
]
->
tagJsonKeyName
),
TSDB_DATA_TYPE_BINARY
);
pExpr
->
base
.
numOfParams
++
;
int16_t
colId
=
tscGetJoinTagColIdByUid
(
&
pQueryInfo
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
);
// set the tag column id for executor to extract correct tag value
tVariant
*
pVariant
=
&
pExpr
->
base
.
param
[
0
];
tVariant
*
pVariant
=
&
pExpr
->
base
.
param
[
pExpr
->
base
.
numOfParams
];
pVariant
->
i64
=
colId
;
pVariant
->
nType
=
TSDB_DATA_TYPE_BIGINT
;
pVariant
->
nLen
=
sizeof
(
int64_t
);
pExpr
->
base
.
numOfParams
=
1
;
pExpr
->
base
.
numOfParams
++
;
}
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
...
...
@@ -808,16 +813,21 @@ static void issueTsCompQuery(SSqlObj* pSql, SJoinSupporter* pSupporter, SSqlObj*
SSchema
colSchema
=
{.
type
=
TSDB_DATA_TYPE_BINARY
,
.
bytes
=
1
};
SColumnIndex
index
=
{
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
tscAddFuncInSelectClause
(
pQueryInfo
,
0
,
TSDB_FUNC_TS_COMP
,
&
index
,
&
colSchema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
SExprInfo
*
pExpr
=
tscAddFuncInSelectClause
(
pQueryInfo
,
0
,
TSDB_FUNC_TS_COMP
,
&
index
,
&
colSchema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
// set the tags value for ts_comp function
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
SExprInfo
*
pExpr
=
tscExprGet
(
pQueryInfo
,
0
);
int16_t
tagColId
=
tscGetJoinTagColIdByUid
(
&
pSupporter
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
);
pExpr
->
base
.
param
[
0
].
i64
=
tagColId
;
pExpr
->
base
.
param
[
0
].
nLen
=
sizeof
(
int64_t
);
pExpr
->
base
.
param
[
0
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
pExpr
->
base
.
numOfParams
=
1
;
pExpr
->
base
.
numOfParams
=
0
;
// the value is 0 by default. just make sure.
// add json tag key, if there is no json tag key, just hold place.
tVariantCreateFromBinary
(
&
(
pExpr
->
base
.
param
[
pExpr
->
base
.
numOfParams
]),
pSupporter
->
tagCond
.
joinInfo
.
joinTables
[
0
]
->
tagJsonKeyName
,
strlen
(
pSupporter
->
tagCond
.
joinInfo
.
joinTables
[
0
]
->
tagJsonKeyName
),
TSDB_DATA_TYPE_BINARY
);
pExpr
->
base
.
numOfParams
++
;
int16_t
tagColId
=
tscGetJoinTagColIdByUid
(
&
pSupporter
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
);
pExpr
->
base
.
param
[
pExpr
->
base
.
numOfParams
].
i64
=
tagColId
;
pExpr
->
base
.
param
[
pExpr
->
base
.
numOfParams
].
nLen
=
sizeof
(
int64_t
);
pExpr
->
base
.
param
[
pExpr
->
base
.
numOfParams
].
nType
=
TSDB_DATA_TYPE_BIGINT
;
pExpr
->
base
.
numOfParams
++
;
}
// add the filter tag column
...
...
@@ -1930,15 +1940,6 @@ int32_t tscCreateJoinSubquery(SSqlObj *pSql, int16_t tableIndex, SJoinSupporter
SColumnIndex
colIndex
=
{
0
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
};
tscAddFuncInSelectClause
(
pNewQueryInfo
,
0
,
TSDB_FUNC_TS_COMP
,
&
colIndex
,
&
colSchema
,
TSDB_COL_NORMAL
,
getNewResColId
(
pCmd
));
// set the tags value for ts_comp function
SExprInfo
*
pExpr
=
tscExprGet
(
pNewQueryInfo
,
0
);
if
(
UTIL_TABLE_IS_SUPER_TABLE
(
pTableMetaInfo
))
{
int16_t
tagColId
=
tscGetJoinTagColIdByUid
(
&
pSupporter
->
tagCond
,
pTableMetaInfo
->
pTableMeta
->
id
.
uid
);
pExpr
->
base
.
param
->
i64
=
tagColId
;
pExpr
->
base
.
numOfParams
=
1
;
}
// add the filter tag column
if
(
pSupporter
->
colList
!=
NULL
)
{
size_t
s
=
taosArrayGetSize
(
pSupporter
->
colList
);
...
...
src/query/src/qExecutor.c
浏览文件 @
60e9fe1f
...
...
@@ -3398,10 +3398,10 @@ void setTagValue(SOperatorInfo* pOperatorInfo, void *pTable, SQLFunctionCtx* pCt
SQueryAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
SExprInfo
*
pExprInfo
=
&
pExpr
[
0
];
if
(
pQueryAttr
->
numOfOutput
==
1
&&
pExprInfo
->
base
.
functionId
==
TSDB_FUNC_TS_COMP
&&
pQueryAttr
->
stableQuery
)
{
assert
(
pExprInfo
->
base
.
numOfParams
==
1
);
if
(
pQueryAttr
->
numOfOutput
==
2
&&
pExprInfo
->
base
.
functionId
==
TSDB_FUNC_TS_COMP
&&
pQueryAttr
->
stableQuery
)
{
assert
(
pExprInfo
->
base
.
numOfParams
==
2
);
int16_t
tagColId
=
(
int16_t
)
pExprInfo
->
base
.
param
[
0
].
i64
;
int16_t
tagColId
=
(
int16_t
)
pExprInfo
->
base
.
param
[
1
].
i64
;
SColumnInfo
*
pColInfo
=
doGetTagColumnInfoById
(
pQueryAttr
->
tagColList
,
pQueryAttr
->
numOfTags
,
tagColId
);
GET_JSON_KEY
(
pExprInfo
)
doSetTagValueInParam
(
pTable
,
param
,
paramLen
,
tagColId
,
&
pCtx
[
0
].
tag
,
pColInfo
->
type
,
pColInfo
->
bytes
);
...
...
@@ -4019,21 +4019,21 @@ void setCtxTagForJoin(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, SExpr
if
(
pQueryAttr
->
stableQuery
&&
(
pRuntimeEnv
->
pTsBuf
!=
NULL
)
&&
(
pExpr
->
functionId
==
TSDB_FUNC_TS
||
pExpr
->
functionId
==
TSDB_FUNC_PRJ
)
&&
(
pExpr
->
colInfo
.
colIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
))
{
assert
(
pExpr
->
numOfParams
==
1
);
assert
(
pExpr
->
numOfParams
==
2
);
int16_t
tagColId
=
(
int16_t
)
pExprInfo
->
base
.
param
[
0
].
i64
;
int16_t
tagColId
=
(
int16_t
)
pExprInfo
->
base
.
param
[
1
].
i64
;
SColumnInfo
*
pColInfo
=
doGetTagColumnInfoById
(
pQueryAttr
->
tagColList
,
pQueryAttr
->
numOfTags
,
tagColId
);
GET_JSON_KEY
(
pExprInfo
)
doSetTagValueInParam
(
pTable
,
param
,
paramLen
,
tagColId
,
&
pCtx
->
tag
,
pColInfo
->
type
,
pColInfo
->
bytes
);
int16_t
tagType
=
pCtx
[
0
].
tag
.
nType
;
if
(
tagType
==
TSDB_DATA_TYPE_BINARY
||
tagType
==
TSDB_DATA_TYPE_NCHAR
)
{
if
(
tagType
==
TSDB_DATA_TYPE_BINARY
||
tagType
==
TSDB_DATA_TYPE_NCHAR
||
tagType
==
TSDB_DATA_TYPE_JSON
)
{
qDebug
(
"QInfo:0x%"
PRIx64
" set tag value for join comparison, colId:%"
PRId64
", val:%s"
,
GET_QID
(
pRuntimeEnv
),
pExprInfo
->
base
.
param
[
0
].
i64
,
pCtx
[
0
].
tag
.
pz
);
pExprInfo
->
base
.
param
[
1
].
i64
,
pCtx
[
0
].
tag
.
pz
);
}
else
{
qDebug
(
"QInfo:0x%"
PRIx64
" set tag value for join comparison, colId:%"
PRId64
", val:%"
PRId64
,
GET_QID
(
pRuntimeEnv
),
pExprInfo
->
base
.
param
[
0
].
i64
,
pCtx
[
0
].
tag
.
i64
);
pExprInfo
->
base
.
param
[
1
].
i64
,
pCtx
[
0
].
tag
.
i64
);
}
}
}
...
...
src/util/src/tcompare.c
浏览文件 @
60e9fe1f
...
...
@@ -581,7 +581,8 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
case
TSDB_DATA_TYPE_USMALLINT
:
DEFAULT_COMP
(
GET_UINT16_VAL
(
f1
),
GET_UINT16_VAL
(
f2
));
case
TSDB_DATA_TYPE_UINT
:
DEFAULT_COMP
(
GET_UINT32_VAL
(
f1
),
GET_UINT32_VAL
(
f2
));
case
TSDB_DATA_TYPE_UBIGINT
:
DEFAULT_COMP
(
GET_UINT64_VAL
(
f1
),
GET_UINT64_VAL
(
f2
));
case
TSDB_DATA_TYPE_NCHAR
:
{
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_JSON
:{
tstr
*
t1
=
(
tstr
*
)
f1
;
tstr
*
t2
=
(
tstr
*
)
f2
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录