Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ba056f7f
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
未验证
提交
ba056f7f
编写于
7月 05, 2022
作者:
X
Xiaoyu Wang
提交者:
GitHub
7月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14508 from taosdata/feature/3.0_debug_wxy
fix: automatically supplement primary key columns when creating stream
上级
04848095
7c5419b4
变更
20
显示空白变更内容
内联
并排
Showing
20 changed file
with
358 addition
and
201 deletion
+358
-201
source/common/src/tmsg.c
source/common/src/tmsg.c
+6
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+229
-128
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+37
-32
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+28
-0
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+2
-0
source/libs/parser/test/parInitialATest.cpp
source/libs/parser/test/parInitialATest.cpp
+2
-2
source/libs/parser/test/parInitialCTest.cpp
source/libs/parser/test/parInitialCTest.cpp
+41
-22
tests/system-test/2-query/abs.py
tests/system-test/2-query/abs.py
+1
-1
tests/system-test/2-query/distribute_agg_apercentile.py
tests/system-test/2-query/distribute_agg_apercentile.py
+1
-1
tests/system-test/2-query/distribute_agg_avg.py
tests/system-test/2-query/distribute_agg_avg.py
+1
-1
tests/system-test/2-query/distribute_agg_count.py
tests/system-test/2-query/distribute_agg_count.py
+1
-1
tests/system-test/2-query/distribute_agg_max.py
tests/system-test/2-query/distribute_agg_max.py
+1
-1
tests/system-test/2-query/distribute_agg_min.py
tests/system-test/2-query/distribute_agg_min.py
+1
-1
tests/system-test/2-query/distribute_agg_spread.py
tests/system-test/2-query/distribute_agg_spread.py
+1
-1
tests/system-test/2-query/distribute_agg_stddev.py
tests/system-test/2-query/distribute_agg_stddev.py
+1
-1
tests/system-test/2-query/distribute_agg_sum.py
tests/system-test/2-query/distribute_agg_sum.py
+1
-1
tests/system-test/2-query/function_null.py
tests/system-test/2-query/function_null.py
+1
-1
tests/system-test/2-query/irate.py
tests/system-test/2-query/irate.py
+1
-1
tests/system-test/2-query/max.py
tests/system-test/2-query/max.py
+1
-1
tests/system-test/2-query/twa.py
tests/system-test/2-query/twa.py
+1
-1
未找到文件。
source/common/src/tmsg.c
浏览文件 @
ba056f7f
...
@@ -2687,11 +2687,13 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
...
@@ -2687,11 +2687,13 @@ int32_t tDeserializeSDbCfgRsp(void *buf, int32_t bufLen, SDbCfgRsp *pRsp) {
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
strict
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
strict
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pRsp
->
cacheLastRow
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
numOfRetensions
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
&
decoder
,
&
pRsp
->
numOfRetensions
)
<
0
)
return
-
1
;
if
(
pRsp
->
numOfRetensions
>
0
)
{
pRsp
->
pRetensions
=
taosArrayInit
(
pRsp
->
numOfRetensions
,
sizeof
(
SRetention
));
pRsp
->
pRetensions
=
taosArrayInit
(
pRsp
->
numOfRetensions
,
sizeof
(
SRetention
));
if
(
pRsp
->
pRetensions
==
NULL
)
{
if
(
pRsp
->
pRetensions
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
}
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfRetensions
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pRsp
->
numOfRetensions
;
++
i
)
{
SRetention
rentension
=
{
0
};
SRetention
rentension
=
{
0
};
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
ba056f7f
...
@@ -784,29 +784,18 @@ static int32_t parseBoolFromValueNode(STranslateContext* pCxt, SValueNode* pVal)
...
@@ -784,29 +784,18 @@ static int32_t parseBoolFromValueNode(STranslateContext* pCxt, SValueNode* pVal)
}
}
}
}
static
EDealRes
translateValueImpl
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
,
SDataType
targetDt
)
{
static
EDealRes
translateDurationValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
uint8_t
precision
=
getPrecisionFromCurrStmt
(
pCxt
->
pCurrStmt
,
targetDt
.
precision
);
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
pVal
->
node
.
resType
.
precision
=
precision
;
pVal
->
node
.
resType
.
precision
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
pVal
->
placeholderNo
>
0
||
pVal
->
isNull
)
{
return
DEAL_RES_CONTINUE
;
}
if
(
TSDB_DATA_TYPE_NULL
==
pVal
->
node
.
resType
.
type
)
{
// TODO
// pVal->node.resType = targetDt;
pVal
->
translate
=
true
;
pVal
->
isNull
=
true
;
return
DEAL_RES_CONTINUE
;
}
if
(
pVal
->
isDuration
)
{
if
(
parseNatualDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
precision
)
!=
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
}
*
(
int64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
*
(
int64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
}
else
{
return
DEAL_RES_CONTINUE
;
}
static
EDealRes
translateNormalValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
,
SDataType
targetDt
,
bool
strict
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
targetDt
.
type
)
{
switch
(
targetDt
.
type
)
{
case
TSDB_DATA_TYPE_NULL
:
break
;
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
if
(
TSDB_CODE_SUCCESS
!=
parseBoolFromValueNode
(
pCxt
,
pVal
))
{
if
(
TSDB_CODE_SUCCESS
!=
parseBoolFromValueNode
(
pCxt
,
pVal
))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
...
@@ -814,42 +803,66 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
...
@@ -814,42 +803,66 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
*
(
bool
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
b
;
*
(
bool
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
b
;
break
;
break
;
case
TSDB_DATA_TYPE_TINYINT
:
{
case
TSDB_DATA_TYPE_TINYINT
:
{
pVal
->
datum
.
i
=
taosStr2Int64
(
pVal
->
literal
,
NULL
,
10
);
code
=
toInteger
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
10
,
&
pVal
->
datum
.
i
);
if
(
strict
&&
(
TSDB_CODE_SUCCESS
!=
code
||
!
IS_VALID_TINYINT
(
pVal
->
datum
.
i
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
int8_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
*
(
int8_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
break
;
}
}
case
TSDB_DATA_TYPE_SMALLINT
:
{
case
TSDB_DATA_TYPE_SMALLINT
:
{
pVal
->
datum
.
i
=
taosStr2Int64
(
pVal
->
literal
,
NULL
,
10
);
code
=
toInteger
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
10
,
&
pVal
->
datum
.
i
);
if
(
strict
&&
(
TSDB_CODE_SUCCESS
!=
code
||
!
IS_VALID_SMALLINT
(
pVal
->
datum
.
i
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
int16_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
*
(
int16_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
break
;
}
}
case
TSDB_DATA_TYPE_INT
:
{
case
TSDB_DATA_TYPE_INT
:
{
pVal
->
datum
.
i
=
taosStr2Int64
(
pVal
->
literal
,
NULL
,
10
);
code
=
toInteger
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
10
,
&
pVal
->
datum
.
i
);
if
(
strict
&&
(
TSDB_CODE_SUCCESS
!=
code
||
!
IS_VALID_INT
(
pVal
->
datum
.
i
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
int32_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
*
(
int32_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
break
;
}
}
case
TSDB_DATA_TYPE_BIGINT
:
{
case
TSDB_DATA_TYPE_BIGINT
:
{
pVal
->
datum
.
i
=
taosStr2Int64
(
pVal
->
literal
,
NULL
,
10
);
code
=
toInteger
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
10
,
&
pVal
->
datum
.
i
);
if
(
strict
&&
(
TSDB_CODE_SUCCESS
!=
code
||
!
IS_VALID_BIGINT
(
pVal
->
datum
.
i
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
int64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
*
(
int64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
i
;
break
;
break
;
}
}
case
TSDB_DATA_TYPE_UTINYINT
:
{
case
TSDB_DATA_TYPE_UTINYINT
:
{
pVal
->
datum
.
u
=
taosStr2UInt64
(
pVal
->
literal
,
NULL
,
10
);
code
=
toUInteger
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
10
,
&
pVal
->
datum
.
u
);
if
(
strict
&&
(
TSDB_CODE_SUCCESS
!=
code
||
!
IS_VALID_UTINYINT
(
pVal
->
datum
.
i
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
uint8_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
*
(
uint8_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
break
;
break
;
}
}
case
TSDB_DATA_TYPE_USMALLINT
:
{
case
TSDB_DATA_TYPE_USMALLINT
:
{
pVal
->
datum
.
u
=
taosStr2UInt64
(
pVal
->
literal
,
NULL
,
10
);
code
=
toUInteger
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
10
,
&
pVal
->
datum
.
u
);
if
(
strict
&&
(
TSDB_CODE_SUCCESS
!=
code
||
!
IS_VALID_USMALLINT
(
pVal
->
datum
.
i
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
uint16_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
*
(
uint16_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
break
;
break
;
}
}
case
TSDB_DATA_TYPE_UINT
:
{
case
TSDB_DATA_TYPE_UINT
:
{
pVal
->
datum
.
u
=
taosStr2UInt64
(
pVal
->
literal
,
NULL
,
10
);
code
=
toUInteger
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
10
,
&
pVal
->
datum
.
u
);
if
(
strict
&&
(
TSDB_CODE_SUCCESS
!=
code
||
!
IS_VALID_UINT
(
pVal
->
datum
.
i
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
uint32_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
*
(
uint32_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
break
;
break
;
}
}
case
TSDB_DATA_TYPE_UBIGINT
:
{
case
TSDB_DATA_TYPE_UBIGINT
:
{
pVal
->
datum
.
u
=
taosStr2UInt64
(
pVal
->
literal
,
NULL
,
10
);
code
=
toUInteger
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
10
,
&
pVal
->
datum
.
u
);
if
(
strict
&&
(
TSDB_CODE_SUCCESS
!=
code
||
!
IS_VALID_UBIGINT
(
pVal
->
datum
.
i
)))
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
*
(
uint64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
*
(
uint64_t
*
)
&
pVal
->
typeData
=
pVal
->
datum
.
u
;
break
;
break
;
}
}
...
@@ -901,10 +914,33 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
...
@@ -901,10 +914,33 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD
default:
default:
break
;
break
;
}
}
return
DEAL_RES_CONTINUE
;
}
static
EDealRes
translateValueImpl
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
,
SDataType
targetDt
,
bool
strict
)
{
if
(
pVal
->
placeholderNo
>
0
||
pVal
->
isNull
)
{
return
DEAL_RES_CONTINUE
;
}
}
pVal
->
node
.
resType
=
targetDt
;
if
(
TSDB_DATA_TYPE_NULL
==
pVal
->
node
.
resType
.
type
)
{
// TODO
// pVal->node.resType = targetDt;
pVal
->
translate
=
true
;
pVal
->
translate
=
true
;
pVal
->
isNull
=
true
;
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
pVal
->
node
.
resType
.
precision
=
getPrecisionFromCurrStmt
(
pCxt
->
pCurrStmt
,
targetDt
.
precision
);
EDealRes
res
=
DEAL_RES_CONTINUE
;
if
(
pVal
->
isDuration
)
{
res
=
translateDurationValue
(
pCxt
,
pVal
);
}
else
{
res
=
translateNormalValue
(
pCxt
,
pVal
,
targetDt
,
strict
);
}
pVal
->
node
.
resType
=
targetDt
;
pVal
->
translate
=
true
;
return
res
;
}
}
static
int32_t
calcTypeBytes
(
SDataType
dt
)
{
static
int32_t
calcTypeBytes
(
SDataType
dt
)
{
...
@@ -920,7 +956,7 @@ static int32_t calcTypeBytes(SDataType dt) {
...
@@ -920,7 +956,7 @@ static int32_t calcTypeBytes(SDataType dt) {
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
SDataType
dt
=
pVal
->
node
.
resType
;
SDataType
dt
=
pVal
->
node
.
resType
;
dt
.
bytes
=
calcTypeBytes
(
dt
);
dt
.
bytes
=
calcTypeBytes
(
dt
);
return
translateValueImpl
(
pCxt
,
pVal
,
dt
);
return
translateValueImpl
(
pCxt
,
pVal
,
dt
,
false
);
}
}
static
bool
isMultiResFunc
(
SNode
*
pNode
)
{
static
bool
isMultiResFunc
(
SNode
*
pNode
)
{
...
@@ -3216,13 +3252,30 @@ static bool validRollupFunc(const char* pFunc) {
...
@@ -3216,13 +3252,30 @@ static bool validRollupFunc(const char* pFunc) {
return
false
;
return
false
;
}
}
static
int32_t
checkTableRollupOption
(
STranslateContext
*
pCxt
,
SNodeList
*
pFuncs
)
{
static
int32_t
checkTableRollupOption
(
STranslateContext
*
pCxt
,
SNodeList
*
pFuncs
,
bool
createStable
,
SDbCfgInfo
*
pDbCfg
)
{
if
(
NULL
==
pFuncs
)
{
if
(
NULL
==
pFuncs
)
{
if
(
NULL
!=
pDbCfg
->
pRetensions
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TABLE_OPTION
,
"To create a super table in a database with the retensions parameter configured, "
"the 'ROLLUP' option must be present"
);
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
1
!=
LIST_LENGTH
(
pFuncs
)
||
!
validRollupFunc
(((
SFunctionNode
*
)
nodesListGetNode
(
pFuncs
,
0
))
->
functionName
))
{
if
(
!
createStable
||
NULL
==
pDbCfg
->
pRetensions
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TABLE_OPTION
,
"Invalid option rollup: Only supported for create super table in databases "
"configured with the 'RETENTIONS' option"
);
}
if
(
1
!=
LIST_LENGTH
(
pFuncs
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
,
"Invalid option rollup: only one function is allowed"
);
}
const
char
*
pFunc
=
((
SFunctionNode
*
)
nodesListGetNode
(
pFuncs
,
0
))
->
functionName
;
if
(
!
validRollupFunc
(
pFunc
))
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
,
"Invalid option rollup: %s function is not supported"
,
pFunc
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -3248,8 +3301,8 @@ static int32_t checkTableTagsSchema(STranslateContext* pCxt, SHashObj* pHash, SN
...
@@ -3248,8 +3301,8 @@ static int32_t checkTableTagsSchema(STranslateContext* pCxt, SHashObj* pHash, SN
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
);
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_ONLY_ONE_JSON_TAG
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
((
TSDB_DATA_TYPE_VARCHAR
==
pTag
->
dataType
.
type
&&
pTag
->
dataType
.
bytes
>
TSDB_MAX_BINARY_LEN
)
||
if
((
TSDB_DATA_TYPE_VARCHAR
==
pTag
->
dataType
.
type
&&
calcTypeBytes
(
pTag
->
dataType
)
>
TSDB_MAX_BINARY_LEN
)
||
(
TSDB_DATA_TYPE_NCHAR
==
pTag
->
dataType
.
type
&&
pTag
->
dataType
.
bytes
>
TSDB_MAX_NCHAR_LEN
))
{
(
TSDB_DATA_TYPE_NCHAR
==
pTag
->
dataType
.
type
&&
calcTypeBytes
(
pTag
->
dataType
)
>
TSDB_MAX_NCHAR_LEN
))
{
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
);
code
=
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN
);
}
}
}
}
...
@@ -3270,11 +3323,11 @@ static int32_t checkTableTagsSchema(STranslateContext* pCxt, SHashObj* pHash, SN
...
@@ -3270,11 +3323,11 @@ static int32_t checkTableTagsSchema(STranslateContext* pCxt, SHashObj* pHash, SN
return
code
;
return
code
;
}
}
static
int32_t
checkTableColsSchema
(
STranslateContext
*
pCxt
,
SHashObj
*
pHash
,
SNodeList
*
pCols
)
{
static
int32_t
checkTableColsSchema
(
STranslateContext
*
pCxt
,
SHashObj
*
pHash
,
int32_t
ntags
,
SNodeList
*
pCols
)
{
int32_t
ncols
=
LIST_LENGTH
(
pCols
);
int32_t
ncols
=
LIST_LENGTH
(
pCols
);
if
(
ncols
<
TSDB_MIN_COLUMNS
)
{
if
(
ncols
<
TSDB_MIN_COLUMNS
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_COLUMNS_NUM
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_COLUMNS_NUM
);
}
else
if
(
ncols
>
TSDB_MAX_COLUMNS
)
{
}
else
if
(
ncols
+
ntags
>
TSDB_MAX_COLUMNS
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TOO_MANY_COLUMNS
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_TOO_MANY_COLUMNS
);
}
}
...
@@ -3330,7 +3383,7 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
...
@@ -3330,7 +3383,7 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
int32_t
code
=
checkTableTagsSchema
(
pCxt
,
pHash
,
pStmt
->
pTags
);
int32_t
code
=
checkTableTagsSchema
(
pCxt
,
pHash
,
pStmt
->
pTags
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTableColsSchema
(
pCxt
,
pHash
,
pStmt
->
pCols
);
code
=
checkTableColsSchema
(
pCxt
,
pHash
,
LIST_LENGTH
(
pStmt
->
pTags
),
pStmt
->
pCols
);
}
}
taosHashCleanup
(
pHash
);
taosHashCleanup
(
pHash
);
...
@@ -3359,11 +3412,18 @@ static int32_t getTableMaxDelayOption(STranslateContext* pCxt, SValueNode* pVal,
...
@@ -3359,11 +3412,18 @@ static int32_t getTableMaxDelayOption(STranslateContext* pCxt, SValueNode* pVal,
pMaxDelay
);
pMaxDelay
);
}
}
static
int32_t
checkTableMaxDelayOption
(
STranslateContext
*
pCxt
,
STableOptions
*
pOptions
)
{
static
int32_t
checkTableMaxDelayOption
(
STranslateContext
*
pCxt
,
STableOptions
*
pOptions
,
bool
createStable
,
SDbCfgInfo
*
pDbCfg
)
{
if
(
NULL
==
pOptions
->
pMaxDelay
)
{
if
(
NULL
==
pOptions
->
pMaxDelay
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
createStable
||
NULL
==
pDbCfg
->
pRetensions
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TABLE_OPTION
,
"Invalid option maxdelay: Only supported for create super table in databases "
"configured with the 'RETENTIONS' option"
);
}
if
(
LIST_LENGTH
(
pOptions
->
pMaxDelay
)
>
2
)
{
if
(
LIST_LENGTH
(
pOptions
->
pMaxDelay
)
>
2
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TABLE_OPTION
,
"maxdelay"
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TABLE_OPTION
,
"maxdelay"
);
}
}
...
@@ -3382,11 +3442,18 @@ static int32_t getTableWatermarkOption(STranslateContext* pCxt, SValueNode* pVal
...
@@ -3382,11 +3442,18 @@ static int32_t getTableWatermarkOption(STranslateContext* pCxt, SValueNode* pVal
pMaxDelay
);
pMaxDelay
);
}
}
static
int32_t
checkTableWatermarkOption
(
STranslateContext
*
pCxt
,
STableOptions
*
pOptions
)
{
static
int32_t
checkTableWatermarkOption
(
STranslateContext
*
pCxt
,
STableOptions
*
pOptions
,
bool
createStable
,
SDbCfgInfo
*
pDbCfg
)
{
if
(
NULL
==
pOptions
->
pWatermark
)
{
if
(
NULL
==
pOptions
->
pWatermark
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
createStable
||
NULL
==
pDbCfg
->
pRetensions
)
{
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TABLE_OPTION
,
"Invalid option watermark: Only supported for create super table in databases "
"configured with the 'RETENTIONS' option"
);
}
if
(
LIST_LENGTH
(
pOptions
->
pWatermark
)
>
2
)
{
if
(
LIST_LENGTH
(
pOptions
->
pWatermark
)
>
2
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TABLE_OPTION
,
"watermark"
);
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_TABLE_OPTION
,
"watermark"
);
}
}
...
@@ -3400,13 +3467,20 @@ static int32_t checkTableWatermarkOption(STranslateContext* pCxt, STableOptions*
...
@@ -3400,13 +3467,20 @@ static int32_t checkTableWatermarkOption(STranslateContext* pCxt, STableOptions*
return
code
;
return
code
;
}
}
static
int32_t
checkCreateTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
static
int32_t
checkCreateTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
,
bool
createStable
)
{
int32_t
code
=
checkTableMaxDelayOption
(
pCxt
,
pStmt
->
pOptions
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SDbCfgInfo
dbCfg
=
{
0
};
if
(
createStable
)
{
code
=
getDBCfg
(
pCxt
,
pStmt
->
dbName
,
&
dbCfg
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTable
WatermarkOption
(
pCxt
,
pStmt
->
pOptions
);
code
=
checkTable
MaxDelayOption
(
pCxt
,
pStmt
->
pOptions
,
createStable
,
&
dbCfg
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTableRollupOption
(
pCxt
,
pStmt
->
pOptions
->
pRollupFuncs
);
code
=
checkTableWatermarkOption
(
pCxt
,
pStmt
->
pOptions
,
createStable
,
&
dbCfg
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTableRollupOption
(
pCxt
,
pStmt
->
pOptions
->
pRollupFuncs
,
createStable
,
&
dbCfg
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
checkTableSmaOption
(
pCxt
,
pStmt
);
code
=
checkTableSmaOption
(
pCxt
,
pStmt
);
...
@@ -3685,7 +3759,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
...
@@ -3685,7 +3759,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
static
int32_t
translateCreateSuperTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
static
int32_t
translateCreateSuperTable
(
STranslateContext
*
pCxt
,
SCreateTableStmt
*
pStmt
)
{
SMCreateStbReq
createReq
=
{
0
};
SMCreateStbReq
createReq
=
{
0
};
int32_t
code
=
checkCreateTable
(
pCxt
,
pStmt
);
int32_t
code
=
checkCreateTable
(
pCxt
,
pStmt
,
true
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildCreateStbReq
(
pCxt
,
pStmt
,
&
createReq
);
code
=
buildCreateStbReq
(
pCxt
,
pStmt
,
&
createReq
);
}
}
...
@@ -4265,6 +4339,39 @@ static void getSourceDatabase(SNode* pStmt, int32_t acctId, char* pDbFName) {
...
@@ -4265,6 +4339,39 @@ static void getSourceDatabase(SNode* pStmt, int32_t acctId, char* pDbFName) {
tNameGetFullDbName
(
&
name
,
pDbFName
);
tNameGetFullDbName
(
&
name
,
pDbFName
);
}
}
static
int32_t
addWstartTsToCreateStreamQuery
(
SNode
*
pStmt
)
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pStmt
;
SNode
*
pProj
=
nodesListGetNode
(
pSelect
->
pProjectionList
,
0
);
if
(
NULL
==
pSelect
->
pWindow
||
(
QUERY_NODE_FUNCTION
==
nodeType
(
pProj
)
&&
0
==
strcmp
(
"_wstartts"
,
((
SFunctionNode
*
)
pProj
)
->
functionName
)))
{
return
TSDB_CODE_SUCCESS
;
}
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
if
(
NULL
==
pFunc
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
strcpy
(
pFunc
->
functionName
,
"_wstartts"
);
strcpy
(
pFunc
->
node
.
aliasName
,
pFunc
->
functionName
);
int32_t
code
=
nodesListPushFront
(
pSelect
->
pProjectionList
,
(
SNode
*
)
pFunc
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyNode
((
SNode
*
)
pFunc
);
}
return
code
;
}
static
int32_t
buildCreateStreamQuery
(
STranslateContext
*
pCxt
,
SNode
*
pStmt
,
SCMCreateStreamReq
*
pReq
)
{
pCxt
->
createStream
=
true
;
int32_t
code
=
addWstartTsToCreateStreamQuery
(
pStmt
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
translateQuery
(
pCxt
,
pStmt
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
getSourceDatabase
(
pStmt
,
pCxt
->
pParseCxt
->
acctId
,
pReq
->
sourceDB
);
code
=
nodesNodeToString
(
pStmt
,
false
,
&
pReq
->
ast
,
NULL
);
}
return
code
;
}
static
int32_t
buildCreateStreamReq
(
STranslateContext
*
pCxt
,
SCreateStreamStmt
*
pStmt
,
SCMCreateStreamReq
*
pReq
)
{
static
int32_t
buildCreateStreamReq
(
STranslateContext
*
pCxt
,
SCreateStreamStmt
*
pStmt
,
SCMCreateStreamReq
*
pReq
)
{
pReq
->
igExists
=
pStmt
->
ignoreExists
;
pReq
->
igExists
=
pStmt
->
ignoreExists
;
...
@@ -4278,13 +4385,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
...
@@ -4278,13 +4385,7 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
tNameExtractFullName
(
&
name
,
pReq
->
targetStbFullName
);
tNameExtractFullName
(
&
name
,
pReq
->
targetStbFullName
);
}
}
pCxt
->
createStream
=
true
;
int32_t
code
=
buildCreateStreamQuery
(
pCxt
,
pStmt
->
pQuery
,
pReq
);
int32_t
code
=
translateQuery
(
pCxt
,
pStmt
->
pQuery
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
getSourceDatabase
(
pStmt
->
pQuery
,
pCxt
->
pParseCxt
->
acctId
,
pReq
->
sourceDB
);
code
=
nodesNodeToString
(
pStmt
->
pQuery
,
false
,
&
pReq
->
ast
,
NULL
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pReq
->
sql
=
strdup
(
pCxt
->
pParseCxt
->
pSql
);
pReq
->
sql
=
strdup
(
pCxt
->
pParseCxt
->
pSql
);
if
(
NULL
==
pReq
->
sql
)
{
if
(
NULL
==
pReq
->
sql
)
{
...
@@ -5233,7 +5334,7 @@ static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt*
...
@@ -5233,7 +5334,7 @@ static int32_t buildCreateTableDataBlock(int32_t acctId, const SCreateTableStmt*
static
int32_t
rewriteCreateTable
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
static
int32_t
rewriteCreateTable
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
SCreateTableStmt
*
pStmt
=
(
SCreateTableStmt
*
)
pQuery
->
pRoot
;
SCreateTableStmt
*
pStmt
=
(
SCreateTableStmt
*
)
pQuery
->
pRoot
;
int32_t
code
=
checkCreateTable
(
pCxt
,
pStmt
);
int32_t
code
=
checkCreateTable
(
pCxt
,
pStmt
,
false
);
SVgroupInfo
info
=
{
0
};
SVgroupInfo
info
=
{
0
};
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
...
@@ -5337,7 +5438,7 @@ static int32_t createTagValFromVal(STranslateContext* pCxt, SDataType targetDt,
...
@@ -5337,7 +5438,7 @@ static int32_t createTagValFromVal(STranslateContext* pCxt, SDataType targetDt,
if
(
NULL
==
*
pVal
)
{
if
(
NULL
==
*
pVal
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
return
DEAL_RES_ERROR
==
translateValueImpl
(
pCxt
,
*
pVal
,
targetDt
)
?
pCxt
->
errCode
:
TSDB_CODE_SUCCESS
;
return
DEAL_RES_ERROR
==
translateValueImpl
(
pCxt
,
*
pVal
,
targetDt
,
true
)
?
pCxt
->
errCode
:
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
createTagVal
(
STranslateContext
*
pCxt
,
uint8_t
precision
,
SSchema
*
pSchema
,
SNode
*
pNode
,
static
int32_t
createTagVal
(
STranslateContext
*
pCxt
,
uint8_t
precision
,
SSchema
*
pSchema
,
SNode
*
pNode
,
...
@@ -5721,7 +5822,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
...
@@ -5721,7 +5822,7 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
}
}
SDataType
targetDt
=
schemaToDataType
(
pTableMeta
->
tableInfo
.
precision
,
pSchema
);
SDataType
targetDt
=
schemaToDataType
(
pTableMeta
->
tableInfo
.
precision
,
pSchema
);
if
(
DEAL_RES_ERROR
==
translateValueImpl
(
pCxt
,
pStmt
->
pVal
,
targetDt
))
{
if
(
DEAL_RES_ERROR
==
translateValueImpl
(
pCxt
,
pStmt
->
pVal
,
targetDt
,
true
))
{
return
pCxt
->
errCode
;
return
pCxt
->
errCode
;
}
}
...
...
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
ba056f7f
...
@@ -159,7 +159,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) {
...
@@ -159,7 +159,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) {
* c4 | column | DOUBLE | 8 |
* c4 | column | DOUBLE | 8 |
* c5 | column | DOUBLE | 8 |
* c5 | column | DOUBLE | 8 |
*/
*/
void
generateTestT
1
(
MockCatalogService
*
mcs
)
{
void
generateTestT
ables
(
MockCatalogService
*
mcs
)
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"t1"
,
TSDB_NORMAL_TABLE
,
6
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"t1"
,
TSDB_NORMAL_TABLE
,
6
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
setVgid
(
1
)
.
setVgid
(
1
)
...
@@ -183,8 +183,18 @@ void generateTestT1(MockCatalogService* mcs) {
...
@@ -183,8 +183,18 @@ void generateTestT1(MockCatalogService* mcs) {
* tag2 | tag | VARCHAR | 20 |
* tag2 | tag | VARCHAR | 20 |
* tag3 | tag | TIMESTAMP | 8 |
* tag3 | tag | TIMESTAMP | 8 |
* Child Table: st1s1, st1s2
* Child Table: st1s1, st1s2
*
* Super Table: st2
* Field | Type | DataType | Bytes |
* ==========================================================================
* ts | column | TIMESTAMP | 8 |
* c1 | column | INT | 4 |
* c2 | column | VARCHAR | 20 |
* jtag | tag | json | -- |
* Child Table: st2s1, st2s2
*/
*/
void
generateTestST1
(
MockCatalogService
*
mcs
)
{
void
generateTestStables
(
MockCatalogService
*
mcs
)
{
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"st1"
,
TSDB_SUPER_TABLE
,
3
,
3
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"st1"
,
TSDB_SUPER_TABLE
,
3
,
3
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
addColumn
(
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
)
.
addColumn
(
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
)
...
@@ -197,19 +207,8 @@ void generateTestST1(MockCatalogService* mcs) {
...
@@ -197,19 +207,8 @@ void generateTestST1(MockCatalogService* mcs) {
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s1"
,
1
);
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s1"
,
1
);
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s2"
,
2
);
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s2"
,
2
);
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s3"
,
1
);
mcs
->
createSubTable
(
"test"
,
"st1"
,
"st1s3"
,
1
);
}
}
{
/*
* Super Table: st2
* Field | Type | DataType | Bytes |
* ==========================================================================
* ts | column | TIMESTAMP | 8 |
* c1 | column | INT | 4 |
* c2 | column | VARCHAR | 20 |
* jtag | tag | json | -- |
* Child Table: st2s1, st2s2
*/
void
generateTestST2
(
MockCatalogService
*
mcs
)
{
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"st2"
,
TSDB_SUPER_TABLE
,
3
,
1
)
ITableBuilder
&
builder
=
mcs
->
createTableBuilder
(
"test"
,
"st2"
,
TSDB_SUPER_TABLE
,
3
,
1
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
setPrecision
(
TSDB_TIME_PRECISION_MILLI
)
.
addColumn
(
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
)
.
addColumn
(
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
)
...
@@ -219,6 +218,7 @@ void generateTestST2(MockCatalogService* mcs) {
...
@@ -219,6 +218,7 @@ void generateTestST2(MockCatalogService* mcs) {
builder
.
done
();
builder
.
done
();
mcs
->
createSubTable
(
"test"
,
"st2"
,
"st2s1"
,
1
);
mcs
->
createSubTable
(
"test"
,
"st2"
,
"st2s1"
,
1
);
mcs
->
createSubTable
(
"test"
,
"st2"
,
"st2s2"
,
2
);
mcs
->
createSubTable
(
"test"
,
"st2"
,
"st2s2"
,
2
);
}
}
}
void
generateFunctions
(
MockCatalogService
*
mcs
)
{
void
generateFunctions
(
MockCatalogService
*
mcs
)
{
...
@@ -233,6 +233,11 @@ void generateDnodes(MockCatalogService* mcs) {
...
@@ -233,6 +233,11 @@ void generateDnodes(MockCatalogService* mcs) {
mcs
->
createDnode
(
3
,
"host3"
,
7030
);
mcs
->
createDnode
(
3
,
"host3"
,
7030
);
}
}
void
generateDatabases
(
MockCatalogService
*
mcs
)
{
mcs
->
createDatabase
(
"test"
);
mcs
->
createDatabase
(
"rollup_db"
,
true
);
}
}
// namespace
}
// namespace
int32_t
__catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
)
{
return
0
;
}
int32_t
__catalogGetHandle
(
const
char
*
clusterId
,
struct
SCatalog
**
catalogHandle
)
{
return
0
;
}
...
@@ -262,7 +267,7 @@ int32_t __catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char
...
@@ -262,7 +267,7 @@ int32_t __catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char
}
}
int32_t
__catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
int32_t
__catalogGetDBCfg
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SDbCfgInfo
*
pDbCfg
)
{
return
0
;
return
g_mockCatalogService
->
catalogGetDBCfg
(
dbFName
,
pDbCfg
)
;
}
}
int32_t
__catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
int32_t
__catalogChkAuth
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
user
,
const
char
*
dbFName
,
AUTH_TYPE
type
,
...
@@ -359,11 +364,11 @@ void initMetaDataEnv() {
...
@@ -359,11 +364,11 @@ void initMetaDataEnv() {
}
}
void
generateMetaData
()
{
void
generateMetaData
()
{
generateDatabases
(
g_mockCatalogService
.
get
());
generateInformationSchema
(
g_mockCatalogService
.
get
());
generateInformationSchema
(
g_mockCatalogService
.
get
());
generatePerformanceSchema
(
g_mockCatalogService
.
get
());
generatePerformanceSchema
(
g_mockCatalogService
.
get
());
generateTestT1
(
g_mockCatalogService
.
get
());
generateTestTables
(
g_mockCatalogService
.
get
());
generateTestST1
(
g_mockCatalogService
.
get
());
generateTestStables
(
g_mockCatalogService
.
get
());
generateTestST2
(
g_mockCatalogService
.
get
());
generateFunctions
(
g_mockCatalogService
.
get
());
generateFunctions
(
g_mockCatalogService
.
get
());
generateDnodes
(
g_mockCatalogService
.
get
());
generateDnodes
(
g_mockCatalogService
.
get
());
g_mockCatalogService
->
showTables
();
g_mockCatalogService
->
showTables
();
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
ba056f7f
...
@@ -140,6 +140,17 @@ class MockCatalogServiceImpl {
...
@@ -140,6 +140,17 @@ class MockCatalogServiceImpl {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
catalogGetDBCfg
(
const
char
*
pDbFName
,
SDbCfgInfo
*
pDbCfg
)
const
{
std
::
string
dbFName
(
pDbFName
);
DbCfgCache
::
const_iterator
it
=
dbCfg_
.
find
(
dbFName
.
substr
(
std
::
string
(
pDbFName
).
find_last_of
(
'.'
)
+
1
));
if
(
dbCfg_
.
end
()
==
it
)
{
return
TSDB_CODE_FAILED
;
}
memcpy
(
pDbCfg
,
&
(
it
->
second
),
sizeof
(
SDbCfgInfo
));
return
TSDB_CODE_SUCCESS
;
}
int32_t
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
{
int32_t
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
{
auto
it
=
udf_
.
find
(
funcName
);
auto
it
=
udf_
.
find
(
funcName
);
if
(
udf_
.
end
()
==
it
)
{
if
(
udf_
.
end
()
==
it
)
{
...
@@ -323,12 +334,21 @@ class MockCatalogServiceImpl {
...
@@ -323,12 +334,21 @@ class MockCatalogServiceImpl {
dnode_
.
insert
(
std
::
make_pair
(
dnodeId
,
epSet
));
dnode_
.
insert
(
std
::
make_pair
(
dnodeId
,
epSet
));
}
}
void
createDatabase
(
const
std
::
string
&
db
,
bool
rollup
)
{
SDbCfgInfo
cfg
=
{
0
};
if
(
rollup
)
{
cfg
.
pRetensions
=
taosArrayInit
(
TARRAY_MIN_SIZE
,
sizeof
(
SRetention
));
}
dbCfg_
.
insert
(
std
::
make_pair
(
db
,
cfg
));
}
private:
private:
typedef
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
MockTableMeta
>>
TableMetaCache
;
typedef
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
MockTableMeta
>>
TableMetaCache
;
typedef
std
::
map
<
std
::
string
,
TableMetaCache
>
DbMetaCache
;
typedef
std
::
map
<
std
::
string
,
TableMetaCache
>
DbMetaCache
;
typedef
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
SFuncInfo
>>
UdfMetaCache
;
typedef
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
SFuncInfo
>>
UdfMetaCache
;
typedef
std
::
map
<
std
::
string
,
std
::
vector
<
STableIndexInfo
>>
IndexMetaCache
;
typedef
std
::
map
<
std
::
string
,
std
::
vector
<
STableIndexInfo
>>
IndexMetaCache
;
typedef
std
::
map
<
int32_t
,
SEpSet
>
DnodeCache
;
typedef
std
::
map
<
int32_t
,
SEpSet
>
DnodeCache
;
typedef
std
::
map
<
std
::
string
,
SDbCfgInfo
>
DbCfgCache
;
uint64_t
getNextId
()
{
return
id_
++
;
}
uint64_t
getNextId
()
{
return
id_
++
;
}
...
@@ -486,6 +506,7 @@ class MockCatalogServiceImpl {
...
@@ -486,6 +506,7 @@ class MockCatalogServiceImpl {
for
(
int32_t
i
=
0
;
i
<
ndbs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
ndbs
;
++
i
)
{
SMetaRes
res
=
{
0
};
SMetaRes
res
=
{
0
};
res
.
pRes
=
taosMemoryCalloc
(
1
,
sizeof
(
SDbCfgInfo
));
res
.
pRes
=
taosMemoryCalloc
(
1
,
sizeof
(
SDbCfgInfo
));
res
.
code
=
catalogGetDBCfg
((
const
char
*
)
taosArrayGet
(
pDbCfgReq
,
i
),
(
SDbCfgInfo
*
)
res
.
pRes
);
taosArrayPush
(
*
pDbCfgData
,
&
res
);
taosArrayPush
(
*
pDbCfgData
,
&
res
);
}
}
}
}
...
@@ -576,6 +597,7 @@ class MockCatalogServiceImpl {
...
@@ -576,6 +597,7 @@ class MockCatalogServiceImpl {
UdfMetaCache
udf_
;
UdfMetaCache
udf_
;
IndexMetaCache
index_
;
IndexMetaCache
index_
;
DnodeCache
dnode_
;
DnodeCache
dnode_
;
DbCfgCache
dbCfg_
;
};
};
MockCatalogService
::
MockCatalogService
()
:
impl_
(
new
MockCatalogServiceImpl
())
{}
MockCatalogService
::
MockCatalogService
()
:
impl_
(
new
MockCatalogServiceImpl
())
{}
...
@@ -605,6 +627,8 @@ void MockCatalogService::createDnode(int32_t dnodeId, const std::string& host, i
...
@@ -605,6 +627,8 @@ void MockCatalogService::createDnode(int32_t dnodeId, const std::string& host, i
impl_
->
createDnode
(
dnodeId
,
host
,
port
);
impl_
->
createDnode
(
dnodeId
,
host
,
port
);
}
}
void
MockCatalogService
::
createDatabase
(
const
std
::
string
&
db
,
bool
rollup
)
{
impl_
->
createDatabase
(
db
,
rollup
);
}
int32_t
MockCatalogService
::
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
const
{
int32_t
MockCatalogService
::
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
const
{
return
impl_
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
);
return
impl_
->
catalogGetTableMeta
(
pTableName
,
pTableMeta
);
}
}
...
@@ -621,6 +645,10 @@ int32_t MockCatalogService::catalogGetDBVgInfo(const char* pDbFName, SArray** pV
...
@@ -621,6 +645,10 @@ int32_t MockCatalogService::catalogGetDBVgInfo(const char* pDbFName, SArray** pV
return
impl_
->
catalogGetDBVgInfo
(
pDbFName
,
pVgList
);
return
impl_
->
catalogGetDBVgInfo
(
pDbFName
,
pVgList
);
}
}
int32_t
MockCatalogService
::
catalogGetDBCfg
(
const
char
*
pDbFName
,
SDbCfgInfo
*
pDbCfg
)
const
{
return
impl_
->
catalogGetDBCfg
(
pDbFName
,
pDbCfg
);
}
int32_t
MockCatalogService
::
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
{
int32_t
MockCatalogService
::
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
{
return
impl_
->
catalogGetUdfInfo
(
funcName
,
pInfo
);
return
impl_
->
catalogGetUdfInfo
(
funcName
,
pInfo
);
}
}
...
...
source/libs/parser/test/mockCatalogService.h
浏览文件 @
ba056f7f
...
@@ -63,11 +63,13 @@ class MockCatalogService {
...
@@ -63,11 +63,13 @@ class MockCatalogService {
void
createFunction
(
const
std
::
string
&
func
,
int8_t
funcType
,
int8_t
outputType
,
int32_t
outputLen
,
int32_t
bufSize
);
void
createFunction
(
const
std
::
string
&
func
,
int8_t
funcType
,
int8_t
outputType
,
int32_t
outputLen
,
int32_t
bufSize
);
void
createSmaIndex
(
const
SMCreateSmaReq
*
pReq
);
void
createSmaIndex
(
const
SMCreateSmaReq
*
pReq
);
void
createDnode
(
int32_t
dnodeId
,
const
std
::
string
&
host
,
int16_t
port
);
void
createDnode
(
int32_t
dnodeId
,
const
std
::
string
&
host
,
int16_t
port
);
void
createDatabase
(
const
std
::
string
&
db
,
bool
rollup
=
false
);
int32_t
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
const
;
int32_t
catalogGetTableMeta
(
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
const
;
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
)
const
;
int32_t
catalogGetTableHashVgroup
(
const
SName
*
pTableName
,
SVgroupInfo
*
vgInfo
)
const
;
int32_t
catalogGetTableDistVgInfo
(
const
SName
*
pTableName
,
SArray
**
pVgList
)
const
;
int32_t
catalogGetTableDistVgInfo
(
const
SName
*
pTableName
,
SArray
**
pVgList
)
const
;
int32_t
catalogGetDBVgInfo
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
;
int32_t
catalogGetDBVgInfo
(
const
char
*
pDbFName
,
SArray
**
pVgList
)
const
;
int32_t
catalogGetDBCfg
(
const
char
*
pDbFName
,
SDbCfgInfo
*
pDbCfg
)
const
;
int32_t
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
;
int32_t
catalogGetUdfInfo
(
const
std
::
string
&
funcName
,
SFuncInfo
*
pInfo
)
const
;
int32_t
catalogGetTableIndex
(
const
SName
*
pTableName
,
SArray
**
pIndexes
)
const
;
int32_t
catalogGetTableIndex
(
const
SName
*
pTableName
,
SArray
**
pIndexes
)
const
;
int32_t
catalogGetDnodeList
(
SArray
**
pDnodes
)
const
;
int32_t
catalogGetDnodeList
(
SArray
**
pDnodes
)
const
;
...
...
source/libs/parser/test/parInitialATest.cpp
浏览文件 @
ba056f7f
...
@@ -38,9 +38,9 @@ TEST_F(ParserInitialATest, alterDnode) {
...
@@ -38,9 +38,9 @@ TEST_F(ParserInitialATest, alterDnode) {
TEST_F
(
ParserInitialATest
,
alterDatabase
)
{
TEST_F
(
ParserInitialATest
,
alterDatabase
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"ALTER DATABASE
wxy_db
CACHELAST 1 FSYNC 200 WAL 1"
);
run
(
"ALTER DATABASE
test
CACHELAST 1 FSYNC 200 WAL 1"
);
run
(
"ALTER DATABASE
wxy_db
KEEP 2400"
);
run
(
"ALTER DATABASE
test
KEEP 2400"
);
}
}
TEST_F
(
ParserInitialATest
,
alterLocal
)
{
TEST_F
(
ParserInitialATest
,
alterLocal
)
{
...
...
source/libs/parser/test/parInitialCTest.cpp
浏览文件 @
ba056f7f
...
@@ -359,11 +359,11 @@ TEST_F(ParserInitialCTest, createStable) {
...
@@ -359,11 +359,11 @@ TEST_F(ParserInitialCTest, createStable) {
memset
(
&
expect
,
0
,
sizeof
(
SMCreateStbReq
));
memset
(
&
expect
,
0
,
sizeof
(
SMCreateStbReq
));
};
};
auto
setCreateStbReqFunc
=
[
&
](
const
char
*
p
Tbname
,
int8_t
igExists
=
0
,
int64_t
delay1
=
-
1
,
int64_t
delay2
=
-
1
,
auto
setCreateStbReqFunc
=
[
&
](
const
char
*
p
DbName
,
const
char
*
pTbName
,
int8_t
igExists
=
0
,
int64_t
delay1
=
-
1
,
int64_t
watermark1
=
TSDB_DEFAULT_ROLLUP_WATERMARK
,
int64_t
delay2
=
-
1
,
int64_t
watermark1
=
TSDB_DEFAULT_ROLLUP_WATERMARK
,
int64_t
watermark2
=
TSDB_DEFAULT_ROLLUP_WATERMARK
,
int64_t
watermark2
=
TSDB_DEFAULT_ROLLUP_WATERMARK
,
int32_t
ttl
=
TSDB_DEFAULT_TABLE_TTL
,
const
char
*
pComment
=
nullptr
)
{
int32_t
ttl
=
TSDB_DEFAULT_TABLE_TTL
,
const
char
*
pComment
=
nullptr
)
{
int32_t
len
=
snprintf
(
expect
.
name
,
sizeof
(
expect
.
name
),
"0.
test.%s"
,
pTbn
ame
);
int32_t
len
=
snprintf
(
expect
.
name
,
sizeof
(
expect
.
name
),
"0.
%s.%s"
,
pDbName
,
pTbN
ame
);
expect
.
name
[
len
]
=
'\0'
;
expect
.
name
[
len
]
=
'\0'
;
expect
.
igExists
=
igExists
;
expect
.
igExists
=
igExists
;
expect
.
delay1
=
delay1
;
expect
.
delay1
=
delay1
;
...
@@ -454,14 +454,14 @@ TEST_F(ParserInitialCTest, createStable) {
...
@@ -454,14 +454,14 @@ TEST_F(ParserInitialCTest, createStable) {
tFreeSMCreateStbReq
(
&
req
);
tFreeSMCreateStbReq
(
&
req
);
});
});
setCreateStbReqFunc
(
"t1"
);
setCreateStbReqFunc
(
"t
est"
,
"t
1"
);
addFieldToCreateStbReqFunc
(
true
,
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
);
addFieldToCreateStbReqFunc
(
true
,
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
);
addFieldToCreateStbReqFunc
(
true
,
"c1"
,
TSDB_DATA_TYPE_INT
);
addFieldToCreateStbReqFunc
(
true
,
"c1"
,
TSDB_DATA_TYPE_INT
);
addFieldToCreateStbReqFunc
(
false
,
"id"
,
TSDB_DATA_TYPE_INT
);
addFieldToCreateStbReqFunc
(
false
,
"id"
,
TSDB_DATA_TYPE_INT
);
run
(
"CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)"
);
run
(
"CREATE STABLE t1(ts TIMESTAMP, c1 INT) TAGS(id INT)"
);
clearCreateStbReq
();
clearCreateStbReq
();
setCreateStbReqFunc
(
"t1"
,
1
,
100
*
MILLISECOND_PER_SECOND
,
10
*
MILLISECOND_PER_MINUTE
,
10
,
setCreateStbReqFunc
(
"
rollup_db"
,
"
t1"
,
1
,
100
*
MILLISECOND_PER_SECOND
,
10
*
MILLISECOND_PER_MINUTE
,
10
,
1
*
MILLISECOND_PER_MINUTE
,
100
,
"test create table"
);
1
*
MILLISECOND_PER_MINUTE
,
100
,
"test create table"
);
addFieldToCreateStbReqFunc
(
true
,
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
,
0
,
0
);
addFieldToCreateStbReqFunc
(
true
,
"ts"
,
TSDB_DATA_TYPE_TIMESTAMP
,
0
,
0
);
addFieldToCreateStbReqFunc
(
true
,
"c1"
,
TSDB_DATA_TYPE_INT
);
addFieldToCreateStbReqFunc
(
true
,
"c1"
,
TSDB_DATA_TYPE_INT
);
...
@@ -493,7 +493,7 @@ TEST_F(ParserInitialCTest, createStable) {
...
@@ -493,7 +493,7 @@ TEST_F(ParserInitialCTest, createStable) {
addFieldToCreateStbReqFunc
(
false
,
"a13"
,
TSDB_DATA_TYPE_BOOL
);
addFieldToCreateStbReqFunc
(
false
,
"a13"
,
TSDB_DATA_TYPE_BOOL
);
addFieldToCreateStbReqFunc
(
false
,
"a14"
,
TSDB_DATA_TYPE_NCHAR
,
30
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
);
addFieldToCreateStbReqFunc
(
false
,
"a14"
,
TSDB_DATA_TYPE_NCHAR
,
30
*
TSDB_NCHAR_SIZE
+
VARSTR_HEADER_SIZE
);
addFieldToCreateStbReqFunc
(
false
,
"a15"
,
TSDB_DATA_TYPE_VARCHAR
,
50
+
VARSTR_HEADER_SIZE
);
addFieldToCreateStbReqFunc
(
false
,
"a15"
,
TSDB_DATA_TYPE_VARCHAR
,
50
+
VARSTR_HEADER_SIZE
);
run
(
"CREATE STABLE IF NOT EXISTS
test
.t1("
run
(
"CREATE STABLE IF NOT EXISTS
rollup_db
.t1("
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), "
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), "
"c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, "
"c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, "
"c13 NCHAR(30), c14 VARCHAR(50)) "
"c13 NCHAR(30), c14 VARCHAR(50)) "
...
@@ -507,12 +507,13 @@ TEST_F(ParserInitialCTest, createStable) {
...
@@ -507,12 +507,13 @@ TEST_F(ParserInitialCTest, createStable) {
TEST_F
(
ParserInitialCTest
,
createStableSemanticCheck
)
{
TEST_F
(
ParserInitialCTest
,
createStableSemanticCheck
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(CEIL)"
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
run
(
"CREATE STABLE rollup_db.stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(CEIL)"
,
TSDB_CODE_PAR_INVALID_ROLLUP_OPTION
);
run
(
"CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 0s WATERMARK 1m"
,
run
(
"CREATE STABLE
rollup_db.
stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 0s WATERMARK 1m"
,
TSDB_CODE_PAR_INVALID_RANGE_OPTION
);
TSDB_CODE_PAR_INVALID_RANGE_OPTION
);
run
(
"CREATE STABLE stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 10s WATERMARK 18m"
,
run
(
"CREATE STABLE
rollup_db.
stb2 (ts TIMESTAMP, c1 INT) TAGS (tag1 INT) ROLLUP(MAX) MAX_DELAY 10s WATERMARK 18m"
,
TSDB_CODE_PAR_INVALID_RANGE_OPTION
);
TSDB_CODE_PAR_INVALID_RANGE_OPTION
);
}
}
...
@@ -561,30 +562,33 @@ TEST_F(ParserInitialCTest, createStream) {
...
@@ -561,30 +562,33 @@ TEST_F(ParserInitialCTest, createStream) {
tFreeSCMCreateStreamReq
(
&
req
);
tFreeSCMCreateStreamReq
(
&
req
);
});
});
setCreateStreamReqFunc
(
"s1"
,
"test"
,
"create stream s1 as select
* from t1
"
);
setCreateStreamReqFunc
(
"s1"
,
"test"
,
"create stream s1 as select
count(*) from t1 interval(10s)
"
);
run
(
"CREATE STREAM s1 AS SELECT
* FROM t1
"
);
run
(
"CREATE STREAM s1 AS SELECT
COUNT(*) FROM t1 INTERVAL(10S)
"
);
clearCreateStreamReq
();
clearCreateStreamReq
();
setCreateStreamReqFunc
(
"s1"
,
"test"
,
"create stream if not exists s1 as select * from t1"
,
nullptr
,
1
);
setCreateStreamReqFunc
(
"s1"
,
"test"
,
"create stream if not exists s1 as select count(*) from t1 interval(10s)"
,
run
(
"CREATE STREAM IF NOT EXISTS s1 AS SELECT * FROM t1"
);
nullptr
,
1
);
run
(
"CREATE STREAM IF NOT EXISTS s1 AS SELECT COUNT(*) FROM t1 INTERVAL(10S)"
);
clearCreateStreamReq
();
clearCreateStreamReq
();
setCreateStreamReqFunc
(
"s1"
,
"test"
,
"create stream s1 into st1 as select
* from t1
"
,
"st1"
);
setCreateStreamReqFunc
(
"s1"
,
"test"
,
"create stream s1 into st1 as select
count(*) from t1 interval(10s)
"
,
"st1"
);
run
(
"CREATE STREAM s1 INTO st1 AS SELECT
* FROM t1
"
);
run
(
"CREATE STREAM s1 INTO st1 AS SELECT
COUNT(*) FROM t1 INTERVAL(10S)
"
);
clearCreateStreamReq
();
clearCreateStreamReq
();
setCreateStreamReqFunc
(
setCreateStreamReqFunc
(
"s1"
,
"test"
,
"s1"
,
"test"
,
"create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired into st1 "
"create stream if not exists s1 trigger max_delay 20s watermark 10s ignore expired into st1 as select * from t1"
,
"as select count(*) from t1 interval(10s)"
,
"st1"
,
1
,
STREAM_TRIGGER_MAX_DELAY
,
20
*
MILLISECOND_PER_SECOND
,
10
*
MILLISECOND_PER_SECOND
,
1
);
"st1"
,
1
,
STREAM_TRIGGER_MAX_DELAY
,
20
*
MILLISECOND_PER_SECOND
,
10
*
MILLISECOND_PER_SECOND
,
run
(
"CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED INTO st1 AS SELECT * FROM t1"
);
1
);
run
(
"CREATE STREAM IF NOT EXISTS s1 TRIGGER MAX_DELAY 20s WATERMARK 10s IGNORE EXPIRED INTO st1 AS SELECT COUNT(*) "
"FROM t1 INTERVAL(10S)"
);
clearCreateStreamReq
();
clearCreateStreamReq
();
}
}
TEST_F
(
ParserInitialCTest
,
createStreamSemanticCheck
)
{
TEST_F
(
ParserInitialCTest
,
createStreamSemanticCheck
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"CREATE STREAM s1 AS SELECT PERCENTILE(c1, 30) FROM t1"
,
TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC
);
run
(
"CREATE STREAM s1 AS SELECT PERCENTILE(c1, 30) FROM t1
INTERVAL(10S)
"
,
TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC
);
}
}
TEST_F
(
ParserInitialCTest
,
createTable
)
{
TEST_F
(
ParserInitialCTest
,
createTable
)
{
...
@@ -598,7 +602,7 @@ TEST_F(ParserInitialCTest, createTable) {
...
@@ -598,7 +602,7 @@ TEST_F(ParserInitialCTest, createTable) {
"c13 NCHAR(30), c15 VARCHAR(50)) "
"c13 NCHAR(30), c15 VARCHAR(50)) "
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)"
);
"TTL 100 COMMENT 'test create table' SMA(c1, c2, c3)"
);
run
(
"CREATE TABLE IF NOT EXISTS
test
.t1("
run
(
"CREATE TABLE IF NOT EXISTS
rollup_db
.t1("
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), "
"ts TIMESTAMP, c1 INT, c2 INT UNSIGNED, c3 BIGINT, c4 BIGINT UNSIGNED, c5 FLOAT, c6 DOUBLE, c7 BINARY(20), "
"c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, "
"c8 SMALLINT, c9 SMALLINT UNSIGNED COMMENT 'test column comment', c10 TINYINT, c11 TINYINT UNSIGNED, c12 BOOL, "
"c13 NCHAR(30), c14 VARCHAR(50)) "
"c13 NCHAR(30), c14 VARCHAR(50)) "
...
@@ -617,6 +621,21 @@ TEST_F(ParserInitialCTest, createTable) {
...
@@ -617,6 +621,21 @@ TEST_F(ParserInitialCTest, createTable) {
// run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW + 1S)");
// run("CREATE TABLE IF NOT EXISTS t1 USING st1 TAGS(1, 'wxy', NOW + 1S)");
}
}
TEST_F
(
ParserInitialCTest
,
createTableSemanticCheck
)
{
useDb
(
"root"
,
"test"
);
string
sql
=
"CREATE TABLE st1(ts TIMESTAMP, "
;
for
(
int32_t
i
=
1
;
i
<
4096
;
++
i
)
{
if
(
i
>
1
)
{
sql
.
append
(
", "
);
}
sql
.
append
(
"c"
+
to_string
(
i
)
+
" INT"
);
}
sql
.
append
(
") TAGS (t1 int)"
);
run
(
sql
,
TSDB_CODE_PAR_TOO_MANY_COLUMNS
);
}
TEST_F
(
ParserInitialCTest
,
createTopic
)
{
TEST_F
(
ParserInitialCTest
,
createTopic
)
{
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
...
...
tests/system-test/2-query/abs.py
浏览文件 @
ba056f7f
...
@@ -139,7 +139,7 @@ class TDTestCase:
...
@@ -139,7 +139,7 @@ class TDTestCase:
)
)
for
i
in
range
(
4
):
for
i
in
range
(
4
):
tdSql
.
execute
(
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/distribute_agg_apercentile.py
浏览文件 @
ba056f7f
...
@@ -36,7 +36,7 @@ class TDTestCase:
...
@@ -36,7 +36,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/distribute_agg_avg.py
浏览文件 @
ba056f7f
...
@@ -53,7 +53,7 @@ class TDTestCase:
...
@@ -53,7 +53,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/distribute_agg_count.py
浏览文件 @
ba056f7f
...
@@ -55,7 +55,7 @@ class TDTestCase:
...
@@ -55,7 +55,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/distribute_agg_max.py
浏览文件 @
ba056f7f
...
@@ -55,7 +55,7 @@ class TDTestCase:
...
@@ -55,7 +55,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/distribute_agg_min.py
浏览文件 @
ba056f7f
...
@@ -55,7 +55,7 @@ class TDTestCase:
...
@@ -55,7 +55,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/distribute_agg_spread.py
浏览文件 @
ba056f7f
...
@@ -55,7 +55,7 @@ class TDTestCase:
...
@@ -55,7 +55,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/distribute_agg_stddev.py
浏览文件 @
ba056f7f
...
@@ -64,7 +64,7 @@ class TDTestCase:
...
@@ -64,7 +64,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/distribute_agg_sum.py
浏览文件 @
ba056f7f
...
@@ -53,7 +53,7 @@ class TDTestCase:
...
@@ -53,7 +53,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/function_null.py
浏览文件 @
ba056f7f
...
@@ -42,7 +42,7 @@ class TDTestCase:
...
@@ -42,7 +42,7 @@ class TDTestCase:
)
)
for
i
in
range
(
4
):
for
i
in
range
(
4
):
tdSql
.
execute
(
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/irate.py
浏览文件 @
ba056f7f
...
@@ -97,7 +97,7 @@ class TDTestCase:
...
@@ -97,7 +97,7 @@ class TDTestCase:
)
)
for
i
in
range
(
4
):
for
i
in
range
(
4
):
tdSql
.
execute
(
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/max.py
浏览文件 @
ba056f7f
...
@@ -109,7 +109,7 @@ class TDTestCase:
...
@@ -109,7 +109,7 @@ class TDTestCase:
'''
'''
)
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
for
i
in
range
(
9
):
for
i
in
range
(
9
):
tdSql
.
execute
(
tdSql
.
execute
(
...
...
tests/system-test/2-query/twa.py
浏览文件 @
ba056f7f
...
@@ -34,7 +34,7 @@ class TDTestCase:
...
@@ -34,7 +34,7 @@ class TDTestCase:
)
)
for
i
in
range
(
self
.
tb_nums
):
for
i
in
range
(
self
.
tb_nums
):
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
tdSql
.
execute
(
f
'create table ct
{
i
+
1
}
using stb1 tags ( now(),
{
1
*
i
}
,
{
11111
*
i
}
,
{
111
*
i
}
,
{
1
*
i
}
,
{
1.11
*
i
}
,
{
11.11
*
i
}
,
{
i
%
2
}
, "binary
{
i
}
", "nchar
{
i
}
" )'
)
ts
=
self
.
ts
ts
=
self
.
ts
for
j
in
range
(
self
.
row_nums
):
for
j
in
range
(
self
.
row_nums
):
ts
+=
j
*
self
.
time_step
ts
+=
j
*
self
.
time_step
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录