Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aa064709
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
aa064709
编写于
10月 28, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-10564] fix memory leak in unit test and refactor some codes.
上级
d12503e6
变更
22
展开全部
隐藏空白更改
内联
并排
Showing
22 changed file
with
1190 addition
and
402 deletion
+1190
-402
include/common/tdataformat.h
include/common/tdataformat.h
+1
-1
include/common/ttime.h
include/common/ttime.h
+2
-1
include/libs/function/function.h
include/libs/function/function.h
+26
-3
include/libs/parser/parser.h
include/libs/parser/parser.h
+2
-16
include/util/tdef.h
include/util/tdef.h
+1
-1
source/common/src/ttime.c
source/common/src/ttime.c
+5
-6
source/libs/function/CMakeLists.txt
source/libs/function/CMakeLists.txt
+2
-2
source/libs/function/inc/taggfunction.h
source/libs/function/inc/taggfunction.h
+0
-2
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+3
-3
source/libs/function/src/texpr.c
source/libs/function/src/texpr.c
+12
-4
source/libs/function/src/tfunction.c
source/libs/function/src/tfunction.c
+40
-47
source/libs/parser/inc/astGenerator.h
source/libs/parser/inc/astGenerator.h
+1
-1
source/libs/parser/inc/parserInt.h
source/libs/parser/inc/parserInt.h
+9
-1
source/libs/parser/inc/queryInfoUtil.h
source/libs/parser/inc/queryInfoUtil.h
+2
-2
source/libs/parser/src/astGenerator.c
source/libs/parser/src/astGenerator.c
+5
-3
source/libs/parser/src/astValidate.c
source/libs/parser/src/astValidate.c
+860
-90
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+10
-1
source/libs/parser/src/parserUtil.c
source/libs/parser/src/parserUtil.c
+2
-9
source/libs/parser/src/queryInfoUtil.c
source/libs/parser/src/queryInfoUtil.c
+11
-53
source/libs/parser/test/CMakeLists.txt
source/libs/parser/test/CMakeLists.txt
+4
-4
source/libs/parser/test/parserTests.cpp
source/libs/parser/test/parserTests.cpp
+137
-105
source/libs/parser/test/tokenizerTest.cpp
source/libs/parser/test/tokenizerTest.cpp
+55
-47
未找到文件。
include/common/tdataformat.h
浏览文件 @
aa064709
...
@@ -308,7 +308,7 @@ static FORCE_INLINE void tdCopyColOfRowBySchema(SDataRow dst, STSchema *pDstSche
...
@@ -308,7 +308,7 @@ static FORCE_INLINE void tdCopyColOfRowBySchema(SDataRow dst, STSchema *pDstSche
SET_DOUBLE_PTR
(
pData
,
value
);
SET_DOUBLE_PTR
(
pData
,
value
);
break
;
break
;
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
if
(
pSrcSchema
->
columns
[
srcIdx
].
colId
==
PRIMARYKEY_TIMESTAMP_COL_I
NDEX
)
{
if
(
pSrcSchema
->
columns
[
srcIdx
].
colId
==
PRIMARYKEY_TIMESTAMP_COL_I
D
)
{
*
(
TSKEY
*
)
pData
=
tdGetKey
(
*
(
TKEY
*
)
value
);
*
(
TSKEY
*
)
pData
=
tdGetKey
(
*
(
TKEY
*
)
value
);
}
else
{
}
else
{
*
(
TSKEY
*
)
pData
=
*
(
TSKEY
*
)
value
;
*
(
TSKEY
*
)
pData
=
*
(
TSKEY
*
)
value
;
...
...
include/common/ttime.h
浏览文件 @
aa064709
...
@@ -23,6 +23,8 @@ extern "C" {
...
@@ -23,6 +23,8 @@ extern "C" {
#include "taosdef.h"
#include "taosdef.h"
#include "taosmsg.h"
#include "taosmsg.h"
#define TIME_IS_VAR_DURATION(_t) ((_t) == 'n' || (_t) == 'y' || (_t) == 'N' || (_t) == 'Y')
/*
/*
* @return timestamp decided by global conf variable, tsTimePrecision
* @return timestamp decided by global conf variable, tsTimePrecision
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
...
@@ -50,7 +52,6 @@ void deltaToUtcInitOnce();
...
@@ -50,7 +52,6 @@ void deltaToUtcInitOnce();
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
);
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/function/function.h
浏览文件 @
aa064709
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#ifndef TDENGINE_
T
FUNCTION_H
#ifndef TDENGINE_FUNCTION_H
#define TDENGINE_
T
FUNCTION_H
#define TDENGINE_FUNCTION_H
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
@@ -24,6 +24,8 @@ extern "C" {
...
@@ -24,6 +24,8 @@ extern "C" {
#include "tvariant.h"
#include "tvariant.h"
#include "tbuffer.h"
#include "tbuffer.h"
#define MAX_INTERVAL_TIME_WINDOW 1000000 // maximum allowed time windows in final results
#define FUNCTION_SCALAR 1
#define FUNCTION_SCALAR 1
#define FUNCTION_AGG 2
#define FUNCTION_AGG 2
...
@@ -184,6 +186,25 @@ typedef struct SResultDataInfo {
...
@@ -184,6 +186,25 @@ typedef struct SResultDataInfo {
int32_t
intermediateBytes
;
int32_t
intermediateBytes
;
}
SResultDataInfo
;
}
SResultDataInfo
;
typedef
struct
SMultiFunctionsDesc
{
bool
stableQuery
;
bool
groupbyColumn
;
bool
simpleAgg
;
bool
arithmeticOnAgg
;
bool
projectionQuery
;
bool
hasFilter
;
bool
onlyTagQuery
;
bool
orderProjectQuery
;
bool
stateWindow
;
bool
globalMerge
;
bool
multigroupResult
;
bool
blockDistribution
;
bool
timewindow
;
bool
topbotQuery
;
bool
interpQuery
;
}
SMultiFunctionsDesc
;
int32_t
getResultDataInfo
(
int32_t
dataType
,
int32_t
dataBytes
,
int32_t
functionId
,
int32_t
param
,
SResultDataInfo
*
pInfo
,
int16_t
extLength
,
int32_t
getResultDataInfo
(
int32_t
dataType
,
int32_t
dataBytes
,
int32_t
functionId
,
int32_t
param
,
SResultDataInfo
*
pInfo
,
int16_t
extLength
,
bool
isSuperTable
);
bool
isSuperTable
);
...
@@ -199,8 +220,10 @@ bool qIsValidUdf(SArray* pUdfInfo, const char* name, int32_t len, int32_t* funct
...
@@ -199,8 +220,10 @@ bool qIsValidUdf(SArray* pUdfInfo, const char* name, int32_t len, int32_t* funct
const
char
*
qGetFunctionName
(
int32_t
functionId
);
const
char
*
qGetFunctionName
(
int32_t
functionId
);
void
extractFunctionDesc
(
SArray
*
pFunctionIdList
,
SMultiFunctionsDesc
*
pDesc
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif // TDENGINE_
T
FUNCTION_H
#endif // TDENGINE_FUNCTION_H
include/libs/parser/parser.h
浏览文件 @
aa064709
...
@@ -24,6 +24,7 @@ extern "C" {
...
@@ -24,6 +24,7 @@ extern "C" {
#include "common.h"
#include "common.h"
#include "tname.h"
#include "tname.h"
#include "tvariant.h"
#include "tvariant.h"
#include "function.h"
typedef
struct
SColumn
{
typedef
struct
SColumn
{
uint64_t
tableUid
;
uint64_t
tableUid
;
...
@@ -130,20 +131,6 @@ typedef struct STableMetaInfo {
...
@@ -130,20 +131,6 @@ typedef struct STableMetaInfo {
SArray
*
tagColList
;
// SArray<SColumn*>, involved tag columns
SArray
*
tagColList
;
// SArray<SColumn*>, involved tag columns
}
STableMetaInfo
;
}
STableMetaInfo
;
typedef
struct
SQueryAttrInfo
{
bool
stableQuery
;
bool
groupbyColumn
;
bool
simpleAgg
;
bool
arithmeticOnAgg
;
bool
projectionQuery
;
bool
hasFilter
;
bool
onlyTagQuery
;
bool
orderProjectQuery
;
bool
stateWindow
;
bool
globalMerge
;
bool
multigroupResult
;
}
SQueryAttrInfo
;
typedef
struct
SQueryStmtInfo
{
typedef
struct
SQueryStmtInfo
{
int16_t
command
;
// the command may be different for each subclause, so keep it seperately.
int16_t
command
;
// the command may be different for each subclause, so keep it seperately.
uint32_t
type
;
// query/insert type
uint32_t
type
;
// query/insert type
...
@@ -177,7 +164,6 @@ typedef struct SQueryStmtInfo {
...
@@ -177,7 +164,6 @@ typedef struct SQueryStmtInfo {
int32_t
udColumnId
;
// current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
int32_t
udColumnId
;
// current user-defined constant output field column id, monotonically decreases from TSDB_UD_COLUMN_INDEX
bool
distinct
;
// distinct tag or not
bool
distinct
;
// distinct tag or not
bool
onlyHasTagCond
;
int32_t
bufLen
;
int32_t
bufLen
;
char
*
buf
;
char
*
buf
;
SArray
*
pUdfInfo
;
SArray
*
pUdfInfo
;
...
@@ -186,7 +172,7 @@ typedef struct SQueryStmtInfo {
...
@@ -186,7 +172,7 @@ typedef struct SQueryStmtInfo {
SArray
*
pUpstream
;
// SArray<struct SQueryStmtInfo>
SArray
*
pUpstream
;
// SArray<struct SQueryStmtInfo>
struct
SQueryStmtInfo
*
pDownstream
;
struct
SQueryStmtInfo
*
pDownstream
;
int32_t
havingFieldNum
;
int32_t
havingFieldNum
;
S
QueryAttrInfo
info
;
S
MultiFunctionsDesc
info
;
}
SQueryStmtInfo
;
}
SQueryStmtInfo
;
typedef
struct
SColumnIndex
{
typedef
struct
SColumnIndex
{
...
...
include/util/tdef.h
浏览文件 @
aa064709
...
@@ -303,7 +303,7 @@ do { \
...
@@ -303,7 +303,7 @@ do { \
#define TSDB_MAX_FIELD_LEN 16384
#define TSDB_MAX_FIELD_LEN 16384
#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define TSDB_MAX_BINARY_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define TSDB_MAX_NCHAR_LEN (TSDB_MAX_FIELD_LEN-TSDB_KEYSIZE) // keep 16384
#define PRIMARYKEY_TIMESTAMP_COL_I
NDEX
0
#define PRIMARYKEY_TIMESTAMP_COL_I
D
0
#define TSDB_MAX_RPC_THREADS 5
#define TSDB_MAX_RPC_THREADS 5
...
...
source/common/src/ttime.c
浏览文件 @
aa064709
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
* An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
* An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
* tomorrow - (allowable under ISO 8601) is supported.
* tomorrow - (allowable under ISO 8601) is supported.
*/
*/
int64_t
user_mktime64
(
const
unsigned
int
year0
,
const
unsigned
int
mon0
,
static
int64_t
user_mktime64
(
const
unsigned
int
year0
,
const
unsigned
int
mon0
,
const
unsigned
int
day
,
const
unsigned
int
hour
,
const
unsigned
int
day
,
const
unsigned
int
hour
,
const
unsigned
int
min
,
const
unsigned
int
sec
,
int64_t
time_zone
)
const
unsigned
int
min
,
const
unsigned
int
sec
,
int64_t
time_zone
)
{
{
...
@@ -79,19 +79,18 @@ void deltaToUtcInitOnce() {
...
@@ -79,19 +79,18 @@ void deltaToUtcInitOnce() {
(
void
)
strptime
(
"1970-01-01 00:00:00"
,
(
const
char
*
)(
"%Y-%m-%d %H:%M:%S"
),
&
tm
);
(
void
)
strptime
(
"1970-01-01 00:00:00"
,
(
const
char
*
)(
"%Y-%m-%d %H:%M:%S"
),
&
tm
);
m_deltaUtc
=
(
int64_t
)
mktime
(
&
tm
);
m_deltaUtc
=
(
int64_t
)
mktime
(
&
tm
);
//printf("====delta:%lld\n\n", seconds);
//printf("====delta:%lld\n\n", seconds);
return
;
}
}
static
int64_t
parseFraction
(
char
*
str
,
char
**
end
,
int32_t
timePrec
);
static
int64_t
parseFraction
(
char
*
str
,
char
**
end
,
int32_t
timePrec
);
static
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
);
static
int32_t
parseTimeWithTz
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
,
char
delim
);
static
int32_t
parseLocaltime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltime
With
Dst
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
int32_t
parseLocaltimeDst
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
);
static
char
*
forwardToTimeStringEnd
(
char
*
str
);
static
char
*
forwardToTimeStringEnd
(
char
*
str
);
static
bool
checkTzPresent
(
char
*
str
,
int32_t
len
);
static
bool
checkTzPresent
(
char
*
str
,
int32_t
len
);
static
int32_t
(
*
parseLocaltimeFp
[])
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
=
{
static
int32_t
(
*
parseLocaltimeFp
[])
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
=
{
parseLocaltime
,
parseLocaltime
,
parseLocaltime
With
Dst
parseLocaltimeDst
};
};
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
int32_t
taosParseTime
(
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
day_light
)
{
...
@@ -116,8 +115,8 @@ bool checkTzPresent(char *str, int32_t len) {
...
@@ -116,8 +115,8 @@ bool checkTzPresent(char *str, int32_t len) {
}
}
c
--
;
c
--
;
}
}
return
false
;
return
false
;
}
}
char
*
forwardToTimeStringEnd
(
char
*
str
)
{
char
*
forwardToTimeStringEnd
(
char
*
str
)
{
...
@@ -344,7 +343,7 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
...
@@ -344,7 +343,7 @@ int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec) {
return
0
;
return
0
;
}
}
int32_t
parseLocaltime
With
Dst
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
{
int32_t
parseLocaltimeDst
(
char
*
timestr
,
int64_t
*
time
,
int32_t
timePrec
)
{
*
time
=
0
;
*
time
=
0
;
struct
tm
tm
=
{
0
};
struct
tm
tm
=
{
0
};
tm
.
tm_isdst
=
-
1
;
tm
.
tm_isdst
=
-
1
;
...
...
source/libs/function/CMakeLists.txt
浏览文件 @
aa064709
...
@@ -7,6 +7,6 @@ target_include_directories(
...
@@ -7,6 +7,6 @@ target_include_directories(
)
)
target_link_libraries
(
target_link_libraries
(
function
function
PRIVATE os util common
PRIVATE os util common
)
)
\ No newline at end of file
source/libs/function/inc/taggfunction.h
浏览文件 @
aa064709
...
@@ -56,8 +56,6 @@ typedef struct SResultRowCellInfo {
...
@@ -56,8 +56,6 @@ typedef struct SResultRowCellInfo {
#define QUERY_DESC_FORWARD_STEP -1
#define QUERY_DESC_FORWARD_STEP -1
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
#define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP)
#define MAX_INTERVAL_TIME_WINDOW 1000000 // maximum allowed time windows in final results
#define TOP_BOTTOM_QUERY_LIMIT 100
#define TOP_BOTTOM_QUERY_LIMIT 100
enum
{
enum
{
...
...
source/libs/function/src/taggfunction.c
浏览文件 @
aa064709
...
@@ -513,7 +513,7 @@ static void count_func_merge(SQLFunctionCtx *pCtx) {
...
@@ -513,7 +513,7 @@ static void count_func_merge(SQLFunctionCtx *pCtx) {
* @return
* @return
*/
*/
int32_t
countRequired
(
SQLFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
int32_t
countRequired
(
SQLFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_I
NDEX
)
{
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_I
D
)
{
return
BLK_DATA_NO_NEEDED
;
return
BLK_DATA_NO_NEEDED
;
}
else
{
}
else
{
return
BLK_DATA_STATIS_NEEDED
;
return
BLK_DATA_STATIS_NEEDED
;
...
@@ -2303,10 +2303,10 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -2303,10 +2303,10 @@ static void top_bottom_func_finalizer(SQLFunctionCtx *pCtx) {
tValuePair
**
tvp
=
pRes
->
res
;
tValuePair
**
tvp
=
pRes
->
res
;
// user specify the order of output by sort the result according to timestamp
// user specify the order of output by sort the result according to timestamp
if
(
pCtx
->
param
[
1
].
i64
==
PRIMARYKEY_TIMESTAMP_COL_I
NDEX
)
{
if
(
pCtx
->
param
[
1
].
i64
==
PRIMARYKEY_TIMESTAMP_COL_I
D
)
{
__compar_fn_t
comparator
=
(
pCtx
->
param
[
2
].
i64
==
TSDB_ORDER_ASC
)
?
resAscComparFn
:
resDescComparFn
;
__compar_fn_t
comparator
=
(
pCtx
->
param
[
2
].
i64
==
TSDB_ORDER_ASC
)
?
resAscComparFn
:
resDescComparFn
;
qsort
(
tvp
,
(
size_t
)
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
qsort
(
tvp
,
(
size_t
)
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
}
else
/*if (pCtx->param[1].i64 > PRIMARYKEY_TIMESTAMP_COL_I
NDEX
)*/
{
}
else
/*if (pCtx->param[1].i64 > PRIMARYKEY_TIMESTAMP_COL_I
D
)*/
{
__compar_fn_t
comparator
=
(
pCtx
->
param
[
2
].
i64
==
TSDB_ORDER_ASC
)
?
resDataAscComparFn
:
resDataDescComparFn
;
__compar_fn_t
comparator
=
(
pCtx
->
param
[
2
].
i64
==
TSDB_ORDER_ASC
)
?
resDataAscComparFn
:
resDataDescComparFn
;
qsort
(
tvp
,
(
size_t
)
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
qsort
(
tvp
,
(
size_t
)
pResInfo
->
numOfRes
,
POINTER_BYTES
,
comparator
);
}
}
...
...
source/libs/function/src/texpr.c
浏览文件 @
aa064709
...
@@ -128,18 +128,26 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) {
...
@@ -128,18 +128,26 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) {
if
(
*
pExpr
==
NULL
)
{
if
(
*
pExpr
==
NULL
)
{
return
;
return
;
}
}
if
((
*
pExpr
)
->
nodeType
==
TEXPR_BINARYEXPR_NODE
)
{
int32_t
type
=
(
*
pExpr
)
->
nodeType
;
if
(
type
==
TEXPR_BINARYEXPR_NODE
)
{
doExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pLeft
,
fp
);
doExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pLeft
,
fp
);
doExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pRight
,
fp
);
doExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pRight
,
fp
);
if
(
fp
!=
NULL
)
{
if
(
fp
!=
NULL
)
{
fp
((
*
pExpr
)
->
_node
.
info
);
fp
((
*
pExpr
)
->
_node
.
info
);
}
}
}
else
if
((
*
pExpr
)
->
nodeType
==
TEXPR_VALUE_NODE
)
{
}
else
if
(
type
==
TEXPR_UNARYEXPR_NODE
)
{
doExprTreeDestroy
(
&
(
*
pExpr
)
->
_node
.
pLeft
,
fp
);
if
(
fp
!=
NULL
)
{
fp
((
*
pExpr
)
->
_node
.
info
);
}
assert
((
*
pExpr
)
->
_node
.
pRight
==
NULL
);
}
else
if
(
type
==
TEXPR_VALUE_NODE
)
{
taosVariantDestroy
((
*
pExpr
)
->
pVal
);
taosVariantDestroy
((
*
pExpr
)
->
pVal
);
free
((
*
pExpr
)
->
pVal
);
free
((
*
pExpr
)
->
pVal
);
}
else
if
(
(
*
pExpr
)
->
nodeT
ype
==
TEXPR_COL_NODE
)
{
}
else
if
(
t
ype
==
TEXPR_COL_NODE
)
{
free
((
*
pExpr
)
->
pSchema
);
free
((
*
pExpr
)
->
pSchema
);
}
}
...
...
source/libs/function/src/tfunction.c
浏览文件 @
aa064709
...
@@ -52,7 +52,7 @@ bool isTagsQuery(SArray* pFunctionIdList) {
...
@@ -52,7 +52,7 @@ bool isTagsQuery(SArray* pFunctionIdList) {
int16_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
int16_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
// "select count(tbname)" query
// "select count(tbname)" query
// if (functId == FUNCTION_COUNT && pExpr->base.col
Info.
colId == TSDB_TBNAME_COLUMN_INDEX) {
// if (functId == FUNCTION_COUNT && pExpr->base.col
pDesc->
colId == TSDB_TBNAME_COLUMN_INDEX) {
// continue;
// continue;
// }
// }
...
@@ -80,19 +80,6 @@ bool isTagsQuery(SArray* pFunctionIdList) {
...
@@ -80,19 +80,6 @@ bool isTagsQuery(SArray* pFunctionIdList) {
// return false;
// return false;
//}
//}
bool
isBlockInfoQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
f
==
FUNCTION_BLKINFO
)
{
return
true
;
}
}
return
false
;
}
bool
isProjectionQuery
(
SArray
*
pFunctionIdList
)
{
bool
isProjectionQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
...
@@ -101,8 +88,12 @@ bool isProjectionQuery(SArray* pFunctionIdList) {
...
@@ -101,8 +88,12 @@ bool isProjectionQuery(SArray* pFunctionIdList) {
continue
;
continue
;
}
}
if
(
f
!=
FUNCTION_PRJ
&&
f
!=
FUNCTION_TAGPRJ
&&
f
!=
FUNCTION_TAG
&&
if
(
f
!=
FUNCTION_PRJ
&&
f
!=
FUNCTION_TS
&&
f
!=
FUNCTION_ARITHM
&&
f
!=
FUNCTION_DIFF
&&
f
!=
FUNCTION_TAGPRJ
&&
f
!=
FUNCTION_TAG
&&
f
!=
FUNCTION_TS
&&
f
!=
FUNCTION_ARITHM
&&
f
!=
FUNCTION_DIFF
&&
f
!=
FUNCTION_DERIVATIVE
)
{
f
!=
FUNCTION_DERIVATIVE
)
{
return
false
;
return
false
;
}
}
...
@@ -111,7 +102,7 @@ bool isProjectionQuery(SArray* pFunctionIdList) {
...
@@ -111,7 +102,7 @@ bool isProjectionQuery(SArray* pFunctionIdList) {
return
true
;
return
true
;
}
}
bool
isDiffDerivQuery
(
SArray
*
pFunctionIdList
)
{
bool
isDiffDeriv
ative
Query
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
...
@@ -127,7 +118,7 @@ bool isDiffDerivQuery(SArray* pFunctionIdList) {
...
@@ -127,7 +118,7 @@ bool isDiffDerivQuery(SArray* pFunctionIdList) {
return
false
;
return
false
;
}
}
bool
is
Point
InterpQuery
(
SArray
*
pFunctionIdList
)
{
bool
isInterpQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
...
@@ -264,8 +255,6 @@ bool needReverseScan(SArray* pFunctionIdList) {
...
@@ -264,8 +255,6 @@ bool needReverseScan(SArray* pFunctionIdList) {
}
}
bool
isSimpleAggregateRv
(
SArray
*
pFunctionIdList
)
{
bool
isSimpleAggregateRv
(
SArray
*
pFunctionIdList
)
{
assert
(
0
);
// if (pQueryInfo->interval.interval > 0 || pQueryInfo->sessionWindow.gap > 0) {
// if (pQueryInfo->interval.interval > 0 || pQueryInfo->sessionWindow.gap > 0) {
// return false;
// return false;
// }
// }
...
@@ -380,33 +369,17 @@ bool isProjectionQueryOnSTable(SArray* pFunctionIdList, int32_t tableIndex) {
...
@@ -380,33 +369,17 @@ bool isProjectionQueryOnSTable(SArray* pFunctionIdList, int32_t tableIndex) {
}
}
bool
hasTagValOutput
(
SArray
*
pFunctionIdList
)
{
bool
hasTagValOutput
(
SArray
*
pFunctionIdList
)
{
// size_t numOfExprs = getNumOfExprs(pQueryInfo);
size_t
size
=
taosArrayGetSize
(
pFunctionIdList
);
// SExprInfo* pExpr1 = getExprInfo(pQueryInfo, 0);
//
// if (numOfExprs == 1 && pExpr1->base.functionId == FUNCTION_TS_COMP) {
// if (numOfExprs == 1 && pExpr1->base.functionId == FUNCTION_TS_COMP) {
// return true;
// return true;
// }
//
// for (int32_t i = 0; i < numOfExprs; ++i) {
// SExprInfo* pExpr = getExprInfo(pQueryInfo, i);
// if (pExpr == NULL) {
// continue;
// }
//
// // ts_comp column required the tag value for join filter
// if (TSDB_COL_IS_TAG(pExpr->base.colInfo.flag)) {
// return true;
// }
// }
// }
return
false
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
}
int32_t
functionId
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
bool
timeWindowInterpoRequired
(
SArray
*
pFunctionIdList
)
{
// ts_comp column required the tag value for join filter
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
if
(
functionId
==
FUNCTION_TAG
||
functionId
==
FUNCTION_TAGPRJ
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
f
==
FUNCTION_TWA
||
f
==
FUNCTION_INTERP
)
{
return
true
;
return
true
;
}
}
}
}
...
@@ -414,8 +387,28 @@ bool timeWindowInterpoRequired(SArray* pFunctionIdList) {
...
@@ -414,8 +387,28 @@ bool timeWindowInterpoRequired(SArray* pFunctionIdList) {
return
false
;
return
false
;
}
}
//SQueryAttrInfo setQueryType(SArray* pFunctionIdList) {
//bool timeWindowInterpoRequired(SArray* pFunctionIdList) {
// assert(pFunctionIdList != NULL);
// int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
//
// for (int32_t i = 0; i < num; ++i) {
// int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
// if (f == FUNCTION_TWA || f == FUNCTION_INTERP) {
// return true;
// }
// }
//
//
//}
// return false;
\ No newline at end of file
//}
void
extractFunctionDesc
(
SArray
*
pFunctionIdList
,
SMultiFunctionsDesc
*
pDesc
)
{
assert
(
pFunctionIdList
!=
NULL
);
pDesc
->
blockDistribution
=
isBlockDistQuery
(
pFunctionIdList
);
if
(
pDesc
->
blockDistribution
)
{
return
;
}
pDesc
->
projectionQuery
=
isProjectionQuery
(
pFunctionIdList
);
pDesc
->
onlyTagQuery
=
isTagsQuery
(
pFunctionIdList
);
pDesc
->
interpQuery
=
isInterpQuery
(
pFunctionIdList
);
}
source/libs/parser/inc/astGenerator.h
浏览文件 @
aa064709
...
@@ -298,7 +298,7 @@ void* destroyCreateTableSql(SCreateTableSql* pCreate);
...
@@ -298,7 +298,7 @@ void* destroyCreateTableSql(SCreateTableSql* pCreate);
void
setDropFuncInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SToken
*
pToken
);
void
setDropFuncInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SToken
*
pToken
);
void
setCreateFuncInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SToken
*
pName
,
SToken
*
pPath
,
SField
*
output
,
SToken
*
bufSize
,
int32_t
funcType
);
void
setCreateFuncInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SToken
*
pName
,
SToken
*
pPath
,
SField
*
output
,
SToken
*
bufSize
,
int32_t
funcType
);
void
SqlInfoDestroy
(
SSqlInfo
*
pInfo
);
void
destroySqlInfo
(
SSqlInfo
*
pInfo
);
void
setDCLSqlElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDCLSqlElems
(
SSqlInfo
*
pInfo
,
int32_t
type
,
int32_t
nParams
,
...);
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SToken
*
pToken
,
SToken
*
existsCheck
,
int16_t
dbType
,
int16_t
tableType
);
void
setDropDbTableInfo
(
SSqlInfo
*
pInfo
,
int32_t
type
,
SToken
*
pToken
,
SToken
*
existsCheck
,
int16_t
dbType
,
int16_t
tableType
);
...
...
source/libs/parser/inc/parserInt.h
浏览文件 @
aa064709
...
@@ -73,7 +73,9 @@ int32_t evaluateSqlNode(SSqlNode* pNode, int32_t tsPrecision, SMsgBuf* pMsgBuf);
...
@@ -73,7 +73,9 @@ int32_t evaluateSqlNode(SSqlNode* pNode, int32_t tsPrecision, SMsgBuf* pMsgBuf);
int32_t
validateSqlNode
(
SSqlNode
*
pSqlNode
,
SQueryStmtInfo
*
pQueryInfo
,
SMsgBuf
*
pMsgBuf
);
int32_t
validateSqlNode
(
SSqlNode
*
pSqlNode
,
SQueryStmtInfo
*
pQueryInfo
,
SMsgBuf
*
pMsgBuf
);
void
initQueryInfo
(
SQueryStmtInfo
*
pQueryInfo
);
SQueryStmtInfo
*
createQueryInfo
();
void
destroyQueryInfo
(
SQueryStmtInfo
*
pQueryInfo
);
int32_t
checkForInvalidExpr
(
SQueryStmtInfo
*
pQueryInfo
,
SMsgBuf
*
pMsgBuf
);
int32_t
checkForInvalidExpr
(
SQueryStmtInfo
*
pQueryInfo
,
SMsgBuf
*
pMsgBuf
);
...
@@ -87,6 +89,12 @@ int32_t checkForInvalidExpr(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
...
@@ -87,6 +89,12 @@ int32_t checkForInvalidExpr(SQueryStmtInfo* pQueryInfo, SMsgBuf* pMsgBuf);
*/
*/
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SMetaReq
*
pMetaInfo
,
char
*
msg
,
int32_t
msgBufLen
);
int32_t
qParserExtractRequestedMetaInfo
(
const
SSqlInfo
*
pSqlInfo
,
SMetaReq
*
pMetaInfo
,
char
*
msg
,
int32_t
msgBufLen
);
/**
* Destroy the meta data request structure.
* @param pMetaInfo
*/
void
qParserClearupMetaRequestInfo
(
SMetaReq
*
pMetaInfo
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/parser/inc/queryInfoUtil.h
浏览文件 @
aa064709
...
@@ -30,9 +30,7 @@ SSchema *getTableTagSchema(const STableMeta* pTableMeta);
...
@@ -30,9 +30,7 @@ SSchema *getTableTagSchema(const STableMeta* pTableMeta);
SSchema
*
getOneColumnSchema
(
const
STableMeta
*
pTableMeta
,
int32_t
colIndex
);
SSchema
*
getOneColumnSchema
(
const
STableMeta
*
pTableMeta
,
int32_t
colIndex
);
size_t
getNumOfExprs
(
SQueryStmtInfo
*
pQueryInfo
);
size_t
getNumOfExprs
(
SQueryStmtInfo
*
pQueryInfo
);
//SExprInfo* createExprInfo(STableMetaInfo* pTableMetaInfo, int16_t functionId, SColumnIndex* pColIndex, struct tExprNode* pParamExpr, SSchema* pResSchema, int16_t interSize);
SExprInfo
*
createBinaryExprInfo
(
struct
tExprNode
*
pNode
,
SSchema
*
pResSchema
);
SExprInfo
*
createBinaryExprInfo
(
struct
tExprNode
*
pNode
,
SSchema
*
pResSchema
);
void
destroyExprInfoList
();
void
addExprInfo
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
index
,
SExprInfo
*
pExprInfo
);
void
addExprInfo
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
index
,
SExprInfo
*
pExprInfo
);
void
updateExprInfo
(
SExprInfo
*
pExprInfo
,
int16_t
functionId
,
int32_t
colId
,
int16_t
srcColumnIndex
,
int16_t
resType
,
int16_t
resSize
);
void
updateExprInfo
(
SExprInfo
*
pExprInfo
,
int16_t
functionId
,
int32_t
colId
,
int16_t
srcColumnIndex
,
int16_t
resType
,
int16_t
resSize
);
...
@@ -42,9 +40,11 @@ int32_t copyAllExprInfo(SArray* dst, const SArray* src, bool deepcopy);
...
@@ -42,9 +40,11 @@ int32_t copyAllExprInfo(SArray* dst, const SArray* src, bool deepcopy);
void
addExprInfoParam
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
);
void
addExprInfoParam
(
SSqlExpr
*
pExpr
,
char
*
argument
,
int32_t
type
,
int32_t
bytes
);
int32_t
getExprFunctionId
(
SExprInfo
*
pExprInfo
);
void
cleanupFieldInfo
(
SFieldInfo
*
pFieldInfo
);
void
cleanupFieldInfo
(
SFieldInfo
*
pFieldInfo
);
STableComInfo
getTableInfo
(
const
STableMeta
*
pTableMeta
);
STableComInfo
getTableInfo
(
const
STableMeta
*
pTableMeta
);
SArray
*
extractFunctionIdList
(
SArray
*
pExprInfoList
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/parser/src/astGenerator.c
浏览文件 @
aa064709
...
@@ -242,7 +242,6 @@ tSqlExpr *tSqlExprClone(tSqlExpr *pSrc) {
...
@@ -242,7 +242,6 @@ tSqlExpr *tSqlExprClone(tSqlExpr *pSrc) {
}
}
void
tSqlExprCompact
(
tSqlExpr
**
pExpr
)
{
void
tSqlExprCompact
(
tSqlExpr
**
pExpr
)
{
if
(
*
pExpr
==
NULL
||
tSqlExprIsParentOfLeaf
(
*
pExpr
))
{
if
(
*
pExpr
==
NULL
||
tSqlExprIsParentOfLeaf
(
*
pExpr
))
{
return
;
return
;
}
}
...
@@ -770,8 +769,11 @@ void setCreateFuncInfo(SSqlInfo *pInfo, int32_t type, SToken *pName, SToken *pPa
...
@@ -770,8 +769,11 @@ void setCreateFuncInfo(SSqlInfo *pInfo, int32_t type, SToken *pName, SToken *pPa
}
}
}
}
void
SqlInfoDestroy
(
SSqlInfo
*
pInfo
)
{
void
destroySqlInfo
(
SSqlInfo
*
pInfo
)
{
if
(
pInfo
==
NULL
)
return
;;
if
(
pInfo
==
NULL
)
{
return
;
}
taosArrayDestroy
(
pInfo
->
funcs
);
taosArrayDestroy
(
pInfo
->
funcs
);
if
(
pInfo
->
type
==
TSDB_SQL_SELECT
)
{
if
(
pInfo
->
type
==
TSDB_SQL_SELECT
)
{
destroyAllSqlNode
(
pInfo
->
list
);
destroyAllSqlNode
(
pInfo
->
list
);
...
...
source/libs/parser/src/astValidate.c
浏览文件 @
aa064709
此差异已折叠。
点击以展开。
source/libs/parser/src/parser.c
浏览文件 @
aa064709
...
@@ -185,4 +185,13 @@ int32_t qParserExtractRequestedMetaInfo(const SSqlInfo* pSqlInfo, SMetaReq* pMet
...
@@ -185,4 +185,13 @@ int32_t qParserExtractRequestedMetaInfo(const SSqlInfo* pSqlInfo, SMetaReq* pMet
}
}
return
code
;
return
code
;
}
}
\ No newline at end of file
void
qParserClearupMetaRequestInfo
(
SMetaReq
*
pMetaReq
)
{
if
(
pMetaReq
==
NULL
)
{
return
;
}
taosArrayDestroy
(
pMetaReq
->
pTableName
);
taosArrayDestroy
(
pMetaReq
->
pUdf
);
}
source/libs/parser/src/parserUtil.c
浏览文件 @
aa064709
...
@@ -576,13 +576,6 @@ TAOS_FIELD* getFieldInfo(SFieldInfo* pFieldInfo, int32_t index) {
...
@@ -576,13 +576,6 @@ TAOS_FIELD* getFieldInfo(SFieldInfo* pFieldInfo, int32_t index) {
return
&
((
SInternalField
*
)
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
index
))
->
field
;
return
&
((
SInternalField
*
)
TARRAY_GET_ELEM
(
pFieldInfo
->
internalField
,
index
))
->
field
;
}
}
int16_t
getFieldInfoOffset
(
SQueryStmtInfo
*
pQueryInfo
,
int32_t
index
)
{
SInternalField
*
pInfo
=
getInternalField
(
&
pQueryInfo
->
fieldsInfo
,
index
);
assert
(
pInfo
!=
NULL
&&
pInfo
->
pExpr
->
pExpr
==
NULL
);
return
0
;
// return pInfo->pExpr->base.offset;
}
int32_t
fieldInfoCompare
(
const
SFieldInfo
*
pFieldInfo1
,
const
SFieldInfo
*
pFieldInfo2
,
int32_t
*
diffSize
)
{
int32_t
fieldInfoCompare
(
const
SFieldInfo
*
pFieldInfo1
,
const
SFieldInfo
*
pFieldInfo2
,
int32_t
*
diffSize
)
{
assert
(
pFieldInfo1
!=
NULL
&&
pFieldInfo2
!=
NULL
);
assert
(
pFieldInfo1
!=
NULL
&&
pFieldInfo2
!=
NULL
);
...
@@ -780,8 +773,8 @@ SColumn* columnListInsert(SArray* pColumnList, int32_t columnIndex, uint64_t uid
...
@@ -780,8 +773,8 @@ SColumn* columnListInsert(SArray* pColumnList, int32_t columnIndex, uint64_t uid
}
}
SColumn
*
insertPrimaryTsColumn
(
SArray
*
pColumnList
,
uint64_t
tableUid
)
{
SColumn
*
insertPrimaryTsColumn
(
SArray
*
pColumnList
,
uint64_t
tableUid
)
{
SSchema
s
=
{.
type
=
TSDB_DATA_TYPE_TIMESTAMP
,
.
bytes
=
TSDB_KEYSIZE
,
.
colId
=
PRIMARYKEY_TIMESTAMP_COL_I
NDEX
};
SSchema
s
=
{.
type
=
TSDB_DATA_TYPE_TIMESTAMP
,
.
bytes
=
TSDB_KEYSIZE
,
.
colId
=
PRIMARYKEY_TIMESTAMP_COL_I
D
};
return
columnListInsert
(
pColumnList
,
PRIMARYKEY_TIMESTAMP_COL_I
NDEX
,
tableUid
,
&
s
);
return
columnListInsert
(
pColumnList
,
PRIMARYKEY_TIMESTAMP_COL_I
D
,
tableUid
,
&
s
);
}
}
void
columnCopy
(
SColumn
*
pDest
,
const
SColumn
*
pSrc
);
void
columnCopy
(
SColumn
*
pDest
,
const
SColumn
*
pSrc
);
...
...
source/libs/parser/src/queryInfoUtil.c
浏览文件 @
aa064709
#include "queryInfoUtil.h"
#include "queryInfoUtil.h"
#include <function.h>
#include "astGenerator.h"
#include "astGenerator.h"
#include "function.h"
#include "function.h"
#include "os.h"
#include "os.h"
...
@@ -55,7 +56,6 @@ SSchema* getTableTagSchema(const STableMeta* pTableMeta) {
...
@@ -55,7 +56,6 @@ SSchema* getTableTagSchema(const STableMeta* pTableMeta) {
}
}
static
tExprNode
*
createUnaryFunctionExprNode
(
int32_t
functionId
,
SSchema
*
pSchema
,
tExprNode
*
pColumnNode
)
{
static
tExprNode
*
createUnaryFunctionExprNode
(
int32_t
functionId
,
SSchema
*
pSchema
,
tExprNode
*
pColumnNode
)
{
if
(
pColumnNode
==
NULL
)
{
if
(
pColumnNode
==
NULL
)
{
pColumnNode
=
calloc
(
1
,
sizeof
(
tExprNode
));
pColumnNode
=
calloc
(
1
,
sizeof
(
tExprNode
));
pColumnNode
->
nodeType
=
TEXPR_COL_NODE
;
pColumnNode
->
nodeType
=
TEXPR_COL_NODE
;
...
@@ -167,6 +167,10 @@ SExprInfo* getExprInfo(SQueryStmtInfo* pQueryInfo, int32_t index) {
...
@@ -167,6 +167,10 @@ SExprInfo* getExprInfo(SQueryStmtInfo* pQueryInfo, int32_t index) {
void
destroyExprInfo
(
SExprInfo
*
pExprInfo
)
{
void
destroyExprInfo
(
SExprInfo
*
pExprInfo
)
{
tExprTreeDestroy
(
pExprInfo
->
pExpr
,
NULL
);
tExprTreeDestroy
(
pExprInfo
->
pExpr
,
NULL
);
for
(
int32_t
i
=
0
;
i
<
pExprInfo
->
base
.
numOfParams
;
++
i
)
{
taosVariantDestroy
(
&
pExprInfo
->
base
.
param
[
i
]);
}
tfree
(
pExprInfo
);
tfree
(
pExprInfo
);
}
}
...
@@ -192,6 +196,11 @@ void addExprInfoParam(SSqlExpr* pExpr, char* argument, int32_t type, int32_t byt
...
@@ -192,6 +196,11 @@ void addExprInfoParam(SSqlExpr* pExpr, char* argument, int32_t type, int32_t byt
assert
(
pExpr
->
numOfParams
<=
3
);
assert
(
pExpr
->
numOfParams
<=
3
);
}
}
int32_t
getExprFunctionId
(
SExprInfo
*
pExprInfo
)
{
assert
(
pExprInfo
!=
NULL
&&
pExprInfo
->
pExpr
!=
NULL
&&
pExprInfo
->
pExpr
->
nodeType
==
TEXPR_UNARYEXPR_NODE
);
return
pExprInfo
->
pExpr
->
_node
.
functionId
;
}
void
assignExprInfo
(
SExprInfo
*
dst
,
const
SExprInfo
*
src
)
{
void
assignExprInfo
(
SExprInfo
*
dst
,
const
SExprInfo
*
src
)
{
assert
(
dst
!=
NULL
&&
src
!=
NULL
);
assert
(
dst
!=
NULL
&&
src
!=
NULL
);
...
@@ -284,62 +293,11 @@ int32_t getResRowLength(SArray* pExprList) {
...
@@ -284,62 +293,11 @@ int32_t getResRowLength(SArray* pExprList) {
return
size
;
return
size
;
}
}
static
void
freeQueryInfoImpl
(
SQueryStmtInfo
*
pQueryInfo
)
{
cleanupTagCond
(
&
pQueryInfo
->
tagCond
);
cleanupColumnCond
(
&
pQueryInfo
->
colCond
);
cleanupFieldInfo
(
&
pQueryInfo
->
fieldsInfo
);
dropAllExprInfo
(
pQueryInfo
->
exprList
);
pQueryInfo
->
exprList
=
NULL
;
if
(
pQueryInfo
->
exprList1
!=
NULL
)
{
dropAllExprInfo
(
pQueryInfo
->
exprList1
);
pQueryInfo
->
exprList1
=
NULL
;
}
columnListDestroy
(
pQueryInfo
->
colList
);
pQueryInfo
->
colList
=
NULL
;
if
(
pQueryInfo
->
groupbyExpr
.
columnInfo
!=
NULL
)
{
taosArrayDestroy
(
pQueryInfo
->
groupbyExpr
.
columnInfo
);
pQueryInfo
->
groupbyExpr
.
columnInfo
=
NULL
;
}
pQueryInfo
->
fillType
=
0
;
tfree
(
pQueryInfo
->
fillVal
);
tfree
(
pQueryInfo
->
buf
);
taosArrayDestroy
(
pQueryInfo
->
pUpstream
);
pQueryInfo
->
pUpstream
=
NULL
;
pQueryInfo
->
bufLen
=
0
;
}
void
freeQueryInfo
(
SQueryStmtInfo
*
pQueryInfo
,
bool
removeCachedMeta
,
uint64_t
id
)
{
while
(
pQueryInfo
!=
NULL
)
{
SQueryStmtInfo
*
p
=
pQueryInfo
->
sibling
;
size_t
numOfUpstream
=
taosArrayGetSize
(
pQueryInfo
->
pUpstream
);
for
(
int32_t
i
=
0
;
i
<
numOfUpstream
;
++
i
)
{
SQueryStmtInfo
*
pUpQueryInfo
=
taosArrayGetP
(
pQueryInfo
->
pUpstream
,
i
);
freeQueryInfoImpl
(
pUpQueryInfo
);
clearAllTableMetaInfo
(
pUpQueryInfo
,
removeCachedMeta
,
id
);
tfree
(
pUpQueryInfo
);
}
freeQueryInfoImpl
(
pQueryInfo
);
clearAllTableMetaInfo
(
pQueryInfo
,
removeCachedMeta
,
id
);
tfree
(
pQueryInfo
);
pQueryInfo
=
p
;
}
}
SArray
*
extractFunctionIdList
(
SArray
*
pExprInfoList
)
{
SArray
*
extractFunctionIdList
(
SArray
*
pExprInfoList
)
{
assert
(
pExprInfoList
!=
NULL
);
assert
(
pExprInfoList
!=
NULL
);
size_t
len
=
taosArrayGetSize
(
pExprInfoList
);
size_t
len
=
taosArrayGetSize
(
pExprInfoList
);
SArray
*
p
=
taosArrayInit
(
len
,
sizeof
(
int
16
_t
));
SArray
*
p
=
taosArrayInit
(
len
,
sizeof
(
int
32
_t
));
for
(
int32_t
i
=
0
;
i
<
len
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
len
;
++
i
)
{
SExprInfo
*
pExprInfo
=
taosArrayGetP
(
pExprInfoList
,
i
);
SExprInfo
*
pExprInfo
=
taosArrayGetP
(
pExprInfoList
,
i
);
taosArrayPush
(
p
,
&
pExprInfo
->
pExpr
->
_node
.
functionId
);
taosArrayPush
(
p
,
&
pExprInfo
->
pExpr
->
_node
.
functionId
);
...
...
source/libs/parser/test/CMakeLists.txt
浏览文件 @
aa064709
...
@@ -5,14 +5,14 @@ MESSAGE(STATUS "build parser unit test")
...
@@ -5,14 +5,14 @@ MESSAGE(STATUS "build parser unit test")
SET
(
CMAKE_CXX_STANDARD 11
)
SET
(
CMAKE_CXX_STANDARD 11
)
AUX_SOURCE_DIRECTORY
(
${
CMAKE_CURRENT_SOURCE_DIR
}
SOURCE_LIST
)
AUX_SOURCE_DIRECTORY
(
${
CMAKE_CURRENT_SOURCE_DIR
}
SOURCE_LIST
)
ADD_EXECUTABLE
(
ast
Test
${
SOURCE_LIST
}
)
ADD_EXECUTABLE
(
parser
Test
${
SOURCE_LIST
}
)
TARGET_LINK_LIBRARIES
(
TARGET_LINK_LIBRARIES
(
ast
Test
parser
Test
PUBLIC os util common parser catalog transport gtest
PUBLIC os util common parser catalog transport gtest
function
)
)
TARGET_INCLUDE_DIRECTORIES
(
TARGET_INCLUDE_DIRECTORIES
(
ast
Test
parser
Test
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/parser/"
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/libs/parser/"
PRIVATE
"
${
CMAKE_SOURCE_DIR
}
/source/libs/parser/inc"
PRIVATE
"
${
CMAKE_SOURCE_DIR
}
/source/libs/parser/inc"
)
)
source/libs/parser/test/parserTests.cpp
浏览文件 @
aa064709
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <function.h>
#include <gtest/gtest.h>
#include <gtest/gtest.h>
#include <iostream>
#include <iostream>
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wwrite-strings"
...
@@ -65,61 +66,64 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -65,61 +66,64 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
}
}
}
}
//TEST(testCase, validateAST_test) {
TEST
(
testCase
,
validateAST_test
)
{
// SSqlInfo info1 = doGenerateAST("select a a1111, a+b + 22, tbname from `t.1abc` where ts<now+2h and `col` < 20 + 99");
SSqlInfo
info1
=
doGenerateAST
(
"select a a1111, a+b + 22, tbname from `t.1abc` where ts<now+2h and `col` < 20 + 99"
);
// ASSERT_EQ(info1.valid, true);
ASSERT_EQ
(
info1
.
valid
,
true
);
//
// char msg[128] = {0};
char
msg
[
128
]
=
{
0
};
// SMsgBuf buf;
SMsgBuf
buf
;
// buf.len = 128;
buf
.
len
=
128
;
// buf.buf = msg;
buf
.
buf
=
msg
;
//
// SSqlNode* pNode = (SSqlNode*) taosArrayGetP(((SArray*)info1.list), 0);
SSqlNode
*
pNode
=
(
SSqlNode
*
)
taosArrayGetP
(((
SArray
*
)
info1
.
list
),
0
);
// int32_t code = evaluateSqlNode(pNode, TSDB_TIME_PRECISION_NANO, &buf);
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
// ASSERT_EQ(code, 0);
ASSERT_EQ
(
code
,
0
);
//
// SMetaReq req = {0};
SMetaReq
req
=
{
0
};
// int32_t ret = qParserExtractRequestedMetaInfo(&info1, &req, msg, 128);
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
// ASSERT_EQ(ret, 0);
ASSERT_EQ
(
ret
,
0
);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
//
// SQueryStmtInfo* pQueryInfo = (SQueryStmtInfo*)calloc(1, sizeof(SQueryStmtInfo));
SQueryStmtInfo
*
pQueryInfo
=
createQueryInfo
();
// initQueryInfo(pQueryInfo);
setTableMetaInfo
(
pQueryInfo
,
&
req
);
// setTableMetaInfo(pQueryInfo, &req);
//
SSqlNode
*
pSqlNode
=
(
SSqlNode
*
)
taosArrayGetP
(
info1
.
list
,
0
);
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
ret
=
validateSqlNode
(
pSqlNode
,
pQueryInfo
,
&
buf
);
// ret = validateSqlNode(pSqlNode, pQueryInfo, &buf);
//
SArray
*
pExprList
=
pQueryInfo
->
exprList
;
// SArray* pExprList = pQueryInfo->exprList;
ASSERT_EQ
(
taosArrayGetSize
(
pExprList
),
3
);
// ASSERT_EQ(taosArrayGetSize(pExprList), 3);
//
SExprInfo
*
p1
=
(
SExprInfo
*
)
taosArrayGetP
(
pExprList
,
0
);
// SExprInfo* p1 = (SExprInfo*) taosArrayGetP(pExprList, 0);
ASSERT_EQ
(
p1
->
base
.
uid
,
110
);
// ASSERT_EQ(p1->base.uid, 110);
ASSERT_EQ
(
p1
->
base
.
numOfParams
,
0
);
// ASSERT_EQ(p1->base.numOfParams, 0);
ASSERT_EQ
(
p1
->
base
.
resSchema
.
type
,
TSDB_DATA_TYPE_INT
);
// ASSERT_EQ(p1->base.resSchema.type, TSDB_DATA_TYPE_INT);
ASSERT_STRCASEEQ
(
p1
->
base
.
resSchema
.
name
,
"a1111"
);
// ASSERT_STRCASEEQ(p1->base.resSchema.name, "a1111");
ASSERT_STRCASEEQ
(
p1
->
base
.
colInfo
.
name
,
"t.1abc.a"
);
// ASSERT_STRCASEEQ(p1->base.colInfo.name, "t.1abc.a");
ASSERT_EQ
(
p1
->
base
.
colInfo
.
colId
,
1
);
ASSERT_EQ
(
p1
->
base
.
colInfo
.
flag
,
TSDB_COL_NORMAL
);
ASSERT_STRCASEEQ
(
p1
->
base
.
token
,
"a"
);
ASSERT_EQ
(
taosArrayGetSize
(
pExprList
),
3
);
SExprInfo
*
p2
=
(
SExprInfo
*
)
taosArrayGetP
(
pExprList
,
1
);
ASSERT_EQ
(
p2
->
base
.
uid
,
0
);
ASSERT_EQ
(
p2
->
base
.
numOfParams
,
1
);
// it is the serialized binary string of expression.
ASSERT_EQ
(
p2
->
base
.
resSchema
.
type
,
TSDB_DATA_TYPE_DOUBLE
);
ASSERT_STRCASEEQ
(
p2
->
base
.
resSchema
.
name
,
"a+b + 22"
);
// ASSERT_STRCASEEQ(p2->base.colInfo.name, "t.1abc.a");
// ASSERT_EQ(p1->base.colInfo.colId, 1);
// ASSERT_EQ(p1->base.colInfo.colId, 1);
// ASSERT_EQ(p1->base.colInfo.flag, TSDB_COL_NORMAL);
// ASSERT_EQ(p1->base.colInfo.flag, TSDB_COL_NORMAL);
// ASSERT_STRCASEEQ(p1->base.token, "a");
ASSERT_STRCASEEQ
(
p2
->
base
.
token
,
"a+b + 22"
);
//
// ASSERT_EQ(taosArrayGetSize(pExprList), 3);
ASSERT_EQ
(
taosArrayGetSize
(
pQueryInfo
->
colList
),
3
);
//
ASSERT_EQ
(
pQueryInfo
->
fieldsInfo
.
numOfOutput
,
3
);
// SExprInfo* p2 = (SExprInfo*) taosArrayGetP(pExprList, 1);
// ASSERT_EQ(p2->base.uid, 0);
destroyQueryInfo
(
pQueryInfo
);
// ASSERT_EQ(p2->base.numOfParams, 1); // it is the serialized binary string of expression.
qParserClearupMetaRequestInfo
(
&
req
);
// ASSERT_EQ(p2->base.resSchema.type, TSDB_DATA_TYPE_DOUBLE);
destroySqlInfo
(
&
info1
);
// ASSERT_STRCASEEQ(p2->base.resSchema.name, "a+b + 22");
}
//
//// ASSERT_STRCASEEQ(p2->base.colInfo.name, "t.1abc.a");
//// ASSERT_EQ(p1->base.colInfo.colId, 1);
//// ASSERT_EQ(p1->base.colInfo.flag, TSDB_COL_NORMAL);
// ASSERT_STRCASEEQ(p2->base.token, "a+b + 22");
//
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 3);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 3);
//}
//
//TEST(testCase, function_Test) {
//TEST(testCase, function_Test) {
// SSqlInfo info1 = doGenerateAST("select count(a) from `t.1abc`");
// SSqlInfo info1 = doGenerateAST("select count(a) from `t.1abc`");
// ASSERT_EQ(info1.valid, true);
// ASSERT_EQ(info1.valid, true);
...
@@ -138,8 +142,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -138,8 +142,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
//
//
// SQueryStmtInfo* pQueryInfo = (SQueryStmtInfo*)calloc(1, sizeof(SQueryStmtInfo));
// SQueryStmtInfo* pQueryInfo = createQueryInfo();
// initQueryInfo(pQueryInfo);
// setTableMetaInfo(pQueryInfo, &req);
// setTableMetaInfo(pQueryInfo, &req);
//
//
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
...
@@ -161,6 +164,10 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -161,6 +164,10 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
//
//
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 2);
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 2);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 1);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 1);
//
// destroyQueryInfo(pQueryInfo);
// qParserClearupMetaRequestInfo(&req);
// destroySqlInfo(&info1);
//}
//}
//
//
//TEST(testCase, function_Test2) {
//TEST(testCase, function_Test2) {
...
@@ -181,8 +188,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -181,8 +188,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
//
//
// SQueryStmtInfo* pQueryInfo = (SQueryStmtInfo*)calloc(1, sizeof(SQueryStmtInfo));
// SQueryStmtInfo* pQueryInfo = createQueryInfo();
// initQueryInfo(pQueryInfo);
// setTableMetaInfo(pQueryInfo, &req);
// setTableMetaInfo(pQueryInfo, &req);
//
//
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
...
@@ -204,6 +210,10 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -204,6 +210,10 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
//
//
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 2);
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 2);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 1);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 1);
//
// destroyQueryInfo(pQueryInfo);
// qParserClearupMetaRequestInfo(&req);
// destroySqlInfo(&info1);
//}
//}
//
//
//TEST(testCase, function_Test3) {
//TEST(testCase, function_Test3) {
...
@@ -224,8 +234,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -224,8 +234,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
//
//
// SQueryStmtInfo* pQueryInfo = (SQueryStmtInfo*)calloc(1, sizeof(SQueryStmtInfo));
// SQueryStmtInfo* pQueryInfo = createQueryInfo();
// initQueryInfo(pQueryInfo);
// setTableMetaInfo(pQueryInfo, &req);
// setTableMetaInfo(pQueryInfo, &req);
//
//
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
...
@@ -246,6 +255,10 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -246,6 +255,10 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
// ASSERT_EQ(p1->base.interBytes, 24);
// ASSERT_EQ(p1->base.interBytes, 24);
//
//
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 4);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 4);
//
// destroyQueryInfo(pQueryInfo);
// qParserClearupMetaRequestInfo(&req);
// destroySqlInfo(&info1);
//}
//}
//
//
//TEST(testCase, function_Test4) {
//TEST(testCase, function_Test4) {
...
@@ -266,8 +279,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -266,8 +279,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
//
//
// SQueryStmtInfo* pQueryInfo = (SQueryStmtInfo*)calloc(1, sizeof(SQueryStmtInfo));
// SQueryStmtInfo* pQueryInfo = createQueryInfo();
// initQueryInfo(pQueryInfo);
// setTableMetaInfo(pQueryInfo, &req);
// setTableMetaInfo(pQueryInfo, &req);
//
//
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
...
@@ -289,6 +301,10 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -289,6 +301,10 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
//
//
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 1);
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 1);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 1);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 1);
//
// destroyQueryInfo(pQueryInfo);
// qParserClearupMetaRequestInfo(&req);
// destroySqlInfo(&info1);
//}
//}
//
//
//TEST(testCase, function_Test5) {
//TEST(testCase, function_Test5) {
...
@@ -309,8 +325,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -309,8 +325,7 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
//
//
// SQueryStmtInfo* pQueryInfo = (SQueryStmtInfo*)calloc(1, sizeof(SQueryStmtInfo));
// SQueryStmtInfo* pQueryInfo = createQueryInfo();
// initQueryInfo(pQueryInfo);
// setTableMetaInfo(pQueryInfo, &req);
// setTableMetaInfo(pQueryInfo, &req);
//
//
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
...
@@ -333,46 +348,63 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
...
@@ -333,46 +348,63 @@ void setTableMetaInfo(SQueryStmtInfo* pQueryInfo, SMetaReq *req) {
//
//
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 3);
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 3);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 1);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 1);
//
// destroyQueryInfo(pQueryInfo);
// qParserClearupMetaRequestInfo(&req);
// destroySqlInfo(&info1);
//}
//}
//
TEST
(
testCase
,
function_Test6
)
{
//TEST(testCase, function_Test6) {
SSqlInfo
info1
=
doGenerateAST
(
"select sum(a+b) as a1, first(b*a) from `t.1abc`"
);
// SSqlInfo info1 = doGenerateAST("select sum(a+b) as a1, first(b*a) from `t.1abc` interval(10s, 1s)");
ASSERT_EQ
(
info1
.
valid
,
true
);
// ASSERT_EQ(info1.valid, true);
//
char
msg
[
128
]
=
{
0
};
// char msg[128] = {0};
SMsgBuf
buf
;
// SMsgBuf buf;
buf
.
len
=
128
;
// buf.len = 128;
buf
.
buf
=
msg
;
// buf.buf = msg;
//
SSqlNode
*
pNode
=
(
SSqlNode
*
)
taosArrayGetP
(((
SArray
*
)
info1
.
list
),
0
);
// SSqlNode* pNode = (SSqlNode*) taosArrayGetP(((SArray*)info1.list), 0);
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
buf
);
// int32_t code = evaluateSqlNode(pNode, TSDB_TIME_PRECISION_NANO, &buf);
ASSERT_EQ
(
code
,
0
);
// ASSERT_EQ(code, 0);
//
SMetaReq
req
=
{
0
};
// SMetaReq req = {0};
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
// int32_t ret = qParserExtractRequestedMetaInfo(&info1, &req, msg, 128);
ASSERT_EQ
(
ret
,
0
);
// ASSERT_EQ(ret, 0);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
//
SQueryStmtInfo
*
pQueryInfo
=
(
SQueryStmtInfo
*
)
calloc
(
1
,
sizeof
(
SQueryStmtInfo
));
// SQueryStmtInfo* pQueryInfo = createQueryInfo();
initQueryInfo
(
pQueryInfo
);
// setTableMetaInfo(pQueryInfo, &req);
setTableMetaInfo
(
pQueryInfo
,
&
req
);
//
// SSqlNode* pSqlNode = (SSqlNode*)taosArrayGetP(info1.list, 0);
SSqlNode
*
pSqlNode
=
(
SSqlNode
*
)
taosArrayGetP
(
info1
.
list
,
0
);
// ret = validateSqlNode(pSqlNode, pQueryInfo, &buf);
ret
=
validateSqlNode
(
pSqlNode
,
pQueryInfo
,
&
buf
);
// ASSERT_EQ(ret, 0);
ASSERT_EQ
(
ret
,
0
);
//
// SArray* pExprList = pQueryInfo->exprList;
SArray
*
pExprList
=
pQueryInfo
->
exprList
;
// ASSERT_EQ(taosArrayGetSize(pExprList), 2);
ASSERT_EQ
(
taosArrayGetSize
(
pExprList
),
2
);
//
// SExprInfo* p1 = (SExprInfo*) taosArrayGetP(pExprList, 0);
SExprInfo
*
p1
=
(
SExprInfo
*
)
taosArrayGetP
(
pExprList
,
0
);
// ASSERT_EQ(p1->base.uid, 110);
ASSERT_EQ
(
p1
->
base
.
uid
,
110
);
// ASSERT_EQ(p1->base.numOfParams, 0);
ASSERT_EQ
(
p1
->
base
.
numOfParams
,
0
);
// ASSERT_EQ(p1->base.resSchema.type, TSDB_DATA_TYPE_DOUBLE);
ASSERT_EQ
(
p1
->
base
.
resSchema
.
type
,
TSDB_DATA_TYPE_DOUBLE
);
// ASSERT_STRCASEEQ(p1->base.resSchema.name, "a1");
ASSERT_STRCASEEQ
(
p1
->
base
.
resSchema
.
name
,
"a1"
);
// ASSERT_EQ(p1->base.colInfo.flag, TSDB_COL_NORMAL);
ASSERT_EQ
(
p1
->
base
.
colInfo
.
flag
,
TSDB_COL_NORMAL
);
// ASSERT_STRCASEEQ(p1->base.token, "sum(a+b)");
ASSERT_STRCASEEQ
(
p1
->
base
.
token
,
"sum(a+b)"
);
// ASSERT_EQ(p1->base.interBytes, 16);
ASSERT_EQ
(
p1
->
base
.
interBytes
,
16
);
// ASSERT_EQ(p1->pExpr->nodeType, TEXPR_UNARYEXPR_NODE);
// ASSERT_EQ(p1->pExpr->_node.functionId, FUNCTION_SUM);
ASSERT_EQ
(
taosArrayGetSize
(
pQueryInfo
->
colList
),
3
);
// ASSERT_TRUE(p1->pExpr->_node.pRight == NULL);
ASSERT_EQ
(
pQueryInfo
->
fieldsInfo
.
numOfOutput
,
2
);
//
}
// tExprNode* pParam = p1->pExpr->_node.pLeft;
\ No newline at end of file
//
// ASSERT_EQ(pParam->nodeType, TEXPR_BINARYEXPR_NODE);
// ASSERT_EQ(pParam->_node.optr, TSDB_BINARY_OP_ADD);
// ASSERT_EQ(pParam->_node.pLeft->nodeType, TEXPR_COL_NODE);
// ASSERT_EQ(pParam->_node.pRight->nodeType, TEXPR_COL_NODE);
//
// ASSERT_EQ(taosArrayGetSize(pQueryInfo->colList), 3);
// ASSERT_EQ(pQueryInfo->fieldsInfo.numOfOutput, 2);
//
// destroyQueryInfo(pQueryInfo);
// qParserClearupMetaRequestInfo(&req);
// destroySqlInfo(&info1);
//}
\ No newline at end of file
source/libs/parser/test/tokenizerTest.cpp
浏览文件 @
aa064709
...
@@ -667,51 +667,59 @@ TEST(testCase, isValidNumber_test) {
...
@@ -667,51 +667,59 @@ TEST(testCase, isValidNumber_test) {
EXPECT_EQ
(
tGetNumericStringType
(
&
t1
),
TK_FLOAT
);
EXPECT_EQ
(
tGetNumericStringType
(
&
t1
),
TK_FLOAT
);
}
}
TEST
(
testCase
,
generateAST_test
)
{
//TEST(testCase, generateAST_test) {
SSqlInfo
info
=
doGenerateAST
(
"select * from t1 where ts < now"
);
// SSqlInfo info = doGenerateAST("select * from t1 where ts < now");
ASSERT_EQ
(
info
.
valid
,
true
);
// ASSERT_EQ(info.valid, true);
//
SSqlInfo
info1
=
doGenerateAST
(
"select * from `t.1abc` where ts<now+2h and col < 20+99"
);
// SSqlInfo info1 = doGenerateAST("select * from `t.1abc` where ts<now+2h and col < 20+99");
ASSERT_EQ
(
info1
.
valid
,
true
);
// ASSERT_EQ(info1.valid, true);
//
char
msg
[
128
]
=
{
0
};
// char msg[128] = {0};
//
SMsgBuf
msgBuf
=
{
0
};
// SMsgBuf msgBuf = {0};
msgBuf
.
buf
=
msg
;
// msgBuf.buf = msg;
msgBuf
.
len
=
128
;
// msgBuf.len = 128;
//
SSqlNode
*
pNode
=
(
SSqlNode
*
)
taosArrayGetP
(((
SArray
*
)
info1
.
list
),
0
);
// SSqlNode* pNode = (SSqlNode*) taosArrayGetP(((SArray*)info1.list), 0);
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
msgBuf
);
// int32_t code = evaluateSqlNode(pNode, TSDB_TIME_PRECISION_NANO, &msgBuf);
ASSERT_EQ
(
code
,
0
);
// ASSERT_EQ(code, 0);
//
SSqlInfo
info2
=
doGenerateAST
(
"select * from abc where ts<now+2"
);
// SSqlInfo info2 = doGenerateAST("select * from abc where ts<now+2");
SSqlNode
*
pNode2
=
(
SSqlNode
*
)
taosArrayGetP
(((
SArray
*
)
info2
.
list
),
0
);
// SSqlNode* pNode2 = (SSqlNode*) taosArrayGetP(((SArray*)info2.list), 0);
code
=
evaluateSqlNode
(
pNode2
,
TSDB_TIME_PRECISION_MILLI
,
&
msgBuf
);
// code = evaluateSqlNode(pNode2, TSDB_TIME_PRECISION_MILLI, &msgBuf);
ASSERT_NE
(
code
,
0
);
// ASSERT_NE(code, 0);
}
//
// destroySqlInfo(&info);
TEST
(
testCase
,
evaluateAST_test
)
{
// destroySqlInfo(&info1);
SSqlInfo
info1
=
doGenerateAST
(
"select a, b+22 from `t.1abc` where ts<now+2h and `col` < 20 + 99"
);
// destroySqlInfo(&info2);
ASSERT_EQ
(
info1
.
valid
,
true
);
//}
//
char
msg
[
128
]
=
{
0
};
//TEST(testCase, evaluateAST_test) {
SMsgBuf
msgBuf
=
{
0
};
// SSqlInfo info1 = doGenerateAST("select a, b+22 from `t.1abc` where ts<now+2h and `col` < 20 + 99");
msgBuf
.
buf
=
msg
;
// ASSERT_EQ(info1.valid, true);
msgBuf
.
len
=
128
;
//
// char msg[128] = {0};
SSqlNode
*
pNode
=
(
SSqlNode
*
)
taosArrayGetP
(((
SArray
*
)
info1
.
list
),
0
);
// SMsgBuf msgBuf = {0};
int32_t
code
=
evaluateSqlNode
(
pNode
,
TSDB_TIME_PRECISION_NANO
,
&
msgBuf
);
// msgBuf.buf = msg;
ASSERT_EQ
(
code
,
0
);
// msgBuf.len = 128;
}
//
// SSqlNode* pNode = (SSqlNode*) taosArrayGetP(((SArray*)info1.list), 0);
TEST
(
testCase
,
extractMeta_test
)
{
// int32_t code = evaluateSqlNode(pNode, TSDB_TIME_PRECISION_NANO, &msgBuf);
SSqlInfo
info1
=
doGenerateAST
(
"select a, b+22 from `t.1abc` where ts<now+2h and `col` < 20 + 99"
);
// ASSERT_EQ(code, 0);
ASSERT_EQ
(
info1
.
valid
,
true
);
// destroySqlInfo(&info1);
//}
char
msg
[
128
]
=
{
0
};
//
SMetaReq
req
=
{
0
};
//TEST(testCase, extractMeta_test) {
int32_t
ret
=
qParserExtractRequestedMetaInfo
(
&
info1
,
&
req
,
msg
,
128
);
// SSqlInfo info1 = doGenerateAST("select a, b+22 from `t.1abc` where ts<now+2h and `col` < 20 + 99");
ASSERT_EQ
(
ret
,
0
);
// ASSERT_EQ(info1.valid, true);
ASSERT_EQ
(
taosArrayGetSize
(
req
.
pTableName
),
1
);
//
}
// char msg[128] = {0};
// SMetaReq req = {0};
// int32_t ret = qParserExtractRequestedMetaInfo(&info1, &req, msg, 128);
// ASSERT_EQ(ret, 0);
// ASSERT_EQ(taosArrayGetSize(req.pTableName), 1);
//
// qParserClearupMetaRequestInfo(&req);
// destroySqlInfo(&info1);
//}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录