Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f0f3fe1e
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看板
未验证
提交
f0f3fe1e
编写于
3月 11, 2022
作者:
M
Minglei Jin
提交者:
GitHub
3月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10590 from taosdata/fix/TS-207-D
Fix/TS-207 order by tags error
上级
2dc55641
28a15713
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
172 addition
and
141 deletion
+172
-141
src/client/src/tscGlobalmerge.c
src/client/src/tscGlobalmerge.c
+3
-3
src/connector/jdbc/src/test/java/com/taosdata/jdbc/JsonTagTest.java
...tor/jdbc/src/test/java/com/taosdata/jdbc/JsonTagTest.java
+1
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJsonTagTest.java
...rc/test/java/com/taosdata/jdbc/rs/RestfulJsonTagTest.java
+1
-1
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ws/WSJsonTagTest.java
...dbc/src/test/java/com/taosdata/jdbc/ws/WSJsonTagTest.java
+1
-1
src/os/src/windows/wString.c
src/os/src/windows/wString.c
+3
-3
src/query/inc/qExtbuffer.h
src/query/inc/qExtbuffer.h
+1
-1
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+5
-1
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+9
-13
src/query/src/qExtbuffer.c
src/query/src/qExtbuffer.c
+37
-20
src/util/src/tcompare.c
src/util/src/tcompare.c
+21
-45
tests/develop-test/0-others/json_tag.py
tests/develop-test/0-others/json_tag.py
+9
-10
tests/develop-test/2-query/function_mode.py
tests/develop-test/2-query/function_mode.py
+6
-6
tests/develop-test/2-query/function_tail.py
tests/develop-test/2-query/function_tail.py
+6
-6
tests/develop-test/2-query/function_unique.py
tests/develop-test/2-query/function_unique.py
+5
-5
tests/pytest/functions/function_stddev.py
tests/pytest/functions/function_stddev.py
+2
-2
tests/pytest/query/bug2117.py
tests/pytest/query/bug2117.py
+4
-4
tests/pytest/query/bug2143.py
tests/pytest/query/bug2143.py
+9
-9
tests/pytest/query/filterOtherTypes.py
tests/pytest/query/filterOtherTypes.py
+2
-2
tests/pytest/query/querySort.py
tests/pytest/query/querySort.py
+41
-3
tests/script/general/parser/columnValue_unsign.sim
tests/script/general/parser/columnValue_unsign.sim
+4
-4
tests/script/general/parser/groupby.sim
tests/script/general/parser/groupby.sim
+2
-1
未找到文件。
src/client/src/tscGlobalmerge.c
浏览文件 @
f0f3fe1e
...
@@ -819,7 +819,7 @@ SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup) {
...
@@ -819,7 +819,7 @@ SSDataBlock* doMultiwayMergeSort(void* param, bool* newgroup) {
pOneDataSrc
->
rowIdx
,
pIndex
->
colIndex
);
pOneDataSrc
->
rowIdx
,
pIndex
->
colIndex
);
char
*
data
=
pInfo
->
prevRow
[
i
];
char
*
data
=
pInfo
->
prevRow
[
i
];
int32_t
ret
=
columnValueAscendingComparator
(
data
,
newRow
,
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
);
int32_t
ret
=
columnValueAscendingComparator
(
data
,
newRow
,
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
,
true
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
continue
;
continue
;
}
else
{
}
else
{
...
@@ -881,7 +881,7 @@ static bool isSameGroup(SArray* orderColumnList, SSDataBlock* pBlock, char** dat
...
@@ -881,7 +881,7 @@ static bool isSameGroup(SArray* orderColumnList, SSDataBlock* pBlock, char** dat
assert
(
pIndex
->
colId
==
pColInfo
->
info
.
colId
);
assert
(
pIndex
->
colId
==
pColInfo
->
info
.
colId
);
char
*
data
=
dataCols
[
i
];
char
*
data
=
dataCols
[
i
];
int32_t
ret
=
columnValueAscendingComparator
(
data
,
pColInfo
->
pData
,
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
);
int32_t
ret
=
columnValueAscendingComparator
(
data
,
pColInfo
->
pData
,
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
,
true
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
continue
;
continue
;
}
else
{
}
else
{
...
@@ -1067,7 +1067,7 @@ static int32_t doSlimitImpl(SOperatorInfo* pOperator, SSLimitOperatorInfo* pInfo
...
@@ -1067,7 +1067,7 @@ static int32_t doSlimitImpl(SOperatorInfo* pOperator, SSLimitOperatorInfo* pInfo
SColumnInfo
*
pColInfo
=
&
pColInfoData
->
info
;
SColumnInfo
*
pColInfo
=
&
pColInfoData
->
info
;
char
*
d
=
rowIndex
*
pColInfo
->
bytes
+
(
char
*
)
pColInfoData
->
pData
;
char
*
d
=
rowIndex
*
pColInfo
->
bytes
+
(
char
*
)
pColInfoData
->
pData
;
int32_t
ret
=
columnValueAscendingComparator
(
pInfo
->
prevRow
[
i
],
d
,
pColInfo
->
type
,
pColInfo
->
bytes
);
int32_t
ret
=
columnValueAscendingComparator
(
pInfo
->
prevRow
[
i
],
d
,
pColInfo
->
type
,
pColInfo
->
bytes
,
true
);
if
(
ret
!=
0
)
{
// it is a new group
if
(
ret
!=
0
)
{
// it is a new group
samegroup
=
false
;
samegroup
=
false
;
break
;
break
;
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/JsonTagTest.java
浏览文件 @
f0f3fe1e
...
@@ -1135,7 +1135,7 @@ public class JsonTagTest {
...
@@ -1135,7 +1135,7 @@ public class JsonTagTest {
}
}
Assert
.
assertEquals
(
8
,
count
);
Assert
.
assertEquals
(
8
,
count
);
Assert
.
assertEquals
(
"\"
femail
\""
,
s
);
Assert
.
assertEquals
(
"\"
收到货
\""
,
s
);
close
(
resultSet
);
close
(
resultSet
);
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulJsonTagTest.java
浏览文件 @
f0f3fe1e
...
@@ -1149,7 +1149,7 @@ public class RestfulJsonTagTest {
...
@@ -1149,7 +1149,7 @@ public class RestfulJsonTagTest {
}
}
Assert
.
assertEquals
(
8
,
count
);
Assert
.
assertEquals
(
8
,
count
);
Assert
.
assertEquals
(
"\"
femail
\""
,
s
);
Assert
.
assertEquals
(
"\"
收到货
\""
,
s
);
close
(
resultSet
);
close
(
resultSet
);
}
}
...
...
src/connector/jdbc/src/test/java/com/taosdata/jdbc/ws/WSJsonTagTest.java
浏览文件 @
f0f3fe1e
...
@@ -1146,7 +1146,7 @@ public class WSJsonTagTest {
...
@@ -1146,7 +1146,7 @@ public class WSJsonTagTest {
}
}
Assert
.
assertEquals
(
8
,
count
);
Assert
.
assertEquals
(
8
,
count
);
Assert
.
assertEquals
(
"\"
femail
\""
,
s
);
Assert
.
assertEquals
(
"\"
收到货
\""
,
s
);
close
(
resultSet
);
close
(
resultSet
);
}
}
...
...
src/os/src/windows/wString.c
浏览文件 @
f0f3fe1e
...
@@ -93,9 +93,9 @@ int32_t twcslen(const wchar_t *wcs) {
...
@@ -93,9 +93,9 @@ int32_t twcslen(const wchar_t *wcs) {
}
}
int32_t
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int32_t
bytes
)
{
int32_t
tasoUcs4Compare
(
void
*
f1_ucs4
,
void
*
f2_ucs4
,
int32_t
bytes
)
{
for
(
int32_t
i
=
0
;
i
<
bytes
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
bytes
;
i
+=
TSDB_NCHAR_SIZE
)
{
int32_t
f1
=
*
(
int32_t
*
)((
char
*
)
f1_ucs4
+
i
*
4
);
int32_t
f1
=
*
(
int32_t
*
)((
char
*
)
f1_ucs4
+
i
);
int32_t
f2
=
*
(
int32_t
*
)((
char
*
)
f2_ucs4
+
i
*
4
);
int32_t
f2
=
*
(
int32_t
*
)((
char
*
)
f2_ucs4
+
i
);
if
((
f1
==
0
&&
f2
!=
0
)
||
(
f1
!=
0
&&
f2
==
0
))
{
if
((
f1
==
0
&&
f2
!=
0
)
||
(
f1
!=
0
&&
f2
==
0
))
{
return
f1
-
f2
;
return
f1
-
f2
;
...
...
src/query/inc/qExtbuffer.h
浏览文件 @
f0f3fe1e
...
@@ -254,7 +254,7 @@ int32_t compare_d(tOrderDescriptor *, int32_t numOfRow1, int32_t s1, char *data1
...
@@ -254,7 +254,7 @@ int32_t compare_d(tOrderDescriptor *, int32_t numOfRow1, int32_t s1, char *data1
struct
SSDataBlock
;
struct
SSDataBlock
;
int32_t
compare_aRv
(
struct
SSDataBlock
*
pBlock
,
SArray
*
colIndex
,
int32_t
numOfCols
,
int32_t
rowIndex
,
char
**
buffer
,
int32_t
order
);
int32_t
compare_aRv
(
struct
SSDataBlock
*
pBlock
,
SArray
*
colIndex
,
int32_t
numOfCols
,
int32_t
rowIndex
,
char
**
buffer
,
int32_t
order
);
int32_t
columnValueAscendingComparator
(
char
*
f1
,
char
*
f2
,
int32_t
type
,
int32_t
bytes
);
int32_t
columnValueAscendingComparator
(
char
*
f1
,
char
*
f2
,
int32_t
type
,
int32_t
bytes
,
bool
lenFirst
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/query/src/qAggMain.c
浏览文件 @
f0f3fe1e
...
@@ -5685,7 +5685,10 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -5685,7 +5685,10 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
// }else{
// }else{
// GET_RES_INFO(pCtx)->numOfRes = pRes->num;
// GET_RES_INFO(pCtx)->numOfRes = pRes->num;
// }
// }
if
(
GET_RES_INFO
(
pCtx
)
->
numOfRes
<=
0
)
return
;
if
(
GET_RES_INFO
(
pCtx
)
->
numOfRes
<=
0
)
{
doFinalizer
(
pCtx
);
return
;
}
taosqsort
(
pRes
->
res
,
pRes
->
num
,
POINTER_BYTES
,
NULL
,
tailComparFn
);
taosqsort
(
pRes
->
res
,
pRes
->
num
,
POINTER_BYTES
,
NULL
,
tailComparFn
);
...
@@ -5693,6 +5696,7 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
...
@@ -5693,6 +5696,7 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) {
void
*
data
=
calloc
(
size
,
GET_RES_INFO
(
pCtx
)
->
numOfRes
);
void
*
data
=
calloc
(
size
,
GET_RES_INFO
(
pCtx
)
->
numOfRes
);
if
(
!
data
){
if
(
!
data
){
qError
(
"calloc error in tail_func_finalizer: size:%d, num:%d"
,
(
int32_t
)
size
,
GET_RES_INFO
(
pCtx
)
->
numOfRes
);
qError
(
"calloc error in tail_func_finalizer: size:%d, num:%d"
,
(
int32_t
)
size
,
GET_RES_INFO
(
pCtx
)
->
numOfRes
);
doFinalizer
(
pCtx
);
return
;
return
;
}
}
for
(
int32_t
i
=
0
;
i
<
GET_RES_INFO
(
pCtx
)
->
numOfRes
;
i
++
){
for
(
int32_t
i
=
0
;
i
<
GET_RES_INFO
(
pCtx
)
->
numOfRes
;
i
++
){
...
...
src/query/src/qExecutor.c
浏览文件 @
f0f3fe1e
...
@@ -283,28 +283,25 @@ static int compareRowData(const void *a, const void *b, const void *userData) {
...
@@ -283,28 +283,25 @@ static int compareRowData(const void *a, const void *b, const void *userData) {
return
(
in1
!=
NULL
&&
in2
!=
NULL
)
?
supporter
->
comFunc
(
in1
,
in2
)
:
0
;
return
(
in1
!=
NULL
&&
in2
!=
NULL
)
?
supporter
->
comFunc
(
in1
,
in2
)
:
0
;
}
}
static
void
sortGroupResByOrderList
(
SGroupResInfo
*
pGroupResInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
,
SSDataBlock
*
pDataBlock
)
{
static
void
sortGroupResByOrderList
(
SGroupResInfo
*
pGroupResInfo
,
SQueryRuntimeEnv
*
pRuntimeEnv
,
SSDataBlock
*
pDataBlock
,
SQLFunctionCtx
*
pCtx
)
{
if
(
pRuntimeEnv
->
pQueryAttr
->
pGroupbyExpr
==
NULL
||
pRuntimeEnv
->
pQueryAttr
->
pGroupbyExpr
->
numOfGroupCols
<=
0
){
// first groupby column is sort column
SColIndex
*
pFirstGroupCol
=
taosArrayGet
(
pRuntimeEnv
->
pQueryAttr
->
pGroupbyExpr
->
columnInfo
,
0
);
if
(
pFirstGroupCol
==
NULL
)
{
return
;
return
;
}
}
if
(
pRuntimeEnv
->
pQueryAttr
->
order
.
orderColId
<=
0
){
// get dataOffset and index on pRuntimeEnv->pQueryAttr->pExpr1
return
;
}
SColIndex
*
pColIndex
=
taosArrayGet
(
pRuntimeEnv
->
pQueryAttr
->
pGroupbyExpr
->
columnInfo
,
0
);
int16_t
dataOffset
=
0
;
int16_t
dataOffset
=
0
;
int16_t
type
=
0
;
int16_t
type
=
0
;
for
(
int32_t
j
=
0
;
j
<
pDataBlock
->
info
.
numOfCols
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pDataBlock
->
info
.
numOfCols
;
++
j
)
{
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
j
);
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pDataBlock
->
pDataBlock
,
j
);
if
(
pC
olInfoData
->
info
.
colId
==
pColIndex
->
colId
)
{
if
(
pC
tx
[
j
].
colId
==
pFirstGroupCol
->
colId
)
{
type
=
p
ColInfoData
->
info
.
t
ype
;
type
=
p
RuntimeEnv
->
pQueryAttr
->
pExpr1
[
j
].
base
.
resT
ype
;
break
;
break
;
}
}
dataOffset
+=
pColInfoData
->
info
.
bytes
;
dataOffset
+=
pColInfoData
->
info
.
bytes
;
}
}
SRowCompSupporter
support
=
{.
pRuntimeEnv
=
pRuntimeEnv
,
.
dataOffset
=
dataOffset
,
.
comFunc
=
getComparFunc
(
type
,
0
)};
SRowCompSupporter
support
=
{.
pRuntimeEnv
=
pRuntimeEnv
,
.
dataOffset
=
dataOffset
,
.
comFunc
=
getComparFunc
(
type
,
0
)};
taosArraySortPWithExt
(
pGroupResInfo
->
pRows
,
compareRowData
,
&
support
);
taosArraySortPWithExt
(
pGroupResInfo
->
pRows
,
compareRowData
,
&
support
);
}
}
...
@@ -7123,7 +7120,7 @@ static SSDataBlock* hashGroupbyAggregate(void* param, bool* newgroup) {
...
@@ -7123,7 +7120,7 @@ static SSDataBlock* hashGroupbyAggregate(void* param, bool* newgroup) {
initGroupResInfo
(
&
pRuntimeEnv
->
groupResInfo
,
&
pInfo
->
binfo
.
resultRowInfo
);
initGroupResInfo
(
&
pRuntimeEnv
->
groupResInfo
,
&
pInfo
->
binfo
.
resultRowInfo
);
if
(
!
pRuntimeEnv
->
pQueryAttr
->
stableQuery
)
{
if
(
!
pRuntimeEnv
->
pQueryAttr
->
stableQuery
)
{
sortGroupResByOrderList
(
&
pRuntimeEnv
->
groupResInfo
,
pRuntimeEnv
,
pInfo
->
binfo
.
pRes
);
sortGroupResByOrderList
(
&
pRuntimeEnv
->
groupResInfo
,
pRuntimeEnv
,
pInfo
->
binfo
.
pRes
,
pInfo
->
binfo
.
pCtx
);
}
}
toSSDataBlock
(
&
pRuntimeEnv
->
groupResInfo
,
pRuntimeEnv
,
pInfo
->
binfo
.
pRes
);
toSSDataBlock
(
&
pRuntimeEnv
->
groupResInfo
,
pRuntimeEnv
,
pInfo
->
binfo
.
pRes
);
...
@@ -9566,7 +9563,6 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
...
@@ -9566,7 +9563,6 @@ SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SGroupbyExpr* pGroupbyExpr, S
pQueryAttr
->
needTableSeqScan
=
pQueryMsg
->
needTableSeqScan
;
pQueryAttr
->
needTableSeqScan
=
pQueryMsg
->
needTableSeqScan
;
pQueryAttr
->
needReverseScan
=
pQueryMsg
->
needReverseScan
;
pQueryAttr
->
needReverseScan
=
pQueryMsg
->
needReverseScan
;
pQueryAttr
->
stateWindow
=
pQueryMsg
->
stateWindow
;
pQueryAttr
->
stateWindow
=
pQueryMsg
->
stateWindow
;
pQueryAttr
->
vgId
=
vgId
;
pQueryAttr
->
pFilters
=
pFilters
;
pQueryAttr
->
pFilters
=
pFilters
;
pQueryAttr
->
range
=
pQueryMsg
->
range
;
pQueryAttr
->
range
=
pQueryMsg
->
range
;
...
...
src/query/src/qExtbuffer.c
浏览文件 @
f0f3fe1e
...
@@ -366,7 +366,7 @@ static int32_t tsCompareFunc(TSKEY k1, TSKEY k2, int32_t order) {
...
@@ -366,7 +366,7 @@ static int32_t tsCompareFunc(TSKEY k1, TSKEY k2, int32_t order) {
}
}
}
}
int32_t
columnValueAscendingComparator
(
char
*
f1
,
char
*
f2
,
int32_t
type
,
int32_t
bytes
)
{
int32_t
columnValueAscendingComparator
(
char
*
f1
,
char
*
f2
,
int32_t
type
,
int32_t
bytes
,
bool
lenFirst
)
{
if
(
type
==
TSDB_DATA_TYPE_JSON
){
if
(
type
==
TSDB_DATA_TYPE_JSON
){
bool
canReturn
=
true
;
bool
canReturn
=
true
;
int32_t
result
=
jsonCompareUnit
(
f1
,
f2
,
&
canReturn
);
int32_t
result
=
jsonCompareUnit
(
f1
,
f2
,
&
canReturn
);
...
@@ -387,31 +387,48 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
...
@@ -387,31 +387,48 @@ int32_t columnValueAscendingComparator(char *f1, char *f2, int32_t type, int32_t
case
TSDB_DATA_TYPE_BINARY
:
{
case
TSDB_DATA_TYPE_BINARY
:
{
int32_t
len1
=
varDataLen
(
f1
);
int32_t
len1
=
varDataLen
(
f1
);
int32_t
len2
=
varDataLen
(
f2
);
int32_t
len2
=
varDataLen
(
f2
);
if
(
len1
!=
len2
)
{
// length first compare
return
len1
>
len2
?
1
:-
1
;
if
(
lenFirst
)
{
}
else
{
if
(
len1
>
len2
)
int32_t
ret
=
strncmp
(
varDataVal
(
f1
),
varDataVal
(
f2
),
len1
);
return
1
;
if
(
ret
==
0
)
{
else
if
(
len1
<
len2
)
return
-
1
;
}
// compare context
int32_t
ret
=
strncmp
(
varDataVal
(
f1
),
varDataVal
(
f2
),
len1
>
len2
?
len2
:
len1
);
if
(
ret
==
0
)
{
if
(
len1
>
len2
)
return
1
;
else
if
(
len1
<
len2
)
return
-
1
;
else
return
0
;
return
0
;
}
return
(
ret
<
0
)
?
-
1
:
1
;
}
}
return
(
ret
<
0
)
?
-
1
:
1
;
};
};
case
TSDB_DATA_TYPE_NCHAR
:
{
// todo handle the var string compare
case
TSDB_DATA_TYPE_NCHAR
:
{
// todo handle the var string compare
int32_t
len1
=
varDataLen
(
f1
);
int32_t
len1
=
varDataLen
(
f1
);
int32_t
len2
=
varDataLen
(
f2
);
int32_t
len2
=
varDataLen
(
f2
);
if
(
len1
!=
len2
)
{
// length first compare
return
len1
>
len2
?
1
:
-
1
;
if
(
lenFirst
)
{
}
else
{
if
(
len1
>
len2
)
int32_t
ret
=
tasoUcs4Compare
(
varDataVal
(
f1
),
varDataVal
(
f2
),
len1
);
return
1
;
if
(
ret
==
0
)
{
else
if
(
len1
<
len2
)
return
-
1
;
}
// compare context
int32_t
ret
=
tasoUcs4Compare
(
varDataVal
(
f1
),
varDataVal
(
f2
),
len1
>
len2
?
len2
:
len1
);
if
(
ret
==
0
)
{
if
(
len1
>
len2
)
return
1
;
else
if
(
len1
<
len2
)
return
-
1
;
else
return
0
;
return
0
;
}
return
(
ret
<
0
)
?
-
1
:
1
;
}
}
return
(
ret
<
0
)
?
-
1
:
1
;
};
};
case
TSDB_DATA_TYPE_UTINYINT
:
DEFAULT_COMP
(
GET_UINT8_VAL
(
f1
),
GET_UINT8_VAL
(
f2
));
case
TSDB_DATA_TYPE_UTINYINT
:
DEFAULT_COMP
(
GET_UINT8_VAL
(
f1
),
GET_UINT8_VAL
(
f2
));
case
TSDB_DATA_TYPE_USMALLINT
:
DEFAULT_COMP
(
GET_UINT16_VAL
(
f1
),
GET_UINT16_VAL
(
f2
));
case
TSDB_DATA_TYPE_USMALLINT
:
DEFAULT_COMP
(
GET_UINT16_VAL
(
f1
),
GET_UINT16_VAL
(
f2
));
...
@@ -442,7 +459,7 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
...
@@ -442,7 +459,7 @@ int32_t compare_a(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
}
}
}
else
{
}
else
{
SSchemaEx
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
SSchemaEx
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
int32_t
ret
=
columnValueAscendingComparator
(
f1
,
f2
,
pSchema
->
field
.
type
,
pSchema
->
field
.
bytes
);
int32_t
ret
=
columnValueAscendingComparator
(
f1
,
f2
,
pSchema
->
field
.
type
,
pSchema
->
field
.
bytes
,
strcmp
(
pSchema
->
field
.
name
,
TSQL_TBNAME_L
)
==
0
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
continue
;
continue
;
}
else
{
}
else
{
...
@@ -471,7 +488,7 @@ int32_t compare_aRv(SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, in
...
@@ -471,7 +488,7 @@ int32_t compare_aRv(SSDataBlock* pBlock, SArray* colIndex, int32_t numOfCols, in
return
ret
;
return
ret
;
}
}
}
else
{
}
else
{
int32_t
ret
=
columnValueAscendingComparator
(
data
,
buffer
[
i
],
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
);
int32_t
ret
=
columnValueAscendingComparator
(
data
,
buffer
[
i
],
pColInfo
->
info
.
type
,
pColInfo
->
info
.
bytes
,
false
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
continue
;
continue
;
}
else
{
}
else
{
...
@@ -503,7 +520,7 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
...
@@ -503,7 +520,7 @@ int32_t compare_d(tOrderDescriptor *pDescriptor, int32_t numOfRows1, int32_t s1,
}
}
}
else
{
}
else
{
SSchemaEx
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
SSchemaEx
*
pSchema
=
&
pDescriptor
->
pColumnModel
->
pFields
[
colIdx
];
int32_t
ret
=
columnValueAscendingComparator
(
f1
,
f2
,
pSchema
->
field
.
type
,
pSchema
->
field
.
bytes
);
int32_t
ret
=
columnValueAscendingComparator
(
f1
,
f2
,
pSchema
->
field
.
type
,
pSchema
->
field
.
bytes
,
strcmp
(
pSchema
->
field
.
name
,
TSQL_TBNAME_L
)
==
0
);
if
(
ret
==
0
)
{
if
(
ret
==
0
)
{
continue
;
continue
;
}
else
{
}
else
{
...
...
src/util/src/tcompare.c
浏览文件 @
f0f3fe1e
...
@@ -183,16 +183,16 @@ int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight) {
...
@@ -183,16 +183,16 @@ int32_t compareLenPrefixedStr(const void *pLeft, const void *pRight) {
int32_t
len1
=
varDataLen
(
pLeft
);
int32_t
len1
=
varDataLen
(
pLeft
);
int32_t
len2
=
varDataLen
(
pRight
);
int32_t
len2
=
varDataLen
(
pRight
);
if
(
len1
!=
len2
)
{
int32_t
ret
=
strncmp
(
varDataVal
(
pLeft
),
varDataVal
(
pRight
),
len1
>
len2
?
len2
:
len1
);
return
len1
>
len2
?
1
:-
1
;
if
(
ret
==
0
)
{
}
else
{
if
(
len1
>
len2
)
int32_t
ret
=
strncmp
(
varDataVal
(
pLeft
),
varDataVal
(
pRight
),
len1
);
return
1
;
if
(
ret
==
0
)
{
else
if
(
len1
<
len2
)
return
-
1
;
else
return
0
;
return
0
;
}
else
{
return
ret
>
0
?
1
:-
1
;
}
}
}
return
(
ret
<
0
)
?
-
1
:
1
;
}
}
int32_t
compareLenPrefixedStrDesc
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareLenPrefixedStrDesc
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
...
@@ -203,16 +203,16 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) {
...
@@ -203,16 +203,16 @@ int32_t compareLenPrefixedWStr(const void *pLeft, const void *pRight) {
int32_t
len1
=
varDataLen
(
pLeft
);
int32_t
len1
=
varDataLen
(
pLeft
);
int32_t
len2
=
varDataLen
(
pRight
);
int32_t
len2
=
varDataLen
(
pRight
);
if
(
len1
!=
len2
)
{
int32_t
ret
=
tasoUcs4Compare
(
varDataVal
(
pLeft
),
varDataVal
(
pRight
),
len1
>
len2
?
len2
:
len1
);
return
len1
>
len2
?
1
:-
1
;
if
(
ret
==
0
)
{
}
else
{
if
(
len1
>
len2
)
int32_t
ret
=
memcmp
((
wchar_t
*
)
pLeft
,
(
wchar_t
*
)
pRight
,
len1
);
return
1
;
if
(
ret
==
0
)
{
else
if
(
len1
<
len2
)
return
-
1
;
else
return
0
;
return
0
;
}
else
{
return
ret
>
0
?
1
:
-
1
;
}
}
}
return
(
ret
<
0
)
?
-
1
:
1
;
}
}
int32_t
compareLenPrefixedWStrDesc
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
int32_t
compareLenPrefixedWStrDesc
(
const
void
*
pLeft
,
const
void
*
pRight
)
{
...
@@ -750,7 +750,8 @@ int32_t jsonCompareUnit(const char* f1, const char* f2, bool* canReturn){
...
@@ -750,7 +750,8 @@ int32_t jsonCompareUnit(const char* f1, const char* f2, bool* canReturn){
}
}
}
}
int32_t
doCompare
(
const
char
*
f1
,
const
char
*
f2
,
int32_t
type
,
size_t
size
)
{
int32_t
doCompare
(
const
char
*
f1
,
const
char
*
f2
,
int32_t
type
,
size_t
size
)
{
if
(
type
==
TSDB_DATA_TYPE_JSON
){
if
(
type
==
TSDB_DATA_TYPE_JSON
){
bool
canReturn
=
true
;
bool
canReturn
=
true
;
int32_t
result
=
jsonCompareUnit
(
f1
,
f2
,
&
canReturn
);
int32_t
result
=
jsonCompareUnit
(
f1
,
f2
,
&
canReturn
);
...
@@ -771,33 +772,8 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
...
@@ -771,33 +772,8 @@ int32_t doCompare(const char* f1, const char* f2, int32_t type, size_t size) {
case
TSDB_DATA_TYPE_USMALLINT
:
DEFAULT_COMP
(
GET_UINT16_VAL
(
f1
),
GET_UINT16_VAL
(
f2
));
case
TSDB_DATA_TYPE_USMALLINT
:
DEFAULT_COMP
(
GET_UINT16_VAL
(
f1
),
GET_UINT16_VAL
(
f2
));
case
TSDB_DATA_TYPE_UINT
:
DEFAULT_COMP
(
GET_UINT32_VAL
(
f1
),
GET_UINT32_VAL
(
f2
));
case
TSDB_DATA_TYPE_UINT
:
DEFAULT_COMP
(
GET_UINT32_VAL
(
f1
),
GET_UINT32_VAL
(
f2
));
case
TSDB_DATA_TYPE_UBIGINT
:
DEFAULT_COMP
(
GET_UINT64_VAL
(
f1
),
GET_UINT64_VAL
(
f2
));
case
TSDB_DATA_TYPE_UBIGINT
:
DEFAULT_COMP
(
GET_UINT64_VAL
(
f1
),
GET_UINT64_VAL
(
f2
));
case
TSDB_DATA_TYPE_NCHAR
:{
case
TSDB_DATA_TYPE_NCHAR
:
return
compareLenPrefixedWStr
(
f1
,
f2
);
tstr
*
t1
=
(
tstr
*
)
f1
;
default:
// BINARY AND NULL AND SO ON
tstr
*
t2
=
(
tstr
*
)
f2
;
return
compareLenPrefixedStr
(
f1
,
f2
);
if
(
t1
->
len
!=
t2
->
len
)
{
return
t1
->
len
>
t2
->
len
?
1
:-
1
;
}
int32_t
ret
=
memcmp
((
wchar_t
*
)
t1
,
(
wchar_t
*
)
t2
,
t2
->
len
);
if
(
ret
==
0
)
{
return
ret
;
}
return
(
ret
<
0
)
?
-
1
:
1
;
}
default:
{
// todo refactor
tstr
*
t1
=
(
tstr
*
)
f1
;
tstr
*
t2
=
(
tstr
*
)
f2
;
if
(
t1
->
len
!=
t2
->
len
)
{
return
t1
->
len
>
t2
->
len
?
1
:-
1
;
}
else
{
int32_t
ret
=
strncmp
(
t1
->
data
,
t2
->
data
,
t1
->
len
);
if
(
ret
==
0
)
{
return
0
;
}
else
{
return
ret
<
0
?
-
1
:
1
;
}
}
}
}
}
}
}
tests/develop-test/0-others/json_tag.py
浏览文件 @
f0f3fe1e
...
@@ -34,7 +34,6 @@ class TDTestCase:
...
@@ -34,7 +34,6 @@ class TDTestCase:
def
run
(
self
):
def
run
(
self
):
tdSql
.
prepare
()
tdSql
.
prepare
()
print
(
"============== STEP 1 ===== prepare data & validate json string"
)
print
(
"============== STEP 1 ===== prepare data & validate json string"
)
tdSql
.
error
(
"create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json, tagint int)"
)
tdSql
.
error
(
"create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json, tagint int)"
)
tdSql
.
error
(
"create table if not exists jsons1(ts timestamp, data json) tags(tagint int)"
)
tdSql
.
error
(
"create table if not exists jsons1(ts timestamp, data json) tags(tagint int)"
)
...
@@ -379,8 +378,8 @@ class TDTestCase:
...
@@ -379,8 +378,8 @@ class TDTestCase:
tdSql
.
error
(
"select count(*) from jsons1 group by jtag->'tag1' order by jtag"
)
tdSql
.
error
(
"select count(*) from jsons1 group by jtag->'tag1' order by jtag"
)
tdSql
.
query
(
"select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc"
)
tdSql
.
query
(
"select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc"
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
0
,
2
)
tdSql
.
checkData
(
1
,
0
,
2
)
tdSql
.
checkData
(
0
,
1
,
'"femail"'
)
tdSql
.
checkData
(
1
,
1
,
'"femail"'
)
tdSql
.
checkData
(
2
,
0
,
1
)
tdSql
.
checkData
(
2
,
0
,
1
)
tdSql
.
checkData
(
2
,
1
,
11
)
tdSql
.
checkData
(
2
,
1
,
11
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
0
,
1
)
...
@@ -398,8 +397,8 @@ class TDTestCase:
...
@@ -398,8 +397,8 @@ class TDTestCase:
tdSql
.
checkData
(
2
,
1
,
"false"
)
tdSql
.
checkData
(
2
,
1
,
"false"
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
0
,
1
)
tdSql
.
checkData
(
5
,
1
,
11
)
tdSql
.
checkData
(
5
,
1
,
11
)
tdSql
.
checkData
(
7
,
0
,
2
)
tdSql
.
checkData
(
6
,
0
,
2
)
tdSql
.
checkData
(
7
,
1
,
'"femail"'
)
tdSql
.
checkData
(
6
,
1
,
'"femail"'
)
# test stddev with group by json tag
# test stddev with group by json tag
tdSql
.
query
(
"select stddev(dataint) from jsons1 group by jtag->'tag1'"
)
tdSql
.
query
(
"select stddev(dataint) from jsons1 group by jtag->'tag1'"
)
...
@@ -407,8 +406,8 @@ class TDTestCase:
...
@@ -407,8 +406,8 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
0
,
1
,
None
)
tdSql
.
checkData
(
1
,
0
,
0
)
tdSql
.
checkData
(
1
,
0
,
0
)
tdSql
.
checkData
(
1
,
1
,
"null"
)
tdSql
.
checkData
(
1
,
1
,
"null"
)
tdSql
.
checkData
(
7
,
0
,
11
)
tdSql
.
checkData
(
6
,
0
,
11
)
tdSql
.
checkData
(
7
,
1
,
'"femail"'
)
tdSql
.
checkData
(
6
,
1
,
'"femail"'
)
res
=
tdSql
.
getColNameList
(
"select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'"
)
res
=
tdSql
.
getColNameList
(
"select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'"
)
cname_list
=
[]
cname_list
=
[]
...
@@ -422,8 +421,8 @@ class TDTestCase:
...
@@ -422,8 +421,8 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
1
,
4
)
tdSql
.
checkData
(
0
,
1
,
4
)
tdSql
.
checkData
(
1
,
1
,
24
)
tdSql
.
checkData
(
1
,
1
,
24
)
tdSql
.
checkData
(
1
,
2
,
None
)
tdSql
.
checkData
(
1
,
2
,
None
)
tdSql
.
checkData
(
10
,
1
,
1
)
tdSql
.
checkData
(
8
,
1
,
1
)
tdSql
.
checkData
(
10
,
2
,
'"femail"'
)
tdSql
.
checkData
(
8
,
2
,
'"femail"'
)
# test having
# test having
tdSql
.
query
(
"select stddev(dataint) from jsons1 group by jtag->'tag1' having stddev(dataint) > 0"
)
tdSql
.
query
(
"select stddev(dataint) from jsons1 group by jtag->'tag1' having stddev(dataint) > 0"
)
...
@@ -437,7 +436,7 @@ class TDTestCase:
...
@@ -437,7 +436,7 @@ class TDTestCase:
tdSql
.
query
(
"select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)"
)
tdSql
.
query
(
"select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)"
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkRows
(
11
)
tdSql
.
checkData
(
0
,
0
,
'"femail"'
)
tdSql
.
checkData
(
1
,
0
,
'"femail"'
)
tdSql
.
checkData
(
2
,
0
,
5
)
tdSql
.
checkData
(
2
,
0
,
5
)
res
=
tdSql
.
getColNameList
(
"select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)"
)
res
=
tdSql
.
getColNameList
(
"select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)"
)
...
...
tests/develop-test/2-query/function_mode.py
浏览文件 @
f0f3fe1e
...
@@ -117,15 +117,15 @@ class TDTestCase:
...
@@ -117,15 +117,15 @@ class TDTestCase:
tdSql
.
execute
(
'insert into D002 values("2021-11-17 20:31:31", 1, 3276, true, NULL, 3.32322, 4.982392323, "你好吗", "sdf", 333)'
)
tdSql
.
execute
(
'insert into D002 values("2021-11-17 20:31:31", 1, 3276, true, NULL, 3.32322, 4.982392323, "你好吗", "sdf", 333)'
)
tdSql
.
query
(
'select mode(num) from d002 group by dbinary'
)
tdSql
.
query
(
'select mode(num) from d002 group by dbinary'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
3276
)
tdSql
.
checkData
(
1
,
0
,
3276
)
tdSql
.
checkData
(
1
,
0
,
None
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
query
(
'select mode(dfloat) from d002 group by dbinary'
)
tdSql
.
query
(
'select mode(dfloat) from d002 group by dbinary'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
None
)
tdSql
.
checkData
(
1
,
0
,
None
)
tdSql
.
query
(
'select mode(dchar) from d002 group by dbinary'
)
tdSql
.
query
(
'select mode(dchar) from d002 group by dbinary'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
"你好吗"
)
tdSql
.
checkData
(
1
,
0
,
"你好吗"
)
tdSql
.
checkData
(
1
,
0
,
"试试"
)
tdSql
.
checkData
(
0
,
0
,
"试试"
)
tdSql
.
query
(
'select mode(dchar) from smode group by dchar'
)
tdSql
.
query
(
'select mode(dchar) from smode group by dchar'
)
tdSql
.
checkRows
(
4
)
tdSql
.
checkRows
(
4
)
tdSql
.
query
(
'select mode(dbool) from smode group by dchar'
)
tdSql
.
query
(
'select mode(dbool) from smode group by dchar'
)
...
@@ -144,7 +144,7 @@ class TDTestCase:
...
@@ -144,7 +144,7 @@ class TDTestCase:
tdSql
.
checkData
(
1
,
1
,
"d002"
)
tdSql
.
checkData
(
1
,
1
,
"d002"
)
#group by tag
#group by tag
tdSql
.
query
(
'select mode(ddouble) from smode group by location'
)
tdSql
.
query
(
'select mode(ddouble) from smode group by location
order by location desc
'
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkRows
(
2
)
tdSql
.
checkData
(
0
,
0
,
4.982392323
)
tdSql
.
checkData
(
0
,
0
,
4.982392323
)
tdSql
.
checkData
(
0
,
1
,
"Beijing.haidian"
)
tdSql
.
checkData
(
0
,
1
,
"Beijing.haidian"
)
...
...
tests/develop-test/2-query/function_tail.py
浏览文件 @
f0f3fe1e
...
@@ -116,10 +116,10 @@ class TDTestCase:
...
@@ -116,10 +116,10 @@ class TDTestCase:
#group by column
#group by column
tdSql
.
query
(
'select tail(dtiny,2) from tail2 group by dnchar'
)
tdSql
.
query
(
'select tail(dtiny,2) from tail2 group by dnchar'
)
tdSql
.
checkRows
(
5
)
tdSql
.
checkRows
(
5
)
tdSql
.
checkData
(
0
,
0
,
"2021-10-15 00:31:33"
)
tdSql
.
checkData
(
2
,
0
,
"2021-10-15 00:31:33"
)
tdSql
.
checkData
(
0
,
1
,
23
)
tdSql
.
checkData
(
2
,
1
,
23
)
tdSql
.
checkData
(
2
,
0
,
"2021-12-24 00:31:34"
)
tdSql
.
checkData
(
1
,
0
,
"2021-12-24 00:31:34"
)
tdSql
.
checkData
(
2
,
1
,
None
)
tdSql
.
checkData
(
1
,
1
,
None
)
tdSql
.
checkData
(
4
,
0
,
"2022-01-01 08:00:07"
)
tdSql
.
checkData
(
4
,
0
,
"2022-01-01 08:00:07"
)
tdSql
.
checkData
(
4
,
1
,
25
)
tdSql
.
checkData
(
4
,
1
,
25
)
tdSql
.
query
(
'select tail(dtiny,2,1) from tail2 group by dnchar'
)
tdSql
.
query
(
'select tail(dtiny,2,1) from tail2 group by dnchar'
)
...
@@ -130,8 +130,8 @@ class TDTestCase:
...
@@ -130,8 +130,8 @@ class TDTestCase:
tdSql
.
checkData
(
0
,
1
,
123
)
tdSql
.
checkData
(
0
,
1
,
123
)
tdSql
.
checkData
(
2
,
0
,
"2021-10-17 00:31:31"
)
tdSql
.
checkData
(
2
,
0
,
"2021-10-17 00:31:31"
)
tdSql
.
checkData
(
2
,
1
,
253
)
tdSql
.
checkData
(
2
,
1
,
253
)
tdSql
.
checkData
(
4
,
0
,
"2022-01-01 08:00:07"
)
tdSql
.
checkData
(
6
,
0
,
"2022-01-01 08:00:07"
)
tdSql
.
checkData
(
4
,
1
,
25
)
tdSql
.
checkData
(
6
,
1
,
25
)
tdSql
.
query
(
'select tail(dtiny,2,1) from stail group by dnchar'
)
tdSql
.
query
(
'select tail(dtiny,2,1) from stail group by dnchar'
)
tdSql
.
checkRows
(
5
)
tdSql
.
checkRows
(
5
)
...
...
tests/develop-test/2-query/function_unique.py
浏览文件 @
f0f3fe1e
...
@@ -142,11 +142,11 @@ class TDTestCase:
...
@@ -142,11 +142,11 @@ class TDTestCase:
tdSql
.
query
(
'select ts,unique(voltage) from unique group by location'
)
tdSql
.
query
(
'select ts,unique(voltage) from unique group by location'
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkRows
(
8
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
0
,
3
,
"Beijing.haidian"
)
tdSql
.
checkData
(
5
,
3
,
"Beijing.haidian"
)
tdSql
.
checkData
(
3
,
2
,
1
)
tdSql
.
checkData
(
0
,
2
,
1
)
tdSql
.
checkData
(
3
,
3
,
"Beijing.Chaoyang"
)
tdSql
.
checkData
(
0
,
3
,
"Beijing.Chaoyang"
)
tdSql
.
checkData
(
5
,
2
,
1
)
tdSql
.
checkData
(
2
,
2
,
1
)
tdSql
.
checkData
(
5
,
3
,
"Beijing.Tongzhou"
)
tdSql
.
checkData
(
2
,
3
,
"Beijing.Tongzhou"
)
#group by ts
#group by ts
tdSql
.
query
(
'select ts,unique(voltage) from unique group by ts'
)
tdSql
.
query
(
'select ts,unique(voltage) from unique group by ts'
)
tdSql
.
checkRows
(
9
)
tdSql
.
checkRows
(
9
)
...
...
tests/pytest/functions/function_stddev.py
浏览文件 @
f0f3fe1e
...
@@ -135,9 +135,9 @@ class TDTestCase:
...
@@ -135,9 +135,9 @@ class TDTestCase:
tdSql
.
execute
(
"insert into std3 values(now + 5s, 4);"
)
tdSql
.
execute
(
"insert into std3 values(now + 5s, 4);"
)
tdSql
.
execute
(
"insert into std3 values(now + 6s, 8);"
)
tdSql
.
execute
(
"insert into std3 values(now + 6s, 8);"
)
tdSql
.
query
(
"select stddev(col1) from stdtable group by loc;"
)
tdSql
.
query
(
"select stddev(col1) from stdtable group by loc;"
)
tdSql
.
checkData
(
0
,
0
,
2.0
)
tdSql
.
checkData
(
2
,
0
,
2.0
)
tdSql
.
checkData
(
1
,
0
,
0.5
)
tdSql
.
checkData
(
1
,
0
,
0.5
)
tdSql
.
checkData
(
2
,
0
,
0.5
)
tdSql
.
checkData
(
0
,
0
,
0.5
)
tdSql
.
execute
(
"create table stdtableint(ts timestamp, col1 int) tags(num int)"
)
tdSql
.
execute
(
"create table stdtableint(ts timestamp, col1 int) tags(num int)"
)
tdSql
.
execute
(
"create table stdint1 using stdtableint tags(1)"
)
tdSql
.
execute
(
"create table stdint1 using stdtableint tags(1)"
)
...
...
tests/pytest/query/bug2117.py
浏览文件 @
f0f3fe1e
...
@@ -49,13 +49,13 @@ class TDTestCase:
...
@@ -49,13 +49,13 @@ class TDTestCase:
tdSql
.
query
(
'select last(*) from mt0 group by c8'
)
tdSql
.
query
(
'select last(*) from mt0 group by c8'
)
tdSql
.
checkData
(
0
,
3
,
5
)
tdSql
.
checkData
(
0
,
3
,
5
)
tdSql
.
checkData
(
0
,
4
,
20
)
tdSql
.
checkData
(
0
,
4
,
20
)
tdSql
.
checkData
(
3
,
1
,
92
)
tdSql
.
checkData
(
3
,
1
,
57
)
tdSql
.
checkData
(
3
,
9
,
'涛思
8
'
)
tdSql
.
checkData
(
3
,
9
,
'涛思
14
'
)
tdSql
.
query
(
'select last(*) from mt0 group by c9'
)
tdSql
.
query
(
'select last(*) from mt0 group by c9'
)
tdSql
.
checkData
(
0
,
3
,
0
)
tdSql
.
checkData
(
0
,
3
,
0
)
tdSql
.
checkData
(
0
,
8
,
'taos38'
)
tdSql
.
checkData
(
0
,
8
,
'taos38'
)
tdSql
.
checkData
(
40
,
1
,
83
)
tdSql
.
checkData
(
35
,
1
,
83
)
tdSql
.
checkData
(
40
,
3
,
40
)
tdSql
.
checkData
(
35
,
3
,
40
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/pytest/query/bug2143.py
浏览文件 @
f0f3fe1e
...
@@ -51,19 +51,19 @@ class TDTestCase:
...
@@ -51,19 +51,19 @@ class TDTestCase:
tdSql
.
checkRows
(
0
)
tdSql
.
checkRows
(
0
)
tdSql
.
query
(
'select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 70 offset 3'
)
tdSql
.
query
(
'select max(c1),min(c1),first(c1),last(c1) from mt0 group by c3 limit 70 offset 3'
)
tdSql
.
checkRows
(
38
)
tdSql
.
checkRows
(
38
)
tdSql
.
query
(
'select max(c1),min(c1),first(c1),last(c1) from mt0 group by c8 limit 3 offset 2'
)
tdSql
.
query
(
'select max(c1),min(c1),first(c1),last(c1) from mt0 group by c8 limit 3 offset
1
2'
)
tdSql
.
checkData
(
0
,
0
,
91
)
tdSql
.
checkData
(
0
,
0
,
91
)
tdSql
.
checkData
(
0
,
1
,
2
)
tdSql
.
checkData
(
0
,
1
,
2
)
tdSql
.
checkData
(
0
,
2
,
2
)
tdSql
.
checkData
(
0
,
2
,
2
)
tdSql
.
checkData
(
0
,
3
,
91
)
tdSql
.
checkData
(
0
,
3
,
91
)
tdSql
.
checkData
(
1
,
0
,
9
2
)
tdSql
.
checkData
(
1
,
0
,
9
4
)
tdSql
.
checkData
(
2
,
1
,
4
)
tdSql
.
checkData
(
2
,
1
,
7
)
tdSql
.
query
(
'select max(c1),min(c1),first(c1),last(c1) from mt0 group by c9 limit 2 offset 9'
)
tdSql
.
query
(
'select max(c1),min(c1),first(c1),last(c1) from mt0 group by c9 limit 2 offset
3
9'
)
tdSql
.
checkData
(
0
,
0
,
96
)
tdSql
.
checkData
(
1
,
0
,
96
)
tdSql
.
checkData
(
0
,
1
,
1
)
tdSql
.
checkData
(
1
,
1
,
1
)
tdSql
.
checkData
(
0
,
2
,
9
)
tdSql
.
checkData
(
1
,
2
,
9
)
tdSql
.
checkData
(
0
,
3
,
9
3
)
tdSql
.
checkData
(
0
,
3
,
9
2
)
tdSql
.
checkData
(
1
,
0
,
97
)
tdSql
.
checkData
(
0
,
0
,
95
)
def
stop
(
self
):
def
stop
(
self
):
tdSql
.
close
()
tdSql
.
close
()
...
...
tests/pytest/query/filterOtherTypes.py
浏览文件 @
f0f3fe1e
...
@@ -303,11 +303,11 @@ class TDTestCase:
...
@@ -303,11 +303,11 @@ class TDTestCase:
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# > for binary type on tag
# > for binary type on tag
tdSql
.
query
(
"select * from st where tagcol3
>
'表'"
)
tdSql
.
query
(
"select * from st where tagcol3
<
'表'"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# >= for binary type on tag
# >= for binary type on tag
tdSql
.
query
(
"select * from st where tagcol3
>
= '表'"
)
tdSql
.
query
(
"select * from st where tagcol3
<
= '表'"
)
tdSql
.
checkRows
(
10
)
tdSql
.
checkRows
(
10
)
# = for binary type on tag
# = for binary type on tag
...
...
tests/pytest/query/querySort.py
浏览文件 @
f0f3fe1e
...
@@ -18,6 +18,8 @@ from util.cases import *
...
@@ -18,6 +18,8 @@ from util.cases import *
from
util.sql
import
*
from
util.sql
import
*
import
numpy
as
np
import
numpy
as
np
# constant define
WAITS
=
5
# wait seconds
class
TDTestCase
:
class
TDTestCase
:
def
init
(
self
,
conn
,
logSql
):
def
init
(
self
,
conn
,
logSql
):
...
@@ -67,9 +69,7 @@ class TDTestCase:
...
@@ -67,9 +69,7 @@ class TDTestCase:
"%s failed: sql:%s, the order provided for col:%d is not correct"
%
"%s failed: sql:%s, the order provided for col:%d is not correct"
%
(
callerFilename
,
tdSql
.
sql
,
col
))
(
callerFilename
,
tdSql
.
sql
,
col
))
def
run
(
self
):
def
test_base
(
self
):
tdSql
.
prepare
()
print
(
"======= step 1: create table and insert data ========="
)
print
(
"======= step 1: create table and insert data ========="
)
tdLog
.
debug
(
tdLog
.
debug
(
''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double,
''' create table st(ts timestamp, tbcol1 tinyint, tbcol2 smallint, tbcol3 int, tbcol4 bigint, tbcol5 float, tbcol6 double,
...
@@ -183,6 +183,44 @@ class TDTestCase:
...
@@ -183,6 +183,44 @@ class TDTestCase:
tdSql
.
close
()
tdSql
.
close
()
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
tdLog
.
success
(
"%s successfully executed"
%
__file__
)
def
create_insert_data
(
self
):
sql
=
"create table sb(ts timestamp, i1 int) tags(t_b1 binary(32), t_n1 nchar(64));"
tdSql
.
execute
(
sql
)
for
i
in
range
(
20
):
value
=
"%s%s%s"
%
(
chr
(
64
+
i
),
chr
(
64
+
i
),
chr
(
65
+
i
))
if
i
%
10
==
5
:
value
+=
"_%s"
%
(
chr
(
66
+
i
))
if
i
%
10
==
0
:
value
+=
"_%s"
%
(
chr
(
67
+
i
))
sql
=
"insert into b%d using sb tags('A%s', 'B%s') values(now, %d);"
%
(
i
,
value
,
value
,
i
+
1000
)
tdSql
.
execute
(
sql
)
def
test_groupby_order
(
self
):
# create and insert data
print
(
"======= group order step 1: create table and insert data ========="
)
self
.
create_insert_data
()
# do query
print
(
"======= group order step 2: do query ========="
)
# ASC
sql
=
"select count(*) from sb group by t_b1 order by t_b1 asc;"
tdSql
.
execute
(
sql
)
tdSql
.
waitedQuery
(
sql
,
20
,
WAITS
)
tdSql
.
checkData
(
0
,
1
,
"A@@A_C"
)
tdSql
.
checkData
(
5
,
1
,
"AEEF_G"
)
tdSql
.
checkData
(
19
,
1
,
"ASST"
)
#DESC
sql
=
"select count(*) from sb group by t_b1 order by t_b1 desc;"
tdSql
.
execute
(
sql
)
tdSql
.
waitedQuery
(
sql
,
20
,
WAITS
)
tdSql
.
checkData
(
19
,
1
,
"A@@A_C"
)
tdSql
.
checkData
(
4
,
1
,
"AOOP_Q"
)
tdSql
.
checkData
(
0
,
1
,
"ASST"
)
def
run
(
self
):
tdSql
.
prepare
()
self
.
test_base
()
self
.
test_groupby_order
()
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addWindows
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tdCases
.
addLinux
(
__file__
,
TDTestCase
())
tests/script/general/parser/columnValue_unsign.sim
浏览文件 @
f0f3fe1e
...
@@ -116,7 +116,7 @@ if $data00 != NULL then
...
@@ -116,7 +116,7 @@ if $data00 != NULL then
return -1
return -1
endi
endi
sql select count(*), a from mt_unsigned_1 group by a;
sql select count(*), a from mt_unsigned_1 group by a
order by a desc
;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
...
@@ -137,7 +137,7 @@ if $data11 != 1 then
...
@@ -137,7 +137,7 @@ if $data11 != 1 then
return -1
return -1
endi
endi
sql select count(*), b from mt_unsigned_1 group by b;
sql select count(*), b from mt_unsigned_1 group by b
order by b desc
;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
...
@@ -158,7 +158,7 @@ if $data11 != 2 then
...
@@ -158,7 +158,7 @@ if $data11 != 2 then
return -1
return -1
endi
endi
sql select count(*), c from mt_unsigned_1 group by c;
sql select count(*), c from mt_unsigned_1 group by c
order by c desc
;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
...
@@ -179,7 +179,7 @@ if $data11 != 3 then
...
@@ -179,7 +179,7 @@ if $data11 != 3 then
return -1
return -1
endi
endi
sql select count(*), d from mt_unsigned_1 group by d;
sql select count(*), d from mt_unsigned_1 group by d
order by d desc
;
if $rows != 2 then
if $rows != 2 then
return -1
return -1
endi
endi
...
...
tests/script/general/parser/groupby.sim
浏览文件 @
f0f3fe1e
...
@@ -594,7 +594,8 @@ if $data10 != @{slop:0.000000, intercept:1.000000}@ then
...
@@ -594,7 +594,8 @@ if $data10 != @{slop:0.000000, intercept:1.000000}@ then
return -1
return -1
endi
endi
if $data90 != @{slop:0.000000, intercept:9.000000}@ then
if $data90 != @{slop:0.000000, intercept:17.000000}@ then
print " data90 expect: {slop:0.000000, intercept:17.000000} real:"$data90
return -1
return -1
endi
endi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录