Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
21e62f12
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看板
提交
21e62f12
编写于
11月 15, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into fix/TD-20412
上级
d985cb71
28cbc95c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
157 addition
and
108 deletion
+157
-108
docs/en/05-get-started/index.md
docs/en/05-get-started/index.md
+5
-5
docs/en/12-taos-sql/02-database.md
docs/en/12-taos-sql/02-database.md
+1
-1
docs/zh/05-get-started/index.md
docs/zh/05-get-started/index.md
+6
-6
docs/zh/12-taos-sql/02-database.md
docs/zh/12-taos-sql/02-database.md
+2
-2
docs/zh/14-reference/04-taosadapter.md
docs/zh/14-reference/04-taosadapter.md
+1
-1
docs/zh/14-reference/07-tdinsight/index.mdx
docs/zh/14-reference/07-tdinsight/index.mdx
+19
-14
source/dnode/vnode/src/tq/tqSink.c
source/dnode/vnode/src/tq/tqSink.c
+5
-1
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+12
-12
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+71
-66
tests/script/tsim/stream/basic1.sim
tests/script/tsim/stream/basic1.sim
+35
-0
未找到文件。
docs/en/05-get-started/index.md
浏览文件 @
21e62f12
...
@@ -24,10 +24,10 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
...
@@ -24,10 +24,10 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
<table
width=
"100%"
>
<table
width=
"100%"
>
<tr
align=
"center"
>
<tr
align=
"center"
>
<td
width=
"20%"
style=
"border:0"
><a
href=
"https://github.com/taosdata/TDengine"
target=
"_blank"
><img
src=
{github}
alt=
"Star GitHub"
width=
"50"
/><p>
Star GitHub
</p></a></td>
<td
width=
"20%"
style=
{{border:0}}
><a
href=
"https://github.com/taosdata/TDengine"
target=
"_blank"
><img
src=
{github}
alt=
"Star GitHub"
width=
"50"
/><p>
Star GitHub
</p></a></td>
<td
width=
"20%"
style=
"border:0"
><a
href=
"https://discord.com/invite/VZdSuUg4pS"
target=
"_blank"
><img
src=
{discord}
alt=
"Join Discord"
width=
"50"
/><p>
Join Discord
</p></a></td>
<td
width=
"20%"
style=
{{border:0}}
><a
href=
"https://discord.com/invite/VZdSuUg4pS"
target=
"_blank"
><img
src=
{discord}
alt=
"Join Discord"
width=
"50"
/><p>
Join Discord
</p></a></td>
<td
width=
"20%"
style=
"border:0"
><a
href=
"https://twitter.com/TDengineDB"
target=
"_blank"
><img
src=
{twitter}
alt=
"Follow Twitter"
width=
"50"
/><p>
Follow Twitter
</p></a></td>
<td
width=
"20%"
style=
{{border:0}}
><a
href=
"https://twitter.com/TDengineDB"
target=
"_blank"
><img
src=
{twitter}
alt=
"Follow Twitter"
width=
"50"
/><p>
Follow Twitter
</p></a></td>
<td
width=
"20%"
style=
"border:0"
><a
href=
"https://www.youtube.com/@tdengine"
target=
"_blank"
><img
src=
{youtube}
alt=
"Subscribe YouTube"
width=
"50"
/><p>
Subscribe YouTube
</p></a></td>
<td
width=
"20%"
style=
{{border:0}}
><a
href=
"https://www.youtube.com/@tdengine"
target=
"_blank"
><img
src=
{youtube}
alt=
"Subscribe YouTube"
width=
"50"
/><p>
Subscribe YouTube
</p></a></td>
<td
width=
"20%"
style=
"border:0"
><a
href=
"https://www.linkedin.com/company/tdengine"
target=
"_blank"
><img
src=
{linkedin}
alt=
"Follow LinkedIn"
width=
"50"
/><p>
Follow LinkedIn
</p></a></td>
<td
width=
"20%"
style=
{{border:0}}
><a
href=
"https://www.linkedin.com/company/tdengine"
target=
"_blank"
><img
src=
{linkedin}
alt=
"Follow LinkedIn"
width=
"50"
/><p>
Follow LinkedIn
</p></a></td>
</tr>
</tr>
</table>
</table>
docs/en/12-taos-sql/02-database.md
浏览文件 @
21e62f12
...
@@ -142,7 +142,7 @@ The preceding SQL statement can be used in migration scenarios. This command can
...
@@ -142,7 +142,7 @@ The preceding SQL statement can be used in migration scenarios. This command can
### View Database Configuration
### View Database Configuration
```
sql
```
sql
S
HOW
DATABASES
\
G
;
S
ELECT
*
FROM
INFORMATION_SCHEMA
.
INS_DATABASES
WHERE
NAME
=
'DBNAME'
\
G
;
```
```
The preceding SQL statement shows the value of each parameter for the specified database. One value is displayed per line.
The preceding SQL statement shows the value of each parameter for the specified database. One value is displayed per line.
...
...
docs/zh/05-get-started/index.md
浏览文件 @
21e62f12
...
@@ -24,13 +24,13 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
...
@@ -24,13 +24,13 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
<table
width=
"100%"
>
<table
width=
"100%"
>
<tr
align=
"center"
>
<tr
align=
"center"
>
<td
style=
"padding:1em;border:0"
><img
src=
{xiaot}
alt=
"小 T 的二维码"
width=
"200"
/></td>
<td
style=
{{padding:'1em',border:0}}
><img
src=
{xiaot}
alt=
"小 T 的二维码"
width=
"200"
/></td>
<td
style=
"padding:1em;border:0"
><img
src=
{channel}
alt=
"TDengine 微信视频号"
width=
"200"
/></td>
<td
style=
{{padding:'1em',border:0}}
><img
src=
{channel}
alt=
"TDengine 微信视频号"
width=
"200"
/></td>
<td
style=
"padding:1em;border:0"
><img
src=
{official_account}
alt=
"TDengine 微信公众号"
width=
"200"
/></td>
<td
style=
{{padding:'1em',border:0}}
><img
src=
{official_account}
alt=
"TDengine 微信公众号"
width=
"200"
/></td>
</tr>
</tr>
<tr
align=
"center"
>
<tr
align=
"center"
>
<td
style=
"padding:1em;border:0"
>
加入“物联网大数据技术前沿群”
<br/>
与大家进行技术交流
</td>
<td
style=
{{padding:'1em',border:0}}
>
加入“物联网大数据技术前沿群”
<br/>
与大家进行技术交流
</td>
<td
style=
"padding:1em;border:0"
>
关注 TDengine 微信视频号
<br/>
收看技术直播与教学视频
</td>
<td
style=
{{padding:'1em',border:0}}
>
关注 TDengine 微信视频号
<br/>
收看技术直播与教学视频
</td>
<td
style=
"padding:1em;border:0"
>
关注 TDengine 微信公众号
<br/>
阅读核心技术与行业案例文章
</td>
<td
style=
{{padding:'1em',border:0}}
>
关注 TDengine 微信公众号
<br/>
阅读核心技术与行业案例文章
</td>
</tr>
</tr>
</table>
</table>
docs/zh/12-taos-sql/02-database.md
浏览文件 @
21e62f12
...
@@ -142,10 +142,10 @@ SHOW CREATE DATABASE db_name;
...
@@ -142,10 +142,10 @@ SHOW CREATE DATABASE db_name;
### 查看数据库参数
### 查看数据库参数
```
sql
```
sql
S
HOW
DATABASES
\
G
;
S
ELECT
*
FROM
INFORMATION_SCHEMA
.
INS_DATABASES
WHERE
NAME
=
'DBNAME'
\
G
;
```
```
会列出
系统中所有
数据库的配置参数,并且每行只显示一个参数。
会列出
指定
数据库的配置参数,并且每行只显示一个参数。
## 删除过期数据
## 删除过期数据
...
...
docs/zh/14-reference/04-taosadapter.md
浏览文件 @
21e62f12
...
@@ -32,7 +32,7 @@ taosAdapter 提供以下功能:
...
@@ -32,7 +32,7 @@ taosAdapter 提供以下功能:
taosAdapter 是 TDengine 服务端软件 的一部分,如果您使用 TDengine server 您不需要任何额外的步骤来安装 taosAdapter。您可以从
[
涛思数据官方网站
](
https://taosdata.com/cn/all-downloads/
)
下载 TDengine server 安装包。如果需要将 taosAdapter 分离部署在 TDengine server 之外的服务器上,则应该在该服务器上安装完整的 TDengine 来安装 taosAdapter。如果您需要使用源代码编译生成 taosAdapter,您可以参考
[
构建 taosAdapter
](
https://github.com/taosdata/taosadapter/blob/3.0/BUILD-CN.md
)
文档。
taosAdapter 是 TDengine 服务端软件 的一部分,如果您使用 TDengine server 您不需要任何额外的步骤来安装 taosAdapter。您可以从
[
涛思数据官方网站
](
https://taosdata.com/cn/all-downloads/
)
下载 TDengine server 安装包。如果需要将 taosAdapter 分离部署在 TDengine server 之外的服务器上,则应该在该服务器上安装完整的 TDengine 来安装 taosAdapter。如果您需要使用源代码编译生成 taosAdapter,您可以参考
[
构建 taosAdapter
](
https://github.com/taosdata/taosadapter/blob/3.0/BUILD-CN.md
)
文档。
###
start/stop
taosAdapter
###
启动/停止
taosAdapter
在 Linux 系统上 taosAdapter 服务默认由 systemd 管理。使用命令
`systemctl start taosadapter`
可以启动 taosAdapter 服务。使用命令
`systemctl stop taosadapter`
可以停止 taosAdapter 服务。
在 Linux 系统上 taosAdapter 服务默认由 systemd 管理。使用命令
`systemctl start taosadapter`
可以启动 taosAdapter 服务。使用命令
`systemctl stop taosadapter`
可以停止 taosAdapter 服务。
...
...
docs/zh/14-reference/07-tdinsight/index.mdx
浏览文件 @
21e62f12
...
@@ -4,6 +4,9 @@ sidebar_label: TDinsight
...
@@ -4,6 +4,9 @@ sidebar_label: TDinsight
description: 基于Grafana的TDengine零依赖监控解决方案
description: 基于Grafana的TDengine零依赖监控解决方案
---
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
TDinsight 是使用监控数据库和 [Grafana] 对 TDengine 进行监控的解决方案。
TDinsight 是使用监控数据库和 [Grafana] 对 TDengine 进行监控的解决方案。
TDengine 通过 [taosKeeper](../taosKeeper) 将服务器的 CPU、内存、硬盘空间、带宽、请求数、磁盘读写速度、慢查询等信息定时写入指定数据库,并对重要的系统操作(比如登录、创建、删除数据库等)以及各种错误报警信息进行记录。通过 [Grafana] 和 [TDengine 数据源插件](https://github.com/taosdata/grafanaplugin/releases),TDinsight 将集群状态、节点信息、插入及查询请求、资源使用情况等进行可视化展示,同时还支持 vnode、dnode、mnode 节点状态异常告警,为开发者实时监控 TDengine 集群运行状态提供了便利。本文将指导用户安装 Grafana 服务器并通过 `TDinsight.sh` 安装脚本自动安装 TDengine 数据源插件及部署 TDinsight 可视化面板。
TDengine 通过 [taosKeeper](../taosKeeper) 将服务器的 CPU、内存、硬盘空间、带宽、请求数、磁盘读写速度、慢查询等信息定时写入指定数据库,并对重要的系统操作(比如登录、创建、删除数据库等)以及各种错误报警信息进行记录。通过 [Grafana] 和 [TDengine 数据源插件](https://github.com/taosdata/grafanaplugin/releases),TDinsight 将集群状态、节点信息、插入及查询请求、资源使用情况等进行可视化展示,同时还支持 vnode、dnode、mnode 节点状态异常告警,为开发者实时监控 TDengine 集群运行状态提供了便利。本文将指导用户安装 Grafana 服务器并通过 `TDinsight.sh` 安装脚本自动安装 TDengine 数据源插件及部署 TDinsight 可视化面板。
...
@@ -41,6 +44,7 @@ sudo apt-get install grafana
...
@@ -41,6 +44,7 @@ sudo apt-get install grafana
```
```
### 在 CentOS / RHEL 上安装 Grafana
### 在 CentOS / RHEL 上安装 Grafana
</TabItem>
</TabItem>
<TabItem label="redhat" value="基于 CentOS / RHEL 系统">
<TabItem label="redhat" value="基于 CentOS / RHEL 系统">
...
@@ -127,20 +131,20 @@ Install and configure TDinsight dashboard in Grafana on Ubuntu 18.04/20.04 syste
...
@@ -127,20 +131,20 @@ Install and configure TDinsight dashboard in Grafana on Ubuntu 18.04/20.04 syste
大多数命令行选项都可以通过环境变量获得同样的效果。
大多数命令行选项都可以通过环境变量获得同样的效果。
| 短选项 | 长选项 | 环境变量 | 说明
|
| 短选项 | 长选项 | 环境变量 | 说明 |
| ------ | -------------------------- | ---------------------------- | -------------------------------------------------------
--------------------
|
| ------ | -------------------------- | ---------------------------- | ------------------------------------------------------- |
| -v | --plugin-version | TDENGINE_PLUGIN_VERSION | TDengine 数据源插件版本,默认使用最新版。
|
| -v | --plugin-version | TDENGINE_PLUGIN_VERSION | TDengine 数据源插件版本,默认使用最新版。 |
| -P | --grafana-provisioning-dir | GF_PROVISIONING_DIR | Grafana 配置目录,默认为`/etc/grafana/provisioning/`
|
| -P | --grafana-provisioning-dir | GF_PROVISIONING_DIR | Grafana 配置目录,默认为`/etc/grafana/provisioning/` |
| -G | --grafana-plugins-dir | GF_PLUGINS_DIR | Grafana 插件目录,默认为`/var/lib/grafana/plugins`。
|
| -G | --grafana-plugins-dir | GF_PLUGINS_DIR | Grafana 插件目录,默认为`/var/lib/grafana/plugins`。 |
| -O | --grafana-org-id | GF_ORG_ID | Grafana 组织 ID,默认为 1。
|
| -O | --grafana-org-id | GF_ORG_ID | Grafana 组织 ID,默认为 1。 |
| -n | --tdengine-ds-name | TDENGINE_DS_NAME | TDengine 数据源名称,默认为 TDengine。
|
| -n | --tdengine-ds-name | TDENGINE_DS_NAME | TDengine 数据源名称,默认为 TDengine。 |
| -a | --tdengine-api | TDENGINE_API | TDengine REST API 端点。默认为`http://127.0.0.1:6041`。
|
| -a | --tdengine-api | TDENGINE_API | TDengine REST API 端点。默认为`http://127.0.0.1:6041`。 |
| -u | --tdengine-user | TDENGINE_USER | TDengine 用户名。 [默认值:root]
|
| -u | --tdengine-user | TDENGINE_USER | TDengine 用户名。 [默认值:root] |
| -p | --tdengine-密码 | TDENGINE_PASSWORD | TDengine 密码。 [默认:taosdata]
|
| -p | --tdengine-密码 | TDENGINE_PASSWORD | TDengine 密码。 [默认:taosdata] |
| -i | --tdinsight-uid | TDINSIGHT_DASHBOARD_UID | TDinsight 仪表盘`uid`。 [默认值:tdinsight]
|
| -i | --tdinsight-uid | TDINSIGHT_DASHBOARD_UID | TDinsight 仪表盘`uid`。 [默认值:tdinsight] |
| -t | --tdinsight-title | TDINSIGHT_DASHBOARD_TITLE | TDinsight 仪表盘标题。 [默认:TDinsight]
|
| -t | --tdinsight-title | TDINSIGHT_DASHBOARD_TITLE | TDinsight 仪表盘标题。 [默认:TDinsight] |
| -e | --tdinsight-可编辑 | TDINSIGHT_DASHBOARD_EDITABLE | 如果配置仪表盘可以编辑。 [默认值:false]
|
| -e | --tdinsight-可编辑 | TDINSIGHT_DASHBOARD_EDITABLE | 如果配置仪表盘可以编辑。 [默认值:false] |
| -E | --external-notifier | EXTERNAL_NOTIFIER | 将外部通知程序 uid 应用于 TDinsight 仪表盘。
|
| -E | --external-notifier | EXTERNAL_NOTIFIER | 将外部通知程序 uid 应用于 TDinsight 仪表盘。 |
假设您在主机 `tdengine` 上启动 TDengine 数据库,HTTP API 端口为 `6041`,用户为 `root1`,密码为 `pass5ord`。执行脚本:
假设您在主机 `tdengine` 上启动 TDengine 数据库,HTTP API 端口为 `6041`,用户为 `root1`,密码为 `pass5ord`。执行脚本:
...
@@ -196,6 +200,7 @@ sudo grafana-cli \
...
@@ -196,6 +200,7 @@ sudo grafana-cli \
[plugins]
[plugins]
allow_loading_unsigned_plugins = tdengine-datasource
allow_loading_unsigned_plugins = tdengine-datasource
```
```
:::
:::
### 启动 Grafana 服务
### 启动 Grafana 服务
...
...
source/dnode/vnode/src/tq/tqSink.c
浏览文件 @
21e62f12
...
@@ -31,7 +31,11 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl
...
@@ -31,7 +31,11 @@ int32_t tqBuildDeleteReq(SVnode* pVnode, const char* stbFullName, const SSDataBl
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
row
);
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
row
);
int64_t
groupId
=
*
(
int64_t
*
)
colDataGetData
(
pGidCol
,
row
);
int64_t
groupId
=
*
(
int64_t
*
)
colDataGetData
(
pGidCol
,
row
);
char
*
name
;
char
*
name
;
void
*
varTbName
=
colDataGetVarData
(
pTbNameCol
,
row
);
void
*
varTbName
=
NULL
;
if
(
!
colDataIsNull
(
pTbNameCol
,
totRow
,
row
,
NULL
))
{
varTbName
=
colDataGetVarData
(
pTbNameCol
,
row
);
}
if
(
varTbName
!=
NULL
&&
varTbName
!=
(
void
*
)
-
1
)
{
if
(
varTbName
!=
NULL
&&
varTbName
!=
(
void
*
)
-
1
)
{
name
=
taosMemoryCalloc
(
1
,
TSDB_TABLE_NAME_LEN
);
name
=
taosMemoryCalloc
(
1
,
TSDB_TABLE_NAME_LEN
);
memcpy
(
name
,
varDataVal
(
varTbName
),
varDataLen
(
varTbName
));
memcpy
(
name
,
varDataVal
(
varTbName
),
varDataLen
(
varTbName
));
...
...
source/libs/scalar/src/filter.c
浏览文件 @
21e62f12
...
@@ -248,9 +248,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
...
@@ -248,9 +248,9 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) {
}
}
}
}
// if (optr == OP_TYPE_JSON_CONTAINS && type == TSDB_DATA_TYPE_JSON) {
// if (optr == OP_TYPE_JSON_CONTAINS && type == TSDB_DATA_TYPE_JSON) {
// return 28;
// return 28;
// }
// }
switch
(
type
)
{
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
...
@@ -1094,7 +1094,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left,
...
@@ -1094,7 +1094,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left,
if
(
tmp
==
NULL
)
{
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
info
->
units
=
(
SFilterUnit
*
)
tmp
;
info
->
units
=
(
SFilterUnit
*
)
tmp
;
memset
(
info
->
units
+
psize
,
0
,
sizeof
(
*
info
->
units
)
*
FILTER_DEFAULT_UNIT_SIZE
);
memset
(
info
->
units
+
psize
,
0
,
sizeof
(
*
info
->
units
)
*
FILTER_DEFAULT_UNIT_SIZE
);
}
}
...
@@ -1176,7 +1176,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
...
@@ -1176,7 +1176,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
SScalarParam
out
=
{.
columnData
=
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
))};
SScalarParam
out
=
{.
columnData
=
taosMemoryCalloc
(
1
,
sizeof
(
SColumnInfoData
))};
out
.
columnData
->
info
.
type
=
type
;
out
.
columnData
->
info
.
type
=
type
;
out
.
columnData
->
info
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
;
//
reserved space for simple_copy
out
.
columnData
->
info
.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
;
//
reserved space for simple_copy
for
(
int32_t
i
=
0
;
i
<
listNode
->
pNodeList
->
length
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
listNode
->
pNodeList
->
length
;
++
i
)
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
cell
->
pNode
;
SValueNode
*
valueNode
=
(
SValueNode
*
)
cell
->
pNode
;
...
@@ -1198,7 +1198,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
...
@@ -1198,7 +1198,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) {
filterAddField
(
info
,
NULL
,
(
void
**
)
&
out
.
columnData
->
pData
,
FLD_TYPE_VALUE
,
&
right
,
len
,
true
);
filterAddField
(
info
,
NULL
,
(
void
**
)
&
out
.
columnData
->
pData
,
FLD_TYPE_VALUE
,
&
right
,
len
,
true
);
out
.
columnData
->
pData
=
NULL
;
out
.
columnData
->
pData
=
NULL
;
}
else
{
}
else
{
void
*
data
=
taosMemoryCalloc
(
1
,
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
);
//
reserved space for simple_copy
void
*
data
=
taosMemoryCalloc
(
1
,
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
);
//
reserved space for simple_copy
if
(
NULL
==
data
)
{
if
(
NULL
==
data
)
{
FLT_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
FLT_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
...
@@ -1640,11 +1640,11 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
...
@@ -1640,11 +1640,11 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
SValueNode
*
var
=
(
SValueNode
*
)
field
->
desc
;
SValueNode
*
var
=
(
SValueNode
*
)
field
->
desc
;
SDataType
*
dType
=
&
var
->
node
.
resType
;
SDataType
*
dType
=
&
var
->
node
.
resType
;
//if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) {
//
if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) {
// qDebug("VAL%d => [type:TS][val:[%" PRIi64 "] - [%" PRId64 "]]", i, *(int64_t *)field->data,
//
qDebug("VAL%d => [type:TS][val:[%" PRIi64 "] - [%" PRId64 "]]", i, *(int64_t *)field->data,
// *(((int64_t *)field->data) + 1));
//
*(((int64_t *)field->data) + 1));
//} else {
//
} else {
qDebug
(
"VAL%d => [type:%d][val:%"
PRIx64
"]"
,
i
,
dType
->
type
,
var
->
datum
.
i
);
// TODO
qDebug
(
"VAL%d => [type:%d][val:%"
PRIx64
"]"
,
i
,
dType
->
type
,
var
->
datum
.
i
);
// TODO
//}
//}
}
else
if
(
field
->
data
)
{
}
else
if
(
field
->
data
)
{
qDebug
(
"VAL%d => [type:NIL][val:NIL]"
,
i
);
// TODO
qDebug
(
"VAL%d => [type:NIL][val:NIL]"
,
i
);
// TODO
...
@@ -1726,7 +1726,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
...
@@ -1726,7 +1726,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options)
ctx
->
isrange
);
ctx
->
isrange
);
if
(
ctx
->
isrange
)
{
if
(
ctx
->
isrange
)
{
SFilterRangeNode
*
r
=
ctx
->
rs
;
SFilterRangeNode
*
r
=
ctx
->
rs
;
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
while
(
r
)
{
while
(
r
)
{
char
str
[
256
]
=
{
0
};
char
str
[
256
]
=
{
0
};
if
(
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_NULL
))
{
if
(
FILTER_GET_FLAG
(
r
->
ra
.
sflag
,
RANGE_FLG_NULL
))
{
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
21e62f12
...
@@ -23,12 +23,13 @@ int32_t scalarGetOperatorParamNum(EOperatorType type) {
...
@@ -23,12 +23,13 @@ int32_t scalarGetOperatorParamNum(EOperatorType type) {
int32_t
sclConvertToTsValueNode
(
int8_t
precision
,
SValueNode
*
valueNode
)
{
int32_t
sclConvertToTsValueNode
(
int8_t
precision
,
SValueNode
*
valueNode
)
{
char
*
timeStr
=
valueNode
->
datum
.
p
;
char
*
timeStr
=
valueNode
->
datum
.
p
;
int
32_t
code
=
int
64_t
value
=
0
;
convertStringToTimestamp
(
valueNode
->
node
.
resType
.
type
,
valueNode
->
datum
.
p
,
precision
,
&
valueNode
->
datum
.
i
);
int32_t
code
=
convertStringToTimestamp
(
valueNode
->
node
.
resType
.
type
,
valueNode
->
datum
.
p
,
precision
,
&
value
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
return
code
;
}
}
taosMemoryFree
(
timeStr
);
taosMemoryFree
(
timeStr
);
valueNode
->
datum
.
i
=
value
;
valueNode
->
typeData
=
valueNode
->
datum
.
i
;
valueNode
->
typeData
=
valueNode
->
datum
.
i
;
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
valueNode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
...
@@ -61,7 +62,7 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara
...
@@ -61,7 +62,7 @@ int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarPara
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
sclConvertValueToSclParam
(
SValueNode
*
pValueNode
,
SScalarParam
*
out
,
int32_t
*
overflow
)
{
int32_t
sclConvertValueToSclParam
(
SValueNode
*
pValueNode
,
SScalarParam
*
out
,
int32_t
*
overflow
)
{
SScalarParam
in
=
{.
numOfRows
=
1
};
SScalarParam
in
=
{.
numOfRows
=
1
};
int32_t
code
=
sclCreateColumnInfoData
(
&
pValueNode
->
node
.
resType
,
1
,
&
in
);
int32_t
code
=
sclCreateColumnInfoData
(
&
pValueNode
->
node
.
resType
,
1
,
&
in
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
@@ -78,7 +79,7 @@ int32_t sclConvertValueToSclParam(SValueNode* pValueNode, SScalarParam* out, int
...
@@ -78,7 +79,7 @@ int32_t sclConvertValueToSclParam(SValueNode* pValueNode, SScalarParam* out, int
}
}
int32_t
sclExtendResRows
(
SScalarParam
*
pDst
,
SScalarParam
*
pSrc
,
SArray
*
pBlockList
)
{
int32_t
sclExtendResRows
(
SScalarParam
*
pDst
,
SScalarParam
*
pSrc
,
SArray
*
pBlockList
)
{
SSDataBlock
*
pb
=
taosArrayGetP
(
pBlockList
,
0
);
SSDataBlock
*
pb
=
taosArrayGetP
(
pBlockList
,
0
);
SScalarParam
*
pLeft
=
taosMemoryCalloc
(
1
,
sizeof
(
SScalarParam
));
SScalarParam
*
pLeft
=
taosMemoryCalloc
(
1
,
sizeof
(
SScalarParam
));
if
(
NULL
==
pLeft
)
{
if
(
NULL
==
pLeft
)
{
sclError
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SScalarParam
));
sclError
(
"calloc %d failed"
,
(
int32_t
)
sizeof
(
SScalarParam
));
...
@@ -90,7 +91,7 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL
...
@@ -90,7 +91,7 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL
if
(
pDst
->
numOfRows
<
pb
->
info
.
rows
)
{
if
(
pDst
->
numOfRows
<
pb
->
info
.
rows
)
{
colInfoDataEnsureCapacity
(
pDst
->
columnData
,
pb
->
info
.
rows
,
true
);
colInfoDataEnsureCapacity
(
pDst
->
columnData
,
pb
->
info
.
rows
,
true
);
}
}
_bin_scalar_fn_t
OperatorFn
=
getBinScalarOperatorFn
(
OP_TYPE_ASSIGN
);
_bin_scalar_fn_t
OperatorFn
=
getBinScalarOperatorFn
(
OP_TYPE_ASSIGN
);
OperatorFn
(
pLeft
,
pSrc
,
pDst
,
TSDB_ORDER_ASC
);
OperatorFn
(
pLeft
,
pSrc
,
pDst
,
TSDB_ORDER_ASC
);
...
@@ -566,7 +567,7 @@ _return:
...
@@ -566,7 +567,7 @@ _return:
SCL_RET
(
code
);
SCL_RET
(
code
);
}
}
int32_t
sclGetNodeRes
(
SNode
*
node
,
SScalarCtx
*
ctx
,
SScalarParam
**
res
)
{
int32_t
sclGetNodeRes
(
SNode
*
node
,
SScalarCtx
*
ctx
,
SScalarParam
**
res
)
{
if
(
NULL
==
node
)
{
if
(
NULL
==
node
)
{
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -576,28 +577,31 @@ int32_t sclGetNodeRes(SNode* node, SScalarCtx *ctx, SScalarParam **res) {
...
@@ -576,28 +577,31 @@ int32_t sclGetNodeRes(SNode* node, SScalarCtx *ctx, SScalarParam **res) {
if
(
NULL
==
*
res
)
{
if
(
NULL
==
*
res
)
{
SCL_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
SCL_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
}
SCL_ERR_RET
(
sclInitParam
(
node
,
*
res
,
ctx
,
&
rowNum
));
SCL_ERR_RET
(
sclInitParam
(
node
,
*
res
,
ctx
,
&
rowNum
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
sclWalkCaseWhenList
(
SScalarCtx
*
ctx
,
SNodeList
*
pList
,
struct
SListCell
*
pCell
,
SScalarParam
*
pCase
,
SScalarParam
*
pElse
,
SScalarParam
*
pComp
,
SScalarParam
*
output
,
int32_t
rowIdx
,
int32_t
totalRows
,
bool
*
complete
)
{
int32_t
sclWalkCaseWhenList
(
SScalarCtx
*
ctx
,
SNodeList
*
pList
,
struct
SListCell
*
pCell
,
SScalarParam
*
pCase
,
SNode
*
node
=
NULL
;
SScalarParam
*
pElse
,
SScalarParam
*
pComp
,
SScalarParam
*
output
,
int32_t
rowIdx
,
SWhenThenNode
*
pWhenThen
=
NULL
;
int32_t
totalRows
,
bool
*
complete
)
{
SScalarParam
*
pWhen
=
NULL
;
SNode
*
node
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
SWhenThenNode
*
pWhenThen
=
NULL
;
int32_t
code
=
0
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
int32_t
code
=
0
;
for
(
SListCell
*
cell
=
pCell
;
(
NULL
!=
cell
?
(
node
=
cell
->
pNode
,
true
)
:
(
node
=
NULL
,
false
));
cell
=
cell
->
pNext
)
{
pWhenThen
=
(
SWhenThenNode
*
)
node
;
for
(
SListCell
*
cell
=
pCell
;
(
NULL
!=
cell
?
(
node
=
cell
->
pNode
,
true
)
:
(
node
=
NULL
,
false
));
cell
=
cell
->
pNext
)
{
pWhenThen
=
(
SWhenThenNode
*
)
node
;
SCL_ERR_RET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_RET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_RET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
SCL_ERR_RET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
vectorCompareImpl
(
pCase
,
pWhen
,
pComp
,
rowIdx
,
1
,
TSDB_ORDER_ASC
,
OP_TYPE_EQUAL
);
vectorCompareImpl
(
pCase
,
pWhen
,
pComp
,
rowIdx
,
1
,
TSDB_ORDER_ASC
,
OP_TYPE_EQUAL
);
bool
*
equal
=
(
bool
*
)
colDataGetData
(
pComp
->
columnData
,
rowIdx
);
bool
*
equal
=
(
bool
*
)
colDataGetData
(
pComp
->
columnData
,
rowIdx
);
if
(
*
equal
)
{
if
(
*
equal
)
{
bool
isNull
=
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
));
bool
isNull
=
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
));
char
*
pData
=
isNull
?
NULL
:
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
));
char
*
pData
=
isNull
?
NULL
:
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
));
...
@@ -607,7 +611,7 @@ int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell*
...
@@ -607,7 +611,7 @@ int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell*
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
*
complete
=
true
;
*
complete
=
true
;
}
}
goto
_return
;
goto
_return
;
}
}
}
}
...
@@ -621,7 +625,7 @@ int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell*
...
@@ -621,7 +625,7 @@ int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell*
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
*
complete
=
true
;
*
complete
=
true
;
}
}
goto
_return
;
goto
_return
;
}
}
...
@@ -633,7 +637,7 @@ int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell*
...
@@ -633,7 +637,7 @@ int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell*
}
}
_return:
_return:
sclFreeParam
(
pWhen
);
sclFreeParam
(
pWhen
);
sclFreeParam
(
pThen
);
sclFreeParam
(
pThen
);
taosMemoryFree
(
pWhen
);
taosMemoryFree
(
pWhen
);
...
@@ -642,24 +646,25 @@ _return:
...
@@ -642,24 +646,25 @@ _return:
SCL_RET
(
code
);
SCL_RET
(
code
);
}
}
int32_t
sclWalkWhenList
(
SScalarCtx
*
ctx
,
SNodeList
*
pList
,
struct
SListCell
*
pCell
,
SScalarParam
*
pElse
,
SScalarParam
*
output
,
int32_t
sclWalkWhenList
(
SScalarCtx
*
ctx
,
SNodeList
*
pList
,
struct
SListCell
*
pCell
,
SScalarParam
*
pElse
,
int32_t
rowIdx
,
int32_t
totalRows
,
bool
*
complete
,
bool
preSingle
)
{
SScalarParam
*
output
,
int32_t
rowIdx
,
int32_t
totalRows
,
bool
*
complete
,
bool
preSingle
)
{
SNode
*
node
=
NULL
;
SNode
*
node
=
NULL
;
SWhenThenNode
*
pWhenThen
=
NULL
;
SWhenThenNode
*
pWhenThen
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
int32_t
code
=
0
;
int32_t
code
=
0
;
for
(
SListCell
*
cell
=
pCell
;
(
NULL
!=
cell
?
(
node
=
cell
->
pNode
,
true
)
:
(
node
=
NULL
,
false
));
cell
=
cell
->
pNext
)
{
for
(
SListCell
*
cell
=
pCell
;
(
NULL
!=
cell
?
(
node
=
cell
->
pNode
,
true
)
:
(
node
=
NULL
,
false
));
pWhenThen
=
(
SWhenThenNode
*
)
node
;
cell
=
cell
->
pNext
)
{
pWhenThen
=
(
SWhenThenNode
*
)
node
;
pWhen
=
NULL
;
pWhen
=
NULL
;
pThen
=
NULL
;
pThen
=
NULL
;
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
bool
*
whenValue
=
(
bool
*
)
colDataGetData
(
pWhen
->
columnData
,
(
pWhen
->
numOfRows
>
1
?
rowIdx
:
0
));
bool
*
whenValue
=
(
bool
*
)
colDataGetData
(
pWhen
->
columnData
,
(
pWhen
->
numOfRows
>
1
?
rowIdx
:
0
));
if
(
*
whenValue
)
{
if
(
*
whenValue
)
{
bool
isNull
=
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
));
bool
isNull
=
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
));
char
*
pData
=
isNull
?
NULL
:
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
));
char
*
pData
=
isNull
?
NULL
:
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
rowIdx
:
0
));
...
@@ -669,7 +674,7 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe
...
@@ -669,7 +674,7 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
*
complete
=
true
;
*
complete
=
true
;
}
}
goto
_return
;
goto
_return
;
}
}
...
@@ -688,7 +693,7 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe
...
@@ -688,7 +693,7 @@ int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCe
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
*
complete
=
true
;
*
complete
=
true
;
}
}
goto
_return
;
goto
_return
;
}
}
...
@@ -868,14 +873,14 @@ _return:
...
@@ -868,14 +873,14 @@ _return:
}
}
int32_t
sclExecCaseWhen
(
SCaseWhenNode
*
node
,
SScalarCtx
*
ctx
,
SScalarParam
*
output
)
{
int32_t
sclExecCaseWhen
(
SCaseWhenNode
*
node
,
SScalarCtx
*
ctx
,
SScalarParam
*
output
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
SScalarParam
*
pCase
=
NULL
;
SScalarParam
*
pCase
=
NULL
;
SScalarParam
*
pElse
=
NULL
;
SScalarParam
*
pElse
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pWhen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
SScalarParam
*
pThen
=
NULL
;
SScalarParam
comp
=
{
0
};
SScalarParam
comp
=
{
0
};
int32_t
rowNum
=
1
;
int32_t
rowNum
=
1
;
bool
complete
=
false
;
bool
complete
=
false
;
if
(
NULL
==
node
->
pWhenThenList
||
node
->
pWhenThenList
->
length
<=
0
)
{
if
(
NULL
==
node
->
pWhenThenList
||
node
->
pWhenThenList
->
length
<=
0
)
{
sclError
(
"invalid whenThen list"
);
sclError
(
"invalid whenThen list"
);
...
@@ -883,24 +888,24 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
...
@@ -883,24 +888,24 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
}
}
if
(
ctx
->
pBlockList
)
{
if
(
ctx
->
pBlockList
)
{
SSDataBlock
*
pb
=
taosArrayGetP
(
ctx
->
pBlockList
,
0
);
SSDataBlock
*
pb
=
taosArrayGetP
(
ctx
->
pBlockList
,
0
);
rowNum
=
pb
->
info
.
rows
;
rowNum
=
pb
->
info
.
rows
;
output
->
numOfRows
=
pb
->
info
.
rows
;
output
->
numOfRows
=
pb
->
info
.
rows
;
}
}
SCL_ERR_JRET
(
sclCreateColumnInfoData
(
&
node
->
node
.
resType
,
rowNum
,
output
));
SCL_ERR_JRET
(
sclCreateColumnInfoData
(
&
node
->
node
.
resType
,
rowNum
,
output
));
SCL_ERR_JRET
(
sclGetNodeRes
(
node
->
pCase
,
ctx
,
&
pCase
));
SCL_ERR_JRET
(
sclGetNodeRes
(
node
->
pCase
,
ctx
,
&
pCase
));
SCL_ERR_JRET
(
sclGetNodeRes
(
node
->
pElse
,
ctx
,
&
pElse
));
SCL_ERR_JRET
(
sclGetNodeRes
(
node
->
pElse
,
ctx
,
&
pElse
));
SDataType
compType
=
{
0
};
SDataType
compType
=
{
0
};
compType
.
type
=
TSDB_DATA_TYPE_BOOL
;
compType
.
type
=
TSDB_DATA_TYPE_BOOL
;
compType
.
bytes
=
tDataTypes
[
compType
.
type
].
bytes
;
compType
.
bytes
=
tDataTypes
[
compType
.
type
].
bytes
;
SCL_ERR_JRET
(
sclCreateColumnInfoData
(
&
compType
,
rowNum
,
&
comp
));
SCL_ERR_JRET
(
sclCreateColumnInfoData
(
&
compType
,
rowNum
,
&
comp
));
SNode
*
tnode
=
NULL
;
SNode
*
tnode
=
NULL
;
SWhenThenNode
*
pWhenThen
=
(
SWhenThenNode
*
)
node
->
pWhenThenList
->
pHead
->
pNode
;
SWhenThenNode
*
pWhenThen
=
(
SWhenThenNode
*
)
node
->
pWhenThenList
->
pHead
->
pNode
;
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pWhen
,
ctx
,
&
pWhen
));
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
SCL_ERR_JRET
(
sclGetNodeRes
(
pWhenThen
->
pThen
,
ctx
,
&
pThen
));
...
@@ -911,17 +916,19 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
...
@@ -911,17 +916,19 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
if
(
pCase
)
{
if
(
pCase
)
{
vectorCompare
(
pCase
,
pWhen
,
&
comp
,
TSDB_ORDER_ASC
,
OP_TYPE_EQUAL
);
vectorCompare
(
pCase
,
pWhen
,
&
comp
,
TSDB_ORDER_ASC
,
OP_TYPE_EQUAL
);
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
bool
*
equal
=
(
bool
*
)
colDataGetData
(
comp
.
columnData
,
(
comp
.
numOfRows
>
1
?
i
:
0
));
bool
*
equal
=
(
bool
*
)
colDataGetData
(
comp
.
columnData
,
(
comp
.
numOfRows
>
1
?
i
:
0
));
if
(
*
equal
)
{
if
(
*
equal
)
{
colDataAppend
(
output
->
columnData
,
i
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)));
colDataAppend
(
output
->
columnData
,
i
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)));
if
(
0
==
i
&&
1
==
pCase
->
numOfRows
&&
1
==
pWhen
->
numOfRows
&&
1
==
pThen
->
numOfRows
&&
rowNum
>
1
)
{
if
(
0
==
i
&&
1
==
pCase
->
numOfRows
&&
1
==
pWhen
->
numOfRows
&&
1
==
pThen
->
numOfRows
&&
rowNum
>
1
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
break
;
break
;
}
}
}
else
{
}
else
{
SCL_ERR_JRET
(
sclWalkCaseWhenList
(
ctx
,
node
->
pWhenThenList
,
node
->
pWhenThenList
->
pHead
->
pNext
,
pCase
,
pElse
,
&
comp
,
output
,
i
,
rowNum
,
&
complete
));
SCL_ERR_JRET
(
sclWalkCaseWhenList
(
ctx
,
node
->
pWhenThenList
,
node
->
pWhenThenList
->
pHead
->
pNext
,
pCase
,
pElse
,
&
comp
,
output
,
i
,
rowNum
,
&
complete
));
if
(
complete
)
{
if
(
complete
)
{
break
;
break
;
}
}
...
@@ -929,15 +936,17 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
...
@@ -929,15 +936,17 @@ int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *outp
}
}
}
else
{
}
else
{
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
bool
*
whenValue
=
(
bool
*
)
colDataGetData
(
pWhen
->
columnData
,
(
pWhen
->
numOfRows
>
1
?
i
:
0
));
bool
*
whenValue
=
(
bool
*
)
colDataGetData
(
pWhen
->
columnData
,
(
pWhen
->
numOfRows
>
1
?
i
:
0
));
if
(
*
whenValue
)
{
if
(
*
whenValue
)
{
colDataAppend
(
output
->
columnData
,
i
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)));
colDataAppend
(
output
->
columnData
,
i
,
colDataGetData
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)),
colDataIsNull_s
(
pThen
->
columnData
,
(
pThen
->
numOfRows
>
1
?
i
:
0
)));
if
(
0
==
i
&&
1
==
pWhen
->
numOfRows
&&
1
==
pThen
->
numOfRows
&&
rowNum
>
1
)
{
if
(
0
==
i
&&
1
==
pWhen
->
numOfRows
&&
1
==
pThen
->
numOfRows
&&
rowNum
>
1
)
{
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
SCL_ERR_JRET
(
sclExtendResRows
(
output
,
output
,
ctx
->
pBlockList
));
break
;
break
;
}
}
}
else
{
}
else
{
SCL_ERR_JRET
(
sclWalkWhenList
(
ctx
,
node
->
pWhenThenList
,
node
->
pWhenThenList
->
pHead
->
pNext
,
pElse
,
output
,
i
,
rowNum
,
&
complete
,
(
pWhen
->
numOfRows
==
1
&&
pThen
->
numOfRows
==
1
)));
SCL_ERR_JRET
(
sclWalkWhenList
(
ctx
,
node
->
pWhenThenList
,
node
->
pWhenThenList
->
pHead
->
pNext
,
pElse
,
output
,
i
,
rowNum
,
&
complete
,
(
pWhen
->
numOfRows
==
1
&&
pThen
->
numOfRows
==
1
)));
if
(
complete
)
{
if
(
complete
)
{
break
;
break
;
}
}
...
@@ -973,7 +982,6 @@ _return:
...
@@ -973,7 +982,6 @@ _return:
SCL_RET
(
code
);
SCL_RET
(
code
);
}
}
EDealRes
sclRewriteNullInOptr
(
SNode
**
pNode
,
SScalarCtx
*
ctx
,
EOperatorType
opType
)
{
EDealRes
sclRewriteNullInOptr
(
SNode
**
pNode
,
SScalarCtx
*
ctx
,
EOperatorType
opType
)
{
if
(
opType
<=
OP_TYPE_CALC_MAX
)
{
if
(
opType
<=
OP_TYPE_CALC_MAX
)
{
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
...
@@ -1097,8 +1105,7 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
...
@@ -1097,8 +1105,7 @@ EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) {
EDealRes
sclRewriteFunction
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
EDealRes
sclRewriteFunction
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SFunctionNode
*
node
=
(
SFunctionNode
*
)
*
pNode
;
SFunctionNode
*
node
=
(
SFunctionNode
*
)
*
pNode
;
SNode
*
tnode
=
NULL
;
SNode
*
tnode
=
NULL
;
if
((
!
fmIsScalarFunc
(
node
->
funcId
)
&&
(
!
ctx
->
dual
))
||
if
((
!
fmIsScalarFunc
(
node
->
funcId
)
&&
(
!
ctx
->
dual
))
||
fmIsUserDefinedFunc
(
node
->
funcId
))
{
fmIsUserDefinedFunc
(
node
->
funcId
))
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
...
@@ -1237,20 +1244,20 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
...
@@ -1237,20 +1244,20 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
EDealRes
sclRewriteCaseWhen
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
EDealRes
sclRewriteCaseWhen
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SCaseWhenNode
*
node
=
(
SCaseWhenNode
*
)
*
pNode
;
SCaseWhenNode
*
node
=
(
SCaseWhenNode
*
)
*
pNode
;
if
((
!
SCL_IS_CONST_NODE
(
node
->
pCase
))
||
(
!
SCL_IS_CONST_NODE
(
node
->
pElse
)))
{
if
((
!
SCL_IS_CONST_NODE
(
node
->
pCase
))
||
(
!
SCL_IS_CONST_NODE
(
node
->
pElse
)))
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
SNode
*
tnode
=
NULL
;
SNode
*
tnode
=
NULL
;
FOREACH
(
tnode
,
node
->
pWhenThenList
)
{
FOREACH
(
tnode
,
node
->
pWhenThenList
)
{
SWhenThenNode
*
pWhenThen
=
(
SWhenThenNode
*
)
tnode
;
SWhenThenNode
*
pWhenThen
=
(
SWhenThenNode
*
)
tnode
;
if
(
!
SCL_IS_CONST_NODE
(
pWhenThen
->
pWhen
)
||
!
SCL_IS_CONST_NODE
(
pWhenThen
->
pThen
))
{
if
(
!
SCL_IS_CONST_NODE
(
pWhenThen
->
pWhen
)
||
!
SCL_IS_CONST_NODE
(
pWhenThen
->
pThen
))
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
}
}
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
ctx
->
code
=
sclExecCaseWhen
(
node
,
ctx
,
&
output
);
ctx
->
code
=
sclExecCaseWhen
(
node
,
ctx
,
&
output
);
...
@@ -1283,13 +1290,12 @@ EDealRes sclRewriteCaseWhen(SNode** pNode, SScalarCtx *ctx) {
...
@@ -1283,13 +1290,12 @@ EDealRes sclRewriteCaseWhen(SNode** pNode, SScalarCtx *ctx) {
}
}
nodesDestroyNode
(
*
pNode
);
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
*
pNode
=
(
SNode
*
)
res
;
sclFreeParam
(
&
output
);
sclFreeParam
(
&
output
);
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
EDealRes
sclConstantsRewriter
(
SNode
**
pNode
,
void
*
pContext
)
{
EDealRes
sclConstantsRewriter
(
SNode
**
pNode
,
void
*
pContext
)
{
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
...
@@ -1416,9 +1422,9 @@ EDealRes sclWalkTarget(SNode *pNode, SScalarCtx *ctx) {
...
@@ -1416,9 +1422,9 @@ EDealRes sclWalkTarget(SNode *pNode, SScalarCtx *ctx) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
EDealRes
sclWalkCaseWhen
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
EDealRes
sclWalkCaseWhen
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
SCaseWhenNode
*
node
=
(
SCaseWhenNode
*
)
pNode
;
SCaseWhenNode
*
node
=
(
SCaseWhenNode
*
)
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
ctx
->
code
=
sclExecCaseWhen
(
node
,
ctx
,
&
output
);
ctx
->
code
=
sclExecCaseWhen
(
node
,
ctx
,
&
output
);
if
(
ctx
->
code
)
{
if
(
ctx
->
code
)
{
...
@@ -1433,11 +1439,10 @@ EDealRes sclWalkCaseWhen(SNode* pNode, SScalarCtx *ctx) {
...
@@ -1433,11 +1439,10 @@ EDealRes sclWalkCaseWhen(SNode* pNode, SScalarCtx *ctx) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
EDealRes
sclCalcWalker
(
SNode
*
pNode
,
void
*
pContext
)
{
EDealRes
sclCalcWalker
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
||
||
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
||
QUERY_NODE_LEFT_VALUE
==
nodeType
(
pNode
)
QUERY_NODE_COLUMN
==
nodeType
(
pNode
)
||
QUERY_NODE_LEFT_VALUE
==
nodeType
(
pNode
)
||
||
QUERY_NODE_WHEN_THEN
==
nodeType
(
pNode
))
{
QUERY_NODE_WHEN_THEN
==
nodeType
(
pNode
))
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
...
...
tests/script/tsim/stream/basic1.sim
浏览文件 @
21e62f12
...
@@ -751,5 +751,40 @@ if $rows != 0 then
...
@@ -751,5 +751,40 @@ if $rows != 0 then
endi
endi
sql insert into t1 values(1648791223000,2,2,3,1.0);
sql insert into t1 values(1648791223000,10,2,3,1.0);
sql insert into t1 values(1648791233000,10,2,3,1.0);
$loop_count = 0
loop16:
sleep 200
sql select * from streamt4;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $rows != 2 then
print =====rows=$rows
goto loop16
endi
sql insert into t1 values(1648791233000,2,2,3,1.0);
$loop_count = 0
loop17:
sleep 200
sql select * from streamt4;
$loop_count = $loop_count + 1
if $loop_count == 10 then
return -1
endi
if $rows != 1 then
print =====rows=$rows
goto loop17
endi
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s stop -x SIGINT
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录