diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6f98693addd5cba9a40f6ab9335054951a78b2ee..0000000000000000000000000000000000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference -version: 2.1 -# Use a package of configuration called an orb. -orbs: - # Declare a dependency on the welcome-orb - welcome: circleci/welcome-orb@0.4.1 -# Orchestrate or schedule a set of jobs -workflows: - # Name the workflow "welcome" - welcome: - # Run the welcome/run job in its own container - jobs: - - welcome/run diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index f4ab3c92519ed218820e07c7fa8ed645f93d94d4..0000000000000000000000000000000000000000 --- a/.drone.yml +++ /dev/null @@ -1,264 +0,0 @@ ---- -kind: pipeline -name: test_arm64_bionic - -platform: - os: linux - arch: arm64 -steps: -- name: build - image: arm64v8/ubuntu:bionic - commands: - - apt-get update - - apt-get install -y cmake git build-essential wget - - wget https://dl.google.com/go/go1.16.9.linux-arm64.tar.gz - - tar -C /usr/local -xzf go1.16.9.linux-arm64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake .. -DCPUTYPE=aarch64 > /dev/null - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 ---- -kind: pipeline -name: test_arm64_focal - -platform: - os: linux - arch: arm64 - -steps: -- name: build - image: arm64v8/ubuntu:focal - commands: - - echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections - - apt-get update - - apt-get install -y -qq git cmake build-essential wget - - wget https://dl.google.com/go/go1.16.9.linux-arm64.tar.gz - - tar -C /usr/local -xzf go1.16.9.linux-arm64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake .. -DCPUTYPE=aarch64 > /dev/null - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 ---- -kind: pipeline -name: test_arm64_centos7 - -platform: - os: linux - arch: arm64 - -steps: -- name: build - image: arm64v8/centos:7 - commands: - - yum install -y epel-release - - yum install -y gcc gcc-c++ make cmake3 wget git - - wget https://dl.google.com/go/go1.16.9.linux-arm64.tar.gz - - tar -C /usr/local -xzf go1.16.9.linux-arm64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - ln -s /usr/bin/cmake3 /usr/bin/cmake - - go version - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake3 .. -DCPUTYPE=aarch64 > /dev/null - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 ---- -kind: pipeline -name: test_arm64_centos8 - -platform: - os: linux - arch: arm64 - -steps: -- name: build - image: arm64v8/centos:8 - commands: - - dnf install -y gcc gcc-c++ make cmake epel-release git libarchive golang - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake .. -DCPUTYPE=aarch64 > /dev/null - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 ---- -kind: pipeline -name: test_arm_bionic - -platform: - os: linux - arch: arm - -steps: -- name: build - image: arm32v7/ubuntu:bionic - commands: - - apt-get update - - apt-get install -y cmake build-essential golang-go git - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake .. -DCPUTYPE=aarch32 > /dev/null - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 ---- -kind: pipeline -name: build_trusty - -platform: - os: linux - arch: amd64 - -steps: -- name: build - image: ubuntu:trusty - commands: - - apt-get update - - apt-get install -y gcc cmake3 build-essential git binutils-2.26 wget - - wget https://dl.google.com/go/go1.16.9.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.16.9.linux-amd64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake .. - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 ---- -kind: pipeline -name: build_xenial - -platform: - os: linux - arch: amd64 - -steps: -- name: build - image: ubuntu:xenial - commands: - - apt-get update - - apt-get install -y gcc cmake build-essential git wget - - wget https://dl.google.com/go/go1.16.9.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.16.9.linux-amd64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake .. - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 ---- -kind: pipeline -name: build_bionic -platform: - os: linux - arch: amd64 - -steps: -- name: build - image: ubuntu:bionic - commands: - - apt-get update - - apt-get install -y gcc cmake build-essential git wget - - wget https://dl.google.com/go/go1.16.9.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.16.9.linux-amd64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake .. - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 ---- -kind: pipeline -name: build_centos7 -platform: - os: linux - arch: amd64 - -steps: -- name: build - image: ansible/centos7-ansible - commands: - - yum install -y epel-release - - yum install -y gcc gcc-c++ make cmake3 wget git - - wget https://dl.google.com/go/go1.16.9.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.16.9.linux-amd64.tar.gz - - export PATH=$PATH:/usr/local/go/bin - - ln -s /usr/bin/cmake3 /usr/bin/cmake - - git submodule update --init --recursive - - mkdir debug - - cd debug - - cmake3 .. - - make -j4 - trigger: - event: - - pull_request - when: - branch: - - develop - - master - - 2.0 \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 9c09b908ad94723e60c3945681c4068e786481d7..7a63174d3f6ae59abd733dce60189b462b8c76f8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -20,3 +20,9 @@ [submodule "examples/rust"] path = examples/rust url = https://github.com/songtianyi/tdengine-rust-bindings.git +[submodule "src/connector/php-tdengine"] + path = src/connector/php-tdengine + url = https://github.com/Yurunsoft/php-tdengine.git +[submodule "src/connector/php-tdengine-restful-connector"] + path = src/connector/php-tdengine-restful-connector + url = https://github.com/Yurunsoft/tdengine-restful-connector.git diff --git a/Jenkinsfile b/Jenkinsfile index 15640f81393f5544cf16d75fa72da062dbbda8b0..0f0a09f2be366eab9488e281f7d65ce9d7592e24 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -116,7 +116,7 @@ def pre_test(){ make > /dev/null make install > /dev/null cd ${WKC}/tests - pip3 install ${WKC}/src/connector/python/ + pip3 install taospy ''' return 1 } diff --git a/Jenkinsfile2 b/Jenkinsfile2 index d93ed9df5b70ce791c444005316bc279ef82666f..8cffa8e06d0643f0a0654ea99f6d89fa6994ee5b 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -21,21 +21,25 @@ def sync_source() { if (env.CHANGE_TARGET == 'master') { sh ''' cd ${WKC} + git clean -fxd git checkout master ''' } else if (env.CHANGE_TARGET == '2.0') { sh ''' cd ${WKC} + git clean -fxd git checkout 2.0 ''' } else if (env.CHANGE_TARGET == '2.4') { sh ''' cd ${WKC} + git clean -fxd git checkout 2.4 ''' } else { sh ''' cd ${WKC} + git clean -fxd git checkout develop ''' } @@ -83,6 +87,16 @@ def sync_source() { cd ${WKC} git fetch origin +refs/pull/${CHANGE_ID}/merge git checkout -qf FETCH_HEAD + + if [ ! -d src/connector/python/.github ]; then + rm -rf src/connector/python/* || : + rm -rf src/connector/python/.* || : + git clone --depth 1 https://github.com/taosdata/taos-connector-python src/connector/python || echo "failed to clone python connector" + else + cd src/connector/python || echo "src/connector/python not exist" + git pull || : + cd ${WKC} + fi ''' } else if (env.CHANGE_URL =~ /\/TDinternal\//) { sh ''' @@ -90,6 +104,16 @@ def sync_source() { cd ${WK} git fetch origin +refs/pull/${CHANGE_ID}/merge git checkout -qf FETCH_HEAD + + if [ ! -d community/src/connector/python/.github ]; then + rm -rf community/src/connector/python/* || : + rm -rf community/src/connector/python/.* || : + git clone --depth 1 https://github.com/taosdata/taos-connector-python community/src/connector/python || echo "failed to clone python connector" + else + cd community/src/connector/python || echo "community/src/connector/python not exist" + git pull || : + cd ${WK} + fi ''' } else { sh ''' @@ -251,20 +275,6 @@ pipeline { } } parallel { - stage ('build worker08_arm32') { - agent {label " worker08_arm32"} - steps { - timeout(time: 20, unit: 'MINUTES') { - pre_test() - script { - sh ''' - echo "worker08_arm32 build done" - date - ''' - } - } - } - } stage ('build worker07_arm64') { agent {label " worker07_arm64 "} steps { diff --git a/cmake/define.inc b/cmake/define.inc index a15a0725ebcc04683cee3559e69cf667a060fc7d..9e3d4a0dfa05d1bdbc783da68d470c3a57f57d7b 100755 --- a/cmake/define.inc +++ b/cmake/define.inc @@ -287,9 +287,17 @@ IF (TD_LINUX) SET(COMMON_FLAGS "${COMMON_FLAGS} -pipe -Wshadow") ENDIF () +MESSAGE(STATUS "CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID}) +IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string ) + string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) + IF (CLANG_VERSION_STRING GREATER_EQUAL 13.0) + SET(COMMON_FLAGS "${COMMON_FLAGS} -Wno-unused-but-set-variable") + ENDIF () +ENDIF () + INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/os/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/util/inc) INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/common/inc) -MESSAGE(STATUS "CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID}) diff --git a/cmake/input.inc b/cmake/input.inc index 9d411e382b4a9b07de238cc1caaa246dcbda57bc..6eb7e44e0af007240c803dd5cf50c69de47f4fc8 100755 --- a/cmake/input.inc +++ b/cmake/input.inc @@ -53,11 +53,6 @@ IF (${MEM_CHECK} MATCHES "true") MESSAGE(STATUS "build with memory check") ENDIF () -IF (${MQTT} MATCHES "false") - SET(TD_MQTT FALSE) - MESSAGE(STATUS "build without mqtt module") -ENDIF () - IF (${RANDOM_FILE_FAIL} MATCHES "true") SET(TD_RANDOM_FILE_FAIL TRUE) MESSAGE(STATUS "build with random-file-fail enabled") @@ -104,4 +99,4 @@ ELSE() MESSAGE(STATUS "build with TSZ enabled") ADD_DEFINITIONS(-DTD_TSZ) set(VAR_TSZ "TSZ" CACHE INTERNAL "global variant tsz" ) -ENDIF() \ No newline at end of file +ENDIF() diff --git a/cmake/install.inc b/cmake/install.inc index 8124929746f42462fd29865814cc2d661a3019f9..6da298ef3e039fc1274acc4e43d7c7ae63356876 100755 --- a/cmake/install.inc +++ b/cmake/install.inc @@ -20,7 +20,7 @@ ELSEIF (TD_WINDOWS) INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .) IF (TD_MVN_INSTALLED) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.37-dist.jar DESTINATION connector/jdbc) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.38-dist.jar DESTINATION connector/jdbc) ENDIF () ELSEIF (TD_DARWIN) SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") diff --git a/docs-cn/01-intro/01-intro.md b/docs-cn/01-intro/01-intro.md index d6b0968e47dd71bdfa648072b198641d74caa8b3..f1e70a1af72ff0c61cd5007cdd62205e369ffc58 100644 --- a/docs-cn/01-intro/01-intro.md +++ b/docs-cn/01-intro/01-intro.md @@ -1,10 +1,9 @@ --- sidebar_label: 产品简介 +title: 产品简介 toc_max_heading_level: 2 --- -# 产品简介 - ## TDengine 简介 TDengine 是一款高性能、分布式、支持 SQL 的时序数据库。而且除时序数据库功能外,它还提供缓存、数据订阅、流式计算等功能,最大程度减少研发和运维的复杂度,且核心代码,包括集群功能全部开源(开源协议,AGPL v3.0)。与其他时序数据数据库相比,TDengine 有以下特点: @@ -25,15 +24,16 @@ TDengine 是一款高性能、分布式、支持 SQL 的时序数据库。而且 - **互动 Console**: 通过命令行 console,不用编程,执行 SQL 语句就能做即席查询、各种数据库的操作、管理以及集群的维护. -采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。但需要指出的是,因充分利用了物联网时序数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。 +采用 TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。表现在几个方面,1:由于其超强性能,它能将系统需要的计算资源和存储资源大幅降低;2:因为采用SQL接口,能与众多第三放软件无缝集成,学习迁移成本大幅下降;3:因为其All In One的特性,系统复杂度降低,能降研发成本;4:因为运维维护简单,运营维护成本能大幅降低。 +在整个时序大数据平台中,TDengine在其中扮演的角色如下: ![TDengine技术生态图](eco_system.png)
图 1. TDengine技术生态图
## TDengine 总体适用场景 -作为一个 IoT 大数据平台,TDengine 的典型适用场景是在 IoT 范畴,而且用户有一定的数据量。本文后续的介绍主要针对这个范畴里面的系统。范畴之外的系统,比如 CRM,ERP 等,不在本文讨论范围内。 +作为一个高性能、分布式、支持 SQL 的时序数据库,TDengine 的典型适用场景包括但不限于 IoT、工业互联网、车联网、IT运维、能源、金融证券等领域。需要指出的是,TDengine是针对时序数据场景设计的专用数据库和专用大数据处理工具,因充分利用了时序大数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM 等通用型数据。本文对适用场景做更多详细的分析。 ### 数据源特点和需求 diff --git a/docs-cn/02-concept/02-concept.md b/docs-cn/02-concept/02-concept.md index ccaa1b51e0410c2a2e02513f5ce6e4a2c6e00325..b1638e838d9b2da35018b4d24640b98d5e476e47 100644 --- a/docs-cn/02-concept/02-concept.md +++ b/docs-cn/02-concept/02-concept.md @@ -1,24 +1,111 @@ -# 基本概念 +--- +title: 数据模型和基本概念 +--- ## 物联网典型场景 -在典型的物联网、车联网、运维监测场景中,往往有多种不同类型的数据采集设备,采集一个到多个不同的物理量。而同一种采集设备类型,往往又有多个具体的采集设备分布在不同的地点。大数据处理系统就是要将各种采集的数据汇总,然后进行计算和分析。对于同一类设备,其采集的数据类似如下的表格: - -| Device ID | Time Stamp | Value 1 | Value 2 | Value 3 | Tag 1 | Tag 2 | -| :-------: | :-----------: | :-----: | :-----: | :-----: | :---: | :---: | -| D1001 | 1538548685000 | 10.3 | 219 | 0.31 | Red | Tesla | -| D1002 | 1538548684000 | 10.2 | 220 | 0.23 | Blue | BMW | -| D1003 | 1538548686500 | 11.5 | 221 | 0.35 | Black | Honda | -| D1004 | 1538548685500 | 13.4 | 223 | 0.29 | Red | Volvo | -| D1001 | 1538548695000 | 12.6 | 218 | 0.33 | Red | Tesla | -| D1004 | 1538548696600 | 11.8 | 221 | 0.28 | Black | Honda | - - -每一条记录都有设备 ID,时间戳,采集的物理量,还有与每个设备相关的静态标签。每个设备是受外界的触发,或按照设定的周期采集数据。采集的数据点是时序的,是一个数据流。 - -**数据特征** - -除时序特征外,仔细研究发现,物联网、车联网、运维监测类数据还具有很多其他明显的特征。 +在典型的物联网、车联网、运维监测场景中,往往有多种不同类型的数据采集设备或采集点,采集一个到多个不同的物理量。而同一种采集设备类型,往往又有多个具体的采集设备分布在不同的地点。采集的物理量都带有时间标签,而且数据量随时间不断增长,但每个数据采集设备或采集点还有自身的静态属性。对于同一类设备,其采集的数据以及静态属性都是很规则的。以智能电表为例,假设每个智能电表采集电流、电压、相位三个量,其采集的数据类似如下的表格: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
设备ID时间戳采集量标签
Device IDTime StampcurrentvoltagephaselocationgroupId
d1001153854868500010.32190.31Beijing.Chaoyang2
d1002153854868400010.22200.23Beijing.Chaoyang3
d1003153854868650011.52210.35Beijing.Haidian3
d1004153854868550013.42230.29Beijing.Haidian2
d1001153854869500012.62180.33Beijing.Chaoyang2
d1004153854869660011.82210.28Beijing.Haidian2
d1002153854869665010.32180.25Beijing.Chaoyang3
d1001153854869680012.32210.31Beijing.Chaoyang2
+ +
表 1:智能电表数据示例
+ +每一条记录都有设备 ID,时间戳,采集的物理量(如上图中的电流、电压、相位),还有与每个设备相关的静态标签(如上述表 1 中的位置 location 和分组 groupId)。每个设备是受外界的触发,或按照设定的周期采集数据。采集的数据点是时序的,是一个数据流。 + +## 数据特征 + +除时序特征外,仔细研究发现,物联网、车联网、运维监测类数据及其应用还具有很多其他明显的特征。 1. 数据是结构化的; 2. 数据极少有更新或删除操作; @@ -28,41 +115,62 @@ 6. 用户关注的是一段时间的趋势,而不是某一特点时间点的值; 7. 数据是有保留期限的; 8. 数据的查询分析一定是基于时间段和地理区域的; -9. 除存储查询外,还往往需要各种统计和实时计算操作; +9. 系统需要各种实时计算和统计操作,包括降采样、插值等特种操作; 10. 数据量巨大,一天采集的数据就可以超过 100 亿条。 充分利用上述特征,TDengine 采取了一特殊的优化的存储和计算设计来处理时序数据,能将系统处理能力显著提高。 -## 数据采集点 +## 采集量(Metric) + +采集量是指传感器、设备或其他类型采集点采集的物理量,比如电流、电压、温度、压力、GPS位置等,是随时间变化的,数据类型可以是整型、浮点型、布尔型,也可是字符串。随着时间的推移,存储的采集量的数据量越来越大。 + +## 标签(Label/Tag) + +标签是指传感器、设备或其他类型采集点的静态属性,不是随时间变化的,比如设备型号、颜色、设备的所在地等,数据类型可以是任何类型。虽然是静态的,但TDengine容许用户修改、删除或增加标签值。与采集量不一样的是,随时间的推移,存储的标签的数据量不会有什么变化。 + +## 数据采集点(Data Colletion Point) + +数据采集点是指按照预设时间周期或受事件触发采集物理量的硬件或软件。一个数据采集点可以采集一个或多个物理量,**但这些物理量都是同一时刻采集的,具有相同的时间戳**。对于复杂的设备,往往有多个数据采集点,每个采集点采集的周期都可能不一样,而且完全独立,不同步。比如对于一台汽车,有数据采集点专门采集GPS位置,有数据采集点专门采集发动机状态,有数据采集点专门采集车内的环境,这样一台汽车就有三个数据采集点。 + +## 关系型数据库模型 + +因为采集的数据一般是结构化数据,同时为降低学习门槛,TDengine 采用传统的关系型数据库模型管理数据。用户需要先创建库,然后创建表,之后才能插入或查询数据。TDengine 采用的是结构化存储,而不是 NoSQL 的 key-value 存储。 + +与通用数据库相比,TDengine通过一个数据采集点一张表,来大幅提高单个数据采集点的插入和查询速度。同时TDengine引入了超级表的概念,让每个表都带有标签,解决多个数据采集点之间的聚合分析问题。 -持续按照预设频率生成数据的软件或硬件设备称为数据采集点。TDengine中推荐一个数据采集点生成的数据存储在对应的一个或若干个表中。采集点产生的数据通常是包括时间戳、测量值、标签等必要信息构成的元组。 +## 一个数据采集点一张表 -## 采集量 +为充分利用其数据的时序性和其他数据特点,TDengine 要求**对每个数据采集点单独建表**(比如有一千万个智能电表,就需创建一千万张表,上述表格中的 d1001,d1002,d1003,d1004 都需单独建表),用来存储这个采集点所采集的时序数据。这种设计有几大优点: -数据采集点生成的具有时间、测量值、标签的元组信息。除了时间戳、标签信息以外的测量值称为采集量。 +1. 由于不同采集设备产生数据的过程完全独立,每个设备的数据源是唯一的,一张表也就只有一个写入者,这样就可采用无锁方式来写,写入速度就能大幅提升。 +2. 对于一个数据采集点而言,其产生的数据是按照时间排序的,因此写的操作可用追加的方式实现,进一步大幅提高数据写入速度。 +3. 一个数据采集点的数据是以块为单位连续存储的。如果读取一个时间段的数据,它能大幅减少随机读取操作,成数量级的提升读取和查询速度。 +4. 一个数据块内部,采用列式存储,对于不同数据类型,采用不同压缩算法,而且由于一个数据采集点的采集量的变化是缓慢的,压缩率更高。 -## 标签 +如果采用传统的方式,将多个设备的数据写入一张表,由于网络延时不可控,不同设备的数据到达服务器的时序是无法保证的,写入操作是要有锁保护的,而且一个设备的数据是难以保证连续存储在一起的。**采用一个数据采集点一张表的方式,能最大程度的保证单个数据采集点的插入和查询的性能是最优的。** -表的结构化描述信息,以一维数组形式存在。标签模式需要在创建超级表的时候指定,后续可动态调整。只有基于超级表创建的子表才具有标签。标签信息的内容首次创建子表的时候指定,并可按需调整。可以看到,TDengine中标签信息是表级别,而不是记录级别。 +TDengine 建议用数据采集点的名字(如上表中的 D1001)来做表名。每个数据采集点可能同时采集多个物理量(如上表中的 curent,voltage,phase),每个物理量对应一张表中的一列,数据类型可以是整型、浮点型、字符串等。除此之外,表的第一列必须是时间戳,即数据类型为 timestamp。对采集的数据,TDengine 将自动按照时间戳建立索引,但对采集的物理量不建任何索引。数据用列式存储方式保存。 -## 数据库 +对于复杂的设备,比如汽车,它有多个数据采集点,那么就需要为一台汽车建立多张表。 - TDengine中数据库与普通数据库管理系统中的数据库语义和行为相同,但是结合应用需求增加了若干配置参数用以控制其行为。 +## 超级表:同一类型数据采集点的集合 -## 超级表 +由于一个数据采集点一张表,导致表的数量巨增,难以管理,而且应用经常需要做采集点之间的聚合操作,聚合的操作也变得复杂起来。为解决这个问题,TDengine 引入超级表(Super Table,简称为 STable)的概念。 -超级表(Super Table, STable)是TDengine中一个重要的概念。超级表是面向相同数据模式的数据表,提供(数据+标签)模式管理和查询处理的逻辑抽象。通常将基于超级表创建的表称为该超级表的子表,并在系统内部建立逻辑关联。超级表与(基于其创建的)子表的关系体现在以下几个方面: +超级表是指某一特定类型的数据采集点的集合。同一类型的数据采集点,其表的结构是完全一样的,但每个表(数据采集点)的静态属性(标签)是不一样的。描述一个超级表(某一特定类型的数据采集点的集合),除需要定义采集量的表结构之外,还需要定义其标签的 schema,标签的数据类型可以是整数、浮点数、字符串,标签可以有多个,可以事后增加、删除或修改。如果整个系统有 N 个不同类型的数据采集点,就需要建立 N 个超级表。 -超级表的子表共享其数据模式和标签模式。因此,不能通过子表调整数据或标签的模式。对于超级表的数据模式修改立即对所有的子表生效。 +在 TDengine 的设计里,**表用来代表一个具体的数据采集点,超级表用来代表一组相同类型的数据采集点集合**。当为某个具体数据采集点创建表时,用户使用超级表的定义做模板,同时指定该具体采集点(表)的标签值。与传统的关系型数据库相比,表(一个数据采集点)是带有静态标签的,而且这些标签可以事后增加、删除、修改。超级表与与基于超级表建立的子表之间的关系表现在: -超级表自身不能存储任何数据或标签信息。因此,不能向一个超级表写入数据,只能将数据写入子表中。 +1. 一张超级表包含有多张子表,这些子表具有相同的采集量 schema,但带有不同的标签值。 +2. 不能通过子表调整数据或标签的模式,对于超级表的数据模式修改立即对所有的子表生效。 +3. 超级表只定义一个模板,自身不存储任何数据或标签信息。因此,不能向一个超级表写入数据,只能将数据写入子表中。 -针对超级表的查询,将所有子表中的数据视为一个整体数据集进行处理。但是可以直接发起针对某个或若干个子表的查询,此时查询请求将该子表视为一个普通的表进行处理。 +针对超级表的查询,TDengine将把所有子表中的数据视为一个整体数据集进行处理,会先把满足标签过滤条件的表从超级表中找出来,然后再扫描这些表的时序数据,进行聚合操作,这样需要扫描的数据集会大幅减少,从而显著提高查询的性能。本质上,TDengine通过对超级表查询的支持,实现了多个同类数据采集点的高效聚合。 -## 表 +## FQDN & End Point -一系列二维数组的集合,用来代表和储存数据对象之间的关系,由纵向的列和横向的行组成。TDengine中的表与普通数据库中的表没有差别。 +FQDN (fully qualified domain name, 完全限定域名)是 Internet 上特定计算机或主机的完整域名。FQDN由两部分组成:主机名和域名。例如,假设邮件服务器的FQDN可能是mail.tdengine.com。主机名是mail,主机位于域名tdengine.com中。DNS(Domain Name System),负责将FQDN翻译成IP,是互联网应用的寻址方式。对于没有DNS的系统,可以通过配置hosts文件来解决。 -但是,对于通过超级表创建的子表,还具有额外的标签数据信息。不能针对某个子表调整数据模式。每个子表具有与其关联的标签数据,并可按需调整内容。但是模式调整必须要通过超级表模式调整来完成。 +TDengine集群的每个节点是由End Point来唯一标识的,End Point是由 FQDN 外加 Port 组成,比如 h1.tdengine.com:6030。这样当IP发生变化的时候,我们依然可以使用 FQDN 来动态找到节点,不需要更改集群的任何配置。而且采用 FQDN,便于内网和外网对同一个集群的统一访问。 -使用TDengine存储和管理物联网数据的时候,推荐使用一个子表存储一个数据采集点生成的数据,而使用超级表用来代表一组相同类型的数据采集点的集合。 +TDengine 不建议采用直接的IP地址访问集群,不利于管理。不了解 FQDN 概念,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 diff --git a/docs-cn/03-get-started/03-get-started.md b/docs-cn/03-get-started/03-get-started.md index a5b872d0ec7f8dedb34aa09ec4442aaf15dbf030..6776455c9dc3ab68d291488b7b3b0353967f0ac1 100644 --- a/docs-cn/03-get-started/03-get-started.md +++ b/docs-cn/03-get-started/03-get-started.md @@ -1,7 +1,21 @@ -# 立即开始 +--- +title: 立即开始 +description: "从 Docker,安装包或使用 apt-get 快速安装 TDengine, 通过命令行程序TAOS CLI和工具 taosdemo 快速体验 TDengine 功能" +--- -## 从 Docker 快速开始 +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import PkgInstall from "./\_pkg_install.mdx"; +import AptGetInstall from "./\_apt_get_install.mdx"; + +## 安装 + +TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供RESTful接口的taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件,目前 2.X 版服务端taosd、taosAdapter 仅在 Linux 系统上安装和运行,后续将支持 Windows、macOS 等系统。应用驱动 taosc 与 TDengine CLI 可以在 Windows 或 Linux 上安装和运行。TDengine 除 RESTful接口外,还提供一些列编程语言的连接器。2.4 之前的版本中,无 taosAdapter,RESTfule 接口均由 taosd 内置的 http 服务提供。 +TDengine 支持 X64/ARM64/MIPS64/Alpha64 硬件平台,后续将支持 ARM32、RISC-V 等 CPU 架构。 + + + 如果已经安装了 docker, 只需执行下面的命令。 ```shell @@ -22,46 +36,32 @@ docker exec -it bash 然后就可以执行相关的 Linux 命令操作和访问 TDengine -详细操作方法请参照 [通过 Docker 快速体验 TDengine](/train-fqa/docker)。 +详细操作方法请参照 [通过 Docker 快速体验 TDengine](/train-faq/docker)。 :::info 从 2.4.0.10 开始,除 taosd 以外,Docker 镜像还包含:taos、taosAdapter、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码。启动 Docker 容器时,将同时启动 taosAdapter 和 taosd,实现对 RESTful 的支持。 ::: -:::note -暂时不建议生产环境采用 Docker 来部署 TDengine 的客户端或服务端,但在开发环境下或初次尝试时,使用 Docker 方式部署是十分方便的。特别是,利用 Docker,可以方便地在 macOS 和 Windows 环境下尝试 TDengine。 - -::: - -## 安装 + + + + + + + + -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; -import PkgInstall from "./\_pkg_install.mdx"; -import AptGetInstall from "./\_apt_get_install.mdx"; -import SrcInstall from "./\_src_install.mdx"; +如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装. -TDengine 包括服务端、客户端和周边生态工具软件,目前 2.0 版服务端仅在 Linux 系统上安装和运行,后续将支持 Windows、macOS 等系统。客户端可以在 Windows 或 Linux 上安装和运行。在任何操作系统上的应用都可以使用 RESTful 接口连接服务端程序 taosd,其中 2.4 之后版本默认使用单独运行的独立组件 taosAdapter 提供 http 服务和更多数据写入方式。taosAdapter 需要手动启动。 -之前版本 TDengine 服务端,以及所有服务端 lite 版,均使用内置 http 服务。 +下载其他组件、最新 Beta 版及之前版本的安装包,请点击[这里](https://www.taosdata.com/cn/all-downloads/)。 -TDengine 支持 X64/ARM64/MIPS64/Alpha64 硬件平台,后续将支持 ARM32、RISC-V 等 CPU 架构。 - - - - - - - - - - - + ## 启动 -使用 `systemctl` 命令来启动 TDengine 的服务进程。 +安装后,请使用 `systemctl` 命令来启动 TDengine 的服务进程。 ```bash systemctl start taosd @@ -79,7 +79,7 @@ systemctl status taosd - systemctl 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 sudo 。 - 为更好的获得产品反馈,改善产品,TDengine 会采集基本的使用信息,但您可以修改系统配置文件 taos.cfg 里的配置参数 telemetryReporting,将其设为 0,就可将其关闭。 -- TDengine 采用 FQDN(一般就是 hostname)作为节点的 ID,为保证正常运行,需要给运行 taosd 的服务器配置好 hostname,在客户端应用运行的机器配置好 DNS 服务或 hosts 文件,保证 FQDN 能够解析。 +- TDengine 采用 FQDN(一般就是 hostname)作为节点的 ID,为保证正常运行,需要给运行 taosd 的服务器配置好 FQDN,在 TDengine CLI 或应用运行的机器配置好 DNS 服务或 hosts 文件,保证 FQDN 能够解析。 - `systemctl stop taosd` 指令在执行后并不会马上停止 TDengine 服务,而是会等待系统中必要的落盘工作正常完成。在数据量很大的情况下,这可能会消耗较长时间。 TDengine 支持在使用 [`systemd`](https://en.wikipedia.org/wiki/Systemd) 做进程服务管理的 Linux 系统上安装,用 `which systemctl` 命令来检测系统中是否存在 `systemd` 包: @@ -92,23 +92,23 @@ which systemctl :::note -## 进入命令行 +## TDengine 命令行 (CLI) -执行 TDengine 客户端程序,您只要在 Linux 终端执行 `taos` 即可。 +为便于检查 TDengine 的状态,执行各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI) taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可。 ```bash taos ``` -如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-fqa/faq) 来解决终端连接服务端失败的问题)。客户端的提示符号如下: +如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。 TDengine CLI 的提示符号如下: ```cmd taos> ``` -在 TDengine 客户端中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例: +在 TDengine CLI中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例: -```mysql +```sql create database demo; use demo; create table t (ts timestamp, speed int); @@ -122,45 +122,11 @@ select * from t; Query OK, 2 row(s) in set (0.003128s) ``` -除执行 SQL 语句外,系统管理员还可以从 TDengine 客户端进行检查系统运行状态、添加删除用户账号等操作。 - -## 命令行参数 - -您可通过配置命令行参数来改变 TDengine 客户端的行为。以下为常用的几个命令行参数: - -- -c, --config-dir: 指定配置文件目录,默认为 `/etc/taos` -- -h, --host: 指定服务的 FQDN 地址或 IP 地址,默认为连接本地服务 -- -s, --commands: 在不进入终端的情况下运行 TDengine 命令 -- -u, --user: 连接 TDengine 服务端的用户名,缺省为 root -- -p, --password: 连接 TDengine 服务端的密码,缺省为 taosdata -- -?, --help: 打印出所有命令行参数 - -示例: - -```bash -taos -h h1.taos.com -s "use db; show tables;" -``` - -## 运行 SQL 命令脚本 - -TDengine 终端可以通过 `source` 命令来运行 SQL 命令脚本。 - -```mysql -taos> source ; -``` - -## taos shell 小技巧 - -- 可以使用上下光标键查看历史输入的指令 -- 修改用户密码:在 shell 中使用 `alter user` 命令,缺省密码为 taosdata -- ctrl+c 中止正在进行中的查询 -- 执行 `RESET QUERY CACHE` 可清除本地缓存的表 schema -- 批量执行 SQL 语句。可以将一系列的 shell 命令(以英文 ; 结尾,每个 SQL 语句为一行)按行存放在文件里,在 shell 里执行命令 `source ` 自动执行该文件里所有的 SQL 语句 -- 输入 q 回车,退出 taos shell +除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TAOS CLI 连同应用驱动也可以独立安装在 Linux 或 windows 机器上运行,更多细节请参考 [这里](../reference/taos-shell/) ## 使用 taosBenchmark 体验写入速度 -启动 TDengine 的服务,在 Linux 终端执行 `taosBenchmark` (曾命名为 taosdemo): +启动 TDengine 的服务,在 Linux 终端执行 `taosBenchmark` (曾命名为 `taosdemo`): ```bash taosBenchmark @@ -170,42 +136,38 @@ taosBenchmark 这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能,即使在一台普通的 PC 服务器往往也仅需十几秒。 -## taosBenchmark 详细功能列表 - -taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,请执行 `taosBenchmark --help` 详细列出。您可以设置不同参数进行体验。 - -taosBenchmark 详细使用方法请参照 [如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)。 +taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)。 -## 使用 taos shell 体验查询速度 +## 使用 TDengine CLI 体验查询速度 -在 TDengine 客户端输入查询命令,体验查询速度。 +使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。 查询超级表下记录总条数: -```mysql +```sql taos> select count(*) from test.meters; ``` 查询 1 亿条记录的平均值、最大值、最小值等: -```mysql +```sql taos> select avg(current), max(voltage), min(phase) from test.meters; ``` 查询 location="beijing" 的记录总条数: -```mysql +```sql taos> select count(*) from test.meters where location="beijing"; ``` 查询 groupId=10 的所有记录的平均值、最大值、最小值等: -```mysql +```sql taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10; ``` 对表 d10 按 10s 进行平均值、最大值和最小值聚合统计: -```mysql +```sql taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s); ``` diff --git a/docs-cn/03-get-started/_apt_get_install.mdx b/docs-cn/03-get-started/_apt_get_install.mdx index 8161d8e805c94e4fdc60a63f7cefc452eb833f5a..b1bc4a13517bbfdc9eda86a58b89aee8e41fa470 100644 --- a/docs-cn/03-get-started/_apt_get_install.mdx +++ b/docs-cn/03-get-started/_apt_get_install.mdx @@ -1,4 +1,4 @@ -如果,可以使用 apt-get 工具从官方仓库安装。 +可以使用 apt-get 工具从官方仓库安装。 **安装包仓库** diff --git a/docs-cn/03-get-started/_pkg_install.mdx b/docs-cn/03-get-started/_pkg_install.mdx index c3d1d97fe318422207f8aadbe60f3ec27dae6e08..13047f99805172cf37958f18a0c94c5b3201745b 100644 --- a/docs-cn/03-get-started/_pkg_install.mdx +++ b/docs-cn/03-get-started/_pkg_install.mdx @@ -1,5 +1,3 @@ -import PkgList from "./_pkg_list.mdx"; - TDengine 的安装非常简单,从下载到安装成功仅仅只要几秒钟。 为方便使用,从 2.4.0.10 开始,标准的服务端安装包包含了 taos、taosd、taosAdapter、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码;如果您只需要用到服务端程序和客户端连接的 C/C++ 语言支持,也可以仅下载 lite 版本的安装包。 @@ -8,6 +6,51 @@ TDengine 的安装非常简单,从下载到安装成功仅仅只要几秒钟 发布版本包括稳定版和 Beta 版,Beta 版含有更多新功能。正式上线或测试建议安装稳定版。您可以根据需要选择下载: - + + +具体的安装方法,请参见[安装包的安装和卸载](/operation/pkg-install)。 + +下载其他组件、最新 Beta 版及之前版本的安装包,请点击[这里](https://www.taosdata.com/all-downloads) -具体的安装方法,请参见 [安装包的安装和卸载](/operation/pkg-install) 以及 [视频教程](https://www.taosdata.com/blog/2020/11/11/1941.html)。 +请点击[这里](https://github.com/taosdata/TDengine/releases) 查看 Release Notes。 diff --git a/docs-cn/03-get-started/_pkg_list.mdx b/docs-cn/03-get-started/_pkg_list.mdx deleted file mode 100644 index 1ed8a107170302c37ac66d2e0087cb14122cf5cb..0000000000000000000000000000000000000000 --- a/docs-cn/03-get-started/_pkg_list.mdx +++ /dev/null @@ -1,48 +0,0 @@ -**最新安装包** - - - -**所有下载** - -https://www.taosdata.com/all-downloads diff --git a/docs-cn/03-get-started/_src_install.mdx b/docs-cn/03-get-started/_src_install.mdx deleted file mode 100644 index 2004d73fe0d7a4c4aaf50fa42e996841c8c08275..0000000000000000000000000000000000000000 --- a/docs-cn/03-get-started/_src_install.mdx +++ /dev/null @@ -1,3 +0,0 @@ -如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装. - -下载其他组件、最新 Beta 版及之前版本的安装包,请点击[这里](https://www.taosdata.com/cn/all-downloads/)。 diff --git a/docs-cn/04-connect/04-connect.mdx b/docs-cn/04-connect/04-connect.mdx deleted file mode 100644 index 6c664f2a7516814802fdeae2579586d3320bfead..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/04-connect.mdx +++ /dev/null @@ -1,91 +0,0 @@ ---- -sidebar_label: 建立连接 -sidebar_position: 4 ---- - -# 建立连接 - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; -import ConnRest from "./_connect_restful.mdx"; -import ConnJava from "./_connect_java.mdx"; -import ConnGo from "./_connect_go.mdx"; -import ConnRust from "./_connect_rust.mdx"; -import ConnNode from "./_connect_node.mdx"; -import ConnJavaNative from "./_connect_java_native.mdx"; -import ConnPythonNative from "./_connect_python_native.mdx"; -import ConnGoNative from "./_connect_go_native.mdx"; -import ConnRustNative from "./_connect_rust_native.mdx"; -import ConnNodeNative from "./_connect_node_native.mdx"; -import ConnCSNative from "./_connect_cs_native.mdx"; -import ConnC from "./_connect_c.mdx"; - -## 连接器介绍 - -TDengine 提供了丰富的应用程序开发接口,其中包括 C/C++、Java、Python、Go、Node.js、C# 、RESTful 等,便于用户快速开发应用。 - -![image-connecotr](/img/connector.png) - -
(图:连接器工作原理)
- -TDengine 提供了 RESTful 接口,应用程序无需安装任何依赖,只需发送 HTTP 请求就可以连接到 TDengine。同时也提供了各语言的连接器,使用驱动程序 (taosc) 连接 TDengine。通过驱动程序可以使用 TDengine 更丰富的功能。 - -## 前提条件 - -在执行这一步之前,请确保有一个正在运行的,且可以访问到的 TDengine。以下所有示例代码,都假设 TDengine 安装在本机,且 fqdn(默认 localhost) 和 serverPort(默认 6030) 都使用默认配置。 - -## 建立连接 - -### RESTful - -如果你安装的是 TDengine 2.4 之后的版本,使用 RESTful 方式连接时还需启动 taosAdaper。 - - - - - - - - - - - - - - - - - - - -### 本地驱动 - -在没有安装 TDengine 服务端软件的系统上使用本地驱动连接 TDengine, 需要提前[安装客户端驱动程序](/reference/connector/#安装客户端驱动)。 -:::note -需要单独安装客户端时,为避免客户端驱动和服务端不兼容,请尽量使用一致的版本。 - -::: - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs-cn/04-connect/_connect_cs_native.mdx b/docs-cn/04-connect/_connect_cs_native.mdx deleted file mode 100644 index 19dc4bb52b8d033d49882d9be6e7a9c76e8fe61f..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_cs_native.mdx +++ /dev/null @@ -1,9 +0,0 @@ -首先添加 [TDengine.Connector](https://www.nuget.org/packages/TDengine.Connector/) 的引用: - -```bash -dotnet add package TDengine.Connector -``` - -```csharp -{{#include docs-examples/csharp/ConnectExample.cs}} -``` diff --git a/docs-cn/04-connect/_connect_go.mdx b/docs-cn/04-connect/_connect_go.mdx deleted file mode 100644 index 17d7eb98ba3fa7483edd54978771e03cc051ff53..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_go.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```go-mod title=go.mod -module goexample - -go 1.17 - -require github.com/taosdata/driver-go/v2 develop -``` - -```go -{{#include docs-examples/go/connect/restexample/main.go}} -``` diff --git a/docs-cn/04-connect/_connect_go_native.mdx b/docs-cn/04-connect/_connect_go_native.mdx deleted file mode 100644 index 44d31f4b8bfde337c5ef31337fc3ccf25149adb1..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_go_native.mdx +++ /dev/null @@ -1,16 +0,0 @@ -:::note -driver-go 使用 cgo 封装了 taosc 的 API。cgo 需要使用 gcc 编译 C 的源码。因此需要确保你的系统上有 gcc。 - -::: - -```go-mod title=go.mod -module goexample - -go 1.17 - -require github.com/taosdata/driver-go/v2 develop -``` - -```go -{{#include docs-examples/go/connect/cgoexample/main.go}} -``` diff --git a/docs-cn/04-connect/_connect_java.mdx b/docs-cn/04-connect/_connect_java.mdx deleted file mode 100644 index 4282e57215a896656c5ca2a51df45f3bef1cdd5a..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_java.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```xml title=pom.xml - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.37 - -``` - -```java -{{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java}} -``` diff --git a/docs-cn/04-connect/_connect_java_native.mdx b/docs-cn/04-connect/_connect_java_native.mdx deleted file mode 100644 index 9d75df6684ace21d1e7c5995d07d578b8d3803d2..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_java_native.mdx +++ /dev/null @@ -1,11 +0,0 @@ -```xml title=pom.xml - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.37 - -``` - -```java -{{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} -``` diff --git a/docs-cn/04-connect/_connect_node_native.mdx b/docs-cn/04-connect/_connect_node_native.mdx deleted file mode 100644 index 4ffeedd8d9fdc600f8f4b5ab1db41b2139a75039..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_node_native.mdx +++ /dev/null @@ -1,9 +0,0 @@ -首先需要安装 node.js 的连接器 `td2.0-connector`: - -```bash -npm install td2.0-connector -``` - -```js -{{#include docs-examples/node/nativeexample/connect.js}} -``` diff --git a/docs-cn/04-connect/_connect_python_native.mdx b/docs-cn/04-connect/_connect_python_native.mdx deleted file mode 100644 index 1a258988835c383285f16ff9eb0b64518941f7b0..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_python_native.mdx +++ /dev/null @@ -1,9 +0,0 @@ -推荐使用 `python >= 3.4`。首先需要安装 python 连接器 `taospy`。执行以下命令即可: - -``` -pip3 install taospy -``` - -```python -{{#include docs-examples/python/connect_exmaple.py}} -``` diff --git a/docs-cn/04-connect/_connect_restful.mdx b/docs-cn/04-connect/_connect_restful.mdx deleted file mode 100644 index d68903aa3979f5098e83a029bae42d5f8363fa93..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_restful.mdx +++ /dev/null @@ -1,22 +0,0 @@ -下面用 curl 工具来演示访问 RESTful 接口。在命令行执行下面的命令: - -```bash -curl http://localhost:6041/rest/sql -u root:taosdata -d "select server_version()" -``` - -- `-u` 用于指定访问数据库的用户名和密码。 -- `-d` 用于指定发送要执行的 SQL 语句。它会被放入 POST 请求的 Body 中。 - -如果正常,会返回一个 JSON 字符串,里面包含了服务端的版本。例如: - -```json -{ - "status": "succ", - "head": ["server_version()"], - "column_meta": [["server_version()", 8, 7]], - "data": [["2.4.0.0"]], - "rows": 1 -} -``` - -了解更多:[RESTful API](/reference/restful-api)。 diff --git a/docs-cn/04-connect/_connect_rust.mdx b/docs-cn/04-connect/_connect_rust.mdx deleted file mode 100644 index b167278a55f9b3dca97367e0b391fef28a00d6ec..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_rust.mdx +++ /dev/null @@ -1,8 +0,0 @@ -```toml title=Cargo.toml -[dependencies] -libtaos = { version = "*", features = ["rest"] } -``` - -```rust -{{#include docs-examples/rust/restexample/examples/connect.rs}} -``` diff --git a/docs-cn/04-connect/_connect_rust_native.mdx b/docs-cn/04-connect/_connect_rust_native.mdx deleted file mode 100644 index 0ee07c295eb457322d32caaa4cb027593ac5966d..0000000000000000000000000000000000000000 --- a/docs-cn/04-connect/_connect_rust_native.mdx +++ /dev/null @@ -1,8 +0,0 @@ -```toml title=Cargo.toml -[dependencies] -libtaos = { version = "0.4.2"} -``` - -```rust -{{#include docs-examples/rust/nativeexample/examples/connect.rs}} -``` diff --git a/docs-cn/04-connect/_category_.yml b/docs-cn/04-develop/01-connect/_category_.yml similarity index 100% rename from docs-cn/04-connect/_category_.yml rename to docs-cn/04-develop/01-connect/_category_.yml diff --git a/docs-cn/04-connect/_connect_c.mdx b/docs-cn/04-develop/01-connect/_connect_c.mdx similarity index 66% rename from docs-cn/04-connect/_connect_c.mdx rename to docs-cn/04-develop/01-connect/_connect_c.mdx index 4d6f1cfe1b06ef9baeb7da2bb2559880ada99fbf..9cd8669561195b49e8428ed490ad97bb5653ae6a 100644 --- a/docs-cn/04-connect/_connect_c.mdx +++ b/docs-cn/04-develop/01-connect/_connect_c.mdx @@ -1,3 +1,3 @@ -```c +```c title="原生连接" {{#include docs-examples/c/connect_example.c}} ``` diff --git a/docs-cn/04-develop/01-connect/_connect_cs.mdx b/docs-cn/04-develop/01-connect/_connect_cs.mdx new file mode 100644 index 0000000000000000000000000000000000000000..204173dd329f6f214a9ea44c2f360be2cdbfdab8 --- /dev/null +++ b/docs-cn/04-develop/01-connect/_connect_cs.mdx @@ -0,0 +1,7 @@ +```csharp title="原生连接" +{{#include docs-examples/csharp/ConnectExample.cs}} +``` +:::info +C# 连接器目前只支持原生连接。 + +::: \ No newline at end of file diff --git a/docs-cn/04-develop/01-connect/_connect_go.mdx b/docs-cn/04-develop/01-connect/_connect_go.mdx new file mode 100644 index 0000000000000000000000000000000000000000..4e4f189672f2fda4b807fe628d4455a41ac4cb69 --- /dev/null +++ b/docs-cn/04-develop/01-connect/_connect_go.mdx @@ -0,0 +1,15 @@ +#### 使用数据库访问统一接口 +```go title="原生连接" +{{#include docs-examples/go/connect/cgoexample/main.go}} +``` +```go title="REST 连接" +{{#include docs-examples/go/connect/restexample/main.go}} +``` +#### 使用高级封装 +也可以使用 driver-go 的 af 包建立连接。这个模块封装了 TDengine 的高级功能, 如:参数绑定、订阅等。 + +```go title="使用 af 包建立原生连接" +{{#include docs-examples/go/connect/afconn/main.go}} +``` + + diff --git a/docs-cn/04-develop/01-connect/_connect_java.mdx b/docs-cn/04-develop/01-connect/_connect_java.mdx new file mode 100644 index 0000000000000000000000000000000000000000..cd6d7c4cab9a84abb22895c704debd260884081f --- /dev/null +++ b/docs-cn/04-develop/01-connect/_connect_java.mdx @@ -0,0 +1,11 @@ +```java title="原生连接" +{{#include docs-examples/java/src/main/java/com/taos/example/JNIConnectExample.java}} +``` +```java title="REST 连接" +{{#include docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java:main}} +``` +使用REST 连接时,如果查询数据量比较大,还可开启批量拉取功能。 +```java title="开启批量拉取功能" {4} +{{#include docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java:main}} +``` +更多连接参数配置,参考[Java 连接器](/reference/connector/java) \ No newline at end of file diff --git a/docs-cn/04-develop/01-connect/_connect_node.mdx b/docs-cn/04-develop/01-connect/_connect_node.mdx new file mode 100644 index 0000000000000000000000000000000000000000..8a259888f87d4d441c58b9a8a9008b19273c1a58 --- /dev/null +++ b/docs-cn/04-develop/01-connect/_connect_node.mdx @@ -0,0 +1,6 @@ +```js title="原生连接" +{{#include docs-examples/node/nativeexample/connect.js}} +``` +```js title="REST 连接" +{{#include docs-examples/node/restexample/connect.js}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/01-connect/_connect_python.mdx b/docs-cn/04-develop/01-connect/_connect_python.mdx new file mode 100644 index 0000000000000000000000000000000000000000..331ec0f693601baeb28ede7b0278e67f1471c187 --- /dev/null +++ b/docs-cn/04-develop/01-connect/_connect_python.mdx @@ -0,0 +1,3 @@ +```python title="原生连接" +{{#include docs-examples/python/connect_exmaple.py}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/01-connect/_connect_r.mdx b/docs-cn/04-develop/01-connect/_connect_r.mdx new file mode 100644 index 0000000000000000000000000000000000000000..a69a57f66be3672d61cb0f84f43aba123cfbd5aa --- /dev/null +++ b/docs-cn/04-develop/01-connect/_connect_r.mdx @@ -0,0 +1,3 @@ +```r title="原生连接" +{{#include docs-examples/R/connect_native.r:demo}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/01-connect/_connect_rust.mdx b/docs-cn/04-develop/01-connect/_connect_rust.mdx new file mode 100644 index 0000000000000000000000000000000000000000..b051108452d16f207ce10b128f5de2e5f507200f --- /dev/null +++ b/docs-cn/04-develop/01-connect/_connect_rust.mdx @@ -0,0 +1,7 @@ +```rust title="原生连接/REST 连接" +{{#include docs-examples/rust/nativeexample/examples/connect.rs}} +``` +:::note +对于 Rust 连接器, 连接方式的不同只体现在使用的特性不同。如果启用了 "rest" 特性,那么只有 RESTful 的实现会被编译进来。 + +::: diff --git a/docs-cn/04-develop/01-connect/index.md b/docs-cn/04-develop/01-connect/index.md new file mode 100644 index 0000000000000000000000000000000000000000..144b08433d511b06a95344e819a907a95779e0d2 --- /dev/null +++ b/docs-cn/04-develop/01-connect/index.md @@ -0,0 +1,239 @@ +--- +title: 建立连接 +description: "本节介绍如何使用连接器建立与 TDengine 的连接,给出连接器安装、连接的简单说明。" +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import ConnJava from "./_connect_java.mdx"; +import ConnGo from "./_connect_go.mdx"; +import ConnRust from "./_connect_rust.mdx"; +import ConnNode from "./_connect_node.mdx"; +import ConnPythonNative from "./_connect_python.mdx"; +import ConnCSNative from "./_connect_cs.mdx"; +import ConnC from "./_connect_c.mdx"; +import ConnR from "./_connect_r.mdx"; +import InstallOnWindows from "../../14-reference/03-connector/_linux_install.mdx"; +import InstallOnLinux from "../../14-reference/03-connector/_windows_install.mdx"; +import VerifyLinux from "../../14-reference/03-connector/_verify_linux.mdx"; +import VerifyWindows from "../../14-reference/03-connector/_verify_windows.mdx"; + +TDengine 提供 REST API,容许在任何平台的任何应用程序通过它访问 TDengine 运行实例,详细介绍请看 [REST API](/reference/rest-api/)。除 REST API 之外,TDengine 还提供多种编程语言的连接器方便用户开发应用程序,其中包括 C/C++、Java、Python、Go、Node.js、C# 等。 本节介绍如何使用连接器建立与 TDengine 的连接,给出连接器安装、连接的简单说明。关于各连接器的详细功能说明,请查看[连接器](https://docs.taosdata.com/reference/connector/) + +## 连接器建立连接的方式 + +连接器建立连接的方式,TDengine 提供两种: + +1. 通过 taosAdapter 组件提供的 REST API 建立与 taosd 的连接,这种连接方式下文中简称"REST 连接“ +2. 通过客户端驱动程序 taosc 直接与服务端程序 taosd 建立连接,这种连接方式下文中简称“原生连接”。 + +无论使用何种方式建立连接,连接器都提供了相同或相似的 API 操作数据库,都可以执行 SQL 语句,只是初始化连接的方式稍有不同,用户在使用上不会感到什么差别。 + +关键不同点在于: + +1. 使用 REST 连接,用户无需安装客户端驱动程序 taosc,具有跨平台易用的优势,但性能要下降 30%左右。 +2. 使用原生连接可以体验 TDengine 的全部功能,如[参数绑定接口](/reference/connector/cpp#参数绑定-api)、[订阅](reference/connector/cpp#数据订阅接口)等等。 + +## 安装客户端驱动 taosc + +如果选择原生连接,而且应用程序不在 TDengine 同一台服务器上运行,你需要先安装客户端驱动,否则可以跳过此一步。为避免客户端驱动和服务端不兼容,请使用一致的版本。 + +### 安装步骤 + + + + + + + + + + +### 安装验证 + +以上安装和配置完成后,并确认 TDengine 服务已经正常启动运行,此时可以执行安装包里带有的 TDengine 命令行程序 taos 进行登录。 + + + + + + + + + + +## 安装连接器 + + + + +如果使用 maven 管理项目,只需在 pom.xml 中加入以下依赖。 + +```xml + + com.taosdata.jdbc + taos-jdbcdriver + 2.0.38 + +``` + + + + +使用 `pip` 从 PyPI 安装: + +``` +pip install taospy +``` + +从 Git URL 安装: + +``` +pip install git+https://github.com/taosdata/taos-connector-python.git +``` + + + + +编辑 `go.mod` 添加 `driver-go` 依赖即可。 + +```go-mod title=go.mod +module goexample + +go 1.17 + +require github.com/taosdata/driver-go/v2 develop +``` + +:::note +driver-go 使用 cgo 封装了 taosc 的 API。cgo 需要使用 gcc 编译 C 的源码。因此需要确保你的系统上有 gcc。 + +::: + + + + +编辑 `Cargo.toml` 添加 `libtaos` 依赖即可。 + +```toml title=Cargo.toml +[dependencies] +libtaos = { version = "0.4.2"} +``` + +:::info +Rust 连接器通过不同的特性区分不同的连接方式。如果要建立 REST 连接,需要开启 `rest` 特性: + +```toml +libtaos = { version = "*", features = ["rest"] } +``` + +::: + + + + +Node.js 连接器通过不同的包提供不同的连接方式。 + +1. 安装 Node.js 原生连接器 + +``` +npm i td2.0-connector +``` + +:::note +推荐 Node 版本大于等于 `node-v12.8.0` 小于 `node-v13.0.0` + +::: 2. 安装 Node.js REST 连接器 + +``` +npm i td2.0-rest-connector +``` + + + + +编辑项目配置文件中添加 [TDengine.Connector](https://www.nuget.org/packages/TDengine.Connector/) 的引用即可: + +```xml title=csharp.csproj {12} + + + + Exe + net6.0 + enable + enable + TDengineExample.AsyncQueryExample + + + + + + + +``` + +也可通过 dotnet 命令添加: + +``` +dotnet add package TDengine.Connector +``` + +:::note +以下示例代码,均基于 dotnet6.0,如果使用其它版本,可能需要做适当调整。 + +::: + + + + +1. 下载 [taos-jdbcdriver-version-dist.jar](https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/2.0.38/)。 +2. 安装 R 的依赖包`RJDBC`: + +```R +install.packages("RJDBC") +``` + + + + +如果已经安装了 TDengine 服务端软件或 TDengine 客户端驱动 taosc, 那么已经安装了 C 连接器,无需额外操作。 +
+ +
+
+ +## 建立连接 + +在执行这一步之前,请确保有一个正在运行的,且可以访问到的 TDengine,而且服务端的 FQDN 配置正确。以下示例代码,都假设 TDengine 安装在本机,且 FQDN(默认 localhost) 和 serverPort(默认 6030) 都使用默认配置。 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +:::tip +如果建立连接失败,大部分情况下是 FQDN 或防火墙的配置不正确,详细的排查方法请看[《常见问题及反馈》](https://docs.taosdata.com/train-faq/faq)中的“遇到错误 Unable to establish connection, 我怎么办?” + +::: diff --git a/docs-cn/05-model/_category_.yml b/docs-cn/04-develop/02-model/_category_.yml similarity index 95% rename from docs-cn/05-model/_category_.yml rename to docs-cn/04-develop/02-model/_category_.yml index c61397aa9b77ad3c29bdd4aed021d1e2c556c4a1..e5dae7c27cf17ff737aa8301bc79aad468c28791 100644 --- a/docs-cn/05-model/_category_.yml +++ b/docs-cn/04-develop/02-model/_category_.yml @@ -1 +1,2 @@ label: 数据建模 + diff --git a/docs-cn/05-model/05-model.mdx b/docs-cn/04-develop/02-model/index.mdx similarity index 69% rename from docs-cn/05-model/05-model.mdx rename to docs-cn/04-develop/02-model/index.mdx index f7f0b51350be62ea2faf8992ba9fc93bd1092979..7cf03cee37a5ac681181b0982e98e48d139ddb83 100644 --- a/docs-cn/05-model/05-model.mdx +++ b/docs-cn/04-develop/02-model/index.mdx @@ -1,18 +1,21 @@ -# TDengine 数据建模 +--- +slug: /model +title: TDengine 数据建模 +--- -TDengine 采用关系型数据模型,需要建库、建表。因此对于一个具体的应用场景,需要考虑库、超级表和普通表的设计。本节不讨论细致的语法规则,只介绍概念。 +TDengine 采用类关系型数据模型,需要建库、建表。因此对于一个具体的应用场景,需要考虑库、超级表和普通表的设计。本节不讨论细致的语法规则,只介绍概念。 关于数据建模请参考[视频教程](https://www.taosdata.com/blog/2020/11/11/1945.html)。 ## 创建库 -不同类型的数据采集点往往具有不同的数据特征,包括数据采集频率的高低,数据保留时间的长短,副本的数目,数据块的大小,是否允许更新数据等等。为了在各种场景下 TDengine 都能最大效率的工作,TDengine 建议将不同数据特征的表创建在不同的库里,因为每个库可以配置不同的存储策略。创建一个库时,除 SQL 标准的选项外,应用还可以指定保留时长、副本数、内存块个数、时间精度、文件块里最大最小记录条数、是否压缩、一个数据文件覆盖的天数等多种参数。比如: +不同类型的数据采集点往往具有不同的数据特征,包括数据采集频率的高低,数据保留时间的长短,副本的数目,数据块的大小,是否允许更新数据等等。为了在各种场景下 TDengine 都能最大效率的工作,TDengine 建议将不同数据特征的表创建在不同的库里,因为每个库可以配置不同的存储策略。创建一个库时,除 SQL 标准的选项外,还可以指定保留时长、副本数、内存块个数、时间精度、文件块里最大最小记录条数、是否压缩、一个数据文件覆盖的天数等多种参数。比如: ```sql CREATE DATABASE power KEEP 365 DAYS 10 BLOCKS 6 UPDATE 1; ``` -上述语句将创建一个名为 power 的库,这个库的数据将保留 365 天(超过 365 天将被自动删除),每 10 天一个数据文件,内存块数为 6,允许更新数据。详细的语法及参数请见 [数据库管理](/reference/taos-sql/database) 章节。 +上述语句将创建一个名为 power 的库,这个库的数据将保留 365 天(超过 365 天将被自动删除),每 10 天一个数据文件,内存块数为 6,允许更新数据。详细的语法及参数请见 [数据库管理](/taos-sql/database) 章节。 创建库之后,需要使用 SQL 命令 `USE` 将当前库切换过来,例如: @@ -24,7 +27,7 @@ USE power; :::note -- 任何一张表或超级表是属于一个库的,在创建表之前,必须先创建库。 +- 任何一张表或超级表必须属于某个库,在创建表之前,必须先创建库。 - 处于两个不同库的表是不能进行 JOIN 操作的。 - 创建并插入记录、查询历史记录的时候,均需要指定时间戳。 @@ -42,11 +45,11 @@ CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAG 这一指令中的 STABLE 关键字,在 2.0.15 之前的版本中需写作 TABLE 。 ::: -与创建普通表一样,创建表时,需要提供表名(示例中为 meters),表结构 Schema,即数据列的定义。第一列必须为时间戳(示例中为 ts),其他列为采集的物理量(示例中为 current, voltage, phase),数据类型可以为整型、浮点型、字符串等。除此之外,还需要提供标签的 schema (示例中为 location, groupId),标签的数据类型可以为整型、浮点型、字符串等。采集点的静态属性往往可以作为标签,比如采集点的地理位置、设备型号、设备组 ID、管理员 ID 等等。标签的 schema 可以事后增加、删除、修改。具体定义以及细节请见 [TAOS SQL 的超级表管理](/reference/taos-sql/stable) 章节。 +与创建普通表一样,创建超级表时,需要提供表名(示例中为 meters),表结构 Schema,即数据列的定义。第一列必须为时间戳(示例中为 ts),其他列为采集的物理量(示例中为 current, voltage, phase),数据类型可以为整型、浮点型、字符串等。除此之外,还需要提供标签的 schema (示例中为 location, groupId),标签的数据类型可以为整型、浮点型、字符串等。采集点的静态属性往往可以作为标签,比如采集点的地理位置、设备型号、设备组 ID、管理员 ID 等等。标签的 schema 可以事后增加、删除、修改。具体定义以及细节请见 [TAOS SQL 的超级表管理](/taos-sql/stable) 章节。 -每一种类型的数据采集点需要建立一个超级表,因此一个物联网系统,往往会有多个超级表。对于电网,我们就需要对智能电表、变压器、母线、开关等都建立一个超级表。在物联网中,一个设备就可能有多个数据采集点(比如一台风力发电的风机,有的采集点采集电流、电压等电参数,有的采集点采集温度、湿度、风向等环境参数),这个时候,对这一类型的设备,需要建立多张超级表。一张超级表里包含的采集物理量必须是同时采集的(时间戳是一致的)。 +每一种类型的数据采集点需要建立一个超级表,因此一个物联网系统,往往会有多个超级表。对于电网,我们就需要对智能电表、变压器、母线、开关等都建立一个超级表。在物联网中,一个设备就可能有多个数据采集点(比如一台风力发电的风机,有的采集点采集电流、电压等电参数,有的采集点采集温度、湿度、风向等环境参数),这个时候,对这一类型的设备,需要建立多张超级表。 -一张超级表最多容许 1024 列,如果一个采集点采集的物理量个数超过 1024,需要建多张超级表来处理。一个系统可以有多个 DB,一个 DB 里可以有一到多个超级表。(从 2.1.7.0 版本开始,列数限制由 1024 列放宽到了 4096 列。) +一张超级表最多容许 4096 列 (在 2.1.7.0 版本之前,列数限制为 1024 列),如果一个采集点采集的物理量个数超过 4096,需要建多张超级表来处理。一个系统可以有多个 DB,一个 DB 里可以有一到多个超级表。 ## 创建表 @@ -56,10 +59,10 @@ TDengine 对每个数据采集点需要独立建表。与标准的关系型数 CREATE TABLE d1001 USING meters TAGS ("Beijing.Chaoyang", 2); ``` -其中 d1001 是表名,meters 是超级表的表名,后面紧跟标签 Location 的具体标签值 ”Beijing.Chaoyang",标签 groupId 的具体标签值 2。虽然在创建表时,需要指定标签值,但可以事后修改。详细细则请见 [TAOS SQL 的表管理](/reference/taos-sql/table) 章节。 +其中 d1001 是表名,meters 是超级表的表名,后面紧跟标签 Location 的具体标签值 ”Beijing.Chaoyang",标签 groupId 的具体标签值 2。虽然在创建表时,需要指定标签值,但可以事后修改。详细细则请见 [TAOS SQL 的表管理](/taos-sql/table) 章节。 :::warning -目前 TDengine 没有从技术层面限制使用一个 database (dbA)的超级表作为模板建立另一个 database (dbB)的子表,后续会禁止这种用法,不建议使用这种方法建表。 +目前 TDengine 没有从技术层面限制使用一个 database (db1) 的超级表作为模板建立另一个 database (db2) 的子表,后续会禁止这种用法,不建议使用这种方法建表。 ::: @@ -67,7 +70,7 @@ TDengine 建议将数据采集点的全局唯一 ID 作为表名(比如设备序 ### 自动建表 -在某些特殊场景中,用户在写数据时并不确定某个数据采集点的表是否存在,此时可在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表。比如: +在某些特殊场景中,用户在写数据时并不确定某个数据采集点的表是否存在,此时可在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表且后面的 USING 语句被忽略。比如: ```sql INSERT INTO d1001 USING meters TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 219, 0.32); @@ -75,7 +78,7 @@ INSERT INTO d1001 USING meters TAGS ("Beijng.Chaoyang", 2) VALUES (now, 10.2, 21 上述 SQL 语句将记录`(now, 10.2, 219, 0.32)`插入表 d1001。如果表 d1001 还未创建,则使用超级表 meters 做模板自动创建,同时打上标签值 `"Beijing.Chaoyang", 2`。 -关于自动建表的详细语法请参见 [插入记录时自动建表](reference/taos-sql/insert#插入记录时自动建表) 章节。 +关于自动建表的详细语法请参见 [插入记录时自动建表](/taos-sql/insert#插入记录时自动建表) 章节。 ## 多列模型 vs 单列模型 diff --git a/docs-cn/04-develop/03-insert-data/01-sql-writing.mdx b/docs-cn/04-develop/03-insert-data/01-sql-writing.mdx new file mode 100644 index 0000000000000000000000000000000000000000..7a4ab3eb72f6bf41e863ba26aa7ef97b503349d8 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/01-sql-writing.mdx @@ -0,0 +1,129 @@ +--- +title: SQL 写入 +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import JavaSQL from "./_java_sql.mdx"; +import JavaStmt from "./_java_stmt.mdx"; +import PySQL from "./_py_sql.mdx"; +import PyStmt from "./_py_stmt.mdx"; +import GoSQL from "./_go_sql.mdx"; +import GoStmt from "./_go_stmt.mdx"; +import RustSQL from "./_rust_sql.mdx"; +import RustStmt from "./_rust_stmt.mdx"; +import NodeSQL from "./_js_sql.mdx"; +import NodeStmt from "./_js_stmt.mdx"; +import CsSQL from "./_cs_sql.mdx"; +import CsStmt from "./_cs_stmt.mdx"; +import CSQL from "./_c_sql.mdx"; +import CStmt from "./_c_stmt.mdx"; + +## SQL 写入简介 + +应用通过连接器执行 INSERT 语句来插入数据,用户还可以通过 TAOS Shell,手动输入 INSERT 语句插入数据。 + +### 一次写入一条 +下面这条 INSERT 就将一条记录写入到表 d1001 中: + +```sql +INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31); +``` + +### 一次写入多条 + +TDengine 支持一次写入多条记录,比如下面这条命令就将两条记录写入到表 d1001 中: + +```sql +INSERT INTO d1001 VALUES (1538548684000, 10.2, 220, 0.23) (1538548696650, 10.3, 218, 0.25); +``` + +### 一次写入多表 + +TDengine 也支持一次向多个表写入数据,比如下面这条命令就向 d1001 写入两条记录,向 d1002 写入一条记录: + +```sql +INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, 218, 0.33) d1002 VALUES (1538548696800, 12.3, 221, 0.31); +``` + +详细的 SQL INSERT 语法规则参考 [TAOS SQL 的数据写入](/taos-sql/insert)。 + +:::info + +- 要提高写入效率,需要批量写入。一批写入的记录条数越多,插入效率就越高。但一条记录不能超过 16K,一条 SQL 语句总长度不能超过 1M 。 +- TDengine 支持多线程同时写入,要进一步提高写入速度,一个客户端需要打开 20 个以上的线程同时写。但线程数达到一定数量后,无法再提高,甚至还会下降,因为线程频繁切换,带来额外开销。 + +::: + +:::warning + +- 对同一张表,如果新插入记录的时间戳已经存在,默认情形下(UPDATE=0)新记录将被直接抛弃,也就是说,在一张表里,时间戳必须是唯一的。如果应用自动生成记录,很有可能生成的时间戳是一样的,这样,成功插入的记录条数会小于应用插入的记录条数。如果在创建数据库时使用了 UPDATE 1 选项,插入相同时间戳的新记录将覆盖原有记录。 +- 写入的数据的时间戳必须大于当前时间减去配置参数 keep 的时间。如果 keep 配置为 3650 天,那么无法写入比 3650 天还早的数据。写入数据的时间戳也不能大于当前时间加配置参数 days。如果 days 为 2,那么无法写入比当前时间还晚 2 天的数据。 + +::: + +## 示例程序 + +### 普通 SQL 写入 + + + + + + + + + + + + + + + + + + + + + + + + + +:::note + +1. 无论 RESTful 方式建立连接还是本地驱动方式建立连接,以上示例代码都能正常工作。 +2. 唯一需要注意的是:由于 RESTful 接口无状态, 不能使用 `use db` 语句来切换数据库, 所以在上面示例中使用了`dbName.tbName`指定表名。 + +::: + +### 参数绑定写入 + +TDengine 也提供了支持参数绑定的 Prepare API,与 MySQL 类似,这些 API 目前也仅支持用问号 `?` 来代表待绑定的参数。从 2.1.1.0 和 2.1.2.0 版本开始,TDengine 大幅改进了参数绑定接口对数据写入(INSERT)场景的支持。这样在通过参数绑定接口写入数据时,就避免了 SQL 语法解析的资源消耗,从而在绝大多数情况下显著提升写入性能。 + +需要注意的是,只有使用原生连接的连接器,才能使用参数绑定功能。 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs-cn/04-develop/03-insert-data/02-influxdb-line.mdx b/docs-cn/04-develop/03-insert-data/02-influxdb-line.mdx new file mode 100644 index 0000000000000000000000000000000000000000..dedd7f0e70834e21257bda78dd184f5ddc520160 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/02-influxdb-line.mdx @@ -0,0 +1,70 @@ +--- +sidebar_label: InfluxDB 行协议 +title: InfluxDB 行协议 +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import JavaLine from "./_java_line.mdx"; +import PyLine from "./_py_line.mdx"; +import GoLine from "./_go_line.mdx"; +import RustLine from "./_rust_line.mdx"; +import NodeLine from "./_js_line.mdx"; +import CsLine from "./_cs_line.mdx"; +import CLine from "./_c_line.mdx"; + +## 协议介绍 + +InfluxDB Line 协议采用一行字符串来表示一行数据。分为四部分: + +``` +measurement,tag_set field_set timestamp +``` + +- measurement 将作为超级表名。它与 tag_set 之间使用一个英文逗号来分隔。 +- tag_set 将作为标签数据,其格式形如 `=,=`,也即可以使用英文逗号来分隔多个标签数据。它与 field_set 之间使用一个半角空格来分隔。 +- field_set 将作为普通列数据,其格式形如 `=,=`,同样是使用英文逗号来分隔多个普通列的数据。它与 timestamp 之间使用一个半角空格来分隔。 +- timestamp 即本行数据对应的主键时间戳。 + +例如: + +``` +meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611249500 +``` + +:::note + +- tag_set 中的所有的数据自动转化为 nchar 数据类型; +- field_set 中的每个数据项都需要对自身的数据类型进行描述, 比如 1.2f32 代表 float 类型的数值 1.2, 如果不带类型后缀会被当作 double 处理; +- timestamp 支持多种时间精度。写入数据的时候需要用参数指定时间精度,支持从小时到纳秒的 6 种时间精度。 + +::: + +要了解更多可参考:[InfluxDB Line 协议官方文档](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/) 和 [TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) + + +## 示例代码 + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs-cn/04-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs-cn/04-develop/03-insert-data/03-opentsdb-telnet.mdx new file mode 100644 index 0000000000000000000000000000000000000000..7efb3e1cf967e6d135e7999b4f0dc191b93a884b --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -0,0 +1,84 @@ +--- +sidebar_label: OpentsDB 行协议 +title: OpentsDB 行协议 +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import JavaTelnet from "./_java_opts_telnet.mdx"; +import PyTelnet from "./_py_opts_telnet.mdx"; +import GoTelnet from "./_go_opts_telnet.mdx"; +import RustTelnet from "./_rust_opts_telnet.mdx"; +import NodeTelnet from "./_js_opts_telnet.mdx"; +import CsTelnet from "./_cs_opts_telnet.mdx"; +import CTelnet from "./_c_opts_telnet.mdx"; + +## 协议介绍 + +OpentsDB 行协议同样采用一行字符串来表示一行数据。OpentsDB 采用的是单列模型,因此一行只能包含一个普通数据列。标签列依然可以有多个。分为四部分,具体格式约定如下: + +```txt + =[ =] +``` + +- metric 将作为超级表名。 +- timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度 +- value 度量值,必须为一个数值。对应的列名也是 “value”。 +- 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型; + +例如: + +```txt +meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3 +``` + +参考[OpenTSDB Telnet API文档](http://opentsdb.net/docs/build/html/api_telnet/put.html)。 + +## 示例代码 + + + + + + + + + + + + + + + + + + + + + + + + + +以上示例代码会自动创建 2 个超级表, 每个超级表有 4 条数据。 + +```cmd +taos> use test; +Database changed. + +taos> show stables; + name | created_time | columns | tags | tables | +============================================================================================ + meters.current | 2022-03-30 17:04:10.877 | 2 | 2 | 2 | + meters.voltage | 2022-03-30 17:04:10.882 | 2 | 2 | 2 | +Query OK, 2 row(s) in set (0.002544s) + +taos> select tbname, * from `meters.current`; + tbname | ts | value | groupid | location | +================================================================================================================================== + t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | Beijing.Haidian | + t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.250 | 11.300000000 | 3 | Beijing.Haidian | + t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.249 | 10.300000000 | 2 | Beijing.Chaoyang | + t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.250 | 12.600000000 | 2 | Beijing.Chaoyang | +Query OK, 4 row(s) in set (0.005399s) +``` diff --git a/docs-cn/04-develop/03-insert-data/04-opentsdb-json.mdx b/docs-cn/04-develop/03-insert-data/04-opentsdb-json.mdx new file mode 100644 index 0000000000000000000000000000000000000000..0767dba0c12cca24c0bcb55c6b95a0392772cafa --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/04-opentsdb-json.mdx @@ -0,0 +1,99 @@ +--- +sidebar_label: OpentsDB JSON 格式协议 +title: OpentsDB JSON 格式协议 +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import JavaJson from "./_java_opts_json.mdx"; +import PyJson from "./_py_opts_json.mdx"; +import GoJson from "./_go_opts_json.mdx"; +import RustJson from "./_rust_opts_json.mdx"; +import NodeJson from "./_js_opts_json.mdx"; +import CsJson from "./_cs_opts_json.mdx"; +import CJson from "./_c_opts_json.mdx"; + +## 协议介绍 + +OpentsDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据。例如: + +```json +[ + { + "metric": "sys.cpu.nice", + "timestamp": 1346846400, + "value": 18, + "tags": { + "host": "web01", + "dc": "lga" + } + }, + { + "metric": "sys.cpu.nice", + "timestamp": 1346846400, + "value": 9, + "tags": { + "host": "web02", + "dc": "lga" + } + } +] +``` + +与 OpentsDB 行协议类似, metric 将作为超级表名, timestamp 表示时间戳,value 表示度量值, tags 表示标签集。 + + +参考[OpenTSDB HTTP API文档](http://opentsdb.net/docs/build/html/api_http/put.html)。 + +:::note +- 对于 JSON 格式协议,TDengine 并不会自动把所有标签转成 nchar 类型, 字符串将将转为 nchar 类型, 数值将同样转换为 double 类型。 +- TDengine 只接收 JSON **数组格式**的字符串,即使一行数据也需要转换成数组形式。 + +::: + +## 示例代码 + + + + + + + + + + + + + + + + + + + + + + + + + +以上示例代码会自动创建 2 个超级表, 每个超级表有 2 条数据。 + +```cmd +taos> use test; +Database changed. + +taos> show stables; + name | created_time | columns | tags | tables | +============================================================================================ + meters.current | 2022-03-29 16:05:25.193 | 2 | 2 | 1 | + meters.voltage | 2022-03-29 16:05:25.200 | 2 | 2 | 1 | +Query OK, 2 row(s) in set (0.001954s) + +taos> select * from `meters.current`; + ts | value | groupid | location | +=================================================================================================================== + 2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | Beijing.Chaoyang | + 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | Beijing.Chaoyang | +Query OK, 2 row(s) in set (0.004076s) +``` diff --git a/docs-cn/04-develop/03-insert-data/_c_line.mdx b/docs-cn/04-develop/03-insert-data/_c_line.mdx new file mode 100644 index 0000000000000000000000000000000000000000..5ef2e9af774c54e9f090357286f83d2280c2ab11 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_c_line.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs-examples/c/line_example.c:main}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/03-insert-data/_c_opts_json.mdx b/docs-cn/04-develop/03-insert-data/_c_opts_json.mdx new file mode 100644 index 0000000000000000000000000000000000000000..22ad2e0122797248a372734aac0f3a16a1356530 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_c_opts_json.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs-examples/c/json_protocol_example.c:main}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/03-insert-data/_c_opts_telnet.mdx b/docs-cn/04-develop/03-insert-data/_c_opts_telnet.mdx new file mode 100644 index 0000000000000000000000000000000000000000..508d7bc98a149f49766bcd0a474ffe226cbe30bb --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_c_opts_telnet.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs-examples/c/telnet_line_example.c:main}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/03-insert-data/_c_sql.mdx b/docs-cn/04-develop/03-insert-data/_c_sql.mdx new file mode 100644 index 0000000000000000000000000000000000000000..f4153fd2c427677a338d0c377663d0335f2672f0 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_c_sql.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs-examples/c/insert_example.c}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/03-insert-data/_c_stmt.mdx b/docs-cn/04-develop/03-insert-data/_c_stmt.mdx new file mode 100644 index 0000000000000000000000000000000000000000..01ac067519a2bd224e313fd70169722ba5f20413 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_c_stmt.mdx @@ -0,0 +1,6 @@ +```c title=一次绑定一行 +{{#include docs-examples/c/stmt_example.c}} +``` +```c title=一次绑定多行 72:117 +{{#include docs-examples/c/multi_bind_example.c}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/03-insert-data/_category_.yml b/docs-cn/04-develop/03-insert-data/_category_.yml new file mode 100644 index 0000000000000000000000000000000000000000..1255095431329864a351b41b639ceb7d1cb40531 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_category_.yml @@ -0,0 +1,5 @@ +label: 写入数据 +link: + type: generated-index + slug: /insert-data/ + description: "TDengine 支持多种写入协议,包括 SQL,InfluxDB Line 协议, OpentsDB Telnet 协议,OpentsDB JSON 格式协议。数据可以单条插入,也可以批量插入,可以插入一个数据采集点的数据,也可以同时插入多个数据采集点的数据。同时,TDengine 支持多线程插入,支持时间乱序数据插入,也支持历史数据插入。InfluxDB Line 协议、OpentsDB Telnet 协议和 OpentsDB JSON 格式协议是 TDengine 支持的三种无模式写入协议。使用无模式方式写入无需提前创建超级表和子表,并且引擎能自适用数据对表结构做调整。" diff --git a/docs-cn/04-develop/03-insert-data/_cs_line.mdx b/docs-cn/04-develop/03-insert-data/_cs_line.mdx new file mode 100644 index 0000000000000000000000000000000000000000..9c275ee3d7c7a1e52fbb34dbae922004543ee3ce --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_cs_line.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs-examples/csharp/InfluxDBLineExample.cs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_cs_opts_json.mdx b/docs-cn/04-develop/03-insert-data/_cs_opts_json.mdx new file mode 100644 index 0000000000000000000000000000000000000000..3d538b8506b298241faecd8098f89571359135c9 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_cs_opts_json.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs-examples/csharp/OptsJsonExample.cs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_cs_opts_telnet.mdx b/docs-cn/04-develop/03-insert-data/_cs_opts_telnet.mdx new file mode 100644 index 0000000000000000000000000000000000000000..c53bf3d7233115351e5af03b7d9e6318aa4a0da6 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_cs_opts_telnet.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs-examples/csharp/OptsTelnetExample.cs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_cs_sql.mdx b/docs-cn/04-develop/03-insert-data/_cs_sql.mdx new file mode 100644 index 0000000000000000000000000000000000000000..c7688bfbe77a1135424d829fe9b29fbb1bc93ae2 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_cs_sql.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs-examples/csharp/SQLInsertExample.cs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_cs_stmt.mdx b/docs-cn/04-develop/03-insert-data/_cs_stmt.mdx new file mode 100644 index 0000000000000000000000000000000000000000..97c3b910ffeb9e0c88fc143a02014115e819c147 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_cs_stmt.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs-examples/csharp/StmtInsertExample.cs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_go_line.mdx b/docs-cn/04-develop/03-insert-data/_go_line.mdx new file mode 100644 index 0000000000000000000000000000000000000000..cd225945b70e28bef2ca7fdaf0d9be0ad7ffc18c --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_go_line.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs-examples/go/insert/line/main.go}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_go_opts_json.mdx b/docs-cn/04-develop/03-insert-data/_go_opts_json.mdx new file mode 100644 index 0000000000000000000000000000000000000000..0c0d3e5b6330e046988cdd02234285ec67e92f01 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_go_opts_json.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs-examples/go/insert/json/main.go}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_go_opts_telnet.mdx b/docs-cn/04-develop/03-insert-data/_go_opts_telnet.mdx new file mode 100644 index 0000000000000000000000000000000000000000..d5ca40cc146e62412476289853e8e2739e0e9e4b --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_go_opts_telnet.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs-examples/go/insert/telnet/main.go}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_go_sql.mdx b/docs-cn/04-develop/03-insert-data/_go_sql.mdx new file mode 100644 index 0000000000000000000000000000000000000000..613a65add1741eb763a4b24e65d180d05f7d670f --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_go_sql.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs-examples/go/insert/sql/main.go}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_go_stmt.mdx b/docs-cn/04-develop/03-insert-data/_go_stmt.mdx new file mode 100644 index 0000000000000000000000000000000000000000..7bb6792d6df5b250850bd0a0021ecceba994aa09 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_go_stmt.mdx @@ -0,0 +1,8 @@ +```go +{{#include docs-examples/go/insert/stmt/main.go}} +``` + +:::tip +driver-go 的模块 `github.com/taosdata/driver-go/v2/wrapper` 是 C 接口的底层封装。使用这个模块也可以实现参数绑定写入。 + +::: diff --git a/docs-cn/04-develop/03-insert-data/_java_line.mdx b/docs-cn/04-develop/03-insert-data/_java_line.mdx new file mode 100644 index 0000000000000000000000000000000000000000..2e59a5d4701b2a2ab04ec5711845dc5c80067a1e --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_java_line.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_java_opts_json.mdx b/docs-cn/04-develop/03-insert-data/_java_opts_json.mdx new file mode 100644 index 0000000000000000000000000000000000000000..826a1a07d9405cb193849f9d21e5444f68517914 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_java_opts_json.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_java_opts_telnet.mdx b/docs-cn/04-develop/03-insert-data/_java_opts_telnet.mdx new file mode 100644 index 0000000000000000000000000000000000000000..954dcc1a482a150dea0b190e1e0593adbfbde796 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_java_opts_telnet.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_java_sql.mdx b/docs-cn/04-develop/03-insert-data/_java_sql.mdx new file mode 100644 index 0000000000000000000000000000000000000000..a863378defe43b1f22c1f98087a34f053a7d6619 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_java_sql.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java:insert}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/03-insert-data/_java_stmt.mdx b/docs-cn/04-develop/03-insert-data/_java_stmt.mdx new file mode 100644 index 0000000000000000000000000000000000000000..54443e535fa84bdf8dc9161ed4ad00f50b26266c --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_java_stmt.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_js_line.mdx b/docs-cn/04-develop/03-insert-data/_js_line.mdx new file mode 100644 index 0000000000000000000000000000000000000000..172c9bc17b8cff8b2620720b235a9c8e69bd4197 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_js_line.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs-examples/node/nativeexample/influxdb_line_example.js}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_js_opts_json.mdx b/docs-cn/04-develop/03-insert-data/_js_opts_json.mdx new file mode 100644 index 0000000000000000000000000000000000000000..20ac9ec91e8dc6675828b16d7da0acb09afd3b5f --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_js_opts_json.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs-examples/node/nativeexample/opentsdb_json_example.js}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_js_opts_telnet.mdx b/docs-cn/04-develop/03-insert-data/_js_opts_telnet.mdx new file mode 100644 index 0000000000000000000000000000000000000000..c3c8c40bd642f4f443de88e3db006ad50724d514 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_js_opts_telnet.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs-examples/node/nativeexample/opentsdb_telnet_example.js}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_js_sql.mdx b/docs-cn/04-develop/03-insert-data/_js_sql.mdx new file mode 100644 index 0000000000000000000000000000000000000000..f5e17c76892a57a94192a95451b508b1c176c984 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_js_sql.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs-examples/node/nativeexample/insert_example.js}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_js_stmt.mdx b/docs-cn/04-develop/03-insert-data/_js_stmt.mdx new file mode 100644 index 0000000000000000000000000000000000000000..17a6c9785c7dc1e3c3fa6a59982913f1f139f9c2 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_js_stmt.mdx @@ -0,0 +1,12 @@ +```js title=一次绑定一行 +{{#include docs-examples/node/nativeexample/param_bind_example.js}} +``` + +```js title=一次绑定多行 +{{#include docs-examples/node/nativeexample/multi_bind_example.js:insertData}} +``` + +:::info +一次绑定一行效率不如一次绑定多行,但支持非 INSERT 语句。一次绑定多行效率更高,但仅支持 INSERT 语句。 + +::: diff --git a/docs-cn/04-develop/03-insert-data/_py_line.mdx b/docs-cn/04-develop/03-insert-data/_py_line.mdx new file mode 100644 index 0000000000000000000000000000000000000000..d3bb1ebb3403b53fa43bfc9d5d1a0de9764d7583 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_py_line.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs-examples/python/line_protocol_example.py}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_py_opts_json.mdx b/docs-cn/04-develop/03-insert-data/_py_opts_json.mdx new file mode 100644 index 0000000000000000000000000000000000000000..cfbfe13ccfdb4f3f34b77300812863fdf70d0f59 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_py_opts_json.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs-examples/python/json_protocol_example.py}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_py_opts_telnet.mdx b/docs-cn/04-develop/03-insert-data/_py_opts_telnet.mdx new file mode 100644 index 0000000000000000000000000000000000000000..14bc65a7a3da815abadf7f25c8deffeac666c8d7 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_py_opts_telnet.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs-examples/python/telnet_line_protocol_example.py}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_py_sql.mdx b/docs-cn/04-develop/03-insert-data/_py_sql.mdx new file mode 100644 index 0000000000000000000000000000000000000000..c0e15b8ec115b9244d50a47c9eafec04bcfdd70c --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_py_sql.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs-examples/python/native_insert_example.py}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_py_stmt.mdx b/docs-cn/04-develop/03-insert-data/_py_stmt.mdx new file mode 100644 index 0000000000000000000000000000000000000000..8241ea86bc64ac64d842dc0a6cddc0eae0399503 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_py_stmt.mdx @@ -0,0 +1,12 @@ +```py title=一次绑定一行 +{{#include docs-examples/python/bind_param_example.py}} +``` + +```py title=一次绑定多行 +{{#include docs-examples/python/multi_bind_example.py:bind_batch}} +``` + +:::info +一次绑定一行效率不如一次绑定多行,但支持非 INSERT 语句。一次绑定多行效率更高,但仅支持 INSERT 语句。 + +::: \ No newline at end of file diff --git a/docs-cn/04-develop/03-insert-data/_rust_line.mdx b/docs-cn/04-develop/03-insert-data/_rust_line.mdx new file mode 100644 index 0000000000000000000000000000000000000000..696ddb7b854751b8dee01047066f97f74212933f --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_rust_line.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_rust_opts_json.mdx b/docs-cn/04-develop/03-insert-data/_rust_opts_json.mdx new file mode 100644 index 0000000000000000000000000000000000000000..97d9052dacd1894cc7548a59951ecfaad9caee87 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_rust_opts_json.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_rust_opts_telnet.mdx b/docs-cn/04-develop/03-insert-data/_rust_opts_telnet.mdx new file mode 100644 index 0000000000000000000000000000000000000000..14021f43d8aff30c35dc30c5d278d4e51f375024 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_rust_opts_telnet.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_rust_sql.mdx b/docs-cn/04-develop/03-insert-data/_rust_sql.mdx new file mode 100644 index 0000000000000000000000000000000000000000..8e8013e4ad734efcc262ea2f750b82210a538e49 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_rust_sql.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs-examples/rust/restexample/examples/insert_example.rs}} +``` diff --git a/docs-cn/04-develop/03-insert-data/_rust_stmt.mdx b/docs-cn/04-develop/03-insert-data/_rust_stmt.mdx new file mode 100644 index 0000000000000000000000000000000000000000..590a7a0e717426ed0235331c49dfc578bc55b2f7 --- /dev/null +++ b/docs-cn/04-develop/03-insert-data/_rust_stmt.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs-examples/rust/nativeexample/examples/stmt_example.rs}} +``` diff --git a/docs-cn/04-develop/04-query-data/_c.mdx b/docs-cn/04-develop/04-query-data/_c.mdx new file mode 100644 index 0000000000000000000000000000000000000000..76c9067e2f6af19465cf7c52c3e9b48bb868547d --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_c.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs-examples/c/query_example.c}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/04-query-data/_c_async.mdx b/docs-cn/04-develop/04-query-data/_c_async.mdx new file mode 100644 index 0000000000000000000000000000000000000000..09f3d3b3ff6d6644f837642ef41db459ba7c5753 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_c_async.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs-examples/c/async_query_example.c:demo}} +``` \ No newline at end of file diff --git a/docs-cn/07-query-data/_category_.yml b/docs-cn/04-develop/04-query-data/_category_.yml similarity index 100% rename from docs-cn/07-query-data/_category_.yml rename to docs-cn/04-develop/04-query-data/_category_.yml diff --git a/docs-cn/04-develop/04-query-data/_cs.mdx b/docs-cn/04-develop/04-query-data/_cs.mdx new file mode 100644 index 0000000000000000000000000000000000000000..2ab52feb564eff0fe251bc9900ea2539171e5dba --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_cs.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs-examples/csharp/QueryExample.cs}} +``` diff --git a/docs-cn/04-develop/04-query-data/_cs_async.mdx b/docs-cn/04-develop/04-query-data/_cs_async.mdx new file mode 100644 index 0000000000000000000000000000000000000000..f868994b303e62016b5e2f9304275135855c6ae5 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_cs_async.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs-examples/csharp/AsyncQueryExample.cs}} +``` diff --git a/docs-cn/04-develop/04-query-data/_go.mdx b/docs-cn/04-develop/04-query-data/_go.mdx new file mode 100644 index 0000000000000000000000000000000000000000..417c12315c06517e2f3de850ac9a379b7714b519 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_go.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs-examples/go/query/sync/main.go}} +``` diff --git a/docs-cn/04-develop/04-query-data/_go_async.mdx b/docs-cn/04-develop/04-query-data/_go_async.mdx new file mode 100644 index 0000000000000000000000000000000000000000..72fff411b980a0dcbdcaf4274722c63e0351db6f --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_go_async.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs-examples/go/query/async/main.go}} +``` diff --git a/docs-cn/04-develop/04-query-data/_java.mdx b/docs-cn/04-develop/04-query-data/_java.mdx new file mode 100644 index 0000000000000000000000000000000000000000..519b9266144486231caf3ee593e973d438941ee4 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_java.mdx @@ -0,0 +1,3 @@ +```java +{{#include docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java}} +``` diff --git a/docs-cn/04-develop/04-query-data/_js.mdx b/docs-cn/04-develop/04-query-data/_js.mdx new file mode 100644 index 0000000000000000000000000000000000000000..c5e4c4f3fc20d3940a2bc6e13e6a5dea8a15ff13 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_js.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs-examples/node/nativeexample/query_example.js}} +``` diff --git a/docs-cn/04-develop/04-query-data/_js_async.mdx b/docs-cn/04-develop/04-query-data/_js_async.mdx new file mode 100644 index 0000000000000000000000000000000000000000..c65d54ed12f6c4bbeb333e0de0ba9ca4638bff84 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_js_async.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs-examples/node/nativeexample/async_query_example.js}} +``` diff --git a/docs-cn/04-develop/04-query-data/_py.mdx b/docs-cn/04-develop/04-query-data/_py.mdx new file mode 100644 index 0000000000000000000000000000000000000000..6a1bacdd3ef91e9484c1d87d6a22de8b128e2144 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_py.mdx @@ -0,0 +1,11 @@ +通过迭代逐行获取查询结果。 + +```py +{{#include docs-examples/python/query_example.py:iter}} +``` + +一次获取所有查询结果,并把每一行转化为一个字典返回。 + +```py +{{#include docs-examples/python/query_example.py:fetch_all}} +``` diff --git a/docs-cn/04-develop/04-query-data/_py_async.mdx b/docs-cn/04-develop/04-query-data/_py_async.mdx new file mode 100644 index 0000000000000000000000000000000000000000..2399a50df645804788036e17bf223c53482d4eaf --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_py_async.mdx @@ -0,0 +1,8 @@ +```py +{{#include docs-examples/python/async_query_example.py}} +``` + +:::note +这个示例程序,目前在 Windows 系统上还无法运行 + +::: diff --git a/docs-cn/04-develop/04-query-data/_rust.mdx b/docs-cn/04-develop/04-query-data/_rust.mdx new file mode 100644 index 0000000000000000000000000000000000000000..742d70fd025ff44b573eedf78441c9d73defad45 --- /dev/null +++ b/docs-cn/04-develop/04-query-data/_rust.mdx @@ -0,0 +1,3 @@ +```rust +{{#include docs-examples/rust/restexample/examples/query_example.rs}} +``` diff --git a/docs-cn/07-query-data/07-query-data.mdx b/docs-cn/04-develop/04-query-data/index.mdx similarity index 59% rename from docs-cn/07-query-data/07-query-data.mdx rename to docs-cn/04-develop/04-query-data/index.mdx index f253b13b0d0b86b9e23a1c419e490fb85b081f85..829280fba5b1e5a956b79699df39f9bb2c1cb177 100644 --- a/docs-cn/07-query-data/07-query-data.mdx +++ b/docs-cn/04-develop/04-query-data/index.mdx @@ -1,11 +1,26 @@ -# 查询数据 +--- +slug: /query-data +title: 查询数据 +description: "主要查询功能,通过连接器执行同步查询和异步查询" +--- import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; +import JavaQuery from "./_java.mdx"; +import PyQuery from "./_py.mdx"; +import GoQuery from "./_go.mdx"; +import RustQuery from "./_rust.mdx"; +import NodeQuery from "./_js.mdx"; +import CsQuery from "./_cs.mdx"; +import CQuery from "./_c.mdx"; +import PyAsync from "./_py_async.mdx"; +import NodeAsync from "./_js_async.mdx"; +import CsAsync from "./_cs_async.mdx"; +import CAsync from "./_c_async.mdx"; ## 主要查询功能 -TDengine 采用 SQL 作为查询语言。应用程序可以通过 C/C++, Java, Go, C#, Python, Node.js 连接器发送 SQL 语句,用户可以通过 TDengine 提供的命令行(Command Line Interface, CLI)工具 TAOS Shell 手动执行 SQL 即席查询(Ad-Hoc Query)。TDengine 支持如下查询功能: +TDengine 采用 SQL 作为查询语言。应用程序可以通过 REST API 或连接器发送 SQL 语句,用户还可以通过 TDengine 命令行工具 taos 手动执行 SQL 即席查询(Ad-Hoc Query)。TDengine 支持如下查询功能: - 单列、多列数据查询 - 标签和数值的多种过滤条件:>, <, =, <\>, like 等 @@ -14,9 +29,9 @@ TDengine 采用 SQL 作为查询语言。应用程序可以通过 C/C++, Java, G - 时间戳对齐的连接查询(Join Query: 隐式连接)操作 - 多种聚合/计算函数: count, max, min, avg, sum, twa, stddev, leastsquares, top, bottom, first, last, percentile, apercentile, last_row, spread, diff 等 -例如:在 TAOS Shell 中,从表 d1001 中查询出 voltage > 215 的记录,按时间降序排列,仅仅输出 2 条。 +例如:在命令行工具 taos 中,从表 d1001 中查询出 voltage > 215 的记录,按时间降序排列,仅仅输出 2 条。 -```mysql +```sql taos> select * from d1001 where voltage > 215 order by ts desc limit 2; ts | current | voltage | phase | ====================================================================================== @@ -27,13 +42,15 @@ Query OK, 2 row(s) in set (0.001100s) 为满足物联网场景的需求,TDengine 支持几个特殊的函数,比如 twa(时间加权平均),spread (最大值与最小值的差),last_row(最后一条记录)等,更多与物联网场景相关的函数将添加进来。TDengine 还支持连续查询。 -具体的查询语法请看 [TAOS SQL 的数据查询](https://www.taosdata.com/cn/documentation/taos-sql#select) 章节。 +具体的查询语法请看 [TAOS SQL 的数据查询](/taos-sql/select) 章节。 ## 多表聚合查询 物联网场景中,往往同一个类型的数据采集点有多个。TDengine 采用超级表(STable)的概念来描述某一个类型的数据采集点,一张普通的表来描述一个具体的数据采集点。同时 TDengine 使用标签来描述数据采集点的静态属性,一个具体的数据采集点有具体的标签值。通过指定标签的过滤条件,TDengine 提供了一高效的方法将超级表(某一类型的数据采集点)所属的子表进行聚合查询。对普通表的聚合函数以及绝大部分操作都适用于超级表,语法完全一样。 -**示例 1**:在 TAOS Shell,查找北京所有智能电表采集的电压平均值,并按照 location 分组 +### 示例一 + +在 TAOS Shell,查找北京所有智能电表采集的电压平均值,并按照 location 分组。 ``` taos> SELECT AVG(voltage) FROM meters GROUP BY location; @@ -44,7 +61,9 @@ taos> SELECT AVG(voltage) FROM meters GROUP BY location; Query OK, 2 row(s) in set (0.002136s) ``` -**示例 2**:在 TAOS shell, 查找 groupId 为 2 的所有智能电表过去 24 小时的记录条数,电流的最大值 +### 示例二 + +在 TAOS shell, 查找 groupId 为 2 的所有智能电表过去 24 小时的记录条数,电流的最大值。 ``` taos> SELECT count(*), max(current) FROM meters where groupId = 2 and ts > now - 24h; @@ -54,7 +73,7 @@ taos> SELECT count(*), max(current) FROM meters where groupId = 2 and ts > now - Query OK, 1 row(s) in set (0.002136s) ``` -TDengine 仅容许对属于同一个超级表的表之间进行聚合查询,不同超级表之间的聚合查询不支持。在 [TAOS SQL 的数据查询](https://www.taosdata.com/cn/documentation/taos-sql#select) 一章,查询类操作都会注明是否支持超级表。 +TDengine 仅容许对属于同一个超级表的表之间进行聚合查询,不同超级表之间的聚合查询不支持。在 [TAOS SQL 的数据查询](/taos-sql/select) 一章,查询类操作都会注明是否支持超级表。 ## 降采样查询、插值 @@ -97,31 +116,63 @@ taos> SELECT SUM(current) FROM meters INTERVAL(1s, 500a); Query OK, 5 row(s) in set (0.001521s) ``` -物联网场景里,每个数据采集点采集数据的时间是难同步的,但很多分析算法(比如 FFT)需要把采集的数据严格按照时间等间隔的对齐,在很多系统里,需要应用自己写程序来处理,但使用 TDengine 的降采样操作就轻松解决。如果一个时间间隔里,没有采集的数据,TDengine 还提供插值计算的功能。 +物联网场景里,每个数据采集点采集数据的时间是难同步的,但很多分析算法(比如 FFT)需要把采集的数据严格按照时间等间隔的对齐,在很多系统里,需要应用自己写程序来处理,但使用 TDengine 的降采样操作就轻松解决。 -语法规则细节请见 [TAOS SQL 的时间维度聚合](https://www.taosdata.com/cn/documentation/taos-sql#aggregation) 章节。 +如果一个时间间隔里,没有采集的数据,TDengine 还提供插值计算的功能。 -## 示例代码 +语法规则细节请见 [TAOS SQL 的按时间窗口切分聚合](/taos-sql/interval) 章节。 -### 同步查询 +## 示例代码 - - - - - - - - +### 查询数据 + +在 [SQL 写入](/develop/insert-data/sql-writing) 一章,我们创建了 power 数据库,并向 meters 表写入了一些数据,以下示例代码展示如何查询这个表的数据。 + + + + + + + + + + + + + + + + + + + + + + + +:::note + +1. 无论是使用 REST 连接还是原生连接的连接器,以上示例代码都能正常工作。 +2. 唯一需要注意的是:由于 RESTful 接口无状态, 不能使用 `use db` 语句来切换数据库。 + +::: + ### 异步查询 - - - - - - - +除同步查询 API 之外,TDengine 还提供性能更高的异步调用 API 处理数据插入、查询操作。在软硬件环境相同的情况下,异步 API 处理数据插入的速度比同步 API 快 2-4 倍。异步 API 采用非阻塞式的调用方式,在系统真正完成某个具体数据库操作前,立即返回。调用的线程可以去处理其他工作,从而可以提升整个应用的性能。异步 API 在网络延迟严重的情况下,优点尤为突出。 + +需要注意的是,只有使用原生连接的连接器,才能使用异步查询功能。 + + + + + + + + + + + diff --git a/docs-cn/08-advance-feature/01-continuous-query.mdx b/docs-cn/04-develop/05-continuous-query.mdx similarity index 86% rename from docs-cn/08-advance-feature/01-continuous-query.mdx rename to docs-cn/04-develop/05-continuous-query.mdx index 2764bd408440bcb22cbb4136dbc8ea9753c7b7bc..2fd1b3cc755188f513fe511541a84efa3558d3ea 100644 --- a/docs-cn/08-advance-feature/01-continuous-query.mdx +++ b/docs-cn/04-develop/05-continuous-query.mdx @@ -1,12 +1,9 @@ --- sidebar_label: 连续查询 +description: "连续查询是一个按照预设频率自动执行的查询功能,提供按照时间窗口的聚合查询能力,是一种简化的时间驱动流式计算。" +title: "连续查询(Continuous Query)" --- -# 连续查询(Continuous Query) - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - 连续查询是 TDengine 定期自动执行的查询,采用滑动窗口的方式进行计算,是一种简化的时间驱动的流式计算。针对库中的表或超级表,TDengine 可提供定期自动执行的连续查询,用户可让 TDengine 推送查询的结果,也可以将结果再写回到 TDengine 中。每次执行的查询是一个时间窗口,时间窗口随着时间流动向前滑动。在定义连续查询的时候需要指定时间窗口(time window, 参数 interval)大小和每次前向增量时间(forward sliding times, 参数 sliding)。 TDengine 的连续查询采用时间驱动模式,可以直接使用 TAOS SQL 进行定义,不需要额外的操作。使用连续查询,可以方便快捷地按照时间窗口生成结果,从而对原始采集数据进行降采样(down sampling)。用户通过 TAOS SQL 定义连续查询以后,TDengine 自动在最后的一个完整的时间周期末端拉起查询,并将计算获得的结果推送给用户或者写回 TDengine。 @@ -15,7 +12,21 @@ TDengine 提供的连续查询与普通流计算中的时间窗口计算具有 - 不同于流计算的实时反馈计算结果,连续查询只在时间窗口关闭以后才开始计算。例如时间周期是 1 天,那么当天的结果只会在 23:59:59 以后才会生成。 - 如果有历史记录写入到已经计算完成的时间区间,连续查询并不会重新进行计算,也不会重新将结果推送给用户。对于写回 TDengine 的模式,也不会更新已经存在的计算结果。 -- 使用连续查询推送结果的模式,服务端并不缓存客户端计算状态,也不提供 Exactly-Once 的语意保证。如果用户的应用端崩溃,再次拉起的连续查询将只会从再次拉起的时间开始重新计算最近的一个完整的时间窗口。如果使用写回模式,TDengine 可确保数据写回的有效性和连续性。 +- 使用连续查询推送结果的模式,服务端并不缓存客户端计算状态,也不提供 Exactly-Once 的语义保证。如果用户的应用端崩溃,再次拉起的连续查询将只会从再次拉起的时间开始重新计算最近的一个完整的时间窗口。如果使用写回模式,TDengine 可确保数据写回的有效性和连续性。 + +## 连续查询语法 + +```sql +[CREATE TABLE AS] SELECT select_expr [, select_expr ...] + FROM {tb_name_list} + [WHERE where_condition] + [INTERVAL(interval_val [, interval_offset]) [SLIDING sliding_val]] + +``` + +INTERVAL: 连续查询作用的时间窗口 + +SLIDING: 连续查询的时间窗口向前滑动的时间间隔 ## 使用连续查询 @@ -28,7 +39,7 @@ create table D1002 using meters tags ("Beijing.Haidian", 2); ... ``` -我们已经知道,可以通过下面这条 SQL 语句以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压。 +可以通过下面这条 SQL 语句以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压。 ```sql select avg(voltage) from meters interval(1m) sliding(30s); @@ -48,7 +59,7 @@ create table avg_vol as select avg(voltage) from meters interval(1m) sliding(30s 会自动创建一个名为 `avg_vol` 的新表,然后每隔 30 秒,TDengine 会增量执行 `as` 后面的 SQL 语句,并将查询结果写入这个表中,用户程序后续只要从 `avg_vol` 中查询数据即可。例如: -```mysql +```sql taos> select * from avg_vol; ts | avg_voltage_ | =================================================== @@ -62,7 +73,7 @@ taos> select * from avg_vol; 此外,TDengine 还支持用户指定连续查询的起止时间。如果不输入开始时间,连续查询将从第一条原始数据所在的时间窗口开始;如果没有输入结束时间,连续查询将永久运行;如果用户指定了结束时间,连续查询在系统时间达到指定的时间以后停止运行。比如使用下面的 SQL 创建的连续查询将运行一小时,之后会自动停止。 -```mysql +```sql create table avg_vol as select avg(voltage) from meters where ts > now and ts <= now + 1h interval(1m) sliding(30s); ``` @@ -71,16 +82,3 @@ create table avg_vol as select avg(voltage) from meters where ts > now and ts <= ## 管理连续查询 用户可在控制台中通过 `show streams` 命令来查看系统中全部运行的连续查询,并可以通过 `kill stream` 命令杀掉对应的连续查询。后续版本会提供更细粒度和便捷的连续查询管理命令。 - -## 示例代码 - - - - - - - - - - - \ No newline at end of file diff --git a/docs-cn/08-advance-feature/02-subscribe.mdx b/docs-cn/04-develop/06-subscribe.mdx similarity index 73% rename from docs-cn/08-advance-feature/02-subscribe.mdx rename to docs-cn/04-develop/06-subscribe.mdx index 96123d1a66ddbbc660760fba71ae56267ccab573..d33a60d8de0a4552fa531d5e390c0faae22057fa 100644 --- a/docs-cn/08-advance-feature/02-subscribe.mdx +++ b/docs-cn/04-develop/06-subscribe.mdx @@ -1,15 +1,24 @@ --- -sidebar_position: 2 -sidebar_label: 订阅 +sidebar_label: 数据订阅 +description: "轻量级的数据订阅与推送服务。连续写入到 TDengine 中的时序数据能够被自动推送到订阅客户端。" +title: 数据订阅 --- -# 数据订阅(Publisher/Subscriber) +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import Java from "./_sub_java.mdx"; +import Python from "./_sub_python.mdx"; +import Go from "./_sub_go.mdx"; +import Rust from "./_sub_rust.mdx"; +import Node from "./_sub_node.mdx"; +import CSharp from "./_sub_cs.mdx"; +import CDemo from "./_sub_c.mdx"; -基于数据天然的时间序列特性,TDengine 的数据写入(insert)与消息系统的数据发布(pub)逻辑上一致,均可视为系统中插入一条带时间戳的新记录。同时,TDengine 在内部严格按照数据时间序列单调递增的方式保存数据。本质上来说,TDengine 中里每一张表均可视为一个标准的消息队列。 +基于数据天然的时间序列特性,TDengine 的数据写入(insert)与消息系统的数据发布(pub)逻辑上一致,均可视为系统中插入一条带时间戳的新记录。同时,TDengine 在内部严格按照数据时间序列单调递增的方式保存数据。本质上来说,TDengine 中每一张表均可视为一个标准的消息队列。 TDengine 内嵌支持轻量级的消息订阅与推送服务。使用系统提供的 API,用户可使用普通查询语句订阅数据库中的一张或多张表。订阅的逻辑和操作状态的维护均是由客户端完成,客户端定时轮询服务器是否有新的记录到达,有新的记录到达就会将结果反馈到客户。 -TDengine 的订阅与推送服务的状态是客户端维持,TDengine 服务器并不维持。因此如果应用重启,从哪个时间点开始获取最新数据,由应用决定。 +TDengine 的订阅与推送服务的状态是由客户端维持,TDengine 服务端并不维持。因此如果应用重启,从哪个时间点开始获取最新数据,由应用决定。 TDengine 的 API 中,与订阅相关的主要有以下三个: @@ -19,7 +28,7 @@ taos_consume taos_unsubscribe ``` -这些 API 的文档请见 [C/C++ Connector](https://www.taosdata.com/cn/documentation/connector#c-cpp),下面仍以智能电表场景为例介绍一下它们的具体用法(超级表和子表结构请参考上一节“连续查询”),完整的示例代码可以在 [这里](https://github.com/taosdata/TDengine/blob/master/examples/c/subscribe.c) 找到。 +这些 API 的文档请见 [C/C++ Connector](/reference/connector/cpp),下面仍以智能电表场景为例介绍一下它们的具体用法(超级表和子表结构请参考上一节“连续查询”),完整的示例代码可以在 [这里](https://github.com/taosdata/TDengine/blob/master/examples/c/subscribe.c) 找到。 如果我们希望当某个电表的电流超过一定限制(比如 10A)后能得到通知并进行一些处理, 有两种方法:一是分别对每张子表进行查询,每次查询后记录最后一条数据的时间戳,后续只查询这个时间戳之后的数据: @@ -161,28 +170,26 @@ $ taos 这时,因为电流超过了 10A,您应该可以看到示例程序将它输出到了屏幕上。您可以继续插入一些数据观察示例程序的输出。 -## Java 使用数据订阅功能 +## 示例程序 -订阅功能也提供了 Java 开发接口,相关说明请见 [Java Connector](https://www.taosdata.com/cn/documentation/connector/java#subscribe)。需要注意的是,目前 Java 接口没有提供异步订阅模式,但用户程序可以通过创建 `TimerTask` 等方式达到同样的效果。 - -下面以一个示例程序介绍其具体使用方法。它所完成的功能与前面介绍的 C 语言示例基本相同,也是订阅数据库中所有电流超过 10A 的记录。 +下面以一个示例程序介绍其具体使用方法。示例程序的目的是订阅数据库中所有电流超过 10A 的记录。 ### 准备数据 -```sql -# 创建 power 库 +``` +# create database "power" taos> create database power; -# 切换库 +# use "power" as the database in following operations taos> use power; -# 创建超级表 +# create super table "meters" taos> create table meters(ts timestamp, current float, voltage int, phase int) tags(location binary(64), groupId int); -# 创建表 +# create tabes using the schema defined by super table "meters" taos> create table d1001 using meters tags ("Beijing.Chaoyang", 2); taos> create table d1002 using meters tags ("Beijing.Haidian", 2); -# 插入测试数据 +# insert some rows taos> insert into d1001 values("2020-08-15 12:00:00.000", 12, 220, 1),("2020-08-15 12:10:00.000", 12.3, 220, 2),("2020-08-15 12:20:00.000", 12.2, 220, 1); taos> insert into d1002 values("2020-08-15 12:00:00.000", 9.9, 220, 1),("2020-08-15 12:10:00.000", 10.3, 220, 1),("2020-08-15 12:20:00.000", 11.2, 220, 1); -# 从超级表 meters 查询电流大于 10A 的记录 +# filter out the rows in which current is bigger than 10A taos> select * from meters where current > 10; ts | current | voltage | phase | location | groupid | =========================================================================================================== @@ -193,64 +200,37 @@ taos> select * from meters where current > 10; 2020-08-15 12:20:00.000 | 12.20000 | 220 | 1 | Beijing.Chaoyang | 2 | Query OK, 5 row(s) in set (0.004896s) ``` - -### 示例程序 - -```java -public class SubscribeDemo { - private static final String topic = "topic-meter-current-bg-10"; - private static final String sql = "select * from meters where current > 10"; - - public static void main(String[] args) { - Connection connection = null; - TSDBSubscribe subscribe = null; - - try { - Class.forName("com.taosdata.jdbc.TSDBDriver"); - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - String jdbcUrl = "jdbc:TAOS://127.0.0.1:6030/power?user=root&password=taosdata"; - connection = DriverManager.getConnection(jdbcUrl, properties); - subscribe = ((TSDBConnection) connection).subscribe(topic, sql, true); // 创建订阅 - int count = 0; - while (count < 10) { - TimeUnit.SECONDS.sleep(1); // 等待1秒,避免频繁调用 consume,给服务端造成压力 - TSDBResultSet resultSet = subscribe.consume(); // 消费数据 - if (resultSet == null) { - continue; - } - ResultSetMetaData metaData = resultSet.getMetaData(); - while (resultSet.next()) { - int columnCount = metaData.getColumnCount(); - for (int i = 1; i <= columnCount; i++) { - System.out.print(metaData.getColumnLabel(i) + ": " + resultSet.getString(i) + "\t"); - } - System.out.println(); - count++; - } - } - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - if (null != subscribe) - subscribe.close(true); // 关闭订阅 - if (connection != null) - connection.close(); - } catch (SQLException throwables) { - throwables.printStackTrace(); - } - } - } -} -``` - -运行示例程序,首先,它会消费符合查询条件的所有历史数据: +### 示例代码 + + + + + + {/* + + + + + + + + + + + + + + */} + + + + + +### 运行示例程序 + +示例程序会先消费符合查询条件的所有历史数据: ```bash -# java -jar subscribe.jar - ts: 1597464000000 current: 12.0 voltage: 220 phase: 1 location: Beijing.Chaoyang groupid : 2 ts: 1597464600000 current: 12.3 voltage: 220 phase: 2 location: Beijing.Chaoyang groupid : 2 ts: 1597465200000 current: 12.2 voltage: 220 phase: 1 location: Beijing.Chaoyang groupid : 2 @@ -260,14 +240,14 @@ ts: 1597465200000 current: 11.2 voltage: 220 phase: 1 location: Beijing.Haidian 接着,使用 taos 客户端向表中新增一条数据: -```sql +``` # taos taos> use power; -taos> insert into d1001 values("2020-08-15 12:40:00.000", 12.4, 220, 1); +taos> insert into d1001 values(now, 12.4, 220, 1); ``` 因为这条数据的电流大于 10A,示例程序会将其消费: ``` -ts: 1597466400000 current: 12.4 voltage: 220 phase: 1 location: Beijing.Chaoyang groupid: 2 +ts: 1651146662805 current: 12.4 voltage: 220 phase: 1 location: Beijing.Chaoyang groupid: 2 ``` diff --git a/docs-cn/08-advance-feature/03-cache.md b/docs-cn/04-develop/07-cache.md similarity index 93% rename from docs-cn/08-advance-feature/03-cache.md rename to docs-cn/04-develop/07-cache.md index 7f100a9b50ebbab6fe1225c584ed18142176701c..fd31335310d62d792e5173e38a9aa778ee6c6c60 100644 --- a/docs-cn/08-advance-feature/03-cache.md +++ b/docs-cn/04-develop/07-cache.md @@ -1,9 +1,9 @@ --- sidebar_label: 缓存 +title: 缓存 +description: "提供写驱动的缓存管理机制,将每个表最近写入的一条记录持续保存在缓存中,可以提供高性能的最近状态查询。" --- -# 缓存(Cache) - TDengine 采用时间驱动缓存管理策略(First-In-First-Out,FIFO),又称为写驱动的缓存管理机制。这种策略有别于读驱动的数据缓存模式(Least-Recent-Used,LRU),直接将最近写入的数据保存在系统的缓存中。当缓存达到临界值的时候,将最早的数据批量写入磁盘。一般意义上来说,对于物联网数据的使用,用户最为关心最近产生的数据,即当前状态。TDengine 充分利用了这一特性,将最近到达的(当前状态)数据保存在缓存中。 TDengine 通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,可通过设置合适的配置参数将 TDengine 作为数据缓存来使用,而不需要再部署额外的缓存系统,可有效地简化系统架构,降低运维的成本。需要注意的是,TDengine 重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的 key-value 缓存系统再将之前缓存的数据重新加载到缓存中。 @@ -14,7 +14,7 @@ TDengine 将内存池按块划分进行管理,数据在内存块里是以行 你可以通过函数 last_row() 快速获取一张表或一张超级表的最后一条记录,这样很便于在大屏显示各设备的实时状态或采集值。例如: -```mysql +```sql select last_row(voltage) from meters where location='Beijing.Chaoyang'; ``` diff --git a/docs-cn/04-develop/08-udf.md b/docs-cn/04-develop/08-udf.md new file mode 100644 index 0000000000000000000000000000000000000000..09681650db32200e60c0fdb787d3e455dd339d85 --- /dev/null +++ b/docs-cn/04-develop/08-udf.md @@ -0,0 +1,208 @@ +--- +sidebar_label: 用户定义函数 +title: UDF(用户定义函数) +description: "支持用户编码的聚合函数和标量函数,在查询中嵌入并使用用户定义函数,拓展查询的能力和功能。" +--- + +在有些应用场景中,应用逻辑需要的查询无法直接使用系统内置的函数来表示。利用 UDF 功能,TDengine 可以插入用户编写的处理代码并在查询中使用它们,就能够很方便地解决特殊应用场景中的使用需求。 UDF 通常以数据表中的一列数据做为输入,同时支持以嵌套子查询的结果作为输入。 + +从 2.2.0.0 版本开始,TDengine 支持通过 C/C++ 语言进行 UDF 定义。接下来结合示例讲解 UDF 的使用方法。 + +用户可以通过 UDF 实现两类函数: 标量函数 和 聚合函数。 + +## 用 C/C++ 语言来定义 UDF + +### 标量函数 + +用户可以按照下列函数模板定义自己的标量计算函数 + + `void udfNormalFunc(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, int* numOfOutput, short otype, short obytes, SUdfInit* buf)` + + 其中 udfNormalFunc 是函数名的占位符,以上述模板实现的函数对行数据块进行标量计算,其参数项是固定的,用于按照约束完成与引擎之间的数据交换。 + +- udfNormalFunc 中各参数的具体含义是: + - data:输入数据。 + - itype:输入数据的类型。这里采用的是短整型表示法,与各种数据类型对应的值可以参见 [column_meta 中的列类型说明](/reference/rest-api/)。例如 4 用于表示 INT 型。 + - iBytes:输入数据中每个值会占用的字节数。 + - numOfRows:输入数据的总行数。 + - ts:主键时间戳在输入中的列数据(只读)。 + - dataOutput:输出数据的缓冲区,缓冲区大小为用户指定的输出类型大小 \* numOfRows。 + - interBuf:中间计算结果的缓冲区,大小为用户在创建 UDF 时指定的 BUFSIZE 大小。通常用于计算中间结果与最终结果不一致时使用,由引擎负责分配与释放。 + - tsOutput:主键时间戳在输出时的列数据,如果非空可用于输出结果对应的时间戳。 + - numOfOutput:输出结果的个数(行数)。 + - oType:输出数据的类型。取值含义与 itype 参数一致。 + - oBytes:输出数据中每个值占用的字节数。 + - buf:用于在 UDF 与引擎间的状态控制信息传递块。 + + [add_one.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) 是结构最简单的 UDF 实现,也即上面定义的 udfNormalFunc 函数的一个具体实现。其功能为:对传入的一个数据列(可能因 WHERE 子句进行了筛选)中的每一项,都输出 +1 之后的值,并且要求输入的列数据类型为 INT。 + +### 聚合函数 + +用户可以按照如下函数模板定义自己的聚合函数。 + +`void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf)` + +其中 udfMergeFunc 是函数名的占位符,以上述模板实现的函数用于对计算中间结果进行聚合,只有针对超级表的聚合查询才需要调用该函数。其中各参数的具体含义是: + + - data:udfNormalFunc 的输出数据数组,如果使用了 interBuf 那么 data 就是 interBuf 的数组。 + - numOfRows:data 中数据的行数。 + - dataOutput:输出数据的缓冲区,大小等于一条最终结果的大小。如果此时输出还不是最终结果,可以选择输出到 interBuf 中即 data 中。 + - numOfOutput:输出结果的个数(行数)。 + - buf:用于在 UDF 与引擎间的状态控制信息传递块。 + +[abs_max.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c) 实现的是一个聚合函数,功能是对一组数据按绝对值取最大值。 + +其计算过程为:与所在查询语句相关的数据会被分为多个行数据块,对每个行数据块调用 udfNormalFunc(在本例的实现代码中,实际函数名是 `abs_max`)来生成每个子表的中间结果,再将子表的中间结果调用 udfMergeFunc(本例中,其实际的函数名是 `abs_max_merge`)进行聚合,生成超级表的最终聚合结果或中间结果。聚合查询最后还会通过 udfFinalizeFunc(本例中,其实际的函数名是 `abs_max_finalize`)再把超级表的中间结果处理为最终结果,最终结果只能含 0 或 1 条结果数据。 + +其他典型场景,如协方差的计算,也可通过定义聚合 UDF 的方式实现。 + +### 最终计算 + +用户可以按下面的函数模板实现自己的函数对计算结果进行最终计算,通常用于有 interBuf 使用的场景。 + +`void abs_max_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf)` + +其中 udfFinalizeFunc 是函数名的占位符 ,其中各参数的具体含义是: + - dataOutput:输出数据的缓冲区。 + - interBuf:中间结算结果缓冲区,可作为输入。 + - numOfOutput:输出数据的个数,对聚合函数来说只能是 0 或者 1。 + - buf:用于在 UDF 与引擎间的状态控制信息传递块。 + +## UDF 实现方式的规则总结 + +三类 UDF 函数: udfNormalFunc、udfMergeFunc、udfFinalizeFunc ,其函数名约定使用相同的前缀,此前缀即 udfNormalFunc 的实际函数名,也即 udfNormalFunc 函数不需要在实际函数名后添加后缀;而udfMergeFunc 的函数名要加上后缀 `_merge`、udfFinalizeFunc 的函数名要加上后缀 `_finalize`,这是 UDF 实现规则的一部分,系统会按照这些函数名后缀来调用相应功能。 + +根据 UDF 函数类型的不同,用户所要实现的功能函数也不同: + +- 标量函数:UDF 中需实现 udfNormalFunc。 +- 聚合函数:UDF 中需实现 udfNormalFunc、udfMergeFunc(对超级表查询)、udfFinalizeFunc。 + +:::note +如果对应的函数不需要具体的功能,也需要实现一个空函数。 + +::: + +## 编译 UDF + +用户定义函数的 C 语言源代码无法直接被 TDengine 系统使用,而是需要先编译为 动态链接库,之后才能载入 TDengine 系统。 + +例如,按照上一章节描述的规则准备好了用户定义函数的源代码 add_one.c,以 Linux 为例可以执行如下指令编译得到动态链接库文件: + +```bash +gcc -g -O0 -fPIC -shared add_one.c -o add_one.so +``` + +这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5 及以上版本。 + +## 在系统中管理和使用 UDF + +### 创建 UDF + +用户可以通过 SQL 指令在系统中加载客户端所在主机上的 UDF 函数库(不能通过 RESTful 接口或 HTTP 管理界面来进行这一过程)。一旦创建成功,则当前 TDengine 集群的所有用户都可以在 SQL 指令中使用这些函数。UDF 存储在系统的 MNode 节点上,因此即使重启 TDengine 系统,已经创建的 UDF 也仍然可用。 + +在创建 UDF 时,需要区分标量函数和聚合函数。如果创建时声明了错误的函数类别,则可能导致通过 SQL 指令调用函数时出错。此外, UDF 支持输入与输出类型不一致,用户需要保证输入数据类型与 UDF 程序匹配,UDF 输出数据类型与 OUTPUTTYPE 匹配。 + +- 创建标量函数 +```sql +CREATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) [ BUFSIZE B ]; +``` + + - ids(X):标量函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; + - ids(Y):包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来; + - typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可; + - B:中间计算结果的缓冲区大小,单位是字节,最小 0,最大 512,如果不使用可以不设置。 + + 例如,如下语句可以把 add_one.so 创建为系统中可用的 UDF: + + ```sql + CREATE FUNCTION add_one AS "/home/taos/udf_example/add_one.so" OUTPUTTYPE INT; + ``` + +- 创建聚合函数: +```sql +CREATE AGGREGATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) [ BUFSIZE B ]; +``` + + - ids(X):聚合函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; + - ids(Y):包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来; + - typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可; + - B:中间计算结果的缓冲区大小,单位是字节,最小 0,最大 512,如果不使用可以不设置。 + + 关于中间计算结果的使用,可以参考示例程序[demo.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c) + + 例如,如下语句可以把 demo.so 创建为系统中可用的 UDF: + + ```sql + CREATE AGGREGATE FUNCTION demo AS "/home/taos/udf_example/demo.so" OUTPUTTYPE DOUBLE bufsize 14; + ``` + +### 管理 UDF + +- 删除指定名称的用户定义函数: +``` +DROP FUNCTION ids(X); +``` + +- ids(X):此参数的含义与 CREATE 指令中的 ids(X) 参数一致,也即要删除的函数的名字,例如 +```sql +DROP FUNCTION add_one; +``` +- 显示系统中当前可用的所有 UDF: +```sql +SHOW FUNCTIONS; +``` + +### 调用 UDF + +在 SQL 指令中,可以直接以在系统中创建 UDF 时赋予的函数名来调用用户定义函数。例如: +```sql +SELECT X(c) FROM table/stable; +``` + +表示对名为 c 的数据列调用名为 X 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。 + +## UDF 的一些使用限制 + +在当前版本下,使用 UDF 存在如下这些限制: + +1. 在创建和调用 UDF 时,服务端和客户端都只支持 Linux 操作系统; +2. UDF 不能与系统内建的 SQL 函数混合使用,暂不支持在一条 SQL 语句中使用多个不同名的 UDF ; +3. UDF 只支持以单个数据列作为输入; +4. UDF 只要创建成功,就会被持久化存储到 MNode 节点中; +5. 无法通过 RESTful 接口来创建 UDF; +6. UDF 在 SQL 中定义的函数名,必须与 .so 库文件实现中的接口函数名前缀保持一致,也即必须是 udfNormalFunc 的名称,而且不可与 TDengine 中已有的内建 SQL 函数重名。 + +## 示例代码 + +### 标量函数示例 [add_one](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) + +
+add_one.c + +```c +{{#include tests/script/sh/add_one.c}} +``` + +
+ +### 向量函数示例 [abs_max](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c) + +
+abs_max.c + +```c +{{#include tests/script/sh/abs_max.c}} +``` + +
+ +### 使用中间计算结果示例 [demo](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c) + +
+demo.c + +```c +{{#include tests/script/sh/demo.c}} +``` + +
diff --git a/docs-cn/04-develop/_category_.yml b/docs-cn/04-develop/_category_.yml new file mode 100644 index 0000000000000000000000000000000000000000..509a9405c42939a4819b87669a4c5b244bd29a8b --- /dev/null +++ b/docs-cn/04-develop/_category_.yml @@ -0,0 +1 @@ +label: 开发指南 \ No newline at end of file diff --git a/docs-cn/04-develop/_sub_c.mdx b/docs-cn/04-develop/_sub_c.mdx new file mode 100644 index 0000000000000000000000000000000000000000..95fef0042d0a277f9136e6e6f8c15558487232f9 --- /dev/null +++ b/docs-cn/04-develop/_sub_c.mdx @@ -0,0 +1,3 @@ +```c +{{#include docs-examples/c/subscribe_demo.c}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/_sub_cs.mdx b/docs-cn/04-develop/_sub_cs.mdx new file mode 100644 index 0000000000000000000000000000000000000000..80934aa4d014a076896dce7f41e520f06ffd735d --- /dev/null +++ b/docs-cn/04-develop/_sub_cs.mdx @@ -0,0 +1,3 @@ +```csharp +{{#include docs-examples/csharp/SubscribeDemo.cs}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/_sub_go.mdx b/docs-cn/04-develop/_sub_go.mdx new file mode 100644 index 0000000000000000000000000000000000000000..cd908fc12c3a35f49ca108ee56c3951c5388a95f --- /dev/null +++ b/docs-cn/04-develop/_sub_go.mdx @@ -0,0 +1,3 @@ +```go +{{#include docs-examples/go/sub/main.go}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/_sub_java.mdx b/docs-cn/04-develop/_sub_java.mdx new file mode 100644 index 0000000000000000000000000000000000000000..1ee0cb1a21e35f6760f8680e2ba6dedee92201cd --- /dev/null +++ b/docs-cn/04-develop/_sub_java.mdx @@ -0,0 +1,7 @@ +```java +{{#include docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java}} +``` +:::note +目前 Java 接口没有提供异步订阅模式,但用户程序可以通过创建 `TimerTask` 等方式达到同样的效果。 + +::: \ No newline at end of file diff --git a/docs-cn/04-develop/_sub_node.mdx b/docs-cn/04-develop/_sub_node.mdx new file mode 100644 index 0000000000000000000000000000000000000000..c93ad627ce9a77ca71a014b41d571089e6c1727b --- /dev/null +++ b/docs-cn/04-develop/_sub_node.mdx @@ -0,0 +1,3 @@ +```js +{{#include docs-examples/node/nativeexample/subscribe_demo.js}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/_sub_python.mdx b/docs-cn/04-develop/_sub_python.mdx new file mode 100644 index 0000000000000000000000000000000000000000..b817deeba6e283a3ba16fee0d580d3823c999536 --- /dev/null +++ b/docs-cn/04-develop/_sub_python.mdx @@ -0,0 +1,3 @@ +```py +{{#include docs-examples/python/subscribe_demo.py}} +``` \ No newline at end of file diff --git a/docs-cn/04-develop/_sub_rust.mdx b/docs-cn/04-develop/_sub_rust.mdx new file mode 100644 index 0000000000000000000000000000000000000000..4750cf7a3b871db48c9e5a26b22ab4b8a03f11be --- /dev/null +++ b/docs-cn/04-develop/_sub_rust.mdx @@ -0,0 +1,3 @@ +```rs +{{#include docs-examples/rust/nativeexample/examples/subscribe_demo.rs}} +``` \ No newline at end of file diff --git a/docs-cn/06-insert-data/01-sql-writing.mdx b/docs-cn/06-insert-data/01-sql-writing.mdx deleted file mode 100644 index 6e5605c75cf13b33406ca5457fdc7b537e8b2be6..0000000000000000000000000000000000000000 --- a/docs-cn/06-insert-data/01-sql-writing.mdx +++ /dev/null @@ -1,65 +0,0 @@ -# SQL 写入 - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - -## SQL 写入 - -应用通过 C/C++, Java, Go, C#, Python, Node.js 连接器执行 SQL insert 语句来插入数据,用户还可以通过 TAOS Shell,手动输入 SQL insert 语句插入数据。比如下面这条 insert 就将一条记录写入到表 d1001 中: - -```mysql -INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31); -``` - -TDengine 支持一次写入多条记录,比如下面这条命令就将两条记录写入到表 d1001 中: - -```mysql -INSERT INTO d1001 VALUES (1538548684000, 10.2, 220, 0.23) (1538548696650, 10.3, 218, 0.25); -``` - -TDengine 也支持一次向多个表写入数据,比如下面这条命令就向 d1001 写入两条记录,向 d1002 写入一条记录: - -```mysql -INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, 218, 0.33) d1002 VALUES (1538548696800, 12.3, 221, 0.31); -``` - -详细的 SQL INSERT 语法规则请见 [TAOS SQL 的数据写入](https://www.taosdata.com/cn/documentation/taos-sql#insert) 章节。 - -:::tip - -- 要提高写入效率,需要批量写入。一批写入的记录条数越多,插入效率就越高。但一条记录不能超过 16K,一条 SQL 语句总长度不能超过 1M 。 -- TDengine 支持多线程同时写入,要进一步提高写入速度,一个客户端需要打开 20 个以上的线程同时写。但线程数达到一定数量后,无法再提高,甚至还会下降,因为线程频繁切换,带来额外开销。 -- 对同一张表,如果新插入记录的时间戳已经存在,默认情形下(UPDATE=0)新记录将被直接抛弃,也就是说,在一张表里,时间戳必须是唯一的。如果应用自动生成记录,很有可能生成的时间戳是一样的,这样,成功插入的记录条数会小于应用插入的记录条数。如果在创建数据库时使用了 UPDATE 1 选项,插入相同时间戳的新记录将覆盖原有记录。 -- 写入的数据的时间戳必须大于当前时间减去配置参数 keep 的时间。如果 keep 配置为 3650 天,那么无法写入比 3650 天还早的数据。写入数据的时间戳也不能大于当前时间加配置参数 days。如果 days 为 2,那么无法写入比当前时间还晚 2 天的数据。 - -::: - -## 示例程序 - -### 普通 SQL 写入 - - - - - - - - - - - -### 动态绑定写入 - -(补充介绍) - -### 示例代码 - - - - - - - - - - diff --git a/docs-cn/06-insert-data/02-influxdb-line.mdx b/docs-cn/06-insert-data/02-influxdb-line.mdx deleted file mode 100644 index 9076b5bad488f1dfb40f25542ad7505b5a5c85b9..0000000000000000000000000000000000000000 --- a/docs-cn/06-insert-data/02-influxdb-line.mdx +++ /dev/null @@ -1,7 +0,0 @@ ---- -sidebar_label: InfluxDB Line 协议 ---- - -# InfluxDB Line 协议 - -## 示例代码 diff --git a/docs-cn/06-insert-data/03-opentsdb-telnet.mdx b/docs-cn/06-insert-data/03-opentsdb-telnet.mdx deleted file mode 100644 index 0bb8b33c8e98c1e20653a4b2af6e565d9b6e1d6d..0000000000000000000000000000000000000000 --- a/docs-cn/06-insert-data/03-opentsdb-telnet.mdx +++ /dev/null @@ -1,7 +0,0 @@ ---- -sidebar_label: OpentsDB Telnet 协议 ---- - -# OpentsDB Telnet 协议 - -## 示例代码 \ No newline at end of file diff --git a/docs-cn/06-insert-data/04-opentsdb-json.mdx b/docs-cn/06-insert-data/04-opentsdb-json.mdx deleted file mode 100644 index 99c62d56cd504bc6b6a1f1c3a0179eebdc24d553..0000000000000000000000000000000000000000 --- a/docs-cn/06-insert-data/04-opentsdb-json.mdx +++ /dev/null @@ -1,7 +0,0 @@ ---- -sidebar_label: OpentsDB JSON 格式协议 ---- - -# OpentsDB JSON 格式协议 - -## 示例代码 diff --git a/docs-cn/06-insert-data/_category_.yml b/docs-cn/06-insert-data/_category_.yml deleted file mode 100644 index 1b37afd70abc99638dd86b02ada3e02f61d1c526..0000000000000000000000000000000000000000 --- a/docs-cn/06-insert-data/_category_.yml +++ /dev/null @@ -1,15 +0,0 @@ -label: 写入数据 -link: - type: generated-index - description: "TDengine 支持多种接口写入数据,包括 SQL,Prometheus,Telegraf,collectd,StatsD,EMQ MQTT Broker,HiveMQ Broker,CSV 文件等,后续还将提供 Kafka,OPC 等接口。数据可以单条插入,也可以批量插入,可以插入一个数据采集点的数据,也可以同时插入多个数据采集点的数据。支持多线程插入,支持时间乱序数据插入,也支持历史数据插入。" - keywords: - [ - SQL, - Prometheus, - Telegraf, - collectd, - StatsD, - EMQ MQTT Broker, - HiveMQ Broker, - CSV, - ] diff --git a/docs-cn/08-advance-feature/04-udf.md b/docs-cn/08-advance-feature/04-udf.md deleted file mode 100644 index 2cc88d8963e9eb57e908ed3f062fe287301b1d30..0000000000000000000000000000000000000000 --- a/docs-cn/08-advance-feature/04-udf.md +++ /dev/null @@ -1,412 +0,0 @@ ---- -sidebar_label: UDF ---- - -# UDF(用户定义函数) - -在有些应用场景中,应用逻辑需要的查询无法直接使用系统内置的函数来表示。利用 UDF 功能,TDengine 可以插入用户编写的处理代码并在查询中使用它们,就能够很方便地解决特殊应用场景中的使用需求。 UDF 通常以数据表中的一列数据做为输入,同时支持以嵌套子查询的结果作为输入。 - -从 2.2.0.0 版本开始,TDengine 支持通过 C/C++ 语言进行 UDF 定义。接下来结合示例讲解 UDF 的使用方法。 - -## 用 C/C++ 语言来定义 UDF - -TDengine 提供 3 个 UDF 的源代码示例,分别为: - -- [add_one.c](#add_one.c) -- [abs_max.c](#abs_max.c) -- [demo.c](#demo.c) - -### 标量函数 - -[add_one.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) 是结构最简单的 UDF 实现。其功能为:对传入的一个数据列(可能因 WHERE 子句进行了筛选)中的每一项,都输出 +1 之后的值,并且要求输入的列数据类型为 INT。 - -这一具体的处理逻辑在函数 `void add_one(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, int* numOfOutput, short otype, short obytes, SUdfInit* buf)` 中定义。这类用于实现 UDF 的基础计算逻辑的函数,我们称为 udfNormalFunc,也就是对行数据块的标量计算函数。需要注意的是,udfNormalFunc 的参数项是固定的,用于按照约束完成与引擎之间的数据交换。 - -- udfNormalFunc 中各参数的具体含义是: - - data:输入数据。 - - itype:输入数据的类型。这里采用的是短整型表示法,与各种数据类型对应的值可以参见 [column_meta 中的列类型说明](https://www.taosdata.com/cn/documentation/connector#column_meta)。例如 4 用于表示 INT 型。 - - iBytes:输入数据中每个值会占用的字节数。 - - numOfRows:输入数据的总行数。 - - ts:主键时间戳在输入中的列数据(只读)。 - - dataOutput:输出数据的缓冲区,缓冲区大小为用户指定的输出类型大小 \* numOfRows。 - - interBuf:中间计算结果的缓冲区,大小为用户在创建 UDF 时指定的 BUFSIZE 大小。通常用于计算中间结果与最终结果不一致时使用,由引擎负责分配与释放。 - - tsOutput:主键时间戳在输出时的列数据,如果非空可用于输出结果对应的时间戳。 - - numOfOutput:输出结果的个数(行数)。 - - oType:输出数据的类型。取值含义与 itype 参数一致。 - - oBytes:输出数据中每个值占用的字节数。 - - buf:用于在 UDF 与引擎间的状态控制信息传递块。 - -### 聚合函数 - -[abs_max.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/abs_max.c) 实现的是一个聚合函数,功能是对一组数据按绝对值取最大值。 - -其计算过程为:与所在查询语句相关的数据会被分为多个行数据块,对每个行数据块调用 udfNormalFunc(在本例的实现代码中,实际函数名是 `abs_max`)来生成每个子表的中间结果,再将子表的中间结果调用 udfMergeFunc(本例中,其实际的函数名是 `abs_max_merge`)进行聚合,生成超级表的最终聚合结果或中间结果。聚合查询最后还会通过 udfFinalizeFunc(本例中,其实际的函数名是 `abs_max_finalize`)再把超级表的中间结果处理为最终结果,最终结果只能含 0 或 1 条结果数据。 - -值得注意的是,udfNormalFunc、udfMergeFunc、udfFinalizeFunc 之间,函数名约定使用相同的前缀,此前缀即 udfNormalFunc 的实际函数名。udfMergeFunc 的函数名后缀 `_merge`、udfFinalizeFunc 的函数名后缀 `_finalize`,是 UDF 实现规则的一部分,系统会按照这些函数名后缀来调用相应功能。 - -- udfMergeFunc 用于对计算中间结果进行聚合,只有针对超级表的聚合查询才需要调用该函数。本例中 udfMergeFunc 对应的实现函数为 `void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf)`,其中各参数的具体含义是: - - - data:udfNormalFunc 的输出数据数组,如果使用了 interBuf 那么 data 就是 interBuf 的数组。 - - numOfRows:data 中数据的行数。 - - dataOutput:输出数据的缓冲区,大小等于一条最终结果的大小。如果此时输出还不是最终结果,可以选择输出到 interBuf 中即 data 中。 - - numOfOutput:输出结果的个数(行数)。 - - buf:用于在 UDF 与引擎间的状态控制信息传递块。 - -- udfFinalizeFunc 用于对计算结果进行最终计算,通常用于有 interBuf 使用的场景。本例中 udfFinalizeFunc 对应的实现函数为 `void abs_max_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf)`,其中各参数的具体含义是: - - dataOutput:输出数据的缓冲区。 - - interBuf:中间结算结果缓冲区,可作为输入。 - - numOfOutput:输出数据的个数,对聚合函数来说只能是 0 或者 1。 - - buf:用于在 UDF 与引擎间的状态控制信息传递块。 - -其他典型场景,如协方差的计算,即可通过定义聚合 UDF 的方式实现。 - -### 其他 UDF 函数 - -用户 UDF 程序除了需要实现上面几个函数外,还有两个用于初始化和释放 UDF 与引擎间的状态控制信息传递块的函数。具体来说,也即对应 udfInitFunc 和 udfDestroyFunc。其函数名命名规则同样是采取以 udfNormalFunc 的实际函数名为前缀,以 `_init` 和 `_destroy` 为后缀。系统会在初始化和资源释放时调用对应名称的函数。 - -- udfInitFunc 用于初始化状态控制信息传递块。上例中 udfInitFunc 对应的实现函数为 `int abs_max_init(SUdfInit* buf)`,其中各参数的具体含义是: - - - buf:用于在 UDF 与引擎间的状态控制信息传递块。 - -- udfDestroyFunc 用于释放状态控制信息传递块。上例中 udfDestroyFunc 对应的实现函数为 `void abs_max_destroy(SUdfInit* buf)`,其中各参数的具体含义是: - - buf:用于在 UDF 与引擎间的状态控制信息传递块。 - -目前该功能暂时没有实际意义,待后续扩展使用。 - -### UDF 实现方式的规则总结 - -根据 UDF 函数类型的不同,用户所要实现的功能函数也不同: - -- 标量函数:UDF 中需实现 udfNormalFunc。 -- 聚合函数:UDF 中需实现 udfNormalFunc、udfMergeFunc(对超级表查询)、udfFinalizeFunc。 - -需要注意的是,如果对应的函数不需要具体的功能,也需要实现一个空函数。 - -## 编译 UDF - -用户定义函数的 C 语言源代码无法直接被 TDengine 系统使用,而是需要先编译为 .so 链接库,之后才能载入 TDengine 系统。 - -例如,按照上一章节描述的规则准备好了用户定义函数的源代码 add_one.c,那么可以执行如下指令编译得到动态链接库文件: - -```bash -gcc -g -O0 -fPIC -shared add_one.c -o add_one.so -``` - -这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5 及以上版本。 - -## 在系统中管理和使用 UDF - -### 创建 UDF - -用户可以通过 SQL 指令在系统中加载客户端所在主机上的 UDF 函数库(不能通过 RESTful 接口或 HTTP 管理界面来进行这一过程)。一旦创建成功,则当前 TDengine 集群的所有用户都可以在 SQL 指令中使用这些函数。UDF 存储在系统的 MNode 节点上,因此即使重启 TDengine 系统,已经创建的 UDF 也仍然可用。 - -在创建 UDF 时,需要区分标量函数和聚合函数。如果创建时声明了错误的函数类别,则可能导致通过 SQL 指令调用函数时出错。此外, UDF 支持输入与输出类型不一致,用户需要保证输入数据类型与 UDF 程序匹配,UDF 输出数据类型与 OUTPUTTYPE 匹配。 - -- 创建标量函数:`CREATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) [ BUFSIZE B ];` - - - ids(X):标量函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; - - ids(Y):包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来; - - typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可; - - B:中间计算结果的缓冲区大小,单位是字节,最小 0,最大 512,如果不使用可以不设置。 - - 例如,如下语句可以把 add_one.so 创建为系统中可用的 UDF: - - ```sql - CREATE FUNCTION add_one AS "/home/taos/udf_example/add_one.so" OUTPUTTYPE INT; - ``` - -- 创建聚合函数:`CREATE AGGREGATE FUNCTION ids(X) AS ids(Y) OUTPUTTYPE typename(Z) [ BUFSIZE B ];` - - - ids(X):聚合函数未来在 SQL 指令中被调用时的函数名,必须与函数实现中 udfNormalFunc 的实际名称一致; - - ids(Y):包含 UDF 函数实现的动态链接库的库文件绝对路径(指的是库文件在当前客户端所在主机上的保存路径,通常是指向一个 .so 文件),这个路径需要用英文单引号或英文双引号括起来; - - typename(Z):此函数计算结果的数据类型,与上文中 udfNormalFunc 的 itype 参数不同,这里不是使用数字表示法,而是直接写类型名称即可; - - B:中间计算结果的缓冲区大小,单位是字节,最小 0,最大 512,如果不使用可以不设置。 - - 关于中间计算结果的使用,可以参考示例程序[demo.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c) - - 例如,如下语句可以把 demo.so 创建为系统中可用的 UDF: - - ```sql - CREATE AGGREGATE FUNCTION demo AS "/home/taos/udf_example/demo.so" OUTPUTTYPE DOUBLE bufsize 14; - ``` - -### 管理 UDF - -- 删除指定名称的用户定义函数:`DROP FUNCTION ids(X);` - - ids(X):此参数的含义与 CREATE 指令中的 ids(X) 参数一致,也即要删除的函数的名字,例如 `DROP FUNCTION add_one;`。 -- 显示系统中当前可用的所有 UDF:`SHOW FUNCTIONS;` - -### 调用 UDF - -在 SQL 指令中,可以直接以在系统中创建 UDF 时赋予的函数名来调用用户定义函数。例如: - -```sql -SELECT X(c) FROM table/stable; -``` - -表示对名为 c 的数据列调用名为 X 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。 - -## UDF 的一些使用限制 - -在当前版本下,使用 UDF 存在如下这些限制: - -1. 在创建和调用 UDF 时,服务端和客户端都只支持 Linux 操作系统; -2. UDF 不能与系统内建的 SQL 函数混合使用,暂不支持在一条 SQL 语句中使用多个不同名的 UDF ; -3. UDF 只支持以单个数据列作为输入; -4. UDF 只要创建成功,就会被持久化存储到 MNode 节点中; -5. 无法通过 RESTful 接口来创建 UDF; -6. UDF 在 SQL 中定义的函数名,必须与 .so 库文件实现中的接口函数名前缀保持一致,也即必须是 udfNormalFunc 的名称,而且不可与 TDengine 中已有的内建 SQL 函数重名。 - -## 代码附件 - -### [add_one.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/add_one.c) - -```c -#include -#include -#include - -typedef struct SUdfInit{ - int maybe_null; /* 1 if function can return NULL */ - int decimals; /* for real functions */ - long long length; /* For string functions */ - char *ptr; /* free pointer for function data */ - int const_item; /* 0 if result is independent of arguments */ -} SUdfInit; - -void add_one(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBUf, char* tsOutput, - int* numOfOutput, short otype, short obytes, SUdfInit* buf) { - int i; - int r = 0; - // printf("add_one input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf); - if (itype == 4) { - for(i=0;i -#include -#include -#include - -typedef struct SUdfInit{ - int maybe_null; /* 1 if function can return NULL */ - int decimals; /* for real functions */ - int64_t length; /* For string functions */ - char *ptr; /* free pointer for function data */ - int const_item; /* 0 if result is independent of arguments */ -} SUdfInit; - - -#define TSDB_DATA_INT_NULL 0x80000000L -#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L - -void abs_max(char* data, short itype, short ibytes, int numOfRows, int64_t* ts, char* dataOutput, char* interBuf, char* tsOutput, - int* numOfOutput, short otype, short obytes, SUdfInit* buf) { - int i; - int64_t r = 0; - // printf("abs_max input data:%p, type:%d, rows:%d, ts:%p, %" PRId64 ", dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf); - if (itype == 5) { - r=*(int64_t *)dataOutput; - *numOfOutput=0; - - for(i=0;i r) { - r = v; - } - } - - *(int64_t *)dataOutput=r; - - // printf("abs_max out, dataoutput:%" PRId64", numOfOutput:%d\n", *(int64_t *)dataOutput, *numOfOutput); - }else { - *numOfOutput=0; - } -} - - - -void abs_max_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf) { - int i; - //int64_t r = 0; - // printf("abs_max_finalize dataoutput:%p:%d, numOfOutput:%d, buf:%p\n", dataOutput, *dataOutput, *numOfOutput, buf); - // *numOfOutput=1; - // printf("abs_max finalize, dataoutput:%" PRId64", numOfOutput:%d\n", *(int64_t *)dataOutput, *numOfOutput); -} - -void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) { - int64_t r = 0; - - if (numOfRows > 0) { - r = *((int64_t *)data); - } - // printf("abs_max_merge numOfRows:%d, dataoutput:%p, buf:%p\n", numOfRows, dataOutput, buf); - for (int i = 1; i < numOfRows; ++i) { - // printf("abs_max_merge %d - %" PRId64"\n", i, *((int64_t *)data + i)); - if (*((int64_t*)data + i) > r) { - r= *((int64_t*)data + i); - } - } - - *(int64_t*)dataOutput=r; - if (numOfRows > 0) { - *numOfOutput=1; - } else { - *numOfOutput=0; - } - - // printf("abs_max_merge, dataoutput:%" PRId64", numOfOutput:%d\n", *(int64_t *)dataOutput, *numOfOutput); -} - - -int abs_max_init(SUdfInit* buf) { - // printf("abs_max init\n"); - return 0; -} - - -void abs_max_destroy(SUdfInit* buf) { - // printf("abs_max destroy\n"); -} -``` - -### [demo.c](https://github.com/taosdata/TDengine/blob/develop/tests/script/sh/demo.c) - -```c -#include -#include -#include - -typedef struct SUdfInit{ - int maybe_null; /* 1 if function can return NULL */ - int decimals; /* for real functions */ - long long length; /* For string functions */ - char *ptr; /* free pointer for function data */ - int const_item; /* 0 if result is independent of arguments */ -} SUdfInit; - -typedef struct SDemo{ - double sum; - int num; - short otype; -}SDemo; - -#define FLOAT_NULL 0x7FF00000 // it is an NAN -#define DOUBLE_NULL 0x7FFFFF0000000000L // it is an NAN - - -void demo(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, - int* numOfOutput, short otype, short obytes, SUdfInit* buf) { - int i; - double r = 0; - SDemo *p = (SDemo *)interBuf; - SDemo *q = (SDemo *)dataOutput; - printf("demo input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, interBUf:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, interBuf, tsOutput, numOfOutput, buf); - - for(i=0;isum += r*r; - } - - p->otype = otype; - p->num += numOfRows; - - q->sum = p->sum; - q->num = p->num; - q->otype = p->otype; - - *numOfOutput=1; - - printf("demo out, sum:%f, num:%d, numOfOutput:%d\n", p->sum, p->num, *numOfOutput); -} - - -void demo_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) { - int i; - SDemo *p = (SDemo *)data; - SDemo res = {0}; - printf("demo_merge input data:%p, rows:%d, dataoutput:%p, numOfOutput:%p, buf:%p\n", data, numOfRows, dataOutput, numOfOutput, buf); - - for(i=0;isum * p->sum; - res.num += p->num; - p++; - } - - p->sum = res.sum; - p->num = res.num; - - *numOfOutput=1; - - printf("demo out, sum:%f, num:%d, numOfOutput:%d\n", p->sum, p->num, *numOfOutput); -} - - - -void demo_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf) { - SDemo *p = (SDemo *)interBuf; - printf("demo_finalize interbuf:%p, numOfOutput:%p, buf:%p, sum:%f, num:%d\n", interBuf, numOfOutput, buf, p->sum, p->num); - if (p->otype == 6) { - if (p->num != 30000) { - *(unsigned int *)dataOutput = FLOAT_NULL; - } else { - *(float *)dataOutput = (float)(p->sum / p->num); - } - printf("finalize values:%f\n", *(float *)dataOutput); - } else if (p->otype == 7) { - if (p->num != 30000) { - *(unsigned long long *)dataOutput = DOUBLE_NULL; - } else { - *(double *)dataOutput = (double)(p->sum / p->num); - } - printf("finalize values:%f\n", *(double *)dataOutput); - } - - *numOfOutput=1; - - printf("demo finalize, numOfOutput:%d\n", *numOfOutput); -} - - -int demo_init(SUdfInit* buf) { - printf("demo init\n"); - return 0; -} - - -void demo_destroy(SUdfInit* buf) { - printf("demo destroy\n"); -} -``` diff --git a/docs-cn/08-advance-feature/08-advance-feature.md b/docs-cn/08-advance-feature/08-advance-feature.md deleted file mode 100644 index 4de393203389c0df473d471c3d934aa640d06b49..0000000000000000000000000000000000000000 --- a/docs-cn/08-advance-feature/08-advance-feature.md +++ /dev/null @@ -1,19 +0,0 @@ -# 高级功能 - -本章介绍以下TDengine中的高级功能。 - -## 连续查询 - -连续查询是一个按照预设频率自动执行的查询功能,提供按照时间窗口的聚合查询能力,是一种简化的时间驱动流式计算。 - -## 订阅 - -轻量级的数据订阅与推送服务。连续写入到TDengine中时序数据均能够推动到订阅客户端。 - -## 缓存 - -提供写驱动的缓存管理机制,将每个表最近的一条写入记录数据持续保存在缓存中,可以提供给高性能的最近状态查询。 - -## 用户定义函数 - -支持用户编码的聚合函数和标量函数,在查询中嵌入并使用用户定义函数,拓展查询的能力和功能。 diff --git a/docs-cn/08-advance-feature/_05-stream.md b/docs-cn/08-advance-feature/_05-stream.md deleted file mode 100644 index 30a9dbdf6888c2981e076c950350bfe1c6769f15..0000000000000000000000000000000000000000 --- a/docs-cn/08-advance-feature/_05-stream.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -sidebar_label: 流计算 ---- - -# 流计算 diff --git a/docs-cn/08-advance-feature/_category_.yml b/docs-cn/08-advance-feature/_category_.yml deleted file mode 100644 index 29235a943efebff0bd732fad8654f138c2b24bc9..0000000000000000000000000000000000000000 --- a/docs-cn/08-advance-feature/_category_.yml +++ /dev/null @@ -1 +0,0 @@ -label: 高级功能 \ No newline at end of file diff --git a/docs-cn/09-third-party/02-prometheus.md b/docs-cn/09-third-party/02-prometheus.md deleted file mode 100644 index 605fe817fe2dde219dea2448f8c8e45fa8a50183..0000000000000000000000000000000000000000 --- a/docs-cn/09-third-party/02-prometheus.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -sidebar_label: Prometheus ---- - -# Prometheus 写入 - -remote_read 和 remote_write 是 Prometheus 数据读写分离的集群方案。 -只需要将 remote_read 和 remote_write url 指向 taosAdapter 对应的 url 同时设置 Basic 验证即可使用。 - -- remote_read url : `http://host_to_taosAdapter:port(default 6041)/prometheus/v1/remote_read/:db` -- remote_write url : `http://host_to_taosAdapter:port(default 6041)/prometheus/v1/remote_write/:db` - -Basic 验证: - -- username: TDengine 连接用户名 -- password: TDengine 连接密码 - -示例 prometheus.yml 如下: - -```yaml -remote_write: - - url: "http://localhost:6041/prometheus/v1/remote_write/prometheus_data" - basic_auth: - username: root - password: taosdata - -remote_read: - - url: "http://localhost:6041/prometheus/v1/remote_read/prometheus_data" - basic_auth: - username: root - password: taosdata - remote_timeout: 10s - read_recent: true -``` diff --git a/docs-cn/09-third-party/03-telegraf.md b/docs-cn/09-third-party/03-telegraf.md deleted file mode 100644 index 191193b426995fb7e3036605f52ddef963da0d55..0000000000000000000000000000000000000000 --- a/docs-cn/09-third-party/03-telegraf.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -sidebar_label: Telegraf ---- - -# Telegraf 写入 - -安装 Telegraf 请参考[官方文档](https://portal.influxdata.com/downloads/)。 - -TDengine 新版本(2.3.0.0+)包含一个 taosAdapter 独立程序,负责接收包括 Telegraf 的多种应用的数据写入。 - -配置方法,在 /etc/telegraf/telegraf.conf 增加如下文字,其中 database name 请填写希望在 TDengine 保存 Telegraf 数据的数据库名,TDengine server/cluster host、username 和 password 填写 TDengine 实际值: - -``` -[[outputs.http]] - url = "http://:6041/influxdb/v1/write?db=" - method = "POST" - timeout = "5s" - username = "" - password = "" - data_format = "influx" - influx_max_line_bytes = 250 -``` - -然后重启 telegraf: - -``` -sudo systemctl start telegraf -``` - -即可在 TDengine 中查询 metrics 数据库中 Telegraf 写入的数据。 - -taosAdapter 相关配置参数请参考 taosadapter --help 命令输出以及相关文档。 diff --git a/docs-cn/09-third-party/05-collectd.md b/docs-cn/09-third-party/05-collectd.md deleted file mode 100644 index c94dd8cb977c0a01d67839467b04e414e33eaf3d..0000000000000000000000000000000000000000 --- a/docs-cn/09-third-party/05-collectd.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -sidebar_label: collectd ---- - -# collectd 写入 - -安装 collectd,请参考[官方文档](https://collectd.org/download.shtml)。 - -TDengine 新版本(2.3.0.0+)包含一个 taosAdapter 独立程序,负责接收包括 collectd 的多种应用的数据写入。 - -在 /etc/collectd/collectd.conf 文件中增加如下内容,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: - -``` -LoadPlugin network - - Server "" "" - -``` - -重启 collectd - -``` -sudo systemctl start collectd -``` - -taosAdapter 相关配置参数请参考 taosadapter --help 命令输出以及相关文档。 diff --git a/docs-cn/09-third-party/06-statsd.md b/docs-cn/09-third-party/06-statsd.md deleted file mode 100644 index b1bf4b06e4a52258df0a2aa3ed5a0a4c7872abb5..0000000000000000000000000000000000000000 --- a/docs-cn/09-third-party/06-statsd.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -sidebar_label: StatsD ---- - -# StatsD 直接写入 - -安装 StatsD -请参考[官方文档](https://github.com/statsd/statsd)。 - -TDengine 新版本(2.3.0.0+)包含一个 taosAdapter 独立程序,负责接收包括 StatsD 的多种应用的数据写入。 - -在 config.js 文件中增加如下内容后启动 StatsD,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: - -``` -backends 部分添加 "./backends/repeater" -repeater 部分添加 { host:'', port: } -``` - -示例配置文件: - -``` -{ -port: 8125 -, backends: ["./backends/repeater"] -, repeater: [{ host: '127.0.0.1', port: 6044}] -} -``` - -taosAdapter 相关配置参数请参考 taosadapter --help 命令输出以及相关文档。 - -icinga2 可以收集监控和性能数据并写入 OpenTSDB,taosAdapter 可以支持接收 icinga2 的数据并写入到 TDengine 中。 diff --git a/docs-cn/09-third-party/07-icinga2.md b/docs-cn/09-third-party/07-icinga2.md deleted file mode 100644 index d83e4fcd309ba2ce54bb0a8a8754bdd2ca19968d..0000000000000000000000000000000000000000 --- a/docs-cn/09-third-party/07-icinga2.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -sidebar_label: icinga2 ---- - -# icinga2 写入 - -- 参考链接 `https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer` 使能 opentsdb-writer -- 使能 taosAdapter 配置项 opentsdb_telnet.enable -- 修改配置文件 /etc/icinga2/features-enabled/opentsdb.conf - -``` -object OpenTsdbWriter "opentsdb" { - host = "host to taosAdapter" - port = 6048 -} -``` - -taosAdapter 相关配置参数请参考 taosadapter --help 命令输出以及相关文档。 \ No newline at end of file diff --git a/docs-cn/09-third-party/08-tcollector.md b/docs-cn/09-third-party/08-tcollector.md deleted file mode 100644 index 70ae0762ee3e1d39876569d4169b26afe1038a34..0000000000000000000000000000000000000000 --- a/docs-cn/09-third-party/08-tcollector.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -sidebar_label: TCollector ---- - -# TCollector 写入 - -TCollector 是一个在客户侧收集本地收集器并发送数据到 OpenTSDB 的进程,taosAdaapter 可以支持接收 TCollector 的数据并写入到 TDengine 中。 - -使能 taosAdapter 配置项 opentsdb_telnet.enable -修改 TCollector 配置文件,修改 OpenTSDB 宿主机地址为 taosAdapter 被部署的地址,并修改端口号为 taosAdapter 使用的端口(默认 6049)。 - -taosAdapter 相关配置参数请参考 taosadapter --help 命令输出以及相关文档。 diff --git a/docs-cn/09-third-party/09-third-party.md b/docs-cn/09-third-party/09-third-party.md deleted file mode 100644 index 6c57defe891c056f42da0607e1a6791fa2ff2e21..0000000000000000000000000000000000000000 --- a/docs-cn/09-third-party/09-third-party.md +++ /dev/null @@ -1,3 +0,0 @@ -# 第三方工具 - -TDengine 通过对标准 SQL 命令、常用数据库连接器标准(例如 JDBC)、ORM 以及其他流行时序数据库写入协议(例如 InfluxDB Line Protocol、OpenTSDB JSON、OpenTSDB Telnet 等)的支持可以使 TDengine 非常容易和第三方工具共同使用。 diff --git a/docs-cn/09-third-party/_category_.yml b/docs-cn/09-third-party/_category_.yml deleted file mode 100644 index 95aee1e75b1165dcb963a376a86cc58b3917e054..0000000000000000000000000000000000000000 --- a/docs-cn/09-third-party/_category_.yml +++ /dev/null @@ -1 +0,0 @@ -label: 第三方工具 diff --git a/docs-cn/10-cluster/01-deploy.md b/docs-cn/10-cluster/01-deploy.md new file mode 100644 index 0000000000000000000000000000000000000000..cee140c0ec13bc9c8052a599a2147acc1aa15a8d --- /dev/null +++ b/docs-cn/10-cluster/01-deploy.md @@ -0,0 +1,138 @@ +--- +title: 集群部署 +--- + +## 准备工作 + +### 第零步 + +规划集群所有物理节点的 FQDN,将规划好的 FQDN 分别添加到每个物理节点的 /etc/hosts;修改每个物理节点的 /etc/hosts,将所有集群物理节点的 IP 与 FQDN 的对应添加好。【如部署了 DNS,请联系网络管理员在 DNS 上做好相关配置】 + +### 第一步 + +如果搭建集群的物理节点中,存有之前的测试数据、装过 1.X 的版本,或者装过其他版本的 TDengine,请先将其删除,并清空所有数据(如果需要保留原有数据,请联系涛思交付团队进行旧版本升级、数据迁移),具体步骤请参考博客[《TDengine 多种安装包的安装和卸载》](https://www.taosdata.com/blog/2019/08/09/566.html)。 + +:::note +因为 FQDN 的信息会写进文件,如果之前没有配置或者更改 FQDN,且启动了 TDengine。请一定在确保数据无用或者备份的前提下,清理一下之前的数据(rm -rf /var/lib/taos/\*); +::: + +:::note +客户端所在服务器也需要配置,确保它可以正确解析每个节点的 FQDN 配置,不管是通过 DNS 服务,还是修改 hosts 文件。 +::: + +### 第二步 + +建议关闭所有物理节点的防火墙,至少保证端口:6030 - 6042 的 TCP 和 UDP 端口都是开放的。强烈建议先关闭防火墙,集群搭建完毕之后,再来配置端口; + +### 第三步 + +在所有物理节点安装 TDengine,且版本必须是一致的,但不要启动 taosd。安装时,提示输入是否要加入一个已经存在的 TDengine 集群时,第一个物理节点直接回车创建新集群,后续物理节点则输入该集群任何一个在线的物理节点的 FQDN:端口号(默认 6030); + +### 第四步 + +检查所有数据节点,以及应用程序所在物理节点的网络设置: + +每个物理节点上执行命令 `hostname -f`,查看和确认所有节点的 hostname 是不相同的(应用驱动所在节点无需做此项检查); + +每个物理节点上执行 ping host,其中 host 是其他物理节点的 hostname,看能否 ping 通其它物理节点;如果不能 ping 通,需要检查网络设置,或 /etc/hosts 文件(Windows 系统默认路径为 C:\Windows\system32\drivers\etc\hosts),或 DNS 的配置。如果无法 ping 通,是无法组成集群的; + +从应用运行的物理节点,ping taosd 运行的数据节点,如果无法 ping 通,应用是无法连接 taosd 的,请检查应用所在物理节点的 DNS 设置或 hosts 文件; + +每个数据节点的 End Point 就是输出的 hostname 外加端口号,比如 h1.taosdata.com:6030。 + +### 第五步 + +修改 TDengine 的配置文件(所有节点的文件 /etc/taos/taos.cfg 都需要修改)。假设准备启动的第一个数据节点 End Point 为 h1.taosdata.com:6030,其与集群配置相关参数如下: + +```c +// firstEp 是每个数据节点首次启动后连接的第一个数据节点 +firstEp h1.taosdata.com:6030 + +// 必须配置为本数据节点的 FQDN,如果本机只有一个 hostname,可注释掉本项 +fqdn h1.taosdata.com + +// 配置本数据节点的端口号,缺省是 6030 +serverPort 6030 + +// 副本数为偶数的时候,需要配置,请参考《Arbitrator 的使用》的部分 +arbitrator ha.taosdata.com:6042 +``` + +一定要修改的参数是 firstEp 和 fqdn。在每个数据节点,firstEp 需全部配置成一样,但 fqdn 一定要配置成其所在数据节点的值。其他参数可不做任何修改,除非你很清楚为什么要修改。 + +加入到集群中的数据节点 dnode,涉及集群相关的下表 9 项参数必须完全相同,否则不能成功加入到集群中。 + +| **#** | **配置参数名称** | **含义** | +| ----- | ------------------ | ------------------------------------------- | +| 1 | numOfMnodes | 系统中管理节点个数 | +| 2 | mnodeEqualVnodeNum | 一个 mnode 等同于 vnode 消耗的个数 | +| 3 | offlineThreshold | dnode 离线阈值,超过该时间将导致 Dnode 离线 | +| 4 | statusInterval | dnode 向 mnode 报告状态时长 | +| 5 | arbitrator | 系统中裁决器的 End Point | +| 6 | timezone | 时区 | +| 7 | balance | 是否启动负载均衡 | +| 8 | maxTablesPerVnode | 每个 vnode 中能够创建的最大表个数 | +| 9 | maxVgroupsPerDb | 每个 DB 中能够使用的最大 vgroup 个数 | + +:::note +在 2.0.19.0 及更早的版本中,除以上 9 项参数外,dnode 加入集群时,还会要求 locale 和 charset 参数的取值也一致。 + +::: + +## 启动集群 + +### 启动第一个数据节点 + +按照《立即开始》里的步骤,启动第一个数据节点,例如 h1.taosdata.com,然后执行 taos,启动 taos shell,从 shell 里执行命令“SHOW DNODES”,如下所示: + +``` +Welcome to the TDengine shell from Linux, Client Version:2.0.0.0 + + +Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. + +taos> show dnodes; + id | end_point | vnodes | cores | status | role | create_time | +===================================================================================== + 1 | h1.taos.com:6030 | 0 | 2 | ready | any | 2020-07-31 03:49:29.202 | +Query OK, 1 row(s) in set (0.006385s) + +taos> +``` + +上述命令里,可以看到刚启动的数据节点的 End Point 是:h1.taos.com:6030,就是这个新集群的 firstEp。 + +### 启动后续数据节点 + +将后续的数据节点添加到现有集群,具体有以下几步: + +按照《立即开始》一章的方法在每个物理节点启动 taosd;(注意:每个物理节点都需要在 taos.cfg 文件中将 firstEp 参数配置为新集群首个节点的 End Point——在本例中是 h1.taos.com:6030) + +在第一个数据节点,使用 CLI 程序 taos,登录进 TDengine 系统,执行命令: + +```sql +CREATE DNODE "h2.taos.com:6030"; +``` + +将新数据节点的 End Point(准备工作中第四步获知的)添加进集群的 EP 列表。“fqdn:port”需要用双引号引起来,否则出错。请注意将示例的“h2.taos.com:6030” 替换为这个新数据节点的 End Point。 + +然后执行命令 + +```sql +SHOW DNODES; +``` + +查看新节点是否被成功加入。如果该被加入的数据节点处于离线状态,请做两个检查: + +查看该数据节点的 taosd 是否正常工作,如果没有正常运行,需要先检查为什么? +查看该数据节点 taosd 日志文件 taosdlog.0 里前面几行日志(一般在 /var/log/taos 目录),看日志里输出的该数据节点 fqdn 以及端口号是否为刚添加的 End Point。如果不一致,需要将正确的 End Point 添加进去。 +按照上述步骤可以源源不断的将新的数据节点加入到集群。 + +:::tip + +任何已经加入集群在线的数据节点,都可以作为后续待加入节点的 firstEp。 +firstEp 这个参数仅仅在该数据节点首次加入集群时有作用,加入集群后,该数据节点会保存最新的 mnode 的 End Point 列表,不再依赖这个参数。 +接下来,配置文件中的 firstEp 参数就主要在客户端连接的时候使用了,例如 taos shell 如果不加参数,会默认连接由 firstEp 指定的节点。 +两个没有配置 firstEp 参数的数据节点 dnode 启动后,会独立运行起来。这个时候,无法将其中一个数据节点加入到另外一个数据节点,形成集群。无法将两个独立的集群合并成为新的集群。 + +::: diff --git a/docs-cn/10-cluster/01-prerequisites.md b/docs-cn/10-cluster/01-prerequisites.md deleted file mode 100644 index 8f88126c931357005fe010c6beb2a6da27f71d88..0000000000000000000000000000000000000000 --- a/docs-cn/10-cluster/01-prerequisites.md +++ /dev/null @@ -1,74 +0,0 @@ -# 准备工作 -## 第零步 - -规划集群所有物理节点的 FQDN,将规划好的 FQDN 分别添加到每个物理节点的/etc/hostname;修改每个物理节点的/etc/hosts,将所有集群物理节点的 IP 与 FQDN 的对应添加好。【如部署了 DNS,请联系网络管理员在 DNS 上做好相关配置】 - -## 第一步 - -如果搭建集群的物理节点中,存有之前的测试数据、装过 1.X 的版本,或者装过其他版本的 TDengine,请先将其删除,并清空所有数据(如果需要保留原有数据,请联系涛思交付团队进行旧版本升级、数据迁移),具体步骤请参考博客《TDengine 多种安装包的安装和卸载》。 - -:::note -因为 FQDN 的信息会写进文件,如果之前没有配置或者更改 FQDN,且启动了 TDengine。请一定在确保数据无用或者备份的前提下,清理一下之前的数据(rm -rf /var/lib/taos/*); -::: - -:::note -客户端也需要配置,确保它可以正确解析每个节点的 FQDN 配置,不管是通过 DNS 服务,还是修改 hosts 文件。 -::: - - -## 第二步 - -建议关闭所有物理节点的防火墙,至少保证端口:6030 - 6042 的 TCP 和 UDP 端口都是开放的。强烈建议先关闭防火墙,集群搭建完毕之后,再来配置端口; - -## 第三步 - -在所有物理节点安装 TDengine,且版本必须是一致的,但不要启动 taosd。安装时,提示输入是否要加入一个已经存在的 TDengine 集群时,第一个物理节点直接回车创建新集群,后续物理节点则输入该集群任何一个在线的物理节点的 FQDN:端口号(默认 6030); - -## 第四步 - -检查所有数据节点,以及应用程序所在物理节点的网络设置: - -每个物理节点上执行命令hostname -f,查看和确认所有节点的 hostname 是不相同的(应用驱动所在节点无需做此项检查); - -每个物理节点上执行ping host,其中 host 是其他物理节点的 hostname,看能否 ping 通其它物理节点;如果不能 ping 通,需要检查网络设置,或/etc/hosts 文件(Windows 系统默认路径为 C:\Windows\system32\drivers\etc\hosts),或 DNS 的配置。如果无法 ping 通,是无法组成集群的; - -从应用运行的物理节点,ping taosd 运行的数据节点,如果无法 ping 通,应用是无法连接 taosd 的,请检查应用所在物理节点的 DNS 设置或 hosts 文件; - -每个数据节点的 End Point 就是输出的 hostname 外加端口号,比如h1.taosdata.com:6030。 - -## 第五步 - -修改 TDengine 的配置文件(所有节点的文件/etc/taos/taos.cfg 都需要修改)。假设准备启动的第一个数据节点 End Point 为 h1.taosdata.com:6030,其与集群配置相关参数如下: - -``` -// firstEp 是每个数据节点首次启动后连接的第一个数据节点 -firstEp h1.taosdata.com:6030 - -// 必须配置为本数据节点的FQDN,如果本机只有一个hostname, 可注释掉本项 -fqdn h1.taosdata.com - -// 配置本数据节点的端口号,缺省是6030 -serverPort 6030 - -// 副本数为偶数的时候,需要配置,请参考《Arbitrator的使用》的部分 -arbitrator ha.taosdata.com:6042 -``` -一定要修改的参数是 firstEp 和 fqdn。在每个数据节点,firstEp 需全部配置成一样,但 fqdn 一定要配置成其所在数据节点的值。其他参数可不做任何修改,除非你很清楚为什么要修改。 - -加入到集群中的数据节点 dnode,涉及集群相关的下表 9 项参数必须完全相同,否则不能成功加入到集群中。 - -| **#** | **配置参数名称** | **含义** | -| ----- | ------------------ | ------------------------------------------- | -| 1 | numOfMnodes | 系统中管理节点个数 | -| 2 | mnodeEqualVnodeNum | 一个 mnode 等同于 vnode 消耗的个数 | -| 3 | offlineThreshold | dnode 离线阈值,超过该时间将导致 Dnode 离线 | -| 4 | statusInterval | dnode 向 mnode 报告状态时长 | -| 5 | arbitrator | 系统中裁决器的 End Point | -| 6 | timezone | 时区 | -| 7 | balance | 是否启动负载均衡 | -| 8 | maxTablesPerVnode | 每个 vnode 中能够创建的最大表个数 | -| 9 | maxVgroupsPerDb | 每个 DB 中能够使用的最大 vgroup 个数 | - -:::note -在 2.0.19.0 及更早的版本中,除以上 9 项参数外,dnode 加入集群时,还会要求 locale 和 charset 参数的取值也一致。 -::: diff --git a/docs-cn/10-cluster/02-cluster-mgmt.md b/docs-cn/10-cluster/02-cluster-mgmt.md index f00a68aad76b02f8e380479a89f05a6e19223c3f..6ab8ec091b898e8f441d75ef898dc0ff06fce6be 100644 --- a/docs-cn/10-cluster/02-cluster-mgmt.md +++ b/docs-cn/10-cluster/02-cluster-mgmt.md @@ -1,117 +1,216 @@ -# 集群部署 -## 启动第一个数据节点 -按照《立即开始》里的指示,启动第一个数据节点,例如 h1.taosdata.com,然后执行 taos, 启动 taos shell,从 shell 里执行命令"show dnodes;",如下所示: -``` +--- +title: 数据节点管理 +--- -Welcome to the TDengine shell from Linux, Client Version:2.0.0.0 +上面已经介绍如何从零开始搭建集群。集群组建完成后,可以随时查看集群中当前的数据节点的状态,还可以添加新的数据节点进行扩容,删除数据节点,甚至手动进行数据节点之间的负载均衡操作。 +:::note -Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. +以下所有执行命令的操作需要先登陆进 TDengine 系统,必要时请使用 root 权限。 -taos> show dnodes; - id | end_point | vnodes | cores | status | role | create_time | -===================================================================================== - 1 | h1.taos.com:6030 | 0 | 2 | ready | any | 2020-07-31 03:49:29.202 | -Query OK, 1 row(s) in set (0.006385s) +::: + +## 查看数据节点 + +启动 TDengine CLI 程序 taos,然后执行: + +```sql +SHOW DNODES; +``` + +它将列出集群中所有的 dnode,每个 dnode 的 ID,end_point(fqdn:port),状态(ready,offline 等),vnode 数目,还未使用的 vnode 数目等信息。在添加或删除一个数据节点后,可以使用该命令查看。 + +输出如下(具体内容仅供参考,取决于实际的集群配置) -taos> ``` -上述命令里,可以看到这个刚启动的这个数据节点的 End Point 是:h1.taos.com:6030,就是这个新集群的 firstEp。 +taos> show dnodes; + id | end_point | vnodes | cores | status | role | create_time | offline reason | +====================================================================================================================================== + 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | | +Query OK, 1 row(s) in set (0.008298s) +``` -## 启动后续数据节点 -将后续的数据节点添加到现有集群,具体有以下几步: +## 查看虚拟节点组 -按照《立即开始》一章的方法在每个物理节点启动 taosd;(注意:每个物理节点都需要在 taos.cfg 文件中将 firstEp 参数配置为新集群首个节点的 End Point——在本例中是 h1.taos.com:6030) +为充分利用多核技术,并提供 scalability,数据需要分片处理。因此 TDengine 会将一个 DB 的数据切分成多份,存放在多个 vnode 里。这些 vnode 可能分布在多个数据节点 dnode 里,这样就实现了水平扩展。一个 vnode 仅仅属于一个 DB,但一个 DB 可以有多个 vnode。vnode 所在的数据节点是 mnode 根据当前系统资源的情况,自动进行分配的,无需任何人工干预。 -在第一个数据节点,使用 CLI 程序 taos,登录进 TDengine 系统,执行命令: +启动 CLI 程序 taos,然后执行: -```mysql -CREATE DNODE "h2.taos.com:6030"; +```sql +USE SOME_DATABASE; +SHOW VGROUPS; ``` -将新数据节点的 End Point (准备工作中第四步获知的) 添加进集群的 EP 列表。"fqdn:port"需要用双引号引起来,否则出错。请注意将示例的“h2.taos.com:6030" 替换为这个新数据节点的 End Point。 -然后执行命令 -```mysql -SHOW DNODES; +输出如下(具体内容仅供参考,取决于实际的集群配置) + +``` +taos> show dnodes; + id | end_point | vnodes | cores | status | role | create_time | offline reason | +====================================================================================================================================== + 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | | +Query OK, 1 row(s) in set (0.008298s) + +taos> use db; +Database changed. + +taos> show vgroups; + vgId | tables | status | onlines | v1_dnode | v1_status | compacting | +========================================================================================== + 14 | 38000 | ready | 1 | 1 | master | 0 | + 15 | 38000 | ready | 1 | 1 | master | 0 | + 16 | 38000 | ready | 1 | 1 | master | 0 | + 17 | 38000 | ready | 1 | 1 | master | 0 | + 18 | 37001 | ready | 1 | 1 | master | 0 | + 19 | 37000 | ready | 1 | 1 | master | 0 | + 20 | 37000 | ready | 1 | 1 | master | 0 | + 21 | 37000 | ready | 1 | 1 | master | 0 | +Query OK, 8 row(s) in set (0.001154s) ``` -查看新节点是否被成功加入。如果该被加入的数据节点处于离线状态,请做两个检查: -查看该数据节点的 taosd 是否正常工作,如果没有正常运行,需要先检查为什么 -查看该数据节点 taosd 日志文件 taosdlog.0 里前面几行日志(一般在/var/log/taos 目录),看日志里输出的该数据节点 fqdn 以及端口号是否为刚添加的 End Point。如果不一致,需要将正确的 End Point 添加进去。 -按照上述步骤可以源源不断的将新的数据节点加入到集群。 +## 添加数据节点 -:::tip +启动 CLI 程序 taos,然后执行: -任何已经加入集群在线的数据节点,都可以作为后续待加入节点的 firstEp。 -firstEp 这个参数仅仅在该数据节点首次加入集群时有作用,加入集群后,该数据节点会保存最新的 mnode 的 End Point 列表,不再依赖这个参数。 -接下来,配置文件中的 firstEp 参数就主要在客户端连接的时候使用了,例如 taos shell 如果不加参数,会默认连接由 firstEp 指定的节点。 -两个没有配置 firstEp 参数的数据节点 dnode 启动后,会独立运行起来。这个时候,无法将其中一个数据节点加入到另外一个数据节点,形成集群。无法将两个独立的集群合并成为新的集群。 +```sql +CREATE DNODE "fqdn:port"; +``` -::: +将新数据节点的 End Point 添加进集群的 EP 列表。“fqdn:port“需要用双引号引起来,否则出错。一个数据节点对外服务的 fqdn 和 port 可以通过配置文件 taos.cfg 进行配置,缺省是自动获取。【强烈不建议用自动获取方式来配置 FQDN,可能导致生成的数据节点的 End Point 不是所期望的】 -## 数据节点管理 -上面已经介绍如何从零开始搭建集群。集群组建完后,还可以随时添加新的数据节点进行扩容,或删除数据节点,并检查集群当前状态。 +示例如下: +``` +taos> create dnode "localhost:7030"; +Query OK, 0 of 0 row(s) in database (0.008203s) -提示: +taos> show dnodes; + id | end_point | vnodes | cores | status | role | create_time | offline reason | +====================================================================================================================================== + 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | | + 2 | localhost:7030 | 0 | 0 | offline | any | 2022-04-19 08:11:42.158 | status not received | +Query OK, 2 row(s) in set (0.001017s) +``` -以下所有执行命令的操作需要先登陆进 TDengine 系统,必要时请使用 root 权限。 -添加数据节点 -执行 CLI 程序 taos,执行: +在上面的示例中可以看到新创建的 dnode 的状态为 offline,待该 dnode 被启动并连接上配置文件中指定的 firstEp后再次查看,得到如下结果(示例) -```mysql -CREATE DNODE "fqdn:port"; ``` -将新数据节点的 End Point 添加进集群的 EP 列表。"fqdn:port"需要用双引号引起来,否则出错。一个数据节点对外服务的 fqdn 和 port 可以通过配置文件 taos.cfg 进行配置,缺省是自动获取。【强烈不建议用自动获取方式来配置 FQDN,可能导致生成的数据节点的 End Point 不是所期望的】 +taos> show dnodes; + id | end_point | vnodes | cores | status | role | create_time | offline reason | +====================================================================================================================================== + 1 | localhost:6030 | 3 | 8 | ready | any | 2022-04-15 08:27:09.359 | | + 2 | localhost:7030 | 6 | 8 | ready | any | 2022-04-19 08:14:59.165 | | +Query OK, 2 row(s) in set (0.001316s) +``` +从中可以看到两个 dnode 状态都为 ready + ## 删除数据节点 -执行 CLI 程序 taos,执行: -```mysql -DROP DNODE "fqdn:port | dnodeID"; +启动 CLI 程序 taos,然后执行: + +```sql +DROP DNODE "fqdn:port"; +``` +或者 +```sql +DROP DNODE dnodeId; +``` + +通过 “fqdn:port” 或 dnodeID 来指定一个具体的节点都是可以的。其中 fqdn 是被删除的节点的 FQDN,port 是其对外服务器的端口号;dnodeID 可以通过 SHOW DNODES 获得。 + +示例如下: +``` +taos> show dnodes; + id | end_point | vnodes | cores | status | role | create_time | offline reason | +====================================================================================================================================== + 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | | + 2 | localhost:7030 | 0 | 0 | offline | any | 2022-04-19 08:11:42.158 | status not received | +Query OK, 2 row(s) in set (0.001017s) + +taos> drop dnode 2; +Query OK, 0 of 0 row(s) in database (0.000518s) + +taos> show dnodes; + id | end_point | vnodes | cores | status | role | create_time | offline reason | +====================================================================================================================================== + 1 | localhost:6030 | 9 | 8 | ready | any | 2022-04-15 08:27:09.359 | | +Query OK, 1 row(s) in set (0.001137s) ``` -通过"fqdn:port"或"dnodeID"来指定一个具体的节点都是可以的。其中 fqdn 是被删除的节点的 FQDN,port 是其对外服务器的端口号;dnodeID 可以通过 SHOW DNODES 获得。 + +上面的示例中,初次执行 `show dnodes` 列出了两个 dnode, 执行 `drop dnode 2` 删除其中 ID 为 2 的 dnode 之后再次执行 `show dnodes`,可以看到只剩下 ID 为 1 的 dnode 。 :::warning -一个数据节点一旦被 drop 之后,不能重新加入集群。需要将此节点重新部署(清空数据文件夹)。集群在完成 drop dnode 操作之前,会将该 dnode 的数据迁移走。 -请注意 drop dnode 和 停止 taosd 进程是两个不同的概念,不要混淆:因为删除 dnode 之前要执行迁移数据的操作,因此被删除的 dnode 必须保持在线状态。待删除操作结束之后,才能停止 taosd 进程。 +数据节点一旦被 drop 之后,不能重新加入集群。需要将此节点重新部署(清空数据文件夹)。集群在完成 `drop dnode` 操作之前,会将该 dnode 的数据迁移走。 +请注意 `drop dnode` 和 停止 taosd 进程是两个不同的概念,不要混淆:因为删除 dnode 之前要执行迁移数据的操作,因此被删除的 dnode 必须保持在线状态。待删除操作结束之后,才能停止 taosd 进程。 一个数据节点被 drop 之后,其他节点都会感知到这个 dnodeID 的删除操作,任何集群中的节点都不会再接收此 dnodeID 的请求。 dnodeID 是集群自动分配的,不得人工指定。它在生成时是递增的,不会重复。 ::: ## 手动迁移数据节点 + 手动将某个 vnode 迁移到指定的 dnode。 -执行 CLI 程序 taos,执行: +启动 CLI 程序 taos,然后执行: -```mysql +```sql ALTER DNODE BALANCE "VNODE:-DNODE:"; ``` + 其中:source-dnodeId 是源 dnodeId,也就是待迁移的 vnode 所在的 dnodeID;vgId 可以通过 SHOW VGROUPS 获得,列表的第一列;dest-dnodeId 是目标 dnodeId。 -:::warning +首先执行 `show vgroups` 查看 vgroup 的分布情况 +``` +taos> show vgroups; + vgId | tables | status | onlines | v1_dnode | v1_status | compacting | +========================================================================================== + 14 | 38000 | ready | 1 | 3 | master | 0 | + 15 | 38000 | ready | 1 | 3 | master | 0 | + 16 | 38000 | ready | 1 | 3 | master | 0 | + 17 | 38000 | ready | 1 | 3 | master | 0 | + 18 | 37001 | ready | 1 | 3 | master | 0 | + 19 | 37000 | ready | 1 | 1 | master | 0 | + 20 | 37000 | ready | 1 | 1 | master | 0 | + 21 | 37000 | ready | 1 | 1 | master | 0 | +Query OK, 8 row(s) in set (0.001314s) +``` -只有在集群的自动负载均衡选项关闭时(balance 设置为 0),才允许手动迁移。 -只有处于正常工作状态的 vnode 才能被迁移:master/slave,当处于 offline/unsynced/syncing 状态时,是不能迁移的。 -迁移前,务必核实目标 dnode 的资源足够:CPU、内存、硬盘。 +从中可以看到在 dnode 3 中有5个 vgroup,而 dnode 1 有 3 个 vgroup,假定我们想将其中 vgId 为18 的 vgroup 从 dnode 3 迁移到 dnode 1 -::: +``` +taos> alter dnode 3 balance "vnode:18-dnode:1"; -## 查看数据节点 -执行 CLI 程序 taos,执行: +DB error: Balance already enabled (0.00755 +``` -```mysql -SHOW DNODES; +上面的结果表明目前所在数据库已经启动了 balance 选项,所以无法进行手动迁移。 + +停止整个集群,将两个 dnode 的配置文件中的 balance 都设置为 0 (默认为1)之后,重新启动集群,再次执行 ` alter dnode` 和 `show vgroups` 命令如下 +``` +taos> alter dnode 3 balance "vnode:18-dnode:1"; +Query OK, 0 row(s) in set (0.000575s) + +taos> show vgroups; + vgId | tables | status | onlines | v1_dnode | v1_status | v2_dnode | v2_status | compacting | +================================================================================================================= + 14 | 38000 | ready | 1 | 3 | master | 0 | NULL | 0 | + 15 | 38000 | ready | 1 | 3 | master | 0 | NULL | 0 | + 16 | 38000 | ready | 1 | 3 | master | 0 | NULL | 0 | + 17 | 38000 | ready | 1 | 3 | master | 0 | NULL | 0 | + 18 | 37001 | ready | 2 | 1 | slave | 3 | master | 0 | + 19 | 37000 | ready | 1 | 1 | master | 0 | NULL | 0 | + 20 | 37000 | ready | 1 | 1 | master | 0 | NULL | 0 | + 21 | 37000 | ready | 1 | 1 | master | 0 | NULL | 0 | +Query OK, 8 row(s) in set (0.001242s) ``` -它将列出集群中所有的 dnode,每个 dnode 的 ID,end_point(fqdn:port),状态(ready, offline 等),vnode 数目,还未使用的 vnode 数目等信息。在添加或删除一个数据节点后,可以使用该命令查看。 -## 查看虚拟节点组 -为充分利用多核技术,并提供 scalability,数据需要分片处理。因此 TDengine 会将一个 DB 的数据切分成多份,存放在多个 vnode 里。这些 vnode 可能分布在多个数据节点 dnode 里,这样就实现了水平扩展。一个 vnode 仅仅属于一个 DB,但一个 DB 可以有多个 vnode。vnode 的是 mnode 根据当前系统资源的情况,自动进行分配的,无需任何人工干预。 +从上面的输出可以看到 vgId 为 18 的 vnode 被从 dnode 3 迁移到了 dnode 1。 -执行 CLI 程序 taos,执行: +:::warning + +只有在集群的自动负载均衡选项关闭时(balance 设置为 0),才允许手动迁移。 +只有处于正常工作状态的 vnode 才能被迁移:master/slave;当处于 offline/unsynced/syncing 状态时,是不能迁移的。 +迁移前,务必核实目标 dnode 的资源足够:CPU、内存、硬盘。 + +::: - ```mysql -USE SOME_DATABASE; -SHOW VGROUPS; - ``` diff --git a/docs-cn/10-cluster/03-ha-and-lb.md b/docs-cn/10-cluster/03-ha-and-lb.md index b9a15a5efc68d4e4f59c131454163067c309685e..3d15feb11c47fe821fa4689de2665a65ea17cbe9 100644 --- a/docs-cn/10-cluster/03-ha-and-lb.md +++ b/docs-cn/10-cluster/03-ha-and-lb.md @@ -1,36 +1,44 @@ -# 高可用与负载均衡 -## vnode 的高可用性 +--- +title: 高可用与负载均衡 +--- + +## Vnode 的高可用性 + TDengine 通过多副本的机制来提供系统的高可用性,包括 vnode 和 mnode 的高可用性。 -vnode 的副本数是与 DB 关联的,一个集群里可以有多个 DB,根据运营的需求,每个 DB 可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数(缺省为 1)。如果副本数为 1,系统的可靠性无法保证,只要数据所在的节点宕机,就将无法提供服务。集群的节点数必须大于等于副本数,否则创建表时将返回错误"more dnodes are needed"。比如下面的命令将创建副本数为 3 的数据库 demo: +vnode 的副本数是与 DB 关联的,一个集群里可以有多个 DB,根据运营的需求,每个 DB 可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数(缺省为 1)。如果副本数为 1,系统的可靠性无法保证,只要数据所在的节点宕机,就将无法提供服务。集群的节点数必须大于等于副本数,否则创建表时将返回错误“more dnodes are needed”。比如下面的命令将创建副本数为 3 的数据库 demo: -```mysql +```sql CREATE DATABASE demo replica 3; ``` -一个 DB 里的数据会被切片分到多个 vnode group,vnode group 里的 vnode 数目就是 DB 的副本数,同一个 vnode group 里各 vnode 的数据是完全一致的。为保证高可用性,vnode group 里的 vnode 一定要分布在不同的数据节点 dnode 里(实际部署时,需要在不同的物理机上),只要一个 vgroup 里超过半数的 vnode 处于工作状态,这个 vgroup 就能正常的对外服务。 + +一个 DB 里的数据会被切片分到多个 vnode group,vnode group 里的 vnode 数目就是 DB 的副本数,同一个 vnode group 里各 vnode 的数据是完全一致的。为保证高可用性,vnode group 里的 vnode 一定要分布在不同的数据节点 dnode 里(实际部署时,需要在不同的物理机上),只要一个 vnode group 里超过半数的 vnode 处于工作状态,这个 vnode group 就能正常的对外服务。 一个数据节点 dnode 里可能有多个 DB 的数据,因此一个 dnode 离线时,可能会影响到多个 DB。如果一个 vnode group 里的一半或一半以上的 vnode 不工作,那么该 vnode group 就无法对外服务,无法插入或读取数据,这样会影响到它所属的 DB 的一部分表的读写操作。 因为 vnode 的引入,无法简单地给出结论:“集群中过半数据节点 dnode 工作,集群就应该工作”。但是对于简单的情形,很好下结论。比如副本数为 3,只有三个 dnode,那如果仅有一个节点不工作,整个集群还是可以正常工作的,但如果有两个数据节点不工作,那整个集群就无法正常工作了。 ## Mnode 的高可用性 -TDengine 集群是由 mnode (taosd 的一个模块,管理节点) 负责管理的,为保证 mnode 的高可用,可以配置多个 mnode 副本,副本数由系统配置参数 numOfMnodes 决定,有效范围为 1-3。为保证元数据的强一致性,mnode 副本之间是通过同步的方式进行数据复制的。 + +TDengine 集群是由 mnode(taosd 的一个模块,管理节点)负责管理的,为保证 mnode 的高可用,可以配置多个 mnode 副本,副本数由系统配置参数 numOfMnodes 决定,有效范围为 1-3。为保证元数据的强一致性,mnode 副本之间是通过同步的方式进行数据复制的。 一个集群有多个数据节点 dnode,但一个 dnode 至多运行一个 mnode 实例。多个 dnode 情况下,哪个 dnode 可以作为 mnode 呢?这是完全由系统根据整个系统资源情况,自动指定的。用户可通过 CLI 程序 taos,在 TDengine 的 console 里,执行如下命令: -```mysql +```sql SHOW MNODES; ``` -来查看 mnode 列表,该列表将列出 mnode 所处的 dnode 的 End Point 和角色(master, slave, unsynced 或 offline)。当集群中第一个数据节点启动时,该数据节点一定会运行一个 mnode 实例,否则该数据节点 dnode 无法正常工作,因为一个系统是必须有至少一个 mnode 的。如果 numOfMnodes 配置为 2,启动第二个 dnode 时,该 dnode 也将运行一个 mnode 实例。 + +来查看 mnode 列表,该列表将列出 mnode 所处的 dnode 的 End Point 和角色(master,slave,unsynced 或 offline)。当集群中第一个数据节点启动时,该数据节点一定会运行一个 mnode 实例,否则该数据节点 dnode 无法正常工作,因为一个系统是必须有至少一个 mnode 的。如果 numOfMnodes 配置为 2,启动第二个 dnode 时,该 dnode 也将运行一个 mnode 实例。 为保证 mnode 服务的高可用性,numOfMnodes 必须设置为 2 或更大。因为 mnode 保存的元数据必须是强一致的,如果 numOfMnodes 大于 2,复制参数 quorum 自动设为 2,也就是说,至少要保证有两个副本写入数据成功,才通知客户端应用写入成功。 -:::note -一个 TDengine 高可用系统,无论是 vnode 还是 mnode, 都必须配置多个副本。 +:::note +一个 TDengine 高可用系统,无论是 vnode 还是 mnode,都必须配置多个副本。 ::: ## 负载均衡 + 有三种情况,将触发负载均衡,而且都无需人工干预。 当一个新数据节点添加进集群时,系统将自动触发负载均衡,一些节点上的数据将被自动转移到新数据节点上,无需任何人工干预。 @@ -38,24 +46,26 @@ SHOW MNODES; 如果一个数据节点过热(数据量过大),系统将自动进行负载均衡,将该数据节点的一些 vnode 自动挪到其他节点。 当上述三种情况发生时,系统将启动各个数据节点的负载计算,从而决定如何挪动。 -:::tip -负载均衡由参数 balance 控制,它决定是否启动自动负载均衡, 0 表示禁用, 1 表示启用自动负载均衡。** +:::tip +负载均衡由参数 balance 控制,它决定是否启动自动负载均衡,0 表示禁用,1 表示启用自动负载均衡。 ::: ## 数据节点离线处理 + 如果一个数据节点离线,TDengine 集群将自动检测到。有如下两种情况: -该数据节点离线超过一定时间(taos.cfg 里配置参数 offlineThreshold 控制时长),系统将自动把该数据节点删除,产生系统报警信息,触发负载均衡流程。如果该被删除的数据节点重新上线时,它将无法加入集群,需要系统管理员重新将其添加进集群才会开始工作。 +该数据节点离线超过一定时间(taos.cfg 里配置参数 offlineThreshold 控制时长),系统将自动把该数据节点删除,产生系统报警信息,触发负载均衡流程。如果该被删除的数据节点重新上线时,它将无法加入集群,需要系统管理员重新将其添加进集群才会开始工作。 离线后,在 offlineThreshold 的时长内重新上线,系统将自动启动数据恢复流程,等数据完全恢复后,该节点将开始正常工作。 -:::note -如果一个虚拟节点组(包括 mnode 组)里所归属的每个数据节点都处于离线或 unsynced 状态,必须等该虚拟节点组里的所有数据节点都上线、都能交换状态信息后,才能选出 Master,该虚拟节点组才能对外提供服务。比如整个集群有 3 个数据节点,副本数为 3,如果 3 个数据节点都宕机,然后 2 个数据节点重启,是无法工作的,只有等 3 个数据节点都重启成功,才能对外服务。 +:::note +如果一个虚拟节点组(包括 mnode 组)里所归属的每个数据节点都处于离线或 unsynced 状态,必须等该虚拟节点组里的所有数据节点都上线、都能交换状态信息后,才能选出 Master,该虚拟节点组才能对外提供服务。比如整个集群有 3 个数据节点,副本数为 3,如果 3 个数据节点都宕机,然后 2 个数据节点重启,是无法工作的,只有等 3 个数据节点都重启成功,才能对外服务。 ::: ## Arbitrator 的使用 + 如果副本数为偶数,当一个 vnode group 里一半或超过一半的 vnode 不工作时,是无法从中选出 master 的。同理,一半或超过一半的 mnode 不工作时,是无法选出 mnode 的 master 的,因为存在“split brain”问题。 为解决这个问题,TDengine 引入了 Arbitrator 的概念。Arbitrator 模拟一个 vnode 或 mnode 在工作,但只简单的负责网络连接,不处理任何数据插入或访问。只要包含 Arbitrator 在内,超过半数的 vnode 或 mnode 工作,那么该 vnode group 或 mnode 组就可以正常的提供数据插入或查询服务。比如对于副本数为 2 的情形,如果一个节点 A 离线,但另外一个节点 B 正常,而且能连接到 Arbitrator,那么节点 B 就能正常工作。 @@ -69,9 +79,9 @@ Arbitrator 的执行程序名为 tarbitrator。该程序对系统资源几乎没 修改每个 taosd 实例的配置文件,在 taos.cfg 里将参数 arbitrator 设置为 tarbitrator 程序所对应的 End Point。(如果该参数配置了,当副本数为偶数时,系统将自动连接配置的 Arbitrator。如果副本数为奇数,即使配置了 Arbitrator,系统也不会去建立连接。) -在配置文件中配置了的 Arbitrator,会出现在 SHOW DNODES; 指令的返回结果中,对应的 role 列的值会是“arb”。 +在配置文件中配置了的 Arbitrator,会出现在 SHOW DNODES 指令的返回结果中,对应的 role 列的值会是“arb”。 查看集群 Arbitrator 的状态【2.0.14.0 以后支持】 -```mysql +```sql SHOW DNODES; ``` diff --git a/docs-cn/10-cluster/_category_.yml b/docs-cn/10-cluster/_category_.yml index 356872bc73715fb8cb8d307d7fe2bfe6def86c27..df953cb6dd297c91f1e6d1e2d30690afab293982 100644 --- a/docs-cn/10-cluster/_category_.yml +++ b/docs-cn/10-cluster/_category_.yml @@ -1,6 +1,7 @@ label: 集群管理 link: type: generated-index + slug: /cluster/ description: "TDengine支持以集群方式部署,以提升系统的处理能力和高可用性。TDengine集群支持任意数据的多副本从而提升高可用性,并自动实现负载均衡。同时TDengine集群具有很好的横向扩展能力以处理更多的数据采集点和更大的数据量。" keywords: [ diff --git a/docs-cn/11-operation/09-status.md b/docs-cn/11-operation/09-status.md deleted file mode 100644 index 7137be1d16b154a78f579b053d09a7d7c8b2fdda..0000000000000000000000000000000000000000 --- a/docs-cn/11-operation/09-status.md +++ /dev/null @@ -1,39 +0,0 @@ -# 系统连接、任务查询管理 - -系统管理员可以从 CLI 查询系统的连接、正在进行的查询、流式计算,并且可以关闭连接、停止正在进行的查询和流式计算。CLI 里 SQL 语法如下: - -```mysql -SHOW CONNECTIONS; -``` - -显示数据库的连接,其中一列显示 ip:port, 为连接的 IP 地址和端口号。 - -```mysql -KILL CONNECTION ; -``` - -强制关闭数据库连接,其中的 connection-id 是 SHOW CONNECTIONS 中显示的第一列的数字。 - -```mysql -SHOW QUERIES; -``` - -显示数据查询,其中第一列显示的以冒号隔开的两个数字为 query-id,为发起该 query 应用连接的 connection-id 和查询次数。 - -```mysql -KILL QUERY ; -``` - -强制关闭数据查询,其中 query-id 是 SHOW QUERIES 中显示的 connection-id:query-no 字串,如“105:2”,拷贝粘贴即可。 - -```mysql -SHOW STREAMS; -``` - -显示流式计算,其中第一列显示的以冒号隔开的两个数字为 stream-id, 为启动该 stream 应用连接的 connection-id 和发起 stream 的次数。 - -```mysql -KILL STREAM ; -``` - -强制关闭流式计算,其中的中 stream-id 是 SHOW STREAMS 中显示的 connection-id:stream-no 字串,如 103:2,拷贝粘贴即可。 diff --git a/docs-cn/11-operation/_category_.yml b/docs-cn/11-operation/_category_.yml deleted file mode 100644 index 73e81280876190b72a1c05b454c4873f1889091f..0000000000000000000000000000000000000000 --- a/docs-cn/11-operation/_category_.yml +++ /dev/null @@ -1,3 +0,0 @@ -label: 运维指南 -link: - type: generated-index \ No newline at end of file diff --git a/docs-cn/14-reference/01-taos-sql/01-data-type.md b/docs-cn/12-taos-sql/01-data-type.md similarity index 90% rename from docs-cn/14-reference/01-taos-sql/01-data-type.md rename to docs-cn/12-taos-sql/01-data-type.md index 107e73de5b6903d7aeaa6d6c8a68fb9f5941b7e9..7e63e1c9507f3b12f37fdb42a9c347bd92aafb75 100644 --- a/docs-cn/14-reference/01-taos-sql/01-data-type.md +++ b/docs-cn/12-taos-sql/01-data-type.md @@ -1,18 +1,17 @@ --- sidebar_label: 支持的数据类型 +title: 支持的数据类型 --- -# 支持的数据类型 - 使用 TDengine,最重要的是时间戳。创建并插入记录、查询历史记录的时候,均需要指定时间戳。时间戳有如下规则: - 时间格式为 `YYYY-MM-DD HH:mm:ss.MS`,默认时间分辨率为毫秒。比如:`2017-08-12 18:25:58.128` - 内部函数 now 是客户端的当前时间 - 插入记录时,如果时间戳为 now,插入数据时使用提交这条记录的客户端的当前时间 -- Epoch Time:时间戳也可以是一个长整数,表示从格林威治时间 1970-01-01 00:00:00.000 (UTC/GMT) 开始的毫秒数(相应地,如果所在 Database 的时间精度设置为“微秒”,则长整型格式的时间戳含义也就对应于从格林威治时间 1970-01-01 00:00:00.000 (UTC/GMT) 开始的微秒数;纳秒精度的逻辑也是类似的。) -- 时间可以加减,比如 now-2h,表明查询时刻向前推 2 个小时(最近 2 小时)。数字后面的时间单位可以是 b(纳秒)、u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 比如 `select * from t1 where ts > now-2w and ts <= now-1w`,表示查询两周前整整一周的数据。在指定降采样操作(down sampling)的时间窗口(interval)时,时间单位还可以使用 n(自然月) 和 y(自然年)。 +- Epoch Time:时间戳也可以是一个长整数,表示从格林威治时间 1970-01-01 00:00:00.000 (UTC/GMT) 开始的毫秒数(相应地,如果所在 Database 的时间精度设置为“微秒”,则长整型格式的时间戳含义也就对应于从格林威治时间 1970-01-01 00:00:00.000 (UTC/GMT) 开始的微秒数;纳秒精度逻辑类似。) +- 时间可以加减,比如 now-2h,表明查询时刻向前推 2 个小时(最近 2 小时)。数字后面的时间单位可以是 b(纳秒)、u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 比如 `select * from t1 where ts > now-2w and ts <= now-1w`,表示查询两周前整整一周的数据。在指定降采样操作(down sampling)的时间窗口(interval)时,时间单位还可以使用 n (自然月) 和 y (自然年)。 -TDengine 缺省的时间戳是毫秒精度,但通过在 `CREATE DATABASE` 时传递的 PRECISION 参数就可以支持微秒和纳秒。(从 2.1.5.0 版本开始支持纳秒精度) +TDengine 缺省的时间戳精度是毫秒,但通过在 `CREATE DATABASE` 时传递的 PRECISION 参数也可以支持微秒和纳秒。(从 2.1.5.0 版本开始支持纳秒精度) ``` CREATE DATABASE db_name PRECISION 'ns'; @@ -24,15 +23,15 @@ CREATE DATABASE db_name PRECISION 'ns'; | --- | :-------: | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 1 | TIMESTAMP | 8 | 时间戳。缺省精度毫秒,可支持微秒和纳秒。从格林威治时间 1970-01-01 00:00:00.000 (UTC/GMT) 开始,计时不能早于该时间。(从 2.0.18.0 版本开始,已经去除了这一时间范围限制)(从 2.1.5.0 版本开始支持纳秒精度) | | 2 | INT | 4 | 整型,范围 [-2^31+1, 2^31-1], -2^31 用作 NULL | -| 3 | BIGINT | 8 | 长整型,范围 [-2^63+1, 2^63-1], -2^63 用于 NULL | +| 3 | BIGINT | 8 | 长整型,范围 [-2^63+1, 2^63-1], -2^63 用作 NULL | | 4 | FLOAT | 4 | 浮点型,有效位数 6-7,范围 [-3.4E38, 3.4E38] | | 5 | DOUBLE | 8 | 双精度浮点型,有效位数 15-16,范围 [-1.7E308, 1.7E308] | | 6 | BINARY | 自定义 | 记录单字节字符串,建议只用于处理 ASCII 可见字符,中文等多字节字符需使用 nchar。理论上,最长可以有 16374 字节。binary 仅支持字符串输入,字符串两端需使用单引号引用。使用时须指定大小,如 binary(20) 定义了最长为 20 个单字节字符的字符串,每个字符占 1 byte 的存储空间,总共固定占用 20 bytes 的空间,此时如果用户字符串超出 20 字节将会报错。对于字符串内的单引号,可以用转义字符反斜线加单引号来表示,即 `\’`。 | -| 7 | SMALLINT | 2 | 短整型, 范围 [-32767, 32767], -32768 用于 NULL | -| 8 | TINYINT | 1 | 单字节整型,范围 [-127, 127], -128 用于 NULL | +| 7 | SMALLINT | 2 | 短整型, 范围 [-32767, 32767], -32768 用作 NULL | +| 8 | TINYINT | 1 | 单字节整型,范围 [-127, 127], -128 用作 NULL | | 9 | BOOL | 1 | 布尔型,{true, false} | | 10 | NCHAR | 自定义 | 记录包含多字节字符在内的字符串,如中文字符。每个 nchar 字符占用 4 bytes 的存储空间。字符串两端使用单引号引用,字符串内的单引号需用转义字符 `\’`。nchar 使用时须指定字符串大小,类型为 nchar(10) 的列表示此列的字符串最多存储 10 个 nchar 字符,会固定占用 40 bytes 的空间。如果用户字符串长度超出声明长度,将会报错。 | -| 11 | JSON | | json 数据类型, 只有 tag 类型可以是 json 格式 | +| 11 | JSON | | json 数据类型, 只有 tag 可以是 json 格式 | @@ -42,7 +41,7 @@ TDengine 对 SQL 语句中的英文字符不区分大小写,自动转化为小 ::: :::note -虽然 Binary 类型在底层存储上支持字节型的二进制字符,但不同编程语言对二进制数据的处理方式并不保证一致,因此建议在 Binary 类型中只存储 ASCII 可见字符,而避免存储不可见字符。多字节的数据,例如中文字符,则需要使用 nchar 类型进行保存。如果强行使用 Binary 类型保存中文字符,虽然有时也能正常读写,但并不带有字符集信息,很容易出现数据乱码甚至数据损坏等情况。 +虽然 BINARY 类型在底层存储上支持字节型的二进制字符,但不同编程语言对二进制数据的处理方式并不保证一致,因此建议在 BINARY 类型中只存储 ASCII 可见字符,而避免存储不可见字符。多字节的数据,例如中文字符,则需要使用 NCHAR 类型进行保存。如果强行使用 BINARY 类型保存中文字符,虽然有时也能正常读写,但并不带有字符集信息,很容易出现数据乱码甚至数据损坏等情况。 ::: diff --git a/docs-cn/14-reference/01-taos-sql/02-database.md b/docs-cn/12-taos-sql/02-database.md similarity index 89% rename from docs-cn/14-reference/01-taos-sql/02-database.md rename to docs-cn/12-taos-sql/02-database.md index 1fe934e87796313b647222a000635d113ef391bb..5240efa26fc98aaa0ffe83abbb3e44a23dbf338c 100644 --- a/docs-cn/14-reference/01-taos-sql/02-database.md +++ b/docs-cn/12-taos-sql/02-database.md @@ -1,34 +1,24 @@ --- sidebar_label: 数据库管理 +title: 数据库管理 --- -# 数据库管理 - ## 创建数据库 ``` CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [DAYS days] [UPDATE 1]; ``` -:::info 说明 - +:::info 1. KEEP 是该数据库的数据保留多长天数,缺省是 3650 天(10 年),数据库会自动删除超过时限的数据; - 2. UPDATE 标志数据库支持更新相同时间戳数据;(从 2.1.7.0 版本开始此参数支持设为 2,表示允许部分列更新,也即更新数据行时未被设置的列会保留原值。)(从 2.0.8.0 版本开始支持此参数。注意此参数不能通过 `ALTER DATABASE` 指令进行修改。) - 1. UPDATE 设为 0 时,表示不允许更新数据,后发送的相同时间戳的数据会被直接丢弃; - 2. UPDATE 设为 1 时,表示更新全部列数据,即如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL; - 3. UPDATE 设为 2 时,表示支持更新部分列数据,即如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值; - - 4. 更多关于 UPDATE 参数的用法,请参考[FAQ](https://www.taosdata.com/cn/documentation/faq)。 - + 4. 更多关于 UPDATE 参数的用法,请参考[FAQ](/train-faq/faq)。 3. 数据库名最大长度为 33; - 4. 一条 SQL 语句的最大长度为 65480 个字符; - -5. 数据库还有更多与存储相关的配置参数,请参见 [服务端配置](https://www.taosdata.com/cn/documentation/administrator#config) 章节。 +5. 数据库还有更多与数据库相关的配置参数,如 cache, blocks, days, keep, minRows, maxRows, wal, fsync, update, cacheLast, replica, quorum, maxVgroupsPerDb, ctime, comp, prec, 具体细节请参见 [配置参数](/reference/config/) 章节。 ::: @@ -44,7 +34,7 @@ SHOW VARIABLES; USE db_name; ``` -使用/切换数据库(在 RESTful 连接方式下无效)。 +使用/切换数据库(在 REST 连接方式下无效)。 ## 删除数据库 diff --git a/docs-cn/14-reference/01-taos-sql/03-table.md b/docs-cn/12-taos-sql/03-table.md similarity index 94% rename from docs-cn/14-reference/01-taos-sql/03-table.md rename to docs-cn/12-taos-sql/03-table.md index 81834bacd47e04249b72aa4f28d31a73b4c74e75..330734f9bc46ffb09fc338997f37c0e05560a2d5 100644 --- a/docs-cn/14-reference/01-taos-sql/03-table.md +++ b/docs-cn/12-taos-sql/03-table.md @@ -1,4 +1,6 @@ -# 表管理 +--- +title: 表管理 +--- ## 创建数据表 @@ -74,13 +76,6 @@ SHOW CREATE TABLE tb_name; 常用于数据库迁移。对一个已经存在的数据表,返回其创建语句;在另一个集群中执行该语句,就能得到一个结构完全相同的数据表。 -## 在线修改显示字符宽度 - -``` -SET MAX_BINARY_DISPLAY_WIDTH ; -``` - -如显示的内容后面以...结尾时,表示该内容已被截断,可通过本命令修改显示字符宽度以显示完整的内容。 ## 获取表的结构信息 @@ -120,3 +115,9 @@ ALTER TABLE tb_name MODIFY COLUMN field_name data_type(length); 如果数据列的类型是可变长格式(BINARY 或 NCHAR),那么可以使用此指令修改其宽度(只能改大,不能改小)。(2.1.3.0 版本新增) 如果表是通过超级表创建,更改表结构的操作只能对超级表进行。同时针对超级表的结构更改对所有通过该结构创建的表生效。对于不是通过超级表创建的表,可以直接修改表结构。 + ### 修改子表标签值 + +``` +ALTER TABLE tb_name SET TAG tag_name=new_tag_value; +``` +如果表是通过超级表创建,可以使用此指令修改其标签值 diff --git a/docs-cn/14-reference/01-taos-sql/04-stable.md b/docs-cn/12-taos-sql/04-stable.md similarity index 79% rename from docs-cn/14-reference/01-taos-sql/04-stable.md rename to docs-cn/12-taos-sql/04-stable.md index 8ac8e669f36fc0dd7066006e5b1e4d4ca7d15cc2..52ec7fa6983abc63bcb839f28f8d9a56d6863cb8 100644 --- a/docs-cn/14-reference/01-taos-sql/04-stable.md +++ b/docs-cn/12-taos-sql/04-stable.md @@ -1,10 +1,13 @@ --- sidebar_label: 超级表管理 +title: 超级表 STable 管理 --- -# 超级表 STable 管理 +:::note -注意:在 2.0.15.0 及以后的版本中,开始支持 STABLE 保留字。也即,在本节后文的指令说明中,CREATE、DROP、ALTER 三个指令在老版本中保留字需写作 TABLE 而不是 STABLE。 +在 2.0.15.0 及以后的版本中开始支持 STABLE 保留字。也即,在本节后文的指令说明中,CREATE、DROP、ALTER 三个指令在 2.0.15.0 之前的版本中 STABLE 保留字需写作 TABLE。 + +::: ## 创建超级表 @@ -18,7 +21,7 @@ CREATE STABLE [IF NOT EXISTS] stb_name (timestamp_field_name TIMESTAMP, field1_n 1. TAGS 列的数据类型不能是 timestamp 类型;(从 2.1.3.0 版本开始,TAGS 列中支持使用 timestamp 类型,但需注意在 TAGS 中的 timestamp 列写入数据时需要提供给定值,而暂不支持四则运算,例如 `NOW + 10s` 这类表达式) 2. TAGS 列名不能与其他列名相同; -3. TAGS 列名不能为预留关键字(参见:[参数限制与保留关键字](https://www.taosdata.com/cn/documentation/administrator#keywords) 章节); +3. TAGS 列名不能为预留关键字(参见:[参数限制与保留关键字](/taos-sql/keywords/) 章节); 4. TAGS 最多允许 128 个,至少 1 个,总长度不超过 16 KB。 ::: @@ -109,11 +112,7 @@ ALTER STABLE stb_name MODIFY TAG tag_name data_type(length); 如果标签的类型是可变长格式(BINARY 或 NCHAR),那么可以使用此指令修改其宽度(只能改大,不能改小)。(2.1.3.0 版本新增) -### 修改子表标签值 - -``` -ALTER TABLE tb_name SET TAG tag_name=new_tag_value; -``` - -说明:除了更新标签的值的操作是针对子表进行,其他所有的标签操作(添加标签、删除标签等)均只能作用于 STable,不能对单个子表操作。对 STable 添加标签以后,依托于该 STable 建立的所有表将自动增加了一个标签,所有新增标签的默认值都是 NULL。 +:::note +除了更新标签的值的操作是针对子表进行,其他所有的标签操作(添加标签、删除标签等)均只能作用于 STable,不能对单个子表操作。对 STable 添加标签以后,依托于该 STable 建立的所有表将自动增加了一个标签,所有新增标签的默认值都是 NULL。 +::: \ No newline at end of file diff --git a/docs-cn/14-reference/01-taos-sql/05-insert.md b/docs-cn/12-taos-sql/05-insert.md similarity index 99% rename from docs-cn/14-reference/01-taos-sql/05-insert.md rename to docs-cn/12-taos-sql/05-insert.md index d0c0c28dba3f5f64ff066f6a313e8307488c13b5..e542e442b78c9033ae37196f4913a7c67fb19d8b 100644 --- a/docs-cn/14-reference/01-taos-sql/05-insert.md +++ b/docs-cn/12-taos-sql/05-insert.md @@ -1,9 +1,8 @@ --- sidebar_label: 数据写入 +title: 数据写入 --- -# 数据写入 - ## 写入语法 ``` diff --git a/docs-cn/14-reference/01-taos-sql/06-select.md b/docs-cn/12-taos-sql/06-select.md similarity index 81% rename from docs-cn/14-reference/01-taos-sql/06-select.md rename to docs-cn/12-taos-sql/06-select.md index dab208f0860ab4eed435d097205e1a803350dcde..6f0a0735135738c9502632387022cc94e9495375 100644 --- a/docs-cn/14-reference/01-taos-sql/06-select.md +++ b/docs-cn/12-taos-sql/06-select.md @@ -1,9 +1,8 @@ --- sidebar_label: 数据查询 +title: 数据查询 --- -# 数据查询 - ## 查询语法 ``` @@ -222,42 +221,43 @@ Query OK, 1 row(s) in set (0.000081s) ## \_block_dist 函数 -用于获得指定的(超级)表的数据块分布信息 +**功能说明**: 用于获得指定的(超级)表的数据块分布信息 ```txt title="语法" SELECT _block_dist() FROM { tb_name | stb_name } ``` -返回结果类型:字符串。 +**返回结果类型**:字符串。 -适用数据类型:不能输入任何参数。 +**适用数据类型**:不能输入任何参数。 -嵌套子查询支持:不支持子查询或嵌套查询。 +**嵌套子查询支持**:不支持子查询或嵌套查询。 -返回 FROM 子句中输入的表或超级表的数据块分布情况。不支持查询条件。 +**返回结果**: -返回的结果是该表或超级表的数据块所包含的行数的数据分布直方图。 +- 返回 FROM 子句中输入的表或超级表的数据块分布情况。不支持查询条件。 +- 返回的结果是该表或超级表的数据块所包含的行数的数据分布直方图。 ```txt title="返回结果" summary: 5th=[392], 10th=[392], 20th=[392], 30th=[392], 40th=[792], 50th=[792] 60th=[792], 70th=[792], 80th=[792], 90th=[792], 95th=[792], 99th=[792] Min=[392(Rows)] Max=[800(Rows)] Avg=[666(Rows)] Stddev=[2.17] Rows=[2000], Blocks=[3], Size=[5.440(Kb)] Comp=[0.23] RowsInMem=[0] SeekHeaderTime=[1(us)] ``` -上述信息的说明如下: +**上述信息的说明如下**: -1. 查询的(超级)表所包含的存储在文件中的数据块(data block)中所包含的数据行的数量分布直方图信息:5%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 95%, 99% 的数值; -2. 所有数据块中,包含行数最少的数据块所包含的行数量, 其中的 Min 指标 392 行。 -3. 所有数据块中,包含行数最多的数据块所包含的行数量, 其中的 Max 指标 800 行。 -4. 所有数据块行数的算数平均值 666 行(其中的 Avg 项)。 -5. 所有数据块中行数分布的均方差为 2.17 ( stddev )。 -6. 数据块包含的行的总数为 2000 行(Rows)。 -7. 数据块总数是 3 个数据块 (Blocks)。 -8. 数据块占用磁盘空间大小 5.44 Kb (size)。 -9. 压缩后的数据块的大小除以原始数据的所获得的压缩比例: 23%(Comp),及压缩后的数据规模是原始数据规模的 23%。 -10. 内存中存在的数据行数是 0,表示内存中没有数据缓存。 -11. 获取数据块信息的过程中读取头文件的时间开销 1 微秒(SeekHeaderTime)。 +- 查询的(超级)表所包含的存储在文件中的数据块(data block)中所包含的数据行的数量分布直方图信息:5%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%, 95%, 99% 的数值; +- 所有数据块中,包含行数最少的数据块所包含的行数量, 其中的 Min 指标 392 行。 +- 所有数据块中,包含行数最多的数据块所包含的行数量, 其中的 Max 指标 800 行。 +- 所有数据块行数的算数平均值 666 行(其中的 Avg 项)。 +- 所有数据块中行数分布的均方差为 2.17 ( stddev )。 +- 数据块包含的行的总数为 2000 行(Rows)。 +- 数据块总数是 3 个数据块 (Blocks)。 +- 数据块占用磁盘空间大小 5.44 Kb (size)。 +- 压缩后的数据块的大小除以原始数据的所获得的压缩比例: 23%(Comp),及压缩后的数据规模是原始数据规模的 23%。 +- 内存中存在的数据行数是 0,表示内存中没有数据缓存。 +- 获取数据块信息的过程中读取头文件的时间开销 1 微秒(SeekHeaderTime)。 -支持版本:指定计算算法的功能从 2.1.0.x 版本开始,2.1.0.0 之前的版本不支持指定使用算法的功能。 +**支持版本**:指定计算算法的功能从 2.1.0.x 版本开始,2.1.0.0 之前的版本不支持指定使用算法的功能。 ## TAOS SQL 中特殊关键词 @@ -323,18 +323,20 @@ Query OK, 1 row(s) in set (0.001091s) | like | match a wildcard string | **`binary`** **`nchar`** | | match/nmatch | filter regex | **`binary`** **`nchar`** | -1. <\> 算子也可以写为 != ,请注意,这个算子不能用于数据表第一列的 timestamp 字段。 -2. like 算子使用通配符字符串进行匹配检查。 +**使用说明**: + +- <\> 算子也可以写为 != ,请注意,这个算子不能用于数据表第一列的 timestamp 字段。 +- like 算子使用通配符字符串进行匹配检查。 - 在通配符字符串中:'%'(百分号)匹配 0 到任意个字符;'\_'(下划线)匹配单个任意 ASCII 字符。 - 如果希望匹配字符串中原本就带有的 \_(下划线)字符,那么可以在通配符字符串中写作 `\_`,也即加一个反斜线来进行转义。(从 2.2.0.0 版本开始支持) - 通配符字符串最长不能超过 20 字节。(从 2.1.6.1 版本开始,通配符字符串的长度放宽到了 100 字节,并可以通过 taos.cfg 中的 maxWildCardsLength 参数来配置这一长度限制。但不建议使用太长的通配符字符串,将有可能严重影响 LIKE 操作的执行性能。) -3. 同时进行多个字段的范围过滤,需要使用关键词 AND 来连接不同的查询条件,暂不支持 OR 连接的不同列之间的查询过滤条件。 +- 同时进行多个字段的范围过滤,需要使用关键词 AND 来连接不同的查询条件,暂不支持 OR 连接的不同列之间的查询过滤条件。 - 从 2.3.0.0 版本开始,已支持完整的同一列和/或不同列间的 AND/OR 运算。 -4. 针对单一字段的过滤,如果是时间过滤条件,则一条语句中只支持设定一个;但针对其他的(普通)列或标签列,则可以使用 `OR` 关键字进行组合条件的查询过滤。例如: `((value > 20 AND value < 30) OR (value < 12))`。 +- 针对单一字段的过滤,如果是时间过滤条件,则一条语句中只支持设定一个;但针对其他的(普通)列或标签列,则可以使用 `OR` 关键字进行组合条件的查询过滤。例如: `((value > 20 AND value < 30) OR (value < 12))`。 - 从 2.3.0.0 版本开始,允许使用多个时间过滤条件,但首列时间戳的过滤运算结果只能包含一个区间。 -5. 从 2.0.17.0 版本开始,条件过滤开始支持 BETWEEN AND 语法,例如 `WHERE col2 BETWEEN 1.5 AND 3.25` 表示查询条件为“1.5 ≤ col2 ≤ 3.25”。 -6. 从 2.1.4.0 版本开始,条件过滤开始支持 IN 算子,例如 `WHERE city IN ('Beijing', 'Shanghai')`。说明:BOOL 类型写作 `{true, false}` 或 `{0, 1}` 均可,但不能写作 0、1 之外的整数;FLOAT 和 DOUBLE 类型会受到浮点数精度影响,集合内的值在精度范围内认为和数据行的值完全相等才能匹配成功;TIMESTAMP 类型支持非主键的列。 -7. 从 2.3.0.0 版本开始,条件过滤开始支持正则表达式,关键字 match/nmatch,不区分大小写。 +- 从 2.0.17.0 版本开始,条件过滤开始支持 BETWEEN AND 语法,例如 `WHERE col2 BETWEEN 1.5 AND 3.25` 表示查询条件为“1.5 ≤ col2 ≤ 3.25”。 +- 从 2.1.4.0 版本开始,条件过滤开始支持 IN 算子,例如 `WHERE city IN ('Beijing', 'Shanghai')`。说明:BOOL 类型写作 `{true, false}` 或 `{0, 1}` 均可,但不能写作 0、1 之外的整数;FLOAT 和 DOUBLE 类型会受到浮点数精度影响,集合内的值在精度范围内认为和数据行的值完全相等才能匹配成功;TIMESTAMP 类型支持非主键的列。 +- 从 2.3.0.0 版本开始,条件过滤开始支持正则表达式,关键字 match/nmatch,不区分大小写。 ## 正则表达式过滤 @@ -376,14 +378,18 @@ WHERE t1.ts = t2.ts AND t1.deviceid = t2.deviceid AND t1.status=0; 类似地,也可以对多个子查询的查询结果进行 JOIN 操作。 -注意,JOIN 操作存在如下限制要求: +:::note + +JOIN语句存在如下限制要求: -1. 参与一条语句中 JOIN 操作的表/超级表最多可以有 10 个。 -2. 在包含 JOIN 操作的查询语句中不支持 FILL。 -3. 暂不支持参与 JOIN 操作的表之间聚合后的四则运算。 -4. 不支持只对其中一部分表做 GROUP BY。 -5. JOIN 查询的不同表的过滤条件之间不能为 OR。 -6. JOIN 查询要求连接条件不能是普通列,只能针对标签和主时间字段列(第一列)。 +- 参与一条语句中 JOIN 操作的表/超级表最多可以有 10 个。 +- 在包含 JOIN 操作的查询语句中不支持 FILL。 +- 暂不支持参与 JOIN 操作的表之间聚合后的四则运算。 +- 不支持只对其中一部分表做 GROUP BY。 +- JOIN 查询的不同表的过滤条件之间不能为 OR。 +- JOIN 查询要求连接条件不能是普通列,只能针对标签和主时间字段列(第一列)。 + +::: ## 嵌套查询 @@ -397,17 +403,17 @@ SELECT ... FROM (SELECT ... FROM ...) ...; :::info -1. 目前仅支持一层嵌套,也即不能在子查询中再嵌入子查询。 -2. 内层查询的返回结果将作为“虚拟表”供外层查询使用,此虚拟表可以使用 AS 语法做重命名,以便于外层查询中方便引用。 -3. 目前不能在“连续查询”功能中使用子查询。 -4. 在内层和外层查询中,都支持普通的表间/超级表间 JOIN。内层查询的计算结果也可以再参与数据子表的 JOIN 操作。 -5. 目前内层查询、外层查询均不支持 UNION 操作。 -6. 内层查询支持的功能特性与非嵌套的查询语句能力是一致的。 +- 目前仅支持一层嵌套,也即不能在子查询中再嵌入子查询。 +- 内层查询的返回结果将作为“虚拟表”供外层查询使用,此虚拟表可以使用 AS 语法做重命名,以便于外层查询中方便引用。 +- 目前不能在“连续查询”功能中使用子查询。 +- 在内层和外层查询中,都支持普通的表间/超级表间 JOIN。内层查询的计算结果也可以再参与数据子表的 JOIN 操作。 +- 目前内层查询、外层查询均不支持 UNION 操作。 +- 内层查询支持的功能特性与非嵌套的查询语句能力是一致的。 - 内层查询的 ORDER BY 子句一般没有意义,建议避免这样的写法以免无谓的资源消耗。 -7. 与非嵌套的查询语句相比,外层查询所能支持的功能特性存在如下限制: +- 与非嵌套的查询语句相比,外层查询所能支持的功能特性存在如下限制: - 计算函数部分: - _. 如果内层查询的结果数据未提供时间戳,那么计算过程依赖时间戳的函数在外层会无法正常工作。例如:TOP, BOTTOM, FIRST, LAST, DIFF。 - _. 计算过程需要两遍扫描的函数,在外层查询中无法正常工作。例如:此类函数包括:STDDEV, PERCENTILE。 + - 如果内层查询的结果数据未提供时间戳,那么计算过程依赖时间戳的函数在外层会无法正常工作。例如:TOP, BOTTOM, FIRST, LAST, DIFF。 + - 计算过程需要两遍扫描的函数,在外层查询中无法正常工作。例如:此类函数包括:STDDEV, PERCENTILE。 - 外层查询中不支持 IN 算子,但在内层中可以使用。 - 外层查询不支持 GROUP BY。 diff --git a/docs-cn/14-reference/01-taos-sql/07-function.md b/docs-cn/12-taos-sql/07-function.md similarity index 52% rename from docs-cn/14-reference/01-taos-sql/07-function.md rename to docs-cn/12-taos-sql/07-function.md index 38671a08ff11d812896fad51b647abb4e4261dd7..de993020740abe39a177f8107f0388dcc439a17e 100644 --- a/docs-cn/14-reference/01-taos-sql/07-function.md +++ b/docs-cn/12-taos-sql/07-function.md @@ -1,9 +1,8 @@ --- sidebar_label: SQL 函数 +title: SQL 函数 --- -# SQL 函数 - ## 聚合函数 TDengine 支持针对数据的聚合查询。提供支持的聚合和选择函数如下: @@ -14,20 +13,21 @@ TDengine 支持针对数据的聚合查询。提供支持的聚合和选择函 SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ``` -- **功能说明**:统计表/超级表中记录行数或某列的非空值个数。 -- **返回数据类型**:长整型 INT64。 -- **应用字段**:应用全部字段。 -- **适用于**:表、超级表。 +**功能说明**:统计表/超级表中记录行数或某列的非空值个数。 + +**返回数据类型**:长整型 INT64。 + +**应用字段**:应用全部字段。 -:::info +**适用于**:表、超级表。 + +**使用说明**: - 可以使用星号(\*)来替代具体的字段,使用星号(\*)返回全部记录数量。 - 针对同一表的(不包含 NULL 值)字段查询结果均相同。 - 如果统计对象是具体的列,则返回该列中非 NULL 值的记录数量。 -::: - -示例: +**示例**: ``` taos> SELECT COUNT(*), COUNT(voltage) FROM meters; @@ -49,12 +49,15 @@ Query OK, 1 row(s) in set (0.001075s) SELECT AVG(field_name) FROM tb_name [WHERE clause]; ``` -- **功能说明**:统计表/超级表中某列的平均值。 -- **返回数据类型**:双精度浮点数 Double。 -- **应用字段**:不能应用在 timestamp、binary、nchar、bool 字段。 -- **适用于**:表、超级表。 +**功能说明**:统计表/超级表中某列的平均值。 -示例: +**返回数据类型**:双精度浮点数 Double。 + +**应用字段**:不能应用在 timestamp、binary、nchar、bool 字段。 + +**适用于**:表、超级表。 + +**示例**: ``` taos> SELECT AVG(current), AVG(voltage), AVG(phase) FROM meters; @@ -76,12 +79,17 @@ Query OK, 1 row(s) in set (0.000943s) SELECT TWA(field_name) FROM tb_name WHERE clause; ``` -- **功能说明**:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。 -- **返回数据类型**:双精度浮点数 Double。 -- **应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 -- **适用于**:表、(超级表。 +**功能说明**:时间加权平均函数。统计表中某列在一段时间内的时间加权平均。 + +**返回数据类型**:双精度浮点数 Double。 + +**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 + +**适用于**:表、超级表。 + +**使用说明**: -说明:从 2.1.3.0 版本开始,TWA 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +- 从 2.1.3.0 版本开始,TWA 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 ### IRATE @@ -95,9 +103,11 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; **应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 -适用于:**表、(超级表)**。 +**适用于**:表、超级表。 + +**使用说明**: -说明:(从 2.1.3.0 版本开始新增此函数)IRATE 可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +- 从 2.1.3.0 版本开始此函数可用,IRATE 可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 ### SUM @@ -113,7 +123,7 @@ SELECT SUM(field_name) FROM tb_name [WHERE clause]; **适用于**:表、超级表。 -示例: +**示例**: ``` taos> SELECT SUM(current), SUM(voltage), SUM(phase) FROM meters; @@ -141,9 +151,9 @@ SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; **应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 -**适用于**:表。(从 2.0.15.1 版本开始,本函数也支持**超级表**) +**适用于**:表、超级表(从 2.0.15.1 版本开始) -示例: +**示例**: ``` taos> SELECT STDDEV(current) FROM d1001; @@ -159,12 +169,15 @@ Query OK, 1 row(s) in set (0.000915s) SELECT LEASTSQUARES(field_name, start_val, step_val) FROM tb_name [WHERE clause]; ``` -- **功能说明**:统计表中某列的值是主键(时间戳)的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。 -- **返回数据类型**:字符串表达式(斜率, 截距)。 -- **应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 -- **适用于**:表。 +**功能说明**:统计表中某列的值是主键(时间戳)的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。 + +**返回数据类型**:字符串表达式(斜率, 截距)。 + +**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 + +**适用于**:表。 -示例: +**示例**: ``` taos> SELECT LEASTSQUARES(current, 1, 1) FROM d1001; @@ -179,13 +192,18 @@ Query OK, 1 row(s) in set (0.000921s) ``` SELECT MODE(field_name) FROM tb_name [WHERE clause]; ``` -- **功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出空。不能匹配标签、时间戳输出。 -- **返回数据类型**:同应用的字段。 -- **应用字段**:适合于除时间主列外的任何类型字段。 -- **说明**:由于返回数据量未知,考虑到内存因素,为了函数可以正常返回结果,建议不重复的数据量在10万级别,否则会报错。 -- **支持的版本**:2.6开始的版本。 -示例: +**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出空。不能匹配标签、时间戳输出。 + +**返回数据类型**:同应用的字段。 + +**应用字段**:适合于除时间主列外的任何类型字段。 + +**使用说明**:由于返回数据量未知,考虑到内存因素,为了函数可以正常返回结果,建议不重复的数据量在 10 万级别,否则会报错。 + +**支持的版本**:2.6.0.0 及以后的版本。 + +**示例**: ``` taos> select voltage from d002; @@ -202,20 +220,25 @@ taos> select mode(voltage) from d002; ======================== 1 | Query OK, 1 row(s) in set (0.019393s) -``` +``` ### HYPERLOGLOG + ``` SELECT HYPERLOGLOG(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -- **功能说明**: - - 采用hyperloglog算法,返回某列的基数。该算法在数据量很大的情况下,可以明显降低内存的占用,但是求出来的基数是个估算值,标准误差(标准误差是多次实验,每次的平均数的标准差,不是与真实结果的误差)为0.81%。 - - 在数据量较少的时候该算法不是很准确,可以使用select count(data) from (select unique(col) as data from table) 的方法。 -- **返回结果类型**:整形。 -- **应用字段**:适合于任何类型字段。 -- **支持的版本**:2.6开始的版本。 -示例: +**功能说明**: + - 采用 hyperloglog 算法,返回某列的基数。该算法在数据量很大的情况下,可以明显降低内存的占用,但是求出来的基数是个估算值,标准误差(标准误差是多次实验,每次的平均数的标准差,不是与真实结果的误差)为 0.81%。 + - 在数据量较少的时候该算法不是很准确,可以使用 select count(data) from (select unique(col) as data from table) 的方法。 + +**返回结果类型**:整形。 + +**应用字段**:适合于任何类型字段。 + +**支持的版本**:2.6.0.0 及以后的版本。 + +**示例**: ``` taos> select dbig from shll; @@ -236,7 +259,7 @@ taos> select hyperloglog(dbig) from shll; ======================== 4 | Query OK, 1 row(s) in set (0.008388s) - ``` +``` ## 选择函数 @@ -256,7 +279,7 @@ SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; **适用于**:表、超级表。 -示例: +**示例**: ``` taos> SELECT MIN(current), MIN(voltage) FROM meters; @@ -286,7 +309,7 @@ SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; **适用于**:表、超级表。 -示例: +**示例**: ``` taos> SELECT MAX(current), MAX(voltage) FROM meters; @@ -316,15 +339,13 @@ SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; **适用于**:表、超级表。 -说明: - -1)如果要返回各个列的首个(时间戳最小)非 NULL 值,可以使用 FIRST(\*); - -2)如果结果集中的某列全部为 NULL 值,则该列的返回结果也是 NULL; +**使用说明**: -3)如果结果集中所有列全部为 NULL 值,则不返回结果。 +- 如果要返回各个列的首个(时间戳最小)非 NULL 值,可以使用 FIRST(\*); +- 如果结果集中的某列全部为 NULL 值,则该列的返回结果也是 NULL; +- 如果结果集中所有列全部为 NULL 值,则不返回结果。 -示例: +**示例**: ``` taos> SELECT FIRST(*) FROM meters; @@ -354,15 +375,14 @@ SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; **适用于**:表、超级表。 -说明: +**使用说明**: -1)如果要返回各个列的最后(时间戳最大)一个非 NULL 值,可以使用 LAST(\*); +- 如果要返回各个列的最后(时间戳最大)一个非 NULL 值,可以使用 LAST(\*); +- 如果结果集中的某列全部为 NULL 值,则该列的返回结果也是 NULL;如果结果集中所有列全部为 NULL 值,则不返回结果。 +- 在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。 -2)如果结果集中的某列全部为 NULL 值,则该列的返回结果也是 NULL;如果结果集中所有列全部为 NULL 值,则不返回结果。 -3)在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。 - -示例: +**示例**: ``` taos> SELECT LAST(*) FROM meters; @@ -392,15 +412,13 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **适用于**:表、超级表。 -说明: - -1)*k*值取值范围 1≤*k*≤100; - -2)系统同时返回该记录关联的时间戳列; +**使用说明**: -3)限制:TOP 函数不支持 FILL 子句。 +- *k*值取值范围 1≤*k*≤100; +- 系统同时返回该记录关联的时间戳列; +- 限制:TOP 函数不支持 FILL 子句。 -示例: +**示例**: ``` taos> SELECT TOP(current, 3) FROM meters; @@ -433,15 +451,13 @@ SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **适用于**:表、超级表。 -说明: +**使用说明**: -1)*k*值取值范围 1≤*k*≤100; +- *k*值取值范围 1≤*k*≤100; +- 系统同时返回该记录关联的时间戳列; +- 限制:BOTTOM 函数不支持 FILL 子句。 -2)系统同时返回该记录关联的时间戳列; - -3)限制:BOTTOM 函数不支持 FILL 子句。 - -示例: +**示例**: ``` taos> SELECT BOTTOM(voltage, 2) FROM meters; @@ -473,9 +489,9 @@ SELECT PERCENTILE(field_name, P) FROM { tb_name } [WHERE clause]; **适用于**:表。 -说明:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 +**使用说明**:*P*值取值范围 0≤*P*≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX。 -示例: +**示例**: ``` taos> SELECT PERCENTILE(current, 20) FROM d1001; @@ -500,9 +516,14 @@ FROM { tb_name | stb_name } [WHERE clause] **适用于**:表、超级表。 -说明:
**P**值有效取值范围 0≤P≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX;
**algo_type**的有效输入:**default** 和 **t-digest**。 用于指定计算近似分位数的算法。可不提供第三个参数的输入,此时将使用 default 的算法进行计算,即 apercentile(column_name, 50, "default") 与 apercentile(column_name, 50) 等价。当使用“t-digest”参数的时候,将使用 t-digest 方式采样计算近似分位数。但该参数指定计算算法的功能从 2.2.0.x 版本开始支持,2.2.0.0 之前的版本不支持指定使用算法的功能。
+**使用说明** + +- **P**值有效取值范围 0≤P≤100,为 0 的时候等同于 MIN,为 100 的时候等同于 MAX; +- **algo_type**的有效输入:**default** 和 **t-digest** +- 用于指定计算近似分位数的算法。可不提供第三个参数的输入,此时将使用 default 的算法进行计算,即 apercentile(column_name, 50, "default") 与 apercentile(column_name, 50) 等价。 +- 当使用“t-digest”参数的时候,将使用 t-digest 方式采样计算近似分位数。但该参数指定计算算法的功能从 2.2.0.x 版本开始支持,2.2.0.0 之前的版本不支持指定使用算法的功能。 -嵌套子查询支持:适用于内层查询和外层查询。 +**嵌套子查询支持**:适用于内层查询和外层查询。 ``` taos> SELECT APERCENTILE(current, 20) FROM d1001; @@ -538,16 +559,12 @@ SELECT LAST_ROW(field_name) FROM { tb_name | stb_name }; **适用于**:表、超级表。 -限制:LAST_ROW() 不能与 INTERVAL 一起使用。 +**使用说明**: -说明:在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。
+- 在用于超级表时,时间戳完全一样且同为最大的数据行可能有多个,那么会从中随机返回一条,而并不保证多次运行所挑选的数据行必然一致。 +- 不能与 INTERVAL 一起使用。 -{" "} - -{" "} - -
-示例: +**示例**: ``` taos> SELECT LAST_ROW(current) FROM meters; @@ -575,53 +592,49 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ **应用字段**:数值型字段。 -适用于:**表、超级表、嵌套查询**。 - -说明: -1)INTERP 用于在指定时间断面获取指定列的记录值,如果该时间断面不存在符合条件的行数据,那么会根据 FILL 参数的设定进行插值。 - -2)INTERP 的输入数据为指定列的数据,可以通过条件语句(where 子句)来对原始列数据进行过滤,如果没有指定过滤条件则输入为全部数据。 - -3)INTERP 的输出时间范围根据 RANGE(timestamp1,timestamp2)字段来指定,需满足 timestamp1<=timestamp2。其中 timestamp1(必选值)为输出时间范围的起始值,即如果 timestamp1 时刻符合插值条件则 timestamp1 为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的 timestamp 不能大于 timestamp2。如果没有指定 RANGE,那么满足过滤条件的输入数据中第一条记录的 timestamp 即为 timestamp1,最后一条记录的 timestamp 即为 timestamp2,同样也满足 timestamp1 <= timestamp2。 - -4)INTERP 根据 EVERY 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(EVERY 值)进行插值。如果没有指定 EVERY,则默认窗口大小为无穷大,即从 timestamp1 开始只有一个窗口。 +**适用于**:表、超级表、嵌套查询。 -5)INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值,如果没有 FILL 字段则默认不插值,即输出为原始记录值或不输出(原始记录不存在)。 -6)INTERP 只能在一个时间序列内进行插值,因此当作用于超级表时必须跟 group by tbname 一起使用,当作用嵌套查询外层时内层子查询不能含 GROUP BY 信息。 +**使用说明** -7)INTERP 的插值结果不受 ORDER BY timestamp 的影响,ORDER BY timestamp 只影响输出结果的排序。 +- INTERP 用于在指定时间断面获取指定列的记录值,如果该时间断面不存在符合条件的行数据,那么会根据 FILL 参数的设定进行插值。 +- INTERP 的输入数据为指定列的数据,可以通过条件语句(where 子句)来对原始列数据进行过滤,如果没有指定过滤条件则输入为全部数据。 +- INTERP 的输出时间范围根据 RANGE(timestamp1,timestamp2)字段来指定,需满足 timestamp1<=timestamp2。其中 timestamp1(必选值)为输出时间范围的起始值,即如果 timestamp1 时刻符合插值条件则 timestamp1 为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的 timestamp 不能大于 timestamp2。如果没有指定 RANGE,那么满足过滤条件的输入数据中第一条记录的 timestamp 即为 timestamp1,最后一条记录的 timestamp 即为 timestamp2,同样也满足 timestamp1 <= timestamp2。 +- INTERP 根据 EVERY 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(EVERY 值)进行插值。如果没有指定 EVERY,则默认窗口大小为无穷大,即从 timestamp1 开始只有一个窗口。 +- INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值,如果没有 FILL 字段则默认不插值,即输出为原始记录值或不输出(原始记录不存在)。 +- INTERP 只能在一个时间序列内进行插值,因此当作用于超级表时必须跟 group by tbname 一起使用,当作用嵌套查询外层时内层子查询不能含 GROUP BY 信息。 +- INTERP 的插值结果不受 ORDER BY timestamp 的影响,ORDER BY timestamp 只影响输出结果的排序。 -SQL 示例: +**SQL示例(基于文档中广泛使用的电表 schema )**: - 1) 单点线性插值 +- 单点线性插值 ``` - taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:40:00','2017-7-14 18:40:00') FILL(LINEAR); + taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:40:00','2017-7-14 18:40:00') FILL(LINEAR); ``` - 2) 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行取值(不插值) +- 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行取值(不插值) ``` - taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s); + taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s); ``` - 3) 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行线性插值 +- 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行线性插值 ``` - taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); + taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); ``` -4.在所有时间范围内每隔 5 秒钟进行向后插值 +- 在所有时间范围内每隔 5 秒钟进行向后插值 ``` - taos> SELECT INTERP(*) FROM t1 EVERY(5s) FILL(NEXT); + taos> SELECT INTERP(current) FROM t1 EVERY(5s) FILL(NEXT); ``` -5.根据 2017-07-14 17:00:00 到 2017-07-14 20:00:00 间的数据进行从 2017-07-14 18:00:00 到 2017-07-14 19:00:00 间每隔 5 秒钟进行线性插值 +- 根据 2017-07-14 17:00:00 到 2017-07-14 20:00:00 间的数据进行从 2017-07-14 18:00:00 到 2017-07-14 19:00:00 间每隔 5 秒钟进行线性插值 ``` - taos> SELECT INTERP(*) FROM t1 where ts >= '2017-07-14 17:00:00' and ts <= '2017-07-14 20:00:00' RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); + taos> SELECT INTERP(current) FROM t1 where ts >= '2017-07-14 17:00:00' and ts <= '2017-07-14 20:00:00' RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); ``` ### INTERP [2.3.1 之前的版本] @@ -638,8 +651,14 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL **适用于**:表、超级表。 -说明:(从 2.0.15.0 版本开始新增此函数)
1)INTERP 必须指定时间断面,如果该时间断面不存在直接对应的数据,那么会根据 FILL 参数的设定进行插值。此外,条件语句里面可附带筛选条件,例如标签、tbname。
2)INTERP 查询要求查询的时间区间必须位于数据集合(表)的所有记录的时间范围之内。如果给定的时间戳位于时间范围之外,即使有插值指令,仍然不返回结果。
3)单个 INTERP 函数查询只能够针对一个时间点进行查询,如果需要返回等时间间隔的断面数据,可以通过 INTERP 配合 EVERY 的方式来进行查询处理(而不是使用 INTERVAL),其含义是每隔固定长度的时间进行插值。
- 示例: +**使用说明**: + +- 从 2.0.15.0 及以后版本可用 +- INTERP 必须指定时间断面,如果该时间断面不存在直接对应的数据,那么会根据 FILL 参数的设定进行插值。此外,条件语句里面可附带筛选条件,例如标签、tbname。 +- INTERP 查询要求查询的时间区间必须位于数据集合(表)的所有记录的时间范围之内。如果给定的时间戳位于时间范围之外,即使有插值指令,仍然不返回结果。 +- 单个 INTERP 函数查询只能够针对一个时间点进行查询,如果需要返回等时间间隔的断面数据,可以通过 INTERP 配合 EVERY 的方式来进行查询处理(而不是使用 INTERVAL),其含义是每隔固定长度的时间进行插值 + +**示例**: ``` taos> SELECT INTERP(*) FROM meters WHERE ts='2017-7-14 18:40:00.004'; @@ -674,20 +693,23 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL ``` ### TAIL + ``` SELECT TAIL(field_name, k, offset_val) FROM {tb_name | stb_name} [WHERE clause]; ``` -**功能说明**:返回跳过最后 offset_value个,然后取连续 k 个记录,不忽略 NULL 值。offset_val 可以不输入。此时返回最后的 k 个记录。当有 offset_val 输入的情况下,该函数功能等效于order by ts desc LIMIT k OFFSET offset_val。 -**参数范围**:k: [1,100] offset_val: [0,100]。 +**功能说明**:返回跳过最后 offset_value 个,然后取连续 k 个记录,不忽略 NULL 值。offset_val 可以不输入。此时返回最后的 k 个记录。当有 offset_val 输入的情况下,该函数功能等效于 `order by ts desc LIMIT k OFFSET offset_val`。 + +**参数范围**:k: [1,100] offset_val: [0,100]。 **返回结果数据类型**:同应用的字段。 **应用字段**:适合于除时间主列外的任何类型字段。 -**支持版本**:2.6 开始的版本。 +**支持版本**:2.6.0.0 及之后的版本。 + +**示例**: -示例: ``` taos> select ts,dbig from tail2; ts | dbig | @@ -709,22 +731,26 @@ Query OK, 2 row(s) in set (0.002307s) ``` ### UNIQUE + ``` SELECT UNIQUE(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` + **功能说明**:返回该列的数值首次出现的值。该函数功能与 distinct 相似,但是可以匹配标签和时间戳信息。可以针对除时间列以外的字段进行查询,可以匹配标签和时间戳,其中的标签和时间戳是第一次出现时刻的标签和时间戳。 **返回结果数据类型**:同应用的字段。 **应用字段**:适合于除时间类型以外的字段。 -**支持版本**:2.6 开始的版本。 +**支持版本**:2.6.0.0 及之后的版本。 + +**使用说明**: + +- 该函数可以应用在普通表和超级表上。不能和窗口操作一起使用,例如 interval/state_window/session_window 。 +- 由于返回数据量未知,考虑到内存因素,为了函数可以正常返回结果,建议不重复的数据量在 10 万级别,否则会报错。 + +**示例**: -**说明**: - - 该函数可以应用在普通表和超级表上。不能和窗口操作一起使用,例如 interval/state_window/session_window 。 - - 由于返回数据量未知,考虑到内存因素,为了函数可以正常返回结果,建议不重复的数据量在10万级别,否则会报错。 - -示例: ``` taos> select ts,voltage from unique1; ts | voltage | @@ -752,29 +778,36 @@ Query OK, 5 row(s) in set (0.108458s) ## 计算函数 -- **DIFF** - ```mysql - SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHERE clause]; - ``` - 功能说明:统计表中某列的值与前一行对应值的差。 ignore_negative 取值为 0|1 , 可以不填,默认值为 0. 不忽略负值。ignore_negative为1时表示忽略负数。 +### DIFF - 返回结果数据类型:同应用字段。 + ```sql + SELECT {DIFF(field_name, ignore_negative) | DIFF(field_name)} FROM tb_name [WHERE clause]; + ``` - 应用字段:不能应用在timestamp、binary、nchar、bool类型字段。 +**功能说明**:统计表中某列的值与前一行对应值的差。 ignore_negative 取值为 0|1 , 可以不填,默认值为 0. 不忽略负值。ignore_negative 为 1 时表示忽略负数。 - 适用于:**表、(超级表)**。 +**返回结果数据类型**:同应用字段。 - 说明:输出结果行数是范围内总行数减一,第一行没有结果输出。从 2.1.3.0 版本开始,DIFF 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。从2.6.0开始,DIFF函数支持ignore_negative参数 +**应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 - 示例: - ```mysql - taos> SELECT DIFF(current) FROM d1001; - ts | diff(current) | - ================================================= - 2018-10-03 14:38:15.000 | 2.30000 | - 2018-10-03 14:38:16.800 | -0.30000 | - Query OK, 2 row(s) in set (0.001162s) - ``` +**适用于**:表、超级表。 + +**使用说明**: + +- 输出结果行数是范围内总行数减一,第一行没有结果输出。 +- 从 2.1.3.0 版本开始,DIFF 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +- 从 2.6.0 开始,DIFF 函数支持 ignore_negative 参数 + +**示例**: + + ```sql + taos> SELECT DIFF(current) FROM d1001; + ts | diff(current) | + ================================================= + 2018-10-03 14:38:15.000 | 2.30000 | + 2018-10-03 14:38:16.800 | -0.30000 | + Query OK, 2 row(s) in set (0.001162s) + ``` ### DERIVATIVE @@ -788,11 +821,14 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER **应用字段**:不能应用在 timestamp、binary、nchar、bool 类型字段。 -适用于:**表、(超级表)**。 +**适用于**:表、超级表 + +**使用说明**: -说明:(从 2.1.3.0 版本开始新增此函数)输出结果行数是范围内总行数减一,第一行没有结果输出。DERIVATIVE 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 +- 从 2.1.3.0 及以后版本可用;输出结果行数是范围内总行数减一,第一行没有结果输出。 +- DERIVATIVE 函数可以在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname)。 -示例: +**示例**: ``` taos> select derivative(current, 10m, 0) from t1; @@ -820,9 +856,9 @@ SELECT SPREAD(field_name) FROM { tb_name | stb_name } [WHERE clause]; **适用于**:表、超级表。 -说明:可用于 TIMESTAMP 字段,此时表示记录的时间覆盖范围。 +**使用说明**:可用于 TIMESTAMP 字段,此时表示记录的时间覆盖范围。 -示例: +**示例**: ``` taos> SELECT SPREAD(voltage) FROM meters; @@ -846,16 +882,18 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; **功能说明**:获得指定列的向上取整数的结果。 -返回结果类型:与指定列的原始数据类型一致。例如,如果指定列的原始数据类型为 Float,那么返回的数据类型也为 Float;如果指定列的原始数据类型为 Double,那么返回的数据类型也为 Double。 +**返回结果类型**:与指定列的原始数据类型一致。例如,如果指定列的原始数据类型为 Float,那么返回的数据类型也为 Float;如果指定列的原始数据类型为 Double,那么返回的数据类型也为 Double。 + +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列,无论 tag 列的类型是什么类型。 -适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列,无论 tag 列的类型是什么类型。 +**适用于**: 普通表、超级表。 -嵌套子查询支持:适用于内层查询和外层查询。 +**嵌套子查询支持**:适用于内层查询和外层查询。 -说明: -支持 +、-、\*、/ 运算,如 ceil(col1) + ceil(col2)。 -只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 -该函数可以应用在普通表和超级表上。 +**使用说明**: + +- 支持 +、-、\*、/ 运算,如 ceil(col1) + ceil(col2)。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 ### FLOOR @@ -875,380 +913,470 @@ SELECT ROUND(field_name) FROM { tb_name | stb_name } [WHERE clause]; **功能说明**:获得指定列的四舍五入的结果。 其他使用说明参见 CEIL 函数描述。 -- **ASIN** - ```mysql - SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] +### CSUM + + ```sql + SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] ``` - 功能说明:获得指定列的反正弦结果 - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL + **功能说明**:累加和(Cumulative sum),输出行与输入行数相同。 + + **返回结果类型**: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 返回结果中同时带有每行记录对应的时间戳。 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 + **适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在标签之上。 - 嵌套子查询支持:适用于内层查询和外层查询。 + **嵌套子查询支持**: 适用于内层查询和外层查询。 - 使用说明: + **使用说明**: + + - 不支持 +、-、*、/ 运算,如 csum(col1) + csum(col2)。 + - 只能与聚合(Aggregation)函数一起使用。 该函数可以应用在普通表和超级表上。 + - 使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**支持版本**: 从2.3.0.x开始支持 - 该函数可以应用在普通表和超级表上。 +### MAVG -- **ACOS** - ```mysql - SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] + ```sql + SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] ``` - 功能说明:获得指定列的反余弦结果 - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL + **功能说明**: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 + + **返回结果类型**: 返回双精度浮点数类型。 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 + **适用数据类型**: 不能应用在 timestamp、binary、nchar、bool 类型上;在超级表查询中使用时,不能应用在标签之上。 - 嵌套子查询支持:适用于内层查询和外层查询。 + **嵌套子查询支持**: 适用于内层查询和外层查询。 - 使用说明: + **使用说明**: + + - 不支持 +、-、*、/ 运算,如 mavg(col1, k1) + mavg(col2, k1); + - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用; + - 该函数可以应用在普通表和超级表上;使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**支持版本**: 从2.3.0.x开始支持 - 该函数可以应用在普通表和超级表上。 +### SAMPLE -- **ATAN** - ```mysql - SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] + ```sql + SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] ``` - 功能说明:获得指定列的反正切结果 - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL + **功能说明**: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 + **返回结果类型**: 同原始数据类型, 返回结果中带有该行记录的时间戳。 - 嵌套子查询支持:适用于内层查询和外层查询。 + **适用数据类型**: 在超级表查询中使用时,不能应用在标签之上。 - 使用说明: + **嵌套子查询支持**: 适用于内层查询和外层查询。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 + **使用说明**: + + - 不能参与表达式计算;该函数可以应用在普通表和超级表上; + - 使用在超级表上的时候,需要搭配 Group by tbname 使用,将结果强制规约到单个时间线。 - 该函数可以应用在普通表和超级表上。 +**支持版本**: 从2.3.0.x开始支持 - 版本2.6.0.x后支持 +### ASIN -- **SIN** - ```mysql - SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:获得指定列的正弦结果 + ```sql + SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL +**功能说明**:获得指定列的反正弦结果 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL - 嵌套子查询支持:适用于内层查询和外层查询。 +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 - 使用说明: +**嵌套子查询支持**:适用于内层查询和外层查询。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**使用说明**: - 该函数可以应用在普通表和超级表上。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 - 版本2.6.0.x后支持 +### ACOS -- **COS** - ```mysql - SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:获得指定列的余弦结果 + ```sql + SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL +**功能说明**:获得指定列的反余弦结果 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL - 嵌套子查询支持:适用于内层查询和外层查询。 +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 - 使用说明: +**嵌套子查询支持**:适用于内层查询和外层查询。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**使用说明**: - 该函数可以应用在普通表和超级表上。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 - 版本2.6.0.x后支持 +### ATAN -- **TAN** - ```mysql - SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:获得指定列的正切结果 + ```sql + SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL +**功能说明**:获得指定列的反正切结果 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL - 嵌套子查询支持:适用于内层查询和外层查询。 +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 - 使用说明: +**嵌套子查询支持**:适用于内层查询和外层查询。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**使用说明**: - 该函数可以应用在普通表和超级表上。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 - 版本2.6.0.x后支持 +### SIN -- **POW** - ```mysql - SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:获得指定列的指数为power的幂 + ```sql + SELECT SIN(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL +**功能说明**:获得指定列的正弦结果 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL - 嵌套子查询支持:适用于内层查询和外层查询。 +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 - 使用说明: +**嵌套子查询支持**:适用于内层查询和外层查询。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**使用说明**: - 该函数可以应用在普通表和超级表上。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 - 版本2.6.0.x后支持 +### COS -- **LOG** - ```mysql - SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:获得指定列对于底数base的对数 + ```sql + SELECT COS(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL +**功能说明**:获得指定列的余弦结果 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL - 嵌套子查询支持:适用于内层查询和外层查询。 +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 - 使用说明: +**嵌套子查询支持**:适用于内层查询和外层查询。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**使用说明**: - 该函数可以应用在普通表和超级表上。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 - 版本2.6.0.x后支持 +### TAN -- **ABS** - ```mysql - SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:获得指定列的绝对值 + ```sql + SELECT TAN(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` - 返回结果类型:如果输入值为整数,输出值是UBIGINT类型。如果输入值是FLOAT/DOUBLE数据类型,输出值是DOUBLE数据类型。 +**功能说明**:获得指定列的正切结果 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL - 嵌套子查询支持:适用于内层查询和外层查询。 +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 - 使用说明: +**嵌套子查询支持**:适用于内层查询和外层查询。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**使用说明**: - 该函数可以应用在普通表和超级表上。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 - 版本2.6.0.x后支持 +### POW -- **SQRT** - ```mysql - SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:获得指定列的平方根 + ```sql + SELECT POW(field_name, power) FROM { tb_name | stb_name } [WHERE clause] + ``` - 返回结果类型:DOUBLE。如果输入值为NULL,输出值也为NULL +**功能说明**:获得指定列的指数为 power 的幂 - 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL - 嵌套子查询支持:适用于内层查询和外层查询。 +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 - 使用说明: +**嵌套子查询支持**:适用于内层查询和外层查询。 - 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +**使用说明**: - 该函数可以应用在普通表和超级表上。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 - 版本2.6.0.x后支持 +### LOG -- **CAST** - ```mysql - SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:数据类型转换函数,输入参数expression支持普通列、常量、标量函数及它们之间的四则运算,不支持tag列,只适用于select子句中。 + ```sql + SELECT LOG(field_name, base) FROM { tb_name | stb_name } [WHERE clause] + ``` + +**功能说明**:获得指定列对于底数 base 的对数 + +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL + +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 + +**嵌套子查询支持**:适用于内层查询和外层查询。 + +**使用说明**: - 返回结果类型:CAST中指定的类型(type_name)。 +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 - 适用数据类型:输入参数expression的类型可以是除JSON外目前所有类型字段(BOOL/TINYINT/SMALLINT/INT/BIGINT/FLOAT/DOUBLE/BINARY(M)/TIMESTAMP/NCHAR(M)/TINYINT UNSIGNED/SMALLINT UNSIGNED/INT UNSIGNED/BIGINT UNSIGNED); 输出目标类型只支持BIGINT/BINARY(N)/TIMESTAMP/NCHAR(N)/BIGINT UNSIGNED。 +### ABS - 说明: + ```sql + SELECT ABS(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` - 对于不能支持的类型转换会直接报错。 +**功能说明**:获得指定列的绝对值 - 如果输入值为NULL则输出值也为NULL。 +**返回结果类型**:如果输入值为整数,输出值是 UBIGINT 类型。如果输入值是 FLOAT/DOUBLE 数据类型,输出值是 DOUBLE 数据类型。 - 对于类型支持但某些值无法正确转换的情况对应的转换后的值以转换函数输出为准。目前可能遇到的几种情况: +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 + +**嵌套子查询支持**:适用于内层查询和外层查询。 + +**使用说明**: + +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 + +### SQRT + + ```sql + SELECT SQRT(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` + +**功能说明**:获得指定列的平方根 + +**返回结果类型**:DOUBLE。如果输入值为 NULL,输出值也为 NULL + +**适用数据类型**:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在 tag 列 + +**嵌套子查询支持**:适用于内层查询和外层查询。 + +**使用说明**: + +- 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用。 +- 该函数可以应用在普通表和超级表上。 +- 版本2.6.0.x后支持 + +### CAST + + ```sql + SELECT CAST(expression AS type_name) FROM { tb_name | stb_name } [WHERE clause] + ``` + +**功能说明**:数据类型转换函数,输入参数 expression 支持普通列、常量、标量函数及它们之间的四则运算,不支持 tag 列,只适用于 select 子句中。 + +**返回结果类型**:CAST 中指定的类型(type_name)。 + +**适用数据类型**: + +- 输入参数 expression 的类型可以是除 JSON 外目前所有类型字段(BOOL/TINYINT/SMALLINT/INT/BIGINT/FLOAT/DOUBLE/BINARY(M)/TIMESTAMP/NCHAR(M)/TINYINT UNSIGNED/SMALLINT UNSIGNED/INT UNSIGNED/BIGINT UNSIGNED); +- 输出目标类型只支持 BIGINT/BINARY(N)/TIMESTAMP/NCHAR(N)/BIGINT UNSIGNED。 + +**使用说明**: + +- 对于不能支持的类型转换会直接报错。 +- 如果输入值为NULL则输出值也为NULL。 +- 对于类型支持但某些值无法正确转换的情况对应的转换后的值以转换函数输出为准。目前可能遇到的几种情况: 1)BINARY/NCHAR转BIGINT/BIGINT UNSIGNED时可能出现的无效字符情况,例如"a"可能转为0。 2)有符号数或TIMESTAMP转BIGINT UNSIGNED可能遇到的溢出问题。 3)BIGINT UNSIGNED转BIGINT可能遇到的溢出问题。 4)FLOAT/DOUBLE转BIGINT/BIGINT UNSIGNED可能遇到的溢出问题。 - 版本2.6.0.x后支持 +- 版本2.6.0.x后支持 -- **CONCAT** - ```mysql - SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:字符串连接函数。 +### CONCAT - 返回结果类型:同输入参数类型,BINARY或者NCHAR。 + ```sql + SELECT CONCAT(str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] + ``` - 适用数据类型:输入参数或者全部是BINARY格式的字符串或者列,或者全部是NCHAR格式的字符串或者列。不能应用在TAG列。 +**功能说明**:字符串连接函数。 - 说明: - - 如果输入值为NULL,输出值为NULL。 - 该函数最小参数个数为2个,最大参数个数为8个。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 - -- **CONCAT_WS** - ``` - SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:带分隔符的字符串连接函数。 +**返回结果类型**:同输入参数类型,BINARY 或者 NCHAR。 - 返回结果类型:同输入参数类型,BINARY或者NCHAR。 +**适用数据类型**:输入参数或者全部是 BINARY 格式的字符串或者列,或者全部是 NCHAR 格式的字符串或者列。不能应用在 TAG 列。 - 适用数据类型:输入参数或者全部是BINARY格式的字符串或者列,或者全部是NCHAR格式的字符串或者列。不能应用在TAG列。 +**使用说明**: - 说明: - - 如果separator值为NULL,输出值为NULL。如果separator值不为NULL,其他输入为NULL,输出为空串 - 该函数最小参数个数为3个,最大参数个数为9个。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 +- 如果输入值为NULL,输出值为NULL。 +- 该函数最小参数个数为2个,最大参数个数为8个。 +- 该函数可以应用在普通表和超级表上。 +- 该函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 -- **LENGTH** - ``` - SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:以字节计数的字符串长度。 +### CONCAT_WS - 返回结果类型:INT。 + ``` + SELECT CONCAT_WS(separator, str1|column1, str2|column2, ...) FROM { tb_name | stb_name } [WHERE clause] + ``` - 适用数据类型:输入参数是BINARY类型或者NCHAR类型的字符串或者列。不能应用在TAG列。 +**功能说明**:带分隔符的字符串连接函数。 - 说明: +**返回结果类型**:同输入参数类型,BINARY 或者 NCHAR。 - 如果输入值为NULL,输出值为NULL。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 +**适用数据类型**:输入参数或者全部是 BINARY 格式的字符串或者列,或者全部是 NCHAR 格式的字符串或者列。不能应用在 TAG 列。 -- **CHAR_LENGTH** - ``` - SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:以字符计数的字符串长度。 +**使用说明**: - 返回结果类型:INT。 +- 如果separator值为NULL,输出值为NULL。如果separator值不为NULL,其他输入为NULL,输出为空串 +- 该函数最小参数个数为3个,最大参数个数为9个。 +- 该函数可以应用在普通表和超级表上。 +- 该函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 - 适用数据类型:输入参数是BINARY类型或者NCHAR类型的字符串或者列。不能应用在TAG列。 +### LENGTH - 说明: - - 如果输入值为NULL,输出值为NULL。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 + ``` + SELECT LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] + ``` -- **LOWER** - ``` - SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:将字符串参数值转换为全小写字母。 +**功能说明**:以字节计数的字符串长度。 - 返回结果类型:同输入类型。 +**返回结果类型**:INT。 - 适用数据类型:输入参数是BINARY类型或者NCHAR类型的字符串或者列。不能应用在TAG列。 +**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 - 说明: - - 如果输入值为NULL,输出值为NULL。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 +**使用说明** -- **UPPER** - ``` - SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:将字符串参数值转换为全大写字母。 +- 如果输入值为NULL,输出值为NULL。 +- 该函数可以应用在普通表和超级表上。 +- 函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 - 返回结果类型:同输入类型。 +### CHAR_LENGTH - 适用数据类型:输入参数是BINARY类型或者NCHAR类型的字符串或者列。不能应用在TAG列。 + ``` + SELECT CHAR_LENGTH(str|column) FROM { tb_name | stb_name } [WHERE clause] + ``` - 说明: - - 如果输入值为NULL,输出值为NULL。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 +**功能说明**:以字符计数的字符串长度。 -- **LTRIM** - ``` - SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:返回清除左边空格后的字符串。 +**返回结果类型**:INT。 - 返回结果类型:同输入类型。 +**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 - 适用数据类型:输入参数是BINARY类型或者NCHAR类型的字符串或者列。不能应用在TAG列。 +**使用说明** - 说明: - - 如果输入值为NULL,输出值为NULL。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 +- 如果输入值为NULL,输出值为NULL。 +- 该函数可以应用在普通表和超级表上。 +- 该函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 -- **RTRIM** - ``` - SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:返回清除右边空格后的字符串。 +### LOWER - 返回结果类型:同输入类型。 + ``` + SELECT LOWER(str|column) FROM { tb_name | stb_name } [WHERE clause] + ``` - 适用数据类型:输入参数是BINARY类型或者NCHAR类型的字符串或者列。不能应用在TAG列。 +**功能说明**:将字符串参数值转换为全小写字母。 - 说明: - - 如果输入值为NULL,输出值为NULL。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 +**返回结果类型**:同输入类型。 -- **SUBSTR** - ``` - SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] - ``` - 功能说明:从源字符串str中的指定位置pos开始取一个长度为len的子串并返回。 +**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 + +**使用说明**: + +- 如果输入值为NULL,输出值为NULL。 +- 该函数可以应用在普通表和超级表上。 +- 该函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 + +### UPPER + + ``` + SELECT UPPER(str|column) FROM { tb_name | stb_name } [WHERE clause] + ``` + +**功能说明**:将字符串参数值转换为全大写字母。 + +**返回结果类型**:同输入类型。 + +**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 + +**使用说明**: + +- 如果输入值为NULL,输出值为NULL。 +- 该函数可以应用在普通表和超级表上。 +- 该函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 + +### LTRIM + + ``` + SELECT LTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] + ``` + +**功能说明**:返回清除左边空格后的字符串。 - 返回结果类型:同输入类型。 +**返回结果类型**:同输入类型。 - 适用数据类型:输入参数是BINARY类型或者NCHAR类型的字符串或者列。不能应用在TAG列。 +**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 - 说明: - - 如果输入值为NULL,输出值为NULL。 - 输入参数pos可以为正数,也可以为负数。如果pos是正数,表示从开始往后抽取子串。如果pos为负数,表示从结尾往前抽取字符串。如果输入参数len被忽略,返回的子串包含从pos开始的整个字串。 - 该函数可以应用在普通表和超级表上。 - 该函数适用于内层查询和外层查询。 - 版本2.6.0.x后支持 +**使用说明**: + +- 如果输入值为NULL,输出值为NULL。 +- 该函数可以应用在普通表和超级表上。 +- 该函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 + +### RTRIM + + ``` + SELECT RTRIM(str|column) FROM { tb_name | stb_name } [WHERE clause] + ``` + +**功能说明**:返回清除右边空格后的字符串。 + +**返回结果类型**:同输入类型。 + +**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 + +**使用说明**: + +- 如果输入值为NULL,输出值为NULL。 +- 该函数可以应用在普通表和超级表上。 +- 该函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 + +### SUBSTR + + ``` + SELECT SUBSTR(str,pos[,len]) FROM { tb_name | stb_name } [WHERE clause] + ``` + +**功能说明**:从源字符串 str 中的指定位置 pos 开始取一个长度为 len 的子串并返回。 + +**返回结果类型**:同输入类型。 + +**适用数据类型**:输入参数是 BINARY 类型或者 NCHAR 类型的字符串或者列。不能应用在 TAG 列。 + +**使用说明**: + +- 如果输入值为NULL,输出值为NULL。 +- 输入参数pos可以为正数,也可以为负数。如果pos是正数,表示开始位置从字符串开头正数计算。如果pos为负数,表示开始位置从字符串结尾倒数计算。如果输入参数len被忽略,返回的子串包含从pos开始的整个字串。 +- 该函数可以应用在普通表和超级表上。 +- 该函数适用于内层查询和外层查询。 +- 版本2.6.0.x后支持 ### 四则运算 @@ -1264,11 +1392,10 @@ SELECT field_name [+|-|*|/|%][Value|field_name] FROM { tb_name | stb_name } [WH **适用于**:表、超级表。 -说明: +**使用说明**: -1)支持两列或多列之间进行计算,可使用括号控制计算优先级; - -2)NULL 字段不参与计算,如果参与计算的某行中包含 NULL,该行的计算结果为 NULL。 +- 支持两列或多列之间进行计算,可使用括号控制计算优先级; +- NULL 字段不参与计算,如果参与计算的某行中包含 NULL,该行的计算结果为 NULL。 ``` taos> SELECT current + voltage * phase FROM d1001; @@ -1281,12 +1408,15 @@ Query OK, 3 row(s) in set (0.001046s) ``` ### STATECOUNT + ``` SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:返回满足某个条件的连续记录的个数,结果作为新的一列追加在每行后面。条件根据参数计算,如果条件为true则加1,条件为false则重置为-1,如果数据为NULL,跳过该条数据。 + +**功能说明**:返回满足某个条件的连续记录的个数,结果作为新的一列追加在每行后面。条件根据参数计算,如果条件为 true 则加 1,条件为 false 则重置为-1,如果数据为 NULL,跳过该条数据。 **参数范围**: + - oper : LT (小于)、GT(大于)、LE(小于等于)、GE(大于等于)、NE(不等于)、EQ(等于),不区分大小写。 - val : 数值型 @@ -1298,13 +1428,13 @@ SELECT STATECOUNT(field_name, oper, val) FROM { tb_name | stb_name } [WHERE clau **支持的版本**:2.6 开始的版本。 -**说明**: +**使用说明**: - 该函数可以应用在普通表上,在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname) +- 不能和窗口操作一起使用,例如 interval/state_window/session_window。 -- 不能和窗口操作一起使用,例如interval/state_window/session_window。 +**示例**: -示例: ``` taos> select ts,dbig from statef2; ts | dbig | @@ -1330,15 +1460,18 @@ Query OK, 6 row(s) in set (0.002791s) ``` ### STATEDURATION + ``` SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [WHERE clause]; ``` -**功能说明**:返回满足某个条件的连续记录的时间长度,结果作为新的一列追加在每行后面。条件根据参数计算,如果条件为true则加上两个记录之间的时间长度(第一个满足条件的记录时间长度记为0),条件为false则重置为-1,如果数据为NULL,跳过该条数据。 + +**功能说明**:返回满足某个条件的连续记录的时间长度,结果作为新的一列追加在每行后面。条件根据参数计算,如果条件为 true 则加上两个记录之间的时间长度(第一个满足条件的记录时间长度记为 0),条件为 false 则重置为-1,如果数据为 NULL,跳过该条数据。 **参数范围**: + - oper : LT (小于)、GT(大于)、LE(小于等于)、GE(大于等于)、NE(不等于)、EQ(等于),不区分大小写。 - val : 数值型 -- unit : 时间长度的单位,范围[1s、1m、1h ],不足一个单位舍去。默认为1s。 +- unit : 时间长度的单位,范围[1s、1m、1h ],不足一个单位舍去。默认为 1s。 **返回结果类型**:整形。 @@ -1348,13 +1481,13 @@ SELECT stateDuration(field_name, oper, val, unit) FROM { tb_name | stb_name } [W **支持的版本**:2.6 开始的版本。 -**说明**: +**使用说明**: - 该函数可以应用在普通表上,在由 GROUP BY 划分出单独时间线的情况下用于超级表(也即 GROUP BY tbname) +- 不能和窗口操作一起使用,例如 interval/state_window/session_window。 -- 不能和窗口操作一起使用,例如interval/state_window/session_window。 +**示例**: -示例: ``` taos> select ts,dbig from statef2; ts | dbig | @@ -1379,12 +1512,13 @@ ts | dbig | stateduration(dbig,gt,2) | Query OK, 6 row(s) in set (0.002613s) ``` -### 时间函数 +## 时间函数 -从 2.6.0.0 版本开始,TDengine查询引擎支持以下时间相关函数: +从 2.6.0.0 版本开始,TDengine 查询引擎支持以下时间相关函数: ### NOW -```mysql + +```sql SELECT NOW() FROM { tb_name | stb_name } [WHERE clause]; SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior NOW(); INSERT INTO tb_name VALUES (NOW(), ...); @@ -1394,17 +1528,19 @@ INSERT INTO tb_name VALUES (NOW(), ...); **返回结果数据类型**:TIMESTAMP 时间戳类型。 -**应用字段**:在 WHERE 或 INSERT 语句中使用时只能作用于TIMESTAMP类型的字段。 +**应用字段**:在 WHERE 或 INSERT 语句中使用时只能作用于 TIMESTAMP 类型的字段。 **适用于**:表、超级表。 -**说明**: - 1)支持时间加减操作,如NOW() + 1s, 支持的时间单位如下: - b(纳秒)、u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 - 2)返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +**使用说明**: -示例: -```mysql +- 支持时间加减操作,如 NOW() + 1s, 支持的时间单位如下: + b(纳秒)、u(微秒)、a(毫秒)、s(秒)、m(分)、h(小时)、d(天)、w(周)。 +- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 + +**示例**: + +```sql taos> SELECT NOW() FROM meters; now() | ========================== @@ -1427,12 +1563,14 @@ taos> INSERT INTO d1001 VALUES (NOW(), 10.2, 219, 0.32); Query OK, 1 of 1 row(s) in database (0.002210s) ``` -## TODAY -```mysql +### TODAY + +```sql SELECT TODAY() FROM { tb_name | stb_name } [WHERE clause]; SELECT select_expr FROM { tb_name | stb_name } WHERE ts_col cond_operatior TODAY()]; INSERT INTO tb_name VALUES (TODAY(), ...); ``` + **功能说明**:返回客户端当日零时的系统时间。 **返回结果数据类型**:TIMESTAMP 时间戳类型。 @@ -1441,13 +1579,15 @@ INSERT INTO tb_name VALUES (TODAY(), ...); **适用于**:表、超级表。 -**说明**: - 1)支持时间加减操作,如TODAY() + 1s, 支持的时间单位如下: - b(纳秒),u(微秒),a(毫秒),s(秒),m(分),h(小时),d(天),w(周)。 - 2)返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +**使用说明**: + +- 支持时间加减操作,如 TODAY() + 1s, 支持的时间单位如下: + b(纳秒),u(微秒),a(毫秒),s(秒),m(分),h(小时),d(天),w(周)。 +- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 + +**示例**: -示例: -```mysql +```sql taos> SELECT TODAY() FROM meters; today() | ========================== @@ -1470,10 +1610,12 @@ taos> INSERT INTO d1001 VALUES (TODAY(), 10.2, 219, 0.32); Query OK, 1 of 1 row(s) in database (0.002210s) ``` -## TIMEZONE -```mysql +### TIMEZONE + +```sql SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; ``` + **功能说明**:返回客户端当前时区信息。 **返回结果数据类型**:BINARY 类型。 @@ -1482,8 +1624,9 @@ SELECT TIMEZONE() FROM { tb_name | stb_name } [WHERE clause]; **适用于**:表、超级表。 -示例: -```mysql +**示例**: + +```sql taos> SELECT TIMEZONE() FROM meters; timezone() | ================================= @@ -1491,10 +1634,12 @@ taos> SELECT TIMEZONE() FROM meters; Query OK, 1 row(s) in set (0.002093s) ``` -## TO_ISO8601 -```mysql +### TO_ISO8601 + +```sql SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; ``` + **功能说明**:将 UNIX 时间戳转换成为 ISO8601 标准的日期时间格式,并附加客户端时区信息。 **返回结果数据类型**:BINARY 类型。 @@ -1503,10 +1648,14 @@ SELECT TO_ISO8601(ts_val | ts_col) FROM { tb_name | stb_name } [WHERE clause]; **适用于**:表、超级表。 -**说明**:如果输入是 UNIX 时间戳常量,返回格式精度由时间戳的位数决定,如果输入是 TIMSTAMP 类型的列,返回格式的时间戳精度与当前 DATABASE 设置的时间精度一致。 +**使用说明**: + +- 如果输入是 UNIX 时间戳常量,返回格式精度由时间戳的位数决定; +- 如果输入是 TIMSTAMP 类型的列,返回格式的时间戳精度与当前 DATABASE 设置的时间精度一致。 -示例: -```mysql +**示例**: + +```sql taos> SELECT TO_ISO8601(1643738400) FROM meters; to_iso8601(1643738400) | ============================== @@ -1520,24 +1669,28 @@ taos> SELECT TO_ISO8601(ts) FROM meters; 2022-02-02T02:00:00+0800 | ``` -## TO_UNIXTIMESTAMP -```mysql +### TO_UNIXTIMESTAMP + +```sql SELECT TO_UNIXTIMESTAMP(datetime_string | ts_col) FROM { tb_name | stb_name } [WHERE clause]; ``` + **功能说明**:将日期时间格式的字符串转换成为 UNIX 时间戳。 -**返回结果数据类型**:长整型INT64。 +**返回结果数据类型**:长整型 INT64。 **应用字段**:字符串常量或是 BINARY/NCHAR 类型的列。 **适用于**:表、超级表。 -说明: -1)输入的日期时间字符串须符合 ISO8601/RFC3339 标准,无法转换的字符串格式将返回0。 -2)返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +**使用说明**: -示例: -```mysql +- 输入的日期时间字符串须符合 ISO8601/RFC3339 标准,无法转换的字符串格式将返回 0。 +- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 + +**示例**: + +```sql taos> SELECT TO_UNIXTIMESTAMP("2022-02-02T02:00:00.000Z") FROM meters; to_unixtimestamp("2022-02-02T02:00:00.000Z") | ============================================== @@ -1551,10 +1704,12 @@ taos> SELECT TO_UNIXTIMESTAMP(col_binary) FROM meters; 1643767200000 | ``` -## TIMETRUNCATE -```mysql +### TIMETRUNCATE + +```sql SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name | stb_name } [WHERE clause]; ``` + **功能说明**:将时间戳按照指定时间单位 time_unit 进行截断。 **返回结果数据类型**:TIMESTAMP 时间戳类型。 @@ -1563,13 +1718,14 @@ SELECT TIMETRUNCATE(ts_val | datetime_string | ts_col, time_unit) FROM { tb_name **适用于**:表、超级表。 -说明: -1)支持的时间单位 time_unit 如下: - 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天)。 -2)返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 +**使用说明**: +- 支持的时间单位 time_unit 如下: + 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天)。 +- 返回的时间戳精度与当前 DATABASE 设置的时间精度一致。 + +**示例**: -示例: -```mysql +```sql taos> SELECT TIMETRUNCATE(1643738522000, 1h) FROM meters; timetruncate(1643738522000, 1h) | =================================== @@ -1591,25 +1747,28 @@ taos> SELECT TIMETRUNCATE(ts, 1h) FROM meters; Query OK, 3 row(s) in set (0.003903s) ``` -## TIMEDIFF -```mysql +### TIMEDIFF + +```sql SELECT TIMEDIFF(ts_val1 | datetime_string1 | ts_col1, ts_val2 | datetime_string2 | ts_col2 [, time_unit]) FROM { tb_name | stb_name } [WHERE clause]; ``` + **功能说明**:计算两个时间戳之间的差值,并近似到时间单位 time_unit 指定的精度。 -**返回结果数据类型**:长整型INT64。 +**返回结果数据类型**:长整型 INT64。 **应用字段**:UNIX 时间戳,日期时间格式的字符串,或者 TIMESTAMP 类型的列。 **适用于**:表、超级表。 -说明: -1)支持的时间单位 time_unit 如下: - 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天)。 -2)如果时间单位 time_unit 未指定, 返回的时间差值精度与当前 DATABASE 设置的时间精度一致。 +**使用说明**: +- 支持的时间单位 time_unit 如下: + 1u(微秒),1a(毫秒),1s(秒),1m(分),1h(小时),1d(天)。 +- 如果时间单位 time_unit 未指定, 返回的时间差值精度与当前 DATABASE 设置的时间精度一致。 + +**示例**: -示例: -```mysql +```sql taos> SELECT TIMEDIFF(1643738400000, 1643742000000) FROM meters; timediff(1643738400000, 1643742000000) | ========================================= diff --git a/docs-cn/14-reference/01-taos-sql/08-interval.md b/docs-cn/12-taos-sql/08-interval.md similarity index 94% rename from docs-cn/14-reference/01-taos-sql/08-interval.md rename to docs-cn/12-taos-sql/08-interval.md index 362ca1bef6ffa2b1e01d739907da5ebff726a500..d62e11b0dbd0ba49ceedb3807e05361f060969b3 100644 --- a/docs-cn/14-reference/01-taos-sql/08-interval.md +++ b/docs-cn/12-taos-sql/08-interval.md @@ -1,8 +1,8 @@ --- sidebar_label: 按窗口切分聚合 +title: 按窗口切分聚合 --- -# 按窗口切分聚合 TDengine 支持按时间段窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。 窗口子句用于针对查询的数据集合进行按照窗口切分成为查询子集并进行聚合,窗口包含时间窗口(time window)、状态窗口(status window)、会话窗口(session window)三种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。 @@ -16,13 +16,13 @@ INTERVAL 子句用于产生相等时间周期的窗口,SLIDING 用以指定窗 INTERVAL 和 SLIDING 子句需要配合聚合和选择函数来使用。以下 SQL 语句非法: ``` -SELECT * FROM temp_table INTERVAL(1S) +SELECT * FROM temp_tb_1 INTERVAL(1m); ``` SLIDING 的向前滑动的时间不能超过一个窗口的时间范围。以下语句非法: ``` -SELECT COUNT(*) FROM temp_table INTERVAL(1D) SLIDING(2D) +SELECT COUNT(*) FROM temp_tb_1 INTERVAL(1m) SLIDING(2m); ``` 当 SLIDING 与 INTERVAL 取值相等的时候,滑动窗口即为翻转窗口。 @@ -38,7 +38,7 @@ _ 从 2.1.5.0 版本开始,INTERVAL 语句允许的最短时间间隔调整为 使用 STATE_WINDOW 来确定状态窗口划分的列。例如: ``` -SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status) +SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status); ``` ## 会话窗口 @@ -51,7 +51,7 @@ SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status) ``` -SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val) +SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val); ``` 这种类型的查询语法如下: @@ -72,7 +72,7 @@ SELECT function_list FROM stb_name ``` - 在聚合查询中,function_list 位置允许使用聚合和选择函数,并要求每个函数仅输出单个结果(例如:COUNT、AVG、SUM、STDDEV、LEASTSQUARES、PERCENTILE、MIN、MAX、FIRST、LAST),而不能使用具有多行输出结果的函数(例如:DIFF 以及四则运算)。 -- 此外也 LAST_ROW 查询也不能与窗口聚合同时出现。 +- 此外 LAST_ROW 查询也不能与窗口聚合同时出现。 - 标量函数(如:CEIL/FLOOR 等)也不能使用在窗口聚合查询中。 - @@ -93,7 +93,7 @@ SELECT function_list FROM stb_name ::: -时间聚合也常被用于连续查询场景,可以参考文档 [连续查询(Continuous Query)](https://www.taosdata.com/cn/documentation/advanced-features#continuous-query)。 +时间聚合也常被用于连续查询场景,可以参考文档 [连续查询(Continuous Query)](/develop/continuous-query)。 ## 示例 diff --git a/docs-cn/14-reference/01-taos-sql/09-limit.md b/docs-cn/12-taos-sql/09-limit.md similarity index 64% rename from docs-cn/14-reference/01-taos-sql/09-limit.md rename to docs-cn/12-taos-sql/09-limit.md index c4e7c6b2f03f3a3f469d32f713bf15bba32f54bc..3c86a3862174377e6a00d046fb69627c773fe76e 100644 --- a/docs-cn/14-reference/01-taos-sql/09-limit.md +++ b/docs-cn/12-taos-sql/09-limit.md @@ -1,17 +1,17 @@ --- sidebar_label: 边界限制 +title: 边界限制 --- -# 边界限制 - ## 一般限制 - 数据库名最大长度为 32。 -- 表名最大长度为 192,每行数据最大长度 16k 个字符, 从 2.1.7.0 版本开始,每行数据最大长度 48k 个字符(注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)。 -- 列名最大长度为 64,最多允许 1024 列,最少需要 2 列,第一列必须是时间戳。(从 2.1.7.0 版本开始,改为最多允许 4096 列) -- 标签名最大长度为 64,最多允许 128 个,可以 1 个,一个表中标签值的总长度不超过 16k 个字符。 +- 表名最大长度为 192,不包括数据库名前缀和分隔符 +- 每行数据最大长度 16k 个字符, 从 2.1.7.0 版本开始,每行数据最大长度 48k 个字符(注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)。 +- 列名最大长度为 64,最多允许 4096 列,最少需要 2 列,第一列必须是时间戳。注:从 2.1.7.0 版本(不含)以前最多允许 4096 列 +- 标签名最大长度为 64,最多允许 128 个,至少要有 1 个标签,一个表中标签值的总长度不超过 16k 个字符。 - SQL 语句最大长度 1048576 个字符,也可通过客户端配置参数 maxSQLLength 修改,取值范围 65480 ~ 1048576。 -- SELECT 语句的查询结果,最多允许返回 1024 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。(从 2.1.7.0 版本开始,改为最多允许 4096 列) +- SELECT 语句的查询结果,最多允许返回 4096 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错。注: 2.1.7.0 版本(不含)之前为最多允许 1024 列 - 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制。 ## GROUP BY 的限制 @@ -35,17 +35,20 @@ IS NOT NULL 支持所有类型的列。不为空的表达式为 <\>"",仅对 ## 表(列)名合法性说明 -TDengine 中的表(列)名命名规则如下: +### TDengine 中的表(列)名命名规则如下: 只能由字母、数字、下划线构成,数字不能在首位,长度不能超过 192 字节,不区分大小写。这里表名称不包括数据库名的前缀和分隔符。 -转移后表(列)名规则: -为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`"。可用让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查,转义符不计入表名称的长度。 +### 转义后表(列)名规则: +为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`",可以避免表名与关键词的冲突,同时不受限于上述表名合法性约束检查,转义符不计入表名的长度。 转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 例如: \`aBc\` 和 \`abc\` 是不同的表(列)名,但是 abc 和 aBc 是相同的表(列)名。 -需要注意的是转义字符中的内容必须是可打印字符。 +:::note +转义字符中的内容必须是可打印字符。 + +::: -支持版本 +### 支持版本 支持转义符的功能从 2.3.0.1 版本开始。 \ No newline at end of file diff --git a/docs-cn/14-reference/01-taos-sql/10-json.md b/docs-cn/12-taos-sql/10-json.md similarity index 98% rename from docs-cn/14-reference/01-taos-sql/10-json.md rename to docs-cn/12-taos-sql/10-json.md index 6a06bd30ea9eec9eb8e1471d60f74416f6e45e96..4a4a8cca732ac433ba5ada1ec3805ebfa663edb3 100644 --- a/docs-cn/14-reference/01-taos-sql/10-json.md +++ b/docs-cn/12-taos-sql/10-json.md @@ -1,8 +1,8 @@ --- sidebar_label: JSON 类型使用说明 +title: JSON 类型使用说明 --- -# JSON 类型使用说明 ## 语法说明 diff --git a/docs-cn/14-reference/01-taos-sql/11-escape.md b/docs-cn/12-taos-sql/11-escape.md similarity index 73% rename from docs-cn/14-reference/01-taos-sql/11-escape.md rename to docs-cn/12-taos-sql/11-escape.md index be27dd4e7b6dd59264d8740f47d4baaf4182a678..756e5c81591e7414827fdc65e228cfafc96214ad 100644 --- a/docs-cn/14-reference/01-taos-sql/11-escape.md +++ b/docs-cn/12-taos-sql/11-escape.md @@ -1,4 +1,6 @@ -# 转义字符说明 +--- +title: 转义字符说明 +--- ## 转义字符表 @@ -25,4 +27,4 @@ 2. 反引号``标识符: 保持原样,不转义 2. 数据里有转义字符 1. 遇到上面定义的转义字符会转义(%和\_见下面说明),如果没有匹配的转义字符会忽略掉转义符\。 - 2. 对于%和*,因为在 like 里这两个字符是通配符,所以在模式匹配 like 里用`\%`%和`\_`表示字符里本身的%和*,如果在 like 模式匹配上下文之外使用`\%`或`\_`,则它们的计算结果为字符串`\%`和`\_`,而不是%和\_。 + 2. 对于%和\_,因为在 like 里这两个字符是通配符,所以在模式匹配 like 里用`\%`%和`\_`表示字符里本身的%和\_,如果在 like 模式匹配上下文之外使用`\%`或`\_`,则它们的计算结果为字符串`\%`和`\_`,而不是%和\_。 diff --git a/docs-cn/14-reference/06-keywords/_category_.yml b/docs-cn/12-taos-sql/12-keywords/_category_.yml similarity index 100% rename from docs-cn/14-reference/06-keywords/_category_.yml rename to docs-cn/12-taos-sql/12-keywords/_category_.yml diff --git a/docs-cn/14-reference/06-keywords/06-keywords.md b/docs-cn/12-taos-sql/12-keywords/index.md similarity index 99% rename from docs-cn/14-reference/06-keywords/06-keywords.md rename to docs-cn/12-taos-sql/12-keywords/index.md index e43d09e8123b46b51c04c2359d1f43e17d569c4c..608d4e080967cfd97072706cf0963ae669960be6 100644 --- a/docs-cn/14-reference/06-keywords/06-keywords.md +++ b/docs-cn/12-taos-sql/12-keywords/index.md @@ -1,7 +1,7 @@ --- sidebar_label: 参数限制与保留关键字 +title: TDengine 参数限制与保留关键字 --- -# TDengine 参数限制与保留关键字 ## 名称命名规则 diff --git a/docs-cn/14-reference/01-taos-sql/_category_.yml b/docs-cn/12-taos-sql/_category_.yml similarity index 100% rename from docs-cn/14-reference/01-taos-sql/_category_.yml rename to docs-cn/12-taos-sql/_category_.yml diff --git a/docs-cn/14-reference/01-taos-sql/01-taos-sql.md b/docs-cn/12-taos-sql/index.md similarity index 84% rename from docs-cn/14-reference/01-taos-sql/01-taos-sql.md rename to docs-cn/12-taos-sql/index.md index 2c8d11288e55fd007b62b0a5fecc7dc7f2dc2737..bc5c2efd67b5dca554ba7e7a0012477af2e373ab 100644 --- a/docs-cn/14-reference/01-taos-sql/01-taos-sql.md +++ b/docs-cn/12-taos-sql/index.md @@ -1,8 +1,10 @@ -# TAOS SQL +--- +title: TAOS SQL +--- 本文档说明 TAOS SQL 支持的语法规则、主要查询功能、支持的 SQL 查询函数,以及常用技巧等内容。阅读本文档需要读者具有基本的 SQL 语言的基础。 -TAOS SQL 是用户对 TDengine 进行数据写入和查询的主要工具。TAOS SQL 为了便于用户快速上手,在一定程度上提供类似于标准 SQL 类似的风格和模式。严格意义上,TAOS SQL 并不是也不试图提供 SQL 标准的语法。此外,由于 TDengine 针对的时序性结构化数据不提供删除功能,因此在 TAO SQL 中不提供数据删除的相关功能。 +TAOS SQL 是用户对 TDengine 进行数据写入和查询的主要工具。TAOS SQL 为了便于用户快速上手,在一定程度上提供与标准 SQL 类似的风格和模式。严格意义上,TAOS SQL 并不是也不试图提供标准的 SQL 语法。此外,由于 TDengine 针对的时序性结构化数据不提供删除功能,因此在 TAO SQL 中不提供数据删除的相关功能。 TAOS SQL 不支持关键字的缩写,例如 DESCRIBE 不能缩写为 DESC。 diff --git a/docs-cn/11-operation/01-pkg-install.md b/docs-cn/13-operation/01-pkg-install.md similarity index 71% rename from docs-cn/11-operation/01-pkg-install.md rename to docs-cn/13-operation/01-pkg-install.md index 257e9bb351bd18071dad7a7f149937c74e45c0ed..92b04a42ec9b3a80187d4482f465190288038f8d 100644 --- a/docs-cn/11-operation/01-pkg-install.md +++ b/docs-cn/13-operation/01-pkg-install.md @@ -1,13 +1,20 @@ -# 安装、卸载、启动和停止 +--- +title: 安装和卸载 +description: 安装、卸载、启动、停止和升级 +--- -TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 等系统,rpm 支持 CentOS/RHEL/SUSE 等系统。同时我们也为企业用户提供 tar.gz 格式安装包。 +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; -## deb 包的安装和卸载 +TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包。 -### 安装 deb +## 安装 -1、从官网下载获得 deb 安装包,比如 TDengine-server-2.0.0.0-Linux-x64.deb; -2、进入到 TDengine-server-2.0.0.0-Linux-x64.deb 安装包所在目录,执行如下的安装命令: + + + +1、从官网下载获得 deb 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.deb; +2、进入到 TDengine-server-2.4.0.7-Linux-x64.deb 安装包所在目录,执行如下的安装命令: ``` $ sudo dpkg -i TDengine-server-2.4.0.7-Linux-x64.deb @@ -18,7 +25,7 @@ Unpacking tdengine (2.4.0.7) over (2.4.0.7) ... Setting up tdengine (2.4.0.7) ... Start to install TDengine... -System hostname is: shuduo-1804 +System hostname is: ubuntu-1804 Enter FQDN:port (like h1.taosdata.com:6030) of an existing TDengine cluster node to join OR leave it blank to build one: @@ -28,33 +35,18 @@ Created symlink /etc/systemd/system/multi-user.target.wants/taosd.service → /e To configure TDengine : edit /etc/taos/taos.cfg To start TDengine : sudo systemctl start taosd -To access TDengine : taos -h shuduo-1804 to login into TDengine server +To access TDengine : taos -h ubuntu-1804 to login into TDengine server TDengine is installed successfully! ``` -注:当安装第一个节点时,出现 Enter FQDN:提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。 - -后续两种安装包也是同样的操作。 + -### 卸载 deb + -卸载命令如下: - -``` -$ sudo dpkg -r tdengine -(Reading database ... 137504 files and directories currently installed.) -Removing tdengine (2.4.0.7) ... -TDengine is removed successfully! -``` - -## rpm 包的安装和卸载 - -### 安装 rpm - -1、从官网下载获得 rpm 安装包,比如 TDengine-server-2.0.0.0-Linux-x64.rpm; -2、进入到 TDengine-server-2.0.0.0-Linux-x64.rpm 安装包所在目录,执行如下的安装命令: +1、从官网下载获得 rpm 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.rpm; +2、进入到 TDengine-server-2.4.0.7-Linux-x64.rpm 安装包所在目录,执行如下的安装命令: ``` $ sudo rpm -ivh TDengine-server-2.4.0.7-Linux-x64.rpm @@ -80,20 +72,11 @@ To access TDengine : taos -h centos7 to login into TDengine server TDengine is installed successfully! ``` -### 卸载 rpm - -卸载命令如下: - -``` -$ sudo rpm -e tdengine -TDengine is removed successfully! -``` - -## tar.gz 格式安装包的安装和卸载 + -### 安装 tar.gz 安装包 + -1、从官网下载获得 tar.gz 安装包,比如 TDengine-server-2.4.0.7-Linux-x64.tar.gz; +1、从官网下载获得 tar.gz 安装包,例如 TDengine-server-2.4.0.7-Linux-x64.tar.gz; 2、进入到 TDengine-server-2.4.0.7-Linux-x64.tar.gz 安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本: ``` @@ -133,16 +116,55 @@ Nginx for TDengine is updated successfully! To configure TDengine : edit /etc/taos/taos.cfg To configure Taos Adapter (if has) : edit /etc/taos/taosadapter.toml To start TDengine : sudo systemctl start taosd -To access TDengine : use taos -h shuduo-1804 in shell OR from http://127.0.0.1:6060 +To access TDengine : use taos -h ubuntu-1804 in shell OR from http://127.0.0.1:6060 TDengine is updated successfully! Install taoskeeper as a standalone service taoskeeper is installed, enable it by `systemctl enable taoskeeper` ``` -说明:install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以用 -e no 参数来执行 install.sh 脚本。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。 +:::info +install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以用 -e no 参数来执行 install.sh 脚本。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。 -### tar.gz 安装后的卸载 +::: + + + + +:::note +当安装第一个节点时,出现 Enter FQDN:提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。 + +::: + +## 卸载 + + + + +卸载命令如下: + +``` +$ sudo dpkg -r tdengine +(Reading database ... 137504 files and directories currently installed.) +Removing tdengine (2.4.0.7) ... +TDengine is removed successfully! + +``` + + + + + +卸载命令如下: + +``` +$ sudo rpm -e tdengine +TDengine is removed successfully! +``` + + + + 卸载命令如下: @@ -154,6 +176,30 @@ TDengine is removed successfully! taosKeeper is removed successfully! ``` + + + +:::info +- TDengine 提供了多种安装包,但最好不要在一个系统上同时使用 tar.gz 安装包和 deb 或 rpm 安装包。否则会相互影响,导致在使用时出现问题。 + +- 对于 deb 包安装后,如果安装目录被手工误删了部分,出现卸载、或重新安装不能成功。此时,需要清除 TDengine 包的安装信息,执行如下命令: + + ``` + $ sudo rm -f /var/lib/dpkg/info/tdengine* + ``` + +然后再重新进行安装就可以了。 + +- 对于 rpm 包安装后,如果安装目录被手工误删了部分,出现卸载、或重新安装不能成功。此时,需要清除 TDengine 包的安装信息,执行如下命令: + + ``` + $ sudo rpm -e --noscripts tdengine + ``` + +然后再重新进行安装就可以了。 + +::: + ## 安装目录说明 TDengine 成功安装后,主安装目录是 /usr/local/taos,目录内容如下: @@ -188,7 +234,7 @@ lrwxrwxrwx 1 root root 13 Feb 22 09:34 log -> /var/log/taos/ 如果是更新安装,当缺省配置文件( /etc/taos/taos.cfg )存在时,仍然使用已有的配置文件,安装包中携带的配置文件修改为 taos.cfg.orig 保存在 /usr/local/taos/cfg/ 目录,可以作为设置配置参数的参考样例;如果不存在配置文件,就使用安装包中自带的配置文件。 -## TDengine 的启动、停止、卸载 +## 启动和停止 TDengine 使用 Linux 系统的 systemd/systemctl/service 来管理系统的启动和、停止、重启操作。TDengine 的服务进程是 taosd,默认情况下 TDengine 在系统启动后将自动启动。DBA 可以通过 systemd/systemctl/service 手动操作停止、启动、重新启动服务。 @@ -206,40 +252,32 @@ TDengine 使用 Linux 系统的 systemd/systemctl/service 来管理系统的启 如果服务进程处于活动状态,则 status 指令会显示如下的相关信息: -``` -...... - -Active: active (running) - -...... -``` + ``` + Active: active (running) + ``` 如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息: -``` -...... - -Active: inactive (dead) - -...... -``` - -## 注意事项 - -- TDengine 提供了多种安装包,但最好不要在一个系统上同时使用 tar.gz 安装包和 deb 或 rpm 安装包。否则会相互影响,导致在使用时出现问题。 - -- 对于 deb 包安装后,如果安装目录被手工误删了部分,出现卸载、或重新安装不能成功。此时,需要清除 TDengine 包的安装信息,执行如下命令: + ``` + Active: inactive (dead) + ``` -``` -$ sudo rm -f /var/lib/dpkg/info/tdengine* -``` +## 升级 +升级分为两个层面:升级安装包 和 升级运行中的实例。 -然后再重新进行安装就可以了。 +升级安装包请遵循前述安装和卸载的步骤先卸载旧版本再安装新版本。 -- 对于 rpm 包安装后,如果安装目录被手工误删了部分,出现卸载、或重新安装不能成功。此时,需要清除 TDengine 包的安装信息,执行如下命令: +升级运行中的实例则要复杂得多,首先请注意版本号,TDengine 的版本号目前分为四段,如 2.4.0.14 和 2.4.0.16,只有前三段版本号一致(即只有第四段版本号不同)才能把一个运行中的实例进行升级。升级步骤如下: +- 停止数据写入 +- 确保所有数据落盘,即写入时序数据库 +- 停止 TDengine 集群 +- 卸载旧版本并安装新版本 +- 重新启动 TDengine 集群 +- 进行简单的查询操作确认旧数据没有丢失 +- 进行简单的写入操作确认 TDengine 集群可用 +- 重新恢复业务数据的写入 -``` -$ sudo rpm -e --noscripts tdengine -``` +:::warning +TDengine 不保证低版本能够兼容高版本的数据,所以任何时候都不推荐降级 -然后再重新进行安装就可以了。 +::: \ No newline at end of file diff --git a/docs-cn/11-operation/02-planning.mdx b/docs-cn/13-operation/02-planning.mdx similarity index 90% rename from docs-cn/11-operation/02-planning.mdx rename to docs-cn/13-operation/02-planning.mdx index 1e62c54ff04f4204be996cf2c92b51f6fdf59d91..954ba7ca00ebdcb10cfcad515292d96127106ff3 100644 --- a/docs-cn/11-operation/02-planning.mdx +++ b/docs-cn/13-operation/02-planning.mdx @@ -1,9 +1,8 @@ --- sidebar_label: 容量规划 +title: 容量规划 --- -# 容量规划 - 使用 TDengine 来搭建一个物联网大数据平台,计算资源、存储资源需要根据业务场景进行规划。下面分别讨论系统运行所需要的内存、CPU 以及硬盘空间。 ## 内存需求 @@ -11,10 +10,10 @@ sidebar_label: 容量规划 每个 Database 可以创建固定数目的 vgroup,默认与 CPU 核数相同,可通过 maxVgroupsPerDb 配置;vgroup 中的每个副本会是一个 vnode;每个 vnode 会占用固定大小的内存(大小与数据库的配置参数 blocks 和 cache 有关);每个 Table 会占用与标签总长度有关的内存;此外,系统会有一些固定的内存开销。因此,每个 DB 需要的系统内存可通过如下公式计算: ``` -Database Memory Size = maxVgroupsPerDb * (blocks * cache + 10MB) + numOfTables * (tagSizePerTable + 0.5KB) +Database Memory Size = maxVgroupsPerDb * replica * (blocks * cache + 10MB) + numOfTables * (tagSizePerTable + 0.5KB) ``` -示例:假设是 4 核机器,cache 是缺省大小 16M, blocks 是缺省值 6,并且一个 DB 中有 10 万张表,标签总长度是 256 字节,则这个 DB 总的内存需求为:4 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 499M。 +示例:假设 maxVgroupPerDB 是缺省值 64,cache 是缺省大小 16M, blocks 是缺省值 6,并且一个 DB 中有 10 万张表,单副本,标签总长度是 256 字节,则这个 DB 总的内存需求为:64 \* 1 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 6792M。 在实际的系统运维中,我们通常会更关心 TDengine 服务进程(taosd)会占用的内存量。 @@ -30,7 +29,7 @@ taosd 内存总量 = vnode 内存 + mnode 内存 + 查询内存 注意:以上内存估算方法,主要讲解了系统的“必须内存需求”,而不是“内存总数上限”。在实际运行的生产环境中,由于操作系统缓存、资源管理调度等方面的原因,内存规划应当在估算结果的基础上保留一定冗余,以维持系统状态和系统性能的稳定性。并且,生产环境通常会配置系统资源的监控工具,以便及时发现硬件资源的紧缺情况。 -最后,如果内存充裕,可以考虑加大 Blocks 的配置,这样更多数据将保存在内存里,提高查询速度。 +最后,如果内存充裕,可以考虑加大 Blocks 的配置,这样更多数据将保存在内存里,提高写入和查询速度。 ### 客户端内存需求 @@ -79,4 +78,4 @@ Raw DataSize = numOfTables * rowSizePerTable * rowsPerTable 因为 TDengine 具有很好的水平扩展能力,根据总量,再根据单个物理机或虚拟机的资源,就可以轻松决定需要购置多少台物理机或虚拟机了。 -**立即计算 CPU、内存、存储,请参见:[资源估算方法](https://www.taosdata.com/config/config.html)。** \ No newline at end of file +**立即计算 CPU、内存、存储,请参见:[资源估算方法](https://www.taosdata.com/config/config.html)。** diff --git a/docs-cn/11-operation/03-tolerance.md b/docs-cn/13-operation/03-tolerance.md similarity index 98% rename from docs-cn/11-operation/03-tolerance.md rename to docs-cn/13-operation/03-tolerance.md index bd293f1609d1fd7bfd5ef22171ed13ff0e822a25..054e5c4cee07f7066038a6bfc5c4b25306b033ce 100644 --- a/docs-cn/11-operation/03-tolerance.md +++ b/docs-cn/13-operation/03-tolerance.md @@ -1,4 +1,6 @@ -# 容错和灾备 +--- +title: 容错和灾备 +--- ## 容错 diff --git a/docs-cn/11-operation/06-admin.md b/docs-cn/13-operation/06-admin.md similarity index 96% rename from docs-cn/11-operation/06-admin.md rename to docs-cn/13-operation/06-admin.md index 9829cc2db0dea629af0d7accc705123da06d5545..7934d31eafb774fb45e1902bee29e8b518d152d6 100644 --- a/docs-cn/11-operation/06-admin.md +++ b/docs-cn/13-operation/06-admin.md @@ -1,4 +1,6 @@ -# 用户管理 +--- +title: 用户管理 +--- 系统管理员可以在 CLI 界面里添加、删除用户,也可以修改密码。CLI 里 SQL 语法如下: @@ -28,7 +30,7 @@ ALTER USER PRIVILEGE ; 说明:系统内共有 super/write/read 三种权限级别,但目前不允许通过 alter 指令把 super 权限赋予用户。 -```mysql +```sql SHOW USERS; ``` diff --git a/docs-cn/11-operation/07-import.md b/docs-cn/13-operation/07-import.md similarity index 95% rename from docs-cn/11-operation/07-import.md rename to docs-cn/13-operation/07-import.md index 0d7517c4389badbe72bf226c8365ccf8995f69a3..7dee05720d4c3446181e8e0d81a5c27e35300ba8 100644 --- a/docs-cn/11-operation/07-import.md +++ b/docs-cn/13-operation/07-import.md @@ -1,4 +1,6 @@ -# 数据导入 +--- +title: 数据导入 +--- TDengine 提供多种方便的数据导入功能,一种按脚本文件导入,一种按数据文件导入,一种是 taosdump 工具导入本身导出的文件。 @@ -10,7 +12,7 @@ TDengine 的 shell 支持 source filename 命令,用于批量运行文件中 TDengine 也支持在 shell 对已存在的表从 CSV 文件中进行数据导入。CSV 文件只属于一张表且 CSV 文件中的数据格式需与要导入表的结构相同,在导入的时候,其语法如下: -```mysql +```sql insert into tb1 file 'path/data.csv'; ``` @@ -21,7 +23,7 @@ insert into tb1 file 'path/data.csv'; 例如,现在存在一个子表 d1001, 其表结构如下: -```mysql +```sql taos> DESCRIBE d1001 Field | Type | Length | Note | ================================================================================= @@ -49,11 +51,11 @@ taos> DESCRIBE d1001 那么可以用如下命令导入数据: -```mysql +```sql taos> insert into d1001 file '~/data.csv'; Query OK, 9 row(s) affected (0.004763s) ``` ## taosdump 工具导入 -TDengine 提供了方便的数据库导入导出工具 taosdump。用户可以将 taosdump 从一个系统导出的数据,导入到其他系统中。具体使用方法,请参见:[TDengine 数据备份工具: taosdump](https://www.taosdata.com/docs/cn/v2.0/tools/taosdump)。 +TDengine 提供了方便的数据库导入导出工具 taosdump。用户可以将 taosdump 从一个系统导出的数据,导入到其他系统中。具体使用方法,请参见:[TDengine 数据备份工具: taosdump](/reference/taosdump)。 diff --git a/docs-cn/11-operation/08-export.md b/docs-cn/13-operation/08-export.md similarity index 71% rename from docs-cn/11-operation/08-export.md rename to docs-cn/13-operation/08-export.md index a2ac4f4c45003d35ca33d2531734072268ff2365..042ecc7ba29f976d50bbca1e3155bd03b2ae7ccc 100644 --- a/docs-cn/11-operation/08-export.md +++ b/docs-cn/13-operation/08-export.md @@ -1,4 +1,6 @@ -# 数据导出 +--- +title: 数据导出 +--- 为方便数据导出,TDengine 提供了两种导出方式,分别是按表导出和用 taosdump 导出。 @@ -6,7 +8,7 @@ 如果用户需要导出一个表或一个 STable 中的数据,可在 taos shell 中运行: -```mysql +```sql select * from >> data.csv; ``` @@ -14,6 +16,5 @@ select * from >> data.csv; ## 用 taosdump 导出数据 -利用 taosdump,用户可以根据需要选择导出所有数据库、一个数据库或者数据库中的一张表,所有数据或一时间段的数据,甚至仅仅表的定义。 - -具体使用方法,请参见博客:[TDengine DUMP 工具使用指南](https://www.taosdata.com/blog/2020/03/09/1334.html)。 \ No newline at end of file +利用 taosdump,用户可以根据需要选择导出所有数据库、一个数据库或者数据库中的一张表,所有数据或一时间段的数据,甚至仅仅表的定义。具体使用方法,请参见: +[TDengine 数据备份工具: taosdump](/reference/taosdump)。 diff --git a/docs-cn/13-operation/09-status.md b/docs-cn/13-operation/09-status.md new file mode 100644 index 0000000000000000000000000000000000000000..e7ae78bace91f6dab06591340965ba04efdd5edb --- /dev/null +++ b/docs-cn/13-operation/09-status.md @@ -0,0 +1,53 @@ +--- +title: 系统连接、任务查询管理 +--- + +系统管理员可以从 CLI 查询系统的连接、正在进行的查询、流式计算,并且可以关闭连接、停止正在进行的查询和流式计算。 + +## 显示数据库的连接 + +```sql +SHOW CONNECTIONS; +``` + +其结果中的一列显示 ip:port, 为连接的 IP 地址和端口号。 + +## 强制关闭数据库连接 + +```sql +KILL CONNECTION ; +``` + +其中的 connection-id 是 SHOW CONNECTIONS 中显示的第一列的数字。 + +## 显示数据查询 + +```sql +SHOW QUERIES; +``` + +其中第一列显示的以冒号隔开的两个数字为 query-id,为发起该 query 应用连接的 connection-id 和查询次数。 + +## 强制关闭数据查询 + +```sql +KILL QUERY ; +``` + +其中 query-id 是 SHOW QUERIES 中显示的 connection-id:query-no 字串,如“105:2”,拷贝粘贴即可。 + +## 显示连续查询 + +```sql +SHOW STREAMS; +``` + +其中第一列显示的以冒号隔开的两个数字为 stream-id, 为启动该 stream 应用连接的 connection-id 和发起 stream 的次数。 + +## 强制关闭连续查询 + +```sql +KILL STREAM ; +``` + +其中的 stream-id 是 SHOW STREAMS 中显示的 connection-id:stream-no 字串,如 103:2,拷贝粘贴即可。 diff --git a/docs-cn/11-operation/10-monitor.md b/docs-cn/13-operation/10-monitor.md similarity index 94% rename from docs-cn/11-operation/10-monitor.md rename to docs-cn/13-operation/10-monitor.md index 367d1dd54ef5d53b43542600c55b8337e721c013..e30be775fb5c337b2a621bea92d3af31a2cb5cc0 100644 --- a/docs-cn/11-operation/10-monitor.md +++ b/docs-cn/13-operation/10-monitor.md @@ -1,4 +1,6 @@ -# 系统监控 +--- +title: 系统监控 +--- TDengine 启动后,会自动创建一个监测数据库 log,并自动将服务器的 CPU、内存、硬盘空间、带宽、请求数、磁盘读写速度、慢查询等信息定时写入该数据库。TDengine 还将重要的系统操作(比如登录、创建、删除数据库等)日志以及各种错误报警信息记录下来存放在 log 库里。系统管理员可以从 CLI 直接查看这个数据库,也可以在 WEB 通过图形化界面查看这些监测信息。 @@ -49,4 +51,4 @@ chmod +x TDinsight.sh 运行程序并重启 Grafana 服务,打开面板:`http://localhost:3000/d/tdinsight`。 -更多使用场景和限制请参考[TDinsight](https://github.com/taosdata/grafanaplugin/blob/master/dashboards/TDinsight.md) 文档。 +更多使用场景和限制请参考[TDinsight](/reference/tdinsight/) 文档。 diff --git a/docs-cn/11-operation/11-optimize.md b/docs-cn/13-operation/11-optimize.md similarity index 83% rename from docs-cn/11-operation/11-optimize.md rename to docs-cn/13-operation/11-optimize.md index b06df1d32a80362e4ea28e92d1c12b6b58b83896..57411dbbb0705ae4c9c4568bb09909918bcee6a3 100644 --- a/docs-cn/11-operation/11-optimize.md +++ b/docs-cn/13-operation/11-optimize.md @@ -1,8 +1,10 @@ -# 性能优化 +--- +title: 性能优化 +--- -因数据行 [update](https://www.taosdata.com/cn/documentation/faq#update)、表删除、数据过期等原因,TDengine 的磁盘存储文件有可能出现数据碎片,影响查询操作的性能表现。从 2.1.3.0 版本开始,新增 SQL 指令 COMPACT 来启动碎片重整过程: +因数据行 [update](/train-faq/faq/#update)、表删除、数据过期等原因,TDengine 的磁盘存储文件有可能出现数据碎片,影响查询操作的性能表现。从 2.1.3.0 版本开始,新增 SQL 指令 COMPACT 来启动碎片重整过程: -```mysql +```sql COMPACT VNODES IN (vg_id1, vg_id2, ...) ``` @@ -10,20 +12,19 @@ COMPACT 命令对指定的一个或多个 VGroup 启动碎片重整,系统会 需要注意的是,碎片重整操作会大幅消耗磁盘 I/O。因此在重整进行期间,有可能会影响节点的写入和查询性能,甚至在极端情况下导致短时间的阻写。 - ## 存储参数优化 不同应用场景的数据往往具有不同的数据特征,比如保留天数、副本数、采集频次、记录大小、采集点的数量、压缩等都可完全不同。为获得在存储上的最高效率,TDengine 提供如下存储相关的系统配置参数(既可以作为 create database 指令的参数,也可以写在 taos.cfg 配置文件中用来设定创建新数据库时所采用的默认值): | # | 配置参数名称 | 单位 | 含义 | **取值范围** | **缺省值** | | --- | ------------ | ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------- | -| 1 | days | 天 | 一个数据文件存储数据的时间跨度 | | 10 | -| 2 | keep | 天 | (可通过 alter database 修改)数据库中数据保留的天数。 | 3650 | -| 3 | cache | MB | 内存块的大小 | | 16 | -| 4 | blocks | | (可通过 alter database 修改)每个 VNODE(TSDB)中有多少个 cache 大小的内存块。因此一个 VNODE 使用的内存大小粗略为(cache \* blocks)。 | | 6 | +| 1 | days | 天 | 一个数据文件存储数据的时间跨度 | 1-3650 | 10 | +| 2 | keep | 天 | (可通过 alter database 修改)数据库中数据保留的天数。 |1-36500 |3650 | +| 3 | cache | MB | 内存块的大小 | 1-128 | 16 | +| 4 | blocks | | (可通过 alter database 修改)每个 VNODE(TSDB)中有多少个 cache 大小的内存块。因此一个 VNODE 使用的内存大小粗略为(cache \* blocks)。 | 3-10000 | 6 | | 5 | quorum | | (可通过 alter database 修改)多副本环境下指令执行的确认数要求 | 1-2 | 1 | -| 6 | minRows | | 文件块中记录的最小条数 | | 100 | -| 7 | maxRows | | 文件块中记录的最大条数 | | 4096 | +| 6 | minRows | | 文件块中记录的最小条数 | 10-1000 | 100 | +| 7 | maxRows | | 文件块中记录的最大条数 | 200-10000 | 4096 | | 8 | comp | | (可通过 alter database 修改)文件压缩标志位 | 0:关闭,1:一阶段压缩,2:两阶段压缩 | 2 | | 9 | walLevel | | (作为 database 的参数时名为 wal;在 taos.cfg 中作为参数时需要写作 walLevel)WAL 级别 | 1:写 wal,但不执行 fsync;2:写 wal, 而且执行 fsync | 1 | | 10 | fsync | 毫秒 | 当 wal 设置为 2 时,执行 fsync 的周期。设置为 0,表示每次写入,立即执行 fsync。 | | 3000 | @@ -34,7 +35,7 @@ COMPACT 命令对指定的一个或多个 VGroup 启动碎片重整,系统会 对于一个应用场景,可能有多种数据特征的数据并存,最佳的设计是将具有相同数据特征的表放在一个库里,这样一个应用有多个库,而每个库可以配置不同的存储参数,从而保证系统有最优的性能。TDengine 允许应用在创建库时指定上述存储参数,如果指定,该参数就将覆盖对应的系统配置参数。举例,有下述 SQL: -```mysql +```sql CREATE DATABASE demo DAYS 10 CACHE 32 BLOCKS 8 REPLICA 3 UPDATE 1; ``` @@ -42,27 +43,27 @@ COMPACT 命令对指定的一个或多个 VGroup 启动碎片重整,系统会 一个数据库创建成功后,仅部分参数可以修改并实时生效,其余参数不能修改: -| **参数名** | **能否修改** | **范围** | **修改语法示例** | -| ----------- | ------------ | ------------------------------------------ | -------------------------------------- | -| name | | | | -| create time | | | | -| ntables | | | | -| vgroups | | | | -| replica | **YES** | 在线 dnode 数目为 1:1-1;2:1-2;>=3:1-3 | ALTER DATABASE REPLICA _n_ | -| quorum | **YES** | 1-2 | ALTER DATABASE QUORUM _n_ | -| days | | | | -| keep | **YES** | days-365000 | ALTER DATABASE KEEP _n_ | -| cache | | | | -| blocks | **YES** | 3-1000 | ALTER DATABASE BLOCKS _n_ | -| minrows | | | | -| maxrows | | | | -| wal | | | | -| fsync | | | | -| comp | **YES** | 0-2 | ALTER DATABASE COMP _n_ | -| precision | | | | -| status | | | | -| update | | | | -| cachelast | **YES** | 0 \| 1 \| 2 \| 3 | ALTER DATABASE CACHELAST _n_ | +| **参数名** | **能否修改** | **范围** | **修改语法示例** | +| ----------- | ------------ | ---------------------------------------------------------- | -------------------------------------- | +| name | | | | +| create time | | | | +| ntables | | | | +| vgroups | | | | +| replica | **YES** | 在线 dnode 数目为:
1:1-1;
2:1-2;
\>=3:1-3 | ALTER DATABASE REPLICA _n_ | +| quorum | **YES** | 1-2 | ALTER DATABASE QUORUM _n_ | +| days | | | | +| keep | **YES** | days-365000 | ALTER DATABASE KEEP _n_ | +| cache | | | | +| blocks | **YES** | 3-1000 | ALTER DATABASE BLOCKS _n_ | +| minrows | | | | +| maxrows | | | | +| wal | | | | +| fsync | | | | +| comp | **YES** | 0-2 | ALTER DATABASE COMP _n_ | +| precision | | | | +| status | | | | +| update | | | | +| cachelast | **YES** | 0 \| 1 \| 2 \| 3 | ALTER DATABASE CACHELAST _n_ | **说明:**在 2.1.3.0 版本之前,通过 ALTER DATABASE 语句修改这些参数后,需要重启服务器才能生效。 @@ -83,7 +84,7 @@ TDengine 集群中加入一个新的 dnode 时,涉及集群相关的一些参 为方便调试,可通过 SQL 语句临时调整每个 dnode 的日志配置,系统重启后会失效: -```mysql +```sql ALTER DNODE ``` @@ -97,4 +98,3 @@ ALTER DNODE ``` alter dnode 1 debugFlag 135; ``` - diff --git a/docs-cn/11-operation/17-diagnose.md b/docs-cn/13-operation/17-diagnose.md similarity index 92% rename from docs-cn/11-operation/17-diagnose.md rename to docs-cn/13-operation/17-diagnose.md index 666fe6e655cab27962d156d97bf14086feaa32b5..e2a2ef035a33a295b206c77ec08edf8f7842671f 100644 --- a/docs-cn/11-operation/17-diagnose.md +++ b/docs-cn/13-operation/17-diagnose.md @@ -1,4 +1,6 @@ -# 诊断及其他 +--- +title: 诊断及其他 +--- ## 网络连接诊断 @@ -9,8 +11,11 @@ 诊断步骤: 1. 如拟诊断的端口范围与服务器 taosd 实例的端口范围相同,须先停掉 taosd 实例 -2. 服务端命令行输入:`taos -n server -P ` 以服务端身份启动对端口 port 为基准端口的监听 -3. 客户端命令行输入:`taos -n client -h -P ` 以客户端身份启动对指定的服务器、指定的端口发送测试包 +2. 服务端命令行输入:`taos -n server -P -l ` 以服务端身份启动对端口 port 为基准端口的监听 +3. 客户端命令行输入:`taos -n client -h -P -l ` 以客户端身份启动对指定的服务器、指定的端口发送测试包 + +-l : 测试网络包的大小(单位:字节)。最小值是 11、最大值是 64000,默认值为 1000。 +注:两端命令行中指定的测试包长度必须一致,否则测试显示失败。 服务端运行正常的话会输出以下信息: @@ -94,7 +99,7 @@ taos -n sync -P 6042 -h -h:所要连接的服务端的 FQDN 或 ip 地址。如果不设置这一项,会使用本机 taos.cfg 文件中 FQDN 参数的设置作为默认值。 -P:所连接服务端的网络端口。默认值为 6030。 -N:诊断过程中使用的网络包总数。最小值是 1、最大值是 10000,默认值为 100。 --l:单个网络包的大小(单位:字节)。最小值是 1024、最大值是 1024 _ 1024 _ 1024,默认值为 1000。 +-l:单个网络包的大小(单位:字节)。最小值是 1024、最大值是 1024 `*` 1024 `*` 1024,默认值为 1024。 -S:网络封包的类型。可以是 TCP 或 UDP,默认值为 TCP。 ## FQDN 解析速度诊断 diff --git a/docs-cn/13-operation/_category_.yml b/docs-cn/13-operation/_category_.yml new file mode 100644 index 0000000000000000000000000000000000000000..930e441defdc80215ce5d90375a9cbd2d4bad947 --- /dev/null +++ b/docs-cn/13-operation/_category_.yml @@ -0,0 +1,4 @@ +label: 运维指南 +link: + slug: /operation/ + type: generated-index diff --git a/docs-cn/13-tdinternal/03-taosd.md b/docs-cn/13-tdinternal/03-taosd.md deleted file mode 100644 index 874fa230290016b88fbc905233745a1052ca5a18..0000000000000000000000000000000000000000 --- a/docs-cn/13-tdinternal/03-taosd.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -sidebar_label: taosd 的设计 ---- - -# taosd的设计 - -逻辑上,TDengine系统包含dnode, taosc和App,dnode是服务器侧执行代码taosd的一个运行实例,因此taosd是TDengine的核心,本文对taosd的设计做一简单的介绍,模块内的实现细节请见其他文档。 - -## 系统模块图 - -taosd包含rpc, dnode, vnode, tsdb, query, cq, sync, wal, mnode, http, monitor等模块,具体如下图: - -![modules.png](/img/architecture/modules.png) - -taosd的启动入口是dnode模块,dnode然后启动其他模块,包括可选配置的http, monitor模块。taosc或dnode之间交互的消息都是通过rpc模块进行,dnode模块根据接收到的消息类型,将消息分发到vnode或mnode的消息队列,或由dnode模块自己消费。dnode的工作线程(worker)消费消息队列里的消息,交给mnode或vnode进行处理。下面对各个模块做简要说明。 - -## RPC模块 - -该模块负责taosd与taosc, 以及其他数据节点之间的通讯。TDengine没有采取标准的HTTP或gRPC等第三方工具,而是实现了自己的通讯模块RPC。 - -考虑到物联网场景下,数据写入的包一般不大,因此除支持TCP连接之外,RPC还支持UDP连接。当数据包小于15K时,RPC将采用UDP方式进行连接,否则将采用TCP连接。对于查询类的消息,RPC不管包的大小,总是采取TCP连接。对于UDP连接,RPC实现了自己的超时、重传、顺序检查等机制,以保证数据可靠传输。 - -RPC模块还提供数据压缩功能,如果数据包的字节数超过系统配置参数compressMsgSize, RPC在传输中将自动压缩数据,以节省带宽。 - -为保证数据的安全和数据的integrity, RPC模块采用MD5做数字签名,对数据的真实性和完整性进行认证。 - -## DNODE模块 - -该模块是整个taosd的入口,它具体负责如下任务: - -- 系统的初始化,包括 - - 从文件taos.cfg读取系统配置参数,从文件dnodeCfg.json读取数据节点的配置参数; - - 启动RPC模块,并建立起与taosc通讯的server连接,与其他数据节点通讯的server连接; - - 启动并初始化dnode的内部管理, 该模块将扫描该数据节点已有的vnode,并打开它们; - - 初始化可配置的模块,如mnode, http, monitor等。 -- 数据节点的管理,包括 - - 定时的向mnode发送status消息,报告自己的状态; - - 根据mnode的指示,创建、改变、删除vnode; - - 根据mnode的指示,修改自己的配置参数; -- 消息的分发、消费,包括 - - 为每一个vnode和mnode的创建并维护一个读队列、一个写队列; - - 将从taosc或其他数据节点来的消息,根据消息类型,将其直接分发到不同的消息队列,或由自己的管理模块直接消费; - - 维护一个读的线程池,消费读队列的消息,交给vnode或mnode处理。为支持高并发,一个读线程(Worker)可以消费多个队列的消息,一个读队列可以由多个worker消费; - - 维护一个写的线程池,消费写队列的消息,交给vnode或mnode处理。为保证写操作的序列化,一个写队列只能由一个写线程负责,但一个写线程可以负责多个写队列。 - -taosd的消息消费由dnode通过读写线程池进行控制,是系统的中枢。该模块内的结构体图如下: - -![dnode.png](/img/architecture/dnode.png) - -## VNODE模块 - -vnode是一独立的数据存储查询逻辑单元,但因为一个vnode只能容许一个DB,因此vnode内部没有account, DB, user等概念。为实现更好的模块化、封装以及未来的扩展,它有很多子模块,包括负责存储的TSDB,负责查询的Query, 负责数据复制的sync,负责数据库日志的的wal, 负责连续查询的cq(continuous query), 负责事件触发的流计算的event等模块,这些子模块只与vnode模块发生关系,与其他模块没有任何调用关系。模块图如下: - -![vnode.png](/img/architecture/vnode.png) - -vnode模块向下,与dnodeVRead,dnodeVWrite发生互动,向上,与子模块发生互动。它主要的功能有: - -- 协调各个子模块的互动。各个子模块之间都不直接调用,都需要通过vnode模块进行; -- 对于来自taosc或mnode的写操作,vnode模块将其分解为写日志(wal), 转发(sync), 本地存储(tsdb)子模块的操作; -- 对于查询操作,分发到query模块进行。 - -一个数据节点里有多个vnode, 因此vnode模块是有多个运行实例的。每个运行实例是完全独立的。 - -vnode与其子模块是通过API直接调用,而不是通过消息队列传递。而且各个子模块只与vnode模块有交互,不与dnode, rpc等模块发生任何直接关联。 - -## MNODE模块 - -mnode是整个系统的大脑,负责整个系统的资源调度,负责meta data的管理与存储。 - -一个运行的系统里,只有一个mnode,但它有多个副本(由系统配置参数numOfMnodes控制)。这些副本分布在不同的dnode里,目的是保证系统的高可靠运行。副本之间的数据复制是采用同步而非异步的方式,以确保数据的一致性,确保数据不会丢失。这些副本会自动选举一个Master,其他副本是slave。所有数据更新类的操作,都只能在master上进行,而查询类的可以在slave节点上进行。代码实现上,同步模块与vnode共享,但mnode被分配一个特殊的vgroup ID: 1,而且quorum大于1。整个集群系统是由多个dnode组成的,运行的mnode的副本数不可能超过dnode的个数,但不会超过配置的副本数。如果某个mnode副本宕机一段时间,只要超过半数的mnode副本仍在运行,运行的mnode会自动根据整个系统的资源情况,在其他dnode里再启动一个mnode, 以保证运行的副本数。 - -各个dnode通过信息交换,保存有mnode各个副本的End Point列表,并向其中的master节点定时(间隔由系统配置参数statusInterval控制)发送status消息,消息体里包含该dnode的CPU、内存、剩余存储空间、vnode个数,以及各个vnode的状态(存储空间、原始数据大小、记录条数、角色等)。这样mnode就了解整个系统的资源情况,如果用户创建新的表,就可以决定需要在哪个dnode创建;如果增加或删除dnode, 或者监测到某dnode数据过热、或离线太长,就可以决定需要挪动那些vnode,以实现负载均衡。 - -mnode里还负责account, user, DB, stable, table, vgroup, dnode的创建、删除与更新。mnode不仅把这些entity的meta data保存在内存,还做持久化存储。但为节省内存,各个表的标签值不保存在mnode(保存在vnode),而且子表不维护自己的schema, 而是与stable共享。为减小mnode的查询压力,taosc会缓存table、stable的schema。对于查询类的操作,各个slave mnode也可以提供,以减轻master压力。 - -## TSDB模块 - -TSDB模块是VNODE中的负责快速高并发地存储和读取属于该VNODE的表的元数据及采集的时序数据的引擎。除此之外,TSDB还提供了表结构的修改、表标签值的修改等功能。TSDB提供API供VNODE和Query等模块调用。TSDB中存储了两类数据,1:元数据信息;2:时序数据 - -### 元数据信息 - -TSDB中存储的元数据包含属于其所在的VNODE中表的类型,schema的定义等。对于超级表和超级表下的子表而言,又包含了tag的schema定义以及子表的tag值等。对于元数据信息而言,TSDB就相当于一个全内存的KV型数据库,属于该VNODE的表对象全部在内存中,方便快速查询表的信息。除此之外,TSDB还对其中的子表,按照tag的第一列取值做了全内存的索引,大大加快了对于标签的过滤查询。TSDB中的元数据的最新状态在落盘时,会以追加(append-only)的形式,写入到meta文件中。meta文件只进行追加操作,即便是元数据的删除,也会以一条记录的形式写入到文件末尾。TSDB也提供了对于元数据的修改操作,如表schema的修改,tag schema的修改以及tag值的修改等。 - -### 时序数据 - -每个TSDB在创建时,都会事先分配一定量的内存缓冲区,且内存缓冲区的大小可配可修改。表采集的时序数据,在写入TSDB时,首先以追加的方式写入到分配的内存缓冲区中,同时建立基于时间戳的内存索引,方便快速查询。当内存缓冲区的数据积累到一定的程度时(达到内存缓冲区总大小的1/3),则会触发落盘操作,将缓冲区中的数据持久化到硬盘文件上。时序数据在内存缓冲区中是以行(row)的形式存储的。 - -而时序数据在写入到TSDB的数据文件时,是以列(column)的形式存储的。TSDB中的数据文件包含多个数据文件组,每个数据文件组中又包含.head、.data和.last三个文件,如(v2f1801.head、v2f1801.data、v2f1801.last)数据文件组。TSDB中的数据文件组是按照时间跨度进行分片的,默认是10天一个文件组,且可通过配置文件及建库选项进行配置。分片的数据文件组又按照编号递增排列,方便快速定位某一时间段的时序数据,高效定位数据文件组。时序数据在TSDB的数据文件中是以块的形式进行列式存储的,每个块中只包含一张表的数据,且数据在一个块中是按照时间顺序递增排列的。在一个数据文件组中,.head文件负责存储数据块的索引及统计信息,如每个块的位置,压缩算法,时间戳范围等。存储在.head文件中一张表的索引信息是按照数据块中存储的数据的时间递增排列的,方便进行折半查找等工作。.head和.last文件是存储真实数据块的文件,若数据块中的数据累计到一定程度,则会写入.data文件中,否则,会写入.last文件中,等待下次落盘时合并数据写入.data文件中,从而大大减少文件中块的个数,避免数据的过度碎片化。 - -## Query模块 - -该模块负责整体系统的查询处理。客户端调用该该模块进行SQL语法解析,并将查询或写入请求发送到vnode,同时负责针对超级表的查询进行二阶段的聚合操作。在Vnode端,该模块调用TSDB模块读取系统中存储的数据进行查询处理。Query模块还定义了系统能够支持的全部查询函数,查询函数的实现机制与查询框架无耦合,可以在不修改查询流程的情况下动态增加查询函数。详细的设计请参见《TDengine 2.0查询模块设计》。 - -## SYNC模块 - -该模块实现数据的多副本复制,包括vnode与mnode的数据复制,支持异步和同步两种复制方式,以满足meta data与时序数据不同复制的需求。因为它为mnode与vnode共享,系统为mnode副本预留了一个特殊的vgroup ID:1。因此vnode group的ID是从2开始的。 - -每个vnode/mnode模块实例会有一对应的sync模块实例,他们是一一对应的。详细设计请见[TDengine 2.0 数据复制模块设计](https://www.taosdata.com/cn/documentation/architecture/replica/) - -## WAL模块 - -该模块负责将新插入的数据写入write ahead log(WAL), 为vnode, mnode共享。以保证服务器crash或其他故障,能从WAL中恢复数据。 - -每个vnode/mnode模块实例会有一对应的wal模块实例,是完全一一对应的。WAL的落盘操作由两个参数walLevel, fsync控制。看具体场景,如果要100%保证数据不会丢失,需要将walLevel配置为2,fsync设置为0,每条数据插入请求,都会实时落盘后,才会给应用确认 - -## HTTP模块 - -该模块负责处理系统对外的RESTful接口,可以通过配置,由dnode启动或停止。 - -该模块将接收到的RESTful请求,做了各种合法性检查后,将其变成标准的SQL语句,通过taosc的异步接口,将请求发往整个系统中的任一dnode。收到处理后的结果后,再翻译成HTTP协议,返回给应用。 - -如果HTTP模块启动,就意味着启动了一个taosc的实例。任一一个dnode都可以启动该模块,以实现对RESTful请求的分布式处理。 - -## Monitor模块 - -该模块负责检测一个dnode的运行状态,可以通过配置,由dnode启动或停止。原则上,每个dnode都应该启动一个monitor实例。 - -Monitor采集TDengine里的关键操作,比如创建、删除、更新账号、表、库等,而且周期性的收集CPU、内存、网络等资源的使用情况(采集周期由系统配置参数monitorInterval控制)。获得这些数据后,monitor模块将采集的数据写入系统的日志库(DB名字由系统配置参数monitorDbName控制)。 - -Monitor模块使用taosc来将采集的数据写入系统,因此每个monitor实例,都有一个taosc运行实例。 - diff --git a/docs-cn/13-tdinternal/_category_.yml b/docs-cn/13-tdinternal/_category_.yml deleted file mode 100644 index e654a7f3d212869be00d819f16dcdb7197244da2..0000000000000000000000000000000000000000 --- a/docs-cn/13-tdinternal/_category_.yml +++ /dev/null @@ -1,3 +0,0 @@ -label: 技术内幕 -link: - type: generated-index \ No newline at end of file diff --git a/docs-cn/14-reference/01-taos-sql/12-errorcode.md b/docs-cn/14-reference/01-taos-sql/12-errorcode.md deleted file mode 100644 index 2013e1e640d10bbd09572ca1d9c4ba12a38620d8..0000000000000000000000000000000000000000 --- a/docs-cn/14-reference/01-taos-sql/12-errorcode.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -sidebar_label: 错误码 ---- - -# 错误码以及对应的十进制码 - -| 状态码 | 模 | 错误码(十六进制) | 错误描述 | 错误码(十进制) | -| :-------------------------------------- | :-: | :----------------: | :------------------------------------------- | :--------------- | -| TSDB_CODE_RPC_ACTION_IN_PROGRESS | 0 | 0x0001 | "Action in progress" | -2147483647 | -| TSDB_CODE_RPC_AUTH_REQUIRED | 0 | 0x0002 | "Authentication required" | -2147483646 | -| TSDB_CODE_RPC_AUTH_FAILURE | 0 | 0x0003 | "Authentication failure" | -2147483645 | -| TSDB_CODE_RPC_REDIRECT | 0 | 0x0004 | "Redirect" | -2147483644 | -| TSDB_CODE_RPC_NOT_READY | 0 | 0x0005 | "System not ready" | -2147483643 | -| TSDB_CODE_RPC_ALREADY_PROCESSED | 0 | 0x0006 | "Message already processed" | -2147483642 | -| TSDB_CODE_RPC_LAST_SESSION_NOT_FINISHED | 0 | 0x0007 | "Last session not finished" | -2147483641 | -| TSDB_CODE_RPC_MISMATCHED_LINK_ID | 0 | 0x0008 | "Mismatched meter id" | -2147483640 | -| TSDB_CODE_RPC_TOO_SLOW | 0 | 0x0009 | "Processing of request timed out" | -2147483639 | -| TSDB_CODE_RPC_MAX_SESSIONS | 0 | 0x000A | "Number of sessions reached limit" | -2147483638 | -| TSDB_CODE_RPC_NETWORK_UNAVAIL | 0 | 0x000B | "Unable to establish connection" | -2147483637 | -| TSDB_CODE_RPC_APP_ERROR | 0 | 0x000C | "Unexpected generic error in RPC" | -2147483636 | -| TSDB_CODE_RPC_UNEXPECTED_RESPONSE | 0 | 0x000D | "Unexpected response" | -2147483635 | -| TSDB_CODE_RPC_INVALID_VALUE | 0 | 0x000E | "Invalid value" | -2147483634 | -| TSDB_CODE_RPC_INVALID_TRAN_ID | 0 | 0x000F | "Invalid transaction id" | -2147483633 | -| TSDB_CODE_RPC_INVALID_SESSION_ID | 0 | 0x0010 | "Invalid session id" | -2147483632 | -| TSDB_CODE_RPC_INVALID_MSG_TYPE | 0 | 0x0011 | "Invalid message type" | -2147483631 | -| TSDB_CODE_RPC_INVALID_RESPONSE_TYPE | 0 | 0x0012 | "Invalid response type" | -2147483630 | -| TSDB_CODE_RPC_INVALID_TIME_STAMP | 0 | 0x0013 | "Invalid timestamp" | -2147483629 | -| TSDB_CODE_COM_OPS_NOT_SUPPORT | 0 | 0x0100 | "Operation not supported" | -2147483392 | -| TSDB_CODE_COM_MEMORY_CORRUPTED | 0 | 0x0101 | "Memory corrupted" | -2147483391 | -| TSDB_CODE_COM_OUT_OF_MEMORY | 0 | 0x0102 | "Out of memory" | -2147483390 | -| TSDB_CODE_COM_INVALID_CFG_MSG | 0 | 0x0103 | "Invalid config message" | -2147483389 | -| TSDB_CODE_COM_FILE_CORRUPTED | 0 | 0x0104 | "Data file corrupted" | -2147483388 | -| TSDB_CODE_TSC_INVALID_OPERATION | 0 | 0x0200 | "Invalid SQL statement" | -2147483136 | -| TSDB_CODE_TSC_INVALID_QHANDLE | 0 | 0x0201 | "Invalid qhandle" | -2147483135 | -| TSDB_CODE_TSC_INVALID_TIME_STAMP | 0 | 0x0202 | "Invalid combination of client/service time" | -2147483134 | -| TSDB_CODE_TSC_INVALID_VALUE | 0 | 0x0203 | "Invalid value in client" | -2147483133 | -| TSDB_CODE_TSC_INVALID_VERSION | 0 | 0x0204 | "Invalid client version" | -2147483132 | -| TSDB_CODE_TSC_INVALID_IE | 0 | 0x0205 | "Invalid client ie" | -2147483131 | -| TSDB_CODE_TSC_INVALID_FQDN | 0 | 0x0206 | "Invalid host name" | -2147483130 | -| TSDB_CODE_TSC_INVALID_USER_LENGTH | 0 | 0x0207 | "Invalid user name" | -2147483129 | -| TSDB_CODE_TSC_INVALID_PASS_LENGTH | 0 | 0x0208 | "Invalid password" | -2147483128 | -| TSDB_CODE_TSC_INVALID_DB_LENGTH | 0 | 0x0209 | "Database name too long" | -2147483127 | -| TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH | 0 | 0x020A | "Table name too long" | -2147483126 | -| TSDB_CODE_TSC_INVALID_CONNECTION | 0 | 0x020B | "Invalid connection" | -2147483125 | -| TSDB_CODE_TSC_OUT_OF_MEMORY | 0 | 0x020C | "System out of memory" | -2147483124 | -| TSDB_CODE_TSC_NO_DISKSPACE | 0 | 0x020D | "System out of disk space" | -2147483123 | -| TSDB_CODE_TSC_QUERY_CACHE_ERASED | 0 | 0x020E | "Query cache erased" | -2147483122 | -| TSDB_CODE_TSC_QUERY_CANCELLED | 0 | 0x020F | "Query terminated" | -2147483121 | -| TSDB_CODE_TSC_SORTED_RES_TOO_MANY | 0 | 0x0210 | "Result set too large to be sorted" | -2147483120 | -| TSDB_CODE_TSC_APP_ERROR | 0 | 0x0211 | "Application error" | -2147483119 | -| TSDB_CODE_TSC_ACTION_IN_PROGRESS | 0 | 0x0212 | "Action in progress" | -2147483118 | -| TSDB_CODE_TSC_DISCONNECTED | 0 | 0x0213 | "Disconnected from service" | -2147483117 | -| TSDB_CODE_TSC_NO_WRITE_AUTH | 0 | 0x0214 | "No write permission" | -2147483116 | -| TSDB_CODE_MND_MSG_NOT_PROCESSED | 0 | 0x0300 | "Message not processed" | -2147482880 | -| TSDB_CODE_MND_ACTION_IN_PROGRESS | 0 | 0x0301 | "Message is progressing" | -2147482879 | -| TSDB_CODE_MND_ACTION_NEED_REPROCESSED | 0 | 0x0302 | "Messag need to be reprocessed" | -2147482878 | -| TSDB_CODE_MND_NO_RIGHTS | 0 | 0x0303 | "Insufficient privilege for operation" | -2147482877 | -| TSDB_CODE_MND_APP_ERROR | 0 | 0x0304 | "Unexpected generic error in mnode" | -2147482876 | -| TSDB_CODE_MND_INVALID_CONNECTION | 0 | 0x0305 | "Invalid message connection" | -2147482875 | -| TSDB_CODE_MND_INVALID_MSG_VERSION | 0 | 0x0306 | "Incompatible protocol version" | -2147482874 | -| TSDB_CODE_MND_INVALID_MSG_LEN | 0 | 0x0307 | "Invalid message length" | -2147482873 | -| TSDB_CODE_MND_INVALID_MSG_TYPE | 0 | 0x0308 | "Invalid message type" | -2147482872 | -| TSDB_CODE_MND_TOO_MANY_SHELL_CONNS | 0 | 0x0309 | "Too many connections" | -2147482871 | -| TSDB_CODE_MND_OUT_OF_MEMORY | 0 | 0x030A | "Out of memory in mnode" | -2147482870 | -| TSDB_CODE_MND_INVALID_SHOWOBJ | 0 | 0x030B | "Data expired" | -2147482869 | -| TSDB_CODE_MND_INVALID_QUERY_ID | 0 | 0x030C | "Invalid query id" | -2147482868 | -| TSDB_CODE_MND_INVALID_STREAM_ID | 0 | 0x030D | "Invalid stream id" | -2147482867 | -| TSDB_CODE_MND_INVALID_CONN_ID | 0 | 0x030E | "Invalid connection id" | -2147482866 | -| TSDB_CODE_MND_SDB_OBJ_ALREADY_THERE | 0 | 0x0320 | "Object already there" | -2147482848 | -| TSDB_CODE_MND_SDB_ERROR | 0 | 0x0321 | "Unexpected generic error in sdb" | -2147482847 | -| TSDB_CODE_MND_SDB_INVALID_TABLE_TYPE | 0 | 0x0322 | "Invalid table type" | -2147482846 | -| TSDB_CODE_MND_SDB_OBJ_NOT_THERE | 0 | 0x0323 | "Object not there" | -2147482845 | -| TSDB_CODE_MND_SDB_INVAID_META_ROW | 0 | 0x0324 | "Invalid meta row" | -2147482844 | -| TSDB_CODE_MND_SDB_INVAID_KEY_TYPE | 0 | 0x0325 | "Invalid key type" | -2147482843 | -| TSDB_CODE_MND_DNODE_ALREADY_EXIST | 0 | 0x0330 | "DNode already exists" | -2147482832 | -| TSDB_CODE_MND_DNODE_NOT_EXIST | 0 | 0x0331 | "DNode does not exist" | -2147482831 | -| TSDB_CODE_MND_VGROUP_NOT_EXIST | 0 | 0x0332 | "VGroup does not exist" | -2147482830 | -| TSDB_CODE_MND_NO_REMOVE_MASTER | 0 | 0x0333 | "Master DNode cannot be removed" | -2147482829 | -| TSDB_CODE_MND_NO_ENOUGH_DNODES | 0 | 0x0334 | "Out of DNodes" | -2147482828 | -| TSDB_CODE_MND_CLUSTER_CFG_INCONSISTENT | 0 | 0x0335 | "Cluster cfg inconsistent" | -2147482827 | -| TSDB_CODE_MND_INVALID_DNODE_CFG_OPTION | 0 | 0x0336 | "Invalid dnode cfg option" | -2147482826 | -| TSDB_CODE_MND_BALANCE_ENABLED | 0 | 0x0337 | "Balance already enabled" | -2147482825 | -| TSDB_CODE_MND_VGROUP_NOT_IN_DNODE | 0 | 0x0338 | "Vgroup not in dnode" | -2147482824 | -| TSDB_CODE_MND_VGROUP_ALREADY_IN_DNODE | 0 | 0x0339 | "Vgroup already in dnode" | -2147482823 | -| TSDB_CODE_MND_DNODE_NOT_FREE | 0 | 0x033A | "Dnode not avaliable" | -2147482822 | -| TSDB_CODE_MND_INVALID_CLUSTER_ID | 0 | 0x033B | "Cluster id not match" | -2147482821 | -| TSDB_CODE_MND_NOT_READY | 0 | 0x033C | "Cluster not ready" | -2147482820 | -| TSDB_CODE_MND_ACCT_ALREADY_EXIST | 0 | 0x0340 | "Account already exists" | -2147482816 | -| TSDB_CODE_MND_INVALID_ACCT | 0 | 0x0341 | "Invalid account" | -2147482815 | -| TSDB_CODE_MND_INVALID_ACCT_OPTION | 0 | 0x0342 | "Invalid account options" | -2147482814 | -| TSDB_CODE_MND_USER_ALREADY_EXIST | 0 | 0x0350 | "User already exists" | -2147482800 | -| TSDB_CODE_MND_INVALID_USER | 0 | 0x0351 | "Invalid user" | -2147482799 | -| TSDB_CODE_MND_INVALID_USER_FORMAT | 0 | 0x0352 | "Invalid user format" | -2147482798 | -| TSDB_CODE_MND_INVALID_PASS_FORMAT | 0 | 0x0353 | "Invalid password format" | -2147482797 | -| TSDB_CODE_MND_NO_USER_FROM_CONN | 0 | 0x0354 | "Can not get user from conn" | -2147482796 | -| TSDB_CODE_MND_TOO_MANY_USERS | 0 | 0x0355 | "Too many users" | -2147482795 | -| TSDB_CODE_MND_TABLE_ALREADY_EXIST | 0 | 0x0360 | "Table already exists" | -2147482784 | -| TSDB_CODE_MND_INVALID_TABLE_ID | 0 | 0x0361 | "Table name too long" | -2147482783 | -| TSDB_CODE_MND_INVALID_TABLE_NAME | 0 | 0x0362 | "Table does not exist" | -2147482782 | -| TSDB_CODE_MND_INVALID_TABLE_TYPE | 0 | 0x0363 | "Invalid table type in tsdb" | -2147482781 | -| TSDB_CODE_MND_TOO_MANY_TAGS | 0 | 0x0364 | "Too many tags" | -2147482780 | -| TSDB_CODE_MND_TOO_MANY_TIMESERIES | 0 | 0x0366 | "Too many time series" | -2147482778 | -| TSDB_CODE_MND_NOT_SUPER_TABLE | 0 | 0x0367 | "Not super table" | -2147482777 | -| TSDB_CODE_MND_COL_NAME_TOO_LONG | 0 | 0x0368 | "Tag name too long" | -2147482776 | -| TSDB_CODE_MND_TAG_ALREAY_EXIST | 0 | 0x0369 | "Tag already exists" | -2147482775 | -| TSDB_CODE_MND_TAG_NOT_EXIST | 0 | 0x036A | "Tag does not exist" | -2147482774 | -| TSDB_CODE_MND_FIELD_ALREAY_EXIST | 0 | 0x036B | "Field already exists" | -2147482773 | -| TSDB_CODE_MND_FIELD_NOT_EXIST | 0 | 0x036C | "Field does not exist" | -2147482772 | -| TSDB_CODE_MND_INVALID_STABLE_NAME | 0 | 0x036D | "Super table does not exist" | -2147482771 | -| TSDB_CODE_MND_DB_NOT_SELECTED | 0 | 0x0380 | "Database not specified or available" | -2147482752 | -| TSDB_CODE_MND_DB_ALREADY_EXIST | 0 | 0x0381 | "Database already exists" | -2147482751 | -| TSDB_CODE_MND_INVALID_DB_OPTION | 0 | 0x0382 | "Invalid database options" | -2147482750 | -| TSDB_CODE_MND_INVALID_DB | 0 | 0x0383 | "Invalid database name" | -2147482749 | -| TSDB_CODE_MND_MONITOR_DB_FORBIDDEN | 0 | 0x0384 | "Cannot delete monitor database" | -2147482748 | -| TSDB_CODE_MND_TOO_MANY_DATABASES | 0 | 0x0385 | "Too many databases for account" | -2147482747 | -| TSDB_CODE_MND_DB_IN_DROPPING | 0 | 0x0386 | "Database not available" | -2147482746 | -| TSDB_CODE_DND_MSG_NOT_PROCESSED | 0 | 0x0400 | "Message not processed" | -2147482624 | -| TSDB_CODE_DND_OUT_OF_MEMORY | 0 | 0x0401 | "Dnode out of memory" | -2147482623 | -| TSDB_CODE_DND_NO_WRITE_ACCESS | 0 | 0x0402 | "No permission for disk files in dnode" | -2147482622 | -| TSDB_CODE_DND_INVALID_MSG_LEN | 0 | 0x0403 | "Invalid message length" | -2147482621 | -| TSDB_CODE_VND_ACTION_IN_PROGRESS | 0 | 0x0500 | "Action in progress" | -2147482368 | -| TSDB_CODE_VND_MSG_NOT_PROCESSED | 0 | 0x0501 | "Message not processed" | -2147482367 | -| TSDB_CODE_VND_ACTION_NEED_REPROCESSED | 0 | 0x0502 | "Action need to be reprocessed" | -2147482366 | -| TSDB_CODE_VND_INVALID_VGROUP_ID | 0 | 0x0503 | "Invalid Vgroup ID" | -2147482365 | -| TSDB_CODE_VND_INIT_FAILED | 0 | 0x0504 | "Vnode initialization failed" | -2147482364 | -| TSDB_CODE_VND_NO_DISKSPACE | 0 | 0x0505 | "System out of disk space" | -2147482363 | -| TSDB_CODE_VND_NO_DISK_PERMISSIONS | 0 | 0x0506 | "No write permission for disk files" | -2147482362 | -| TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR | 0 | 0x0507 | "Missing data file" | -2147482361 | -| TSDB_CODE_VND_OUT_OF_MEMORY | 0 | 0x0508 | "Out of memory" | -2147482360 | -| TSDB_CODE_VND_APP_ERROR | 0 | 0x0509 | "Unexpected generic error in vnode" | -2147482359 | -| TSDB_CODE_VND_INVALID_STATUS | 0 | 0x0510 | "Database not ready" | -2147482352 | -| TSDB_CODE_VND_NOT_SYNCED | 0 | 0x0511 | "Database suspended" | -2147482351 | -| TSDB_CODE_VND_NO_WRITE_AUTH | 0 | 0x0512 | "Write operation denied" | -2147482350 | -| TSDB_CODE_TDB_INVALID_TABLE_ID | 0 | 0x0600 | "Invalid table ID" | -2147482112 | -| TSDB_CODE_TDB_INVALID_TABLE_TYPE | 0 | 0x0601 | "Invalid table type" | -2147482111 | -| TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION | 0 | 0x0602 | "Invalid table schema version" | -2147482110 | -| TSDB_CODE_TDB_TABLE_ALREADY_EXIST | 0 | 0x0603 | "Table already exists" | -2147482109 | -| TSDB_CODE_TDB_INVALID_CONFIG | 0 | 0x0604 | "Invalid configuration" | -2147482108 | -| TSDB_CODE_TDB_INIT_FAILED | 0 | 0x0605 | "Tsdb init failed" | -2147482107 | -| TSDB_CODE_TDB_NO_DISKSPACE | 0 | 0x0606 | "No diskspace for tsdb" | -2147482106 | -| TSDB_CODE_TDB_NO_DISK_PERMISSIONS | 0 | 0x0607 | "No permission for disk files" | -2147482105 | -| TSDB_CODE_TDB_FILE_CORRUPTED | 0 | 0x0608 | "Data file(s) corrupted" | -2147482104 | -| TSDB_CODE_TDB_OUT_OF_MEMORY | 0 | 0x0609 | "Out of memory" | -2147482103 | -| TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE | 0 | 0x060A | "Tag too old" | -2147482102 | -| TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE | 0 | 0x060B | "Timestamp data out of range" | -2147482101 | -| TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP | 0 | 0x060C | "Submit message is messed up" | -2147482100 | -| TSDB_CODE_TDB_INVALID_ACTION | 0 | 0x060D | "Invalid operation" | -2147482099 | -| TSDB_CODE_TDB_INVALID_CREATE_TB_MSG | 0 | 0x060E | "Invalid creation of table" | -2147482098 | -| TSDB_CODE_TDB_NO_TABLE_DATA_IN_MEM | 0 | 0x060F | "No table data in memory skiplist" | -2147482097 | -| TSDB_CODE_TDB_FILE_ALREADY_EXISTS | 0 | 0x0610 | "File already exists" | -2147482096 | -| TSDB_CODE_TDB_TABLE_RECONFIGURE | 0 | 0x0611 | "Need to reconfigure table" | -2147482095 | -| TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO | 0 | 0x0612 | "Invalid information to create table" | -2147482094 | -| TSDB_CODE_QRY_INVALID_QHANDLE | 0 | 0x0700 | "Invalid handle" | -2147481856 | -| TSDB_CODE_QRY_INVALID_MSG | 0 | 0x0701 | "Invalid message" | -2147481855 | -| TSDB_CODE_QRY_NO_DISKSPACE | 0 | 0x0702 | "No diskspace for query" | -2147481854 | -| TSDB_CODE_QRY_OUT_OF_MEMORY | 0 | 0x0703 | "System out of memory" | -2147481853 | -| TSDB_CODE_QRY_APP_ERROR | 0 | 0x0704 | "Unexpected generic error in query" | -2147481852 | -| TSDB_CODE_QRY_DUP_JOIN_KEY | 0 | 0x0705 | "Duplicated join key" | -2147481851 | -| TSDB_CODE_QRY_EXCEED_TAGS_LIMIT | 0 | 0x0706 | "Tag conditon too many" | -2147481850 | -| TSDB_CODE_QRY_NOT_READY | 0 | 0x0707 | "Query not ready" | -2147481849 | -| TSDB_CODE_QRY_HAS_RSP | 0 | 0x0708 | "Query should response" | -2147481848 | -| TSDB_CODE_GRANT_EXPIRED | 0 | 0x0800 | "License expired" | -2147481600 | -| TSDB_CODE_GRANT_DNODE_LIMITED | 0 | 0x0801 | "DNode creation limited by licence" | -2147481599 | -| TSDB_CODE_GRANT_ACCT_LIMITED | 0 | 0x0802 | "Account creation limited by license" | -2147481598 | -| TSDB_CODE_GRANT_TIMESERIES_LIMITED | 0 | 0x0803 | "Table creation limited by license" | -2147481597 | -| TSDB_CODE_GRANT_DB_LIMITED | 0 | 0x0804 | "DB creation limited by license" | -2147481596 | -| TSDB_CODE_GRANT_USER_LIMITED | 0 | 0x0805 | "User creation limited by license" | -2147481595 | -| TSDB_CODE_GRANT_CONN_LIMITED | 0 | 0x0806 | "Conn creation limited by license" | -2147481594 | -| TSDB_CODE_GRANT_STREAM_LIMITED | 0 | 0x0807 | "Stream creation limited by license" | -2147481593 | -| TSDB_CODE_GRANT_SPEED_LIMITED | 0 | 0x0808 | "Write speed limited by license" | -2147481592 | -| TSDB_CODE_GRANT_STORAGE_LIMITED | 0 | 0x0809 | "Storage capacity limited by license" | -2147481591 | -| TSDB_CODE_GRANT_QUERYTIME_LIMITED | 0 | 0x080A | "Query time limited by license" | -2147481590 | -| TSDB_CODE_GRANT_CPU_LIMITED | 0 | 0x080B | "CPU cores limited by license" | -2147481589 | -| TSDB_CODE_SYN_INVALID_CONFIG | 0 | 0x0900 | "Invalid Sync Configuration" | -2147481344 | -| TSDB_CODE_SYN_NOT_ENABLED | 0 | 0x0901 | "Sync module not enabled" | -2147481343 | -| TSDB_CODE_WAL_APP_ERROR | 0 | 0x1000 | "Unexpected generic error in wal" | -2147479552 | diff --git a/docs-cn/14-reference/02-restful-api/02-restful-api.mdx b/docs-cn/14-reference/02-rest-api/02-rest-api.mdx similarity index 92% rename from docs-cn/14-reference/02-restful-api/02-restful-api.mdx rename to docs-cn/14-reference/02-rest-api/02-rest-api.mdx index 6173c3215ac5a5dccc1caa206f89b77d101a6e70..42f93fce0d325eb5c42392bcffb678b113612961 100644 --- a/docs-cn/14-reference/02-restful-api/02-restful-api.mdx +++ b/docs-cn/14-reference/02-rest-api/02-rest-api.mdx @@ -1,6 +1,8 @@ -# RESTful API +--- +title: REST API +--- -为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 RESTful API。为最大程度降低学习成本,不同于其他数据库 RESTful API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。RESTful 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。 +为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 REST API。为最大程度降低学习成本,不同于其他数据库 REST API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。REST 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。 注意:与原生连接器的一个区别是,RESTful 接口是无状态的,因此 `USE db_name` 指令没有效果,所有对表名、超级表名的引用都需要指定数据库名前缀。(从 2.2.0.0 版本开始,支持在 RESTful url 中指定 db_name,这时如果 SQL 语句中没有指定数据库名前缀的话,会使用 url 中指定的这个 db_name。从 2.4.0.0 版本开始,RESTful 默认由 taosAdapter 提供,要求必须在 url 中指定 db_name。) @@ -70,9 +72,7 @@ h1.taosdata.com:6041/rest/sql } ``` -## RESTful 连接器的使用 - -### HTTP 请求格式 +## HTTP 请求格式 ``` http://:/rest/sql/[db_name] @@ -292,7 +292,7 @@ HTTP 请求 URL 采用 `sqlutc` 时,返回结果集的时间戳将采用 UTC ## 重要配置项 -下面仅列出一些与 RESTful 接口有关的配置参数,其他系统参数请看配置文件里的说明。(注意:配置修改后,需要重启 taosd 服务才能生效) +下面仅列出一些与 RESTful 接口有关的配置参数,其他系统参数请看配置文件里的说明。 - 对外提供 RESTful 服务的端口号,默认绑定到 6041(实际取值是 serverPort + 11,因此可以通过修改 serverPort 参数的设置来修改)。 - httpMaxThreads: 启动的线程数量,默认为 2(2.0.17.0 版本开始,默认值改为 CPU 核数的一半向下取整)。 @@ -300,3 +300,8 @@ HTTP 请求 URL 采用 `sqlutc` 时,返回结果集的时间戳将采用 UTC - httpEnableCompress: 是否支持压缩,默认不支持,目前 TDengine 仅支持 gzip 压缩格式。 - httpDebugFlag: 日志开关,默认 131。131:仅错误和报警信息,135:调试信息,143:非常详细的调试信息,默认 131。 - httpDbNameMandatory: 是否必须在 RESTful url 中指定默认的数据库名。默认为 0,即关闭此检查。如果设置为 1,那么每个 RESTful url 中都必须设置一个默认数据库名,否则无论此时执行的 SQL 语句是否需要指定数据库,都会返回一个执行错误,拒绝执行此 SQL 语句。 + +:::note +如果使用 taosd 提供的 REST API, 那么以上配置需要写在 taosd 的配置文件 taos.cfg 中。如果使用 taosAdaper 提供的 REST API, 那么需要参考 taosAdaper [对应的配置方法](/reference/taosadapter/)。 + +::: diff --git a/docs-cn/14-reference/02-rest-api/_category_.yml b/docs-cn/14-reference/02-rest-api/_category_.yml new file mode 100644 index 0000000000000000000000000000000000000000..57a20d8458e937f60c41806be4392ebb2d13e0f7 --- /dev/null +++ b/docs-cn/14-reference/02-rest-api/_category_.yml @@ -0,0 +1 @@ +label: REST API diff --git a/docs-cn/14-reference/02-restful-api/_category_.yml b/docs-cn/14-reference/02-restful-api/_category_.yml deleted file mode 100644 index 736836846eef118e51ab802811151e26646684e9..0000000000000000000000000000000000000000 --- a/docs-cn/14-reference/02-restful-api/_category_.yml +++ /dev/null @@ -1 +0,0 @@ -label: RESTful API diff --git a/docs-cn/14-reference/03-connector/03-connector.mdx b/docs-cn/14-reference/03-connector/03-connector.mdx index 2036a591ff1f6f579dfec4e2e014573900d3c21d..c0e714f148a7821e070be38a5484484fdd747e9a 100644 --- a/docs-cn/14-reference/03-connector/03-connector.mdx +++ b/docs-cn/14-reference/03-connector/03-connector.mdx @@ -1,55 +1,78 @@ -# 连接器 +--- +title: 连接器 +--- -TDengine 提供了丰富的应用程序开发接口,其中包括 C/C++、Java、Python、Go、Node.js、C# 、RESTful 等,便于用户快速开发应用。 +TDengine 提供了丰富的应用程序开发接口,为了便于用户快速开发自己的应用,TDengine 支持了多种编程语言的连接器,其中官方连接器包括支持 C/C++、Java、Python、Go、Node.js、C# 和 Rust 的连接器。这些连接器支持使用原生接口(taosc)和 REST 接口(部分语言暂不支持)连接 TDengine 集群。社区开发者也贡献了多个非官方连接器,例如 ADO.NET 连接器、Lua 连接器和 PHP 连接器。 -![image-connecotr](/img/connector.png) +![image-connector](/img/connector.png) -## 支持的系统 +## 支持的平台 -目前 TDengine 的连接器可支持的平台广泛,包括:X64/X86/ARM64/ARM32/MIPS/Alpha 等硬件平台,以及 Linux/Win64/Win32 等开发环境。对照矩阵如下: +目前 TDengine 的原生接口连接器可支持的平台包括:X64/X86/ARM64/ARM32/MIPS/Alpha 等硬件平台,以及 Linux/Win64/Win32 等开发环境。对照矩阵如下: -| **CPU** | **OS** | **JDBC** | **Python** | **Go** | **Node.js** | **C#** | **Rust** | **RESTful** | -| -------------- | --------- | -------- | ---------- | ------ | ----------- | ------ | -------- | ----------- | -| **X86 64bit** | **Linux** | ● | ● | ● | ● | ● | ● | ● | -| **X86 64bit** | **Win64** | ● | ● | ● | ● | ● | ● | ● | -| **X86 64bit** | **Win32** | ● | ● | ● | ● | ○ | ○ | ● | -| **X86 32bit** | **Win32** | ○ | ○ | ○ | ○ | ○ | ○ | ● | -| **ARM64** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● | -| **ARM32** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● | -| **MIPS 龙芯** | **Linux** | ○ | ○ | ○ | ○ | ○ | ○ | ○ | -| **Alpha 申威** | **Linux** | ○ | ○ | -- | -- | -- | -- | ○ | -| **X86 海光** | **Linux** | ○ | ○ | ○ | -- | -- | -- | ○ | +| **CPU** | **OS** | **JDBC** | **Python** | **Go** | **Node.js** | **C#** | **Rust** | C/C++ | +| -------------- | --------- | -------- | ---------- | ------ | ----------- | ------ | -------- | ----- | +| **X86 64bit** | **Linux** | ● | ● | ● | ● | ● | ● | ● | +| **X86 64bit** | **Win64** | ● | ● | ● | ● | ● | ● | ● | +| **X86 64bit** | **Win32** | ● | ● | ● | ● | ○ | ○ | ● | +| **X86 32bit** | **Win32** | ○ | ○ | ○ | ○ | ○ | ○ | ● | +| **ARM64** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● | +| **ARM32** | **Linux** | ● | ● | ● | ● | ○ | ○ | ● | +| **MIPS 龙芯** | **Linux** | ○ | ○ | ○ | ○ | ○ | ○ | ○ | +| **Alpha 申威** | **Linux** | ○ | ○ | -- | -- | -- | -- | ○ | +| **X86 海光** | **Linux** | ○ | ○ | ○ | -- | -- | -- | ○ | 其中 ● 表示官方测试验证通过,○ 表示非官方测试验证通过,-- 表示未经验证。 -## 特性矩阵 +使用 REST 连接由于不依赖客户端驱动可以支持更广泛的操作系统。 -连接器对 TDengine 特性的支持对照矩阵如下[1]: +## 版本支持 -| **Feature** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** | -| ------------------ | --------- | ---------- | -------- | -------- | ----------- | -------- | -| **连接管理** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **同步查询** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **异步查询** | 不支持[2] | 支持 | 支持 | 支持 | 支持 | 暂不支持 | -| **参数绑定** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **获取系统信息** | 暂不支持 | 支持 | 暂不支持 | 暂不支持 | 支持 | 暂不支持 | -| **错误信息** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **订阅功能** | 支持 | 支持 | 支持 | 支持 | 支持 | 暂不支持 | -| **Schemaless** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **RESTful 连接** | 支持 | 支持 | 支持 | 暂不支持 | 支持 | 支持 | -| **批量拉取(WS)** | 支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | +TDengine 版本更新往往会增加新的功能特性,列表中的连接器版本为连接器最佳适配版本。 -备注: +| **TDengine 版本** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** | +| --------------------- | -------- | ---------- | ------------ | ------------- | --------------- | -------- | +| **2.4.0.14 及以上** | 2.0.38 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 | +| **2.4.0.6 及以上** | 2.0.37 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 | +| **2.4.0.4 - 2.4.0.5** | 2.0.37 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 | +| **2.2.x.x ** | 2.0.36 | 当前版本 | master 分支 | n/a | 2.0.7 - 2.0.9 | 当前版本 | +| **2.0.x.x ** | 2.0.34 | 当前版本 | master 分支 | n/a | 2.0.1 - 2.0.6 | 当前版本 | -[1]: 由于不同语言数据库框架规范不同,并不意味着所有 C/C++ 接口都需要对应支持。 +## 功能特性 -[2]: JDBC 标准为同步查询。 +连接器对 TDengine 功能特性的支持对照如下: + +### 使用原生接口(taosc) + +| **功能特性** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** | +| -------------- | -------- | ---------- | ------ | ------ | ----------- | -------- | +| **连接管理** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | +| **普通查询** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | +| **连续查询** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | +| **参数绑定** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | +| **订阅功能** | 支持 | 支持 | 支持 | 支持 | 支持 | 暂不支持 | +| **Schemaless** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | +| **DataFrame** | 不支持 | 支持 | 不支持 | 不支持 | 不支持 | 不支持 | + +:::info +由于不同编程语言数据库框架规范不同,并不意味着所有 C/C++ 接口都需要对应封装支持。 +::: + +### 使用 REST 接口 + +| **功能特性** | **Java** | **Python** | **Go** | **C#(暂不支持)** | **Node.js** | **Rust** | +| ------------------------------ | -------- | ---------- | -------- | ------------------ | ----------- | -------- | +| **连接管理** | 支持 | 支持 | 支持 | N/A | 支持 | 支持 | +| **普通查询** | 支持 | 支持 | 支持 | N/A | 支持 | 支持 | +| **连续查询** | 支持 | 支持 | 支持 | N/A | 支持 | 支持 | +| **参数绑定** | 不支持 | 不支持 | 不支持 | N/A | 不支持 | 不支持 | +| **订阅功能** | 不支持 | 不支持 | 不支持 | N/A | 不支持 | 不支持 | +| **Schemaless** | 暂不支持 | 暂不支持 | 暂不支持 | N/A | 暂不支持 | 暂不支持 | +| **批量拉取(基于 WebSocket)** | 支持 | 暂不支持 | 暂不支持 | N/A | 暂不支持 | 暂不支持 | +| **DataFrame** | 不支持 | 支持 | 不支持 | N/A | 不支持 | 不支持 | :::warning -- 在没有安装 TDengine 服务端软件的系统中使用连接器(除 RESTful 外)访问 TDengine 数据库,需要安装相应版本的客户端安装包来使应用驱动(Linux 系统中文件名为 libtaos.so,Windows 系统中为 taos.dll)被安装在系统中,否则会产生无法找到相应库文件的错误。 -- 所有执行 SQL 语句的 API,例如 C/C++ Connector 中的 `tao_query`、`taos_query_a`、`taos_subscribe` 等,以及其它语言中与它们对应的 API,每次都只能执行一条 SQL 语句,如果实际参数中包含了多条语句,它们的行为是未定义的。 -- 升级 TDengine 到 2.0.8.0 版本的用户,必须更新 JDBC。连接 TDengine 必须升级 taos-jdbcdriver 到 2.0.12 及以上。详细的版本依赖关系请参见 [taos-jdbcdriver 文档](https://www.taosdata.com/cn/documentation/connector/java#version)。 - 无论选用何种编程语言的连接器,2.0 及以上版本的 TDengine 推荐数据库应用的每个线程都建立一个独立的连接,或基于线程建立连接池,以避免连接内的“USE statement”状态量在线程之间相互干扰(但连接的查询和写入操作都是线程安全的)。 ::: @@ -58,13 +81,13 @@ import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; import InstallOnWindows from "./_linux_install.mdx"; import InstallOnLinux from "./_windows_install.mdx"; -import VarifyWindows from "./_varify_linux.mdx"; -import VarifyLinux from "./_varify_windows.mdx"; +import VerifyWindows from "./_verify_windows.mdx"; +import VerifyLinux from "./_verify_linux.mdx"; ## 安装客户端驱动 :::info -只有在没有安装 TDengine 服务端软件的系统上使用非 RESTFful 连接器才需要安装客户端驱动。 +只有在没有安装 TDengine 服务端软件的系统上使用原生接口连接器才需要安装客户端驱动。 ::: @@ -81,13 +104,14 @@ import VarifyLinux from "./_varify_windows.mdx"; ### 安装验证 -以上安装和配置完成后,并确认 TDengine 服务已经正常启动运行,此时可以执行 taos 客户端进行登录。 +以上安装和配置完成后,并确认 TDengine 服务已经正常启动运行,此时可以执行 TDengine CLI 工具进行登录。 - + - + + diff --git a/docs-cn/14-reference/03-connector/_linux_install.mdx b/docs-cn/14-reference/03-connector/_linux_install.mdx index 21dacdfdb8f64364bb7aae0567a424bc98e2ef96..be363395cb6340a00ea0e51a0facc57a0340b301 100644 --- a/docs-cn/14-reference/03-connector/_linux_install.mdx +++ b/docs-cn/14-reference/03-connector/_linux_install.mdx @@ -4,24 +4,23 @@ - ARM32 硬件环境:TDengine-client-2.x.x.x-Linux-aarch32.tar.gz 2. 解压缩软件包 - 将软件包放置在当前用户可读写的任意目录下,然后执行下面的命令:`tar -xzvf TDengine-client-xxxxxxxxx.tar.gz` - 其中 xxxxxxxxx 需要替换为实际版本的字符串。 + 将软件包放置在当前用户可读写的任意目录下,然后执行下面的命令:`tar -xzvf TDengine-client-VERSION.tar.gz` + 其中 VERSION 需要替换为实际版本的字符串。 3. 执行安装脚本 解压软件包之后,会在解压目录下看到以下文件(目录): - ​ - _ install_client.sh_:安装脚本,用于应用驱动程序 - ​ - _ taos.tar.gz_:应用驱动安装包 - ​ - _ driver_:TDengine 应用驱动 driver - ​ - _connector_: 各种编程语言连接器(go/nodejs/python/JDBC) - ​ - _examples_: 各种编程语言的示例程序(c/C#/go/JDBC/MATLAB/python/R) + - _ install_client.sh_:安装脚本,用于应用驱动程序 + - _ taos.tar.gz_:应用驱动安装包 + - _ driver_:TDengine 应用驱动 driver + - _examples_: 各种编程语言的示例程序(c/C#/go/JDBC/MATLAB/python/R) 运行 install_client.sh 进行安装。 4. 配置 taos.cfg - 编辑 taos.cfg 文件(默认路径/etc/taos/taos.cfg),将 firstEP 修改为 TDengine 服务器的 End Point,例如:`h1.taos.com:6030` + 编辑 taos.cfg 文件(默认路径/etc/taos/taos.cfg),将 firstEP 修改为 TDengine 服务器的 End Point,例如:`h1.tdengine.com:6030` :::tip -1. 如本机没有部署 TDengine 服务,仅安装了应用驱动,则 taos.cfg 中仅需配置 firstEP,无需配置 FQDN。 -2. 为防止与服务器端连接时出现“unable to resolve FQDN”错误,建议确认客户端的 hosts 文件已经配置正确的 FQDN 值。 +1. 如本机没有部署 TDengine 服务,仅安装了应用驱动,则 taos.cfg 中仅需配置 firstEP,无需在本机配置 FQDN。 +2. 为防止与服务器端连接时出现“Unable to resolve FQDN”错误,建议确认本机的 hosts 文件已经配置了服务器正确的 FQDN 值,或配置好了 DNS 服务。 ::: diff --git a/docs-cn/14-reference/03-connector/_preparition.mdx b/docs-cn/14-reference/03-connector/_preparition.mdx new file mode 100644 index 0000000000000000000000000000000000000000..87538ebfd8c60507aec90ee86e427d85979dbc4a --- /dev/null +++ b/docs-cn/14-reference/03-connector/_preparition.mdx @@ -0,0 +1,10 @@ +- 已安装客户端驱动(使用原生连接必须安装,使用 REST 连接无需安装) + +:::info + +由于 TDengine 的客户端驱动使用 C 语言编写,使用原生连接时需要加载系统对应安装在本地的客户端驱动共享库文件,通常包含在 TDengine 安装包。TDengine Linux 服务端安装包附带了 TDengine 客户端,也可以单独安装 [Linux 客户端](/get-started/) 。在 Windows 环境开发时需要安装 TDengine 对应的 [Windows 客户端](https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client) 。 + +- libtaos.so: 在 Linux 系统中成功安装 TDengine 后,依赖的 Linux 版客户端驱动 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。 +- taos.dll: 在 Windows 系统中安装完客户端之后,依赖的 Windows 版客户端驱动 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。 + +::: diff --git a/docs-cn/14-reference/03-connector/_varify_linux.mdx b/docs-cn/14-reference/03-connector/_verify_linux.mdx similarity index 87% rename from docs-cn/14-reference/03-connector/_varify_linux.mdx rename to docs-cn/14-reference/03-connector/_verify_linux.mdx index 8c355560d7750cac8eea9c6f72f7b24a398ac274..84839f8e94fe68a709238b608ddd487afaaa97b1 100644 --- a/docs-cn/14-reference/03-connector/_varify_linux.mdx +++ b/docs-cn/14-reference/03-connector/_verify_linux.mdx @@ -1,14 +1,14 @@ -在 Linux shell 下直接执行 taos,应该就能正常连接到 TDegine 服务,进入到 taos shell 界面,示例如下: - -```mysql -$ taos -Welcome to the TDengine shell from Linux, Client Version:2.0.5.0 -Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. -taos> show databases; -name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB)| blocks | minrows | maxrows | wallevel | fsync | comp | precision | status | -========================================================================================================================================================================================================================= -test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16| 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready | -log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1| 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready | -Query OK, 2 row(s) in set (0.001198s) -taos> -``` +在 Linux shell 下直接执行 `taos` 连接到 TDegine 服务,进入到 TDengine CLI 界面,示例如下: + +```text +$ taos +Welcome to the TDengine shell from Linux, Client Version:2.0.5.0 +Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. +taos> show databases; +name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB)| blocks | minrows | maxrows | wallevel | fsync | comp | precision | status | +========================================================================================================================================================================================================================= +test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16| 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready | +log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1| 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready | +Query OK, 2 row(s) in set (0.001198s) +taos> +``` diff --git a/docs-cn/14-reference/03-connector/_varify_windows.mdx b/docs-cn/14-reference/03-connector/_verify_windows.mdx similarity index 86% rename from docs-cn/14-reference/03-connector/_varify_windows.mdx rename to docs-cn/14-reference/03-connector/_verify_windows.mdx index 9383ed2b23e70c5321c52dc67e5686e5afe23c4c..19ac71ec310ea18eb8dacde6dfa34f3bcd57f560 100644 --- a/docs-cn/14-reference/03-connector/_varify_windows.mdx +++ b/docs-cn/14-reference/03-connector/_verify_windows.mdx @@ -1,14 +1,14 @@ -在 cmd 下进入到 c:\TDengine 目录下直接执行 taos.exe,应该就能正常链接到 tdegine 服务,进入到 taos shell 界面,示例如下: - -```mysql - C:\TDengine>taos - Welcome to the TDengine shell from Linux, Client Version:2.0.5.0 - Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. - taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | precision | status | - =================================================================================================================================================================================================================================================================== - test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready | - log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready | - Query OK, 2 row(s) in set (0.045000s) - taos> -``` \ No newline at end of file +在 cmd 下进入到 C:\TDengine 目录下直接执行 `taos.exe`,连接到 TDengine 服务,进入到 TDengine CLI 界面,示例如下: + +```text + C:\TDengine>taos + Welcome to the TDengine shell from Linux, Client Version:2.0.5.0 + Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. + taos> show databases; + name | created_time | ntables | vgroups | replica | quorum | days | keep1,keep2,keep(D) | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | precision | status | + =================================================================================================================================================================================================================================================================== + test | 2020-10-14 10:35:48.617 | 10 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready | + log | 2020-10-12 09:08:21.651 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready | + Query OK, 2 row(s) in set (0.045000s) + taos> +``` diff --git a/docs-cn/14-reference/03-connector/_windows_install.mdx b/docs-cn/14-reference/03-connector/_windows_install.mdx index 67b04607172d5cd6e00b44d21b60c2c1a28d738a..ac7d5bfc0a9bdcfba7fa66258a4fdf097f1629b5 100644 --- a/docs-cn/14-reference/03-connector/_windows_install.mdx +++ b/docs-cn/14-reference/03-connector/_windows_install.mdx @@ -6,7 +6,7 @@ 默认安装路径为:C:\TDengine,其中包括以下文件(目录): - - _taos.exe_:taos shell 命令行程序 + - _taos.exe_:TDengine CLI 命令行程序 - _cfg_ : 配置文件目录 - _driver_: 应用驱动动态链接库 - _examples_: 示例程序 bash/C/C#/go/JDBC/Python/Node.js @@ -16,11 +16,11 @@ 4. 配置 taos.cfg - 编辑 taos.cfg 文件(默认路径 C:\TDengine\cfg\taos.cfg),将 firstEP 修改为 TDengine 服务器的 End Point,例如:`h1.taos.com:6030`。 + 编辑 taos.cfg 文件(默认路径 C:\TDengine\cfg\taos.cfg),将 firstEP 修改为 TDengine 服务器的 End Point,例如:`h1.tdengine.com:6030`。 :::tip -1. 如利用 FQDN 连接服务器,必须确认本机网络环境 DNS 已配置好,或在 hosts 文件中添加 FQDN 寻址记录,如编辑 C:\Windows\system32\drivers\etc\hosts,添加如下的记录:`192.168.1.99 h1.taos.com` +1. 如利用 FQDN 连接服务器,必须确认本机网络环境 DNS 已配置好,或在 hosts 文件中添加 FQDN 寻址记录, 如编辑 C:\Windows\system32\drivers\etc\hosts,添加类似如下的记录:`192.168.1.99 h1.taos.com` 2. 卸载:运行 unins000.exe 可卸载 TDengine 应用驱动。 ::: diff --git a/docs-cn/14-reference/03-connector/cpp.mdx b/docs-cn/14-reference/03-connector/cpp.mdx index a10fe7ef4c9e61e1207cc324b53423702a3afbe7..29aebaed3d8ca852950508ba751b8c86689724ca 100644 --- a/docs-cn/14-reference/03-connector/cpp.mdx +++ b/docs-cn/14-reference/03-connector/cpp.mdx @@ -1,44 +1,134 @@ --- sidebar_position: 1 +sidebar_label: C/C++ +title: C/C++ Connector --- -# C/C++ Connector +C/C++ 开发人员可以使用 TDengine 的客户端驱动,即 C/C++连接器 (以下都用 TDengine 客户端驱动表示),开发自己的应用来连接 TDengine 集群完成数据存储、查询以及其他功能。TDengine 客户端驱动的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TDengine 头文件 _taos.h_,里面列出了提供的 API 的函数原型;应用程序还要链接到所在平台上对应的动态库。 -**C/C++连接器支持的系统有**: - -| **CPU 类型** | x64(64bit) | | | ARM64 | ARM32 | -| ------------ | ------------ | -------- | -------- | -------- | -------- | -| **OS 类型** | Linux | Win64 | Win32 | Linux | Linux | -| **支持与否** | **支持** | **支持** | **支持** | **支持** | **支持** | +```c +#include +``` -C/C++的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TDengine 头文件 _taos.h_,里面列出了提供的 API 的函数原型。安装后,taos.h 位于: +TDengine 服务端或客户端安装后,`taos.h` 位于: - Linux:`/usr/local/taos/include` - Windows:`C:\TDengine\include` -```C -#include +TDengine 客户端驱动的动态库位于: + +- Linux: `/usr/local/taos/driver/libtaos.so` +- Windows: `C:\TDengine\taos.dll` + +## 支持的平台 + +请参考[支持的平台列表](/reference/connector#支持的平台) + +## 支持的版本 + +TDengine 客户端驱动的版本号与 TDengine 服务端的版本号是一一对应的强对应关系,建议使用与 TDengine 服务端完全相同的客户端驱动。虽然低版本的客户端驱动在前三段版本号一致(即仅第四段版本号不同)的情况下也能够与高版本的服务端相兼容,但这并非推荐用法。强烈不建议使用高版本的客户端驱动访问低版本的服务端。 + +## 安装步骤 + +TDengine 客户端驱动的安装请参考 [安装指南](/reference/connector#安装步骤) + +## 建立连接 + +使用客户端驱动访问 TDengine 集群的基本过程为:建立连接、查询和写入、关闭连接、清除资源。 + +下面为建立连接的示例代码,其中省略了查询和写入部分,展示了如何建立连接、关闭连接以及清除资源。 + +```c + TAOS *taos = taos_connect("localhost:6030", "root", "taosdata", NULL, 0); + if (taos == NULL) { + printf("failed to connect to server, reason:%s\n", "null taos" /*taos_errstr(taos)*/); + exit(1); + } + + /* put your code here for read and write */ + + taos_close(taos); + taos_cleanup(); ``` -注意: +在上面的示例代码中, `taos_connect` 建立到客户端程序所在主机的 6030 端口的连接,`taos_close`关闭当前连接,`taos_cleanup`清除客户端驱动所申请和使用的资源。 + +:::note -- 在编译时需要链接 TDengine 动态库。Linux 为 _libtaos.so_ ,安装后,位于 _/usr/local/taos/driver_。Windows 为 taos.dll,安装后位于 _C:\TDengine_。 - 如未特别说明,当 API 的返回值是整数时,_0_ 代表成功,其它是代表失败原因的错误码,当返回值是指针时, _NULL_ 表示失败。 -- 在 taoserror.h 中有所有的错误码,以及对应的原因描述。 +- 所有的错误码以及对应的原因描述在 taoserror.h 文件中。 + +::: + +## 示例程序 + +本节展示了使用客户端驱动访问 TDengine 集群的常见访问方式的示例代码。 + +### 同步查询示例 + +
+同步查询 + +```c +{{#include examples/c/demo.c}} +``` + +
+ +### 异步查询示例 + +
+异步查询 + +```c +{{#include examples/c/asyncdemo.c}} +``` + +
-### 示例程序 +### 参数绑定示例 -使用 C/C++连接器的示例代码请参见 https://github.com/taosdata/TDengine/tree/develop/examples/c 。 +
+参数绑定 -示例程序源码也可以在安装目录下的 examples/c 路径下找到: +```c +{{#include examples/c/prepare.c}} +``` + +
+ +### 无模式写入示例 + +
+无模式写入 -**apitest.c、asyncdemo.c、demo.c、prepare.c、stream.c、subscribe.c** +```c +{{#include examples/c/schemaless.c}} +``` + +
-该目录下有 makefile,在 Linux 环境下,直接执行 make 就可以编译得到执行文件。 +### 订阅和消费示例 -在一台机器上启动 TDengine 服务,执行这些示例程序,按照提示输入 TDengine 服务的 FQDN,就可以正常运行,并打印出信息。 +
+订阅和消费 -**提示:**在 ARM 环境下编译时,请将 makefile 中的-msse4.2 打开,这个选项只有在 x64/x86 硬件平台上才能支持。 +```c +{{#include examples/c/subscribe.c}} +``` + +
+ +:::info +更多示例代码及下载请见 [github](https://github.com/taosdata/TDengine/tree/develop/examples/c) +也可以在安装目录下的 examples/c 路径下找到。 该目录下有 makefile,在 Linux 环境下,直接执行 make 就可以编译得到执行文件。 +**提示:**在 ARM 环境下编译时,请将 makefile 中的 `-msse4.2` 去掉,这个选项只有在 x64/x86 硬件平台上才能支持。 + +::: + +## API 参考 + +以下分别介绍 TDengine 客户端驱动的基础 API、同步 API、异步 API、订阅 API 和无模式写入 API。 ### 基础 API @@ -46,7 +136,7 @@ C/C++的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TD - `void taos_init()` - 初始化运行环境。如果应用没有主动调用该 API,那么应用在调用`taos_connect`时将自动调用,故应用程序一般无需手动调用该 API。 + 初始化运行环境。如果应用没有主动调用该 API,那么应用在调用 `taos_connect()` 时将自动调用,故应用程序一般无需手动调用该 API。 - `void taos_cleanup()` @@ -72,7 +162,10 @@ C/C++的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TD 返回值为空表示失败。应用程序需要保存返回的参数,以便后续 API 调用。 - **提示:** 同一进程可以根据不同的 host/port 连接多个 taosd 集群 + :::info + 同一进程可以根据不同的 host/port 连接多个 TDengine 集群 + + ::: - `char *taos_get_server_info(TAOS *taos)` @@ -80,19 +173,19 @@ C/C++的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TD - `int taos_select_db(TAOS *taos, const char *db)` - 将当前的缺省数据库设置为`db`。 + 将当前的缺省数据库设置为 `db`。 - `void taos_close(TAOS *taos)` - 关闭连接,其中`taos`是`taos_connect`函数返回的指针。 + 关闭连接,其中`taos`是 `taos_connect()` 函数返回的指针。 ### 同步查询 API -传统的数据库操作 API,都属于同步操作。应用调用 API 后,一直处于阻塞状态,直到服务器返回结果。TDengine 支持如下 API: +传统的数据库操作 API,都属于同步操作。应用调用 API 后,一直处于阻塞状态,直到服务端返回结果。 - `TAOS_RES* taos_query(TAOS *taos, const char *sql)` - 该 API 用来执行 SQL 语句,可以是 DQL、DML 或 DDL 语句。 其中的`taos`参数是通过`taos_connect`获得的指针。不能通过返回值是否是 NULL 来判断执行结果是否失败,而是需要用`taos_errno`函数解析结果集中的错误代码来进行判断。 + 该 API 用来执行 SQL 语句,可以是 DQL、DML 或 DDL 语句。 其中的 `taos` 参数是通过 `taos_connect()` 获得的指针。不能通过返回值是否是 `NULL` 来判断执行结果是否失败,而是需要用 `taos_errno()` 函数解析结果集中的错误代码来进行判断。 - `int taos_result_precision(TAOS_RES *res)` @@ -112,7 +205,7 @@ C/C++的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TD - `int* taos_fetch_lengths(TAOS_RES *res)` - 获取结果集中每个字段的长度。 返回值是一个数组,其长度为结果集的列数。 + 获取结果集中每个字段的长度。返回值是一个数组,其长度为结果集的列数。 - `int taos_affected_rows(TAOS_RES *res)` @@ -120,13 +213,13 @@ C/C++的 API 类似于 MySQL 的 C API。应用程序使用时,需要包含 TD - `TAOS_FIELD *taos_fetch_fields(TAOS_RES *res)` - 获取查询结果集每列数据的属性(列的名称、列的数据类型、列的长度),与 taos_num_fileds 配合使用,可用来解析`taos_fetch_row`返回的一个元组(一行)的数据。 `TAOS_FIELD` 的结构如下: + 获取查询结果集每列数据的属性(列的名称、列的数据类型、列的长度),与 `taos_num_fileds()` 配合使用,可用来解析 `taos_fetch_row()` 返回的一个元组(一行)的数据。 `TAOS_FIELD` 的结构如下: ```c typedef struct taosField { - char name[65]; // 列名 - uint8_t type; // 数据类型 - int16_t bytes; // 长度,单位是字节 + char name[65]; // column name + uint8_t type; // data type + int16_t bytes; // length, in bytes } TAOS_FIELD; ``` @@ -136,7 +229,7 @@ typedef struct taosField { - `void taos_free_result(TAOS_RES *res)` - 释放查询结果集以及相关的资源。查询完成后,务必调用该 API 释放资源,否则可能导致应用内存泄露。但也需注意,释放资源后,如果再调用`taos_consume`等获取查询结果的函数,将导致应用 Crash。 + 释放查询结果集以及相关的资源。查询完成后,务必调用该 API 释放资源,否则可能导致应用内存泄露。但也需注意,释放资源后,如果再调用 `taos_consume()` 等获取查询结果的函数,将导致应用崩溃。 - `char *taos_errstr(TAOS_RES *res)` @@ -146,7 +239,10 @@ typedef struct taosField { 获取最近一次 API 调用失败的原因,返回值为错误代码。 -**注意**:2.0 及以上版本 TDengine 推荐数据库应用的每个线程都建立一个独立的连接,或基于线程建立连接池。而不推荐在应用中将该连接 (TAOS\*) 结构体传递到不同的线程共享使用。基于 TAOS 结构体发出的查询、写入等操作具有多线程安全性,但 “USE statement” 等状态量有可能在线程之间相互干扰。此外,C 语言的连接器可以按照需求动态建立面向数据库的新连接(该过程对用户不可见),同时建议只有在程序最后退出的时候才调用 taos_close 关闭连接。 +:::note +2.0 及以上版本 TDengine 推荐数据库应用的每个线程都建立一个独立的连接,或基于线程建立连接池。而不推荐在应用中将该连接 (TAOS\*) 结构体传递到不同的线程共享使用。基于 TAOS 结构体发出的查询、写入等操作具有多线程安全性,但 “USE statement” 等状态量有可能在线程之间相互干扰。此外,C 语言的连接器可以按照需求动态建立面向数据库的新连接(该过程对用户不可见),同时建议只有在程序最后退出的时候才调用 `taos_close()` 关闭连接。 + +::: ### 异步查询 API @@ -160,40 +256,37 @@ typedef struct taosField { 异步执行 SQL 语句。 - - taos:调用 taos_connect 返回的数据库连接 + - taos:调用 `taos_connect()` 返回的数据库连接 - sql:需要执行的 SQL 语句 - - fp:用户定义的回调函数,其第三个参数`code`用于指示操作是否成功,`0`表示成功,负数表示失败(调用`taos_errstr`获取失败原因)。应用在定义回调函数的时候,主要处理第二个参数`TAOS_RES *`,该参数是查询返回的结果集 + - fp:用户定义的回调函数,其第三个参数 `code` 用于指示操作是否成功,`0` 表示成功,负数表示失败(调用 `taos_errstr()` 可获取失败原因)。应用在定义回调函数的时候,主要处理第二个参数 `TAOS_RES *`,该参数是查询返回的结果集 - param:应用提供一个用于回调的参数 - `void taos_fetch_rows_a(TAOS_RES *res, void (*fp)(void *param, TAOS_RES *, int numOfRows), void *param);` - 批量获取异步查询的结果集,只能与`taos_query_a`配合使用。其中: + 批量获取异步查询的结果集,只能与 `taos_query_a()` 配合使用。其中: - - res:`taos_query_a`回调时返回的结果集 - - fp:回调函数。其参数`param`是用户可定义的传递给回调函数的参数结构体;`numOfRows`是获取到的数据的行数(不是整个查询结果集的函数)。 在回调函数中,应用可以通过调用`taos_fetch_row`前向迭代获取批量记录中每一行记录。读完一块内的所有记录后,应用需要在回调函数中继续调用`taos_fetch_rows_a`获取下一批记录进行处理,直到返回的记录数(numOfRows)为零(结果返回完成)或记录数为负值(查询出错)。 + - res:`taos_query_a()` 回调时返回的结果集 + - fp:回调函数。其参数 `param` 是用户可定义的传递给回调函数的参数结构体;`numOfRows` 是获取到的数据的行数(不是整个查询结果集的函数)。 在回调函数中,应用可以通过调用 `taos_fetch_row()` 前向迭代获取批量记录中每一行记录。读完一块内的所有记录后,应用需要在回调函数中继续调用 `taos_fetch_rows_a()` 获取下一批记录进行处理,直到返回的记录数 `numOfRows` 为零(结果返回完成)或记录数为负值(查询出错)。 TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多线程同时打开多张表,并可以同时对每张打开的表进行查询或者插入操作。需要指出的是,**客户端应用必须确保对同一张表的操作完全串行化**,即对同一个表的插入或查询操作未完成时(未返回时),不能够执行第二个插入或查询操作。 - ### 参数绑定 API -除了直接调用 `taos_query` 进行查询,TDengine 也提供了支持参数绑定的 Prepare API,与 MySQL 一样,这些 API 目前也仅支持用问号 `?` 来代表待绑定的参数。文档中有时也会把此功能称为“原生接口写入”。 +除了直接调用 `taos_query()` 进行查询,TDengine 也提供了支持参数绑定的 Prepare API,风格与 MySQL 类似,目前也仅支持用问号 `?` 来代表待绑定的参数。 从 2.1.1.0 和 2.1.2.0 版本开始,TDengine 大幅改进了参数绑定接口对数据写入(INSERT)场景的支持。这样在通过参数绑定接口写入数据时,就避免了 SQL 语法解析的资源消耗,从而在绝大多数情况下显著提升写入性能。此时的典型操作步骤如下: -1. 调用 `taos_stmt_init` 创建参数绑定对象; -2. 调用 `taos_stmt_prepare` 解析 INSERT 语句; -3. 如果 INSERT 语句中预留了表名但没有预留 TAGS,那么调用 `taos_stmt_set_tbname` 来设置表名; -4. 如果 INSERT 语句中既预留了表名又预留了 TAGS(例如 INSERT 语句采取的是自动建表的方式),那么调用 `taos_stmt_set_tbname_tags` 来设置表名和 TAGS 的值; -5. 调用 `taos_stmt_bind_param_batch` 以多列的方式设置 VALUES 的值,或者调用 `taos_stmt_bind_param` 以单行的方式设置 VALUES 的值; -6. 调用 `taos_stmt_add_batch` 把当前绑定的参数加入批处理; +1. 调用 `taos_stmt_init()` 创建参数绑定对象; +2. 调用 `taos_stmt_prepare()` 解析 INSERT 语句; +3. 如果 INSERT 语句中预留了表名但没有预留 TAGS,那么调用 `taos_stmt_set_tbname()` 来设置表名; +4. 如果 INSERT 语句中既预留了表名又预留了 TAGS(例如 INSERT 语句采取的是自动建表的方式),那么调用 `taos_stmt_set_tbname_tags()` 来设置表名和 TAGS 的值; +5. 调用 `taos_stmt_bind_param_batch()` 以多列的方式设置 VALUES 的值,或者调用 `taos_stmt_bind_param()` 以单行的方式设置 VALUES 的值; +6. 调用 `taos_stmt_add_batch()` 把当前绑定的参数加入批处理; 7. 可以重复第 3 ~ 6 步,为批处理加入更多的数据行; -8. 调用 `taos_stmt_execute` 执行已经准备好的批处理指令; -9. 执行完毕,调用 `taos_stmt_close` 释放所有资源。 +8. 调用 `taos_stmt_execute()` 执行已经准备好的批处理指令; +9. 执行完毕,调用 `taos_stmt_close()` 释放所有资源。 -说明:如果 `taos_stmt_execute` 执行成功,假如不需要改变 SQL 语句的话,那么是可以复用 `taos_stmt_prepare` 的解析结果,直接进行第 3 ~ 6 步绑定新数据的。但如果执行出错,那么并不建议继续在当前的环境上下文下继续工作,而是建议释放资源,然后从 `taos_stmt_init` 步骤重新开始。 - -除 C/C++ 语言外,TDengine 的 Java 语言 JNI Connector 也提供参数绑定接口支持,具体请另外参见:[参数绑定接口的 Java 用法](https://www.taosdata.com/cn/documentation/connector/java#stmt-java)。 +说明:如果 `taos_stmt_execute()` 执行成功,假如不需要改变 SQL 语句的话,那么是可以复用 `taos_stmt_prepare()` 的解析结果,直接进行第 3 ~ 6 步绑定新数据的。但如果执行出错,那么并不建议继续在当前的环境上下文下继续工作,而是建议释放资源,然后从 `taos_stmt_init()` 步骤重新开始。 接口相关的具体函数如下(也可以参考 [prepare.c](https://github.com/taosdata/TDengine/blob/develop/examples/c/prepare.c) 文件中使用对应函数的方式): @@ -207,50 +300,50 @@ TDengine 的异步 API 均采用非阻塞调用模式。应用程序可以用多 - `int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind)` - 不如 `taos_stmt_bind_param_batch` 效率高,但可以支持非 INSERT 类型的 SQL 语句。 - 进行参数绑定,bind 指向一个数组(代表所要绑定的一行数据),需保证此数组中的元素数量和顺序与 SQL 语句中的参数完全一致。TAOS_BIND 的使用方法与 MySQL 中的 MYSQL_BIND 一致,具体定义如下: - -```c -typedef struct TAOS_BIND { - int buffer_type; - void * buffer; - unsigned long buffer_length; // 未实际使用 - unsigned long *length; - int * is_null; - int is_unsigned; // 未实际使用 - int * error; // 未实际使用 -} TAOS_BIND; -``` + 不如 `taos_stmt_bind_param_batch()` 效率高,但可以支持非 INSERT 类型的 SQL 语句。 + 进行参数绑定,bind 指向一个数组(代表所要绑定的一行数据),需保证此数组中的元素数量和顺序与 SQL 语句中的参数完全一致。TAOS_BIND 的使用方法与 MySQL 中的 MYSQL_BIND 类似,具体定义如下: + + ```c + typedef struct TAOS_BIND { + int buffer_type; + void * buffer; + uintptr_t buffer_length; // not in use + uintptr_t * length; + int * is_null; + int is_unsigned; // not in use + int * error; // not in use + } TAOS_BIND; + ``` - `int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name)` - (2.1.1.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) + (2.1.1.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) 当 SQL 语句中的表名使用了 `?` 占位时,可以使用此函数绑定一个具体的表名。 - `int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags)` - (2.1.2.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) - 当 SQL 语句中的表名和 TAGS 都使用了 `?` 占位时,可以使用此函数绑定具体的表名和具体的 TAGS 取值。最典型的使用场景是使用了自动建表功能的 INSERT 语句(目前版本不支持指定具体的 TAGS 列)。tags 参数中的列数量需要与 SQL 语句中要求的 TAGS 数量完全一致。 + (2.1.2.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) + 当 SQL 语句中的表名和 TAGS 都使用了 `?` 占位时,可以使用此函数绑定具体的表名和具体的 TAGS 取值。最典型的使用场景是使用了自动建表功能的 INSERT 语句(目前版本不支持指定具体的 TAGS 列)。TAGS 参数中的列数量需要与 SQL 语句中要求的 TAGS 数量完全一致。 - `int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind)` - (2.1.1.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) + (2.1.1.0 版本新增,仅支持用于替换 INSERT 语句中的参数值) 以多列的方式传递待绑定的数据,需要保证这里传递的数据列的顺序、列的数量与 SQL 语句中的 VALUES 参数完全一致。TAOS_MULTI_BIND 的具体定义如下: -```c -typedef struct TAOS_MULTI_BIND { - int buffer_type; - void * buffer; - uintptr_t buffer_length; - int32_t * length; - char * is_null; - int num; // 列的个数,即 buffer 中的参数个数 -} TAOS_MULTI_BIND; -``` + ```c + typedef struct TAOS_MULTI_BIND { + int buffer_type; + void * buffer; + uintptr_t buffer_length; + uintptr_t * length; + char * is_null; + int num; // the number of columns + } TAOS_MULTI_BIND; + ``` - `int taos_stmt_add_batch(TAOS_STMT *stmt)` - 将当前绑定的参数加入批处理中,调用此函数后,可以再次调用 `taos_stmt_bind_param` 或 `taos_stmt_bind_param_batch` 绑定新的参数。需要注意,此函数仅支持 INSERT/IMPORT 语句,如果是 SELECT 等其他 SQL 语句,将返回错误。 + 将当前绑定的参数加入批处理中,调用此函数后,可以再次调用 `taos_stmt_bind_param()` 或 `taos_stmt_bind_param_batch()` 绑定新的参数。需要注意,此函数仅支持 INSERT/IMPORT 语句,如果是 SELECT 等其他 SQL 语句,将返回错误。 - `int taos_stmt_execute(TAOS_STMT *stmt)` @@ -258,7 +351,7 @@ typedef struct TAOS_MULTI_BIND { - `TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt)` - 获取语句的结果集。结果集的使用方式与非参数化调用时一致,使用完成后,应对此结果集调用 `taos_free_result` 以释放资源。 + 获取语句的结果集。结果集的使用方式与非参数化调用时一致,使用完成后,应对此结果集调用 `taos_free_result()` 以释放资源。 - `int taos_stmt_close(TAOS_STMT *stmt)` @@ -266,107 +359,54 @@ typedef struct TAOS_MULTI_BIND { - `char * taos_stmt_errstr(TAOS_STMT *stmt)` - (2.1.3.0 版本新增) - 用于在其他 stmt API 返回错误(返回错误码或空指针)时获取错误信息。 + (2.1.3.0 版本新增) + 用于在其他 STMT API 返回错误(返回错误码或空指针)时获取错误信息。 - -### Schemaless 方式写入接口 +### 无模式写入 API -除了使用 SQL 方式或者使用参数绑定 API 写入数据外,还可以使用 Schemaless 的方式完成写入。Schemaless 可以免于预先创建超级表/数据子表的数据结构,而是可以直接写入数据,TDengine 系统会根据写入的数据内容自动创建和维护所需要的表结构。Schemaless 的使用方式详见 [Schemaless 写入](https://www.taosdata.com/cn/documentation/insert#schemaless) 章节,这里介绍与之配套使用的 C/C++ API。 +除了使用 SQL 方式或者使用参数绑定 API 写入数据外,还可以使用 Schemaless 的方式完成写入。Schemaless 可以免于预先创建超级表/数据子表的数据结构,而是可以直接写入数据,TDengine 系统会根据写入的数据内容自动创建和维护所需要的表结构。Schemaless 的使用方式详见 [Schemaless 写入](/reference/schemaless/) 章节,这里介绍与之配套使用的 C/C++ API。 - `TAOS_RES* taos_schemaless_insert(TAOS* taos, const char* lines[], int numLines, int protocol, int precision)` - **功能说明** - 该接口将行协议的文本数据写入到 TDengine 中。 - - **参数说明** - taos: 数据库连接,通过 taos_connect 函数建立的数据库连接。 - lines:文本数据。满足解析格式要求的无模式文本字符串。 - numLines:文本数据的行数,不能为 0 。 - protocol: 行协议类型,用于标识文本数据格式。 - precision:文本数据中的时间戳精度字符串。 - - **返回值** - TAOS_RES 结构体,应用可以通过使用 taos_errstr 获得错误信息,也可以使用 taos_errno 获得错误码。 - 在某些情况下,返回的 TAOS_RES 为 NULL,此时仍然可以调用 taos_errno 来安全地获得错误码信息。 - 返回的 TAOS_RES 需要调用方来负责释放,否则会出现内存泄漏。 - - **说明** - 协议类型是枚举类型,包含以下三种格式: - TSDB_SML_LINE_PROTOCOL:InfluxDB 行协议(Line Protocol) - TSDB_SML_TELNET_PROTOCOL: OpenTSDB 文本行协议 - TSDB_SML_JSON_PROTOCOL: OpenTSDB Json 协议格式 - - 时间戳分辨率的定义,定义在 taos.h 文件中,具体内容如下: - TSDB_SML_TIMESTAMP_NOT_CONFIGURED = 0, - TSDB_SML_TIMESTAMP_HOURS, - TSDB_SML_TIMESTAMP_MINUTES, - TSDB_SML_TIMESTAMP_SECONDS, - TSDB_SML_TIMESTAMP_MILLI_SECONDS, - TSDB_SML_TIMESTAMP_MICRO_SECONDS, - TSDB_SML_TIMESTAMP_NANO_SECONDS - - 需要注意的是,时间戳分辨率参数只在协议类型为 SML_LINE_PROTOCOL 的时候生效。 - 对于 OpenTSDB 的文本协议,时间戳的解析遵循其官方解析规则 — 按照时间戳包含的字符的数量来确认时间精度。 - - **支持版本** - 该功能接口从 2.3.0.0 版本开始支持。 - -```c -#include -#include -#include - -int main() { - const char* host = "127.0.0.1"; - const char* user = "root"; - const char* passwd = "taosdata"; - - // connect to server - TAOS* taos = taos_connect(host, user, passwd, "test", 0); + **功能说明** + 该接口将行协议的文本数据写入到 TDengine 中。 - // prepare the line string - char* lines1[] = { - "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", - "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000" - }; + **参数说明** + taos: 数据库连接,通过 `taos_connect()` 函数建立的数据库连接。 + lines:文本数据。满足解析格式要求的无模式文本字符串。 + numLines:文本数据的行数,不能为 0 。 + protocol: 行协议类型,用于标识文本数据格式。 + precision:文本数据中的时间戳精度字符串。 - // schema-less insert - TAOS_RES* res = taos_schemaless_insert(taos, lines1, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - if (taos_errno(res) != 0) { - printf("failed to insert schema-less data, reason: %s\n", taos_errstr(res)); - } - - taos_free_result(res); - - // close the connection - taos_close(taos); - return (code); -} -``` + **返回值** + TAOS_RES 结构体,应用可以通过使用 `taos_errstr()` 获得错误信息,也可以使用 `taos_errno()` 获得错误码。 + 在某些情况下,返回的 TAOS_RES 为 `NULL`,此时仍然可以调用 `taos_errno()` 来安全地获得错误码信息。 + 返回的 TAOS_RES 需要调用方来负责释放,否则会出现内存泄漏。 -### 连续查询接口 + **说明** + 协议类型是枚举类型,包含以下三种格式: -TDengine 提供时间驱动的实时流式计算 API。可以每隔一指定的时间段,对一张或多张数据库的表(数据流)进行各种实时聚合计算操作。操作简单,仅有打开、关闭流的 API。具体如下: + - TSDB_SML_LINE_PROTOCOL:InfluxDB 行协议(Line Protocol) + - TSDB_SML_TELNET_PROTOCOL: OpenTSDB Telnet 文本行协议 + - TSDB_SML_JSON_PROTOCOL: OpenTSDB Json 协议格式 -- `TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sql, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), int64_t stime, void *param, void (*callback)(void *))` + 时间戳分辨率的定义,定义在 taos.h 文件中,具体内容如下: - 该 API 用来创建数据流,其中: + - TSDB_SML_TIMESTAMP_NOT_CONFIGURED = 0, + - TSDB_SML_TIMESTAMP_HOURS, + - TSDB_SML_TIMESTAMP_MINUTES, + - TSDB_SML_TIMESTAMP_SECONDS, + - TSDB_SML_TIMESTAMP_MILLI_SECONDS, + - TSDB_SML_TIMESTAMP_MICRO_SECONDS, + - TSDB_SML_TIMESTAMP_NANO_SECONDS - - taos:已经建立好的数据库连接。 - - sql:SQL 查询语句(仅能使用查询语句)。 - - fp:用户定义的回调函数指针,每次流式计算完成后,TDengine 将查询的结果(TAOS_ROW)、查询状态(TAOS_RES)、用户定义参数(PARAM)传递给回调函数,在回调函数内,用户可以使用 taos_num_fields 获取结果集列数,taos_fetch_fields 获取结果集每列数据的类型。 - - stime:是流式计算开始的时间。如果是“64 位整数最小值”,表示从现在开始;如果不为“64 位整数最小值”,表示从指定的时间开始计算(UTC 时间从 1970/1/1 算起的毫秒数)。 - - param:是应用提供的用于回调的一个参数,回调时,提供给应用。 - - callback: 第二个回调函数,会在连续查询自动停止时被调用。 + 需要注意的是,时间戳分辨率参数只在协议类型为 `SML_LINE_PROTOCOL` 的时候生效。 + 对于 OpenTSDB 的文本协议,时间戳的解析遵循其官方解析规则 — 按照时间戳包含的字符的数量来确认时间精度。 - 返回值为 NULL,表示创建失败;返回值不为空,表示成功。 + **支持版本** + 该功能接口从 2.3.0.0 版本开始支持。 -- `void taos_close_stream (TAOS_STREAM *tstr)` - - 关闭数据流,其中提供的参数是 taos_open_stream 的返回值。用户停止流式计算的时候,务必关闭该数据流。 - -### 数据订阅接口 +### 订阅和消费 API 订阅 API 目前支持订阅一张或多张表,并通过定期轮询的方式不断获取写入表中的最新数据。 @@ -380,7 +420,7 @@ TDengine 提供时间驱动的实时流式计算 API。可以每隔一指定的 - sql:订阅的查询语句,此语句只能是 `select` 语句,只应查询原始数据,只能按时间正序查询数据 - fp:收到查询结果时的回调函数(稍后介绍函数原型),只在异步调用时使用,同步调用时此参数应该传 `NULL` - param:调用回调函数时的附加参数,系统 API 将其原样传递到回调函数,不进行任何处理 - - interval:轮询周期,单位为毫秒。异步调用时,将根据此参数周期性的调用回调函数,为避免对系统性能造成影响,不建议将此参数设置的过小;同步调用时,如两次调用`taos_consume`的间隔小于此周期,API 将会阻塞,直到时间间隔超过此周期。 + - interval:轮询周期,单位为毫秒。异步调用时,将根据此参数周期性的调用回调函数,为避免对系统性能造成影响,不建议将此参数设置的过小;同步调用时,如两次调用 `taos_consume()` 的间隔小于此周期,API 将会阻塞,直到时间间隔超过此周期。 - `typedef void (*TAOS_SUBSCRIBE_CALLBACK)(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code)` @@ -388,17 +428,23 @@ TDengine 提供时间驱动的实时流式计算 API。可以每隔一指定的 - tsub:订阅对象 - res:查询结果集,注意结果集中可能没有记录 - - param:调用 `taos_subscribe`时客户程序提供的附加参数 + - param:调用 `taos_subscribe()` 时客户程序提供的附加参数 - code:错误码 - **注意**:在这个回调函数里不可以做耗时过长的处理,尤其是对于返回的结果集中数据较多的情况,否则有可能导致客户端阻塞等异常状态。如果必须进行复杂计算,则建议在另外的线程中进行处理。 + :::note + 在这个回调函数里不可以做耗时过长的处理,尤其是对于返回的结果集中数据较多的情况,否则有可能导致客户端阻塞等异常状态。如果必须进行复杂计算,则建议在另外的线程中进行处理。 + + ::: - `TAOS_RES *taos_consume(TAOS_SUB *tsub)` - 同步模式下,该函数用来获取订阅的结果。 用户应用程序将其置于一个循环之中。 如两次调用`taos_consume`的间隔小于订阅的轮询周期,API 将会阻塞,直到时间间隔超过此周期。 如果数据库有新记录到达,该 API 将返回该最新的记录,否则返回一个没有记录的空结果集。 如果返回值为 `NULL`,说明系统出错。 异步模式下,用户程序不应调用此 API。 + 同步模式下,该函数用来获取订阅的结果。 用户应用程序将其置于一个循环之中。 如两次调用 `taos_consume()` 的间隔小于订阅的轮询周期,API 将会阻塞,直到时间间隔超过此周期。如果数据库有新记录到达,该 API 将返回该最新的记录,否则返回一个没有记录的空结果集。 如果返回值为 `NULL`,说明系统出错。 异步模式下,用户程序不应调用此 API。 + + :::note + 在调用 `taos_consume()` 之后,用户应用应确保尽快调用 `taos_fetch_row()` 或 `taos_fetch_block()` 来处理订阅结果,否则服务端会持续缓存查询结果数据等待客户端读取,极端情况下会导致服务端内存消耗殆尽,影响服务稳定性。 - **注意**:在调用 `taos_consume()` 之后,用户应用应确保尽快调用 `taos_fetch_row()` 或 `taos_fetch_block()` 来处理订阅结果,否则服务端会持续缓存查询结果数据等待客户端读取,极端情况下会导致服务端内存消耗殆尽,影响服务稳定性。 + ::: - `void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress)` - 取消订阅。 如参数 `keepProgress` 不为 0,API 会保留订阅的进度信息,后续调用 `taos_subscribe` 时可以基于此进度继续;否则将删除进度信息,后续只能重新开始读取数据。 + 取消订阅。 如参数 `keepProgress` 不为 0,API 会保留订阅的进度信息,后续调用 `taos_subscribe()` 时可以基于此进度继续;否则将删除进度信息,后续只能重新开始读取数据。 diff --git a/docs-cn/14-reference/03-connector/cshapr.mdx b/docs-cn/14-reference/03-connector/cshapr.mdx deleted file mode 100644 index 9ce6d024dce8dcf1d9010f158d20effd4c054739..0000000000000000000000000000000000000000 --- a/docs-cn/14-reference/03-connector/cshapr.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -sidebar_position: 7 -sidebar_label: C# ---- - -# C# 连接器 - -- C# 连接器支持的系统有:Linux 64/Windows x64/Windows x86 - -- C# 连接器现在也支持从[Nuget 下载引用](https://www.nuget.org/packages/TDengine.Connector/) - -- 在 Windows 系统上,C# 应用程序可以使用 TDengine 的原生 C 接口来执行所有数据库操作,后续版本将提供 ORM(Dapper)框架驱动。 - -## 安装准备 - -- 应用驱动安装请参考[安装连接器驱动步骤](https://www.taosdata.com/cn/documentation/connector#driver)。 -- 接口文件 TDengineDrivercs.cs 和参考程序示例 TDengineTest.cs 均位于 Windows 客户端 install_directory/examples/C#目录下。 -- 安装[.NET SDK](https://dotnet.microsoft.com/download) - -## 示例程序 - -示例程序源码位于 - -- {client_install_directory}/examples/C# -- [C# example source code on GitHub](https://github.com/taosdata/TDengine/tree/develop/examples/C%23) - -:::note -TDengineTest.cs C# 示例源程序,包含了数据库连接参数,以及如何执行数据插入、查询等操作。 - -::: - -## 安装验证 - -需要先安装 .NET SDK - -```cmd -cd {client_install_directory}/examples/C#/C#Checker -//运行测试 -dotnet run -- -h . // 此步骤会先build,然后再运行。 -``` - -## C# 连接器的使用 - -在 Windows 系统上,C# 应用程序可以使用 TDengine 的 C# 连接器接口来执行所有数据库的操作。使用的具体步骤如下所示: - -- 创建一个 C# project(需要 .NET SDK). - - ```cmd - mkdir test - cd test - dotnet new console - ``` - -- 通过 Nuget 引用 TDengineDriver 包 - - ```cmd - dotnet add package TDengine.Connector - ``` - -- 在项目中需要用到 TDengineConnector 的地方引用 TDengineDriver namespace。 - - ```cs - using TDengineDriver; - ``` - -- 用户可以参考[TDengineTest.cs](https://github.com/taosdata/TDengine/tree/develop/examples/C%2523/TDengineTest)来定义数据库连接参数,以及如何执行数据插入、查询等操作。 - -:::note - -- TDengine V2.0.3.0 之后同时支持 32 位和 64 位 Windows 系统,所以 C# 项目在生成 .exe 文件时,“解决方案”/“项目”的“平台”请选择对应的 x86 或 x64。 -- 此接口目前已经在 Visual Studio 2015/2017 中验证过,其它 Visual Studio 版本尚待验证。 -- 此连接器需要用到 taos.dll 文件,所以在未安装客户端时需要在执行应用程序前,拷贝 Windows{client_install_directory}/driver 目录中的 taos.dll 文件到项目最后生成 .exe 可执行文件所在的文件夹。之后运行 exe 文件,即可访问 TDengine 数据库并做插入、查询等操作。 - -::: - -## 第三方驱动 - -Maikebing.Data.Taos 是一个 TDengine 的 ADO.NET 提供器,支持 Linux,Windows。该开发包由热心贡献者`麦壳饼@@maikebing`提供,具体请参考: - -- 接口下载:https://github.com/maikebing/Maikebing.EntityFrameworkCore.Taos -- 用法说明:https://www.taosdata.com/blog/2020/11/02/1901.html diff --git a/docs-cn/14-reference/03-connector/csharp.mdx b/docs-cn/14-reference/03-connector/csharp.mdx new file mode 100644 index 0000000000000000000000000000000000000000..bbefaacb459153ab5116d557fdf1940d487b4bd3 --- /dev/null +++ b/docs-cn/14-reference/03-connector/csharp.mdx @@ -0,0 +1,189 @@ +--- +toc_max_heading_level: 4 +sidebar_position: 7 +sidebar_label: C# +title: C# Connector +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +import Preparition from "./_preparition.mdx" +import CSInsert from "../../04-develop/03-insert-data/_cs_sql.mdx" +import CSInfluxLine from "../../04-develop/03-insert-data/_cs_line.mdx" +import CSOpenTSDBTelnet from "../../04-develop/03-insert-data/_cs_opts_telnet.mdx" +import CSOpenTSDBJson from "../../04-develop/03-insert-data/_cs_opts_json.mdx" +import CSQuery from "../../04-develop/04-query-data/_cs.mdx" +import CSAsyncQuery from "../../04-develop/04-query-data/_cs_async.mdx" + +`TDengine.Connector` 是 TDengine 提供的 C# 语言连接器。C# 开发人员可以通过它开发存取 TDengine 集群数据的 C# 应用软件。 + +`TDengine.Connector` 连接器支持通过 TDengine 客户端驱动(taosc)建立与 TDengine 运行实例的连接,提供数据写入、查询、订阅、schemaless 数据写入、参数绑定接口数据写入等功能 `TDengine.Connector` 目前暂未提供 REST 连接方式,用户可以参考 [RESTful APIs](https://docs.taosdata.com//reference/restful-api/) 文档自行编写。 + +本文介绍如何在 Linux 或 Windows 环境中安装 `TDengine.Connector`,并通过 `TDengine.Connector` 连接 TDengine 集群,进行数据写入、查询等基本操作。 + +`TDengine.Connector` 的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-dotnet)。 + +## 支持的平台 + +支持的平台和 TDengine 客户端驱动支持的平台一致。 + +## 版本支持 + +请参考[版本支持列表](/reference/connector#版本支持) + +## 支持的功能特性 + +1. 连接管理 +2. 普通查询 +3. 连续查询 +4. 参数绑定 +5. 订阅功能 +6. Schemaless + +## 安装步骤 + +### 安装前准备 + +* 安装 [.NET SDK](https://dotnet.microsoft.com/download) +* [Nuget 客户端](https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools) (可选安装) +* 安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动) + +### 使用 dotnet CLI 安装 + + + + +可以在当前 .NET 项目的路径下,通过 dotnet 命令引用 Nuget 中发布的 `TDengine.Connector` 到当前项目。 + +``` bash +dotnet add package TDengine.Connector +``` + + + + +可以下载 TDengine 的源码,直接引用最新版本的 TDengine.Connector 库 + +```bash +git clone https://github.com/taosdata/TDengine.git +cd TDengine/src/connector/C#/src/ +cp -r TDengineDriver/ myProject + +cd myProject +dotnet add TDengineDriver/TDengineDriver.csproj +``` + + + +## 建立连接 + +``` C# +using TDengineDriver; + +namespace TDengineExample +{ + + internal class EstablishConnection + { + static void Main(String[] args) + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = ""; + + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + Console.WriteLine("Connect to TDengine failed"); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + TDengine.Close(conn); + TDengine.Cleanup(); + } + } +} + +``` + +## 使用示例 + +### 写入数据 + +#### SQL 写入 + + + +#### InfluxDB 行协议写入 + + + +#### OpenTSDB Telnet 行协议写入 + + + +#### OpenTSDB JSON 行协议写入 + + + +### 查询数据 + +#### 同步查询 + + + +#### 异步查询 + + + +### 更多示例程序 + +|示例程序 | 示例程序描述 | +|--------------------------------------------------------------------------------------------------------------------|--------------------------------------------| +| [C#checker](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/C%23checker) | 使用 TDengine.Connector 可以通过 help 命令中提供的参数,测试C# Driver的同步写入和查询 | +| [TDengineTest](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/TDengineTest) | 使用 TDengine.Connector 实现的简单写入和查询的示例 | +| [insertCn](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/insertCn) | 使用 TDengine.Connector 实现的写入和查询中文字符的示例 | +| [jsonTag](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/jsonTag) | 使用 TDengine.Connector 实现的写入和查询 json tag 类型数据的示例 | +| [stmt](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/stmt) | 使用 TDengine.Connector 实现的参数绑定的示例 | +| [schemaless](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/schemaless) | 使用 TDengine.Connector 实现的使用 schemaless 写入的示例 | +| [benchmark](https://github.com/taosdata/TDengine/tree/develop/examples/C%23/taosdemo) | 使用 TDengine.Connector 实现的简易 Benchmark | +| [async query](https://github.com/taosdata/taos-connector-dotnet/blob/develop/examples/QueryAsyncSample.cs) | 使用 TDengine.Connector 实现的异步查询的示例 | +| [subscribe](https://github.com/taosdata/taos-connector-dotnet/blob/develop/examples/SubscribeSample.cs) | 使用 TDengine.Connector 实现的订阅数据的示例 | + +## 重要更新记录 + +| TDengine.Connector | 说明 | +|--------------------|--------------------------------| +| 1.0.6 | 修复 schemaless 在 1.0.4 和 1.0.5 中失效 bug。 | +| 1.0.5 | 修复 Windows 同步查询中文报错 bug。 | +| 1.0.4 | 新增异步查询,订阅等功能。修复绑定参数 bug。 | +| 1.0.3 | 新增参数绑定、schemaless、 json tag等功能。 | +| 1.0.2 | 新增连接管理、同步查询、错误信息等功能。 | + +## 其他说明 + +### 第三方驱动 + +`Maikebing.Data.Taos` 是一个 TDengine 的 ADO.NET 连接器,支持 Linux,Windows 平台。该连接器由社区贡献者`麦壳饼@@maikebing` 提供,具体请参考: + +* 接口下载: +* 用法说明: + +## 常见问题 + +1. "Unable to establish connection","Unable to resolve FQDN" + + 一般是因为 FQDN 配置不正确。可以参考[如何彻底搞懂 TDengine 的 FQDN](https://www.taosdata.com/blog/2021/07/29/2741.html)解决。 + +2. Unhandled exception. System.DllNotFoundException: Unable to load DLL 'taos' or one of its dependencies: 找不到指定的模块。 + + 一般是因为程序没有找到依赖的客户端驱动。解决方法为:Windows 下可以将 `C:\TDengine\driver\taos.dll` 拷贝到 `C:\Windows\System32\ ` 目录下,Linux 下建立如下软链接 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 + +## API 参考 + +[API 参考](https://docs.taosdata.com/api/connector-csharp/html/860d2ac1-dd52-39c9-e460-0829c4e5a40b.htm) diff --git a/docs-cn/14-reference/03-connector/go.mdx b/docs-cn/14-reference/03-connector/go.mdx index 888f4ae139c8246553ee863668ca11d6683f7068..2c73443a1c919ee41899baba5cb1e1aecc4b5552 100644 --- a/docs-cn/14-reference/03-connector/go.mdx +++ b/docs-cn/14-reference/03-connector/go.mdx @@ -1,138 +1,222 @@ --- +toc_max_heading_level: 4 sidebar_position: 4 +sidebar_label: Go +title: TDengine Go Connector --- -# Go Connector +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; -## 安装准备 +import Preparition from "./_preparition.mdx" +import GoInsert from "../../04-develop/03-insert-data/_go_sql.mdx" +import GoInfluxLine from "../../04-develop/03-insert-data/_go_line.mdx" +import GoOpenTSDBTelnet from "../../04-develop/03-insert-data/_go_opts_telnet.mdx" +import GoOpenTSDBJson from "../../04-develop/03-insert-data/_go_opts_json.mdx" +import GoQuery from "../../04-develop/04-query-data/_go.mdx" -Go 连接器支持的系统有: +`driver-go` 是 TDengine 的官方 Go 语言连接器,实现了 Go 语言[ database/sql ](https://golang.org/pkg/database/sql/) 包的接口。Go 开发人员可以通过它开发存取 TDengine 集群数据的应用软件。 -| **CPU 类型** | x64(64bit) | | | aarch64 | aarch32 | -| ------------ | ------------ | -------- | -------- | -------- | ---------- | -| **OS 类型** | Linux | Win64 | Win32 | Linux | Linux | -| **支持与否** | **支持** | **支持** | **支持** | **支持** | **开发中** | +`driver-go` 提供两种形式的连接器。一种是**原生连接器**,它通过 TDengine 客户端驱动程序(taosc)原生连接 TDengine 运行实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能。另外一种是 **REST 连接器**,它通过 taosAdapter 提供的 REST 接口连接 TDengine 运行实例。REST 连接实现的功能特性集合和原生连接有少量不同。 -安装前准备:已安装好 TDengine 应用驱动,参考[安装连接器驱动步骤](/reference/connector)。 +本文介绍如何安装 `driver-go`,并通过 `driver-go` 连接 TDengine 集群、进行数据查询、数据写入等基本操作。 -## 示例程序 +`driver-go` 的源码托管在 [GitHub](https://github.com/taosdata/driver-go)。 -使用 Go 连接器的示例代码请参考 `https://github.com/taosdata/TDengine/tree/develop/examples/go` 以及[视频教程](https://www.taosdata.com/blog/2020/11/11/1951.html)。 +## 支持的平台 -示例程序源码也位于安装目录下的 examples/go/taosdemo.go 文件中。 +原生连接器支持的平台和 TDengine 客户端驱动支持的平台一致。 +REST 连接器支持所有能运行 Go 的平台。 -:::tip -建议 Go 版本是 1.13 及以上,并开启模块支持: -::: +## 版本支持 -```sh -go env -w GO111MODULE=on -go env -w GOPROXY=https://goproxy.io,direct -``` +请参考[版本支持列表](/reference/connector#版本支持) -在 taosdemo.go 所在目录下进行编译和执行: +## 支持的功能特性 -```sh -go mod init taosdemo -go get github.com/taosdata/driver-go/taosSql -# use win branch in Windows platform. -#go get github.com/taosdata/driver-go/taosSql@win -go build -./taosdemo -h fqdn -p serverPort -``` +### 原生连接器 -## Go 连接器的使用 +“原生连接”指连接器通过 TDengine 客户端驱动(taosc)直接与 TDengine 运行实例建立的连接。支持的功能特性有: -TDengine 提供了 GO 驱动程序包`taosSql`。`taosSql` 实现了 GO 语言的内置接口 `database/sql/driver`。用户只需按如下方式引入包就可以在应用程序中访问 TDengine。 +* 普通查询 +* 连续查询 +* 订阅 +* schemaless 接口 +* 参数绑定接口 -```go -import ( - "database/sql" - _ "github.com/taosdata/driver-go/v2/taosSql" -) -``` +### REST 连接器 -:::tip -下划线与双引号之间必须有一个空格。 +"REST 连接"指连接器通过 taosAdapter 组件提供的 REST API 与 TDengine 运行实例建立的连接。支持的功能特性有: -::: +* 普通查询 +* 连续查询 -`taosSql` 的 v2 版本进行了重构,分离出内置数据库操作接口 `database/sql/driver` 到目录 `taosSql`;订阅、 stmt 等其他功能放到目录 `af`。 +## 安装步骤 -## 常用 API +### 安装前准备 + +* 安装 Go 开发环境(Go 1.14 及以上,GCC 4.8.5 及以上) +* 如果使用原生连接器,请安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动) + +配置好环境变量,检查命令: + +* ```go env``` +* ```gcc -v``` + +### 使用 go get 安装 + +`go get -u github.com/taosdata/driver-go/v2@develop` + +### 使用 go mod 管理 -- `sql.Open(DRIVER_NAME string, dataSourceName string) *DB` +1. 使用 `go mod` 命令初始化项目: - 该 API 用来打开 DB,返回一个类型为\*DB 的对象,一般情况下,DRIVER_NAME 设置为字符串 `taosSql`,dataSourceName 设置为字符串 `user:password@/tcp(host:port)/dbname`,如果客户想要用多个 goroutine 并发访问 TDengine, 那么需要在各个 goroutine 中分别创建一个 sql.Open 对象并用之访问 TDengine。 + ```text + go mod init taos-demo + ``` - **注意**: 该 API 成功创建的时候,并没有做权限等检查,只有在真正执行 Query 或者 Exec 的时候才能真正的去创建连接,并同时检查 user/password/host/port 是不是合法。另外,由于整个驱动程序大部分实现都下沉到 taosSql 所依赖的 libtaos 动态库中。所以,sql.Open 本身特别轻量。 +2. 引入 taosSql : -- `func (db *DB) Exec(query string, args ...interface{}) (Result, error)` + ```go + import ( + "database/sql" + _ "github.com/taosdata/driver-go/v2/taosSql" + ) + ``` + +3. 使用 `go mod tidy` 更新依赖包: + + ```text + go mod tidy + ``` + +4. 使用 `go run taos-demo` 运行程序或使用 `go build` 命令编译出二进制文件。 -sql.Open 内置的方法,用来执行非查询相关 SQL + ```text + go run taos-demo + go build + ``` -- `func (db *DB) Query(query string, args ...interface{}) (*Rows, error)` +## 建立连接 -sql.Open 内置的方法,用来执行查询语句 +### 数据源名称(DSN) -- `func (db *DB) Prepare(query string) (*Stmt, error)` +数据源名称具有通用格式,例如 [PEAR DB](http://pear.php.net/manual/en/package.database.db.intro-dsn.php),但没有类型前缀(方括号表示可选): - sql.Open 内置的方法,Prepare creates a prepared statement for later queries or executions. +``` text +[username[:password]@][protocol[(address)]]/[dbname][?param1=value1&...¶mN=valueN] +``` + +完整形式的 DSN: + +```text +username:password@protocol(address)/dbname?param=value +``` +### 使用连接器进行连接 -- `func (s *Stmt) Exec(args ...interface{}) (Result, error)` + + + +_taosSql_ 通过 cgo 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动就可以使用 [`database/sql`](https://golang.org/pkg/database/sql/) 的接口。 + +使用 `taosSql` 作为 `driverName` 并且使用一个正确的 [DSN](#DSN) 作为 `dataSourceName`,DSN 支持的参数: + +* configPath 指定 taos.cfg 目录 + +示例: + +```go +package main - sql.Open 内置的方法,executes a prepared statement with the given arguments and returns a Result summarizing the effect of the statement. +import ( + "database/sql" + "fmt" -- `func (s *Stmt) Query(args ...interface{}) (*Rows, error)` + _ "github.com/taosdata/driver-go/v2/taosSql" +) - sql.Open 内置的方法,Query executes a prepared query statement with the given arguments and returns the query results as a \*Rows. +func main() { + var taosUri = "root:taosdata/tcp(localhost:6030)/" + taos, err := sql.Open("taosSql", taosUri) + if err != nil { + fmt.Println("failed to connect TDengine, err:", err) + return + } +} +``` -- `func (s *Stmt) Close() error` + + - sql.Open 内置的方法,Close closes the statement. +_taosRestful_ 通过 `http client` 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动就可以使用[`database/sql`](https://golang.org/pkg/database/sql/)的接口。 -## 其他代码示例 +使用 `taosRestful` 作为 `driverName` 并且使用一个正确的 [DSN](#DSN) 作为 `dataSourceName`,DSN 支持的参数: -[Consume Messages from Kafka](https://github.com/taosdata/go-demo-kafka) 是一个通过 Go 语言实现消费 Kafka 队列写入 TDengine 的示例程序,也可以作为通过 Go 连接 TDengine 的写法参考。 +* `disableCompression` 是否接受压缩数据,默认为 true 不接受压缩数据,如果传输数据使用 gzip 压缩设置为 false。 +* `readBufferSize` 读取数据的缓存区大小默认为 4K(4096),当查询结果数据量多时可以适当调大该值。 -## Go RESTful 的使用 +示例: -### 引入 +```go +package main -```go restful import ( - "database/sql" - _ "github.com/taosdata/driver-go/v2/taosRestful" + "database/sql" + "fmt" + + _ "github.com/taosdata/driver-go/v2/taosRestful" ) + +func main() { + var taosUri = "root:taosdata/http(localhost:6041)/" + taos, err := sql.Open("taosRestful", taosUri) + if err != nil { + fmt.Println("failed to connect TDengine, err:", err) + return + } +} ``` + + + +## 使用示例 + +### 写入数据 + +#### SQL 写入 -`go.mod ` 的文件 require 块使用  github.com/taosdata/driver-go/v2 develop  之后执行  `go mod tidy ` + -`sql.Open `的 driverName 为  `taosRestful` +#### InfluxDB 行协议写入 -### DSN + -格式为: +#### OpenTSDB Telnet 行协议写入 -数据库用户名:数据库密码@连接方式(域名或 ip:端口)/[数据库][?参数] + -样例: +#### OpenTSDB JSON 行协议写入 -`root:taosdata@http(localhost:6041)/test?readBufferSize=52428800` + -参数: +### 查询数据 -`disableCompression` 是否接受压缩数据,默认为 true 不接受压缩数据,如果传输数据使用 gzip 压缩设置为 false。 + -`readBufferSize` 读取数据的缓存区大小默认为 4K(4096),当查询结果数据量多时可以适当调大该值。 +### 更多示例程序 -### 使用限制 +* [示例程序](https://github.com/taosdata/TDengine/tree/develop/examples/go) +* [视频教程](https://www.taosdata.com/blog/2020/11/11/1951.html)。 -由于 RESTful 接口无状态所以 `use db` 语法不会生效,需要将 db 名称放到 SQL 语句中,如:`create table if not exists tb1 (ts timestamp, a int)`改为`create table if not exists test.tb1 (ts timestamp, a int)`否则将报错`[0x217] Database not specified or available`。 +## 使用限制 -也可以将 db 名称放到 DSN 中,将 `root:taosdata@http(localhost:6041)/` 改为 `root:taosdata@http(localhost:6041)/test`,此方法在 TDengine 2.4.0.5 版本的 taosAdapter 开始支持。当指定的 db 不存在时执行 `create database` 语句不会报错,而执行针对该 db 的其他查询或写入操作会报错。完整示例如下: +由于 REST 接口无状态所以 `use db` 语法不会生效,需要将 db 名称放到 SQL 语句中,如:`create table if not exists tb1 (ts timestamp, a int)`改为`create table if not exists test.tb1 (ts timestamp, a int)`否则将报错`[0x217] Database not specified or available`。 -```go restful demo +也可以将 db 名称放到 DSN 中,将 `root:taosdata@http(localhost:6041)/` 改为 `root:taosdata@http(localhost:6041)/test`,此方法在 TDengine 2.4.0.5 版本的 taosAdapter 开始支持。当指定的 db 不存在时执行 `create database` 语句不会报错,而执行针对该 db 的其他查询或写入操作会报错。 + +完整示例如下: + +```go package main import ( @@ -180,32 +264,148 @@ func main() { } ``` -### 常见问题 +## 常见问题 -- 无法找到包`github.com/taosdata/driver-go/v2/taosRestful` +1. 无法找到包 `github.com/taosdata/driver-go/v2/taosRestful` 将 `go.mod` 中 require 块对`github.com/taosdata/driver-go/v2`的引用改为`github.com/taosdata/driver-go/v2 develop`,之后执行 `go mod tidy`。 -- stmt 相关接口崩溃 +2. database/sql 中 stmt(参数绑定)相关接口崩溃 - RESTful 不支持 stmt 相关接口,建议使用`db.Exec`和`db.Query`。 + REST 不支持参数绑定相关接口,建议使用`db.Exec`和`db.Query`。 -- 使用 `use db` 语句后执行其他语句报错 `[0x217] Database not specified or available` +3. 使用 `use db` 语句后执行其他语句报错 `[0x217] Database not specified or available` - 在 RESTful 接口中 SQL 语句的执行无上下文关联,使用 `use db` 语句不会生效,解决办法见上方使用限制章节。 + 在 REST 接口中 SQL 语句的执行无上下文关联,使用 `use db` 语句不会生效,解决办法见上方使用限制章节。 -- 使用 taosSql 不报错使用 taosRestful 报错 `[0x217] Database not specified or available` +4. 使用 taosSql 不报错使用 taosRestful 报错 `[0x217] Database not specified or available` - 因为 RESTful 接口无状态,使用 `use db` 语句不会生效,解决办法见上方使用限制章节。 + 因为 REST 接口无状态,使用 `use db` 语句不会生效,解决办法见上方使用限制章节。 -- 升级 `github.com/taosdata/driver-go/v2/taosRestful` +5. 升级 `github.com/taosdata/driver-go/v2/taosRestful` 将 `go.mod` 文件中对 `github.com/taosdata/driver-go/v2` 的引用改为 `github.com/taosdata/driver-go/v2 develop`,之后执行 `go mod tidy`。 -- readBufferSize 参数调大后无明显效果 +6. `readBufferSize` 参数调大后无明显效果 + + `readBufferSize` 调大后会减少获取结果时 `syscall` 的调用。如果查询结果的数据量不大,修改该参数不会带来明显提升,如果该参数修改过大,瓶颈会在解析 JSON 数据。如果需要优化查询速度,需要根据实际情况调整该值来达到查询效果最优。 + +7. `disableCompression` 参数设置为 `false` 时查询效率降低 + + 当 `disableCompression` 参数设置为 `false` 时查询结果会使用 `gzip` 压缩后传输,拿到数据后要先进行 `gzip` 解压。 + +8. `go get` 命令无法获取包,或者获取包超时 + + 设置 Go 代理 `go env -w GOPROXY=https://goproxy.cn,direct`。 + +## 常用 API + +### database/sql API + +* `sql.Open(DRIVER_NAME string, dataSourceName string) *DB` + + 该 API 用来打开 DB,返回一个类型为 \*DB 的对象。 + +:::info +该 API 成功创建的时候,并没有做权限等检查,只有在真正执行 Query 或者 Exec 的时候才能真正的去创建连接,并同时检查 user/password/host/port 是不是合法。 +::: + +* `func (db *DB) Exec(query string, args ...interface{}) (Result, error)` + + `sql.Open` 内置的方法,用来执行非查询相关 SQL。 + +* `func (db *DB) Query(query string, args ...interface{}) (*Rows, error)` + + `sql.Open` 内置的方法,用来执行查询语句。 + +### 高级功能(af)API + +`af` 包封装了连接管理、订阅、schemaless、参数绑定等 TDengine 高级功能。 + +#### 连接管理 + +* `af.Open(host, user, pass, db string, port int) (*Connector, error)` + + 该 API 通过 cgo 创建与 taosd 的连接。 + +* `func (conn *Connector) Close() error` + + 关闭与 taosd 的连接。 + +#### 订阅 + +* `func (conn *Connector) Subscribe(restart bool, topic string, sql string, interval time.Duration) (Subscriber, error)` + + 订阅数据。 + +* `func (s *taosSubscriber) Consume() (driver.Rows, error)` + + 消费订阅数据,返回 `database/sql/driver` 包的 `Rows` 结构。 + +* `func (s *taosSubscriber) Unsubscribe(keepProgress bool)` + + 取消订阅数据。 + +#### schemaless + +* `func (conn *Connector) InfluxDBInsertLines(lines []string, precision string) error` + + 写入 influxDB 行协议。 + +* `func (conn *Connector) OpenTSDBInsertTelnetLines(lines []string) error` + + 写入 OpenTDSB telnet 协议数据。 + +* `func (conn *Connector) OpenTSDBInsertJsonPayload(payload string) error` + + 写入 OpenTSDB JSON 协议数据。 + +#### 参数绑定 + +* `func (conn *Connector) StmtExecute(sql string, params *param.Param) (res driver.Result, err error)` + + 参数绑定单行插入。 + +* `func (conn *Connector) StmtQuery(sql string, params *param.Param) (rows driver.Rows, err error)` + + 参数绑定查询,返回 `database/sql/driver` 包的 `Rows` 结构。 + +* `func (conn *Connector) InsertStmt() *insertstmt.InsertStmt` + + 初始化参数。 + +* `func (stmt *InsertStmt) Prepare(sql string) error` + + 参数绑定预处理 SQL 语句。 + +* `func (stmt *InsertStmt) SetTableName(name string) error` + + 参数绑定设置表名。 + +* `func (stmt *InsertStmt) SetSubTableName(name string) error` + + 参数绑定设置子表名。 + +* `func (stmt *InsertStmt) BindParam(params []*param.Param, bindType *param.ColumnType) error` + + 参数绑定多行数据。 + +* `func (stmt *InsertStmt) AddBatch() error` + + 添加到参数绑定批处理。 + +* `func (stmt *InsertStmt) Execute() error` + + 执行参数绑定。 + +* `func (stmt *InsertStmt) GetAffectedRows() int` + + 获取参数绑定插入受影响行数。 + +* `func (stmt *InsertStmt) Close() error` - readBufferSize 调大后会减少获取结果时 syscall 的调用。如果查询结果的数据量不大,修改该参数不会带来明显提升,如果该参数修改过大,瓶颈会在解析 JSON 数据。如果需要优化查询速度,需要根据实际情况调整该值来达到查询效果最优。 + 结束参数绑定。 -- disableCompression 参数设置为 false 时查询效率降低 +## API 参考 - 当 disableCompression 参数设置为 false 时查询结果会 gzip 压缩后传输,拿到数据后要先进行 gzip 解压。 +全部 API 见 [driver-go 文档](https://pkg.go.dev/github.com/taosdata/driver-go/v2) diff --git a/docs-cn/14-reference/03-connector/java.mdx b/docs-cn/14-reference/03-connector/java.mdx index 95c04171e1141f587f9fcb5d790548ef412af7c6..293deb4fe6bc47e149e64bb738569f29744734e9 100644 --- a/docs-cn/14-reference/03-connector/java.mdx +++ b/docs-cn/14-reference/03-connector/java.mdx @@ -1,81 +1,41 @@ --- +toc_max_heading_level: 4 sidebar_position: 2 +sidebar_label: Java +title: TDengine Java Connector +description: TDengine Java 连接器基于标准 JDBC API 实现, 并提供原生连接与 REST连接两种连接器。 --- -# Java Connector +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; -## 总体介绍 +`taos-jdbcdriver` 是 TDengine 的官方 Java 语言连接器,Java 开发人员可以通过它开发存取 TDengine 数据库的应用软件。`taos-jdbcdriver` 实现了 JDBC driver 标准的接口,并提供两种形式的连接器。一种是通过 TDengine 客户端驱动程序(taosc)原生连接 TDengine 实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能,一种是通过 taosAdapter 提供的 REST 接口连接 TDengine 实例(2.0.18 及更高版本)。REST 连接实现的功能集合和原生连接有少量不同。 -`taos-jdbcdriver` 的实现包括 2 种形式: JDBC-JNI 和 JDBC-RESTful(taos-jdbcdriver-2.0.18 开始支持 JDBC-RESTful)。 JDBC-JNI 通过调用客户端 libtaos.so(或 taos.dll )的本地方法实现, JDBC-RESTful 则在内部封装了 RESTful 接口实现。 +![tdengine-connector](tdengine-jdbc-connector.png) -![tdengine-connector](/img/tdengine-jdbc-connector.png) +上图显示了两种 Java 应用使用连接器访问 TDengine 的两种方式: -上图显示了 3 种 Java 应用使用连接器访问 TDengine 的方式: +- JDBC 原生连接:Java 应用在物理节点 1(pnode1)上使用 TSDBDriver 直接调用客户端驱动(libtaos.so 或 taos.dll)的 API 将写入和查询请求发送到位于物理节点 2(pnode2)上的 taosd 实例。 +- JDBC REST 连接:Java 应用通过 RestfulDriver 将 SQL 封装成一个 REST 请求,发送给物理节点 2 的 REST 服务器(taosAdapter),通过 REST 服务器请求 taosd 并返回结果。 -- JDBC-JNI:Java 应用在物理节点 1(pnode1)上使用 JDBC-JNI 的 API ,直接调用客户端 API(libtaos.so 或 taos.dll)将写入和查询请求发送到位于物理节点 2(pnode2)上的 taosd 实例。 -- RESTful:应用将 SQL 发送给位于物理节点 2(pnode2)上的 RESTful 连接器,再调用客户端 API(libtaos.so)。 -- JDBC-RESTful:Java 应用通过 JDBC-RESTful 的 API ,将 SQL 封装成一个 RESTful 请求,发送给物理节点 2 的 RESTful 连接器。 +使用 REST 连接器,不依赖 TDengine 客户端驱动,可以跨平台,更加方便灵活,但性能比原生连接器低约 30%。 -TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致,但 TDengine 与关系对象型数据库的使用场景和技术特征存在差异,导致 `taos-jdbcdriver` 与传统的 JDBC driver 也存在一定差异。在使用时需要注意以下几点: +:::info +TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致,但 TDengine 与关系对象型数据库的使用场景和技术特征存在差异,所以`taos-jdbcdriver` 与传统的 JDBC driver 也存在一定差异。在使用时需要注意以下几点: - TDengine 目前不支持针对单条数据记录的删除操作。 - 目前不支持事务操作。 -### JDBC-JNI 和 JDBC-RESTful 的对比 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
对比项JDBC-JNIJDBC-RESTful
支持的操作系统linux、windows全平台
是否需要安装 client需要不需要
server 升级后是否需要升级 client需要不需要
写入性能JDBC-RESTful 是 JDBC-JNI 的 50%~90%
查询性能JDBC-RESTful 与 JDBC-JNI 没有差别
- -注意: - -- 与 JNI 方式不同,RESTful 接口是无状态的。在使用 JDBC-RESTful 时,需要在 sql 中指定表、超级表的数据库名称。例如: +::: -```sql -INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES(now, 24.6); -``` +## 支持的平台 -- 从 taos-jdbcdriver-2.0.36 和 TDengine 2.2.0.0 版本开始,如果在 url 中指定了 dbname,那么,JDBC-RESTful 会默认使用/rest/sql/dbname 作为 resful 请求的 url,在 sql 中不需要指定 dbname。例如:url 为 jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperatrue) tags('beijing') values(now, 24.6); +原生连接器支持的平台和 TDengine 客户端驱动支持的平台一致。 +REST 连接器支持所有能运行 Java 的平台。 ## 版本支持 -| taos-jdbcdriver 版本 | TDengine 2.0.x.x 版本 | TDengine 2.2.x.x 版本 | TDengine 2.4.x.x 版本 | JDK 版本 | -| -------------------- | --------------------- | --------------------- | --------------------- | -------- | -| 2.0.37 | X | X | 2.4.0.6 以上 | 1.8.x | -| 2.0.36 | X | 2.2.2.11 以上 | 2.4.0.0 - 2.4.0.5 | 1.8.x | -| 2.0.35 | X | 2.2.2.11 以上 | 2.3.0.0 - 2.4.0.5 | 1.8.x | -| 2.0.33 - 2.0.34 | 2.0.3.0 以上 | 2.2.0.0 以上 | 2.4.0.0 - 2.4.0.5 | 1.8.x | -| 2.0.31 - 2.0.32 | 2.1.3.0 - 2.1.7.7 | X | X | 1.8.x | -| 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.1 | X | X | 1.8.x | -| 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.4 | X | X | 1.8.x | -| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.3 | X | X | 1.8.x | +请参考[版本支持列表](/reference/connector#版本支持) ## TDengine DataType 和 Java DataType @@ -95,26 +55,21 @@ TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对 | NCHAR | java.lang.String | java.lang.String | | JSON | - | java.lang.String | -注意:JSON 类型仅在 tag 中支持。 +**注意**:JSON 类型仅在 tag 中支持。 -## 安装 Java Connector +## 安装步骤 ### 安装前准备 使用 Java Connector 连接数据库前,需要具备以下条件: -1. Linux 或 Windows 操作系统 -2. Java 1.8 以上运行时环境 -3. TDengine-client(使用 JDBC-JNI 时必须,使用 JDBC-RESTful 时非必须) - -**注意**:由于 TDengine 的应用驱动是使用 C 语言开发的,使用 taos-jdbcdriver 驱动包时需要依赖系统对应的本地函数库。 - -- libtaos.so 在 Linux 系统中成功安装 TDengine 后,依赖的本地函数库 libtaos.so 文件会被自动拷贝至 /usr/lib/libtaos.so,该目录包含在 Linux 自动扫描路径上,无需单独指定。 -- taos.dll 在 Windows 系统中安装完客户端之后,驱动包依赖的 taos.dll 文件会自动拷贝到系统默认搜索路径 C:/Windows/System32 下,同样无需要单独指定。 +- 已安装 Java 1.8 或以上版本运行时环境和 Maven 3.6 或以上版本 +- 已安装 TDengine 客户端驱动(使用原生连接必须安装,使用 REST 连接无需安装),具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动) -**注意**:在 Windows 环境开发时需要安装 TDengine 对应的 [windows 客户端](https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client),Linux 服务器安装完 TDengine 之后默认已安装 client,也可以单独安装 [Linux 客户端](https://www.taosdata.com/cn/getting-started/#快速上手) 连接远程 TDengine Server。 +### 安装连接器 -### 通过 maven 获取 JDBC driver + + 目前 taos-jdbcdriver 已经发布到 [Sonatype Repository](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver) 仓库,且各大仓库都已同步。 @@ -122,51 +77,41 @@ TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对 - [mvnrepository](https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver) - [maven.aliyun](https://maven.aliyun.com/mvn/search) -maven 项目中,在 pom.xml 中添加以下依赖: +Maven 项目中,在 pom.xml 中添加以下依赖: ```xml-dtd com.taosdata.jdbc taos-jdbcdriver - 2.0.18 + 2.0.** ``` -### 通过源码编译获取 JDBC driver + + -可以通过下载 TDengine 的源码,自己编译最新版本的 java connector +可以通过下载 TDengine 的源码,自己编译最新版本的 Java connector ```shell git clone https://github.com/taosdata/TDengine.git cd TDengine/src/connector/jdbc -mvn clean package -Dmaven.test.skip=true +mvn clean install -Dmaven.test.skip=true ``` -编译后,在 target 目录下会产生 taos-jdbcdriver-2.0.XX-dist.jar 的 jar 包。 +编译后,在 target 目录下会产生 taos-jdbcdriver-2.0.XX-dist.jar 的 jar 包,并自动将编译的 jar 文件放在本地的 Maven 仓库中。 -## Java 连接器的使用 + + -### 获取连接 +## 建立连接 -#### 指定 URL 获取连接 - -通过指定 URL 获取连接,如下所示: - -```java -Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); -String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata"; -Connection conn = DriverManager.getConnection(jdbcUrl); -``` - -以上示例,使用 **JDBC-RESTful** 的 driver,建立了到 hostname 为 taosdemo.com,端口为 6041,数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 - -使用 JDBC-RESTful 接口,不需要依赖本地函数库。与 JDBC-JNI 相比,仅需要: +TDengine 的 JDBC URL 规范格式为: +`jdbc:[TAOS|TAOS-RS]://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]` -1. driverClass 指定为“com.taosdata.jdbc.rs.RestfulDriver”; -2. jdbcUrl 以“jdbc:TAOS-RS://”开头; -3. 使用 6041 作为连接端口。 +对于建立连接,原生连接器与 REST 连接器有细微不同。 -如果希望获得更好的写入和查询性能,Java 应用可以使用 **JDBC-JNI** 的 driver,如下所示: + + ```java Class.forName("com.taosdata.jdbc.TSDBDriver"); @@ -174,16 +119,9 @@ String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata Connection conn = DriverManager.getConnection(jdbcUrl); ``` -以上示例,使用了 JDBC-JNI 的 driver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 - -**注意**:使用 JDBC-JNI 的 driver,taos-jdbcdriver 驱动包时需要依赖系统对应的本地函数库(Linux 下是 libtaos.so;Windows 下是 taos.dll)。 +以上示例,使用了 JDBC 原生连接的 TSDBDriver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 -> 在 Windows 环境开发时需要安装 TDengine 对应的 [windows 客户端](https://www.taosdata.com/cn/all-downloads/#TDengine-Windows-Client),Linux 服务器安装完 TDengine 之后默认已安装 client,也可以单独安装 [Linux 客户端](https://www.taosdata.com/cn/getting-started/#%E5%AE%A2%E6%88%B7%E7%AB%AF) 连接远程 TDengine Server。 - -JDBC-JNI 的使用请参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1955.html)。 - -TDengine 的 JDBC URL 规范格式为: -`jdbc:[TAOS|TAOS-RS]://[host_name]:[port]/[database_name]?[user={user}|&password={password}|&charset={charset}|&cfgdir={config_dir}|&locale={locale}|&timezone={timezone}]` +**注意**:使用 JDBC 原生连接,taos-jdbcdriver 需要依赖客户端驱动(Linux 下是 libtaos.so;Windows 下是 taos.dll)。 url 中的配置参数如下: @@ -193,46 +131,14 @@ url 中的配置参数如下: - charset:客户端使用的字符集,默认值为系统字符集。 - locale:客户端语言环境,默认值系统当前 locale。 - timezone:客户端使用的时区,默认值为系统当前时区。 -- batchfetch: 仅在使用 JDBC-JNI 时生效。true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。 -- timestampFormat: 仅在使用 JDBC-RESTful 时生效. 'TIMESTAMP':结果集中 timestamp 类型的字段为一个 long 值; 'UTC':结果集中 timestamp 类型的字段为一个 UTC 时间格式的字符串; 'STRING':结果集中 timestamp 类型的字段为一个本地时间格式的字符串。默认值为'STRING'。 -- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 sql 执行失败,继续执行下面的 sq 了。false:不再执行失败 sql 后的任何语句。默认值为:false。 +- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。开启批量拉取同时获取一批数据在查询数据量较大时批量拉取可以有效的提升查询性能。 +- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败将继续执行下面的 SQL。false:不再执行失败 SQL 后的任何语句。默认值为:false。 -#### 指定 URL 和 Properties 获取连接 +JDBC 原生连接的使用请参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1955.html)。 -除了通过指定的 URL 获取连接,还可以使用 Properties 指定建立连接时的参数,如下所示: +**使用 TDengine 客户端驱动配置文件建立连接 ** -```java -public Connection getConn() throws Exception{ - Class.forName("com.taosdata.jdbc.TSDBDriver"); - // Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); - String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"; - // String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata"; - Properties connProps = new Properties(); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - Connection conn = DriverManager.getConnection(jdbcUrl, connProps); - return conn; -} -``` - -以上示例,建立一个到 hostname 为 taosdemo.com,端口为 6030,数据库名为 test 的连接。注释为使用 JDBC-RESTful 时的方法。这个连接在 url 中指定了用户名(user)为 root,密码(password)为 taosdata,并在 connProps 中指定了使用的字符集、语言环境、时区等信息。 - -properties 中的配置参数如下: - -- TSDBDriver.PROPERTY_KEY_USER:登录 TDengine 用户名,默认值 'root'。 -- TSDBDriver.PROPERTY_KEY_PASSWORD:用户登录密码,默认值 'taosdata'。 -- TSDBDriver.PROPERTY_KEY_CONFIG_DIR:客户端配置文件目录路径,Linux OS 上默认值 `/etc/taos`,Windows OS 上默认值 `C:/TDengine/cfg`。 -- TSDBDriver.PROPERTY_KEY_CHARSET:客户端使用的字符集,默认值为系统字符集。 -- TSDBDriver.PROPERTY_KEY_LOCALE:客户端语言环境,默认值系统当前 locale。 -- TSDBDriver.PROPERTY_KEY_TIME_ZONE:客户端使用的时区,默认值为系统当前时区。 -- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: 仅在使用 JDBC-JNI 时生效。true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。 -- TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT: 仅在使用 JDBC-RESTful 时生效. 'TIMESTAMP':结果集中 timestamp 类型的字段为一个 long 值; 'UTC':结果集中 timestamp 类型的字段为一个 UTC 时间格式的字符串; 'STRING':结果集中 timestamp 类型的字段为一个本地时间格式的字符串。默认值为'STRING'。 -- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE:true:在执行 Statement 的 executeBatch 时,如果中间有一条 sql 执行失败,继续执行下面的 sq 了。false:不再执行失败 sql 后的任何语句。默认值为:false。 - -#### 使用客户端配置文件建立连接 - -当使用 JDBC-JNI 连接 TDengine 集群时,可以使用客户端配置文件,在客户端配置文件中指定集群的 firstEp、secondEp 参数。如下所示: +当使用 JDBC 原生连接连接 TDengine 集群时,可以使用 TDengine 客户端驱动配置文件,在配置文件中指定集群的 firstEp、secondEp 等参数。如下所示: 1. 在 Java 应用中不指定 hostname 和 port @@ -251,7 +157,7 @@ public Connection getConn() throws Exception{ 2. 在配置文件中指定 firstEp 和 secondEp -``` +```shell # first fully qualified domain name (FQDN) for TDengine system firstEp cluster_node1:6030 @@ -269,19 +175,107 @@ secondEp cluster_node2:6030 TDengine 中,只要保证 firstEp 和 secondEp 中一个节点有效,就可以正常建立到集群的连接。 -> 注意:这里的配置文件指的是调用 JDBC Connector 的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。 +> **注意**:这里的配置文件指的是调用 JDBC Connector 的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。 -#### 配置参数的优先级 + + -通过以上 3 种方式获取连接,如果配置参数在 url、Properties、客户端配置文件中有重复,则参数的`优先级由高到低`分别如下: +```java +Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); +String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata"; +Connection conn = DriverManager.getConnection(jdbcUrl); +``` + +以上示例,使用了 JDBC REST 连接的 RestfulDriver,建立了到 hostname 为 taosdemo.com,端口为 6041,数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。 + +使用 JDBC REST 连接,不需要依赖客户端驱动。与 JDBC 原生连接相比,仅需要: + +1. driverClass 指定为“com.taosdata.jdbc.rs.RestfulDriver”; +2. jdbcUrl 以“jdbc:TAOS-RS://”开头; +3. 使用 6041 作为连接端口。 + +url 中的配置参数如下: + +- user:登录 TDengine 用户名,默认值 'root'。 +- password:用户登录密码,默认值 'taosdata'。 +- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。从 taos-jdbcdriver-2.0.38 和 TDengine 2.4.0.12 版本开始,JDBC REST 连接增加批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。 +- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。 + +**注意**:部分配置项(比如:locale、timezone)在 REST 连接中不生效。 + +:::note + +- 与原生连接方式不同,REST 接口是无状态的。在使用 JDBC REST 连接时,需要在 SQL 中指定表、超级表的数据库名称。例如: + +```sql +INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES(now, 24.6); +``` + +- 从 taos-jdbcdriver-2.0.36 和 TDengine 2.2.0.0 版本开始,如果在 url 中指定了 dbname,那么,JDBC REST 连接会默认使用/rest/sql/dbname 作为 resful 请求的 url,在 SQL 中不需要指定 dbname。例如:url 为 jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperatrue) tags('beijing') values(now, 24.6); + +::: + + + + +### 指定 URL 和 Properties 获取连接 + +除了通过指定的 URL 获取连接,还可以使用 Properties 指定建立连接时的参数。 + +**注意**: + +- 应用中设置的 client parameter 为进程级别的,即如果要更新 client 的参数,需要重启应用。这是因为 client parameter 是全局参数,仅在应用程序的第一次设置生效。 +- 以下示例代码基于 taos-jdbcdriver-2.0.36。 + +```java +public Connection getConn() throws Exception{ + Class.forName("com.taosdata.jdbc.TSDBDriver"); + String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"; + Properties connProps = new Properties(); + connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + connProps.setProperty("debugFlag", "135"); + connProps.setProperty("maxSQLLength", "1048576"); + Connection conn = DriverManager.getConnection(jdbcUrl, connProps); + return conn; +} + +public Connection getRestConn() throws Exception{ + Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); + String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata"; + Properties connProps = new Properties(); + connProps.setProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD, "true"); + Connection conn = DriverManager.getConnection(jdbcUrl, connProps); + return conn; +} +``` + +以上示例,建立一个到 hostname 为 taosdemo.com,端口为 6030/6041,数据库名为 test 的连接。这个连接在 url 中指定了用户名(user)为 root,密码(password)为 taosdata,并在 connProps 中指定了使用的字符集、语言环境、时区、是否开启批量拉取等信息。 + +properties 中的配置参数如下: + +- TSDBDriver.PROPERTY_KEY_USER:登录 TDengine 用户名,默认值 'root'。 +- TSDBDriver.PROPERTY_KEY_PASSWORD:用户登录密码,默认值 'taosdata'。 +- TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。 +- TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 sq 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。 +- TSDBDriver.PROPERTY_KEY_CONFIG_DIR:仅在使用 JDBC 原生连接时生效。客户端配置文件目录路径,Linux OS 上默认值 `/etc/taos`,Windows OS 上默认值 `C:/TDengine/cfg`。 +- TSDBDriver.PROPERTY_KEY_CHARSET:仅在使用 JDBC 原生连接时生效。 客户端使用的字符集,默认值为系统字符集。 +- TSDBDriver.PROPERTY_KEY_LOCALE:仅在使用 JDBC 原生连接时生效。 客户端语言环境,默认值系统当前 locale。 +- TSDBDriver.PROPERTY_KEY_TIME_ZONE:仅在使用 JDBC 原生连接时生效。 客户端使用的时区,默认值为系统当前时区。 +- 此外对 JDBC 原生连接,通过指定 URL 和 Properties 还可以指定其他参数,比如日志级别、SQL 长度等。更多详细配置请参考[客户端配置](/reference/config/#仅客户端适用)。 + +### 配置参数的优先级 + +通过前面三种方式获取连接,如果配置参数在 url、Properties、客户端配置文件中有重复,则参数的`优先级由高到低`分别如下: 1. JDBC URL 参数,如上所述,可以在 JDBC URL 的参数中指定。 2. Properties connProps -3. 客户端配置文件 taos.cfg +3. 使用原生连接时,TDengine 客户端驱动的配置文件 taos.cfg 例如:在 url 中指定了 password 为 taosdata,在 Properties 中指定了 password 为 taosdemo,那么,JDBC 会使用 url 中的 password 建立连接。 -> 更多详细配置请参考[客户端配置](https://www.taosdata.com/cn/documentation/administrator/#client) +## 使用示例 ### 创建数据库和表 @@ -298,7 +292,7 @@ stmt.executeUpdate("use db"); stmt.executeUpdate("create table if not exists tb (ts timestamp, temperature int, humidity float)"); ``` -> 注意:如果不使用 `use db` 指定数据库,则后续对表的操作都需要增加数据库名称作为前缀,如 db.tb。 +> **注意**:如果不使用 `use db` 指定数据库,则后续对表的操作都需要增加数据库名称作为前缀,如 db.tb。 ### 插入数据 @@ -350,25 +344,24 @@ try (Statement statement = connection.createStatement()) { } ``` -JDBC 连接器可能报错的错误码包括 3 种:JDBC driver 本身的报错(错误码在 0x2301 到 0x2350 之间),JNI 方法的报错(错误码在 0x2351 到 0x2400 之间),TDengine 其他功能模块的报错。 +JDBC 连接器可能报错的错误码包括 3 种:JDBC driver 本身的报错(错误码在 0x2301 到 0x2350 之间),原生连接方法的报错(错误码在 0x2351 到 0x2400 之间),TDengine 其他功能模块的报错。 具体的错误码请参考: - https://github.com/taosdata/TDengine/blob/develop/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java - https://github.com/taosdata/TDengine/blob/develop/src/inc/taoserror.h -### 通过参数绑定写入数据 +### 通过参数绑定写入数据 + +从 2.1.2.0 版本开始,TDengine 的 JDBC 原生连接实现大幅改进了参数绑定方式对数据写入(INSERT)场景的支持。采用这种方式写入数据时,能避免 SQL 语法解析的资源消耗,从而在很多情况下显著提升写入性能。 -从 2.1.2.0 版本开始,TDengine 的 JDBC-JNI 实现大幅改进了参数绑定方式对数据写入(INSERT)场景的支持。采用这种方式写入数据时,能避免 SQL 语法解析的资源消耗,从而在很多情况下显著提升写入性能。 -注意: +**注意**: -- JDBC-RESTful 实现并不提供参数绑定这种使用方式 +- JDBC REST 连接目前不支持参数绑定 - 以下示例代码基于 taos-jdbcdriver-2.0.36 - binary 类型数据需要调用 setString 方法,nchar 类型数据需要调用 setNString 方法 - setString 和 setNString 都要求用户在 size 参数里声明表定义中对应列的列宽 -示例代码: - ```java public class ParameterBindingDemo { @@ -626,70 +619,49 @@ public void setString(int columnIndex, ArrayList list, int size) throws public void setNString(int columnIndex, ArrayList list, int size) throws SQLException ``` -### 设置客户端参数 +### 无模式写入 -从 TDengine-2.3.5.0 版本开始,jdbc driver 支持在应用的第一次连接中,设置 TDengine 的客户端参数。Driver 支持 JDBC-JNI 方式中,通过 jdbcUrl 和 properties 两种方式设置 client parameter。 -注意: +从 2.2.0.0 版本开始,TDengine 增加了对无模式写入功能。无模式写入兼容 InfluxDB 的 行协议(Line Protocol)、OpenTSDB 的 telnet 行协议和 OpenTSDB 的 JSON 格式协议。详情请参见[无模式写入](/reference/schemaless/)。 -- JDBC-RESTful 不支持设置 client parameter 的功能。 -- 应用中设置的 client parameter 为进程级别的,即如果要更新 client 的参数,需要重启应用。这是因为 client parameter 是全局参数,仅在应用程序的第一次设置生效。 -- 以下示例代码基于 taos-jdbcdriver-2.0.36。 +**注意**: -示例代码: +- JDBC REST 连接目前不支持无模式写入 +- 以下示例代码基于 taos-jdbcdriver-2.0.36 ```java -public class ClientParameterSetting { +public class SchemalessInsertTest { private static final String host = "127.0.0.1"; + private static final String lineDemo = "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000"; + private static final String telnetDemo = "stb0_0 1626006833 4 host=host0 interface=eth0"; + private static final String jsonDemo = "{\"metric\": \"meter_current\",\"timestamp\": 1346846400,\"value\": 10.3, \"tags\": {\"groupid\": 2, \"location\": \"Beijing\", \"id\": \"d1001\"}}"; public static void main(String[] args) throws SQLException { - setParameterInJdbcUrl(); - - setParameterInProperties(); - } - - private static void setParameterInJdbcUrl() throws SQLException { - String jdbcUrl = "jdbc:TAOS://" + host + ":6030/?debugFlag=135&asyncLog=0"; - - Connection connection = DriverManager.getConnection(jdbcUrl, "root", "taosdata"); - - printDatabase(connection); - - connection.close(); - } - - private static void setParameterInProperties() throws SQLException { - String jdbcUrl = "jdbc:TAOS://" + host + ":6030/"; - Properties properties = new Properties(); - properties.setProperty("user", "root"); - properties.setProperty("password", "taosdata"); - properties.setProperty("debugFlag", "135"); - properties.setProperty("asyncLog", "0"); - properties.setProperty("maxSQLLength", "1048576"); - - try (Connection conn = DriverManager.getConnection(jdbcUrl, properties)) { - printDatabase(conn); + final String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; + try (Connection connection = DriverManager.getConnection(url)) { + init(connection); + + SchemalessWriter writer = new SchemalessWriter(connection); + writer.write(lineDemo, SchemalessProtocolType.LINE, SchemalessTimestampType.NANO_SECONDS); + writer.write(telnetDemo, SchemalessProtocolType.TELNET, SchemalessTimestampType.MILLI_SECONDS); + writer.write(jsonDemo, SchemalessProtocolType.JSON, SchemalessTimestampType.NOT_CONFIGURED); } } - private static void printDatabase(Connection connection) throws SQLException { + private static void init(Connection connection) throws SQLException { try (Statement stmt = connection.createStatement()) { - ResultSet rs = stmt.executeQuery("show databases"); - - ResultSetMetaData meta = rs.getMetaData(); - while (rs.next()) { - for (int i = 1; i <= meta.getColumnCount(); i++) { - System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); - } - System.out.println(); - } + stmt.executeUpdate("drop database if exists test_schemaless"); + stmt.executeUpdate("create database if not exists test_schemaless"); + stmt.executeUpdate("use test_schemaless"); } } } ``` -## 订阅 +### 订阅 -### 创建 +TDengine Java 连接器支持订阅功能,应用 API 如下: + +#### 创建订阅 ```java TSDBSubscribe sub = ((TSDBConnection)conn).subscribe("topic", "select * from meters", false); @@ -703,7 +675,7 @@ TSDBSubscribe sub = ((TSDBConnection)conn).subscribe("topic", "select * from met 如上面的例子将使用 SQL 语句 `select * from meters` 创建一个名为 `topic` 的订阅,如果这个订阅已经存在,将继续之前的查询进度,而不是从头开始消费所有的数据。 -### 消费数据 +#### 订阅消费数据 ```java int total = 0; @@ -721,7 +693,7 @@ while(true) { `consume` 方法返回一个结果集,其中包含从上次 `consume` 到目前为止的所有新数据。请务必按需选择合理的调用 `consume` 的频率(如例子中的 `Thread.sleep(1000)`),否则会给服务端造成不必要的压力。 -### 关闭订阅 +#### 关闭订阅 ```java sub.close(true); @@ -729,7 +701,7 @@ sub.close(true); `close` 方法关闭一个订阅。如果其参数为 `true` 表示保留订阅进度信息,后续可以创建同名订阅继续消费数据;如为 `false` 则不保留订阅进度。 -## 关闭资源 +### 关闭资源 ```java resultSet.close(); @@ -739,9 +711,9 @@ conn.close(); > `注意务必要将 connection 进行关闭`,否则会出现连接泄露。 -## 与连接池使用 +### 与连接池使用 -### HikariCP +#### HikariCP 使用示例如下: @@ -775,7 +747,7 @@ conn.close(); > 通过 HikariDataSource.getConnection() 获取连接后,使用完成后需要调用 close() 方法,实际上它并不会关闭连接,只是放回连接池中。 > 更多 HikariCP 使用问题请查看[官方说明](https://github.com/brettwooldridge/HikariCP)。 -### Druid +#### Druid 使用示例如下: @@ -820,33 +792,48 @@ server_status()| Query OK, 1 row(s) in set (0.000141s) ``` -## 在框架中使用 +### 更多示例程序 -- Spring JdbcTemplate 中使用 taos-jdbcdriver,可参考 [SpringJdbcTemplate](https://github.com/taosdata/TDengine/tree/develop/examples/JDBC/SpringJdbcTemplate) -- Springboot + Mybatis 中使用,可参考 [springbootdemo](https://github.com/taosdata/TDengine/tree/develop/examples/JDBC/springbootdemo) +示例程序源码位于 `TDengine/examples/JDBC` 下: -## 示例程序 +- JDBCDemo:JDBC 示例源程序。 +- JDBCConnectorChecker:JDBC 安装校验源程序及 jar 包。 +- connectionPools:HikariCP, Druid, dbcp, c3p0 等连接池中使用 taos-jdbcdriver。 +- SpringJdbcTemplate:Spring JdbcTemplate 中使用 taos-jdbcdriver。 +- mybatisplus-demo:Springboot + Mybatis 中使用 taos-jdbcdriver。 -示例程序源码位于 TDengine/test/examples/JDBC 下: +请参考:[JDBC example](https://github.com/taosdata/TDengine/tree/develop/examples/JDBC) -- JDBCDemo:JDBC 示例源程序 -- JDBCConnectorChecker:JDBC 安装校验源程序及 jar 包 -- Springbootdemo:springboot 示例源程序 -- SpringJdbcTemplate:SpringJDBC 模板 +## 重要更新记录 -请参考:[JDBC example](https://github.com/taosdata/TDengine/tree/develop/examples/JDBC) +| taos-jdbcdriver 版本 | 主要变化 | +| :------------------: | :----------------------------: | +| 2.0.38 | JDBC REST 连接增加批量拉取功能 | +| 2.0.37 | 增加对 json tag 支持 | +| 2.0.36 | 增加对 schemaless 写入支持 | ## 常见问题 -- 使用 Statement 的 addBatch 和 executeBatch 来执行“批量写入/更行”,为什么没有带来性能上的提升? - **原因**:TDengine 的 JDBC 实现中,通过 addBatch 方法提交的 sql 语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。 +1. 使用 Statement 的 `addBatch` 和 `executeBatch` 来执行“批量写入/更行”,为什么没有带来性能上的提升? + + **原因**:TDengine 的 JDBC 实现中,通过 `addBatch` 方法提交的 SQL 语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。 + **解决方法**:1. 在一条 insert 语句中拼接多个 values 值;2. 使用多线程的方式并发插入;3. 使用参数绑定的写入方式 -- java.lang.UnsatisfiedLinkError: no taos in java.library.path + +2. java.lang.UnsatisfiedLinkError: no taos in java.library.path + **原因**:程序没有找到依赖的本地函数库 taos。 + **解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可。 -- java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform +3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform + **原因**:目前 TDengine 只支持 64 位 JDK。 + **解决方法**:重新安装 64 位 JDK。 -- 其它问题请参考 [Issues](https://github.com/taosdata/TDengine/issues) +4. 其它问题请参考 [FAQ](/train-faq/faq) + +## API 参考 + +[taos-jdbcdriver doc](https://docs.taosdata.com/api/taos-jdbcdriver) diff --git a/docs-cn/14-reference/03-connector/node.mdx b/docs-cn/14-reference/03-connector/node.mdx index 0a34aacbcff9c499ee28665ef12337e42408a87b..c95e0dfaed8ec9ca0e10b6393bce42f1cadc08b7 100644 --- a/docs-cn/14-reference/03-connector/node.mdx +++ b/docs-cn/14-reference/03-connector/node.mdx @@ -1,50 +1,76 @@ --- -sidebar_position: 5 +toc_max_heading_level: 4 +sidebar_position: 6 +sidebar_label: Node.js +title: TDengine Node.js Connector --- -# Node.js Connector +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; -Node.js 连接器支持的系统有: +import Preparition from "./_preparition.mdx"; +import NodeInsert from "../../04-develop/03-insert-data/_js_sql.mdx"; +import NodeInfluxLine from "../../04-develop/03-insert-data/_js_line.mdx"; +import NodeOpenTSDBTelnet from "../../04-develop/03-insert-data/_js_opts_telnet.mdx"; +import NodeOpenTSDBJson from "../../04-develop/03-insert-data/_js_opts_json.mdx"; +import NodeQuery from "../../04-develop/04-query-data/_js.mdx"; +import NodeAsyncQuery from "../../04-develop/04-query-data/_js_async.mdx"; -| **CPU 类型** | x64(64bit) | | | aarch64 | aarch32 | -| ------------ | ------------ | -------- | -------- | -------- | -------- | -| **OS 类型** | Linux | Win64 | Win32 | Linux | Linux | -| **支持与否** | **支持** | **支持** | **支持** | **支持** | **支持** | +`td2.0-connector` 是 TDengine 的官方 Node.js 语言连接器。Node.js 开发人员可以通过它开发可以存取 TDengine 集群数据的应用软件。 -Node.js 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1957.html)。 +`td2.0-connector` 支持两种形式的连接器。一种是**原生连接器**,它通过 TDengine 客户端驱动程序(taosc)连接 TDengine 运行实例,支持数据写入、查询、订阅、schemaless 接口和参数绑定接口等功能。另外一种是 **REST 连接器**,它通过 taosAdapter 提供的 REST 接口连接 TDengine 的运行实例。REST 连接器可以在任何平台运行,但性能略为下降,接口实现的功能特性集合和原生接口有少量不同。 -### 安装准备 +`td2.0-connector` 的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-node)。 -- 应用驱动安装请参考[安装连接器驱动步骤](https://www.taosdata.com/cn/documentation/connector#driver)。 +## 支持的平台 -### 安装 Node.js 连接器 +原生连接器支持的平台和 TDengine 客户端驱动支持的平台一致。 +REST 连接器支持所有能运行 Node.js 的平台。 -用户可以通过[npm](https://www.npmjs.com/)来进行安装,也可以通过源代码*src/connector/nodejs/* 来进行安装。具体安装步骤如下: +## 版本支持 -首先,通过[npm](https://www.npmjs.com/)安装 node.js 连接器。 +请参考[版本支持列表](/reference/connector#版本支持) -```bash -npm install td2.0-connector -``` +## 支持的功能特性 + +### 原生连接器 + +1. 连接管理 +2. 普通查询 +3. 连续查询 +4. 参数绑定 +5. 订阅功能 +6. Schemaless + +### REST 连接器 -我们建议用户使用 npm 安装 node.js 连接器。如果您没有安装 npm,可以将*src/connector/nodejs/*拷贝到您的 nodejs 项目目录下。 +1. 连接管理 +2. 普通查询 +3. 连续查询 -我们使用[node-gyp](https://github.com/nodejs/node-gyp)和 TDengine 服务端进行交互。安装 node.js 连接器之前,还需要根据具体操作系统来安装下文提到的一些依赖工具。 +## 安装步骤 -### Linux +### 安装前准备 + +- 安装 Node.js 开发环境 +- 如果使用 REST 连接器,跳过此步。但如果使用原生连接器,请安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动)。我们使用 [node-gyp](https://github.com/nodejs/node-gyp) 和 TDengine 实例进行交互,还需要根据具体操作系统来安装下文提到的一些依赖工具。 + + + - `python` (建议`v2.7` , `v3.x.x` 目前还不支持) -- `node` 2.0.6 支持 v12.x 和 v10.x,2.0.5 及更早版本支持 v10.x 版本,其他版本可能存在包兼容性的问题。 +- `td2.0-connector` 2.0.6 支持 Node.js LTS v10.9.0 或更高版本, Node.js LTS v12.8.0 或更高版本;2.0.5 及更早版本支持 Node.js LTS v10.x 版本。其他版本可能存在包兼容性的问题 - `make` -- c 语言编译器比如[GCC](https://gcc.gnu.org) +- C 语言编译器,[GCC](https://gcc.gnu.org) v4.8.5 或更高版本 -### Windows + + -#### 安装方法 1 +- 安装方法 1 -使用微软的[windows-build-tools](https://github.com/felixrieseberg/windows-build-tools)在`cmd` 命令行界面执行`npm install --global --production windows-build-tools` 即可安装所有的必备工具。 +使用微软的[ windows-build-tools ](https://github.com/felixrieseberg/windows-build-tools)在`cmd` 命令行界面执行`npm install --global --production windows-build-tools` 即可安装所有的必备工具。 -#### 安装方法 2 +- 安装方法 2 手动安装以下工具: @@ -52,26 +78,41 @@ npm install td2.0-connector - 安装 [Python](https://www.python.org/downloads/) 2.7(`v3.x.x` 暂不支持) 并执行 `npm config set python python2.7` - 进入`cmd`命令行界面,`npm config set msvs_version 2017` -如果以上步骤不能成功执行,可以参考微软的 node.js 用户手册[Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules)。 +参考微软的 Node.js 用户手册[ Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules)。 如果在 Windows 10 ARM 上使用 ARM64 Node.js,还需添加 "Visual C++ compilers and libraries for ARM64" 和 "Visual C++ ATL for ARM64"。 -### 示例程序 + + + +### 使用 npm 安装 + + + -示例程序源码位于 install_directory/examples/nodejs,有: +```bash +npm install td2.0-connector +``` -Node-example.js node.js 示例源程序 -Node-example-raw.js + + + +```bash +npm i td2.0-rest-connector +``` + + + ### 安装验证 -在安装好 TDengine 客户端后,使用 nodejsChecker.js 程序能够验证当前环境是否支持 nodejs 方式访问 Tdengine。 +在安装好 TDengine 客户端后,使用 nodejsChecker.js 程序能够验证当前环境是否支持 Node.js 方式访问 TDengine。 验证方法: -1. 新建安装验证目录,例如:`~/tdengine-test`,拷贝 github 上 nodejsChecker.js 源程序。下载地址:(https://github.com/taosdata/TDengine/tree/develop/examples/nodejs/nodejsChecker.js)。 +- 新建安装验证目录,例如:`~/tdengine-test`,下载 GitHub 上 [nodejsChecker.js 源代码](https://github.com/taosdata/TDengine/tree/develop/examples/nodejs/nodejsChecker.js)到本地。 -2. 在命令行中执行以下命令: +- 在命令行中执行以下命令。 ```bash npm init -y @@ -79,121 +120,140 @@ npm install td2.0-connector node nodejsChecker.js host=localhost ``` -3. 执行以上步骤后,在命令行会输出 nodejs 连接 Tdengine 实例,并执行简答插入和查询的结果。 +- 执行以上步骤后,在命令行会输出 nodejsChecker.js 连接 TDengine 实例,并执行简单插入和查询的结果。 -### Node.js 连接器的使用 +## 建立连接 -以下是 Node.js 连接器的一些基本使用方法,详细的使用方法可参考[TDengine Node.js connector](https://github.com/taosdata/TDengine/tree/develop/src/connector/nodejs)。 +请选择使用一种连接器。 -#### 建立连接 + + -使用 node.js 连接器时,必须先`require td2.0-connector`,然后使用 `taos.connect` 函数建立到服务端的连接。例如如下代码: +安装并引用 `td2.0-connector` 包。 ```javascript +//A cursor also needs to be initialized in order to interact with TDengine from Node.js. const taos = require("td2.0-connector"); var conn = taos.connect({ - host: "taosdemo.com", + host: "127.0.0.1", user: "root", password: "taosdata", config: "/etc/taos", - port: 6030, + port: 0, }); var cursor = conn.cursor(); // Initializing a new cursor -``` -建立了一个到 hostname 为 taosdemo.com,端口为 6030(Tdengine 的默认端口号)的连接。连接指定了用户名(root)和密码(taosdata)。taos.connect 函数必须提供的参数是`host`,其它参数在没有提供的情况下会使用如下的默认值。taos.connect 返回了`cursor` 对象,使用 cursor 来执行 sql 语句。 +//Close a connection +conn.close(); +``` -#### 执行 SQL 和插入数据 + + -对于 DDL 语句(例如 create database、create table、use 等),可以使用 cursor 的 execute 方法。代码如下: +安装并引用 `td2.0-rest-connector` 包。 -```js -cursor.execute("create database if not exists test;"); +```javascript +//A cursor also needs to be initialized in order to interact with TDengine from Node.js. +import { options, connect } from "td2.0-rest-connector"; +options.path = "/rest/sqlt"; +// set host +options.host = "localhost"; +// set other options like user/passwd + +let conn = connect(options); +let cursor = conn.cursor(); ``` -以上代码创建了一个名称为 test 的数据库。对于 DDL 语句,一般没有返回值,cursor 的 execute 返回值为 0。 + + -对于 Insert 语句,代码如下: +## 使用示例 -```js -var affectRows = cursor.execute( - "insert into test.weather values(now, 22.3, 34);" -); -``` +### 写入数据 -execute 方法的返回值为该语句影响的行数,上面的 sql 向 test 库的 weather 表中,插入了一条数据,则返回值 affectRows 为 1。 +#### SQL 写入 -TDengine 目前还不支持 delete 语句。但从 2.0.8.0 版本开始,可以通过 `CREATE DATABASE` 时指定的 UPDATE 参数来启用对数据行的 update。 + -#### 查询 +#### InfluxDB 行协议写入 -可通过 `cursor.query` 函数来查询数据库。 + -```javascript -var query = cursor.query("show databases;"); -``` +#### OpenTSDB Telnet 行协议写入 -查询的结果可以通过 `query.execute()` 函数获取并打印出来。 + -```javascript -var promise = query.execute(); -promise.then(function (result) { - result.pretty(); -}); -``` +#### OpenTSDB JSON 行协议写入 -格式化查询语句还可以使用`query`的`bind`方法。如下面的示例:`query`会自动将提供的数值填入查询语句的`?`里。 + -```javascript -var query = cursor - .query("select * from meterinfo.meters where ts <= ? and areaid = ?;") - .bind(new Date(), 5); -query.execute().then(function (result) { - result.pretty(); -}); -``` +### 查询数据 -如果在`query`语句里提供第二个参数并设为`true`也可以立即获取查询结果。如下: +#### 同步查询 -```javascript -var promise = cursor.query( - "select * from meterinfo.meters where v1 = 30;", - true -); -promise.then(function (result) { - result.pretty(); -}); -``` + -#### 关闭连接 +#### 异步查询 -在完成插入、查询等操作后,要关闭连接。代码如下: + -```js -conn.close(); -``` +## 更多示例程序 -#### 异步函数 +| 示例程序 | 示例程序描述 | +| ------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------- | +| [connection](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/cursorClose.js) | 建立连接的示例。 | +| [stmtBindBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamBatchSample.js) | 绑定多行参数插入的示例。 | +| [stmtBind](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindParamSample.js) | 一行一行绑定参数插入的示例。 | +| [stmtBindSingleParamBatch](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtBindSingleParamBatchSample.js) | 按列绑定参数插入的示例。 | +| [stmtUseResult](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/stmtUseResultSample.js) | 绑定参数查询的示例。 | +| [json tag](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testJsonTag.js) | Json tag 的使用示例。 | +| [Nanosecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testNanoseconds.js) | 时间戳为纳秒精度的使用的示例。 | +| [Microsecond](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testMicroseconds.js) | 时间戳为微秒精度的使用的示例。 | +| [schemless insert](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSchemalessInsert.js) | schemless 插入的示例。 | +| [subscribe](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/testSubscribe.js) | 订阅的使用示例。 | +| [asyncQuery](https://github.com/taosdata/taos-connector-node/tree/develop/nodejs/examples/tset.js) | 异步查询的使用示例。 | +| [REST](https://github.com/taosdata/taos-connector-node/blob/develop/typescript-rest/example/example.ts) | 使用 REST 连接的 TypeScript 使用示例。 | -异步查询数据库的操作和上面类似,只需要在`cursor.execute`, `TaosQuery.execute`等函数后面加上`_a`。 +## 使用限制 -```javascript -var promise1 = cursor - .query("select count(*), avg(v1), avg(v2) from meter1;") - .execute_a(); -var promise2 = cursor - .query("select count(*), avg(v1), avg(v2) from meter2;") - .execute_a(); -promise1.then(function (result) { - result.pretty(); -}); -promise2.then(function (result) { - result.pretty(); -}); -``` +Node.js 连接器 >= v2.0.6 目前支持 node 的版本为:支持 >=v12.8.0 <= v12.9.1 || >=v10.20.0 <= v10.9.0 ;2.0.5 及更早版本支持 v10.x 版本,其他版本可能存在包兼容性的问题。 + +## 其他说明 + +Node.js 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1957.html)。 + +## 常见问题 + +1. 使用 REST 连接需要启动 taosadapter。 + + ```bash + sudo systemctl start taosadapter + ``` + +2. Node.js 版本 + + 连接器 >v2.0.6 目前兼容的 Node.js 版本为:>=v10.20.0 <= v10.9.0 || >=v12.8.0 <= v12.9.1 + +3. "Unable to establish connection","Unable to resolve FQDN" + + 一般都是因为配置 FQDN 不正确。 可以参考[如何彻底搞懂 TDengine 的 FQDN](https://www.taosdata.com/blog/2021/07/29/2741.html) 。 + +## 重要更新记录 + +### 原生接口连接器 + +| td2.0-connector 版本 | 说明 | +| -------------------- | ---------------------------------------------------------------- | +| 2.0.12 | 修复 cursor.close() 报错的 bug。 | +| 2.0.11 | 支持绑定参数、json tag、schemaless 接口等功能。 | +| 2.0.10 | 支持连接管理,普通查询、连续查询、获取系统信息、订阅功能等功能。 | + +### REST 接口连接器 -### 示例 +| td2.0-rest-connector 版本 | 说明 | +| ------------------------- | ---------------------------------------------------------------- | +| 1.0.3 | 支持连接管理、普通查询、获取系统信息、错误信息、连续查询等功能。 | -[node-example.js](https://github.com/taosdata/tests/tree/master/examples/nodejs/node-example.js)提供了一个使用 NodeJS 连接器建表,插入天气数据并查询插入的数据的代码示例。 +## API 参考 -[node-example-raw.js](https://github.com/taosdata/tests/tree/master/examples/nodejs/node-example-raw.js)同样是一个使用 NodeJS 连接器建表,插入天气数据并查询插入的数据的代码示例,但和上面不同的是,该示例只使用`cursor`。 +[API 参考](https://docs.taosdata.com/api/td2.0-connector/) diff --git a/docs-cn/14-reference/03-connector/python.mdx b/docs-cn/14-reference/03-connector/python.mdx index dd260e499d466537d60dac7b09938443a66a33f7..abe569ed2683b84eb7cf586a15efec25237ddaf3 100644 --- a/docs-cn/14-reference/03-connector/python.mdx +++ b/docs-cn/14-reference/03-connector/python.mdx @@ -1,355 +1,353 @@ --- sidebar_position: 3 +sidebar_label: Python +title: Python Connector +description: "taospy 是 TDengine 的官方 Python 连接器。taospy 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。tasopy 对 TDengine 的原生接口和 REST 接口都进行了封装, 分别对应 tasopy 的两个子模块:tasos 和 taosrest。除了对原生接口和 REST 接口的封装,taospy 还提供了符合 Python 数据访问规范(PEP 249)的编程接口。这使得 taospy 和很多第三方工具集成变得简单,比如 SQLAlchemy 和 pandas" --- -# Python Connector +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; -Python 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1963.html) +`taospy` 是 TDengine 的官方 Python 连接器。`taospy` 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。`tasopy` 对 TDengine 的[原生接口](/reference/connector/cpp)和 [REST 接口](/reference/rest-api)都进行了封装, 分别对应 `tasopy` 包的 `taos` 模块 和 `taosrest` 模块。 +除了对原生接口和 REST 接口的封装,`taospy` 还提供了符合 [Python 数据访问规范(PEP 249)](https://peps.python.org/pep-0249/) 的编程接口。这使得 `taospy` 和很多第三方工具集成变得简单,比如 [SQLAlchemy](https://www.sqlalchemy.org/) 和 [pandas](https://pandas.pydata.org/)。 -- **安装**:参见下面具体步骤 -- **示例程序**:位于 install_directory/examples/python +使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口与服务端建立的连接的方式下文中称为“REST 连接”。 -### 安装 +Python 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-python)。 -Python 连接器支持的系统有:Linux 64/Windows x64 +## 支持的平台 -安装前准备: +- 原生连接[支持的平台](/reference/connector/#支持的平台)和 TDengine 客户端支持的平台一致。 +- REST 连接支持所有能运行 Python 的平台。 -- 已安装好 TDengine 应用驱动,请参考[安装连接器驱动步骤](https://www.taosdata.com/cn/documentation/connector#driver) -- 已安装 python 2.7 or >= 3.4 -- 已安装 pip +## 版本选择 -### Python 连接器安装 +无论使用什么版本的 TDengine 都建议使用最新版本的 `tasopy`。 -Python 连接器可以通过 `pip` 从 PyPI 下载安装。注意 TDengine Python 连接器的包名为 `taospy` 而不是 `taos`(这是一个与 TDengine 无关的另一个程序)。但为保持向后兼容性,仍然使用 `import taos` 导入。 +## 支持的功能 -```bash -pip install taospy -``` +- 原生连接支持 TDeingine 的所有核心功能, 包括: 连接管理、查询(包括写入)、参数绑定、订阅、无模式写入(Schemaless)。 +- REST 连接目前仅支持查询功能。 -如果不使用系统默认的 `python` 和 `pip`,则需要指定 `pip` 的版本或路径: +## 安装 -```bash -pip2 install taospy -pip3 install taospy -``` +### 准备 -Python 命令行依赖 taos 动态库 `libtaos.so` 或 `taos.dll`, 对于 Windows 客户端,安装 TDengine windows 客户端后,如果不能正常 `import taos`,可以将 `C:\TDengine\driver\taos.dll` 拷贝到 `C:\windows\system32` 目录后重新尝试。 +1. 安装 Python。建议使用 Python >= 3.6。如果系统上还没有 Python 可参考 [Python BeginnersGuide](https://wiki.python.org/moin/BeginnersGuide/Download) 安装。 +2. 安装 [pip](https://pypi.org/project/pip/)。大部分情况下 Python 的安装包都自带了 pip 工具, 如果没有请参考 [pip docuemntation](https://pip.pypa.io/en/stable/installation/) 安装。 +3. 如果使用原生连接,还需[安装客户端驱动](../#安装客户端驱动)。客户端软件包含了 TDengine 客户端动态链接库(libtaos.so 或 taos.dll) 和 TDengine CLI。 -对于无法联网用户,可以将 TDengine 客户端中的 `connector/python` 路径(Linux 下其安装路径为 `/usr/local/taos/connector/python/`,Windows 下默认安装路径为 `C:\TDengine\connector\python`)添加到 `PYTHONPATH` 环境变量中使用。 +### 使用 pip 安装 -### 示例程序 +#### 卸载旧版本 -示例程序源码位于 `/examples/python`,有: +如果以前安装过旧版本的 Python 连接器, 请提前卸载。 -- **read_example.py** Python 示例源程序 +``` +pip3 uninstall taos taospy +``` -用户可以参考`read_example.py`这个程序来设计用户自己的写入、查询程序。 +:::note +较早的 TDengine 客户端软件包含了 Python 连接器。如果从客户端软件的安装目录安装了 Python 连接器,那么对应的 Python 包名是 `taos`。 所以上述卸载命令包含了 `taos`, 不存在也没关系。 -在安装了对应的应用驱动后,通过`import taos`引入 taos 类。主要步骤如下: +::: -- 通过 taos.connect 获取 TaosConnection 对象,这个对象可以一个程序只申请一个,在多线程中共享。 +#### 安装 `tasopy` -- 通过 TaosConnection 对象的 `.cursor()` 方法获取一个新的游标对象,这个游标对象必须保证每个线程独享。 + + -- 通过游标对象的 execute()方法,执行写入或查询的 SQL 语句。 +安装最新版本 -- 如果执行的是写入语句,execute 返回的是成功写入的行数信息 affected rows。 +``` +pip3 install taospy +``` -- 如果执行的是查询语句,则 execute 执行成功后,需要通过 fetchall 方法去拉取结果集。 具体方法可以参考示例代码。 +也可以指定某个特定版本安装。 -### 安装验证 +``` +pip3 install taospy==2.3.0 +``` -运行如下指令: + + -```bash -cd {install_directory}/examples/python/PYTHONConnectorChecker/` -python3 PythonChecker.py -host +``` +pip3 install git+https://github.com/taosdata/taos-connector-python.git ``` -验证通过将打印出成功信息。 + + -### Python 连接器的使用 +### 安装验证 -#### PEP-249 兼容 API + + -您可以像其他数据库一样,使用类似 [PEP-249](https://www.python.org/dev/peps/pep-0249/) 数据库 API 规范风格的 API: +对于原生连接,需要验证客户端驱动和 Python 连接器本身是否都正确安装。如果能成功导入 `taos` 模块,则说明已经正确安装了客户端驱动和 Python 连接器。可在 Python 交互式 Shell 中输入: ```python import taos +``` + + + -conn = taos.connect() -cursor = conn.cursor() +对于 REST 连接,只需验证是否能成功导入 `taosrest` 模块。可在 Python 交互式 Shell 中输入: -cursor.execute("show databases") -results = cursor.fetchall() -for row in results: - print(row) +```python +import taosrest ``` -##### 代码示例 + + -1. 导入 TDengine 客户端模块 +:::tip +如果系统上有多个版本的 Python,则可能有多个 `pip` 命令。要确保使用的 `pip` 命令路径是正确的。上面我们用 `pip3` 命令安装,排除了使用 Python 2.x 版本对应的 `pip` 的可能性。但是如果系统上有多个 Python 3.x 版本,仍需检查安装路径是否正确。最简单的验证方式是,在命令再次输入 `pip3 install taospy`, 就会打印出 `taospy` 的具体安装位置,比如在 Windows 上: - ```python - import taos - ``` +``` +C:\> pip3 install taospy +Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple +Requirement already satisfied: taospy in c:\users\username\appdata\local\programs\python\python310\lib\site-packages (2.3.0) +``` -2. 获取连接并获取游标对象 +::: - ```python - conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos") - c1 = conn.cursor() - ``` +## 建立连接 - _host_ 是 TDengine 服务端所在 IP, _config_ 为客户端配置文件所在目录。 +### 连通性测试 -3. 写入数据 +在用连接器建立连接之前,建议先测试本地 TDengine CLI 到 TDengine 集群的连通性。 - ```python - import datetime + + - # 创建数据库 - c1.execute('create database db') - c1.execute('use db') - # 建表 - c1.execute('create table tb (ts timestamp, temperature int, humidity float)') - # 插入数据 - start_time = datetime.datetime(2019, 11, 1) - affected_rows = c1.execute('insert into tb values (\'%s\', 0, 0.0)' %start_time) - # 批量插入数据 - time_interval = datetime.timedelta(seconds=60) - sqlcmd = ['insert into tb values'] - for irow in range(1,11): - start_time += time_interval - sqlcmd.append('(\'%s\', %d, %f)' %(start_time, irow, irow*1.2)) - affected_rows = c1.execute(' '.join(sqlcmd)) - ``` +请确保 TDengine 集群已经启动, 且集群中机器的 FQDN (如果启动的是单机版,FQDN 默认为 hostname)在本机能够解析, 可用 ping 命令进行测试: -4. 查询数据 +``` +ping +``` - ```python - c1.execute('select * from tb') - # 拉取查询结果 - data = c1.fetchall() - # 返回的结果是一个列表,每一行构成列表的一个元素 - numOfRows = c1.rowcount - numOfCols = len(c1.description) - for irow in range(numOfRows): - print("Row%d: ts=%s, temperature=%d, humidity=%f" %(irow, data[irow][0], data[irow][1], data[irow][2])) +然后测试用 TDengine CLI 能否正常连接集群: - # 直接使用cursor 循环拉取查询结果 - c1.execute('select * from tb') - for data in c1: - print("ts=%s, temperature=%d, humidity=%f" %(data[0], data[1], data[2])) - ``` +``` +taos -h -p +``` -#### Query API +上面的 FQDN 可以为集群中任意一个 dnode 的 FQDN, PORT 为这个 dnode 对应的 serverPort。 -从 v2.1.0 版本开始, 我们提供另外一种方法:`connection.query` 来操作数据库。 + + -```python -import taos +对于 REST 连接, 除了确保集群已经启动,还要确保 taosAdapter 组件已经启动。可以使用如下 curl 命令测试: + +``` +curl -u root:taosdata http://:/rest/sql -d "select server_version()" +``` -conn = taos.connect() -conn.execute("create database if not exists pytest") +上面的 FQDN 为运行 taosAdapter 的机器的 FQDN, PORT 为 taosAdapter 配置的监听端口, 默认为 6041。 +如果测试成功,会输出服务器版本信息,比如: -result = conn.query("show databases") -num_of_fields = result.field_count -for field in result.fields: - print(field) -for row in result: - print(row) -conn.execute("drop database pytest") +```json +{ + "status": "succ", + "head": ["server_version()"], + "column_meta": [["server_version()", 8, 8]], + "data": [["2.4.0.16"]], + "rows": 1 +} ``` -`query` 方法会返回一个 `TaosResult` 对象,并提供了以下属性或方法: + + -属性: +### 使用连接器建立连接 -- `fields`: `TaosFields` 集合类,提供返回数据的列信息。 -- `field_count`: 返回数据的列数. -- `affected_rows`: 插入数据的行数. -- `row_count`: 查询数据结果数. -- `precision`: 当前数据库的时间精度. +以下示例代码假设 TDengine 安装在本机, 且 FQDN 和 serverPort 都使用了默认配置。 -方法: + + -- `fetch_all()`: 类似于 `cursor.fetchall()` 返回同样的集合数据 -- `fetch_all_into_dict()`: v2.1.1 新添加的 API,将上面的数据转换成字典类型返回 -- `blocks_iter()` `rows_iter()`: 根据底层 API 提供的两种不同迭代器。 -- `fetch_rows_a`: 异步 API -- `errno`: 错误码 -- `errstr`: 错误信息 -- `close`: 关闭结果对象,一般不需要直接调用 +```python +{{#include docs-examples/python/connect_native_reference.py}} +``` -#### 订阅 API +`connect` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明: -1. 创建一个同步订阅队列: +- `host` : 要连接的节点的 FQDN。 没有默认值。如果不同提供此参数,则会连接客户端配置文件中的 firstEP。 +- `user` :TDengine 用户名。 默认值是 root。 +- `password` : TDengine 用户密码。 默认值是 taosdata。 +- `port` : 要连接的数据节点的起始端口,即 serverPort 配置。默认值是 6030。只有在提供了 host 参数的时候,这个参数才生效。 +- `config` : 客户端配置文件路径。 在 Windows 系统上默认是 `C:\TDengine\cfg`。 在 Linux 系统上默认是 `/etc/taos/`。 +- `timezone` : 查询结果中 TIMESTAMP 类型的数据,转换为 python 的 datetime 对象时使用的时区。默认为本地时区。 - ```python - # 创建一个主题为 'test' 消费周期为1000毫秒的订阅 - # 第一个参数为 True 表示重新开始订阅,如为 False 且之前创建过主题为 'test' 的订阅, - # 则表示继续消费此订阅的数据,而不是重新开始消费所有数据 - sub = conn.subscribe(True, "test", "select * from tb;", 1000) - ``` +:::warning +`config` 和 `timezone` 都是进程级别的配置。建议一个进程建立的所有连接都使用相同的参数值。否则可能产生无法预知的错误。 +::: -2. 消费订阅的数据 +:::tip +`connect` 函数返回 `taos.TaosConnection` 实例。 在客户端多线程的场景下,推荐每个线程申请一个独立的连接实例,而不建议多线程共享一个连接。 - ```python - data = sub.consume() - for d in data: - print(d) - ``` +::: -3. 取消订阅 + + - ```python - sub.close() - ``` +```python +{{#include docs-examples/python/connect_rest_examples.py:connect}} +``` -4. 关闭连接 +`connect` 函数的所有参数都是可选的关键字参数。下面是连接参数的具体说明: - ```python - conn.close() - ``` +- `host`: 要连接的主机。默认是 localhost。 +- `user`: TDenigne 用户名。默认是 root。 +- `password`: TDeingine 用户密码。默认是 taosdata。 +- `port`: taosAdapter REST 服务监听端口。默认是 6041. +- `timeout`: HTTP 请求超时时间。单位为秒。默认为 `socket._GLOBAL_DEFAULT_TIMEOUT`。 一般无需配置。 -#### JSON 类型 +:::note -从 `taospy` `v2.2.0` 开始,Python 连接器开始支持 JSON 数据类型的标签(TDengine 版本要求 Beta 版 2.3.5+, 稳定版 2.4.0+)。 +::: -创建一个使用 JSON 类型标签的超级表及其子表: + + -```python -# encoding:UTF-8 -import taos +## 示例程序 -conn = taos.connect() -conn.execute("create database if not exists py_test_json_type") -conn.execute("use py_test_json_type") +### 基本使用 -conn.execute("create stable s1 (ts timestamp, v1 int) tags (info json)") -conn.execute("create table s1_1 using s1 tags ('{\"k1\": \"v1\"}')") -``` + + -查询子表标签及表名: +##### TaosConnection 类的使用 -```python -tags = conn.query("select info, tbname from s1").fetch_all_into_dict() -tags +`TaosConnection` 类既包含对 PEP249 Connection 接口的实现(如:`cursor`方法和 `close` 方法),也包含很多扩展功能(如: `execute`、 `query`、`schemaless_insert` 和 `subscribe` 方法。 + +```python title="execute 方法" +{{#include docs-examples/python/connection_usage_native_reference.py:insert}} ``` -`tags` 内容为: +```python title="query 方法" +{{#include docs-examples/python/connection_usage_native_reference.py:query}} +``` -```python -[{'info': '{"k1":"v1"}', 'tbname': 's1_1'}] +:::tip +查询结果只能获取一次。比如上面的示例中 `featch_all` 和 `fetch_all_into_dict` 只能用一个。重复获取得到的结果为空列表。 +::: + +##### TaosResult 类的使用 + +上面 `TaosConnection` 类的使用示例中,我们已经展示了两种获取查询结果的方法: `featch_all` 和 `fetch_all_into_dict`。除此之外 `TaosResult` 还提供了按行迭代(`rows_iter`)或按数据块迭代(`blocks_iter`)结果集的方法。在查询数据量较大的场景,使用这两个方法会更高效。 + +```python title="blocks_iter 方法" +{{#include docs-examples/python/result_set_examples.py}} ``` +##### TaosCursor 类的使用 -获取 JSON 中某值: +`TaosConnection` 类和 `TaosResult` 类已经实现了原生接口的所有功能。如果你对 PEP249 规范中的接口比较熟悉也可以使用 `TaosCursor` 类提供的方法。 -```python -k1 = conn.query("select info->'k1' as k1 from s1").fetch_all_into_dict() -""" ->>> k1 -[{'k1': '"v1"'}] -""" +```python title="TaosCursor 的使用" +{{#include docs-examples/python/cursor_usage_native_reference.py}} ``` -更多 JSON 类型的操作方式请参考 [JSON 类型使用说明](https://www.taosdata.com/cn/documentation/taos-sql)。 +:::note +TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能跨线程共享使用,否则会导致返回结果出现错误。 -#### 关于纳秒 (nanosecond) 在 Python 连接器中的说明 +::: -由于目前 Python 对 nanosecond 支持的不完善(参见链接 1. 2. ),目前的实现方式是在 nanosecond 精度时返回整数,而不是 ms 和 us 返回的 datetime 类型,应用开发者需要自行处理,建议使用 pandas 的 to_datetime()。未来如果 Python 正式完整支持了纳秒,涛思数据可能会修改相关接口。 + + -1. https://stackoverflow.com/questions/10611328/parsing-datetime-strings-containing-nanoseconds -2. https://www.python.org/dev/peps/pep-0564/ +##### TaosRestCursor 类的使用 -#### 帮助信息 +`TaosRestCursor` 类是对 PEP249 Cursor 接口的实现。 -用户可通过 python 的帮助信息直接查看模块的使用信息,或者参考 tests/examples/python 中的示例程序。以下为部分常用类和方法: +```python title="TaosRestCursor 的使用" +{{#include docs-examples/python/connect_rest_examples.py:basic}} +``` +- `cursor.execute` : 用来执行任意 SQL 语句。 +- `cursor.rowcount`: 对于写入操作返回写入成功记录数。对于查询操作,返回结果集行数。 +- `cursor.description` : 返回字段的描述信息。关于描述信息的具体格式请参考[TaosRestCursor](https://docs.taosdata.com/api/taospy/taosrest/cursor.html)。 -- _TaosConnection_ 类 +##### RestClient 类的使用 - 参考 python 中 help(taos.TaosConnection)。 - 这个类对应客户端和 TDengine 建立的一个连接。在客户端多线程的场景下,推荐每个线程申请一个独立的连接实例,而不建议多线程共享一个连接。 +`RestClient` 类是对于 [REST API](/reference/rest-api) 的直接封装。它只包含一个 `sql()` 方法用于执行任意 SQL 语句, 并返回执行结果。 -- _TaosCursor_ 类 +```python title="RestClient 的使用" +{{#include docs-examples/python/rest_client_example.py}} +``` - 参考 python 中 help(taos.TaosCursor)。 - 这个类对应客户端进行的写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能跨线程共享使用,否则会导致返回结果出现错误。 +对于 `sql()` 方法更详细的介绍, 请参考 [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html)。 -- _connect_ 方法 - 用于生成 taos.TaosConnection 的实例。 -## RESTful Connector + + -为支持各种不同类型平台的开发,TDengine 提供符合 REST 设计标准的 API,即 RESTful API。为最大程度降低学习成本,不同于其他数据库 RESTful API 的设计方法,TDengine 直接通过 HTTP POST 请求 BODY 中包含的 SQL 语句来操作数据库,仅需要一个 URL。RESTful 连接器的使用参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1965.html)。 +### 与 pandas 一起使用 -注意:与原生连接器的一个区别是,RESTful 接口是无状态的,因此 `USE db_name` 指令没有效果,所有对表名、超级表名的引用都需要指定数据库名前缀。(从 2.2.0.0 版本开始,支持在 RESTful url 中指定 db_name,这时如果 SQL 语句中没有指定数据库名前缀的话,会使用 url 中指定的这个 db_name。从 2.4.0.0 版本开始,RESTful 默认有 taosAdapter 提供,要求必须在 url 中指定 db_name。) + + -### 安装 +```python +{{#include docs-examples/python/conn_native_pandas.py}} +``` -RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安装任何 TDengine 的库,只要客户端的开发语言支持 HTTP 协议即可。 + + -### 验证 +```python +{{#include docs-examples/python/conn_rest_pandas.py}} +``` -在已经安装 TDengine 服务器端的情况下,可以按照如下方式进行验证。 + + -下面以 Ubuntu 环境中使用 curl 工具(确认已经安装)来验证 RESTful 接口的正常。 +### 其它示例程序 -下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 fqdn 和端口号: +| 示例程序链接 | 示例程序内容 | +| ------------------------------------------------------------------------------------------------------------- | ----------------------- | +| [bind_multi.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-multi.py) | 参数绑定, 一次绑定多行 | +| [bind_row.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/bind-row.py) | 参数绑定,一次绑定一行 | +| [insert_lines.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/insert-lines.py) | InfluxDB 行协议写入 | +| [json_tag.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/json-tag.py) | 使用 JSON 类型的标签 | +| [subscribe-async.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-async.py) | 异步订阅 | +| [subscribe-sync.py](https://github.com/taosdata/taos-connector-python/blob/main/examples/subscribe-sync.py) | 同步订阅 | -```html -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' -h1.taosdata.com:6041/rest/sql -``` +## 其它说明 -返回值结果如下表示验证通过: +### 异常处理 -```json -{ - "status": "succ", - "head": [ - "name", - "created_time", - "ntables", - "vgroups", - "replica", - "quorum", - "days", - "keep1,keep2,keep(D)", - "cache(MB)", - "blocks", - "minrows", - "maxrows", - "wallevel", - "fsync", - "comp", - "precision", - "status" - ], - "data": [ - [ - "log", - "2020-09-02 17:23:00.039", - 4, - 1, - 1, - 1, - 10, - "30,30,30", - 1, - 3, - 100, - 4096, - 1, - 3000, - 2, - "us", - "ready" - ] - ], - "rows": 1 -} +所有数据库操作如果出现异常,都会直接抛出来。由应用程序负责异常处理。比如: + +```python +{{#include docs-examples/python/handle_exception.py}} ``` + +### 关于纳秒 (nanosecond) + +由于目前 Python 对 nanosecond 支持的不完善(见下面的链接),目前的实现方式是在 nanosecond 精度时返回整数,而不是 ms 和 us 返回的 datetime 类型,应用开发者需要自行处理,建议使用 pandas 的 to_datetime()。未来如果 Python 正式完整支持了纳秒,Python 连接器可能会修改相关接口。 + +1. https://stackoverflow.com/questions/10611328/parsing-datetime-strings-containing-nanoseconds +2. https://www.python.org/dev/peps/pep-0564/ + + +## 常见问题 + +欢迎[提问或报告问题](https://github.com/taosdata/taos-connector-python/issues)。 + +## 重要更新 + +| 连接器版本 | 重要更新 | 发布日期 | +| ---------- | --------------------------------------------------------------------------------- | ---------- | +| 2.3.1 | 1. support TDengine REST API
2. remove support for Python version below 3.6 | 2022-04-28 | +| 2.2.5 | support timezone option when connect | 2022-04-13 | +| 2.2.2 | support sqlalchemy dialect plugin | 2022-03-28 | + + +[**Release Notes**](https://github.com/taosdata/taos-connector-python/releases) + +## API 参考 + +- [taos](https://docs.taosdata.com/api/taospy/taos/) +- [taosrest](https://docs.taosdata.com/api/taospy/taosrest) diff --git a/docs-cn/14-reference/03-connector/rust.mdx b/docs-cn/14-reference/03-connector/rust.mdx index 4928e1f0795651bac4fdf96f5f692aa11c82e996..2f7f466ca2ea8e97bb2c8f6b622916c4cf59180a 100644 --- a/docs-cn/14-reference/03-connector/rust.mdx +++ b/docs-cn/14-reference/03-connector/rust.mdx @@ -1,110 +1,388 @@ -# Rust Connector +--- +toc_max_heading_level: 4 +sidebar_position: 5 +sidebar_label: Rust +title: TDengine Rust Connector +--- -![Crates.io](https://img.shields.io/crates/v/libtaos) ![Crates.io](https://img.shields.io/crates/d/libtaos) +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; -> Rust 连接器仍然在快速开发中,版本 API 变动在所难免,在 1.0 之前无法保证其向后兼容,请使用时注意版本及对应的文档。 +import Preparition from "./_preparition.mdx" +import RustInsert from "../../04-develop/03-insert-data/_rust_sql.mdx" +import RustInfluxLine from "../../04-develop/03-insert-data/_rust_line.mdx" +import RustOpenTSDBTelnet from "../../04-develop/03-insert-data/_rust_opts_telnet.mdx" +import RustOpenTSDBJson from "../../04-develop/03-insert-data/_rust_opts_json.mdx" +import RustQuery from "../../04-develop/04-query-data/_rust.mdx" -感谢 [@songtianyi](https://github.com/songtianyi) 对 [libtdengine](https://github.com/songtianyi/tdengine-rust-bindings) 的贡献,使 Rust 社区能够使用 Rust 连接[TDengine]. [libtaos-rs] 项目旨在为 Rust 开发者提供官方支持,使用 taosc 接口及 HTTP 接口构建兼容 API 以便于用户切换接口方式。 +[![Crates.io](https://img.shields.io/crates/v/libtaos)](https://crates.io/crates/libtaos) ![Crates.io](https://img.shields.io/crates/d/libtaos) [![docs.rs](https://img.shields.io/docsrs/libtaos)](https://docs.rs/libtaos) -## 依赖 +`libtaos` 是 TDengine 的官方 Rust 语言连接器。Rust 开发人员可以通过它开发存取 TDengine 数据库的应用软件。 -- [Rust](https://www.rust-lang.org/learn/get-started) +`libtaos` 提供两种形式的连接器。一种是**原生连接器**,它通过 TDengine 客户端驱动程序(taosc)连接 TDengine 运行实例。另外一种是 **REST 连接器**,它通过 taosAdapter 的 REST 接口连接 TDengine 运行实例。你可以通过不同的 “特性(即 Cargo 关键字 features)” 来指定使用哪种连接器。REST 连接器可以在任何平台运行,但原生连接器依赖 TDengine 客户端能运行的平台。 -默认情况下,[libtaos-rs] 使用 C 接口连接数据库,所以您需要: +`libtaos` 的源码托管在 [GitHub](https://github.com/taosdata/libtaos-rs)。 -- [TDengine 客户端](https://www.taosdata.com/cn/getting-started/#%E9%80%9A%E8%BF%87%E5%AE%89%E8%A3%85%E5%8C%85%E5%AE%89%E8%A3%85) -- `clang`: `bindgen` 使用 `libclangAST` 来生成对应的 Rust 绑定。 +## 支持的平台 -## 特性列表 +原生连接器支持的平台和 TDengine 客户端驱动支持的平台一致。 +REST 连接器支持所有能运行 Rust 的平台。 -- [x] C 接口的 Rust 绑定 -- [x] 使用 `rest` feature 来启用 RESTful API. -- [x] [r2d2] 连接池支持(feature `r2d2`) -- [ ] 迭代器接口 -- [ ] 流式计算接口 -- [ ] 订阅支持 +## 版本支持 -## 构建和测试 +请参考[版本支持列表](/reference/connector#版本支持) -```sh -cargo build -cargo test -``` +Rust 连接器仍然在快速开发中,1.0 之前无法保证其向后兼容。建议使用 2.4 版本以上的 TDengine,以避免已知问题。 + +## 安装 -测试使用默认用户名密码和本地连接。您可以根据具体情况设置环境变量: +### 安装前准备 +* 安装 Rust 开发工具链 +* 如果使用原生连接器,请安装 TDengine 客户端驱动,具体步骤请参考[安装客户端驱动](/reference/connector#安装客户端驱动) -- `TEST_TAOS_IP` -- `TEST_TAOS_PORT` -- `TEST_TAOS_USER` -- `TEST_TAOS_PASS` -- `TEST_TAOS_DB` +### 添加 libtaos 依赖 -## 使用 +根据选择的连接器,按照如下说明在 [Rust](https://rust-lang.org) 项目中添加 [libtaos][libtaos] 依赖: -使用默认的 taosc 连接方式,可以在 `Cargo.toml` 中直接添加 `libtaos` 依赖: + + + +在 `Cargo.toml` 文件中添加 [libtaos][libtaos]: ```toml [dependencies] -libtaos = "v0.3.8" +# use default feature +libtaos = "*" ``` -添加 feature `r2d2` 来启动连接池: + + + +在 `Cargo.toml` 文件中添加 [libtaos][libtaos],并启用 `rest` 特性。 ```toml [dependencies] -libtaos = { version = "*", features = ["r2d2"] } +# use rest feature +libtaos = { version = "*", features = ["rest"]} ``` -对于 RESTful 接口,可使用 `rest` 特性来替代 taosc,免去安装 TDengine 客户端。 + + + + +### 使用连接池 + +请在 `Cargo.toml` 中启用 `r2d2` 特性。 ```toml [dependencies] -libtaos = { version = "*", features = ["rest"] } +# with taosc +libtaos = { version = "*", features = ["r2d2"] } +# or rest +libtaos = { version = "*", features = ["rest", "r2d2"] } +``` + +## 建立连接 + +[TaosCfgBuilder] 为使用者提供构造器形式的 API,以便于后续创建连接或使用连接池。 + +```rust +let cfg: TaosCfg = TaosCfgBuilder::default() + .ip("127.0.0.1") + .user("root") + .pass("taosdata") + .db("log") // do not set if not require a default database. + .port(6030u16) + .build() + .expect("TaosCfg builder error"); +} ``` -本项目中提供一个 [示例程序](https://github.com/taosdata/libtaos-rs/blob/main/examples/demo.rs) 如下: +现在您可以使用该对象创建连接: ```rust +let conn = cfg.connect()?; +``` + +连接对象可以创建多个: + +```rust +let conn = cfg.connect()?; +let conn2 = cfg.connect()?; +``` + +可以在应用中使用连接池: + +```rust +let pool = r2d2::Pool::builder() + .max_size(10000) // max connections + .build(cfg)?; + // ... -#[tokio::main] -async fn main() -> Result<(), Error> { - init(); - let taos = taos_connect()?; - - assert_eq!( - taos.query("drop database if exists demo").await.is_ok(), - true - ); - assert_eq!(taos.query("create database demo").await.is_ok(), true); - assert_eq!(taos.query("use demo").await.is_ok(), true); - assert_eq!( - taos.query("create table m1 (ts timestamp, speed int)") - .await - .is_ok(), - true - ); - - for i in 0..10i32 { - assert_eq!( - taos.query(format!("insert into m1 values (now+{}s, {})", i, i).as_str()) - .await - .is_ok(), - true - ); - } - let rows = taos.query("select * from m1").await?; +// Use pool to get connection +let conn = pool.get()?; +``` - println!("{}", rows.column_meta.into_iter().map(|col| col.name).join(",")); +之后您可以对数据库进行相关操作: + +```rust +async fn demo() -> Result<(), Error> { + // get connection ... + + // create database + conn.exec("create database if not exists demo").await?; + // change database context + conn.exec("use demo").await?; + // create table + conn.exec("create table if not exists tb1 (ts timestamp, v int)").await?; + // insert + conn.exec("insert into tb1 values(now, 1)").await?; + // query + let rows = conn.query("select * from tb1").await?; for row in rows.rows { println!("{}", row.into_iter().join(",")); } - Ok(()) } ``` -您可以在 [bailongma-rs] - 一个 Rust 编写的 Prometheus 远程存储 API 适配器 - 看到如何在具体应用中使用 Rust 连接器。 +## 使用示例 + +### 写入数据 + +#### SQL 写入 + + + +#### InfluxDB 行协议写入 + + + +#### OpenTSDB Telnet 行协议写入 + + + +#### OpenTSDB JSON 行协议写入 + + + +### 查询数据 + + + +### 更多示例程序 + +| 程序路径 | 程序说明 | +| -------------- | ----------------------------------------------------------------------------- | +| [demo.rs] | 基本API 使用示例 | +| [bailongma-rs] | 使用 TDengine 作为存储后端的 Prometheus 远程存储 API 适配器,使用 r2d2 连接池 | + +## API 参考 + +### 连接构造器 API + +[Builder Pattern](https://doc.rust-lang.org/1.0.0/style/ownership/builders.html) 构造器模式是 Rust 处理复杂数据类型或可选配置类型的解决方案。[libtaos] 实现中,使用连接构造器 [TaosCfgBuilder] 作为 TDengine Rust 连接器的入口。[TaosCfgBuilder] 提供对服务器、端口、数据库、用户名和密码等的可选配置。 + +使用 `default()` 方法可以构建一个默认参数的 [TaosCfg],用于后续连接数据库或建立连接池。 + +```rust +let cfg = TaosCfgBuilder::default().build()?; +``` + +使用构造器模式,用户可按需设置: + +```rust +let cfg = TaosCfgBuilder::default() + .ip("127.0.0.1") + .user("root") + .pass("taosdata") + .db("log") + .port(6030u16) + .build()?; +``` + +使用 [TaosCfg] 对象创建 TDengine 连接: + +```rust +let conn: Taos = cfg.connect(); +``` + +### 连接池 + +在复杂应用中,建议启用连接池。[libtaos] 的连接池使用 [r2d2] 实现。 + +如下,可以生成一个默认参数的连接池。 + +```rust +let pool = r2d2::Pool::new(cfg)?; +``` + +同样可以使用连接池的构造器,对连接池参数进行设置: + +```rust + use std::time::Duration; + let pool = r2d2::Pool::builder() + .max_size(5000) // max connections + .max_lifetime(Some(Duration::from_minutes(100))) // lifetime of each connection + .min_idle(Some(1000)) // minimal idle connections + .connection_timeout(Duration::from_minutes(2)) + .build(cfg); +``` + +在应用代码中,使用 `pool.get()?` 来获取一个连接对象 [Taos]。 + +```rust +let taos = pool.get()?; +``` + +### 连接 + +[Taos] 结构体是 [libtaos] 中的连接管理者,主要提供了两个 API: + +1. `exec`: 执行某个非查询类 SQL 语句,例如 `CREATE`,`ALTER`,`INSERT` 等。 + + ```rust + taos.exec().await?; + ``` + +2. `query`:执行查询语句,返回 [TaosQueryData] 对象。 + + ```rust + let q = taos.query("select * from log.logs").await?; + ``` + + [TaosQueryData] 对象存储了查询结果数据和返回的列的基本信息(列名,类型,长度): + + 列信息使用 [ColumnMeta] 存储: + + ```rust + let cols = &q.column_meta; + for col in cols { + println!("name: {}, type: {:?}, bytes: {}", col.name, col.type_, col.bytes); + } + ``` + + 逐行获取数据: + + ```rust + for (i, row) in q.rows.iter().enumerate() { + for (j, cell) in row.iter().enumerate() { + println!("cell({}, {}) data: {}", i, j, cell); + } + } + ``` + +需要注意的是,需要使用 Rust 异步函数和异步运行时。 + +[Taos] 提供部分 SQL 的 Rust 方法化以减少 `format!` 代码块的频率: + +- `.describe(table: &str)`: 执行 `DESCRIBE` 并返回一个 Rust 数据结构。 +- `.create_database(database: &str)`: 执行 `CREATE DATABASE` 语句。 +- `.use_database(database: &str)`: 执行 `USE` 语句。 + +除此之外,该结构也是 [参数绑定](#参数绑定接口) 和 [行协议接口](#行协议接口) 的入口,使用方法请参考具体的 API 说明。 + +### 参数绑定接口 + +与 C 接口类似,Rust 提供参数绑定接口。首先,通过 [Taos] 对象创建一个 SQL 语句的参数绑定对象 [Stmt]: + +```rust +let mut stmt: Stmt = taos.stmt("insert into ? values(?,?)")?; +``` + +参数绑定对象提供了一组接口用于实现参数绑定: + +##### `.set_tbname(tbname: impl ToCString)` + +用于绑定表名。 + +##### `.set_tbname_tags(tbname: impl ToCString, tags: impl IntoParams)` + +当 SQL 语句使用超级表时,用于绑定子表表名和标签值: + +```rust +let mut stmt = taos.stmt("insert into ? using stb0 tags(?) values(?,?)")?; +// tags can be created with any supported type, here is an example using JSON +let v = Field::Json(serde_json::from_str("{\"tag1\":\"一二三四五六七八九十\"}").unwrap()); +stmt.set_tbname_tags("tb0", [&tag])?; +``` + +##### `.bind(params: impl IntoParams)` + +用于绑定值类型。使用 [Field] 结构体构建需要的类型并绑定: + +```rust +let ts = Field::Timestamp(Timestamp::now()); +let value = Field::Float(0.0); +stmt.bind(vec![ts, value].iter())?; +``` + +##### `.execute()` + +执行 SQL。[Stmt] 对象可以复用,在执行后可以重新绑定并执行。 + +```rust +stmt.execute()?; + +// next bind cycle. +//stmt.set_tbname()?; +//stmt.bind()?; +//stmt.execute()?; +``` + +### 行协议接口 + +行协议接口支持多种模式和不同精度,需要引入 schemaless 模块中的常量以进行设置: + +```rust +use libtaos::*; +use libtaos::schemaless::*; +``` + +- InfluxDB 行协议 + + ```rust + let lines = [ + "st,t1=abc,t2=def,t3=anything c1=3i64,c3=L\"pass\",c2=false 1626006833639000000" + "st,t1=abc,t2=def,t3=anything c1=3i64,c3=L\"abc\",c4=4f64 1626006833639000000" + ]; + taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANOSECONDS)?; + ``` + +- OpenTSDB Telnet 协议 + + ```rust + let lines = ["sys.if.bytes.out 1479496100 1.3E3 host=web01 interface=eth0"]; + taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_SECONDS)?; + ``` + +- OpenTSDB JSON 协议 + + ```rust + let lines = [r#" + { + "metric": "st", + "timestamp": 1626006833, + "value": 10, + "tags": { + "t1": true, + "t2": false, + "t3": 10, + "t4": "123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>" + } + }"#]; + taos.schemaless_insert(&lines, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_SECONDS)?; + ``` + +其他相关结构体 API 使用说明请移步 Rust 文档托管网页:。 -[libtaos-rs]: https://github.com/taosdata/libtaos-rs +[libtaos]: https://github.com/taosdata/libtaos-rs [tdengine]: https://github.com/taosdata/TDengine [bailongma-rs]: https://github.com/taosdata/bailongma-rs [r2d2]: https://crates.io/crates/r2d2 +[demo.rs]: https://github.com/taosdata/libtaos-rs/blob/main/examples/demo.rs +[TaosCfgBuilder]: https://docs.rs/libtaos/latest/libtaos/struct.TaosCfgBuilder.html +[TaosCfg]: https://docs.rs/libtaos/latest/libtaos/struct.TaosCfg.html +[Taos]: https://docs.rs/libtaos/latest/libtaos/struct.Taos.html +[TaosQueryData]: https://docs.rs/libtaos/latest/libtaos/field/struct.TaosQueryData.html +[Field]: https://docs.rs/libtaos/latest/libtaos/field/enum.Field.html +[Stmt]: https://docs.rs/libtaos/latest/libtaos/stmt/struct.Stmt.html diff --git a/docs-cn/14-reference/03-connector/tdengine-jdbc-connector.png b/docs-cn/14-reference/03-connector/tdengine-jdbc-connector.png new file mode 100644 index 0000000000000000000000000000000000000000..1cb8401ea30b01d8db652ed4ea70ecc511de7461 Binary files /dev/null and b/docs-cn/14-reference/03-connector/tdengine-jdbc-connector.png differ diff --git a/docs-cn/14-reference/04-taosadapter.md b/docs-cn/14-reference/04-taosadapter.md new file mode 100644 index 0000000000000000000000000000000000000000..158d4ab008c3b3eca28cd469c38f451b22678518 --- /dev/null +++ b/docs-cn/14-reference/04-taosadapter.md @@ -0,0 +1,338 @@ +--- +title: "taosAdapter" +description: "taosAdapter 是一个 TDengine 的配套工具,是 TDengine 集群和应用程序之间的桥梁和适配器。它提供了一种易于使用和高效的方式来直接从数据收集代理软件(如 Telegraf、StatsD、collectd 等)摄取数据。它还提供了 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine" +sidebar_label: "taosAdapter" +--- + +import Prometheus from "./_prometheus.mdx" +import CollectD from "./_collectd.mdx" +import StatsD from "./_statsd.mdx" +import Icinga2 from "./_icinga2.mdx" +import Tcollector from "./_tcollector.mdx" + +taosAdapter 是一个 TDengine 的配套工具,是 TDengine 集群和应用程序之间的桥梁和适配器。它提供了一种易于使用和高效的方式来直接从数据收集代理软件(如 Telegraf、StatsD、collectd 等)摄取数据。它还提供了 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。 + +taosAdapter 提供以下功能: + +- RESTful 接口 +- 兼容 InfluxDB v1 写接口 +- 兼容 OpenTSDB JSON 和 telnet 格式写入 +- 无缝连接到 Telegraf +- 无缝连接到 collectd +- 无缝连接到 StatsD +- 支持 Prometheus remote_read 和 remote_write + +## taosAdapter 架构图 + +![taosAdapter Architecture](taosAdapter-architecture.png) + +## taosAdapter 部署方法 + +### 安装 taosAdapter + +taosAdapter 从 TDengine v2.4.0.0 版本开始成为 TDengine 服务端软件 的一部分,如果您使用 TDengine server 您不需要任何额外的步骤来安装 taosAdapter。您可以从[涛思数据官方网站](https://taosdata.com/cn/all-downloads/)下载 TDengine server(taosAdapter 包含在 v2.4.0.0 及以上版本)安装包。如果需要将 taosAdapter 分离部署在 TDengine server 之外的服务器上,则应该在该服务器上安装完整的 TDengine 来安装 taosAdapter。如果您需要使用源代码编译生成 taosAdapter,您可以参考[构建 taosAdapter](https://github.com/taosdata/taosadapter/blob/develop/BUILD-CN.md)文档。 + +### start/stop taosAdapter + +在 Linux 系统上 taosAdapter 服务默认由 systemd 管理。使用命令 `systemctl start taosadapter` 可以启动 taosAdapter 服务。使用命令 `systemctl stop taosadapter` 可以停止 taosAdapter 服务。 + +### 移除 taosAdapter + +使用命令 rmtaos 可以移除包括 taosAdapter 在内的 TDengine server 软件。 + +### 升级 taosAdapter + +taosAdapter 和 TDengine server 需要使用相同版本。请通过升级 TDengine server 来升级 taosAdapter。 +与 taosd 分离部署的 taosAdapter 必须通过升级其所在服务器的 TDengine server 才能得到升级。 + +## taosAdapter 参数列表 + +taosAdapter 支持通过命令行参数、环境变量和配置文件来进行配置。默认配置文件是 /etc/taos/taosadapter.toml。 + +命令行参数优先于环境变量优先于配置文件,命令行用法是 arg=val,如 taosadapter -p=30000 --debug=true,详细列表如下: + +```shell +Usage of taosAdapter: + --collectd.db string collectd db name. Env "TAOS_ADAPTER_COLLECTD_DB" (default "collectd") + --collectd.enable enable collectd. Env "TAOS_ADAPTER_COLLECTD_ENABLE" (default true) + --collectd.password string collectd password. Env "TAOS_ADAPTER_COLLECTD_PASSWORD" (default "taosdata") + --collectd.port int collectd server port. Env "TAOS_ADAPTER_COLLECTD_PORT" (default 6045) + --collectd.user string collectd user. Env "TAOS_ADAPTER_COLLECTD_USER" (default "root") + --collectd.worker int collectd write worker. Env "TAOS_ADAPTER_COLLECTD_WORKER" (default 10) + -c, --config string config path default /etc/taos/taosadapter.toml + --cors.allowAllOrigins cors allow all origins. Env "TAOS_ADAPTER_CORS_ALLOW_ALL_ORIGINS" (default true) + --cors.allowCredentials cors allow credentials. Env "TAOS_ADAPTER_CORS_ALLOW_Credentials" + --cors.allowHeaders stringArray cors allow HEADERS. Env "TAOS_ADAPTER_ALLOW_HEADERS" + --cors.allowOrigins stringArray cors allow origins. Env "TAOS_ADAPTER_ALLOW_ORIGINS" + --cors.allowWebSockets cors allow WebSockets. Env "TAOS_ADAPTER_CORS_ALLOW_WebSockets" + --cors.exposeHeaders stringArray cors expose headers. Env "TAOS_ADAPTER_Expose_Headers" + --debug enable debug mode. Env "TAOS_ADAPTER_DEBUG" + --help Print this help message and exit + --influxdb.enable enable influxdb. Env "TAOS_ADAPTER_INFLUXDB_ENABLE" (default true) + --log.path string log path. Env "TAOS_ADAPTER_LOG_PATH" (default "/var/log/taos") + --log.rotationCount uint log rotation count. Env "TAOS_ADAPTER_LOG_ROTATION_COUNT" (default 30) + --log.rotationSize string log rotation size(KB MB GB), must be a positive integer. Env "TAOS_ADAPTER_LOG_ROTATION_SIZE" (default "1GB") + --log.rotationTime duration log rotation time. Env "TAOS_ADAPTER_LOG_ROTATION_TIME" (default 24h0m0s) + --logLevel string log level (panic fatal error warn warning info debug trace). Env "TAOS_ADAPTER_LOG_LEVEL" (default "info") + --monitor.collectDuration duration Set monitor duration. Env "TAOS_MONITOR_COLLECT_DURATION" (default 3s) + --monitor.identity string The identity of the current instance, or 'hostname:port' if it is empty. Env "TAOS_MONITOR_IDENTITY" + --monitor.incgroup Whether running in cgroup. Env "TAOS_MONITOR_INCGROUP" + --monitor.password string TDengine password. Env "TAOS_MONITOR_PASSWORD" (default "taosdata") + --monitor.pauseAllMemoryThreshold float Memory percentage threshold for pause all. Env "TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD" (default 80) + --monitor.pauseQueryMemoryThreshold float Memory percentage threshold for pause query. Env "TAOS_MONITOR_PAUSE_QUERY_MEMORY_THRESHOLD" (default 70) + --monitor.user string TDengine user. Env "TAOS_MONITOR_USER" (default "root") + --monitor.writeInterval duration Set write to TDengine interval. Env "TAOS_MONITOR_WRITE_INTERVAL" (default 30s) + --monitor.writeToTD Whether write metrics to TDengine. Env "TAOS_MONITOR_WRITE_TO_TD" (default true) + --node_exporter.caCertFile string node_exporter ca cert file path. Env "TAOS_ADAPTER_NODE_EXPORTER_CA_CERT_FILE" + --node_exporter.certFile string node_exporter cert file path. Env "TAOS_ADAPTER_NODE_EXPORTER_CERT_FILE" + --node_exporter.db string node_exporter db name. Env "TAOS_ADAPTER_NODE_EXPORTER_DB" (default "node_exporter") + --node_exporter.enable enable node_exporter. Env "TAOS_ADAPTER_NODE_EXPORTER_ENABLE" + --node_exporter.gatherDuration duration node_exporter gather duration. Env "TAOS_ADAPTER_NODE_EXPORTER_GATHER_DURATION" (default 5s) + --node_exporter.httpBearerTokenString string node_exporter http bearer token. Env "TAOS_ADAPTER_NODE_EXPORTER_HTTP_BEARER_TOKEN_STRING" + --node_exporter.httpPassword string node_exporter http password. Env "TAOS_ADAPTER_NODE_EXPORTER_HTTP_PASSWORD" + --node_exporter.httpUsername string node_exporter http username. Env "TAOS_ADAPTER_NODE_EXPORTER_HTTP_USERNAME" + --node_exporter.insecureSkipVerify node_exporter skip ssl check. Env "TAOS_ADAPTER_NODE_EXPORTER_INSECURE_SKIP_VERIFY" (default true) + --node_exporter.keyFile string node_exporter cert key file path. Env "TAOS_ADAPTER_NODE_EXPORTER_KEY_FILE" + --node_exporter.password string node_exporter password. Env "TAOS_ADAPTER_NODE_EXPORTER_PASSWORD" (default "taosdata") + --node_exporter.responseTimeout duration node_exporter response timeout. Env "TAOS_ADAPTER_NODE_EXPORTER_RESPONSE_TIMEOUT" (default 5s) + --node_exporter.urls strings node_exporter urls. Env "TAOS_ADAPTER_NODE_EXPORTER_URLS" (default [http://localhost:9100]) + --node_exporter.user string node_exporter user. Env "TAOS_ADAPTER_NODE_EXPORTER_USER" (default "root") + --opentsdb.enable enable opentsdb. Env "TAOS_ADAPTER_OPENTSDB_ENABLE" (default true) + --opentsdb_telnet.dbs strings opentsdb_telnet db names. Env "TAOS_ADAPTER_OPENTSDB_TELNET_DBS" (default [opentsdb_telnet,collectd_tsdb,icinga2_tsdb,tcollector_tsdb]) + --opentsdb_telnet.enable enable opentsdb telnet,warning: without auth info(default false). Env "TAOS_ADAPTER_OPENTSDB_TELNET_ENABLE" + --opentsdb_telnet.maxTCPConnections int max tcp connections. Env "TAOS_ADAPTER_OPENTSDB_TELNET_MAX_TCP_CONNECTIONS" (default 250) + --opentsdb_telnet.password string opentsdb_telnet password. Env "TAOS_ADAPTER_OPENTSDB_TELNET_PASSWORD" (default "taosdata") + --opentsdb_telnet.ports ints opentsdb telnet tcp port. Env "TAOS_ADAPTER_OPENTSDB_TELNET_PORTS" (default [6046,6047,6048,6049]) + --opentsdb_telnet.tcpKeepAlive enable tcp keep alive. Env "TAOS_ADAPTER_OPENTSDB_TELNET_TCP_KEEP_ALIVE" + --opentsdb_telnet.user string opentsdb_telnet user. Env "TAOS_ADAPTER_OPENTSDB_TELNET_USER" (default "root") + --pool.idleTimeout duration Set idle connection timeout. Env "TAOS_ADAPTER_POOL_IDLE_TIMEOUT" (default 1h0m0s) + --pool.maxConnect int max connections to taosd. Env "TAOS_ADAPTER_POOL_MAX_CONNECT" (default 4000) + --pool.maxIdle int max idle connections to taosd. Env "TAOS_ADAPTER_POOL_MAX_IDLE" (default 4000) + -P, --port int http port. Env "TAOS_ADAPTER_PORT" (default 6041) + --prometheus.enable enable prometheus. Env "TAOS_ADAPTER_PROMETHEUS_ENABLE" (default true) + --restfulRowLimit int restful returns the maximum number of rows (-1 means no limit). Env "TAOS_ADAPTER_RESTFUL_ROW_LIMIT" (default -1) + --ssl.certFile string ssl cert file path. Env "TAOS_ADAPTER_SSL_CERT_FILE" + --ssl.enable enable ssl. Env "TAOS_ADAPTER_SSL_ENABLE" + --ssl.keyFile string ssl key file path. Env "TAOS_ADAPTER_SSL_KEY_FILE" + --statsd.allowPendingMessages int statsd allow pending messages. Env "TAOS_ADAPTER_STATSD_ALLOW_PENDING_MESSAGES" (default 50000) + --statsd.db string statsd db name. Env "TAOS_ADAPTER_STATSD_DB" (default "statsd") + --statsd.deleteCounters statsd delete counter cache after gather. Env "TAOS_ADAPTER_STATSD_DELETE_COUNTERS" (default true) + --statsd.deleteGauges statsd delete gauge cache after gather. Env "TAOS_ADAPTER_STATSD_DELETE_GAUGES" (default true) + --statsd.deleteSets statsd delete set cache after gather. Env "TAOS_ADAPTER_STATSD_DELETE_SETS" (default true) + --statsd.deleteTimings statsd delete timing cache after gather. Env "TAOS_ADAPTER_STATSD_DELETE_TIMINGS" (default true) + --statsd.enable enable statsd. Env "TAOS_ADAPTER_STATSD_ENABLE" (default true) + --statsd.gatherInterval duration statsd gather interval. Env "TAOS_ADAPTER_STATSD_GATHER_INTERVAL" (default 5s) + --statsd.maxTCPConnections int statsd max tcp connections. Env "TAOS_ADAPTER_STATSD_MAX_TCP_CONNECTIONS" (default 250) + --statsd.password string statsd password. Env "TAOS_ADAPTER_STATSD_PASSWORD" (default "taosdata") + --statsd.port int statsd server port. Env "TAOS_ADAPTER_STATSD_PORT" (default 6044) + --statsd.protocol string statsd protocol [tcp or udp]. Env "TAOS_ADAPTER_STATSD_PROTOCOL" (default "udp") + --statsd.tcpKeepAlive enable tcp keep alive. Env "TAOS_ADAPTER_STATSD_TCP_KEEP_ALIVE" + --statsd.user string statsd user. Env "TAOS_ADAPTER_STATSD_USER" (default "root") + --statsd.worker int statsd write worker. Env "TAOS_ADAPTER_STATSD_WORKER" (default 10) + --taosConfigDir string load taos client config path. Env "TAOS_ADAPTER_TAOS_CONFIG_FILE" + --version Print the version and exit +``` + +备注: +使用浏览器进行接口调用请根据实际情况设置如下跨源资源共享(CORS)参数: + +```text +AllowAllOrigins +AllowOrigins +AllowHeaders +ExposeHeaders +AllowCredentials +AllowWebSockets +``` + +如果不通过浏览器进行接口调用无需关心这几项配置。 + +关于 CORS 协议细节请参考:[https://www.w3.org/wiki/CORS_Enabled](https://www.w3.org/wiki/CORS_Enabled) 或 [https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/CORS)。 + +示例配置文件参见 [example/config/taosadapter.toml](https://github.com/taosdata/taosadapter/blob/develop/example/config/taosadapter.toml)。 + +## 功能列表 + +- 与 RESTful 接口兼容 + [https://www.taosdata.com/cn/documentation/connector#restful](https://www.taosdata.com/cn/documentation/connector#restful) +- 兼容 InfluxDB v1 写接口 + [https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/](https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/write/) +- 兼容 OpenTSDB JSON 和 telnet 格式写入 + - + - +- 与 collectd 无缝连接 + collectd 是一个系统统计收集守护程序,请访问 [https://collectd.org/](https://collectd.org/) 了解更多信息。 +- Seamless connection with StatsD + StatsD 是一个简单而强大的统计信息汇总的守护程序。请访问 [https://github.com/statsd/statsd](https://github.com/statsd/statsd) 了解更多信息。 +- 与 icinga2 的无缝连接 + icinga2 是一个收集检查结果指标和性能数据的软件。请访问 [https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer](https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer) 了解更多信息。 +- 与 tcollector 无缝连接 + TCollector 是一个客户端进程,从本地收集器收集数据,并将数据推送到 OpenTSDB。请访问 [http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html](http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html) 了解更多信息。 +- 无缝连接 node_exporter + node_export 是一个机器指标的导出器。请访问 [https://github.com/prometheus/node_exporter](https://github.com/prometheus/node_exporter) 了解更多信息。 +- 支持 Prometheus remote_read 和 remote_write + remote_read 和 remote_write 是 Prometheus 数据读写分离的集群方案。请访问[https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis](https://prometheus.io/blog/2019/10/10/remote-read-meets-streaming/#remote-apis) 了解更多信息。 + +## 接口 + +### TDengine RESTful 接口 + +您可以使用任何支持 http 协议的客户端通过访问 RESTful 接口地址 `http://:6041/` 来写入数据到 TDengine 或从 TDengine 中查询数据。细节请参考[官方文档](/reference/connector#restful)。支持如下 EndPoint : + +```text +/rest/sql +/rest/sqlt +/rest/sqlutc +``` + +### InfluxDB + +您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://:6041/` 来写入 InfluxDB 兼容格式的数据到 TDengine。EndPoint 如下: + +```text +/influxdb/v1/write +``` + +支持 InfluxDB 查询参数如下: + +- `db` 指定 TDengine 使用的数据库名 +- `precision` TDengine 使用的时间精度 +- `u` TDengine 用户名 +- `p` TDengine 密码 + +注意: 目前不支持 InfluxDB 的 token 验证方式只支持 Basic 验证和查询参数验证。 + +### OpenTSDB + +您可以使用任何支持 http 协议的客户端访问 Restful 接口地址 `http://:6041/` 来写入 OpenTSDB 兼容格式的数据到 TDengine。EndPoint 如下: + +```text +/opentsdb/v1/put/json/:db +/opentsdb/v1/put/telnet/:db +``` + +### collectd + + + +### StatsD + + + +### icinga2 OpenTSDB writer + + + +### TCollector + + + +### node_exporter + +Prometheus 使用的由\*NIX 内核暴露的硬件和操作系统指标的输出器 + +- 启用 taosAdapter 的配置 node_exporter.enable +- 设置 node_exporter 的相关配置 +- 重新启动 taosAdapter + +### prometheus + + + +## 内存使用优化方法 + +taosAdapter 将监测自身运行过程中内存使用率并通过两个阈值进行调节。有效值范围为 -1 到 100 的整数,单位为系统物理内存的百分比。 + +- pauseQueryMemoryThreshold +- pauseAllMemoryThreshold + +当超过 pauseQueryMemoryThreshold 阈值时时停止处理查询请求。 + +http 返回内容: + +- code 503 +- body "query memory exceeds threshold" + +当超过 pauseAllMemoryThreshold 阈值时停止处理所有写入和查询请求。 + +http 返回内容: + +- code 503 +- body "memory exceeds threshold" + +当内存回落到阈值之下时恢复对应功能。 + +状态检查接口 `http://:6041/-/ping` + +- 正常返回 `code 200` +- 无参数 如果内存超过 pauseAllMemoryThreshold 将返回 `code 503` +- 请求参数 `action=query` 如果内存超过 pauseQueryMemoryThreshold 或 pauseAllMemoryThreshold 将返回 `code 503` + +对应配置参数 + +```text + monitor.collectDuration 监测间隔 环境变量 "TAOS_MONITOR_COLLECT_DURATION" (默认值 3s) + monitor.incgroup 是否是cgroup中运行(容器中运行设置为 true) 环境变量 "TAOS_MONITOR_INCGROUP" + monitor.pauseAllMemoryThreshold 不再进行插入和查询的内存阈值 环境变量 "TAOS_MONITOR_PAUSE_ALL_MEMORY_THRESHOLD" (默认值 80) + monitor.pauseQueryMemoryThreshold 不再进行查询的内存阈值 环境变量 "TAOS_MONITOR_PAUSE_QUERY_MEMORY_THRESHOLD" (默认值 70) +``` + +您可以根据具体项目应用场景和运营策略进行相应调整,并建议使用运营监控软件及时进行系统内存状态监控。负载均衡器也可以通过这个接口检查 taosAdapter 运行状态。 + +## taosAdapter 监控指标 + +taosAdapter 采集 http 相关指标、cpu 百分比和内存百分比。 + +### http 接口 + +提供符合 [OpenMetrics](https://github.com/OpenObservability/OpenMetrics/blob/main/specification/OpenMetrics.md) 接口: + +```text +http://:6041/metrics +``` + +### 写入 TDengine + +taosAdapter 支持将 http 监控、cpu 百分比和内存百分比写入 TDengine。 + +有关配置参数 + +| **配置项** | **描述** | **默认值** | +| ----------------------- | --------------------------------------------------------- | ---------- | +| monitor.collectDuration | cpu 和内存采集间隔 | 3s | +| monitor.identity | 当前 taosadapter 的标识符如果不设置将使用 'hostname:port' | | +| monitor.incgroup | 是否是 cgroup 中运行(容器中运行设置为 true) | false | +| monitor.writeToTD | 是否写入到 TDengine | true | +| monitor.user | TDengine 连接用户名 | root | +| monitor.password | TDengine 连接密码 | taosdata | +| monitor.writeInterval | 写入 TDengine 间隔 | 30s | + +## 结果返回条数限制 + +taosAdapter 通过参数 `restfulRowLimit` 来控制结果的返回条数,-1 代表无限制,默认无限制。 + +该参数控制以下接口返回 + +- `http://:6041/rest/sql` +- `http://:6041/rest/sqlt` +- `http://:6041/rest/sqlutc` +- `http://:6041/prometheus/v1/remote_read/:db` + +## 故障解决 + +您可以通过命令 `systemctl status taosadapter` 来检查 taosAdapter 运行状态。 + +您也可以通过设置 --logLevel 参数或者环境变量 TAOS_ADAPTER_LOG_LEVEL 来调节 taosAdapter 日志输出详细程度。有效值包括: panic、fatal、error、warn、warning、info、debug 以及 trace。 + +## 如何从旧版本 TDengine 迁移到 taosAdapter + +在 TDengine server 2.2.x.x 或更早期版本中,taosd 进程包含一个内嵌的 http 服务。如前面所述,taosAdapter 是一个使用 systemd 管理的独立软件,拥有自己的进程。并且两者有一些配置参数和行为是不同的,请见下表: + +| **#** | **embedded httpd** | **taosAdapter** | **comment** | +| ----- | ------------------- | ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | +| 1 | httpEnableRecordSql | --logLevel=debug | | +| 2 | httpMaxThreads | n/a | taosAdapter 自动管理线程池,无需此参数 | +| 3 | telegrafUseFieldNum | 请参考 taosAdapter telegraf 配置方法 | | +| 4 | restfulRowLimit | restfulRowLimit | 内嵌 httpd 默认输出 10240 行数据,最大允许值为 102400。taosAdapter 也提供 restfulRowLimit 但是默认不做限制。您可以根据实际场景需求进行配置 | +| 5 | httpDebugFlag | 不适用 | httpdDebugFlag 对 taosAdapter 不起作用 | +| 6 | httpDBNameMandatory | 不适用 | taosAdapter 要求 URL 中必须指定数据库名 | diff --git a/docs-cn/14-reference/05-taosbenchmark.md b/docs-cn/14-reference/05-taosbenchmark.md new file mode 100644 index 0000000000000000000000000000000000000000..c8668dedc5527f667dedf5fee9b54872047f0a51 --- /dev/null +++ b/docs-cn/14-reference/05-taosbenchmark.md @@ -0,0 +1,431 @@ +--- +title: taosBenchmark +sidebar_label: taosBenchmark +toc_max_heading_level: 4 +--- + +## 简介 + +taosBenchmark (曾用名 taosdemo ) 是一个用于测试 TDengine 产品性能的工具。taosBenchmark 可以测试 TDengine 的插入、查询和订阅等功能的性能,它可以模拟由大量设备产生的大量数据,还可以灵活地控制数据库、超级表、标签列的数量和类型、数据列的数量和类型、子表的数量、每张子表的数据量、插入数据的时间间隔、taosBenchmark 的工作线程数量、是否以及如何插入乱序数据等。为了兼容过往用户的使用习惯,安装包提供 了 taosdemo 作为 taosBenchmark 的软链接。 + +## 安装 + +taosBenchmark 有两种安装方式: + +- 安装 TDengine 官方安装包的同时会自动安装 taosBenchmark, 详情请参考[ TDengine 安装](/operation/pkg-install)。 + +- 单独编译 taos-tools 并安装, 详情请参考 [taos-tools](https://github.com/taosdata/taos-tools) 仓库。 + +## 运行 + +### 配置和运行方式 + +taosBenchmark 支持两种配置方式:[命令行参数](#命令行参数详解) 和 [JSON 配置文件](#配置文件参数详解)。这两种方式是互斥的,在使用配置文件时只能使用一个命令行参数 `-f ` 指定配置文件。在使用命令行参数运行 taosBenchmark 并控制其行为时则不能使用 `-f` 参数而要用其它参数来进行配置。除此之外,taosBenchmark 还提供了一种特殊的运行方式,即无参数运行。 + +taosBenchmark 支持对 TDengine 做完备的性能测试,其所支持的 TDengine 功能分为三大类:写入、查询和订阅。这三种功能之间是互斥的,每次运行 taosBenchmark 只能选择其中之一。值得注意的是,所要测试的功能类型在使用命令行配置方式时是不可配置的,命令行配置方式只能测试写入性能。若要测试 TDegnine 的查询和订阅性能,必须使用配置文件的方式,通过配置文件中的参数 `filetype` 指定所要测试的功能类型。 + +**在运行 taosBenchmark 之前要确保 TDengine 集群已经在正确运行。** + +### 无命令行参数运行 + +执行下列命令即可快速体验 taosBenchmark 对 TDengine 进行基于默认配置的写入性能测试。 + +```bash +taosBenchmark +``` + +在无参数运行时,taosBenchmark 默认连接 `/etc/taos` 下指定的 TDengine 集群,并在 TDengine 中创建一个名为 test 的数据库,test 数据库下创建名为 meters 的一张超级表,超级表下创建 10000 张表,每张表中写入 10000 条记录。注意,如果已有 test 数据库,这个命令会先删除该数据库后建立一个全新的 test 数据库。 + +### 使用命令行配置参数运行 + +在使用命令行参数运行 taosBenchmark 并控制其行为时,`-f ` 参数不能使用。所有配置参数都必须通过命令行指定。以下是使用命令行方式测试 taosBenchmark 写入性能的一个示例。 + +```bash +taosBenchmark -I stmt -n 200 -t 100 +``` + +上面的命令 `taosBenchmark` 将创建一个名为`test`的数据库,在其中建立一张超级表`meters`,在该超级表中建立 100 张子表并使用参数绑定的方式为每张子表插入 200 条记录。 + +### 使用配置文件运行 + +taosBenchmark 安装包中提供了配置文件的示例,位于 `/examples/taosbenchmark-json` 下 + +使用如下命令行即可运行 taosBenchmark 并通过配置文件控制其行为。 + +```bash +taosBenchmark -f +``` + +**下面是几个配置文件的示例:** + +#### 插入场景 JSON 配置文件示例 + +
+insert.json + +```json +{{#include /taos-tools/example/insert.json}} +``` + +
+ +#### 查询场景 JSON 配置文件示例 + +
+query.json + +```json +{{#include /taos-tools/example/query.json}} +``` + +
+ +#### 订阅场景 JSON 配置文件示例 + +
+subscribe.json + +```json +{{#include /taos-tools/example/subscribe.json}} +``` + +
+ +## 命令行参数详解 + +- **-f/--file ** : + 要使用的 JSON 配置文件,由该文件指定所有参数,本参数与命令行其他参数不能同时使用。没有默认值。 + +- **-c/--config-dir ** : + TDengine 集群配置文件所在的目录,默认路径是 /etc/taos 。 + +- **-h/--host ** : + 指定要连接的 TDengine 服务端的 FQDN,默认值为 localhost 。 + +- **-P/--port ** : + 要连接的 TDengine 服务器的端口号,默认值为 6030 。 + +- **-I/--interface ** : + 插入模式,可选项有 taosc, rest, stmt, sml, sml-rest, 分别对应普通写入、restful 接口写入、参数绑定接口写入、schemaless 接口写入、restful schemaless 接口写入 (由 taosAdapter 提供)。默认值为 taosc。 + +- **-u/--user ** : + 用于连接 TDengine 服务端的用户名,默认为 root 。 + +- **-p/--password ** : + 用于连接 TDengine 服务端的密码,默认值为 taosdata。 + +- **-o/--output ** : + 结果输出文件的路径,默认值为 ./output.txt。 + +- **-T/--thread ** : + 插入数据的线程数量,默认为 8 。 + +- **-B/--interlace-rows ** : + 启用交错插入模式并同时指定向每个子表每次插入的数据行数。交错插入模式是指依次向每张子表插入由本参数所指定的行数并重复这个过程,直到所有子表的数据都插入完成。默认值为 0, 即向一张子表完成数据插入后才会向下一张子表进行数据插入。 + +- **-i/--insert-interval ** : + 指定交错插入模式的插入间隔,单位为 ms,默认值为 0。 只有当 `-B/--interlace-rows` 大于 0 时才起作用。意味着数据插入线程在为每个子表插入隔行扫描记录后,会等待该值指定的时间间隔后再进行下一轮写入。 + +- **-r/--rec-per-req ** : + 每次向 TDegnine 请求写入的数据行数,默认值为 30000 。 + +- **-t/--tables ** : + 指定子表的数量,默认为 10000 。 + +- **-S/--timestampstep ** : + 每个子表中插入数据的时间戳步长,单位是 ms,默认值是 1。 + +- **-n/--records ** : + 每个子表插入的记录数,默认值为 10000 。 + +- **-d/--database ** : + 所使用的数据库的名称,默认值为 test 。 + +- **-b/--data-type ** : + 超级表的数据列的类型。如果不使用则默认为有三个数据列,其类型分别为 FLOAT, INT, FLOAT 。 + +- **-l/--columns ** : + 超级表的数据列的总数量。如果同时设置了该参数和 `-b/--data-type`,则最后的结果列数为两者取大。如果本参数指定的数量大于 `-b/--data-type` 指定的列数,则未指定的列类型默认为 INT, 例如: `-l 5 -b float,double`, 那么最后的列为 `FLOAT,DOUBLE,INT,INT,INT`。如果 columns 指定的数量小于或等于 `-b/--data-type` 指定的列数,则结果为 `-b/--data-type` 指定的列和类型,例如: `-l 3 -b float,double,float,bigint`,那么最后的列为 `FLOAT,DOUBLE,FLOAT,BIGINT` 。 + +- **-A/--tag-type ** : + 超级表的标签列类型。nchar 和 binary 类型可以同时设置长度,例如: + +``` +taosBenchmark -A INT,DOUBLE,NCHAR,BINARY(16) +``` + +如果没有设置标签类型,默认是两个标签,其类型分别为 INT 和 BINARY(16)。 +注意:在有的 shell 比如 bash 命令里面 “()” 需要转义,则上述指令应为: + +``` +taosBenchmark -A INT,DOUBLE,NCHAR,BINARY\(16\) +``` + +- **-w/--binwidth **: + nchar 和 binary 类型的默认长度,默认值为 64。 + +- **-m/--table-prefix ** : + 子表名称的前缀,默认值为 "d"。 + +- **-E/--escape-character** : + 开关参数,指定在超级表和子表名称中是否使用转义字符。默认值为不使用。 + +- **-C/--chinese** : + 开关参数,指定 nchar 和 binary 是否使用 Unicode 中文字符。默认值为不使用。 + +- **-N/--normal-table** : + 开关参数,指定只创建普通表,不创建超级表。默认值为 false。仅当插入模式为 taosc, stmt, rest 模式下可以使用。 + +- **-M/--random** : + 开关参数,插入数据为生成的随机值。默认值为 false。若配置此参数,则随机生成要插入的数据。对于数值类型的 标签列/数据列,其值为该类型取值范围内的随机值。对于 NCHAR 和 BINARY 类型的 标签列/数据列,其值为指定长度范围内的随机字符串。 + +- **-x/--aggr-func** : + 开关参数,指示插入后查询聚合函数。默认值为 false。 + +- **-y/--answer-yes** : + 开关参数,要求用户在提示后确认才能继续。默认值为 false 。 + +- **-O/--disorder ** : + 指定乱序数据的百分比概率,其值域为 [0,50]。默认为 0,即没有乱序数据。 + +- **-R/--disorder-range ** : + 指定乱序数据的时间戳回退范围。所生成的乱序时间戳为非乱序情况下应该使用的时间戳减去这个范围内的一个随机值。仅在 `-O/--disorder` 指定的乱序数据百分比大于 0 时有效。 + +- **-F/--prepare_rand ** : + 生成的随机数据中唯一值的数量。若为 1 则表示所有数据都相同。默认值为 10000 。 + +- **-a/--replica ** : + 创建数据库时指定其副本数,默认值为 1 。 + +- **-V/--version** : + 显示版本信息并退出。不能与其它参数混用。 + +- **-?/--help** : + 显示帮助信息并退出。不能与其它参数混用。 + +## 配置文件参数详解 + +### 通用配置参数 + +本节所列参数适用于所有功能模式。 + +- **filetype** : 要测试的功能,可选值为 `insert`, `query` 和 `subscribe`。分别对应插入、查询和订阅功能。每个配置文件中只能指定其中之一。 +- **cfgdir** : TDengine 集群配置文件所在的目录,默认路径是 /etc/taos 。 + +- **host** : 指定要连接的 TDengine 服务端的 FQDN,默认值为 localhost。 + +- **port** : 要连接的 TDengine 服务器的端口号,默认值为 6030。 + +- **user** : 用于连接 TDengine 服务端的用户名,默认为 root。 + +- **password** : 用于连接 TDengine 服务端的密码,默认值为 taosdata。 + +### 插入场景配置参数 + +插入场景下 `filetype` 必须设置为 `insert`,该参数及其它通用参数详见[通用配置参数](#通用配置参数) + +#### 数据库相关配置参数 + +创建数据库时的相关参数在 json 配置文件中的 `dbinfo` 中配置,具体参数如下。这些参数与 TDengine 中 `create database` 时所指定的数据库参数相对应。 + +- **name** : 数据库名。 + +- **drop** : 插入前是否删除数据库,默认为 true。 + +- **replica** : 创建数据库时指定的副本数。 + +- **days** : 单个数据文件中存储数据的时间跨度,默认值为 10。 + +- **cache** : 缓存块的大小,单位是 MB,默认值是 16。 + +- **blocks** : 每个 vnode 中缓存块的数量,默认为 6。 + +- **precision** : 数据库时间精度,默认值为 "ms"。 + +- **keep** : 保留数据的天数,默认值为 3650。 + +- **minRows** : 文件块中的最小记录数,默认值为 100。 + +- **maxRows** : 文件块中的最大记录数,默认值为 4096。 + +- **comp** : 文件压缩标志,默认值为 2。 + +- **walLevel** : WAL 级别,默认为 1。 + +- **cacheLast** : 是否允许将每个表的最后一条记录保留在内存中,默认值为 0,可选值为 0,1,2,3。 + +- **quorum** : 多副本模式下的写确认数量,默认值为 1。 + +- **fsync** : 当 wal 设置为 2 时,fsync 的间隔时间,单位为 ms,默认值为 3000。 + +- **update** : 是否支持数据更新,默认值为 0, 可选值为 0, 1, 2。 + +#### 超级表相关配置参数 + +创建超级表时的相关参数在 json 配置文件中的 `super_tables` 中配置,具体参数如下表。 + +- **name**: 超级表名,必须配置,没有默认值。 +- **child_table_exists** : 子表是否已经存在,默认值为 "no",可选值为 "yes" 或 "no"。 + +- **child_table_count** : 子表的数量,默认值为 10。 + +- **child_table_prefix** : 子表名称的前缀,必选配置项,没有默认值。 + +- **escape_character** : 超级表和子表名称中是否包含转义字符,默认值为 "no",可选值为 "yes" 或 "no"。 + +- **auto_create_table** : 仅当 insert_mode 为 taosc, rest, stmt 并且 childtable_exists 为 "no" 时生效,该参数为 "yes" 表示 taosBenchmark 在插入数据时会自动创建不存在的表;为 "no" 则表示先提前建好所有表再进行插入。 + +- **batch_create_tbl_num** : 创建子表时每批次的建表数量,默认为 10。注:实际的批数不一定与该值相同,当执行的 SQL 语句大于支持的最大长度时,会自动截断再执行,继续创建。 + +- **data_source** : 数据的来源,默认为 taosBenchmark 随机产生,可以配置为 "rand" 和 "sample"。为 "sample" 时使用 sample_file 参数指定的文件内的数据。 + +- **insert_mode** : 插入模式,可选项有 taosc, rest, stmt, sml, sml-rest, 分别对应普通写入、restful 接口写入、参数绑定接口写入、schemaless 接口写入、restful schemaless 接口写入 (由 taosAdapter 提供)。默认值为 taosc 。 + +- **non_stop_mode** : 指定是否持续写入,若为 "yes" 则 insert_rows 失效,直到 Ctrl + C 停止程序,写入才会停止。默认值为 "no",即写入指定数量的记录后停止。注:即使在持续写入模式下 insert_rows 失效,但其也必须被配置为一个非零正整数。 + +- **line_protocol** : 使用行协议插入数据,仅当 insert_mode 为 sml 或 sml-rest 时生效,可选项为 line, telnet, json。 + +- **tcp_transfer** : telnet 模式下的通信协议,仅当 insert_mode 为 sml-rest 并且 line_protocol 为 telnet 时生效。如果不配置,则默认为 http 协议。 + +- **insert_rows** : 每个子表插入的记录数,默认为 0 。 + +- **childtable_offset** : 仅当 childtable_exists 为 yes 时生效,指定从超级表获取子表列表时的偏移量,即从第几个子表开始。 + +- **childtable_limit** : 仅当 childtable_exists 为 yes 时生效,指定从超级表获取子表列表的上限。 + +- **interlace_rows** : 启用交错插入模式并同时指定向每个子表每次插入的数据行数。交错插入模式是指依次向每张子表插入由本参数所指定的行数并重复这个过程,直到所有子表的数据都插入完成。默认值为 0, 即向一张子表完成数据插入后才会向下一张子表进行数据插入。 + +- **insert_interval** : 指定交错插入模式的插入间隔,单位为 ms,默认值为 0。 只有当 `-B/--interlace-rows` 大于 0 时才起作用。意味着数据插入线程在为每个子表插入隔行扫描记录后,会等待该值指定的时间间隔后再进行下一轮写入。 + +- **partial_col_num** : 若该值为正数 n 时, 则仅向前 n 列写入,仅当 insert_mode 为 taosc 和 rest 时生效,如果 n 为 0 则是向全部列写入。 + +- **disorder_ratio** : 指定乱序数据的百分比概率,其值域为 [0,50]。默认为 0,即没有乱序数据。 + +- **disorder_range** : 指定乱序数据的时间戳回退范围。所生成的乱序时间戳为非乱序情况下应该使用的时间戳减去这个范围内的一个随机值。仅在 `-O/--disorder` 指定的乱序数据百分比大于 0 时有效。 + +- **timestamp_step** : 每个子表中插入数据的时间戳步长,单位与数据库的 `precision` 一致,默认值是 1。 + +- **start_timestamp** : 每个子表的时间戳起始值,默认值是 now。 + +- **sample_format** : 样本数据文件的类型,现在只支持 "csv" 。 + +- **sample_file** : 指定 csv 格式的文件作为数据源,仅当 data_source 为 sample 时生效。若 csv 文件内的数据行数小于等于 prepared_rand,那么会循环读取 csv 文件数据直到与 prepared_rand 相同;否则则会只读取 prepared_rand 个数的行的数据。也即最终生成的数据行数为二者取小。 + +- **use_sample_ts** : 仅当 data_source 为 sample 时生效,表示 sample_file 指定的 csv 文件内是否包含第一列时间戳,默认为 no。 若设置为 yes, 则使用 csv 文件第一列作为时间戳,由于同一子表时间戳不能重复,生成的数据量取决于 csv 文件内的数据行数相同,此时 insert_rows 失效。 + +- **tags_file** : 仅当 insert_mode 为 taosc, rest 的模式下生效。 最终的 tag 的数值与 childtable_count 有关,如果 csv 文件内的 tag 数据行小于给定的子表数量,那么会循环读取 csv 文件数据直到生成 childtable_count 指定的子表数量;否则则只会读取 childtable_count 行 tag 数据。也即最终生成的子表数量为二者取小。 + +#### 标签列与数据列配置参数 + +指定超级表标签列与数据列的配置参数分别在 `super_tables` 中的 `columns` 和 `tag` 中。 + +- **type** : 指定列类型,可选值请参考 TDengine 支持的数据类型。 + 注:JSON 数据类型比较特殊,只能用于标签,当使用 JSON 类型作为 tag 时有且只能有这一个标签,此时 count 和 len 代表的意义分别是 JSON tag 内的 key-value pair 的个数和每个 KV pair 的 value 的值的长度,value 默认为 string。 + +- **len** : 指定该数据类型的长度,对 NCHAR,BINARY 和 JSON 数据类型有效。如果对其他数据类型配置了该参数,若为 0 , 则代表该列始终都是以 null 值写入;如果不为 0 则被忽略。 + +- **count** : 指定该类型列连续出现的数量,例如 "count": 4096 即可生成 4096 个指定类型的列。 + +- **name** : 列的名字,若与 count 同时使用,比如 "name":"current", "count":3, 则 3 个列的名字分别为 current, current_2. current_3。 + +- **min** : 数据类型的 列/标签 的最小值。 + +- **max** : 数据类型的 列/标签 的最大值。 + +- **values** : nchar/binary 列/标签的值域,将从值中随机选择。 + +#### 插入行为配置参数 + +- **thread_count** : 插入数据的线程数量,默认为 8。 + +- **connection_pool_size** : 预先建立的与 TDengine 服务端之间的连接的数量。若不配置,则与所指定的线程数相同。 + +- **result_file** : 结果输出文件的路径,默认值为 ./output.txt。 + +- **confirm_parameter_prompt** : 开关参数,要求用户在提示后确认才能继续。默认值为 false 。 + +- **interlace_rows** : 启用交错插入模式并同时指定向每个子表每次插入的数据行数。交错插入模式是指依次向每张子表插入由本参数所指定的行数并重复这个过程,直到所有子表的数据都插入完成。默认值为 0, 即向一张子表完成数据插入后才会向下一张子表进行数据插入。 + 在 `super_tables` 中也可以配置该参数,若配置则以 `super_tables` 中的配置为高优先级,覆盖全局设置。 + +- **insert_interval** : + 指定交错插入模式的插入间隔,单位为 ms,默认值为 0。 只有当 `-B/--interlace-rows` 大于 0 时才起作用。意味着数据插入线程在为每个子表插入隔行扫描记录后,会等待该值指定的时间间隔后再进行下一轮写入。 + 在 `super_tables` 中也可以配置该参数,若配置则以 `super_tables` 中的配置为高优先级,覆盖全局设置。 + +- **num_of_records_per_req** : + 每次向 TDegnine 请求写入的数据行数,默认值为 30000 。当其设置过大时,TDegnine 客户端驱动会返回相应的错误信息,此时需要调低这个参数的设置以满足写入要求。 + +- **prepare_rand** : 生成的随机数据中唯一值的数量。若为 1 则表示所有数据都相同。默认值为 10000 。 + +### 查询场景配置参数 + +查询场景下 `filetype` 必须设置为 `qeury`,该参数及其它通用参数详见[通用配置参数](#通用配置参数) + +#### 执行指定查询语句的配置参数 + +查询子表或者普通表的配置参数在 `specified_table_query` 中设置。 + +- **query_interval** : 查询时间间隔,单位是秒,默认值为 0。 + +- **threads** : 执行查询 SQL 的线程数,默认值为 1。 + +- **sqls**: + - **sql**: 执行的 SQL 命令,必填。 + - **result**: 保存查询结果的文件,未指定则不保存。 + +#### 查询超级表的配置参数 + +查询超级表的配置参数在 `super_table_query` 中设置。 + +- **stblname** : 指定要查询的超级表的名称,必填。 + +- **query_interval** : 查询时间间隔,单位是秒,默认值为 0。 + +- **threads** : 执行查询 SQL 的线程数,默认值为 1。 + +- **sqls** : + - **sql** : 执行的 SQL 命令,必填;对于超级表的查询 SQL,在 SQL 命令中保留 "xxxx",程序会自动将其替换为超级表的所有子表名。 + 替换为超级表中所有的子表名。 + - **result** : 保存查询结果的文件,未指定则不保存。 + +### 订阅场景配置参数 + +订阅场景下 `filetype` 必须设置为 `subscribe`,该参数及其它通用参数详见[通用配置参数](#通用配置参数) + +#### 执行指定订阅语句的配置参数 + +订阅子表或者普通表的配置参数在 `specified_table_query` 中设置。 + +- **threads** : 执行 SQL 的线程数,默认为 1。 + +- **interva** : 执行订阅的时间间隔,单位为秒,默认为 0。 + +- **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。 + +- **keepProgress** : "yes" 表示保留订阅进度,"no" 表示不保留,默认值为 "no"。 + +- **resubAfterConsume** : "yes" 表示取消之前的订阅然后再次订阅, "no" 表示继续之前的订阅,默认值为 "no"。 + +- **sqls** : + - **sql** : 执行的 SQL 命令,必填。 + - **result** : 保存查询结果的文件,未指定则不保存。 + +#### 订阅超级表的配置参数 + +订阅超级表的配置参数在 `super_table_query` 中设置。 + +- **stblname** : 要订阅的超级表名称,必填。 + +- **threads** : 执行 SQL 的线程数,默认为 1。 + +- **interva** : 执行订阅的时间间隔,单位为秒,默认为 0。 + +- **restart** : "yes" 表示开始新的订阅,"no" 表示继续之前的订阅,默认值为 "no"。 + +- **keepProgress** : "yes" 表示保留订阅进度,"no" 表示不保留,默认值为 "no"。 + +- **resubAfterConsume** : "yes" 表示取消之前的订阅然后再次订阅, "no" 表示继续之前的订阅,默认值为 "no"。 + +- **sqls** : + - **sql** : 执行的 SQL 命令,必填;对于超级表的查询 SQL,在 SQL 命令中保留 "xxxx",程序会自动将其替换为超级表的所有子表名。 + 替换为超级表中所有的子表名。 + - **result** : 保存查询结果的文件,未指定则不保存。 diff --git a/docs-cn/14-reference/06-taosdump.md b/docs-cn/14-reference/06-taosdump.md new file mode 100644 index 0000000000000000000000000000000000000000..ede5d236a975b8c892545105b5537c2eea84d081 --- /dev/null +++ b/docs-cn/14-reference/06-taosdump.md @@ -0,0 +1,118 @@ +--- +title: taosdump +--- + +## 简介 + +taosdump 是一个支持从运行中的 TDengine 集群备份数据并将备份的数据恢复 +到相同或另一个运行中的 TDengine 集群中的工具应用程序。 + +taosdump 可以用数据库、超级表或普通表作为逻辑数据单元进行备份,也可以对数据库、超级 +表和普通表中指定时间段内的数据记录进行备份。使用时可以指定数据备份的目录路径,如果 +不指定位置,taosdump 默认会将数据备份到当前目录。 + +如果指定的位置已经有数据文件,taosdump 会提示用户并立即退出,避免数据被覆盖。这意味着同一路径只能被用于一次备份。 +如果看到相关提示,请小心操作。 + +taosdump 是一个逻辑备份工具,它不应被用于备份任何原始数据、环境设置、 +硬件信息、服务端配置或集群的拓扑结构。taosdump 使用 +[ Apache AVRO ](https://avro.apache.org/)作为数据文件格式来存储备份数据。 + +## 安装 + +taosdump 有两种安装方式: + +- 安装 taosTools 官方安装包, 请从[所有下载链接](https://www.taosdata.com/all-downloads)页面找到 taosTools 并下载安装。 + +- 单独编译 taos-tools 并安装, 详情请参考 [taos-tools](https://github.com/taosdata/taos-tools) 仓库。 + +## 常用使用场景 + +### taosdump 备份数据 + +1. 备份所有数据库:指定 `-A` 或 `--all-databases` 参数; +2. 备份多个指定数据库:使用 `-D db1,db2,...` 参数; +3. 备份指定数据库中的某些超级表或普通表:使用 `dbname stbname1 stbname2 tbname1 tbname2 ...` 参数,注意这种输入序列第一个参数为数据库名称,且只支持一个数据库,第二个和之后的参数为该数据库中的超级表或普通表名称,中间以空格分隔; +4. 备份系统 log 库:TDengine 集群通常会包含一个系统数据库,名为 `log`,这个数据库内的数据为 TDengine 自我运行的数据,taosdump 默认不会对 log 库进行备份。如果有特定需求对 log 库进行备份,可以使用 `-a` 或 `--allow-sys` 命令行参数。 +5. “宽容”模式备份:taosdump 1.4.1 之后的版本提供 `-n` 参数和 `-L` 参数,用于备份数据时不使用转义字符和“宽容”模式,可以在表名、列名、标签名没使用转义字符的情况下减少备份数据时间和备份数据占用空间。如果不确定符合使用 `-n` 和 `-L` 条件时请使用默认参数进行“严格”模式进行备份。转义字符的说明请参考[官方文档](/taos-sql/escape)。 + +:::tip +- taosdump 1.4.1 之后的版本提供 `-I` 参数,用于解析 avro 文件 schema 和数据,如果指定 `-s` 参数将只解析 schema。 +- taosdump 1.4.2 之后的备份使用 `-B` 参数指定的批次数,默认值为 16384,如果在某些环境下由于网络速度或磁盘性能不足导致 "Error actual dump .. batch .." 可以通过 `-B` 参数挑战为更小的值进行尝试。 + +::: + +### taosdump 恢复数据 + +恢复指定路径下的数据文件:使用 `-i` 参数加上数据文件所在路径。如前面提及,不应该使用同一个目录备份不同数据集合,也不应该在同一路径多次备份同一数据集,否则备份数据会造成覆盖或多次备份。 + +:::tip +taosdump 内部使用 TDengine stmt binding API 进行恢复数据的写入,为提高数据恢复性能,目前使用 16384 为一次写入批次。如果备份数据中有比较多列数据,可能会导致产生 "WAL size exceeds limit" 错误,此时可以通过使用 `-B` 参数调整为一个更小的值进行尝试。 + +::: + +## 详细命令行参数列表 + +以下为 taosdump 详细命令行参数列表: + +``` +Usage: taosdump [OPTION...] dbname [tbname ...] + or: taosdump [OPTION...] --databases db1,db2,... + or: taosdump [OPTION...] --all-databases + or: taosdump [OPTION...] -i inpath + or: taosdump [OPTION...] -o outpath + + -h, --host=HOST Server host dumping data from. Default is + localhost. + -p, --password User password to connect to server. Default is + taosdata. + -P, --port=PORT Port to connect + -u, --user=USER User name used to connect to server. Default is + root. + -c, --config-dir=CONFIG_DIR Configure directory. Default is /etc/taos + -i, --inpath=INPATH Input file path. + -o, --outpath=OUTPATH Output file path. + -r, --resultFile=RESULTFILE DumpOut/In Result file path and name. + -a, --allow-sys Allow to dump system database + -A, --all-databases Dump all databases. + -D, --databases=DATABASES Dump inputted databases. Use comma to separate + databases' name. + -N, --without-property Dump database without its properties. + -s, --schemaonly Only dump tables' schema. + -y, --answer-yes Input yes for prompt. It will skip data file + checking! + -d, --avro-codec=snappy Choose an avro codec among null, deflate, snappy, + and lzma. + -S, --start-time=START_TIME Start time to dump. Either epoch or + ISO8601/RFC3339 format is acceptable. ISO8601 + format example: 2017-10-01T00:00:00.000+0800 or + 2017-10-0100:00:00:000+0800 or '2017-10-01 + 00:00:00.000+0800' + -E, --end-time=END_TIME End time to dump. Either epoch or ISO8601/RFC3339 + format is acceptable. ISO8601 format example: + 2017-10-01T00:00:00.000+0800 or + 2017-10-0100:00:00.000+0800 or '2017-10-01 + 00:00:00.000+0800' + -B, --data-batch=DATA_BATCH Number of data per query/insert statement when + backup/restore. Default value is 16384. If you see + 'error actual dump .. batch ..' when backup or if + you see 'WAL size exceeds limit' error when + restore, please adjust the value to a smaller one + and try. The workable value is related to the + length of the row and type of table schema. + -I, --inspect inspect avro file content and print on screen + -L, --loose-mode Using loose mode if the table name and column name + use letter and number only. Default is NOT. + -n, --no-escape No escape char '`'. Default is using it. + -T, --thread-num=THREAD_NUM Number of thread for dump in file. Default is + 5. + -g, --debug Print debug info. + -?, --help Give this help list + --usage Give a short usage message + -V, --version Print program version + +Mandatory or optional arguments to long options are also mandatory or optional +for any corresponding short options. + +Report bugs to . +``` diff --git a/docs-cn/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json b/docs-cn/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json new file mode 100644 index 0000000000000000000000000000000000000000..f651983528ca824b4e6b14586aac5a5bfb4ecab8 --- /dev/null +++ b/docs-cn/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json @@ -0,0 +1,3191 @@ +{ + "__inputs": [ + { + "name": "DS_TDENGINE", + "label": "TDengine", + "description": "", + "type": "datasource", + "pluginId": "tdengine-datasource", + "pluginName": "TDengine" + } + ], + "__requires": [ + { + "type": "panel", + "id": "gauge", + "name": "Gauge", + "version": "" + }, + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "7.5.10" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "" + }, + { + "type": "panel", + "id": "piechart", + "name": "Pie chart v2", + "version": "" + }, + { + "type": "panel", + "id": "stat", + "name": "Stat", + "version": "" + }, + { + "type": "panel", + "id": "table", + "name": "Table", + "version": "" + }, + { + "type": "datasource", + "id": "tdengine-datasource", + "name": "TDengine", + "version": "3.1.0" + }, + { + "type": "panel", + "id": "text", + "name": "Text", + "version": "" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "TDengine nodes metrics.", + "editable": true, + "gnetId": 15146, + "graphTooltip": 0, + "id": null, + "iteration": 1635263227798, + "links": [], + "panels": [ + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 57, + "panels": [], + "title": "Cluster Status", + "type": "row" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 24, + "x": 0, + "y": 1 + }, + "id": 32, + "options": { + "content": "

TDengine Cluster Dashboard

>\n", + "mode": "markdown" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "mnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "-- OVERVIEW --", + "transformations": [ + { + "id": "calculateField", + "options": { + "binary": { + "left": "Time", + "operator": "+", + "reducer": "sum", + "right": "" + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + } + ], + "type": "text" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 8, + "x": 0, + "y": 4 + }, + "id": 28, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Master MNode", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": "master" + } + }, + "fieldName": "role" + } + ], + "match": "all", + "type": "include" + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["dnodes"] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 7, + "x": 8, + "y": 4 + }, + "id": 70, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "/^Time$/", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Master MNode Create Time", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": "master" + } + }, + "fieldName": "role" + } + ], + "match": "all", + "type": "include" + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["Time"] + } + } + }, + { + "id": "calculateField", + "options": { + "mode": "reduceRow", + "reduce": { + "reducer": "min" + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": null, + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 9, + "x": 15, + "y": 4 + }, + "id": 29, + "options": { + "showHeader": true + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show variables", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Variables", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["value", "name"] + } + } + }, + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": ".*" + } + }, + "fieldName": "name" + } + ], + "match": "all", + "type": "include" + } + } + ], + "type": "table" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 0, + "y": 7 + }, + "id": 33, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "/.*/", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "select server_version()", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Server Version", + "transformations": [], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 2, + "y": 7 + }, + "id": 27, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Number of MNodes", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "greater", + "options": { + "value": 0 + } + }, + "fieldName": "id" + } + ], + "match": "any", + "type": "include" + } + }, + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": ["count"] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["id"] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 5, + "y": 7 + }, + "id": 41, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["last"], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Dnodes", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": ["count"] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["id"] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 7, + "y": 7 + }, + "id": 31, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": ["last"], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Offline Dnodes", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": "ready" + } + }, + "fieldName": "status" + } + ], + "match": "all", + "type": "exclude" + } + }, + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": ["count"] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["id"] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 7 + }, + "id": 65, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show databases;", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Number of Databases", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": ["count"] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["name"] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 12, + "y": 7 + }, + "id": 69, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show databases;", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Number of Vgroups", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["vgroups"] + } + } + }, + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": ["sum"] + } + } + ], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "displayMode": "auto", + "filterable": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "role" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "from": "", + "id": 1, + "text": "", + "to": "", + "type": 2, + "value": "" + } + ] + } + ] + } + ] + }, + "gridPos": { + "h": 3, + "w": 9, + "x": 0, + "y": 10 + }, + "id": 67, + "options": { + "showHeader": true + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Number of DNodes for each Role", + "transformations": [ + { + "id": "groupBy", + "options": { + "fields": { + "end_point": { + "aggregations": ["count"], + "operation": "aggregate" + }, + "role": { + "aggregations": [], + "operation": "groupby" + } + } + } + }, + { + "id": "filterFieldsByName", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": {}, + "indexByName": {}, + "renameByName": { + "end_point (count)": "Number of DNodes", + "role": "Dnode Role" + } + } + } + ], + "type": "table" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 10 + }, + "id": 55, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show connections", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Number of Connections", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": ["count"] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["connId"] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 12, + "y": 10 + }, + "id": 68, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show databases;", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Number of Tables", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["ntables"] + } + } + }, + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": ["sum"] + } + } + ], + "type": "stat" + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 13 + }, + "id": 24, + "panels": [], + "title": "Dnodes Status", + "type": "row" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "displayMode": "auto", + "filterable": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "status" + }, + "properties": [ + { + "id": "custom.width", + "value": 86 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "vnodes" + }, + "properties": [ + { + "id": "custom.width", + "value": 77 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "role" + }, + "properties": [ + { + "id": "custom.width", + "value": 84 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "cores" + }, + "properties": [ + { + "id": "custom.width", + "value": 75 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "end_point" + }, + "properties": [ + { + "id": "custom.width", + "value": 205 + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "id" + }, + "properties": [ + { + "id": "custom.width", + "value": 78 + } + ] + } + ] + }, + "gridPos": { + "h": 5, + "w": 16, + "x": 0, + "y": 14 + }, + "id": 36, + "options": { + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "DNodes Status", + "type": "table" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 8, + "x": 16, + "y": 14 + }, + "id": 40, + "options": { + "displayLabels": [], + "legend": { + "displayMode": "table", + "placement": "right", + "values": ["value"] + }, + "pieType": "pie", + "reduceOptions": { + "calcs": ["lastNotNull"], + "fields": "/.*/", + "values": false + }, + "text": { + "titleSize": 6 + } + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "title": "Offline Reasons", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": "ready" + } + }, + "fieldName": "status" + } + ], + "match": "all", + "type": "exclude" + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": ["offline reason", "end_point"] + } + } + }, + { + "id": "groupBy", + "options": { + "fields": { + "Time": { + "aggregations": ["count"], + "operation": "aggregate" + }, + "end_point": { + "aggregations": ["count"], + "operation": "aggregate" + }, + "offline reason": { + "aggregations": [], + "operation": "groupby" + } + } + } + } + ], + "type": "piechart" + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 19 + }, + "id": 22, + "panels": [], + "title": "Mnodes Status", + "type": "row" + }, + { + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 38, + "options": { + "showHeader": true + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes;", + "target": "select metric", + "type": "timeserie" + } + ], + "title": "Mnodes Status", + "type": "table" + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 20, + "panels": [], + "repeat": "fqdn", + "title": "节点资源占用 [ $fqdn ]", + "type": "row" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decmbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 0, + "y": 26 + }, + "id": 66, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["mean"], + "fields": "/^taosd$/", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "memory", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select last(mem_taosd) as taosd, last(mem_total) as total from log.dn where fqdn = '$fqdn' and ts >= now -5m and ts < now", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Current Memory Usage of taosd", + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "taosd max memery last 10 minutes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.5 + }, + { + "color": "red", + "value": 0.8 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "last(cpu_taosd)" + }, + "properties": [ + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 5, + "y": 26 + }, + "id": 45, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["mean"], + "fields": "/^last\\(cpu_taosd\\)$/", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "mem_taosd", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select last(cpu_taosd) from log.dn where fqdn = '$fqdn'", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Current CPU Usage of taosd", + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "avg band speed last one minute", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "Kbits" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 10, + "y": 26 + }, + "id": 14, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["last"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "band_speed", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select avg(band_speed) from log.dn where fqdn='$fqdn' and ts >= now-5m and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "band speed", + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "io read/write rate", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "Kbits" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 14, + "y": 26 + }, + "id": 48, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["last"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select last(io_read) as io_read, last(io_write) as io_write from log.dn where fqdn='$fqdn' and ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "IO Rate", + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 75 + }, + { + "color": "red", + "value": 80 + }, + { + "color": "dark-red", + "value": 95 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 19, + "y": 26 + }, + "id": 51, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["last"], + "fields": "/^disk_used_percent$/", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "disk_used", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select last(disk_used) as used from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "disk_total", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select last(disk_total) as total from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "disk_used_percent", + "expression": "A/B", + "formatType": "Time series", + "hide": false, + "queryType": "Arithmetic", + "refId": "C", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Disk Used", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": ["lastNotNull"] + } + } + ], + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "taosd max memery last 10 minutes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decmbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 0, + "y": 32 + }, + "id": 12, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["mean"], + "fields": "/^taosd$/", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "memory", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select max(mem_taosd) as taosd, max(mem_total) as total from log.dn where fqdn = '$fqdn' and ts >= now -5m and ts < now", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Max Memory Usage of taosd in Last 5 minute", + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "taosd max memery last 10 minutes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.5 + }, + { + "color": "red", + "value": 0.8 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 5, + "y": 32 + }, + "id": 43, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["mean"], + "fields": "", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "mem_taosd", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select max(cpu_taosd) from log.dn where fqdn = '$fqdn' and ts >= now -5m and ts < now", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Max CPU Usage of taosd in Last 5 minute", + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "avg band speed last one minute", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "Kbits" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 10, + "y": 32 + }, + "id": 50, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["last"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "band_speed", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select max(band_speed) from log.dn where fqdn = '$fqdn' and ts >= now-1h", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Max band speed in last hour", + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "io read/write rate", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "Kbits" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 14, + "y": 32 + }, + "id": 49, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["last"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select max(io_read) as io_read, max(io_write) as io_write from log.dn where fqdn = '$fqdn'", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Max IO Rate in last hour", + "type": "gauge" + }, + { + "datasource": "${DS_TDENGINE}", + "description": "io read/write rate", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "cpm" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 19, + "y": 32 + }, + "id": 52, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": ["last"], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "alias": "req-http", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select sum(req_http) as req_http from log.dn where fqdn = '$fqdn' and ts >= now - 1h interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "req-inserts", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select sum(req_insert) as req_insert from log.dn where fqdn = '$fqdn' and ts >= now - 1h interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "req-selects", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "C", + "sql": "select sum(req_select) as req_select from log.dn where fqdn = '$fqdn' and ts >= now - 1h interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Requests in last Minute", + "type": "gauge" + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TDENGINE}", + "description": "monitor system cpu", + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 12, + "x": 0, + "y": 38 + }, + "hiddenSeries": false, + "hideTimeOverride": true, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "cpu_system", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(cpu_system) from log.dn where fqdn='$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "cpu_taosd", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(cpu_taosd) from log.dn where fqdn='$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": "1h", + "timeRegions": [], + "timeShift": "30s", + "title": "CPU 资源占用情况", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "percent", + "label": "使用占比", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TDENGINE}", + "description": "monitor system cpu", + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 12, + "x": 12, + "y": 38 + }, + "hiddenSeries": false, + "hideTimeOverride": true, + "id": 42, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "system", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(mem_system) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "taosd", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(mem_taosd) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "total", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "C", + "sql": "select avg(mem_total) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": "1h", + "timeRegions": [], + "timeShift": "30s", + "title": "内存资源占用情况", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "decmbytes", + "label": "使用占比", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 49 + }, + "hiddenSeries": false, + "id": 54, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "percent", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "disk_used", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(disk_used) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(30s)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "disk_total", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(disk_total) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(30s)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "percent", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "D", + "sql": "select avg(disk_used)/avg(disk_total) * 100 from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(30s)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Disk Used Percent", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "gbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "percent", + "label": "Disk Used", + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 49 + }, + "hiddenSeries": false, + "id": 64, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "disk_used", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select derivative(value, 1m, 0) from (select avg(disk_used) as value from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m))", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Disk Used Increasing Rate per Minute", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percentunit", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "percentunit", + "label": "Disk Used", + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TDENGINE}", + "description": "total select request per minute last hour", + "fieldConfig": { + "defaults": { + "unit": "cpm" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 58 + }, + "hiddenSeries": false, + "id": 8, + "interval": null, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "maxDataPoints": 100, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "req_select", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select sum(req_select) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "req_insert", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select sum(req_insert) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "req_http", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "C", + "sql": "select sum(req_http) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Requets Count per Minutes $fqdn", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "cpm", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TDENGINE}", + "description": "io", + "fieldConfig": { + "defaults": { + "links": [], + "unit": "Kbits" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 58 + }, + "hiddenSeries": false, + "hideTimeOverride": true, + "id": 47, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "io-read", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(io_read) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "io-write", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(io_write) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "io-read-last-hour", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "C", + "sql": "select avg(io_read) from log.dn where fqdn = '$fqdn' and ts >= now-2h and ts < now - 1h interval(1m)", + "target": "select metric", + "timeshift": { + "period": 1, + "unit": "hours" + }, + "type": "timeserie" + }, + { + "alias": "io-write-last-hour", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "D", + "sql": "select avg(io_write) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "timeshift": { + "period": 1, + "unit": "hours" + }, + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": "1h", + "timeRegions": [], + "timeShift": "30s", + "title": "IO", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "Kbits", + "label": "IO Rate", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 67 + }, + "id": 63, + "panels": [], + "title": "Login History", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TDENGINE}", + "fieldConfig": { + "defaults": { + "displayName": "Logins Per Minute", + "unit": "cpm" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 68 + }, + "hiddenSeries": false, + "id": 61, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "logins", + "nullPointMode": "null as zero" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "logins", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select count(*) from log.log where ts >= $from and ts < $to interval (1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Login Counts per Minute", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "cpm", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "1m", + "schemaVersion": 27, + "style": "dark", + "tags": ["TDengine", "multiple"], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "TDengine", + "value": "TDengine" + }, + "description": "TDengine Data Source Selector", + "error": null, + "hide": 0, + "includeAll": false, + "label": "Datasource", + "multi": false, + "name": "ds", + "options": [], + "query": "tdengine-datasource", + "queryValue": "", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, + { + "allValue": null, + "current": {}, + "datasource": "${DS_TDENGINE}", + "definition": "select fqdn from log.dn", + "description": "TDengine Nodes FQDN (Hostname)", + "error": null, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "fqdn", + "options": [], + "query": "select fqdn from log.dn", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"] + }, + "timezone": "", + "title": "Multiple TDengines Monitoring", + "uid": "tdengine-multiple", + "version": 4 +} diff --git a/docs-cn/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json b/docs-cn/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json new file mode 100644 index 0000000000000000000000000000000000000000..ab98354aaeae8c4dc945aae085d12fec50b530d1 --- /dev/null +++ b/docs-cn/14-reference/07-tdinsight/assets/15155-tdengine-alert-demo.json @@ -0,0 +1,212 @@ +{ + "__inputs": [ + { + "name": "DS_TDENGINE", + "label": "TDengine", + "description": "", + "type": "datasource", + "pluginId": "tdengine-datasource", + "pluginName": "TDengine" + } + ], + "__requires": [ + { + "type": "grafana", + "id": "grafana", + "name": "Grafana", + "version": "7.5.10" + }, + { + "type": "panel", + "id": "graph", + "name": "Graph", + "version": "" + }, + { + "type": "datasource", + "id": "tdengine-datasource", + "name": "TDengine", + "version": "3.1.0" + } + ], + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": null, + "links": [], + "panels": [ + { + "alert": { + "alertRuleTags": {}, + "conditions": [ + { + "evaluator": { + "params": [5], + "type": "gt" + }, + "operator": { + "type": "and" + }, + "query": { + "params": ["A", "10s", "now"] + }, + "reducer": { + "params": [], + "type": "avg" + }, + "type": "query" + } + ], + "executionErrorState": "alerting", + "for": "5m", + "frequency": "10s", + "handler": 1, + "message": "This is a alert demo!", + "name": "cpu load average alert", + "noDataState": "no_data", + "notifications": [ + { + "uid": "4sKm9jd7k" + }, + { + "uid": "QyczKkFnk" + } + ] + }, + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TDENGINE}", + "decimals": null, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": true, + "current": true, + "hideEmpty": false, + "max": true, + "min": true, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "system", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select avg(cpu_system) as system from log.dn where ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [ + { + "colorMode": "critical", + "fill": true, + "line": true, + "op": "gt", + "value": 5, + "visible": true + } + ], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "CPU Load Average", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "percent", + "label": "Percent", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "schemaVersion": 27, + "style": "dark", + "tags": ["TDengine"], + "templating": { + "list": [] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "TDengine Alert Demo", + "uid": "aLN9ujOnk", + "version": 15 +} diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.png new file mode 100644 index 0000000000000000000000000000000000000000..4708f836feb21980f2db7fed4a55f799b23a6ec1 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-1-cluster-status.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.png new file mode 100644 index 0000000000000000000000000000000000000000..f2684e6eed70e8f56697eae42b495d6bd62815e8 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-2-dnodes.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.png new file mode 100644 index 0000000000000000000000000000000000000000..74686691e4106b8646c3deee1e0ce73b2f53f1ea Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-3-mnodes.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-4-requests.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-4-requests.png new file mode 100644 index 0000000000000000000000000000000000000000..27964215567f9f961c0aeaf1b863188437008fb7 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-4-requests.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-5-database.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-5-database.png new file mode 100644 index 0000000000000000000000000000000000000000..b0d3abbf21ec4d4bd7bfb95fcc03a5f936b22665 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-5-database.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.png new file mode 100644 index 0000000000000000000000000000000000000000..2b54cbeb83bcff12f20461a4f57f882e2073f231 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-6-dnode-usage.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-7-login-history.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-7-login-history.png new file mode 100644 index 0000000000000000000000000000000000000000..eb3848657f13900c856ac595c20766465157e9c4 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-7-login-history.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-8-taosadaper.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-8-taosadaper.png new file mode 100644 index 0000000000000000000000000000000000000000..d94b2e02ac9855bb3d2f77d8902e068839db364f Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-8-taosadaper.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/TDinsight-full.png b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-full.png new file mode 100644 index 0000000000000000000000000000000000000000..654df2934597ce600a1dc2dcd0cab7e29de7076d Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/TDinsight-full.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-manager-status.png b/docs-cn/14-reference/07-tdinsight/assets/alert-manager-status.png new file mode 100644 index 0000000000000000000000000000000000000000..e3afa22c0326d70567ec4529c83101c746daac87 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/alert-manager-status.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-notification-channel.png b/docs-cn/14-reference/07-tdinsight/assets/alert-notification-channel.png new file mode 100644 index 0000000000000000000000000000000000000000..198bf37141c86a66cdd91b47a331bcdeb83daaf8 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/alert-notification-channel.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-query-demo.png b/docs-cn/14-reference/07-tdinsight/assets/alert-query-demo.png new file mode 100644 index 0000000000000000000000000000000000000000..ace3aa3c2f8f14fabdac54bc25ae2d9449445b69 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/alert-query-demo.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.png b/docs-cn/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.png new file mode 100644 index 0000000000000000000000000000000000000000..7082e49f6beb8690c36f98a3f4ff2befdb8fd014 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/alert-rule-condition-notifications.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/alert-rule-test.png b/docs-cn/14-reference/07-tdinsight/assets/alert-rule-test.png new file mode 100644 index 0000000000000000000000000000000000000000..ffd4911b53854c42dbf0ff11838cb604fa694138 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/alert-rule-test.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-button.png b/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-button.png new file mode 100644 index 0000000000000000000000000000000000000000..802c7366f921301bd7fbc62458e56b2d1eaf195c Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-button.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.png b/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.png new file mode 100644 index 0000000000000000000000000000000000000000..019ec921b6f808671f4f864ddf3380159d4a0dcc Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-tdengine.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-test.png b/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-test.png new file mode 100644 index 0000000000000000000000000000000000000000..3963abb4ea8ae0e6f5557466f7a5b746c2d2ea3c Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource-test.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource.png b/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource.png new file mode 100644 index 0000000000000000000000000000000000000000..837100464b35a5cafac474723aef603f91945ebc Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/howto-add-datasource.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-display.png b/docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-display.png new file mode 100644 index 0000000000000000000000000000000000000000..98223df25499effac343ff5723544a3c289f18fa Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-display.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-import-options.png b/docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-import-options.png new file mode 100644 index 0000000000000000000000000000000000000000..07aba348f02b4fb8ef68e79664920c119b842d4c Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/howto-dashboard-import-options.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/howto-import-dashboard.png b/docs-cn/14-reference/07-tdinsight/assets/howto-import-dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..7e28939ead8bf3b6e2b4330e4f9b59c2e39b5c1c Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/howto-import-dashboard.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/import-dashboard-15167.png b/docs-cn/14-reference/07-tdinsight/assets/import-dashboard-15167.png new file mode 100644 index 0000000000000000000000000000000000000000..981f640b14d18aa6f0682768d8405a232df500f6 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/import-dashboard-15167.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.png b/docs-cn/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.png new file mode 100644 index 0000000000000000000000000000000000000000..94ef4fa5fe63e535118a81707b413c028ce01f70 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/import-dashboard-for-tdengine.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.png b/docs-cn/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.png new file mode 100644 index 0000000000000000000000000000000000000000..670cacc377c2801fa9437c3c132c5c7fbc361b0f Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/import-via-grafana-dot-com.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/import_dashboard.png b/docs-cn/14-reference/07-tdinsight/assets/import_dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..d74cd36c96ee0fd24ddc6feae2da07824816f745 Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/import_dashboard.png differ diff --git a/docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json b/docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json new file mode 100644 index 0000000000000000000000000000000000000000..b4254c428b28a0084e54b5e3c509dd2e0ec651b9 --- /dev/null +++ b/docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json @@ -0,0 +1,3358 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "description": "TDengine nodes metrics.", + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 3, + "iteration": 1634275785625, + "links": [], + "panels": [ + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 57, + "panels": [], + "title": "Cluster Status", + "type": "row" + }, + { + "datasource": null, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 24, + "x": 0, + "y": 1 + }, + "id": 32, + "options": { + "content": "

TDengine Cluster Dashboard

>\n", + "mode": "markdown" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "mnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "-- OVERVIEW --", + "transformations": [ + { + "id": "calculateField", + "options": { + "binary": { + "left": "Time", + "operator": "+", + "reducer": "sum", + "right": "" + }, + "mode": "binary", + "reduce": { + "reducer": "sum" + } + } + } + ], + "type": "text" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 8, + "x": 0, + "y": 4 + }, + "id": 28, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Master MNode", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": "master" + } + }, + "fieldName": "role" + } + ], + "match": "all", + "type": "include" + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "dnodes" + ] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 7, + "x": 8, + "y": 4 + }, + "id": 70, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/^Time$/", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Master MNode Create Time", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": "master" + } + }, + "fieldName": "role" + } + ], + "match": "all", + "type": "include" + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "Time" + ] + } + } + }, + { + "id": "calculateField", + "options": { + "mode": "reduceRow", + "reduce": { + "reducer": "min" + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": null, + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 9, + "x": 15, + "y": 4 + }, + "id": 29, + "options": { + "showHeader": true + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show variables", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Variables", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "value", + "name" + ] + } + } + }, + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": ".*" + } + }, + "fieldName": "name" + } + ], + "match": "all", + "type": "include" + } + } + ], + "type": "table" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 0, + "y": 7 + }, + "id": 33, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/.*/", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "select server_version()", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Server Version", + "transformations": [], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 2, + "y": 7 + }, + "id": 27, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Number of MNodes", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "greater", + "options": { + "value": 0 + } + }, + "fieldName": "id" + } + ], + "match": "any", + "type": "include" + } + }, + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": [ + "count" + ] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "id" + ] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 5, + "y": 7 + }, + "id": 41, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Dnodes", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": [ + "count" + ] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "id" + ] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 1 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 2, + "x": 7, + "y": 7 + }, + "id": 31, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "text": {}, + "textMode": "value" + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Offline Dnodes", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": "ready" + } + }, + "fieldName": "status" + } + ], + "match": "all", + "type": "exclude" + } + }, + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": [ + "count" + ] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "id" + ] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 7 + }, + "id": 65, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show databases;", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Number of Databases", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": [ + "count" + ] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "name" + ] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 12, + "y": 7 + }, + "id": 69, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show databases;", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Number of Vgroups", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "vgroups" + ] + } + } + }, + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": [ + "sum" + ] + } + } + ], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "displayMode": "auto", + "filterable": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "role" + }, + "properties": [ + { + "id": "mappings", + "value": [ + { + "from": "", + "id": 1, + "text": "", + "to": "", + "type": 2, + "value": "" + } + ] + } + ] + } + ] + }, + "gridPos": { + "h": 3, + "w": 9, + "x": 0, + "y": 10 + }, + "id": 67, + "options": { + "showHeader": true + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Number of DNodes for each Role", + "transformations": [ + { + "id": "groupBy", + "options": { + "fields": { + "end_point": { + "aggregations": [ + "count" + ], + "operation": "aggregate" + }, + "role": { + "aggregations": [], + "operation": "groupby" + } + } + } + }, + { + "id": "filterFieldsByName", + "options": {} + }, + { + "id": "organize", + "options": { + "excludeByName": {}, + "indexByName": {}, + "renameByName": { + "end_point (count)": "Number of DNodes", + "role": "Dnode Role" + } + } + } + ], + "type": "table" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 9, + "y": 10 + }, + "id": 55, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show connections", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Number of Connections", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": [ + "count" + ] + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "connId" + ] + } + } + } + ], + "type": "stat" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 3, + "x": 12, + "y": 10 + }, + "id": 68, + "options": { + "colorMode": "value", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": true + }, + "text": {}, + "textMode": "auto" + }, + "pluginVersion": "7.5.10", + "repeatDirection": "h", + "targets": [ + { + "alias": "dnodes", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "show databases;", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Total Number of Tables", + "transformations": [ + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "ntables" + ] + } + } + }, + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": [ + "sum" + ] + } + } + ], + "type": "stat" + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 13 + }, + "id": 24, + "panels": [], + "title": "Dnodes Status", + "type": "row" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "displayMode": "auto", + "filterable": true + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "status" + }, + "properties": [ + { + "id": "custom.width", + "value": null + } + ] + }, + { + "matcher": { + "id": "byName", + "options": "vnodes" + }, + "properties": [ + { + "id": "custom.width", + "value": null + } + ] + } + ] + }, + "gridPos": { + "h": 5, + "w": 16, + "x": 0, + "y": 14 + }, + "id": 36, + "options": { + "showHeader": true, + "sortBy": [] + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "DNodes Status", + "type": "table" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 8, + "x": 16, + "y": 14 + }, + "id": 40, + "options": { + "displayLabels": [], + "legend": { + "displayMode": "table", + "placement": "right", + "values": [ + "value" + ] + }, + "pieType": "pie", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "/.*/", + "values": false + }, + "text": { + "titleSize": 6 + } + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "show dnodes", + "target": "select metric", + "type": "timeserie" + } + ], + "title": "Offline Reasons", + "transformations": [ + { + "id": "filterByValue", + "options": { + "filters": [ + { + "config": { + "id": "regex", + "options": { + "value": "ready" + } + }, + "fieldName": "status" + } + ], + "match": "all", + "type": "exclude" + } + }, + { + "id": "filterFieldsByName", + "options": { + "include": { + "names": [ + "offline reason", + "end_point" + ] + } + } + }, + { + "id": "groupBy", + "options": { + "fields": { + "Time": { + "aggregations": [ + "count" + ], + "operation": "aggregate" + }, + "end_point": { + "aggregations": [ + "count" + ], + "operation": "aggregate" + }, + "offline reason": { + "aggregations": [], + "operation": "groupby" + } + } + } + } + ], + "type": "piechart" + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 19 + }, + "id": 22, + "panels": [], + "title": "Mnodes Status", + "type": "row" + }, + { + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "center", + "filterable": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 24, + "x": 0, + "y": 20 + }, + "id": 38, + "options": { + "showHeader": true + }, + "pluginVersion": "7.5.10", + "targets": [ + { + "formatType": "Table", + "queryType": "SQL", + "refId": "A", + "sql": "show mnodes;", + "target": "select metric", + "type": "timeserie" + } + ], + "title": "Mnodes Status", + "type": "table" + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 25 + }, + "id": 20, + "panels": [], + "repeat": "fqdn", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "title": "节点资源占用 [ $fqdn ]", + "type": "row" + }, + { + "datasource": "${ds}", + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decmbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 0, + "y": 26 + }, + "id": 66, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "/^taosd$/", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "memory", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select last(mem_taosd) as taosd, last(mem_total) as total from log.dn where fqdn = '$fqdn' and ts >= now -5m and ts < now", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Current Memory Usage of taosd", + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "taosd max memery last 10 minutes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.5 + }, + { + "color": "red", + "value": 0.8 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [ + { + "matcher": { + "id": "byName", + "options": "last(cpu_taosd)" + }, + "properties": [ + { + "id": "thresholds", + "value": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + } + ] + } + ] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 5, + "y": 26 + }, + "id": 45, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "/^last\\(cpu_taosd\\)$/", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "mem_taosd", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select last(cpu_taosd) from log.dn where fqdn = '$fqdn'", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Current CPU Usage of taosd", + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "avg band speed last one minute", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "Kbits" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 10, + "y": 26 + }, + "id": 14, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "band_speed", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select avg(band_speed) from log.dn where fqdn='$fqdn' and ts >= now-5m and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "band speed", + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "io read/write rate", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "Kbits" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 14, + "y": 26 + }, + "id": 48, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select last(io_read) as io_read, last(io_write) as io_write from log.dn where fqdn='$fqdn' and ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "IO Rate", + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 75 + }, + { + "color": "red", + "value": 80 + }, + { + "color": "dark-red", + "value": 95 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 19, + "y": 26 + }, + "id": 51, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "/^disk_used_percent$/", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "disk_used", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select last(disk_used) as used from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "disk_total", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select last(disk_total) as total from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "disk_used_percent", + "expression": "A/B", + "formatType": "Time series", + "hide": false, + "queryType": "Arithmetic", + "refId": "C", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Disk Used", + "transformations": [ + { + "id": "reduce", + "options": { + "includeTimeField": false, + "mode": "reduceFields", + "reducers": [ + "lastNotNull" + ] + } + } + ], + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "taosd max memery last 10 minutes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + } + ] + }, + "unit": "decmbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 0, + "y": 32 + }, + "id": 12, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "/^taosd$/", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "memory", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select max(mem_taosd) as taosd, max(mem_total) as total from log.dn where fqdn = '$fqdn' and ts >= now -5m and ts < now", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Max Memory Usage of taosd in Last 5 minute", + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "taosd max memery last 10 minutes", + "fieldConfig": { + "defaults": { + "color": { + "mode": "continuous-GrYlRd" + }, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 0.5 + }, + { + "color": "red", + "value": 0.8 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 5, + "y": 32 + }, + "id": 43, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": true, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "mem_taosd", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select max(cpu_taosd) from log.dn where fqdn = '$fqdn' and ts >= now -5m and ts < now", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Max CPU Usage of taosd in Last 5 minute", + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "avg band speed last one minute", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "Kbits" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 4, + "x": 10, + "y": 32 + }, + "id": 50, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "band_speed", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select max(band_speed) from log.dn where fqdn = '$fqdn' and ts >= now-1h", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Max band speed in last hour", + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "io read/write rate", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "Kbits" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 14, + "y": 32 + }, + "id": 49, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select max(io_read) as io_read, max(io_write) as io_write from log.dn where fqdn = '$fqdn'", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Max IO Rate in last hour", + "type": "gauge" + }, + { + "datasource": "${ds}", + "description": "io read/write rate", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ] + }, + "unit": "cpm" + }, + "overrides": [] + }, + "gridPos": { + "h": 6, + "w": 5, + "x": 19, + "y": 32 + }, + "id": 52, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "last" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true, + "text": {} + }, + "pluginVersion": "7.5.10", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "targets": [ + { + "alias": "req-http", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select sum(req_http) as req_http from log.dn where fqdn = '$fqdn' and ts >= now - 1h interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "req-inserts", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select sum(req_insert) as req_insert from log.dn where fqdn = '$fqdn' and ts >= now - 1h interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "req-selects", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "C", + "sql": "select sum(req_select) as req_select from log.dn where fqdn = '$fqdn' and ts >= now - 1h interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Requests in last Minute", + "type": "gauge" + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${ds}", + "description": "monitor system cpu", + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 12, + "x": 0, + "y": 38 + }, + "hiddenSeries": false, + "hideTimeOverride": true, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "cpu_system", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(cpu_system) from log.dn where fqdn='$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "cpu_taosd", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(cpu_taosd) from log.dn where fqdn='$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": "1h", + "timeRegions": [], + "timeShift": "30s", + "title": "CPU 资源占用情况", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:58", + "decimals": null, + "format": "percent", + "label": "使用占比", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:59", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${ds}", + "description": "monitor system cpu", + "fieldConfig": { + "defaults": { + "links": [] + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 12, + "x": 12, + "y": 38 + }, + "hiddenSeries": false, + "hideTimeOverride": true, + "id": 42, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "system", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(mem_system) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "taosd", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(mem_taosd) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "total", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "C", + "sql": "select avg(mem_total) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(30s)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": "1h", + "timeRegions": [], + "timeShift": "30s", + "title": "内存资源占用情况", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:58", + "decimals": null, + "format": "decmbytes", + "label": "使用占比", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:59", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "unit": "percent" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 49 + }, + "hiddenSeries": false, + "id": 54, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "seriesOverrides": [ + { + "$$hashKey": "object:249", + "alias": "disk_used", + "hiddenSeries": true + }, + { + "$$hashKey": "object:256", + "alias": "disk_total", + "hiddenSeries": true + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "disk_used", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(disk_used) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(30s)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "disk_total", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(disk_total) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(30s)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "percent", + "expression": "A/B * 100", + "formatType": "Time series", + "hide": false, + "queryType": "Arithmetic", + "refId": "C", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Disk Used Percent", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:456", + "format": "percent", + "label": null, + "logBase": 1, + "max": "100", + "min": "0", + "show": true + }, + { + "$$hashKey": "object:457", + "format": "percentunit", + "label": "Disk Used", + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${ds}", + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 49 + }, + "hiddenSeries": false, + "id": 64, + "legend": { + "alignAsTable": false, + "avg": false, + "current": true, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "seriesOverrides": [ + { + "$$hashKey": "object:834", + "alias": "percent", + "yaxis": 2 + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "disk_used", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(disk_used) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(30s)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "disk_total", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(disk_total) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(30s)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "percent", + "expression": "A/B", + "formatType": "Time series", + "hide": false, + "queryType": "Arithmetic", + "refId": "C", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Disk Used", + "tooltip": { + "shared": false, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:456", + "format": "decgbytes", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:457", + "format": "percentunit", + "label": "Disk Used", + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${ds}", + "description": "total select request per minute last hour", + "fieldConfig": { + "defaults": { + "unit": "cpm" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 0, + "y": 58 + }, + "hiddenSeries": false, + "id": 8, + "interval": null, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "maxDataPoints": 100, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "req_select", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select sum(req_select) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "timeshift": { + "period": null + }, + "type": "timeserie" + }, + { + "alias": "req_insert", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select sum(req_insert) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "req_http", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "C", + "sql": "select sum(req_http) from log.dn where fqdn = '$fqdn' and ts >= $from and ts < $to interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Requets Count per Minutes $fqdn", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:127", + "format": "cpm", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "$$hashKey": "object:128", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "${ds}", + "description": "io", + "fieldConfig": { + "defaults": { + "links": [], + "unit": "Kbits" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 9, + "w": 12, + "x": 12, + "y": 58 + }, + "hiddenSeries": false, + "hideTimeOverride": true, + "id": 47, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "scopedVars": { + "fqdn": { + "selected": true, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + } + }, + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "io-read", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "A", + "sql": "select avg(io_read) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "io-write", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "B", + "sql": "select avg(io_write) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "io-read-last-hour", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "C", + "sql": "select avg(io_read) from log.dn where fqdn = '$fqdn' and ts >= now-2h and ts < now - 1h interval(1m)", + "target": "select metric", + "timeshift": { + "period": 1, + "unit": "hours" + }, + "type": "timeserie" + }, + { + "alias": "io-write-last-hour", + "formatType": "Time series", + "hide": false, + "queryType": "SQL", + "refId": "D", + "sql": "select avg(io_write) from log.dn where fqdn = '$fqdn' and ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "timeshift": { + "period": 1, + "unit": "hours" + }, + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": "1h", + "timeRegions": [], + "timeShift": "30s", + "title": "IO", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:58", + "decimals": null, + "format": "Kbits", + "label": "使用占比", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:59", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "collapsed": false, + "datasource": null, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 67 + }, + "id": 63, + "panels": [], + "title": "Login History", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${ds}", + "fieldConfig": { + "defaults": { + "displayName": "Logins Per Minute", + "unit": "cpm" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 68 + }, + "hiddenSeries": false, + "id": 61, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "7.5.10", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "$$hashKey": "object:756", + "alias": "logins", + "nullPointMode": "null as zero" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "logins", + "formatType": "Time series", + "queryType": "SQL", + "refId": "A", + "sql": "select count(*) from log.log where ts >= $from and ts < $to interval (1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Login Counts per Minute", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:585", + "format": "cpm", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:586", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "1m", + "schemaVersion": 27, + "style": "dark", + "tags": [ + "TDengine" + ], + "templating": { + "list": [ + { + "current": { + "selected": true, + "text": "TDengine", + "value": "TDengine" + }, + "description": "TDengine Data Source Selector", + "error": null, + "hide": 0, + "includeAll": false, + "label": "Datasource", + "multi": false, + "name": "ds", + "options": [], + "query": "tdengine-datasource", + "queryValue": "", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, + { + "allValue": null, + "current": { + "selected": false, + "text": "huolinhe-TM1701:6030", + "value": "huolinhe-TM1701:6030" + }, + "datasource": "${ds}", + "definition": "select fqdn from log.dn", + "description": "TDengine Nodes FQDN (Hostname)", + "error": null, + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "fqdn", + "options": [], + "query": "select fqdn from log.dn", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "TDengine", + "uid": "tdengine", + "version": 8 +} \ No newline at end of file diff --git a/docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana.json b/docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana.json new file mode 100644 index 0000000000000000000000000000000000000000..7696cfce3fcca3dd5f9278c91d3df2c1b32b9c97 --- /dev/null +++ b/docs-cn/14-reference/07-tdinsight/assets/tdengine-grafana.json @@ -0,0 +1,627 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 3, + "links": [], + "panels": [ + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"], + "datasource": "TDengine", + "description": "total select request per minute last hour", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 8, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "次数/min", + "postfixFontSize": "20%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": true, + "lineColor": "rgb(31, 120, 193)", + "show": true, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "alias": "req_select", + "refId": "A", + "sql": "select sum(req_select) from log.dn where ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": "120,240", + "timeFrom": null, + "timeShift": null, + "title": "req select", + "type": "singlestat", + "valueFontSize": "150%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "total" + }, + { + "cacheTimeout": null, + "colorBackground": false, + "colorValue": true, + "colors": ["#299c46", "rgba(237, 129, 40, 0.89)", "#d44a3a"], + "datasource": "TDengine", + "description": "total insert request per minute for last hour", + "format": "none", + "gauge": { + "maxValue": 100, + "minValue": 0, + "show": false, + "thresholdLabels": false, + "thresholdMarkers": true + }, + "gridPos": { + "h": 6, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 6, + "interval": null, + "links": [], + "mappingType": 1, + "mappingTypes": [ + { + "name": "value to text", + "value": 1 + }, + { + "name": "range to text", + "value": 2 + } + ], + "maxDataPoints": 100, + "nullPointMode": "connected", + "nullText": null, + "options": {}, + "postfix": "次数/min", + "postfixFontSize": "20%", + "prefix": "", + "prefixFontSize": "50%", + "rangeMaps": [ + { + "from": "null", + "text": "N/A", + "to": "null" + } + ], + "sparkline": { + "fillColor": "rgba(31, 118, 189, 0.18)", + "full": false, + "lineColor": "rgb(31, 120, 193)", + "show": true, + "ymax": null, + "ymin": null + }, + "tableColumn": "", + "targets": [ + { + "alias": "req_insert", + "refId": "A", + "sql": "select sum(req_insert) from log.dn where ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": "110,240", + "timeFrom": null, + "timeShift": null, + "title": "req insert", + "type": "singlestat", + "valueFontSize": "150%", + "valueMaps": [ + { + "op": "=", + "text": "N/A", + "value": "null" + } + ], + "valueName": "total" + }, + { + "datasource": "TDengine", + "description": "taosd max memery last 10 minutes", + "gridPos": { + "h": 6, + "w": 8, + "x": 0, + "y": 6 + }, + "id": 12, + "options": { + "fieldOptions": { + "calcs": ["mean"], + "defaults": { + "mappings": [], + "max": 4096, + "min": 0, + "thresholds": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + }, + { + "color": "#EAB839", + "value": 2048 + } + ], + "unit": "decmbytes" + }, + "thresholds": [ + { + "index": 0, + "color": "green", + "value": null + }, + { + "index": 1, + "color": "red", + "value": 80 + }, + { + "index": 2, + "color": "#EAB839", + "value": 2048 + } + ], + "override": {}, + "values": false + }, + "orientation": "auto", + "showThresholdLabels": true, + "showThresholdMarkers": true + }, + "pluginVersion": "6.4.3", + "targets": [ + { + "alias": "mem_taosd", + "refId": "A", + "sql": "select max(mem_taosd) from log.dn where ts >= now -10m and ts < now", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "taosd memery", + "type": "gauge" + }, + { + "datasource": "TDengine", + "description": "max System Memory last 1 hour", + "gridPos": { + "h": 6, + "w": 8, + "x": 8, + "y": 6 + }, + "id": 10, + "options": { + "fieldOptions": { + "calcs": ["last"], + "mappings": [], + "defaults": { + "mappings": [], + "max": 4, + "min": 0, + "thresholds": [ + { + "color": "green", + "value": null + }, + { + "color": "semi-dark-orange", + "value": 60 + }, + { + "color": "dark-red", + "value": 80 + } + ], + "title": "", + "unit": "decmbytes" + }, + "thresholds": [ + { + "index": 0, + "color": "green", + "value": null + }, + { + "index": 1, + "color": "semi-dark-orange", + "value": 60 + }, + { + "index": 2, + "color": "dark-red", + "value": 80 + } + ], + "override": {}, + "values": false + }, + "orientation": "auto", + "showThresholdLabels": true, + "showThresholdMarkers": true + }, + "pluginVersion": "6.4.3", + "targets": [ + { + "alias": "mem_system", + "refId": "A", + "sql": "select max(mem_system) from log.dn where ts >= now -10h and ts < now", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "system memory", + "type": "gauge" + }, + { + "datasource": "TDengine", + "description": "avg band speed last one minute", + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 6 + }, + "id": 14, + "options": { + "fieldOptions": { + "calcs": ["last"], + "defaults": { + "mappings": [], + "max": 8192, + "min": 0, + "thresholds": [ + { + "color": "green", + "value": null + }, + { + "color": "#EAB839", + "value": 4916 + }, + { + "color": "red", + "value": 6554 + } + ], + "unit": "Kbits" + }, + "mappings": [], + "thresholds": [ + { + "index": 0, + "color": "green", + "value": null + }, + { + "index": 1, + "color": "#EAB839", + "value": 4916 + }, + { + "index": 2, + "color": "red", + "value": 6554 + } + ], + "override": {}, + "values": false + }, + "orientation": "auto", + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "6.4.3", + "targets": [ + { + "alias": "band_speed", + "refId": "A", + "sql": "select avg(band_speed) from log.dn where ts >= now-1h and ts < now interval(1m)", + "target": "select metric", + "type": "timeserie" + } + ], + "timeFrom": null, + "timeShift": null, + "title": "band speed", + "type": "gauge" + }, + { + "aliasColors": {}, + "bars": false, + "cacheTimeout": null, + "dashLength": 10, + "dashes": false, + "datasource": "TDengine", + "description": "monitor system cpu", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 12, + "x": 0, + "y": 12 + }, + "hideTimeOverride": true, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pluginVersion": "6.4.3", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "cpu_system11", + "hide": false, + "refId": "A", + "sql": "select avg(cpu_system) from log.dn where ts >= now-1h and ts < now interval(1s)", + "target": "select metric", + "type": "timeserie" + }, + { + "alias": "cpu_taosd", + "hide": false, + "refId": "B", + "sql": "select avg(cpu_taosd) from log.dn where ts >= now-1h and ts < now interval(1s)", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": "1h", + "timeRegions": [], + "timeShift": "30s", + "title": "cpu_system", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": null, + "format": "percent", + "label": "使用占比", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "TDengine", + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 12, + "x": 12, + "y": 12 + }, + "id": 18, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "", + "refId": "A", + "sql": "select avg(disk_used) disk_used from log.dn where ts >= $from and ts < $to interval(1s) group by fqdn", + "target": "select metric", + "type": "timeserie" + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "avg_disk_used", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "decgbytes", + "label": "", + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 20, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-1h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "TDengine", + "uid": "FE-vpe0Wk", + "version": 1 +} diff --git a/docs-cn/14-reference/07-tdinsight/assets/tdengine_dashboard.png b/docs-cn/14-reference/07-tdinsight/assets/tdengine_dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..0101e7430cb2ef673818de8bd3af53d0d082ad3f Binary files /dev/null and b/docs-cn/14-reference/07-tdinsight/assets/tdengine_dashboard.png differ diff --git a/docs-cn/14-reference/07-tdinsight/index.md b/docs-cn/14-reference/07-tdinsight/index.md new file mode 100644 index 0000000000000000000000000000000000000000..553ae48b285f39a1fb29ebe946cb9b949adf9664 --- /dev/null +++ b/docs-cn/14-reference/07-tdinsight/index.md @@ -0,0 +1,427 @@ +--- +title: TDinsight - 基于Grafana的TDengine零依赖监控解决方案 +sidebar_label: TDinsight +--- + +TDinsight 是使用 [TDengine] 原生监控数据库和 [Grafana] 对 TDengine 进行监控的解决方案。 + +TDengine 启动后,会自动创建一个监测数据库 log,并自动将服务器的 CPU、内存、硬盘空间、带宽、请求数、磁盘读写速度、慢查询等信息定时写入该数据库,并对重要的系统操作(比如登录、创建、删除数据库等)以及各种错误报警信息进行记录。通过 [Grafana] 和 [TDengine 数据源插件](https://github.com/taosdata/grafanaplugin/releases),TDinsight 将集群状态、节点信息、插入及查询请求、资源使用情况等进行可视化展示,同时还支持 vnode、dnode、mnode 节点状态异常告警,为开发者实时监控 TDengine 集群运行状态提供了便利。本文将指导用户安装 Grafana 服务器并通过 `TDinsight.sh` 安装脚本自动安装 TDengine 数据源插件及部署 TDinsight 可视化面板。 + +## 系统要求 + +要部署 TDinsight,需要一个单节点的 TDengine 服务器或一个多节点的 [TDengine] 集群,以及一个[Grafana]服务器。此仪表盘需要 TDengine 2.3.3.0 及以上,并启用 `log` 数据库(`monitor = 1`)。 + +## 安装 Grafana + +我们建议在此处使用最新的[Grafana] 7 或 8 版本。您可以在任何[支持的操作系统](https://grafana.com/docs/grafana/latest/installation/requirements/#supported-operating-systems)中,按照 [Grafana 官方文档安装说明](https://grafana.com/docs/grafana/latest/installation/) 安装 [Grafana]。 + +### 在 Debian 或 Ubuntu 上安装 Grafana + +对于 Debian 或 Ubuntu 操作系统,建议使用 Grafana 镜像仓库。使用如下命令从零开始安装: + +```bash +sudo apt-get install -y apt-transport-https +sudo apt-get install -y software-properties-common wget +wget -q -O - https://packages.grafana.com/gpg.key |\ + sudo apt-key add - +echo "deb https://packages.grafana.com/oss/deb stable main" |\ + sudo tee -a /etc/apt/sources.list.d/grafana.list +sudo apt-get update +sudo apt-get install grafana +``` + +### 在 CentOS / RHEL 上安装 Grafana + +您可以从官方 YUM 镜像仓库安装。 + +```bash +sudo tee /etc/yum.repos.d/grafana.repo << EOF +[grafana] +name=grafana +baseurl=https://packages.grafana.com/oss/rpm +repo_gpgcheck=1 +enabled=1 +gpgcheck=1 +gpgkey=https://packages.grafana.com/gpg.key +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt +EOF +sudo yum install grafana +``` + +或者用 RPM 安装: + +```bash +wget https://dl.grafana.com/oss/release/grafana-7.5.11-1.x86_64.rpm +sudo yum install grafana-7.5.11-1.x86_64.rpm +# or +sudo yum install \ + https://dl.grafana.com/oss/release/grafana-7.5.11-1.x86_64.rpm +``` + +## 自动部署 TDinsight + +我们提供了一个自动化安装脚本 [`TDinsight.sh`](https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh) 脚本以便用户快速进行安装配置。 + +您可以通过 `wget` 或其他工具下载该脚本: + +```bash +wget https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh +chmod +x TDinsight.sh +``` + +这个脚本会自动下载最新的[Grafana TDengine 数据源插件](https://github.com/taosdata/grafanaplugin/releases/latest) 和 [TDinsight 仪表盘](https://grafana.com/grafana/dashboards/15167) ,将命令行选项中的可配置参数转为 [Grafana Provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/) 配置文件,以进行自动化部署及更新等操作。利用该脚本提供的告警设置选项,你还可以获得内置的阿里云短信告警通知支持。 + +假设您在同一台主机上使用 TDengine 和 Grafana 的默认服务。运行 `./TDinsight.sh` 并打开 Grafana 浏览器窗口就可以看到 TDinsight 仪表盘了。 + +下面是 TDinsight.sh 的用法说明: + +```bash +Usage: + ./TDinsight.sh + ./TDinsight.sh -h|--help + ./TDinsight.sh -n -a -u -p + +Install and configure TDinsight dashboard in Grafana on ubuntu 18.04/20.04 system. + +-h, -help, --help Display help + +-V, -verbose, --verbose Run script in verbose mode. Will print out each step of execution. + +-v, --plugin-version TDengine datasource plugin version, [default: latest] + +-P, --grafana-provisioning-dir Grafana provisioning directory, [default: /etc/grafana/provisioning/] +-G, --grafana-plugins-dir Grafana plugins directory, [default: /var/lib/grafana/plugins] +-O, --grafana-org-id Grafana orgnization id. [default: 1] + +-n, --tdengine-ds-name TDengine datasource name, no space. [default: TDengine] +-a, --tdengine-api TDengine REST API endpoint. [default: http://127.0.0.1:6041] +-u, --tdengine-user TDengine user name. [default: root] +-p, --tdengine-password TDengine password. [default: taosdata] + +-i, --tdinsight-uid Replace with a non-space ascii code as the dashboard id. [default: tdinsight] +-t, --tdinsight-title Dashboard title. [default: TDinsight] +-e, --tdinsight-editable If the provisioning dashboard could be editable. [default: false] + +-E, --external-notifier Apply external notifier uid to TDinsight dashboard. + +Aliyun SMS as Notifier: +-s, --sms-enabled To enable tdengine-datasource plugin builtin aliyun sms webhook. +-N, --sms-notifier-name Provisioning notifier name.[default: TDinsight Builtin SMS] +-U, --sms-notifier-uid Provisioning notifier uid, use lowercase notifier name by default. +-D, --sms-notifier-is-default Set notifier as default. +-I, --sms-access-key-id Aliyun sms access key id +-K, --sms-access-key-secret Aliyun sms access key secret +-S, --sms-sign-name Sign name +-C, --sms-template-code Template code +-T, --sms-template-param Template param, a escaped json string like '{"alarm_level":"%s","time":"%s","name":"%s","content":"%s"}' +-B, --sms-phone-numbers Comma-separated numbers list, eg "189xxxxxxxx,132xxxxxxxx" +-L, --sms-listen-addr [default: 127.0.0.1:9100] +``` + +大多数命令行选项都可以通过环境变量获得同样的效果。 + +| 短选项 | 长选项 | 环境变量 | 说明 | +| ------ | -------------------------- | ---------------------------- | --------------------------------------------------------------------------- | +| -v | --plugin-version | TDENGINE_PLUGIN_VERSION | TDengine 数据源插件版本,默认使用最新版。 | +| -P | --grafana-provisioning-dir | GF_PROVISIONING_DIR | Grafana 配置目录,默认为`/etc/grafana/provisioning/` | +| -G | --grafana-plugins-dir | GF_PLUGINS_DIR | Grafana 插件目录,默认为`/var/lib/grafana/plugins`。 | +| -O | --grafana-org-id | GF_ORG_ID | Grafana 组织 ID,默认为 1。 | +| -n | --tdengine-ds-name | TDENGINE_DS_NAME | TDengine 数据源名称,默认为 TDengine。 | +| -a | --tdengine-api | TDENGINE_API | TDengine REST API 端点。默认为`http://127.0.0.1:6041`。 | +| -u | --tdengine-user | TDENGINE_USER | TDengine 用户名。 [默认值:root] | +| -p | --tdengine-密码 | TDENGINE_PASSWORD | TDengine 密码。 [默认:taosdata] | +| -i | --tdinsight-uid | TDINSIGHT_DASHBOARD_UID | TDinsight 仪表盘`uid`。 [默认值:tdinsight] | +| -t | --tdinsight-title | TDINSIGHT_DASHBOARD_TITLE | TDinsight 仪表盘标题。 [默认:TDinsight] | +| -e | --tdinsight-可编辑 | TDINSIGHT_DASHBOARD_EDITABLE | 如果配置仪表盘可以编辑。 [默认值:false] | +| -E | --external-notifier | EXTERNAL_NOTIFIER | 将外部通知程序 uid 应用于 TDinsight 仪表盘。 | +| -s | --sms-enabled | SMS_ENABLED | 启用阿里云短信 webhook 内置的 tdengine-datasource 插件。 | +| -N | --sms-notifier-name | SMS_NOTIFIER_NAME | 供应通知程序名称。[默认:`TDinsight Builtin SMS`] | +| -U | --sms-notifier-uid | SMS_NOTIFIER_UID | "Notification Channel" `uid`,默认使用程序名称的小写,其他字符用 “-” 代替。 | +| -D | --sms-notifier-is-default | SMS_NOTIFIER_IS_DEFAULT | 将内置短信通知设置为默认值。 | +| -I | --sms-access-key-id | SMS_ACCESS_KEY_ID | 阿里云短信访问密钥 id | +| -K | --sms-access-key-secret | SMS_ACCESS_KEY_SECRET | 阿里云短信访问秘钥 | +| -S | --sms-sign-name | SMS_SIGN_NAME | 签名 | +| -C | --sms-template-code | SMS_TEMPLATE_CODE | 模板代码 | +| -T | --sms-template-param | SMS_TEMPLATE_PARAM | 模板参数的 JSON 模板 | +| -B | --sms-phone-numbers | SMS_PHONE_NUMBERS | 逗号分隔的手机号列表,例如`"189xxxxxxxx,132xxxxxxxx"` | +| -L | --sms-listen-addr | SMS_LISTEN_ADDR | 内置 sms webhook 监听地址,默认为`127.0.0.1:9100` | + +假设您在主机 `tdengine` 上启动 TDengine 数据库,HTTP API 端口为 `6041`,用户为 `root1`,密码为 `pass5ord`。执行脚本: + +```bash +sudo ./TDinsight.sh -a http://tdengine:6041 -u root1 -p pass5ord +``` + +我们提供了一个“-E”选项,用于从命令行配置 TDinsight 使用现有的通知通道(Notification Channel)。假设你的 Grafana 用户和密码是 `admin:admin`,使用以下命令获取已有的通知通道的`uid`: + +```bash +curl --no-progress-meter -u admin:admin http://localhost:3000/api/alert-notifications | jq +``` + +使用上面获取的 `uid` 值作为 `-E` 输入。 + +```bash +sudo ./TDinsight.sh -a http://tdengine:6041 -u root1 -p pass5ord -E existing-notifier +``` + +如果你想使用[阿里云短信](https://www.aliyun.com/product/sms)服务作为通知渠道,你应该使用`-s`标志启用并添加以下参数: + +- `-N`:Notification Channel 名,默认为`TDinsight Builtin SMS`。 +- `-U`:Channel uid,默认是 `name` 的小写,任何其他字符都替换为 - ,对于默认的 `-N`,其 uid 为 `tdinsight-builtin-sms`。 +- `-I`:阿里云短信访问密钥 id。 +- `-K`:阿里云短信访问秘钥。 +- `-S`:阿里云短信签名。 +- `-C`:阿里云短信模板 ID。 +- `-T`:阿里云短信模板参数,为 JSON 格式模板,示例如下 `'{"alarm_level":"%s","time":"%s","name":"%s","content":"%s "}'`。有四个参数:告警级别、时间、名称和告警内容。 +- `-B`:电话号码列表,以逗号`,`分隔。 + +如果要监控多个 TDengine 集群,则需要设置多个 TDinsight 仪表盘。设置非默认 TDinsight 需要进行一些更改: `-n` `-i` `-t` 选项需要更改为非默认名称,如果使用 内置短信告警功能,`-N` 和 `-L` 也应该改变。 + +```bash +sudo ./TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata -i tdinsight-env1 -t 'TDinsight Env1' +# 如果使用内置短信通知 +sudo ./TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata -i tdinsight-env1 -t 'TDinsight Env1' \ + -s -N 'Env1 SMS' -I xx -K xx -S xx -C SMS_XX -T '' -B 00000000000 -L 127.0.0.01:10611 +``` + +请注意,配置数据源、通知 Channel 和仪表盘在前端是不可更改的。您应该再次通过此脚本更新配置或手动更改 `/etc/grafana/provisioning` 目录(这是 Grafana 的默认目录,根据需要使用`-P`选项更改)中的配置文件。 + +特别地,当您使用 Grafana Cloud 或其他组织时,`-O` 可用于设置组织 ID。 `-G` 可指定 Grafana 插件安装目录。 `-e` 参数将仪表盘设置为可编辑。 + +## 手动设置 TDinsight + +### 安装 TDengine 数据源插件 + +从 GitHub 安装 TDengine 最新版数据源插件。 + +```bash +get_latest_release() { + curl --silent "https://api.github.com/repos/taosdata/grafanaplugin/releases/latest" | + grep '"tag_name":' | + sed -E 's/.*"v([^"]+)".*/\1/' +} +TDENGINE_PLUGIN_VERSION=$(get_latest_release) +sudo grafana-cli \ + --pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v$TDENGINE_PLUGIN_VERSION/tdengine-datasource-$TDENGINE_PLUGIN_VERSION.zip \ + plugins install tdengine-datasource +``` + +### 配置 Grafana + +将以下设置添加到配置文件 `/etc/grafana/grafana.ini`,以启用未签名插件。 + +```ini +[plugins] +allow_loading_unsigned_plugins = tdengine-datasource +``` + +### 启动 Grafana 服务 + +```bash +sudo systemctl start grafana-server +sudo systemctl enable grafana-server +``` + +### 登录到 Grafana + +在 Web 浏览器中打开默认的 Grafana 网址:`http://localhost:3000`。 +默认用户名/密码都是 `admin`。Grafana 会要求在首次登录后更改密码。 + +### 添加 TDengine 数据源 + +指向 **Configurations** -> **Data Sources** 菜单,然后点击 **Add data source** 按钮。 + +![添加数据源按钮](./assets/howto-add-datasource-button.png) + +搜索并选择**TDengine**。 + +![添加数据源](./assets/howto-add-datasource-tdengine.png) + +配置 TDengine 数据源。 + +![数据源配置](./assets/howto-add-datasource.png) + +保存并测试,正常情况下会报告 'TDengine Data source is working'。 + +![数据源测试](./assets/howto-add-datasource-test.png) + +### 导入仪表盘 + +指向 **+** / **Create** - **import**(或 `/dashboard/import` url)。 + +![导入仪表盘和配置](./assets/import_dashboard.png) + +在 **Import via grafana.com** 位置键入仪表盘 ID `15167` 并 **Load**。 + +![通过 grafana.com 导入](./assets/import-dashboard-15167.png) + +导入完成后,TDinsight 的完整页面视图如下所示。 + +![显示](./assets/TDinsight-full.png) + +## TDinsight 仪表盘详细信息 + +TDinsight 仪表盘旨在提供 TDengine 相关资源使用情况[dnodes, mdodes, vnodes](https://www.taosdata.com/cn/documentation/architecture#cluster)或数据库的使用情况和状态。 + +指标详情如下: + +### 集群状态 + +![tdinsight-mnodes-overview](./assets/TDinsight-1-cluster-status.png) + +这部分包括集群当前信息和状态,告警信息也在此处(从左到右,从上到下)。 + +- **First EP**:当前 TDengine 集群中的`firstEp`设置。 +- **Version**:TDengine 服务器版本(master mnode)。 +- **Master Uptime**: 当前 Master MNode 被选举为 Master 后经过的时间。 +- **Expire Time** - 企业版过期时间。 +- **Used Measuring Points** - 企业版已使用的测点数。 +- **Databases** - 数据库个数。 +- **Connections** - 当前连接个数。 +- **DNodes/MNodes/VGroups/VNodes**:每种资源的总数和存活数。 +- **DNodes/MNodes/VGroups/VNodes Alive Percent**:每种资源的存活数/总数的比例,启用告警规则,并在资源存活率(1 分钟内平均健康资源比例)不足 100%时触发。 +- **Messuring Points Used**:启用告警规则的测点数用量(社区版无数据,默认情况下是健康的)。 +- **Grants Expire Time**:启用告警规则的企业版过期时间(社区版无数据,默认情况是健康的)。 +- **Error Rate**:启用警报的集群总合错误率(每秒平均错误数)。 +- **Variables**:`show variables` 表格展示。 + +### DNodes 状态 + +![tdinsight-mnodes-overview](./assets/TDinsight-2-dnodes.png) + +- **DNodes Status**:`show dnodes` 的简单表格视图。 +- **DNodes Lifetime**:从创建 dnode 开始经过的时间。 +- **DNodes Number**:DNodes 数量变化。 +- **Offline Reason**:如果有任何 dnode 状态为离线,则以饼图形式展示离线原因。 + +### MNode 概述 + +![tdinsight-mnodes-overview](./assets/TDinsight-3-mnodes.png) + +1. **MNodes Status**:`show mnodes` 的简单表格视图。 +2. **MNodes Number**:类似于`DNodes Number`,MNodes 数量变化。 + +### 请求 + +![tdinsight-requests](./assets/TDinsight-4-requests.png) + +1. **Requests Rate(Inserts per Second)**:平均每秒插入次数。 +2. **Requests (Selects)**:查询请求数及变化率(count of second)。 +3. **Requests (HTTP)**:HTTP 请求数和请求速率(count of second)。 + +### 数据库 + +![tdinsight-database](./assets/TDinsight-5-database.png) + +数据库使用情况,对变量 `$database` 的每个值即每个数据库进行重复多行展示。 + +1. **STables**:超级表数量。 +2. **Total Tables**:所有表数量。 +3. **Sub Tables**:所有超级表子表的数量。 +4. **Tables**:所有普通表数量随时间变化图。 +5. **Tables Number Foreach VGroups**:每个 VGroups 包含的表数量。 + +### DNode 资源使用情况 + +![dnode-usage](./assets/TDinsight-6-dnode-usage.png) + +数据节点资源使用情况展示,对变量 `$fqdn` 即每个数据节点进行重复多行展示。包括: + +1. **Uptime**:从创建 dnode 开始经过的时间。 +2. **Has MNodes?**:当前 dnode 是否为 mnode。 +3. **CPU Cores**:CPU 核数。 +4. **VNodes Number**:当前 dnode 的 VNodes 数量。 +5. **VNodes Masters**:处于 master 角色的 vnode 数量。 +6. **Current CPU Usage of taosd**:taosd 进程的 CPU 使用率。 +7. **Current Memory Usage of taosd**:taosd 进程的内存使用情况。 +8. **Disk Used**:taosd 数据目录的总磁盘使用百分比。 +9. **CPU Usage**:进程和系统 CPU 使用率。 +10. **RAM Usage**:RAM 使用指标时间序列视图。 +11. **Disk Used**:多级存储下每个级别使用的磁盘(默认为 level0 级)。 +12. **Disk Increasing Rate per Minute**:每分钟磁盘用量增加或减少的百分比。 +13. **Disk IO**:磁盘 IO 速率。 +14. **Net IO**:网络 IO,除本机网络之外的总合网络 IO 速率。 + +### 登录历史 + +![登录历史](./assets/TDinsight-7-login-history.png) + +目前只报告每分钟登录次数。 + +### TaosAdapter + +![taosadapter](./assets/TDinsight-8-taosadaper.png) + +包含 taosAdapter 请求统计和状态详情。包括: + +1. **http_request**: 包含总请求数,请求失败数以及正在处理的请求数 +2. **top 3 request endpoint**: 按终端分组,请求排名前三的数据 +3. **Memory Used**: taosAdapter 内存使用情况 +4. **latency_quantile(ms)**: (1, 2, 5, 9, 99)阶段的分位数 +5. **top 3 failed request endpoint**: 按终端分组,请求失败排名前三的数据 +6. **CPU Used**: taosAdapter cpu 使用情况 + +## 升级 + +通过 `TDinsight.sh` 脚本安装的 TDinsight,可以通过重新运行该脚本就可以升级到最新的 Grafana 插件和 TDinsight Dashboard。 + +手动安装的情况下,可按照上述步骤自行安装新的 Grafana 插件和 Dashboard。 + +## 卸载 + +通过 `TDinsight.sh` 脚本安装的 TDinsight,可以使用命令行 `TDinsight.sh -R` 清理相关资源。 + +手动安装时,要完全卸载 TDinsight,需要清理以下内容: + +1. Grafana 中的 TDinsight Dashboard。 +2. Grafana 中的 Data Source 数据源。 +3. 从插件安装目录删除 `tdengine-datasource` 插件。 + +## 整合的 Docker 示例 + +```bash +git clone --depth 1 https://github.com/taosdata/grafanaplugin.git +cd grafanaplugin +``` + +根据需要在 `docker-compose.yml` 文件中修改: + +```yaml +version: "3.7" + +services: + grafana: + image: grafana/grafana:7.5.10 + volumes: + - ./dist:/var/lib/grafana/plugins/tdengine-datasource + - ./grafana/grafana.ini:/etc/grafana/grafana.ini + - ./grafana/provisioning/:/etc/grafana/provisioning/ + - grafana-data:/var/lib/grafana + environment: + TDENGINE_API: ${TDENGINE_API} + TDENGINE_USER: ${TDENGINE_USER} + TDENGINE_PASS: ${TDENGINE_PASS} + SMS_ACCESS_KEY_ID: ${SMS_ACCESS_KEY_ID} + SMS_ACCESS_KEY_SECRET: ${SMS_ACCESS_KEY_SECRET} + SMS_SIGN_NAME: ${SMS_SIGN_NAME} + SMS_TEMPLATE_CODE: ${SMS_TEMPLATE_CODE} + SMS_TEMPLATE_PARAM: "${SMS_TEMPLATE_PARAM}" + SMS_PHONE_NUMBERS: $SMS_PHONE_NUMBERS + SMS_LISTEN_ADDR: ${SMS_LISTEN_ADDR} + ports: + - 3000:3000 +volumes: + grafana-data: +``` + +替换`docker-compose.yml`中的环境变量或保存环境变量到`.env`文件,然后用`docker-compose up`启动 Grafana。`docker-compose` 工具的具体用法参见 [Docker Compose Reference](https://docs.docker.com/compose/) + +```bash +docker-compose up -d +``` + +TDinsight 已经通过 Provisioning 部署完毕,请到 http://localhost:3000/d/tdinsight/ 查看仪表盘。 + +[grafana]: https://grafana.com +[tdengine]: https://www.taosdata.com diff --git a/docs-cn/14-reference/08-server-config/_category_.yml b/docs-cn/14-reference/08-server-config/_category_.yml deleted file mode 100644 index e05fbeb578ceb525ae80f3d50c3e018df13bfa56..0000000000000000000000000000000000000000 --- a/docs-cn/14-reference/08-server-config/_category_.yml +++ /dev/null @@ -1 +0,0 @@ -label: 服务端配置 \ No newline at end of file diff --git a/docs-cn/14-reference/08-taos-shell.md b/docs-cn/14-reference/08-taos-shell.md new file mode 100644 index 0000000000000000000000000000000000000000..c9167fcf2643954981925fb5ef67a60cbad97a6d --- /dev/null +++ b/docs-cn/14-reference/08-taos-shell.md @@ -0,0 +1,85 @@ +--- +title: TDengine 命令行(CLI) +sidebar_label: TDengine CLI +description: TDengine CLI 的使用说明和技巧 +--- + +TDengine 命令行程序(以下简称 TDengine CLI)是用户操作 TDengine 实例并与之交互的最简洁最常用的方式。 + +## 安装 + +如果在 TDengine 服务器端执行,无需任何安装,已经自动安装好。如果要在非 TDengine 服务器端运行,需要安装 TDengine 客户端驱动,具体安装,请参考 [连接器](/reference/connector/)。 + +## 执行 + +要进入 TDengine CLI,您只要在 Linux 终端或Windos 终端执行 `taos` 即可。 + +```bash +taos +``` +如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。TDengine CLI 的提示符号如下: + +```cmd +taos> +``` +进入CLI后,你可执行各种SQL语句,包括插入、查询以及各种管理命令。 + +## 执行 SQL 脚本 + +在 TDengine CLI 里可以通过 `source` 命令来运行 SQL 命令脚本。 + +```sql +taos> source ; +``` + +## 在线修改显示字符宽度 + +可以在 TDengine CLI 里使用如下命令调整字符显示宽度 + +```sql +taos> SET MAX_BINARY_DISPLAY_WIDTH ; +``` + +如显示的内容后面以...结尾时,表示该内容已被截断,可通过本命令修改显示字符宽度以显示完整的内容。 + +## 命令行参数 + +您可通过配置命令行参数来改变 TDengine CLI 的行为。以下为常用的几个命令行参数: + +- -h, --host=HOST: 要连接的 TDengine 服务端所在服务器的 FQDN, 默认为连接本地服务 +- -P, --port=PORT: 指定服务端所用端口号 +- -u, --user=USER: 连接时使用的用户名 +- -p, --password=PASSWORD: 连接服务端时使用的密码 +- -?, --help: 打印出所有命令行参数 + +还有更多其他参数: + +- -c, --config-dir: 指定配置文件目录,默认为 `/etc/taos`,该目录下的配置文件默认名称为 taos.cfg +- -C, --dump-config: 打印 -c 指定的目录中 taos.cfg 的配置参数 +- -d, --database=DATABASE: 指定连接到服务端时使用的数据库 +- -D, --directory=DIRECTORY: 导入指定路径中的 SQL 脚本文件 +- -f, --file=FILE: 以非交互模式执行 SQL 脚本文件 +- -k, --check=CHECK: 指定要检查的表 +- -l, --pktlen=PKTLEN: 网络测试时使用的测试包大小 +- -n, --netrole=NETROLE: 网络连接测试时的测试范围,默认为 startup, 可选值为 client, server, rpc, startup, sync, speed, fqdn +- -r, --raw-time: 将时间输出出 uint64_t +- -s, --commands=COMMAND: 以非交互模式执行的 SQL 命令 +- -S, --pkttype=PKTTYPE: 指定网络测试所用的包类型,默认为 TCP。只有 netrole 为 speed 时既可以指定为 TCP 也可以指定为 UDP +- -T, --thread=THREADNUM: 以多线程模式导入数据时的线程数 +- -s, --commands: 在不进入终端的情况下运行 TDengine 命令 +- -z, --timezone=TIMEZONE: 指定时区,默认为本地 +- -V, --version: 打印出当前版本号 + +示例: + +```bash +taos -h h1.taos.com -s "use db; show tables;" +``` +## TDengine CLI 小技巧 + +- 可以使用上下光标键查看历史输入的指令 +- 修改用户密码:在 shell 中使用 `alter user` 命令,缺省密码为 taosdata +- ctrl+c 中止正在进行中的查询 +- 执行 `RESET QUERY CACHE` 可清除本地缓存的表 schema +- 批量执行 SQL 语句。可以将一系列的 shell 命令(以英文 ; 结尾,每个 SQL 语句为一行)按行存放在文件里,在 shell 里执行命令 `source ` 自动执行该文件里所有的 SQL 语句 +- 输入 q 回车,退出 taos shell diff --git a/docs-cn/14-reference/09-client-config/09-client-config.md b/docs-cn/14-reference/09-client-config/09-client-config.md deleted file mode 100644 index 15ca79b029d8194c5af0c43ab579aac8727b06d4..0000000000000000000000000000000000000000 --- a/docs-cn/14-reference/09-client-config/09-client-config.md +++ /dev/null @@ -1,105 +0,0 @@ -# 客户端及应用驱动配置 - -TDengine 系统的前台交互客户端应用程序为 taos,以及应用驱动,它与 taosd 共享同一个配置文件 taos.cfg。运行 taos 时,使用参数-c 指定配置文件目录,如 taos -c /home/cfg,表示使用/home/cfg/目录下的 taos.cfg 配置文件中的参数,缺省目录是/etc/taos。更多 taos 的使用方法请见帮助信息 `taos --help`。本节主要说明 taos 客户端应用在配置文件 taos.cfg 文件中使用到的参数。 - -**2.0.10.0 之后版本支持命令行以下参数显示当前客户端参数的配置** - -```bash -taos -C 或 taos --dump-config -``` - -客户端及应用驱动配置参数列表及解释 - -- firstEp: taos 启动时,主动连接的集群中第一个 taosd 实例的 end point, 缺省值为 localhost:6030。 - -- secondEp: taos 启动时,如果 firstEp 连不上,将尝试连接 secondEp。 - -- locale:系统区位信息及编码格式。 - - 默认值:系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置。 - - TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提供一种专门的字段类型 nchar。写入 nchar 字段的数据将统一采用 UCS4-LE 格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用 nchar 字段来存储诸如中文、日文、韩文等非 ASCII 字符,需要正确设置客户端的编码格式。 - - 客户端的输入的字符均采用操作系统当前默认的编码格式,在 Linux 系统上多为 UTF-8,部分中文系统编码则可能是 GB18030 或 GBK 等。在 docker 环境中默认的编码是 POSIX。在中文版 Windows 系统中,编码则是 CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证 nchar 中的数据正确转换为 UCS4-LE 编码格式。 - - 在 Linux 中 locale 的命名规则为: <语言>\_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh 代表中文,CN 代表大陆地区,UTF-8 表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux 系统与 Mac OSX 系统可以通过设置 locale 来确定系统的字符编码,由于 Windows 使用的 locale 中不是 POSIX 标准的 locale 格式,因此在 Windows 下需要采用另一个配置参数 charset 来指定字符编码。在 Linux 系统中也可以使用 charset 来指定字符编码。 - -- charset:字符集编码。 - - 默认值:系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置。 - - 如果配置文件中不设置 charset,在 Linux 系统中,taos 在启动时候,自动读取系统当前的 locale 信息,并从 locale 信息中解析提取 charset 编码格式。如果自动读取 locale 信息失败,则尝试读取 charset 配置,如果读取 charset 配置也失败,则中断启动过程。 - - 在 Linux 系统中,locale 信息包含了字符编码信息,因此正确设置了 Linux 系统 locale 以后可以不用再单独设置 charset。例如: - - ``` - locale zh_CN.UTF-8 - ``` - - 在 Windows 系统中,无法从 locale 获取系统当前编码。如果无法从配置文件中读取字符串编码信息,taos 默认设置为字符编码为 CP936。其等效在配置文件中添加如下配置: - - ``` - charset CP936 - ``` - - 如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。 - - 在 Linux 系统中,如果用户同时设置了 locale 和字符集编码 charset,并且 locale 和 charset 的不一致,后设置的值将覆盖前面设置的值。 - - ``` - locale zh_CN.UTF-8 - charset GBK - ``` - - 则 charset 的有效值是 GBK。 - - ``` - charset GBK - locale zh_CN.UTF-8 - ``` - - charset 的有效值是 UTF-8。 - - 日志的配置参数,与 server 的配置参数完全一样。 - -- timezone - - 默认值:动态获取当前客户端运行系统所在的时区。 - - 为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix 时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。 - - 在 Linux 系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如: - - ``` - timezone UTC-8 - timezone GMT-8 - timezone Asia/Shanghai - ``` - - 均是合法的设置东八区时区的格式。但需注意,Windows 下并不支持 `timezone Asia/Shanghai` 这样的写法,而必须写成 `timezone UTC-8`。 - - 时区的设置对于查询和写入 SQL 语句中非 Unix 时间戳的内容(时间戳字符串、关键词 now 的解析)产生影响。例如: - - ```sql - SELECT count(*) FROM table_name WHERE TS<'2019-04-11 12:01:08'; - ``` - - 在东八区,SQL 语句等效于 - - ```sql - SELECT count(*) FROM table_name WHERE TS<1554955268000; - ``` - - 在 UTC 时区,SQL 语句等效于 - - ```sql - SELECT count(*) FROM table_name WHERE TS<1554984068000; - ``` - - 为了避免使用字符串时间格式带来的不确定性,也可以直接使用 Unix 时间戳。此外,还可以在 SQL 语句中使用带有时区的时间戳字符串,例如:RFC3339 格式的时间戳字符串,2013-04-12T15:52:01.123+08:00 或者 ISO-8601 格式时间戳字符串 2013-04-12T15:52:01.123+0800。上述两个字符串转化为 Unix 时间戳不受系统所在时区的影响。 - - 启动 taos 时,也可以从命令行指定一个 taosd 实例的 end point,否则就从 taos.cfg 读取。 - -- maxBinaryDisplayWidth - - Shell 中 binary 和 nchar 字段的显示宽度上限,超过此限制的部分将被隐藏。默认值:30。可在 taos shell 中通过命令 set max_binary_display_width nn 动态修改此选项。 diff --git a/docs-cn/14-reference/09-client-config/_category_.yml b/docs-cn/14-reference/09-client-config/_category_.yml deleted file mode 100644 index ad6e70b96dd031cc3d2607565f91d554e19addeb..0000000000000000000000000000000000000000 --- a/docs-cn/14-reference/09-client-config/_category_.yml +++ /dev/null @@ -1 +0,0 @@ -label: 客户端配置 diff --git a/docs-cn/14-reference/05-support-platform/_category_.yml b/docs-cn/14-reference/09-support-platform/_category_.yml similarity index 100% rename from docs-cn/14-reference/05-support-platform/_category_.yml rename to docs-cn/14-reference/09-support-platform/_category_.yml diff --git a/docs-cn/14-reference/05-support-platform/05-support-platform.md b/docs-cn/14-reference/09-support-platform/index.md similarity index 99% rename from docs-cn/14-reference/05-support-platform/05-support-platform.md rename to docs-cn/14-reference/09-support-platform/index.md index 35fb659b08c6fb9426d76cbb0d854e39a82f226d..11374e4deb44de4a08ce5c239cd6166014e7ee1d 100644 --- a/docs-cn/14-reference/05-support-platform/05-support-platform.md +++ b/docs-cn/14-reference/09-support-platform/index.md @@ -1,4 +1,6 @@ -# 支持平台列表 +--- +title: 支持平台列表 +--- ## TDengine 服务端支持的平台列表 diff --git a/docs-cn/14-reference/07-docker/_category_.yml b/docs-cn/14-reference/11-docker/_category_.yml similarity index 100% rename from docs-cn/14-reference/07-docker/_category_.yml rename to docs-cn/14-reference/11-docker/_category_.yml diff --git a/docs-cn/14-reference/07-docker/07-docker.md b/docs-cn/14-reference/11-docker/index.md similarity index 99% rename from docs-cn/14-reference/07-docker/07-docker.md rename to docs-cn/14-reference/11-docker/index.md index 3efcd0bace13c0b391f06a312e0affb7991610bd..6960db08b271b628d5c3c451865e4a7187b1712f 100644 --- a/docs-cn/14-reference/07-docker/07-docker.md +++ b/docs-cn/14-reference/11-docker/index.md @@ -1,4 +1,6 @@ -# 用 Docker 部署 TDengine +--- +title: 用 Docker 部署 TDengine +--- 本章主要介绍如何在容器中启动 TDengine 服务并访问它。 注意:可以在 docker run 命令行中或者 docker-compose 文件中使用环境变量来控制容器中服务的行为。 diff --git a/docs-cn/14-reference/12-config/_category_.yml b/docs-cn/14-reference/12-config/_category_.yml new file mode 100644 index 0000000000000000000000000000000000000000..8d3cfcc8d0d8966bf1354f9ece83faea105f9c7a --- /dev/null +++ b/docs-cn/14-reference/12-config/_category_.yml @@ -0,0 +1 @@ +label: 配置参数 \ No newline at end of file diff --git a/docs-cn/14-reference/08-server-config/08-server-config.md b/docs-cn/14-reference/12-config/index.md similarity index 86% rename from docs-cn/14-reference/08-server-config/08-server-config.md rename to docs-cn/14-reference/12-config/index.md index 844aa21c4378e892e1379e28b5501f8eaceb4750..0f7ba121c7e22c738772eef4178aab6e53adb6fd 100644 --- a/docs-cn/14-reference/08-server-config/08-server-config.md +++ b/docs-cn/14-reference/12-config/index.md @@ -1,4 +1,9 @@ -# 服务端配置 +--- +title: 配置参数 +description: "TDengine 客户端和服务配置列表" +--- + +## 为服务端指定配置文件 TDengine 系统后台服务由 taosd 提供,可以在配置文件 taos.cfg 里修改配置参数,以满足不同场景的需求。配置文件的缺省位置在/etc/taos 目录,可以通过 taosd 命令行执行参数 -c 指定配置文件目录。比如,指定配置文件位于`/home/user` 这个目录: @@ -12,28 +17,56 @@ taosd -c /home/user taosd -C ``` -下面仅仅列出一些重要的配置参数,更多的参数请看配置文件里的说明。而且这些参数的缺省配置都是可以工作的,一般无需设置。 +## 为客户端指定配置文件 + +TDengine 系统的前台交互客户端应用程序为 taos,以及应用驱动,它可以与 taosd 共享同一个配置文件 taos.cfg,也可以使用单独指定配置文件。运行 taos 时,使用参数-c 指定配置文件目录,如 taos -c /home/cfg,表示使用/home/cfg/目录下的 taos.cfg 配置文件中的参数,缺省目录是/etc/taos。更多 taos 的使用方法请见帮助信息 `taos --help`。 + +**2.0.10.0 之后版本支持命令行以下参数显示当前客户端参数的配置** + +```bash +taos -C +``` + +```bash +taos --dump-config +``` + +# 配置参数详细列表 + +:::note +本节内容覆盖产品的配置参数,适用于服务端的参数按其对产品行为的影响进行分类,这其中有部分参数也同时适用于客户端;但有少量参数仅适用于客户端,这部分参数进行了单独归类。 + +::: + :::note 配置文件参数修改后,需要重启*taosd*服务,或客户端应用才能生效。 ::: -## 首要参数 +## 连接相关 -### firstEP +### firstEp | 属性 | 说明 | | -------- | ----------------------------------------------------- | | 适用范围 | 服务端和客户端均适用 | -| 含义 | taosd 启动时,主动连接的集群中首个 dnode 的 end point | +| 含义 | taosd 或者 taos 启动时,主动连接的集群中首个 dnode 的 end point | | 缺省值 | localhost:6030 | +### secondEp + +| 属性 | 说明 | +| -------- | ---------------------------------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | +| 含义 | taosd 或者 taos 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 end point | +| 缺省值 | 无 | + ### fqdn | 属性 | 说明 | | -------- | ----------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | +| 适用范围 | 仅服务端适用 | | 含义 | 数据节点的 FQDN。如果习惯 IP 地址访问,可设置为该节点的 IP 地址。 | | 缺省值 | 缺省为操作系统配置的第一个 hostname。 | | 补充说明 | 这个参数值的长度需要控制在 96 个字符以内。 | @@ -42,10 +75,10 @@ taosd -C | 属性 | 说明 | | -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | +| 适用范围 | 仅服务端适用 | | 含义 | taosd 启动后,对外服务的端口号 | | 缺省值 | 6030 | -| 补充说明 | RESTful 服务使用的端口号是在此基础上+11,即默认值为 6041(注意 2.4 及后续版本使用 taosAdapter 提供 RESTful 接口)。 | +| 补充说明 | RESTful 服务在2.4.0.0之前(不含)由taosd提供,默认端口为 6041; 在2.4.0.0 及后续版本由 taosAdapter,默认端口为6041 | :::note 对于端口,TDengine 会使用从 serverPort 起 13 个连续的 TCP 和 UDP 端口号,请务必在防火墙打开。因此如果是缺省配置,需要打开从 6030 到 6042 共 13 个端口,而且必须 TCP 和 UDP 都打开。(详细的端口情况请参见下表) @@ -55,7 +88,7 @@ taosd -C | TCP | 6030 | 客户端与服务端之间通讯。 | 由配置文件设置 serverPort 决定。 | | TCP | 6035 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | | TCP | 6040 | 多节点集群的节点间数据同步。 | 随 serverPort 端口变化。 | -| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](https://www.taosdata.com/cn/documentation/tools/adapter)。 | +| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | | TCP | 6042 | Arbitrator 的服务端口。 | 随 Arbitrator 启动参数设置变化。 | | TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | | TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | @@ -64,32 +97,36 @@ taosd -C | UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | | UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 +### maxShellConns -### logDir - -| 属性 | 说明 | -| -------- | -------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 日志文件目录,客户端和服务器的运行日志将写入该目录 | -| 缺省值 | /var/log/taos | +| 属性 | 说明 | +| -------- | ----------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 一个 dnode 容许的连接数 | +| 取值范围 | 10-50000000 | +| 缺省值 | 5000 | -### dataDir +### maxConnections -| 属性 | 说明 | -| -------- | ------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 数据文件目录,所有的数据文件都将写入该目录 | -| 缺省值 | /var/lib/taos | +| 属性 | 说明 | +| -------- | ------------------------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 一个数据库连接所容许的 dnode 连接数 | +| 取值范围 | 1-100000 | +| 缺省值 | 5000 | +| 补充说明 | 实际测试下来,如果默认没有配,选 50 个 worker thread 会产生 Network unavailable | -### arbitrator +### rpcForceTcp -| 属性 | 说明 | -| -------- | ------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 系统中裁决器的 end point | -| 缺省值 | 空 | +| 属性 | 说明 | +| -------- | --------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | +| 含义 | 强制使用 TCP 传输 | +| 取值范围 | 0: 不开启 1: 开启 | +| 缺省值 | 0 | +| 补充说明 | 在网络比较差的环境中,建议开启。
2.0 版本新增。 | -## 开关类 +## 监控相关 ### monitor @@ -100,51 +137,56 @@ taosd -C | 取值范围 | 0:关闭监控服务, 1:激活监控服务。 | | 缺省值 | 0 | -### vnodeBak +### monitorInterval + +| 属性 | 说明 | +| -------- | -------------------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 监控数据库记录系统参数(CPU/内存)的时间间隔 | +| 单位 | 秒 | +| 取值范围 | 1-600 | +| 缺省值 | 30 | -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 删除 vnode 时是否备份 vnode 目录 | -| 取值范围 | 0:否,1:是 | -| 缺省值 | 1 | -### elemetryRePorting +### telemetryReporting | 属性 | 说明 | | -------- | ---------------------------------------- | | 适用范围 | 仅服务端适用 | | 含义 | 是否允许 TDengine 采集和上报基本使用信息 | -| 取值范围 | 0:不允许
1:允许 | +| 取值范围 | 0:不允许 1:允许 | | 缺省值 | 1 | -### balance +## 查询相关 -| 属性 | 说明 | -| -------- | ---------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否启动负载均衡 | -| 取值范围 | 0,1 | -| 缺省值 | 1 | +### queryBufferSize -### stream +| 属性 | 说明 | +| -------- | ------------------------------------------------------------------------------------------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 为所有并发查询占用保留的内存大小。 | +| 单位 | MB | +| 缺省值 | 无 | +| 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。
(2.0.15 以前的版本中,此参数的单位是字节) | -| 属性 | 说明 | -| -------- | ------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 是否启用连续查询(流计算功能) | -| 取值范围 | 0:不允许
1:允许 | -| 缺省值 | 1 | +### ratioOfQueryCores -### enableCoreFile +| 属性 | 说明 | +| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | +| 适用范围 | 仅服务端适用 | +| 含义 | 设置查询线程的最大数量。 | +| 缺省值 | 1 | +| 补充说明 | 最小值 0 表示只有 1 个查询线程
最大值 2 表示最大建立 2 倍 CPU 核数的查询线程。
默认为 1,表示最大和 CPU 核数相等的查询线程。
该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 是否开启服务 crash 时生成 core 文件 | -| 取值范围 | 0:否,1:是 | -| 缺省值 | 1 | -| 补充说明 | 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下
2、手动启动,就在 taosd 执行目录下。 | +### maxNumOfDistinctRes + +| 属性 | 说明 | +| -------- | -------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 允许返回的 distinct 结果最大行数 | +| 取值范围 | 默认值为 10 万,最大值 1 亿 | +| 缺省值 | 10 万 | +| 补充说明 | 2.3 版本新增。 | | ## 区域相关 @@ -156,6 +198,41 @@ taosd -C | 含义 | 时区 | | 缺省值 | 从系统中动态获取当前的时区设置 | +:::info +为应对多时区的数据写入和查询问题,TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区,产生的时间戳均一致。需要注意的是,Unix 时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。 + + 在 Linux 系统中,客户端会自动读取系统设置的时区信息。用户也可以采用多种方式在配置文件设置时区。例如: + + ``` + timezone UTC-8 + timezone GMT-8 + timezone Asia/Shanghai + ``` + + 均是合法的设置东八区时区的格式。但需注意,Windows 下并不支持 `timezone Asia/Shanghai` 这样的写法,而必须写成 `timezone UTC-8`。 + + 时区的设置对于查询和写入 SQL 语句中非 Unix 时间戳的内容(时间戳字符串、关键词 now 的解析)产生影响。例如: + + ```sql + SELECT count(*) FROM table_name WHERE TS<'2019-04-11 12:01:08'; + ``` + + 在东八区,SQL 语句等效于 + + ```sql + SELECT count(*) FROM table_name WHERE TS<1554955268000; + ``` + + 在 UTC 时区,SQL 语句等效于 + + ```sql + SELECT count(*) FROM table_name WHERE TS<1554984068000; + ``` + + 为了避免使用字符串时间格式带来的不确定性,也可以直接使用 Unix 时间戳。此外,还可以在 SQL 语句中使用带有时区的时间戳字符串,例如:RFC3339 格式的时间戳字符串,2013-04-12T15:52:01.123+08:00 或者 ISO-8601 格式时间戳字符串 2013-04-12T15:52:01.123+0800。上述两个字符串转化为 Unix 时间戳不受系统所在时区的影响。 + +::: + ### locale | 属性 | 说明 | @@ -164,6 +241,15 @@ taosd -C | 含义 | 系统区位信息及编码格式 | | 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 | +:::info + TDengine 为存储中文、日文、韩文等非 ASCII 编码的宽字符,提供一种专门的字段类型 nchar。写入 nchar 字段的数据将统一采用 UCS4-LE 格式进行编码并发送到服务器。需要注意的是,编码正确性是客户端来保证。因此,如果用户想要正常使用 nchar 字段来存储诸如中文、日文、韩文等非 ASCII 字符,需要正确设置客户端的编码格式。 + + 客户端的输入的字符均采用操作系统当前默认的编码格式,在 Linux 系统上多为 UTF-8,部分中文系统编码则可能是 GB18030 或 GBK 等。在 docker 环境中默认的编码是 POSIX。在中文版 Windows 系统中,编码则是 CP936。客户端需要确保正确设置自己所使用的字符集,即客户端运行的操作系统当前编码字符集,才能保证 nchar 中的数据正确转换为 UCS4-LE 编码格式。 + + 在 Linux 中 locale 的命名规则为: <语言>\_<地区>.<字符集编码> 如:zh_CN.UTF-8,zh 代表中文,CN 代表大陆地区,UTF-8 表示字符集。字符集编码为客户端正确解析本地字符串提供编码转换的说明。Linux 系统与 Mac OSX 系统可以通过设置 locale 来确定系统的字符编码,由于 Windows 使用的 locale 中不是 POSIX 标准的 locale 格式,因此在 Windows 下需要采用另一个配置参数 charset 来指定字符编码。在 Linux 系统中也可以使用 charset 来指定字符编码。 + +::: + ### charset | 属性 | 说明 | @@ -172,8 +258,51 @@ taosd -C | 含义 | 字符集编码 | | 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 | +:::info +如果配置文件中不设置 charset,在 Linux 系统中,taos 在启动时候,自动读取系统当前的 locale 信息,并从 locale 信息中解析提取 charset 编码格式。如果自动读取 locale 信息失败,则尝试读取 charset 配置,如果读取 charset 配置也失败,则中断启动过程。 + + 在 Linux 系统中,locale 信息包含了字符编码信息,因此正确设置了 Linux 系统 locale 以后可以不用再单独设置 charset。例如: + + ``` + locale zh_CN.UTF-8 + ``` + + 在 Windows 系统中,无法从 locale 获取系统当前编码。如果无法从配置文件中读取字符串编码信息,taos 默认设置为字符编码为 CP936。其等效在配置文件中添加如下配置: + + ``` + charset CP936 + ``` + + 如果需要调整字符编码,请查阅当前操作系统使用的编码,并在配置文件中正确设置。 + + 在 Linux 系统中,如果用户同时设置了 locale 和字符集编码 charset,并且 locale 和 charset 的不一致,后设置的值将覆盖前面设置的值。 + + ``` + locale zh_CN.UTF-8 + charset GBK + ``` + + 则 charset 的有效值是 GBK。 + + ``` + charset GBK + locale zh_CN.UTF-8 + ``` + + charset 的有效值是 UTF-8。 + +::: + ## 存储相关 +### dataDir + +| 属性 | 说明 | +| -------- | ------------------------------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 数据文件目录,所有的数据文件都将写入该目录 | +| 缺省值 | /var/lib/taos | + ### cache | 属性 | 说明 | @@ -264,16 +393,6 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。 - -### minimalLogDirGB - -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 当日志文件夹的磁盘大小小于该值时,停止写日志 | -| 单位 | GB | -| 缺省值 | 0.1 | - ### minimalTmpDirGB | 属性 | 说明 | @@ -281,7 +400,7 @@ taosd -C | 适用范围 | 服务端和客户端均适用 | | 含义 | 当日志文件夹的磁盘大小小于该值时,停止写临时文件 | | 单位 | GB | -| 缺省值 | 0.1 | +| 缺省值 | 1.0 | ### minimalDataDirGB @@ -290,10 +409,27 @@ taosd -C | 适用范围 | 仅服务端适用 | | 含义 | 当日志文件夹的磁盘大小小于该值时,停止写时序数据 | | 单位 | GB | -| 缺省值 | 0.1 | +| 缺省值 | 2.0 | + +### vnodeBak + +| 属性 | 说明 | +| -------- | -------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 删除 vnode 时是否备份 vnode 目录 | +| 取值范围 | 0:否,1:是 | +| 缺省值 | 1 | ## 集群相关 +### numOfMnodes + +| 属性 | 说明 | +| -------- | ------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 系统中管理节点个数 | +| 缺省值 | 3 | + ### replica | 属性 | 说明 | @@ -320,6 +456,32 @@ taosd -C | 含义 | dnode 的可选角色 | | 取值范围 | 0:any(既可作为 mnode,也可分配 vnode)
1:mgmt(只能作为 mnode,不能分配 vnode)
2:dnode(不能作为 mnode,只能分配 vnode) | | 缺省值 | 0 | +### balance + +| 属性 | 说明 | +| -------- | ---------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 是否启动负载均衡 | +| 取值范围 | 0,1 | +| 缺省值 | 1 | + +### balanceInterval + +| 属性 | 说明 | +| -------- | ------------------------------------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 管理节点在正常运行状态下,检查负载均衡的时间间隔 | +| 单位 | 秒 | +| 取值范围 | 1-30000 | +| 缺省值 | 300 | + +### arbitrator + +| 属性 | 说明 | +| -------- | ------------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 系统中裁决器的 end point,其格式如firstEp | +| 缺省值 | 空 | ## 时间相关 @@ -373,28 +535,7 @@ taosd -C | 取值范围 | 1-8640000 | | 缺省值 | 7200 | -### minSlidingTime - -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 最小滑动窗口时长 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000 | -| 缺省值 | 10 | -| 补充说明 | 支持 us 补值后,这个值就是 1us 了。 | - -### minIntervalTime - -| 属性 | 说明 | -| -------- | -------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 时间窗口最小值 | -| 单位 | 毫秒 | -| 取值范围 | 1-1000000 | -| 缺省值 | 10 | - -### maxTmerCtrl +### maxTmrCtrl | 属性 | 说明 | | -------- | -------------------- | @@ -404,16 +545,6 @@ taosd -C | 取值范围 | 8-2048 | | 缺省值 | 512 | -### monitorInterval - -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 监控数据库记录系统参数(CPU/内存)的时间间隔 | -| 单位 | 秒 | -| 取值范围 | 1-600 | -| 缺省值 | 30 | - ### offlineThreshold | 属性 | 说明 | @@ -424,47 +555,8 @@ taosd -C | 取值范围 | 5-7200000 | | 缺省值 | 86400\*10(10 天) | -### maxStreamCompDelay - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询启动最大延迟 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 20000 | -| 补充说明 | 为避免多个 stream 同时执行占用太多系统资源,程序中对 stream 的执行时间人为增加了一些随机的延时。
maxFirstStreamCompDelay 是 stream 第一次执行前最少要等待的时间。
streamCompDelayRatio 是延迟时间的计算系数,它乘以查询的 interval 后为延迟时间基准。
maxStreamCompDelay 是延迟时间基准的上限。
实际延迟时间为一个不超过延迟时间基准的随机值。
stream 某次计算失败后需要重试,retryStreamCompDelay 是重试的等待时间基准。
实际重试等待时间为不超过等待时间基准的随机值。 | - -### maxFirstStreamCompDelay - -| 属性 | 说明 | -| -------- | -------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 第一次连续查询启动最大延迟 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 10000 | - -### retryStreamCompDelay - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询重试等待间隔 | -| 单位 | 毫秒 | -| 取值范围 | 10-1000000000 | -| 缺省值 | 10 | - -### streamCompDelayRatio - -| 属性 | 说明 | -| -------- | -------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 连续查询的延迟时间计算系数 | -| 取值范围 | 0.1-0.9 | -| 缺省值 | 0.1 | -## 数量相关 +## 性能调优 ### numOfThreadsPerCore @@ -484,14 +576,6 @@ taosd -C | 缺省值 | 1 | | 补充说明 | 该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | -### numOfMnodes - -| 属性 | 说明 | -| -------- | ------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 系统中管理节点个数 | -| 缺省值 | 3 | - ### maxVgroupsPerDb | 属性 | 说明 | @@ -509,41 +593,47 @@ taosd -C | 含义 | 每个 vnode 中能够创建的最大表个数 | | 缺省值 | 1000000 | -### maxNumOfOrderedRes +### minTablesPerVnode -| 属性 | 说明 | -| -------- | -------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 支持超级表时间排序允许的最多记录数限制 | -| 缺省值 | 10 万 | +| 属性 | 说明 | +| -------- | --------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 每个 vnode 中必须创建表的最小数量 | +| 缺省值 | 1000 | -### maxShellConns +### tableIncStepPerVnode -| 属性 | 说明 | -| -------- | ----------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 一个 dnode 容许的连接数 | -| 取值范围 | 10-50000000 | -| 缺省值 | 5000 | +| 属性 | 说明 | +| -------- | ----------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 每个 vnode 中超过最小表数,i.e. minTablesPerVnode, 后递增步长 | +| 缺省值 | 1000 | -### maxConnections +### maxNumOfOrderedRes + +| 属性 | 说明 | +| -------- | -------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | +| 含义 | 支持超级表时间排序允许的最多记录数限制 | +| 缺省值 | 10 万 | -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 一个数据库连接所容许的 dnode 连接数 | -| 取值范围 | 1-100000 | -| 缺省值 | 5000 | -| 补充说明 | 实际测试下来,如果默认没有配,选 50 个 worker thread 会产生 Network unavailable | ### mnodeEqualVnodeNum | 属性 | 说明 | | -------- | ---------------------------------- | | 适用范围 | 仅服务端适用 | -| 含义 | 一个 mnode 等同于 vnode 消耗的个数 | +| 含义 | 将一个 mnode 等同于 vnode 消耗的个数 | | 缺省值 | 4 | +### numOfCommitThreads + +| 属性 | 说明 | +| -------- | ---------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 设置写入线程的最大数量 | +| 缺省值 | | + ## 压缩相关 ### comp @@ -555,6 +645,14 @@ taosd -C | 取值范围 | 0:关闭,1:一阶段压缩,2:两阶段压缩 | | 缺省值 | 2 | +### tsdbMetaCompactRatio + +| 属性 | 说明 | +| -------- | -------------------------------------------------------------- | +| 含义 | tsdb meta 文件中冗余数据超过多少阈值,开启 meta 文件的压缩功能 | +| 取值范围 | 0:不开启,[1-100]:冗余数据比例 | +| 缺省值 | 0 | + ### compressMsgSize | 属性 | 说明 | @@ -606,8 +704,90 @@ taosd -C | 缺省值 | 0.0000000000000001 | | 补充说明 | 小于此值的浮点数尾数部分将被截取 | +## 连续查询相关 + +### stream + +| 属性 | 说明 | +| -------- | ------------------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 是否启用连续查询(流计算功能) | +| 取值范围 | 0:不允许
1:允许 | +| 缺省值 | 1 | + +### minSlidingTime + +| 属性 | 说明 | +| -------- | ----------------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 最小滑动窗口时长 | +| 单位 | 毫秒 | +| 取值范围 | 10-1000000 | +| 缺省值 | 10 | +| 补充说明 | 支持 us 补值后,这个值就是 1us 了。 | + +### minIntervalTime + +| 属性 | 说明 | +| -------- | -------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 时间窗口最小值 | +| 单位 | 毫秒 | +| 取值范围 | 1-1000000 | +| 缺省值 | 10 | + +### maxStreamCompDelay + +| 属性 | 说明 | +| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| 适用范围 | 仅服务端适用 | +| 含义 | 连续查询启动最大延迟 | +| 单位 | 毫秒 | +| 取值范围 | 10-1000000000 | +| 缺省值 | 20000 | + +### maxFirstStreamCompDelay + +| 属性 | 说明 | +| -------- | -------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 第一次连续查询启动最大延迟 | +| 单位 | 毫秒 | +| 取值范围 | 10-1000000000 | +| 缺省值 | 10000 | + +### retryStreamCompDelay + +| 属性 | 说明 | +| -------- | -------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 连续查询重试等待间隔 | +| 单位 | 毫秒 | +| 取值范围 | 10-1000000000 | +| 缺省值 | 10 | + +### streamCompDelayRatio + +| 属性 | 说明 | +| -------- | -------------------------- | +| 适用范围 | 仅服务端适用 | +| 含义 | 连续查询的延迟时间计算系数,实际延迟时间为本参数乘以计算时间窗口 | +| 取值范围 | 0.1-0.9 | +| 缺省值 | 0.1 | + +:::info +为避免多个 stream 同时执行占用太多系统资源,程序中对 stream 的执行时间人为增加了一些随机的延时。
maxFirstStreamCompDelay 是 stream 第一次执行前最少要等待的时间。
streamCompDelayRatio 是延迟时间的计算系数,它乘以查询的 interval 后为延迟时间基准。
maxStreamCompDelay 是延迟时间基准的上限。
实际延迟时间为一个不超过延迟时间基准的随机值。
stream 某次计算失败后需要重试,retryStreamCompDelay 是重试的等待时间基准。
实际重试等待时间为不超过等待时间基准的随机值。 + +::: + ## HTTP 相关 +:::note +HTTP服务在2.4.0.0(不含)以前的版本中由taosd提供,在2.4.0.0以后(含)由taosAdapter提供。 +本节的配置参数仅在2.4.0.0(不含)以前的版本中生效。如果您使用的是2.4.0.0(含)及以后的版本请参考[文档](/reference/taosadapter/)。 + +::: + ### http | 属性 | 说明 | @@ -622,7 +802,7 @@ taosd -C | 属性 | 说明 | | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | | 适用范围 | 仅服务端适用 | -| 含义 | 内部使用,记录通过 RESTFul 接口,产生的 SQL 调用。taosAdapter 配置或有不同,请参考相应[文档](https://www.taosdata.com/cn/documentation/tools/adapter)。 | +| 含义 | 记录通过 RESTFul 接口,产生的 SQL 调用。 | | 缺省值 | 0 | | 补充说明 | 生成的文件(httpnote.0/httpnote.1),与服务端日志所在目录相同。 | @@ -631,7 +811,7 @@ taosd -C | 属性 | 说明 | | -------- | --------------------------------------------------------------------------------------------------------------------------- | | 适用范围 | 仅服务端适用 | -| 含义 | RESTFul 接口的线程数。taosAdapter 配置或有不同,请参考相应[文档](https://www.taosdata.com/cn/documentation/tools/adapter)。 | +| 含义 | RESTFul 接口的线程数。taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | | 缺省值 | 2 | ### restfulRowLimit @@ -639,7 +819,7 @@ taosd -C | 属性 | 说明 | | -------- | ------------------------------------------------------------------------------------------------------------------------------------- | | 适用范围 | 仅服务端适用 | -| 含义 | RESTFul 接口单次返回的记录条数。taosAdapter 配置或有不同,请参考相应[文档](https://www.taosdata.com/cn/documentation/tools/adapter)。 | +| 含义 | RESTFul 接口单次返回的记录条数。taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | | 缺省值 | 10240 | | 补充说明 | 最大 10,000,000 | @@ -655,6 +835,24 @@ taosd -C ## 日志相关 +### logDir + +| 属性 | 说明 | +| -------- | -------------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | +| 含义 | 日志文件目录,客户端和服务器的运行日志将写入该目录 | +| 缺省值 | /var/log/taos | + +### minimalLogDirGB + +| 属性 | 说明 | +| -------- | -------------------------------------------- | +| 适用范围 | 服务端和客户端均适用 | +| 含义 | 当日志文件夹的磁盘大小小于该值时,停止写日志 | +| 单位 | GB | +| 缺省值 | 1.0 | + + ### numOfLogLines | 属性 | 说明 | @@ -853,138 +1051,6 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -## 内部配置 - -### secondEP - -| 属性 | 说明 | -| -------- | ---------------------------------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | taosd 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 end point | -| 缺省值 | 无 | - -### scriptDir - -| 属性 | 说明 | -| -------- | ------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | | -| 缺省值 | | - -### balanceInterval - -| 属性 | 说明 | -| -------- | ------------------------------------------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | 管理节点在正常运行状态下,检查负载均衡的时间间隔 | -| 单位 | 秒 | -| 取值范围 | 1-30000 | -| 缺省值 | 300 | - -### minTablesPerVnode - -| 属性 | 说明 | -| -------- | --------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode 中必须创建的最小表个数 | -| 缺省值 | 1000 | - -### tableIncStepPerVnode - -| 属性 | 说明 | -| -------- | ----------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 每个 vnode 中超过最小表数后递增步长 | -| 缺省值 | 1000 | - -### mqttHostName - -| 属性 | 说明 | -| -------- | -------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | mqtt uri | -| 缺省值 | | -| 补充说明 | mqtt://username:password@hostname:1883/taos/ | - -### mqttPort - -| 属性 | 说明 | -| -------- | ---------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | mqtt client name | -| 缺省值 | | -| 补充说明 | 1883 | - -### mqttTopic - -| 属性 | 说明 | -| -------- | ------------ | -| 适用范围 | 仅服务端适用 | -| 含义 | | -| 缺省值 | | -| 补充说明 | /test | - -### mqtt - -| 属性 | 说明 | -| -------- | --------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 服务器内部的 mqtt 服务开关。 | -| 取值范围 | 0:关闭 mqtt 服务, 1:激活 mqtt 服务。 | -| 缺省值 | 0 | - -### telegrafUseFieldNum - -| 属性 | 说明 | -| -------- | ---- | -| 适用范围 | | -| 含义 | | -| 缺省值 | | - -### gitinfo - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | | -| 取值范围 | 1 | -| 缺省值 | | - -### gitinfoofInternal - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | | -| 取值范围 | 2 | -| 缺省值 | | - -### Buildinfo - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | | -| 取值范围 | 3 | -| 缺省值 | | - -### version - -| 属性 | 说明 | -| -------- | -------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | | -| 取值范围 | 4 | -| 缺省值 | | - -### numOfCommitThreads - -| 属性 | 说明 | -| -------- | ---------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 设置写入线程的最大数量 | -| 缺省值 | | - ## 仅客户端适用 ### maxSQLLength @@ -1013,7 +1079,11 @@ taosd -C | 含义 | Taos shell 中 binary 和 nchar 字段的显示宽度上限,超过此限制的部分将被隐藏 | | 取值范围 | 5 - | | 缺省值 | 30 | -| 补充说明 | 实际上限按以下规则计算:如果字段值的长度大于 maxBinaryDisplayWidth,则显示上限为 **字段名长度** 和 **maxBinaryDisplayWidth** 的较大者。
否则,上限为 **字段名长度** 和 **字段值长度** 的较大者。
可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项 | + +:::info +实际上限按以下规则计算:如果字段值的长度大于 maxBinaryDisplayWidth,则显示上限为 **字段名长度** 和 **maxBinaryDisplayWidth** 的较大者。
否则,上限为 **字段名长度** 和 **字段值长度** 的较大者。
可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项 + +::: ### maxWildCardsLength @@ -1025,14 +1095,6 @@ taosd -C | 缺省值 | 100 | | 补充说明 | 2.1.6.1 版本新增。 | -### tsdbMetaCompactRatio - -| 属性 | 说明 | -| -------- | -------------------------------------------------------------- | -| 含义 | tsdb meta 文件中冗余数据超过多少阈值,开启 meta 文件的压缩功能 | -| 取值范围 | 0:不开启,[1-100]:冗余数据比例 | -| 缺省值 | 0 | - ### clientMerge | 属性 | 说明 | @@ -1053,42 +1115,12 @@ taosd -C ## 其他 -### queryBufferSize - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 为所有并发查询占用保留的内存大小。 | -| 单位 | MB | -| 缺省值 | | -| 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。
(2.0.15 以前的版本中,此参数的单位是字节) | - -### ratioOfQueryCores - -| 属性 | 说明 | -| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --- | -| 适用范围 | 仅服务端适用 | -| 含义 | 设置查询线程的最大数量。 | -| 缺省值 | | -| 补充说明 | 最小值 0 表示只有 1 个查询线程
最大值 2 表示最大建立 2 倍 CPU 核数的查询线程。
默认为 1,表示最大和 CPU 核数相等的查询线程。
该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | | - -### rpcForceTcp - -| 属性 | 说明 | -| -------- | --------------------------------------------------- | -| 适用范围 | 服务端和客户端均适用 | -| 含义 | 强制使用 TCP 传输 | -| 取值范围 | 0: 不开启 1: 开启 | -| 缺省值 | 0 | -| 补充说明 | 在网络比较差的环境中,建议开启。
2.0 版本新增。 | - -### maxNumOfDistinctRes - -| 属性 | 说明 | -| -------- | -------------------------------- | -| 适用范围 | 仅服务端适用 | -| 含义 | 允许返回的 distinct 结果最大行数 | -| 取值范围 | 默认值为 10 万,最大值 1 亿 | -| 缺省值 | 10 万 | -| 补充说明 | 2.3 版本新增。 | +### enableCoreFile +| 属性 | 说明 | +| -------- | ------------------------------------------------------------------------------------------------------------------------------------------ | +| 适用范围 | 服务端和客户端均适用 | +| 含义 | 是否开启服务 crash 时生成 core 文件 | +| 取值范围 | 0:否,1:是 | +| 缺省值 | 1 | +| 补充说明 | 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下
2、手动启动,就在 taosd 执行目录下。 | \ No newline at end of file diff --git a/docs-cn/17-train-fqa/04-direcotry.md b/docs-cn/14-reference/12-directory.md similarity index 69% rename from docs-cn/17-train-fqa/04-direcotry.md rename to docs-cn/14-reference/12-directory.md index c2746de1c1dd98f9ffa715680d4a1048cd3e8c02..df2a6536ee1faf9ef9a041a453ecd3d3375483f6 100644 --- a/docs-cn/17-train-fqa/04-direcotry.md +++ b/docs-cn/14-reference/12-directory.md @@ -1,11 +1,12 @@ -# 文件目录结构 +--- +title: 文件目录结构 +--- 安装 TDengine 后,默认会在操作系统中生成下列目录或文件: | 目录/文件 | 说明 | | ------------------------- | -------------------------------------------------------------------- | | /usr/local/taos/bin | TDengine 可执行文件目录。其中的执行文件都会软链接到/usr/bin 目录下。 | -| /usr/local/taos/connector | TDengine 各种连接器目录。 | | /usr/local/taos/driver | TDengine 动态链接库目录。会软链接到/usr/lib 目录下。 | | /usr/local/taos/examples | TDengine 各种语言应用示例目录。 | | /usr/local/taos/include | TDengine 对外提供的 C 语言接口的头文件。 | @@ -21,7 +22,13 @@ TDengine 的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下 - _taos_:TDengine Shell 可执行文件 - _taosdump_:数据导入导出工具 - _taosBenchmark_:TDengine 测试工具 -- remove.sh:卸载 TDengine 的脚本,请谨慎执行,链接到/usr/bin 目录下的**rmtaos**命令。会删除 TDengine 的安装目录/usr/local/taos,但会保留/etc/taos、/var/lib/taos、/var/log/taos。 +- _remove.sh_:卸载 TDengine 的脚本,请谨慎执行,链接到/usr/bin 目录下的**rmtaos**命令。会删除 TDengine 的安装目录/usr/local/taos,但会保留/etc/taos、/var/lib/taos、/var/log/taos +- _taosadapter_: 提供 RESTful 服务和接受其他多种软件写入请求的服务端可执行文件 +- _tarbitrator_: 提供双节点集群部署的仲裁功能 +- _run_taosd_and_taosadapter.sh_:同时启动 taosd 和 taosAdapter 的脚本 +- _TDinsight.sh_:用于下载 TDinsight 并安装的脚本 +- _set_core.sh_:用于方便调试设置系统生成 core dump 文件的脚本 +- _taosd-dump-cfg.gdb_:用于方便调试 taosd 的 gdb 执行脚本。 :::note 2.4.0.0 版本之后的 taosBenchmark 和 taosdump 需要安装独立安装包 taosTools。 diff --git a/docs-cn/14-reference/13-schemaless/13-schemaless.md b/docs-cn/14-reference/13-schemaless/13-schemaless.md index 9e74d5ac4d040fbb84650e2e65350b36716dee5e..7b34b97ce06626bda91919f31e4691125df0defa 100644 --- a/docs-cn/14-reference/13-schemaless/13-schemaless.md +++ b/docs-cn/14-reference/13-schemaless/13-schemaless.md @@ -1,4 +1,6 @@ -# Schemaless 写入 +--- +title: Schemaless 写入 +--- ## 前言 @@ -6,7 +8,6 @@ 从 2.2.0.0 版本开始,提供调用 Schemaless 写入方式,可以免于预先创建超级表/子表的步骤,随着数据写入接口能够自动创建与数据对应的存储结构。并且在必要时,Schemaless 将自动增加必要的数据列,保证用户写入的数据可以被正确存储。 - 无模式写入方式建立的超级表及其对应的子表与通过 SQL 直接建立的超级表和子表完全没有区别,你也可以通过,SQL 语句直接向其中写入数据。需要注意的是,通过无模式写入方式建立的表,其表名是基于标签值按照固定的映射规则生成,所以无法明确地进行表意,缺乏可读性。 ## 无模式写入行协议 @@ -68,7 +69,7 @@ st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000 "measurement,tag_key1=tag_value1,tag_key2=tag_value2" ``` -需要注意的是,这里的 tag*key1, tag_key2 并不是用户输入的标签的原始顺序,而是使用了标签名称按照字符串升序排列后的结果。所以,tag_key1 并不是在行协议中输入的第一个标签。 +需要注意的是,这里的 tag_key1, tag_key2 并不是用户输入的标签的原始顺序,而是使用了标签名称按照字符串升序排列后的结果。所以,tag_key1 并不是在行协议中输入的第一个标签。 排列完成以后计算该字符串的 MD5 散列值 "md5_val"。然后将计算的结果与字符串组合生成表名:“t_md5_val”。其中的 “t*” 是固定的前缀,每个通过该映射关系自动生成的表都具有该前缀。 2. 如果解析行协议获得的超级表不存在,则会创建这个超级表。 @@ -80,9 +81,10 @@ st,t1=3,t2=4,t3=t3 c1=3i64,c3="passit",c2=false,c4=4f64 1626006833639000000 7. 如果指定的数据子表已经存在,而且本次指定的标签列取值跟已保存的值不一样,那么最新的数据行中的值会覆盖旧的标签列取值。 8. 整个处理过程中遇到的错误会中断写入过程,并返回错误代码。 -:::Tip +:::tip 无模式所有的处理逻辑,仍会遵循 TDengine 对数据结构的底层限制,例如每行数据的总长度不能超过 -16k 字节。这方面的具体限制约束请参见 [TAOS SQL 边界限制](https://www.taosdata.com/cn/documentation/taos-sql#limitation) +16k 字节。这方面的具体限制约束请参见 [TAOS SQL 边界限制](/taos-sql/limit) + ::: ## 时间分辨率识别 @@ -161,4 +163,4 @@ TDengine 提供数据写入的幂等性保证,即您可以反复调用 API 进 如果是无模式写入过程中的数据本身错误,应用会得到 TSDB_CODE_TSC_LINE_SYNTAX_ERROR 错误信息,该错误信息表明错误发生在写入文本中。其他的错误码与原系统一致,可以通过 -taos_errstr 获取具体的错误原因。 \ No newline at end of file +taos_errstr 获取具体的错误原因。 diff --git a/docs-cn/14-reference/_category_.yml b/docs-cn/14-reference/_category_.yml index 9381de6f82b806cb79e17e983c984de1c761fb18..f8031c35755f5912110136e8fdf3b176ddf5d6b0 100644 --- a/docs-cn/14-reference/_category_.yml +++ b/docs-cn/14-reference/_category_.yml @@ -1,3 +1,4 @@ label: 参考指南 link: + slug: /reference/ type: generated-index \ No newline at end of file diff --git a/docs-cn/14-reference/_collectd.mdx b/docs-cn/14-reference/_collectd.mdx new file mode 100644 index 0000000000000000000000000000000000000000..1853769bf926a081a80cdf72b8e822e58cefb1e9 --- /dev/null +++ b/docs-cn/14-reference/_collectd.mdx @@ -0,0 +1,85 @@ +### 配置 taosAdapter + +配置 taosAdapter 接收 collectd 数据的方法: + +- 在 taosAdapter 配置文件(默认位置为 /etc/taos/taosadapter.toml)中使能配置项 + +``` +... +[opentsdb_telnet] +enable = true +maxTCPConnections = 250 +tcpKeepAlive = false +dbs = ["opentsdb_telnet", "collectd", "icinga2", "tcollector"] +ports = [6046, 6047, 6048, 6049] +user = "root" +password = "taosdata" +... +``` + +其中 taosAdapter 默认写入的数据库名称为 `collectd`,也可以修改 taosAdapter 配置文件 dbs 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过配置文件 taosAdapter 需重新启动。 + +- 也可以使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 collectd 数据功能,具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) + +### 配置 collectd +# +collectd 使用插件机制可以以多种形式将采集到的监控数据写入到不同的数据存储软件。TDengine 支持直接采集插件和 write_tsdb 插件。 + +#### 配置接收直接采集插件数据 + +修改 collectd 配置文件(默认位置 /etc/collectd/collectd.conf)相关配置项。 + +```text +LoadPlugin network + + Server "" "" + +``` + +其中 填写运行 taosAdapter 的服务器域名或 IP 地址。 填写 taosAdapter 用于接收 collectd 数据的端口(默认为 6045)。 + +实例如下: + +```text +LoadPlugin network + + Server "127.0.0.1" "6045" + +``` + +#### 配置 write_tsdb 插件数据 + +修改 collectd 配置文件(默认位置 /etc/collectd/collectd.conf)相关配置项。 + +```text +LoadPlugin write_tsdb + + + Host "" + Port "" + ... + + +``` + +其中 填写运行 taosAdapter 的服务器域名或 IP 地址。 填写 taosAdapter 用于接收 collectd write_tsdb 插件的数据(默认为 6047)。 + +```text +LoadPlugin write_tsdb + + + Host "127.0.0.1" + Port "6047" + HostTags "status=production" + StoreRates false + AlwaysAppendDS false + + +``` + +然后重启 collectd: + +``` +systemctl restart collectd +``` + diff --git a/docs-cn/14-reference/_icinga2.mdx b/docs-cn/14-reference/_icinga2.mdx new file mode 100644 index 0000000000000000000000000000000000000000..0ed5023f953a6d879cc553def3aa0eaa9098afd5 --- /dev/null +++ b/docs-cn/14-reference/_icinga2.mdx @@ -0,0 +1,44 @@ +### 配置 taosAdapter + +配置 taosAdapter 接收 icinga2 数据的方法: + +- 在 taosAdapter 配置文件(默认位置 /etc/taos/taosadapter.toml)中使能配置项 + +``` +... +[opentsdb_telnet] +enable = true +maxTCPConnections = 250 +tcpKeepAlive = false +dbs = ["opentsdb_telnet", "collectd", "icinga2", "tcollector"] +ports = [6046, 6047, 6048, 6049] +user = "root" +password = "taosdata" +... +``` + +其中 taosAdapter 默认写入的数据库名称为 `icinga2`,也可以修改 taosAdapter 配置文件 dbs 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过 taosAdapter 需重新启动。 + +- 也可以使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 icinga2 数据功能,具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) + +### 配置 icinga2 + +- 使能 icinga2 的 opentsdb-writer(参考链接 https://icinga.com/docs/icinga-2/latest/doc/14-features/#opentsdb-writer) +- 修改配置文件 `/etc/icinga2/features-enabled/opentsdb.conf` 填写 为运行 taosAdapter 的服务器的域名或 IP 地址, 填写 taosAdapter 支持接收 icinga2 数据的相应端口(默认为 6048) + +``` +object OpenTsdbWriter "opentsdb" { + host = "" + port = +} +``` + +实例文件: + +``` +object OpenTsdbWriter "opentsdb" { + host = "127.0.0.1" + port = 6048 +} +``` + diff --git a/docs-cn/14-reference/_prometheus.mdx b/docs-cn/14-reference/_prometheus.mdx new file mode 100644 index 0000000000000000000000000000000000000000..be73d95cbc001727ee1ea60759f37e0a836643c2 --- /dev/null +++ b/docs-cn/14-reference/_prometheus.mdx @@ -0,0 +1,31 @@ +配置 Prometheus 是通过编辑 Prometheus 配置文件 prometheus.yml (默认位置 /etc/prometheus/prometheus.yml)完成的。 + +### 配置第三方数据库地址 + +将其中的 remote_read url 和 remote_write url 指向运行 taosAdapter 服务的服务器域名或 IP 地址,REST 服务端口(taosAdapter 默认使用 6041),以及希望写入 TDengine 的数据库名称,并确保相应的 URL 形式如下: + +- remote_read url : `http://:/prometheus/v1/remote_read/` +- remote_write url : `http://:/prometheus/v1/remote_write/` + +### 配置 Basic 验证 + +- username: +- password: + +### prometheus.yml 文件中 remote_write 和 remote_read 相关部分配置示例 + +```yaml +remote_write: + - url: "http://localhost:6041/prometheus/v1/remote_write/prometheus_data" + basic_auth: + username: root + password: taosdata + +remote_read: + - url: "http://localhost:6041/prometheus/v1/remote_read/prometheus_data" + basic_auth: + username: root + password: taosdata + remote_timeout: 10s + read_recent: true +``` diff --git a/docs-cn/14-reference/_statsd.mdx b/docs-cn/14-reference/_statsd.mdx new file mode 100644 index 0000000000000000000000000000000000000000..b225c44267d7ae32e3845972f683f664e11e9cae --- /dev/null +++ b/docs-cn/14-reference/_statsd.mdx @@ -0,0 +1,55 @@ +### 配置 taosAdapter + +配置 taosAdapter 接收 StatsD 数据的方法: + +- 在 taosAdapter 配置文件(默认位置 /etc/taos/taosadapter.toml)中使能配置项 + +``` +... +[statsd] +enable = true +port = 6044 +db = "statsd" +user = "root" +password = "taosdata" +worker = 10 +gatherInterval = "5s" +protocol = "udp" +maxTCPConnections = 250 +tcpKeepAlive = false +allowPendingMessages = 50000 +deleteCounters = true +deleteGauges = true +deleteSets = true +deleteTimings = true +... +``` + +其中 taosAdapter 默认写入的数据库名称为 `statsd`,也可以修改 taosAdapter 配置文件 db 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过配置文件 taosAdapter 需重新启动。 + +- 也可以使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 StatsD 数据功能,具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) + +### 配置 StatsD + +使用 StatsD 需要下载其[源代码](https://github.com/statsd/statsd)。其配置文件请参考其源代码下载到本地的根目录下的示例文件 `exampleConfig.js` 进行修改。其中 填写运行 taosAdapter 的服务器域名或 IP 地址,请填写 taosAdapter 接收 StatsD 数据的端口(默认为 6044)。 + +``` +backends 部分添加 "./backends/repeater" +repeater 部分添加 { host:'', port: } +``` + +示例配置文件: + +``` +{ +port: 8125 +, backends: ["./backends/repeater"] +, repeater: [{ host: '127.0.0.1', port: 6044}] +} +``` + +增加如下内容后启动 StatsD(假设配置文件修改为 config.js)。 + +``` +node stats.js config.js & +``` diff --git a/docs-cn/14-reference/_tcollector.mdx b/docs-cn/14-reference/_tcollector.mdx new file mode 100644 index 0000000000000000000000000000000000000000..8e51975b512d658e27a53b469d981e1c85a871dc --- /dev/null +++ b/docs-cn/14-reference/_tcollector.mdx @@ -0,0 +1,82 @@ + +### 配置 taosAdapter + +配置 taosAdapter 接收 TCollector 数据的方法: + +- 在 taosAdapter 配置文件(默认位置 /etc/taos/taosadapter.toml)中使能配置项 + +``` +... +[opentsdb_telnet] +enable = true +maxTCPConnections = 250 +tcpKeepAlive = false +dbs = ["opentsdb_telnet", "collectd", "icinga2", "tcollector"] +ports = [6046, 6047, 6048, 6049] +user = "root" +password = "taosdata" +... +``` + +其中 taosAdapter 默认写入的数据库名称为 `tcollector`,也可以修改 taosAdapter 配置文件 dbs 项来指定不同的名称。user 和 password 填写实际 TDengine 配置的值。修改过配置文件 taosAdapter 需重新启动。 + +- 也可以使用 taosAdapter 命令行参数或设置环境变量启动的方式,使能 taosAdapter 接收 tcollector 数据功能,具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) + +### 配置 TCollector + +使用 TCollector 需下载其[源代码](https://github.com/OpenTSDB/tcollector)。其配置项在其源代码中。注意:TCollector 各个版本区别较大,这里仅以当前 master 分支最新代码 (git commit: 37ae920) 为例。 + +修改 `collectors/etc/config.py` 和 `tcollector.py` 两个文件中相应内容。将原指向 OpenTSDB 宿主机的地址修改为 taosAdapter 被部署的服务器域名或 IP 地址,修改端口为 taosAdapter 支持 TCollector 使用的相应端口(默认为 6049)。 + +示例为源代码修改内容的 git diff 输出: + +``` +index e7e7a1c..ec3e23c 100644 +--- a/collectors/etc/config.py ++++ b/collectors/etc/config.py +@@ -59,13 +59,13 @@ def get_defaults(): + 'http_password': False, + 'reconnectinterval': 0, + 'http_username': False, +- 'port': 4242, ++ 'port': 6049, + 'pidfile': '/var/run/tcollector.pid', + 'http': False, + 'http_api_path': "api/put", + 'tags': [], + 'remove_inactive_collectors': False, +- 'host': '', ++ 'host': '127.0.0.1', + 'logfile': '/var/log/tcollector.log', + 'cdir': default_cdir, + 'ssl': False, +diff --git a/tcollector.py b/tcollector.py +index 21f9b23..4c71ba2 100755 +--- a/tcollector.py ++++ b/tcollector.py +@@ -64,7 +64,7 @@ ALIVE = True + # exceptions, something is not right and tcollector will shutdown. + # Hopefully some kind of supervising daemon will then restart it. + MAX_UNCAUGHT_EXCEPTIONS = 100 +-DEFAULT_PORT = 4242 ++DEFAULT_PORT = 6049 + MAX_REASONABLE_TIMESTAMP = 2209212000 # Good until Tue 3 Jan 14:00:00 GMT 2040 + # How long to wait for datapoints before assuming + # a collector is dead and restarting it +@@ -943,13 +943,13 @@ def parse_cmdline(argv): + 'http_password': False, + 'reconnectinterval': 0, + 'http_username': False, +- 'port': 4242, ++ 'port': 6049, + 'pidfile': '/var/run/tcollector.pid', + 'http': False, + 'http_api_path': "api/put", + 'tags': [], + 'remove_inactive_collectors': False, +- 'host': '', ++ 'host': '127.0.0.1', + 'logfile': '/var/log/tcollector.log', + 'cdir': default_cdir, + 'ssl': False, +``` diff --git a/docs-cn/14-reference/_telegraf.mdx b/docs-cn/14-reference/_telegraf.mdx new file mode 100644 index 0000000000000000000000000000000000000000..bae46d66062ad7d5bfc2487900c02bd7a19ce4f6 --- /dev/null +++ b/docs-cn/14-reference/_telegraf.mdx @@ -0,0 +1,27 @@ + +在 Telegraf 配置文件(默认位置 /etc/telegraf/telegraf.conf) 增加 outputs.http 输出模块配置: + +``` +[[outputs.http]] + url = "http://:/influxdb/v1/write?db=" + ... + username = "" + password = "" + ... +``` + +其中 请填写运行 taosAdapter 服务的服务器域名或 IP 地址, 请填写 REST 服务的端口(默认为 6041), 请填写当前运行的 TDengine 实际配置, 请填写希望在 TDengine 保存 Telegraf 数据的数据库名。 + +示例如下: + +``` +[[outputs.http]] + url = "http://127.0.0.1:6041/influxdb/v1/write?db=telegraf" + method = "POST" + timeout = "5s" + username = "root" + password = "taosdata" + data_format = "influx" + influx_max_line_bytes = 250 +``` + diff --git a/docs-cn/14-reference/taosAdapter-architecture.png b/docs-cn/14-reference/taosAdapter-architecture.png new file mode 100644 index 0000000000000000000000000000000000000000..08a9018553aae6f86b42d127b372d0cecfa9bdf8 Binary files /dev/null and b/docs-cn/14-reference/taosAdapter-architecture.png differ diff --git a/docs-cn/16-iot-bigdata/_category_.yml b/docs-cn/16-iot-bigdata/_category_.yml deleted file mode 100644 index 400c7656a3749cfd5ced4b8921f683c4a0054459..0000000000000000000000000000000000000000 --- a/docs-cn/16-iot-bigdata/_category_.yml +++ /dev/null @@ -1,3 +0,0 @@ -label: 物联网大数据 -link: - type: generated-index \ No newline at end of file diff --git a/docs-cn/17-train-fqa/01-faq.md b/docs-cn/17-train-fqa/01-faq.md deleted file mode 100644 index 27ba469415211f05639b0f70a13cffa67ac8bd51..0000000000000000000000000000000000000000 --- a/docs-cn/17-train-fqa/01-faq.md +++ /dev/null @@ -1,222 +0,0 @@ -# 常见问题及反馈 - -## 问题反馈 - -如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包: - -1. /var/log/taos (如果没有修改过默认路径) -2. /etc/taos - -附上必要的问题描述,包括使用的 TDengine 版本信息、平台环境信息、发生该问题的执行操作、出现问题的表征及大概的时间,在 [GitHub](https://github.com/taosdata/TDengine) 提交 issue。 - -为了保证有足够的 debug 信息,如果问题能够重复,请修改/etc/taos/taos.cfg 文件,最后面添加一行“debugFlag 135"(不带引号本身),然后重启 taosd, 重复问题,然后再递交。也可以通过如下 SQL 语句,临时设置 taosd 的日志级别。 - -``` - alter dnode debugFlag 135; -``` - -但系统正常运行时,请一定将 debugFlag 设置为 131,否则会产生大量的日志信息,降低系统效率。 - -## 常见问题列表 - -**1. TDengine2.0 之前的版本升级到 2.0 及以上的版本应该注意什么?☆☆☆** - -2.0 版在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作: - -1. 删除配置文件,执行 `sudo rm -rf /etc/taos/taos.cfg` -2. 删除日志文件,执行 `sudo rm -rf /var/log/taos/` -3. 确保数据已经不再需要的前提下,删除数据文件,执行 `sudo rm -rf /var/lib/taos/` -4. 安装最新稳定版本的 TDengine -5. 如果需要迁移数据或者数据文件损坏,请联系涛思数据官方技术支持团队,进行协助解决 - -**2. Windows 平台下 JDBCDriver 找不到动态链接库,怎么办?** - -请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/03/950.html)。 - -**3. 创建数据表时提示 more dnodes are needed** - -请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/03/965.html)。 - -**4. 如何让 TDengine crash 时生成 core 文件?** - -请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/06/974.html)。 - -**5. 遇到错误“Unable to establish connection”, 我怎么办?** - -客户端遇到连接故障,请按照下面的步骤进行检查: - -1. 检查网络环境 - - - 云服务器:检查云服务器的安全组是否打开 TCP/UDP 端口 6030-6042 的访问权限 - - 本地虚拟机:检查网络能否 ping 通,尽量避免使用`localhost` 作为 hostname - - 公司服务器:如果为 NAT 网络环境,请务必检查服务器能否将消息返回值客户端 - -2. 确保客户端与服务端版本号是完全一致的,开源社区版和企业版也不能混用 - -3. 在服务器,执行 `systemctl status taosd` 检查*taosd*运行状态。如果没有运行,启动*taosd* - -4. 确认客户端连接时指定了正确的服务器 FQDN (Fully Qualified Domain Name —— 可在服务器上执行 Linux 命令 hostname -f 获得),FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)。 - -5. ping 服务器 FQDN,如果没有反应,请检查你的网络,DNS 设置,或客户端所在计算机的系统 hosts 文件。如果部署的是 TDengine 集群,客户端需要能 ping 通所有集群节点的 FQDN。 - -6. 检查防火墙设置(Ubuntu 使用 ufw status,CentOS 使用 firewall-cmd --list-port),确认 TCP/UDP 端口 6030-6042 是打开的 - -7. 对于 Linux 上的 JDBC(ODBC, Python, Go 等接口类似)连接, 确保*libtaos.so*在目录*/usr/local/taos/driver*里, 并且*/usr/local/taos/driver*在系统库函数搜索路径*LD_LIBRARY_PATH*里 - -8. 对于 Windows 上的 JDBC, ODBC, Python, Go 等连接,确保*C:\TDengine\driver\taos.dll*在你的系统库函数搜索目录里 (建议*taos.dll*放在目录 _C:\Windows\System32_) - -9. 如果仍不能排除连接故障 - - - Linux 系统请使用命令行工具 nc 来分别判断指定端口的 TCP 和 UDP 连接是否通畅 - 检查 UDP 端口连接是否工作:`nc -vuz {hostIP} {port} ` - 检查服务器侧 TCP 端口连接是否工作:`nc -l {port}` - 检查客户端侧 TCP 端口连接是否工作:`nc {hostIP} {port}` - - - Windows 系统请使用 PowerShell 命令 Net-TestConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问 - -10. 也可以使用 taos 程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括 TCP 和 UDP):[TDengine 内嵌网络检测工具使用指南](https://www.taosdata.com/blog/2020/09/08/1816.html)。 - -**6. 遇到错误“Unexpected generic error in RPC”或者“Unable to resolve FQDN”,我怎么办?** - -产生这个错误,是由于客户端或数据节点无法解析 FQDN(Fully Qualified Domain Name)导致。对于 TAOS Shell 或客户端应用,请做如下检查: - -1. 请检查连接的服务器的 FQDN 是否正确,FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html) -2. 如果网络配置有 DNS server,请检查是否正常工作 -3. 如果网络没有配置 DNS server,请检查客户端所在机器的 hosts 文件,查看该 FQDN 是否配置,并是否有正确的 IP 地址 -4. 如果网络配置 OK,从客户端所在机器,你需要能 Ping 该连接的 FQDN,否则客户端是无法连接服务器的 -5. 如果服务器曾经使用过 TDengine,且更改过 hostname,建议检查 data 目录的 dnodeEps.json 是否符合当前配置的 EP,路径默认为/var/lib/taos/dnode。正常情况下,建议更换新的数据目录或者备份后删除以前的数据目录,这样可以避免该问题。 -6. 检查/etc/hosts 和/etc/hostname 是否是预配置的 FQDN - -**7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误** - -如果你确认语法正确,2.0 之前版本,请检查 SQL 语句长度是否超过 64K。如果超过,也会返回这个错误。 - -**8. 是否支持 validation queries?** - -TDengine 还没有一组专用的 validation queries。然而建议你使用系统监测的数据库”log"来做。 - - - -**9. 我可以删除或更新一条记录吗?** - -TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。 - -从 2.0.8.0 开始,TDengine 支持更新已经写入数据的功能。使用更新功能需要在创建数据库时使用 UPDATE 1 参数,之后可以使用 INSERT INTO 命令更新已经写入的相同时间戳数据。UPDATE 参数不支持 ALTER DATABASE 命令修改。没有使用 UPDATE 1 参数创建的数据库,写入相同时间戳的数据不会修改之前的数据,也不会报错。 - -另需注意,在 UPDATE 设置为 0 时,后发送的相同时间戳的数据会被直接丢弃,但并不会报错,而且仍然会被计入 affected rows (所以不能利用 INSERT 指令的返回信息进行时间戳查重)。这样设计的主要原因是,TDengine 把写入的数据看做一个数据流,无论时间戳是否出现冲突,TDengine 都认为产生数据的原始设备真实地产生了这样的数据。UPDATE 参数只是控制这样的流数据在进行持久化时要怎样处理——UPDATE 为 0 时,表示先写入的数据覆盖后写入的数据;而 UPDATE 为 1 时,表示后写入的数据覆盖先写入的数据。这种覆盖关系如何选择,取决于对数据的后续使用和统计中,希望以先还是后生成的数据为准。 - -此外,从 2.1.7.0 版本开始,支持将 UPDATE 参数设为 2,表示“支持部分列更新”。也即,当 UPDATE 设为 1 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL;而当 UPDATE 设为 2 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值。 - -**10. 我怎么创建超过 1024 列的表?** - -使用 2.0 及其以上版本,默认支持 1024 列;2.0 之前的版本,TDengine 最大允许创建 250 列的表。但是如果确实超过限值,建议按照数据特性,逻辑地将这个宽表分解成几个小表。(从 2.1.7.0 版本开始,表的最大列数增加到了 4096 列。) - -**11. 最有效的写入数据的方法是什么?** - -批量插入。每条写入语句可以一张表同时插入多条记录,也可以同时插入多张表的多条记录。 - -**12. Windows 系统下插入的 nchar 类数据中的汉字被解析成了乱码如何解决?** - -Windows 下插入 nchar 类的数据中如果有中文,请先确认系统的地区设置成了中国(在 Control Panel 里可以设置),这时 cmd 中的`taos`客户端应该已经可以正常工作了;如果是在 IDE 里开发 Java 应用,比如 Eclipse, Intellij,请确认 IDE 里的文件编码为 GBK(这是 Java 默认的编码类型),然后在生成 Connection 时,初始化客户端的配置,具体语句如下: - -```JAVA -Class.forName("com.taosdata.jdbc.TSDBDriver"); -Properties properties = new Properties(); -properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8"); -Connection = DriverManager.getConnection(url, properties); -``` - -**13.JDBC 报错: the excuted SQL is not a DML or a DDL?** - -请更新至最新的 JDBC 驱动 - -```xml - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.27 - -``` - -**14. taos connect failed, reason: invalid timestamp** - -常见原因是服务器和客户端时间没有校准,可以通过和时间服务器同步的方式(Linux 下使用 ntpdate 命令,Windows 在系统时间设置中选择自动同步)校准。 - -**15. 表名显示不全** - -由于 taos shell 在终端中显示宽度有限,有可能比较长的表名显示不全,如果按照显示的不全的表名进行相关操作会发生 Table does not exist 错误。解决方法可以是通过修改 taos.cfg 文件中的设置项 maxBinaryDisplayWidth, 或者直接输入命令 set max_binary_display_width 100。或者在命令结尾使用 \G 参数来调整结果的显示方式。 - -**16. 如何进行数据迁移?** - -TDengine 是根据 hostname 唯一标志一台机器的,在数据文件从机器 A 移动机器 B 时,注意如下两件事: - -- 2.0.0.0 至 2.0.6.x 的版本,重新配置机器 B 的 hostname 为机器 A 的 hostname。 -- 2.0.7.0 及以后的版本,到/var/lib/taos/dnode 下,修复 dnodeEps.json 的 dnodeId 对应的 FQDN,重启。确保机器内所有机器的此文件是完全相同的。 -- 1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。 - -**17. 如何在命令行程序 taos 中临时调整日志级别** - -为了调试方便,从 2.0.16 版本开始,命令行程序 taos 新增了与日志记录相关的两条指令: - -```mysql -ALTER LOCAL flag_name flag_value; -``` - -其含义是,在当前的命令行程序下,修改一个特定模块的日志记录级别(只对当前命令行程序有效,如果 taos 命令行程序重启,则需要重新设置): - -- flag_name 的取值可以是:debugFlag,cDebugFlag,tmrDebugFlag,uDebugFlag,rpcDebugFlag -- flag_value 的取值可以是:131(输出错误和警告日志),135( 输出错误、警告和调试日志),143( 输出错误、警告、调试和跟踪日志) - -```mysql -ALTER LOCAL RESETLOG; -``` - -其含义是,清空本机所有由客户端生成的日志文件。 - - - -**18. 时间戳的时区信息是怎样处理的?** - -TDengine 中时间戳的时区总是由客户端进行处理,而与服务端无关。具体来说,客户端会对 SQL 语句中的时间戳进行时区转换,转为 UTC 时区(即 Unix 时间戳——Unix Timestamp)再交由服务端进行写入和查询;在读取数据时,服务端也是采用 UTC 时区提供原始数据,客户端收到后再根据本地设置,把时间戳转换为本地系统所要求的时区进行显示。 - -客户端在处理时间戳字符串时,会采取如下逻辑: - -1. 在未做特殊设置的情况下,客户端默认使用所在操作系统的时区设置。 -2. 如果在 taos.cfg 中设置了 timezone 参数,则客户端会以这个配置文件中的设置为准。 -3. 如果在 C/C++/Java/Python 等各种编程语言的 Connector Driver 中,在建立数据库连接时显式指定了 timezone,那么会以这个指定的时区设置为准。例如 Java Connector 的 JDBC URL 中就有 timezone 参数。 -4. 在书写 SQL 语句时,也可以直接使用 Unix 时间戳(例如 `1554984068000`)或带有时区的时间戳字符串,也即以 RFC 3339 格式(例如 `2013-04-12T15:52:01.123+08:00`)或 ISO-8601 格式(例如 `2013-04-12T15:52:01.123+0800`)来书写时间戳,此时这些时间戳的取值将不再受其他时区设置的影响。 - - - -**19. TDengine 都会用到哪些网络端口?** - -在 TDengine 2.0 版本中,会用到以下这些网络端口(以默认端口 6030 为前提进行说明,如果修改了配置文件中的设置,那么这里列举的端口都会出现变化),管理员可以参考这里的信息调整防火墙设置: - -| 协议 | 默认端口 | 用途说明 | 修改方法 | -| :--- | :-------- | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- | -| TCP | 6030 | 客户端与服务端之间通讯。 | 由配置文件设置 serverPort 决定。 | -| TCP | 6035 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | -| TCP | 6040 | 多节点集群的节点间数据同步。 | 随 serverPort 端口变化。 | -| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](https://www.taosdata.com/cn/documentation/tools/adapter)。 | -| TCP | 6042 | Arbitrator 的服务端口。 | 随 Arbitrator 启动参数设置变化。 | -| TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | -| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| TCP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | -| TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | -| UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | -| UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | - -**20. go 语言编写组件编译失败怎样解决?** - -新版本 TDengine 2.3.0.0 包含一个使用 go 语言开发的 taosAdapter 独立组件,需要单独运行,取代之前 taosd 内置的 httpd ,提供包含原 httpd 功能以及支持多种其他软件(Prometheus、Telegraf、collectd、StatsD 等)的数据接入功能。 -使用最新 develop 分支代码编译需要先 `git submodule update --init --recursive` 下载 taosAdapter 仓库代码后再编译。 - -目前编译方式默认自动编译 taosAdapter。go 语言版本要求 1.14 以上,如果发生 go 编译错误,往往是国内访问 go mod 问题,可以通过设置 go 环境变量来解决: - -```sh -go env -w GO111MODULE=on -go env -w GOPROXY=https://goproxy.cn,direct -``` - -如果希望继续使用之前的内置 httpd,可以关闭 taosAdapter 编译,使用 -`cmake .. -DBUILD_HTTP=true` 使用原来内置的 httpd。 diff --git a/docs-cn/09-third-party/01-grafana.mdx b/docs-cn/20-third-party/01-grafana.mdx similarity index 86% rename from docs-cn/09-third-party/01-grafana.mdx rename to docs-cn/20-third-party/01-grafana.mdx index c34c617010daf92225f5e086355ec5d822c39d51..569cd750475447c9c6d107949c99b9405867916e 100644 --- a/docs-cn/09-third-party/01-grafana.mdx +++ b/docs-cn/20-third-party/01-grafana.mdx @@ -1,10 +1,9 @@ --- sidebar_label: Grafana +title: Grafana --- -# Grafana - -TDengine 能够与开源数据可视化系统 [Grafana](https://www.grafana.com/) 快速集成搭建数据监测报警系统,整个过程无需任何代码开发,TDengine 中数据表中内容可以在仪表盘(DashBoard)上进行可视化展现。关于 TDengine 插件的使用您可以在[GitHub](https://github.com/taosdata/grafanaplugin/blob/master/README.md)中了解更多。 +TDengine 能够与开源数据可视化系统 [Grafana](https://www.grafana.com/) 快速集成搭建数据监测报警系统,整个过程无需任何代码开发,TDengine 中数据表的内容可以在仪表盘(DashBoard)上进行可视化展现。关于 TDengine 插件的使用您可以在[GitHub](https://github.com/taosdata/grafanaplugin/blob/master/README.md)中了解更多。 ## 安装 Grafana @@ -12,20 +11,20 @@ TDengine 能够与开源数据可视化系统 [Grafana](https://www.grafana.com/ ## 配置 Grafana -TDengine 的 Grafana 插件托管在 GitHub,可从 下载,当前最新版本为 3.1.3。 +TDengine 的 Grafana 插件托管在 GitHub,可从 下载,当前最新版本为 3.1.4。 推荐使用 [`grafana-cli` 命令行工具](https://grafana.com/docs/grafana/latest/administration/cli/) 进行插件安装。 ```bash sudo -u grafana grafana-cli \ - --pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip \ + --pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v3.1.4/tdengine-datasource-3.1.4.zip \ plugins install tdengine-datasource ``` 或者下载到本地并解压到 Grafana 插件目录。 ```bash -GF_VERSION=3.1.3 +GF_VERSION=3.1.4 wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip ``` @@ -45,7 +44,7 @@ allow_loading_unsigned_plugins = tdengine-datasource 在 Docker 环境下,可以使用如下的环境变量设置自动安装并设置 TDengine 插件: ```bash -GF_INSTALL_PLUGINS=https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip;tdengine-datasource +GF_INSTALL_PLUGINS=https://github.com/taosdata/grafanaplugin/releases/download/v3.1.4/tdengine-datasource-3.1.4.zip;tdengine-datasource GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=tdengine-datasource ``` @@ -65,7 +64,7 @@ GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=tdengine-datasource ![img](/img/connections/add_datasource3.jpg) -- Host: TDengine 集群的中任意一台服务器的 IP 地址与 TDengine RESTful 接口的端口号(6041),默认 http://localhost:6041。注意:从 2.4 版本开始 RESTful 服务默认使用独立组件 taosAdapter 提供,请参考相关文档配置部署。 +- Host: TDengine 集群中提供 REST 服务 (在 2.4 之前由 taosd 提供, 从 2.4 开始由 taosAdapter 提供)的组件所在服务器的 IP 地址与 TDengine REST 服务的端口号(6041),默认 http://localhost:6041。 - User:TDengine 用户名。 - Password:TDengine 用户密码。 @@ -93,4 +92,4 @@ GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=tdengine-datasource ### 导入 Dashboard -在 2.3.3.0 及以上版本,您可以导入 TDinsight Dashboard (Grafana Dashboard ID: [15167](https://grafana.com/grafana/dashboards/15167)) 作为 TDengine 集群的监控可视化工具。安装和使用说明请见 [TDinsight 用户手册](https://www.taosdata.com/cn/documentation/tools/insight)。 +在 2.3.3.0 及以上版本,您可以导入 TDinsight Dashboard (Grafana Dashboard ID: [15167](https://grafana.com/grafana/dashboards/15167)) 作为 TDengine 集群的监控可视化工具。安装和使用说明请见 [TDinsight 用户手册](/reference/tdinsight/)。 diff --git a/docs-cn/20-third-party/02-prometheus.md b/docs-cn/20-third-party/02-prometheus.md new file mode 100644 index 0000000000000000000000000000000000000000..0fe534b8df263064e5269e1732b69893efd7a79a --- /dev/null +++ b/docs-cn/20-third-party/02-prometheus.md @@ -0,0 +1,89 @@ +--- +sidebar_label: Prometheus +title: Prometheus +--- + +import Prometheus from "../14-reference/_prometheus.mdx" + +Prometheus 是一款流行的开源监控告警系统。Prometheus 于2016年加入了 Cloud Native Computing Foundation (云原生云计算基金会,简称 CNCF),成为继 Kubernetes 之后的第二个托管项目,该项目拥有非常活跃的开发人员和用户社区。 + +Prometheus 提供了 `remote_write` 和 `remote_read` 接口来利用其它数据库产品作为它的存储引擎。为了让 Prometheus 生态圈的用户能够利用 TDengine 的高效写入和查询,TDengine 也提供了对这两个接口的支持。 + +通过适当的配置, Prometheus 的数据可以通过 `remote_write` 接口存储到 TDengine 中,也可以通过 `remote_read` 接口来查询存储在 TDengine 中的数据,充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 + +## 前置条件 + +要将 Prometheus 数据写入 TDengine 需要以下几方面的准备工作。 +- TDengine 集群已经部署并正常运行 +- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- Prometheus 已经安装。安装 Prometheus 请参考[官方文档](https://prometheus.io/docs/prometheus/latest/installation/) + +## 配置步骤 + + +## 验证方法 + +重启 Prometheus 后可参考以下示例验证从 Prometheus 向 TDengine 写入数据并能够正确读出。 + +### 使用 TDengine CLI 查询写入数据 +``` +taos> show databases; + name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | +==================================================================================================================================================================================================================================================================================== + test | 2022-04-12 08:07:58.756 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | + log | 2022-04-20 07:19:50.260 | 2 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | + prometheus_data | 2022-04-20 07:21:09.202 | 158 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | + db | 2022-04-15 06:37:08.512 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | +Query OK, 4 row(s) in set (0.000585s) + +taos> use prometheus_data; +Database changed. + +taos> show stables; + name | created_time | columns | tags | tables | +============================================================================================ + metrics | 2022-04-20 07:21:09.209 | 2 | 1 | 1389 | +Query OK, 1 row(s) in set (0.000487s) + +taos> select * from metrics limit 10; + ts | value | labels | +============================================================================================= + 2022-04-20 07:21:09.193000000 | 0.000024996 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:14.193000000 | 0.000024996 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:19.193000000 | 0.000024996 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:24.193000000 | 0.000024996 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:29.193000000 | 0.000024996 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:09.193000000 | 0.000054249 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:14.193000000 | 0.000054249 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:19.193000000 | 0.000054249 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:24.193000000 | 0.000054249 | {"__name__":"go_gc_duration... | + 2022-04-20 07:21:29.193000000 | 0.000054249 | {"__name__":"go_gc_duration... | +Query OK, 10 row(s) in set (0.011146s) +``` + +### 使用 promql-cli 通过 remote_read 从 TDengine 读取数据 + +安装 promql-cli + +``` + go install github.com/nalbury/promql-cli@latest +``` + +在 TDengine 和 taosAdapter 服务运行状态对 Prometheus 数据进行查询 + +``` +ubuntu@shuduo-1804 ~ $ promql-cli --host "http://127.0.0.1:9090" "sum(up) by (job)" +JOB VALUE TIMESTAMP +prometheus 1 2022-04-20T08:05:26Z +node 1 2022-04-20T08:05:26Z +``` + +暂停 taosAdapter 服务后对 Prometheus 数据进行查询 + +``` +ubuntu@shuduo-1804 ~ $ sudo systemctl stop taosadapter.service +ubuntu@shuduo-1804 ~ $ promql-cli --host "http://127.0.0.1:9090" "sum(up) by (job)" +VALUE TIMESTAMP + +``` + diff --git a/docs-cn/20-third-party/03-telegraf.md b/docs-cn/20-third-party/03-telegraf.md new file mode 100644 index 0000000000000000000000000000000000000000..88a69211c0592940d7f75d34c03bcc0593cd74d6 --- /dev/null +++ b/docs-cn/20-third-party/03-telegraf.md @@ -0,0 +1,67 @@ +--- +sidebar_label: Telegraf +title: Telegraf 写入 +--- + +import Telegraf from "../14-reference/_telegraf.mdx" + +Telegraf 是一款十分流行的指标采集开源软件。在数据采集和平台监控系统中,Telegraf 可以采集多种组件的运行信息,而不需要自己手写脚本定时采集,降低数据获取的难度。 + +只需要将 Telegraf 的输出配置增加指向 taosAdapter 对应的 url 并修改若干配置项即可将 Telegraf 的数据写入到 TDengine 中。将 Telegraf 的数据存在到 TDengine 中可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 + +## 前置条件 + +要将 Telegraf 数据写入 TDengine 需要以下几方面的准备工作。 +- TDengine 集群已经部署并正常运行 +- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- Telegraf 已经安装。安装 Telegraf 请参考[官方文档](https://docs.influxdata.com/telegraf/v1.22/install/) + +## 配置步骤 + + +## 验证方法 + +重启 Telegraf 服务: + +``` +sudo systemctl restart telegraf +``` + +使用 TDengine CLI 验证从 Telegraf 向 TDengine 写入数据并能够正确读出: + +``` +taos> show databases; + name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | +==================================================================================================================================================================================================================================================================================== + telegraf | 2022-04-20 08:47:53.488 | 22 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | + log | 2022-04-20 07:19:50.260 | 9 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | +Query OK, 2 row(s) in set (0.002401s) + +taos> use telegraf; +Database changed. + +taos> show stables; + name | created_time | columns | tags | tables | +============================================================================================ + swap | 2022-04-20 08:47:53.532 | 7 | 1 | 1 | + cpu | 2022-04-20 08:48:03.488 | 11 | 2 | 5 | + system | 2022-04-20 08:47:53.512 | 8 | 1 | 1 | + diskio | 2022-04-20 08:47:53.550 | 12 | 2 | 15 | + kernel | 2022-04-20 08:47:53.503 | 6 | 1 | 1 | + mem | 2022-04-20 08:47:53.521 | 35 | 1 | 1 | + processes | 2022-04-20 08:47:53.555 | 12 | 1 | 1 | + disk | 2022-04-20 08:47:53.541 | 8 | 5 | 2 | +Query OK, 8 row(s) in set (0.000521s) + +taos> select * from telegraf.system limit 10; + ts | load1 | load5 | load15 | n_cpus | n_users | uptime | uptime_format | host +| +============================================================================================================================================================================================================================================= + 2022-04-20 08:47:50.000000000 | 0.000000000 | 0.050000000 | 0.070000000 | 4 | 1 | 5533 | 1:32 | shuduo-1804 +| + 2022-04-20 08:48:00.000000000 | 0.000000000 | 0.050000000 | 0.070000000 | 4 | 1 | 5543 | 1:32 | shuduo-1804 +| + 2022-04-20 08:48:10.000000000 | 0.000000000 | 0.040000000 | 0.070000000 | 4 | 1 | 5553 | 1:32 | shuduo-1804 +| +Query OK, 3 row(s) in set (0.013269s) +``` diff --git a/docs-cn/20-third-party/05-collectd.md b/docs-cn/20-third-party/05-collectd.md new file mode 100644 index 0000000000000000000000000000000000000000..04892fd42e92e962fcccadf626f67c432e78d286 --- /dev/null +++ b/docs-cn/20-third-party/05-collectd.md @@ -0,0 +1,73 @@ +--- +sidebar_label: collectd +title: collectd 写入 +--- + +import CollectD from "../14-reference/_collectd.mdx" + +collectd 是一个用来收集系统性能的守护进程。collectd 提供各种存储方式来存储不同值的机制。它会在系统运行和存储信息时周期性的统计系统的相关统计信息。利用这些信息有助于查找当前系统性能瓶颈和预测系统未来的负载等。 + +只需要将 collectd 的配置指向运行 taosAdapter 的服务器域名(或 IP 地址)和相应端口即可将 collectd 采集的数据写入到 TDengine,可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 + +## 前置条件 + +要将 collectd 数据写入 TDengine,需要几方面的准备工作。 +- TDengine 集群已经部署并正常运行 +- taosAdapter 已经安装并正常运行,具体细节请参考[ taosAdapter 的使用手册](/reference/taosadapter) +- collectd 已经安装。安装 collectd 请参考[官方文档](https://collectd.org/download.shtml) + +## 配置步骤 + + +## 验证方法 + +重启 collectd + +``` +sudo systemctl restart collectd +``` + +使用 TDengine CLI 验证从 collectd 向 TDengine 写入数据并能够正确读出: + +``` +taos> show databases; + name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | +==================================================================================================================================================================================================================================================================================== + collectd | 2022-04-20 09:27:45.460 | 95 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | + log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | +Query OK, 2 row(s) in set (0.003266s) + +taos> use collectd; +Database changed. + +taos> show stables; + name | created_time | columns | tags | tables | +============================================================================================ + load_1 | 2022-04-20 09:27:45.492 | 2 | 2 | 1 | + memory_value | 2022-04-20 09:27:45.463 | 2 | 3 | 6 | + df_value | 2022-04-20 09:27:45.463 | 2 | 4 | 25 | + load_2 | 2022-04-20 09:27:45.501 | 2 | 2 | 1 | + load_0 | 2022-04-20 09:27:45.485 | 2 | 2 | 1 | + interface_1 | 2022-04-20 09:27:45.488 | 2 | 3 | 12 | + irq_value | 2022-04-20 09:27:45.476 | 2 | 3 | 31 | + interface_0 | 2022-04-20 09:27:45.480 | 2 | 3 | 12 | + entropy_value | 2022-04-20 09:27:45.473 | 2 | 2 | 1 | + swap_value | 2022-04-20 09:27:45.477 | 2 | 3 | 5 | +Query OK, 10 row(s) in set (0.002236s) + +taos> select * from collectd.memory_value limit 10; + ts | value | host | type_instance | type | +========================================================================================================================================================= + 2022-04-20 09:27:45.459653462 | 54689792.000000000 | shuduo-1804 | buffered | memory | + 2022-04-20 09:27:55.453168283 | 57212928.000000000 | shuduo-1804 | buffered | memory | + 2022-04-20 09:28:05.453004291 | 57942016.000000000 | shuduo-1804 | buffered | memory | + 2022-04-20 09:27:45.459653462 | 6381330432.000000000 | shuduo-1804 | free | memory | + 2022-04-20 09:27:55.453168283 | 6357643264.000000000 | shuduo-1804 | free | memory | + 2022-04-20 09:28:05.453004291 | 6349987840.000000000 | shuduo-1804 | free | memory | + 2022-04-20 09:27:45.459653462 | 107040768.000000000 | shuduo-1804 | slab_recl | memory | + 2022-04-20 09:27:55.453168283 | 107536384.000000000 | shuduo-1804 | slab_recl | memory | + 2022-04-20 09:28:05.453004291 | 107634688.000000000 | shuduo-1804 | slab_recl | memory | + 2022-04-20 09:27:45.459653462 | 309137408.000000000 | shuduo-1804 | used | memory | +Query OK, 10 row(s) in set (0.010348s) +``` + diff --git a/docs-cn/20-third-party/06-statsd.md b/docs-cn/20-third-party/06-statsd.md new file mode 100644 index 0000000000000000000000000000000000000000..bcbd6c42ae5dd1c83be428797544d254e11a0238 --- /dev/null +++ b/docs-cn/20-third-party/06-statsd.md @@ -0,0 +1,68 @@ +--- +sidebar_label: StatsD +title: StatsD 直接写入 +--- + +import StatsD from "../14-reference/_statsd.mdx" + +StatsD 是汇总和总结应用指标的一个简单的守护进程,近些年来发展迅速,已经变成了一个用于收集应用性能指标的统一的协议。 + +只需要在 StatsD 的配置文件中填写运行 taosAdapter 的服务器域名(或 IP 地址)和相应端口即可将 StatsD 的数据写入到 TDengine 中,可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 + +## 前置条件 + +要将 StatsD 数据写入 TDengine 需要以下几方面的准备工作。 +- TDengine 集群已经部署并正常运行 +- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- StatsD 已经安装。安装 StatsD 请参考[官方文档](https://github.com/statsd/statsd) + +## 配置步骤 + + +## 验证方法 + +运行 StatsD: + +``` +$ node stats.js config.js & +[1] 8546 +$ 20 Apr 09:54:41 - [8546] reading config file: exampleConfig.js +20 Apr 09:54:41 - server is up INFO +``` + +使用 nc 写入测试数据: + +``` +$ echo "foo:1|c" | nc -u -w0 127.0.0.1 8125 +``` + +使用 TDengine CLI 验证从 StatsD 向 TDengine 写入数据并能够正确读出: + +``` +Welcome to the TDengine shell from Linux, Client Version:2.4.0.0 +Copyright (c) 2020 by TAOS Data, Inc. All rights reserved. + +taos> show databases; + name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | +==================================================================================================================================================================================================================================================================================== + log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | + statsd | 2022-04-20 09:54:51.220 | 1 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | +Query OK, 2 row(s) in set (0.003142s) + +taos> use statsd; +Database changed. + +taos> show stables; + name | created_time | columns | tags | tables | +============================================================================================ + foo | 2022-04-20 09:54:51.234 | 2 | 1 | 1 | +Query OK, 1 row(s) in set (0.002161s) + +taos> select * from foo; + ts | value | metric_type | +======================================================================================= + 2022-04-20 09:54:51.219614235 | 1 | counter | +Query OK, 1 row(s) in set (0.004179s) + +taos> +``` diff --git a/docs-cn/20-third-party/07-icinga2.md b/docs-cn/20-third-party/07-icinga2.md new file mode 100644 index 0000000000000000000000000000000000000000..ed1f1404a730eca5f51e2ff9bbcd54949018f8ea --- /dev/null +++ b/docs-cn/20-third-party/07-icinga2.md @@ -0,0 +1,74 @@ +--- +sidebar_label: icinga2 +title: icinga2 写入 +--- + +import Icinga2 from "../14-reference/_icinga2.mdx" + +icinga2 是一款开源主机、网络监控软件,最初由 Nagios 网络监控应用发展而来。目前,icinga2 遵从 GNU GPL v2 许可协议发行。 + +只需要将 icinga2 的配置修改指向 taosAdapter 对应的服务器和相应端口即可将 icinga2 采集的数据存在到 TDengine 中,可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 + +## 前置条件 + +要将 icinga2 数据写入 TDengine 需要以下几方面的准备工作。 +- TDengine 集群已经部署并正常运行 +- taosAdapter 已经安装并正常运行。具体细节请参考[ taosAdapter 的使用手册](/reference/taosadapter) +- icinga2 已经安装。安装 icinga2 请参考[官方文档](https://icinga.com/docs/icinga-2/latest/doc/02-installation/) + +## 配置步骤 + + +## 验证方法 + +重启 taosAdapter: +``` +sudo systemctl restart taosadapter +``` + +重启 icinga2: + +``` +sudo systemctl restart icinga2 +``` + +等待 10 秒左右后,使用 TDengine CLI 查询 TDengine 验证是否创建相应数据库并写入数据: + +``` +taos> show databases; + name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | +==================================================================================================================================================================================================================================================================================== + log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | + icinga2 | 2022-04-20 12:11:39.697 | 13 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | +Query OK, 2 row(s) in set (0.001867s) + +taos> use icinga2; +Database changed. + +taos> show stables; + name | created_time | columns | tags | tables | +============================================================================================ + icinga.service.users.state_... | 2022-04-20 12:11:39.726 | 2 | 1 | 1 | + icinga.service.users.acknow... | 2022-04-20 12:11:39.756 | 2 | 1 | 1 | + icinga.service.procs.downti... | 2022-04-20 12:11:44.541 | 2 | 1 | 1 | + icinga.service.users.users | 2022-04-20 12:11:39.770 | 2 | 1 | 1 | + icinga.service.procs.procs_min | 2022-04-20 12:11:44.599 | 2 | 1 | 1 | + icinga.service.users.users_min | 2022-04-20 12:11:39.809 | 2 | 1 | 1 | + icinga.check.max_check_atte... | 2022-04-20 12:11:39.847 | 2 | 3 | 2 | + icinga.service.procs.state_... | 2022-04-20 12:11:44.522 | 2 | 1 | 1 | + icinga.service.procs.procs_... | 2022-04-20 12:11:44.576 | 2 | 1 | 1 | + icinga.service.users.users_... | 2022-04-20 12:11:39.796 | 2 | 1 | 1 | + icinga.check.latency | 2022-04-20 12:11:39.869 | 2 | 3 | 2 | + icinga.service.procs.procs_... | 2022-04-20 12:11:44.588 | 2 | 1 | 1 | + icinga.service.users.downti... | 2022-04-20 12:11:39.746 | 2 | 1 | 1 | + icinga.service.users.users_... | 2022-04-20 12:11:39.783 | 2 | 1 | 1 | + icinga.service.users.reachable | 2022-04-20 12:11:39.736 | 2 | 1 | 1 | + icinga.service.procs.procs | 2022-04-20 12:11:44.565 | 2 | 1 | 1 | + icinga.service.procs.acknow... | 2022-04-20 12:11:44.554 | 2 | 1 | 1 | + icinga.service.procs.state | 2022-04-20 12:11:44.509 | 2 | 1 | 1 | + icinga.service.procs.reachable | 2022-04-20 12:11:44.532 | 2 | 1 | 1 | + icinga.check.current_attempt | 2022-04-20 12:11:39.825 | 2 | 3 | 2 | + icinga.check.execution_time | 2022-04-20 12:11:39.898 | 2 | 3 | 2 | + icinga.service.users.state | 2022-04-20 12:11:39.704 | 2 | 1 | 1 | +Query OK, 22 row(s) in set (0.002317s) +``` diff --git a/docs-cn/20-third-party/08-tcollector.md b/docs-cn/20-third-party/08-tcollector.md new file mode 100644 index 0000000000000000000000000000000000000000..5fbf001fa093f978dfdcd0f3f344a131d56ed9f9 --- /dev/null +++ b/docs-cn/20-third-party/08-tcollector.md @@ -0,0 +1,67 @@ +--- +sidebar_label: TCollector +title: TCollector 写入 +--- + +import Tcollector from "../14-reference/_tcollector.mdx" + +TCollector 是 openTSDB 的一部分,它用来采集客户端日志发送给数据库。 + +只需要将 TCollector 的配置修改指向运行 taosAdapter 的服务器域名(或 IP 地址)和相应端口即可将 TCollector 采集的数据存在到 TDengine 中,可以充分利用 TDengine 对时序数据的高效存储查询性能和集群处理能力。 + +## 前置条件 + +要将 TCollector 数据写入 TDengine 需要以下几方面的准备工作。 +- TDengine 集群已经部署并正常运行 +- taosAdapter 已经安装并正常运行。具体细节请参考 [taosAdapter 的使用手册](/reference/taosadapter) +- TCollector 已经安装。安装 TCollector 请参考[官方文档](http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html#installation-of-tcollector) + +## 配置步骤 + + +## 验证方法 + +重启 taosAdapter: + +``` +sudo systemctl restart taosadapter +``` + +手动执行 `sudo ./tcollector.py` + +等待数秒后使用 TDengine CLI 查询 TDengine 是否创建相应数据库并写入数据。 + +``` +taos> show databases; + name | created_time | ntables | vgroups | replica | quorum | days | keep | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | cachelast | precision | update | status | +==================================================================================================================================================================================================================================================================================== + tcollector | 2022-04-20 12:44:49.604 | 88 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ns | 2 | ready | + log | 2022-04-20 07:19:50.260 | 11 | 1 | 1 | 1 | 10 | 3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | 0 | ms | 0 | ready | +Query OK, 2 row(s) in set (0.002679s) + +taos> use tcollector; +Database changed. + +taos> show stables; + name | created_time | columns | tags | tables | +============================================================================================ + proc.meminfo.hugepages_rsvd | 2022-04-20 12:44:53.945 | 2 | 1 | 1 | + proc.meminfo.directmap1g | 2022-04-20 12:44:54.110 | 2 | 1 | 1 | + proc.meminfo.vmallocchunk | 2022-04-20 12:44:53.724 | 2 | 1 | 1 | + proc.meminfo.hugepagesize | 2022-04-20 12:44:54.004 | 2 | 1 | 1 | + tcollector.reader.lines_dro... | 2022-04-20 12:44:49.675 | 2 | 1 | 1 | + proc.meminfo.sunreclaim | 2022-04-20 12:44:53.437 | 2 | 1 | 1 | + proc.stat.ctxt | 2022-04-20 12:44:55.363 | 2 | 1 | 1 | + proc.meminfo.swaptotal | 2022-04-20 12:44:53.158 | 2 | 1 | 1 | + proc.uptime.total | 2022-04-20 12:44:52.813 | 2 | 1 | 1 | + tcollector.collector.lines_... | 2022-04-20 12:44:49.895 | 2 | 2 | 51 | + proc.meminfo.vmallocused | 2022-04-20 12:44:53.704 | 2 | 1 | 1 | + proc.meminfo.memavailable | 2022-04-20 12:44:52.939 | 2 | 1 | 1 | + sys.numa.foreign_allocs | 2022-04-20 12:44:57.929 | 2 | 2 | 1 | + proc.meminfo.committed_as | 2022-04-20 12:44:53.639 | 2 | 1 | 1 | + proc.vmstat.pswpin | 2022-04-20 12:44:54.177 | 2 | 1 | 1 | + proc.meminfo.cmafree | 2022-04-20 12:44:53.865 | 2 | 1 | 1 | + proc.meminfo.mapped | 2022-04-20 12:44:53.349 | 2 | 1 | 1 | + proc.vmstat.pgmajfault | 2022-04-20 12:44:54.251 | 2 | 1 | 1 | +... +``` diff --git a/docs-cn/09-third-party/09-emq-broder.md b/docs-cn/20-third-party/09-emq-broder.md similarity index 96% rename from docs-cn/09-third-party/09-emq-broder.md rename to docs-cn/20-third-party/09-emq-broder.md index 0d2bd4d2f996247119bca736d295b7faf5d55e23..a661943088e2b478ff9940b6679a47c1bbb039ed 100644 --- a/docs-cn/09-third-party/09-emq-broder.md +++ b/docs-cn/20-third-party/09-emq-broder.md @@ -1,7 +1,6 @@ --- sidebar_label: EMQ Broker +title: EMQ Broker 写入 --- -# EMQ Broker 写入 - MQTT 是流行的物联网数据传输协议,[EMQ](https://github.com/emqx/emqx)是一开源的 MQTT Broker 软件,无需任何代码,只需要在 EMQ Dashboard 里使用“规则”做简单配置,即可将 MQTT 的数据直接写入 TDengine。EMQ X 支持通过 发送到 Web 服务的方式保存数据到 TDEngine,也在企业版上提供原生的 TDEngine 驱动实现直接保存。详细使用方法请参考 [EMQ 官方文档](https://docs.emqx.io/broker/latest/cn/rule/rule-example.html#%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE%E5%88%B0-tdengine)。 diff --git a/docs-cn/09-third-party/10-hive-mq-broker.md b/docs-cn/20-third-party/10-hive-mq-broker.md similarity index 95% rename from docs-cn/09-third-party/10-hive-mq-broker.md rename to docs-cn/20-third-party/10-hive-mq-broker.md index 81657da1009c286ece906116abf33428868c1971..f75ed793d6272ae27f92676e2096ef455f638aa6 100644 --- a/docs-cn/09-third-party/10-hive-mq-broker.md +++ b/docs-cn/20-third-party/10-hive-mq-broker.md @@ -1,7 +1,6 @@ --- sidebar_label: HiveMQ Broker +title: HiveMQ Broker 写入 --- -# HiveMQ Broker 写入 - [HiveMQ](https://www.hivemq.com/) 是一个提供免费个人版和企业版的 MQTT 代理,主要用于企业和新兴的机器到机器 M2M 通讯和内部传输,满足可伸缩性、易管理和安全特性。HiveMQ 提供了开源的插件开发包。可以通过 HiveMQ extension - TDengine 保存数据到 TDengine。详细使用方法请参考 [HiveMQ extension - TDengine 说明文档](https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README.md)。 diff --git a/docs-cn/20-third-party/_category_.yml b/docs-cn/20-third-party/_category_.yml new file mode 100644 index 0000000000000000000000000000000000000000..cf9d95e5f9e0941f64159ffa17619839fdafbf05 --- /dev/null +++ b/docs-cn/20-third-party/_category_.yml @@ -0,0 +1,6 @@ +label: 第三方工具 +link: + type: generated-index + slug: /third-party/ + description: TDengine 通过对标准 SQL 命令、常用数据库连接器标准(例如 JDBC)、ORM 以及其他流行时序数据库写入协议(例如 InfluxDB Line Protocol、OpenTSDB JSON、OpenTSDB Telnet 等)的支持可以使 TDengine 非常容易和第三方工具共同使用。 + diff --git a/docs-cn/20-third-party/_deploytaosadapter.mdx b/docs-cn/20-third-party/_deploytaosadapter.mdx new file mode 100644 index 0000000000000000000000000000000000000000..ec40744c9a4620801e59aadd49996a0b6381f1bc --- /dev/null +++ b/docs-cn/20-third-party/_deploytaosadapter.mdx @@ -0,0 +1,18 @@ +### 部署taosAdapter + +taosAdapter 可以和 TDengine 部署在同一个系统中,也可以分离部署。 + +启动 taosAdapter: + +``` +systemctl start taosadapter +``` + +检查 taosAdapter 的运行状态: + +``` +systemctl status taosadapter +``` + +taosAdapter 详细的配置参数和使用请参考 `taosadapter --help` 命令输出以及 [参考文档](/reference/taosadapter) 。 + diff --git a/docs-cn/13-tdinternal/01-arch.md b/docs-cn/21-tdinternal/01-arch.md similarity index 55% rename from docs-cn/13-tdinternal/01-arch.md rename to docs-cn/21-tdinternal/01-arch.md index f276a8e86ba52aa63a49b0c8f3022a3acb7f39ba..84f6d239dd9fb347a4850966d391cb0b629a7944 100644 --- a/docs-cn/13-tdinternal/01-arch.md +++ b/docs-cn/21-tdinternal/01-arch.md @@ -1,155 +1,8 @@ --- -sidebar_label: 数据模型和整体架构 +sidebar_label: 整体架构 +title: 整体架构 --- -# 数据模型和整体架构 - -## 数据模型 - -### 物联网典型场景 - -在典型的物联网、车联网、运维监测场景中,往往有多种不同类型的数据采集设备,采集一个到多个不同的物理量。而同一种采集设备类型,往往又有多个具体的采集设备分布在不同的地点。大数据处理系统就是要将各种采集的数据汇总,然后进行计算和分析。对于同一类设备,其采集的数据都是很规则的。以智能电表为例,假设每个智能电表采集电流、电压、相位三个量,其采集的数据类似如下的表格: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
设备ID时间戳采集量标签
Device IDTime StampcurrentvoltagephaselocationgroupId
d1001153854868500010.32190.31Beijing.Chaoyang2
d1002153854868400010.22200.23Beijing.Chaoyang3
d1003153854868650011.52210.35Beijing.Haidian3
d1004153854868550013.42230.29Beijing.Haidian2
d1001153854869500012.62180.33Beijing.Chaoyang2
d1004153854869660011.82210.28Beijing.Haidian2
d1002153854869665010.32180.25Beijing.Chaoyang3
d1001153854869680012.32210.31Beijing.Chaoyang2
- -
表 1:智能电表数据示例
- -每一条记录都有设备 ID,时间戳,采集的物理量(如上图中的电流、电压、相位),还有与每个设备相关的静态标签(如上述表 1 中的位置 Location 和分组 groupId)。每个设备是受外界的触发,或按照设定的周期采集数据。采集的数据点是时序的,是一个数据流。 - -### 数据特征 - -除时序特征外,仔细研究发现,物联网、车联网、运维监测类数据还具有很多其他明显的特征: - -1. 数据高度结构化; -2. 数据极少有更新或删除操作; -3. 无需传统数据库的事务处理; -4. 相对互联网应用,写多读少; -5. 流量平稳,根据设备数量和采集频次,可以预测出来; -6. 用户关注的是一段时间的趋势,而不是某一特定时间点的值; -7. 数据有保留期限; -8. 数据的查询分析一定是基于时间段和空间区域; -9. 除存储、查询操作外,还需要各种统计和实时计算操作; -10. 数据量巨大,一天可能采集的数据就可以超过 100 亿条。 - -充分利用上述特征,TDengine 采取了经特殊优化的存储和计算设计来处理时序数据,它将系统处理能力显著提高,同时大幅降低了系统运维的复杂度。 - -### 关系型数据库模型 - -因为采集的数据一般是结构化数据,同时为降低学习门槛,TDengine 采用传统的关系型数据库模型管理数据。因此用户需要先创建库,然后创建表,之后才能插入或查询数据。TDengine 采用的是结构化存储,而不是 NoSQL 的 key-value 存储。 - -### 一个数据采集点一张表 - -为充分利用其数据的时序性和其他数据特点,TDengine 要求**对每个数据采集点单独建表**(比如有一千万个智能电表,就需创建一千万张表,上述表格中的 d1001, d1002, d1003, d1004 都需单独建表),用来存储这个采集点所采集的时序数据。这种设计有几大优点: - -1. 能保证一个采集点的数据在存储介质上是以块为单位连续存储的。如果读取一个时间段的数据,它能大幅减少随机读取操作,成数量级的提升读取和查询速度。 -2. 由于不同采集设备产生数据的过程完全独立,每个设备的数据源是唯一的,一张表也就只有一个写入者,这样就可采用无锁方式来写,写入速度就能大幅提升。 -3. 对于一个数据采集点而言,其产生的数据是时序的,因此写的操作可用追加的方式实现,进一步大幅提高数据写入速度。 - -如果采用传统的方式,将多个设备的数据写入一张表,由于网络延时不可控,不同设备的数据到达服务器的时序是无法保证的,写入操作是要有锁保护的,而且一个设备的数据是难以保证连续存储在一起的。**采用一个数据采集点一张表的方式,能最大程度的保证单个数据采集点的插入和查询的性能是最优的。** - -TDengine 建议用数据采集点的名字(如上表中的 D1001)来做表名。每个数据采集点可能同时采集多个物理量(如上表中的 curent, voltage, phase),每个物理量对应一张表中的一列,数据类型可以是整型、浮点型、字符串等。除此之外,表的第一列必须是时间戳,即数据类型为 timestamp。对采集的数据,TDengine 将自动按照时间戳建立索引,但对采集的物理量不建任何索引。数据用列式存储方式保存。 - -### 超级表:同一类型数据采集点的集合 - -由于一个数据采集点一张表,导致表的数量巨增,难以管理,而且应用经常需要做采集点之间的聚合操作,聚合的操作也变得复杂起来。为解决这个问题,TDengine 引入超级表(Super Table,简称为 STable)的概念。 - -超级表是指某一特定类型的数据采集点的集合。同一类型的数据采集点,其表的结构是完全一样的,但每个表(数据采集点)的静态属性(标签)是不一样的。描述一个超级表(某一特定类型的数据采集点的集合),除需要定义采集量的表结构之外,还需要定义其标签的 schema,标签的数据类型可以是整数、浮点数、字符串,标签可以有多个,可以事后增加、删除或修改。如果整个系统有 N 个不同类型的数据采集点,就需要建立 N 个超级表。 - -在 TDengine 的设计里,**表用来代表一个具体的数据采集点,超级表用来代表一组相同类型的数据采集点集合**。当为某个具体数据采集点创建表时,用户使用超级表的定义做模板,同时指定该具体采集点(表)的标签值。与传统的关系型数据库相比,表(一个数据采集点)是带有静态标签的,而且这些标签可以事后增加、删除、修改。**一张超级表包含有多张表,这些表具有相同的时序数据 schema,但带有不同的标签值**。 - -当对多个具有相同数据类型的数据采集点进行聚合操作时,TDengine 会先把满足标签过滤条件的表从超级表中找出来,然后再扫描这些表的时序数据,进行聚合操作,这样需要扫描的数据集会大幅减少,从而显著提高聚合计算的性能。 - ## 集群与基本逻辑单元 TDengine 的设计是基于单个硬件、软件系统不可靠,基于任何单台计算机都无法提供足够计算能力和存储能力处理海量数据的假设进行设计的。因此 TDengine 从研发的第一天起,就按照分布式高可靠架构进行设计,是支持水平扩展的,这样任何单台或多台服务器发生硬件故障或软件错误都不影响系统的可用性和可靠性。同时,通过节点虚拟化并辅以自动化负载均衡技术,TDengine 能最高效率地利用异构集群中的计算和存储资源降低硬件投资。 @@ -162,25 +15,25 @@ TDengine 分布式架构的逻辑结构图如下:
图 1 TDengine架构示意图
-一个完整的 TDengine 系统是运行在一到多个物理节点上的,逻辑上,它包含数据节点(dnode)、TDengine 应用驱动(taosc)以及应用(app)。系统中存在一到多个数据节点,这些数据节点组成一个集群(cluster)。应用通过 taosc 的 API 与 TDengine 集群进行互动。下面对每个逻辑单元进行简要介绍。 +一个完整的 TDengine 系统是运行在一到多个物理节点上的,逻辑上,它包含数据节点(dnode)、TDengine 应用驱动(taosc)以及应用(app)。系统中存在一到多个数据节点,这些数据节点组成一个集群(cluster)。应用通过 taosc 的 API 与 TDengine 集群进行互动。下面对每个逻辑单元进行简要介绍。 -**物理节点(pnode):** pnode 是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有 OS 的物理机、虚拟机或 Docker 容器。物理节点由其配置的 FQDN (Fully Qualified Domain Name)来标识。TDengine 完全依赖 FQDN 来进行网络通讯,如果不了解 FQDN,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 +**物理节点(pnode):** pnode 是一独立运行、拥有自己的计算、存储和网络能力的计算机,可以是安装有 OS 的物理机、虚拟机或 Docker 容器。物理节点由其配置的 FQDN(Fully Qualified Domain Name)来标识。TDengine 完全依赖 FQDN 来进行网络通讯,如果不了解 FQDN,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。 -**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode)。dnode 在系统中的唯一标识由实例的 End Point (EP)决定。EP 是 dnode 所在物理节点的 FQDN (Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 +**数据节点(dnode):** dnode 是 TDengine 服务器侧执行代码 taosd 在物理节点上的一个运行实例,一个工作的系统必须有至少一个数据节点。dnode 包含零到多个逻辑的虚拟节点(vnode),零或者至多一个逻辑的管理节点(mnode)。dnode 在系统中的唯一标识由实例的 End Point(EP)决定。EP 是 dnode 所在物理节点的 FQDN(Fully Qualified Domain Name)和系统所配置的网络端口号(Port)的组合。通过配置不同的端口,一个物理节点(一台物理机、虚拟机或容器)可以运行多个实例,或有多个数据节点。 -**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2, V3, V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 +**虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2,V3,V4 等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的 EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 -**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(开源版最多不超过 3 个) mnode,它们自动构建成为一个虚拟管理节点组(图中 M0, M1, M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步, 任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 +**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(开源版最多不超过 3 个)mnode,它们自动构建成为一个虚拟管理节点组(图中 M0,M1,M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步,任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的 EP 来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的 EP。 -**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vnode group)来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 vnode group ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 +**虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vgroup)来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建 DB 时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 VGroup ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的 ID 也不会被收回重复利用。 -**TAOSC:** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,为支持全分布式的 RESTful 接口,taosc 在 TDengine 集群的每个 dnode 上都有一运行实例。 +**Taosc** taosc 是 TDengine 给应用提供的驱动程序(driver),负责处理应用与集群的接口交互,提供 C/C++ 语言原生接口,内嵌于 JDBC、C#、Python、Go、Node.js 语言连接库里。应用都是通过 taosc 而不是直接连接集群中的数据节点与整个集群进行交互的。这个模块负责获取并缓存元数据;将插入、查询等请求转发到正确的数据节点;在把结果返回给应用时,还需要负责最后一级的聚合、排序、过滤等操作。对于 JDBC、C/C++、C#、Python、Go、Node.js 接口而言,这个模块是在应用所处的物理节点上运行。同时,为支持全分布式的 RESTful 接口,taosc 在 TDengine 集群的每个 dnode 上都有一运行实例。 ### 节点之间的通讯 **通讯方式:**TDengine 系统的各个数据节点之间,以及应用驱动与各数据节点之间的通讯是通过 TCP/UDP 进行的。因为考虑到物联网场景,数据写入的包一般不大,因此 TDengine 除采用 TCP 做传输之外,还采用 UDP 方式,因为 UDP 更加高效,而且不受连接数的限制。TDengine 实现了自己的超时、重传、确认等机制,以确保 UDP 的可靠传输。对于数据量不到 15K 的数据包,采取 UDP 的方式进行传输,超过 15K 的,或者是查询类的操作,自动采取 TCP 的方式进行传输。同时,TDengine 根据配置和数据包,会自动对数据进行压缩/解压缩,数字签名/认证等处理。对于数据节点之间的数据复制,只采用 TCP 方式进行数据传输。 -**FQDN 配置:**一个数据节点有一个或多个 FQDN,可以在系统配置文件 taos.cfg 通过参数"fqdn"进行指定,如果没有指定,系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN,可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP,因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EP(End Point) 由 FQDN + Port 组成。采用 FQDN,需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。 +**FQDN 配置:**一个数据节点有一个或多个 FQDN,可以在系统配置文件 taos.cfg 通过参数“fqdn”进行指定,如果没有指定,系统将自动获取计算机的 hostname 作为其 FQDN。如果节点没有配置 FQDN,可以直接将该节点的配置参数 fqdn 设置为它的 IP 地址。但不建议使用 IP,因为 IP 地址可变,一旦变化,将让集群无法正常工作。一个数据节点的 EP(End Point)由 FQDN + Port 组成。采用 FQDN,需要保证 DNS 服务正常工作,或者在节点以及应用所在的节点配置好 hosts 文件。另外,这个参数值的长度需要控制在 96 个字符以内。 **端口配置:**一个数据节点对外的端口由 TDengine 的系统配置参数 serverPort 决定,对集群内部通讯的端口是 serverPort+5。为支持多线程高效的处理 UDP 数据,每个对内和对外的 UDP 连接,都需要占用 5 个连续的端口。 @@ -188,9 +41,9 @@ TDengine 分布式架构的逻辑结构图如下: - 集群数据节点对外提供 RESTful 服务占用一个 TCP 端口,是 serverPort+11。 - 集群内数据节点与 Arbitrator 节点之间通讯占用一个 TCP 端口,是 serverPort+12。 -因此一个数据节点总的端口范围为 serverPort 到 serverPort+12,总共 13 个 TCP/UDP 端口。使用时,需要确保防火墙将这些端口打开。每个数据节点可以配置不同的 serverPort。(详细的端口情况请参见 [TDengine 2.0 端口说明](https://www.taosdata.com/cn/documentation/faq#port)) +因此一个数据节点总的端口范围为 serverPort 到 serverPort+12,总共 13 个 TCP/UDP 端口。使用时,需要确保防火墙将这些端口打开。每个数据节点可以配置不同的 serverPort。详细的端口情况请参见 [TDengine 2.0 端口说明](/train-faq/faq#port) -**集群对外连接:**TDengine 集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,连接需要提供的网络参数是一数据节点的 End Point(FQDN 加配置的端口号)。通过命令行 CLI 启动应用 taos 时,可以通过选项-h 来指定数据节点的 FQDN, -P 来指定其配置的端口号,如果端口不配置,将采用 TDengine 的系统配置参数 serverPort。 +**集群对外连接:**TDengine 集群可以容纳单个、多个甚至几千个数据节点。应用只需要向集群中任何一个数据节点发起连接即可,连接需要提供的网络参数是一数据节点的 End Point(FQDN 加配置的端口号)。通过命令行 CLI 启动应用 taos 时,可以通过选项-h 来指定数据节点的 FQDN,-P 来指定其配置的端口号,如果端口不配置,将采用 TDengine 的系统配置参数 serverPort。 **集群内部通讯:**各个数据节点之间通过 TCP/UDP 进行连接。一个数据节点启动时,将获取 mnode 所在的 dnode 的 EP 信息,然后与系统中的 mnode 建立起连接,交换信息。获取 mnode 的 EP 信息有三步: @@ -200,11 +53,11 @@ TDengine 分布式架构的逻辑结构图如下: 获取 mnode EP 列表后,数据节点发起连接,如果连接成功,则成功加入进工作的集群,如果不成功,则尝试 mnode EP 列表中的下一个。如果都尝试了,但连接都仍然失败,则休眠几秒后,再进行尝试。 -**MNODE 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?这是系统自动决定的,无需任何人工干预。原则如下:一个数据节点启动时,会检查自己的 End Point, 并与获取的 mnode EP List 进行比对,如果在其中,该数据节点认为自己应该启动 mnode 模块,成为 mnode。如果自己的 EP 不在 mnode EP List 里,则不启动 mnode 模块。在系统的运行过程中,由于负载均衡、宕机等原因,mnode 有可能迁移至新的 dnode,但一切都是透明的,无需人工干预,配置参数的修改,是 mnode 自己根据资源做出的决定。 +**Mnode 的选择:**TDengine 逻辑上有管理节点,但没有单独的执行代码,服务器侧只有一套执行代码 taosd。那么哪个数据节点会是管理节点呢?这是系统自动决定的,无需任何人工干预。原则如下:一个数据节点启动时,会检查自己的 End Point,并与获取的 mnode EP List 进行比对,如果在其中,该数据节点认为自己应该启动 mnode 模块,成为 mnode。如果自己的 EP 不在 mnode EP List 里,则不启动 mnode 模块。在系统的运行过程中,由于负载均衡、宕机等原因,mnode 有可能迁移至新的 dnode,但一切都是透明的,无需人工干预,配置参数的修改,是 mnode 自己根据资源做出的决定。 -**新数据节点的加入:**系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用 TDengine CLI 连接到现有工作的数据节点,然后用命令"create dnode"将新的数据节点的 End Point 添加进去; 第二步:在新的数据节点的系统配置参数文件 taos.cfg 里,将 firstEp, secondEp 参数设置为现有集群中任意两个数据节点的 EP 即可。具体添加的详细步骤请见详细的用户手册。这样就把集群一步一步的建立起来。 +**新数据节点的加入:**系统有了一个数据节点后,就已经成为一个工作的系统。添加新的节点进集群时,有两个步骤,第一步:使用 TDengine CLI 连接到现有工作的数据节点,然后用命令“CREATE DNODE”将新的数据节点的 End Point 添加进去;第二步:在新的数据节点的系统配置参数文件 taos.cfg 里,将 firstEp,secondEp 参数设置为现有集群中任意两个数据节点的 EP 即可。具体添加的详细步骤请见详细的用户手册。这样就把集群一步一步的建立起来。 -**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,但 mnode 是系统自动创建并维护的,因此对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list, 就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 +**重定向:**无论是 dnode 还是 taosc,最先都是要发起与 mnode 的连接,但 mnode 是系统自动创建并维护的,因此对于用户来说,并不知道哪个 dnode 在运行 mnode。TDengine 只要求向系统中任何一个工作的 dnode 发起连接即可。因为任何一个正在运行的 dnode,都维护有目前运行的 mnode EP List。当收到一个来自新启动的 dnode 或 taosc 的连接请求,如果自己不是 mnode,则将 mnode EP List 回复给对方,taosc 或新启动的 dnode 收到这个 list,就重新尝试建立连接。当 mnode EP List 发生改变,通过节点之间的消息交互,各个数据节点就很快获取最新列表,并通知 taosc。 ### 一个典型的消息流程 @@ -216,14 +69,14 @@ TDengine 分布式架构的逻辑结构图如下: 1. 应用通过 JDBC 或其他 API 接口发起插入数据的请求。 2. taosc 会检查缓存,看是否保存有该表的 meta data。如果有,直接到第 4 步。如果没有,taosc 将向 mnode 发出 get meta-data 请求。 -3. mnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema, 而且还有该表所属的 vgroup 信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point)。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode, taosc 将向下一个 mnode 发出请求。 +3. mnode 将该表的 meta-data 返回给 taosc。Meta-data 包含有该表的 schema,而且还有该表所属的 vgroup 信息(vnode ID 以及所在的 dnode 的 End Point,如果副本数为 N,就有 N 组 End Point)。如果 taosc 迟迟得不到 mnode 回应,而且存在多个 mnode,taosc 将向下一个 mnode 发出请求。 4. taosc 向 master vnode 发起插入请求。 5. vnode 插入数据后,给 taosc 一个应答,表示插入成功。如果 taosc 迟迟得不到 vnode 的回应,taosc 会认为该节点已经离线。这种情况下,如果被插入的数据库有多个副本,taosc 将向 vgroup 里下一个 vnode 发出插入请求。 6. taosc 通知 APP,写入成功。 对于第二和第三步,taosc 启动时,并不知道 mnode 的 End Point,因此会直接向配置的集群对外服务的 End Point 发起请求。如果接收到该请求的 dnode 并没有配置 mnode,该 dnode 会在回复的消息中告知 mnode EP 列表,这样 taosc 会重新向新的 mnode 的 EP 发出获取 meta-data 的请求。 -对于第四和第五步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 master,就假设第一个 vnodeID 就是 master,向它发出请求。如果接收到请求的 vnode 并不是 master,它会在回复中告知谁是 master,这样 taosc 就向建议的 master vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 master 节点的信息。 +对于第四和第五步,没有缓存的情况下,taosc 无法知道虚拟节点组里谁是 master,就假设第一个 vnodeID 就是 master,向它发出请求。如果接收到请求的 vnode 并不是 master,它会在回复中告知谁是 master,这样 taosc 就向建议的 master vnode 发出请求。一旦得到插入成功的回复,taosc 会缓存 master 节点的信息。 上述是插入数据的流程,查询、计算的流程也完全一致。taosc 把这些复杂的流程全部封装屏蔽了,对于应用来说无感知也无需任何特别处理。 @@ -246,27 +99,27 @@ TDengine 存储的数据包括采集的时序数据以及库、表相关的元 ### 数据分片 -对于海量的数据管理,为实现水平扩展,一般都需要采取分片(Sharding)分区(Partitioning)策略。TDengine 是通过 vnode 来实现数据分片的,通过一个时间段一个数据文件来实现时序数据分区的。 +对于海量的数据管理,为实现水平扩展,一般都需要采取分片(Sharding)分区(Partitioning)策略。TDengine 是通过 vnode 来实现数据分片的,通过一个时间段一个数据文件来实现时序数据分区的。 -vnode(虚拟数据节点)负责为采集的时序数据提供写入、查询和计算功能。为便于负载均衡、数据恢复、支持异构环境,TDengine 将一个数据节点根据其计算和存储资源切分为多个 vnode。这些 vnode 的管理是 TDengine 自动完成的,对应用完全透明。 +vnode(虚拟数据节点)负责为采集的时序数据提供写入、查询和计算功能。为便于负载均衡、数据恢复、支持异构环境,TDengine 将一个数据节点根据其计算和存储资源切分为多个 vnode。这些 vnode 的管理是 TDengine 自动完成的,对应用完全透明。 -对于单独一个数据采集点,无论其数据量多大,一个 vnode(或 vnode group, 如果副本数大于 1)有足够的计算资源和存储资源来处理(如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。一个数据节点上,除非特殊配置,一个 DB 拥有的 vnode 数目不会超过系统核的数目。 +对于单独一个数据采集点,无论其数据量多大,一个 vnode(或 vgroup,如果副本数大于 1)有足够的计算资源和存储资源来处理(如果每秒生成一条 16 字节的记录,一年产生的原始数据不到 0.5G),因此 TDengine 将一张表(一个数据采集点)的所有数据都存放在一个 vnode 里,而不会让同一个采集点的数据分布到两个或多个 dnode 上。而且一个 vnode 可存储多个数据采集点(表)的数据,一个 vnode 可容纳的表的数目的上限为一百万。设计上,一个 vnode 里所有的表都属于同一个 DB。一个数据节点上,除非特殊配置,一个 DB 拥有的 vnode 数目不会超过系统核的数目。 -创建 DB 时,系统并不会马上分配资源。但当创建一张表时,系统将看是否有已经分配的 vnode, 且该 vnode 是否有空余的表空间,如果有,立即在该有空位的 vnode 创建表。如果没有,系统将从集群中,根据当前的负载情况,在一个 dnode 上创建一新的 vnode, 然后创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup (虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 +创建 DB 时,系统并不会马上分配资源。但当创建一张表时,系统将看是否有已经分配的 vnode,且该 vnode 是否有空余的表空间,如果有,立即在该有空位的 vnode 创建表。如果没有,系统将从集群中,根据当前的负载情况,在一个 dnode 上创建一新的 vnode,然后创建表。如果 DB 有多个副本,系统不是只创建一个 vnode,而是一个 vgroup(虚拟数据节点组)。系统对 vnode 的数目没有任何限制,仅仅受限于物理节点本身的计算和存储资源。 -每张表的 meta data(包含 schema, 标签等)也存放于 vnode 里,而不是集中存放于 mnode,实际上这是对 Meta 数据的分片,这样便于高效并行的进行标签过滤操作。 +每张表的 meta data(包含 schema,标签等)也存放于 vnode 里,而不是集中存放于 mnode,实际上这是对 Meta 数据的分片,这样便于高效并行的进行标签过滤操作。 ### 数据分区 -TDengine 除 vnode 分片之外,还对时序数据按照时间段进行分区。每个数据文件只包含一个时间段的时序数据,时间段的长度由 DB 的配置参数 days 决定。这种按时间段分区的方法还便于高效实现数据的保留策略,只要数据文件超过规定的天数(系统配置参数 keep),将被自动删除。而且不同的时间段可以存放于不同的路径和存储介质,以便于大数据的冷热管理,实现多级存储。 +TDengine 除 vnode 分片之外,还对时序数据按照时间段进行分区。每个数据文件只包含一个时间段的时序数据,时间段的长度由 DB 的配置参数 days 决定。这种按时间段分区的方法还便于高效实现数据的保留策略,只要数据文件超过规定的天数(系统配置参数 keep),将被自动删除。而且不同的时间段可以存放于不同的路径和存储介质,以便于大数据的冷热管理,实现多级存储。 总的来说,**TDengine 是通过 vnode 以及时间两个维度,对大数据进行切分**,便于并行高效的管理,实现水平扩展。 ### 负载均衡 -每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。 +每个 dnode 都定时向 mnode(虚拟管理节点)报告其状态(包括硬盘空间、内存大小、CPU、网络、虚拟节点个数等),因此 mnode 了解整个集群的状态。基于整体状态,当 mnode 发现某个 dnode 负载过重,它会将 dnode 上的一个或多个 vnode 挪到其他 dnode。在挪动过程中,对外服务继续进行,数据插入、查询和计算操作都不受影响。 -如果 mnode 一段时间没有收到 dnode 的状态报告,mnode 会认为这个 dnode 已经离线。如果离线时间超过一定时长(时长由配置参数 offlineThreshold 决定),该 dnode 将被 mnode 强制剔除出集群。该 dnode 上的 vnodes 如果副本数大于 1,系统将自动在其他 dnode 上创建新的副本,以保证数据的副本数。如果该 dnode 上还有 mnode, 而且 mnode 的副本数大于 1,系统也将自动在其他 dnode 上创建新的 mnode, 以保证 mnode 的副本数。 +如果 mnode 一段时间没有收到 dnode 的状态报告,mnode 会认为这个 dnode 已经离线。如果离线时间超过一定时长(时长由配置参数 offlineThreshold 决定),该 dnode 将被 mnode 强制剔除出集群。该 dnode 上的 vnodes 如果副本数大于 1,系统将自动在其他 dnode 上创建新的副本,以保证数据的副本数。如果该 dnode 上还有 mnode,而且 mnode 的副本数大于 1,系统也将自动在其他 dnode 上创建新的 mnode,以保证 mnode 的副本数。 当新的数据节点被添加进集群,因为新的计算和存储被添加进来,系统也将自动启动负载均衡流程。 @@ -288,9 +141,9 @@ Master Vnode 遵循下面的写入流程: 1. master vnode 收到应用的数据插入请求,验证 OK,进入下一步; 2. 如果系统配置参数 walLevel 大于 0,vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; -3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 slave vnodes, 该转发包带有数据的版本号(version); +3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 slave vnodes,该转发包带有数据的版本号(version); 4. 写入内存,并将记录加入到 skip list; -5. master vnode 返回确认信息给应用,表示写入成功。 +5. master vnode 返回确认信息给应用,表示写入成功; 6. 如果第 2、3、4 步中任何一步失败,将直接返回错误给应用。 ### Slave Vnode 写入流程 @@ -309,16 +162,16 @@ Master Vnode 遵循下面的写入流程: ### 主从选择 -Vnode 会保持一个数据版本号(version),对内存数据进行持久化存储时,对该版本号也进行持久化存储。每个数据更新操作,无论是采集的时序数据还是元数据,这个版本号将增加 1。 +Vnode 会保持一个数据版本号(version),对内存数据进行持久化存储时,对该版本号也进行持久化存储。每个数据更新操作,无论是采集的时序数据还是元数据,这个版本号将增加 1。 -一个 vnode 启动时,角色(master、slave) 是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,其中包括 version 和自己的角色。通过 status 的交换,系统进入选主流程,规则如下: +一个 vnode 启动时,角色(master、slave)是不定的,数据是处于未同步状态,它需要与虚拟节点组内其他节点建立 TCP 连接,并互相交换 status,其中包括 version 和自己的角色。通过 status 的交换,系统进入选主流程,规则如下: 1. 如果只有一个副本,该副本永远就是 master 2. 所有副本都在线时,版本最高的被选为 master 3. 在线的虚拟节点数过半,而且有虚拟节点是 slave 的话,该虚拟节点自动成为 master 4. 对于 2 和 3,如果多个虚拟节点满足成为 master 的要求,那么虚拟节点组的节点列表里,最前面的选为 master -更多的关于数据复制的流程,请见[TDengine 2.0 数据复制模块设计](https://www.taosdata.com/cn/documentation/architecture/replica/)。 +更多的关于数据复制的流程,请见[《TDengine 2.0 数据复制模块设计》](/tdinternal/replica/)。 ### 同步复制 @@ -344,11 +197,11 @@ TDengine 采用数据驱动的方式让缓存中的数据写入硬盘进行持 对于采集的数据,一般有保留时长,这个时长由系统配置参数 keep 决定。超过这个设置天数的数据文件,将被系统自动删除,释放存储空间。 -给定 days 与 keep 两个参数,一个典型工作状态的 vnode 中总的数据文件数为:`向上取整(keep/days)+1`个。总的数据文件个数不宜过大,也不宜过小。10 到 100 以内合适。基于这个原则,可以设置合理的 days。目前的版本,参数 keep 可以修改,但对于参数 days,一旦设置后,不可修改。 +给定 days 与 keep 两个参数,一个典型工作状态的 vnode 中总的数据文件数为:向上取整 `(keep/days)+1` 个。总的数据文件个数不宜过大,也不宜过小。10 到 100 以内合适。基于这个原则,可以设置合理的 days。目前的版本,参数 keep 可以修改,但对于参数 days,一旦设置后,不可修改。 在每个数据文件里,一张表的数据是一块一块存储的。一张表可以有一到多个数据文件块。在一个文件块里,数据是列式存储的,占用的是一片连续的存储空间,这样大大提高读取速度。文件块的大小由系统参数 maxRows (每块最大记录条数)决定,缺省值为 4096。这个值不宜过大,也不宜过小。过大,定位具体时间段的数据的搜索时间会变长,影响读取速度;过小,数据块的索引太大,压缩效率偏低,也影响读取速度。 -每个数据文件(.data 结尾)都有一个对应的索引文件(.head 结尾),该索引文件对每张表都有一数据块的摘要信息,记录了每个数据块在数据文件中的偏移量,数据的起止时间等信息,以帮助系统迅速定位需要查找的数据。每个数据文件还有一对应的 last 文件(.last 结尾),该文件是为防止落盘时数据块碎片化而设计的。如果一张表落盘的记录条数没有达到系统配置参数 minRows(每块最小记录条数),将被先存储到 last 文件,等下次落盘时,新落盘的记录将与 last 文件的记录进行合并,再写入数据文件。 +每个数据文件(.data 结尾)都有一个对应的索引文件(.head 结尾),该索引文件对每张表都有一数据块的摘要信息,记录了每个数据块在数据文件中的偏移量,数据的起止时间等信息,以帮助系统迅速定位需要查找的数据。每个数据文件还有一对应的 last 文件(.last 结尾),该文件是为防止落盘时数据块碎片化而设计的。如果一张表落盘的记录条数没有达到系统配置参数 minRows(每块最小记录条数),将被先存储到 last 文件,等下次落盘时,新落盘的记录将与 last 文件的记录进行合并,再写入数据文件。 数据写入磁盘时,根据系统配置参数 comp 决定是否压缩数据。TDengine 提供了三种压缩选项:无压缩、一阶段压缩和两阶段压缩,分别对应 comp 值为 0、1 和 2 的情况。一阶段压缩根据数据的类型进行了相应的压缩,压缩算法包括 delta-delta 编码、simple 8B 方法、zig-zag 编码、LZ4 等算法。二阶段压缩在一阶段压缩的基础上又用通用压缩算法进行了压缩,压缩率更高。 @@ -376,7 +229,7 @@ dataDir [path] 需要说明的是,数据在不同级别的存储介质上的移动,是由系统自动完成的,用户无需干预。 - primary: 是否为主挂载点,0(否)或 1(是),省略默认为 1。 -在配置中,只允许一个主挂载点的存在(level=0, primary=1),例如采用如下的配置方式: +在配置中,只允许一个主挂载点的存在(level=0,primary=1),例如采用如下的配置方式: ``` dataDir /mnt/data1 0 1 @@ -387,19 +240,21 @@ dataDir /mnt/data5 2 0 dataDir /mnt/data6 2 0 ``` -注意: +:::note 1. 多级存储不允许跨级配置,合法的配置方案有:仅 0 级,仅 0 级+ 1 级,以及 0 级+ 1 级+ 2 级。而不允许只配置 level=0 和 level=2,而不配置 level=1。 2. 禁止手动移除使用中的挂载盘,挂载盘目前不支持非本地的网络盘。 3. 多级存储目前不支持删除已经挂载的硬盘的功能。 +::: + ## 数据查询 TDengine 提供了多种多样针对表和超级表的查询处理功能,除了常规的聚合查询之外,还提供针对时序数据的窗口查询、统计聚合等功能。TDengine 的查询处理需要客户端、vnode、mnode 节点协同完成。 ### 单表查询 -SQL 语句的解析和校验工作在客户端完成。解析 SQL 语句并生成抽象语法树(Abstract Syntax Tree, AST),然后对其进行校验和检查。以及向管理节点(mnode)请求查询中指定表的元数据信息(table metadata)。 +SQL 语句的解析和校验工作在客户端完成。解析 SQL 语句并生成抽象语法树(Abstract Syntax Tree,AST),然后对其进行校验和检查。以及向管理节点(mnode)请求查询中指定表的元数据信息(table metadata)。 根据元数据信息中的 End Point 信息,将查询请求序列化后发送到该表所在的数据节点(dnode)。dnode 接收到查询请求后,识别出该查询请求指向的虚拟节点(vnode),将消息转发到 vnode 的查询执行队列。vnode 的查询执行线程建立基础的查询执行环境,并立即返回该查询请求,同时开始执行该查询。 @@ -423,7 +278,7 @@ SELECT COUNT(*) FROM d1001 INTERVAL(1h); SELECT COUNT(*) FROM d1001 WHERE ts >= '2017-7-14 00:00:00' AND ts < '2017-7-14 23:59:59' INTERVAL(1h) FILL(PREV); ``` -针对 d1001 设备采集数据统计每小时记录数,如果某一个小时不存在数据,则返回之前一个小时的统计数据。TDengine 提供前向插值(prev)、线性插值(linear)、NULL 值填充(NULL)、特定值填充(value)。 +针对 d1001 设备采集数据统计每小时记录数,如果某一个小时不存在数据,则返回之前一个小时的统计数据。TDengine 提供前向插值(prev)、线性插值(linear)、空值填充(NULL)、特定值填充(value)。 ### 多表聚合查询 @@ -434,7 +289,7 @@ TDengine 对每个数据采集点单独建表,但在实际应用中经常需
图 5 多表聚合查询原理图
1. 应用将一个查询条件发往系统; -2. taosc 将超级表的名字发往 meta node(管理节点); +2. taosc 将超级表的名字发往 meta node(管理节点); 3. 管理节点将超级表所拥有的 vnode 列表发回 taosc; 4. taosc 将计算的请求连同标签过滤条件发往这些 vnode 对应的多个数据节点; 5. 每个 vnode 先在内存里查找出自己节点里符合标签过滤条件的表的集合,然后扫描存储的时序数据,完成相应的聚合计算,将结果返回给 taosc; diff --git a/docs-cn/13-tdinternal/02-replica.md b/docs-cn/21-tdinternal/02-replica.md similarity index 99% rename from docs-cn/13-tdinternal/02-replica.md rename to docs-cn/21-tdinternal/02-replica.md index 037ce0682ade1677da00287dd5f30696c3eaf17b..6a384b982d22956dd514d8df05dc827ca6f8b729 100644 --- a/docs-cn/13-tdinternal/02-replica.md +++ b/docs-cn/21-tdinternal/02-replica.md @@ -1,9 +1,8 @@ --- sidebar_label: 数据复制模块设计 +title: 数据复制模块设计 --- -# 数据复制模块设计 - ## 数据复制概述 数据复制(Replication)是指同一份数据在多个物理地点保存。它的目的是防止数据丢失,提高系统的高可用性(High Availability),而且通过应用访问多个副本,提升数据查询性能。 @@ -14,7 +13,7 @@ TDengine面向的是物联网场景,需要支持数据的实时复制,来最 数据复制是与数据存储(写入、读取)密切相关的,但两者又是相对独立,可以完全脱耦的。在TDengine系统中,有两种不同类型的数据,一种是时序数据,由TSDB模块负责;一种是元数据(Meta Data), 由MNODE负责。这两种性质不同的数据都需要同步功能。数据复制模块通过不同的实例启动配置参数,为这两种类型数据都提供同步功能。 -在阅读本文之前,请先阅读《[TDengine 2.0 整体架构](https://www.taosdata.com/cn/documentation/architecture/)》,了解TDengine的集群设计和基本概念 +在阅读本文之前,请先阅读《[TDengine 2.0 整体架构](/tdinternal/arch/)》,了解TDengine的集群设计和基本概念 特别注明:本文中提到数据更新操作包括数据的增加、删除与修改。 diff --git a/docs-cn/21-tdinternal/03-taosd.md b/docs-cn/21-tdinternal/03-taosd.md new file mode 100644 index 0000000000000000000000000000000000000000..f0f50e03e277524fc37f44a2207b43e87898937e --- /dev/null +++ b/docs-cn/21-tdinternal/03-taosd.md @@ -0,0 +1,121 @@ +--- +sidebar_label: taosd 的设计 +title: taosd的设计 +--- + + +逻辑上,TDengine 系统包含 dnode,taosc 和 App,dnode 是服务器侧执行代码 taosd 的一个运行实例,因此 taosd 是 TDengine 的核心,本文对 taosd 的设计做一简单的介绍,模块内的实现细节请见其他文档。 + +## 系统模块图 + +taosd 包含 rpc,dnode,vnode,tsdb,query,cq,sync,wal,mnode,http,monitor 等模块,具体如下图: + +![modules.png](/img/architecture/modules.png) + +taosd 的启动入口是 dnode 模块,dnode 然后启动其他模块,包括可选配置的 http,monitor 模块。taosc 或 dnode 之间交互的消息都是通过 rpc 模块进行,dnode 模块根据接收到的消息类型,将消息分发到 vnode 或 mnode 的消息队列,或由 dnode 模块自己消费。dnode 的工作线程(worker)消费消息队列里的消息,交给 mnode 或 vnode 进行处理。下面对各个模块做简要说明。 + +## RPC模块 + +该模块负责 taosd 与 taosc,以及其他数据节点之间的通讯。TDengine 没有采取标准的 HTTP 或 gRPC 等第三方工具,而是实现了自己的通讯模块 RPC。 + +考虑到物联网场景下,数据写入的包一般不大,因此除支持 TCP 连接之外,RPC 还支持 UDP 连接。当数据包小于 15K 时,RPC 将采用 UDP 方式进行连接,否则将采用 TCP 连接。对于查询类的消息,RPC 不管包的大小,总是采取 TCP 连接。对于 UDP 连接,RPC 实现了自己的超时、重传、顺序检查等机制,以保证数据可靠传输。 + +RPC 模块还提供数据压缩功能,如果数据包的字节数超过系统配置参数 compressMsgSize,RPC 在传输中将自动压缩数据,以节省带宽。 + +为保证数据的安全和数据的 integrity,RPC 模块采用 MD5 做数字签名,对数据的真实性和完整性进行认证。 + +## DNODE模块 + +该模块是整个 taosd 的入口,它具体负责如下任务: + +- 系统的初始化,包括 + - 从文件 taos.cfg 读取系统配置参数,从文件 dnodeCfg.json 读取数据节点的配置参数; + - 启动 RPC 模块,并建立起与 taosc 通讯的 server 连接,与其他数据节点通讯的 server 连接; + - 启动并初始化 dnode 的内部管理,该模块将扫描该数据节点已有的 vnode ,并打开它们; + - 初始化可配置的模块,如 mnode,http,monitor 等。 +- 数据节点的管理,包括 + - 定时的向 mnode 发送 status 消息,报告自己的状态; + - 根据 mnode 的指示,创建、改变、删除 vnode; + - 根据 mnode 的指示,修改自己的配置参数; +- 消息的分发、消费,包括 + - 为每一个 vnode 和 mnode 的创建并维护一个读队列、一个写队列; + - 将从 taosc 或其他数据节点来的消息,根据消息类型,将其直接分发到不同的消息队列,或由自己的管理模块直接消费; + - 维护一个读的线程池,消费读队列的消息,交给 vnode 或 mnode 处理。为支持高并发,一个读线程(worker)可以消费多个队列的消息,一个读队列可以由多个 worker 消费; + - 维护一个写的线程池,消费写队列的消息,交给 vnode 或 mnode 处理。为保证写操作的序列化,一个写队列只能由一个写线程负责,但一个写线程可以负责多个写队列。 + +taosd 的消息消费由 dnode 通过读写线程池进行控制,是系统的中枢。该模块内的结构体图如下: + +![dnode.png](/img/architecture/dnode.png) + +## VNODE模块 + +vnode 是一独立的数据存储查询逻辑单元,但因为一个 vnode 只能容许一个 DB ,因此 vnode 内部没有 account,DB,user 等概念。为实现更好的模块化、封装以及未来的扩展,它有很多子模块,包括负责存储的 TSDB,负责查询的 query,负责数据复制的 sync,负责数据库日志的的 wal,负责连续查询的 cq(continuous query),负责事件触发的流计算的 event 等模块,这些子模块只与 vnode 模块发生关系,与其他模块没有任何调用关系。模块图如下: + +![vnode.png](/img/architecture/vnode.png) + +vnode 模块向下,与 dnodeVRead,dnodeVWrite 发生互动,向上,与子模块发生互动。它主要的功能有: + +- 协调各个子模块的互动。各个子模块之间都不直接调用,都需要通过 vnode 模块进行; +- 对于来自 taosc 或 mnode 的写操作,vnode 模块将其分解为写日志(wal),转发(sync),本地存储(TSDB)子模块的操作; +- 对于查询操作,分发到 query 模块进行。 + +一个数据节点里有多个 vnode,因此 vnode 模块是有多个运行实例的。每个运行实例是完全独立的。 + +vnode 与其子模块是通过 API 直接调用,而不是通过消息队列传递。而且各个子模块只与 vnode 模块有交互,不与 dnode,rpc 等模块发生任何直接关联。 + +## MNODE模块 + +mnode 是整个系统的大脑,负责整个系统的资源调度,负责 meta data 的管理与存储。 + +一个运行的系统里,只有一个 mnode,但它有多个副本(由系统配置参数 numOfMnodes 控制)。这些副本分布在不同的 dnode 里,目的是保证系统的高可靠运行。副本之间的数据复制是采用同步而非异步的方式,以确保数据的一致性,确保数据不会丢失。这些副本会自动选举一个 Master,其他副本是 slave。所有数据更新类的操作,都只能在 master 上进行,而查询类的可以在 slave 节点上进行。代码实现上,同步模块与 vnode 共享,但 mnode 被分配一个特殊的 vgroup ID: 1,而且 quorum 大于1。整个集群系统是由多个 dnode 组成的,运行的 mnode 的副本数不可能超过 dnode 的个数,但不会超过配置的副本数。如果某个 mnode 副本宕机一段时间,只要超过半数的 mnode 副本仍在运行,运行的 mnode 会自动根据整个系统的资源情况,在其他 dnode 里再启动一个 mnode,以保证运行的副本数。 + +各个 dnode 通过信息交换,保存有 mnode 各个副本的 End Point 列表,并向其中的 master 节点定时(间隔由系统配置参数 statusInterval 控制)发送 status 消息,消息体里包含该 dnode 的 CPU、内存、剩余存储空间、vnode 个数,以及各个 vnode 的状态(存储空间、原始数据大小、记录条数、角色等)。这样 mnode 就了解整个系统的资源情况,如果用户创建新的表,就可以决定需要在哪个 dnode 创建;如果增加或删除 dnode,或者监测到某 dnode 数据过热、或离线太长,就可以决定需要挪动那些 vnode,以实现负载均衡。 + +mnode 里还负责 account,user,DB,stable,table,vgroup,dnode 的创建、删除与更新。mnode 不仅把这些 entity 的 meta data 保存在内存,还做持久化存储。但为节省内存,各个表的标签值不保存在 mnode(保存在 vnode),而且子表不维护自己的 schema,而是与 stable 共享。为减小 mnode 的查询压力,taosc 会缓存 table、stable 的 schema。对于查询类的操作,各个 slave mnode 也可以提供,以减轻 master 压力。 + +## TSDB模块 + +TSDB 模块是 vnode 中的负责快速高并发地存储和读取属于该 vnode 的表的元数据及采集的时序数据的引擎。除此之外,TSDB 还提供了表结构的修改、表标签值的修改等功能。TSDB 提供 API 供 vnode 和 query 等模块调用。TSDB 中存储了两类数据,1:元数据信息;2:时序数据 + +### 元数据信息 + +TSDB 中存储的元数据包含属于其所在的 vnode 中表的类型,schema 的定义等。对于超级表和超级表下的子表而言,又包含了 tag 的 schema 定义以及子表的 tag 值等。对于元数据信息而言,TSDB 就相当于一个全内存的KV型数据库,属于该 vnode 的表对象全部在内存中,方便快速查询表的信息。除此之外,TSDB 还对其中的子表,按照 tag 的第一列取值做了全内存的索引,大大加快了对于标签的过滤查询。TSDB 中的元数据的最新状态在落盘时,会以追加(append-only)的形式,写入到 meta 文件中。meta 文件只进行追加操作,即便是元数据的删除,也会以一条记录的形式写入到文件末尾。TSDB 也提供了对于元数据的修改操作,如表 schema 的修改,tag schema 的修改以及 tag 值的修改等。 + +### 时序数据 + +每个 TSDB 在创建时,都会事先分配一定量的内存缓冲区,且内存缓冲区的大小可配可修改。表采集的时序数据,在写入 TSDB 时,首先以追加的方式写入到分配的内存缓冲区中,同时建立基于时间戳的内存索引,方便快速查询。当内存缓冲区的数据积累到一定的程度时(达到内存缓冲区总大小的 1/3),则会触发落盘操作,将缓冲区中的数据持久化到硬盘文件上。时序数据在内存缓冲区中是以行(row)的形式存储的。 + +而时序数据在写入到 TSDB 的数据文件时,是以列(column)的形式存储的。TSDB 中的数据文件包含多个数据文件组,每个数据文件组中又包含 .head、.data 和 .last 三个文件,如(v2f1801.head、v2f1801.data、v2f1801.last)数据文件组。TSDB 中的数据文件组是按照时间跨度进行分片的,默认是 10 天一个文件组,且可通过配置文件及建库选项进行配置。分片的数据文件组又按照编号递增排列,方便快速定位某一时间段的时序数据,高效定位数据文件组。时序数据在 TSDB 的数据文件中是以块的形式进行列式存储的,每个块中只包含一张表的数据,且数据在一个块中是按照时间顺序递增排列的。在一个数据文件组中,.head 文件负责存储数据块的索引及统计信息,如每个块的位置,压缩算法,时间戳范围等。存储在 .head 文件中一张表的索引信息是按照数据块中存储的数据的时间递增排列的,方便进行折半查找等工作。.head 和 .last文件是存储真实数据块的文件,若数据块中的数据累计到一定程度,则会写入 .data 文件中,否则,会写入 .last 文件中,等待下次落盘时合并数据写入 .data 文件中,从而大大减少文件中块的个数,避免数据的过度碎片化。 + +## Query模块 + +该模块负责整体系统的查询处理。客户端调用该该模块进行 SQL 语法解析,并将查询或写入请求发送到 vnode ,同时负责针对超级表的查询进行二阶段的聚合操作。在 vnode 端,该模块调用 TSDB 模块读取系统中存储的数据进行查询处理。query 模块还定义了系统能够支持的全部查询函数,查询函数的实现机制与查询框架无耦合,可以在不修改查询流程的情况下动态增加查询函数。详细的设计请参见《TDengine 2.0 查询模块设计》。 + +## SYNC模块 + +该模块实现数据的多副本复制,包括vnode与mnode的数据复制,支持异步和同步两种复制方式,以满足meta data与时序数据不同复制的需求。因为它为mnode与vnode共享,系统为mnode副本预留了一个特殊的vgroup ID:1。因此vnode group的ID是从2开始的。 + +每个vnode/mnode模块实例会有一对应的sync模块实例,他们是一一对应的。详细设计请见[TDengine 2.0 数据复制模块设计](/tdinternal/replica/) + +## WAL模块 + +该模块负责将新插入的数据写入 write ahead log(WAL),为vnode,mnode共享。以保证服务器 crash 或其他故障,能从 WAL 中恢复数据。 + +每个 vnode/mnode 模块实例会有一对应的 wal 模块实例,是完全一一对应的。WAL 的落盘操作由两个参数 walLevel,fsync 控制。看具体场景,如果要 100% 保证数据不会丢失,需要将 walLevel 配置为 2,fsync 设置为 0,每条数据插入请求,都会实时落盘后,才会给应用确认 + +## HTTP模块 + +该模块负责处理系统对外的 RESTful 接口,可以通过配置,由 dnode 启动或停止 。(仅 2.2 及之前的版本中存在) + +该模块将接收到的 RESTful 请求,做了各种合法性检查后,将其变成标准的 SQL 语句,通过 taosc 的异步接口,将请求发往整个系统中的任一 dnode 。收到处理后的结果后,再翻译成 HTTP 协议,返回给应用。 + +如果HTTP模块启动,就意味着启动了一个taosc的实例。任一一个dnode都可以启动该模块,以实现对RESTful请求的分布式处理。 + +## Monitor模块 + +该模块负责检测一个 dnode 的运行状态,可以通过配置,由 dnode 启动或停止。原则上,每个 dnode 都应该启动一个 monitor 实例。 + +Monitor 采集 TDengine 里的关键操作,比如创建、删除、更新账号、表、库等,而且周期性的收集 CPU、内存、网络等资源的使用情况(采集周期由系统配置参数 monitorInterval 控制)。获得这些数据后,monitor 模块将采集的数据写入系统的日志库(DB 名字由系统配置参数 monitorDbName 控制)。 + +Monitor 模块使用 taosc 来将采集的数据写入系统,因此每个 monitor 实例,都有一个 taosc 运行实例。 + diff --git a/docs-cn/13-tdinternal/12-tsz-compress.md b/docs-cn/21-tdinternal/12-tsz-compress.md similarity index 98% rename from docs-cn/13-tdinternal/12-tsz-compress.md rename to docs-cn/21-tdinternal/12-tsz-compress.md index 5072b474195fa648f5f8e29a6954e8ef6fe35e06..baf5df15db3b44edc9e0bd6909e46fa84b676a0b 100644 --- a/docs-cn/13-tdinternal/12-tsz-compress.md +++ b/docs-cn/21-tdinternal/12-tsz-compress.md @@ -1,4 +1,6 @@ -# TSZ 压缩算法 +--- +title: TSZ 压缩算法 +--- TSZ 压缩算法是 TDengine 为浮点数据类型提供更加丰富的压缩功能,可以实现浮点数的有损至无损全状态压缩,相比原来在 TDengine 中原有压缩算法,TSZ 压缩算法压缩选项更丰富,压缩率更高,即使切到无损状态下对浮点数压缩,压缩率也会比原来的压缩算法高一倍。 diff --git a/docs-cn/16-iot-bigdata/iot-bigdata.md b/docs-cn/21-tdinternal/30-iot-big-data.md similarity index 61% rename from docs-cn/16-iot-bigdata/iot-bigdata.md rename to docs-cn/21-tdinternal/30-iot-big-data.md index 5687dd3fda161c426108dba298b73fc4db949c28..a234713f883056e3d1a0dcbfe8e2e47a82865f81 100644 --- a/docs-cn/16-iot-bigdata/iot-bigdata.md +++ b/docs-cn/21-tdinternal/30-iot-big-data.md @@ -1,5 +1,7 @@ -# 物联网大数据 - +--- +title: 物联网大数据 +description: "物联网、工业互联网大数据的特点;物联网大数据平台应具备的功能和特点;通用大数据架构为什么不适合处理物联网数据;物联网、车联网、工业互联网大数据平台,为什么推荐使用 TDengine" +--- - [物联网、工业互联网大数据的特点](https://www.taosdata.com/blog/2019/07/09/105.html) - [物联网大数据平台应具备的功能和特点](https://www.taosdata.com/blog/2019/07/29/542.html) diff --git a/docs-cn/21-tdinternal/_category_.yml b/docs-cn/21-tdinternal/_category_.yml new file mode 100644 index 0000000000000000000000000000000000000000..73c78f68a520fefecc145daaa24fe7e28c7c78e2 --- /dev/null +++ b/docs-cn/21-tdinternal/_category_.yml @@ -0,0 +1,4 @@ +label: 技术内幕 +link: + slug: /tdinternal/ + type: generated-index \ No newline at end of file diff --git a/docs-cn/15-application/01-telegraf.md b/docs-cn/25-application/01-telegraf.md similarity index 98% rename from docs-cn/15-application/01-telegraf.md rename to docs-cn/25-application/01-telegraf.md index a23240debebbbf4a9da023f904562f04276f5b12..87f74fa67fbdbc3e4c5631b9cd393c4a78d3e25e 100644 --- a/docs-cn/15-application/01-telegraf.md +++ b/docs-cn/25-application/01-telegraf.md @@ -1,9 +1,8 @@ --- sidebar_label: TDengine + Telegraf + Grafana +title: 使用 TDengine + Telegraf + Grafana 快速搭建 IT 运维展示系统 --- -# 使用 TDengine + Telegraf + Grafana 快速搭建 IT 运维展示系统 - ## 背景介绍 TDengine 是涛思数据专为物联网、车联网、工业互联网、IT 运维等设计和优化的大数据平台。自从 2019 年 7 月开源以来,凭借创新的数据建模设计、快捷的安装方式、易用的编程接口和强大的数据写入查询性能博得了大量时序数据开发者的青睐。 diff --git a/docs-cn/15-application/02-collectd.md b/docs-cn/25-application/02-collectd.md similarity index 92% rename from docs-cn/15-application/02-collectd.md rename to docs-cn/25-application/02-collectd.md index 10f8eff8b7ade5a66357fb095a600fa453f53731..da055632837e74f4d863148843f1001cc3aa3e8b 100644 --- a/docs-cn/15-application/02-collectd.md +++ b/docs-cn/25-application/02-collectd.md @@ -1,9 +1,8 @@ --- sidebar_label: TDengine + collectd/StatsD + Grafana +title: 使用 TDengine + collectd/StatsD + Grafana 快速搭建 IT 运维监控系统 --- -# 使用 TDengine + collectd/StatsD + Grafana 快速搭建 IT 运维监控系统 - ## 背景介绍 TDengine 是涛思数据专为物联网、车联网、工业互联网、IT 运维等设计和优化的大数据平台。自从 2019 年 7 月开源以来,凭借创新的数据建模设计、快捷的安装方式、易用的编程接口和强大的数据写入查询性能博得了大量时序数据开发者的青睐。 @@ -37,7 +36,7 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### 安装 TDengine -从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 +从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 ## 数据链路设置 @@ -53,7 +52,7 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### 配置 collectd -在 /etc/collectd/collectd.conf 文件中增加如下内容,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: +在 `/etc/collectd/collectd.conf` 文件中增加如下内容,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: ``` LoadPlugin network @@ -66,7 +65,7 @@ sudo systemctl start collectd ### 配置 StatsD -在 config.js 文件中增加如下内容后启动 StatsD,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: +在 `config.js` 文件中增加如下内容后启动 StatsD,其中 host 和 port 请填写 TDengine 和 taosAdapter 配置的实际值: ``` backends 部分添加 "./backends/repeater" diff --git a/docs-cn/15-application/03-immigrate.md b/docs-cn/25-application/03-immigrate.md similarity index 97% rename from docs-cn/15-application/03-immigrate.md rename to docs-cn/25-application/03-immigrate.md index 1e3087c06f40ae393ad55f71b534ca0cf424cb74..9b2c04e96ecf5f7f43abc2a3e2c6fbce03840d9c 100644 --- a/docs-cn/15-application/03-immigrate.md +++ b/docs-cn/25-application/03-immigrate.md @@ -1,9 +1,8 @@ --- sidebar_label: OpenTSDB 迁移到 TDengine +title: OpenTSDB 应用迁移到 TDengine 的最佳实践 --- -# OpenTSDB 应用迁移到 TDengine 的最佳实践 - 作为一个分布式、可伸缩、基于 HBase 的分布式时序数据库系统,得益于其先发优势,OpenTSDB 被 DevOps 领域的人员引入并广泛地应用在了运维监控领域。但最近几年,随着云计算、微服务、容器化等新技术快速落地发展,企业级服务种类变得越来越多,架构也越来越复杂,应用运行基础环境日益多样化,给系统和运行监控带来的压力也越来越大。从这一现状出发,使用 OpenTSDB 作为 DevOps 的监控后端存储,越来越受困于其性能问题以及迟缓的功能升级,以及由此而衍生出来的应用部署成本上升和运行效率降低等问题,这些问题随着系统规模的扩大日益严重。 在这一背景下,为满足高速增长的物联网大数据市场和技术需求,在吸取众多传统关系型数据库、NoSQL 数据库、流计算引擎、消息队列等软件的优点之后,涛思数据自主开发出创新型大数据处理产品 TDengine。在时序大数据处理上,TDengine 有着自己独特的优势。就 OpenTSDB 当前遇到的问题来说,TDengine 能够有效解决。 @@ -48,7 +47,7 @@ sidebar_label: OpenTSDB 迁移到 TDengine 用户可以根据需求弹性部署 taosAdapter 实例,结合场景的需要,快速提升数据写入的吞吐量,为不同应用场景下的数据写入提供保障。 -通过 taosAdapter,用户可以将 collectd 和 StatsD 收集的数据直接推送到 TDengine ,实现应用场景的无缝迁移,非常的轻松便捷。taosAdapter 还支持 Telegraf、Icinga、TCollector 、node_exporter 的数据接入,使用详情参考[taosAdapter](https://www.taosdata.com/cn/documentation/tools/adapter)。 +通过 taosAdapter,用户可以将 collectd 和 StatsD 收集的数据直接推送到 TDengine ,实现应用场景的无缝迁移,非常的轻松便捷。taosAdapter 还支持 Telegraf、Icinga、TCollector 、node_exporter 的数据接入,使用详情参考[taosAdapter](/reference/taosadapter/)。 如果使用 collectd,修改其默认位置 `/etc/collectd/collectd.conf` 的配置文件为指向 taosAdapter 部署的节点 IP 地址和端口。假设 taosAdapter 的 IP 地址为 192.168.1.130,端口为 6046,配置如下: @@ -66,7 +65,7 @@ LoadPlugin write_tsdb - **调整看板(Dashborad)系统** -在数据能够正常写入 TDengine 后,可以调整适配 Grafana 将写入 TDengine 的数据可视化呈现出来。获取和使用 TDengine 提供的 Grafana 插件请参考[与其他工具的连接](https://www.taosdata.com/cn/documentation/connections#grafana)。 +在数据能够正常写入 TDengine 后,可以调整适配 Grafana 将写入 TDengine 的数据可视化呈现出来。获取和使用 TDengine 提供的 Grafana 插件请参考[与其他工具的连接](/third-party/grafana)。 TDengine 提供了默认的两套 Dashboard 模板,用户只需要将 Grafana 目录下的模板导入到 Grafana 中即可激活使用。 @@ -361,7 +360,7 @@ WHERE ts>=1510560000 AND ts<=1515000009 ### 计算资源估算 -由于物联网数据的特殊性,数据产生的频率固定以后,TDengine 写入的过程对于(计算和存储)资源消耗都保持一个相对固定的量。《[TDengine 的运营与维护](https://www.taosdata.com/cn/documentation/administrator)》上的描述,该系统中每秒 22000 个写入,消耗 CPU 不到 1 个核。 +由于物联网数据的特殊性,数据产生的频率固定以后,TDengine 写入的过程对于(计算和存储)资源消耗都保持一个相对固定的量。《[TDengine 运维指南](/operation/)》上的描述,该系统中每秒 22000 个写入,消耗 CPU 不到 1 个核。 在针对查询所需要消耗的 CPU 资源的估算上,假设应用要求数据库提供的 QPS 为 10000,每次查询消耗的 CPU 时间约 1 ms,那么每个核每秒提供的查询为 1000 QPS,满足 10000 QPS 的查询请求,至少需要 10 个核。为了让系统整体上 CPU 负载小于 50%,整个集群需要 10 个核的两倍,即 20 个核。 @@ -385,11 +384,11 @@ TDengine 提供了丰富的帮助文档说明集群安装、部署的诸多方 为确保系统能够正常获取运行的必要信息。请在服务端正确设置以下关键参数: -FQDN、firstEp、secondEP、dataDir、logDir、tmpDir、serverPort。各参数的具体含义及设置的要求,可参见文档《[TDengine 集群安装、管理](https://www.taosdata.com/cn/documentation/cluster)》 +FQDN、firstEp、secondEP、dataDir、logDir、tmpDir、serverPort。各参数的具体含义及设置的要求,可参见文档《[TDengine 集群安装、管理](/cluster/)》 按照相同的步骤,在需要运行的节点上设置参数,并启动 taosd 服务,然后添加 Dnode 到集群中。 -最后启动 taos,执行命令 show dnodes,如果能看到所有的加入集群的节点,那么集群顺利搭建完成。具体的操作流程及注意事项,请参阅文档《[TDengine 集群安装、管理](https://www.taosdata.com/cn/documentation/cluster)》 +最后启动 taos,执行命令 show dnodes,如果能看到所有的加入集群的节点,那么集群顺利搭建完成。具体的操作流程及注意事项,请参阅文档《[TDengine 集群安装、管理](/cluster/)》 ## 附录 4: 超级表名称 @@ -397,5 +396,5 @@ FQDN、firstEp、secondEP、dataDir、logDir、tmpDir、serverPort。各参数 ## 附录 5:参考文章 -1. [使用 TDengine + collectd/StatsD + Grafana 快速搭建 IT 运维监控系统](https://www.taosdata.com/cn/documentation20/devops/collectd) -2. [通过 collectd 将采集数据直接写入 TDengine](https://www.taosdata.com/cn/documentation20/insert#collectd) +1. [使用 TDengine + collectd/StatsD + Grafana 快速搭建 IT 运维监控系统](/application/collectd/) +2. [通过 collectd 将采集数据直接写入 TDengine](/third-party/collectd/) diff --git a/docs-cn/15-application/_category_.yml b/docs-cn/25-application/_category_.yml similarity index 69% rename from docs-cn/15-application/_category_.yml rename to docs-cn/25-application/_category_.yml index 725833f45110361f27e6fcb7015b4e2413fda7bb..141c9269b50a2155391543ecea1dfe5c918e113c 100644 --- a/docs-cn/15-application/_category_.yml +++ b/docs-cn/25-application/_category_.yml @@ -1,3 +1,4 @@ label: 应用实践 link: + slug: /application/ type: generated-index diff --git a/docs-cn/27-train-faq/01-faq.md b/docs-cn/27-train-faq/01-faq.md new file mode 100644 index 0000000000000000000000000000000000000000..fac12cb44eaff68ec74d3019e537aecb0291410f --- /dev/null +++ b/docs-cn/27-train-faq/01-faq.md @@ -0,0 +1,224 @@ +--- +title: 常见问题及反馈 +--- + +## 问题反馈 + +如果 FAQ 中的信息不能够帮到您,需要 TDengine 技术团队的技术支持与协助,请将以下两个目录中内容打包: + +1. /var/log/taos (如果没有修改过默认路径) +2. /etc/taos + +附上必要的问题描述,包括使用的 TDengine 版本信息、平台环境信息、发生该问题的执行操作、出现问题的表征及大概的时间,在 [GitHub](https://github.com/taosdata/TDengine) 提交 issue。 + +为了保证有足够的 debug 信息,如果问题能够重复,请修改/etc/taos/taos.cfg 文件,最后面添加一行“debugFlag 135"(不带引号本身),然后重启 taosd, 重复问题,然后再递交。也可以通过如下 SQL 语句,临时设置 taosd 的日志级别。 + +``` + alter dnode debugFlag 135; +``` + +但系统正常运行时,请一定将 debugFlag 设置为 131,否则会产生大量的日志信息,降低系统效率。 + +## 常见问题列表 + +**1. TDengine2.0 之前的版本升级到 2.0 及以上的版本应该注意什么?☆☆☆** + + 2.0 版在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作: + + 1. 删除配置文件,执行 `sudo rm -rf /etc/taos/taos.cfg` + 2. 删除日志文件,执行 `sudo rm -rf /var/log/taos/` + 3. 确保数据已经不再需要的前提下,删除数据文件,执行 `sudo rm -rf /var/lib/taos/` + 4. 安装最新稳定版本的 TDengine + 5. 如果需要迁移数据或者数据文件损坏,请联系涛思数据官方技术支持团队,进行协助解决 + +**2. Windows 平台下 JDBCDriver 找不到动态链接库,怎么办?** + + 请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/03/950.html)。 + +**3. 创建数据表时提示 more dnodes are needed** + + 请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/03/965.html)。 + +**4. 如何让 TDengine crash 时生成 core 文件?** + + 请看为此问题撰写的[技术博客](https://www.taosdata.com/blog/2019/12/06/974.html)。 + +**5. 遇到错误“Unable to establish connection”, 我怎么办?** + + 客户端遇到连接故障,请按照下面的步骤进行检查: + + 1. 检查网络环境 + + - 云服务器:检查云服务器的安全组是否打开 TCP/UDP 端口 6030-6042 的访问权限 + - 本地虚拟机:检查网络能否 ping 通,尽量避免使用`localhost` 作为 hostname + - 公司服务器:如果为 NAT 网络环境,请务必检查服务器能否将消息返回值客户端 + + 2. 确保客户端与服务端版本号是完全一致的,开源社区版和企业版也不能混用 + + 3. 在服务器,执行 `systemctl status taosd` 检查*taosd*运行状态。如果没有运行,启动*taosd* + + 4. 确认客户端连接时指定了正确的服务器 FQDN (Fully Qualified Domain Name —— 可在服务器上执行 Linux 命令 hostname -f 获得),FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html)。 + + 5. ping 服务器 FQDN,如果没有反应,请检查你的网络,DNS 设置,或客户端所在计算机的系统 hosts 文件。如果部署的是 TDengine 集群,客户端需要能 ping 通所有集群节点的 FQDN。 + + 6. 检查防火墙设置(Ubuntu 使用 ufw status,CentOS 使用 firewall-cmd --list-port),确认 TCP/UDP 端口 6030-6042 是打开的 + + 7. 对于 Linux 上的 JDBC(ODBC, Python, Go 等接口类似)连接, 确保*libtaos.so*在目录*/usr/local/taos/driver*里, 并且*/usr/local/taos/driver*在系统库函数搜索路径*LD_LIBRARY_PATH*里 + + 8. 对于 Windows 上的 JDBC, ODBC, Python, Go 等连接,确保*C:\TDengine\driver\taos.dll*在你的系统库函数搜索目录里 (建议*taos.dll*放在目录 _C:\Windows\System32_) + + 9. 如果仍不能排除连接故障 + + - Linux 系统请使用命令行工具 nc 来分别判断指定端口的 TCP 和 UDP 连接是否通畅 + 检查 UDP 端口连接是否工作:`nc -vuz {hostIP} {port} ` + 检查服务器侧 TCP 端口连接是否工作:`nc -l {port}` + 检查客户端侧 TCP 端口连接是否工作:`nc {hostIP} {port}` + + - Windows 系统请使用 PowerShell 命令 Net-TestConnection -ComputerName {fqdn} -Port {port} 检测服务段端口是否访问 + + 10. 也可以使用 taos 程序内嵌的网络连通检测功能,来验证服务器和客户端之间指定的端口连接是否通畅(包括 TCP 和 UDP):[TDengine 内嵌网络检测工具使用指南](https://www.taosdata.com/blog/2020/09/08/1816.html)。 + +**6. 遇到错误“Unexpected generic error in RPC”或者“Unable to resolve FQDN”,我怎么办?** + + 产生这个错误,是由于客户端或数据节点无法解析 FQDN(Fully Qualified Domain Name)导致。对于 TAOS Shell 或客户端应用,请做如下检查: + + 1. 请检查连接的服务器的 FQDN 是否正确,FQDN 配置参考:[一篇文章说清楚 TDengine 的 FQDN](https://www.taosdata.com/blog/2020/09/11/1824.html) + 2. 如果网络配置有 DNS server,请检查是否正常工作 + 3. 如果网络没有配置 DNS server,请检查客户端所在机器的 hosts 文件,查看该 FQDN 是否配置,并是否有正确的 IP 地址 + 4. 如果网络配置 OK,从客户端所在机器,你需要能 Ping 该连接的 FQDN,否则客户端是无法连接服务器的 + 5. 如果服务器曾经使用过 TDengine,且更改过 hostname,建议检查 data 目录的 dnodeEps.json 是否符合当前配置的 EP,路径默认为/var/lib/taos/dnode。正常情况下,建议更换新的数据目录或者备份后删除以前的数据目录,这样可以避免该问题。 + 6. 检查/etc/hosts 和/etc/hostname 是否是预配置的 FQDN + +**7. 虽然语法正确,为什么我还是得到 "Invalid SQL" 错误** + + 如果你确认语法正确,2.0 之前版本,请检查 SQL 语句长度是否超过 64K。如果超过,也会返回这个错误。 + +**8. 是否支持 validation queries?** + + TDengine 还没有一组专用的 validation queries。然而建议你使用系统监测的数据库”log"来做。 + + + +**9. 我可以删除或更新一条记录吗?** + + TDengine 目前尚不支持删除功能,未来根据用户需求可能会支持。 + + 从 2.0.8.0 开始,TDengine 支持更新已经写入数据的功能。使用更新功能需要在创建数据库时使用 UPDATE 1 参数,之后可以使用 INSERT INTO 命令更新已经写入的相同时间戳数据。UPDATE 参数不支持 ALTER DATABASE 命令修改。没有使用 UPDATE 1 参数创建的数据库,写入相同时间戳的数据不会修改之前的数据,也不会报错。 + + 另需注意,在 UPDATE 设置为 0 时,后发送的相同时间戳的数据会被直接丢弃,但并不会报错,而且仍然会被计入 affected rows (所以不能利用 INSERT 指令的返回信息进行时间戳查重)。这样设计的主要原因是,TDengine 把写入的数据看做一个数据流,无论时间戳是否出现冲突,TDengine 都认为产生数据的原始设备真实地产生了这样的数据。UPDATE 参数只是控制这样的流数据在进行持久化时要怎样处理——UPDATE 为 0 时,表示先写入的数据覆盖后写入的数据;而 UPDATE 为 1 时,表示后写入的数据覆盖先写入的数据。这种覆盖关系如何选择,取决于对数据的后续使用和统计中,希望以先还是后生成的数据为准。 + + 此外,从 2.1.7.0 版本开始,支持将 UPDATE 参数设为 2,表示“支持部分列更新”。也即,当 UPDATE 设为 1 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会被设为 NULL;而当 UPDATE 设为 2 时,如果更新一个数据行,其中某些列没有提供取值,那么这些列会保持原有数据行中的对应值。 + +**10. 我怎么创建超过 1024 列的表?** + + 使用 2.0 及其以上版本,默认支持 1024 列;2.0 之前的版本,TDengine 最大允许创建 250 列的表。但是如果确实超过限值,建议按照数据特性,逻辑地将这个宽表分解成几个小表。(从 2.1.7.0 版本开始,表的最大列数增加到了 4096 列。) + +**11. 最有效的写入数据的方法是什么?** + + 批量插入。每条写入语句可以一张表同时插入多条记录,也可以同时插入多张表的多条记录。 + +**12. Windows 系统下插入的 nchar 类数据中的汉字被解析成了乱码如何解决?** + + Windows 下插入 nchar 类的数据中如果有中文,请先确认系统的地区设置成了中国(在 Control Panel 里可以设置),这时 cmd 中的`taos`客户端应该已经可以正常工作了;如果是在 IDE 里开发 Java 应用,比如 Eclipse, Intellij,请确认 IDE 里的文件编码为 GBK(这是 Java 默认的编码类型),然后在生成 Connection 时,初始化客户端的配置,具体语句如下: + + ```JAVA + Class.forName("com.taosdata.jdbc.TSDBDriver"); + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.LOCALE_KEY, "UTF-8"); + Connection = DriverManager.getConnection(url, properties); + ``` + +**13.JDBC 报错: the excuted SQL is not a DML or a DDL?** + + 请更新至最新的 JDBC 驱动 + + ```xml + + com.taosdata.jdbc + taos-jdbcdriver + 2.0.27 + + ``` + +**14. taos connect failed, reason: invalid timestamp** + + 常见原因是服务器和客户端时间没有校准,可以通过和时间服务器同步的方式(Linux 下使用 ntpdate 命令,Windows 在系统时间设置中选择自动同步)校准。 + +**15. 表名显示不全** + + 由于 taos shell 在终端中显示宽度有限,有可能比较长的表名显示不全,如果按照显示的不全的表名进行相关操作会发生 Table does not exist 错误。解决方法可以是通过修改 taos.cfg 文件中的设置项 maxBinaryDisplayWidth, 或者直接输入命令 set max_binary_display_width 100。或者在命令结尾使用 \G 参数来调整结果的显示方式。 + +**16. 如何进行数据迁移?** + + TDengine 是根据 hostname 唯一标志一台机器的,在数据文件从机器 A 移动机器 B 时,注意如下两件事: + + - 2.0.0.0 至 2.0.6.x 的版本,重新配置机器 B 的 hostname 为机器 A 的 hostname。 + - 2.0.7.0 及以后的版本,到/var/lib/taos/dnode 下,修复 dnodeEps.json 的 dnodeId 对应的 FQDN,重启。确保机器内所有机器的此文件是完全相同的。 + - 1.x 和 2.x 版本的存储结构不兼容,需要使用迁移工具或者自己开发应用导出导入数据。 + +**17. 如何在命令行程序 taos 中临时调整日志级别** + + 为了调试方便,从 2.0.16 版本开始,命令行程序 taos 新增了与日志记录相关的两条指令: + + ```sql + ALTER LOCAL flag_name flag_value; + ``` + + 其含义是,在当前的命令行程序下,修改一个特定模块的日志记录级别(只对当前命令行程序有效,如果 taos 命令行程序重启,则需要重新设置): + + - flag_name 的取值可以是:debugFlag,cDebugFlag,tmrDebugFlag,uDebugFlag,rpcDebugFlag + - flag_value 的取值可以是:131(输出错误和警告日志),135( 输出错误、警告和调试日志),143( 输出错误、警告、调试和跟踪日志) + + ```sql + ALTER LOCAL RESETLOG; + ``` + + 其含义是,清空本机所有由客户端生成的日志文件。 + + + +**18. 时间戳的时区信息是怎样处理的?** + + TDengine 中时间戳的时区总是由客户端进行处理,而与服务端无关。具体来说,客户端会对 SQL 语句中的时间戳进行时区转换,转为 UTC 时区(即 Unix 时间戳——Unix Timestamp)再交由服务端进行写入和查询;在读取数据时,服务端也是采用 UTC 时区提供原始数据,客户端收到后再根据本地设置,把时间戳转换为本地系统所要求的时区进行显示。 + + 客户端在处理时间戳字符串时,会采取如下逻辑: + + 1. 在未做特殊设置的情况下,客户端默认使用所在操作系统的时区设置。 + 2. 如果在 taos.cfg 中设置了 timezone 参数,则客户端会以这个配置文件中的设置为准。 + 3. 如果在 C/C++/Java/Python 等各种编程语言的 Connector Driver 中,在建立数据库连接时显式指定了 timezone,那么会以这个指定的时区设置为准。例如 Java Connector 的 JDBC URL 中就有 timezone 参数。 + 4. 在书写 SQL 语句时,也可以直接使用 Unix 时间戳(例如 `1554984068000`)或带有时区的时间戳字符串,也即以 RFC 3339 格式(例如 `2013-04-12T15:52:01.123+08:00`)或 ISO-8601 格式(例如 `2013-04-12T15:52:01.123+0800`)来书写时间戳,此时这些时间戳的取值将不再受其他时区设置的影响。 + + + +**19. TDengine 都会用到哪些网络端口?** + + 在 TDengine 2.0 版本中,会用到以下这些网络端口(以默认端口 6030 为前提进行说明,如果修改了配置文件中的设置,那么这里列举的端口都会出现变化),管理员可以参考这里的信息调整防火墙设置: + +| 协议 | 默认端口 | 用途说明 | 修改方法 | +| :--- | :-------- | :---------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------- | +| TCP | 6030 | 客户端与服务端之间通讯。 | 由配置文件设置 serverPort 决定。 | +| TCP | 6035 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | +| TCP | 6040 | 多节点集群的节点间数据同步。 | 随 serverPort 端口变化。 | +| TCP | 6041 | 客户端与服务端之间的 RESTful 通讯。 | 随 serverPort 端口变化。注意 taosAdapter 配置或有不同,请参考相应[文档](/reference/taosadapter/)。 | +| TCP | 6042 | Arbitrator 的服务端口。 | 随 Arbitrator 启动参数设置变化。 | +| TCP | 6043 | TaosKeeper 监控服务端口。 | 随 TaosKeeper 启动参数设置变化。 | +| TCP | 6044 | 支持 StatsD 的数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | +| TCP | 6045 | 支持 collectd 数据接入端口。 | 随 taosAdapter 启动参数设置变化(2.3.0.1+以上版本)。 | +| TCP | 6060 | 企业版内 Monitor 服务的网络端口。 | | +| UDP | 6030-6034 | 客户端与服务端之间通讯。 | 随 serverPort 端口变化。 | +| UDP | 6035-6039 | 多节点集群的节点间通讯。 | 随 serverPort 端口变化。 | + +**20. go 语言编写组件编译失败怎样解决?** + + 新版本 TDengine 2.3.0.0 包含一个使用 go 语言开发的 taosAdapter 独立组件,需要单独运行,取代之前 taosd 内置的 httpd ,提供包含原 httpd 功能以及支持多种其他软件(Prometheus、Telegraf、collectd、StatsD 等)的数据接入功能。 + 使用最新 develop 分支代码编译需要先 `git submodule update --init --recursive` 下载 taosAdapter 仓库代码后再编译。 + + 目前编译方式默认自动编译 taosAdapter。go 语言版本要求 1.14 以上,如果发生 go 编译错误,往往是国内访问 go mod 问题,可以通过设置 go 环境变量来解决: + + ```sh + go env -w GO111MODULE=on + go env -w GOPROXY=https://goproxy.cn,direct + ``` + + 如果希望继续使用之前的内置 httpd,可以关闭 taosAdapter 编译,使用 + `cmake .. -DBUILD_HTTP=true` 使用原来内置的 httpd。 diff --git a/docs-cn/17-train-fqa/02-video.mdx b/docs-cn/27-train-faq/02-video.mdx similarity index 97% rename from docs-cn/17-train-fqa/02-video.mdx rename to docs-cn/27-train-faq/02-video.mdx index 767b154fd34f3898a269bb505999a9de2bf11799..b644412332fe817ea7fdc2c9ddc176ecc9858c56 100644 --- a/docs-cn/17-train-fqa/02-video.mdx +++ b/docs-cn/27-train-faq/02-video.mdx @@ -1,6 +1,6 @@ -# 视频教程 - -## +--- +title: 视频教程 +--- ## 技术公开课 diff --git a/docs-cn/17-train-fqa/03-docker.md b/docs-cn/27-train-faq/03-docker.md similarity index 96% rename from docs-cn/17-train-fqa/03-docker.md rename to docs-cn/27-train-faq/03-docker.md index 54b94c9abae50d5a6581ed4bce321bc5d5e761f3..a86b72a39e94c4db7d3b229fba2260df36ef2a88 100644 --- a/docs-cn/17-train-fqa/03-docker.md +++ b/docs-cn/27-train-faq/03-docker.md @@ -1,4 +1,6 @@ -# 通过 Docker 快速体验 TDengine +--- +title: 通过 Docker 快速体验 TDengine +--- 虽然并不推荐在生产环境中通过 Docker 来部署 TDengine 服务,但 Docker 工具能够很好地屏蔽底层操作系统的环境差异,很适合在开发测试或初次体验时用于安装运行 TDengine 的工具集。特别是,借助 Docker,能够比较方便地在 macOS 和 Windows 系统上尝试 TDengine,而无需安装虚拟机或额外租用 Linux 服务器。另外,从 2.0.14.0 版本开始,TDengine 提供的镜像已经可以同时支持 X86-64、X86、arm64、arm32 平台,像 NAS、树莓派、嵌入式开发板之类可以运行 docker 的非主流计算机也可以基于本文档轻松体验 TDengine。 @@ -24,7 +26,7 @@ $ docker run -d -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdeng 526aa188da767ae94b244226a2b2eec2b5f17dd8eff592893d9ec0cd0f3a1ccd ``` -这条命令,启动一个运行了 TDengine server 的 docker 容器,并且将容器的 6030 到 6049 端口映射到宿主机的 6030 到 6049 端口上。如果宿主机已经运行了 TDengine server 并占用了相同端口,需要映射容器的端口到不同的未使用端口段。(详情参见 [TDengine 2.0 端口说明](https://www.taosdata.com/cn/documentation/faq#port))。为了支持 TDengine 客户端操作 TDengine server 服务, TCP 和 UDP 端口都需要打开。 +这条命令,启动一个运行了 TDengine server 的 docker 容器,并且将容器的 6030 到 6049 端口映射到宿主机的 6030 到 6049 端口上。如果宿主机已经运行了 TDengine server 并占用了相同端口,需要映射容器的端口到不同的未使用端口段。(详情参见 [TDengine 2.0 端口说明](/train-faq/faq#port)。为了支持 TDengine 客户端操作 TDengine server 服务, TCP 和 UDP 端口都需要打开。 - **docker run**:通过 Docker 运行一个容器 - **-d**:让容器在后台运行 @@ -88,7 +90,7 @@ taos> TDengine 终端成功连接服务端,打印出了欢迎消息和版本信息。如果失败,会有错误信息打印出来。 -在 TDengine 终端中,可以通过 SQL 命令来创建/删除数据库、表、超级表等,并可以进行插入和查询操作。具体可以参考 [TAOS SQL 说明文档](https://www.taosdata.com/cn/documentation/taos-sql)。 +在 TDengine 终端中,可以通过 SQL 命令来创建/删除数据库、表、超级表等,并可以进行插入和查询操作。具体可以参考 [TAOS SQL 说明文档](/taos-sql/)。 ### 在宿主机访问 Docker 容器中的 TDengine server @@ -115,15 +117,15 @@ curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql {"status":"succ","head":["name","created_time","ntables","vgroups","replica","quorum","days","keep0,keep1,keep(D)","cache(MB)","blocks","minrows","maxrows","wallevel","fsync","comp","cachelast","precision","update","status"],"column_meta":[["name",8,32],["created_time",9,8],["ntables",4,4],["vgroups",4,4],["replica",3,2],["quorum",3,2],["days",3,2],["keep0,keep1,keep(D)",8,24],["cache(MB)",4,4],["blocks",4,4],["minrows",4,4],["maxrows",4,4],["wallevel",2,1],["fsync",4,4],["comp",2,1],["cachelast",2,1],["precision",8,3],["update",2,1],["status",8,10]],"data":[["test","2021-08-18 06:01:11.021",10000,4,1,1,10,"3650,3650,3650",16,6,100,4096,1,3000,2,0,"ms",0,"ready"],["log","2021-08-18 05:51:51.065",4,1,1,1,10,"30,30,30",1,3,100,4096,1,3000,2,0,"us",0,"ready"]],"rows":2} ``` -这条命令,通过 RESTful 接口访问 TDengine server,这时连接的是本机的 6041 端口,可见连接成功。 +这条命令,通过 REST API 访问 TDengine server,这时连接的是本机的 6041 端口,可见连接成功。 -TDengine RESTful 接口详情请参考[官方文档](https://www.taosdata.com/cn/documentation/connector#restful)。 +TDengine REST API 详情请参考[官方文档](/reference/rest-api/)。 ### 使用 Docker 容器运行 TDengine server 和 taosAdapter 在 TDegnine 2.4.0.0 之后版本的 Docker 容器,开始提供一个独立运行的组件 taosAdapter,代替之前版本 TDengine 中 taosd 进程中内置的 http server。taosAdapter 支持通过 RESTful 接口对 TDengine server 的数据写入和查询能力,并提供和 InfluxDB/OpenTSDB 兼容的数据摄取接口,允许 InfluxDB/OpenTSDB 应用程序无缝移植到 TDengine。在新版本 Docker 镜像中,默认启用了 taosAdapter,也可以使用 docker run 命令中设置 TAOS_DISABLE_ADAPTER=true 来禁用 taosAdapter;也可以在 docker run 命令中单独使用 taosAdapter,而不运行 taosd 。 -注意:如果容器中运行 taosAdapter,需要根据需要映射其他端口,具体端口默认配置和修改方法请参考[taosAdapter 文档](https://github.com/taosdata/taosadapter/blob/develop/README-CN.md)。 +注意:如果容器中运行 taosAdapter,需要根据需要映射其他端口,具体端口默认配置和修改方法请参考[taosAdapter 文档](/reference/taosadapter/)。 使用 docker 运行 TDengine 2.4.0.4 版本镜像(taosd + taosAdapter): diff --git a/docs-cn/17-train-fqa/_category_.yml b/docs-cn/27-train-faq/_category_.yml similarity index 74% rename from docs-cn/17-train-fqa/_category_.yml rename to docs-cn/27-train-faq/_category_.yml index 27e8b47b49ee57d059b3088e583bf2c6a9d4df99..034d5894b9aea00e43caf4df21cb39487d8baf7b 100644 --- a/docs-cn/17-train-fqa/_category_.yml +++ b/docs-cn/27-train-faq/_category_.yml @@ -1,3 +1,4 @@ label: FAQ、教程及其它 link: + slug: /train-faq/ type: generated-index diff --git a/docs-examples/.gitignore b/docs-examples/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..7ed6d403bf5f64c0cb230265b4dffee609dea93b --- /dev/null +++ b/docs-examples/.gitignore @@ -0,0 +1,3 @@ +.vscode +*.lock +.idea \ No newline at end of file diff --git a/docs-examples/.gitignre b/docs-examples/.gitignre new file mode 100644 index 0000000000000000000000000000000000000000..0853156c65c2c6c1b693290e74c3ee630bcaac19 --- /dev/null +++ b/docs-examples/.gitignre @@ -0,0 +1,2 @@ +.vscode +*.lock \ No newline at end of file diff --git a/docs-examples/R/connect_native.r b/docs-examples/R/connect_native.r new file mode 100644 index 0000000000000000000000000000000000000000..18c142872be5efaa7167c10a25f62bcb9fbf5a52 --- /dev/null +++ b/docs-examples/R/connect_native.r @@ -0,0 +1,16 @@ +if (! "RJDBC" %in% installed.packages()[, "Package"]) { + install.packages('RJDBC', repos='http://cran.us.r-project.org') +} + +# ANCHOR: demo +library("DBI") +library("rJava") +library("RJDBC") + +args<- commandArgs(trailingOnly = TRUE) +driver_path = args[1] # path to jdbc-driver for example: "/root/taos-jdbcdriver-2.0.37-dist.jar" +driver = JDBC("com.taosdata.jdbc.TSDBDriver", driver_path) +conn = dbConnect(driver, "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata") +dbGetQuery(conn, "SELECT server_version()") +dbDisconnect(conn) +# ANCHOR_END: demo \ No newline at end of file diff --git a/docs-examples/R/connect_rest.r b/docs-examples/R/connect_rest.r new file mode 100644 index 0000000000000000000000000000000000000000..5ceec572fc26575dfc597983eeac3233bc4488ab --- /dev/null +++ b/docs-examples/R/connect_rest.r @@ -0,0 +1,12 @@ +if (! "RJDBC" %in% installed.packages()[, "Package"]) { + install.packages('RJDBC', repos='http://cran.us.r-project.org') +} + +library("DBI") +library("rJava") +library("RJDBC") +driver_path = "/home/debug/build/lib/taos-jdbcdriver-2.0.38-dist.jar" +driver = JDBC("com.taosdata.jdbc.rs.RestfulDriver", driver_path) +conn = dbConnect(driver, "jdbc:TAOS-RS://localhost:6041?user=root&password=taosdata") +dbGetQuery(conn, "SELECT server_version()") +dbDisconnect(conn) \ No newline at end of file diff --git a/docs-examples/c/.gitignore b/docs-examples/c/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..afe974314989a1e3aa4eee703738a9a960c18577 --- /dev/null +++ b/docs-examples/c/.gitignore @@ -0,0 +1,3 @@ +* +!*.c +!.gitignore diff --git a/docs-examples/c/async_query_example.c b/docs-examples/c/async_query_example.c new file mode 100644 index 0000000000000000000000000000000000000000..77002891bb4c03f7c7e32b329678e8a124f12a99 --- /dev/null +++ b/docs-examples/c/async_query_example.c @@ -0,0 +1,195 @@ +// compile with: +// gcc -o async_query_example async_query_example.c -ltaos + +#include +#include +#include +#include +#include +#include + +typedef int16_t VarDataLenT; + +#define TSDB_NCHAR_SIZE sizeof(int32_t) +#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) + +#define GET_FLOAT_VAL(x) (*(float *)(x)) +#define GET_DOUBLE_VAL(x) (*(double *)(x)) + +#define varDataLen(v) ((VarDataLenT *)(v))[0] + +int printRow(char *str, TAOS_ROW row, TAOS_FIELD *fields, int numFields) { + int len = 0; + char split = ' '; + + for (int i = 0; i < numFields; ++i) { + if (i > 0) { + str[len++] = split; + } + + if (row[i] == NULL) { + len += sprintf(str + len, "%s", "NULL"); + continue; + } + + switch (fields[i].type) { + case TSDB_DATA_TYPE_TINYINT: + len += sprintf(str + len, "%d", *((int8_t *)row[i])); + break; + + case TSDB_DATA_TYPE_UTINYINT: + len += sprintf(str + len, "%u", *((uint8_t *)row[i])); + break; + + case TSDB_DATA_TYPE_SMALLINT: + len += sprintf(str + len, "%d", *((int16_t *)row[i])); + break; + + case TSDB_DATA_TYPE_USMALLINT: + len += sprintf(str + len, "%u", *((uint16_t *)row[i])); + break; + + case TSDB_DATA_TYPE_INT: + len += sprintf(str + len, "%d", *((int32_t *)row[i])); + break; + + case TSDB_DATA_TYPE_UINT: + len += sprintf(str + len, "%u", *((uint32_t *)row[i])); + break; + + case TSDB_DATA_TYPE_BIGINT: + len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i])); + break; + + case TSDB_DATA_TYPE_UBIGINT: + len += sprintf(str + len, "%" PRIu64, *((uint64_t *)row[i])); + break; + + case TSDB_DATA_TYPE_FLOAT: { + float fv = 0; + fv = GET_FLOAT_VAL(row[i]); + len += sprintf(str + len, "%f", fv); + } break; + + case TSDB_DATA_TYPE_DOUBLE: { + double dv = 0; + dv = GET_DOUBLE_VAL(row[i]); + len += sprintf(str + len, "%lf", dv); + } break; + + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE); + memcpy(str + len, row[i], charLen); + len += charLen; + } break; + + case TSDB_DATA_TYPE_TIMESTAMP: + len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i])); + break; + + case TSDB_DATA_TYPE_BOOL: + len += sprintf(str + len, "%d", *((int8_t *)row[i])); + default: + break; + } + } + + return len; +} + +void printHeader(TAOS_RES *res) { + int numFields = taos_num_fields(res); + TAOS_FIELD *fields = taos_fetch_fields(res); + char header[256] = {0}; + int len = 0; + for (int i = 0; i < numFields; ++i) { + len += sprintf(header + len, "%s ", fields[i].name); + } + puts(header); +} + +// ANCHOR: demo + +/** + * @brief call back function of taos_fetch_row_a + * + * @param param : the third parameter you passed to taos_fetch_row_a + * @param res : pointer of TAOS_RES + * @param numOfRow : number of rows fetched in this batch. will be 0 if there is no more data. + * @return void* + */ +void *fetch_row_callback(void *param, TAOS_RES *res, int numOfRow) { + printf("numOfRow = %d \n", numOfRow); + int numFields = taos_num_fields(res); + TAOS_FIELD *fields = taos_fetch_fields(res); + TAOS *_taos = (TAOS *)param; + if (numOfRow > 0) { + for (int i = 0; i < numOfRow; ++i) { + TAOS_ROW row = taos_fetch_row(res); + char temp[256] = {0}; + printRow(temp, row, fields, numFields); + puts(temp); + } + taos_fetch_rows_a(res, fetch_row_callback, _taos); + } else { + printf("no more data, close the connection.\n"); + taos_free_result(res); + taos_close(_taos); + taos_cleanup(); + } +} + +/** + * @brief callback function of taos_query_a + * + * @param param: the fourth parameter you passed to taos_query_a + * @param res : the result set + * @param code : status code + * @return void* + */ +void *select_callback(void *param, TAOS_RES *res, int code) { + printf("query callback ...\n"); + TAOS *_taos = (TAOS *)param; + if (code == 0 && res) { + printHeader(res); + taos_fetch_rows_a(res, fetch_row_callback, _taos); + } else { + printf("failed to exeuce taos_query. error: %s\n", taos_errstr(res)); + taos_free_result(res); + taos_close(_taos); + taos_cleanup(); + exit(EXIT_FAILURE); + } +} + +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", "power", 6030); + if (taos == NULL) { + puts("failed to connect to server"); + exit(EXIT_FAILURE); + } + // param one is the connection returned by taos_connect. + // param two is the SQL to execute. + // param three is the callback function. + // param four can be any pointer. It will be passed to your callback function as the first parameter. we use taos + // here, because we want to close it after getting data. + taos_query_a(taos, "SELECT * FROM meters", select_callback, taos); + sleep(1); +} + +// output: +// query callback ... +// ts current voltage phase location groupid +// numOfRow = 8 +// 1538548685000 10.300000 219 0.310000 beijing.chaoyang 2 +// 1538548695000 12.600000 218 0.330000 beijing.chaoyang 2 +// 1538548696800 12.300000 221 0.310000 beijing.chaoyang 2 +// 1538548696650 10.300000 218 0.250000 beijing.chaoyang 3 +// 1538548685500 11.800000 221 0.280000 beijing.haidian 2 +// 1538548696600 13.400000 223 0.290000 beijing.haidian 2 +// 1538548685000 10.800000 223 0.290000 beijing.haidian 3 +// 1538548686500 11.500000 221 0.350000 beijing.haidian 3 +// numOfRow = 0 +// no more data, close the connection. +// ANCHOR_END: demo \ No newline at end of file diff --git a/docs-examples/c/connect_example b/docs-examples/c/connect_example deleted file mode 100644 index 1d9451cbf6724d51dbbc9baeba97d779461b2a5d..0000000000000000000000000000000000000000 Binary files a/docs-examples/c/connect_example and /dev/null differ diff --git a/docs-examples/c/connect_example.c b/docs-examples/c/connect_example.c index a64bc43361a05ba91b8637a15c7379fc3a2aef12..ff0891e08267840fd5141d1b4271109d832c1c51 100644 --- a/docs-examples/c/connect_example.c +++ b/docs-examples/c/connect_example.c @@ -1,13 +1,24 @@ // compile with -// gcc connect_example.c -o connect_example -I /usr/local/taos/include -L /usr/local/taos/driver -ltaos +// gcc connect_example.c -o connect_example -ltaos #include +#include #include "taos.h" -#include "taoserror.h" int main() { - // if don't want to connect to a default db, set it to NULL. + const char *host = "localhost"; + const char *user = "root"; + const char *passwd = "taosdata"; + // if don't want to connect to a default db, set it to NULL or "" const char *db = NULL; - TAOS *taos = taos_connect("localhost", "root", "taosdata", db, 6030); - printf("Connected\n"); - taos_close(taos); + uint16_t port = 0; // 0 means use the default port + TAOS *taos = taos_connect(host, user, passwd, db, port); + if (taos == NULL) { + int errono = taos_errno(NULL); + char *msg = taos_errstr(NULL); + printf("%d, %s\n", errono, msg); + } else { + printf("connected\n"); + taos_close(taos); + } + taos_cleanup(); } diff --git a/docs-examples/c/error_handle_example.c b/docs-examples/c/error_handle_example.c new file mode 100644 index 0000000000000000000000000000000000000000..36bb7f12f77a46230add5af82b68e6fb86ddfe77 --- /dev/null +++ b/docs-examples/c/error_handle_example.c @@ -0,0 +1,24 @@ +// compile with +// gcc error_handle_example.c -o error_handle_example -ltaos +#include +#include +#include "taos.h" + +int main() { + const char *host = "localhost"; + const char *user = "root"; + const char *passwd = "taosdata"; + // if don't want to connect to a default db, set it to NULL or "" + const char *db = "notexist"; + uint16_t port = 0; // 0 means use the default port + TAOS *taos = taos_connect(host, user, passwd, db, port); + if (taos == NULL) { + int errono = taos_errno(NULL); + char *msg = taos_errstr(NULL); + printf("%d, %s\n", errono, msg); + } else { + printf("connected\n"); + taos_close(taos); + } + taos_cleanup(); +} diff --git a/docs-examples/c/insert_example.c b/docs-examples/c/insert_example.c new file mode 100644 index 0000000000000000000000000000000000000000..ca12be9314efbda707dbd05449c746794c209743 --- /dev/null +++ b/docs-examples/c/insert_example.c @@ -0,0 +1,51 @@ +// compile with +// gcc -o insert_example insert_example.c -ltaos +#include +#include +#include "taos.h" + + +/** + * @brief execute sql and print affected rows. + * + * @param taos + * @param sql + */ +void executeSQL(TAOS *taos, const char *sql) { + TAOS_RES *res = taos_query(taos, sql); + int code = taos_errno(res); + if (code != 0) { + printf("Error code: %d; Message: %s\n", code, taos_errstr(res)); + taos_free_result(res); + taos_close(taos); + exit(EXIT_FAILURE); + } + int affectedRows = taos_affected_rows(res); + printf("affected rows %d\n", affectedRows); + taos_free_result(res); +} + + + +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 6030); + if (taos == NULL) { + printf("failed to connect to server\n"); + exit(EXIT_FAILURE); + } + executeSQL(taos, "CREATE DATABASE power"); + executeSQL(taos, "USE power"); + executeSQL(taos, "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"); + executeSQL(taos, "INSERT INTO d1001 USING meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)" + "d1002 USING meters TAGS(Beijing.Chaoyang, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)" + "d1003 USING meters TAGS(Beijing.Haidian, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)" + "d1004 USING meters TAGS(Beijing.Haidian, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)"); + taos_close(taos); + taos_cleanup(); +} + +// output: +// affected rows 0 +// affected rows 0 +// affected rows 0 +// affected rows 8 \ No newline at end of file diff --git a/docs-examples/c/json_protocol_example.c b/docs-examples/c/json_protocol_example.c new file mode 100644 index 0000000000000000000000000000000000000000..182fd201308facc80c76f36cfa57580784d70413 --- /dev/null +++ b/docs-examples/c/json_protocol_example.c @@ -0,0 +1,52 @@ +// compile with +// gcc -o json_protocol_example json_protocol_example.c -ltaos +#include +#include +#include +#include "taos.h" + +void executeSQL(TAOS *taos, const char *sql) { + TAOS_RES *res = taos_query(taos, sql); + int code = taos_errno(res); + if (code != 0) { + printf("%s\n", taos_errstr(res)); + taos_free_result(res); + taos_close(taos); + exit(EXIT_FAILURE); + } + taos_free_result(res); +} + +// ANCHOR: main +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", "", 6030); + if (taos == NULL) { + printf("failed to connect to server\n"); + exit(EXIT_FAILURE); + } + executeSQL(taos, "DROP DATABASE IF EXISTS test"); + executeSQL(taos, "CREATE DATABASE test"); + executeSQL(taos, "USE test"); + char *line = + "[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": " + "\"Beijing.Chaoyang\", \"groupid\": 2}},{\"metric\": \"meters.voltage\", \"timestamp\": 1648432611249, " + "\"value\": 219, \"tags\": {\"location\": \"Beijing.Haidian\", \"groupid\": 1}},{\"metric\": \"meters.current\", " + "\"timestamp\": 1648432611250, \"value\": 12.6, \"tags\": {\"location\": \"Beijing.Chaoyang\", \"groupid\": " + "2}},{\"metric\": \"meters.voltage\", \"timestamp\": 1648432611250, \"value\": 221, \"tags\": {\"location\": " + "\"Beijing.Haidian\", \"groupid\": 1}}]"; + + char *lines[] = {line}; + TAOS_RES *res = taos_schemaless_insert(taos, lines, 1, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED); + if (taos_errno(res) != 0) { + printf("failed to insert schema-less data, reason: %s\n", taos_errstr(res)); + } else { + int affectedRow = taos_affected_rows(res); + printf("successfully inserted %d rows\n", affectedRow); + } + taos_free_result(res); + taos_close(taos); + taos_cleanup(); +} +// output: +// successfully inserted 4 rows +// ANCHOR_END: main diff --git a/docs-examples/c/line_example.c b/docs-examples/c/line_example.c new file mode 100644 index 0000000000000000000000000000000000000000..8dd4b1a5075369625645959da0476b76b9fbf290 --- /dev/null +++ b/docs-examples/c/line_example.c @@ -0,0 +1,47 @@ +// compile with +// gcc -o line_example line_example.c -ltaos +#include +#include +#include +#include "taos.h" + +void executeSQL(TAOS *taos, const char *sql) { + TAOS_RES *res = taos_query(taos, sql); + int code = taos_errno(res); + if (code != 0) { + printf("%s\n", taos_errstr(res)); + taos_free_result(res); + taos_close(taos); + exit(EXIT_FAILURE); + } + taos_free_result(res); +} + +// ANCHOR: main +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", "", 0); + if (taos == NULL) { + printf("failed to connect to server\n"); + exit(EXIT_FAILURE); + } + executeSQL(taos, "DROP DATABASE IF EXISTS test"); + executeSQL(taos, "CREATE DATABASE test"); + executeSQL(taos, "USE test"); + char *lines[] = {"meters,location=Beijing.Haidian,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249", + "meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250", + "meters,location=Beijing.Haidian,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249", + "meters,location=Beijing.Haidian,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250"}; + TAOS_RES *res = taos_schemaless_insert(taos, lines, 4, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); + if (taos_errno(res) != 0) { + printf("failed to insert schema-less data, reason: %s\n", taos_errstr(res)); + } else { + int affectedRows = taos_affected_rows(res); + printf("successfully inserted %d rows\n", affectedRows); + } + taos_free_result(res); + taos_close(taos); + taos_cleanup(); +} +// output: +// successfully inserted 4 rows +// ANCHOR_END: main \ No newline at end of file diff --git a/docs-examples/c/multi_bind_example.c b/docs-examples/c/multi_bind_example.c new file mode 100644 index 0000000000000000000000000000000000000000..fe11df9caad3e216fbd0b1ff2f40a54fe3ba86e5 --- /dev/null +++ b/docs-examples/c/multi_bind_example.c @@ -0,0 +1,147 @@ +// compile with +// gcc -o multi_bind_example multi_bind_example.c -ltaos +#include +#include +#include +#include "taos.h" + +/** + * @brief execute sql only and ignore result set + * + * @param taos + * @param sql + */ +void executeSQL(TAOS *taos, const char *sql) { + TAOS_RES *res = taos_query(taos, sql); + int code = taos_errno(res); + if (code != 0) { + printf("%s\n", taos_errstr(res)); + taos_free_result(res); + taos_close(taos); + exit(EXIT_FAILURE); + } + taos_free_result(res); +} + +/** + * @brief exit program when error occur. + * + * @param stmt + * @param code + * @param msg + */ +void checkErrorCode(TAOS_STMT *stmt, int code, const char *msg) { + if (code != 0) { + printf("%s. error: %s\n", msg, taos_stmt_errstr(stmt)); + taos_stmt_close(stmt); + exit(EXIT_FAILURE); + } +} + +/** + * @brief insert data using stmt API + * + * @param taos + */ +void insertData(TAOS *taos) { + // init + TAOS_STMT *stmt = taos_stmt_init(taos); + // prepare + const char *sql = "INSERT INTO ? USING meters TAGS(?, ?) values(?, ?, ?, ?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + checkErrorCode(stmt, code, "failed to execute taos_stmt_prepare"); + // bind table name and tags + TAOS_BIND tags[2]; + char *location = "Beijing.Chaoyang"; + int groupId = 2; + tags[0].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[0].buffer_length = strlen(location); + tags[0].length = &tags[0].buffer_length; + tags[0].buffer = location; + tags[0].is_null = NULL; + + tags[1].buffer_type = TSDB_DATA_TYPE_INT; + tags[1].buffer_length = sizeof(int); + tags[1].length = &tags[1].buffer_length; + tags[1].buffer = &groupId; + tags[1].is_null = NULL; + + code = taos_stmt_set_tbname_tags(stmt, "d1001", tags); + checkErrorCode(stmt, code, "failed to execute taos_stmt_set_tbname_tags"); + + // highlight-start + // insert two rows with multi binds + TAOS_MULTI_BIND params[4]; + // values to bind + int64_t ts[] = {1648432611249, 1648432611749}; + float current[] = {10.3, 12.6}; + int voltage[] = {219, 218}; + float phase[] = {0.31, 0.33}; + // is_null array + char is_null[2] = {0}; + // length array + int32_t int64Len[2] = {sizeof(int64_t)}; + int32_t floatLen[2] = {sizeof(float)}; + int32_t intLen[2] = {sizeof(int)}; + + params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + params[0].buffer_length = sizeof(int64_t); + params[0].buffer = ts; + params[0].length = int64Len; + params[0].is_null = is_null; + params[0].num = 2; + + params[1].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[1].buffer_length = sizeof(float); + params[1].buffer = current; + params[1].length = floatLen; + params[1].is_null = is_null; + params[1].num = 2; + + params[2].buffer_type = TSDB_DATA_TYPE_INT; + params[2].buffer_length = sizeof(int); + params[2].buffer = voltage; + params[2].length = intLen; + params[2].is_null = is_null; + params[2].num = 2; + + params[3].buffer_type = TSDB_DATA_TYPE_FLOAT; + params[3].buffer_length = sizeof(float); + params[3].buffer = phase; + params[3].length = floatLen; + params[3].is_null = is_null; + params[3].num = 2; + + code = taos_stmt_bind_param_batch(stmt, params); // bind batch + checkErrorCode(stmt, code, "failed to execute taos_stmt_bind_param_batch"); + code = taos_stmt_add_batch(stmt); // add batch + checkErrorCode(stmt, code, "failed to execute taos_stmt_add_batch"); + // highlight-end + // execute + code = taos_stmt_execute(stmt); + checkErrorCode(stmt, code, "failed to execute taos_stmt_execute"); + int affectedRows = taos_stmt_affected_rows(stmt); + printf("successfully inserted %d rows\n", affectedRows); + // close + taos_stmt_close(stmt); +} + +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 6030); + if (taos == NULL) { + printf("failed to connect to server\n"); + exit(EXIT_FAILURE); + } + executeSQL(taos, "DROP DATABASE IF EXISTS power"); + executeSQL(taos, "CREATE DATABASE power"); + executeSQL(taos, "USE power"); + executeSQL(taos, + "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), " + "groupId INT)"); + insertData(taos); + taos_close(taos); + taos_cleanup(); +} + +// output: +// successfully inserted 2 rows \ No newline at end of file diff --git a/docs-examples/c/query_example.c b/docs-examples/c/query_example.c new file mode 100644 index 0000000000000000000000000000000000000000..4314ac4fe2f5b5251af2462bf0b20ebeed7cac5e --- /dev/null +++ b/docs-examples/c/query_example.c @@ -0,0 +1,143 @@ +// compile with: +// gcc -o query_example query_example.c -ltaos +#include +#include +#include +#include +#include + +typedef int16_t VarDataLenT; + +#define TSDB_NCHAR_SIZE sizeof(int32_t) +#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) + +#define GET_FLOAT_VAL(x) (*(float *)(x)) +#define GET_DOUBLE_VAL(x) (*(double *)(x)) + +#define varDataLen(v) ((VarDataLenT *)(v))[0] + +int printRow(char *str, TAOS_ROW row, TAOS_FIELD *fields, int numFields) { + int len = 0; + char split = ' '; + + for (int i = 0; i < numFields; ++i) { + if (i > 0) { + str[len++] = split; + } + + if (row[i] == NULL) { + len += sprintf(str + len, "%s", "NULL"); + continue; + } + + switch (fields[i].type) { + case TSDB_DATA_TYPE_TINYINT: + len += sprintf(str + len, "%d", *((int8_t *)row[i])); + break; + + case TSDB_DATA_TYPE_UTINYINT: + len += sprintf(str + len, "%u", *((uint8_t *)row[i])); + break; + + case TSDB_DATA_TYPE_SMALLINT: + len += sprintf(str + len, "%d", *((int16_t *)row[i])); + break; + + case TSDB_DATA_TYPE_USMALLINT: + len += sprintf(str + len, "%u", *((uint16_t *)row[i])); + break; + + case TSDB_DATA_TYPE_INT: + len += sprintf(str + len, "%d", *((int32_t *)row[i])); + break; + + case TSDB_DATA_TYPE_UINT: + len += sprintf(str + len, "%u", *((uint32_t *)row[i])); + break; + + case TSDB_DATA_TYPE_BIGINT: + len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i])); + break; + + case TSDB_DATA_TYPE_UBIGINT: + len += sprintf(str + len, "%" PRIu64, *((uint64_t *)row[i])); + break; + + case TSDB_DATA_TYPE_FLOAT: { + float fv = 0; + fv = GET_FLOAT_VAL(row[i]); + len += sprintf(str + len, "%f", fv); + } break; + + case TSDB_DATA_TYPE_DOUBLE: { + double dv = 0; + dv = GET_DOUBLE_VAL(row[i]); + len += sprintf(str + len, "%lf", dv); + } break; + + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: { + int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE); + memcpy(str + len, row[i], charLen); + len += charLen; + } break; + + case TSDB_DATA_TYPE_TIMESTAMP: + len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i])); + break; + + case TSDB_DATA_TYPE_BOOL: + len += sprintf(str + len, "%d", *((int8_t *)row[i])); + default: + break; + } + } + + return len; +} + +/** + * @brief print column name and values of each row + * + * @param res + * @return int + */ +static int printResult(TAOS_RES *res) { + int numFields = taos_num_fields(res); + TAOS_FIELD *fields = taos_fetch_fields(res); + char header[256] = {0}; + int len = 0; + for (int i = 0; i < numFields; ++i) { + len += sprintf(header + len, "%s ", fields[i].name); + } + puts(header); + + TAOS_ROW row = NULL; + while ((row = taos_fetch_row(res))) { + char temp[256] = {0}; + printRow(temp, row, fields, numFields); + puts(temp); + } +} + +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", "power", 6030); + if (taos == NULL) { + puts("failed to connect to server"); + exit(EXIT_FAILURE); + } + TAOS_RES *res = taos_query(taos, "SELECT * FROM meters LIMIT 2"); + if (taos_errno(res) != 0) { + printf("failed to exeuce taos_query. error: %s\n", taos_errstr(res)); + exit(EXIT_FAILURE); + } + printResult(res); + taos_free_result(res); + taos_close(taos); + taos_cleanup(); +} + +// output: +// ts current voltage phase location groupid +// 1648432611249 10.300000 219 0.310000 Beijing.Chaoyang 2 +// 1648432611749 12.600000 218 0.330000 Beijing.Chaoyang 2 \ No newline at end of file diff --git a/docs-examples/c/stmt_example.c b/docs-examples/c/stmt_example.c new file mode 100644 index 0000000000000000000000000000000000000000..fab1506f953ef68050e4318406fa2ba1a0202929 --- /dev/null +++ b/docs-examples/c/stmt_example.c @@ -0,0 +1,141 @@ +// compile with +// gcc -o stmt_example stmt_example.c -ltaos +#include +#include +#include +#include "taos.h" + +/** + * @brief execute sql only. + * + * @param taos + * @param sql + */ +void executeSQL(TAOS *taos, const char *sql) { + TAOS_RES *res = taos_query(taos, sql); + int code = taos_errno(res); + if (code != 0) { + printf("%s\n", taos_errstr(res)); + taos_free_result(res); + taos_close(taos); + exit(EXIT_FAILURE); + } + taos_free_result(res); +} + +/** + * @brief check return status and exit program when error occur. + * + * @param stmt + * @param code + * @param msg + */ +void checkErrorCode(TAOS_STMT *stmt, int code, const char* msg) { + if (code != 0) { + printf("%s. error: %s\n", msg, taos_stmt_errstr(stmt)); + taos_stmt_close(stmt); + exit(EXIT_FAILURE); + } +} + +typedef struct { + int64_t ts; + float current; + int voltage; + float phase; +} Row; + +/** + * @brief insert data using stmt API + * + * @param taos + */ +void insertData(TAOS *taos) { + // init + TAOS_STMT *stmt = taos_stmt_init(taos); + // prepare + const char *sql = "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)"; + int code = taos_stmt_prepare(stmt, sql, 0); + checkErrorCode(stmt, code, "failed to execute taos_stmt_prepare"); + // bind table name and tags + TAOS_BIND tags[2]; + char* location = "Beijing.Chaoyang"; + int groupId = 2; + tags[0].buffer_type = TSDB_DATA_TYPE_BINARY; + tags[0].buffer_length = strlen(location); + tags[0].length = &tags[0].buffer_length; + tags[0].buffer = location; + tags[0].is_null = NULL; + + tags[1].buffer_type = TSDB_DATA_TYPE_INT; + tags[1].buffer_length = sizeof(int); + tags[1].length = &tags[1].buffer_length; + tags[1].buffer = &groupId; + tags[1].is_null = NULL; + + code = taos_stmt_set_tbname_tags(stmt, "d1001", tags); + checkErrorCode(stmt, code, "failed to execute taos_stmt_set_tbname_tags"); + + // insert two rows + Row rows[2] = { + {1648432611249, 10.3, 219, 0.31}, + {1648432611749, 12.6, 218, 0.33}, + }; + + TAOS_BIND values[4]; + values[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; + values[0].buffer_length = sizeof(int64_t); + values[0].length = &values[0].buffer_length; + values[0].is_null = NULL; + + values[1].buffer_type = TSDB_DATA_TYPE_FLOAT; + values[1].buffer_length = sizeof(float); + values[1].length = &values[1].buffer_length; + values[1].is_null = NULL; + + values[2].buffer_type = TSDB_DATA_TYPE_INT; + values[2].buffer_length = sizeof(int); + values[2].length = &values[2].buffer_length; + values[2].is_null = NULL; + + values[3].buffer_type = TSDB_DATA_TYPE_FLOAT; + values[3].buffer_length = sizeof(float); + values[3].length = &values[3].buffer_length; + values[3].is_null = NULL; + + for (int i = 0; i < 2; ++i) { + values[0].buffer = &rows[i].ts; + values[1].buffer = &rows[i].current; + values[2].buffer = &rows[i].voltage; + values[3].buffer = &rows[i].phase; + code = taos_stmt_bind_param(stmt, values); // bind param + checkErrorCode(stmt, code, "failed to execute taos_stmt_bind_param"); + code = taos_stmt_add_batch(stmt); // add batch + checkErrorCode(stmt, code, "failed to execute taos_stmt_add_batch"); + } + // execute + code = taos_stmt_execute(stmt); + checkErrorCode(stmt, code, "failed to execute taos_stmt_execute"); + int affectedRows = taos_stmt_affected_rows(stmt); + printf("successfully inserted %d rows\n", affectedRows); + // close + taos_stmt_close(stmt); +} + +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 6030); + if (taos == NULL) { + printf("failed to connect to server\n"); + exit(EXIT_FAILURE); + } + executeSQL(taos, "CREATE DATABASE power"); + executeSQL(taos, "USE power"); + executeSQL(taos, "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"); + insertData(taos); + taos_close(taos); + taos_cleanup(); +} + + +// output: +// successfully inserted 2 rows \ No newline at end of file diff --git a/docs-examples/c/subscribe_demo.c b/docs-examples/c/subscribe_demo.c new file mode 100644 index 0000000000000000000000000000000000000000..3c6c4176f7b4914b9a50184906f220d0e8a1a248 --- /dev/null +++ b/docs-examples/c/subscribe_demo.c @@ -0,0 +1,63 @@ +// compile with: +// gcc -o subscribe_demo subscribe_demo.c -ltaos + +#include +#include +#include +#include + +int nTotalRows; + +/** + * @brief callback function of subscription. + * + * @param tsub + * @param res + * @param param. the additional parameter passed to taos_subscribe + * @param code. error code + */ +void subscribe_callback(TAOS_SUB* tsub, TAOS_RES* res, void* param, int code) { + if (code != 0) { + printf("error: %d\n", code); + exit(EXIT_FAILURE); + } + + TAOS_ROW row = NULL; + int num_fields = taos_num_fields(res); + TAOS_FIELD* fields = taos_fetch_fields(res); + int nRows = 0; + + while ((row = taos_fetch_row(res))) { + char buf[4096] = {0}; + taos_print_row(buf, row, fields, num_fields); + puts(buf); + nRows++; + } + + nTotalRows += nRows; + printf("%d rows consumed.\n", nRows); +} + +int main() { + TAOS* taos = taos_connect("localhost", "root", "taosdata", NULL, 6030); + if (taos == NULL) { + printf("failed to connect to server\n"); + exit(EXIT_FAILURE); + } + + int restart = 1; // if the topic already exists, where to subscribe from the begine. + const char* topic = "topic-meter-current-bg-10"; + const char* sql = "select * from power.meters where current > 10"; + void* param = NULL; // additional parameter. + int interval = 2000; // consumption interval in microseconds. + TAOS_SUB* tsub = taos_subscribe(taos, restart, topic, sql, subscribe_callback, NULL, interval); + + getchar(); // press Enter to stop + + printf("total rows consumed: %d\n", nTotalRows); + int keep = 0; // weather to keep subscribe process + taos_unsubscribe(tsub, keep); + + taos_close(taos); + taos_cleanup(); +} \ No newline at end of file diff --git a/docs-examples/c/telnet_line_example.c b/docs-examples/c/telnet_line_example.c new file mode 100644 index 0000000000000000000000000000000000000000..913d433f6aec07b3bce115d45536ffa4b45a0481 --- /dev/null +++ b/docs-examples/c/telnet_line_example.c @@ -0,0 +1,54 @@ +// compile with +// gcc -o telnet_line_example telnet_line_example.c -ltaos +#include +#include +#include +#include "taos.h" + +void executeSQL(TAOS *taos, const char *sql) { + TAOS_RES *res = taos_query(taos, sql); + int code = taos_errno(res); + if (code != 0) { + printf("%s\n", taos_errstr(res)); + taos_free_result(res); + taos_close(taos); + exit(EXIT_FAILURE); + } + taos_free_result(res); +} + +// ANCHOR: main +int main() { + TAOS *taos = taos_connect("localhost", "root", "taosdata", "", 6030); + if (taos == NULL) { + printf("failed to connect to server\n"); + exit(EXIT_FAILURE); + } + executeSQL(taos, "DROP DATABASE IF EXISTS test"); + executeSQL(taos, "CREATE DATABASE test"); + executeSQL(taos, "USE test"); + char *lines[] = { + "meters.current 1648432611249 10.3 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611250 12.6 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611249 10.8 location=Beijing.Haidian groupid=3", + "meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611249 219 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611250 218 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611249 221 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611250 217 location=Beijing.Haidian groupid=3", + }; + TAOS_RES *res = taos_schemaless_insert(taos, lines, 8, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NOT_CONFIGURED); + if (taos_errno(res) != 0) { + printf("failed to insert schema-less data, reason: %s\n", taos_errstr(res)); + } else { + int affectedRow = taos_affected_rows(res); + printf("successfully inserted %d rows\n", affectedRow); + } + + taos_free_result(res); + taos_close(taos); + taos_cleanup(); +} +// output: +// successfully inserted 8 rows +// ANCHOR_END: main diff --git a/src/connector/C#/examples/lib/Utils.cs b/docs-examples/csharp/AsyncQueryExample.cs similarity index 53% rename from src/connector/C#/examples/lib/Utils.cs rename to docs-examples/csharp/AsyncQueryExample.cs index a2fb25c70162a49ac8f1bb24f451cac413f72733..fe30d21efe82e8d1dc414bd4723227ca93bc944f 100644 --- a/src/connector/C#/examples/lib/Utils.cs +++ b/docs-examples/csharp/AsyncQueryExample.cs @@ -1,110 +1,69 @@ -using System; using TDengineDriver; using System.Runtime.InteropServices; -using System.Text; -using System.Collections.Generic; -namespace Sample.UtilsTools + +namespace TDengineExample { - public class UtilsTools + public class AsyncQueryExample { - - static string ip = "127.0.0.1"; - static string user = "root"; - static string password = "taosdata"; - static string db = ""; - static short port = 0; - static string globalDbName = "csharp_example_db"; - //get a TDengine connection - public static IntPtr TDConnection() - { - TDengine.Options((int)TDengineInitOption.TSDB_OPTION_CONFIGDIR, GetConfigPath()); - TDengine.Options((int)TDengineInitOption.TSDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - TDengine.Init(); - - IntPtr conn = TDengine.Connect(ip, user, password, db, port); - UtilsTools.ExecuteUpdate(conn, $"drop database if exists {globalDbName}"); - UtilsTools.ExecuteUpdate(conn, $"create database if not exists {globalDbName} keep 3650"); - UtilsTools.ExecuteUpdate(conn, $"use {globalDbName}"); - return conn; - } - //get taos.cfg file based on different os - public static string GetConfigPath() + static void Main() { - string configDir = ""; - if (OperatingSystem.IsOSPlatform("Windows")) - { - configDir = "C:/TDengine/cfg"; - } - else if (OperatingSystem.IsOSPlatform("Linux")) - { - configDir = "/etc/taos"; - } - else if (OperatingSystem.IsOSPlatform("macOS")) - { - configDir = "/usr/local/etc/taos"; - } - return configDir; - } - - public static IntPtr ExecuteQuery(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) - { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - return res; + IntPtr conn = GetConnection(); + QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback); + TDengine.QueryAsync(conn, "select * from meters", queryAsyncCallback, IntPtr.Zero); + Thread.Sleep(2000); + TDengine.Close(conn); + TDengine.Cleanup(); } - public static IntPtr ExecuteErrorQuery(IntPtr conn, String sql) + static void QueryCallback(IntPtr param, IntPtr taosRes, int code) { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) + if (code == 0 && taosRes != IntPtr.Zero) { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); + FetchRowAsyncCallback fetchRowAsyncCallback = new FetchRowAsyncCallback(FetchRowCallback); + TDengine.FetchRowAsync(taosRes, fetchRowAsyncCallback, param); } else { - Console.WriteLine(sql.ToString() + " success"); - + Console.WriteLine($"async query data failed, failed code {code}"); } - return res; } - public static void ExecuteUpdate(IntPtr conn, String sql) + static void FetchRowCallback(IntPtr param, IntPtr taosRes, int numOfRows) { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) + if (numOfRows > 0) { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); + Console.WriteLine($"{numOfRows} rows async retrieved"); + DisplayRes(taosRes); + TDengine.FetchRowAsync(taosRes, FetchRowCallback, param); } else { - Console.WriteLine(sql.ToString() + " success"); + if (numOfRows == 0) + { + Console.WriteLine("async retrieve complete."); + } + else + { + Console.WriteLine($"FetchRowAsync callback error, error code {numOfRows}"); + } + TDengine.FreeResult(taosRes); } - TDengine.FreeResult(res); } public static void DisplayRes(IntPtr res) { if (!IsValidResult(res)) { - ExitProgram(); + TDengine.Cleanup(); + System.Environment.Exit(1); } - List metaList = GetResField(res); + List metaList = TDengine.FetchFields(res); int fieldCount = metaList.Count; // metaList.ForEach((item) => { Console.Write("{0} ({1}) \t|\t", item.name, item.size); }); - List dataList = QueryRes(res, metaList); + List dataList = QueryRes(res, metaList); for (int index = 0; index < dataList.Count; index++) { if (index % fieldCount == 0 && index != 0) @@ -117,29 +76,6 @@ namespace Sample.UtilsTools Console.WriteLine(""); } - public static List> GetResultSet(IntPtr res) - { - List> result = new List>(); - List colName = new List(); - List dataRaw = new List(); - if (!IsValidResult(res)) - { - ExitProgram(); - } - - List meta = GetResField(res); - result.Add(colName); - - dataRaw = QueryRes(res, meta); - result.Add(dataRaw); - - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - } - return result; - } - public static bool IsValidResult(IntPtr res) { if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) @@ -154,69 +90,31 @@ namespace Sample.UtilsTools } return true; } - public static void CloseConnection(IntPtr conn) - { - ExecuteUpdate(conn, $"drop database if exists {globalDbName}"); - if (conn != IntPtr.Zero) - { - if (TDengine.Close(conn) == 0) - { - Console.WriteLine("close connection success"); - } - else - { - Console.WriteLine("close Connection failed"); - } - } - } - public static List GetResField(IntPtr res) - { - List meta = TDengine.FetchFields(res); - return meta; - } - public static void ExitProgram() - { - TDengine.Cleanup(); - System.Environment.Exit(0); - } - public static List GetResData(IntPtr res) - { - List colName = new List(); - List dataRaw = new List(); - if (!IsValidResult(res)) - { - ExitProgram(); - } - List meta = GetResField(res); - dataRaw = QueryRes(res, meta); - return dataRaw; - } - private static List QueryRes(IntPtr res, List meta) + private static List QueryRes(IntPtr res, List meta) { IntPtr taosRow; - List dataRaw = new List(); - int fieldCount = meta.Count; + List dataRaw = new(); while ((taosRow = TDengine.FetchRows(res)) != IntPtr.Zero) { - dataRaw.AddRange(FetchRow(taosRow,res)); + dataRaw.AddRange(FetchRow(taosRow, res)); } if (TDengine.ErrorNo(res) != 0) { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); + Console.Write("Query is not complete, Error {0} {1}", TDengine.ErrorNo(res), TDengine.Error(res)); } - // TDengine.FreeResult(res); + TDengine.FreeResult(res); Console.WriteLine(""); return dataRaw; } - - public static List FetchRow(IntPtr taosRow, IntPtr taosRes)//, List metaList, int numOfFiled + public static List FetchRow(IntPtr taosRow, IntPtr taosRes)//, List metaList, int numOfFiled { List metaList = TDengine.FetchFields(taosRes); int numOfFiled = TDengine.FieldCount(taosRes); - List dataRaw = new List(); + + List dataRaw = new(); IntPtr colLengthPrt = TDengine.FetchLengths(taosRes); int[] colLengthArr = new int[numOfFiled]; @@ -235,7 +133,7 @@ namespace Sample.UtilsTools switch ((TDengineDataType)meta.type) { case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; + bool v1 = Marshal.ReadByte(data) != 0; dataRaw.Add(v1); break; case TDengineDataType.TSDB_DATA_TYPE_TINYINT: @@ -293,7 +191,7 @@ namespace Sample.UtilsTools case TDengineDataType.TSDB_DATA_TYPE_JSONTAG: string v16 = Marshal.PtrToStringUTF8(data, colLengthArr[i]); dataRaw.Add(v16); - break; + break; default: dataRaw.Add("nonsupport data type"); break; @@ -302,6 +200,39 @@ namespace Sample.UtilsTools } return dataRaw; } + + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = "power"; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + Console.WriteLine("Connect to TDengine failed"); + Environment.Exit(0); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } } } +//output: +//Connect to TDengine success +//8 rows async retrieved + +//1538548685000 | 10.3 | 219 | 0.31 | beijing.chaoyang | 2 | +//1538548695000 | 12.6 | 218 | 0.33 | beijing.chaoyang | 2 | +//1538548696800 | 12.3 | 221 | 0.31 | beijing.chaoyang | 2 | +//1538548696650 | 10.3 | 218 | 0.25 | beijing.chaoyang | 3 | +//1538548685500 | 11.8 | 221 | 0.28 | beijing.haidian | 2 | +//1538548696600 | 13.4 | 223 | 0.29 | beijing.haidian | 2 | +//1538548685000 | 10.8 | 223 | 0.29 | beijing.haidian | 3 | +//1538548686500 | 11.5 | 221 | 0.35 | beijing.haidian | 3 | +//async retrieve complete. \ No newline at end of file diff --git a/docs-examples/csharp/ConnectExample.cs b/docs-examples/csharp/ConnectExample.cs index 6eef617015ed3f628b7f35bf2e553fdfc5eef558..f3548ee65daab8a59695499339a8f89b0aa33a10 100644 --- a/docs-examples/csharp/ConnectExample.cs +++ b/docs-examples/csharp/ConnectExample.cs @@ -1,25 +1,28 @@ +using TDengineDriver; -namespace TDExamples +namespace TDengineExample { - internal class ConnectExample + + internal class ConnectExample { static void Main(String[] args) - { + { string host = "localhost"; short port = 6030; string username = "root"; string password = "taosdata"; string dbname = ""; - + var conn = TDengine.Connect(host, username, password, dbname, port); if (conn == IntPtr.Zero) { Console.WriteLine("Connect to TDengine failed"); } - else - { + else + { Console.WriteLine("Connect to TDengine success"); } + TDengine.Close(conn); TDengine.Cleanup(); } } diff --git a/docs-examples/csharp/InfluxDBLineExample.cs b/docs-examples/csharp/InfluxDBLineExample.cs new file mode 100644 index 0000000000000000000000000000000000000000..7aad08825209db568d61e5963ec7a00034ab7ca7 --- /dev/null +++ b/docs-examples/csharp/InfluxDBLineExample.cs @@ -0,0 +1,77 @@ +using TDengineDriver; + +namespace TDengineExample +{ + internal class InfluxDBLineExample + { + static void Main() + { + IntPtr conn = GetConnection(); + PrepareDatabase(conn); + string[] lines = { + "meters,location=Beijing.Haidian,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249", + "meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250", + "meters,location=Beijing.Haidian,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249", + "meters,location=Beijing.Haidian,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250" + }; + IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_MILLI_SECONDS); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + else + { + int affectedRows = TDengine.AffectRows(res); + Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); + } + TDengine.FreeResult(res); + ExitProgram(conn, 0); + + } + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = ""; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + Console.WriteLine("Connect to TDengine failed"); + TDengine.Cleanup(); + Environment.Exit(1); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } + + static void PrepareDatabase(IntPtr conn) + { + IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + res = TDengine.Query(conn, "USE test"); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + } + + static void ExitProgram(IntPtr conn, int exitCode) + { + TDengine.Close(conn); + TDengine.Cleanup(); + Environment.Exit(exitCode); + } + } + +} diff --git a/docs-examples/csharp/OptsJsonExample.cs b/docs-examples/csharp/OptsJsonExample.cs new file mode 100644 index 0000000000000000000000000000000000000000..d774a325afa1a8d93eb858f23dcd97dd29f8653d --- /dev/null +++ b/docs-examples/csharp/OptsJsonExample.cs @@ -0,0 +1,76 @@ +using TDengineDriver; + +namespace TDengineExample +{ + internal class OptsJsonExample + { + static void Main() + { + IntPtr conn = GetConnection(); + PrepareDatabase(conn); + string[] lines = { "[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": \"Beijing.Chaoyang\", \"groupid\": 2}}," + + " {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611249, \"value\": 219, \"tags\": {\"location\": \"Beijing.Haidian\", \"groupid\": 1}}, " + + "{\"metric\": \"meters.current\", \"timestamp\": 1648432611250, \"value\": 12.6, \"tags\": {\"location\": \"Beijing.Chaoyang\", \"groupid\": 2}}," + + " {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611250, \"value\": 221, \"tags\": {\"location\": \"Beijing.Haidian\", \"groupid\": 1}}]" + }; + + IntPtr res = TDengine.SchemalessInsert(conn, lines, 1, (int)TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + else + { + int affectedRows = TDengine.AffectRows(res); + Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); + } + TDengine.FreeResult(res); + ExitProgram(conn, 0); + + } + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = ""; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + Console.WriteLine("Connect to TDengine failed"); + TDengine.Cleanup(); + Environment.Exit(1); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } + + static void PrepareDatabase(IntPtr conn) + { + IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + res = TDengine.Query(conn, "USE test"); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + } + + static void ExitProgram(IntPtr conn, int exitCode) + { + TDengine.Close(conn); + TDengine.Cleanup(); + Environment.Exit(exitCode); + } + } +} diff --git a/docs-examples/csharp/OptsTelnetExample.cs b/docs-examples/csharp/OptsTelnetExample.cs new file mode 100644 index 0000000000000000000000000000000000000000..81608c32213fa0618a2ca6e0769aacf8e9c8e64d --- /dev/null +++ b/docs-examples/csharp/OptsTelnetExample.cs @@ -0,0 +1,80 @@ +using TDengineDriver; + +namespace TDengineExample +{ + internal class OptsTelnetExample + { + static void Main() + { + IntPtr conn = GetConnection(); + PrepareDatabase(conn); + string[] lines = { + "meters.current 1648432611249 10.3 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611250 12.6 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611249 10.8 location=Beijing.Haidian groupid=3", + "meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611249 219 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611250 218 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611249 221 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611250 217 location=Beijing.Haidian groupid=3", + }; + IntPtr res = TDengine.SchemalessInsert(conn, lines, lines.Length, (int)TDengineSchemalessProtocol.TSDB_SML_TELNET_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NOT_CONFIGURED); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("SchemalessInsert failed since " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + else + { + int affectedRows = TDengine.AffectRows(res); + Console.WriteLine($"SchemalessInsert success, affected {affectedRows} rows"); + } + TDengine.FreeResult(res); + ExitProgram(conn, 0); + + } + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = ""; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + Console.WriteLine("Connect to TDengine failed"); + TDengine.Cleanup(); + Environment.Exit(1); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } + + static void PrepareDatabase(IntPtr conn) + { + IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("failed to create database, reason: " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + res = TDengine.Query(conn, "USE test"); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("failed to change database, reason: " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + } + + static void ExitProgram(IntPtr conn, int exitCode) + { + TDengine.Close(conn); + TDengine.Cleanup(); + Environment.Exit(exitCode); + } + } +} diff --git a/docs-examples/csharp/QueryExample.cs b/docs-examples/csharp/QueryExample.cs new file mode 100644 index 0000000000000000000000000000000000000000..f00e391100c7ce42177e2987f5b0b32dc02262c4 --- /dev/null +++ b/docs-examples/csharp/QueryExample.cs @@ -0,0 +1,162 @@ +using TDengineDriver; +using System.Runtime.InteropServices; + +namespace TDengineExample +{ + internal class QueryExample + { + static void Main() + { + IntPtr conn = GetConnection(); + // run query + IntPtr res = TDengine.Query(conn, "SELECT * FROM test.meters LIMIT 2"); + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine("Failed to query since: " + TDengine.Error(res)); + TDengine.Close(conn); + TDengine.Cleanup(); + return; + } + + // get filed count + int fieldCount = TDengine.FieldCount(res); + Console.WriteLine("fieldCount=" + fieldCount); + + // print column names + List metas = TDengine.FetchFields(res); + for (int i = 0; i < metas.Count; i++) + { + Console.Write(metas[i].name + "\t"); + } + Console.WriteLine(); + + // print values + IntPtr row; + while ((row = TDengine.FetchRows(res)) != IntPtr.Zero) + { + List metaList = TDengine.FetchFields(res); + int numOfFiled = TDengine.FieldCount(res); + + List dataRaw = new List(); + + IntPtr colLengthPrt = TDengine.FetchLengths(res); + int[] colLengthArr = new int[numOfFiled]; + Marshal.Copy(colLengthPrt, colLengthArr, 0, numOfFiled); + + for (int i = 0; i < numOfFiled; i++) + { + TDengineMeta meta = metaList[i]; + IntPtr data = Marshal.ReadIntPtr(row, IntPtr.Size * i); + + if (data == IntPtr.Zero) + { + Console.Write("NULL\t"); + continue; + } + switch ((TDengineDataType)meta.type) + { + case TDengineDataType.TSDB_DATA_TYPE_BOOL: + bool v1 = Marshal.ReadByte(data) == 0 ? false : true; + Console.Write(v1.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_TINYINT: + sbyte v2 = (sbyte)Marshal.ReadByte(data); + Console.Write(v2.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: + short v3 = Marshal.ReadInt16(data); + Console.Write(v3.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_INT: + int v4 = Marshal.ReadInt32(data); + Console.Write(v4.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_BIGINT: + long v5 = Marshal.ReadInt64(data); + Console.Write(v5.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_FLOAT: + float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); + Console.Write(v6.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: + double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); + Console.Write(v7.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_BINARY: + string v8 = Marshal.PtrToStringUTF8(data, colLengthArr[i]); + Console.Write(v8 + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: + long v9 = Marshal.ReadInt64(data); + Console.Write(v9.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_NCHAR: + string v10 = Marshal.PtrToStringUTF8(data, colLengthArr[i]); + Console.Write(v10 + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: + byte v12 = Marshal.ReadByte(data); + Console.Write(v12.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: + ushort v13 = (ushort)Marshal.ReadInt16(data); + Console.Write(v13.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_UINT: + uint v14 = (uint)Marshal.ReadInt32(data); + Console.Write(v14.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: + ulong v15 = (ulong)Marshal.ReadInt64(data); + Console.Write(v15.ToString() + "\t"); + break; + case TDengineDataType.TSDB_DATA_TYPE_JSONTAG: + string v16 = Marshal.PtrToStringUTF8(data, colLengthArr[i]); + Console.Write(v16 + "\t"); + break; + default: + Console.Write("nonsupport data type value"); + break; + } + + } + Console.WriteLine(); + } + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine($"Query is not complete, Error {TDengine.ErrorNo(res)} {TDengine.Error(res)}"); + } + // exit + TDengine.FreeResult(res); + TDengine.Close(conn); + TDengine.Cleanup(); + } + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = "power"; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + Console.WriteLine("Connect to TDengine failed"); + System.Environment.Exit(0); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } + } +} + +// output: +// Connect to TDengine success +// fieldCount=6 +// ts current voltage phase location groupid +// 1648432611249 10.3 219 0.31 Beijing.Chaoyang 2 +// 1648432611749 12.6 218 0.33 Beijing.Chaoyang 2 \ No newline at end of file diff --git a/docs-examples/csharp/SQLInsertExample.cs b/docs-examples/csharp/SQLInsertExample.cs new file mode 100644 index 0000000000000000000000000000000000000000..fa2e2a50daf06f4d948479e7f5b0df82c517f809 --- /dev/null +++ b/docs-examples/csharp/SQLInsertExample.cs @@ -0,0 +1,69 @@ +using TDengineDriver; + + +namespace TDengineExample +{ + internal class SQLInsertExample + { + + static void Main() + { + IntPtr conn = GetConnection(); + IntPtr res = TDengine.Query(conn, "CREATE DATABASE power"); + CheckRes(conn, res, "failed to create database"); + res = TDengine.Query(conn, "USE power"); + CheckRes(conn, res, "failed to change database"); + res = TDengine.Query(conn, "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"); + CheckRes(conn, res, "failed to create stable"); + var sql = "INSERT INTO d1001 USING meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) " + + "d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) " + + "d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000)('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) " + + "d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000)('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + res = TDengine.Query(conn, sql); + CheckRes(conn, res, "failed to insert data"); + int affectedRows = TDengine.AffectRows(res); + Console.WriteLine("affectedRows " + affectedRows); + ExitProgram(conn, 0); + } + + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = ""; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + Console.WriteLine("Connect to TDengine failed"); + Environment.Exit(0); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } + + static void CheckRes(IntPtr conn, IntPtr res, String errorMsg) + { + if (TDengine.ErrorNo(res) != 0) + { + Console.Write(errorMsg + " since: " + TDengine.Error(res)); + ExitProgram(conn, 1); + } + } + + static void ExitProgram(IntPtr conn, int exitCode) + { + TDengine.Close(conn); + TDengine.Cleanup(); + Environment.Exit(exitCode); + } + } +} + +// output: +// Connect to TDengine success +// affectedRows 8 diff --git a/docs-examples/csharp/StmtInsertExample.cs b/docs-examples/csharp/StmtInsertExample.cs new file mode 100644 index 0000000000000000000000000000000000000000..d6e00dd4ac54ab8dbfc33b93896d19fc585e7642 --- /dev/null +++ b/docs-examples/csharp/StmtInsertExample.cs @@ -0,0 +1,115 @@ +using TDengineDriver; + +namespace TDengineExample +{ + internal class StmtInsertExample + { + private static IntPtr conn; + private static IntPtr stmt; + static void Main() + { + conn = GetConnection(); + PrepareSTable(); + // 1. init and prepare + stmt = TDengine.StmtInit(conn); + if (stmt == IntPtr.Zero) + { + Console.WriteLine("failed to init stmt, " + TDengine.Error(stmt)); + ExitProgram(); + } + int res = TDengine.StmtPrepare(stmt, "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)"); + CheckStmtRes(res, "failed to prepare stmt"); + + // 2. bind table name and tags + TAOS_BIND[] tags = new TAOS_BIND[2] { TaosBind.BindBinary("Beijing.Chaoyang"), TaosBind.BindInt(2) }; + res = TDengine.StmtSetTbnameTags(stmt, "d1001", tags); + CheckStmtRes(res, "failed to bind table name and tags"); + + // 3. bind values + TAOS_MULTI_BIND[] values = new TAOS_MULTI_BIND[4] { + TaosMultiBind.MultiBindTimestamp(new long[2] { 1648432611249, 1648432611749}), + TaosMultiBind.MultiBindFloat(new float?[2] { 10.3f, 12.6f}), + TaosMultiBind.MultiBindInt(new int?[2] { 219, 218}), + TaosMultiBind.MultiBindFloat(new float?[2]{ 0.31f, 0.33f}) + }; + res = TDengine.StmtBindParamBatch(stmt, values); + CheckStmtRes(res, "failed to bind params"); + + // 4. add batch + res = TDengine.StmtAddBatch(stmt); + CheckStmtRes(res, "failed to add batch"); + + // 5. execute + res = TDengine.StmtExecute(stmt); + CheckStmtRes(res, "faild to execute"); + + // 6. free + TaosBind.FreeTaosBind(tags); + TaosMultiBind.FreeTaosBind(values); + TDengine.Close(conn); + TDengine.Cleanup(); + } + + static IntPtr GetConnection() + { + string host = "localhost"; + short port = 6030; + string username = "root"; + string password = "taosdata"; + string dbname = ""; + var conn = TDengine.Connect(host, username, password, dbname, port); + if (conn == IntPtr.Zero) + { + Console.WriteLine("Connect to TDengine failed"); + Environment.Exit(0); + } + else + { + Console.WriteLine("Connect to TDengine success"); + } + return conn; + } + + + + static void PrepareSTable() + { + IntPtr res = TDengine.Query(conn, "CREATE DATABASE power"); + CheckResPtr(res, "failed to create database"); + res = TDengine.Query(conn, "USE power"); + CheckResPtr(res, "failed to change database"); + res = TDengine.Query(conn, "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)"); + CheckResPtr(res, "failed to create stable"); + } + + static void CheckStmtRes(int res, string errorMsg) + { + if (res != 0) + { + Console.WriteLine(errorMsg + ", " + TDengine.StmtErrorStr(stmt)); + int code = TDengine.StmtClose(stmt); + if (code != 0) + { + Console.WriteLine($"falied to close stmt, {code} reason: {TDengine.StmtErrorStr(stmt)} "); + } + ExitProgram(); + } + } + + static void CheckResPtr(IntPtr res, string errorMsg) + { + if (TDengine.ErrorNo(res) != 0) + { + Console.WriteLine(errorMsg + " since:" + TDengine.Error(res)); + ExitProgram(); + } + } + + static void ExitProgram() + { + TDengine.Close(conn); + TDengine.Cleanup(); + Environment.Exit(1); + } + } +} diff --git a/docs-examples/csharp/SubscribeDemo.cs b/docs-examples/csharp/SubscribeDemo.cs new file mode 100644 index 0000000000000000000000000000000000000000..34509215da73ea6369eb95f458d622cd95a97932 --- /dev/null +++ b/docs-examples/csharp/SubscribeDemo.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace csharp +{ + internal class SubscribeDemo + { + } +} diff --git a/docs-examples/csharp/asyncquery.csproj b/docs-examples/csharp/asyncquery.csproj new file mode 100644 index 0000000000000000000000000000000000000000..7a952fe7abd15798bc704de52aa72624e59061eb --- /dev/null +++ b/docs-examples/csharp/asyncquery.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + TDengineExample.AsyncQueryExample + + + + + + + diff --git a/tests/examples/C#/jsonTag/jsonTag.csproj b/docs-examples/csharp/connect.csproj similarity index 52% rename from tests/examples/C#/jsonTag/jsonTag.csproj rename to docs-examples/csharp/connect.csproj index ed3af6e806f0321828742597d226011bfb4d5185..27cffa30ae5a98277b74c63cf3d2c749ec67ce8d 100644 --- a/tests/examples/C#/jsonTag/jsonTag.csproj +++ b/docs-examples/csharp/connect.csproj @@ -1,12 +1,15 @@ - - - - Exe - net5.0 - - + + + + Exe + net6.0 + enable + enable + TDengineExample.ConnectExample + + - - - - + + + + diff --git a/docs-examples/csharp/influxdbline.csproj b/docs-examples/csharp/influxdbline.csproj new file mode 100644 index 0000000000000000000000000000000000000000..a8b197dc7167f229b903bfd010a9ff7282c9173b --- /dev/null +++ b/docs-examples/csharp/influxdbline.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + TDengineExample.InfluxDBLineExample + + + + + + + diff --git a/tests/examples/C#/TDengineTest/TDengineTest.csproj b/docs-examples/csharp/optsjson.csproj similarity index 51% rename from tests/examples/C#/TDengineTest/TDengineTest.csproj rename to docs-examples/csharp/optsjson.csproj index 211c927d3d36df5941291319e3c85707610c6a8f..b1bd83405efb1086b23134a9c875912a9c09e3f8 100644 --- a/tests/examples/C#/TDengineTest/TDengineTest.csproj +++ b/docs-examples/csharp/optsjson.csproj @@ -2,11 +2,14 @@ Exe - net5.0 + net6.0 + enable + enable + TDengineExample.OptsJsonExample - + diff --git a/docs-examples/csharp/optstelnet.csproj b/docs-examples/csharp/optstelnet.csproj new file mode 100644 index 0000000000000000000000000000000000000000..1ab41067715f8cb070e78aec2be59d686bac0e86 --- /dev/null +++ b/docs-examples/csharp/optstelnet.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + TDengineExample.OptsTelnetExample + + + + + + + diff --git a/docs-examples/csharp/csharp.csproj b/docs-examples/csharp/query.csproj similarity index 82% rename from docs-examples/csharp/csharp.csproj rename to docs-examples/csharp/query.csproj index 529b75ab3f477858ff6c2f4f52f1caa20e0999f9..63f13c3ddbf13be9ffe5c39054cc6e4cae6001e7 100644 --- a/docs-examples/csharp/csharp.csproj +++ b/docs-examples/csharp/query.csproj @@ -5,10 +5,11 @@ net6.0 enable enable + TDengineExample.QueryExample - + diff --git a/docs-examples/csharp/sqlinsert.csproj b/docs-examples/csharp/sqlinsert.csproj new file mode 100644 index 0000000000000000000000000000000000000000..0380395a5ad00d96418410b2f7974b294bf2bb07 --- /dev/null +++ b/docs-examples/csharp/sqlinsert.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + TDengineExample.SQLInsertExample + + + + + + + diff --git a/docs-examples/csharp/stmtinsert.csproj b/docs-examples/csharp/stmtinsert.csproj new file mode 100644 index 0000000000000000000000000000000000000000..8defb895eb2894c680fe1b9dd7346223f0f92df1 --- /dev/null +++ b/docs-examples/csharp/stmtinsert.csproj @@ -0,0 +1,15 @@ + + + + Exe + net6.0 + enable + enable + TDengineExample.StmtInsertExample + + + + + + + diff --git a/tests/examples/C#/C#checker/C#checker.csproj b/docs-examples/csharp/subscribe.csproj similarity index 52% rename from tests/examples/C#/C#checker/C#checker.csproj rename to docs-examples/csharp/subscribe.csproj index afeeaf3f01301210c0e945c8e02b40790ebec743..8286922c6f926b166f14983525e604ce9e13d74a 100644 --- a/tests/examples/C#/C#checker/C#checker.csproj +++ b/docs-examples/csharp/subscribe.csproj @@ -2,12 +2,14 @@ Exe - net5.0 - C_checker + net6.0 + enable + enable + TDengineExample.SubscribeDemo - + diff --git a/docs-examples/go/.gitignore b/docs-examples/go/.gitignore index d48c759d6c990444f193c0043ec9b316029d31bc..b6128386c306834cddeb425f365720bb9c9ce790 100644 --- a/docs-examples/go/.gitignore +++ b/docs-examples/go/.gitignore @@ -1,2 +1,3 @@ .idea -.vscode \ No newline at end of file +.vscode +tmp/ \ No newline at end of file diff --git a/docs-examples/go/connect/afconn/main.go b/docs-examples/go/connect/afconn/main.go new file mode 100644 index 0000000000000000000000000000000000000000..2d36ef03ab049a313ed0416f552397ff252e022e --- /dev/null +++ b/docs-examples/go/connect/afconn/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + + "github.com/taosdata/driver-go/v2/af" +) + +func main() { + conn, err := af.Open("localhost", "root", "taosdata", "", 6030) + defer conn.Close() + if err != nil { + fmt.Println("failed to connect, err:", err) + } else { + fmt.Println("connected") + } +} diff --git a/docs-examples/go/connect/restexample/main.go b/docs-examples/go/connect/restexample/main.go index 5b243fd0e9c3566fe27350d04f209e43bfa56cc1..9c05e7eed80dee4ae7e6b20637d265f388d7438d 100644 --- a/docs-examples/go/connect/restexample/main.go +++ b/docs-examples/go/connect/restexample/main.go @@ -8,7 +8,7 @@ import ( ) func main() { - var taosDSN = "root:taosdata@http(localhost:6041)" + var taosDSN = "root:taosdata@http(localhost:6041)/" taos, err := sql.Open("taosRestful", taosDSN) if err != nil { fmt.Println("failed to connect TDengine, err:", err) diff --git a/docs-examples/go/connect/wrapper/main.go b/docs-examples/go/connect/wrapper/main.go new file mode 100644 index 0000000000000000000000000000000000000000..d7e71a8baf229012b6944aad0eaac232924dd667 --- /dev/null +++ b/docs-examples/go/connect/wrapper/main.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + + "github.com/taosdata/driver-go/v2/wrapper" +) + +func main() { + conn, err := wrapper.TaosConnect("localhost", "root", "taosdata", "", 6030) + defer wrapper.TaosClose(conn) + if err != nil { + fmt.Println("fail to connect, err:", err) + } else { + fmt.Println("connected") + } +} diff --git a/docs-examples/go/go.mod b/docs-examples/go/go.mod index d543c0c7a65de69defc646c55c194922694c7dd2..5945e395e93b373d47fe71f3584c37fed9526638 100644 --- a/docs-examples/go/go.mod +++ b/docs-examples/go/go.mod @@ -2,10 +2,5 @@ module goexample go 1.17 -require github.com/taosdata/driver-go/v2 v2.0.1-0.20220222122038-174cb6c68124 +require github.com/taosdata/driver-go/v2 develop -require ( - github.com/json-iterator/go v1.1.12 // indirect - github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect -) diff --git a/docs-examples/go/go.sum b/docs-examples/go/go.sum deleted file mode 100644 index 22e91ce03352936a9a3b2d02392b0c076b68ed67..0000000000000000000000000000000000000000 --- a/docs-examples/go/go.sum +++ /dev/null @@ -1,21 +0,0 @@ -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/taosdata/driver-go/v2 v2.0.1-0.20220222122038-174cb6c68124 h1:xDsYj1FnTBhhjMovgg67YtvTcRwICOTtUFkTxTS1LBM= -github.com/taosdata/driver-go/v2 v2.0.1-0.20220222122038-174cb6c68124/go.mod h1:ZAb4yDucTytX1Gy69F3nTRV+lEXmjkyF4J6OiYCR9NI= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/docs-examples/go/insert/json/main.go b/docs-examples/go/insert/json/main.go new file mode 100644 index 0000000000000000000000000000000000000000..47d9e9984adc05896fb9954ad3deffde3764b836 --- /dev/null +++ b/docs-examples/go/insert/json/main.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + + "github.com/taosdata/driver-go/v2/af" +) + +func prepareDatabase(conn *af.Connector) { + _, err := conn.Exec("CREATE DATABASE test") + if err != nil { + panic(err) + } + _, err = conn.Exec("USE test") + if err != nil { + panic(err) + } +} + +func main() { + conn, err := af.Open("localhost", "root", "taosdata", "", 6030) + if err != nil { + fmt.Println("fail to connect, err:", err) + } + defer conn.Close() + prepareDatabase(conn) + + payload := `[{"metric": "meters.current", "timestamp": 1648432611249, "value": 10.3, "tags": {"location": "Beijing.Chaoyang", "groupid": 2}}, + {"metric": "meters.voltage", "timestamp": 1648432611249, "value": 219, "tags": {"location": "Beijing.Haidian", "groupid": 1}}, + {"metric": "meters.current", "timestamp": 1648432611250, "value": 12.6, "tags": {"location": "Beijing.Chaoyang", "groupid": 2}}, + {"metric": "meters.voltage", "timestamp": 1648432611250, "value": 221, "tags": {"location": "Beijing.Haidian", "groupid": 1}}]` + + err = conn.OpenTSDBInsertJsonPayload(payload) + if err != nil { + fmt.Println("insert error:", err) + } +} diff --git a/docs-examples/go/insert/line/main.go b/docs-examples/go/insert/line/main.go new file mode 100644 index 0000000000000000000000000000000000000000..bbc41468fe5f13d3e6f896445bb88f3eba584d0f --- /dev/null +++ b/docs-examples/go/insert/line/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "fmt" + + "github.com/taosdata/driver-go/v2/af" +) + +func prepareDatabase(conn *af.Connector) { + _, err := conn.Exec("CREATE DATABASE test") + if err != nil { + panic(err) + } + _, err = conn.Exec("USE test") + if err != nil { + panic(err) + } +} + +func main() { + conn, err := af.Open("localhost", "root", "taosdata", "", 6030) + if err != nil { + fmt.Println("fail to connect, err:", err) + } + defer conn.Close() + prepareDatabase(conn) + var lines = []string{ + "meters,location=Beijing.Haidian,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249", + "meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250", + "meters,location=Beijing.Haidian,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249", + "meters,location=Beijing.Haidian,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250", + } + + err = conn.InfluxDBInsertLines(lines, "ms") + if err != nil { + fmt.Println("insert error:", err) + } +} diff --git a/docs-examples/go/insert/sql/main.go b/docs-examples/go/insert/sql/main.go new file mode 100644 index 0000000000000000000000000000000000000000..91386855334c1930af721e0b4f43395c6a6d8e82 --- /dev/null +++ b/docs-examples/go/insert/sql/main.go @@ -0,0 +1,49 @@ +package main + +import ( + "database/sql" + "fmt" + + _ "github.com/taosdata/driver-go/v2/taosRestful" +) + +func createStable(taos *sql.DB) { + _, err := taos.Exec("CREATE DATABASE power") + if err != nil { + fmt.Println("failed to create database, err:", err) + } + _, err = taos.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") + if err != nil { + fmt.Println("failed to create stable, err:", err) + } +} + +func insertData(taos *sql.DB) { + sql := `INSERT INTO power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) + power.d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) + power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) + power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)` + result, err := taos.Exec(sql) + if err != nil { + fmt.Println("failed to insert, err:", err) + return + } + rowsAffected, err := result.RowsAffected() + if err != nil { + fmt.Println("failed to get affected rows, err:", err) + return + } + fmt.Println("RowsAffected", rowsAffected) +} + +func main() { + var taosDSN = "root:taosdata@http(localhost:6041)/" + taos, err := sql.Open("taosRestful", taosDSN) + if err != nil { + fmt.Println("failed to connect TDengine, err:", err) + return + } + defer taos.Close() + createStable(taos) + insertData(taos) +} diff --git a/docs-examples/go/insert/stmt/main.go b/docs-examples/go/insert/stmt/main.go new file mode 100644 index 0000000000000000000000000000000000000000..c50200ebb427c4c64c2737cb8fe4c3d287551a34 --- /dev/null +++ b/docs-examples/go/insert/stmt/main.go @@ -0,0 +1,73 @@ +package main + +import ( + "fmt" + "time" + + "github.com/taosdata/driver-go/v2/af" + "github.com/taosdata/driver-go/v2/af/param" + "github.com/taosdata/driver-go/v2/common" +) + +func checkErr(err error, prompt string) { + if err != nil { + fmt.Printf("%s\n", prompt) + panic(err) + } +} + +func prepareStable(conn *af.Connector) { + _, err := conn.Exec("CREATE DATABASE power") + checkErr(err, "failed to create database") + _, err = conn.Exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") + checkErr(err, "failed to create stable") + _, err = conn.Exec("USE power") + checkErr(err, "failed to change database") +} + +func main() { + conn, err := af.Open("localhost", "root", "taosdata", "", 6030) + checkErr(err, "fail to connect") + defer conn.Close() + prepareStable(conn) + // create stmt + stmt := conn.InsertStmt() + defer stmt.Close() + err = stmt.Prepare("INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)") + checkErr(err, "failed to create prepare statement") + + // bind table name and tags + tagParams := param.NewParam(2).AddBinary([]byte("Beijing.Chaoyang")).AddInt(2) + err = stmt.SetTableNameWithTags("d1001", tagParams) + checkErr(err, "failed to execute SetTableNameWithTags") + + // specify ColumnType + var bindType *param.ColumnType = param.NewColumnType(4).AddTimestamp().AddFloat().AddInt().AddFloat() + + // bind values. note: can only bind one row each time. + valueParams := []*param.Param{ + param.NewParam(1).AddTimestamp(time.Unix(1648432611, 249300000), common.PrecisionMilliSecond), + param.NewParam(1).AddFloat(10.3), + param.NewParam(1).AddInt(219), + param.NewParam(1).AddFloat(0.31), + } + err = stmt.BindParam(valueParams, bindType) + checkErr(err, "BindParam error") + err = stmt.AddBatch() + checkErr(err, "AddBatch error") + + // bind one more row + valueParams = []*param.Param{ + param.NewParam(1).AddTimestamp(time.Unix(1648432611, 749300000), common.PrecisionMilliSecond), + param.NewParam(1).AddFloat(12.6), + param.NewParam(1).AddInt(218), + param.NewParam(1).AddFloat(0.33), + } + err = stmt.BindParam(valueParams, bindType) + checkErr(err, "BindParam error") + err = stmt.AddBatch() + checkErr(err, "AddBatch error") + // execute + err = stmt.Execute() + checkErr(err, "Execute batch error") +} diff --git a/docs-examples/go/insert/telnet/main.go b/docs-examples/go/insert/telnet/main.go new file mode 100644 index 0000000000000000000000000000000000000000..879e6d5cece74fd0b7c815dd34614dca3c9d4544 --- /dev/null +++ b/docs-examples/go/insert/telnet/main.go @@ -0,0 +1,42 @@ +package main + +import ( + "fmt" + + "github.com/taosdata/driver-go/v2/af" +) + +func prepareDatabase(conn *af.Connector) { + _, err := conn.Exec("CREATE DATABASE test") + if err != nil { + panic(err) + } + _, err = conn.Exec("USE test") + if err != nil { + panic(err) + } +} + +func main() { + conn, err := af.Open("localhost", "root", "taosdata", "", 6030) + if err != nil { + fmt.Println("fail to connect, err:", err) + } + defer conn.Close() + prepareDatabase(conn) + var lines = []string{ + "meters.current 1648432611249 10.3 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611250 12.6 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611249 10.8 location=Beijing.Haidian groupid=3", + "meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611249 219 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611250 218 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611249 221 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611250 217 location=Beijing.Haidian groupid=3", + } + + err = conn.OpenTSDBInsertTelnetLines(lines) + if err != nil { + fmt.Println("insert error:", err) + } +} diff --git a/docs-examples/go/query/async/main.go b/docs-examples/go/query/async/main.go new file mode 100644 index 0000000000000000000000000000000000000000..7776ec8d3f268a3ef393d2097b71dc5681cf48d9 --- /dev/null +++ b/docs-examples/go/query/async/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("hello world!") +} diff --git a/docs-examples/go/query/sync/main.go b/docs-examples/go/query/sync/main.go new file mode 100644 index 0000000000000000000000000000000000000000..0326c7a7da5da212f66b1421bb46e5972bef9609 --- /dev/null +++ b/docs-examples/go/query/sync/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "database/sql" + "fmt" + "time" + + _ "github.com/taosdata/driver-go/v2/taosRestful" +) + +func main() { + var taosDSN = "root:taosdata@http(localhost:6041)/power" + taos, err := sql.Open("taosRestful", taosDSN) + if err != nil { + fmt.Println("failed to connect TDengine, err:", err) + return + } + defer taos.Close() + rows, err := taos.Query("SELECT ts, current FROM meters LIMIT 2") + if err != nil { + fmt.Println("failed to select from table, err:", err) + return + } + + defer rows.Close() + for rows.Next() { + var r struct { + ts time.Time + current float32 + } + err := rows.Scan(&r.ts, &r.current) + if err != nil { + fmt.Println("scan error:\n", err) + return + } + fmt.Println(r.ts, r.current) + } +} diff --git a/docs-examples/go/sub/main.go b/docs-examples/go/sub/main.go index d41736bddc6c4fbf1dea8dcd14f691e0c6a5cd68..c44521b34026ebf6f84f70022a7c2d1f83e9b781 100644 --- a/docs-examples/go/sub/main.go +++ b/docs-examples/go/sub/main.go @@ -48,4 +48,6 @@ func main() { } }() } -} \ No newline at end of file +} + +// 未完成 diff --git a/docs-examples/java/pom.xml b/docs-examples/java/pom.xml index 45edee9b6628611aa7517429bfe0cc4a88d5fd2a..a48ba398da92f401235819d067aa2ba6f8b173ea 100644 --- a/docs-examples/java/pom.xml +++ b/docs-examples/java/pom.xml @@ -17,15 +17,17 @@ + com.taosdata.jdbc taos-jdbcdriver - 2.0.37 + 2.0.38 + junit junit - 4.11 + 4.13.1 test diff --git a/docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java b/docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java new file mode 100644 index 0000000000000000000000000000000000000000..cb83424576a4fd7dfa09ea297294ed77b66bd12d --- /dev/null +++ b/docs-examples/java/src/main/java/com/taos/example/JSONProtocolExample.java @@ -0,0 +1,40 @@ +package com.taos.example; + +import com.taosdata.jdbc.SchemalessWriter; +import com.taosdata.jdbc.enums.SchemalessProtocolType; +import com.taosdata.jdbc.enums.SchemalessTimestampType; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; + +public class JSONProtocolExample { + private static Connection getConnection() throws SQLException { + String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata"; + return DriverManager.getConnection(jdbcUrl); + } + + private static void createDatabase(Connection conn) throws SQLException { + try (Statement stmt = conn.createStatement()) { + stmt.execute("CREATE DATABASE IF NOT EXISTS test"); + stmt.execute("USE test"); + } + } + + private static String getJSONData() { + return "[{\"metric\": \"meters.current\", \"timestamp\": 1648432611249, \"value\": 10.3, \"tags\": {\"location\": \"Beijing.Chaoyang\", \"groupid\": 2}}," + + " {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611249, \"value\": 219, \"tags\": {\"location\": \"Beijing.Haidian\", \"groupid\": 1}}, " + + "{\"metric\": \"meters.current\", \"timestamp\": 1648432611250, \"value\": 12.6, \"tags\": {\"location\": \"Beijing.Chaoyang\", \"groupid\": 2}}," + + " {\"metric\": \"meters.voltage\", \"timestamp\": 1648432611250, \"value\": 221, \"tags\": {\"location\": \"Beijing.Haidian\", \"groupid\": 1}}]"; + } + + public static void main(String[] args) throws SQLException { + try (Connection conn = getConnection()) { + createDatabase(conn); + SchemalessWriter writer = new SchemalessWriter(conn); + String jsonData = getJSONData(); + writer.write(jsonData, SchemalessProtocolType.JSON, SchemalessTimestampType.NOT_CONFIGURED); + } + } +} diff --git a/docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java b/docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java new file mode 100644 index 0000000000000000000000000000000000000000..8a2eabe0a91f7966cc3cc6b7dfeeb71b71b88d92 --- /dev/null +++ b/docs-examples/java/src/main/java/com/taos/example/LineProtocolExample.java @@ -0,0 +1,42 @@ +package com.taos.example; + +import com.taosdata.jdbc.SchemalessWriter; +import com.taosdata.jdbc.enums.SchemalessProtocolType; +import com.taosdata.jdbc.enums.SchemalessTimestampType; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; + +public class LineProtocolExample { + // format: measurement,tag_set field_set timestamp + private static String[] lines = { + "meters,location=Beijing.Haidian,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249000", // micro + // seconds + "meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611249500", + "meters,location=Beijing.Haidian,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249300", + "meters,location=Beijing.Haidian,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611249800", + }; + + private static Connection getConnection() throws SQLException { + String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata"; + return DriverManager.getConnection(jdbcUrl); + } + + private static void createDatabase(Connection conn) throws SQLException { + try (Statement stmt = conn.createStatement()) { + // the default precision is ms (microsecond), but we use us(microsecond) here. + stmt.execute("CREATE DATABASE IF NOT EXISTS test PRECISION 'us'"); + stmt.execute("USE test"); + } + } + + public static void main(String[] args) throws SQLException { + try (Connection conn = getConnection()) { + createDatabase(conn); + SchemalessWriter writer = new SchemalessWriter(conn); + writer.write(lines, SchemalessProtocolType.LINE, SchemalessTimestampType.MICRO_SECONDS); + } + } +} diff --git a/docs-examples/java/src/main/java/com/taos/example/QueryExample.java b/docs-examples/java/src/main/java/com/taos/example/QueryExample.java deleted file mode 100644 index 21e00336e898e933e2504bed7c8eed3f8fadc2ef..0000000000000000000000000000000000000000 --- a/docs-examples/java/src/main/java/com/taos/example/QueryExample.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.taos.example; - -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; - -public class QueryExample { - static void printResult(ResultSet resultSet) throws SQLException { - ResultSetMetaData metaData = resultSet.getMetaData(); - while (resultSet.next()) { - for (int i = 1; i <= metaData.getColumnCount(); i++) { - String columnLabel = metaData.getColumnLabel(i); - String value = resultSet.getString(i); - System.out.printf("%s: %s\t", columnLabel, value); - } - System.out.println(); - } - } -} diff --git a/docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java b/docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java index 68d81dbbcc00d42fc38e0ba903854b3c03259490..9d077812e0ff9d0de2952d97aa12f870e6412885 100644 --- a/docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java +++ b/docs-examples/java/src/main/java/com/taos/example/RESTConnectExample.java @@ -1,25 +1,16 @@ package com.taos.example; -import com.taosdata.jdbc.TSDBDriver; - import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; -import java.util.Properties; public class RESTConnectExample { + // ANCHOR: main public static void main(String[] args) throws SQLException { String jdbcUrl = "jdbc:TAOS-RS://localhost:6041?user=root&password=taosdata"; - Properties connProps = new Properties(); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - Connection conn = DriverManager.getConnection(jdbcUrl, connProps); + Connection conn = DriverManager.getConnection(jdbcUrl); System.out.println("Connected"); conn.close(); } -} - -// use -// String jdbcUrl = "jdbc:TAOS-RS://localhost:6041/dbName?user=root&password=taosdata"; -// if you want to connect to a default database. \ No newline at end of file + // ANCHOR_END: main +} \ No newline at end of file diff --git a/docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java b/docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java new file mode 100644 index 0000000000000000000000000000000000000000..de89f26cbe38f9343d60aeb8d3e9ce7f67c2e764 --- /dev/null +++ b/docs-examples/java/src/main/java/com/taos/example/RestInsertExample.java @@ -0,0 +1,74 @@ +package com.taos.example; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Arrays; +import java.util.List; + + +public class RestInsertExample { + private static Connection getConnection() throws SQLException { + String jdbcUrl = "jdbc:TAOS-RS://localhost:6041?user=root&password=taosdata"; + return DriverManager.getConnection(jdbcUrl); + } + + private static List getRawData() { + return Arrays.asList( + "d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,Beijing.Chaoyang,2", + "d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,Beijing.Chaoyang,2", + "d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,Beijing.Chaoyang,2", + "d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,Beijing.Chaoyang,3", + "d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,Beijing.Haidian,2", + "d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,Beijing.Haidian,2", + "d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,Beijing.Haidian,3", + "d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,Beijing.Haidian,3" + ); + } + + + /** + * The generated SQL is: + * INSERT INTO power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES('2018-10-03 14:38:05.000',10.30000,219,0.31000) + * power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES('2018-10-03 14:38:15.000',12.60000,218,0.33000) + * power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES('2018-10-03 14:38:16.800',12.30000,221,0.31000) + * power.d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES('2018-10-03 14:38:16.650',10.30000,218,0.25000) + * power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES('2018-10-03 14:38:05.500',11.80000,221,0.28000) + * power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES('2018-10-03 14:38:16.600',13.40000,223,0.29000) + * power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES('2018-10-03 14:38:05.000',10.80000,223,0.29000) + * power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES('2018-10-03 14:38:06.500',11.50000,221,0.35000) + */ + private static String getSQL() { + StringBuilder sb = new StringBuilder("INSERT INTO "); + for (String line : getRawData()) { + String[] ps = line.split(","); + sb.append("power." + ps[0]).append(" USING power.meters TAGS(") + .append(ps[5]).append(", ") // tag: location + .append(ps[6]) // tag: groupId + .append(") VALUES(") + .append('\'').append(ps[1]).append('\'').append(",") // ts + .append(ps[2]).append(",") // current + .append(ps[3]).append(",") // voltage + .append(ps[4]).append(") "); // phase + } + return sb.toString(); + } + + public static void insertData() throws SQLException { + try (Connection conn = getConnection()) { + try (Statement stmt = conn.createStatement()) { + stmt.execute("CREATE DATABASE power KEEP 3650"); + stmt.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " + + "TAGS (location BINARY(64), groupId INT)"); + String sql = getSQL(); + int rowCount = stmt.executeUpdate(sql); + System.out.println("rowCount=" + rowCount); // rowCount=8 + } + } + } + + public static void main(String[] args) throws SQLException { + insertData(); + } +} diff --git a/docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java b/docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java new file mode 100644 index 0000000000000000000000000000000000000000..b1a1d224c6d9af2b83ac039726dcdb49a33ec2b0 --- /dev/null +++ b/docs-examples/java/src/main/java/com/taos/example/RestQueryExample.java @@ -0,0 +1,55 @@ +package com.taos.example; + +import java.sql.*; + +public class RestQueryExample { + private static Connection getConnection() throws SQLException { + String jdbcUrl = "jdbc:TAOS-RS://localhost:6041/power?user=root&password=taosdata"; + return DriverManager.getConnection(jdbcUrl); + } + + private static void printRow(ResultSet rs) throws SQLException { + ResultSetMetaData meta = rs.getMetaData(); + for (int i = 1; i <= meta.getColumnCount(); i++) { + String value = rs.getString(i); + System.out.print(value); + System.out.print("\t"); + } + System.out.println(); + } + + private static void printColName(ResultSet rs) throws SQLException { + ResultSetMetaData meta = rs.getMetaData(); + for (int i = 1; i <= meta.getColumnCount(); i++) { + String colLabel = meta.getColumnLabel(i); + System.out.print(colLabel); + System.out.print("\t"); + } + System.out.println(); + } + + private static void processResult(ResultSet rs) throws SQLException { + printColName(rs); + while (rs.next()) { + printRow(rs); + } + } + + private static void queryData() throws SQLException { + try (Connection conn = getConnection()) { + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("SELECT AVG(voltage) FROM meters GROUP BY location"); + processResult(rs); + } + } + } + + public static void main(String[] args) throws SQLException { + queryData(); + } +} + +// possible output: +// avg(voltage) location +// 222.0 Beijing.Haidian +// 219.0 Beijing.Chaoyang diff --git a/docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java b/docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java new file mode 100644 index 0000000000000000000000000000000000000000..2a7ccebf41cae1a22d7516966e2c6ffb10011b64 --- /dev/null +++ b/docs-examples/java/src/main/java/com/taos/example/StmtInsertExample.java @@ -0,0 +1,84 @@ +package com.taos.example; + +import com.taosdata.jdbc.TSDBPreparedStatement; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class StmtInsertExample { + private static ArrayList tsToLongArray(String ts) { + ArrayList result = new ArrayList<>(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); + LocalDateTime localDateTime = LocalDateTime.parse(ts, formatter); + result.add(localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli()); + return result; + } + + private static ArrayList toArray(T v) { + ArrayList result = new ArrayList<>(); + result.add(v); + return result; + } + + private static List getRawData() { + return Arrays.asList( + "d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,Beijing.Chaoyang,2", + "d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,Beijing.Chaoyang,2", + "d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,Beijing.Chaoyang,2", + "d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,Beijing.Chaoyang,3", + "d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,Beijing.Haidian,2", + "d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,Beijing.Haidian,2", + "d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,Beijing.Haidian,3", + "d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,Beijing.Haidian,3" + ); + } + + private static Connection getConnection() throws SQLException { + String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata"; + return DriverManager.getConnection(jdbcUrl); + } + + private static void createTable(Connection conn) throws SQLException { + try (Statement stmt = conn.createStatement()) { + stmt.execute("CREATE DATABASE power KEEP 3650"); + stmt.executeUpdate("USE power"); + stmt.execute("CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " + + "TAGS (location BINARY(64), groupId INT)"); + } + } + + private static void insertData() throws SQLException { + try (Connection conn = getConnection()) { + createTable(conn); + String psql = "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)"; + try (TSDBPreparedStatement pst = (TSDBPreparedStatement) conn.prepareStatement(psql)) { + for (String line : getRawData()) { + String[] ps = line.split(","); + // bind table name and tags + pst.setTableName(ps[0]); + pst.setTagString(0, ps[5]); + pst.setTagInt(1, Integer.valueOf(ps[6])); + // bind values + pst.setTimestamp(0, tsToLongArray(ps[1])); //ps[1] looks like: 2018-10-03 14:38:05.000 + pst.setFloat(1, toArray(Float.valueOf(ps[2]))); + pst.setInt(2, toArray(Integer.valueOf(ps[3]))); + pst.setFloat(3, toArray(Float.valueOf(ps[4]))); + pst.columnDataAddBatch(); + } + pst.columnDataExecuteBatch(); + } + } + } + + public static void main(String[] args) throws SQLException { + insertData(); + } +} diff --git a/docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java b/docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java new file mode 100644 index 0000000000000000000000000000000000000000..d82d03b9de561e3ea6a8e7d40a48ce9dd3f2a20d --- /dev/null +++ b/docs-examples/java/src/main/java/com/taos/example/SubscribeDemo.java @@ -0,0 +1,65 @@ +package com.taos.example; + +import com.taosdata.jdbc.TSDBConnection; +import com.taosdata.jdbc.TSDBDriver; +import com.taosdata.jdbc.TSDBResultSet; +import com.taosdata.jdbc.TSDBSubscribe; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +public class SubscribeDemo { + private static final String topic = "topic-meter-current-bg-10"; + private static final String sql = "select * from meters where current > 10"; + + public static void main(String[] args) { + Connection connection = null; + TSDBSubscribe subscribe = null; + + try { + Class.forName("com.taosdata.jdbc.TSDBDriver"); + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + String jdbcUrl = "jdbc:TAOS://127.0.0.1:6030/power?user=root&password=taosdata"; + connection = DriverManager.getConnection(jdbcUrl, properties); + // create subscribe + subscribe = ((TSDBConnection) connection).subscribe(topic, sql, true); + int count = 0; + while (count < 10) { + // wait 1 second to avoid frequent calls to consume + TimeUnit.SECONDS.sleep(1); + // consume + TSDBResultSet resultSet = subscribe.consume(); + if (resultSet == null) { + continue; + } + ResultSetMetaData metaData = resultSet.getMetaData(); + while (resultSet.next()) { + int columnCount = metaData.getColumnCount(); + for (int i = 1; i <= columnCount; i++) { + System.out.print(metaData.getColumnLabel(i) + ": " + resultSet.getString(i) + "\t"); + } + System.out.println(); + count++; + } + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (null != subscribe) + // close subscribe + subscribe.close(true); + if (connection != null) + connection.close(); + } catch (SQLException throwable) { + throwable.printStackTrace(); + } + } + } +} \ No newline at end of file diff --git a/docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java b/docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java new file mode 100644 index 0000000000000000000000000000000000000000..1431eccf16dabaac20f60ae7e971ef49707ba509 --- /dev/null +++ b/docs-examples/java/src/main/java/com/taos/example/TelnetLineProtocolExample.java @@ -0,0 +1,45 @@ +package com.taos.example; + +import com.taosdata.jdbc.SchemalessWriter; +import com.taosdata.jdbc.enums.SchemalessProtocolType; +import com.taosdata.jdbc.enums.SchemalessTimestampType; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.sql.Statement; + +public class TelnetLineProtocolExample { + // format: =[ =] + private static String[] lines = { "meters.current 1648432611249 10.3 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611250 12.6 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611249 10.8 location=Beijing.Haidian groupid=3", + "meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611249 219 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611250 218 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611249 221 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611250 217 location=Beijing.Haidian groupid=3", + }; + + private static Connection getConnection() throws SQLException { + String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata"; + return DriverManager.getConnection(jdbcUrl); + } + + private static void createDatabase(Connection conn) throws SQLException { + try (Statement stmt = conn.createStatement()) { + // the default precision is ms (microsecond), but we use us(microsecond) here. + stmt.execute("CREATE DATABASE IF NOT EXISTS test precision 'us'"); + stmt.execute("USE test"); + } + } + + public static void main(String[] args) throws SQLException { + try (Connection conn = getConnection()) { + createDatabase(conn); + SchemalessWriter writer = new SchemalessWriter(conn); + writer.write(lines, SchemalessProtocolType.TELNET, SchemalessTimestampType.NOT_CONFIGURED); + } + } + +} diff --git a/docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java b/docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java new file mode 100644 index 0000000000000000000000000000000000000000..48d1dde593cc347632efb6612946aa16e82e8b94 --- /dev/null +++ b/docs-examples/java/src/main/java/com/taos/example/WSConnectExample.java @@ -0,0 +1,21 @@ +package com.taos.example; + +import com.taosdata.jdbc.TSDBDriver; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +public class WSConnectExample { + // ANCHOR: main + public static void main(String[] args) throws SQLException { + String jdbcUrl = "jdbc:TAOS-RS://localhost:6041?user=root&password=taosdata"; + Properties connProps = new Properties(); + connProps.setProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD, "true"); + Connection conn = DriverManager.getConnection(jdbcUrl, connProps); + System.out.println("Connected"); + conn.close(); + } + // ANCHOR_END: main +} diff --git a/docs-examples/java/src/test/java/com/taos/test/TestAll.java b/docs-examples/java/src/test/java/com/taos/test/TestAll.java new file mode 100644 index 0000000000000000000000000000000000000000..92fe14a49d5f5ea5d7ea5f1d809867b3de0cc9d2 --- /dev/null +++ b/docs-examples/java/src/test/java/com/taos/test/TestAll.java @@ -0,0 +1,91 @@ +package com.taos.test; + +import com.taos.example.*; +import org.junit.FixMethodOrder; +import org.junit.Test; + +import java.sql.*; + +@FixMethodOrder +public class TestAll { + private String[] args = new String[]{}; + + public void dropDB(String dbName) throws SQLException { + String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata"; + try (Connection conn = DriverManager.getConnection(jdbcUrl)) { + try (Statement stmt = conn.createStatement()) { + stmt.execute("drop database if exists " + dbName); + } + } + } + + public void insertData() throws SQLException { + String jdbcUrl = "jdbc:TAOS://localhost:6030?user=root&password=taosdata"; + try (Connection conn = DriverManager.getConnection(jdbcUrl)) { + try (Statement stmt = conn.createStatement()) { + String sql = "INSERT INTO power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES('2018-10-03 14:38:05.000',10.30000,219,0.31000)\n" + + " power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES('2018-10-03 15:38:15.000',12.60000,218,0.33000)\n" + + " power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES('2018-10-03 15:38:16.800',12.30000,221,0.31000)\n" + + " power.d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES('2018-10-03 15:38:16.650',10.30000,218,0.25000)\n" + + " power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES('2018-10-03 15:38:05.500',11.80000,221,0.28000)\n" + + " power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES('2018-10-03 15:38:16.600',13.40000,223,0.29000)\n" + + " power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES('2018-10-03 15:38:05.000',10.80000,223,0.29000)\n" + + " power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES('2018-10-03 15:38:06.000',10.80000,223,0.29000)\n" + + " power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES('2018-10-03 15:38:07.000',10.80000,223,0.29000)\n" + + " power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES('2018-10-03 15:38:08.500',11.50000,221,0.35000)"; + + stmt.execute(sql); + } + } + } + + @Test + public void testJNIConnect() throws SQLException { + JNIConnectExample.main(args); + } + + @Test + public void testRestConnect() throws SQLException { + RESTConnectExample.main(args); + } + + @Test + public void testRestInsert() throws SQLException { + dropDB("power"); + RestInsertExample.main(args); + RestQueryExample.main(args); + } + + @Test + public void testStmtInsert() throws SQLException { + dropDB("power"); + StmtInsertExample.main(args); + } + + @Test + public void testSubscribe() { + + Thread thread = new Thread(() -> { + try { + Thread.sleep(1000); + insertData(); + } catch (SQLException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + }); + thread.start(); + SubscribeDemo.main(args); + } + + @Test + public void testSchemaless() throws SQLException { + LineProtocolExample.main(args); + TelnetLineProtocolExample.main(args); + // for json protocol, tags may be double type. but for telnet protocol tag must be nchar type. + // To avoid type mismatch, we delete database test. + dropDB("test"); + JSONProtocolExample.main(args); + } +} diff --git a/docs-examples/node/nativeexample/async_query_example.js b/docs-examples/node/nativeexample/async_query_example.js new file mode 100644 index 0000000000000000000000000000000000000000..25b78bc48a82454cc0f9db69b77323a00f3852b4 --- /dev/null +++ b/docs-examples/node/nativeexample/async_query_example.js @@ -0,0 +1,21 @@ +const taos = require("td2.0-connector"); +const conn = taos.connect({ host: "localhost", database: "power" }); +const cursor = conn.cursor(); + +function queryExample() { + cursor + .query("SELECT ts, current FROM meters LIMIT 2") + .execute_a() + .then((result) => { + result.pretty(); + }); +} + +try { + queryExample(); +} finally { + setTimeout(() => { + conn.close(); + }, 2000); +} +// bug here: jira 14506 diff --git a/docs-examples/node/nativeexample/connect.js b/docs-examples/node/nativeexample/connect.js index 6949a1b70bf78e2bade37cf9221c4d089b0511b5..da791c566e3aa40315b6f35cfeca704040cd8107 100644 --- a/docs-examples/node/nativeexample/connect.js +++ b/docs-examples/node/nativeexample/connect.js @@ -7,3 +7,7 @@ var conn = taos.connect({ password: "taosdata", }); conn.close(); + +// run with: node connect.js +// output: +// Successfully connected to TDengine diff --git a/docs-examples/node/nativeexample/influxdb_line_example.js b/docs-examples/node/nativeexample/influxdb_line_example.js new file mode 100644 index 0000000000000000000000000000000000000000..a9fc6d11df0b335b92bb3292baaa017cb4bc42ea --- /dev/null +++ b/docs-examples/node/nativeexample/influxdb_line_example.js @@ -0,0 +1,34 @@ +const taos = require("td2.0-connector"); + +const conn = taos.connect({ + host: "localhost", +}); + +const cursor = conn.cursor(); + +function createDatabase() { + cursor.execute("CREATE DATABASE test"); + cursor.execute("USE test"); +} + +function insertData() { + const lines = [ + "meters,location=Beijing.Haidian,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249", + "meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250", + "meters,location=Beijing.Haidian,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249", + "meters,location=Beijing.Haidian,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250", + ]; + cursor.schemalessInsert( + lines, + taos.SCHEMALESS_PROTOCOL.TSDB_SML_LINE_PROTOCOL, + taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_MILLI_SECONDS + ); +} + +try { + createDatabase(); + insertData(); +} finally { + cursor.close(); + conn.close(); +} diff --git a/docs-examples/node/nativeexample/insert_example.js b/docs-examples/node/nativeexample/insert_example.js new file mode 100644 index 0000000000000000000000000000000000000000..85a353f889176655654d8c39c9a905054d3b6622 --- /dev/null +++ b/docs-examples/node/nativeexample/insert_example.js @@ -0,0 +1,31 @@ +const taos = require("td2.0-connector"); + +const conn = taos.connect({ + host: "localhost", +}); + +const cursor = conn.cursor(); +try { + cursor.execute("CREATE DATABASE power"); + cursor.execute("USE power"); + cursor.execute( + "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)" + ); + var sql = `INSERT INTO power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) +power.d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) +power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) +power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)`; + cursor.execute(sql); +} finally { + cursor.close(); + conn.close(); +} + +// run with: node insert_example.js +// output: +// Successfully connected to TDengine +// Query OK, 0 row(s) affected (0.00509570s) +// Query OK, 0 row(s) affected (0.00130880s) +// Query OK, 0 row(s) affected (0.00467900s) +// Query OK, 8 row(s) affected (0.04043550s) +// Connection is closed diff --git a/docs-examples/node/nativeexample/multi_bind_example.js b/docs-examples/node/nativeexample/multi_bind_example.js new file mode 100644 index 0000000000000000000000000000000000000000..d52581ec8e10c6edfbc8fc8f7ca78512b5c93d74 --- /dev/null +++ b/docs-examples/node/nativeexample/multi_bind_example.js @@ -0,0 +1,53 @@ +const taos = require("td2.0-connector"); + +const conn = taos.connect({ + host: "localhost", +}); + +const cursor = conn.cursor(); + +function prepareSTable() { + cursor.execute("CREATE DATABASE power"); + cursor.execute("USE power"); + cursor.execute( + "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)" + ); +} + +//ANCHOR: insertData +function insertData() { + // init + cursor.stmtInit(); + // prepare + cursor.stmtPrepare( + "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)" + ); + + // bind table name and tags + let tagBind = new taos.TaosBind(2); + tagBind.bindBinary("Beijing.Chaoyang"); + tagBind.bindInt(2); + cursor.stmtSetTbnameTags("d1001", tagBind.getBind()); + + // bind values + let valueBind = new taos.TaosMultiBindArr(4); + valueBind.multiBindTimestamp([1648432611249, 1648432611749]); + valueBind.multiBindFloat([10.3, 12.6]); + valueBind.multiBindInt([219, 218]); + valueBind.multiBindFloat([0.31, 0.33]); + cursor.stmtBindParamBatch(valueBind.getMultiBindArr()); + cursor.stmtAddBatch(); + + // execute + cursor.stmtExecute(); + cursor.stmtClose(); +} +//ANCHOR_END: insertData + +try { + prepareSTable(); + insertData(); +} finally { + cursor.close(); + conn.close(); +} diff --git a/docs-examples/node/nativeexample/opentsdb_json_example.js b/docs-examples/node/nativeexample/opentsdb_json_example.js new file mode 100644 index 0000000000000000000000000000000000000000..6d436a8e9ebe0230bba22064e8fb6c180c14b5d1 --- /dev/null +++ b/docs-examples/node/nativeexample/opentsdb_json_example.js @@ -0,0 +1,55 @@ +const taos = require("td2.0-connector"); + +const conn = taos.connect({ + host: "localhost", +}); + +const cursor = conn.cursor(); + +function createDatabase() { + cursor.execute("CREATE DATABASE test"); + cursor.execute("USE test"); +} + +function insertData() { + const lines = [ + { + metric: "meters.current", + timestamp: 1648432611249, + value: 10.3, + tags: { location: "Beijing.Chaoyang", groupid: 2 }, + }, + { + metric: "meters.voltage", + timestamp: 1648432611249, + value: 219, + tags: { location: "Beijing.Haidian", groupid: 1 }, + }, + { + metric: "meters.current", + timestamp: 1648432611250, + value: 12.6, + tags: { location: "Beijing.Chaoyang", groupid: 2 }, + }, + { + metric: "meters.voltage", + timestamp: 1648432611250, + value: 221, + tags: { location: "Beijing.Haidian", groupid: 1 }, + }, + ]; + + cursor.schemalessInsert( + [JSON.stringify(lines)], + taos.SCHEMALESS_PROTOCOL.TSDB_SML_JSON_PROTOCOL, + taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_NOT_CONFIGURED + ); +} + +try { + createDatabase(); + insertData(); +} finally { + cursor.close(); + conn.close(); +} diff --git a/docs-examples/node/nativeexample/opentsdb_telnet_example.js b/docs-examples/node/nativeexample/opentsdb_telnet_example.js new file mode 100644 index 0000000000000000000000000000000000000000..01e79c2dcacd923cd708d1d228959a628d0ff26a --- /dev/null +++ b/docs-examples/node/nativeexample/opentsdb_telnet_example.js @@ -0,0 +1,38 @@ +const taos = require("td2.0-connector"); + +const conn = taos.connect({ + host: "localhost", +}); + +const cursor = conn.cursor(); + +function createDatabase() { + cursor.execute("CREATE DATABASE test"); + cursor.execute("USE test"); +} + +function insertData() { + const lines = [ + "meters.current 1648432611249 10.3 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611250 12.6 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611249 10.8 location=Beijing.Haidian groupid=3", + "meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611249 219 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611250 218 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611249 221 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611250 217 location=Beijing.Haidian groupid=3", + ]; + cursor.schemalessInsert( + lines, + taos.SCHEMALESS_PROTOCOL.TSDB_SML_TELNET_PROTOCOL, + taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_NOT_CONFIGURED + ); +} + +try { + createDatabase(); + insertData(); +} finally { + cursor.close(); + conn.close(); +} diff --git a/docs-examples/node/nativeexample/param_bind_example.js b/docs-examples/node/nativeexample/param_bind_example.js new file mode 100644 index 0000000000000000000000000000000000000000..9117f46c3eeabd9009b72fa9d4a8503e65884242 --- /dev/null +++ b/docs-examples/node/nativeexample/param_bind_example.js @@ -0,0 +1,57 @@ +const taos = require("td2.0-connector"); + +const conn = taos.connect({ + host: "localhost", +}); + +const cursor = conn.cursor(); + +function prepareSTable() { + cursor.execute("CREATE DATABASE power"); + cursor.execute("USE power"); + cursor.execute( + "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)" + ); +} + +function insertData() { + // init + cursor.stmtInit(); + // prepare + cursor.stmtPrepare( + "INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)" + ); + + // bind table name and tags + let tagBind = new taos.TaosBind(2); + tagBind.bindBinary("Beijing.Chaoyang"); + tagBind.bindInt(2); + cursor.stmtSetTbnameTags("d1001", tagBind.getBind()); + + // bind values + let rows = [ + [1648432611249, 10.3, 219, 0.31], + [1648432611749, 12.6, 218, 0.33], + ]; + for (let row of rows) { + let valueBind = new taos.TaosBind(4); + valueBind.bindTimestamp(row[0]); + valueBind.bindFloat(row[1]); + valueBind.bindInt(row[2]); + valueBind.bindFloat(row[3]); + cursor.stmtBindParam(valueBind.getBind()); + cursor.stmtAddBatch(); + } + + // execute + cursor.stmtExecute(); + cursor.stmtClose(); +} + +try { + prepareSTable(); + insertData(); +} finally { + cursor.close(); + conn.close(); +} diff --git a/docs-examples/node/nativeexample/query_example.js b/docs-examples/node/nativeexample/query_example.js new file mode 100644 index 0000000000000000000000000000000000000000..a51bc939ae8dc458f019ac3bf006d9320dfdee81 --- /dev/null +++ b/docs-examples/node/nativeexample/query_example.js @@ -0,0 +1,17 @@ +const taos = require("td2.0-connector"); + +const conn = taos.connect({ host: "localhost", database: "power" }); +const cursor = conn.cursor(); +const query = cursor.query("SELECT ts, current FROM meters LIMIT 2"); +query.execute().then(function (result) { + result.pretty(); +}); + +// output: +// Successfully connected to TDengine +// Query OK, 2 row(s) in set (0.00317767s) + +// ts | current | +// ======================================================= +// 2018-10-03 14:38:05.000 | 10.3 | +// 2018-10-03 14:38:15.000 | 12.6 | diff --git a/docs-examples/node/nativeexample/subscribe_demo.js b/docs-examples/node/nativeexample/subscribe_demo.js new file mode 100644 index 0000000000000000000000000000000000000000..bdf0c98687c359ba20664e869a25690dffbabd29 --- /dev/null +++ b/docs-examples/node/nativeexample/subscribe_demo.js @@ -0,0 +1,4 @@ +const taos = require("td2.0-connector"); + +const conn = taos.connect({ host: "localhost", database: "power" }); +// 未完成 \ No newline at end of file diff --git a/docs-examples/node/package.json b/docs-examples/node/package.json index 25cb23798d36e35b59db79bc7d122daf137754e4..f56196d2e5011b1c56e59d78d2ce5fdda98205e9 100644 --- a/docs-examples/node/package.json +++ b/docs-examples/node/package.json @@ -4,6 +4,7 @@ "main": "index.js", "license": "MIT", "dependencies": { - "td2.0-connector": "^2.0.10" + "td2.0-connector": "^2.0.12", + "td2.0-rest-connector": "^1.0.0" } } diff --git a/docs-examples/node/restexample/connect.js b/docs-examples/node/restexample/connect.js new file mode 100644 index 0000000000000000000000000000000000000000..b84ce2fadf9177983701582b05200986ea9d5ba7 --- /dev/null +++ b/docs-examples/node/restexample/connect.js @@ -0,0 +1,20 @@ +const { options, connect } = require("td2.0-rest-connector"); + +async function test() { + options.path = "/rest/sqlt"; + options.host = "localhost"; + let conn = connect(options); + let cursor = conn.cursor(); + try { + let res = await cursor.query("SELECT server_version()"); + res.toString(); + } catch (err) { + console.log(err); + } +} +test(); + +// output: +// server_version() | +// =================== +// 2.4.0.12 | diff --git a/src/connector/python/examples/query-async.py b/docs-examples/python/async_query_example.py similarity index 67% rename from src/connector/python/examples/query-async.py rename to docs-examples/python/async_query_example.py index 585db2344eda4c5d38c2868c35f4d91c50926880..a78f44230a34d40a5326dea367bbad11a6e51da2 100644 --- a/src/connector/python/examples/query-async.py +++ b/docs-examples/python/async_query_example.py @@ -1,6 +1,8 @@ -from taos import * -from ctypes import * import time +from ctypes import * + +from taos import * + def fetch_callback(p_param, p_result, num_of_rows): print("fetched ", num_of_rows, "rows") @@ -10,7 +12,6 @@ def fetch_callback(p_param, p_result, num_of_rows): if num_of_rows == 0: print("fetching completed") p.contents.done = True - # should explicitly close the result in fetch completed or cause error result.close() return if num_of_rows < 0: @@ -18,25 +19,20 @@ def fetch_callback(p_param, p_result, num_of_rows): result.check_error(num_of_rows) result.close() return None - + for row in result.rows_iter(num_of_rows): - # print(row) - None + print(row) p.contents.count += result.row_count result.fetch_rows_a(fetch_callback, p_param) - def query_callback(p_param, p_result, code): - # type: (c_void_p, c_void_p, c_int) -> None if p_result is None: return result = TaosResult(p_result) if code == 0: result.fetch_rows_a(fetch_callback, p_param) result.check_error(code) - # explicitly close result while query failed - result.close() class Counter(Structure): @@ -47,16 +43,30 @@ class Counter(Structure): def test_query(conn): - # type: (TaosConnection) -> None counter = Counter(count=0) - conn.query_a("select * from log.log", query_callback, byref(counter)) + conn.query_a("select ts, current, voltage from power.meters", query_callback, byref(counter)) while not counter.done: - print("wait query callback") + print(counter) time.sleep(1) print(counter) - # conn.close() + conn.close() if __name__ == "__main__": - test_query(connect()) \ No newline at end of file + test_query(connect()) + +# possible output: +# { count: 0, done: False } +# fetched 8 rows +# 1538548685000 10.300000 219 +# 1538548695000 12.600000 218 +# 1538548696800 12.300000 221 +# 1538548696650 10.300000 218 +# 1538548685500 11.800000 221 +# 1538548696600 13.400000 223 +# 1538548685500 10.800000 223 +# 1538548686500 11.500000 221 +# fetched 0 rows +# fetching completed +# { count: 8, done: True } diff --git a/docs-examples/python/bind_param_example.py b/docs-examples/python/bind_param_example.py new file mode 100644 index 0000000000000000000000000000000000000000..503a2eb5dd91a3516f87a4d3c1c3218cb6505236 --- /dev/null +++ b/docs-examples/python/bind_param_example.py @@ -0,0 +1,60 @@ +import taos +from datetime import datetime + +# note: lines have already been sorted by table name +lines = [('d1001', '2018-10-03 14:38:05.000', 10.30000, 219, 0.31000, 'Beijing.Chaoyang', 2), + ('d1001', '2018-10-03 14:38:15.000', 12.60000, 218, 0.33000, 'Beijing.Chaoyang', 2), + ('d1001', '2018-10-03 14:38:16.800', 12.30000, 221, 0.31000, 'Beijing.Chaoyang', 2), + ('d1002', '2018-10-03 14:38:16.650', 10.30000, 218, 0.25000, 'Beijing.Chaoyang', 3), + ('d1003', '2018-10-03 14:38:05.500', 11.80000, 221, 0.28000, 'Beijing.Haidian', 2), + ('d1003', '2018-10-03 14:38:16.600', 13.40000, 223, 0.29000, 'Beijing.Haidian', 2), + ('d1004', '2018-10-03 14:38:05.000', 10.80000, 223, 0.29000, 'Beijing.Haidian', 3), + ('d1004', '2018-10-03 14:38:06.500', 11.50000, 221, 0.35000, 'Beijing.Haidian', 3)] + + +def get_ts(ts: str): + dt = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S.%f') + return int(dt.timestamp() * 1000) + + +def create_stable(): + conn = taos.connect() + try: + conn.execute("CREATE DATABASE power") + conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " + "TAGS (location BINARY(64), groupId INT)") + finally: + conn.close() + + +def bind_row_by_row(stmt: taos.TaosStmt): + tb_name = None + for row in lines: + if tb_name != row[0]: + tb_name = row[0] + tags: taos.TaosBind = taos.new_bind_params(2) # 2 is count of tags + tags[0].binary(row[5]) # location + tags[1].int(row[6]) # groupId + stmt.set_tbname_tags(tb_name, tags) + values: taos.TaosBind = taos.new_bind_params(4) # 4 is count of columns + values[0].timestamp(get_ts(row[1])) + values[1].float(row[2]) + values[2].int(row[3]) + values[3].float(row[4]) + stmt.bind_param(values) + + +def insert_data(): + conn = taos.connect(database="power") + try: + stmt = conn.statement("INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)") + bind_row_by_row(stmt) + stmt.execute() + stmt.close() + finally: + conn.close() + + +if __name__ == '__main__': + create_stable() + insert_data() diff --git a/docs-examples/python/conn_native_pandas.py b/docs-examples/python/conn_native_pandas.py new file mode 100644 index 0000000000000000000000000000000000000000..314759f7662c7bf4c9df2c8b3396ad3101c91cd4 --- /dev/null +++ b/docs-examples/python/conn_native_pandas.py @@ -0,0 +1,19 @@ +import pandas +from sqlalchemy import create_engine + +engine = create_engine("taos://root:taosdata@localhost:6030/power") +df = pandas.read_sql("SELECT * FROM meters", engine) + +# print index +print(df.index) +# print data type of element in ts column +print(type(df.ts[0])) +print(df.head(3)) + +# output: +# RangeIndex(start=0, stop=8, step=1) +# +# ts current voltage phase location groupid +# 0 2018-10-03 14:38:05.000 10.3 219 0.31 beijing.chaoyang 2 +# 1 2018-10-03 14:38:15.000 12.6 218 0.33 beijing.chaoyang 2 +# 2 2018-10-03 14:38:16.800 12.3 221 0.31 beijing.chaoyang 2 diff --git a/docs-examples/python/conn_rest_pandas.py b/docs-examples/python/conn_rest_pandas.py new file mode 100644 index 0000000000000000000000000000000000000000..143e4275fa4eda685766297e4b90cba3935a574d --- /dev/null +++ b/docs-examples/python/conn_rest_pandas.py @@ -0,0 +1,19 @@ +import pandas +from sqlalchemy import create_engine + +engine = create_engine("taosrest://root:taosdata@localhost:6041") +df: pandas.DataFrame = pandas.read_sql("SELECT * FROM power.meters", engine) + +# print index +print(df.index) +# print data type of element in ts column +print(type(df.ts[0])) +print(df.head(3)) + +# output: +# +# RangeIndex(start=0, stop=8, step=1) +# ts current ... location groupid +# 0 2018-10-03 14:38:05+08:00 10.3 ... beijing.chaoyang 2 +# 1 2018-10-03 14:38:15+08:00 12.6 ... beijing.chaoyang 2 +# 2 2018-10-03 14:38:16.800000+08:00 12.3 ... beijing.chaoyang 2 diff --git a/docs-examples/python/connect_exmaple.py b/docs-examples/python/connect_exmaple.py index 5d57ae6815ceda3c51c75d4e12d4ae9a7438469b..719af79fd12c14cc16e4e3e3c4d6362da5a7520d 100644 --- a/docs-examples/python/connect_exmaple.py +++ b/docs-examples/python/connect_exmaple.py @@ -5,7 +5,6 @@ def test_connection(): # all parameters are optional. # if database is specified, # then it must exist. - # we use database log here, because it always exists. conn = taos.connect(host="localhost", port=6030, user="root", diff --git a/docs-examples/python/connect_native_reference.py b/docs-examples/python/connect_native_reference.py new file mode 100644 index 0000000000000000000000000000000000000000..c17e9795b58724f6646b8d7c0f84047098a93d69 --- /dev/null +++ b/docs-examples/python/connect_native_reference.py @@ -0,0 +1,20 @@ +import taos + +conn: taos.TaosConnection = taos.connect(host="localhost", + user="root", + password="taosdata", + database="test", + port=6030, + config="/etc/taos", # for windows the default value is C:\TDengine\cfg + timezone="Asia/Shanghai") # default your host's timezone + +server_version = conn.server_info +print("server_version", server_version) +client_version = conn.client_info +print("client_version", client_version) # 2.4.0.16 + +conn.close() + +# possible output: +# 2.4.0.16 +# 2.4.0.16 diff --git a/docs-examples/python/connect_rest_examples.py b/docs-examples/python/connect_rest_examples.py new file mode 100644 index 0000000000000000000000000000000000000000..a043d506b965bc31179dbb6f38749d196ab338ff --- /dev/null +++ b/docs-examples/python/connect_rest_examples.py @@ -0,0 +1,45 @@ +# ANCHOR: connect +from taosrest import connect, TaosRestConnection, TaosRestCursor + +conn: TaosRestConnection = connect(host="localhost", + user="root", + password="taosdata", + port=6041, + timeout=30) + +# ANCHOR_END: connect +# ANCHOR: basic +# create STable +cursor: TaosRestCursor = conn.cursor() +cursor.execute("DROP DATABASE IF EXISTS power") +cursor.execute("CREATE DATABASE power") +cursor.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") + +# insert data +cursor.execute("""INSERT INTO power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) + power.d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) + power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) + power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)""") +print("inserted row count:", cursor.rowcount) + +# query data +cursor.execute("SELECT * FROM power.meters LIMIT 3") +# get total rows +print("queried row count:", cursor.rowcount) +# get column names from cursor +column_names = [meta[0] for meta in cursor.description] +# get rows +data: list[tuple] = cursor.fetchall() +print(column_names) +for row in data: + print(row) + +# output: +# inserted row count: 8 +# queried row count: 3 +# ['ts', 'current', 'voltage', 'phase', 'location', 'groupid'] +# [datetime.datetime(2018, 10, 3, 14, 38, 5, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 10.3, 219, 0.31, 'beijing.chaoyang', 2] +# [datetime.datetime(2018, 10, 3, 14, 38, 15, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 12.6, 218, 0.33, 'beijing.chaoyang', 2] +# [datetime.datetime(2018, 10, 3, 14, 38, 16, 800000, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 12.3, 221, 0.31, 'beijing.chaoyang', 2] + +# ANCHOR_END: basic diff --git a/docs-examples/python/connection_usage_native_reference.py b/docs-examples/python/connection_usage_native_reference.py new file mode 100644 index 0000000000000000000000000000000000000000..4803511e427bf4d906fd3a14ff6faf5a000da96c --- /dev/null +++ b/docs-examples/python/connection_usage_native_reference.py @@ -0,0 +1,45 @@ +import taos + +# ANCHOR: insert +conn = taos.connect() +# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement. +conn.execute("DROP DATABASE IF EXISTS test") +conn.execute("CREATE DATABASE test") +# change database. same as execute "USE db" +conn.select_db("test") +conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)") +affected_row: int = conn.execute("INSERT INTO t1 USING weather TAGS(1) VALUES (now, 23.5) (now+1m, 23.5) (now+2m 24.4)") +print("affected_row", affected_row) +# output: +# affected_row 3 +# ANCHOR_END: insert + +# ANCHOR: query +# Execute a sql and get its result set. It's useful for SELECT statement +result: taos.TaosResult = conn.query("SELECT * from weather") + +# Get fields from result +fields: taos.field.TaosFields = result.fields +for field in fields: + print(field) # {name: ts, type: 9, bytes: 8} + +# output: +# {name: ts, type: 9, bytes: 8} +# {name: temperature, type: 6, bytes: 4} +# {name: location, type: 4, bytes: 4} + +# Get data from result as list of tuple +data = result.fetch_all() +print(data) +# output: +# [(datetime.datetime(2022, 4, 27, 9, 4, 25, 367000), 23.5, 1), (datetime.datetime(2022, 4, 27, 9, 5, 25, 367000), 23.5, 1), (datetime.datetime(2022, 4, 27, 9, 6, 25, 367000), 24.399999618530273, 1)] + +# Or get data from result as a list of dict +# map_data = result.fetch_all_into_dict() +# print(map_data) +# output: +# [{'ts': datetime.datetime(2022, 4, 27, 9, 1, 15, 343000), 'temperature': 23.5, 'location': 1}, {'ts': datetime.datetime(2022, 4, 27, 9, 2, 15, 343000), 'temperature': 23.5, 'location': 1}, {'ts': datetime.datetime(2022, 4, 27, 9, 3, 15, 343000), 'temperature': 24.399999618530273, 'location': 1}] +# ANCHOR_END: query + + +conn.close() diff --git a/docs-examples/python/cursor_usage_native_reference.py b/docs-examples/python/cursor_usage_native_reference.py new file mode 100644 index 0000000000000000000000000000000000000000..a5103810f0199708f94b5c36e1dc080b7998e420 --- /dev/null +++ b/docs-examples/python/cursor_usage_native_reference.py @@ -0,0 +1,32 @@ +import taos + +conn = taos.connect() +cursor = conn.cursor() + +cursor.execute("DROP DATABASE IF EXISTS test") +cursor.execute("CREATE DATABASE test") +cursor.execute("USE test") +cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)") + +for i in range(1000): + location = str(i % 10) + tb = "t" + location + cursor.execute(f"INSERT INTO {tb} USING weather TAGS({location}) VALUES (now+{i}a, 23.5) (now+{i + 1}a, 23.5)") + +cursor.execute("SELECT count(*) FROM weather") +data = cursor.fetchall() +print("count:", data[0][0]) +cursor.execute("SELECT tbname, * FROM weather LIMIT 2") +col_names = [meta[0] for meta in cursor.description] +print(col_names) +rows = cursor.fetchall() +print(rows) + +cursor.close() +conn.close() + +# output: +# count: 2000 +# ['tbname', 'ts', 'temperature', 'location'] +# row_count: -1 +# [('t0', datetime.datetime(2022, 4, 27, 14, 54, 24, 392000), 23.5, 0), ('t0', datetime.datetime(2022, 4, 27, 14, 54, 24, 393000), 23.5, 0)] diff --git a/docs-examples/python/handle_exception.py b/docs-examples/python/handle_exception.py new file mode 100644 index 0000000000000000000000000000000000000000..278feb4e96081e922555eab8ba8dfc1855909955 --- /dev/null +++ b/docs-examples/python/handle_exception.py @@ -0,0 +1,23 @@ +import taos + +conn: taos.TaosConnection = None +try: + conn = taos.connect() + conn.execute("CREATE TABLE 123") # wrong sql +except taos.Error as e: + print(e) + print("exception class: ", e.__class__.__name__) + print("error number:", e.errno) + print("error message:", e.msg) +except BaseException as other: + print("exception occur") + print(other) +finally: + if conn is not None: + conn.close() + +# output: +# [0x0216]: syntax error near 'Incomplete SQL statement' +# exception class: ProgrammingError +# error number: -2147483114 +# error message: syntax error near 'Incomplete SQL statement' diff --git a/docs-examples/python/json_protocol_example.py b/docs-examples/python/json_protocol_example.py new file mode 100644 index 0000000000000000000000000000000000000000..5bb4d629bccf3d79e74b381d6259de86d6522315 --- /dev/null +++ b/docs-examples/python/json_protocol_example.py @@ -0,0 +1,38 @@ +import json + +import taos +from taos import SmlProtocol, SmlPrecision + +lines = [{"metric": "meters.current", "timestamp": 1648432611249, "value": 10.3, "tags": {"location": "Beijing.Chaoyang", "groupid": 2}}, + {"metric": "meters.voltage", "timestamp": 1648432611249, "value": 219, + "tags": {"location": "Beijing.Haidian", "groupid": 1}}, + {"metric": "meters.current", "timestamp": 1648432611250, "value": 12.6, + "tags": {"location": "Beijing.Chaoyang", "groupid": 2}}, + {"metric": "meters.voltage", "timestamp": 1648432611250, "value": 221, "tags": {"location": "Beijing.Haidian", "groupid": 1}}] + + +def get_connection(): + return taos.connect() + + +def create_database(conn): + conn.execute("CREATE DATABASE test") + conn.execute("USE test") + + +def insert_lines(conn): + global lines + lines = json.dumps(lines) + # note: the first parameter must be a list with only one element. + affected_rows = conn.schemaless_insert( + [lines], SmlProtocol.JSON_PROTOCOL, SmlPrecision.NOT_CONFIGURED) + print(affected_rows) # 4 + + +if __name__ == '__main__': + connection = get_connection() + try: + create_database(connection) + insert_lines(connection) + finally: + connection.close() diff --git a/docs-examples/python/line_protocol_example.py b/docs-examples/python/line_protocol_example.py new file mode 100644 index 0000000000000000000000000000000000000000..02baeb2104f9f48984b4d34afb5e67af641d4e32 --- /dev/null +++ b/docs-examples/python/line_protocol_example.py @@ -0,0 +1,34 @@ +import taos +from taos import SmlProtocol, SmlPrecision + +lines = ["meters,location=Beijing.Haidian,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249000", + "meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611249500", + "meters,location=Beijing.Haidian,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249300", + "meters,location=Beijing.Haidian,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611249800", + ] + + +def get_connection(): + # create connection use firstEP in taos.cfg. + return taos.connect() + + +def create_database(conn): + # the default precision is ms (microsecond), but we use us(microsecond) here. + conn.execute("CREATE DATABASE test precision 'us'") + conn.execute("USE test") + + +def insert_lines(conn): + affected_rows = conn.schemaless_insert( + lines, SmlProtocol.LINE_PROTOCOL, SmlPrecision.MICRO_SECONDS) + print(affected_rows) # 8 + + +if __name__ == '__main__': + connection = get_connection() + try: + create_database(connection) + insert_lines(connection) + finally: + connection.close() diff --git a/docs-examples/python/multi_bind_example.py b/docs-examples/python/multi_bind_example.py new file mode 100644 index 0000000000000000000000000000000000000000..1714121d72705ab8d619a41f3463af4aa3193871 --- /dev/null +++ b/docs-examples/python/multi_bind_example.py @@ -0,0 +1,88 @@ +import taos +from datetime import datetime + +# ANCHOR: bind_batch +table_tags = { + "d1001": ('Beijing.Chaoyang', 2), + "d1002": ('Beijing.Chaoyang', 3), + "d1003": ('Beijing.Haidian', 2), + "d1004": ('Beijing.Haidian', 3) +} + +table_values = { + "d1001": [ + ['2018-10-03 14:38:05.000', '2018-10-03 14:38:15.000', '2018-10-03 14:38:16.800'], + [10.3, 12.6, 12.3], + [219, 218, 221], + [0.31, 0.33, 0.32] + ], + "d1002": [ + ['2018-10-03 14:38:16.650'], [10.3], [218], [0.25] + ], + "d1003": [ + ['2018-10-03 14:38:05.500', '2018-10-03 14:38:16.600'], + [11.8, 13.4], + [221, 223], + [0.28, 0.29] + ], + "d1004": [ + ['2018-10-03 14:38:05.500', '2018-10-03 14:38:06.500'], + [10.8, 11.5], + [223, 221], + [0.29, 0.35] + ] +} + + +def bind_multi_rows(stmt: taos.TaosStmt): + """ + batch bind example + """ + for tb_name in table_values.keys(): + tags = table_tags[tb_name] + tag_params = taos.new_bind_params(2) + tag_params[0].binary(tags[0]) + tag_params[1].int(tags[1]) + stmt.set_tbname_tags(tb_name, tag_params) + + values = table_values[tb_name] + value_params = taos.new_multi_binds(4) + value_params[0].timestamp([get_ts(t) for t in values[0]]) + value_params[1].float(values[1]) + value_params[2].int(values[2]) + value_params[3].float(values[3]) + stmt.bind_param_batch(value_params) + + +def insert_data(): + conn = taos.connect(database="power") + try: + stmt = conn.statement("INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)") + bind_multi_rows(stmt) + stmt.execute() + stmt.close() + finally: + conn.close() + + +# ANCHOR_END: bind_batch + + +def create_stable(): + conn = taos.connect() + try: + conn.execute("CREATE DATABASE power") + conn.execute("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " + "TAGS (location BINARY(64), groupId INT)") + finally: + conn.close() + + +def get_ts(ts: str): + dt = datetime.strptime(ts, '%Y-%m-%d %H:%M:%S.%f') + return int(dt.timestamp() * 1000) + + +if __name__ == '__main__': + create_stable() + insert_data() diff --git a/docs-examples/python/native_insert_example.py b/docs-examples/python/native_insert_example.py new file mode 100644 index 0000000000000000000000000000000000000000..94d4888a8f5330b9e39d5ae051fcb68f9825505f --- /dev/null +++ b/docs-examples/python/native_insert_example.py @@ -0,0 +1,60 @@ +import taos + +lines = ["d1001,2018-10-03 14:38:05.000,10.30000,219,0.31000,Beijing.Chaoyang,2", + "d1004,2018-10-03 14:38:05.000,10.80000,223,0.29000,Beijing.Haidian,3", + "d1003,2018-10-03 14:38:05.500,11.80000,221,0.28000,Beijing.Haidian,2", + "d1004,2018-10-03 14:38:06.500,11.50000,221,0.35000,Beijing.Haidian,3", + "d1002,2018-10-03 14:38:16.650,10.30000,218,0.25000,Beijing.Chaoyang,3", + "d1001,2018-10-03 14:38:15.000,12.60000,218,0.33000,Beijing.Chaoyang,2", + "d1001,2018-10-03 14:38:16.800,12.30000,221,0.31000,Beijing.Chaoyang,2", + "d1003,2018-10-03 14:38:16.600,13.40000,223,0.29000,Beijing.Haidian,2"] + + +def get_connection() -> taos.TaosConnection: + """ + create connection use firstEp in taos.cfg and use default user and password. + """ + return taos.connect() + + +def create_stable(conn: taos.TaosConnection): + conn.execute("CREATE DATABASE power") + conn.execute("USE power") + conn.execute("CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) " + "TAGS (location BINARY(64), groupId INT)") + + +# The generated SQL is: +# INSERT INTO d1001 USING meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) +# d1002 USING meters TAGS(Beijing.Chaoyang, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) +# d1003 USING meters TAGS(Beijing.Haidian, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) +# d1004 USING meters TAGS(Beijing.Haidian, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000) + +def get_sql(): + global lines + lines = map(lambda line: line.split(','), lines) # [['d1001', ...]...] + lines = sorted(lines, key=lambda ls: ls[0]) # sort by table name + sql = "INSERT INTO " + tb_name = None + for ps in lines: + tmp_tb_name = ps[0] + if tb_name != tmp_tb_name: + tb_name = tmp_tb_name + sql += f"{tb_name} USING meters TAGS({ps[5]}, {ps[6]}) VALUES " + sql += f"('{ps[1]}', {ps[2]}, {ps[3]}, {ps[4]}) " + return sql + + +def insert_data(conn: taos.TaosConnection): + sql = get_sql() + affected_rows = conn.execute(sql) + print("affected_rows", affected_rows) # 8 + + +if __name__ == '__main__': + connection = get_connection() + try: + create_stable(connection) + insert_data(connection) + finally: + connection.close() diff --git a/docs-examples/python/query_example.py b/docs-examples/python/query_example.py new file mode 100644 index 0000000000000000000000000000000000000000..6d33c49c968d9210b475931b5d8cecca0ceff3e3 --- /dev/null +++ b/docs-examples/python/query_example.py @@ -0,0 +1,42 @@ +import taos + + +# ANCHOR: iter +def query_api_demo(conn: taos.TaosConnection): + result: taos.TaosResult = conn.query("SELECT tbname, * FROM meters LIMIT 2") + print("field count:", result.field_count) + print("meta of fields[1]:", result.fields[1]) + print("======================Iterate on result=========================") + for row in result: + print(row) + + +# field count: 7 +# meta of files[1]: {name: ts, type: 9, bytes: 8} +# ======================Iterate on result========================= +# ('d1001', datetime.datetime(2018, 10, 3, 14, 38, 5), 10.300000190734863, 219, 0.3100000023841858, 'Beijing.Chaoyang', 2) +# ('d1001', datetime.datetime(2018, 10, 3, 14, 38, 15), 12.600000381469727, 218, 0.33000001311302185, 'Beijing.Chaoyang', 2) +# ANCHOR_END: iter + +# ANCHOR: fetch_all +def fetch_all_demo(conn: taos.TaosConnection): + result: taos.TaosResult = conn.query("SELECT ts, current FROM meters LIMIT 2") + rows = result.fetch_all_into_dict() + print("row count:", result.row_count) + print("===============all data===================") + print(rows) + + +# row count: 2 +# ===============all data=================== +# [{'ts': datetime.datetime(2018, 10, 3, 14, 38, 5), 'current': 10.300000190734863}, +# {'ts': datetime.datetime(2018, 10, 3, 14, 38, 15), 'current': 12.600000381469727}] +# ANCHOR_END: fetch_all + +if __name__ == '__main__': + connection = taos.connect(database="power") + try: + query_api_demo(connection) + fetch_all_demo(connection) + finally: + connection.close() diff --git a/docs-examples/python/rest_client_example.py b/docs-examples/python/rest_client_example.py new file mode 100644 index 0000000000000000000000000000000000000000..46d33a1d795f8c8dbb0b830061d43ed4510046ba --- /dev/null +++ b/docs-examples/python/rest_client_example.py @@ -0,0 +1,9 @@ +from taosrest import RestClient + +client = RestClient("localhost", 6041, "root", "taosdata") +res: dict = client.sql("SELECT ts, current FROM power.meters LIMIT 1") +print(res) + +# output: +# {'status': 'succ', 'head': ['ts', 'current'], 'column_meta': [['ts', 9, 8], ['current', 6, 4]], 'data': [[datetime.datetime(2018, 10, 3, 14, 38, 5, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 10.3]], 'rows': 1} + diff --git a/docs-examples/python/result_set_examples.py b/docs-examples/python/result_set_examples.py new file mode 100644 index 0000000000000000000000000000000000000000..6cba0d3f73cdaa408309de93652ed8f346c8f759 --- /dev/null +++ b/docs-examples/python/result_set_examples.py @@ -0,0 +1,33 @@ +import taos + +conn = taos.connect() +conn.execute("DROP DATABASE IF EXISTS test") +conn.execute("CREATE DATABASE test") +conn.select_db("test") +conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)") +# prepare data +for i in range(2000): + location = str(i % 10) + tb = "t" + location + conn.execute(f"INSERT INTO {tb} USING weather TAGS({location}) VALUES (now+{i}a, 23.5) (now+{i + 1}a, 23.5)") + +result: taos.TaosResult = conn.query("SELECT * FROM weather") + +block_index = 0 +blocks: taos.TaosBlocks = result.blocks_iter() +for rows, length in blocks: + print("block ", block_index, " length", length) + print("first row in this block:", rows[0]) + block_index += 1 + +conn.close() + +# possible output: +# block 0 length 1200 +# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 46000), 23.5, 0) +# block 1 length 1200 +# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 76000), 23.5, 3) +# block 2 length 1200 +# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 99000), 23.5, 6) +# block 3 length 400 +# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 122000), 23.5, 9) diff --git a/docs-examples/python/subscribe_demo.py b/docs-examples/python/subscribe_demo.py new file mode 100644 index 0000000000000000000000000000000000000000..cc53e59d81a6bfd33d002f076a28016ece1a2b17 --- /dev/null +++ b/docs-examples/python/subscribe_demo.py @@ -0,0 +1 @@ +import taos \ No newline at end of file diff --git a/docs-examples/python/telnet_line_protocol_example.py b/docs-examples/python/telnet_line_protocol_example.py new file mode 100644 index 0000000000000000000000000000000000000000..072835109ee238940e6fe5880b72b2b04e0157fa --- /dev/null +++ b/docs-examples/python/telnet_line_protocol_example.py @@ -0,0 +1,38 @@ +import taos +from taos import SmlProtocol, SmlPrecision + +# format: =[ =] +lines = ["meters.current 1648432611249 10.3 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611250 12.6 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611249 10.8 location=Beijing.Haidian groupid=3", + "meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611249 219 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611250 218 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611249 221 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611250 217 location=Beijing.Haidian groupid=3", + ] + + +# create connection use firstEp in taos.cfg. +def get_connection(): + return taos.connect() + + +def create_database(conn): + conn.execute("CREATE DATABASE test") + conn.execute("USE test") + + +def insert_lines(conn): + affected_rows = conn.schemaless_insert( + lines, SmlProtocol.TELNET_PROTOCOL, SmlPrecision.NOT_CONFIGURED) + print(affected_rows) # 8 + + +if __name__ == '__main__': + connection = get_connection() + try: + create_database(connection) + insert_lines(connection) + finally: + connection.close() diff --git a/docs-examples/rust/.gitignore b/docs-examples/rust/.gitignore deleted file mode 100644 index c8e4894416937b2d7c921cf5d1782a67e070fe7e..0000000000000000000000000000000000000000 --- a/docs-examples/rust/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.lock \ No newline at end of file diff --git a/docs-examples/rust/Cargo.lock b/docs-examples/rust/Cargo.lock deleted file mode 100644 index d88aa0ab5587ef00f16d73e5772530df5c2d89b2..0000000000000000000000000000000000000000 --- a/docs-examples/rust/Cargo.lock +++ /dev/null @@ -1,948 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "base64" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" - -[[package]] -name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata", -] - -[[package]] -name = "bumpalo" -version = "3.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" - -[[package]] -name = "bytes" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", - "winapi", -] - -[[package]] -name = "darling" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f2c43f534ea4b0b049015d00269734195e6d3f0f6635cb692251aca6f9f8b3c" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e91455b86830a1c21799d94524df0845183fa55bafd9aa137b01c7d1065fa36" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29b5acf0dea37a7f66f7b25d2c5e93fd46f8f6968b1a5d7a3e02e97768afc95a" -dependencies = [ - "darling_core", - "quote", - "syn", -] - -[[package]] -name = "derive_builder" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d13202debe11181040ae9063d739fa32cfcaaebe2275fe387703460ae2365b30" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66e616858f6187ed828df7c64a6d71720d83767a7f19740b2d1b6fe6327b36e5" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "derive_builder_macro" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58a94ace95092c5acb1e97a7e846b310cfbd499652f72297da7493f618a98d73" -dependencies = [ - "derive_builder_core", - "syn", -] - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "encoding_rs" -version = "0.8.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "form_urlencoded" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" -dependencies = [ - "matches", - "percent-encoding", -] - -[[package]] -name = "futures-channel" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" - -[[package]] -name = "futures-sink" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" - -[[package]] -name = "futures-task" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" - -[[package]] -name = "futures-util" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" -dependencies = [ - "futures-core", - "futures-task", - "pin-project-lite", - "pin-utils", -] - -[[package]] -name = "h2" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62eeb471aa3e3c9197aa4bfeabfe02982f6dc96f750486c0bb0009ac58b26d2b" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" - -[[package]] -name = "http" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" -dependencies = [ - "bytes", - "http", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" - -[[package]] -name = "httpdate" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" - -[[package]] -name = "hyper" -version = "0.14.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b26ae0a80afebe130861d90abf98e3814a4f28a4c6ffeb5ab8ebb2be311e0ef2" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "indexmap" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" -dependencies = [ - "autocfg", - "hashbrown", -] - -[[package]] -name = "ipnet" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c" - -[[package]] -name = "itertools" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" - -[[package]] -name = "js-sys" -version = "0.3.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a38fc24e30fd564ce974c02bf1d337caddff65be6cc4735a1f7eab22a7440f04" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.121" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" - -[[package]] -name = "libtaos" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d298164350053f81f958b8590a4d9bccc4d7f66a6aad3ffc0e937de9432bf88" -dependencies = [ - "bstr", - "chrono", - "derive_builder", - "itertools", - "lazy_static", - "log", - "num_enum", - "paste", - "reqwest", - "serde", - "serde_json", - "serde_repr", - "stdext", - "thiserror", -] - -[[package]] -name = "log" -version = "0.4.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "matches" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" - -[[package]] -name = "memchr" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" - -[[package]] -name = "mime" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" - -[[package]] -name = "mio" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" -dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "wasi 0.11.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", -] - -[[package]] -name = "nativeexample" -version = "0.1.0" -dependencies = [ - "libtaos", -] - -[[package]] -name = "ntapi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", -] - -[[package]] -name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_enum" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" -dependencies = [ - "num_enum_derive", -] - -[[package]] -name = "num_enum_derive" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "paste" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0744126afe1a6dd7f394cb50a716dbe086cb06e255e53d8d0185d82828358fb5" - -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "pin-project-lite" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "proc-macro-crate" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" -dependencies = [ - "thiserror", - "toml", -] - -[[package]] -name = "proc-macro2" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" -dependencies = [ - "unicode-xid", -] - -[[package]] -name = "quote" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" - -[[package]] -name = "reqwest" -version = "0.11.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a1f7aa4f35e5e8b4160449f51afc758f0ce6454315a9fa7d0d113e958c41eb" -dependencies = [ - "base64", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "hyper", - "ipnet", - "js-sys", - "lazy_static", - "log", - "mime", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "tokio", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - -[[package]] -name = "restexample" -version = "0.1.0" -dependencies = [ - "libtaos", -] - -[[package]] -name = "ryu" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" - -[[package]] -name = "serde" -version = "1.0.136" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.136" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_repr" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98d0516900518c29efa217c298fa1f4e6c6ffc85ae29fd7f4ee48f176e1a9ed5" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "slab" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" - -[[package]] -name = "socket2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "stdext" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f3b6b32ae82412fb897ef134867d53a294f57ba5b758f06d71e865352c3e207" - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "syn" -version = "1.0.89" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" -dependencies = [ - "proc-macro2", - "quote", - "unicode-xid", -] - -[[package]] -name = "thiserror" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "time" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] - -[[package]] -name = "tinyvec" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - -[[package]] -name = "tokio" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" -dependencies = [ - "bytes", - "libc", - "memchr", - "mio", - "pin-project-lite", - "socket2", - "winapi", -] - -[[package]] -name = "tokio-util" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" -dependencies = [ - "bytes", - "futures-core", - "futures-sink", - "log", - "pin-project-lite", - "tokio", -] - -[[package]] -name = "toml" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" -dependencies = [ - "serde", -] - -[[package]] -name = "tower-service" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" - -[[package]] -name = "tracing" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f" -dependencies = [ - "cfg-if", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "try-lock" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" - -[[package]] -name = "unicode-bidi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" - -[[package]] -name = "unicode-normalization" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - -[[package]] -name = "url" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" -dependencies = [ - "form_urlencoded", - "idna", - "matches", - "percent-encoding", -] - -[[package]] -name = "want" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" -dependencies = [ - "log", - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb6ec270a31b1d3c7e266b999739109abce8b6c87e4b31fcfcd788b65267395" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" - -[[package]] -name = "web-sys" -version = "0.3.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c060b319f29dd25724f09a2ba1418f142f539b2be99fbf4d2d5a8f7330afb8eb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "winreg" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" -dependencies = [ - "winapi", -] diff --git a/docs-examples/rust/Cargo.toml b/docs-examples/rust/Cargo.toml index 136d09ffbbbd9c7bc1b876e7bfc630dea0560382..114407e69edcb94fdeef77e6ae581569c5451160 100644 --- a/docs-examples/rust/Cargo.toml +++ b/docs-examples/rust/Cargo.toml @@ -1,2 +1,2 @@ [workspace] -members = ["restexample", "nativeexample"] +members = ["restexample", "nativeexample", "schemalessexample"] diff --git a/docs-examples/rust/nativeexample/Cargo.toml b/docs-examples/rust/nativeexample/Cargo.toml index 11e6087ea56cea88ece7ca2199d9ed55128fb711..64fd10a3e915a39c321b56b6f38be51417d8d18e 100644 --- a/docs-examples/rust/nativeexample/Cargo.toml +++ b/docs-examples/rust/nativeexample/Cargo.toml @@ -5,4 +5,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libtaos = { version = "0.4.2" } +libtaos = { version = "0.4.3" } +tokio = { version = "*", features = ["rt", "macros", "rt-multi-thread"] } +bstr = { version = "*" } diff --git a/docs-examples/rust/nativeexample/examples/stmt_example.rs b/docs-examples/rust/nativeexample/examples/stmt_example.rs new file mode 100644 index 0000000000000000000000000000000000000000..a791a4135984a33dded145e8175d7ade57de8d77 --- /dev/null +++ b/docs-examples/rust/nativeexample/examples/stmt_example.rs @@ -0,0 +1,38 @@ +use bstr::BString; +use libtaos::*; + +#[tokio::main] +async fn main() -> Result<(), Error> { + let taos = TaosCfg::default().connect().expect("fail to connect"); + taos.create_database("power").await?; + taos.use_database("power").await?; + taos.exec("CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)").await?; + let mut stmt = taos.stmt("INSERT INTO ? USING meters TAGS(?, ?) VALUES(?, ?, ?, ?)")?; + // bind table name and tags + stmt.set_tbname_tags( + "d1001", + [ + Field::Binary(BString::from("Beijing.Chaoyang")), + Field::Int(2), + ], + )?; + // bind values. + let values = vec![ + Field::Timestamp(Timestamp::new(1648432611249, TimestampPrecision::Milli)), + Field::Float(10.3), + Field::Int(219), + Field::Float(0.31), + ]; + stmt.bind(&values)?; + // bind one more row + let values2 = vec![ + Field::Timestamp(Timestamp::new(1648432611749, TimestampPrecision::Milli)), + Field::Float(12.6), + Field::Int(218), + Field::Float(0.33), + ]; + stmt.bind(&values2)?; + // execute + stmt.execute()?; + Ok(()) +} diff --git a/docs-examples/rust/nativeexample/examples/subscribe_demo.rs b/docs-examples/rust/nativeexample/examples/subscribe_demo.rs new file mode 100644 index 0000000000000000000000000000000000000000..4febff9be7bd5771db449fbfb184a9f208e61d8a --- /dev/null +++ b/docs-examples/rust/nativeexample/examples/subscribe_demo.rs @@ -0,0 +1,3 @@ +fn main() { + +} \ No newline at end of file diff --git a/docs-examples/rust/nativeexample/examples/src/main.rs b/docs-examples/rust/nativeexample/src/main.rs similarity index 100% rename from docs-examples/rust/nativeexample/examples/src/main.rs rename to docs-examples/rust/nativeexample/src/main.rs diff --git a/docs-examples/rust/restexample/Cargo.toml b/docs-examples/rust/restexample/Cargo.toml index 0f04e73c94fd2c9a6064e3eb0fbb6fe24cf51d06..a5f89f8a3be3baabd298a70947f6c5d3df088aae 100644 --- a/docs-examples/rust/restexample/Cargo.toml +++ b/docs-examples/rust/restexample/Cargo.toml @@ -3,6 +3,6 @@ name = "restexample" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libtaos = { version = "*", features = ["rest"] } +libtaos = { version = "0.4.3", features = ["rest"] } +tokio = { version = "*", features = ["rt", "macros", "rt-multi-thread"] } diff --git a/docs-examples/rust/restexample/examples/connect.rs b/docs-examples/rust/restexample/examples/connect.rs index 8e27458de5d428479668a0e5133ca904cf27c213..b3718342c4a142786572a7eec46d6fa36f651566 100644 --- a/docs-examples/rust/restexample/examples/connect.rs +++ b/docs-examples/rust/restexample/examples/connect.rs @@ -12,8 +12,9 @@ fn taos_connect() -> Result { .connect() } -fn main() { +#[tokio::main] +async fn main() { #[allow(unused_variables)] - let taos = taos_connect().unwrap(); + let taos = taos_connect().expect("connect error"); println!("Connected") } diff --git a/docs-examples/rust/restexample/examples/insert_example.rs b/docs-examples/rust/restexample/examples/insert_example.rs new file mode 100644 index 0000000000000000000000000000000000000000..d7acc98d096fb3cd6bea22d6c5f6f0f5caea50af --- /dev/null +++ b/docs-examples/rust/restexample/examples/insert_example.rs @@ -0,0 +1,18 @@ +use libtaos::*; + +#[tokio::main] +async fn main() -> Result<(), Error> { + let taos = TaosCfg::default().connect().expect("fail to connect"); + taos.create_database("power").await?; + taos.exec("CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)").await?; + let sql = "INSERT INTO power.d1001 USING power.meters TAGS(Beijing.Chaoyang, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) + power.d1002 USING power.meters TAGS(Beijing.Chaoyang, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) + power.d1003 USING power.meters TAGS(Beijing.Haidian, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) + power.d1004 USING power.meters TAGS(Beijing.Haidian, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)"; + let result = taos.query(sql).await?; + println!("{:?}", result); + Ok(()) +} + +// output: +// TaosQueryData { column_meta: [ColumnMeta { name: "affected_rows", type_: Int, bytes: 4 }], rows: [[Int(8)]] } diff --git a/docs-examples/rust/restexample/examples/query_example.rs b/docs-examples/rust/restexample/examples/query_example.rs new file mode 100644 index 0000000000000000000000000000000000000000..bbe0cfaabf0d3b078606e823dd504be4153832e7 --- /dev/null +++ b/docs-examples/rust/restexample/examples/query_example.rs @@ -0,0 +1,39 @@ +use libtaos::*; + +fn taos_connect() -> Result { + TaosCfgBuilder::default() + .ip("localhost") + .user("root") + .pass("taosdata") + .db("power") + .port(6030u16) + .build() + .expect("TaosCfg builder error") + .connect() +} + +#[tokio::main] +async fn main() -> Result<(), Error> { + let taos = taos_connect().expect("connect error"); + let result = taos.query("SELECT ts, current FROM meters LIMIT 2").await?; + // print column names + let meta: Vec = result.column_meta; + for column in meta { + print!("{}\t", column.name) + } + println!(); + // print rows + let rows: Vec> = result.rows; + for row in rows { + for field in row { + print!("{}\t", field); + } + println!(); + } + Ok(()) +} + +// output: +// ts current +// 2022-03-28 09:56:51.249 10.3 +// 2022-03-28 09:56:51.749 12.6 diff --git a/docs-examples/rust/schemalessexample/Cargo.toml b/docs-examples/rust/schemalessexample/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..32c6a122318d16f488210da54f1600ba8f6a8b7c --- /dev/null +++ b/docs-examples/rust/schemalessexample/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "schemalessexample" +version = "0.1.0" +edition = "2021" + +[dependencies] +libtaos = { version = "0.4.3" } diff --git a/docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs b/docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs new file mode 100644 index 0000000000000000000000000000000000000000..e93888cc83d12f3bec7370a66e8a85d38cec42ad --- /dev/null +++ b/docs-examples/rust/schemalessexample/examples/influxdb_line_example.rs @@ -0,0 +1,22 @@ +use libtaos::schemaless::*; +use libtaos::*; + +fn main() { + let taos = TaosCfg::default().connect().expect("fail to connect"); + taos.raw_query("CREATE DATABASE test").unwrap(); + taos.raw_query("USE test").unwrap(); + let lines = ["meters,location=Beijing.Haidian,groupid=2 current=11.8,voltage=221,phase=0.28 1648432611249", + "meters,location=Beijing.Haidian,groupid=2 current=13.4,voltage=223,phase=0.29 1648432611250", + "meters,location=Beijing.Haidian,groupid=3 current=10.8,voltage=223,phase=0.29 1648432611249", + "meters,location=Beijing.Haidian,groupid=3 current=11.3,voltage=221,phase=0.35 1648432611250"]; + let affected_rows = taos + .schemaless_insert( + &lines, + TSDB_SML_LINE_PROTOCOL, + TSDB_SML_TIMESTAMP_MILLISECONDS, + ) + .unwrap(); + println!("affected_rows={}", affected_rows); +} + +// run with: cargo run --example influxdb_line_example diff --git a/docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs b/docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs new file mode 100644 index 0000000000000000000000000000000000000000..1d66bd1f2b1bcbe82dc3ee3e8e25ea4c521c81f0 --- /dev/null +++ b/docs-examples/rust/schemalessexample/examples/opentsdb_json_example.rs @@ -0,0 +1,25 @@ +use libtaos::schemaless::*; +use libtaos::*; + +fn main() { + let taos = TaosCfg::default().connect().expect("fail to connect"); + taos.raw_query("CREATE DATABASE test").unwrap(); + taos.raw_query("USE test").unwrap(); + let lines = [ + r#"[{"metric": "meters.current", "timestamp": 1648432611249, "value": 10.3, "tags": {"location": "Beijing.Chaoyang", "groupid": 2}}, + {"metric": "meters.voltage", "timestamp": 1648432611249, "value": 219, "tags": {"location": "Beijing.Haidian", "groupid": 1}}, + {"metric": "meters.current", "timestamp": 1648432611250, "value": 12.6, "tags": {"location": "Beijing.Chaoyang", "groupid": 2}}, + {"metric": "meters.voltage", "timestamp": 1648432611250, "value": 221, "tags": {"location": "Beijing.Haidian", "groupid": 1}}]"#, + ]; + + let affected_rows = taos + .schemaless_insert( + &lines, + TSDB_SML_JSON_PROTOCOL, + TSDB_SML_TIMESTAMP_NOT_CONFIGURED, + ) + .unwrap(); + println!("affected_rows={}", affected_rows); // affected_rows=4 +} + +// run with: cargo run --example opentsdb_json_example diff --git a/docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs b/docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs new file mode 100644 index 0000000000000000000000000000000000000000..18d7500714d9e41b1bebd490199d296ead3dc7c4 --- /dev/null +++ b/docs-examples/rust/schemalessexample/examples/opentsdb_telnet_example.rs @@ -0,0 +1,28 @@ +use libtaos::schemaless::*; +use libtaos::*; + +fn main() { + let taos = TaosCfg::default().connect().expect("fail to connect"); + taos.raw_query("CREATE DATABASE test").unwrap(); + taos.raw_query("USE test").unwrap(); + let lines = [ + "meters.current 1648432611249 10.3 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611250 12.6 location=Beijing.Chaoyang groupid=2", + "meters.current 1648432611249 10.8 location=Beijing.Haidian groupid=3", + "meters.current 1648432611250 11.3 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611249 219 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611250 218 location=Beijing.Chaoyang groupid=2", + "meters.voltage 1648432611249 221 location=Beijing.Haidian groupid=3", + "meters.voltage 1648432611250 217 location=Beijing.Haidian groupid=3", + ]; + let affected_rows = taos + .schemaless_insert( + &lines, + TSDB_SML_TELNET_PROTOCOL, + TSDB_SML_TIMESTAMP_NOT_CONFIGURED, + ) + .unwrap(); + println!("affected_rows={}", affected_rows); // affected_rows=8 +} + +// run with: cargo run --example opentsdb_telnet_example diff --git a/docs-examples/rust/schemalessexample/src/main.rs b/docs-examples/rust/schemalessexample/src/main.rs new file mode 100644 index 0000000000000000000000000000000000000000..e7a11a969c037e00a796aafeff6258501ec15e9a --- /dev/null +++ b/docs-examples/rust/schemalessexample/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/documentation20/cn/00.index/docs.md b/documentation20/cn/00.index/docs.md index a48ea49f59ce3fbccf5370de2276692f8e367fe3..bafd993b3f4d196367d50b4b83ad0b9f4dbe9cb9 100644 --- a/documentation20/cn/00.index/docs.md +++ b/documentation20/cn/00.index/docs.md @@ -81,6 +81,7 @@ TDengine 是一个高效的存储、查询、分析时序大数据的平台, - [C# Connector](/connector#csharp):给 C# 应用提供一个连接 TDengine 服务器的驱动 - [Windows 客户端](https://www.taosdata.com/blog/2019/07/26/514.html):自行编译 Windows 客户端,Windows 环境的各种连接器都需要它 - [Rust Connector](/connector/rust): Rust 语言下通过 libtaos 客户端或 RESTful 接口,连接 TDengine 服务器。 +- [PHP Connector](/connector/php): 给 PHP 应用提供一个连接 TDengine 服务器的驱动,或 RESTful 接口,连接 TDengine 服务器。 ## TDengine 组件与工具 @@ -96,6 +97,7 @@ TDengine 是一个高效的存储、查询、分析时序大数据的平台, - [IDEA Database](https://www.taosdata.com/blog/2020/08/27/1767.html):通过 IDEA 数据库管理工具可视化使用 TDengine - [TDengineGUI](https://github.com/skye0207/TDengineGUI):基于 Electron 开发的跨平台 TDengine 图形化管理工具 - [DataX](https://www.taosdata.com/blog/2021/10/26/3156.html):支持 TDengine 和其他数据库之间进行数据迁移的工具 +- [Awesome TDengine](https://github.com/taosdata/awesome-tdengine):与 TDengine 有关的精彩项目精选清单 ## [TDengine 集群的安装、管理](/cluster) diff --git a/documentation20/cn/02.getting-started/docs.md b/documentation20/cn/02.getting-started/docs.md index 454018a882ff221ae3a482cbef0fcc5c200c61d9..128ce81abec58f046a4ec7f65dcaea8bfdb5b989 100644 --- a/documentation20/cn/02.getting-started/docs.md +++ b/documentation20/cn/02.getting-started/docs.md @@ -34,7 +34,9 @@ TDengine 的安装非常简单,从下载到安装成功仅仅只要几秒钟 具体的安装方法,请参见 [TDengine 多种安装包的安装和卸载](https://www.taosdata.com/cn/getting-started/install) 以及 [视频教程](https://www.taosdata.com/blog/2020/11/11/1941.html)。 -**请点击[这里](https://github.com/taosdata/TDengine/releases)查看 release notes。** +下载其他组件、最新 Beta 版及之前版本的安装包,请点击 [这里](https://www.taosdata.com/cn/all-downloads/) + +**请点击 [这里](https://github.com/taosdata/TDengine/releases) 查看 Release Notes。** ### 使用 apt-get 安装 @@ -59,8 +61,6 @@ sudo apt-get install tdengine 如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装. -**下载其他组件、最新 Beta 版及之前版本的安装包,请点击[这里](https://www.taosdata.com/cn/all-downloads/)** - ## 轻松启动 安装成功后,用户可使用 `systemctl` 命令来启动 TDengine 的服务进程。 diff --git a/documentation20/cn/03.architecture/docs.md b/documentation20/cn/03.architecture/docs.md index 0c0ab8e65e120ddfbd45ff6c7f51b949d71c915b..4376015c73a8f3b03efba4b6a484f3d739aea634 100644 --- a/documentation20/cn/03.architecture/docs.md +++ b/documentation20/cn/03.architecture/docs.md @@ -167,7 +167,7 @@ TDengine 分布式架构的逻辑结构图如下: **虚拟节点(vnode):** 为更好的支持数据分片、负载均衡,防止数据过热或倾斜,数据节点被虚拟化成多个虚拟节点(vnode,图中 V2, V3, V4等)。每个 vnode 都是一个相对独立的工作单元,是时序数据存储的基本单元,具有独立的运行线程、内存空间与持久化存储的路径。一个 vnode 包含一定数量的表(数据采集点)。当创建一张新表时,系统会检查是否需要创建新的 vnode。一个数据节点上能创建的 vnode 的数量取决于该数据节点所在物理节点的硬件资源。一个 vnode 只属于一个 DB,但一个 DB 可以有多个 vnode。一个 vnode 除存储的时序数据外,也保存有所包含的表的 schema、标签值等。一个虚拟节点由所属的数据节点的EP,以及所属的 VGroup ID 在系统内唯一标识,由管理节点创建并管理。 -**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(开源版最多不超过 3 个) mnode,它们自动构建成为一个虚拟管理节点组(图中 M0, M1, M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步, 任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的EP来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的EP。 +**管理节点(mnode):** 一个虚拟的逻辑单元,负责所有数据节点运行状态的监控和维护,以及节点之间的负载均衡(图中 M)。同时,管理节点也负责元数据(包括用户、数据库、表、静态标签等)的存储和管理,因此也称为 Meta Node。TDengine 集群中可配置多个(最多不超过 3 个) mnode,它们自动构建成为一个虚拟管理节点组(图中 M0, M1, M2)。mnode 间采用 master/slave 的机制进行管理,而且采取强一致方式进行数据同步, 任何数据更新操作只能在 Master 上进行。mnode 集群的创建由系统自动完成,无需人工干预。每个 dnode 上至多有一个 mnode,由所属的数据节点的EP来唯一标识。每个 dnode 通过内部消息交互自动获取整个集群中所有 mnode 所在的 dnode 的EP。 **虚拟节点组(VGroup):** 不同数据节点上的 vnode 可以组成一个虚拟节点组(vnode group)来保证系统的高可靠。虚拟节点组内采取 master/slave 的方式进行管理。写操作只能在 master vnode 上进行,系统采用异步复制的方式将数据同步到 slave vnode,这样确保了一份数据在多个物理节点上有拷贝。一个 vgroup 里虚拟节点个数就是数据的副本数。如果一个 DB 的副本数为 N,系统必须有至少 N 数据节点。副本数在创建DB时通过参数 replica 可以指定,缺省为 1。使用 TDengine 的多副本特性,可以不再需要昂贵的磁盘阵列等存储设备,就可以获得同样的数据高可靠性。虚拟节点组由管理节点创建、管理,并且由管理节点分配一个系统唯一的 ID,VGroup ID。如果两个虚拟节点的 vnode group ID 相同,说明他们属于同一个组,数据互为备份。虚拟节点组里虚拟节点的个数是可以动态改变的,容许只有一个,也就是没有数据复制。VGroup ID 是永远不变的,即使一个虚拟节点组被删除,它的ID也不会被收回重复利用。 diff --git a/documentation20/cn/08.connector/01.java/docs.md b/documentation20/cn/08.connector/01.java/docs.md index 15f69ae0eff0d56ef0803be16285106e234f7e83..caa880618fad933f94a0177354907d7c5199603c 100644 --- a/documentation20/cn/08.connector/01.java/docs.md +++ b/documentation20/cn/08.connector/01.java/docs.md @@ -57,10 +57,11 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES( | taos-jdbcdriver 版本 | TDengine 2.0.x.x 版本 | TDengine 2.2.x.x 版本 | TDengine 2.4.x.x 版本 | JDK 版本 | | -------------------- | --------------------- | --------------------- | --------------------- | -------- | -| 2.0.37 | X | X | 2.4.0.6 以上 | 1.8.x | -| 2.0.36 | X | 2.2.2.11 以上 | 2.4.0.0 - 2.4.0.5 | 1.8.x | -| 2.0.35 | X | 2.2.2.11 以上 | 2.3.0.0 - 2.4.0.5 | 1.8.x | -| 2.0.33 - 2.0.34 | 2.0.3.0 以上 | 2.2.0.0 以上 | 2.4.0.0 - 2.4.0.5 | 1.8.x | +| 2.0.38 | X | X | 2.4.0.14 及以上 | 1.8.x | +| 2.0.37 | X | X | 2.4.0.6 及以上 | 1.8.x | +| 2.0.36 | X | 2.2.2.11 及以上 | 2.4.0.0 - 2.4.0.5 | 1.8.x | +| 2.0.35 | X | 2.2.2.11 及以上 | 2.3.0.0 - 2.4.0.5 | 1.8.x | +| 2.0.33 - 2.0.34 | 2.0.3.0 及以上 | 2.2.0.0 及以上 | 2.4.0.0 - 2.4.0.5 | 1.8.x | | 2.0.31 - 2.0.32 | 2.1.3.0 - 2.1.7.7 | X | X | 1.8.x | | 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.1 | X | X | 1.8.x | | 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.4 | X | X | 1.8.x | @@ -114,7 +115,8 @@ maven 项目中,在pom.xml 中添加以下依赖: com.taosdata.jdbc taos-jdbcdriver - 2.0.18 + + 2.x.xx ``` @@ -150,7 +152,18 @@ Connection conn = DriverManager.getConnection(jdbcUrl); 2. jdbcUrl 以“jdbc:TAOS-RS://”开头; 3. 使用 6041 作为连接端口。 -如果希望获得更好的写入和查询性能,Java 应用可以使用 **JDBC-JNI** 的driver,如下所示: +从 taos-jdbcdriver-2.0.38 和 TDengine 2.4.0.12 版本开始,**JDBC-RESTful** 的 driver 增加批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 **JDBC-RESTful** 支持大数据量查询,并提升查询性能。 + +连接开启批量拉取方式: + +``` +String url = "jdbc:TAOS-RS://taosdemo.com:6041/?user=root&password=taosdata";Properties properties = new Properties(); +properties.setProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD, "true"); +Connection connection = DriverManager.getConnection(url, properties); +``` + +如果希望获得更好的写入和查询性能,Java 应用可以使用 **JDBC-JNI** 的 driver,如下所示: + ```java Class.forName("com.taosdata.jdbc.TSDBDriver"); String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata"; @@ -206,7 +219,7 @@ properties 中的配置参数如下: * TSDBDriver.PROPERTY_KEY_CHARSET:客户端使用的字符集,默认值为系统字符集。 * TSDBDriver.PROPERTY_KEY_LOCALE:客户端语言环境,默认值系统当前 locale。 * TSDBDriver.PROPERTY_KEY_TIME_ZONE:客户端使用的时区,默认值为系统当前时区。 -* TSDBDriver.PROPERTY_KEY_BATCH_LOAD: 仅在使用JDBC-JNI时生效。true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。 +* TSDBDriver.PROPERTY_KEY_BATCH_LOAD: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。 * TSDBDriver.PROPERTY_KEY_TIMESTAMP_FORMAT: 仅在使用JDBC-RESTful时生效. 'TIMESTAMP':结果集中timestamp类型的字段为一个long值; 'UTC':结果集中timestamp类型的字段为一个UTC时间格式的字符串; 'STRING':结果集中timestamp类型的字段为一个本地时间格式的字符串。默认值为'STRING'。 * TSDBDriver.PROPERTY_KEY_BATCH_ERROR_IGNORE:true:在执行Statement的executeBatch时,如果中间有一条sql执行失败,继续执行下面的sq了。false:不再执行失败sql后的任何语句。默认值为:false。 diff --git a/documentation20/cn/08.connector/03.php/docs.md b/documentation20/cn/08.connector/03.php/docs.md new file mode 100644 index 0000000000000000000000000000000000000000..eb772689e4699716a45a78dfb2723aa7a0cfa516 --- /dev/null +++ b/documentation20/cn/08.connector/03.php/docs.md @@ -0,0 +1,275 @@ +# PHP 连接器 + +## php-tdengine + +这是 [Swoole](https://github.com/swoole/swoole-src) 开发组成员,[imi](https://github.com/imiphp/imi) 框架作者宇润开发的 php TDengine 客户端扩展,依赖 `libtaos`。 + +源代码: + +### 依赖 + +- [PHP](https://www.php.net/) >= 7.4 + +- [Swoole](https://github.com/swoole/swoole-src) >= 4.8 (可选) + +- [TDengine客户端](https://www.taosdata.com/cn/getting-started/#%E9%80%9A%E8%BF%87%E5%AE%89%E8%A3%85%E5%8C%85%E5%AE%89%E8%A3%85) >= 2.0 + +## 特性列表 + +- 参数绑定 +- 支持 Swoole 协程化 +- 主流操作系统支持:Windows、Linux、MacOS +- 测试用例覆盖 + +### 编译安装 + +**下载代码并解压:** + +```shell +curl -L -o php-tdengine.tar.gz https://github.com/Yurunsoft/php-tdengine/archive/refs/tags/v1.0.0.tar.gz \ +&& mkdir php-tdengine \ +&& tar -xzf php-tdengine.tar.gz -C php-tdengine --strip-components=1 +``` + +> 版本 `v1.0.0` 可替换为任意更新的版本,可在 Release 中查看最新版本。 + +**非 Swoole 环境:** + +```shell +phpize && ./configure && make -j && make install +``` + +**手动指定 tdengine 目录:** + +```shell +phpize && ./configure --with-tdengine-dir=/usr/local/Cellar/tdengine/2.4.0.0 && make -j && make install +``` + +> `--with-tdengine-dir=` 后跟上 tdengine 目录。 +> 适用于默认找不到的情况,或者 MacOS 系统用户。 + +**Swoole 环境:** + +```shell +phpize && ./configure --enable-swoole && make -j && make install +``` + +**启用扩展:** + +方法一:在 `php.ini` 中加入 `extension=tdengine` + +方法二:运行带参数 `php -dextension=tdengine test.php` + +### PHP 代码编写 + +> 所有错误都会抛出异常: `TDengine\Exception\TDengineException` + +**基本:** + +```php +use TDengine\Connection; + +// 获取扩展版本号 +var_dump(\TDengine\EXTENSION_VERSION); + +// 设置客户端选项 +\TDengine\setOptions([ + \TDengine\TSDB_OPTION_LOCALE => 'en_US.UTF-8', // 区域 + \TDengine\TSDB_OPTION_CHARSET => 'UTF-8', // 字符集 + \TDengine\TSDB_OPTION_TIMEZONE => 'Asia/Shanghai', // 时区 + \TDengine\TSDB_OPTION_CONFIGDIR => '/etc/taos', // 配置目录 + \TDengine\TSDB_OPTION_SHELL_ACTIVITY_TIMER => 3, // shell 活动定时器 +]); + +// 获取客户端版本信息 +var_dump(\TDengine\CLIENT_VERSION); +var_dump(\TDengine\getClientInfo()); + +// 以下值都是默认值,不改可以不传 +$host = '127.0.0.1'; +$port = 6030; +$user = 'root'; +$pass = 'taosdata'; +$db = null; + +// 实例化 +$connection = new Connection($host, $port, $user, $pass, $db); +// 连接 +$connection->connection(); +// 获取连接参数 +$connection->getHost(); +$connection->getPort(); +$connection->getUser(); +$connection->getPass(); +$connection->getDb(); +// 获取服务端信息 +$connection->getServerInfo(); +// 选择默认数据库 +$connection->selectDb('db1'); +// 关闭连接 +$connection->close(); +``` + +**查询:** + +```php +// 查询 +$resource = $connection->query($sql); // 支持查询和插入 +// 获取结果集时间戳字段的精度,0 代表毫秒,1 代表微秒,2 代表纳秒 +$resource->getResultPrecision(); +// 获取所有数据 +$resource->fetch(); +// 获取一行数据 +$resource->fetchRow(); +// 获取字段数组 +$resource->fetchFields(); +// 获取列数 +$resource->getFieldCount(); +// 获取影响行数 +$resource->affectedRows(); +// 获取 SQL 语句 +$resource->getSql(); +// 获取连接对象 +$resource->getConnection(); +// 关闭资源(一般不需要手动关闭,变量销毁时会自动释放) +$resource->close(); +``` + +**参数绑定:** + +```php +// 查询 +$stmt = $connection->prepare($sql); // 支持查询和插入,参数用?占位 +// 绑定参数方法1 +$stmt->bindParams( + // [字段类型, 值] + [TDengine\TSDB_DATA_TYPE_TIMESTAMP, $time1], + [TDengine\TSDB_DATA_TYPE_INT, 36], + [TDengine\TSDB_DATA_TYPE_FLOAT, 44.0], +); +// 绑定参数方法2 +$stmt->bindParams([ + // ['type' => 字段类型, 'value' => 值] + ['type' => TDengine\TSDB_DATA_TYPE_TIMESTAMP, 'value' => $time2], + ['type' => TDengine\TSDB_DATA_TYPE_INT, 'value' => 36], + ['type' => TDengine\TSDB_DATA_TYPE_FLOAT, 'value' => 44.0], +]); +// 执行 SQL,返回 Resource,使用方法同 query() 返回值 +$resource = $stmt->execute(); +// 获取 SQL 语句 +$stmt->getSql(); +// 获取连接对象 +$stmt->getConnection(); +// 关闭(一般不需要手动关闭,变量销毁时会自动释放) +$stmt->close(); +``` + +**字段类型:** + +| 参数名称 | 说明 | +| ------------ | ------------ +| `TDengine\TSDB_DATA_TYPE_NULL` | null | +| `TDengine\TSDB_DATA_TYPE_BOOL` | bool | +| `TDengine\TSDB_DATA_TYPE_TINYINT` | tinyint | +| `TDengine\TSDB_DATA_TYPE_SMALLINT` | smallint | +| `TDengine\TSDB_DATA_TYPE_INT` | int | +| `TDengine\TSDB_DATA_TYPE_BIGINT` | bigint | +| `TDengine\TSDB_DATA_TYPE_FLOAT` | float | +| `TDengine\TSDB_DATA_TYPE_DOUBLE` | double | +| `TDengine\TSDB_DATA_TYPE_BINARY` | binary | +| `TDengine\TSDB_DATA_TYPE_TIMESTAMP` | timestamp | +| `TDengine\TSDB_DATA_TYPE_NCHAR` | nchar | +| `TDengine\TSDB_DATA_TYPE_UTINYINT` | utinyint | +| `TDengine\TSDB_DATA_TYPE_USMALLINT` | usmallint | +| `TDengine\TSDB_DATA_TYPE_UINT` | uint | +| `TDengine\TSDB_DATA_TYPE_UBIGINT` | ubigint | + +### 在框架中使用 + +- imi 框架请看:[imi-tdengine](https://github.com/imiphp/imi-tdengine) + +## tdengine-restful-connector + +封装了 TDEngine 的 RESTful 接口,可以使用 PHP 轻松地操作 TDEngine 的数据插入和查询了。 + +此项目支持在 PHP >= 7.0 的项目中使用。 + +支持在 ThinkPHP、Laravel、Swoole、imi 等项目中使用 + +在 Swoole 环境中支持协程化,不会阻塞! + +Github: + +### 安装 + +`composer require yurunsoft/tdengine-restful-connector` + +### 使用 + +**使用连接管理器:** + +```php +// 增加名称为 test 的连接配置 +\Yurun\TDEngine\TDEngineManager::setClientConfig('test', new \Yurun\TDEngine\ClientConfig([ + // 'host' => '127.0.0.1', + // 'hostName' => '', + // 'port' => 6041, + // 'user' => 'root', + // 'password' => 'taosdata', + // 'db' => 'database' + // 'ssl' => false, + // 'timestampFormat' => \Yurun\TDEngine\Constants\TimeStampFormat::LOCAL_STRING, + // 'keepAlive' => true, +])); +// 设置默认数据库为test +\Yurun\TDEngine\TDEngineManager::setDefaultClientName('test'); +// 获取客户端对象(\Yurun\TDEngine\Client) +$client = \Yurun\TDEngine\TDEngineManager::getClient(); +``` + +**直接 new 客户端:** + +```php +$client = new \Yurun\TDEngine\Client(new \Yurun\TDEngine\ClientConfig([ + // 'host' => '127.0.0.1', + // 'hostName' => '', + // 'port' => 6041, + // 'user' => 'root', + // 'password' => 'taosdata', + // 'db' => 'database' + // 'ssl' => false, + // 'timestampFormat' => \Yurun\TDEngine\Constants\TimeStampFormat::LOCAL_STRING, + // 'keepAlive' => true, +])); + +// 通过 sql 方法执行 sql 语句 +var_dump($client->sql('create database if not exists db_test')); +var_dump($client->sql('show databases')); +var_dump($client->sql('create table if not exists db_test.tb (ts timestamp, temperature int, humidity float)')); +var_dump($client->sql(sprintf('insert into db_test.tb values(%s,%s,%s)', time() * 1000, mt_rand(), mt_rand() / mt_rand()))); + +$result = $client->sql('select * from db_test.tb'); + +$result->getResponse(); // 获取接口原始返回数据 + +// 获取列数据 +foreach ($result->getColumns() as $column) +{ + $column->getName(); // 列名 + $column->getType(); // 列类型值 + $column->getTypeName(); // 列类型名称 + $column->getLength(); // 类型长度 +} + +// 获取数据 +foreach ($result->getData() as $row) +{ + echo $row['列名']; // 经过处理,可以直接使用列名获取指定列数据 +} + +$result->getStatus(); // 告知操作结果是成功还是失败;同接口返回格式 + +$result->getHead(); // 表的定义,如果不返回结果集,则仅有一列“affected_rows”。(从 2.0.17 版本开始,建议不要依赖 head 返回值来判断数据列类型,而推荐使用 column_meta。在未来版本中,有可能会从返回值中去掉 head 这一项。);同接口返回格式 + +$result->getRow(); // 表明总共多少行数据;同接口返回格式 +``` diff --git a/documentation20/cn/08.connector/docs.md b/documentation20/cn/08.connector/docs.md index b3ff66765f39636a110bff38c1a11a934982fa52..1051933cce100065a81aea01e112e6d75f40f48e 100644 --- a/documentation20/cn/08.connector/docs.md +++ b/documentation20/cn/08.connector/docs.md @@ -486,26 +486,6 @@ int main() { } ``` -### 连续查询接口 - -TDengine 提供时间驱动的实时流式计算 API。可以每隔一指定的时间段,对一张或多张数据库的表(数据流)进行各种实时聚合计算操作。操作简单,仅有打开、关闭流的 API。具体如下: - -- `TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sql, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), int64_t stime, void *param, void (*callback)(void *))` - - 该 API 用来创建数据流,其中: - * taos:已经建立好的数据库连接。 - * sql:SQL查询语句(仅能使用查询语句)。 - * fp:用户定义的回调函数指针,每次流式计算完成后,TDengine将查询的结果(TAOS_ROW)、查询状态(TAOS_RES)、用户定义参数(PARAM)传递给回调函数,在回调函数内,用户可以使用taos_num_fields获取结果集列数,taos_fetch_fields获取结果集每列数据的类型。 - * stime:是流式计算开始的时间。如果是“64位整数最小值”,表示从现在开始;如果不为“64位整数最小值”,表示从指定的时间开始计算(UTC时间从1970/1/1算起的毫秒数)。 - * param:是应用提供的用于回调的一个参数,回调时,提供给应用。 - * callback: 第二个回调函数,会在连续查询自动停止时被调用。 - - 返回值为 NULL,表示创建失败;返回值不为空,表示成功。 - -- `void taos_close_stream (TAOS_STREAM *tstr)` - - 关闭数据流,其中提供的参数是 taos_open_stream 的返回值。用户停止流式计算的时候,务必关闭该数据流。 - ### 数据订阅接口 订阅 API 目前支持订阅一张或多张表,并通过定期轮询的方式不断获取写入表中的最新数据。 diff --git a/documentation20/cn/09.connections/docs.md b/documentation20/cn/09.connections/docs.md index 44a56e47cabc7fdf364ead27f3fd5dacfd77713a..b6459957ead6cbde9933571d9d9399e34cd14999 100644 --- a/documentation20/cn/09.connections/docs.md +++ b/documentation20/cn/09.connections/docs.md @@ -93,3 +93,94 @@ GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=tdengine-datasource 在 2.3.3.0 及以上版本,您可以导入 TDinsight Dashboard (Grafana Dashboard ID: [15167](https://grafana.com/grafana/dashboards/15167)) 作为 TDengine 集群的监控可视化工具。安装和使用说明请见 [TDinsight 用户手册](https://www.taosdata.com/cn/documentation/tools/insight)。 +## Matlab + +MatLab 可以通过安装包内提供的 JDBC Driver 直接连接到 TDengine 获取数据到本地工作空间。 + +### MatLab 的 JDBC 接口适配 + +MatLab 的适配有下面几个步骤,下面以 Windows10 上适配 MatLab2017a 为例: + +- 从 (maven.org)[https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/] 或其他 maven 镜像网站下载 TDengine JDBC 驱动程序 JDBCDriver-x.x.x-dist.jar 拷贝到 ${matlab_root}\MATLAB\R2017a\java\jar\toolbox +- 将 TDengine 安装包内的 taos.lib 文件拷贝至${matlab_ root _dir}\MATLAB\R2017a\lib\win64 +- 将新添加的驱动 jar 包加入 MatLab 的 classpath。在 ${matlab_ root _dir}\MATLAB\R2017a\toolbox\local\classpath.txt 文件中添加下面一行 + +``` +$matlabroot/java/jar/toolbox/JDBCDriver-x.x.x-dist.jar +``` + +- 在${user_home}\AppData\Roaming\MathWorks\MATLAB\R2017a\下添加一个文件 javalibrarypath.txt, 并在该文件中添加 taos.dll 的路径,比如您的 taos.dll 是在安装时拷贝到了 C:\Windows\System32 下,那么就应该在 javalibrarypath.txt 中添加如下一行: + +``` +C:\Windows\System32 +``` + +### 在 MatLab 中连接 TDengine 获取数据 + +在成功进行了上述配置后,打开 MatLab。 + +- 创建一个连接: + +```matlab +conn = database(‘db’, ‘root’, ‘taosdata’, ‘com.taosdata.jdbc.TSDBDriver’, ‘jdbc:TSDB://127.0.0.1:0/’) +``` + +- 执行一次查询: + +```matlab +sql0 = [‘select * from tb’] +data = select(conn, sql0); +``` + +- 插入一条记录: + +```matlab +sql1 = [‘insert into tb values (now, 1)’] +exec(conn, sql1) +``` + +更多例子细节请参考安装包内 examples\Matlab\TDengineDemo.m 文件。 + +## R + +R 语言支持通过 JDBC 接口来连接 TDengine 数据库。首先需要安装 R 语言的 JDBC 包,下载 RJDBC 的时候,还会自动下载 RJDBC 依赖的 DBI 和 rJava 这两个package。启动 R 语言环境,然后执行以下命令安装 R 语言的 JDBC 支持库: + +```R +install.packages('RJDBC', repos='http://cran.us.r-project.org') +``` + +安装完成以后,通过执行`library()`命令加载 DBI、rJava 和 _RJDBC_ 包: + +```R +library('DBI') +library('rJava') +library('RJDBC') +``` + +然后加载 TDengine 的 JDBC 驱动: + +```R +drv<-JDBC("com.taosdata.jdbc.TSDBDriver","JDBCDriver-2.0.0-dist.jar", identifier.quote="\"") +``` + +如果执行成功,不会出现任何错误信息。之后通过以下命令尝试连接数据库: + +```R +conn<-dbConnect(drv,"jdbc:TSDB://127.0.0.1:0/?user=root&password=taosdata","root","taosdata") +``` + +也可以使用 RESTful 来连接 TDengine。 + +```R +conn<-dbConnect(drv,"jdbc:TAOS-RS://127.0.0.1:6041/test?user=root&password=taosdata","root","taosdata") +``` + +注意将上述命令中的IP地址替换成正确的IP地址。如果没有任务错误的信息,则连接数据库成功,否则需要根据错误提示调整连接的命令。TDengine 支持以下的 _RJDBC_ 包中函数: + +- dbWriteTable(conn, "test", iris, overwrite=FALSE, append=TRUE):将数据框 iris 写入表 test 中,overwrite 必须设置为 false,append 必须设为 TRUE,且数据框 iris 要与表 test 的结构一致。 +- dbGetQuery(conn, "select count(*) from test"):查询语句 +- dbSendUpdate(conn, "use db"):执行任何非查询 SQL 语句。例如 dbSendUpdate(conn, "use db"), 写入数据 dbSendUpdate(conn, "insert into t1 values(now, 99)") 等。 +- dbReadTable(conn, "test"):读取表 test 中数据 +- dbDisconnect(conn):关闭连接 +- dbRemoveTable(conn, "test"):删除表 test + diff --git a/documentation20/cn/11.administrator/docs.md b/documentation20/cn/11.administrator/docs.md index 2339ba20f3126db31b7c879e56adb67c6cb9ef33..50b22c726251b660741cc2882eb36aa652412e18 100644 --- a/documentation20/cn/11.administrator/docs.md +++ b/documentation20/cn/11.administrator/docs.md @@ -582,37 +582,7 @@ taosd -C | 取值范围 | 1-3 | | 缺省值 | 1 | -47. **mqttHostName** - - | 属性 | 说明 | - |---|---| - | 内部配置 | Yes | - | 适用范围 | 仅服务端适用 | - | 含义 | mqtt uri | - | 缺省值 | | - | 补充说明 | mqtt://username:password@hostname:1883/taos/ | - -48. **mqttPort** - - | 属性 | 说明 | - |---|---| - | 内部配置 | Yes | - | 适用范围 | 仅服务端适用 | - | 含义 | mqtt client name | - | 缺省值 | | - | 补充说明 | 1883 | - -49. **mqttTopic** - - | 属性 | 说明 | - |---|---| - | 内部配置 | Yes | - | 适用范围 | 仅服务端适用 | - | 含义 | | - | 缺省值 | | - | 补充说明 | /test | - -50. **compressMsgSize** +47. **compressMsgSize** | 属性 | 说明 | |---|---| @@ -623,7 +593,7 @@ taosd -C | 取值范围 | `0 `表示对所有的消息均进行压缩 >0: 超过该值的消息才进行压缩 -1: 不压缩 | | 缺省值 | -1 | -51. **maxSQLLength** +48. **maxSQLLength** | 属性 | 说明 | |---|---| @@ -634,7 +604,7 @@ taosd -C | 取值范围 | 65480-1048576 | | 缺省值 | 1048576 | -52. **maxNumOfOrderedRes** +49. **maxNumOfOrderedRes** | 属性 | 说明 | |---|---| @@ -643,7 +613,7 @@ taosd -C | 含义 | 支持超级表时间排序允许的最多记录数限制 | | 缺省值 | 10 万 | -53. **timezone** +50. **timezone** | 属性 | 说明 | |---|---| @@ -652,7 +622,7 @@ taosd -C | 含义 | 时区 | | 缺省值 | 从系统中动态获取当前的时区设置 | -54. **locale** +51. **locale** | 属性 | 说明 | |---|---| @@ -661,7 +631,7 @@ taosd -C | 含义 | 系统区位信息及编码格式 | | 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 | -55. **charset** +52. **charset** | 属性 | 说明 | |---|---| @@ -670,7 +640,7 @@ taosd -C | 含义 | 字符集编码 | | 缺省值 | 系统中动态获取,如果自动获取失败,需要用户在配置文件设置或通过 API 设置 | -56. **maxShellConns** +53. **maxShellConns** | 属性 | 说明 | |---|---| @@ -680,7 +650,7 @@ taosd -C | 取值范围 | 10-50000000 | | 缺省值 | 5000 | -57. **maxConnections** +54. **maxConnections** | 属性 | 说明 | |---|---| @@ -691,7 +661,7 @@ taosd -C | 缺省值 | 5000 | | 补充说明 | 实际测试下来,如果默认没有配,选 50 个 worker thread 会产生 Network unavailable | -58. **minimalLogDirGB** +55. **minimalLogDirGB** | 属性 | 说明 | |---|---| @@ -699,9 +669,9 @@ taosd -C | 适用范围 | 服务端和客户端均适用 | | 含义 | 当日志文件夹的磁盘大小小于该值时,停止写日志 | | 单位| GB | - | 缺省值 | 0.1 | + | 缺省值 | 1.0 | -59. **minimalTmpDirGB** +56. **minimalTmpDirGB** | 属性 | 说明 | |---|---| @@ -709,9 +679,9 @@ taosd -C | 适用范围 | 服务端和客户端均适用 | | 含义 | 当日志文件夹的磁盘大小小于该值时,停止写临时文件 | | 单位| GB | - | 缺省值 | 0.1 | + | 缺省值 | 1.0 | -60. **minimalDataDirGB** +57. **minimalDataDirGB** | 属性 | 说明 | |---|---| @@ -719,9 +689,9 @@ taosd -C | 适用范围 | 仅服务端适用 | | 含义 | 当日志文件夹的磁盘大小小于该值时,停止写时序数据 | | 单位| GB | - | 缺省值 | 0.1 | + | 缺省值 | 2.0 | -61. **mnodeEqualVnodeNum** +58. **mnodeEqualVnodeNum** | 属性 | 说明 | |---|---| @@ -730,7 +700,7 @@ taosd -C | 含义 | 一个 mnode 等同于 vnode 消耗的个数 | | 缺省值 | 4 | -62. **http** +59. **http** | 属性 | 说明 | |---|---| @@ -740,17 +710,7 @@ taosd -C | 取值范围 | 0:关闭 http 服务, 1:激活 http 服务。 | | 缺省值 | 1 | -63. **mqtt** - - | 属性 | 说明 | - |---|---| - | 内部配置 | Yes | - | 适用范围 | 仅服务端适用 | - | 含义 | 服务器内部的 mqtt 服务开关。 | - | 取值范围 | 0:关闭 mqtt 服务, 1:激活 mqtt 服务。 | - | 缺省值 | 0 | - -64. **monitor** +60. **monitor** | 属性 | 说明 | |---|---| @@ -760,7 +720,7 @@ taosd -C | 取值范围 | 0:关闭监控服务, 1:激活监控服务。 | | 缺省值 | 0 | -65. **httpEnableRecordSql** +61. **httpEnableRecordSql** | 属性 | 说明 | |---|---| @@ -770,7 +730,7 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 生成的文件(httpnote.0/httpnote.1),与服务端日志所在目录相同。 | -66. **httpMaxThreads** +62. **httpMaxThreads** | 属性 | 说明 | |---|---| @@ -779,7 +739,7 @@ taosd -C | 含义 | RESTFul 接口的线程数。taosAdapter 配置或有不同,请参考相应[文档](https://www.taosdata.com/cn/documentation/tools/adapter)。 | | 缺省值 | 2 | -67. **telegrafUseFieldNum** +63. **telegrafUseFieldNum** | 属性 | 说明 | |---|---| @@ -788,7 +748,7 @@ taosd -C | 含义 | | | 缺省值 | | -68. **restfulRowLimit** +64. **restfulRowLimit** | 属性 | 说明 | |---|---| @@ -798,7 +758,7 @@ taosd -C | 缺省值 | 10240 | | 补充说明 | 最大 10,000,000 | -69. **numOfLogLines** +65. **numOfLogLines** | 属性 | 说明 | |---|---| @@ -807,7 +767,7 @@ taosd -C | 含义 | 单个日志文件允许的最大行数。 | | 缺省值 | 10,000,000 | -70. **asyncLog** +66. **asyncLog** | 属性 | 说明 | |---|---| @@ -817,7 +777,7 @@ taosd -C | 取值范围 | 0:同步、1:异步 | | 缺省值 | 1 | -71. **logKeepDays** +67. **logKeepDays** | 属性 | 说明 | |---|---| @@ -828,7 +788,7 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 大于 0 时,日志文件会被重命名为 taosdlog.xxx,其中 xxx 为日志文件最后修改的时间戳。 | -72. **debugFlag** +68. **debugFlag** | 属性 | 说明 | |---|---| @@ -838,7 +798,7 @@ taosd -C | 取值范围 | 131(输出错误和警告日志),135(输出错误、警告和调试日志),143(输出错误、警告、调试和跟踪日志) | | 缺省值 | 131 或 135(不同模块有不同的默认值) | -73. **mDebugFlag** +69. **mDebugFlag** | 属性 | 说明 | |---|---| @@ -848,7 +808,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | 135 | -74. **dDebugFlag** +70. **dDebugFlag** | 属性 | 说明 | |---|---| @@ -858,7 +818,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | 135 | -75. **sDebugFlag** +71. **sDebugFlag** | 属性 | 说明 | |---|---| @@ -868,7 +828,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | 135 | -76. **wDebugFlag** +72. **wDebugFlag** | 属性 | 说明 | |---|---| @@ -878,7 +838,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | 135 | -77. **sdbDebugFlag** +73. **sdbDebugFlag** | 属性 | 说明 | |---|---| @@ -888,7 +848,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | 135 | -78. **rpcDebugFlag** +74. **rpcDebugFlag** | 属性 | 说明 | |---|---| @@ -898,7 +858,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -79. **tmrDebugFlag** +75. **tmrDebugFlag** | 属性 | 说明 | |---|---| @@ -908,7 +868,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -80. **cDebugFlag** +76. **cDebugFlag** | 属性 | 说明 | |---|---| @@ -918,7 +878,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -81. **jniDebugFlag** +77. **jniDebugFlag** | 属性 | 说明 | |---|---| @@ -928,7 +888,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -82. **odbcDebugFlag** +78. **odbcDebugFlag** | 属性 | 说明 | |---|---| @@ -938,7 +898,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -83. **uDebugFlag** +79. **uDebugFlag** | 属性 | 说明 | |---|---| @@ -948,7 +908,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -84. **httpDebugFlag** +80. **httpDebugFlag** | 属性 | 说明 | |---|---| @@ -958,17 +918,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -85. **mqttDebugFlag** - - | 属性 | 说明 | - |---|---| - | 内部配置 | No | - | 适用范围 | 仅服务端适用 | - | 含义 | mqtt 模块的日志开关 | - | 取值范围 | 同上 | - | 缺省值 | | - -86. **monitorDebugFlag** +81. **monitorDebugFlag** | 属性 | 说明 | |---|---| @@ -978,7 +928,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -87. **qDebugFlag** +82. **qDebugFlag** | 属性 | 说明 | |---|---| @@ -988,7 +938,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -88. **vDebugFlag** +83. **vDebugFlag** | 属性 | 说明 | |---|---| @@ -998,7 +948,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -89. **tsdbDebugFlag** +84. **tsdbDebugFlag** | 属性 | 说明 | |---|---| @@ -1008,7 +958,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -90. **cqDebugFlag** +85. **cqDebugFlag** | 属性 | 说明 | |---|---| @@ -1018,7 +968,7 @@ taosd -C | 取值范围 | 同上 | | 缺省值 | | -91. **tscEnableRecordSql** +86. **tscEnableRecordSql** | 属性 | 说明 | |---|---| @@ -1029,7 +979,7 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 生成的文件(tscnote-xxxx.0/tscnote-xxx.1,xxxx 是 pid),与客户端日志所在目录相同。 | -92. **enableCoreFile** +87. **enableCoreFile** | 属性 | 说明 | |---|---| @@ -1040,7 +990,7 @@ taosd -C | 缺省值 | 1 | | 补充说明 | 不同的启动方式,生成 core 文件的目录如下:1、systemctl start taosd 启动:生成的 core 在根目录下
2、手动启动,就在 taosd 执行目录下。 | -93. **gitinfo** +88. **gitinfo** | 属性 | 说明 | |---|---| @@ -1050,7 +1000,7 @@ taosd -C | 取值范围 | 1 | | 缺省值 | | -94. **gitinfoofInternal** +89. **gitinfoofInternal** | 属性 | 说明 | |---|---| @@ -1060,7 +1010,7 @@ taosd -C | 取值范围 | 2 | | 缺省值 | | -95. **Buildinfo** +90. **Buildinfo** | 属性 | 说明 | |---|---| @@ -1070,7 +1020,7 @@ taosd -C | 取值范围 | 3 | | 缺省值 | | -96. **version** +91. **version** | 属性 | 说明 | |---|---| @@ -1080,7 +1030,7 @@ taosd -C | 取值范围 | 4 | | 缺省值 | | -97. **maxBinaryDisplayWidth** +92. **maxBinaryDisplayWidth** | 属性 | 说明 | |---|---| @@ -1091,7 +1041,7 @@ taosd -C | 缺省值 | 30 | | 补充说明 | 实际上限按以下规则计算:如果字段值的长度大于 maxBinaryDisplayWidth,则显示上限为 **字段名长度** 和 **maxBinaryDisplayWidth** 的较大者。
否则,上限为 **字段名长度** 和 **字段值长度** 的较大者。
可在 shell 中通过命令 set max_binary_display_width nn 动态修改此选项 | -98. **queryBufferSize** +93. **queryBufferSize** | 属性 | 说明 | |---|---| @@ -1102,7 +1052,7 @@ taosd -C | 缺省值 | | | 补充说明 | 计算规则可以根据实际应用可能的最大并发数和表的数字相乘,再乘 170 。
(2.0.15 以前的版本中,此参数的单位是字节) | -99. **ratioOfQueryCores** +94. **ratioOfQueryCores** | 属性 | 说明 | |---|---| @@ -1112,7 +1062,7 @@ taosd -C | 缺省值 | | | 补充说明 | 最小值 0 表示只有 1 个查询线程
最大值 2 表示最大建立 2 倍 CPU 核数的查询线程。
默认为 1,表示最大和 CPU 核数相等的查询线程。
该值可以为小数,即 0.5 表示最大建立 CPU 核数一半的查询线程。 | -100. **update** +95. **update** | 属性 | 说明 | |---|---| @@ -1123,7 +1073,7 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 2.0.8.0 版本之前,不支持此参数。 | -101. **cacheLast** +96. **cacheLast** | 属性 | 说明 | |---|---| @@ -1134,7 +1084,7 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 2.1.2.0 版本之前、2.0.20.7 版本之前在 taos.cfg 文件中不支持此参数。 | -102. **numOfCommitThreads** +97. **numOfCommitThreads** | 属性 | 说明 | |---|---| @@ -1143,7 +1093,7 @@ taosd -C | 含义 | 设置写入线程的最大数量 | | 缺省值 | | -103. **maxWildCardsLength** +98. **maxWildCardsLength** | 属性 | 说明 | |---|---| @@ -1155,7 +1105,7 @@ taosd -C | 缺省值 | 100 | | 补充说明 | 2.1.6.1 版本新增。 | -104. **compressColData** +99. **compressColData** | 属性 | 说明 | |---|---| @@ -1167,7 +1117,7 @@ taosd -C | 缺省值 | -1 | | 补充说明 | 2.3.0.0 版本新增。 | -105. **tsdbMetaCompactRatio** +100. **tsdbMetaCompactRatio** | 属性 | 说明 | |---|---| @@ -1177,7 +1127,7 @@ taosd -C | 取值范围 | 0:不开启,[1-100]:冗余数据比例 | | 缺省值 | 0 | -106. **rpcForceTcp** +101. **rpcForceTcp** | 属性 | 说明 | |---|---| @@ -1188,7 +1138,7 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 在网络比较差的环境中,建议开启。
2.0 版本新增。 | -107. **maxNumOfDistinctRes** +102. **maxNumOfDistinctRes** | 属性 | 说明 | |---|---| @@ -1199,7 +1149,7 @@ taosd -C | 缺省值 | 10 万 | | 补充说明 | 2.3 版本新增。 | -108. **clientMerge** +103. **clientMerge** | 属性 | 说明 | |---|---| @@ -1210,7 +1160,7 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 2.3 版本新增。 | -109. **httpDBNameMandatory** +104. **httpDBNameMandatory** | 属性 | 说明 | |---|---| @@ -1221,7 +1171,7 @@ taosd -C | 缺省值 | 0 | | 补充说明 | 2.3 版本新增。 | -110. **maxRegexStringLen** +105. **maxRegexStringLen** | 属性 | 说明 | |---|---| @@ -1232,7 +1182,7 @@ taosd -C | 缺省值 | 128 | | 补充说明 | 2.3 版本新增。 | -111. **lossyColumns** +106. **lossyColumns** | 属性 | 说明 | |---|---| @@ -1243,7 +1193,7 @@ taosd -C | 缺省值 | 默认为空字符串,关闭有损压缩 | | 补充说明 | 2.4.0.10版本新增。| -112. **fPrecision** +107. **fPrecision** | 属性 | 说明 | |---|---| @@ -1254,7 +1204,7 @@ taosd -C | 缺省值 | 0.00000001(1E-8)| | 补充说明 | 2.4.0.10版本新增。| -113. **dPrecision** +108. **dPrecision** | 属性 | 说明 | |---|---| @@ -1265,7 +1215,7 @@ taosd -C | 缺省值 | 0.0000000000000001(1E-16)| | 补充说明 | 2.4.0.10版本新增。| -114. **maxRange** +109. **maxRange** | 属性 | 说明 | |---|---| @@ -1276,7 +1226,7 @@ taosd -C | 缺省值 | 自动预测 | | 补充说明 | 2.4.0.10版本新增。| -115. **Range** +110. **Range** | 属性 | 说明 | |---|---| @@ -1324,7 +1274,7 @@ taosd -C | create time | | | | | ntables | | | | | vgroups | | | | -| replica | **YES** | 在线 dnode 数目为 1:1-1;2:1-2;>=3:1-3 | ALTER DATABASE REPLICA *n* | +| replica | **YES** | 在线 dnode 数目为:
1:1-1;
2:1-2;
>=3:1-3 | ALTER DATABASE REPLICA *n* | | quorum | **YES** | 1-2 | ALTER DATABASE QUORUM *n* | | days | | | | | keep | **YES** | days-365000 | ALTER DATABASE KEEP *n* | diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index 329a51d80f41530bb5e876554d1ab1fcd83a486f..2fd86b1c9e55230f5497534ee909d587afd52626 100755 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -807,7 +807,7 @@ Query OK, 1 row(s) in set (0.001091s) **语法** - WHERE (tag|tbname) **match/MATCH/nmatch/NMATCH** *regex* + WHERE (column|tag|tbname) **match/MATCH/nmatch/NMATCH** *regex* match/MATCH 匹配正则表达式 @@ -815,7 +815,7 @@ Query OK, 1 row(s) in set (0.001091s) **正则表达式规范** - 确保使用的正则表达式符合POSIX的规范,具体规范内容可参见[Regular Expressions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html) + 确保使用的正则表达式符合POSIX的规范,具体规范内容可参见 [Regular Expressions](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html),目前 TDengine 使用的是 glibc 里面的 regex 实现,使用正则表达式进行 match 时是区分大小写的 **正则表达使用示例** @@ -848,7 +848,7 @@ Query OK, 1 row(s) in set (0.001091s) **使用限制** - 只能针对表名(即 tbname 筛选)、binary/nchar类型标签值进行正则表达式过滤,不支持普通列的过滤。 + 只能针对表名 (tbname) 以及binary类型的普通列或标签进行正则表达式过滤。 正则匹配字符串长度不能超过 128 字节。可以通过参数 *maxRegexStringLen* 设置和调整最大允许的正则匹配字符串,该参数是客户端配置参数,需要重启客户端才能生效。 @@ -1128,6 +1128,8 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 返回结果数据类型:同应用的字段。 应用字段:适合于除时间主列外的任何类型字段。 + + 支持的版本:2.6.0.x 之后的版本。 说明:由于返回数据量未知,考虑到内存因素,为了函数可以正常返回结果,建议不重复的数据量在10万级别,否则会报错。 @@ -1510,27 +1512,27 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 7)INTERP的插值结果不受ORDER BY timestamp的影响,ORDER BY timestamp只影响输出结果的排序。 - SQL示例: + SQL示例(基于文档中广泛使用的电表 schema ) 1) 单点线性插值 ```mysql - taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:40:00','2017-7-14 18:40:00') FILL(LINEAR); + taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:40:00','2017-7-14 18:40:00') FILL(LINEAR); ``` 2) 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行取值(不插值) ```mysql - taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s); + taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s); ``` 3) 在2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行线性插值 ```mysql - taos> SELECT INTERP(*) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); + taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); ``` 4.在所有时间范围内每隔5秒钟进行向后插值 ```mysql - taos> SELECT INTERP(*) FROM t1 EVERY(5s) FILL(NEXT); + taos> SELECT INTERP(current) FROM t1 EVERY(5s) FILL(NEXT); ``` 5.根据2017-07-14 17:00:00到2017-07-14 20:00:00间的数据进行从2017-07-14 18:00:00到2017-07-14 19:00:00间每隔5秒钟进行线性插值 ```mysql - taos> SELECT INTERP(*) FROM t1 where ts >= '2017-07-14 17:00:00' and ts <= '2017-07-14 20:00:00' RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); + taos> SELECT INTERP(current) FROM t1 where ts >= '2017-07-14 17:00:00' and ts <= '2017-07-14 20:00:00' RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR); ``` @@ -1776,6 +1778,59 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 功能说明:获得指定列的四舍五入的结果。 其他使用说明参见CEIL函数描述。 +- **CSUM** + ```sql + SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` + + 功能说明:累加和(Cumulative sum),输出行与输入行数相同。 + + 返回结果类型: 输入列如果是整数类型返回值为长整型 (int64_t),浮点数返回值为双精度浮点数(Double)。无符号整数类型返回值为无符号长整型(uint64_t)。 返回结果中同时带有每行记录对应的时间戳。 + + 适用数据类型:不能应用在 timestamp、binary、nchar、bool 类型字段上;在超级表查询中使用时,不能应用在标签之上。 + + 嵌套子查询支持: 适用于内层查询和外层查询。 + + 补充说明: 不支持 +、-、*、/ 运算,如 csum(col1) + csum(col2)。只能与聚合(Aggregation)函数一起使用。 该函数可以应用在普通表和超级表上。 使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 + + 支持版本: 从2.3.0.x开始支持 + +- **MAVG** + ```sql + SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] + ``` + + 功能说明: 计算连续 k 个值的移动平均数(moving average)。如果输入行数小于 k,则无结果输出。参数 k 的合法输入范围是 1≤ k ≤ 1000。 + + 返回结果类型: 返回双精度浮点数类型。 + + 适用数据类型: 不能应用在 timestamp、binary、nchar、bool 类型上;在超级表查询中使用时,不能应用在标签之上。 + + 嵌套子查询支持: 适用于内层查询和外层查询。 + + 补充说明: 不支持 +、-、*、/ 运算,如 mavg(col1, k1) + mavg(col2, k1); 只能与普通列,选择(Selection)、投影(Projection)函数一起使用,不能与聚合(Aggregation)函数一起使用;该函数可以应用在普通表和超级表上;使用在超级表上的时候,需要搭配 Group by tbname使用,将结果强制规约到单个时间线。 + + 支持版本: 从2.3.0.x开始支持 + +- **SAMPLE** + ```sql + SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] + ``` + + 功能说明: 获取数据的 k 个采样值。参数 k 的合法输入范围是 1≤ k ≤ 1000。 + + 返回结果类型: 同原始数据类型, 返回结果中带有该行记录的时间戳。 + + 适用数据类型: 在超级表查询中使用时,不能应用在标签之上。 + + 嵌套子查询支持: 适用于内层查询和外层查询。 + + 补充说明: 不能参与表达式计算;该函数可以应用在普通表和超级表上;使用在超级表上的时候,需要搭配 Group by tbname 使用,将结果强制规约到单个时间线。 + + 支持版本: 从2.3.0.x开始支持 + + + - **ASIN** ```mysql SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] @@ -1794,6 +1849,8 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 该函数可以应用在普通表和超级表上。 + 版本2.6.0.x后支持 + - **ACOS** ```mysql SELECT ACOS(field_name) FROM { tb_name | stb_name } [WHERE clause] @@ -1812,6 +1869,8 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 该函数可以应用在普通表和超级表上。 + 版本2.6.0.x后支持 + - **ATAN** ```mysql SELECT ATAN(field_name) FROM { tb_name | stb_name } [WHERE clause] @@ -2146,7 +2205,7 @@ TDengine支持针对数据的聚合查询。提供支持的聚合和选择函数 说明: 如果输入值为NULL,输出值为NULL。 - 输入参数pos可以为正数,也可以为负数。如果pos是正数,表示从开始往后抽取子串。如果pos为负数,表示从结尾往前抽取字符串。如果输入参数len被忽略,返回的子串包含从pos开始的整个字串。 + 输入参数pos可以为正数,也可以为负数。如果pos是正数,表示开始位置从字符串开头正数计算。如果pos为负数,表示开始位置从字符串结尾倒数计算。如果输入参数len被忽略,返回的子串包含从pos开始的整个字串。 该函数可以应用在普通表和超级表上。 该函数适用于内层查询和外层查询。 版本2.6.0.x后支持 @@ -2728,7 +2787,7 @@ IS NOT NULL 支持所有类型的列。不为空的表达式为 <>"",仅对非 TDengine 中的表(列)名命名规则如下: 只能由字母、数字、下划线构成,数字不能在首位,长度不能超过192字节,不区分大小写。这里表名称不包括数据库名的前缀和分隔符。 -转移后表(列)名规则: +转义后表(列)名规则: 为了兼容支持更多形式的表(列)名,TDengine 引入新的转义符 "`"。可用让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查,转义符不计入表名称的长度。 转义后的表(列)名同样受到长度限制要求,且长度计算的时候不计算转义符。使用转义字符以后,不再对转义字符中的内容进行大小写统一。 diff --git a/documentation20/cn/14.devops/02.collectd/docs.md b/documentation20/cn/14.devops/02.collectd/docs.md index a21c82a88a8264c8cf03dec0aae63fb55d980cb8..7c02620c4caee338d87989a380d0fcbbabc27969 100644 --- a/documentation20/cn/14.devops/02.collectd/docs.md +++ b/documentation20/cn/14.devops/02.collectd/docs.md @@ -33,7 +33,7 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ### 安装 TDengine -从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 +从涛思数据官网[下载](http://taosdata.com/cn/all-downloads/)页面下载最新 TDengine-server 2.3.0.0 或以上版本安装。 ## 数据链路设置 diff --git a/documentation20/en/00.index/docs.md b/documentation20/en/00.index/docs.md index 9870f0f25e4b73458357e35fa10d6a8e3575c5fa..ae7818bc7aa13b3cbb6e62a51889c80704d49233 100644 --- a/documentation20/en/00.index/docs.md +++ b/documentation20/en/00.index/docs.md @@ -98,6 +98,7 @@ TDengine is a highly efficient platform to store, query, and analyze time-series - [IDEA Database](https://www.taosdata.com/blog/2020/08/27/1767.html): use TDengine visually through IDEA Database Management Tool - [TDengineGUI](https://github.com/skye0207/TDengineGUI): a TDengine management tool with Graphical User Interface - [DataX](https://github.com/taosdata/datax): a data immigration tool with TDengine supported +- [Awesome TDengine](https://github.com/taosdata/awesome-tdengine):A curated list of awesome things related to TDengine ## [Installation and Management of TDengine Cluster](/cluster) diff --git a/documentation20/en/08.connector/01.java/docs.md b/documentation20/en/08.connector/01.java/docs.md index df65e06ccac6b7482a9890c0cf7f33cc40eac859..a60d1799dff36fdc651217456067cc2b555ff81f 100644 --- a/documentation20/en/08.connector/01.java/docs.md +++ b/documentation20/en/08.connector/01.java/docs.md @@ -55,15 +55,16 @@ INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('beijing') VALUES( ## JDBC driver version and supported TDengine and JDK versions | taos-jdbcdriver version | TDengine 2.0.x.x version | TDengine 2.2.x.x version | TDengine 2.4.x.x version | JDK version | -|---------------------| ----------------------| ----------------------| ----------------------| -------- | -| 2.0.37 | X | X | 2.4.0.6 以上 | 1.8.x | -| 2.0.36 | X | 2.2.2.11 以上 | 2.4.0.0 - 2.4.0.5 | 1.8.x | -| 2.0.35 | X | 2.2.2.11 以上 | 2.3.0.0 - 2.4.0.5 | 1.8.x | -| 2.0.33 - 2.0.34 | 2.0.3.0 以上 | 2.2.0.0 以上 | 2.4.0.0 - 2.4.0.5 | 1.8.x | -| 2.0.31 - 2.0.32 | 2.1.3.0 - 2.1.7.7 | X | X | 1.8.x | -| 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.1 | X | X | 1.8.x | -| 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.4 | X | X | 1.8.x | -| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.3 | X | X | 1.8.x | +| ----------------------- | ------------------------ | ------------------------ | ------------------------ | ----------- | +| 2.0.38 | X | X | 2.4.0.14 or later | 1.8.x | +| 2.0.37 | X | X | 2.4.0.6 or later | 1.8.x | +| 2.0.36 | X | 2.2.2.11 or later | 2.4.0.0 - 2.4.0.5 | 1.8.x | +| 2.0.35 | X | 2.2.2.11 or later | 2.3.0.0 - 2.4.0.5 | 1.8.x | +| 2.0.33 - 2.0.34 | 2.0.3.0 or later | 2.2.0.0 or later | 2.4.0.0 - 2.4.0.5 | 1.8.x | +| 2.0.31 - 2.0.32 | 2.1.3.0 - 2.1.7.7 | X | X | 1.8.x | +| 2.0.22 - 2.0.30 | 2.0.18.0 - 2.1.2.1 | X | X | 1.8.x | +| 2.0.12 - 2.0.21 | 2.0.8.0 - 2.0.17.4 | X | X | 1.8.x | +| 2.0.4 - 2.0.11 | 2.0.0.0 - 2.0.7.3 | X | X | 1.8.x | ## DataType in TDengine and Java connector @@ -148,6 +149,16 @@ The JDBC-RESTful does not depend on the local function library. Compared with JD * JdbcUrl starts with "JDBC:TAOS-RS://" * Use port 6041 as the connection port +JDBC 2.0.38 and later version with TDengine 2.4.0.12 (and later version) start to support a new bulk-pulling feature. It provides higher data transmission performance and larger volume data queries capability via WebSocket communication. + +Create bulk-pulling connection: + +``` +String url = "jdbc:TAOS-RS://taosdemo.com:6041/?user=root&password=taosdata";Properties properties = new Properties(); +properties.setProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD, "true"); +Connection connection = DriverManager.getConnection(url, properties); +``` + For better write and query performance, Java applications can use the JDBC-JNI driver, as shown below: ```java @@ -173,7 +184,7 @@ The configuration parameters in the URL are as follows: * charset: character set used by the client. The default value is the system character set. * locale: client locale. The default value is the current system locale. * timezone: timezone used by the client. The default value is the current timezone of the system. -* batchfetch: only valid for JDBC-JNI. True if batch ResultSet fetching is enabled; false if row-by-row ResultSet fetching is enabled. Default value is false. +* batchfetch: True if batch ResultSet fetching is enabled; false if row-by-row ResultSet fetching is enabled. Default value is false. * timestampFormat: only valid for JDBC-RESTful. 'TIMESTAMP' if you want to get a long value in a ResultSet; 'UTC' if you want to get a string in UTC date-time format in a ResultSet; 'STRING' if you want to get a local date-time format string in ResultSet. Default value is 'STRING'. * batchErrorIgnore: true if you want to continue executing the rest of the SQL when error happens during execute the executeBatch method in Statement; false, false if the remaining SQL statements are not executed. Default value is false. diff --git a/documentation20/en/08.connector/docs.md b/documentation20/en/08.connector/docs.md index be6c675246824ab52b7d3fe4e68cd3c3fad897be..c82ea08bda58c887aab6551c498a4ed5eb341dae 100644 --- a/documentation20/en/08.connector/docs.md +++ b/documentation20/en/08.connector/docs.md @@ -420,7 +420,7 @@ In addition to writing data using SQL or using the parameter binding API, writin #include #include #include - + int main() { const char* host = "127.0.0.1"; const char* user = "root"; @@ -428,48 +428,27 @@ int main() { // connect to server TAOS* taos = taos_connect(host, user, passwd, "test", 0); - + // prepare the line string char* lines1[] = { "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000" }; - + // schema-less insert TAOS_RES* res = taos_schemaless_insert(taos, lines1, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); if (taos_errno(res) != 0) { printf("failed to insert schema-less data, reason: %s\n", taos_errstr(res)); } - + taos_free_result(res); - + // close the connection taos_close(taos); return (code); } ``` -### Continuous query interface - -TDengine provides time-driven real-time stream computing APIs. You can perform various real-time aggregation calculation operations on tables (data streams) of one or more databases at regular intervals. The operation is simple, only APIs for opening and closing streams. The details are as follows: - -- `TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sql, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), int64_t stime, void *param, void (*callback)(void *))` - -This API is used to create data streams where: - - * taos: Database connection established - * sql: SQL query statement (query statement only) - * fp: user-defined callback function pointer. After each stream computing is completed, TDengine passes the query result (TAOS_ROW), query status (TAOS_RES), and user-defined parameters (PARAM) to the callback function. In the callback function, the user can use `taos_num_fields()` to obtain the number of columns in the result set, and `taos_fetch_fields()` to obtain the type of data in each column of the result set. - * stime: The time when stream computing starts. If it is 0, it means starting from now. If it is not zero, it means starting from the specified time (the number of milliseconds from 1970/1/1 UTC time). - * param: It is a parameter provided by the application for callback. During callback, the parameter is provided to the application - * callback: The second callback function is called when the continuous query stop automatically. - -The return value is NULL, indicating creation failed; the return value is not NULL, indicating creation successful. - -- `void taos_close_stream (TAOS_STREAM *tstr)` - -Close the data flow, where the parameter provided is the return value of `taos_open_stream()`. When the user stops stream computing, be sure to close the data flow. - ### Data subscription interface The subscription API currently supports subscribing to one or more tables and continuously obtaining the latest data written to the tables through regular polling. diff --git a/documentation20/en/09.connections/docs.md b/documentation20/en/09.connections/docs.md index 6cd3cf6483564f733c1c79bd698af3022d2e73d1..09456d94d0d3fab0febc7d6c80b20ec826a2b8f4 100644 --- a/documentation20/en/09.connections/docs.md +++ b/documentation20/en/09.connections/docs.md @@ -101,16 +101,17 @@ MATLAB can access data to the local workspace by connecting directly to the TDen Several steps are required to adapt MATLAB to TDengine. Taking adapting MATLAB2017a on Windows10 as an example: -- Copy the file JDBCDriver-1.0.0-dist.jar in TDengine package to the directory ${matlab_root}\MATLAB\R2017a\java\jar\toolbox -- Copy the file taos.lib in TDengine package to ${matlab root dir}\MATLAB\R2017a\lib\win64 +- Please download TDengine JDBC driver dist jar file from (maven.org)[https://repo1.maven.org/maven2/com/taosdata/jdbc/taos-jdbcdriver/] or other maven.org's mirrors site and copy it to the directory ${matlab_root}\MATLAB\R2017a\java\jar\toolbox +- Copy the file taos.lib from TDengine installation package to ${matlab root dir}\MATLAB\R2017a\lib\win64 - Add the .jar package just copied to the MATLAB classpath. Append the line below as the end of the file of ${matlab root dir}\MATLAB\R2017a\toolbox\local\classpath.txt -- ``` - $matlabroot/java/jar/toolbox/JDBCDriver-1.0.0-dist.jar + ``` + $matlabroot/java/jar/toolbox/JDBCDriver-x.x.x-dist.jar ``` - Create a file called javalibrarypath.txt in directory ${user_home}\AppData\Roaming\MathWorks\MATLAB\R2017a_, and add the _taos.dll path in the file. For example, if the file taos.dll is in the directory of C:\Windows\System32,then add the following line in file javalibrarypath.txt: -- ``` + + ``` C:\Windows\System32 ``` @@ -142,13 +143,19 @@ For more detailed examples, please refer to the examples\matlab\TDengineDemo.m f ## R -R language supports connection to the TDengine database through the JDBC interface. First, you need to install the JDBC package of R language. Launch the R language environment, and then execute the following command to install the JDBC support library for R language: +R language supports connection to the TDengine database through the JDBC interface. First, you need to install the JDBC package of R language. Its dependencies such as DBI and rJava will be automatically downloaded too. Launch the R language environment, and then execute the following command to install the JDBC support library for R language: ```R install.packages('RJDBC', repos='http://cran.us.r-project.org') ``` -After installed, load the RJDBC package by executing `library('RJDBC')` command. +After installed, load the DBI, rJava and RJDBC package by executing `library()` command. + +```R +library('DBI') +library('rJava') +library('RJDBC') +``` Then load the TDengine JDBC driver: @@ -159,7 +166,13 @@ drv<-JDBC("com.taosdata.jdbc.TSDBDriver","JDBCDriver-2.0.0-dist.jar", identifier If succeed, no error message will display. Then use the following command to try a database connection: ```R -conn<-dbConnect(drv,"jdbc:TSDB://192.168.0.1:0/?user=root&password=taosdata","root","taosdata") +conn<-dbConnect(drv,"jdbc:TSDB://127.0.0.1:0/?user=root&password=taosdata","root","taosdata") +``` + +Or you can use the RESTful interface to access TDengine. + +```R +conn<-dbConnect(drv,"jdbc:TAOS-RS://127.0.0.1:6041/test?user=root&password=taosdata","root","taosdata") ``` Please replace the IP address in the command above to the correct one. If no error message is shown, then the connection is established successfully, otherwise the connection command needs to be adjusted according to the error prompt. TDengine supports below functions in *RJDBC* package: @@ -171,7 +184,3 @@ Please replace the IP address in the command above to the correct one. If no err - `dbDisconnect(conn)`: close a connection - `dbRemoveTable(conn, "test")`: remove table test -The functions below are not supported currently: - -- `dbExistsTable(conn, "test")`: if table test exists -- `dbListTables(conn)`: list all tables in the connection diff --git a/documentation20/en/12.taos-sql/docs.md b/documentation20/en/12.taos-sql/docs.md index 8b40da8c7609290224c40d383848c70295f19274..137dfe9123fe817307bd2414e4d81dd305aba2d8 100755 --- a/documentation20/en/12.taos-sql/docs.md +++ b/documentation20/en/12.taos-sql/docs.md @@ -1304,6 +1304,62 @@ TDengine supports aggregations over data, they are listed below: Query OK, 1 row(s) in set (0.000836s) ``` +- **CSUM** + ```sql + SELECT CSUM(field_name) FROM { tb_name | stb_name } [WHERE clause] + ``` + + Function: Cumulative sum computes the running total of one time series. It occurs in select clause of SQL statement. + + Input: Input column data type should be a numeric type. + + Output: If the input data type is unsigned int type, the result data type is uint64_t. If the input data type is signed int type, the result data type is int64_t. If the input data type is float or double, the result data type is double. The function also outputs the timestamp of the current row. + + Table: The csum function only applies to the normal table, child table, and super table with group by tbname. + + Nested Query: The csum function applies to both outer query and nested query. + + Note: Can't be used with +-*/ arithmatic operations,like csum(col1) + csum(col2), can only be used with aggragation functions. + +- **MAVG** + ```sql + SELECT MAVG(field_name, K) FROM { tb_name | stb_name } [WHERE clause] + ``` + + Function: Moving Average Function Computes the rolling simple average over k values of one time series. It occurs in select clause of SQL statement. If the input time series has less than k values, no result is calculated. + + Input: Input column data should be a numeric type. + + Output: The Result data type is double. The function also outputs the timestamp of the current row. + + Parameter: K is an integer between 1 and 1000. + + Table: The mavg function only applies to the normal table, child table, and super table with group by tbname. + + Nested Query: The mavg function applies to both outer query and nested query. + + Note: Can't be used with +-*/ arithmatic operations, like mavg(col1, k1) + mavg(col2, k1); can only be used with normal columns, selection and projection functions,can't be used with aggragation functions. + +- **SAMPLE** + ``` + SELECT SAMPLE(field_name, K) FROM { tb_name | stb_name } [WHERE clause] + ``` + + Function: Sample function samples k values from a specific time series with equal probability. It occurs in select clause of SQL statement + + Input: There are no restrictions on the input data type. + + Output: The output data type is the same as the input data type. The function also outputs the timestamp of the current row. + + Parameter: K is an integer between 1 and 1000. + + Table: he sample function only applies to the normal table, child table, and super table with group by tbname. + + Nested Query: The sample function applies to both outer query and nested query. + + Note: Can't be used as operand in an expression + + - **ASIN** ```mysql SELECT ASIN(field_name) FROM { tb_name | stb_name } [WHERE clause] @@ -1703,7 +1759,7 @@ TDengine supports aggregations over data, they are listed below: Notes: Returns NULL when input is NULL. - Input pos can be negative or positive. If it is a positive number, this function extracts from the beginning of the string. If it is a negative number, this function extracts from the end of the string + Input pos can be negative or positive. If it is a positive number, the beginning of the substring is pos characters from the beginning of the string. If it is a negative number, the beginning of the substring is pos characters from the end of the string If input len is omitted, the output is whole substring starting from pos. This function applies to normal table, child table and super table This function applies to bother out query and inner query diff --git a/documentation20/en/14.devops/03.immigrate/docs.md b/documentation20/en/14.devops/03.immigrate/docs.md index 54c431b043a969a7151a27696620b4284a4501d1..6669f5d7bc26f375233c369c4930b2518d097f89 100644 --- a/documentation20/en/14.devops/03.immigrate/docs.md +++ b/documentation20/en/14.devops/03.immigrate/docs.md @@ -9,7 +9,7 @@ Compared with OpenTSDB, TDengine has the following distinctive features. - Performance of data writing and querying far exceeds that of OpenTSDB. - Efficient compression mechanism for time-series data, which compresses less than 1/5 of the storage space on disk. - The installation and deployment is very simple, a single installation package to complete the installation and deployment, no other third-party software, the entire installation and deployment process in seconds; -- The built-in functions cover all the query functions supported by OpenTSDB, and also support more time-series data query functions, scalar functions and aggregation functions, and support advanced query functions such as multiple time-window aggregation, join query, expression operation, multiple group aggregation, user-defined sorting, and user-defined functions. Adopting SQL-like syntax rules, it is easier to learn and basically has no learning cost. +- The built-in functions cover all the query functions supported by OpenTSDB, and also support more time-series data query functions, scalar functions and aggregation functions, and support advanced query functions such as multiple time-window aggregation, join query, expression operation, multiple group aggregation, user-defined sorting, and user-defined functions. Adopting SQL-like syntax rules, it is easier to learn and basically has no learning cost. For OpenTSDB functions, please refer to Appendix 1 in this blog (scroll down to find it); for any other functions supported by TDengine, please refer to the SQL reference guide part in TDengine document on website. - Supports up to 128 tags with a total tag length of up to 16 KB. - In addition to HTTP, it also provides interfaces to Java, Python, C, Rust, Go, and other languages, and supports a variety of enterprise-class standard connector protocols such as JDBC. @@ -207,7 +207,9 @@ Equivalent function: avg Example. +```sql SELECT avg(val) FROM (SELECT first(val) FROM super_table WHERE ts >= startTime and ts <= endTime INTERVAL(20s) Fill(linear)) INTERVAL(20s) +``` Notes. @@ -226,7 +228,9 @@ Equivalent function: count Example. +```sql SELECT COUNT(*) FROM super_table_name; +``` **Dev** @@ -234,7 +238,9 @@ Equivalent function: stddev Example. +```sql SELECT STDDEV(val) FROM table_name +``` **Estimated percentiles** @@ -242,7 +248,9 @@ Equivalent function: apercentile Example. +```sql SELECT APERCENTILE(col1, 50, “t-digest”) FROM table_name +``` Remark. @@ -254,7 +262,9 @@ Equivalent function: first Example. +```sql SELECT FIRST(col1) FROM table_name +``` **Last** @@ -262,7 +272,9 @@ Equivalent function: last Example. +```sql SELECT LAST(col1) FROM table_name +``` **Max** @@ -270,7 +282,9 @@ Equivalent function: max Example. +```sql SELECT MAX(value) FROM (SELECT FIRST(val) value FROM table_name INTERVAL(10s) FILL(linear)) INTERVAL(10s) +``` Note: The Max function requires interpolation, for the reasons given above. @@ -280,13 +294,17 @@ Equivalent function: min Example. +```sql SELECT MIN(value) FROM (select first(val) value FROM table_name INTERVAL(10s) FILL(linear)) INTERVAL(10s); +``` **MinMax** Equivalent function: max +```sql SELECT max(val) FROM table_name +``` Note: This function does not require interpolation, so it can be calculated directly. @@ -294,7 +312,9 @@ Note: This function does not require interpolation, so it can be calculated dire Equivalent function: min +```sql SELECT min(val) FROM table_name +``` Note: This function does not require interpolation, so it can be calculated directly. @@ -308,7 +328,9 @@ Note: Equivalent function: sum +```sql SELECT MAX(value) FROM (SELECT FIRST(val) value FROM table_name INTERVAL(10s) FILL(linear)) INTERVAL(10s) +``` Note: This function does not require interpolation, so it can be calculated directly. @@ -316,7 +338,9 @@ Note: This function does not require interpolation, so it can be calculated dire Equivalent function: sum +```sql SELECT SUM(val) FROM table_name +``` Note: This function does not require interpolation, so it can be calculated directly. @@ -331,8 +355,10 @@ query = { "metric":"cpu.usage_user", }] } +``` // Equivalent SQL: +```sql SELECT count(*) FROM `cpu.usage_user` WHERE ts>=1510560000 AND ts<=1515000009 diff --git a/examples/C#/.gitignore b/examples/C#/.gitignore index 2a959a77c900524f996f3214446d37f34026c6e4..b488758990212a16505807bc1debc907d4660a5a 100644 --- a/examples/C#/.gitignore +++ b/examples/C#/.gitignore @@ -14,4 +14,5 @@ taosdemo/obj/ jsonTag/bin/ jsonTag/obj/ insertCn/bin/ -insertCn/obj/ \ No newline at end of file +insertCn/obj/ +.vs diff --git a/examples/JDBC/taosdemo/pom.xml b/examples/JDBC/taosdemo/pom.xml index e249d83e16def830b61e9f8ab82197d30e7e0d33..c50f77f1ed15c1cfe9b722718afd4a9fbfd03bb3 100644 --- a/examples/JDBC/taosdemo/pom.xml +++ b/examples/JDBC/taosdemo/pom.xml @@ -10,7 +10,7 @@ Demo project for TDengine - 5.3.14 + 5.3.19 diff --git a/examples/TypeScript-REST/.gitignore b/examples/TypeScript-REST/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..8841450353604aee9473e923ff9aa3e88fae0346 --- /dev/null +++ b/examples/TypeScript-REST/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +package-lock.json +test.js \ No newline at end of file diff --git a/examples/TypeScript-REST/package.json b/examples/TypeScript-REST/package.json new file mode 100644 index 0000000000000000000000000000000000000000..265659d25e2962295d13642a20577910262c1744 --- /dev/null +++ b/examples/TypeScript-REST/package.json @@ -0,0 +1,12 @@ +{ + "devDependencies": { + "@types/node": "^17.0.23", + "typescript": "^4.6.3" + }, + "scripts": { + "test": "tsc test.ts && node test.js" + }, + "dependencies": { + "td2.0-rest-connector": "^1.0.3" + } +} diff --git a/examples/TypeScript-REST/test.ts b/examples/TypeScript-REST/test.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4767457f58f73f92c5165f5a8b6688b2ab57ff2 --- /dev/null +++ b/examples/TypeScript-REST/test.ts @@ -0,0 +1,57 @@ +import { options, connect } from 'td2.0-rest-connector' +options.path = '/rest/sqlt' +options.host = 'localhost' + +const db = 'rest_ts_db'; +const table = 'rest' +const createDB = `create database if not exists ${db} keep 3650`; +const dropDB = `drop database if exists ${db}`; +const createTB = `create table if not exists ${db}.${table}(ts timestamp,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(40),nchr nchar(40))`; +const addColumn = `alter table ${db}.${table} add column new_column nchar(40) `; +const dropColumn = `alter table ${db}.${table} drop column new_column`; +const insertSql = `insert into ${db}.${table} values('2022-03-30 18:30:51.567',1,2,3,4,'binary1','nchar1')` + + `('2022-03-30 18:30:51.568',5,6,7,8,'binary2','nchar2')` + + `('2022-03-30 18:30:51.569',9,0,1,2,'binary3','nchar3')`; +const querySql = `select * from ${db}.${table}`; +const errorSql = 'show database'; + +let conn = connect(options); +let cursor = conn.cursor(); + +async function execute(sql:string, pure = false) { + let result = await cursor.query(sql, pure); + // print query result as taos shell + result.toString(); + // Get Result object, return Result object. + console.log("result.getResult()",result.getResult()); + // Get status, return 'succ'|'error'. + console.log("result.getStatus()",result.getStatus()); + // Get head,return response head (Array|undefined,when execute failed this is undefined). + console.log("result.getHead()",result.getHead()); + // Get Meta data, return Meta[]|undefined(when execute failed this is undefined). + console.log("result.getMeta()",result.getMeta()); + // Get data,return Array>|undefined(when execute failed this is undefined). + console.log("result.getData()",result.getData()); + // Get affect rows,return number|undefined(when execute failed this is undefined). + console.log("result.getAffectRows()",result.getAffectRows()); + // Get command,return SQL send to server(need to `query(sql,false)`,set 'pure=false',default true). + console.log("result.getCommand()",result.getCommand()); + // Get error code ,return number|undefined(when execute failed this is undefined). + console.log("result.getErrCode()",result.getErrCode()); + // Get error string,return string|undefined(when execute failed this is undefined). + console.log("result.getErrStr()",result.getErrStr()); +} + +(async () => { + let start = new Date().getTime(); // 开始时间 + await execute(createDB); + await execute(createTB); + await execute(addColumn); + await execute(dropColumn); + await execute(insertSql); + await execute(querySql); + await execute(errorSql); + await execute(dropDB); + let end = new Date().getTime(); // 结束时间 + console.log("total spend time:%d ms",end - start); +})() diff --git a/examples/TypeScript-REST/tsconfig.json b/examples/TypeScript-REST/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..56794816baf823f6c2be68914c1cecc8af38a43e --- /dev/null +++ b/examples/TypeScript-REST/tsconfig.json @@ -0,0 +1,101 @@ +{ + "compilerOptions": { + /* Visit https://aka.ms/tsconfig.json to read more about this file */ + + /* Projects */ + // "incremental": true, /* Enable incremental compilation */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ + // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "resolveJsonModule": true, /* Enable importing .json files */ + // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ + // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ + // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/examples/c/apitest.c b/examples/c/apitest.c index 2c197887e7d7f1e6397213641a02ee8b37a84190..597a108a2686b4dd501513ea895c25a2de1b8dad 100644 --- a/examples/c/apitest.c +++ b/examples/c/apitest.c @@ -262,32 +262,6 @@ void verify_async(TAOS* taos) { usleep(1000000); } -void stream_callback(void* param, TAOS_RES* res, TAOS_ROW row) { - if (res == NULL || row == NULL) { - return; - } - - int num_fields = taos_num_fields(res); - TAOS_FIELD* fields = taos_fetch_fields(res); - - printf("got one row from stream_callback\n"); - char temp[256] = {0}; - taos_print_row(temp, row, fields, num_fields); - puts(temp); -} - -void verify_stream(TAOS* taos) { - prepare_data(taos); - TAOS_STREAM* strm = - taos_open_stream(taos, "select count(*) from meters interval(1m)", stream_callback, 0, NULL, NULL); - printf("waiting for stream data\n"); - usleep(100000); - TAOS_RES* result = taos_query(taos, "insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);"); - taos_free_result(result); - usleep(200000000); - taos_close_stream(strm); -} - void verify_schema_less(TAOS* taos) { TAOS_RES* result; result = taos_query(taos, "drop database if exists test;"); @@ -447,8 +421,6 @@ int main(int argc, char* argv[]) { printf("*********** verify subscribe ************\n"); verify_subscribe(taos); - printf("************ verify stream *************\n"); - // verify_stream(taos); printf("done\n"); taos_close(taos); taos_cleanup(); diff --git a/examples/c/makefile b/examples/c/makefile index 355d1a2d54c1293e909309dafe986daa716ac293..4d6cfc1f5f3e8d4d8b0a7ce88ce285c1b3259a5a 100644 --- a/examples/c/makefile +++ b/examples/c/makefile @@ -17,7 +17,6 @@ exe: gcc $(CFLAGS) ./asyncdemo.c -o $(ROOT)asyncdemo $(LFLAGS) gcc $(CFLAGS) ./demo.c -o $(ROOT)demo $(LFLAGS) gcc $(CFLAGS) ./prepare.c -o $(ROOT)prepare $(LFLAGS) - gcc $(CFLAGS) ./stream.c -o $(ROOT)stream $(LFLAGS) gcc $(CFLAGS) ./subscribe.c -o $(ROOT)subscribe $(LFLAGS) gcc $(CFLAGS) ./apitest.c -o $(ROOT)apitest $(LFLAGS) @@ -25,6 +24,5 @@ clean: rm $(ROOT)asyncdemo rm $(ROOT)demo rm $(ROOT)prepare - rm $(ROOT)stream rm $(ROOT)subscribe rm $(ROOT)apitest diff --git a/examples/c/stream.c b/examples/c/stream.c deleted file mode 100644 index f759da4283bfca69d921f4bbfbb2e78e2123a70c..0000000000000000000000000000000000000000 --- a/examples/c/stream.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include // include TDengine header file -#include - -typedef struct { - char server_ip[64]; - char db_name[64]; - char tbl_name[64]; -} param; - -int g_thread_exit_flag = 0; -void *insert_rows(void *sarg); - -void streamCallBack(void *param, TAOS_RES *res, TAOS_ROW row) { - // in this simple demo, it just print out the result - char temp[128]; - - TAOS_FIELD *fields = taos_fetch_fields(res); - int numFields = taos_num_fields(res); - - taos_print_row(temp, row, fields, numFields); - - printf("\n%s\n", temp); -} - -int main(int argc, char *argv[]) { - TAOS *taos; - char db_name[64]; - char tbl_name[64]; - char sql[1024] = {0}; - - if (argc != 4) { - printf("usage: %s server-ip dbname tblname\n", argv[0]); - exit(0); - } - - strcpy(db_name, argv[2]); - strcpy(tbl_name, argv[3]); - - // create pthread to insert into row per second for stream calc - param *t_param = (param *)malloc(sizeof(param)); - if (NULL == t_param) { - printf("failed to malloc\n"); - exit(1); - } - memset(t_param, 0, sizeof(param)); - strcpy(t_param->server_ip, argv[1]); - strcpy(t_param->db_name, db_name); - strcpy(t_param->tbl_name, tbl_name); - - pthread_t pid; - pthread_create(&pid, NULL, (void *(*)(void *))insert_rows, t_param); - - sleep(3); // waiting for database is created. - // open connection to database - taos = taos_connect(argv[1], "root", "taosdata", db_name, 0); - if (taos == NULL) { - printf("failed to connet to server:%s\n", argv[1]); - free(t_param); - exit(1); - } - - // starting stream calc, - printf("please input stream SQL:[e.g., select count(*) from tblname interval(5s) sliding(2s);]\n"); - fgets(sql, sizeof(sql), stdin); - if (sql[0] == 0) { - printf("input NULL stream SQL, so exit!\n"); - free(t_param); - exit(1); - } - - // param is set to NULL in this demo, it shall be set to the pointer to app context - TAOS_STREAM *pStream = taos_open_stream(taos, sql, streamCallBack, 0, NULL, NULL); - if (NULL == pStream) { - printf("failed to create stream\n"); - free(t_param); - exit(1); - } - - printf("press any key to exit\n"); - getchar(); - - taos_close_stream(pStream); - - g_thread_exit_flag = 1; - pthread_join(pid, NULL); - - taos_close(taos); - free(t_param); - - return 0; -} - -void *insert_rows(void *sarg) { - TAOS * taos; - char command[1024] = {0}; - param *winfo = (param *)sarg; - - if (NULL == winfo) { - printf("para is null!\n"); - exit(1); - } - - taos = taos_connect(winfo->server_ip, "root", "taosdata", NULL, 0); - if (taos == NULL) { - printf("failed to connet to server:%s\n", winfo->server_ip); - exit(1); - } - - // drop database - sprintf(command, "drop database %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to drop database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // create database - sprintf(command, "create database %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to create database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // use database - sprintf(command, "use %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to use database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // create table - sprintf(command, "create table %s (ts timestamp, speed int);", winfo->tbl_name); - if (taos_query(taos, command) != 0) { - printf("failed to create table, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // insert data - int64_t begin = (int64_t)time(NULL); - int index = 0; - while (1) { - if (g_thread_exit_flag) break; - - index++; - sprintf(command, "insert into %s values (%ld, %d)", winfo->tbl_name, (begin + index) * 1000, index); - if (taos_query(taos, command)) { - printf("failed to insert row [%s], reason:%s\n", command, taos_errstr(taos)); - } - sleep(1); - } - - taos_close(taos); - return 0; -} diff --git a/examples/go/taosdemo.go b/examples/go/taosdemo.go index 543cfcc0f65aad154cc411891a76ae2fdb4e0e02..6eba0cd448cc761ae9b9c069f083beea8069e42d 100644 --- a/examples/go/taosdemo.go +++ b/examples/go/taosdemo.go @@ -26,7 +26,7 @@ import ( "sync" "time" - _ "github.com/taosdata/driver-go/taosSql" + _ "github.com/taosdata/driver-go/v2/taosSql" ) const ( diff --git a/examples/lua/OpenResty/so/luaconnector51.so b/examples/lua/OpenResty/so/luaconnector51.so index 442de6e39f909e1aeb869988722b84795c048855..449466da2d3121380d070ffca1411162cbd0bd32 100755 Binary files a/examples/lua/OpenResty/so/luaconnector51.so and b/examples/lua/OpenResty/so/luaconnector51.so differ diff --git a/examples/lua/build.sh b/examples/lua/build.sh index 9d00c6842515415034ce0b5dc71d5d6af9ffc881..b4d61f54ca6c5dcbc26682fa08bf7cd12d0d7080 100755 --- a/examples/lua/build.sh +++ b/examples/lua/build.sh @@ -1,3 +1,4 @@ +#!/bin/bash lua_header_installed=`apt-cache policy liblua5.3-dev|grep Installed|grep none > /dev/null; echo $?` if [ "$lua_header_installed" = "0" ]; then echo "If need, please input root password to install liblua5.3-dev for build the connector.." diff --git a/examples/lua/lua51/lua_connector51.c b/examples/lua/lua51/lua_connector51.c index 7aad42f29343306516c6d8973b76060f3e1e6dfe..ac840913f9eef3f451268ffae53d406e690afe2f 100644 --- a/examples/lua/lua51/lua_connector51.c +++ b/examples/lua/lua51/lua_connector51.c @@ -303,51 +303,6 @@ void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){ // printf("-----------------------------------------------------------------------------------\n\r"); } -static int l_open_stream(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct cb_param *p = malloc(sizeof(struct cb_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL); - if (s == NULL) { - printf("failed to open stream, reason:%s\n", taos_errstr(taos)); - free(p); - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "stream"); - }else{ - // printf("success to open stream\n"); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - p->stream = s; - lua_pushlightuserdata(L,p); - lua_setfield(L, table_index, "stream");//stream has different content in lua and c. - } - - return 1; -} - -static int l_close_stream(lua_State *L){ - //TODO:get stream and free cb_param - struct cb_param *p = lua_touserdata(L,1); - taos_close_stream(p->stream); - free(p); - return 0; -} - static int l_close(lua_State *L){ TAOS *taos= (TAOS*)lua_topointer(L,1); lua_newtable(L); @@ -373,8 +328,6 @@ static const struct luaL_Reg lib[] = { {"query", l_query}, {"query_a",l_async_query}, {"close", l_close}, - {"open_stream", l_open_stream}, - {"close_stream", l_close_stream}, {NULL, NULL} }; diff --git a/examples/lua/lua_connector.c b/examples/lua/lua_connector.c index 035b17eb2a729c5267996fe7e3b7d3e1cf122d3e..ce13ab3829dec17e4df97ab94f358bd128e80cf1 100644 --- a/examples/lua/lua_connector.c +++ b/examples/lua/lua_connector.c @@ -241,112 +241,6 @@ static int l_async_query(lua_State *L){ return 1; } -void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){ - struct cb_param* p = (struct cb_param*) param; - TAOS_FIELD *fields = taos_fetch_fields(result); - int numFields = taos_num_fields(result); - - // printf("\nnumfields:%d\n", numFields); - //printf("\n\r-----------------------------------------------------------------------------------\n"); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - - lua_newtable(L); - - for (int i = 0; i < numFields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - - switch (fields[i].type) { - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - default: - lua_pushnil(L); - break; - } - - lua_settable(L, -3); - } - - lua_call(L, 1, 0); - - // printf("-----------------------------------------------------------------------------------\n\r"); -} - -static int l_open_stream(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct cb_param *p = malloc(sizeof(struct cb_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL); - if (s == NULL) { - printf("failed to open stream, reason:%s\n", taos_errstr(taos)); - free(p); - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "stream"); - }else{ - // printf("success to open stream\n"); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - p->stream = s; - lua_pushlightuserdata(L,p); - lua_setfield(L, table_index, "stream");//stream has different content in lua and c. - } - - return 1; -} - -static int l_close_stream(lua_State *L){ - //TODO:get stream and free cb_param - struct cb_param *p = lua_touserdata(L,1); - taos_close_stream(p->stream); - free(p); - return 0; -} static int l_close(lua_State *L){ TAOS *taos= (TAOS*)lua_topointer(L,1); @@ -373,8 +267,6 @@ static const struct luaL_Reg lib[] = { {"query", l_query}, {"query_a",l_async_query}, {"close", l_close}, - {"open_stream", l_open_stream}, - {"close_stream", l_close_stream}, {NULL, NULL} }; diff --git a/examples/lua/test.lua b/examples/lua/test.lua index c124b50a4dbd954ab47098e527bd2d35ee44384e..a858dbb6ad7a100060715b2c3347b60b1e07a617 100644 --- a/examples/lua/test.lua +++ b/examples/lua/test.lua @@ -9,6 +9,50 @@ local config = { max_packet_size = 1024 * 1024 } +function dump(obj) + local getIndent, quoteStr, wrapKey, wrapVal, dumpObj + getIndent = function(level) + return string.rep("\t", level) + end + quoteStr = function(str) + return '"' .. string.gsub(str, '"', '\\"') .. '"' + end + wrapKey = function(val) + if type(val) == "number" then + return "[" .. val .. "]" + elseif type(val) == "string" then + return "[" .. quoteStr(val) .. "]" + else + return "[" .. tostring(val) .. "]" + end + end + wrapVal = function(val, level) + if type(val) == "table" then + return dumpObj(val, level) + elseif type(val) == "number" then + return val + elseif type(val) == "string" then + return quoteStr(val) + else + return tostring(val) + end + end + dumpObj = function(obj, level) + if type(obj) ~= "table" then + return wrapVal(obj) + end + level = level + 1 + local tokens = {} + tokens[#tokens + 1] = "{" + for k, v in pairs(obj) do + tokens[#tokens + 1] = getIndent(level) .. wrapKey(k) .. " = " .. wrapVal(v, level) .. "," + end + tokens[#tokens + 1] = getIndent(level - 1) .. "}" + return table.concat(tokens, "\n") + end + return dumpObj(obj, 0) +end + local conn local res = driver.connect(config) if res.code ~=0 then @@ -75,14 +119,14 @@ else end -res = driver.query(conn,"CREATE TABLE thermometer (ts timestamp, degree double) TAGS(location binary(20), type int)") +res = driver.query(conn,"create table thermometer (ts timestamp, degree double) tags(location binary(20), type int)") if res.code ~=0 then print(res.error) return else print("create super table--- pass") end -res = driver.query(conn,"CREATE TABLE therm1 USING thermometer TAGS ('beijing', 1)") +res = driver.query(conn,"create table therm1 using thermometer tags ('beijing', 1)") if res.code ~=0 then print(res.error) return @@ -90,7 +134,7 @@ else print("create table--- pass") end -res = driver.query(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.001', 20),('2019-09-01 00:00:00.002', 21)") +res = driver.query(conn,"insert into therm1 values ('2019-09-01 00:00:00.001', 20),('2019-09-01 00:00:00.002', 21)") if res.code ~=0 then print(res.error) @@ -103,7 +147,7 @@ else end end -res = driver.query(conn,"SELECT COUNT(*) count, AVG(degree) AS av, MAX(degree), MIN(degree) FROM thermometer WHERE location='beijing' or location='tianjin' GROUP BY location, type") +res = driver.query(conn,"select count(*) count, avg(degree) as av, max(degree), min(degree) from thermometer where location='beijing' or location='tianjin' group by location, type") if res.code ~=0 then print("select from super table--- failed:"..res.error) return @@ -129,33 +173,16 @@ function async_query_callback(res) end end -driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback) - - -function stream_callback(t) - print("------------------------") - print("continuous query result:") - for key, value in pairs(t) do - print("key:"..key..", value:"..value) - end -end +driver.query_a(conn,"insert into therm1 values ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback) -local stream -res = driver.open_stream(conn,"SELECT COUNT(*) as count, AVG(degree) as avg, MAX(degree) as max, MIN(degree) as min FROM thermometer interval(2s) sliding(2s);)",0, stream_callback) -if res.code ~=0 then - print("open stream--- failed:"..res.error) - return -else - print("open stream--- pass") - stream = res.stream -end +res = driver.query(conn, "create table avg_degree as select avg(degree) from thermometer where ts > now and ts <= now + 1m interval(5s) sliding(1s)") -print("From now on we start continous insert in an definite (infinite if you want) loop.") +print("From now on we start continous insertion in an definite (infinite if you want) loop.") local loop_index = 0 while loop_index < 30 do local t = os.time()*1000 local v = loop_index - res = driver.query(conn,string.format("INSERT INTO therm1 VALUES (%d, %d)",t,v)) + res = driver.query(conn,string.format("insert into therm1 values (%d, %d)",t,v)) if res.code ~=0 then print("continous insertion--- failed:" .. res.error) @@ -163,10 +190,17 @@ while loop_index < 30 do else --print("insert successfully, affected:"..res.affected) end + local res1 = driver.query(conn, string.format("select last(*) from avg_degree")) + if res1.code ~=0 then + print("select failed: "..res1.error) + return + else +-- print(dump(res1)) + if(#res1.item > 0) then print("avg_degree: " .. res1.item[1]["last(avg_degree_)"]) end + end + os.execute("sleep " .. 1) loop_index = loop_index + 1 end -driver.close_stream(stream) - driver.close(conn) diff --git a/examples/rust b/examples/rust index 1c8924dc668e6aa848214c2fc54e3ace3f5bf8df..7ed7a97715388fa144718764d6bf20f9bfc29a12 160000 --- a/examples/rust +++ b/examples/rust @@ -1 +1 @@ -Subproject commit 1c8924dc668e6aa848214c2fc54e3ace3f5bf8df +Subproject commit 7ed7a97715388fa144718764d6bf20f9bfc29a12 diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 46e27b98e9339cb0cb0cb0d8fe0d038bde926148..7d77a0b23e70782f1a8a0160812820c91640f9dc 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -174,13 +174,13 @@ keepColumnName 1 # maxConnections 5000 # stop writing logs when the disk size of the log folder is less than this value -# minimalLogDirGB 0.1 +# minimalLogDirGB 1.0 # stop writing temporary files when the disk size of the tmp folder is less than this value -# minimalTmpDirGB 0.1 +# minimalTmpDirGB 1.0 # if disk free space is less than this value, taosd service exit directly within startup process -# minimalDataDirGB 0.1 +# minimalDataDirGB 2.0 # One mnode is equal to the number of vnode consumed # mnodeEqualVnodeNum 4 @@ -307,3 +307,6 @@ keepColumnName 1 # unit MB. Flush vnode wal file if walSize > walFlushSize and walSize > cache*0.5*blocks # walFlushSize 1024 + +# unit Hour. Latency of data migration +# keepTimeOffset 0 diff --git a/packaging/deb/makedeb.sh b/packaging/deb/makedeb.sh index 42110657a6d9c32d37637c034a84ae34cbedba8e..5ae7edbfad325e7494fea85958b682f8444bd187 100755 --- a/packaging/deb/makedeb.sh +++ b/packaging/deb/makedeb.sh @@ -59,7 +59,7 @@ cp ${compile_dir}/../packaging/tools/set_core.sh ${pkg_dir}${install_home_pat cp ${compile_dir}/../packaging/tools/taosd-dump-cfg.gdb ${pkg_dir}${install_home_path}/bin cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin -cp ${compile_dir}/build/bin/taosBenchmark ${pkg_dir}${install_home_path}/bin +#cp ${compile_dir}/build/bin/taosBenchmark ${pkg_dir}${install_home_path}/bin if [ -f "${compile_dir}/build/bin/taosadapter" ]; then cp ${compile_dir}/build/bin/taosadapter ${pkg_dir}${install_home_path}/bin ||: diff --git a/packaging/docker/Dockerfile b/packaging/docker/Dockerfile index 1f3bd503f6a641679924075e8ca9d164cb1a5ee3..26349e257676d99d0ea81e03509c8b09c20a2248 100644 --- a/packaging/docker/Dockerfile +++ b/packaging/docker/Dockerfile @@ -9,8 +9,10 @@ RUN echo ${pkgFile} && echo ${dirName} COPY ${pkgFile} /root/ RUN tar -zxf ${pkgFile} -WORKDIR /root/${dirName}/ -RUN /bin/bash install.sh -e no +WORKDIR /root/ +RUN cd /root/${dirName}/ && /bin/bash install.sh -e no && cd /root +RUN rm /root/${pkgFile} +RUN rm -rf /root/${dirName} ENV DEBIAN_FRONTEND=noninteractive RUN apt-get clean && apt-get update && apt-get install -y locales tzdata netcat && locale-gen en_US.UTF-8 diff --git a/packaging/docker/dockerbuild.sh b/packaging/docker/dockerbuild.sh index 2483973111a871a0cc958675531cb8a85d73fdac..541ae6ec1398ae40a450382d25aa53bec18a8ced 100755 --- a/packaging/docker/dockerbuild.sh +++ b/packaging/docker/dockerbuild.sh @@ -18,8 +18,9 @@ version="" passWord="" pkgFile="" verType="stable" +dockerLatest="n" -while getopts "hc:n:p:f:V:" arg +while getopts "hc:n:p:f:V:a:b:" arg do case $arg in c) @@ -38,17 +39,25 @@ do #echo "pkgFile=$OPTARG" pkgFile=$(echo $OPTARG) ;; + b) + #echo "branchName=$OPTARG" + branchName=$(echo $OPTARG) + ;; V) #echo "verType=$OPTARG" verType=$(echo $OPTARG) ;; + a) + #echo "dockerLatest=$OPTARG" + dockerLatest=$(echo $OPTARG) + ;; h) echo "Usage: `basename $0` -c [aarch32 | aarch64 | amd64 | x86 | mips64 ...] " echo " -n [version number] " echo " -p [password for docker hub] " echo " -V [stable | beta] " echo " -f [pkg file] " - + echo " -a [y | n ] " exit 0 ;; ?) #unknow option @@ -58,13 +67,11 @@ do esac done -# if [ "$verType" == "beta" ]; then -# pkgFile=TDengine-server-${version}-Linux-${cpuType}-${verType}.tar.gz -# elif [ "$verType" == "stable" ]; then -# pkgFile=TDengine-server-${version}-Linux-${cpuType}.tar.gz -# else -# echo "unknow verType, nor stabel or beta" -# exit 1 + +# Check_verison() +# { +# } + if [ "$verType" == "beta" ]; then dockername=${cpuType}-${verType} @@ -84,6 +91,9 @@ echo "====NOTES: ${pkgFile} must be in the same directory as dockerbuild.sh====" scriptDir=$(dirname $(readlink -f $0)) comunityArchiveDir=/nas/TDengine/v$version/community # community version’package directory +communityDir=${scriptDir}/../../../community +DockerfilePath=${communityDir}/packaging/docker/ +Dockerfile=${communityDir}/packaging/docker/Dockerfile cd ${scriptDir} cp -f ${comunityArchiveDir}/${pkgFile} . @@ -100,13 +110,65 @@ else exit 1 fi -docker build --rm -f "Dockerfile" --network=host -t tdengine/tdengine-${dockername}:${version} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName} --build-arg cpuType=${cpuTypeAlias} +docker build --rm -f "${Dockerfile}" --network=host -t tdengine/tdengine-${dockername}:${version} "." --build-arg pkgFile=${pkgFile} --build-arg dirName=${dirName} --build-arg cpuType=${cpuTypeAlias} docker login -u tdengine -p ${passWord} #replace the docker registry username and password docker push tdengine/tdengine-${dockername}:${version} -# set this version to latest version -docker tag tdengine/tdengine-${dockername}:${version} tdengine/tdengine-${dockername}:latest -docker push tdengine/tdengine-${dockername}:latest +if [ -n "$(docker ps -aq)" ] ;then + echo "delete docker process" + docker stop $(docker ps -aq) + docker rm $(docker ps -aq) +fi + +if [ -n "$(pidof taosd)" ] ;then + echo "kill taosd " + kill -9 $(pidof taosd) +fi + +if [ -n "$(pidof power)" ] ;then + echo "kill power " + kill -9 $(pidof power) +fi +echo ">>>>>>>>>>>>> check whether tdengine/tdengine-${dockername}:${version} has been published" +docker run -d --name doctest -p 6030-6049:6030-6049 -p 6030-6049:6030-6049/udp tdengine/tdengine-${dockername}:${version} +sleep 2 +curl -u root:taosdata -d 'show variables;' 127.0.0.1:6041/rest/sql > temp1.data +data_version=$( cat temp1.data |jq .data| jq '.[]' |grep "version" -A 2 -B 1 | jq ".[1]") +echo "${data_version}" +if [ "${data_version}" == "\"${version}\"" ] ; then + echo "docker version is right " +else + echo "docker version is wrong " + exit 1 +fi +rm -rf temp1.data + +# set this version to latest version +if [ ${dockerLatest} == 'y' ] ;then + docker tag tdengine/tdengine-${dockername}:${version} tdengine/tdengine-${dockername}:latest + docker push tdengine/tdengine-${dockername}:latest + echo ">>>>>>>>>>>>> check whether tdengine/tdengine-${dockername}:latest has been published correctly" + docker run -d --name doctestla -p 7030-7049:6030-6049 -p 7030-7049:6030-6049/udp tdengine/tdengine-${dockername}:latest + sleep 2 + curl -u root:taosdata -d 'show variables;' 127.0.0.1:7041/rest/sql > temp2.data + version_latest=` cat temp2.data |jq .data| jq '.[]' |grep "version" -A 2 -B 1 | jq ".[1]" ` + echo "${version_latest}" + if [ "${version_latest}" == "\"${version}\"" ] ; then + echo "docker version is right " + else + echo "docker version is wrong " + exit 1 + fi +fi +rm -rf temp2.data + +if [ -n "$(docker ps -aq)" ] ;then + echo "delte docker process" + docker stop $(docker ps -aq) + docker rm $(docker ps -aq) +fi + +cd ${scriptDir} rm -f ${pkgFile} diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index dcc615132896e25c7f18398643576608b344f58e..c3dd3506cbf1c22307727c0fb5e3bbdd76cac00e 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -68,7 +68,7 @@ cp %{_compiledir}/../packaging/tools/set_core.sh %{buildroot}%{homepath}/bin cp %{_compiledir}/../packaging/tools/taosd-dump-cfg.gdb %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin -cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin +#cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin if [ -f %{_compiledir}/build/bin/taosadapter ]; then cp %{_compiledir}/build/bin/taosadapter %{buildroot}%{homepath}/bin ||: diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index ee01252b5ff6ade06ea6526315ab960657a5705b..19fa1f969e39ee46434a6127cd8823e252804d2a 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -827,9 +827,11 @@ function update_TDengine() { install_log install_header install_lib -# if [ "$pagMode" != "lite" ]; then -# install_connector -# fi + + if [ "$verMode" == "cluster" ]; then + install_connector + fi + install_examples if [ -z $1 ]; then install_bin @@ -912,9 +914,9 @@ function install_TDengine() { #install_avro lib #install_avro lib64 - # if [ "$pagMode" != "lite" ]; then - # install_connector - # fi + if [ "$verMode" == "cluster" ]; then + install_connector + fi install_examples if [ -z $1 ]; then # install service and client diff --git a/packaging/tools/install_client.sh b/packaging/tools/install_client.sh index baef60886405a8bafaf28a263d233d6846b5f911..28001fb769e5f3b6b59680c398ab683a287f1352 100755 --- a/packaging/tools/install_client.sh +++ b/packaging/tools/install_client.sh @@ -21,6 +21,7 @@ tarName="taos.tar.gz" osType=Linux pagMode=full +verMode=edge if [ "$osType" != "Darwin" ]; then script_dir=$(dirname $(readlink -f "$0")) @@ -78,15 +79,19 @@ function kill_client() { } function install_main_path() { - #create install main dir and all sub dir - ${csudo}rm -rf ${install_main_dir} || : - ${csudo}mkdir -p ${install_main_dir} - ${csudo}mkdir -p ${install_main_dir}/cfg - ${csudo}mkdir -p ${install_main_dir}/bin - ${csudo}mkdir -p ${install_main_dir}/connector - ${csudo}mkdir -p ${install_main_dir}/driver + #create install main dir and all sub dir + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + ${csudo}mkdir -p ${install_main_dir}/driver + if [ $productName == "TDengine" ]; then ${csudo}mkdir -p ${install_main_dir}/examples - ${csudo}mkdir -p ${install_main_dir}/include + fi + ${csudo}mkdir -p ${install_main_dir}/include + if [ "$verMode" == "cluster" ]; then + ${csudo}mkdir -p ${install_main_dir}/connector + fi } function install_bin() { @@ -257,8 +262,8 @@ function update_TDengine() { install_header install_lib install_jemalloc - if [ "$pagMode" != "lite" ]; then - install_connector + if [ "$verMode" == "cluster" ]; then + install_connector fi install_examples install_bin @@ -271,31 +276,31 @@ function update_TDengine() { } function install_TDengine() { - # Start to install - if [ ! -e ${tarName} ]; then - echo "File ${tarName} does not exist" - exit 1 - fi - tar -zxf ${tarName} + # Start to install + if [ ! -e ${tarName} ]; then + echo "File ${tarName} does not exist" + exit 1 + fi + tar -zxf ${tarName} - echo -e "${GREEN}Start to install ${productName} client...${NC}" + echo -e "${GREEN}Start to install ${productName} client...${NC}" - install_main_path - install_log - install_header - install_lib - install_jemalloc - if [ "$pagMode" != "lite" ]; then - install_connector - fi - install_examples - install_bin - install_config + install_main_path + install_log + install_header + install_lib + install_jemalloc + if [ "$verMode" == "cluster" ]; then + install_connector + fi + install_examples + install_bin + install_config - echo - echo -e "\033[44;32;1m${productName} client is installed successfully!${NC}" + echo + echo -e "\033[44;32;1m${productName} client is installed successfully!${NC}" - rm -rf $(tar -tf ${tarName}) + rm -rf $(tar -tf ${tarName}) } diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index b24759e640f172befb16d624abd62c6c9484255e..89865ae54f7b42b56c4ad4e85f51e4f84e0a720d 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -127,25 +127,60 @@ if [ "$osType" == "Darwin" ]; then sed 's/osType=Linux/osType=Darwin/g' ${install_dir}/install_client.sh >>install_client_temp.sh mv install_client_temp.sh ${install_dir}/install_client.sh fi + +if [ "$verMode" == "cluster" ]; then + sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/install_client.sh >>install_client_temp.sh + mv install_client_temp.sh ${install_dir}/install_client.sh +fi + if [ "$pagMode" == "lite" ]; then sed 's/pagMode=full/pagMode=lite/g' ${install_dir}/install_client.sh >>install_client_temp.sh mv install_client_temp.sh ${install_dir}/install_client.sh fi chmod a+x ${install_dir}/install_client.sh -# Copy example code -mkdir -p ${install_dir}/examples -examples_dir="${top_dir}/examples" -cp -r ${examples_dir}/c ${install_dir}/examples -if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then - cp -r ${examples_dir}/JDBC ${install_dir}/examples - cp -r ${examples_dir}/matlab ${install_dir}/examples - cp -r ${examples_dir}/python ${install_dir}/examples - cp -r ${examples_dir}/R ${install_dir}/examples - cp -r ${examples_dir}/go ${install_dir}/examples - cp -r ${examples_dir}/nodejs ${install_dir}/examples - cp -r ${examples_dir}/C# ${install_dir}/examples - mkdir -p ${install_dir}/examples/taosbenchmark-json && cp ${examples_dir}/../src/kit/taos-tools/example/* ${install_dir}/examples/taosbenchmark-json +if [[ $productName == "TDengine" ]]; then + # Copy example code + mkdir -p ${install_dir}/examples + examples_dir="${top_dir}/examples" + cp -r ${examples_dir}/c ${install_dir}/examples + if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then + cp -r ${examples_dir}/JDBC ${install_dir}/examples + cp -r ${examples_dir}/matlab ${install_dir}/examples + cp -r ${examples_dir}/python ${install_dir}/examples + cp -r ${examples_dir}/R ${install_dir}/examples + cp -r ${examples_dir}/go ${install_dir}/examples + cp -r ${examples_dir}/nodejs ${install_dir}/examples + cp -r ${examples_dir}/C# ${install_dir}/examples + mkdir -p ${install_dir}/examples/taosbenchmark-json && cp ${examples_dir}/../src/kit/taos-tools/example/* ${install_dir}/examples/taosbenchmark-json + fi + + if [ "$verMode" == "cluster" ]; then + # Copy connector + connector_dir="${code_dir}/connector" + mkdir -p ${install_dir}/connector + if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then + if [ "$osType" != "Darwin" ]; then + cp ${build_dir}/lib/*.jar ${install_dir}/connector || : + fi + if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then + cp -r ${connector_dir}/go ${install_dir}/connector + else + echo "WARNING: go connector not found, please check if want to use it!" + fi + git clone --depth 1 https://github.com/taosdata/taos-connector-python ${install_dir}/connector/python + rm -rf ${install_dir}/connector/python/.git ||: +# cp -r ${connector_dir}/python ${install_dir}/connector + git clone --depth 1 https://github.com/taosdata/taos-connector-node ${install_dir}/connector/nodejs + rm -rf ${install_dir}/connector/nodejs/.git ||: + + git clone --depth 1 https://github.com/taosdata/taos-connector-dotnet ${install_dir}/connector/dotnet + rm -rf ${install_dir}/connector/dotnet/.git ||: +# cp -r ${connector_dir}/nodejs ${install_dir}/connector + git clone --depth 1 https://github.com/taosdata/libtaos-rs ${install_dir}/connector/rust + rm -rf ${install_dir}/connector/rust/.git ||: + fi + fi fi # Copy driver mkdir -p ${install_dir}/driver diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 34198eae15fa44a13eb2dc97a2be3aebc98f3d64..21aa476fecf153f4c1a91f93390b5818c29b1127 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -67,10 +67,19 @@ else wget https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh -O ${build_dir}/bin/TDinsight.sh \ && echo "TDinsight.sh downloaded!" \ || echo "failed to download TDinsight.sh" + # download TDinsight caches + orig_pwd=$(pwd) + tdinsight_caches="" + cd ${build_dir}/bin/ && \ + chmod +x TDinsight.sh + tdinsight_caches=$(./TDinsight.sh --download-only | xargs -i printf "${build_dir}/bin/{} ") + cd $orig_pwd + echo "TDinsight caches: $tdinsight_caches" taostools_bin_files=" ${build_dir}/bin/taosdump \ ${build_dir}/bin/taosBenchmark \ - ${build_dir}/bin/TDinsight.sh " + ${build_dir}/bin/TDinsight.sh \ + $tdinsight_caches" bin_files="${build_dir}/bin/${serverName} \ ${build_dir}/bin/${clientName} \ @@ -287,20 +296,34 @@ fi mkdir -p ${install_dir}/driver && cp ${lib_files} ${install_dir}/driver && echo "${versionComp}" >${install_dir}/driver/vercomp.txt # Copy connector -#connector_dir="${code_dir}/connector" -#mkdir -p ${install_dir}/connector -#if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then -# cp ${build_dir}/lib/*.jar ${install_dir}/connector || : -# if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then -# cp -r ${connector_dir}/go ${install_dir}/connector -# else -# echo "WARNING: go connector not found, please check if want to use it!" -# fi -# cp -r ${connector_dir}/python ${install_dir}/connector -# cp -r ${connector_dir}/nodejs ${install_dir}/connector -#fi +if [ "$verMode" == "cluster" ]; then + connector_dir="${code_dir}/connector" + mkdir -p ${install_dir}/connector + if [[ "$pagMode" != "lite" ]] && [[ "$cpuType" != "aarch32" ]]; then + cp ${build_dir}/lib/*.jar ${install_dir}/connector || : + if find ${connector_dir}/go -mindepth 1 -maxdepth 1 | read; then + cp -r ${connector_dir}/go ${install_dir}/connector + else + echo "WARNING: go connector not found, please check if want to use it!" + fi + git clone --depth 1 https://github.com/taosdata/taos-connector-python ${install_dir}/connector/python + rm -rf ${install_dir}/connector/python/.git ||: + + git clone --depth 1 https://github.com/taosdata/taos-connector-node ${install_dir}/connector/nodejs + rm -rf ${install_dir}/connector/nodejs/.git ||: + + git clone --depth 1 https://github.com/taosdata/taos-connector-dotnet ${install_dir}/connector/dotnet + rm -rf ${install_dir}/connector/dotnet/.git ||: + + git clone --depth 1 https://github.com/taosdata/libtaos-rs ${install_dir}/connector/rust + rm -rf ${install_dir}/connector/rust/.git ||: + # cp -r ${connector_dir}/python ${install_dir}/connector + # cp -r ${connector_dir}/nodejs ${install_dir}/connector + fi +fi + # Copy release note -# cp ${script_dir}/release_note ${install_dir} +cp ${script_dir}/release_note ${install_dir} # exit 1 diff --git a/src/client/inc/tscUtil.h b/src/client/inc/tscUtil.h index e380dc77768a97a267ce80f8fb20273acb389fa7..f7d3aa630f24e0054a1ce963e6a1939a511fe4d7 100644 --- a/src/client/inc/tscUtil.h +++ b/src/client/inc/tscUtil.h @@ -400,7 +400,7 @@ void tscRemoveCachedTableMeta(STableMetaInfo* pTableMetaInfo, uint64_t id); char* cloneCurrentDBName(SSqlObj* pSql); -int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, int16_t startColId); +int parseJsontoTagData(char* json, uint32_t jsonLength, SKVRowBuilder* kvRowBuilder, char* errMsg, int16_t startColId); int8_t jsonType2DbType(double data, int jsonType); void getJsonKey(SStrToken *t0); diff --git a/src/client/src/taos.def b/src/client/src/taos.def index b3f232bb7b33b93c50dfb35536b4ebe6e633e95c..7a4e842d0c7b4ba4ff9d0e87ebd4c95f734260ea 100644 --- a/src/client/src/taos.def +++ b/src/client/src/taos.def @@ -41,8 +41,6 @@ taos_fetch_rows_a taos_subscribe taos_consume taos_unsubscribe -taos_open_stream -taos_close_stream taos_load_table_info taos_data_type taos_stmt_set_sub_tbname @@ -57,4 +55,4 @@ taos_print_row_ex taos_stmt_affected_rows taos_is_update_query taos_reset_current_db -taos_parse_time \ No newline at end of file +taos_parse_time diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index f648baa9744cf00545e3f96b736661dce6e958e0..81d658d964dc2a404e04f363751e0a17ebe6e46f 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -240,6 +240,18 @@ static int32_t tscGetNthFieldResult(TAOS_ROW row, TAOS_FIELD* fields, int *lengt case TSDB_DATA_TYPE_BIGINT: sprintf(result, "%"PRId64, *((int64_t *)val)); break; + case TSDB_DATA_TYPE_UTINYINT: + sprintf(result, "%u", *((uint8_t *)val)); + break; + case TSDB_DATA_TYPE_USMALLINT: + sprintf(result, "%u", *((uint16_t *)val)); + break; + case TSDB_DATA_TYPE_UINT: + sprintf(result, "%u", *((uint32_t *)val)); + break; + case TSDB_DATA_TYPE_UBIGINT: + sprintf(result, "%"PRIu64, *((uint64_t *)val)); + break; case TSDB_DATA_TYPE_FLOAT: sprintf(result, "%f", GET_FLOAT_VAL(val)); break; diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index c5719dde276abecd667efc95a960ab1a45af6962..af8c6837219cc32e22491427f04a19f70a8e50b0 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -1068,7 +1068,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC tfree(tmp); return tscSQLSyntaxErrMsg(pInsertParam->msg, "json tag too long", NULL); } - code = parseJsontoTagData(sToken.z, &kvRowBuilder, pInsertParam->msg, pTagSchema[spd.boundedColumns[0]].colId); + code = parseJsontoTagData(sToken.z, sToken.n, &kvRowBuilder, pInsertParam->msg, pTagSchema[spd.boundedColumns[0]].colId); if (code != TSDB_CODE_SUCCESS) { tdDestroyKVRowBuilder(&kvRowBuilder); tscDestroyBoundColumnInfo(&spd); diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index 19b78dd8d45a9d770570e6d42bc19fa01110692b..611038d98e46e7cc36f7b3889901ee57f28de20a 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -178,10 +178,10 @@ static int32_t getSmlMd5ChildTableName(TAOS_SML_DATA_POINT* point, char* tableNa } size_t len = 0; char* keyJoined = taosStringBuilderGetResult(&sb, &len); - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); - MD5Final(&context); + T_MD5_CTX context; + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); + tMD5Final(&context); uint64_t digest1 = *(uint64_t*)(context.digest); uint64_t digest2 = *(uint64_t*)(context.digest + 8); *tableNameLen = snprintf(tableName, *tableNameLen, diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index bfc3b9f0be1cedfe1e7c3d66f1fa3ab16f5d37f3..537e4eb35a6e6b8db2587eb66d420e2f9d77e5b6 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -24,6 +24,7 @@ #include "taos.h" #include "tscUtil.h" +void taos_close_stream(TAOS_STREAM *handle); void tscSaveSlowQueryFp(void *handle, void *tmrId); TAOS *tscSlowQueryConn = NULL; bool tscSlowQueryConnInitialized = false; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 2ab7e93c388e4e195f1c961f8a43089b0fc5aa65..43716a65b1350d8e21783d436da4759b8cfca49c 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -282,6 +282,8 @@ static uint8_t convertRelationalOperator(SStrToken *pToken) { return TSDB_BINARY_OP_DIVIDE; case TK_REM: return TSDB_BINARY_OP_REMAINDER; + case TK_BITAND: + return TSDB_BINARY_OP_BITAND; case TK_LIKE: return TSDB_RELATION_LIKE; case TK_MATCH: @@ -1849,8 +1851,6 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 } } - // expr string is set as the parameter of function - SColumnIndex index = {.tableIndex = tableIndex}; tExprNode* pNode = NULL; SArray* colList = taosArrayInit(10, sizeof(SColIndex)); @@ -1889,9 +1889,11 @@ static int32_t handleScalarTypeExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32 return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } - + SColumnIndex index = {.tableIndex = tableIndex}; SExprInfo* pExpr = tscExprAppend(pQueryInfo, TSDB_FUNC_SCALAR_EXPR, &index, pNode->resultType, pNode->resultBytes, getNewResColId(pCmd), 0, false); + // set the colId to the result column id + pExpr->base.colInfo.colId = pExpr->base.resColId; char* name = (pItem->aliasName != NULL)? pItem->aliasName:pItem->pNode->exprToken.z; size_t len = MIN(sizeof(pExpr->base.aliasName), pItem->pNode->exprToken.n + 1); @@ -3360,13 +3362,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col tVariantDump(pVariant, val, TSDB_DATA_TYPE_BIGINT, true); if(functionId == TSDB_FUNC_UNIQUE){ // consider of memory size - if(pSchema->bytes < 10){ - GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS * 100; - }else if(pSchema->bytes < 100){ - GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS * 10; - }else{ - GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS; - } + GET_INT64_VAL(val) = MAX_UNIQUE_RESULT_ROWS; } int64_t numRowsSelected = GET_INT64_VAL(val); @@ -3589,7 +3585,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col } pVariant = &pParamElem[2].pNode->value; - if (pVariant == NULL && pVariant->nType != TSDB_DATA_TYPE_BINARY) { + if (pVariant == NULL || pVariant->nType != TSDB_DATA_TYPE_BINARY) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } @@ -4427,8 +4423,8 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd const char* msg4 = "join query does not support group by"; const char* msg5 = "not allowed column type for group by"; const char* msg6 = "tags not allowed for table query"; - const char* msg7 = "not support group by expression"; - const char* msg8 = "normal column can only locate at the end of group by clause"; + //const char* msg7 = "not support group by expression"; + //const char* msg8 = "normal column can only locate at the end of group by clause"; const char* msg9 = "json tag must be use ->'key'"; const char* msg10 = "non json column can not use ->'key'"; const char* msg11 = "group by json->'key' is too long"; @@ -4552,19 +4548,6 @@ int32_t validateGroupbyNode(SQueryInfo* pQueryInfo, SArray* pList, SSqlCmd* pCmd } } - // 1. only one normal column allowed in the group by clause - // 2. the normal column in the group by clause can only located in the end position - if (numOfGroupCols > 1) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg7); - } - - for(int32_t i = 0; i < num; ++i) { - SColIndex* pIndex = taosArrayGet(pGroupExpr->columnInfo, i); - if (TSDB_COL_IS_NORMAL_COL(pIndex->flag) && i != num - 1) { - return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg8); - } - } - pQueryInfo->groupbyExpr.tableIndex = tableIndex; return TSDB_CODE_SUCCESS; } @@ -4827,7 +4810,7 @@ static int32_t getColQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlEx }; if (pQueryInfo->colCond == NULL) { - pQueryInfo->colCond = taosArrayInit(2, sizeof(SCond)); + pQueryInfo->colCond = taosArrayInit(2, sizeof(STblCond)); } taosArrayPush(pQueryInfo->colCond, &cond); @@ -7106,6 +7089,10 @@ int32_t validateOrderbyNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SSqlNode* pSq return invalidOperationMsg(pMsgBuf, msg1); } + if (index.columnIndex == TSDB_TBNAME_COLUMN_INDEX) { + return invalidOperationMsg(pMsgBuf, msg1); + } + if (udf) { return invalidOperationMsg(pMsgBuf, msg11); } @@ -7364,7 +7351,7 @@ int32_t setAlterTableInfo(SSqlObj* pSql, struct SSqlInfo* pInfo) { int8_t tagVal = TSDB_DATA_JSON_PLACEHOLDER; tdAddColToKVRow(&kvRowBuilder, pTagsSchema->colId, pTagsSchema->type, &tagVal, false); - code = parseJsontoTagData(pItem->pVar.pz, &kvRowBuilder, pMsg, pTagsSchema->colId); + code = parseJsontoTagData(pItem->pVar.pz, pItem->pVar.nLen, &kvRowBuilder, pMsg, pTagsSchema->colId); if (code != TSDB_CODE_SUCCESS) { tdDestroyKVRowBuilder(&kvRowBuilder); return code; @@ -7713,16 +7700,18 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) { const int tokenBalance = 2; const int tokenMonitor = 3; const int tokenDebugFlag = 4; - const int tokenDebugFlagEnd = 20; - const int tokenOfflineInterval = 21; + const int tokenDebugFlagEnd = 19; + const int tokenOfflineInterval = 20; + const int tokenKeepTimeOffset = 21; const SDNodeDynConfOption cfgOptions[] = { {"resetLog", 8}, {"resetQueryCache", 15}, {"balance", 7}, {"monitor", 7}, {"debugFlag", 9}, {"monDebugFlag", 12}, {"vDebugFlag", 10}, {"mDebugFlag", 10}, {"cDebugFlag", 10}, {"httpDebugFlag", 13}, {"qDebugflag", 10}, {"sdbDebugFlag", 12}, {"uDebugFlag", 10}, {"tsdbDebugFlag", 13}, {"sDebugflag", 10}, {"rpcDebugFlag", 12}, - {"dDebugFlag", 10}, {"mqttDebugFlag", 13}, {"wDebugFlag", 10}, {"tmrDebugFlag", 12}, + {"dDebugFlag", 10}, {"wDebugFlag", 10}, {"tmrDebugFlag", 12}, {"cqDebugFlag", 11}, {"offlineInterval", 15}, + {"keepTimeOffset", 14}, }; SStrToken* pOptionToken = taosArrayGet(pOptions->a, 1); @@ -7762,6 +7751,14 @@ int32_t validateDNodeConfig(SMiscInfo* pOptions) { return TSDB_CODE_TSC_INVALID_OPERATION; // options value is invalid } return TSDB_CODE_SUCCESS; + } else if ((strncasecmp(cfgOptions[tokenKeepTimeOffset].name, pOptionToken->z, pOptionToken->n) == 0) && + (cfgOptions[tokenKeepTimeOffset].len == pOptionToken->n)) { + SStrToken* pValToken = taosArrayGet(pOptions->a, 2); + int32_t val = strtol(pValToken->z, NULL, 10); + if (val < -23 || val > 23) { + return TSDB_CODE_TSC_INVALID_OPERATION; // options value is invalid + } + return TSDB_CODE_SUCCESS; } else { SStrToken* pValToken = taosArrayGet(pOptions->a, 2); @@ -8268,6 +8265,24 @@ static void updateTagPrjFunction(SQueryInfo* pQueryInfo) { } } +/* + retrun false : expr is not in groupbu column. + return true : expr is in groupby column. +*/ +static bool check_expr_in_groupby_colum(SGroupbyExpr* pGroupbyExpr, SExprInfo* pExpr){ + SColIndex* pIndex = NULL; + assert( pExpr); + if (NULL == pGroupbyExpr) + return false; + for (int32_t k = 0; k < pGroupbyExpr->numOfGroupCols ; ++k) { + pIndex = taosArrayGet(pGroupbyExpr->columnInfo, k); + if (!strcmp(pIndex->name,&pExpr->base.colInfo.name[1])){ // notes:first char is dot, skip one char. + return true; + } + } + return false; +} + /* * check for selectivity function + tags column function both exist. * 1. tagprj functions are not compatible with aggregated function when missing "group by" clause @@ -8285,12 +8300,15 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) { int16_t numOfTimeWindow = 0; size_t numOfExprs = taosArrayGetSize(pQueryInfo->exprList); + SGroupbyExpr* pGroupbyExpr = &pQueryInfo->groupbyExpr; for (int32_t i = 0; i < numOfExprs; ++i) { SExprInfo* pExpr = taosArrayGetP(pQueryInfo->exprList, i); if (pExpr->base.functionId == TSDB_FUNC_TAGPRJ || (pExpr->base.functionId == TSDB_FUNC_PRJ && pExpr->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX)) { - tagTsColExists = true; // selectivity + ts/tag column - break; + if (false == check_expr_in_groupby_colum(pGroupbyExpr,pExpr)) { + tagTsColExists = true; // selectivity + ts/tag column + break; + } } } @@ -8514,7 +8532,8 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* const char* msg4 = "retrieve tags not compatible with group by or interval query"; const char* msg5 = "functions can not be mixed up"; const char* msg6 = "TWA/Diff/Derivative/Irate/CSum/MAvg/Elapsed/stateCount/stateDuration only support group by tbname"; - const char* msg7 = "unique/state function does not supportted in state window query"; + const char* msg7 = "unique/state function not supported in state window query"; + const char* msg8 = "histogram function not supported in time window query"; // only retrieve tags, group by is not supportted if (tscQueryTags(pQueryInfo)) { @@ -8528,10 +8547,19 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* return TSDB_CODE_SUCCESS; } } + if (tscIsProjectionQuery(pQueryInfo) && tscIsSessionWindowQuery(pQueryInfo)) { return invalidOperationMsg(msg, msg3); } + size_t numOfExprs = tscNumOfExprs(pQueryInfo); + for (int32_t i = 0; i < numOfExprs; ++i) { + SExprInfo* pExpr = tscExprGet(pQueryInfo, i); + if ((isTimeWindowQuery(pQueryInfo) || pQueryInfo->stateWindow) && pExpr->base.functionId == TSDB_FUNC_HISTOGRAM) { + return invalidOperationMsg(msg, msg8); + } + } + if (pQueryInfo->groupbyExpr.numOfGroupCols > 0) { // check if all the tags prj columns belongs to the group by columns if (onlyTagPrjFunction(pQueryInfo) && allTagPrjInGroupby(pQueryInfo)) { @@ -8575,7 +8603,7 @@ int32_t doFunctionsCompatibleCheck(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, char* } } - if (pQueryInfo->stateWindow && (f == TSDB_FUNC_UNIQUE || f == TSDB_FUNC_STATE_COUNT || f == TSDB_FUNC_STATE_DURATION)){ + if (pQueryInfo->stateWindow && (f == TSDB_FUNC_UNIQUE || f == TSDB_FUNC_STATE_COUNT || f == TSDB_FUNC_STATE_DURATION)) { return invalidOperationMsg(msg, msg7); } @@ -9170,7 +9198,7 @@ int32_t doCheckForCreateFromStable(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg3); } - ret = parseJsontoTagData(pItem->pVar.pz, &kvRowBuilder, tscGetErrorMsgPayload(pCmd), pTagSchema[0].colId); + ret = parseJsontoTagData(pItem->pVar.pz, pItem->pVar.nLen, &kvRowBuilder, tscGetErrorMsgPayload(pCmd), pTagSchema[0].colId); if (ret != TSDB_CODE_SUCCESS) { tdDestroyKVRowBuilder(&kvRowBuilder); return ret; @@ -10113,7 +10141,7 @@ static STableMeta* extractTempTableMetaFromSubquery(SQueryInfo* pUpstream) { static int32_t doValidateSubquery(SSqlNode* pSqlNode, int32_t index, SSqlObj* pSql, SQueryInfo* pQueryInfo, char* msgBuf) { SRelElementPair* subInfo = taosArrayGet(pSqlNode->from->list, index); - // union all is not support currently + // union all is not supported currently SSqlNode* p = taosArrayGetP(subInfo->pSubquery, 0); if (taosArrayGetSize(subInfo->pSubquery) >= 2) { return invalidOperationMsg(msgBuf, "not support union in subquery"); @@ -10663,6 +10691,23 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS } } + if (pSqlExpr->tokenId == TK_BITAND && pSqlExpr->pLeft != NULL && pSqlExpr->pRight != NULL) { + // for example: col type is "bool" but expr "col & 1" received + uint8_t colType = pLeft->pSchema->type; + SStrToken *exprToken = &pSqlExpr->pRight->exprToken; + if (pSqlExpr->pLeft->type == SQL_NODE_TABLE_COLUMN && pSqlExpr->pRight->type == SQL_NODE_VALUE) { + if (colType == TSDB_DATA_TYPE_BOOL) { + if ((exprToken->n != 4 || strncasecmp(exprToken->z, "true", 4)) && (exprToken->n != 5 || strncasecmp(exprToken->z, "false", 5))) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } else if (IS_SIGNED_NUMERIC_TYPE(colType) || IS_UNSIGNED_NUMERIC_TYPE(colType)) { + if ((exprToken->n == 4 && strncasecmp(exprToken->z, "true", 4) == 0) || (exprToken->n == 5 || strncasecmp(exprToken->z, "false", 5) == 0)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + } + } + if (pSqlExpr->pRight != NULL) { int32_t ret = exprTreeFromSqlExpr(pCmd, &pRight, pSqlExpr->pRight, pQueryInfo, pCols, uid); if (ret != TSDB_CODE_SUCCESS) { @@ -10700,9 +10745,11 @@ int32_t exprTreeFromSqlExpr(SSqlCmd* pCmd, tExprNode **pExpr, const tSqlExpr* pS if (pLeft->_node.optr == TSDB_RELATION_ARROW){ pLeft = pLeft->_node.pLeft; } - if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL && pLeft->nodeType == TSQL_NODE_COL && - (pLeft->pSchema->type == TSDB_DATA_TYPE_BOOL || pLeft->pSchema->type == TSDB_DATA_TYPE_JSON)) { - return TSDB_CODE_TSC_INVALID_OPERATION; + if (pRight->pVal->nType == TSDB_DATA_TYPE_BOOL && pLeft->nodeType == TSQL_NODE_COL) { + if (((*pExpr)->_node.optr != TSDB_BINARY_OP_BITAND && pLeft->pSchema->type == TSDB_DATA_TYPE_BOOL) || + pLeft->pSchema->type == TSDB_DATA_TYPE_JSON) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } } } } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 59c0da340b1f241c2a8240714e4d5de8ac249437..879fed06669162dbf10f48c00415c7246b5548a6 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -222,6 +222,8 @@ TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, return pObj; } + printf("connect failed, reason: %s\n\n", taos_errstr(pSql)); + return NULL; } diff --git a/src/client/src/tscStream.c b/src/client/src/tscStream.c index e2779854e096fcea454db76c26ff365a9f6e1309..0ed4c0a270ca675dfc445f387ad48de5171df7d9 100644 --- a/src/client/src/tscStream.c +++ b/src/client/src/tscStream.c @@ -26,6 +26,7 @@ #include "tscProfile.h" #include "tscSubquery.h" +void taos_close_stream(TAOS_STREAM *handle); static void tscProcessStreamQueryCallback(void *param, TAOS_RES *tres, int numOfRows); static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOfRows); static void tscSetNextLaunchTimer(SSqlStream *pStream, SSqlObj *pSql); diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index fe3f1b4c40f752ffc3c255e918c246fdc6d52f07..4482f846d902e673eb5d7d15c8ffe2db899c725f 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -1213,7 +1213,7 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar for (int32_t i = 0; i < joinNum; ++i) { // reorganize the tid-tag value according to both the vgroup id and tag values // sort according to the tag value - size_t num = taosArrayGetSize(ctxlist[i].res); + int32_t num = (int32_t) taosArrayGetSize(ctxlist[i].res); int32_t ret = tidTagsMergeSort(ctxlist[i].res, 0, num - 1, size); if (ret != TSDB_CODE_SUCCESS) { @@ -1222,7 +1222,7 @@ static int32_t getIntersectionOfTableTuple(SQueryInfo* pQueryInfo, SSqlObj* pPar taosArrayPush(resList, &ctxlist[i].res); - tscDebug("0x%"PRIx64" tags match complete, result num: %"PRIzu, pParentSql->self, num); + tscDebug("0x%"PRIx64" tags match complete, result num: %d", pParentSql->self, num); } return TSDB_CODE_SUCCESS; @@ -1672,7 +1672,7 @@ static void joinRetrieveFinalResCallback(void* param, TAOS_RES* tres, int numOfR if (pRes1->row > 0 && pRes1->numOfRows > 0) { tscDebug("0x%"PRIx64" sub:0x%"PRIx64" index:%d numOfRows:%d total:%"PRId64 " (not retrieve)", pParentSql->self, pParentSql->pSubs[i]->self, i, pRes1->numOfRows, pRes1->numOfTotal); - assert(pRes1->row < pRes1->numOfRows); + assert(pRes1->row < pRes1->numOfRows || (pRes1->row == pRes1->numOfRows && pRes1->completed)); } else { if (!stableQuery) { pRes1->numOfClauseTotal += pRes1->numOfRows; @@ -1841,7 +1841,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) { SSqlRes* pRes1 = &pSql1->res; - if (pRes1->row >= pRes1->numOfRows) { + if (pRes1->row >= pRes1->numOfRows && !pRes1->completed) { subquerySetState(pSql1, &pSql->subState, i, 0); } } @@ -1863,7 +1863,7 @@ void tscFetchDatablockForSubquery(SSqlObj* pSql) { STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, 0); - if (pRes1->row >= pRes1->numOfRows) { + if (pRes1->row >= pRes1->numOfRows && !pRes1->completed) { tscDebug("0x%"PRIx64" subquery:0x%"PRIx64" retrieve data from vnode, subquery:%d, vgroupIndex:%d", pSql->self, pSql1->self, pSupporter->subqueryIndex, pTableMetaInfo->vgroupIndex); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index ee676cfa021ae841c8b55d3bc80aa3e66d9da1d7..47efc29031b972818fbc540150613b61c0b199c5 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -116,9 +116,26 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le return TSDB_CODE_TSC_INVALID_VALUE; } - *str = '\''; + bool squote = false; + for (int32_t i = 0; i < bufSize; ++i) { + if (((char *)buf)[i] == '\'') { + squote = true; + break; + } + } + + if (squote) { + *str = '\"'; + } else { + *str = '\''; + } + memcpy(str + 1, buf, bufSize); - *(str + bufSize + 1) = '\''; + if (squote) { + *(str + bufSize + 1) = '\"'; + } else { + *(str + bufSize + 1) = '\''; + } n = bufSize + 2; break; @@ -978,6 +995,26 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterI pColData->pData = pRes->urow[i]; } + if (pColData->info.type == TSDB_DATA_TYPE_NCHAR) { + int32_t rows = pBlock->info.rows; + int32_t bytes = pColData->info.bytes; + char *dstData = malloc(bytes * rows); + char *srcData = pColData->pData; + for (int32_t j = 0; j < rows; ++j) { + char *srcRow = srcData + bytes * j; + char *dstRow = dstData + bytes * j; + if(isNull(srcRow, TSDB_DATA_TYPE_NCHAR)){ + varDataCopy(dstRow, srcRow); + continue; + } + int32_t len = 0; + taosMbsToUcs4(varDataVal(srcRow), varDataLen(srcRow), varDataVal(dstRow), + bytes-VARSTR_HEADER_SIZE, &len); + varDataSetLen(dstRow, len); + } + memcpy(srcData, dstData, bytes*rows); + free(dstData); + } offset += pColData->info.bytes; } @@ -986,14 +1023,9 @@ static void doSetupSDataBlock(SSqlRes* pRes, SSDataBlock* pBlock, void* pFilterI SColumnDataParam param = {.numOfCols = pBlock->info.numOfCols, .pDataBlock = pBlock->pDataBlock}; filterSetColFieldData(pFilterInfo, ¶m, getColumnDataFromId); - bool gotNchar = false; - filterConverNcharColumns(pFilterInfo, pBlock->info.rows, &gotNchar); int8_t* p = NULL; //bool all = doFilterDataBlock(pFilterInfo, numOfFilterCols, pBlock->info.rows, p); bool all = filterExecute(pFilterInfo, pBlock->info.rows, &p, NULL, 0); - if (gotNchar) { - filterFreeNcharColumns(pFilterInfo); - } if (!all) { if (p) { doCompactSDataBlock(pBlock, pBlock->info.rows, p); @@ -1496,6 +1528,11 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue tscDebug("0x%"PRIx64" create QInfo 0x%"PRIx64" to execute the main query while all nest queries are ready", pSql->self, pSql->self); px->pQInfo = createQInfoFromQueryNode(px, &tableGroupInfo, pSourceOperator, NULL, NULL, MASTER_SCAN, pSql->self); + if (px->pQInfo == NULL) { + tscAsyncResultOnError(pSql); + pOutput->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + return; + } px->pQInfo->runtimeEnv.udfIsCopy = true; px->pQInfo->runtimeEnv.pUdfInfo = pUdfInfo; @@ -1508,7 +1545,7 @@ void handleDownstreamOperator(SSqlObj** pSqlObjList, int32_t numOfUpstream, SQue uint64_t qId = pSql->self; qTableQuery(px->pQInfo, &qId); - convertQueryResult(pOutput, px, pSql->self, false, false); + convertQueryResult(pOutput, px, pSql->self, true, false); } static void tscDestroyResPointerInfo(SSqlRes* pRes) { @@ -2979,7 +3016,8 @@ int32_t tscValidateName(SStrToken* pToken, bool escapeEnabled, bool *dbIncluded) if (sep == NULL) { return TSDB_CODE_TSC_INVALID_OPERATION; } - *dbIncluded = true; + + if (dbIncluded) *dbIncluded = true; return tscValidateName(pToken, escapeEnabled, NULL); } @@ -4244,6 +4282,10 @@ void executeQuery(SSqlObj* pSql, SQueryInfo* pQueryInfo) { } return; + } else if (hasMoreClauseToTry(pSql)) { + if (pthread_mutex_init(&pSql->subState.mutex, NULL) != 0) { + goto _error; + } } pSql->cmd.active = pQueryInfo; @@ -5393,7 +5435,7 @@ char* cloneCurrentDBName(SSqlObj* pSql) { return p; } -int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, int16_t startColId){ +int parseJsontoTagData(char* json, uint32_t jsonLength, SKVRowBuilder* kvRowBuilder, char* errMsg, int16_t startColId){ // set json NULL data uint8_t nullTypeVal[CHAR_BYTES + VARSTR_HEADER_SIZE + INT_BYTES] = {0}; uint32_t jsonNULL = TSDB_DATA_JSON_NULL; @@ -5404,7 +5446,7 @@ int parseJsontoTagData(char* json, SKVRowBuilder* kvRowBuilder, char* errMsg, in varDataSetLen(nullTypeVal + CHAR_BYTES, INT_BYTES); *(uint32_t*)(varDataVal(nullTypeKey)) = jsonNULL; tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, nullTypeKey, false); // add json null type - if (!json || strtrim(json) == 0 || strncasecmp(json, "null", 4) == 0){ + if (!json || strtrim(json) == 0 || (jsonLength == strlen("null") && strncasecmp(json, "null", 4) == 0)){ *(uint32_t*)(varDataVal(nullTypeVal + CHAR_BYTES)) = jsonNULL; tdAddColToKVRow(kvRowBuilder, jsonIndex++, TSDB_DATA_TYPE_NCHAR, nullTypeVal, true); // add json null value return TSDB_CODE_SUCCESS; diff --git a/src/client/tests/CMakeLists.txt b/src/client/tests/CMakeLists.txt index 6ba6d5f6a800f63989249afbaaf6973708963745..457bc732ee41d1106c2ee7445334af8765cfa028 100644 --- a/src/client/tests/CMakeLists.txt +++ b/src/client/tests/CMakeLists.txt @@ -12,7 +12,9 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) SET(CMAKE_CXX_STANDARD 11) INCLUDE_DIRECTORIES(/usr/include /usr/local/include) - LINK_DIRECTORIES(/usr/lib /usr/local/lib) + IF (NOT LIB_GTEST_STATIC_DIR) + LINK_DIRECTORIES(/usr/lib /usr/local/lib) + ENDIF() AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 06ed93b110281756ade98d5e99dd4b57b4924fc3..3add0b566dffb88d0a60e70c6098fd6586d3b689 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -43,6 +43,8 @@ extern int64_t tsArbOnlineTimestamp; extern int32_t tsDnodeId; extern int64_t tsDnodeStartTime; extern int8_t tsDnodeNopLoop; +extern int32_t tsTcpConnTimeout; +extern int32_t tsSyncCheckInterval; // common extern int tsRpcTimer; @@ -140,15 +142,6 @@ extern int8_t tsTelegrafUseFieldNum; extern int8_t tsHttpDbNameMandatory; extern int32_t tsHttpKeepAlive; -// mqtt -extern int8_t tsEnableMqttModule; -extern char tsMqttHostName[]; -extern char tsMqttPort[]; -extern char tsMqttUser[]; -extern char tsMqttPass[]; -extern char tsMqttClientId[]; -extern char tsMqttTopic[]; - // monitor extern int8_t tsEnableMonitorModule; extern int8_t tsMonitorReplica; @@ -193,6 +186,7 @@ extern float tsReservedTmpDirectorySpace; extern float tsMinimalDataDirGB; extern int32_t tsTotalMemoryMB; extern uint32_t tsVersion; +extern int32_t tsKeepTimeOffset; // build info extern char version[]; @@ -213,7 +207,6 @@ extern int32_t jniDebugFlag; extern int32_t tmrDebugFlag; extern int32_t sdbDebugFlag; extern int32_t httpDebugFlag; -extern int32_t mqttDebugFlag; extern int32_t monDebugFlag; extern int32_t uDebugFlag; extern int32_t rpcDebugFlag; diff --git a/src/common/src/tarithoperator.c b/src/common/src/tarithoperator.c index 4a01fe57f8646029b51ec97f72ad1e17f9bf8634..6f3ac3e407c5ff2fe9d43a32e0514076a5fc4241 100644 --- a/src/common/src/tarithoperator.c +++ b/src/common/src/tarithoperator.c @@ -126,6 +126,9 @@ _arithmetic_getVectorDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) { typedef void* (*_arithmetic_getVectorValueAddr_fn_t)(void *src, int32_t index); +void* getVectorValueAddr_BOOL(void *src, int32_t index) { + return (void*)((bool *)src + index); +} void* getVectorValueAddr_TINYINT(void *src, int32_t index) { return (void*)((int8_t *)src + index); } @@ -159,7 +162,9 @@ void* getVectorValueAddr_DOUBLE(void *src, int32_t index) { _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) { _arithmetic_getVectorValueAddr_fn_t p = NULL; - if(srcType==TSDB_DATA_TYPE_TINYINT) { + if (srcType == TSDB_DATA_TYPE_BOOL) { + p = getVectorValueAddr_BOOL; + }else if(srcType == TSDB_DATA_TYPE_TINYINT) { p = getVectorValueAddr_TINYINT; }else if(srcType==TSDB_DATA_TYPE_UTINYINT) { p = getVectorValueAddr_UTINYINT; @@ -469,6 +474,271 @@ void vectorRemainder(void *left, int32_t len1, int32_t _left_type, void *right, } } +void vectorBitand(void *left, int32_t len1, int32_t _left_type, void *right, int32_t len2, int32_t _right_type, void *out, int32_t _ord) { + int32_t i = (_ord == TSDB_ORDER_ASC) ? 0 : MAX(len1, len2) - 1; + int32_t step = (_ord == TSDB_ORDER_ASC) ? 1 : -1; + char *output = out; + _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnLeft = getVectorValueAddrFn(_left_type); + _arithmetic_getVectorValueAddr_fn_t getVectorValueAddrFnRight = getVectorValueAddrFn(_right_type); + + if (len1 == (len2)) { + for (; i >= 0 && i < (len2); i += step) { + if (isNull(getVectorValueAddrFnLeft(left, i), _left_type) || isNull(getVectorValueAddrFnRight(right, i), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } + + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = (*((bool *) left + i)) & (*((bool *) right + i)); + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = (*((int8_t *) left + i)) & (*((int8_t *) right + i)); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = (*((int16_t *) left + i)) & (*((int16_t *) right + i)); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = (*((int32_t *) left + i)) & (*((int32_t *) right + i)); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = (*((int64_t *) left + i)) & (*((int64_t *) right + i)); + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = (*((uint8_t *) left + i)) & (*((uint8_t *) right + i)); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = (*((uint16_t *) left + i)) & (*((uint16_t *) right + i)); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = (*((uint32_t *) left + i)) & (*((uint32_t *) right + i)); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = (*((uint64_t *) left + i)) & (*((uint64_t *) right + i)); + output += sizeof(int64_t); + break; + } + } + } else if (len1 == 1) { + for (; i >= 0 && i < (len2); i += step) { + if (isNull(getVectorValueAddrFnLeft(left, 0), _left_type) || isNull(getVectorValueAddrFnRight(right, i), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } + + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = (*(bool *) left) & (*((bool *) right + i)); + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = (*(int8_t *) left) & (*((int8_t *) right + i)); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = (*(int16_t *) left) & (*((int16_t *) right + i)); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = (*(int32_t *) left) & (*((int32_t *) right + i)); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = (*(int64_t *) left) & (*((int64_t *) right + i)); + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = (*(uint8_t *) left) & (*((uint8_t *) right + i)); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = (*(uint16_t *) left) & (*((uint16_t *) right + i)); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = (*(uint32_t *) left) & (*((uint32_t *) right + i)); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = (*(uint64_t *) left) & (*((uint64_t *) right + i)); + output += sizeof(int64_t); + break; + } + } + } else if ((len2) == 1) { + for (; i >= 0 && i < len1; i += step) { + if (isNull(getVectorValueAddrFnLeft(left, i), _left_type) || isNull(getVectorValueAddrFnRight(right, 0), _right_type)) { + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = TSDB_DATA_BOOL_NULL; + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = TSDB_DATA_TINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = TSDB_DATA_SMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = TSDB_DATA_INT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = TSDB_DATA_BIGINT_NULL; + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = TSDB_DATA_UTINYINT_NULL; + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = TSDB_DATA_USMALLINT_NULL; + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = TSDB_DATA_UINT_NULL; + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = TSDB_DATA_UBIGINT_NULL; + output += sizeof(int64_t); + break; + } + continue; + } + + switch (_left_type) { + case TSDB_DATA_TYPE_BOOL: + *(bool *) output = (*((bool *) left + i)) & (*(bool *) right); + output += sizeof(bool); + break; + case TSDB_DATA_TYPE_TINYINT: + *(int8_t *) output = (*((int8_t *) left + i)) & (*(int8_t *) right); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_SMALLINT: + *(int16_t *) output = (*((int16_t *) left + i)) & (*(int16_t *) right); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_INT: + *(int32_t *) output = (*((int32_t *) left + i)) & (*(int32_t *) right); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_BIGINT: + *(int64_t *) output = (*((int64_t *) left + i)) & (*(int64_t *) right); + output += sizeof(int64_t); + break; + + case TSDB_DATA_TYPE_UTINYINT: + *(uint8_t *) output = (*((uint8_t *) left + i)) & (*(uint8_t *) right); + output += sizeof(int8_t); + break; + case TSDB_DATA_TYPE_USMALLINT: + *(uint16_t *) output = (*((uint16_t *) left + i)) & (*(uint16_t *) right); + output += sizeof(int16_t); + break; + case TSDB_DATA_TYPE_UINT: + *(uint32_t *) output = (*((uint32_t *) left + i)) & (*(uint32_t *) right); + output += sizeof(int32_t); + break; + case TSDB_DATA_TYPE_UBIGINT: + *(uint64_t *) output = (*((uint64_t *) left + i)) & (*(uint64_t *) right); + output += sizeof(int64_t); + break; + } + } + } +} + _arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr) { switch (arithmeticOptr) { case TSDB_BINARY_OP_ADD: @@ -481,6 +751,8 @@ _arithmetic_operator_fn_t getArithmeticOperatorFn(int32_t arithmeticOptr) { return vectorDivide; case TSDB_BINARY_OP_REMAINDER: return vectorRemainder; + case TSDB_BINARY_OP_BITAND: + return vectorBitand; default: assert(0); return NULL; diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index 2774d9e2fabd11a3fcb45d650dc696518d504501..d348beb20ce562bd178743f38cfe2a92eddb9354 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -107,11 +107,13 @@ int32_t exprTreeValidateFunctionNode(char* msgbuf, tExprNode *pExpr) { } int32_t exprTreeValidateExprNode(tExprNode *pExpr) { + int16_t leftType = pExpr->_node.pLeft->resultType; + int16_t rightType = pExpr->_node.pRight->resultType; + int16_t resultType = leftType; + if (pExpr->_node.optr == TSDB_BINARY_OP_ADD || pExpr->_node.optr == TSDB_BINARY_OP_SUBTRACT || pExpr->_node.optr == TSDB_BINARY_OP_MULTIPLY || pExpr->_node.optr == TSDB_BINARY_OP_DIVIDE || pExpr->_node.optr == TSDB_BINARY_OP_REMAINDER) { - int16_t leftType = pExpr->_node.pLeft->resultType; - int16_t rightType = pExpr->_node.pRight->resultType; if ((!IS_NUMERIC_TYPE(leftType) && !IS_TIMESTAMP_TYPE(leftType)) || (!IS_NUMERIC_TYPE(rightType) && !IS_TIMESTAMP_TYPE(rightType))) { return TSDB_CODE_TSC_INVALID_OPERATION; @@ -133,6 +135,171 @@ int32_t exprTreeValidateExprNode(tExprNode *pExpr) { pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; } return TSDB_CODE_SUCCESS; + } else if (pExpr->_node.optr == TSDB_BINARY_OP_BITAND) { + if ((leftType != TSDB_DATA_TYPE_BOOL && !IS_SIGNED_NUMERIC_TYPE(leftType) && !IS_UNSIGNED_NUMERIC_TYPE(leftType)) || + (rightType != TSDB_DATA_TYPE_BOOL && !IS_SIGNED_NUMERIC_TYPE(rightType) && !IS_UNSIGNED_NUMERIC_TYPE(rightType))) + { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + + uint8_t schemaType; + // now leftType and rightType are both numeric + if (pExpr->_node.pLeft->nodeType == TSQL_NODE_COL && pExpr->_node.pRight->nodeType == TSQL_NODE_COL) { + if (leftType != rightType) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } else if (pExpr->_node.pLeft->nodeType == TSQL_NODE_COL) { + if (pExpr->_node.pRight->nodeType != TSQL_NODE_VALUE) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } else { + schemaType = pExpr->_node.pLeft->pSchema->type; + int64_t sVal = pExpr->_node.pRight->pVal->i64; + uint64_t uVal = pExpr->_node.pRight->pVal->u64; + + switch (schemaType) { + case TSDB_DATA_TYPE_BOOL: + if ((pExpr->_node.pRight->pVal->nType != TSDB_DATA_TYPE_BOOL) || + (pExpr->_node.pRight->pVal->i64 != 0 && + pExpr->_node.pRight->pVal->i64 != 1 && + pExpr->_node.pRight->pVal->i64 != TSDB_DATA_BOOL_NULL)) + { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + case TSDB_DATA_TYPE_TINYINT: + if (sVal < -128 || sVal > 127) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + case TSDB_DATA_TYPE_SMALLINT: + if (sVal < -32768 || sVal > 32767) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + case TSDB_DATA_TYPE_INT: + if (sVal < INT32_MIN || sVal > INT32_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + case TSDB_DATA_TYPE_BIGINT: + if (sVal < INT64_MIN || sVal > INT64_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + case TSDB_DATA_TYPE_UTINYINT: + if (uVal > 255) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + case TSDB_DATA_TYPE_USMALLINT: + if (uVal > 65535) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + case TSDB_DATA_TYPE_UINT: + if (uVal > UINT32_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + case TSDB_DATA_TYPE_UBIGINT: + if (uVal > UINT64_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + break; + } + + pExpr->_node.pRight->pSchema->type = schemaType; + pExpr->_node.pRight->pVal->nType = schemaType; + + pExpr->_node.pRight->resultType = schemaType; + pExpr->_node.pRight->resultBytes = tDataTypes[schemaType].bytes; + } + } else { + if (pExpr->_node.pLeft->nodeType != TSQL_NODE_VALUE) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } else { + schemaType = pExpr->_node.pRight->pSchema->type; + int64_t sVal = pExpr->_node.pLeft->pVal->i64; + uint64_t uVal = pExpr->_node.pLeft->pVal->u64; + switch (schemaType) { + case TSDB_DATA_TYPE_BOOL: + if ((pExpr->_node.pLeft->pVal->nType != TSDB_DATA_TYPE_BOOL) || + (pExpr->_node.pLeft->pVal->i64 != 0 && + pExpr->_node.pLeft->pVal->i64 != 1 && + pExpr->_node.pLeft->pVal->i64 != TSDB_DATA_BOOL_NULL)) + { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 1; + break; + case TSDB_DATA_TYPE_TINYINT: + if (sVal < -128 || sVal > 127) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 1; + break; + case TSDB_DATA_TYPE_SMALLINT: + if (sVal < -32768 || sVal > 32767) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 2; + break; + case TSDB_DATA_TYPE_INT: + if (sVal < INT32_MIN || sVal > INT32_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 4; + break; + case TSDB_DATA_TYPE_BIGINT: + if (sVal < INT64_MIN || sVal > INT64_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 8; + break; + case TSDB_DATA_TYPE_UTINYINT: + if (uVal > 255) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 1; + break; + case TSDB_DATA_TYPE_USMALLINT: + if (uVal > 65535) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 2; + break; + case TSDB_DATA_TYPE_UINT: + if (uVal > UINT32_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 4; + break; + case TSDB_DATA_TYPE_UBIGINT: + if (uVal > UINT64_MAX) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + pExpr->_node.pLeft->pVal->nLen = 8; + break; + } + + pExpr->_node.pLeft->pSchema->type = schemaType; + pExpr->_node.pLeft->pVal->nType = schemaType; + + pExpr->_node.pLeft->resultType = schemaType; + pExpr->_node.pLeft->resultBytes = tDataTypes[schemaType].bytes; + } + + resultType = schemaType; + } + + if (resultType == TSDB_DATA_TYPE_BOOL) { + pExpr->resultType = TSDB_DATA_TYPE_BOOL; + pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; + } else { + pExpr->resultType = resultType; + pExpr->resultBytes = tDataTypes[resultType].bytes; + } + return TSDB_CODE_SUCCESS; } else { return TSDB_CODE_SUCCESS; } @@ -241,7 +408,8 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf return; } case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_UBIGINT: { + case TSDB_DATA_TYPE_UBIGINT: + case TSDB_DATA_TYPE_TIMESTAMP: { int64_t* p = (int64_t*) dest; int64_t* pSrc = (int64_t*) src; @@ -438,7 +606,7 @@ void exprTreeFunctionNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOper } pInputs[i].numOfRows = (int16_t)numOfRows; } else if (pChild->nodeType == TSQL_NODE_VALUE) { - pChildrenOutput[i] = malloc(pChild->resultBytes); + pChildrenOutput[i] = malloc((pChild->resultBytes+1)*TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); tVariantDump(pChild->pVal, pChildrenOutput[i], pChild->resultType, true); pInputs[i].data = pChildrenOutput[i]; pInputs[i].numOfRows = 1; @@ -535,7 +703,11 @@ void exprTreeExprNodeTraverse(tExprNode *pExpr, int32_t numOfRows, tExprOperandI if(leftType == TSDB_DATA_TYPE_TIMESTAMP || rightType == TSDB_DATA_TYPE_TIMESTAMP) { output->type = TSDB_DATA_TYPE_BIGINT; } else { - output->type = TSDB_DATA_TYPE_DOUBLE; + if (pExpr->_node.optr == TSDB_BINARY_OP_BITAND) { + output->type = leftType; // rightType must be the same as leftType + } else { + output->type = TSDB_DATA_TYPE_DOUBLE; + } } output->bytes = tDataTypes[output->type].bytes; @@ -955,7 +1127,7 @@ int32_t exprValidateStringConcatNode(tExprNode *pExpr) { if (!IS_VAR_DATA_TYPE(child->pVal->nType)) { return TSDB_CODE_TSC_INVALID_OPERATION; } - char* payload = malloc(child->pVal->nLen * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); tVariantDump(child->pVal, payload, resultType, true); int16_t resultBytes = varDataTLen(payload); free(payload); @@ -1027,7 +1199,7 @@ int32_t exprValidateStringConcatWsNode(tExprNode *pExpr) { if (!IS_VAR_DATA_TYPE(child->pVal->nType)) { return TSDB_CODE_TSC_INVALID_OPERATION; } - char* payload = malloc(child->pVal->nLen * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + char* payload = malloc((child->pVal->nLen+1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); tVariantDump(child->pVal, payload, resultType, true); int16_t resultBytes = varDataTLen(payload); free(payload); @@ -1181,8 +1353,7 @@ int32_t exprValidateCastNode(char* msgbuf, tExprNode *pExpr) { int32_t exprValidateMathNode(tExprNode *pExpr) { switch (pExpr->_func.functionId) { - case TSDB_FUNC_SCALAR_POW: - case TSDB_FUNC_SCALAR_LOG: { + case TSDB_FUNC_SCALAR_POW: { if (pExpr->_func.numChildren != 2) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -1197,6 +1368,27 @@ int32_t exprValidateMathNode(tExprNode *pExpr) { return TSDB_CODE_SUCCESS; } + + case TSDB_FUNC_SCALAR_LOG: { + if (pExpr->_func.numChildren != 1 && pExpr->_func.numChildren != 2) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + tExprNode *child1 = pExpr->_func.pChildren[0]; + if (!IS_NUMERIC_TYPE(child1->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + if (pExpr->_func.numChildren == 2) { + tExprNode *child2 = pExpr->_func.pChildren[1]; + if (!IS_NUMERIC_TYPE(child2->resultType)) { + return TSDB_CODE_TSC_INVALID_OPERATION; + } + } + + pExpr->resultType = TSDB_DATA_TYPE_DOUBLE; + pExpr->resultBytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; + + return TSDB_CODE_SUCCESS; + } case TSDB_FUNC_SCALAR_ABS: { if (pExpr->_func.numChildren != 1) { return TSDB_CODE_TSC_INVALID_OPERATION; @@ -2040,13 +2232,19 @@ void vectorMathFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn if (!hasNullInputs) { switch (functionId) { case TSDB_FUNC_SCALAR_LOG: { - assert(numInputs == 2); - double base = 0; - GET_TYPED_DATA(base, double, pInputs[1].type, inputData[1]); + double base = 2.7182818284590452354; //const M_E + if (numInputs == 2) { + GET_TYPED_DATA(base, double, pInputs[1].type, inputData[1]); + } double v1 = 0; GET_TYPED_DATA(v1, double, pInputs[0].type, inputData[0]); - double result = log(v1) / log(base); - SET_TYPED_DATA(outputData, pOutput->type, result); + if (numInputs == 2) { + double result = log(v1) / log(base); + SET_TYPED_DATA(outputData, pOutput->type, result); + } else { + double result = log(v1); + SET_TYPED_DATA(outputData, pOutput->type, result); + } break; } @@ -2230,14 +2428,12 @@ void vectorMathFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn void convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, int64_t *timeVal) { int32_t charLen = varDataLen(inputData); - char *newColData; + char *newColData = calloc(1, charLen + 1); if (type == TSDB_DATA_TYPE_BINARY) { - newColData = calloc(1, charLen + 1); memcpy(newColData, varDataVal(inputData), charLen); taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, 0); tfree(newColData); } else if (type == TSDB_DATA_TYPE_NCHAR) { - newColData = calloc(1, charLen / TSDB_NCHAR_SIZE + 1); int len = taosUcs4ToMbs(varDataVal(inputData), charLen, newColData); if (len < 0){ uError("convertStringToTimestamp taosUcs4ToMbs error"); diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 922ae1dedc806c8939a142d737e4661f3fe4561d..616c5fba890a03a2f59a6bee6ae7d2f79ee52760 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -48,6 +48,8 @@ char tsEmail[TSDB_FQDN_LEN] = {0}; int32_t tsDnodeId = 0; int64_t tsDnodeStartTime = 0; int8_t tsDnodeNopLoop = 0; +int32_t tsTcpConnTimeout = 1000; +int32_t tsSyncCheckInterval = 1500; // common int32_t tsRpcTimer = 300; @@ -185,15 +187,6 @@ int8_t tsTelegrafUseFieldNum = 0; int8_t tsHttpDbNameMandatory = 0; int32_t tsHttpKeepAlive = 30000; -// mqtt -int8_t tsEnableMqttModule = 0; // not finished yet, not started it by default -char tsMqttHostName[TSDB_MQTT_HOSTNAME_LEN] = "test.mosquitto.org"; -char tsMqttPort[TSDB_MQTT_PORT_LEN] = "1883"; -char tsMqttUser[TSDB_MQTT_USER_LEN] = {0}; -char tsMqttPass[TSDB_MQTT_PASS_LEN] = {0}; -char tsMqttClientId[TSDB_MQTT_CLIENT_ID_LEN] = "TDengineMqttSubscriber"; -char tsMqttTopic[TSDB_MQTT_TOPIC_LEN] = "/test"; // # - // monitor int8_t tsEnableMonitorModule = 1; int8_t tsMonitorReplica = 1; @@ -217,6 +210,7 @@ char tsMnodeBakDir[PATH_MAX] = {0}; char tsDataDir[PATH_MAX] = {0}; char tsScriptDir[PATH_MAX] = {0}; char tsTempDir[PATH_MAX] = "/tmp/"; +int32_t tsKeepTimeOffset = 0; int32_t tsDiskCfgNum = 0; int32_t tsTopicBianryLen = 16000; @@ -261,7 +255,6 @@ uint32_t cDebugFlag = 131; int32_t jniDebugFlag = 131; int32_t odbcDebugFlag = 131; int32_t httpDebugFlag = 131; -int32_t mqttDebugFlag = 131; int32_t monDebugFlag = 131; uint32_t qDebugFlag = 131; int32_t rpcDebugFlag = 131; @@ -318,7 +311,6 @@ void taosSetAllDebugFlag() { jniDebugFlag = debugFlag; odbcDebugFlag = debugFlag; httpDebugFlag = debugFlag; - mqttDebugFlag = debugFlag; monDebugFlag = debugFlag; qDebugFlag = debugFlag; rpcDebugFlag = debugFlag; @@ -635,6 +627,26 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "tcpConnTimout"; + cfg.ptr = &tsTcpConnTimeout; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 1; + cfg.maxValue = 10000; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_MS; + taosInitConfigOption(cfg); + + cfg.option = "syncCheckInterval"; + cfg.ptr = &tsSyncCheckInterval; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = 1; + cfg.maxValue = 10000; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_MS; + taosInitConfigOption(cfg); + cfg.option = "balance"; cfg.ptr = &tsEnableBalance; cfg.valType = TAOS_CFG_VTYPE_INT8; @@ -665,6 +677,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "keepTimeOffset"; + cfg.ptr = &tsKeepTimeOffset; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; + cfg.minValue = -23; + cfg.maxValue = 23; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + // 0-any; 1-mnode; 2-vnode cfg.option = "role"; cfg.ptr = &tsAlternativeRole; @@ -1018,36 +1040,6 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "mqttHostName"; - cfg.ptr = tsMqttHostName; - cfg.valType = TAOS_CFG_VTYPE_STRING; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT; - cfg.minValue = 0; - cfg.maxValue = 0; - cfg.ptrLength = TSDB_MQTT_HOSTNAME_LEN; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - - cfg.option = "mqttPort"; - cfg.ptr = tsMqttPort; - cfg.valType = TAOS_CFG_VTYPE_STRING; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT; - cfg.minValue = 0; - cfg.maxValue = 0; - cfg.ptrLength = TSDB_MQTT_PORT_LEN; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - - cfg.option = "mqttTopic"; - cfg.ptr = tsMqttTopic; - cfg.valType = TAOS_CFG_VTYPE_STRING; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_NOT_PRINT; - cfg.minValue = 0; - cfg.maxValue = 0; - cfg.ptrLength = TSDB_MQTT_TOPIC_LEN; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - cfg.option = "compressMsgSize"; cfg.ptr = &tsCompressMsgSize; cfg.valType = TAOS_CFG_VTYPE_INT32; @@ -1272,16 +1264,6 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "mqtt"; - cfg.ptr = &tsEnableMqttModule; - cfg.valType = TAOS_CFG_VTYPE_INT8; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 0; - cfg.maxValue = 1; - cfg.ptrLength = 1; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - cfg.option = "monitor"; cfg.ptr = &tsEnableMonitorModule; cfg.valType = TAOS_CFG_VTYPE_INT8; @@ -1534,16 +1516,6 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "mqttDebugFlag"; - cfg.ptr = &mqttDebugFlag; - cfg.valType = TAOS_CFG_VTYPE_INT32; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_LOG; - cfg.minValue = 0; - cfg.maxValue = 255; - cfg.ptrLength = 0; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - cfg.option = "monDebugFlag"; cfg.ptr = &monDebugFlag; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/connector/C#/.gitignore b/src/connector/C#/.gitignore index 80558c70a1571c863749550f66d642baf089d627..959149abb5828bf55949aa4cc66a97e960abdeab 100644 --- a/src/connector/C#/.gitignore +++ b/src/connector/C#/.gitignore @@ -8,3 +8,5 @@ src/test/doc/ NugetPackTest/ examples/bin/ examples/obj/ +src/TDengineDriver/doc/ +.vs diff --git a/src/connector/C#/csharpTaos.sln b/src/connector/C#/csharpTaos.sln deleted file mode 100644 index 158cc7eb3bcdd502f78ef26a60b1949e4c31ebd0..0000000000000000000000000000000000000000 --- a/src/connector/C#/csharpTaos.sln +++ /dev/null @@ -1,72 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30114.105 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A1FB5B66-E32F-4789-9BE9-042E5BD21087}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TDengineDriver", "src\TDengineDriver\TDengineDriver.csproj", "{5BED7402-0A65-4ED9-A491-C56BFB518045}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CB8E6458-31E1-4351-B704-1B918E998654}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XUnitTest", "src\test\XUnitTest\XUnitTest.csproj", "{64C0A478-2591-4459-9F8F-A70F37976A41}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunctionTest", "src\test\FunctionTest\FunctionTest.csproj", "{E66B034B-4677-4BFB-8B87-84715D281E21}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|Any CPU.Build.0 = Debug|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|x64.ActiveCfg = Debug|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|x64.Build.0 = Debug|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|x86.ActiveCfg = Debug|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Debug|x86.Build.0 = Debug|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|Any CPU.ActiveCfg = Release|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|Any CPU.Build.0 = Release|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|x64.ActiveCfg = Release|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|x64.Build.0 = Release|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|x86.ActiveCfg = Release|Any CPU - {5BED7402-0A65-4ED9-A491-C56BFB518045}.Release|x86.Build.0 = Release|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|Any CPU.Build.0 = Debug|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|x64.ActiveCfg = Debug|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|x64.Build.0 = Debug|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|x86.ActiveCfg = Debug|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Debug|x86.Build.0 = Debug|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Release|Any CPU.ActiveCfg = Release|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Release|Any CPU.Build.0 = Release|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Release|x64.ActiveCfg = Release|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Release|x64.Build.0 = Release|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Release|x86.ActiveCfg = Release|Any CPU - {64C0A478-2591-4459-9F8F-A70F37976A41}.Release|x86.Build.0 = Release|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Debug|x64.ActiveCfg = Debug|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Debug|x64.Build.0 = Debug|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Debug|x86.ActiveCfg = Debug|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Debug|x86.Build.0 = Debug|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Release|Any CPU.Build.0 = Release|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Release|x64.ActiveCfg = Release|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Release|x64.Build.0 = Release|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Release|x86.ActiveCfg = Release|Any CPU - {E66B034B-4677-4BFB-8B87-84715D281E21}.Release|x86.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {5BED7402-0A65-4ED9-A491-C56BFB518045} = {A1FB5B66-E32F-4789-9BE9-042E5BD21087} - {CB8E6458-31E1-4351-B704-1B918E998654} = {A1FB5B66-E32F-4789-9BE9-042E5BD21087} - {64C0A478-2591-4459-9F8F-A70F37976A41} = {CB8E6458-31E1-4351-B704-1B918E998654} - {E66B034B-4677-4BFB-8B87-84715D281E21} = {CB8E6458-31E1-4351-B704-1B918E998654} - EndGlobalSection -EndGlobal diff --git a/src/connector/C#/examples/Main.cs b/src/connector/C#/examples/Main.cs deleted file mode 100644 index dbf29fc17675e9f18633ab2e997dce3138a33800..0000000000000000000000000000000000000000 --- a/src/connector/C#/examples/Main.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using Sample.UtilsTools; -using System.Runtime.InteropServices; -using TDengineDriver; -using Example; -using System.Collections.Generic; - -namespace AsyncQueryExample -{ - public class EntryPoint - { - static void Main(string[] args) - { - IntPtr conn = UtilsTools.TDConnection(); - - AsyncQuerySample asyncQuery = new AsyncQuerySample(); - asyncQuery.RunQueryAsync(conn, "query_async"); - - SubscribeSample subscribeSample = new SubscribeSample(); - subscribeSample.RunSubscribeWithCallback(conn, "subscribe_with_callback"); - subscribeSample.RunSubscribeWithoutCallback(conn, "subscribe_without_callback"); - - StreamSample streamSample = new StreamSample(); - streamSample.RunStreamOption1(conn, "stream_sample_option1"); - - UtilsTools.CloseConnection(conn); - } - } -} diff --git a/src/connector/C#/examples/QueryAsyncSample.cs b/src/connector/C#/examples/QueryAsyncSample.cs deleted file mode 100644 index cfd1f7a0c599d1fec0a847a0c700c57d964b41c2..0000000000000000000000000000000000000000 --- a/src/connector/C#/examples/QueryAsyncSample.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using TDengineDriver; -using Sample.UtilsTools; -using System.Runtime.InteropServices; -using System.Threading; - -namespace Example -{ - public class AsyncQuerySample - { - public void RunQueryAsync(IntPtr conn, string table) - { - QueryAsyncCallback queryAsyncCallback = new QueryAsyncCallback(QueryCallback); - PrepareData(conn, table); - Console.WriteLine($"Start calling QueryAsync(),query {table}'s data asynchronously."); - TDengine.QueryAsync(conn, $"select * from {table}", queryAsyncCallback, IntPtr.Zero); - Thread.Sleep(2000); - Console.WriteLine("QueryAsync done."); - - } - - //prepare the data(table and insert data) - public void PrepareData(IntPtr conn, string tableName) - { - string createTable = $"create table if not exists {tableName} (ts timestamp,i8 tinyint,i16 smallint,i32 int,i64 bigint)tags(t_bnry binary(50), t_nchr nchar(50));"; - string insert1 = $"insert into {tableName}_s01 using {tableName} tags('tag1','标签1') values(now,1,2,3,4)(now+1m,5,6,7,8)(now+2m,9,0,-1,-2)(now+3m,-3,-4,-5,-6)(now+4m,-7,-8,-9,0)"; - string insert2 = $"insert into {tableName}_s02 using {tableName} tags('tag2','标签2') values(now,1,2,3,4)(now+1m,5,6,7,8)(now+2m,9,0,-1,-2)(now+3m,-3,-4,-5,-6)(now+4m,-7,-8,-9,0)"; - string insert3 = $"insert into {tableName}_s03 using {tableName} tags('tag3','标签3') values(now,1,2,3,4)(now+1m,5,6,7,8)(now+2m,9,0,-1,-2)(now+3m,-3,-4,-5,-6)(now+4m,-7,-8,-9,0)"; - string insert4 = $"insert into {tableName}_s04 using {tableName} tags('tag4','标签4') values(now,1,2,3,4)(now+1m,5,6,7,8)(now+2m,9,0,-1,-2)(now+3m,-3,-4,-5,-6)(now+4m,-7,-8,-9,0)"; - string insert5 = $"insert into {tableName}_s05 using {tableName} tags('tag5','标签5') values(now,1,2,3,4)(now+1m,5,6,7,8)(now+2m,9,0,-1,-2)(now+3m,-3,-4,-5,-6)(now+4m,-7,-8,-9,0)"; - - UtilsTools.ExecuteUpdate(conn, createTable); - UtilsTools.ExecuteUpdate(conn, insert1); - Thread.Sleep(100); - UtilsTools.ExecuteUpdate(conn, insert2); - Thread.Sleep(100); - UtilsTools.ExecuteUpdate(conn, insert3); - Thread.Sleep(100); - UtilsTools.ExecuteUpdate(conn, insert4); - Thread.Sleep(100); - UtilsTools.ExecuteUpdate(conn, insert5); - - } - - public void QueryCallback(IntPtr param, IntPtr taosRes, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - FetchRowAsyncCallback fetchRowAsyncCallback = new FetchRowAsyncCallback(FetchCallback); - TDengine.FetchRowAsync(taosRes, fetchRowAsyncCallback, param); - } - else - { - Console.WriteLine($"async query data failed, failed code {code}"); - } - } - - // Iteratively call this interface until "numOfRows" is no greater than 0. - public void FetchCallback(IntPtr param, IntPtr taosRes, int numOfRows) - { - if (numOfRows > 0) - { - Console.WriteLine($"{numOfRows} rows async retrieved"); - UtilsTools.DisplayRes(taosRes); - TDengine.FetchRowAsync(taosRes, FetchCallback, param); - } - else - { - if (numOfRows == 0) - { - Console.WriteLine("async retrieve complete."); - - } - else - { - Console.WriteLine($"FetchRowAsync callback error, error code {numOfRows}"); - } - TDengine.FreeResult(taosRes); - } - } - } - - -} \ No newline at end of file diff --git a/src/connector/C#/examples/StreamSample.cs b/src/connector/C#/examples/StreamSample.cs deleted file mode 100644 index e90a82c4e3679f41004fa8295783e72fdf6fe643..0000000000000000000000000000000000000000 --- a/src/connector/C#/examples/StreamSample.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using TDengineDriver; -using Sample.UtilsTools; -using System.Runtime.InteropServices; -using System.Threading; -using System.Collections.Generic; -using System.Text; - -namespace Example -{ - public class StreamSample - { - - public void RunStreamOption1(IntPtr conn, string table) - { - - PrepareData(conn, table); - StreamOpenCallback streamOpenCallback = new StreamOpenCallback(StreamCallback); - IntPtr stream = TDengine.OpenStream(conn, $"select count(*) from {table} interval(1m) sliding(30s)", streamOpenCallback, 0, IntPtr.Zero, null); - if (stream == IntPtr.Zero) - { - throw new Exception("OPenStream failed"); - } - else - { - Thread.Sleep(100000); - AddNewData(conn, table, 5,true); - Thread.Sleep(100000); - - TDengine.CloseStream(stream); - Console.WriteLine("stream done"); - - } - } - - - public void StreamCallback(IntPtr param, IntPtr taosRes, IntPtr taosRow) - { - - if (taosRes == IntPtr.Zero || taosRow == IntPtr.Zero) - { - return; - } - else - { - var rowData = new List(); - rowData = UtilsTools.FetchRow(taosRow, taosRes); - int count = 0; - rowData.ForEach((item) => - { - - Console.Write("{0} \t|\t", item.ToString()); - count++; - if (count % rowData.Count == 0) - { - Console.WriteLine(""); - } - }); - } - } - - public void PrepareData(IntPtr conn, string tableName) - { - string createTable = $"create table if not exists {tableName} (ts timestamp,i8 tinyint,i16 smallint,i32 int,i64 bigint);"; - UtilsTools.ExecuteUpdate(conn, createTable); - AddNewData(conn, tableName, 5); - } - - public void AddNewData(IntPtr conn, string tableName, int numRows,bool interval = false) - { - long ts = 1646150410100; - Random rs = new Random(); - StringBuilder insert = new StringBuilder(); - - Random rd = new Random(); - for (int i = 0; i < numRows; i++) - { - insert.Append("insert into "); - insert.Append(tableName); - insert.Append(" values "); - insert.Append('('); - insert.Append(ts); - insert.Append(','); - insert.Append(rs.Next(sbyte.MinValue+1, sbyte.MaxValue)); - insert.Append(','); - insert.Append(rs.Next(short.MinValue+1, short.MaxValue)); - insert.Append(','); - insert.Append(rs.Next(int.MinValue+1, int.MaxValue)); - insert.Append(','); - insert.Append(rs.Next(int.MinValue+1, int.MaxValue)); - insert.Append(')'); - UtilsTools.ExecuteUpdate(conn, insert.ToString()); - insert.Clear(); - ts += rd.Next(10000, 100000); - if( interval) - { - Thread.Sleep(rs.Next(100,300) * i); - } - else - { - continue; - } - } - } - - } -} \ No newline at end of file diff --git a/src/connector/C#/examples/SubscribeSample.cs b/src/connector/C#/examples/SubscribeSample.cs deleted file mode 100644 index 446b37f6a2bfb22b45f4e74903268c3bf4123e48..0000000000000000000000000000000000000000 --- a/src/connector/C#/examples/SubscribeSample.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using TDengineDriver; -using Sample.UtilsTools; -using System.Runtime.InteropServices; -using System.Collections.Generic; -using System.Threading; - -namespace Example -{ - - public class SubscribeSample - { - long ts = 1646150410000; - public void RunSubscribeWithCallback(IntPtr conn, string table) - { - PrepareData(conn, table); - string topic = $"{table}_topic"; - string sql = $"select * from {table}"; - SubscribeCallback subscribeCallback = new SubscribeCallback(SubCallback); - - // Subscribe from earliest timestamp in the table. - IntPtr subscribe = TDengine.Subscribe(conn, true, topic, sql, subscribeCallback, IntPtr.Zero, 1000); - - // Add new data. - for (int i = 0; i < 4; i++) - { - InsertData(conn, table); - } - Console.WriteLine("Unsubscribe and keep the subscribe progress "); - TDengine.Unsubscribe(subscribe, true); - - Console.WriteLine("Subscribe from last subscribe progress"); - subscribe = TDengine.Subscribe(conn, false, topic, sql, subscribeCallback, IntPtr.Zero, 1000); - for (int i = 0; i < 4; i++) - { - InsertData(conn, table); - } - Console.WriteLine("Unsubscribe and remove the subscribe progress "); - TDengine.Unsubscribe(subscribe, false); - } - - public void RunSubscribeWithoutCallback(IntPtr conn, string table) - { - - PrepareData(conn, table); - string topic = $"{table}_topic"; - string sql = $"select * from {table}"; - IntPtr subscribe = TDengine.Subscribe(conn, true, topic, sql, null, IntPtr.Zero, 1000); - Console.WriteLine("consume from begin"); - //Don't release this TAO_RES and end of the subscribe application,other wise will lead crash. - IntPtr taosRes = TDengine.Consume(subscribe); - UtilsTools.DisplayRes(taosRes); - for (int i = 0; i < 3; i++) - { - InsertData(conn, table); - } - Console.WriteLine("consume new data"); - taosRes = TDengine.Consume(subscribe); - UtilsTools.DisplayRes(taosRes); - Console.WriteLine("Unsubscribe and keep progress"); - TDengine.Unsubscribe(subscribe, true); - - // Subscribe from last subscribe progress. - subscribe = TDengine.Subscribe(conn, false, topic, sql, null, IntPtr.Zero, 1000); - for (int i = 0; i < 3; i++) - { - InsertData(conn, table); - Console.WriteLine($"Consume {i+1} time"); - taosRes = TDengine.Consume(subscribe); - // The interval between two consume should greater than "interval" pass in Subscribe(). - // Otherwise consume will be blocked. - Thread.Sleep(1000); - UtilsTools.DisplayRes(taosRes); - } - TDengine.Unsubscribe(subscribe, false); - TDengine.FreeResult(taosRes); - } - - public void SubCallback(IntPtr subscribe, IntPtr taosRes, IntPtr param, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - // cannot free taosRes using taosRes, otherwise will cause crash. - Console.WriteLine($"Display taosRes in subscribe callback"); - UtilsTools.DisplayRes(taosRes); - } - else - { - Console.WriteLine($"async query data failed, failed code {code}"); - } - - } - public void PrepareData(IntPtr conn, string tableName) - { - string createTable = $"create table if not exists {tableName} (ts timestamp,i8 tinyint,i16 smallint,i32 int,i64 bigint);"; - string insert1 = $"insert into {tableName} values({ts},1,2,3,4)"; - - UtilsTools.ExecuteUpdate(conn, createTable); - UtilsTools.ExecuteUpdate(conn, insert1); - } - - public void InsertData(IntPtr conn, string tableName) - { - ts = ts + 100; - string insert1 = $"insert into {tableName} values({ts},1,2,3,4)"; - ts = ts + 100; - string insert2 = $"insert into {tableName} values({ts},-1,-2,-3,-4)"; - - UtilsTools.ExecuteUpdate(conn, insert1); - UtilsTools.ExecuteUpdate(conn, insert2); - Thread.Sleep(500); - } - - } -} diff --git a/src/connector/C#/examples/examples.csproj b/src/connector/C#/examples/examples.csproj deleted file mode 100644 index 862df00f04deffb445f4cdf16a8285b907279bb6..0000000000000000000000000000000000000000 --- a/src/connector/C#/examples/examples.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - Exe - net5.0 - - - diff --git a/src/connector/C#/src/TDengineDriver/TDengineDriver.cs b/src/connector/C#/src/TDengineDriver/TDengineDriver.cs deleted file mode 100644 index 8a0c1b4796004dc5cba91d18388cc91918aacd4a..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/TDengineDriver/TDengineDriver.cs +++ /dev/null @@ -1,593 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -namespace TDengineDriver -{ - public enum TDengineDataType - { - TSDB_DATA_TYPE_NULL = 0, // 1 bytes - TSDB_DATA_TYPE_BOOL = 1, // 1 bytes - TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes - TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes - TSDB_DATA_TYPE_INT = 4, // 4 bytes - TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes - TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes - TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes - TSDB_DATA_TYPE_BINARY = 8, // string - TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes - TSDB_DATA_TYPE_NCHAR = 10, // unicode string - TSDB_DATA_TYPE_UTINYINT = 11,// 1 byte - TSDB_DATA_TYPE_USMALLINT = 12,// 2 bytes - TSDB_DATA_TYPE_UINT = 13, // 4 bytes - TSDB_DATA_TYPE_UBIGINT = 14, // 8 bytes - TSDB_DATA_TYPE_JSONTAG = 15 //4096 bytes - } - - public enum TDengineInitOption - { - TSDB_OPTION_LOCALE = 0, - TSDB_OPTION_CHARSET = 1, - TSDB_OPTION_TIMEZONE = 2, - TSDB_OPTION_CONFIGDIR = 3, - TSDB_OPTION_SHELL_ACTIVITY_TIMER = 4 - } - enum TaosField - { - STRUCT_SIZE = 68, - NAME_LENGTH = 65, - TYPE_OFFSET = 65, - BYTES_OFFSET = 66, - - } - public class TDengineMeta - { - public string name; - public short size; - public byte type; - public string TypeName() - { - switch ((TDengineDataType)type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - return "BOOL"; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - return "TINYINT"; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - return "SMALLINT"; - case TDengineDataType.TSDB_DATA_TYPE_INT: - return "INT"; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - return "BIGINT"; - case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: - return "TINYINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: - return "SMALLINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_UINT: - return "INT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: - return "BIGINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - return "FLOAT"; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - return "DOUBLE"; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - return "BINARY"; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - return "TIMESTAMP"; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - return "NCHAR"; - case TDengineDataType.TSDB_DATA_TYPE_JSONTAG: - return "JSON"; - default: - return "undefine"; - } - } - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public struct TAOS_BIND - { - // column type - public int buffer_type; - // one column value - public IntPtr buffer; - // unused - public Int32 buffer_length; - // actual value length in buffer - public IntPtr length; - // indicates the column value is null or not - public IntPtr is_null; - // unused - public int is_unsigned; - // unused - public IntPtr error; - public Int64 u; - public uint allocated; - } - - - [StructLayout(LayoutKind.Sequential)] - public struct TAOS_MULTI_BIND - { - // column type - public int buffer_type; - - // array, one or more lines column value - public IntPtr buffer; - - //length of element in TAOS_MULTI_BIND.buffer (for binary and nchar it is the longest element's length) - public ulong buffer_length; - - //array, actual data length for each value - public IntPtr length; - - //array, indicates each column value is null or not - public IntPtr is_null; - - // line number, or the values number in buffer - public int num; - } - - /// - /// User defined callback function for interface "QueryAsync()" - /// ,actually is a delegate in .Net. - /// This function aim to handle the taoRes which points to - /// the caller method's sql resultset. - /// - /// This parameter will sent by caller method (QueryAsync()). - /// This is the retrieved by caller method's sql. - /// 0 for indicate operation success and negative for operation fail. - public delegate void QueryAsyncCallback(IntPtr param, IntPtr taoRes, int code); - - /// - /// User defined callback function for interface "FetchRowAsync()" - /// ,actually is a delegate in .Net. - /// This callback allow applications to get each row of the - /// batch records by calling FetchRowAsync() forward iteration. - /// After reading all the records in a block, the application needs to continue calling - /// FetchRowAsync() in this callback function to obtain the next batch of records for - /// processing until the number of records - /// - /// The parameter passed by - /// Query status - /// The number of rows of data obtained (not a function of - /// the entire query result set). When the number is zero (the result is returned) - /// or the number of records is negative (the query fails). - public delegate void FetchRowAsyncCallback(IntPtr param, IntPtr taoRes, int numOfRows); - - /// - /// In asynchronous mode, the prototype of the callback function. - /// - /// Subscription object return by - /// Query retrieve result set. (Note there may be no record in the result set.) - /// Additional parameters supplied by the client when taos_subscribe is called. - /// Error code. - public delegate void SubscribeCallback(IntPtr subscribe, IntPtr tasRes, IntPtr param, int code); - public delegate void StreamOpenCallback(IntPtr param, IntPtr taosRes, IntPtr taosRow); - public delegate void StreamOpenCallback2(IntPtr ptr); - - public class TDengine - { - public const int TSDB_CODE_SUCCESS = 0; - - [DllImport("taos", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)] - static extern public void Init(); - - [DllImport("taos", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)] - static extern public void Cleanup(); - - [DllImport("taos", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)] - static extern public void Options(int option, string value); - - [DllImport("taos", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr Connect(string ip, string user, string password, string db, short port); - - [DllImport("taos", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr taos_errstr(IntPtr res); - static public string Error(IntPtr res) - { - IntPtr errPtr = taos_errstr(res); - return Marshal.PtrToStringAnsi(errPtr); - } - - [DllImport("taos", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)] - static extern public int ErrorNo(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)] - // static extern public IntPtr Query(IntPtr conn, string sqlstr); - static extern private IntPtr Query(IntPtr conn, IntPtr byteArr); - - static public IntPtr Query(IntPtr conn, string command) - { - IntPtr res = IntPtr.Zero; - - IntPtr commandBuffer = Marshal.StringToCoTaskMemUTF8(command); - res = Query(conn, commandBuffer); - return res; - } - - [DllImport("taos", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)] - static extern public int AffectRows(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)] - static extern public int FieldCount(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr taos_fetch_fields(IntPtr res); - static public List FetchFields(IntPtr res) - { - // const int fieldSize = 68; - - List metaList = new List(); - if (res == IntPtr.Zero) - { - return metaList; - } - - int fieldCount = FieldCount(res); - IntPtr fieldsPtr = taos_fetch_fields(res); - - for (int i = 0; i < fieldCount; ++i) - { - int offset = i * (int)TaosField.STRUCT_SIZE; - TDengineMeta meta = new TDengineMeta(); - meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset); - meta.type = Marshal.ReadByte(fieldsPtr + offset + (int)TaosField.TYPE_OFFSET); - meta.size = Marshal.ReadInt16(fieldsPtr + offset + (int)TaosField.BYTES_OFFSET); - metaList.Add(meta); - } - - - return metaList; - } - - [DllImport("taos", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr FetchRows(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr FreeResult(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] - static extern public int Close(IntPtr taos); - - //get precision of restultset - [DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)] - static extern public int ResultPrecision(IntPtr taos); - - - - //stmt APIs: - /// - /// init a TAOS_STMT object for later use. - /// - /// a valid taos connection - /// - /// Not NULL returned for success, NULL for failure. And it should be freed with taos_stmt_close. - /// - [DllImport("taos", EntryPoint = "taos_stmt_init", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr StmtInit(IntPtr taos); - - /// - /// prepare a sql statement,'sql' should be a valid INSERT/SELECT statement. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// sql string,used to bind parameters with - /// no used - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_prepare", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtPrepare(IntPtr stmt, string sql); - - /// - /// For INSERT only. Used to bind table name as a parmeter for the input stmt object. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// table name you want to bind - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_set_tbname", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtSetTbname(IntPtr stmt, string name); - - /// - /// For INSERT only. - /// Set a table name for binding table name as parameter. Only used for binding all tables - /// in one stable, user application must call 'loadTableInfo' API to load all table - /// meta before calling this API. If the table meta is not cached locally, it will return error. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// table name which is belong to an stable - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_set_sub_tbname", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtSetSubTbname(IntPtr stmt, string name); - - /// - /// For INSERT only. - /// set a table name for binding table name as parameter and tag values for all tag parameters. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// use to set table name - /// - /// is an array contains all tag values,each item in the array represents a tag column's value. - /// the item number and sequence should keep consistence with that in stable tag definition. - /// - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_set_tbname_tags", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtSetTbnameTags(IntPtr stmt, string name, TAOS_BIND[] tags); - - /// - /// For both INSERT and SELECT. - /// bind a whole line data. - /// The usage of structure TAOS_BIND is the same with MYSQL_BIND in MySQL. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// - /// points to an array contains the whole line data. - /// the item number and sequence should keep consistence with columns in sql statement. - /// - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_bind_param", CallingConvention = CallingConvention.Cdecl, SetLastError = true)] - static extern public int StmtBindParam(IntPtr stmt, TAOS_BIND[] bind); - - /// - /// bind a single column's data, INTERNAL used and for INSERT only. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// points to a column's data which could be the one or more lines. - /// the column's index in prepared sql statement, it starts from 0. - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_bind_single_param_batch", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtBindSingleParamBatch(IntPtr stmt, ref TAOS_MULTI_BIND bind, int colIdx); - - /// - /// for INSERT only - /// bind one or multiple lines data. The parameter 'bind' - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// - /// points to an array contains one or more lines data.Each item in array represents a column's value(s), - /// the item number and sequence should keep consistence with columns in sql statement. - /// - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_bind_param_batch", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtBindParamBatch(IntPtr stmt, [In, Out] TAOS_MULTI_BIND[] bind); - - /// - /// For INSERT only. - /// add all current bound parameters to batch process. Must be called after each call to - /// StmtBindParam/StmtBindSingleParamBatch, or all columns binds for one or more lines - /// with StmtBindSingleParamBatch. User application can call any bind parameter - /// API again to bind more data lines after calling to this API. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_add_batch", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtAddBatch(IntPtr stmt); - - /// - /// actually execute the INSERT/SELECT sql statement. - /// User application can continue to bind new data after calling to this API. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// - [DllImport("taos", EntryPoint = "taos_stmt_execute", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtExecute(IntPtr stmt); - - /// - /// For SELECT only,getting the query result. User application should free it with API 'FreeResult' at the end. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// Not NULL for success, NULL for failure. - [DllImport("taos", EntryPoint = "taos_stmt_use_result", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr StmtUseResult(IntPtr stmt); - - /// - /// close STMT object and free resources. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_close", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtClose(IntPtr stmt); - - [DllImport("taos", EntryPoint = "taos_load_table_info", CallingConvention = CallingConvention.Cdecl)] - /// - /// user application must call this API to load all tables meta, - /// - /// taos connection - /// tablelist - /// - static extern private int LoadTableInfoDll(IntPtr taos, string tableList); - - /// - /// user application call this API to load all tables meta,this method call the native - /// method LoadTableInfoDll. - /// this method must be called before StmtSetSubTbname(IntPtr stmt, string name); - /// - /// taos connection - /// tables need to load meta info are form in an array - /// - static public int LoadTableInfo(IntPtr taos, string[] tableList) - { - string listStr = string.Join(",", tableList); - return LoadTableInfoDll(taos, listStr); - } - - /// - /// get detail error message when got failure for any stmt API call. If not failure, the result - /// returned in this API is unknown. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// point the error message - [DllImport("taos", EntryPoint = "taos_stmt_errstr", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr StmtErrPtr(IntPtr stmt); - - /// - /// get detail error message when got failure for any stmt API call. If not failure, the result - /// returned in this API is unknown. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// error string - static public string StmtErrorStr(IntPtr stmt) - { - IntPtr stmtErrPrt = StmtErrPtr(stmt); - return Marshal.PtrToStringAnsi(stmtErrPrt); - } - - [DllImport("taos", EntryPoint = "taos_fetch_lengths", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr FetchLengths(IntPtr taos); - - // Async Query - /// - /// This API uses non-blocking call mode. - /// Application can open multiple tables and manipulate(query or insert) opened table concurrently. - /// So applications must ensure that opetations on the same table is completely serialized. - /// Because that will cause some query and insert operations cannot be performed. - /// - /// A taos connection return by Connect() - /// sql command need to execute - /// User-defined callback function. - /// the parameter for callback - [DllImport("taos", EntryPoint = "taos_query_a", CallingConvention = CallingConvention.Cdecl)] - static extern public void QueryAsync(IntPtr taos, string sql, QueryAsyncCallback fq, IntPtr param); - - /// - /// Get the result set of asynchronous queries in batch, - /// which can only be used with QueryAsync().FetchRowAsyncCallback - /// - /// The result set returned when backcall QueryAsyncCallback - /// Callback function. - /// The parameter for callback FetchRowAsyncCallback - [DllImport("taos", EntryPoint = "taos_fetch_rows_a", CallingConvention = CallingConvention.Cdecl)] - static extern public void FetchRowAsync(IntPtr taoRes, FetchRowAsyncCallback fq, IntPtr param); - - // Subscribe - - /// - /// This function is used for start subscription service. - /// - /// taos connection return by - /// If the subscription is already exists, to decide whether to - /// start over or continue with previous subscription. - /// The name of the subscription.(This is the unique identification of the subscription). - /// The subscribe statement(select only).Only query original data and in positive time sequence. - /// The callback function when the query result is received. - /// Additional parameter when calling callback function. System API will pass it to - /// callback function without any operations.It is only used when calling asynchronously, - /// and this parameter should be passed to NULL when calling synchronously - /// Polling period in milliseconds. During asynchronous call, the callback function will be - /// called periodically according to this parameter; In order to avoid affecting system - /// performance, it is not recommended to set this parameter too small; When calling synchronously, - /// if the interval between two calls to taos_consume is less than this period, the API will block - /// until the interval exceeds this period. - /// Return null for failure, return subscribe object for success. - [DllImport("taos", EntryPoint = "taos_subscribe", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr Subscribe(IntPtr taos, int restart, string topic, string sql, SubscribeCallback fq, IntPtr param, int interval); - static public IntPtr Subscribe(IntPtr taos, bool restart, string topic, string sql, SubscribeCallback fq, IntPtr param, int interval) - { - if (taos == IntPtr.Zero) - { - Console.WriteLine("taos connect is null,subscribe failed"); - throw new Exception("taos connect is null"); - } - else - { - IntPtr subPtr = Subscribe(taos, restart == true ? 1 : 0, topic, sql, fq, param, interval); - return subPtr; - } - } - - /// - /// Only synchronous mode, this function is used to get the result of subscription. - /// If the interval between two calls to taos_consume is less than the polling - /// cycle of the subscription, the API will block until the interval exceeds this - /// cycle. If a new record arrives in the database, the API will return the latest - /// record, otherwise it will return an empty result set with no records. - /// If the return value is NULL, it indicates a system error. - /// - /// Subscription object return by . - /// - [DllImport("taos", EntryPoint = "taos_consume", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr TaosConsume(IntPtr subscribe); - static public IntPtr Consume(IntPtr subscribe) - { - IntPtr res = IntPtr.Zero; - if (subscribe == IntPtr.Zero) - { - Console.WriteLine("Object subscribe is null,please subscribe first."); - throw new Exception("Object subscribe is null"); - } - else - { - res = TaosConsume(subscribe); - } - return res; - } - - /// - /// Unsubscribe. - /// - /// Subscription object return by . - /// If it is not 0, the API will keep the progress of subscription, - /// and the and the subsequent call to taos_subscribe can continue - /// based on this progress; otherwise, the progress information will - /// be deleted and the data can only be read again. - /// - [DllImport("taos", EntryPoint = "taos_unsubscribe", CallingConvention = CallingConvention.Cdecl)] - static extern private void Unsubscribe(IntPtr subscribe, int keep); - static public void Unsubscribe(IntPtr subscribe, bool keep) - { - if (subscribe == IntPtr.Zero) - { - Console.WriteLine("subscribe is null, close Unsubscribe failed"); - throw new Exception("Object subscribe is null"); - } - else - { - Unsubscribe(subscribe, keep == true ? 1 : 0); - Console.WriteLine("Unsubscribe success."); - } - - } - // Stream - - /// - /// Used to open an stream, which can do continuous query. - /// - /// taos connection return by - /// Query statement( query only) - /// User defined callback. - /// The time when stream computing starts. If it is 0, it means starting from now. - /// If it is not zero, it means starting from the specified time (the number of - /// milliseconds from 1970/1/1 UTC time). - /// - /// First parameter provide by application for callback usage. - /// While callback,this parameter is provided to the application. - /// The second callback function which will be called when the continuous query - /// stop automatically. - /// Return null indicate creation failed, not null for success. - [DllImport("taos", EntryPoint = "taos_open_stream", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr OpenStream(IntPtr taos, string sql, StreamOpenCallback fp, Int64 stime, IntPtr param, StreamOpenCallback2 callback2); - - /// - /// Used too stop data flow. - /// Remember to stop data flow when you stopped steam computing. - /// - /// Value returned by - [DllImport("taos", EntryPoint = "taos_close_stream", CallingConvention = CallingConvention.Cdecl)] - static extern public void CloseStream(IntPtr stream); - - } -} diff --git a/src/connector/C#/src/TDengineDriver/TDengineDriver.csproj b/src/connector/C#/src/TDengineDriver/TDengineDriver.csproj deleted file mode 100644 index 4a030046a1096490e014de9eed6b5f6ac669d7c8..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/TDengineDriver/TDengineDriver.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - net5;netstandard2.1; - TDengine.Connector - logo.jpg - 1.0.4 - taosdata - www.taosdata.com - MIT - Taos;Data;Microsoft.NET.Sdk;IOT;bigdata;TDengine;taosdata - - This is the C# connector's classlib that lets you connect to TDengine. - This C # connector supports: Linux 64/Windows x64/Windows x86. - more information please visit: https://www.taosdata.com - - https://github.com/taosdata/TDengine/tree/develop/src/connector/C%2523/src/TDengineDriver - CS1591 - - - - - - - diff --git a/src/connector/C#/src/TDengineDriver/TaosBind.cs b/src/connector/C#/src/TDengineDriver/TaosBind.cs deleted file mode 100644 index 0528cda3eaf35014b4c7fe66f926edac86748236..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/TDengineDriver/TaosBind.cs +++ /dev/null @@ -1,337 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using System.Text; - -namespace TDengineDriver -{ - /// - /// this class used to get an instance of struct of TAO_BIND or TAOS_MULTI_BIND - /// And the instance is corresponding with TDengine data type. For example, calling - /// "bindBinary" will return a TAOS_BIND object that is corresponding with TDengine's - /// binary type. - /// - public class TaosBind - { - public static TAOS_BIND BindBool(bool val) - { - TAOS_BIND bind = new TAOS_BIND(); - byte[] boolByteArr = BitConverter.GetBytes(val); - int boolByteArrSize = Marshal.SizeOf(boolByteArr[0]) * boolByteArr.Length; - IntPtr c_bool = Marshal.AllocHGlobal(1); - Marshal.Copy(boolByteArr, 0, c_bool, boolByteArr.Length); - - int length = sizeof(Boolean); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BOOL; - bind.buffer = c_bool; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - public static TAOS_BIND BindTinyInt(sbyte val) - { - TAOS_BIND bind = new TAOS_BIND(); - - byte[] tinyIntByteArr = BitConverter.GetBytes(val); - int tinyIntByteArrSize = Marshal.SizeOf(tinyIntByteArr[0]) * tinyIntByteArr.Length; - IntPtr c_tinyint = Marshal.AllocHGlobal(tinyIntByteArrSize); - Marshal.Copy(tinyIntByteArr, 0, c_tinyint, tinyIntByteArr.Length); - - int length = sizeof(sbyte); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TINYINT; - bind.buffer = c_tinyint; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - return bind; - - } - - public static TAOS_BIND BindSmallInt(short val) - { - - TAOS_BIND bind = new TAOS_BIND(); - IntPtr c_smallint = Marshal.AllocHGlobal(sizeof(short)); - Marshal.WriteInt16(c_smallint, val); - - int length = sizeof(short); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_SMALLINT; - bind.buffer = c_smallint; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindInt(int val) - { - TAOS_BIND bind = new TAOS_BIND(); - IntPtr c_int = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(c_int, val); - - int length = sizeof(int); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_INT; - bind.buffer = c_int; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindBigInt(long val) - { - - TAOS_BIND bind = new TAOS_BIND(); - IntPtr c_bigint = Marshal.AllocHGlobal(sizeof(long)); - Marshal.WriteInt64(c_bigint, val); - - int length = sizeof(long); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BIGINT; - bind.buffer = c_bigint; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindUTinyInt(byte val) - { - TAOS_BIND bind = new TAOS_BIND(); - - IntPtr c_unsigned_tinyint = Marshal.AllocHGlobal(sizeof(byte)); - Marshal.WriteByte(c_unsigned_tinyint, val); - - int length = sizeof(byte); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UTINYINT; - bind.buffer = c_unsigned_tinyint; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindUSmallInt(UInt16 val) - { - TAOS_BIND bind = new TAOS_BIND(); - - byte[] uSmallIntByteArr = BitConverter.GetBytes(val); - int usmallSize = Marshal.SizeOf(uSmallIntByteArr[0]) * uSmallIntByteArr.Length; - IntPtr c_unsigned_smallint = Marshal.AllocHGlobal(usmallSize); - Marshal.Copy(uSmallIntByteArr, 0, c_unsigned_smallint, uSmallIntByteArr.Length); - - int length = sizeof(UInt16); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_USMALLINT; - bind.buffer = c_unsigned_smallint; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindUInt(uint val) - { - TAOS_BIND bind = new TAOS_BIND(); - - byte[] byteArr = BitConverter.GetBytes(val); - int usmallSize = Marshal.SizeOf(byteArr[0]) * byteArr.Length; - IntPtr c_unsigned_int = Marshal.AllocHGlobal(usmallSize); - Marshal.Copy(byteArr, 0, c_unsigned_int, byteArr.Length); - - int length = sizeof(uint); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UINT; - bind.buffer = c_unsigned_int; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindUBigInt(ulong val) - { - TAOS_BIND bind = new TAOS_BIND(); - - byte[] byteArr = BitConverter.GetBytes(val); - int usmallSize = Marshal.SizeOf(byteArr[0]) * byteArr.Length; - IntPtr c_unsigned_bigint = Marshal.AllocHGlobal(usmallSize); - Marshal.Copy(byteArr, 0, c_unsigned_bigint, byteArr.Length); - - int length = sizeof(ulong); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UBIGINT; - bind.buffer = c_unsigned_bigint; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindFloat(float val) - { - TAOS_BIND bind = new TAOS_BIND(); - - byte[] byteArr = BitConverter.GetBytes(val); - int floatByteArrSize = Marshal.SizeOf(byteArr[0]) * byteArr.Length; - IntPtr c_float = Marshal.AllocHGlobal(floatByteArrSize); - Marshal.Copy(byteArr, 0, c_float, byteArr.Length); - - int length = sizeof(float); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_FLOAT; - bind.buffer = c_float; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindDouble(Double val) - { - TAOS_BIND bind = new TAOS_BIND(); - - byte[] byteArr = BitConverter.GetBytes(val); - int doubleByteArrSize = Marshal.SizeOf(byteArr[0]) * byteArr.Length; - IntPtr c_double = Marshal.AllocHGlobal(doubleByteArrSize); - Marshal.Copy(byteArr, 0, c_double, byteArr.Length); - - int length = sizeof(Double); - IntPtr lengthPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_DOUBLE; - bind.buffer = c_double; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindBinary(String val) - { - - TAOS_BIND bind = new TAOS_BIND(); - // IntPtr unmanagedBinary = Marshal.StringToHGlobalAnsi(val); - IntPtr c_str = Marshal.StringToCoTaskMemUTF8(val); - - var strToBytes = System.Text.Encoding.UTF8.GetBytes(val); - int length = strToBytes.Length; - IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong)); - Marshal.WriteInt64(lenPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BINARY; - bind.buffer = c_str; - bind.buffer_length = length; - bind.length = lenPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - public static TAOS_BIND BindNchar(String val) - { - TAOS_BIND bind = new TAOS_BIND(); - var strToBytes = System.Text.Encoding.UTF8.GetBytes(val); - // IntPtr unmanagedNchar = (IntPtr)Marshal.StringToHGlobalAnsi(val); - IntPtr c_str = (IntPtr)Marshal.StringToCoTaskMemUTF8(val); - - - int length = strToBytes.Length; - IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(ulong)); - Marshal.WriteInt64(lenPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NCHAR; - bind.buffer = c_str; - bind.buffer_length = length; - bind.length = lenPtr; - bind.is_null = IntPtr.Zero; - - return bind; - } - - public static TAOS_BIND BindNil() - { - TAOS_BIND bind = new TAOS_BIND(); - - int isNull = 1;//IntPtr.Size; - IntPtr lenPtr = Marshal.AllocHGlobal(sizeof(int)); - Marshal.WriteInt32(lenPtr, isNull); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NULL; - bind.is_null = lenPtr; - return bind; - } - - public static TAOS_BIND BindTimestamp(long ts) - { - - TAOS_BIND bind = new TAOS_BIND(); - IntPtr c_long = Marshal.AllocHGlobal(sizeof(long)); - Marshal.WriteInt64(c_long, ts); - - int length = sizeof(long); - IntPtr lengthPtr = Marshal.AllocHGlobal(4); - Marshal.WriteInt32(lengthPtr, length); - - bind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP; - bind.buffer = c_long; - bind.buffer_length = length; - bind.length = lengthPtr; - bind.is_null = IntPtr.Zero; - - return bind; - - } - - public static void FreeTaosBind(TAOS_BIND[] binds) - { - foreach (TAOS_BIND bind in binds) - { - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - if (bind.is_null != IntPtr.Zero) - { - // Console.WriteLine(bind.is_null); - Marshal.FreeHGlobal(bind.is_null); - } - - } - } - } - -} \ No newline at end of file diff --git a/src/connector/C#/src/TDengineDriver/TaosMultiBind.cs b/src/connector/C#/src/TDengineDriver/TaosMultiBind.cs deleted file mode 100644 index 69ce27eec3bcb47673927ba50d8c94cbf12658f8..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/TDengineDriver/TaosMultiBind.cs +++ /dev/null @@ -1,621 +0,0 @@ -using System; -using System.Text; -using System.Runtime.InteropServices; - -namespace TDengineDriver -{ - public class TaosMultiBind - { - public static TAOS_MULTI_BIND MultiBindBool(bool?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - //the size of buffer array element - int typeSize = sizeof(bool); - //size of int - int intSize = sizeof(int); - int byteSize = sizeof(byte); - - //TAOS_MULTI_BIND.buffer - IntPtr c_bool_ptr = Marshal.AllocHGlobal(elementCount * typeSize); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - for (int i = 0; i < elementCount; i++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteByte(c_bool_ptr, typeSize * i, Convert.ToByte(arr[i] ?? false)); - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - } - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BOOL; - multiBind.buffer = c_bool_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindTinyInt(sbyte?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - //the size of buffer array element - int typeSize = sizeof(byte); - int byteSize = sizeof(byte); - //size of int - int intSize = sizeof(int); - - //TAOS_MULTI_BIND.buffer - IntPtr c_tinyint_ptr = Marshal.AllocHGlobal(elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(intSize * elementCount); - - for (int i = 0; i < elementCount; i++) - { - Byte[] toByteArr = BitConverter.GetBytes(arr[i] ?? sbyte.MinValue); - - //set TAOS_MULTI_BIND.buffer - Marshal.WriteByte(c_tinyint_ptr, typeSize * i, toByteArr[0]); - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - } - - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TINYINT; - multiBind.buffer = c_tinyint_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindSmallInt(short?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - //the size of buffer array element - int typeSize = sizeof(short); - //size of int - int intSize = sizeof(int); - int byteSize = sizeof(byte); - - //TAOS_MULTI_BIND.buffer - IntPtr c_smallint_ptr = Marshal.AllocHGlobal(elementCount * typeSize); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - for (int i = 0; i < elementCount; i++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteInt16(c_smallint_ptr, typeSize * i, arr[i] ?? short.MinValue); - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - - } - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_SMALLINT; - multiBind.buffer = c_smallint_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindInt(int?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(int); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - - //TAOS_MULTI_BIND.buffer - IntPtr c_int_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - for (int i = 0; i < elementCount; i++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteInt32(c_int_ptr, typeSize * i, arr[i] ?? int.MinValue); - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - - } - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_INT; - multiBind.buffer = c_int_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindBigint(long?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(long); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - - //TAOS_MULTI_BIND.buffer - IntPtr c_long_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - for (int i = 0; i < elementCount; i++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteInt64(c_long_ptr, typeSize * i, arr[i] ?? long.MinValue); - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - - - } - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BIGINT; - multiBind.buffer = c_long_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindFloat(float?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(float); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - //used to replace null - float[] arrTmp = new float[elementCount]; - - //TAOS_MULTI_BIND.buffer - IntPtr c_float_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - - for (int i = 0; i < elementCount; i++) - { - arrTmp[i] = arr[i] ?? float.MinValue; - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - } - //set TAOS_MULTI_BIND.buffer - Marshal.Copy(arrTmp, 0, c_float_ptr, elementCount); - - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_FLOAT; - multiBind.buffer = c_float_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindDouble(double?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(double); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - //used to replace null - double[] arrTmp = new double[elementCount]; - - //TAOS_MULTI_BIND.buffer - IntPtr c_double_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - - for (int i = 0; i < elementCount; i++) - { - arrTmp[i] = arr[i] ?? double.MinValue; - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - } - //set TAOS_MULTI_BIND.buffer - Marshal.Copy(arrTmp, 0, c_double_ptr, elementCount); - - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_DOUBLE; - multiBind.buffer = c_double_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindUTinyInt(byte?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(byte); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - //used to replace null - - //TAOS_MULTI_BIND.buffer - IntPtr c_unsigned_tinyint_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - - for (int i = 0; i < elementCount; i++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteByte(c_unsigned_tinyint_ptr, typeSize * i, arr[i] ?? byte.MaxValue); - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - } - - - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UTINYINT; - multiBind.buffer = c_unsigned_tinyint_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindUSmallInt(ushort?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(ushort); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - //used to replace null - - //TAOS_MULTI_BIND.buffer - IntPtr c_unsigned_smallint_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - - for (int i = 0; i < elementCount; i++) - { - byte[] byteArr = BitConverter.GetBytes(arr[i] ?? ushort.MaxValue); - for (int j = 0; j < byteArr.Length; j++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteByte(c_unsigned_smallint_ptr, typeSize * i + j * byteSize, byteArr[j]); - } - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - } - - - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_USMALLINT; - multiBind.buffer = c_unsigned_smallint_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindUInt(uint?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(uint); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - //used to replace null - - //TAOS_MULTI_BIND.buffer - IntPtr c_unsigned_int_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - - for (int i = 0; i < elementCount; i++) - { - byte[] byteArr = BitConverter.GetBytes(arr[i] ?? uint.MaxValue); - for (int j = 0; j < byteArr.Length; j++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteByte(c_unsigned_int_ptr, typeSize * i + j * byteSize, byteArr[j]); - } - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - } - - - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UINT; - multiBind.buffer = c_unsigned_int_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindUBigInt(ulong?[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(ulong); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - //used to replace null - - //TAOS_MULTI_BIND.buffer - IntPtr c_unsigned_bigint_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - - for (int i = 0; i < elementCount; i++) - { - byte[] byteArr = BitConverter.GetBytes(arr[i] ?? ulong.MaxValue); - for (int j = 0; j < byteArr.Length; j++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteByte(c_unsigned_bigint_ptr, typeSize * i + j * byteSize, byteArr[j]); - } - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(arr[i].Equals(null) ? 1 : 0)); - } - - - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_UBIGINT; - multiBind.buffer = c_unsigned_bigint_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - public static TAOS_MULTI_BIND MultiBindBinary(string[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - //TypeSize represent the Max element length of the comming arr - //The size of the buffer is typeSize * elementCount - //This buffer is used to store TAOS_MULTI_BIND.buffer - int typeSize = MaxElementLength(arr); - //This intSize is used to calculate buffer size of the struct TAOS_MULTI_BIND's - //length. The buffer is intSize * elementCount,which is used to store TAOS_MULTI_BIND.length - int intSize = sizeof(int); - //This byteSize is used to calculate the buffer size of the struct TAOS_MULTI_BIND.is_null - //This buffer size is byteSize * elementCount - int byteSize = sizeof(byte); - - StringBuilder arrStrBuilder = new StringBuilder(); ; - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - //TAOS_MULTI_BIND.buffer - IntPtr c_char_prt = Marshal.AllocHGlobal(typeSize * elementCount); - - for (int i = 0; i < elementCount; i++) - { - int itemLength = 0; - byte[] decodeByte = GetStringEncodeByte(arr[i]); - itemLength = decodeByte.Length; - if (!String.IsNullOrEmpty(arr[i])) - { - for (int j = 0; j < itemLength; j++) - { - //Read byte after byte - Marshal.WriteByte(c_char_prt, i * typeSize + j, decodeByte[j]); - } - } - //Set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, itemLength); - //Set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(String.IsNullOrEmpty(arr[i]) ? 1 : 0)); - } - //Config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_BINARY; - multiBind.buffer = c_char_prt; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - - public static TAOS_MULTI_BIND MultiBindNchar(string[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - //TypeSize represent the Max element length of the comming arr - //The size of the buffer is typeSize * elementCount - //This buffer is used to store TAOS_MULTI_BIND.buffer - int typeSize = MaxElementLength(arr); - //This intSize is used to calculate buffer size of the struct TAOS_MULTI_BIND's - //length. The buffer is intSize * elementCount,which is used to store TAOS_MULTI_BIND.length - int intSize = sizeof(int); - //This byteSize is used to calculate the buffer size of the struct TAOS_MULTI_BIND.is_null - //This buffer size is byteSize * elementCount - int byteSize = sizeof(byte); - - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - //TAOS_MULTI_BIND.buffer - IntPtr c_char_prt = Marshal.AllocHGlobal(typeSize * elementCount); - - for (int i = 0; i < elementCount; i++) - { - int itemLength = 0; - byte[] decodeByte = GetStringEncodeByte(arr[i]); - itemLength = decodeByte.Length; - if (!String.IsNullOrEmpty(arr[i])) - { - for (int j = 0; j < itemLength; j++) - { - //Read byte after byte - Marshal.WriteByte(c_char_prt, i * typeSize + j, decodeByte[j]); - } - } - //Set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, itemLength); - //Set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, Convert.ToByte(String.IsNullOrEmpty(arr[i]) ? 1 : 0)); - } - //Config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_NCHAR; - multiBind.buffer = c_char_prt; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - - public static TAOS_MULTI_BIND MultiBindTimestamp(long[] arr) - { - TAOS_MULTI_BIND multiBind = new TAOS_MULTI_BIND(); - int elementCount = arr.Length; - int typeSize = sizeof(long); - int intSize = sizeof(int); - int byteSize = sizeof(byte); - //TAOS_MULTI_BIND.buffer - IntPtr c_long_ptr = Marshal.AllocHGlobal(typeSize * elementCount); - //TAOS_MULTI_BIND.length - IntPtr lengthArr = Marshal.AllocHGlobal(intSize * elementCount); - //TAOS_MULTI_BIND.is_null - IntPtr nullArr = Marshal.AllocHGlobal(byteSize * elementCount); - - for (int i = 0; i < elementCount; i++) - { - //set TAOS_MULTI_BIND.buffer - Marshal.WriteInt64(c_long_ptr, typeSize * i, arr[i]); - //set TAOS_MULTI_BIND.length - Marshal.WriteInt32(lengthArr, intSize * i, typeSize); - //set TAOS_MULTI_BIND.is_null - Marshal.WriteByte(nullArr, byteSize * i, 0); - } - - //config TAOS_MULTI_BIND - multiBind.buffer_type = (int)TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP; - multiBind.buffer = c_long_ptr; - multiBind.buffer_length = (ulong)typeSize; - multiBind.length = lengthArr; - multiBind.is_null = nullArr; - multiBind.num = elementCount; - - return multiBind; - } - - public static void FreeTaosBind(TAOS_MULTI_BIND[] mBinds) - { - foreach (TAOS_MULTI_BIND bind in mBinds) - { - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - Marshal.FreeHGlobal(bind.is_null); - } - } - - private static char[] AlignCharArr(int offSet) - { - char[] alignChar = new char[offSet]; - for (int i = 0; i < offSet; i++) - { - alignChar[i] = char.MinValue; - } - return alignChar; - } - - private static int MaxElementLength(String[] strArr) - { - int max = 0; - for (int i = 0; i < strArr.Length; i++) - { - int tmpLength = GetStringEncodeByte(strArr[i]).Length; - if (!String.IsNullOrEmpty(strArr[i]) && max < tmpLength) - { - max = tmpLength; - } - } - return max; - } - - private static Byte[] GetStringEncodeByte(string str) - { - Byte[] strToBytes = null; - if (String.IsNullOrEmpty(str)) - { - strToBytes = System.Text.Encoding.Default.GetBytes(String.Empty); - } - else - { - strToBytes = System.Text.Encoding.Default.GetBytes(str); - } - return strToBytes; - } - } - -} \ No newline at end of file diff --git a/src/connector/C#/src/TDengineDriver/resource/logo.jpg b/src/connector/C#/src/TDengineDriver/resource/logo.jpg deleted file mode 100644 index b64b508f91beabdc6759dad955db5464a0efdac2..0000000000000000000000000000000000000000 Binary files a/src/connector/C#/src/TDengineDriver/resource/logo.jpg and /dev/null differ diff --git a/src/connector/C#/src/test/FunctionTest/DataSource.cs b/src/connector/C#/src/test/FunctionTest/DataSource.cs deleted file mode 100644 index 58e99c6387c41360e137fa6bc5fbad3396afc337..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/DataSource.cs +++ /dev/null @@ -1,421 +0,0 @@ -using System; -using Test.UtilsTools; -using TDengineDriver; -using System.Collections.Generic; -namespace Test.UtilsTools.DataSource -{ - public class DataSource - { - public static long[] tsArr = new long[5] { 1637064040000, 1637064041000, 1637064042000, 1637064043000, 1637064044000 }; - public static bool?[] boolArr = new bool?[5] { true, false, null, true, true }; - public static sbyte?[] tinyIntArr = new sbyte?[5] { -127, 0, null, 8, 127 }; - public static short?[] shortArr = new short?[5] { short.MinValue + 1, -200, null, 100, short.MaxValue }; - public static int?[] intArr = new int?[5] { -200, -100, null, 0, 300 }; - public static long?[] longArr = new long?[5] { long.MinValue + 1, -2000, null, 1000, long.MaxValue }; - public static float?[] floatArr = new float?[5] { float.MinValue + 1, -12.1F, null, 0F, float.MaxValue }; - public static double?[] doubleArr = new double?[5] { double.MinValue + 1, -19.112D, null, 0D, double.MaxValue }; - public static byte?[] uTinyIntArr = new byte?[5] { byte.MinValue, 12, null, 89, byte.MaxValue - 1 }; - public static ushort?[] uShortArr = new ushort?[5] { ushort.MinValue, 200, null, 400, ushort.MaxValue - 1 }; - public static uint?[] uIntArr = new uint?[5] { uint.MinValue, 100, null, 2, uint.MaxValue - 1 }; - public static ulong?[] uLongArr = new ulong?[5] { ulong.MinValue, 2000, null, 1000, long.MaxValue - 1 }; - public static string[] binaryArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", String.Empty, null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?" }; - public static string[] ncharArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", string.Empty }; - - public static string[] binaryArrCn = new string[5] { "涛思数据", String.Empty, null, "taosdata涛思数据", "涛思数据TDengine" }; - public static string[] NcharArrCn = new string[5] { "涛思数据", null, "taosdata涛思数据", "涛思数据TDengine", String.Empty }; - - // Construct a TAOS_BIND array which contains normal character. - // For stmt bind tags,this will be used as tag info - public static TAOS_BIND[] GetTags() - { - TAOS_BIND[] binds = new TAOS_BIND[13]; - binds[0] = TaosBind.BindBool(true); - binds[1] = TaosBind.BindTinyInt(-2); - binds[2] = TaosBind.BindSmallInt(short.MaxValue); - binds[3] = TaosBind.BindInt(int.MaxValue); - binds[4] = TaosBind.BindBigInt(Int64.MaxValue); - binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1); - binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1); - binds[7] = TaosBind.BindUInt(uint.MinValue + 1); - binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1); - binds[9] = TaosBind.BindFloat(11.11F); - binds[10] = TaosBind.BindDouble(22.22D); - binds[11] = TaosBind.BindBinary("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); - binds[12] = TaosBind.BindNchar("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); - return binds; - } - // Get the tag data within and string list - // Which will be retrieved as a string List - private static List GetTagData() - { - List tagData = new List(); - tagData.Add(true.ToString()); - tagData.Add((-2).ToString()); - tagData.Add((short.MaxValue).ToString()); - tagData.Add((int.MaxValue).ToString()); - tagData.Add((Int64.MaxValue).ToString()); - tagData.Add((byte.MaxValue - 1).ToString()); - tagData.Add((UInt16.MaxValue - 1).ToString()); - tagData.Add((uint.MinValue + 1).ToString()); - tagData.Add((UInt64.MinValue + 1).ToString()); - tagData.Add((11.11F).ToString()); - tagData.Add((22.22D).ToString()); - tagData.Add("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); - tagData.Add("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); - return tagData; - } - - public static List GetMultiBindStableRowData() - { - List rowData = new List(); - List tagData = GetTagData(); - for (int i = 0; i < tsArr.Length; i++) - { - rowData.Add(tsArr[i].ToString()); - rowData.Add(boolArr[i].Equals(null) ? "NULL" : boolArr[i].ToString()); - rowData.Add(tinyIntArr[i].Equals(null) ? "NULL" : tinyIntArr[i].ToString()); - rowData.Add(shortArr[i].Equals(null) ? "NULL" : shortArr[i].ToString()); - rowData.Add(intArr[i].Equals(null) ? "NULL" : intArr[i].ToString()); - rowData.Add(longArr[i].Equals(null) ? "NULL" : longArr[i].ToString()); - rowData.Add(floatArr[i].Equals(null) ? "NULL" : floatArr[i].ToString()); - rowData.Add(doubleArr[i].Equals(null) ? "NULL" : doubleArr[i].ToString()); - rowData.Add(uTinyIntArr[i].Equals(null) ? "NULL" : uTinyIntArr[i].ToString()); - rowData.Add(uShortArr[i].Equals(null) ? "NULL" : uShortArr[i].ToString()); - rowData.Add(uIntArr[i].Equals(null) ? "NULL" : uIntArr[i].ToString()); - rowData.Add(uLongArr[i].Equals(null) ? "NULL" : uLongArr[i].ToString()); - rowData.Add(String.IsNullOrEmpty(binaryArr[i]) ? "NULL" : binaryArr[i]); - rowData.Add(String.IsNullOrEmpty(ncharArr[i]) ? "NULL" : ncharArr[i]); - rowData.AddRange(tagData); - // Console.WriteLine("binaryArrCn[{0}]:{1},ncharArr[{0}]:{2}",i,String.IsNullOrEmpty(binaryArrCn[i]) ? "NULL" : binaryArrCn[i],String.IsNullOrEmpty(ncharArr[i]) ? "NULL" : NcharArrCn[i]); - // Console.WriteLine("binaryArrCn[{0}]:{1},ncharArr[{0}]:{2}",i,String.IsNullOrEmpty(binaryArrCn[i]) ? 0 :binaryArrCn[i].Length, String.IsNullOrEmpty(ncharArr[i]) ? 0 : NcharArrCn[i].Length); - // Console.WriteLine("========"); - - } - return rowData; - - } - // Construct a TAOS_BIND array which contains chinese character. - // For stmt bind tags,this will be used as tag info - public static TAOS_BIND[] GetCNTags() - { - TAOS_BIND[] binds = new TAOS_BIND[13]; - binds[0] = TaosBind.BindBool(true); - binds[1] = TaosBind.BindTinyInt(-2); - binds[2] = TaosBind.BindSmallInt(short.MaxValue - 1); - binds[3] = TaosBind.BindInt(int.MaxValue - 1); - binds[4] = TaosBind.BindBigInt(Int64.MaxValue - 1); - binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1); - binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1); - binds[7] = TaosBind.BindUInt(uint.MinValue + 1); - binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1); - binds[9] = TaosBind.BindFloat(11.11F); - binds[10] = TaosBind.BindDouble(22.22D); - binds[11] = TaosBind.BindBinary("TDengine涛思数据"); - binds[12] = TaosBind.BindNchar("涛思数据taos"); - return binds; - } - // Get the tag data within and string list - // Which will be retrieved as a string List - private static List GetTagCNData() - { - List tagData = new List(); - tagData.Add(true.ToString()); - tagData.Add((-2).ToString()); - tagData.Add((short.MaxValue - 1).ToString()); - tagData.Add((int.MaxValue - 1).ToString()); - tagData.Add((Int64.MaxValue - 1).ToString()); - tagData.Add((byte.MaxValue - 1).ToString()); - tagData.Add((UInt16.MaxValue - 1).ToString()); - tagData.Add((uint.MinValue + 1).ToString()); - tagData.Add((UInt64.MinValue + 1).ToString()); - tagData.Add((11.11F).ToString()); - tagData.Add((22.22D).ToString()); - tagData.Add("TDengine涛思数据"); - tagData.Add("涛思数据taos"); - return tagData; - } - // A line of data that's without CN character. - // Which is construct as an TAOS_BIND array - public static TAOS_BIND[] GetNTableCNRow() - { - TAOS_BIND[] binds = new TAOS_BIND[15]; - binds[0] = TaosBind.BindTimestamp(1637064040000); - binds[1] = TaosBind.BindTinyInt(-2); - binds[2] = TaosBind.BindSmallInt(short.MaxValue); - binds[3] = TaosBind.BindInt(int.MaxValue); - binds[4] = TaosBind.BindBigInt(Int64.MaxValue); - binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1); - binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1); - binds[7] = TaosBind.BindUInt(uint.MinValue + 1); - binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1); - binds[9] = TaosBind.BindFloat(11.11F); - binds[10] = TaosBind.BindDouble(22.22D); - binds[11] = TaosBind.BindBinary("TDengine数据"); - binds[12] = TaosBind.BindNchar("taosdata涛思数据"); - binds[13] = TaosBind.BindBool(true); - binds[14] = TaosBind.BindNil(); - return binds; - } - //Get and list data that will be insert into table - public static List GetNTableCNRowData() - { - var data = new List{ - "1637064040000", - "-2", - short.MaxValue.ToString(), - int.MaxValue.ToString(), - Int64.MaxValue.ToString(), - (byte.MaxValue - 1).ToString(), - (UInt16.MaxValue - 1).ToString(), - (uint.MinValue + 1).ToString(), - (UInt64.MinValue + 1).ToString(), - (11.11F).ToString(), - (22.22D).ToString(), - "TDengine数据", - "taosdata涛思数据", - "True", - "NULL" - }; - return data; - } - // Get the data value and tag values which have chinese characters - // And retrieved as a string list.This is single Line. - public static List GetSTableCNRowData() - { - List columnData = GetNTableCNRowData(); - List tagData = GetTagCNData(); - columnData.AddRange(tagData); - return columnData; - } - - // A line of data that's without CN character - public static TAOS_BIND[] GetNTableRow() - { - TAOS_BIND[] binds = new TAOS_BIND[15]; - binds[0] = TaosBind.BindTimestamp(1637064040000); - binds[1] = TaosBind.BindTinyInt(-2); - binds[2] = TaosBind.BindSmallInt(short.MaxValue); - binds[3] = TaosBind.BindInt(int.MaxValue); - binds[4] = TaosBind.BindBigInt(Int64.MaxValue); - binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1); - binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1); - binds[7] = TaosBind.BindUInt(uint.MinValue + 1); - binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1); - binds[9] = TaosBind.BindFloat(11.11F); - binds[10] = TaosBind.BindDouble(22.22D); - binds[11] = TaosBind.BindBinary("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); - binds[12] = TaosBind.BindNchar("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); - binds[13] = TaosBind.BindBool(true); - binds[14] = TaosBind.BindNil(); - return binds; - } - // A List of data ,use as expectResData. The value is equal to getNTableRow() - public static List GetNTableRowData() - { - var data = new List{ - "1637064040000", - "-2", - short.MaxValue.ToString(), - int.MaxValue.ToString(), - (Int64.MaxValue).ToString(), - (byte.MaxValue - 1).ToString(), - (UInt16.MaxValue - 1).ToString(), - (uint.MinValue + 1).ToString(), - (UInt64.MinValue + 1).ToString(), - (11.11F).ToString(), - (22.22D).ToString(), - "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}", - "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}", - true.ToString(), - "NULL" - }; - return data; - } - - // Five lines of data, that is construct as taos_multi_bind array. - // There aren't any CN character - public static TAOS_MULTI_BIND[] GetMultiBindArr() - { - TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14]; - mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr); - mBinds[1] = TaosMultiBind.MultiBindBool(boolArr); - mBinds[2] = TaosMultiBind.MultiBindTinyInt(tinyIntArr); - mBinds[3] = TaosMultiBind.MultiBindSmallInt(shortArr); - mBinds[4] = TaosMultiBind.MultiBindInt(intArr); - mBinds[5] = TaosMultiBind.MultiBindBigint(longArr); - mBinds[6] = TaosMultiBind.MultiBindFloat(floatArr); - mBinds[7] = TaosMultiBind.MultiBindDouble(doubleArr); - mBinds[8] = TaosMultiBind.MultiBindUTinyInt(uTinyIntArr); - mBinds[9] = TaosMultiBind.MultiBindUSmallInt(uShortArr); - mBinds[10] = TaosMultiBind.MultiBindUInt(uIntArr); - mBinds[11] = TaosMultiBind.MultiBindUBigInt(uLongArr); - mBinds[12] = TaosMultiBind.MultiBindBinary(binaryArr); - mBinds[13] = TaosMultiBind.MultiBindNchar(ncharArr); - return mBinds; - } - // A List of data ,use as expectResData. The value is equal to GetMultiBindCNArr() - public static List GetMultiBindResData() - { - var rowData = new List(); - for (int i = 0; i < tsArr.Length; i++) - { - rowData.Add(tsArr[i].ToString()); - rowData.Add(boolArr[i].Equals(null) ? "NULL" : boolArr[i].ToString()); - rowData.Add(tinyIntArr[i].Equals(null) ? "NULL" : tinyIntArr[i].ToString()); - rowData.Add(shortArr[i].Equals(null) ? "NULL" : shortArr[i].ToString()); - rowData.Add(intArr[i].Equals(null) ? "NULL" : intArr[i].ToString()); - rowData.Add(longArr[i].Equals(null) ? "NULL" : longArr[i].ToString()); - rowData.Add(floatArr[i].Equals(null) ? "NULL" : floatArr[i].ToString()); - rowData.Add(doubleArr[i].Equals(null) ? "NULL" : doubleArr[i].ToString()); - rowData.Add(uTinyIntArr[i].Equals(null) ? "NULL" : uTinyIntArr[i].ToString()); - rowData.Add(uShortArr[i].Equals(null) ? "NULL" : uShortArr[i].ToString()); - rowData.Add(uIntArr[i].Equals(null) ? "NULL" : uIntArr[i].ToString()); - rowData.Add(uLongArr[i].Equals(null) ? "NULL" : uLongArr[i].ToString()); - rowData.Add(String.IsNullOrEmpty(binaryArr[i]) ? "NULL" : binaryArr[i]); - rowData.Add(String.IsNullOrEmpty(ncharArr[i]) ? "NULL" : ncharArr[i]); - // Console.WriteLine("binaryArrCn[{0}]:{1},NcharArrCn[{0}]:{2}",i,String.IsNullOrEmpty(binaryArrCn[i]) ? "NULL" : binaryArrCn[i],String.IsNullOrEmpty(NcharArrCn[i]) ? "NULL" : NcharArrCn[i]); - // Console.WriteLine("binaryArrCn[{0}]:{1},NcharArrCn[{0}]:{2}",i,String.IsNullOrEmpty(binaryArrCn[i]) ? 0 :binaryArrCn[i].Length, String.IsNullOrEmpty(NcharArrCn[i]) ? 0 : NcharArrCn[i].Length); - // Console.WriteLine("========"); - - } - return rowData; - } - // Five lines of data, that is construct as taos_multi_bind array. - // There are some CN characters and letters. - public static TAOS_MULTI_BIND[] GetMultiBindCNArr() - { - TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14]; - mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr); - mBinds[1] = TaosMultiBind.MultiBindBool(boolArr); - mBinds[2] = TaosMultiBind.MultiBindTinyInt(tinyIntArr); - mBinds[3] = TaosMultiBind.MultiBindSmallInt(shortArr); - mBinds[4] = TaosMultiBind.MultiBindInt(intArr); - mBinds[5] = TaosMultiBind.MultiBindBigint(longArr); - mBinds[6] = TaosMultiBind.MultiBindFloat(floatArr); - mBinds[7] = TaosMultiBind.MultiBindDouble(doubleArr); - mBinds[8] = TaosMultiBind.MultiBindUTinyInt(uTinyIntArr); - mBinds[9] = TaosMultiBind.MultiBindUSmallInt(uShortArr); - mBinds[10] = TaosMultiBind.MultiBindUInt(uIntArr); - mBinds[11] = TaosMultiBind.MultiBindUBigInt(uLongArr); - mBinds[12] = TaosMultiBind.MultiBindBinary(binaryArrCn); - mBinds[13] = TaosMultiBind.MultiBindNchar(NcharArrCn); - return mBinds; - } - // A List of data ,use as expectResData. The value is equal to GetMultiBindCNArr() - public static List GetMultiBindCNRowData() - { - var rowData = new List(); - for (int i = 0; i < tsArr.Length; i++) - { - rowData.Add(tsArr[i].ToString()); - rowData.Add(boolArr[i].Equals(null) ? "NULL" : boolArr[i].ToString()); - rowData.Add(tinyIntArr[i].Equals(null) ? "NULL" : tinyIntArr[i].ToString()); - rowData.Add(shortArr[i].Equals(null) ? "NULL" : shortArr[i].ToString()); - rowData.Add(intArr[i].Equals(null) ? "NULL" : intArr[i].ToString()); - rowData.Add(longArr[i].Equals(null) ? "NULL" : longArr[i].ToString()); - rowData.Add(floatArr[i].Equals(null) ? "NULL" : floatArr[i].ToString()); - rowData.Add(doubleArr[i].Equals(null) ? "NULL" : doubleArr[i].ToString()); - rowData.Add(uTinyIntArr[i].Equals(null) ? "NULL" : uTinyIntArr[i].ToString()); - rowData.Add(uShortArr[i].Equals(null) ? "NULL" : uShortArr[i].ToString()); - rowData.Add(uIntArr[i].Equals(null) ? "NULL" : uIntArr[i].ToString()); - rowData.Add(uLongArr[i].Equals(null) ? "NULL" : uLongArr[i].ToString()); - rowData.Add(String.IsNullOrEmpty(binaryArrCn[i]) ? "NULL" : binaryArrCn[i]); - rowData.Add(String.IsNullOrEmpty(NcharArrCn[i]) ? "NULL" : NcharArrCn[i]); - // Console.WriteLine("binaryArrCn[{0}]:{1},NcharArrCn[{0}]:{2}",i,String.IsNullOrEmpty(binaryArrCn[i]) ? "NULL" : binaryArrCn[i],String.IsNullOrEmpty(NcharArrCn[i]) ? "NULL" : NcharArrCn[i]); - // Console.WriteLine("binaryArrCn[{0}]:{1},NcharArrCn[{0}]:{2}",i,String.IsNullOrEmpty(binaryArrCn[i]) ? 0 :binaryArrCn[i].Length, String.IsNullOrEmpty(NcharArrCn[i]) ? 0 : NcharArrCn[i].Length); - // Console.WriteLine("========"); - - } - return rowData; - } - - public static List GetMultiBindStableCNRowData() - { - List columnData = new List(); - List tagData = GetTagCNData(); - for (int i = 0; i < tsArr.Length; i++) - { - columnData.Add(tsArr[i].ToString()); - columnData.Add(boolArr[i].Equals(null) ? "NULL" : boolArr[i].ToString()); - columnData.Add(tinyIntArr[i].Equals(null) ? "NULL" : tinyIntArr[i].ToString()); - columnData.Add(shortArr[i].Equals(null) ? "NULL" : shortArr[i].ToString()); - columnData.Add(intArr[i].Equals(null) ? "NULL" : intArr[i].ToString()); - columnData.Add(longArr[i].Equals(null) ? "NULL" : longArr[i].ToString()); - columnData.Add(floatArr[i].Equals(null) ? "NULL" : floatArr[i].ToString()); - columnData.Add(doubleArr[i].Equals(null) ? "NULL" : doubleArr[i].ToString()); - columnData.Add(uTinyIntArr[i].Equals(null) ? "NULL" : uTinyIntArr[i].ToString()); - columnData.Add(uShortArr[i].Equals(null) ? "NULL" : uShortArr[i].ToString()); - columnData.Add(uIntArr[i].Equals(null) ? "NULL" : uIntArr[i].ToString()); - columnData.Add(uLongArr[i].Equals(null) ? "NULL" : uLongArr[i].ToString()); - columnData.Add(String.IsNullOrEmpty(binaryArrCn[i]) ? "NULL" : binaryArrCn[i]); - columnData.Add(String.IsNullOrEmpty(NcharArrCn[i]) ? "NULL" : NcharArrCn[i]); - columnData.AddRange(tagData); - // Console.WriteLine("binaryArrCn[{0}]:{1},NcharArrCn[{0}]:{2}",i,String.IsNullOrEmpty(binaryArrCn[i]) ? "NULL" : binaryArrCn[i],String.IsNullOrEmpty(NcharArrCn[i]) ? "NULL" : NcharArrCn[i]); - // Console.WriteLine("binaryArrCn[{0}]:{1},NcharArrCn[{0}]:{2}",i,String.IsNullOrEmpty(binaryArrCn[i]) ? 0 :binaryArrCn[i].Length, String.IsNullOrEmpty(NcharArrCn[i]) ? 0 : NcharArrCn[i].Length); - // Console.WriteLine("========"); - - } - return columnData; - } - - public static TAOS_BIND[] GetQueryCondition() - { - TAOS_BIND[] queryCondition = new TAOS_BIND[2]; - queryCondition[0] = TaosBind.BindTinyInt(0); - queryCondition[1] = TaosBind.BindInt(1000); - return queryCondition; - - } - public static void FreeTaosBind(TAOS_BIND[] binds) - { - TaosBind.FreeTaosBind(binds); - } - - public static void FreeTaosMBind(TAOS_MULTI_BIND[] mBinds) - { - TaosMultiBind.FreeTaosBind(mBinds); - } - //Get the TDengineMeta list from the ddl either normal table or stable - public static List GetMetaFromDDL(string dllStr) - { - var expectResMeta = new List(); - //"CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT);"; - int bracketInd = dllStr.IndexOf("("); - //(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT); - string subDllStr = dllStr.Substring(bracketInd); - - String[] stableSeparators = new String[] { "tags", "TAGS" }; - //(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) - //(location BINARY(30), groupId INT) - String[] dllStrElements = subDllStr.Split(stableSeparators, StringSplitOptions.RemoveEmptyEntries); - //(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) - dllStrElements[0] = dllStrElements[0].Substring(1, dllStrElements[0].Length - 2); - String[] finalStr1 = dllStrElements[0].Split(',', StringSplitOptions.RemoveEmptyEntries); - foreach (string item in finalStr1) - { - //ts TIMESTAMP - string[] itemArr = item.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries); - // Console.WriteLine("GetMetaFromDLL():{0},{1}",itemArr[0],itemArr[1]); - expectResMeta.Add(UtilsTools.ConstructTDengineMeta(itemArr[0], itemArr[1])); - } - if (dllStr.Contains("TAGS") || dllStr.Contains("tags")) - { - //location BINARY(30), groupId INT - dllStrElements[1] = dllStrElements[1].Substring(1, dllStrElements[1].Length - 2); - //location BINARY(30) groupId INT - String[] finalStr2 = dllStrElements[1].Split(',', StringSplitOptions.RemoveEmptyEntries); - Console.WriteLine("========"); - foreach (string item in finalStr2) - { - //location BINARY(30) - string[] itemArr = item.Split(' ', 2, StringSplitOptions.RemoveEmptyEntries); - // Console.WriteLine("GetMetaFromDLL():{0},{1}",itemArr[0],itemArr[1]); - expectResMeta.Add(UtilsTools.ConstructTDengineMeta(itemArr[0], itemArr[1])); - } - - } - return expectResMeta; - } - - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/FetchFields.cs b/src/connector/C#/src/test/FunctionTest/FetchFields.cs deleted file mode 100644 index b0a5859d4dddef0b24bd98cc8183917b6ec4e1cb..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/FetchFields.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using Test.UtilsTools; -using TDengineDriver; -using System.Collections.Generic; -using Xunit; -using Test.UtilsTools.ResultSet; -using Test.Fixture; -using Test.Case.Attributes; - -namespace Cases -{ - [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] - [Collection("Database collection")] - public class FetchFieldCases - { - - DatabaseFixture database; - - - public FetchFieldCases(DatabaseFixture fixture) - { - this.database = fixture; - } - /// xiaolei - /// FetchFieldsCases.TestFetchFieldsJsonTag - /// test taos_fetch_fields(), check the meta data - /// FetchFields.cs - /// pass or failed - [Fact(DisplayName = "FetchFieldsCases.TestFetchFieldJsonTag()"),TestExeOrder(1),Trait("Category", "FetchFieldJsonTag")] - public void TestFetchFieldJsonTag() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - string tableName = "fetch_fields"; - var expectResMeta = new List { - UtilsTools.ConstructTDengineMeta("ts", "timestamp"), - UtilsTools.ConstructTDengineMeta("b", "bool"), - UtilsTools.ConstructTDengineMeta("v1", "tinyint"), - UtilsTools.ConstructTDengineMeta("v2", "smallint"), - UtilsTools.ConstructTDengineMeta("v4", "int"), - UtilsTools.ConstructTDengineMeta("v8", "bigint"), - UtilsTools.ConstructTDengineMeta("f4", "float"), - UtilsTools.ConstructTDengineMeta("f8", "double"), - UtilsTools.ConstructTDengineMeta("u1", "tinyint unsigned"), - UtilsTools.ConstructTDengineMeta("u2", "smallint unsigned"), - UtilsTools.ConstructTDengineMeta("u4", "int unsigned"), - UtilsTools.ConstructTDengineMeta("u8", "bigint unsigned"), - UtilsTools.ConstructTDengineMeta("bin", "binary(200)"), - UtilsTools.ConstructTDengineMeta("blob", "nchar(200)"), - UtilsTools.ConstructTDengineMeta("jsontag", "json"), - }; - var expectResData = new List { "1637064040000", "true", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "XI", "XII", "{\"k1\": \"v1\"}" }; - String dropTb = "drop table if exists " + tableName; - String createTb = "create stable " + tableName - + " (ts timestamp" + - ",b bool" + - ",v1 tinyint" + - ",v2 smallint" + - ",v4 int" + - ",v8 bigint" + - ",f4 float" + - ",f8 double" + - ",u1 tinyint unsigned" + - ",u2 smallint unsigned" + - ",u4 int unsigned" + - ",u8 bigint unsigned" + - ",bin binary(200)" + - ",blob nchar(200)" + - ")" + - "tags" + - "(jsontag json);"; - String insertSql = "insert into " + tableName + "_t1 using " + tableName + - " tags('{\"k1\": \"v1\"}') " + - "values(1637064040000,true,1,2,3,4,5,6,7,8,9,10,'XI','XII')"; - String selectSql = "select * from " + tableName; - String dropSql = "drop table " + tableName; - - UtilsTools.ExecuteUpdate(conn, dropTb); - UtilsTools.ExecuteUpdate(conn, createTb); - UtilsTools.ExecuteUpdate(conn, insertSql); - _res = UtilsTools.ExecuteQuery(conn, selectSql); - - ResultSet actualResult = new ResultSet(_res); - List actualMeta = actualResult.GetResultMeta(); - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - } - } -} diff --git a/src/connector/C#/src/test/FunctionTest/FetchLength.cs b/src/connector/C#/src/test/FunctionTest/FetchLength.cs deleted file mode 100644 index 928e1dfa92a723c52a2939bece2552ddeba7fd3f..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/FetchLength.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using Test.UtilsTools; -using System.Collections.Generic; -using Xunit; -using TDengineDriver; -using Test.UtilsTools.ResultSet; -using Test.Case.Attributes; -namespace Cases -{ - [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] - - public class FetchLengthCase - { - /// xiaolei - /// TestRetrieveBinary - /// TD-12103 C# connector fetch_row with binary data retrieving error - /// FetchLength.cs - /// pass or failed - [Fact(DisplayName = "FetchLengthCase.TestRetrieveBinary()"),TestExeOrder(1)] - public void TestRetrieveBinary() - { - IntPtr conn = UtilsTools.TDConnection(); - var expectData = new List { "log", "test", "db02", "db3" }; - var expectMeta = new List{ - UtilsTools.ConstructTDengineMeta("ts","timestamp"), - UtilsTools.ConstructTDengineMeta("name","binary(10)"), - UtilsTools.ConstructTDengineMeta("n","int") - }; - string sql0 = "drop table if exists stb1;"; - string sql1 = "create stable if not exists stb1 (ts timestamp, name binary(10)) tags(n int);"; - string sql2 = $"insert into tb1 using stb1 tags(1) values(now, '{expectData[0]}');"; - string sql3 = $"insert into tb2 using stb1 tags(2) values(now, '{expectData[1]}');"; - string sql4 = $"insert into tb3 using stb1 tags(3) values(now, '{expectData[2]}');"; - string sql5 = $"insert into tb4 using stb1 tags(4) values(now, '{expectData[3]}');"; - - string sql6 = "select distinct(name) from stb1;"; - UtilsTools.ExecuteQuery(conn, sql0); - UtilsTools.ExecuteQuery(conn, sql1); - UtilsTools.ExecuteQuery(conn, sql2); - UtilsTools.ExecuteQuery(conn, sql3); - UtilsTools.ExecuteQuery(conn, sql4); - UtilsTools.ExecuteQuery(conn, sql5); - - IntPtr resPtr = IntPtr.Zero; - resPtr = UtilsTools.ExecuteQuery(conn, sql6); - - ResultSet actualResult = new ResultSet(resPtr); - List actualData = actualResult.GetResultData(); - List actualMeta = actualResult.GetResultMeta(); - expectData.Reverse(); - - Assert.Equal(expectData[0], actualData[0]); - Assert.Equal(expectMeta[1].name, actualMeta[0].name); - Assert.Equal(expectMeta[1].size, actualMeta[0].size); - Assert.Equal(expectMeta[1].type, actualMeta[0].type); - - } - } -} diff --git a/src/connector/C#/src/test/FunctionTest/FunctionTest.csproj b/src/connector/C#/src/test/FunctionTest/FunctionTest.csproj deleted file mode 100644 index a30d3c760056ba25e3cfbec83067718712b5229f..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/FunctionTest.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - net5.0 - false - CS1591;CS0168 - true - ..\doc\FunctionTest.XML - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/src/connector/C#/src/test/FunctionTest/InsertCn.cs b/src/connector/C#/src/test/FunctionTest/InsertCn.cs deleted file mode 100644 index 51931340f50a9b9b8876a1d8ba2cf11c13259e97..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/InsertCn.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using Test.UtilsTools; -using TDengineDriver; -using Test.UtilsTools.DataSource; -using Xunit; -using System.Collections.Generic; -using Test.UtilsTools.ResultSet; -using Test.Case.Attributes; -using Test.Fixture; -namespace Cases -{ - [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] - [Collection("Database collection")] - public class InsertCNCases - { - DatabaseFixture database; - public InsertCNCases(DatabaseFixture fixture) - { - this.database = fixture; - } - /// xiaolei - /// InsertCNCases.TestNTable - /// Test insert Chinese characters into normal table's nchar column - /// InsertCn.cs - /// pass or failed - [Fact(DisplayName = "InsertCNCases.TestNTable"), TestExeOrder(1)] - public void TestNTable() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - string tableName = "cn_insert_nchar_ntable"; - // var expectResData = new List { "1637064040000", "true", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "XI", "XII", "{\"k1\": \"v1\"}" }; - var colData = new List{1637064040000,1,"涛思数据", - 1637064041000,2,"涛思数据taosdata", - 1637064042000,3,"TDegnine涛思数据", - 1637064043000,4,"4涛思数据", - 1637064044000,5,"涛思数据5", - 1637064045000,6,"taos涛思数据6", - 1637064046000,7,"7涛思数据taos", - 1637064047000,8,"8&涛思数据taos", - 1637064048000,9,"&涛思数据taos9" - }; - - String dropTb = "drop table if exists " + tableName; - String createTb = $"create table if not exists {tableName} (ts timestamp,v4 int,blob nchar(200));"; - String insertSql = UtilsTools.ConstructInsertSql(tableName, "", colData, null, 9); - String selectSql = "select * from " + tableName; - String dropSql = "drop table " + tableName; - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - UtilsTools.ExecuteUpdate(conn, dropTb); - UtilsTools.ExecuteUpdate(conn, createTb); - UtilsTools.ExecuteUpdate(conn, insertSql); - _res = UtilsTools.ExecuteQuery(conn, selectSql); - - ResultSet actualResult = new ResultSet(_res); - List actualMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(colData[i].ToString(), actualResData[i]); - } - - } - - /// xiaolei - /// InsertCNCases.TestSTable - /// test insert Chinese character into stable's nchar column,both tag and column - /// InsertCn.cs - /// pass or failed - [Fact(DisplayName = "InsertCNCases.TestSTable()"), TestExeOrder(2)] - public void TestSTable() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - string tableName = "cn_insert_nchar_stable"; - var colData = new List{1637064040000,1,"涛思数据", - 1637064041000,2,"涛思数据taosdata", - 1637064042000,3,"TDegnine涛思数据", - 1637064043000,4,"4涛思数据", - 1637064044000,5,"涛思数据5", - 1637064045000,6,"taos涛思数据6", - 1637064046000,7,"7涛思数据taos", - 1637064047000,8,"8&涛思数据taos", - 1637064048000,9,"&涛思数据taos9" - }; - var tagData = new List { 1, "涛思数据", }; - String dropTb = "drop table if exists " + tableName; - String createTb = $"create table {tableName} (ts timestamp,v4 int,blob nchar(200))tags(id int,name nchar(50));"; - String insertSql = UtilsTools.ConstructInsertSql(tableName + "_sub1", tableName, colData, tagData, 9); - String selectSql = "select * from " + tableName; - String dropSql = "drop table " + tableName; - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - List expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 9); - - UtilsTools.ExecuteUpdate(conn, dropTb); - UtilsTools.ExecuteUpdate(conn, createTb); - UtilsTools.ExecuteUpdate(conn, insertSql); - _res = UtilsTools.ExecuteQuery(conn, selectSql); - - ResultSet actualResult = new ResultSet(_res); - List actualMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i].ToString(), actualResData[i]); - } - } - - /// xiaolei - /// InsertCNCases.TestInsertMultiNTable - /// test insert Chinese character into normal table's multiple nchar columns - /// InsertCn.cs - /// pass or failed - [Fact(DisplayName = "InsertCNCases.TestInsertMultiNTable()"), TestExeOrder(3)] - public void TestInsertMultiNTable() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - string tableName = "cn_multi_insert_nchar_ntable"; - var colData = new List{1637064040000,1,"涛思数据","保利广场","Beijing","China", - 1637064041000,2,"涛思数据taosdata","保利广场baoli","Beijing","China", - 1637064042000,3,"TDegnine涛思数据","time广场","NewYork","US", - 1637064043000,4,"4涛思数据","4广场南部","London","UK", - 1637064044000,5,"涛思数据5","!广场路中部123","Tokyo","JP", - 1637064045000,6,"taos涛思数据6","青年广场123号!","Washin","DC", - 1637064046000,7,"7涛思数据taos","asdf#壮年广场%#endregion","NewYork","US", - 1637064047000,8,"8&涛思数据taos","incluse阿斯顿发","NewYork","US", - 1637064048000,9,"&涛思数据taos9","123黑化肥werq会挥……&¥%发!afsdfa","NewYork","US", - }; - - String dropTb = "drop table if exists " + tableName; - String createTb = $"create table if not exists {tableName} (ts timestamp,v4 int,blob nchar(200),location nchar(200),city binary(100),coutry binary(200));"; - String insertSql = UtilsTools.ConstructInsertSql(tableName, "", colData, null, 9); - String selectSql = "select * from " + tableName; - String dropSql = "drop table " + tableName; - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - UtilsTools.ExecuteUpdate(conn, dropTb); - UtilsTools.ExecuteUpdate(conn, createTb); - UtilsTools.ExecuteUpdate(conn, insertSql); - _res = UtilsTools.ExecuteQuery(conn, selectSql); - - ResultSet actualResult = new ResultSet(_res); - List actualMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(colData[i].ToString(), actualResData[i]); - } - } - - /// xiaolei - /// InsertCNCases.TestInsertMultiSTable - /// test insert Chinese character into stable's multiple nchar columns - /// InsertCn.cs - /// pass or failed - [Fact(DisplayName = "InsertCNCases.TestInsertMultiSTable()"), TestExeOrder(4)] - public void TestInsertMultiSTable() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - string tableName = "cn_multi_insert_nchar_stable"; - var colData = new List{1637064040000,1,"涛思数据","保利广场","Beijing","China", - 1637064041000,2,"涛思数据taosdata","保利广场baoli","Beijing","China", - 1637064042000,3,"TDegnine涛思数据","time广场","NewYork","US", - 1637064043000,4,"4涛思数据","4广场南部","London","UK", - 1637064044000,5,"涛思数据5","!广场路中部123","Tokyo","JP", - 1637064045000,6,"taos涛思数据6","青年广场123号!","Washin","DC", - 1637064046000,7,"7涛思数据taos","asdf#壮年广场%#endregion","NewYork","US", - 1637064047000,8,"8&涛思数据taos","incluse阿斯顿发","NewYork","US", - 1637064048000,9,"&涛思数据taos9","123黑化肥werq会挥……&¥%发!afsdfa","NewYork","US", - }; - var tagData = new List { 1, "涛思数据", "中国北方&南方长江黄河!49wq", "tdengine" }; - String dropTb = "drop table if exists " + tableName; - String createTb = $"create table if not exists {tableName} (ts timestamp," + - $"v4 int," + - $"blob nchar(200)," + - $"locate nchar(200)," + - $"country nchar(200)," + - $"city nchar(50)" + - $")tags(" + - $"id int," + - $"name nchar(50)," + - $"addr nchar(200)," + - $"en_name binary(200));"; - String insertSql = UtilsTools.ConstructInsertSql(tableName + "_sub1", tableName, colData, tagData, 9); - String selectSql = "select * from " + tableName; - String dropSql = "drop table " + tableName; - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - List expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 9); - - UtilsTools.ExecuteUpdate(conn, dropTb); - UtilsTools.ExecuteUpdate(conn, createTb); - UtilsTools.ExecuteUpdate(conn, insertSql); - _res = UtilsTools.ExecuteQuery(conn, selectSql); - - ResultSet actualResult = new ResultSet(_res); - List actualMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i].ToString(), actualResData[i]); - } - } - } -} diff --git a/src/connector/C#/src/test/FunctionTest/QueryAsync.cs b/src/connector/C#/src/test/FunctionTest/QueryAsync.cs deleted file mode 100644 index 31e6665d6bfbc286eb817e0c1e4967aa7fefafd6..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/QueryAsync.cs +++ /dev/null @@ -1,295 +0,0 @@ -using TDengineDriver; -using Test.UtilsTools; -using System; -using Xunit; -using System.Collections.Generic; -using Test.UtilsTools.DataSource; -using Test.UtilsTools.ResultSet; -using Xunit.Abstractions; -using Test.Fixture; -using Test.Case.Attributes; - -namespace Cases -{ - [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] - [Collection("Database collection")] - - public class QueryAsyncCases - { - DatabaseFixture database; - - private readonly ITestOutputHelper output; - - public QueryAsyncCases(DatabaseFixture fixture, ITestOutputHelper output) - { - this.database = fixture; - this.output = output; - } - /// xiaolei - /// QueryAsyncCases.QueryAsyncCases - /// Test query without condition - /// QueryAsync.cs - /// pass or failed - [Fact(DisplayName = "QueryAsyncCases.QueryWithoutCondition()"),TestExeOrder(1),Trait("Category", "QueryAWithoutCondition")] - public void QueryWithoutCondition() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - - var tableName = "query_a_without_condition"; - var createSql = $"create table if not exists {tableName}(ts timestamp,bl bool,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(50),nchr nchar(50))tags(t_i32 int,t_bnr binary(50),t_nchr nchar(50))"; - var dropSql = $"drop table if exists {tableName}"; - - var colData = new List{1646150410100,true,1,11,1111,11111111,"value one","值壹", - 1646150410200,true,2,22,2222,22222222,"value two","值贰", - 1646150410300,false,3,33,3333,33333333,"value three","值三", - }; - var tagData = new List { 1, "tag_one", "标签壹" }; - String insertSql = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData, tagData, 3); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 3); - - var querySql = $"select * from {tableName}"; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - UtilsTools.ExecuteUpdate(conn, insertSql); - - QueryAsyncCallback fq = new QueryAsyncCallback(QueryCallback); - TDengine.QueryAsync(conn, querySql, fq, IntPtr.Zero); - - void QueryCallback(IntPtr param, IntPtr taosRes, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - FetchRowAsyncCallback fetchRowAsyncCallback = new FetchRowAsyncCallback(FetchCallback); - TDengine.FetchRowAsync(taosRes, fetchRowAsyncCallback, param); - } - else - { - Console.WriteLine($"async query data failed, failed code {code}"); - } - - } - - void FetchCallback(IntPtr param, IntPtr taosRes, int numOfRows) - { - if (numOfRows > 0) - { - ResultSet actualResult = new ResultSet(taosRes); - List actualMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - // Console.WriteLine("{0},{1},{2}", i, expectResData[i], actualResData[i]); - Assert.Equal(expectResData[i].ToString(), actualResData[i]); - } - - TDengine.FetchRowAsync(taosRes, FetchCallback, param); - } - else - { - if (numOfRows == 0) - { - Console.WriteLine("async retrieve complete."); - - } - else - { - Console.WriteLine($"FetchRowAsync callback error, error code {numOfRows}"); - } - TDengine.FreeResult(taosRes); - } - } - } - - /// xiaolei - /// QueryAsyncCases.QueryWithCondition - /// Test query with condition - /// QueryAsync.cs - /// pass or failed - [Fact(DisplayName = "QueryAsyncCases.QueryWithCondition()"),TestExeOrder(2),Trait("Category", "QueryAWithCondition")] - public void QueryWithCondition() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - - var tableName = "query_a_with_condition"; - var createSql = $"create table if not exists {tableName}(ts timestamp,bl bool,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(50),nchr nchar(50))tags(t_i32 int,t_bnr binary(50),t_nchr nchar(50))"; - var dropSql = $"drop table if exists {tableName}"; - - var colData = new List{1646150410100,true,1,11,1111,11111111,"value one","值壹", - 1646150410200,true,2,22,2222,22222222,"value two","值贰", - 1646150410300,false,3,33,3333,33333333,"value three","值三", - }; - var colDataActual = colData.GetRange(8, 8); - var tagData = new List { 1, "tag_one", "标签壹" }; - String insertSql = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData, tagData, 3); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = UtilsTools.CombineColAndTagData(colDataActual, tagData, 1); - colDataActual.ForEach((item) => { Console.Write("{0}\t", item); }); - - var querySql = $"select * from {tableName} where bl=true and t_bnr='tag_one' and i8>1 and t_nchr = '标签壹'"; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - UtilsTools.ExecuteUpdate(conn, insertSql); - QueryAsyncCallback fq = new QueryAsyncCallback(QueryCallback); - TDengine.QueryAsync(conn, querySql, fq, IntPtr.Zero); - - void QueryCallback(IntPtr param, IntPtr taosRes, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - FetchRowAsyncCallback fetchRowAsyncCallback = new FetchRowAsyncCallback(FetchCallback); - TDengine.FetchRowAsync(taosRes, fetchRowAsyncCallback, param); - } - else - { - Console.WriteLine($"async query data failed, failed code {code}"); - } - - } - - void FetchCallback(IntPtr param, IntPtr taosRes, int numOfRows) - { - if (numOfRows > 0) - { - ResultSet actualResult = new ResultSet(taosRes); - List actualMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - // Console.WriteLine("{0},{1},{2}", i, expectResData[i], actualResData[i]); - Assert.Equal(expectResData[i].ToString(), actualResData[i]); - } - - TDengine.FetchRowAsync(taosRes, FetchCallback, param); - } - else - { - if (numOfRows == 0) - { - Console.WriteLine("async retrieve complete."); - - } - else - { - Console.WriteLine($"FetchRowAsync callback error, error code {numOfRows}"); - } - TDengine.FreeResult(taosRes); - } - } - - } - - /// xiaolei - /// QueryAsyncCases.QueryWithJsonCondition - /// Test query with condition - /// QueryAsync.cs - /// pass or failed - [Fact(DisplayName = "QueryAsyncCases.QueryWithJsonCondition()"),TestExeOrder(3),Trait("Category", "QueryAWithJsonCondition")] - public void QueryWithJsonCondition() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - - var tableName = "query_a_json_condition"; - var createSql = $"create table if not exists {tableName}(ts timestamp,bl bool,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(50),nchr nchar(50))tags(jtag json)"; - var dropSql = $"drop table if exists {tableName}"; - - var colData1 = new List{1646150410100,true,1,11,1111,11111111,"value one","值壹", - 1646150410200,true,2,22,2222,22222222,"value two","值贰", - 1646150410300,false,3,33,3333,33333333,"value three","值三", - }; - var colData2 = new List{1646150410400,false,4,44,4444,44444444,"value three","值肆", - 1646150410500,true,5,55,5555,55555555,"value one","值伍", - 1646150410600,true,6,66,6666,66666666,"value two","值陆", - }; - var tagData1 = new List { "{\"t_bnr\":\"tag1\",\"t_i32\":1,\"t_nchr\":\"标签壹\"}" }; - var tagData2 = new List { "{\"t_bnr\":\"tag2\",\"t_i32\":2,\"t_nchar\":\"标签贰\"}" }; - var querySql = $"select * from {tableName} where jtag->'t_bnr'='tag1';"; - - - String insertSql1 = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData1, tagData1, 3); - String insertSql2 = UtilsTools.ConstructInsertSql(tableName + "_s02", tableName, colData1, tagData2, 3); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = UtilsTools.CombineColAndTagData(colData1, tagData1, 3); - - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - UtilsTools.ExecuteUpdate(conn, insertSql1); - UtilsTools.ExecuteUpdate(conn, insertSql2); - QueryAsyncCallback fq = new QueryAsyncCallback(QueryCallback); - TDengine.QueryAsync(conn, querySql, fq, IntPtr.Zero); - - void QueryCallback(IntPtr param, IntPtr taosRes, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - FetchRowAsyncCallback fetchRowAsyncCallback = new FetchRowAsyncCallback(FetchCallback); - TDengine.FetchRowAsync(taosRes, fetchRowAsyncCallback, param); - } - else - { - Console.WriteLine($"async query data failed, failed code {code}"); - } - - } - - void FetchCallback(IntPtr param, IntPtr taosRes, int numOfRows) - { - if (numOfRows > 0) - { - ResultSet actualResult = new ResultSet(taosRes); - List actualMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - // Console.WriteLine("{0},{1},{2}", i, expectResData[i], actualResData[i]); - Assert.Equal(expectResData[i].ToString(), actualResData[i]); - } - - TDengine.FetchRowAsync(taosRes, FetchCallback, param); - } - else - { - if (numOfRows == 0) - { - Console.WriteLine("async retrieve complete."); - - } - else - { - Console.WriteLine($"FetchRowAsync callback error, error code {numOfRows}"); - } - TDengine.FreeResult(taosRes); - } - } - - - } - } -} diff --git a/src/connector/C#/src/test/FunctionTest/StmtNormalTable.cs b/src/connector/C#/src/test/FunctionTest/StmtNormalTable.cs deleted file mode 100644 index 72983dd02d44d8a1cf1cb2b80cf5ed033860b2f4..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/StmtNormalTable.cs +++ /dev/null @@ -1,466 +0,0 @@ -using System; -using Test.UtilsTools; -using TDengineDriver; -using Test.UtilsTools.DataSource; -using Xunit; -using System.Collections.Generic; -using Test.UtilsTools.ResultSet; -using Test.Fixture; -using Test.Case.Attributes; - -namespace Cases -{ - [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] - [Collection("Database collection")] - public class NormalTableStmtCases - { - DatabaseFixture database; - - public NormalTableStmtCases(DatabaseFixture fixture) - { - this.database = fixture; - } - /// xiaolei - /// NormalTableStmtCases.TestBindSingleLineCN - /// Test stmt insert single line of chinese character into normal table by column after column - /// StmtNormalTable.cs - /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLineCN()"),TestExeOrder(2),Trait("Category", "bindParamCN")] - public void TestBindSingleLineCN() - { - string tableName = "ntb_stmt_cases_test_bind_single_line_cn"; - String createTb = $"create table if not exists {tableName} (" + - "ts timestamp," + - "tt tinyint," + - "si smallint," + - "ii int," + - "bi bigint," + - "tu tinyint unsigned," + - "su smallint unsigned," + - "iu int unsigned," + - "bu bigint unsigned," + - "ff float," + - "dd double," + - "bb binary(200)," + - "nc nchar(200)," + - "bo bool," + - "nullval int" + - ");"; - string insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - string dropSql = $"drop table if exists {tableName}"; - string querySql = "select * from " + tableName; - TAOS_BIND[] _valuesRow = DataSource.GetNTableCNRow(); - List expectResData = DataSource.GetNTableCNRowData(); - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createTb); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableName(stmt, tableName); - StmtUtilTools.BindParam(stmt, _valuesRow); - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - DataSource.FreeTaosBind(_valuesRow); - - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - } - - /// xiaolei - /// NormalTableStmtCases.TestBindColumnCN - /// Test stmt insert single line of chinese character into normal table by column after column - /// StmtNormalTable.cs - /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindColumnCN()"),TestExeOrder(4),Trait("Category", "bindSingleColumnCN")] - public void TestBindColumnCN() - { - string tableName = "ntb_stmt_cases_test_bind_column_cn"; - String createTb = $"create table if not exists {tableName} " + - " (" + - "ts timestamp," + - "b bool," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "f4 float," + - "f8 double," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "bin binary(200)," + - "blob nchar(200)" + - ");"; - String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName} "; - List expectResData = DataSource.GetMultiBindCNRowData(); - TAOS_MULTI_BIND[] mBind = DataSource.GetMultiBindCNArr(); - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createTb); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableName(stmt, tableName); - - StmtUtilTools.BindSingleParamBatch(stmt, mBind[0], 0); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[1], 1); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[2], 2); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[3], 3); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[4], 4); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[5], 5); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[6], 6); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[7], 7); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[8], 8); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[9], 9); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[10], 10); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[11], 11); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[12], 12); - StmtUtilTools.BindSingleParamBatch(stmt, mBind[13], 13); - - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - - DataSource.FreeTaosMBind(mBind); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - - } - } - - /// xiaolei - /// NormalTableStmtCases.TestBindMultiLineCN - /// Test stmt insert single line of chinese character into normal table by column after column - /// StmtNormalTable.cs - /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindMultiLineCN()"),TestExeOrder(6),Trait("Category", "bindParamBatchCN")] - public void TestBindMultiLineCN() - { - string tableName = "ntb_stmt_cases_test_bind_multi_lines_cn"; - TAOS_MULTI_BIND[] mBind = DataSource.GetMultiBindCNArr(); - String createTb = $"create table if not exists {tableName} " + - " (" + - "ts timestamp," + - "b bool," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "f4 float," + - "f8 double," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "bin binary(200)," + - "blob nchar(200)" + - ");"; - String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName} "; - List expectResData = DataSource.GetMultiBindCNRowData(); - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - IntPtr conn = database.conn; ; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createTb); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableName(stmt, tableName); - StmtUtilTools.BindParamBatch(stmt, mBind); - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - - DataSource.FreeTaosMBind(mBind); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - Assert.Equal(expectResMeta.Count, actualResMeta.Count); - Assert.Equal(expectResData.Count, actualResData.Count); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - } - - /// xiaolei - /// NormalTableStmtCases.TestBindSingleLine - /// Test stmt insert single line data into normal table - /// StmtNormalTable.cs - /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindSingleLine"),TestExeOrder(3),Trait("Category", "BindSingleColumn")] - public void TestBindSingleLine() - { - string tableName = "ntb_stmt_cases_test_bind_single_line"; - String createTb = $"create table if not exists {tableName} (" + - "ts timestamp," + - "tt tinyint," + - "si smallint," + - "ii int," + - "bi bigint," + - "tu tinyint unsigned," + - "su smallint unsigned," + - "iu int unsigned," + - "bu bigint unsigned," + - "ff float," + - "dd double," + - "bb binary(200)," + - "nc nchar(200)," + - "bo bool," + - "nullval int" + - ");"; - string insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - string dropSql = $"drop table if exists {tableName}"; - string querySql = "select * from " + tableName; - TAOS_BIND[] valuesRow = DataSource.GetNTableRow(); - List expectResData = DataSource.GetNTableRowData(); - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - IntPtr conn = database.conn; - UtilsTools.ExecuteQuery(conn, dropSql); - UtilsTools.ExecuteQuery(conn, createTb); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableName(stmt, tableName); - StmtUtilTools.BindParam(stmt, valuesRow); - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - DataSource.FreeTaosBind(valuesRow); - - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - Assert.Equal(expectResMeta.Count, actualResMeta.Count); - Assert.Equal(expectResData.Count, actualResData.Count); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - - } - - /// xiaolei - /// NormalTableStmtCases.TestBindMultiLine - /// Test stmt insert multiple rows of data into normal table - /// StmtNormalTable.cs - /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindMultiLine()"),TestExeOrder(5),Trait("Category", "bindParamBatch")] - public void TestBindMultiLine() - { - string tableName = "ntb_stmt_case_test_bind_multi_lines"; - String createTb = $"create table if not exists {tableName} " + - " (" + - "ts timestamp," + - "b bool," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "f4 float," + - "f8 double," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "bin binary(200)," + - "blob nchar(200)" + - ");"; - String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName} "; - List expectResData = DataSource.GetMultiBindResData(); - TAOS_MULTI_BIND[] mBind = DataSource.GetMultiBindArr(); - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createTb); - - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableName(stmt, tableName); - StmtUtilTools.BindParamBatch(stmt, mBind); - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - DataSource.FreeTaosMBind(mBind); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - Assert.Equal(expectResMeta.Count, actualResMeta.Count); - Assert.Equal(expectResData.Count, actualResData.Count); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - } - - /// xiaolei - /// NormalTableStmtCases.TestBindColumn - /// Test stmt insert multiple rows of data into normal table by column after column - /// StmtNormalTable.cs - /// pass or failed - [Fact(DisplayName = "NormalTableStmtCases.TestBindColumn()"),TestExeOrder(1),Trait("Category", "bindParam")] - public void TestBindColumn() - { - string tableName = "ntb_stmt_cases_test_bind_column"; - DataSource data = new DataSource(); - String createTb = $"create table if not exists {tableName} " + - " (" + - "ts timestamp," + - "b bool," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "f4 float," + - "f8 double," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "bin binary(200)," + - "blob nchar(200)" + - ");"; - String insertSql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName} "; - List expectResData = DataSource.GetMultiBindResData(); - TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindArr(); - List expectResMeta = DataSource.GetMetaFromDDL(createTb); - - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createTb); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableName(stmt, tableName); - - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[0], 0); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[1], 1); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[2], 2); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[3], 3); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[4], 4); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[5], 5); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[6], 6); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[7], 7); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[8], 8); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[9], 9); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[10], 10); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[11], 11); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[12], 12); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[13], 13); - - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - - DataSource.FreeTaosMBind(mBinds); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - Assert.Equal(expectResMeta.Count, actualResMeta.Count); - Assert.Equal(expectResData.Count, actualResData.Count); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - - } - - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/StmtQuery.cs b/src/connector/C#/src/test/FunctionTest/StmtQuery.cs deleted file mode 100644 index 2911b8889e9c7520bf942fd65bc1bd5cc021ef53..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/StmtQuery.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using Test.UtilsTools; -using TDengineDriver; -using Test.UtilsTools.DataSource; - -namespace Cases -{ - public class StmtSTableQuery - { - public void Test(IntPtr conn, string tableName) - { - string selectSql = "SELECT * FROM " + tableName + " WHERE v1 > ? AND v4 < ?"; - TAOS_BIND[] queryCondition = DataSource.GetQueryCondition(); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, selectSql); - - StmtUtilTools.BindParam(stmt, queryCondition); - StmtUtilTools.StmtExecute(stmt); - IntPtr res = StmtUtilTools.StmtUseResult(stmt); - UtilsTools.DisplayRes(res); - - StmtUtilTools.StmtClose(stmt); - DataSource.FreeTaosBind(queryCondition); - - } - } - - public class StmtNTableQuery - { - public void Test(IntPtr conn, string tableName) - { - string selectSql = "SELECT * FROM " + tableName + " WHERE v1 > ? AND v4 < ?"; - TAOS_BIND[] queryCondition = DataSource.GetQueryCondition(); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, selectSql); - - StmtUtilTools.BindParam(stmt, queryCondition); - StmtUtilTools.StmtExecute(stmt); - IntPtr res = StmtUtilTools.StmtUseResult(stmt); - UtilsTools.DisplayRes(res); - - StmtUtilTools.StmtClose(stmt); - DataSource.FreeTaosBind(queryCondition); - - } - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/StmtStable.cs b/src/connector/C#/src/test/FunctionTest/StmtStable.cs deleted file mode 100644 index 44ecb298ffcfb3786c1fe76e4ce65336ad2b52fd..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/StmtStable.cs +++ /dev/null @@ -1,481 +0,0 @@ -using System; -using Test.UtilsTools; -using TDengineDriver; -using Test.UtilsTools.DataSource; -using System.Collections.Generic; -using Test.UtilsTools.ResultSet; -using Xunit; -using Test.Fixture; -using Test.Case.Attributes; - -namespace Cases -{ - [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] - [Collection("Database collection")] - - public class StableStmtCases - { - - DatabaseFixture database; - - - public StableStmtCases(DatabaseFixture fixture) - { - this.database = fixture; - } - /// xiaolei - /// StableStmtCases.TestBindSingleLineCN - /// Test stmt insert single line of chinese character into stable by column after column - /// StmtSTable.cs - /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindSingleLineCN()"),TestExeOrder(2),Trait("Category", "BindParamCN")] - public void TestBindSingleLineCN() - { - string tableName = "stb_stmt_cases_test_bind_single_line_cn"; - String createSql = $"create stable if not exists {tableName} " + - " (ts timestamp," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "f4 float," + - "f8 double," + - "bin binary(200)," + - "blob nchar(200)," + - "b bool," + - "nilcol int)" + - "tags" + - "(bo bool," + - "tt tinyint," + - "si smallint," + - "ii int," + - "bi bigint," + - "tu tinyint unsigned," + - "su smallint unsigned," + - "iu int unsigned," + - "bu bigint unsigned," + - "ff float," + - "dd double," + - "bb binary(200)," + - "nc nchar(200)" + - ");"; - String insertSql = $"insert into ? using {tableName} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName} ;"; - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = DataSource.GetSTableCNRowData(); - TAOS_BIND[] tags = DataSource.GetCNTags(); - TAOS_BIND[] binds = DataSource.GetNTableCNRow(); - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); - StmtUtilTools.BindParam(stmt, binds); - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - - DataSource.FreeTaosBind(tags); - DataSource.FreeTaosBind(binds); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - - } - - /// xiaolei - /// StableStmtCases.TestBindColumnCN - /// Test stmt insert single line of chinese character into stable by column after column - /// StmtSTable.cs - /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindColumnCN()"),TestExeOrder(4),Trait("Category", "BindParamColumnCN")] - public void TestBindColumnCN() - { - string tableName = "stb_stmt_cases_test_bindcolumn_cn"; - String createSql = $"create stable if not exists {tableName} " + - "(ts timestamp," + - "b bool," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "f4 float," + - "f8 double," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "bin binary(200)," + - "blob nchar(200)" + - ")" + - "tags" + - "(bo bool," + - "tt tinyint," + - "si smallint," + - "ii int," + - "bi bigint," + - "tu tinyint unsigned," + - "su smallint unsigned," + - "iu int unsigned," + - "bu bigint unsigned," + - "ff float," + - "dd double," + - "bb binary(200)," + - "nc nchar(200)" + - ");"; - String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName};"; - TAOS_BIND[] tags = DataSource.GetCNTags(); - TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindCNArr(); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = DataSource.GetMultiBindStableCNRowData(); - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); - - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[0], 0); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[1], 1); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[2], 2); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[3], 3); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[4], 4); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[5], 5); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[6], 6); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[7], 7); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[8], 8); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[9], 9); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[10], 10); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[11], 11); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[12], 12); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[13], 13); - - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - - DataSource.FreeTaosBind(tags); - DataSource.FreeTaosMBind(mBinds); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - - - } - - /// xiaolei - /// StableStmtCases.TestBindMultiLineCN - /// Test stmt insert single line of chinese character into stable by column after column - /// StmtSTable.cs - /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindMultiLineCN()"),TestExeOrder(6),Trait("Category", "BindParamBatchCN")] - public void TestBindMultiLineCN() - { - string tableName = "stb_stmt_cases_test_bind_multi_line_cn"; - String createSql = $"create stable if not exists {tableName} " + - "(ts timestamp," + - "b bool," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "f4 float," + - "f8 double," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "bin binary(200)," + - "blob nchar(200)" + - ")" + - "tags" + - "(bo bool," + - "tt tinyint," + - "si smallint," + - "ii int," + - "bi bigint," + - "tu tinyint unsigned," + - "su smallint unsigned," + - "iu int unsigned," + - "bu bigint unsigned," + - "ff float," + - "dd double," + - "bb binary(200)," + - "nc nchar(200)" + - ");"; - String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName};"; - TAOS_BIND[] tags = DataSource.GetCNTags(); - TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindCNArr(); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = DataSource.GetMultiBindStableCNRowData(); - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); - StmtUtilTools.BindParamBatch(stmt, mBinds); - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - - StmtUtilTools.StmtClose(stmt); - DataSource.FreeTaosBind(tags); - DataSource.FreeTaosMBind(mBinds); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - } - - /// xiaolei - /// StableStmtCases.TestBindMultiLine - /// Test stmt insert single line into stable by column after column - /// StmtSTable.cs - /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindMultiLine()"),TestExeOrder(5),Trait("Category", "BindParamBatch")] - public void TestBindMultiLine() - { - string tableName = "stb_stmt_cases_test_bind_multi_line"; - string createSql = $"create stable if not exists {tableName} " + - "(ts timestamp," + - "b bool," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "f4 float," + - "f8 double," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "bin binary(200)," + - "blob nchar(200)" + - ")" + - "tags" + - "(bo bool," + - "tt tinyint," + - "si smallint," + - "ii int," + - "bi bigint," + - "tu tinyint unsigned," + - "su smallint unsigned," + - "iu int unsigned," + - "bu bigint unsigned," + - "ff float," + - "dd double," + - "bb binary(200)," + - "nc nchar(200)" + - ");"; - String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName};"; - TAOS_BIND[] tags = DataSource.GetTags(); - TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindArr(); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = DataSource.GetMultiBindStableRowData(); - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); - StmtUtilTools.BindParamBatch(stmt, mBinds); - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - - DataSource.FreeTaosBind(tags); - DataSource.FreeTaosMBind(mBinds); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - // Assert.Equal(expectResData[i],actualResData[i]); - if (expectResData[i] != actualResData[i]) - { - Console.WriteLine("{0}==>,expectResData:{1},actualResData:{2}", i, expectResData[i], actualResData[i]); - } - - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - } - - /// xiaolei - /// StableStmtCases.TestBindColumn - /// Test stmt insert single line of chinese character into stable by column after column - /// StmtSTable.cs - /// pass or failed - [Fact(DisplayName = "StableStmtCases.TestBindColumn()"),TestExeOrder(3),Trait("Category", "BindParamColumn")] - public void TestBindColumn() - { - string tableName = "stb_stmt_cases_test_bindcolumn"; - string createSql = $"create stable if not exists {tableName} " + - "(ts timestamp," + - "b bool," + - "v1 tinyint," + - "v2 smallint," + - "v4 int," + - "v8 bigint," + - "f4 float," + - "f8 double," + - "u1 tinyint unsigned," + - "u2 smallint unsigned," + - "u4 int unsigned," + - "u8 bigint unsigned," + - "bin binary(200)," + - "blob nchar(200)" + - ")" + - "tags" + - "(bo bool," + - "tt tinyint," + - "si smallint," + - "ii int," + - "bi bigint," + - "tu tinyint unsigned," + - "su smallint unsigned," + - "iu int unsigned," + - "bu bigint unsigned," + - "ff float," + - "dd double," + - "bb binary(200)," + - "nc nchar(200)" + - ");"; - String insertSql = "insert into ? using " + tableName + " tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - String dropSql = $"drop table if exists {tableName};"; - TAOS_BIND[] tags = DataSource.GetTags(); - TAOS_MULTI_BIND[] mBinds = DataSource.GetMultiBindArr(); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = DataSource.GetMultiBindStableRowData(); - - IntPtr conn = database.conn; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - - IntPtr stmt = StmtUtilTools.StmtInit(conn); - StmtUtilTools.StmtPrepare(stmt, insertSql); - - StmtUtilTools.SetTableNameTags(stmt, tableName + "_t1", tags); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[0], 0); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[1], 1); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[2], 2); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[3], 3); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[4], 4); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[5], 5); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[6], 6); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[7], 7); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[8], 8); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[9], 9); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[10], 10); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[11], 11); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[12], 12); - StmtUtilTools.BindSingleParamBatch(stmt, mBinds[13], 13); - - StmtUtilTools.AddBatch(stmt); - StmtUtilTools.StmtExecute(stmt); - StmtUtilTools.StmtClose(stmt); - - DataSource.FreeTaosBind(tags); - DataSource.FreeTaosMBind(mBinds); - - string querySql = "select * from " + tableName; - IntPtr res = UtilsTools.ExecuteQuery(conn, querySql); - ResultSet actualResult = new ResultSet(res); - - List actualResMeta = actualResult.GetResultMeta(); - List actualResData = actualResult.GetResultData(); - - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - Assert.Equal(expectResData[i], actualResData[i]); - } - // Assert metadata - for (int i = 0; i < actualResMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualResMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualResMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualResMeta[i].size); - } - - } - - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/Subscribe.cs b/src/connector/C#/src/test/FunctionTest/Subscribe.cs deleted file mode 100644 index 57ded4a82f530b759b014f8109cd63246f2dfc3b..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/Subscribe.cs +++ /dev/null @@ -1,184 +0,0 @@ -using TDengineDriver; -using Test.UtilsTools; -using System; -using System.Collections.Generic; -using Xunit; -using Test.UtilsTools.DataSource; -using System.Threading; -using Xunit.Abstractions; -using Test.Fixture; -using Test.Case.Attributes; - -namespace Cases -{ - [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] - [Collection("Database collection")] - - public class SubscribeCases - { - DatabaseFixture database; - - private readonly ITestOutputHelper output; - - public SubscribeCases(DatabaseFixture fixture, ITestOutputHelper output) - { - this.database = fixture; - this.output = output; - } - /// xiaolei - /// SubscribeCases.ConsumeFromBegin - /// Subscribe a table and consume from beginning. - /// Subscribe.cs - /// pass or failed - [Fact(DisplayName = "SubscribeCases.ConsumeFromBegin()"), TestExeOrder(1), Trait("Category", "Without callback")] - public void ConsumeFromBegin() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - - var tableName = "subscribe_from_begin"; - var createSql = $"create table if not exists {tableName}(ts timestamp,bl bool,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(50),nchr nchar(50))tags(t_i32 int,t_bnr binary(50),t_nchr nchar(50))"; - var dropSql = $"drop table if exists {tableName}"; - - var colData = new List{1646150410100,true,1,11,1111,11111111,"value one","值壹", - 1646150410200,true,2,22,2222,22222222,"value two","值贰", - 1646150410300,false,3,33,3333,33333333,"value three","值三", - }; - - var colData2 = new List{1646150410400,false,4,44,4444,44444444,"value three","值肆", - 1646150410500,true,5,55,5555,55555555,"value one","值伍", - 1646150410600,true,6,66,6666,66666666,"value two","值陆", - }; - - var tagData = new List { 1, "tag_one", "标签壹" }; - var tagData2 = new List { 2, "tag_two", "标签贰" }; - - String insertSql = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData, tagData, 3); - String insertSql2 = UtilsTools.ConstructInsertSql(tableName + "_s02", tableName, colData2, tagData2, 3); - // Then - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 3); - List expectResData2 = UtilsTools.CombineColAndTagData(colData2, tagData2, 3); - expectResData.AddRange(expectResData2); - - var querySql = $"select * from {tableName}"; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - UtilsTools.ExecuteUpdate(conn, insertSql); - - - IntPtr subscribe = TDengine.Subscribe(conn, true, tableName, querySql, null, IntPtr.Zero, 0); - _res = TDengine.Consume(subscribe); - // need to call fetch TAOS_RES - UtilsTools.GetResDataWithoutFree(_res); - TDengine.Unsubscribe(subscribe, true); - - UtilsTools.ExecuteUpdate(conn, insertSql2); - Thread.Sleep(100); - - - subscribe = TDengine.Subscribe(conn, true, tableName, querySql, null, IntPtr.Zero, 0); - _res = TDengine.Consume(subscribe); - - List actualMeta = UtilsTools.GetResField(_res); - List actualResData = UtilsTools.GetResDataWithoutFree(_res); - TDengine.Unsubscribe(subscribe, false); - - Assert.Equal(expectResData.Count, actualResData.Count); - output.WriteLine("Assert Meta data"); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - output.WriteLine("Assert retrieve data"); - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - // output.WriteLine("{0},{1},{2}", i, expectResData[i], actualResData[i]); - Assert.Equal(expectResData[i].ToString(), actualResData[i]); - } - - } - - /// xiaolei - /// SubscribeCases.ConsumeFromLastProgress - /// Subscribe table from the last progress. - /// Subscribe.cs - /// pass or failed - [Fact(DisplayName = "SubscribeCases.ConsumeFromLastProgress()"), TestExeOrder(2), Trait("Category", "Without callback")] - public void ConsumeFromLastProgress() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - - var tableName = "subscribe_from_progress"; - var createSql = $"create table if not exists {tableName}(ts timestamp,bl bool,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(50),nchr nchar(50))tags(t_i32 int,t_bnr binary(50),t_nchr nchar(50))"; - var dropSql = $"drop table if exists {tableName}"; - - var colData = new List{1646150410100,true,1,11,1111,11111111,"value one","值壹", - 1646150410200,true,2,22,2222,22222222,"value two","值贰", - 1646150410300,false,3,33,3333,33333333,"value three","值叁", - }; - - var colData2 = new List{1646150410400,false,4,44,4444,44444444,"value three","值肆", - 1646150410500,true,5,55,5555,55555555,"value one","值伍", - 1646150410600,true,6,66,6666,66666666,"value two","值陆", - }; - - var tagData = new List { 1, "tag_one", "标签壹" }; - var tagData2 = new List { 2, "tag_two", "标签贰" }; - - String insertSql = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData, tagData, 3); - String insertSql2 = UtilsTools.ConstructInsertSql(tableName + "_s02", tableName, colData2, tagData2, 3); - // Then - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 3); - List expectResData2 = UtilsTools.CombineColAndTagData(colData2, tagData2, 3); - - - var querySql = $"select * from {tableName}"; - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - UtilsTools.ExecuteUpdate(conn, insertSql); - - // First time subscribe - IntPtr subscribe = TDengine.Subscribe(conn, true, tableName, querySql, null, IntPtr.Zero, 20); - _res = TDengine.Consume(subscribe); - // need to call fetch TAOS_RES - UtilsTools.GetResDataWithoutFree(_res); - // Close subscribe and save progress. - TDengine.Unsubscribe(subscribe, true); - - // Insert new data. - UtilsTools.ExecuteUpdate(conn, insertSql2); - Thread.Sleep(1000); - - subscribe = TDengine.Subscribe(conn, false, tableName, querySql, null, IntPtr.Zero, 20); - _res = TDengine.Consume(subscribe); - - List actualMeta = UtilsTools.GetResField(_res); - List actualResData = UtilsTools.GetResDataWithoutFree(_res); - TDengine.Unsubscribe(subscribe, true); - output.WriteLine("Assert Meta data"); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - output.WriteLine("Assert retrieve data"); - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - // output.WriteLine("{0},{1},{2}", i, expectResData[i], actualResData[i]); - Assert.Equal(expectResData2[i].ToString(), actualResData[i]); - } - - } - } - -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/SubscribeAsync.cs b/src/connector/C#/src/test/FunctionTest/SubscribeAsync.cs deleted file mode 100644 index 6a954ef0e048331fdf9809e0030240cd80fa1d6f..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/SubscribeAsync.cs +++ /dev/null @@ -1,237 +0,0 @@ -using TDengineDriver; -using Test.UtilsTools; -using System; -using System.Collections.Generic; -using Xunit; -using Test.UtilsTools.DataSource; -using System.Threading; -using Xunit.Abstractions; -using Test.Fixture; -using Test.Case.Attributes; - -namespace Cases -{ - [TestCaseOrderer("XUnit.Case.Orderers.TestExeOrderer", "Cases.ExeOrder")] - [Collection("Database collection")] - public class SubscribeAsyncCases - { - DatabaseFixture database; - - private readonly ITestOutputHelper output; - - public SubscribeAsyncCases(DatabaseFixture fixture, ITestOutputHelper output) - { - this.database = fixture; - this.output = output; - } - - /// xiaolei - /// SubscribeAsyncCases.ConsumeFromBegin - /// Subscribe a table and consume through callback and the beginning record of the table - /// Subscribe.cs - /// pass or failed - [Fact(DisplayName = "SubscribeAsyncCases.ConsumeFromBegin()"), TestExeOrder(1), Trait("Category", "With callback")] - public void ConsumeFromBegin() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - - var tableName = "subscribe_async_from_begin"; - var createSql = $"create table if not exists {tableName}(ts timestamp,bl bool,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(50),nchr nchar(50))tags(t_i32 int,t_bnr binary(50),t_nchr nchar(50))"; - var dropSql = $"drop table if exists {tableName}"; - - var colData = new List{1646150410100,true,1,11,1111,11111111,"value one","值壹", - 1646150410200,true,2,22,2222,22222222,"value two","值贰", - 1646150410300,false,3,33,3333,33333333,"value three","值三", - }; - - var colData2 = new List{1646150410400,false,4,44,4444,44444444,"value three","值肆", - 1646150410500,true,5,55,5555,55555555,"value one","值伍", - 1646150410600,true,6,66,6666,66666666,"value two","值陆", - }; - - var tagData = new List { 1, "tag_one", "标签壹" }; - var tagData2 = new List { 2, "tag_two", "标签贰" }; - - String insertSql = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData, tagData, 3); - String insertSql2 = UtilsTools.ConstructInsertSql(tableName + "_s02", tableName, colData2, tagData2, 3); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 3); - List expectResData2 = UtilsTools.CombineColAndTagData(colData2, tagData2, 3); - expectResData.AddRange(expectResData2); - var querySql = $"select * from {tableName}"; - - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - UtilsTools.ExecuteUpdate(conn, insertSql); - - SubscribeCallback subscribeCallback1 = new SubscribeCallback(SubCallback1); - SubscribeCallback subscribeCallback2 = new SubscribeCallback(SubCallback2); - IntPtr subscribe = TDengine.Subscribe(conn, true, tableName, querySql, subscribeCallback1, IntPtr.Zero, 200); - - UtilsTools.ExecuteUpdate(conn, insertSql2); - Thread.Sleep(1000); - TDengine.Unsubscribe(subscribe, true); - - subscribe = TDengine.Subscribe(conn, true, tableName, querySql, subscribeCallback2, IntPtr.Zero, 200); - Thread.Sleep(1000); - TDengine.Unsubscribe(subscribe, false); - void SubCallback1(IntPtr subscribe, IntPtr taosRes, IntPtr param, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - // cannot free taosRes using taosRes, otherwise will cause crash. - UtilsTools.GetResDataWithoutFree(taosRes); - } - else - { - output.WriteLine($"async query data failed, failed code:{code}, reason:{TDengine.Error(taosRes)}"); - } - - } - - void SubCallback2(IntPtr subscribe, IntPtr taosRes, IntPtr param, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - List actualMeta = UtilsTools.GetResField(taosRes); - List actualResData = UtilsTools.GetResDataWithoutFree(taosRes); - // UtilsTools.DisplayRes(taosRes); - if (actualResData.Count == 0) - { - output.WriteLine($"consume in subscribe callback without data"); - } - else - { - output.WriteLine($"consume in subscribe callback with data"); - - Assert.Equal(expectResData.Count, actualResData.Count); - output.WriteLine("Assert Meta data"); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - output.WriteLine("Assert retrieve data"); - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - // output.WriteLine("index:{0},expectResData:{1},actualResData:{2}", i, expectResData[i], actualResData[i]); - Assert.Equal(expectResData[i].ToString(), actualResData[i]); - } - } - } - else - { - output.WriteLine($"async query data failed, failed code:{code}, reason:{TDengine.Error(taosRes)}"); - } - } - - } - - /// xiaolei - /// SubscribeAsyncCases.ConsumeFromLastProgress - /// Subscribe a table and consume through callback and from last consume progress. - /// Subscribe.cs - /// pass or failed - [Fact(DisplayName = "SubscribeAsyncCases.ConsumeFromLastProgress()"), TestExeOrder(2), Trait("Category", "With callback")] - public void ConsumeFromLastProgress() - { - IntPtr conn = database.conn; - IntPtr _res = IntPtr.Zero; - - var tableName = "subscribe_async_from_begin"; - var createSql = $"create table if not exists {tableName}(ts timestamp,bl bool,i8 tinyint,i16 smallint,i32 int,i64 bigint,bnr binary(50),nchr nchar(50))tags(t_i32 int,t_bnr binary(50),t_nchr nchar(50))"; - var dropSql = $"drop table if exists {tableName}"; - - var colData = new List{1646150410100,true,1,11,1111,11111111,"value one","值壹", - 1646150410200,true,2,22,2222,22222222,"value two","值贰", - 1646150410300,false,3,33,3333,33333333,"value three","值三", - }; - - var colData2 = new List{1646150410400,false,4,44,4444,44444444,"value three","值肆", - 1646150410500,true,5,55,5555,55555555,"value one","值伍", - 1646150410600,true,6,66,6666,66666666,"value two","值陆", - }; - - var tagData = new List { 1, "tag_one", "标签壹" }; - var tagData2 = new List { 2, "tag_two", "标签贰" }; - - String insertSql = UtilsTools.ConstructInsertSql(tableName + "_s01", tableName, colData, tagData, 3); - String insertSql2 = UtilsTools.ConstructInsertSql(tableName + "_s02", tableName, colData2, tagData2, 3); - List expectResMeta = DataSource.GetMetaFromDDL(createSql); - List expectResData = UtilsTools.CombineColAndTagData(colData, tagData, 3); - List expectResData2 = UtilsTools.CombineColAndTagData(colData2, tagData2, 3); - var querySql = $"select * from {tableName}"; - - UtilsTools.ExecuteUpdate(conn, dropSql); - UtilsTools.ExecuteUpdate(conn, createSql); - UtilsTools.ExecuteUpdate(conn, insertSql); - - SubscribeCallback subscribeCallback1 = new SubscribeCallback(SubCallback1); - SubscribeCallback subscribeCallback2 = new SubscribeCallback(SubCallback2); - IntPtr subscribe = TDengine.Subscribe(conn, true, tableName, querySql, subscribeCallback1, IntPtr.Zero, 200); - Thread.Sleep(1000); - TDengine.Unsubscribe(subscribe, true); - UtilsTools.ExecuteUpdate(conn, insertSql2); - subscribe = TDengine.Subscribe(conn, false, tableName, querySql, subscribeCallback2, IntPtr.Zero, 200); - Thread.Sleep(1000); - TDengine.Unsubscribe(subscribe, false); - void SubCallback1(IntPtr subscribe, IntPtr taosRes, IntPtr param, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - // cannot free taosRes using taosRes, otherwise will cause crash. - UtilsTools.GetResDataWithoutFree(taosRes); - } - else if (taosRes != IntPtr.Zero) - { - output.WriteLine($"async query data failed, failed code:{code}, reason:{TDengine.Error(taosRes)}"); - } - - } - - void SubCallback2(IntPtr subscribe, IntPtr taosRes, IntPtr param, int code) - { - if (code == 0 && taosRes != IntPtr.Zero) - { - List actualMeta = UtilsTools.GetResField(taosRes); - List actualResData = UtilsTools.GetResDataWithoutFree(taosRes); - UtilsTools.DisplayRes(taosRes); - if (actualResData.Count == 0) - { - output.WriteLine($"consume in subscribe callback without data"); - } - else - { - output.WriteLine($"consume in subscribe callback with data"); - - Assert.Equal(expectResData2.Count, actualResData.Count); - output.WriteLine("Assert Meta data"); - //Assert Meta data - for (int i = 0; i < actualMeta.Count; i++) - { - Assert.Equal(expectResMeta[i].name, actualMeta[i].name); - Assert.Equal(expectResMeta[i].type, actualMeta[i].type); - Assert.Equal(expectResMeta[i].size, actualMeta[i].size); - } - output.WriteLine("Assert retrieve data"); - // Assert retrieve data - for (int i = 0; i < actualResData.Count; i++) - { - // output.WriteLine("index:{0},expectResData:{1},actualResData:{2}", i, expectResData[i], actualResData[i]); - Assert.Equal(expectResData2[i].ToString(), actualResData[i]); - } - } - } - else - { - output.WriteLine($"async query data failed, failed code:{code}, reason:{TDengine.Error(taosRes)}"); - } - } - - } - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/lib/DBFixture.cs b/src/connector/C#/src/test/FunctionTest/lib/DBFixture.cs deleted file mode 100644 index 295726a525fb7a6c7740d5216fa19ee797109eb1..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/lib/DBFixture.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Configuration; -using System.Data.SqlClient; -using System.Runtime.InteropServices; -using TDengineDriver; - -namespace Test.Fixture -{ - public class DatabaseFixture : IDisposable - { - public IntPtr conn { get; set; } - - private string user = "root"; - private string password = "taosdata"; - private string ip = "127.0.0.1"; - private short port = 0; - - private string db = "xunit_test_fixture"; - public DatabaseFixture() - { - conn = TDengine.Connect(ip, user, password, "", port); - IntPtr res; - if (conn != IntPtr.Zero) - { - if ((res = TDengine.Query(conn, $"create database if not exists {db} keep 3650")) != IntPtr.Zero) - { - if ((res = TDengine.Query(conn, $"use {db}")) != IntPtr.Zero) - { - Console.WriteLine("Get connection success"); - } - else - { - throw new Exception(TDengine.Error(res)); - } - } - else - { - throw new Exception(TDengine.Error(res)); - } - } - else - { - throw new Exception("Get TDConnection failed"); - } - } - - // public IntPtr TDConnection { get; } - - public void Dispose() - { - IntPtr res; - if (conn != IntPtr.Zero) - { - if ((res = TDengine.Query(conn, $"drop database if exists {db}")) != IntPtr.Zero) - { - if (TDengine.Close(conn) == 0) - { - Console.WriteLine("close connection success"); - } - else - { - throw new Exception("close connection failed"); - } - - } - else - { - throw new Exception(TDengine.Error(res)); - } - } - else - { - throw new Exception("connection if already null"); - } - - } - - } -} diff --git a/src/connector/C#/src/test/FunctionTest/lib/DatabaseCollection.cs b/src/connector/C#/src/test/FunctionTest/lib/DatabaseCollection.cs deleted file mode 100644 index 11651f99b9fab5ea7c1f86bad4a14e7bea590378..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/lib/DatabaseCollection.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Xunit; -using Test.Fixture; -[CollectionDefinition("Database collection")] -public class DatabaseCollection : ICollectionFixture -{ - // This class has no code, and is never created. Its purpose is simply - // to be the place to apply [CollectionDefinition] and all the - // ICollectionFixture<> interfaces. -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/lib/ResultSetUtils.cs b/src/connector/C#/src/test/FunctionTest/lib/ResultSetUtils.cs deleted file mode 100644 index 4fd7f871316623486508532dfdc91f1d58005e3e..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/lib/ResultSetUtils.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using TDengineDriver; -using System.Collections.Generic; -namespace Test.UtilsTools.ResultSet -{ - public class ResultSet - { - private List resultMeta; - private List resultData; - // private bool isValidResult = false; - public ResultSet(IntPtr res) - { - - resultMeta = UtilsTools.GetResField(res); - resultData = UtilsTools.GetResData(res); - } - - public ResultSet(List meta, List data) - { - resultMeta = meta; - resultData = data; - } - - public List GetResultData() - { - return resultData; - } - - public List GetResultMeta() - { - return resultMeta; - } - - } - -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/lib/StmtUtil.cs b/src/connector/C#/src/test/FunctionTest/lib/StmtUtil.cs deleted file mode 100644 index 8f68157e095fd3aa3e47bb5aa19dc08d42be4628..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/lib/StmtUtil.cs +++ /dev/null @@ -1,198 +0,0 @@ -using System; -using TDengineDriver; -using System.Runtime.InteropServices; - -namespace Test.UtilsTools -{ - public class StmtUtilTools - { - public static IntPtr StmtInit(IntPtr conn) - { - IntPtr stmt = TDengine.StmtInit(conn); - if (stmt == IntPtr.Zero) - { - Console.WriteLine("Init stmt failed"); - UtilsTools.CloseConnection(conn); - UtilsTools.ExitProgram(); - } - else - { - Console.WriteLine("Init stmt success"); - } - return stmt; - } - - public static void StmtPrepare(IntPtr stmt, string sql) - { - int res = TDengine.StmtPrepare(stmt, sql); - if (res == 0) - { - Console.WriteLine("stmt prepare success"); - } - else - { - Console.WriteLine("stmt prepare failed " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - - public static void SetTableName(IntPtr stmt, String tableName) - { - int res = TDengine.StmtSetTbname(stmt, tableName); - if (res == 0) - { - Console.WriteLine("set_tbname success"); - } - else - { - Console.Write("set_tbname failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - - public static void SetTableNameTags(IntPtr stmt, String tableName, TAOS_BIND[] tags) - { - int res = TDengine.StmtSetTbnameTags(stmt, tableName, tags); - if (res == 0) - { - Console.WriteLine("set tbname && tags success"); - - } - else - { - Console.Write("set tbname && tags failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - - public static void SetSubTableName(IntPtr stmt, string name) - { - int res = TDengine.StmtSetSubTbname(stmt, name); - if (res == 0) - { - Console.WriteLine("set subtable name success"); - } - else - { - Console.Write("set subtable name failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - - } - - public static void BindParam(IntPtr stmt, TAOS_BIND[] binds) - { - int res = TDengine.StmtBindParam(stmt, binds); - if (res == 0) - { - Console.WriteLine("bind para success"); - } - else - { - Console.Write("bind para failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - - public static void BindSingleParamBatch(IntPtr stmt, TAOS_MULTI_BIND bind, int index) - { - int res = TDengine.StmtBindSingleParamBatch(stmt, ref bind, index); - if (res == 0) - { - Console.WriteLine("single bind batch success"); - } - else - { - Console.Write("single bind batch failed: " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - - public static void BindParamBatch(IntPtr stmt, TAOS_MULTI_BIND[] bind) - { - int res = TDengine.StmtBindParamBatch(stmt, bind); - if (res == 0) - { - Console.WriteLine("bind parameter batch success"); - } - else - { - Console.WriteLine("bind parameter batch failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - - public static void AddBatch(IntPtr stmt) - { - int res = TDengine.StmtAddBatch(stmt); - if (res == 0) - { - Console.WriteLine("stmt add batch success"); - } - else - { - Console.Write("stmt add batch failed,reason: " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - public static void StmtExecute(IntPtr stmt) - { - int res = TDengine.StmtExecute(stmt); - if (res == 0) - { - Console.WriteLine("Execute stmt success"); - } - else - { - Console.Write("Execute stmt failed,reason: " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - public static void StmtClose(IntPtr stmt) - { - int res = TDengine.StmtClose(stmt); - if (res == 0) - { - Console.WriteLine("close stmt success"); - } - else - { - Console.WriteLine("close stmt failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(stmt); - } - } - - public static IntPtr StmtUseResult(IntPtr stmt) - { - IntPtr res = TDengine.StmtUseResult(stmt); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - StmtClose(stmt); - } - else - { - Console.WriteLine("StmtUseResult success"); - - } - return res; - } - - public static void loadTableInfo(IntPtr conn, string[] arr) - { - if (TDengine.LoadTableInfo(conn, arr) == 0) - { - Console.WriteLine("load table info success"); - } - else - { - Console.WriteLine("load table info failed"); - } - } - - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/lib/TestExeOrder.cs b/src/connector/C#/src/test/FunctionTest/lib/TestExeOrder.cs deleted file mode 100644 index 8fec01c0bae05c1be047040c883d75b0b5091229..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/lib/TestExeOrder.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Test.Case.Attributes -{ - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - public class TestExeOrderAttribute : Attribute - { - public int ExeOrder { get; private set; } - - public TestExeOrderAttribute(int exeOrder) => ExeOrder = exeOrder; - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/lib/TestExeOrderer.cs b/src/connector/C#/src/test/FunctionTest/lib/TestExeOrderer.cs deleted file mode 100644 index 4ae0a41e86ef4b10de862000ce7e5409164e2a2f..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/lib/TestExeOrderer.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Xunit.Abstractions; -using Xunit.Sdk; -using Test.Case.Attributes; - -namespace XUnit.Case.Orderers -{ - public class TestExeOrderer : ITestCaseOrderer - { - public IEnumerable OrderTestCases( - IEnumerable testCases) where TTestCase : ITestCase - { - string assemblyName = typeof(TestExeOrderAttribute).AssemblyQualifiedName!; - var sortedMethods = new SortedDictionary>(); - foreach (TTestCase testCase in testCases) - { - int exeOrder = testCase.TestMethod.Method - .GetCustomAttributes(assemblyName) - .FirstOrDefault() - ?.GetNamedArgument(nameof(TestExeOrderAttribute.ExeOrder)) ?? 0; - - GetOrCreate(sortedMethods, exeOrder).Add(testCase); - } - - foreach (TTestCase testCase in - sortedMethods.Keys.SelectMany( - exeOrder => sortedMethods[exeOrder].OrderBy( - testCase => testCase.TestMethod.Method.Name))) - { - yield return testCase; - } - } - - private static TValue GetOrCreate( - IDictionary dictionary, TKey key) - where TKey : struct - where TValue : new() => - dictionary.TryGetValue(key, out TValue result) - ? result - : (dictionary[key] = new TValue()); - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/FunctionTest/lib/Utils.cs b/src/connector/C#/src/test/FunctionTest/lib/Utils.cs deleted file mode 100644 index 9604a0b043fc7b99ee4e58208ba1ff5212453fc5..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/FunctionTest/lib/Utils.cs +++ /dev/null @@ -1,511 +0,0 @@ -using System; -using TDengineDriver; -using System.Runtime.InteropServices; -using System.Text; -using System.Collections.Generic; -using Xunit.Abstractions; -namespace Test.UtilsTools -{ - public class UtilsTools - { - - static string ip = "127.0.0.1"; - static string user = "root"; - static string password = "taosdata"; - static string db = ""; - static short port = 0; - //get a TDengine connection - public static IntPtr TDConnection() - { - TDengine.Options((int)TDengineInitOption.TSDB_OPTION_CONFIGDIR, GetConfigPath()); - TDengine.Options((int)TDengineInitOption.TSDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - TDengine.Init(); - IntPtr conn = TDengine.Connect(ip, user, password, db, port); - // UtilsTools.ExecuteUpdate(conn, "drop database if exists csharp"); - UtilsTools.ExecuteUpdate(conn, "create database if not exists csharp keep 3650"); - UtilsTools.ExecuteUpdate(conn, "use csharp"); - return conn; - } - //get taos.cfg file based on different os - public static string GetConfigPath() - { - string configDir = ""; - if (OperatingSystem.IsOSPlatform("Windows")) - { - configDir = "C:/TDengine/cfg"; - } - else if (OperatingSystem.IsOSPlatform("Linux")) - { - configDir = "/etc/taos"; - } - else if (OperatingSystem.IsOSPlatform("macOS")) - { - configDir = "/usr/local/etc/taos"; - } - return configDir; - } - - public static IntPtr ExecuteQuery(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) - { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - return res; - } - - public static IntPtr ExecuteErrorQuery(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) - { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - - } - return res; - } - - public static void ExecuteUpdate(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) - { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - - } - TDengine.FreeResult(res); - } - - public static void DisplayRes(IntPtr res) - { - if (!IsValidResult(res)) - { - ExitProgram(); - } - - List metaList = GetResField(res); - int fieldCount = metaList.Count; - - IntPtr rowdata; - List dataList = QueryRes(res, metaList); - for (int i = 0; i < dataList.Count; i += metaList.Count) - { - for (int j = 0; j < metaList.Count; j++) - { - Console.Write(" {0} \t|", dataList[i + j]); - - } - Console.WriteLine(""); - } - - } - - public static List> GetResultSet(IntPtr res) - { - List> result = new List>(); - List colName = new List(); - List dataRaw = new List(); - if (!IsValidResult(res)) - { - ExitProgram(); - } - - List metaList = GetResField(res); - result.Add(colName); - - dataRaw = QueryRes(res, metaList); - result.Add(dataRaw); - - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - } - return result; - } - - public static bool IsValidResult(IntPtr res) - { - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - return false; - } - Console.WriteLine(""); - return false; - } - return true; - } - public static void CloseConnection(IntPtr conn) - { - ExecuteUpdate(conn, "drop database if exists csharp"); - if (conn != IntPtr.Zero) - { - if (TDengine.Close(conn) == 0) - { - Console.WriteLine("close connection success"); - } - else - { - Console.WriteLine("close Connection failed"); - } - } - } - public static List GetResField(IntPtr res) - { - List metaList = TDengine.FetchFields(res); - return metaList; - } - public static void AssertEqual(string expectVal, string actualVal) - { - if (expectVal == actualVal) - { - Console.WriteLine("{0}=={1} pass", expectVal, actualVal); - } - else - { - Console.WriteLine("{0}=={1} failed", expectVal, actualVal); - ExitProgram(); - } - } - public static void ExitProgram() - { - TDengine.Cleanup(); - System.Environment.Exit(0); - } - public static List GetResData(IntPtr res) - { - List dataRaw = GetResDataWithoutFree(res); - FreeResult(res); - return dataRaw; - } - - public static TDengineMeta ConstructTDengineMeta(string name, string type) - { - - TDengineMeta _meta = new TDengineMeta(); - _meta.name = name; - char[] separators = new char[] { '(', ')' }; - string[] subs = type.Split(separators, StringSplitOptions.RemoveEmptyEntries); - - switch (subs[0].ToUpper()) - { - case "BOOL": - _meta.type = 1; - _meta.size = 1; - break; - case "TINYINT": - _meta.type = 2; - _meta.size = 1; - break; - case "SMALLINT": - _meta.type = 3; - _meta.size = 2; - break; - case "INT": - _meta.type = 4; - _meta.size = 4; - break; - case "BIGINT": - _meta.type = 5; - _meta.size = 8; - break; - case "TINYINT UNSIGNED": - _meta.type = 11; - _meta.size = 1; - break; - case "SMALLINT UNSIGNED": - _meta.type = 12; - _meta.size = 2; - break; - case "INT UNSIGNED": - _meta.type = 13; - _meta.size = 4; - break; - case "BIGINT UNSIGNED": - _meta.type = 14; - _meta.size = 8; - break; - case "FLOAT": - _meta.type = 6; - _meta.size = 4; - break; - case "DOUBLE": - _meta.type = 7; - _meta.size = 8; - break; - case "BINARY": - _meta.type = 8; - _meta.size = short.Parse(subs[1]); - break; - case "TIMESTAMP": - _meta.type = 9; - _meta.size = 8; - break; - case "NCHAR": - _meta.type = 10; - _meta.size = short.Parse(subs[1]); - break; - case "JSON": - _meta.type = 15; - _meta.size = 4096; - break; - default: - _meta.type = byte.MaxValue; - _meta.size = 0; - break; - } - return _meta; - } - - private static List QueryRes(IntPtr res, List meta) - { - IntPtr taosRow; - List dataRaw = new List(); - int fieldCount = meta.Count; - while ((taosRow = TDengine.FetchRows(res)) != IntPtr.Zero) - { - dataRaw.AddRange(FetchRow(taosRow, res)); - } - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - } - Console.WriteLine(""); - return dataRaw; - } - - // Generate insert sql for the with the coldata and tag data - public static string ConstructInsertSql(string table, string stable, List colData, List tagData, int numOfRows) - { - int numOfFields = colData.Count / numOfRows; - StringBuilder insertSql; - - if (stable == "") - { - insertSql = new StringBuilder($"insert into {table} values("); - } - else - { - insertSql = new StringBuilder($"insert into {table} using {stable} tags("); - - for (int j = 0; j < tagData.Count; j++) - { - if (tagData[j] is String) - { - insertSql.Append('\''); - insertSql.Append(tagData[j]); - insertSql.Append('\''); - } - else - { - insertSql.Append(tagData[j]); - } - if (j + 1 != tagData.Count) - { - insertSql.Append(','); - } - } - - insertSql.Append(")values("); - } - for (int i = 0; i < colData.Count; i++) - { - - if (colData[i] is String) - { - insertSql.Append('\''); - insertSql.Append(colData[i]); - insertSql.Append('\''); - } - else - { - insertSql.Append(colData[i]); - } - - if ((i + 1) % numOfFields == 0 && (i + 1) != colData.Count) - { - insertSql.Append(")("); - } - else if ((i + 1) == colData.Count) - { - insertSql.Append(')'); - } - else - { - insertSql.Append(','); - } - } - insertSql.Append(';'); - //Console.WriteLine(insertSql.ToString()); - - return insertSql.ToString(); - } - - public static List CombineColAndTagData(List colData, List tagData, int numOfRows) - { - var list = new List(); - for (int i = 0; i < colData.Count; i++) - { - list.Add(colData[i]); - if ((i + 1) % (colData.Count / numOfRows) == 0) - { - for (int j = 0; j < tagData.Count; j++) - { - list.Add(tagData[j]); - } - } - } - return list; - } - - /// - /// Using this method to free TAOS_RES,otherwise will lead memory - /// leak.Notice do not call this method while subscribe/consume until - /// end of the program. - /// - /// TAOS_RES, the resultset usually is return by taos_query() - public static void FreeResult(IntPtr res) - { - TDengine.FreeResult(res); - } - - - /// - /// Using to parse TAOS_ROW. - /// - /// This is TAOS_RES pointer - /// This is TAOS_ROW pointer - /// - public static List FetchRow(IntPtr taosRow, IntPtr taosRes) - { - List metaList = TDengine.FetchFields(taosRes); - int numOfFiled = TDengine.FieldCount(taosRes); - - List dataRaw = new List(); - - IntPtr colLengthPrt = TDengine.FetchLengths(taosRes); - int[] colLengthArr = new int[numOfFiled]; - Marshal.Copy(colLengthPrt, colLengthArr, 0, numOfFiled); - - for (int i = 0; i < numOfFiled; i++) - { - TDengineMeta meta = metaList[i]; - IntPtr data = Marshal.ReadIntPtr(taosRow, IntPtr.Size * i); - - if (data == IntPtr.Zero) - { - dataRaw.Add("NULL"); - continue; - } - switch ((TDengineDataType)meta.type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; - dataRaw.Add(v1.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - sbyte v2 = (sbyte)Marshal.ReadByte(data); - dataRaw.Add(v2.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - short v3 = Marshal.ReadInt16(data); - dataRaw.Add(v3.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_INT: - int v4 = Marshal.ReadInt32(data); - dataRaw.Add(v4.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - long v5 = Marshal.ReadInt64(data); - dataRaw.Add(v5.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); - dataRaw.Add(v6.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); - dataRaw.Add(v7.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - string v8 = Marshal.PtrToStringUTF8(data, colLengthArr[i]); - dataRaw.Add(v8); - break; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - long v9 = Marshal.ReadInt64(data); - dataRaw.Add(v9.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - string v10 = Marshal.PtrToStringUTF8(data, colLengthArr[i]); - dataRaw.Add(v10); - break; - case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: - byte v12 = Marshal.ReadByte(data); - dataRaw.Add(v12.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: - ushort v13 = (ushort)Marshal.ReadInt16(data); - dataRaw.Add(v13.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_UINT: - uint v14 = (uint)Marshal.ReadInt32(data); - dataRaw.Add(v14.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: - ulong v15 = (ulong)Marshal.ReadInt64(data); - dataRaw.Add(v15.ToString()); - break; - case TDengineDataType.TSDB_DATA_TYPE_JSONTAG: - string v16 = Marshal.PtrToStringUTF8(data, colLengthArr[i]); - dataRaw.Add(v16); - break; - default: - dataRaw.Add("nonsupport data type value"); - break; - } - - } - return dataRaw; - } - - /// - /// Get the result data from TAO_RES but this interface will - /// not free the TAO_RES at the end. Remember to free the TAOS_RES - /// when you need to do so. - /// - /// This is a TAOS_RES pointer. - /// - public static List GetResDataWithoutFree(IntPtr res) - { - List colName = new List(); - List dataRaw = new List(); - if (!IsValidResult(res)) - { - ExitProgram(); - } - List meta = GetResField(res); - dataRaw = QueryRes(res, meta); - return dataRaw; - } - } - -} - diff --git a/src/connector/C#/src/test/XUnitTest/TestTDengineMeta.cs b/src/connector/C#/src/test/XUnitTest/TestTDengineMeta.cs deleted file mode 100644 index 2890501e93c10b49462027d1fd907c6480dd82f8..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/XUnitTest/TestTDengineMeta.cs +++ /dev/null @@ -1,250 +0,0 @@ -using System; -using Xunit; -using TDengineDriver; - -namespace TDengineDriver.Test -{ - public class TestTDengineMeta - { - /// xiaolei - /// TestTDengineMeta.TestTypeNameBool - /// Unit test for object TDengineDriver.TDengineMeta's bool meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameBool() - { - string typeName = "BOOL"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 1; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameTINYINT - /// Unit test for object TDengineDriver.TDengineMeta's TinnyInt's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameTINYINT() - { - string typeName = "TINYINT"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 2; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameSMALLINT - /// Unit test for object TDengineDriver.TDengineMeta's SMALLINT's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameSMALLINT() - { - string typeName = "SMALLINT"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 3; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameINT - /// Unit test for object TDengineDriver.TDengineMeta's INT's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameINT() - { - string typeName = "INT"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 4; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameBIGINT - /// Unit test for object TDengineDriver.TDengineMeta's BIGINT's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameBIGINT() - { - string typeName = "BIGINT"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 5; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameUTINYINT - /// Unit test for object TDengineDriver.TDengineMeta's TINYINT UNSIGNED's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameUTINYINT() - { - string typeName = "TINYINT UNSIGNED"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 11; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameUSMALLINT - /// Unit test for object TDengineDriver.TDengineMeta's SMALLINT UNSIGNED's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameUSMALLINT() - { - string typeName = "SMALLINT UNSIGNED"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 12; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameUINT - /// Unit test for object TDengineDriver.TDengineMeta's INT UNSIGNED's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameUINT() - { - string typeName = "INT UNSIGNED"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 13; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameUBIGINT - /// Unit test for object TDengineDriver.TDengineMeta's BIGINT UNSIGNED's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameUBIGINT() - { - string typeName = "BIGINT UNSIGNED"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 14; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameFLOAT - /// Unit test for object TDengineDriver.TDengineMeta's FLOAT's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameFLOAT() - { - string typeName = "FLOAT"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 6; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameDOUBLE - /// Unit test for object TDengineDriver.TDengineMeta's DOUBLE's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameDOUBLE() - { - string typeName = "DOUBLE"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 7; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameSTRING - /// Unit test for object TDengineDriver.TDengineMeta's BINARY's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameSTRING() - { - string typeName = "BINARY"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 8; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameTIMESTAMP - /// Unit test for object TDengineDriver.TDengineMeta's TIMESTAMP's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameTIMESTAMP() - { - string typeName = "TIMESTAMP"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 9; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameNCHAR - /// Unit test for object TDengineDriver.TDengineMeta's NCHAR's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameNCHAR() - { - string typeName = "NCHAR"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - meta.type = 10; - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - /// xiaolei - /// TestTDengineMeta.TestTypeNameUndefined - /// Unit test for object TDengineDriver.TDengineMeta's undefine's meta info - /// TestTDengineMeta.cs - /// pass or failed - [Fact] - public void TestTypeNameUndefined() - { - string typeName = "undefine"; - TDengineDriver.TDengineMeta meta = new TDengineDriver.TDengineMeta(); - - string metaTypeName = meta.TypeName(); - - Assert.Equal(metaTypeName, typeName); - - } - } -} diff --git a/src/connector/C#/src/test/XUnitTest/TestTaosBind.cs b/src/connector/C#/src/test/XUnitTest/TestTaosBind.cs deleted file mode 100644 index 07678e6f84435438843c349bb287da7204eb535c..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/XUnitTest/TestTaosBind.cs +++ /dev/null @@ -1,1014 +0,0 @@ -using System; -using Xunit; -using TDengineDriver; -using System.Runtime.InteropServices; - -namespace TDengineDriver.Test -{ - public class TestTaosBind - { - /// xiaolei - /// TestTaosBind.TestBindBoolTrue - /// Unit test for binding boolean true value using TAOS_BIND struct through stmt - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindBoolTrue() - { - int bufferType = 1; - bool buffer = true; - int bufferLength = sizeof(bool); - int length = sizeof(bool); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindBool(true); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - bool bindBuffer = Convert.ToBoolean(Marshal.ReadByte(bind.buffer)); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - - } - - /// xiaolei - /// TestTaosBind.TestBindBoolFalse - /// Unit test for binding boolean false value using TAOS_BIND struct through stmt - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindBoolFalse() - { - int bufferType = 1; - bool buffer = false; - int bufferLength = sizeof(bool); - int length = sizeof(bool); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindBool(false); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - bool bindBuffer = Convert.ToBoolean(Marshal.ReadByte(bind.buffer)); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - - } - - /// xiaolei - /// TestTaosBind.TestBindTinyIntZero - /// Unit test for binding tinny int zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindTinyIntZero() - { - int bufferType = 2; - sbyte buffer = 0; - int bufferLength = sizeof(sbyte); - int length = sizeof(sbyte); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindTinyInt(0); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - sbyte bindBuffer = Convert.ToSByte(Marshal.ReadByte(bind.buffer)); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - /// xiaolei - /// TestTaosBind.TestBindTinyIntPositive - /// Unit test for binding tinny int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindTinyIntPositive() - { - int bufferType = 2; - sbyte buffer = sbyte.MaxValue; - int bufferLength = sizeof(sbyte); - int length = sizeof(sbyte); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindTinyInt(sbyte.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - sbyte bindBuffer = Convert.ToSByte(Marshal.ReadByte(bind.buffer)); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindTinyIntNegative - /// Unit test for binding tinny int negative value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindTinyIntNegative() - { - int bufferType = 2; - short buffer = sbyte.MinValue; - int bufferLength = sizeof(sbyte); - int length = sizeof(sbyte); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindTinyInt(sbyte.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - short bindBuffer = Marshal.ReadInt16(bind.buffer); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindSmallIntNegative - /// Unit test for binding small int negative value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindSmallIntNegative() - { - int bufferType = 3; - short buffer = short.MinValue; - int bufferLength = sizeof(short); - int length = sizeof(short); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindSmallInt(short.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - short bindBuffer = Marshal.ReadInt16(bind.buffer); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindSmallIntZero - /// Unit test for binding small int zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindSmallIntZero() - { - int bufferType = 3; - short buffer = 0; - int bufferLength = sizeof(short); - int length = sizeof(short); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindSmallInt(0); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - short bindBuffer = Marshal.ReadInt16(bind.buffer); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindSmallIntPositive - /// Unit test for binding small int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindSmallIntPositive() - { - int bufferType = 3; - short buffer = short.MaxValue; - int bufferLength = sizeof(short); - int length = sizeof(short); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindSmallInt(short.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - short bindBuffer = Marshal.ReadInt16(bind.buffer); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindIntNegative - /// Unit test for binding small int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindIntNegative() - { - int bufferType = 4; - int buffer = int.MinValue; - int bufferLength = sizeof(int); - int length = sizeof(int); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindInt(int.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - int bindBuffer = Marshal.ReadInt32(bind.buffer); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindIntZero - /// Unit test for binding int zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindIntZero() - { - int bufferType = 4; - int buffer = 0; - int bufferLength = sizeof(int); - int length = sizeof(int); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindInt(0); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - int bindBuffer = Marshal.ReadInt32(bind.buffer); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindIntPositive - /// Unit test for binding int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindIntPositive() - { - int bufferType = 4; - int buffer = int.MaxValue; - int bufferLength = sizeof(int); - int length = sizeof(int); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindInt(int.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - int bindBuffer = Marshal.ReadInt32(bind.buffer); - - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindBigIntNegative - /// Unit test for binding int negative value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindBigIntNegative() - { - int bufferType = 5; - long buffer = long.MinValue; - int bufferLength = sizeof(long); - int length = sizeof(long); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindBigInt(long.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - long bindBuffer = Marshal.ReadInt64(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindBigIntZero - /// Unit test for binding big int zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindBigIntZero() - { - int bufferType = 5; - long buffer = 0; - int bufferLength = sizeof(long); - int length = sizeof(long); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindBigInt(0); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - long bindBuffer = Marshal.ReadInt64(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindBigIntPositive - /// Unit test for binding big int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindBigIntPositive() - { - int bufferType = 5; - long buffer = long.MaxValue; - int bufferLength = sizeof(long); - int length = sizeof(long); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindBigInt(long.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - long bindBuffer = Marshal.ReadInt64(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindBigIntPositive - /// Unit test for binding big int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindUTinyZero() - { - int bufferType = 11; - byte buffer = 0; - int bufferLength = sizeof(sbyte); - int length = sizeof(sbyte); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindUTinyInt(0); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - byte bindBuffer = Marshal.ReadByte(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindUTinyPositive - /// Unit test for binding unsigned tinny int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindUTinyPositive() - { - int bufferType = 11; - byte buffer = byte.MaxValue; - int bufferLength = sizeof(sbyte); - int length = sizeof(sbyte); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindUTinyInt(byte.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - byte bindBuffer = Marshal.ReadByte(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindUSmallIntZero - /// Unit test for binding unsigned small int zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindUSmallIntZero() - { - int bufferType = 12; - ushort buffer = ushort.MinValue; - int bufferLength = sizeof(ushort); - int length = sizeof(ushort); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindUSmallInt(ushort.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - ushort bindBuffer = (ushort)Marshal.ReadInt16(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindUSmallIntPositive - /// Unit test for binding unsigned small int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindUSmallIntPositive() - { - int bufferType = 12; - ushort buffer = ushort.MaxValue; - int bufferLength = sizeof(ushort); - int length = sizeof(ushort); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindUSmallInt(ushort.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - ushort bindBuffer = (ushort)Marshal.ReadInt16(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindUIntZero - /// Unit test for binding unsigned int zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindUIntZero() - { - int bufferType = 13; - uint buffer = uint.MinValue; - int bufferLength = sizeof(uint); - int length = sizeof(uint); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindUInt(uint.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - uint bindBuffer = (uint)Marshal.ReadInt32(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindUIntPositive - /// Unit test for binding unsigned int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindUIntPositive() - { - int bufferType = 13; - uint buffer = uint.MaxValue; - int bufferLength = sizeof(uint); - int length = sizeof(uint); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindUInt(uint.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - uint bindBuffer = (uint)Marshal.ReadInt32(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindUBigIntZero - /// Unit test for binding unsigned big int zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindUBigIntZero() - { - int bufferType = 14; - ulong buffer = ulong.MinValue; - int bufferLength = sizeof(ulong); - int length = sizeof(ulong); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindUBigInt(ulong.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - ulong bindBuffer = (ulong)Marshal.ReadInt64(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindUBigIntPositive - /// Unit test for binding unsigned big int positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindUBigIntPositive() - { - int bufferType = 14; - ulong buffer = ulong.MaxValue; - int bufferLength = sizeof(ulong); - int length = sizeof(ulong); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindUBigInt(ulong.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - ulong bindBuffer = (ulong)Marshal.ReadInt64(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindFloatNegative - /// Unit test for binding float negative value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindFloatNegative() - { - int bufferType = 6; - float buffer = float.MinValue; - int bufferLength = sizeof(float); - int length = sizeof(float); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindFloat(float.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - float[] bindBufferArr = new float[1]; - Marshal.Copy(bind.buffer, bindBufferArr, 0, bindBufferArr.Length); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBufferArr[0], buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindFloatNegative - /// Unit test for binding float zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindFloatZero() - { - int bufferType = 6; - float buffer = 0; - int bufferLength = sizeof(float); - int length = sizeof(float); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindFloat(0F); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - float[] bindBufferArr = new float[1]; - Marshal.Copy(bind.buffer, bindBufferArr, 0, bindBufferArr.Length); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBufferArr[0], buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindFloatPositive - /// Unit test for binding float positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindFloatPositive() - { - int bufferType = 6; - float buffer = float.MaxValue; - int bufferLength = sizeof(float); - int length = sizeof(float); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindFloat(float.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - float[] bindBufferArr = new float[1]; - Marshal.Copy(bind.buffer, bindBufferArr, 0, bindBufferArr.Length); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBufferArr[0], buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindDoubleZero - /// Unit test for binding double zero value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindDoubleZero() - { - int bufferType = 7; - double buffer = 0; - int bufferLength = sizeof(double); - int length = sizeof(double); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindDouble(0D); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - double[] bindBufferArr = new double[1]; - Marshal.Copy(bind.buffer, bindBufferArr, 0, bindBufferArr.Length); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBufferArr[0], buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindDoublePositive - /// Unit test for binding double positive value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindDoublePositive() - { - int bufferType = 7; - double buffer = double.MaxValue; - int bufferLength = sizeof(double); - int length = sizeof(double); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindDouble(double.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - double[] bindBufferArr = new double[1]; - Marshal.Copy(bind.buffer, bindBufferArr, 0, bindBufferArr.Length); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBufferArr[0], buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindDoubleNegative - /// Unit test for binding double negative value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindDoubleNegative() - { - int bufferType = 7; - double buffer = double.MinValue; - int bufferLength = sizeof(double); - int length = sizeof(double); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindDouble(double.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - double[] bindBufferArr = new double[1]; - Marshal.Copy(bind.buffer, bindBufferArr, 0, bindBufferArr.Length); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBufferArr[0], buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindBinaryEn - /// Unit test for binding binary character without CN character using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindBinaryEn() - { - int bufferType = 8; - String buffer = "qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="; - int bufferLength = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - int length = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - - TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - string bindBuffer = Marshal.PtrToStringUTF8(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindBinaryCn - /// Unit test for binding binary character with CN character using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindBinaryCn() - { - int bufferType = 8; - String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"; - int bufferLength = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - int length = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - - TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - string bindBuffer = Marshal.PtrToStringUTF8(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindBinaryCnAndEn - /// Unit test for binding binary characters with CN and other characters using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindBinaryCnAndEn() - { - int bufferType = 8; - String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; - int bufferLength = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - int length = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - - TDengineDriver.TAOS_BIND bind = TaosBind.BindBinary("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - string bindBuffer = Marshal.PtrToStringUTF8(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindNcharEn - /// Unit test for binding nchar characters without cn using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindNcharEn() - { - int bufferType = 10; - String buffer = "qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="; - int bufferLength = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - int length = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - - TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("qwertyuiopasdghjklzxcvbnm<>?:\"{}+_)(*&^%$#@!~QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./`1234567890-="); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - string bindBuffer = Marshal.PtrToStringUTF8(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindNcharCn - /// Unit test for binding nchar characters with cn using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindNcharCn() - { - int bufferType = 10; - String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"; - int bufferLength = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - int length = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - - TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./"); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - string bindBuffer = Marshal.PtrToStringUTF8(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindNcharCnAndEn - /// Unit test for binding nchar with cn characters and other characters using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindNcharCnAndEn() - { - int bufferType = 10; - String buffer = "一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"; - int bufferLength = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - int length = System.Text.Encoding.UTF8.GetBytes(buffer).Length; - - TDengineDriver.TAOS_BIND bind = TaosBind.BindNchar("一二两三四五六七八九十廿毛另壹贰叁肆伍陆柒捌玖拾佰仟万亿元角分零整1234567890`~!@#$%^&*()_+[]{};':<>?,./qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM"); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - string bindBuffer = Marshal.PtrToStringUTF8(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindNil - /// Unit test for binding null value using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindNil() - { - int bufferType = 0; - int isNull = 1; - - TDengineDriver.TAOS_BIND bind = TaosBind.BindNil(); - - int bindIsNull = Marshal.ReadInt32(bind.is_null); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindIsNull, isNull); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindTimestampNegative - /// Unit test for binding negative timestamp using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindTimestampNegative() - { - int bufferType = 9; - long buffer = long.MinValue; - int bufferLength = sizeof(long); - int length = sizeof(long); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindTimestamp(long.MinValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - long bindBuffer = Marshal.ReadInt64(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - /// xiaolei - /// TestTaosBind.TestBindTimestampZero - /// Unit test for binding zero timestamp using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindTimestampZero() - { - int bufferType = 9; - long buffer = 0; - int bufferLength = sizeof(long); - int length = sizeof(long); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindTimestamp(0); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - long bindBuffer = Marshal.ReadInt64(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - - /// xiaolei - /// TestTaosBind.TestBindTimestampPositive - /// Unit test for binding positive timestamp using TAOS_BIND struct through stmt. - /// TestTaosBind.cs - /// pass or failed - [Fact] - public void TestBindTimestampPositive() - { - int bufferType = 9; - long buffer = long.MaxValue; - int bufferLength = sizeof(long); - int length = sizeof(long); - - TDengineDriver.TAOS_BIND bind = TaosBind.BindTimestamp(long.MaxValue); - int bindLengthPtr = Marshal.ReadInt32(bind.length); - long bindBuffer = Marshal.ReadInt64(bind.buffer); - - Assert.Equal(bind.buffer_type, bufferType); - Assert.Equal(bindBuffer, buffer); - Assert.Equal(bind.buffer_length, bufferLength); - Assert.Equal(bindLengthPtr, length); - - Marshal.FreeHGlobal(bind.buffer); - Marshal.FreeHGlobal(bind.length); - } - - } -} \ No newline at end of file diff --git a/src/connector/C#/src/test/XUnitTest/XUnitTest.csproj b/src/connector/C#/src/test/XUnitTest/XUnitTest.csproj deleted file mode 100644 index 6da7156111003eb671c3a0fa392f1d6adc7ac0d1..0000000000000000000000000000000000000000 --- a/src/connector/C#/src/test/XUnitTest/XUnitTest.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - net5.0 - false - CS1591 - true - ..\doc\UnitTest.XML - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - diff --git a/src/connector/TypeScript-REST/.gitignore b/src/connector/TypeScript-REST/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3f8f105c3b5634cb11e115ad351bacf9715005d5 --- /dev/null +++ b/src/connector/TypeScript-REST/.gitignore @@ -0,0 +1,7 @@ +package-lock.json +dist/main +dist/module +dist/types.d.ts +node_modules/ +tsc/ +.parcel-cache/ \ No newline at end of file diff --git a/src/connector/TypeScript-REST/readme.md b/src/connector/TypeScript-REST/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..776d2d521248a2805c4df04d26e71a3db70e6678 --- /dev/null +++ b/src/connector/TypeScript-REST/readme.md @@ -0,0 +1,39 @@ +# TDengine RESTful +This is a TDengine's RESTful connector in TypeScript. It's depend on [node-fetch v2](https://github.com/node-fetch/node-fetch/tree/2.x). Using `fetch(url,options)` to send sql statement and receive response. + +# Usage + +```TypeScript +import { options, connect } from 'td2.0-rest-connector' +options.path='/rest/sqlt'; +// set host +options.host='localhost'; +// set other options like user/passwd + +let conn = connect(options); +let cursor = conn.cursor(); +(async()=>{ + let result = await cursor.query('show databases'); + // print query result as taos shell + result.toString(); + // Get Result object, return Result object. + console.log(result.getResult()); + // Get status, return 'succ'|'error'. + console.log(result.getStatus()); + // Get head,return response head (Array|undefined,when execute failed this is undefined). + console.log(result.getHead()); + // Get Meta data, return Meta[]|undefined(when execute failed this is undefined). + console.log(result.getMeta()); + // Get data,return Array>|undefined(when execute failed this is undefined). + console.log(result.getData()); + // Get affect rows,return number|undefined(when execute failed this is undefined). + console.log(result.getAffectRows()); + // Get command,return SQL send to server(need to `query(sql,false)`,set 'pure=false',default true). + console.log(result.getCommand()); + // Get error code ,return number|undefined(when execute failed this is undefined). + console.log(result.getErrCode()); + // Get error string,return string|undefined(when execute failed this is undefined). + console.log(result.getErrStr()); +})() + +``` diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index d0e4e2351962b00c3843f437e93fe91c843df40b..0647f17fc1ae41b05bc898f544c83fbc92f365b7 100644 --- a/src/connector/jdbc/CMakeLists.txt +++ b/src/connector/jdbc/CMakeLists.txt @@ -13,7 +13,7 @@ IF (TD_MVN_INSTALLED) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/deploy-pom.xml DEPENDS ${_depends} COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.37-dist.jar ${LIBRARY_OUTPUT_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.38-dist.jar ${LIBRARY_OUTPUT_PATH} COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMAND ${CMAKE_COMMAND} -E touch "${_output}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml index e482dd97de336cb1108d40b4e14ccd946fc1425e..54eb18e8d513f3f7e98283741a18ddd38810837b 100755 --- a/src/connector/jdbc/deploy-pom.xml +++ b/src/connector/jdbc/deploy-pom.xml @@ -5,7 +5,7 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.37 + 2.0.38 jar JDBCDriver @@ -44,21 +44,25 @@ test - org.apache.httpcomponents httpclient - 4.5.8 + 4.5.13 com.alibaba fastjson - 1.2.58 + 1.2.79 com.google.guava guava - 29.0-jre + 30.1.1-jre + + + org.java-websocket + Java-WebSocket + 1.5.2 diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index e5b4a37a8a8e1b86b2f24ffd16d6a19707f3a3c3..f196a6b4216f7b48c65b7475ebb488009b322eba 100644 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.taosdata.jdbc taos-jdbcdriver - 2.0.37 + 2.0.38 jar JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java index ac1e91b51d2b3ae857100036e430f92366b181d7..7e02d80ae8224dadbb8984ca486632d53d903ef3 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBPreparedStatement.java @@ -81,14 +81,6 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat */ private void preprocessSql() { /***For processing some of Spark SQLs*/ - // should replace it first - this.rawSql = this.rawSql.replaceAll("or (.*) is null", ""); - this.rawSql = this.rawSql.replaceAll(" where ", " WHERE "); - this.rawSql = this.rawSql.replaceAll(" or ", " OR "); - this.rawSql = this.rawSql.replaceAll(" and ", " AND "); - this.rawSql = this.rawSql.replaceAll(" is null", " IS NULL"); - this.rawSql = this.rawSql.replaceAll(" is not null", " IS NOT NULL"); - // SELECT * FROM db.tb WHERE 1=0 this.rawSql = this.rawSql.replaceAll("WHERE 1=0", "WHERE _c0=1"); this.rawSql = this.rawSql.replaceAll("WHERE 1=2", "WHERE _c0=1"); @@ -96,24 +88,6 @@ public class TSDBPreparedStatement extends TSDBStatement implements PreparedStat // SELECT "ts","val" FROM db.tb this.rawSql = this.rawSql.replaceAll("\"", ""); - // SELECT 1 FROM db.tb - this.rawSql = this.rawSql.replaceAll("SELECT 1 FROM", "SELECT * FROM"); - - // SELECT "ts","val" FROM db.tb WHERE ts < 33 or ts is null - this.rawSql = this.rawSql.replaceAll("OR (.*) IS NULL", ""); - - // SELECT "ts","val" FROM db.tb WHERE ts is null or ts < 33 - this.rawSql = this.rawSql.replaceAll("(.*) IS NULL OR", ""); - - // SELECT 1 FROM db.tb WHERE (("val" IS NOT NULL) AND ("val" > 50)) AND (ts >= 66) - this.rawSql = this.rawSql.replaceAll("\\(\\((.*) IS NOT NULL\\) AND", "("); - - // SELECT 1 FROM db.tb WHERE ("val" IS NOT NULL) AND ("val" > 50) AND (ts >= 66) - this.rawSql = this.rawSql.replaceAll("\\((.*) IS NOT NULL\\) AND", ""); - - // SELECT "ts","val" FROM db.tb WHERE (("val" IS NOT NULL)) AND (ts < 33 or ts is null) - this.rawSql = this.rawSql.replaceAll("\\(\\((.*) IS NOT NULL\\)\\) AND", ""); - /***** For processing inner subqueries *****/ Pattern pattern = Pattern.compile("FROM\\s+((\\(.+\\))\\s+SUB_QRY)", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(rawSql); diff --git a/src/connector/node-red-contrib-tdengine/package-lock.json b/src/connector/node-red-contrib-tdengine/package-lock.json index 3d2f9977419c62649b3eb332014f4baaa7b0810f..32a4442ac68ddd8ed2d9412f03c741022dad10fb 100644 --- a/src/connector/node-red-contrib-tdengine/package-lock.json +++ b/src/connector/node-red-contrib-tdengine/package-lock.json @@ -1656,9 +1656,9 @@ } }, "minimist": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", - "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", "dev": true }, "minipass": { @@ -1687,9 +1687,9 @@ "dev": true }, "moment": { - "version": "2.29.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", - "integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ==", + "version": "2.29.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.2.tgz", + "integrity": "sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==", "dev": true }, "moment-timezone": { diff --git a/src/connector/node-rest/.gitignore b/src/connector/node-rest/.gitignore deleted file mode 100644 index 6768d98a52ecd40637abf9c402fe9ed6f5bd5936..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/.gitignore +++ /dev/null @@ -1,128 +0,0 @@ - -# Created by https://www.toptal.com/developers/gitignore/api/node -# Edit at https://www.toptal.com/developers/gitignore?templates=node - -### Node ### -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* -lerna-debug.log* -.pnpm-debug.log* - -# Diagnostic reports (https://nodejs.org/api/report.html) -report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage -*.lcov - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Snowpack dependency directory (https://snowpack.dev/) -web_modules/ - -# TypeScript cache -*.tsbuildinfo - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Microbundle cache -.rpt2_cache/ -.rts2_cache_cjs/ -.rts2_cache_es/ -.rts2_cache_umd/ - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env -.env.test -.env.production - -# parcel-bundler cache (https://parceljs.org/) -.cache -.parcel-cache - -# Next.js build output -.next -out - -# Nuxt.js build / generate output -.nuxt -dist - -# Gatsby files -.cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js -# https://nextjs.org/blog/next-9-1#public-directory-support -# public - -# vuepress build output -.vuepress/dist - -# Serverless directories -.serverless/ - -# FuseBox cache -.fusebox/ - -# DynamoDB Local files -.dynamodb/ - -# TernJS port file -.tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - -# yarn v2 -.yarn/cache -.yarn/unplugged -.yarn/build-state.yml -.yarn/install-state.gz -.pnp.* - -# End of https://www.toptal.com/developers/gitignore/api/node - -lib/ -yarn.lock diff --git a/src/connector/node-rest/.nvmrc b/src/connector/node-rest/.nvmrc deleted file mode 100644 index 8351c19397f4fcd5238d10034fa7fa384f14d580..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -14 diff --git a/src/connector/node-rest/TDengineRest.js b/src/connector/node-rest/TDengineRest.js deleted file mode 100644 index 68ac76019d0c14d31128e9f596b5f18fce59f568..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/TDengineRest.js +++ /dev/null @@ -1,5 +0,0 @@ -import {TDengineRestConnection} from './src/restConnect' - -export function TDRestConnection(connection = {}) { - return new TDengineRestConnection(connection) -} diff --git a/src/connector/node-rest/examples/show-database.js b/src/connector/node-rest/examples/show-database.js deleted file mode 100644 index bf51b8a675e1e0b86f0761b6f47d72f73c80c0ff..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/examples/show-database.js +++ /dev/null @@ -1,13 +0,0 @@ -import {TDengineRestConnection} from "../src/restConnect"; - -let conn = new TDengineRestConnection({host: '127.0.0.1', user: 'root', pass: 'taosdata', port: 6041}) -let cursor = conn.cursor(); -console.log(conn) -let data = {}; -(async () => { - data = await cursor.query("show databases"); - data.toString() -})() - - - diff --git a/src/connector/node-rest/package-lock.json b/src/connector/node-rest/package-lock.json deleted file mode 100644 index c60bffc65d4f1446e060695462b0bde54a28c22f..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/package-lock.json +++ /dev/null @@ -1,1426 +0,0 @@ -{ - "name": "td-rest-connector", - "version": "1.0.0", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@babel/code-frame": { - "version": "7.12.11", - "resolved": "https://registry.nlark.com/@babel/code-frame/download/@babel/code-frame-7.12.11.tgz", - "integrity": "sha1-9K1DWqJj25NbjxDyxVLSP7cWpj8=", - "dev": true, - "requires": { - "@babel/highlight": "^7.10.4" - } - }, - "@babel/helper-validator-identifier": { - "version": "7.14.9", - "resolved": "https://registry.nlark.com/@babel/helper-validator-identifier/download/@babel/helper-validator-identifier-7.14.9.tgz", - "integrity": "sha1-ZlTRcbICT22O4VG/JQlpmRkTHUg=", - "dev": true - }, - "@babel/highlight": { - "version": "7.14.5", - "resolved": "https://registry.nlark.com/@babel/highlight/download/@babel/highlight-7.14.5.tgz", - "integrity": "sha1-aGGlLwOWZAUAH2qlNKAaJNmejNk=", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.14.5", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - }, - "dependencies": { - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.nlark.com/chalk/download/chalk-2.4.2.tgz?cache=0&sync_timestamp=1627647108647&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fchalk%2Fdownload%2Fchalk-2.4.2.tgz", - "integrity": "sha1-zUJUFnelQzPPVBpJEIwUMrRMlCQ=", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz?cache=0&sync_timestamp=1618677264890&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fescape-string-regexp%2Fdownload%2Fescape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - } - } - }, - "@eslint/eslintrc": { - "version": "0.4.3", - "resolved": "https://registry.nlark.com/@eslint/eslintrc/download/@eslint/eslintrc-0.4.3.tgz", - "integrity": "sha1-nkKYHvA1vrPdSa3ResuW6P9vOUw=", - "dev": true, - "requires": { - "ajv": "^6.12.4", - "debug": "^4.1.1", - "espree": "^7.3.0", - "globals": "^13.9.0", - "ignore": "^4.0.6", - "import-fresh": "^3.2.1", - "js-yaml": "^3.13.1", - "minimatch": "^3.0.4", - "strip-json-comments": "^3.1.1" - } - }, - "@humanwhocodes/config-array": { - "version": "0.5.0", - "resolved": "https://registry.nlark.com/@humanwhocodes/config-array/download/@humanwhocodes/config-array-0.5.0.tgz", - "integrity": "sha1-FAeWfUxu7Nc4j4Os8er00Mbljvk=", - "dev": true, - "requires": { - "@humanwhocodes/object-schema": "^1.2.0", - "debug": "^4.1.1", - "minimatch": "^3.0.4" - } - }, - "@humanwhocodes/object-schema": { - "version": "1.2.0", - "resolved": "https://registry.nlark.com/@humanwhocodes/object-schema/download/@humanwhocodes/object-schema-1.2.0.tgz", - "integrity": "sha1-h956+cIxgm/daKxyWPd8Qp4OX88=", - "dev": true - }, - "acorn": { - "version": "7.4.1", - "resolved": "https://registry.nlark.com/acorn/download/acorn-7.4.1.tgz", - "integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=", - "dev": true - }, - "acorn-jsx": { - "version": "5.3.2", - "resolved": "https://registry.nlark.com/acorn-jsx/download/acorn-jsx-5.3.2.tgz", - "integrity": "sha1-ftW7VZCLOy8bxVxq8WU7rafweTc=", - "dev": true - }, - "ajv": { - "version": "6.12.6", - "resolved": "https://registry.nlark.com/ajv/download/ajv-6.12.6.tgz", - "integrity": "sha1-uvWmLoArB9l3A0WG+MO69a3ybfQ=", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npm.taobao.org/ansi-colors/download/ansi-colors-4.1.1.tgz", - "integrity": "sha1-y7muJWv3UK8eqzRPIpqif+lLo0g=", - "dev": true - }, - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.nlark.com/ansi-styles/download/ansi-styles-3.2.1.tgz", - "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.nlark.com/argparse/download/argparse-1.0.10.tgz", - "integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "assert": { - "version": "2.0.0", - "resolved": "https://registry.npm.taobao.org/assert/download/assert-2.0.0.tgz", - "integrity": "sha1-lfwcYW1IcTUQaA8ury0Q3SLgLTI=", - "dev": true, - "requires": { - "es6-object-assign": "^1.1.0", - "is-nan": "^1.2.1", - "object-is": "^1.0.1", - "util": "^0.12.0" - } - }, - "astral-regex": { - "version": "2.0.0", - "resolved": "https://registry.npm.taobao.org/astral-regex/download/astral-regex-2.0.0.tgz", - "integrity": "sha1-SDFDxWeu7UeFdZwIZXhtx319LjE=", - "dev": true - }, - "available-typed-arrays": { - "version": "1.0.5", - "resolved": "https://registry.nlark.com/available-typed-arrays/download/available-typed-arrays-1.0.5.tgz", - "integrity": "sha1-kvlWFlAQadB9EO2y/DfT4cZRI7c=", - "dev": true - }, - "balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.nlark.com/balanced-match/download/balanced-match-1.0.2.tgz", - "integrity": "sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4=", - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.11.tgz?cache=0&sync_timestamp=1614010713935&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbrace-expansion%2Fdownload%2Fbrace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "call-bind": { - "version": "1.0.2", - "resolved": "https://registry.nlark.com/call-bind/download/call-bind-1.0.2.tgz", - "integrity": "sha1-sdTonmiBGcPJqQOtMKuy9qkZvjw=", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "get-intrinsic": "^1.0.2" - } - }, - "callsites": { - "version": "3.1.0", - "resolved": "https://registry.nlark.com/callsites/download/callsites-3.1.0.tgz", - "integrity": "sha1-s2MKvYlDQy9Us/BRkjjjPNffL3M=", - "dev": true - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.nlark.com/chalk/download/chalk-4.1.2.tgz?cache=0&sync_timestamp=1627647108647&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fchalk%2Fdownload%2Fchalk-4.1.2.tgz", - "integrity": "sha1-qsTit3NKdAhnrrFr8CqtVWoeegE=", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.nlark.com/ansi-styles/download/ansi-styles-4.3.0.tgz", - "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.nlark.com/color-convert/download/color-convert-2.0.1.tgz", - "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.nlark.com/color-name/download/color-name-1.1.4.tgz", - "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.nlark.com/has-flag/download/has-flag-4.0.0.tgz?cache=0&sync_timestamp=1626716143790&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fhas-flag%2Fdownload%2Fhas-flag-4.0.0.tgz", - "integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.nlark.com/supports-color/download/supports-color-7.2.0.tgz", - "integrity": "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.nlark.com/color-convert/download/color-convert-1.9.3.tgz", - "integrity": "sha1-u3GFBpDh8TZWfeYp0tVHHe2kweg=", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.nlark.com/color-name/download/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.nlark.com/concat-map/download/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.nlark.com/cross-spawn/download/cross-spawn-7.0.3.tgz", - "integrity": "sha1-9zqFudXUHQRVUcF34ogtSshXKKY=", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "data-uri-to-buffer": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.0.tgz", - "integrity": "sha512-Vr3mLBA8qWmcuschSLAOogKgQ/Jwxulv3RNE4FXnYWRGujzrRWQI4m12fQqRkwX06C0KanhLr4hK+GydchZsaA==" - }, - "debug": { - "version": "4.3.2", - "resolved": "https://registry.nlark.com/debug/download/debug-4.3.2.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdebug%2Fdownload%2Fdebug-4.3.2.tgz", - "integrity": "sha1-8KScGKyHeeMdSgxgKd+3aHPHQos=", - "dev": true, - "requires": { - "ms": "2.1.2" - } - }, - "deep-is": { - "version": "0.1.4", - "resolved": "https://registry.nlark.com/deep-is/download/deep-is-0.1.4.tgz?cache=0&sync_timestamp=1630774723365&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fdeep-is%2Fdownload%2Fdeep-is-0.1.4.tgz", - "integrity": "sha1-pvLc5hL63S7x9Rm3NVHxfoUZmDE=", - "dev": true - }, - "define-properties": { - "version": "1.1.3", - "resolved": "https://registry.nlark.com/define-properties/download/define-properties-1.1.3.tgz", - "integrity": "sha1-z4jabL7ib+bbcJT2HYcMvYTO6fE=", - "dev": true, - "requires": { - "object-keys": "^1.0.12" - } - }, - "doctrine": { - "version": "3.0.0", - "resolved": "https://registry.npm.taobao.org/doctrine/download/doctrine-3.0.0.tgz", - "integrity": "sha1-rd6+rXKmV023g2OdyHoSF3OXOWE=", - "dev": true, - "requires": { - "esutils": "^2.0.2" - } - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.nlark.com/emoji-regex/download/emoji-regex-8.0.0.tgz", - "integrity": "sha1-6Bj9ac5cz8tARZT4QpY79TFkzDc=", - "dev": true - }, - "enquirer": { - "version": "2.3.6", - "resolved": "https://registry.npm.taobao.org/enquirer/download/enquirer-2.3.6.tgz", - "integrity": "sha1-Kn/l3WNKHkElqXXsmU/1RW3Dc00=", - "dev": true, - "requires": { - "ansi-colors": "^4.1.1" - } - }, - "es-abstract": { - "version": "1.18.6", - "resolved": "https://registry.nlark.com/es-abstract/download/es-abstract-1.18.6.tgz?cache=0&sync_timestamp=1631076806734&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fes-abstract%2Fdownload%2Fes-abstract-1.18.6.tgz", - "integrity": "sha1-LETj6npiVQORZNJlWXd6bZeMtFY=", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "get-intrinsic": "^1.1.1", - "get-symbol-description": "^1.0.0", - "has": "^1.0.3", - "has-symbols": "^1.0.2", - "internal-slot": "^1.0.3", - "is-callable": "^1.2.4", - "is-negative-zero": "^2.0.1", - "is-regex": "^1.1.4", - "is-string": "^1.0.7", - "object-inspect": "^1.11.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.2", - "string.prototype.trimend": "^1.0.4", - "string.prototype.trimstart": "^1.0.4", - "unbox-primitive": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.nlark.com/es-to-primitive/download/es-to-primitive-1.2.1.tgz", - "integrity": "sha1-5VzUyc3BiLzvsDs2bHNjI/xciYo=", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "es6-object-assign": { - "version": "1.1.0", - "resolved": "https://registry.npm.taobao.org/es6-object-assign/download/es6-object-assign-1.1.0.tgz", - "integrity": "sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=", - "dev": true - }, - "esbuild": { - "version": "0.12.25", - "resolved": "https://registry.nlark.com/esbuild/download/esbuild-0.12.25.tgz", - "integrity": "sha1-whMc7wIs+f6UqqXgARCyf8l2Iho=", - "dev": true - }, - "escape-string-regexp": { - "version": "4.0.0", - "resolved": "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-4.0.0.tgz?cache=0&sync_timestamp=1618677264890&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fescape-string-regexp%2Fdownload%2Fescape-string-regexp-4.0.0.tgz", - "integrity": "sha1-FLqDpdNz49MR5a/KKc9b+tllvzQ=", - "dev": true - }, - "eslint": { - "version": "7.32.0", - "resolved": "https://registry.nlark.com/eslint/download/eslint-7.32.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Feslint%2Fdownload%2Feslint-7.32.0.tgz", - "integrity": "sha1-xtMooUvj+wjI0dIeEsAv23oqgS0=", - "dev": true, - "requires": { - "@babel/code-frame": "7.12.11", - "@eslint/eslintrc": "^0.4.3", - "@humanwhocodes/config-array": "^0.5.0", - "ajv": "^6.10.0", - "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", - "debug": "^4.0.1", - "doctrine": "^3.0.0", - "enquirer": "^2.3.5", - "escape-string-regexp": "^4.0.0", - "eslint-scope": "^5.1.1", - "eslint-utils": "^2.1.0", - "eslint-visitor-keys": "^2.0.0", - "espree": "^7.3.1", - "esquery": "^1.4.0", - "esutils": "^2.0.2", - "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^5.1.2", - "globals": "^13.6.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", - "imurmurhash": "^0.1.4", - "is-glob": "^4.0.0", - "js-yaml": "^3.13.1", - "json-stable-stringify-without-jsonify": "^1.0.1", - "levn": "^0.4.1", - "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", - "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "progress": "^2.0.0", - "regexpp": "^3.1.0", - "semver": "^7.2.1", - "strip-ansi": "^6.0.0", - "strip-json-comments": "^3.1.0", - "table": "^6.0.9", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" - } - }, - "eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.nlark.com/eslint-scope/download/eslint-scope-5.1.1.tgz?cache=0&sync_timestamp=1627061650854&other_urls=https%3A%2F%2Fregistry.nlark.com%2Feslint-scope%2Fdownload%2Feslint-scope-5.1.1.tgz", - "integrity": "sha1-54blmmbLkrP2wfsNUIqrF0hI9Iw=", - "dev": true, - "requires": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - } - }, - "eslint-utils": { - "version": "2.1.0", - "resolved": "https://registry.nlark.com/eslint-utils/download/eslint-utils-2.1.0.tgz", - "integrity": "sha1-0t5eA0JOcH3BDHQGjd7a5wh0Gyc=", - "dev": true, - "requires": { - "eslint-visitor-keys": "^1.1.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.nlark.com/eslint-visitor-keys/download/eslint-visitor-keys-1.3.0.tgz?cache=0&sync_timestamp=1624559014210&other_urls=https%3A%2F%2Fregistry.nlark.com%2Feslint-visitor-keys%2Fdownload%2Feslint-visitor-keys-1.3.0.tgz", - "integrity": "sha1-MOvR73wv3/AcOk8VEESvJfqwUj4=", - "dev": true - } - } - }, - "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.nlark.com/eslint-visitor-keys/download/eslint-visitor-keys-2.1.0.tgz?cache=0&sync_timestamp=1624559014210&other_urls=https%3A%2F%2Fregistry.nlark.com%2Feslint-visitor-keys%2Fdownload%2Feslint-visitor-keys-2.1.0.tgz", - "integrity": "sha1-9lMoJZMFknOSyTjtROsKXJsr0wM=", - "dev": true - }, - "espree": { - "version": "7.3.1", - "resolved": "https://registry.nlark.com/espree/download/espree-7.3.1.tgz?cache=0&sync_timestamp=1625021119997&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fespree%2Fdownload%2Fespree-7.3.1.tgz", - "integrity": "sha1-8t8zC3Usb1UBn4vYm3ZgA5wbu7Y=", - "dev": true, - "requires": { - "acorn": "^7.4.0", - "acorn-jsx": "^5.3.1", - "eslint-visitor-keys": "^1.3.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "1.3.0", - "resolved": "https://registry.nlark.com/eslint-visitor-keys/download/eslint-visitor-keys-1.3.0.tgz?cache=0&sync_timestamp=1624559014210&other_urls=https%3A%2F%2Fregistry.nlark.com%2Feslint-visitor-keys%2Fdownload%2Feslint-visitor-keys-1.3.0.tgz", - "integrity": "sha1-MOvR73wv3/AcOk8VEESvJfqwUj4=", - "dev": true - } - } - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npm.taobao.org/esprima/download/esprima-4.0.1.tgz", - "integrity": "sha1-E7BM2z5sXRnfkatph6hpVhmwqnE=", - "dev": true - }, - "esquery": { - "version": "1.4.0", - "resolved": "https://registry.nlark.com/esquery/download/esquery-1.4.0.tgz", - "integrity": "sha1-IUj/w4uC6McFff7UhCWz5h8PJKU=", - "dev": true, - "requires": { - "estraverse": "^5.1.0" - }, - "dependencies": { - "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npm.taobao.org/estraverse/download/estraverse-5.2.0.tgz", - "integrity": "sha1-MH30JUfmzHMk088DwVXVzbjFOIA=", - "dev": true - } - } - }, - "esrecurse": { - "version": "4.3.0", - "resolved": "https://registry.npm.taobao.org/esrecurse/download/esrecurse-4.3.0.tgz", - "integrity": "sha1-eteWTWeauyi+5yzsY3WLHF0smSE=", - "dev": true, - "requires": { - "estraverse": "^5.2.0" - }, - "dependencies": { - "estraverse": { - "version": "5.2.0", - "resolved": "https://registry.npm.taobao.org/estraverse/download/estraverse-5.2.0.tgz", - "integrity": "sha1-MH30JUfmzHMk088DwVXVzbjFOIA=", - "dev": true - } - } - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npm.taobao.org/estraverse/download/estraverse-4.3.0.tgz", - "integrity": "sha1-OYrT88WiSUi+dyXoPRGn3ijNvR0=", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npm.taobao.org/esutils/download/esutils-2.0.3.tgz", - "integrity": "sha1-dNLrTeC42hKTcRkQ1Qd1ubcQ72Q=", - "dev": true - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npm.taobao.org/fast-deep-equal/download/fast-deep-equal-3.1.3.tgz", - "integrity": "sha1-On1WtVnWy8PrUSMlJE5hmmXGxSU=", - "dev": true - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npm.taobao.org/fast-json-stable-stringify/download/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha1-h0v2nG9ATCtdmcSBNBOZ/VWJJjM=", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npm.taobao.org/fast-levenshtein/download/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "fetch-blob": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.1.4.tgz", - "integrity": "sha512-Eq5Xv5+VlSrYWEqKrusxY1C3Hm/hjeAsCGVG3ft7pZahlUAChpGZT/Ms1WmSLnEAisEXszjzu/s+ce6HZB2VHA==", - "requires": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - } - }, - "file-entry-cache": { - "version": "6.0.1", - "resolved": "https://registry.npm.taobao.org/file-entry-cache/download/file-entry-cache-6.0.1.tgz?cache=0&sync_timestamp=1613794546707&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ffile-entry-cache%2Fdownload%2Ffile-entry-cache-6.0.1.tgz", - "integrity": "sha1-IRst2WWcsDlLBz5zI6w8kz1SICc=", - "dev": true, - "requires": { - "flat-cache": "^3.0.4" - } - }, - "flat-cache": { - "version": "3.0.4", - "resolved": "https://registry.npm.taobao.org/flat-cache/download/flat-cache-3.0.4.tgz", - "integrity": "sha1-YbAzgwKy/p+Vfcwy/CqH8cMEixE=", - "dev": true, - "requires": { - "flatted": "^3.1.0", - "rimraf": "^3.0.2" - } - }, - "flatted": { - "version": "3.2.2", - "resolved": "https://registry.nlark.com/flatted/download/flatted-3.2.2.tgz?cache=0&sync_timestamp=1627541315228&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fflatted%2Fdownload%2Fflatted-3.2.2.tgz", - "integrity": "sha1-ZL/tXLaP48p4s+shStl7Y77c5WE=", - "dev": true - }, - "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npm.taobao.org/foreach/download/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", - "dev": true - }, - "formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "requires": { - "fetch-blob": "^3.1.2" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.nlark.com/fs.realpath/download/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npm.taobao.org/function-bind/download/function-bind-1.1.1.tgz", - "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=", - "dev": true - }, - "functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.nlark.com/functional-red-black-tree/download/functional-red-black-tree-1.0.1.tgz?cache=0&sync_timestamp=1618847182644&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ffunctional-red-black-tree%2Fdownload%2Ffunctional-red-black-tree-1.0.1.tgz", - "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", - "dev": true - }, - "get-intrinsic": { - "version": "1.1.1", - "resolved": "https://registry.nlark.com/get-intrinsic/download/get-intrinsic-1.1.1.tgz", - "integrity": "sha1-FfWfN2+FXERpY5SPDSTNNje0q8Y=", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1" - } - }, - "get-symbol-description": { - "version": "1.0.0", - "resolved": "https://registry.nlark.com/get-symbol-description/download/get-symbol-description-1.0.0.tgz", - "integrity": "sha1-f9uByQAQH71WTdXxowr1qtweWNY=", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "get-intrinsic": "^1.1.1" - } - }, - "glob": { - "version": "7.1.7", - "resolved": "https://registry.nlark.com/glob/download/glob-7.1.7.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fglob%2Fdownload%2Fglob-7.1.7.tgz", - "integrity": "sha1-Oxk+kjPwHULQs/eClLvutBj5SpA=", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.nlark.com/glob-parent/download/glob-parent-5.1.2.tgz?cache=0&sync_timestamp=1626760235241&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fglob-parent%2Fdownload%2Fglob-parent-5.1.2.tgz", - "integrity": "sha1-hpgyxYA0/mikCTwX3BXoNA2EAcQ=", - "dev": true, - "requires": { - "is-glob": "^4.0.1" - } - }, - "globals": { - "version": "13.11.0", - "resolved": "https://registry.nlark.com/globals/download/globals-13.11.0.tgz", - "integrity": "sha1-QO9njaEX/nvS4o8fqySVG9AlW+c=", - "dev": true, - "requires": { - "type-fest": "^0.20.2" - } - }, - "has": { - "version": "1.0.3", - "resolved": "https://registry.npm.taobao.org/has/download/has-1.0.3.tgz", - "integrity": "sha1-ci18v8H2qoJB8W3YFOAR4fQeh5Y=", - "dev": true, - "requires": { - "function-bind": "^1.1.1" - } - }, - "has-bigints": { - "version": "1.0.1", - "resolved": "https://registry.npm.taobao.org/has-bigints/download/has-bigints-1.0.1.tgz", - "integrity": "sha1-ZP5qywIGc+O3jbA1pa9pqp0HsRM=", - "dev": true - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.nlark.com/has-flag/download/has-flag-3.0.0.tgz?cache=0&sync_timestamp=1626716143790&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fhas-flag%2Fdownload%2Fhas-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "has-symbols": { - "version": "1.0.2", - "resolved": "https://registry.npm.taobao.org/has-symbols/download/has-symbols-1.0.2.tgz?cache=0&sync_timestamp=1614443577352&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fhas-symbols%2Fdownload%2Fhas-symbols-1.0.2.tgz", - "integrity": "sha1-Fl0wcMADCXUqEjakeTMeOsVvFCM=", - "dev": true - }, - "has-tostringtag": { - "version": "1.0.0", - "resolved": "https://registry.nlark.com/has-tostringtag/download/has-tostringtag-1.0.0.tgz?cache=0&sync_timestamp=1628197490246&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fhas-tostringtag%2Fdownload%2Fhas-tostringtag-1.0.0.tgz", - "integrity": "sha1-fhM4GKfTlHNPlB5zw9P5KR5liyU=", - "dev": true, - "requires": { - "has-symbols": "^1.0.2" - } - }, - "ignore": { - "version": "4.0.6", - "resolved": "https://registry.nlark.com/ignore/download/ignore-4.0.6.tgz", - "integrity": "sha1-dQ49tYYgh7RzfrrIIH/9HvJ7Jfw=", - "dev": true - }, - "import-fresh": { - "version": "3.3.0", - "resolved": "https://registry.npm.taobao.org/import-fresh/download/import-fresh-3.3.0.tgz?cache=0&sync_timestamp=1608469520031&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fimport-fresh%2Fdownload%2Fimport-fresh-3.3.0.tgz", - "integrity": "sha1-NxYsJfy566oublPVtNiM4X2eDCs=", - "dev": true, - "requires": { - "parent-module": "^1.0.0", - "resolve-from": "^4.0.0" - } - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.nlark.com/imurmurhash/download/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npm.taobao.org/inflight/download/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npm.taobao.org/inherits/download/inherits-2.0.4.tgz", - "integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=", - "dev": true - }, - "internal-slot": { - "version": "1.0.3", - "resolved": "https://registry.nlark.com/internal-slot/download/internal-slot-1.0.3.tgz", - "integrity": "sha1-c0fjB97uovqsKsYgXUvH00ln9Zw=", - "dev": true, - "requires": { - "get-intrinsic": "^1.1.0", - "has": "^1.0.3", - "side-channel": "^1.0.4" - } - }, - "is-arguments": { - "version": "1.1.1", - "resolved": "https://registry.nlark.com/is-arguments/download/is-arguments-1.1.1.tgz?cache=0&sync_timestamp=1628202102318&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-arguments%2Fdownload%2Fis-arguments-1.1.1.tgz", - "integrity": "sha1-FbP4j9oB8ql/7ITKdhpWDxI++ps=", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-bigint": { - "version": "1.0.4", - "resolved": "https://registry.nlark.com/is-bigint/download/is-bigint-1.0.4.tgz?cache=0&sync_timestamp=1628747504782&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-bigint%2Fdownload%2Fis-bigint-1.0.4.tgz", - "integrity": "sha1-CBR6GHW8KzIAXUHM2Ckd/8ZpHfM=", - "dev": true, - "requires": { - "has-bigints": "^1.0.1" - } - }, - "is-boolean-object": { - "version": "1.1.2", - "resolved": "https://registry.nlark.com/is-boolean-object/download/is-boolean-object-1.1.2.tgz?cache=0&sync_timestamp=1628207133571&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-boolean-object%2Fdownload%2Fis-boolean-object-1.1.2.tgz", - "integrity": "sha1-XG3CACRt2TIa5LiFoRS7H3X2Nxk=", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-callable": { - "version": "1.2.4", - "resolved": "https://registry.nlark.com/is-callable/download/is-callable-1.2.4.tgz?cache=0&sync_timestamp=1628259683451&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-callable%2Fdownload%2Fis-callable-1.2.4.tgz", - "integrity": "sha1-RzAdWN0CWUB4ZVR4U99tYf5HGUU=", - "dev": true - }, - "is-date-object": { - "version": "1.0.5", - "resolved": "https://registry.nlark.com/is-date-object/download/is-date-object-1.0.5.tgz", - "integrity": "sha1-CEHVU25yTCVZe/bqYuG9OCmN8x8=", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.nlark.com/is-extglob/download/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npm.taobao.org/is-fullwidth-code-point/download/is-fullwidth-code-point-3.0.0.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-fullwidth-code-point%2Fdownload%2Fis-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha1-8Rb4Bk/pCz94RKOJl8C3UFEmnx0=", - "dev": true - }, - "is-generator-function": { - "version": "1.0.10", - "resolved": "https://registry.nlark.com/is-generator-function/download/is-generator-function-1.0.10.tgz?cache=0&sync_timestamp=1628227835267&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-generator-function%2Fdownload%2Fis-generator-function-1.0.10.tgz", - "integrity": "sha1-8VWLrxrBfg3up8BBXEODUf8rPHI=", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.nlark.com/is-glob/download/is-glob-4.0.1.tgz", - "integrity": "sha1-dWfb6fL14kZ7x3q4PEopSCQHpdw=", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-nan": { - "version": "1.3.2", - "resolved": "https://registry.npm.taobao.org/is-nan/download/is-nan-1.3.2.tgz", - "integrity": "sha1-BDpUreoxdItVts1OCara+mm9nh0=", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3" - } - }, - "is-negative-zero": { - "version": "2.0.1", - "resolved": "https://registry.npm.taobao.org/is-negative-zero/download/is-negative-zero-2.0.1.tgz?cache=0&sync_timestamp=1607123314998&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fis-negative-zero%2Fdownload%2Fis-negative-zero-2.0.1.tgz", - "integrity": "sha1-PedGwY3aIxkkGlNnWQjY92bxHCQ=", - "dev": true - }, - "is-number-object": { - "version": "1.0.6", - "resolved": "https://registry.nlark.com/is-number-object/download/is-number-object-1.0.6.tgz", - "integrity": "sha1-anqvg4x/BoalC0VT9+VKlklOifA=", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-regex": { - "version": "1.1.4", - "resolved": "https://registry.nlark.com/is-regex/download/is-regex-1.1.4.tgz", - "integrity": "sha1-7vVmPNWfpMCuM5UFMj32hUuxWVg=", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "has-tostringtag": "^1.0.0" - } - }, - "is-string": { - "version": "1.0.7", - "resolved": "https://registry.nlark.com/is-string/download/is-string-1.0.7.tgz", - "integrity": "sha1-DdEr8gBvJVu1j2lREO/3SR7rwP0=", - "dev": true, - "requires": { - "has-tostringtag": "^1.0.0" - } - }, - "is-symbol": { - "version": "1.0.4", - "resolved": "https://registry.nlark.com/is-symbol/download/is-symbol-1.0.4.tgz?cache=0&sync_timestamp=1620501308896&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-symbol%2Fdownload%2Fis-symbol-1.0.4.tgz", - "integrity": "sha1-ptrJO2NbBjymhyI23oiRClevE5w=", - "dev": true, - "requires": { - "has-symbols": "^1.0.2" - } - }, - "is-typed-array": { - "version": "1.1.8", - "resolved": "https://registry.nlark.com/is-typed-array/download/is-typed-array-1.1.8.tgz", - "integrity": "sha1-y6plhdx9tDMYvFuJUj6jhKb2Xnk=", - "dev": true, - "requires": { - "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.2", - "es-abstract": "^1.18.5", - "foreach": "^2.0.5", - "has-tostringtag": "^1.0.0" - } - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npm.taobao.org/isexe/download/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.nlark.com/js-tokens/download/js-tokens-4.0.0.tgz", - "integrity": "sha1-GSA/tZmR35jjoocFDUZHzerzJJk=", - "dev": true - }, - "js-yaml": { - "version": "3.14.1", - "resolved": "https://registry.nlark.com/js-yaml/download/js-yaml-3.14.1.tgz?cache=0&sync_timestamp=1618847247867&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fjs-yaml%2Fdownload%2Fjs-yaml-3.14.1.tgz", - "integrity": "sha1-2ugS/bOCX6MGYJqHFzg8UMNqBTc=", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.nlark.com/json-schema-traverse/download/json-schema-traverse-0.4.1.tgz", - "integrity": "sha1-afaofZUTq4u4/mO9sJecRI5oRmA=", - "dev": true - }, - "json-stable-stringify-without-jsonify": { - "version": "1.0.1", - "resolved": "https://registry.nlark.com/json-stable-stringify-without-jsonify/download/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", - "dev": true - }, - "levn": { - "version": "0.4.1", - "resolved": "https://registry.nlark.com/levn/download/levn-0.4.1.tgz", - "integrity": "sha1-rkViwAdHO5MqYgDUAyaN0v/8at4=", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1", - "type-check": "~0.4.0" - } - }, - "lodash.clonedeep": { - "version": "4.5.0", - "resolved": "https://registry.nlark.com/lodash.clonedeep/download/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", - "dev": true - }, - "lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.nlark.com/lodash.merge/download/lodash.merge-4.6.2.tgz", - "integrity": "sha1-VYqlO0O2YeGSWgr9+japoQhf5Xo=", - "dev": true - }, - "lodash.truncate": { - "version": "4.4.2", - "resolved": "https://registry.nlark.com/lodash.truncate/download/lodash.truncate-4.4.2.tgz", - "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", - "dev": true - }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.nlark.com/lru-cache/download/lru-cache-6.0.0.tgz", - "integrity": "sha1-bW/mVw69lqr5D8rR2vo7JWbbOpQ=", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.nlark.com/minimatch/download/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.nlark.com/ms/download/ms-2.1.2.tgz", - "integrity": "sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk=", - "dev": true - }, - "natural-compare": { - "version": "1.4.0", - "resolved": "https://registry.npm.taobao.org/natural-compare/download/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true - }, - "node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" - }, - "node-fetch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.1.1.tgz", - "integrity": "sha512-SMk+vKgU77PYotRdWzqZGTZeuFKlsJ0hu4KPviQKkfY+N3vn2MIzr0rvpnYpR8MtB3IEuhlEcuOLbGvLRlA+yg==", - "requires": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.3", - "formdata-polyfill": "^4.0.10" - } - }, - "object-inspect": { - "version": "1.11.0", - "resolved": "https://registry.nlark.com/object-inspect/download/object-inspect-1.11.0.tgz", - "integrity": "sha1-nc6xRs7dQUig2eUauI00z1CZIrE=", - "dev": true - }, - "object-is": { - "version": "1.1.5", - "resolved": "https://registry.npm.taobao.org/object-is/download/object-is-1.1.5.tgz?cache=0&sync_timestamp=1613858420069&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fobject-is%2Fdownload%2Fobject-is-1.1.5.tgz", - "integrity": "sha1-ud7qpfx/GEag+uzc7sE45XePU6w=", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - } - }, - "object-keys": { - "version": "1.1.1", - "resolved": "https://registry.npm.taobao.org/object-keys/download/object-keys-1.1.1.tgz", - "integrity": "sha1-HEfyct8nfzsdrwYWd9nILiMixg4=", - "dev": true - }, - "object.assign": { - "version": "4.1.2", - "resolved": "https://registry.npm.taobao.org/object.assign/download/object.assign-4.1.2.tgz?cache=0&sync_timestamp=1604115183005&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fobject.assign%2Fdownload%2Fobject.assign-4.1.2.tgz", - "integrity": "sha1-DtVKNC7Os3s4/3brgxoOeIy2OUA=", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "define-properties": "^1.1.3", - "has-symbols": "^1.0.1", - "object-keys": "^1.1.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.nlark.com/once/download/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "optionator": { - "version": "0.9.1", - "resolved": "https://registry.nlark.com/optionator/download/optionator-0.9.1.tgz", - "integrity": "sha1-TyNqY3Pa4FZqbUPhMmZ09QwpFJk=", - "dev": true, - "requires": { - "deep-is": "^0.1.3", - "fast-levenshtein": "^2.0.6", - "levn": "^0.4.1", - "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" - } - }, - "parent-module": { - "version": "1.0.1", - "resolved": "https://registry.nlark.com/parent-module/download/parent-module-1.0.1.tgz", - "integrity": "sha1-aR0nCeeMefrjoVZiJFLQB2LKqqI=", - "dev": true, - "requires": { - "callsites": "^3.0.0" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.nlark.com/path-is-absolute/download/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.nlark.com/path-key/download/path-key-3.1.1.tgz", - "integrity": "sha1-WB9q3mWMu6ZaDTOA3ndTKVBU83U=", - "dev": true - }, - "prelude-ls": { - "version": "1.2.1", - "resolved": "https://registry.npm.taobao.org/prelude-ls/download/prelude-ls-1.2.1.tgz", - "integrity": "sha1-3rxkidem5rDnYRiIzsiAM30xY5Y=", - "dev": true - }, - "progress": { - "version": "2.0.3", - "resolved": "https://registry.nlark.com/progress/download/progress-2.0.3.tgz", - "integrity": "sha1-foz42PW48jnBvGi+tOt4Vn1XLvg=", - "dev": true - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npm.taobao.org/punycode/download/punycode-2.1.1.tgz", - "integrity": "sha1-tYsBCsQMIsVldhbI0sLALHv0eew=", - "dev": true - }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.nlark.com/regexpp/download/regexpp-3.2.0.tgz?cache=0&sync_timestamp=1623669109412&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fregexpp%2Fdownload%2Fregexpp-3.2.0.tgz", - "integrity": "sha1-BCWido2PI7rXDKS5BGH6LxIT4bI=", - "dev": true - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npm.taobao.org/require-from-string/download/require-from-string-2.0.2.tgz", - "integrity": "sha1-iaf92TgmEmcxjq/hT5wy5ZjDaQk=", - "dev": true - }, - "resolve-from": { - "version": "4.0.0", - "resolved": "https://registry.npm.taobao.org/resolve-from/download/resolve-from-4.0.0.tgz", - "integrity": "sha1-SrzYUq0y3Xuqv+m0DgCjbbXzkuY=", - "dev": true - }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npm.taobao.org/rimraf/download/rimraf-3.0.2.tgz", - "integrity": "sha1-8aVAK6YiCtUswSgrrBrjqkn9Bho=", - "dev": true, - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.1.tgz", - "integrity": "sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY=", - "dev": true - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.nlark.com/semver/download/semver-7.3.5.tgz", - "integrity": "sha1-C2Ich5NI2JmOSw5L6Us/EuYBjvc=", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.nlark.com/shebang-command/download/shebang-command-2.0.0.tgz", - "integrity": "sha1-zNCvT4g1+9wmW4JGGq8MNmY/NOo=", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.nlark.com/shebang-regex/download/shebang-regex-3.0.0.tgz", - "integrity": "sha1-rhbxZE2HPsrYQ7AwexQzYtTEIXI=", - "dev": true - }, - "side-channel": { - "version": "1.0.4", - "resolved": "https://registry.npm.taobao.org/side-channel/download/side-channel-1.0.4.tgz", - "integrity": "sha1-785cj9wQTudRslxY1CkAEfpeos8=", - "dev": true, - "requires": { - "call-bind": "^1.0.0", - "get-intrinsic": "^1.0.2", - "object-inspect": "^1.9.0" - } - }, - "slice-ansi": { - "version": "4.0.0", - "resolved": "https://registry.nlark.com/slice-ansi/download/slice-ansi-4.0.0.tgz", - "integrity": "sha1-UA6N0P1VsFgVCGJVsxla3ypF/ms=", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "astral-regex": "^2.0.0", - "is-fullwidth-code-point": "^3.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.nlark.com/ansi-styles/download/ansi-styles-4.3.0.tgz", - "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.nlark.com/color-convert/download/color-convert-2.0.1.tgz", - "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.nlark.com/color-name/download/color-name-1.1.4.tgz", - "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", - "dev": true - } - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npm.taobao.org/sprintf-js/download/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.nlark.com/string-width/download/string-width-4.2.2.tgz", - "integrity": "sha1-2v1PlVmnWFz7pSnGoKT3NIjr1MU=", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "string.prototype.trimend": { - "version": "1.0.4", - "resolved": "https://registry.npm.taobao.org/string.prototype.trimend/download/string.prototype.trimend-1.0.4.tgz", - "integrity": "sha1-51rpDClCxjUEaGwYsoe0oLGkX4A=", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - } - }, - "string.prototype.trimstart": { - "version": "1.0.4", - "resolved": "https://registry.npm.taobao.org/string.prototype.trimstart/download/string.prototype.trimstart-1.0.4.tgz?cache=0&sync_timestamp=1614127318238&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fstring.prototype.trimstart%2Fdownload%2Fstring.prototype.trimstart-1.0.4.tgz", - "integrity": "sha1-s2OZr0qymZtMnGSL16P7K7Jv7u0=", - "dev": true, - "requires": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.3" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.nlark.com/strip-ansi/download/strip-ansi-6.0.0.tgz", - "integrity": "sha1-CxVx3XZpzNTz4G4U7x7tJiJa5TI=", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "strip-json-comments": { - "version": "3.1.1", - "resolved": "https://registry.nlark.com/strip-json-comments/download/strip-json-comments-3.1.1.tgz", - "integrity": "sha1-MfEoGzgyYwQ0gxwxDAHMzajL4AY=", - "dev": true - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.nlark.com/supports-color/download/supports-color-5.5.0.tgz", - "integrity": "sha1-4uaaRKyHcveKHsCzW2id9lMO/I8=", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "table": { - "version": "6.7.1", - "resolved": "https://registry.nlark.com/table/download/table-6.7.1.tgz?cache=0&sync_timestamp=1620957375998&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftable%2Fdownload%2Ftable-6.7.1.tgz", - "integrity": "sha1-7gVZK3FDgxqMlPPO5qrkwczvM+I=", - "dev": true, - "requires": { - "ajv": "^8.0.1", - "lodash.clonedeep": "^4.5.0", - "lodash.truncate": "^4.4.2", - "slice-ansi": "^4.0.0", - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ajv": { - "version": "8.6.2", - "resolved": "https://registry.nlark.com/ajv/download/ajv-8.6.2.tgz", - "integrity": "sha1-L7ReDl/LwIEzJsHD2lNdGIG7BXE=", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "json-schema-traverse": "^1.0.0", - "require-from-string": "^2.0.2", - "uri-js": "^4.2.2" - } - }, - "json-schema-traverse": { - "version": "1.0.0", - "resolved": "https://registry.nlark.com/json-schema-traverse/download/json-schema-traverse-1.0.0.tgz", - "integrity": "sha1-rnvLNlard6c7pcSb9lTzjmtoYOI=", - "dev": true - } - } - }, - "text-table": { - "version": "0.2.0", - "resolved": "https://registry.npm.taobao.org/text-table/download/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", - "dev": true - }, - "type-check": { - "version": "0.4.0", - "resolved": "https://registry.nlark.com/type-check/download/type-check-0.4.0.tgz", - "integrity": "sha1-B7ggO/pwVsBlcFDjzNLDdzC6uPE=", - "dev": true, - "requires": { - "prelude-ls": "^1.2.1" - } - }, - "type-fest": { - "version": "0.20.2", - "resolved": "https://registry.nlark.com/type-fest/download/type-fest-0.20.2.tgz", - "integrity": "sha1-G/IH9LKPkVg2ZstfvTJ4hzAc1fQ=", - "dev": true - }, - "unbox-primitive": { - "version": "1.0.1", - "resolved": "https://registry.nlark.com/unbox-primitive/download/unbox-primitive-1.0.1.tgz", - "integrity": "sha1-CF4hViXsMWJXTciFmr7nilmxRHE=", - "dev": true, - "requires": { - "function-bind": "^1.1.1", - "has-bigints": "^1.0.1", - "has-symbols": "^1.0.2", - "which-boxed-primitive": "^1.0.2" - } - }, - "uri-js": { - "version": "4.4.1", - "resolved": "https://registry.npm.taobao.org/uri-js/download/uri-js-4.4.1.tgz?cache=0&sync_timestamp=1610240086113&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Furi-js%2Fdownload%2Furi-js-4.4.1.tgz", - "integrity": "sha1-mxpSWVIlhZ5V9mnZKPiMbFfyp34=", - "dev": true, - "requires": { - "punycode": "^2.1.0" - } - }, - "util": { - "version": "0.12.4", - "resolved": "https://registry.nlark.com/util/download/util-0.12.4.tgz?cache=0&sync_timestamp=1622213272480&other_urls=https%3A%2F%2Fregistry.nlark.com%2Futil%2Fdownload%2Futil-0.12.4.tgz", - "integrity": "sha1-ZhIaMUIN+PAcoMRkvhXfodGFAlM=", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "is-arguments": "^1.0.4", - "is-generator-function": "^1.0.7", - "is-typed-array": "^1.1.3", - "safe-buffer": "^5.1.2", - "which-typed-array": "^1.1.2" - } - }, - "v8-compile-cache": { - "version": "2.3.0", - "resolved": "https://registry.npm.taobao.org/v8-compile-cache/download/v8-compile-cache-2.3.0.tgz", - "integrity": "sha1-LeGWGMZtwkfc+2+ZM4A12CRaLO4=", - "dev": true - }, - "web-streams-polyfill": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.0.tgz", - "integrity": "sha512-EqPmREeOzttaLRm5HS7io98goBgZ7IVz79aDvqjD0kYXLtFZTc0T/U6wHTPKyIjb+MdN7DFIIX6hgdBEpWmfPA==" - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npm.taobao.org/which/download/which-2.0.2.tgz", - "integrity": "sha1-fGqN0KY2oDJ+ELWckobu6T8/UbE=", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-boxed-primitive": { - "version": "1.0.2", - "resolved": "https://registry.npm.taobao.org/which-boxed-primitive/download/which-boxed-primitive-1.0.2.tgz", - "integrity": "sha1-E3V7yJsgmwSf5dhkMOIc9AqJqOY=", - "dev": true, - "requires": { - "is-bigint": "^1.0.1", - "is-boolean-object": "^1.1.0", - "is-number-object": "^1.0.4", - "is-string": "^1.0.5", - "is-symbol": "^1.0.3" - } - }, - "which-typed-array": { - "version": "1.1.7", - "resolved": "https://registry.nlark.com/which-typed-array/download/which-typed-array-1.1.7.tgz?cache=0&sync_timestamp=1630377722719&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fwhich-typed-array%2Fdownload%2Fwhich-typed-array-1.1.7.tgz", - "integrity": "sha1-J2F5m5oi1LhmCzwbQKuqdzlpF5M=", - "dev": true, - "requires": { - "available-typed-arrays": "^1.0.5", - "call-bind": "^1.0.2", - "es-abstract": "^1.18.5", - "foreach": "^2.0.5", - "has-tostringtag": "^1.0.0", - "is-typed-array": "^1.1.7" - } - }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.nlark.com/word-wrap/download/word-wrap-1.2.3.tgz", - "integrity": "sha1-YQY29rH3A4kb00dxzLF/uTtHB5w=", - "dev": true - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.nlark.com/wrappy/download/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npm.taobao.org/yallist/download/yallist-4.0.0.tgz", - "integrity": "sha1-m7knkNnA7/7GO+c1GeEaNQGaOnI=", - "dev": true - } - } -} diff --git a/src/connector/node-rest/package.json b/src/connector/node-rest/package.json deleted file mode 100644 index f314abd6463bd4fe5046f2ae68f338cd06acd250..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "td-rest-connector", - "version": "1.0.0", - "description": "A Node.js connector for TDengine restful", - "module": "src/TDengineRest.js", - "main": "lib/TDengineclearRest.js", - "license": "MIT", - "scripts": { - "prepare": "npm run build", - "build": "esbuild --bundle --platform=node --outfile=lib/TDengineRest.js ./TDengineRest.js", - "build:dev": "esbuild --bundle --platform=node --outfile=dist/examples/show-database.js examples/show-database.js ", - "build:test": "esbuild test/testRestConn.js --bundle --platform=node --outfile=dist/tests/testRestConn.js ", - "test": "node dist/tests/testRestConn.js" - }, - "devDependencies": { - "esbuild": "^0.12.25", - "eslint": "^7.32.0", - "assert": "^2.0.0" - }, - "dependencies": { - "node-fetch": "^3.x" - } -} diff --git a/src/connector/node-rest/readme.md b/src/connector/node-rest/readme.md deleted file mode 100644 index db8d57c2ee0bc506921510f73c534fe4f607b537..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/readme.md +++ /dev/null @@ -1,40 +0,0 @@ -# TDengine Nodejs Restful - -This is the Node.js library that lets you connect to [TDengine](https://www.github.com/taosdata/tdengine) though -restful. This restful can help you access the TDengine from different platform. - -## Install -To get started, just type in the following to install the connector through [npm](https://www.npmjs.com/) - -```cmd -npm install td-rest-connector -``` - -## Usage - -### Connection - -```javascript -import taoRest from 'TDengineRest' -var connRest = taoRest({host:'127.0.0.1',user:'root',pass:'taosdata',port:6041}) -``` - -query -```javascript -(async()=>{ - data = await connRest.query("show databases"); - data.toString(); - } -)() -``` - -## Example -An example of using the NodeJS Restful connector to create a table with weather data and create and execute queries can be found [here](https://github.com/taosdata/TDengine/tree/master/tests/examples/node-rest/show-database.js) - -## Contributing to TDengine - -Please follow the [contribution guidelines](https://github.com/taosdata/TDengine/blob/master/CONTRIBUTING.md) to contribute to the project. - -## License - -[GNU AGPL v3.0](http://www.gnu.org/licenses/agpl-3.0.html) diff --git a/src/connector/node-rest/src/restConnect.js b/src/connector/node-rest/src/restConnect.js deleted file mode 100644 index ca6acc3e47c48c1e0020b2e5c07693159ad25670..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/src/restConnect.js +++ /dev/null @@ -1,59 +0,0 @@ -import {TDengineRestCursor} from '../src/restCursor' - -/** - *this class collect basic information that can be used to build - * a restful connection. - */ -export class TDengineRestConnection { - /** - * constructor,give variables some default values - * @param options - * @returns {TDengineRestConnection} - */ - constructor(options) { - this.host = 'localhost' - this.port = '6041' - this.user = 'root' - this.pass = 'taosdata' - this.path = '/rest/sqlt/' - this._initConnection(options) - return this - } - - /** - * used to init the connection info using the input options - * @param options - * @private - */ - _initConnection(options) { - if (options['host']) { - this.host = options['host'] - } - if (options['port']) { - this.port = options['port'] - } - if (options['user']) { - this.user = options['user'] - } - if (options['pass']) { - this.pass = options['pass'] - } - if (options['path']) { - this.path = options['path'] - } - } - - /** - * cursor will return an object of TDengineRestCursor, which can send restful(http) request and get - * the response from server. - * @returns {TDengineRestCursor} - */ - cursor() { - return new TDengineRestCursor(this) - } -} - - - - - diff --git a/src/connector/node-rest/src/restConstant.js b/src/connector/node-rest/src/restConstant.js deleted file mode 100644 index 9bab9313b3d376a1384f69b4fd7cb0dba6b1ab87..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/src/restConstant.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * indicate the every type's type code - * @type {{"0": string, "1": string, "2": string, "3": string, "4": string, "5": string, "6": string, "7": string, "8": string, "9": string, "10": string}} - */ -export const typeCodesToName = { - 0: 'Null', - 1: 'Boolean', - 2: 'Tiny Int', - 3: 'Small Int', - 4: 'Int', - 5: 'Big Int', - 6: 'Float', - 7: 'Double', - 8: 'Binary', - 9: 'Timestamp', - 10: 'Nchar', -} - -/** - * get the type of input typecode, in fact the response of restful will send every column's typecode - * @param typecode - * @returns {*} - */ -export function getTaoType(typecode) { - return typeCodesToName[typecode]; -} \ No newline at end of file diff --git a/src/connector/node-rest/src/restCursor.js b/src/connector/node-rest/src/restCursor.js deleted file mode 100644 index beb712f1775ab424456a267723b564bd338bebd2..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/src/restCursor.js +++ /dev/null @@ -1,66 +0,0 @@ -import fetch from 'node-fetch' -import {TDengineRestResultSet} from '../src/restResult' - -/** - * this class is core of restful js connector - * this class resends http request to the TDengine server - * and receive the response. - */ -export class TDengineRestCursor { - /** - * constructor,used to get the connection info - * @param connection - */ - constructor(connection) { - this._connection = null; - this.data = []; - this.http = false - if (connection != null) { - this._connection = connection - } else { - throw new Error("A TDengineRestConnection object is required to be passed to the TDengineRestCursor") - } - } - - /** - * used to build an url,like http://localhost:6041/rest/sql - * @returns {string} - * @private - */ - _apiUpl() { - return (this.http ? "https" : "http") + "://" + this._connection.host + ":" + this._connection.port + this._connection.path - } - - /** - * used to make an authorization token - * @returns {string} - * @private - */ - _token() { - return 'Basic ' + Buffer.from(this._connection.user + ":" + this._connection.pass).toString('base64') - } - - /** - * Used fetch to send http request, and return the response as an object of TDengineRestResultSet - * @param sql - * @returns {Promise} - */ - async query(sql) { - try { - let response = await fetch(this._apiUpl(), { - method: 'POST', - body: sql, - headers: {'Authorization': this._token()} - }) - // if (response.status == 'succ') { - return await new TDengineRestResultSet(await response.json()) - // } else { - // throw new Error(response.desc) - // } - } catch (e) { - console.log("Request Failed " + e) - } - - } -} - diff --git a/src/connector/node-rest/src/restResult.js b/src/connector/node-rest/src/restResult.js deleted file mode 100644 index ba469eb4ec5d7e75bb8682a4d7cbf1d709bb9e87..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/src/restResult.js +++ /dev/null @@ -1,159 +0,0 @@ -import {getTaoType} from '../src/restConstant' - - -export class TDengineRestResultSet { - constructor(result) { - this.status = '' //succ - this.column_name = {} //head - this.column_type = {} //column_meta - this.data = {} - this.affectRows = null //rows - this.code = null - this.desc = null - this._init(result) - } - - //initial the resultSet with a jason parameter - /** - * - * @param jason - */ - _init(result) { - if (result.status) { - this.status = result.status - } - if (result.head) { - this.column_name = result.head - } - if (result.column_meta) { - this.column_type = result.column_meta - } - if (result.data) { - this.data = result.data - } - if (result.rows) { - this.affectRows = result.rows - } - if (result.code) { - this.code = result.code - } - if (result.desc) { - this.desc = result.desc - } - } - - getStatus() { - return this.status - } - - getColumn_name() { - return this.column_name - } - - getColumn_type() { - let column_data = [] - this.column_type.forEach(function (column) { - column[1] = getTaoType(column[1]) - column_data.push(column) - }) - return column_data - } - - getData() { - return this.data - } - - getAffectRow() { - return this.affectRows - } - - getCode() { - return this.code - } - - getDesc() { - return this.desc - } - - - toString() { - if(this.status === 'succ'){ - let fields = this.column_type - let rows = this.data - this._prettyStr(fields, rows) - }else{ - console.log(this.status+":"+this.desc) - } - } - - _prettyStr(fields, data) { - let colName = [] - let colType = [] - let colSize = [] - let colStr = "" - - - for (let i = 0; i < fields.length; i++) { - colName.push(fields[i][0]) - colType.push(fields[i][1]) - - if ((fields[i][1]) == 8 || (fields[i][1]) == 10) { - colSize.push(Math.max(fields[i][0].length, fields[i][2])); //max(column_name.length,column_type_precision) - } else { - colSize.push(Math.max(fields[i][0].length, suggestedMinWidths[fields[i][1]]));// max(column_name.length,suggest_column_with_suggestion) - } - // console.log(colSize) - } - colName.forEach((name, i) => { - colStr += this._fillEmpty(Math.floor(colSize[i] / 2 - name.length / 2)) + name.toString() + this._fillEmpty(Math.ceil(colSize[i] / 2 - name.length / 2)) + " | " - }) - - let strSperator = "" - let sizeSum = colSize.reduce((a, b) => a += b, (0)) + colSize.length * 3 - strSperator = this._printN("=", sizeSum) - - console.log("\n" + colStr) - console.log(strSperator) - - data.forEach((row) => { - let rowStr = "" - row.forEach((cell, index) => { - rowStr += cell == null ? 'null' : cell.toString(); - rowStr += this._fillEmpty(colSize[index] - cell.toString().length) + " | " - }) - console.log(rowStr) - }) - - return colStr - } - - _fillEmpty(n) { - let str = ""; - for (let i = 0; i < n; i++) { - str += " "; - } - return str; - } - - _printN(s, n) { - let f = ""; - for (let i = 0; i < n; i++) { - f += s; - } - return f; - } -} - -const suggestedMinWidths = { - 0: 4, - 1: 4, - 2: 4, - 3: 6, - 4: 11, - 5: 12, - 6: 24, - 7: 24, - 8: 10, - 9: 25, - 10: 10, -} diff --git a/src/connector/node-rest/test/testRestConn.js b/src/connector/node-rest/test/testRestConn.js deleted file mode 100644 index 011a4b66e4a5fae09468610575a581ae185f9bbb..0000000000000000000000000000000000000000 --- a/src/connector/node-rest/test/testRestConn.js +++ /dev/null @@ -1,39 +0,0 @@ -import {TDRestConnection} from "../TDengineRest"; -import assert from "assert" - -let conn = new TDRestConnection({host: '127.0.0.1', user: 'root', pass: 'taosdata', port: 6041}); -let cursor = conn.cursor(); - -const createDB = "create database if not exists node_rest"; -const dropDB = "drop database if exists node_rest"; -const createTBL = "CREATE STABLE if not exists node_rest.meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int)"; -const dropTBL = "drop table if exists node_rest.meters "; -const insert = "INSERT INTO node_rest.d1001 USING node_rest.meters TAGS (\"Beijng.Chaoyang\", 2) VALUES (now, 10.2, 219, 0.32) "; -const select = "select * from node_rest.d1001 "; -const selectStbl = "select * from node_rest.meters"; - -async function execute(sql) { - console.log("SQL:" + sql); - let result = await cursor.query(sql); - try { - assert.strictEqual(result.getStatus(), 'succ', new Error("response error")) - result.toString() - } catch (e) { - console.log(e) - } - -} - -(async () => { - await execute(createDB); - await execute(createTBL); - await execute(insert); - await execute(select); - await execute(selectStbl); - await execute(dropDB); -})() - -// (async () => { -// result = await cursor.query("drop database if exists node_rest").catch(e=>console.log(e)) -// result.toString() -// })() diff --git a/src/connector/nodejs/examples/performance.js b/src/connector/nodejs/examples/performance.js deleted file mode 100644 index ea197f034435e28edd67df8d5f4b141f410fed81..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/performance.js +++ /dev/null @@ -1,89 +0,0 @@ -function memoryUsageData() { - let s = process.memoryUsage() - for (key in s) { - s[key] = (s[key]/1000000).toFixed(3) + "MB"; - } - return s; -} -console.log("initial mem usage:", memoryUsageData()); - -const { PerformanceObserver, performance } = require('perf_hooks'); -const taos = require('../tdengine'); -var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0}); -var c1 = conn.cursor(); - -// Initialize env -c1.execute('create database if not exists td_connector_test;'); -c1.execute('use td_connector_test;') -c1.execute('create table if not exists all_types (ts timestamp, _int int, _bigint bigint, _float float, _double double, _binary binary(40), _smallint smallint, _tinyint tinyint, _bool bool, _nchar nchar(40));'); -c1.execute('create table if not exists stabletest (ts timestamp, v1 int, v2 int, v3 int, v4 double) tags (id int, location binary(20));') - - -// Insertion into single table Performance Test -var dataPrepTime = 0; -var insertTime = 0; -var insertTime5000 = 0; -var avgInsert5ktime = 0; -const obs = new PerformanceObserver((items) => { - let entry = items.getEntries()[0]; - - if (entry.name == 'Data Prep') { - dataPrepTime += entry.duration; - } - else if (entry.name == 'Insert'){ - insertTime += entry.duration - } - else { - console.log(entry.name + ': ' + (entry.duration/1000).toFixed(8) + 's'); - } - performance.clearMarks(); -}); -obs.observe({ entryTypes: ['measure'] }); - -function R(l,r) { - return Math.random() * (r - l) - r; -} -function randomBool() { - if (Math.random() < 0.5) { - return true; - } - return false; -} -function insertN(n) { - for (let i = 0; i < n; i++) { - performance.mark('A3'); - let insertData = ["now + " + i + "m", // Timestamp - parseInt( R(-Math.pow(2,31) + 1 , Math.pow(2,31) - 1) ), // Int - parseInt( R(-Math.pow(2,31) + 1 , Math.pow(2,31) - 1) ), // BigInt - parseFloat( R(-3.4E38, 3.4E38) ), // Float - parseFloat( R(-1.7E308, 1.7E308) ), // Double - "\"Long Binary\"", // Binary - parseInt( R(-32767, 32767) ), // Small Int - parseInt( R(-127, 127) ), // Tiny Int - randomBool(), - "\"Nchars 一些中文字幕\""]; // Bool - let query = 'insert into td_connector_test.all_types values(' + insertData.join(',') + ' );'; - performance.mark('B3'); - performance.measure('Data Prep', 'A3', 'B3'); - performance.mark('A2'); - c1.execute(query, {quiet:true}); - performance.mark('B2'); - performance.measure('Insert', 'A2', 'B2'); - if ( i % 5000 == 4999) { - console.log("Insert # " + (i+1)); - console.log('Insert 5k records: ' + ((insertTime - insertTime5000)/1000).toFixed(8) + 's'); - insertTime5000 = insertTime; - avgInsert5ktime = (avgInsert5ktime/1000 * Math.floor(i / 5000) + insertTime5000/1000) / Math.ceil( i / 5000); - console.log('DataPrepTime So Far: ' + (dataPrepTime/1000).toFixed(8) + 's | Inserting time So Far: ' + (insertTime/1000).toFixed(8) + 's | Avg. Insert 5k time: ' + avgInsert5ktime.toFixed(8)); - - - } - } -} -performance.mark('insert 1E5') -insertN(1E5); -performance.mark('insert 1E5 2') -performance.measure('Insert With Logs', 'insert 1E5', 'insert 1E5 2'); -console.log('DataPrepTime: ' + (dataPrepTime/1000).toFixed(8) + 's | Inserting time: ' + (insertTime/1000).toFixed(8) + 's'); -dataPrepTime = 0; insertTime = 0; -//'insert into td_connector_test.all_types values (now, null,null,null,null,null,null,null,null,null);' diff --git a/src/connector/nodejs/examples/stmtBindParamBatchSample.js b/src/connector/nodejs/examples/stmtBindParamBatchSample.js deleted file mode 100755 index c7748790875a5d7e99482dbf1266917fd2882231..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/stmtBindParamBatchSample.js +++ /dev/null @@ -1,111 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect({ host: "localhost" }); -var cursor = conn.cursor(); - -function executeUpdate(updateSql) { - console.log(updateSql); - cursor.execute(updateSql); -} -function executeQuery(querySql) { - - let query = cursor.query(querySql); - query.execute().then((result => { - console.log(querySql); - result.pretty(); - })); -} - -function stmtBindParamBatchSample() { - let db = 'node_test_db'; - let table = 'stmt_taos_bind_param_batch'; - - let createDB = `create database if not exists ${db} keep 3650;`; - let dropDB = `drop database if exists ${db};`; - let useDB = `use ${db}`; - let createTable = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `t_bl bool,` + - `t_i8 tinyint,` + - `t_i16 smallint,` + - `t_i32 int,` + - `t_i64 bigint,` + - `t_f32 float,` + - `t_d64 double,` + - `t_bnr binary(20),` + - `t_nchr nchar(20),` + - `t_u8 tinyint unsigned,` + - `t_u16 smallint unsigned,` + - `t_u32 int unsigned,` + - `t_u64 bigint unsigned` + - `);`; - let querySql = `select * from ${table};`; - let insertSql = `insert into ? using ${table} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?);`; - - executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(useDB); - executeUpdate(createTable); - - let mBinds = new taos.TaosMultiBindArr(14); - mBinds.multiBindTimestamp([1642435200000, 1642435300000, 1642435400000, 1642435500000, 1642435600000]); - mBinds.multiBindBool([true, false, true, undefined, null]); - mBinds.multiBindTinyInt([-127, 3, 127, null, undefined]); - mBinds.multiBindSmallInt([-256, 0, 256, null, undefined]); - mBinds.multiBindInt([-1299, 0, 1233, null, undefined]); - mBinds.multiBindBigInt([16424352000002222n, -16424354000001111n, 0, null, undefined]); - mBinds.multiBindFloat([12.33, 0, -3.1415, null, undefined]); - mBinds.multiBindDouble([3.141592653, 0, -3.141592653, null, undefined]); - mBinds.multiBindBinary(['TDengine_Binary', '', 'taosdata涛思数据', null, undefined]); - mBinds.multiBindNchar(['taos_data_nchar', 'taosdata涛思数据', '', null, undefined]); - mBinds.multiBindUTinyInt([0, 127, 254, null, undefined]); - mBinds.multiBindUSmallInt([0, 256, 512, null, undefined]); - mBinds.multiBindUInt([0, 1233, 4294967294, null, undefined]); - mBinds.multiBindUBigInt([16424352000002222n, 36424354000001111n, 0, null, undefined]); - - let tags = new taos.TaosBind(13); - - tags.bindBool(true); - tags.bindTinyInt(127); - tags.bindSmallInt(32767); - tags.bindInt(1234555); - tags.bindBigInt(-164243520000011111n); - tags.bindFloat(214.02); - tags.bindDouble(2.01); - tags.bindBinary('taosdata涛思数据'); - tags.bindNchar('TDengine数据'); - tags.bindUTinyInt(254); - tags.bindUSmallInt(65534); - tags.bindUInt(4294967290); - tags.bindUBigInt(164243520000011111n); - - cursor.stmtInit(); - cursor.stmtPrepare(insertSql); - cursor.stmtSetTbnameTags('s_01', tags.getBind()); - cursor.stmtBindParamBatch(mBinds.getMultiBindArr()); - cursor.stmtAddBatch(); - cursor.stmtExecute(); - cursor.stmtClose(); - - executeQuery(querySql); - executeUpdate(dropDB); - -} - -stmtBindParamBatchSample(); -setTimeout(() => { - conn.close(); -}, 2000); diff --git a/src/connector/nodejs/examples/stmtBindParamSample.js b/src/connector/nodejs/examples/stmtBindParamSample.js deleted file mode 100644 index 57c097d8cf1215b60a3ce386eb4b60f2005e7c87..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/stmtBindParamSample.js +++ /dev/null @@ -1,82 +0,0 @@ -// const TaosBind = require('../nodetaos/taosBind'); -const taos = require('../tdengine'); -var conn = taos.connect({ host: "localhost" }); -var cursor = conn.cursor(); - -function executeUpdate(updateSql) { - console.log(updateSql); - cursor.execute(updateSql); -} -function executeQuery(querySql) { - - let query = cursor.query(querySql); - query.execute().then((result => { - console.log(querySql); - result.pretty(); - })); -} - -function stmtBindParamSample() { - let db = 'node_test_db'; - let table = 'stmt_taos_bind_sample'; - - let createDB = `create database if not exists ${db} keep 3650;`; - let dropDB = `drop database if exists ${db};`; - let useDB = `use ${db}`; - let createTable = `create table if not exists ${table} ` + - `(ts timestamp,` + - `nil int,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned);`; - let querySql = `select * from ${table};`; - let insertSql = `insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);` - - executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(useDB); - executeUpdate(createTable); - - let binds = new taos.TaosBind(15); - binds.bindTimestamp(1642435200000); - binds.bindNil(); - binds.bindBool(true); - binds.bindTinyInt(127); - binds.bindSmallInt(32767); - binds.bindInt(1234555); - binds.bindBigInt(-164243520000011111n); - binds.bindFloat(214.02); - binds.bindDouble(2.01); - binds.bindBinary('taosdata涛思数据'); - binds.bindNchar('TDengine数据'); - binds.bindUTinyInt(254); - binds.bindUSmallInt(65534); - binds.bindUInt(4294967294); - binds.bindUBigInt(164243520000011111n); - - cursor.stmtInit(); - cursor.stmtPrepare(insertSql); - cursor.stmtSetTbname(table); - cursor.stmtBindParam(binds.getBind()); - cursor.stmtAddBatch(); - cursor.stmtExecute(); - cursor.stmtClose(); - - executeQuery(querySql); - executeUpdate(dropDB); -} - -stmtBindParamSample(); -setTimeout(() => { - conn.close(); -}, 2000); \ No newline at end of file diff --git a/src/connector/nodejs/examples/stmtBindSingleParamBatchSample.js b/src/connector/nodejs/examples/stmtBindSingleParamBatchSample.js deleted file mode 100755 index 938de75b7f3314ce3db32294de9d30b609e480b8..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/stmtBindSingleParamBatchSample.js +++ /dev/null @@ -1,101 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect({ host: "localhost" }); -var cursor = conn.cursor(); - -function executeUpdate(updateSql) { - console.log(updateSql); - cursor.execute(updateSql); -} -function executeQuery(querySql) { - - let query = cursor.query(querySql); - query.execute().then((result => { - console.log(querySql); - result.pretty(); - - })); -} - -function stmtSingleParaBatchSample() { - let db = 'node_test_db'; - let table = 'stmt_taos_bind_single_bind_batch'; - - let createDB = `create database if not exists ${db} keep 3650;`; - let dropDB = `drop database if exists ${db};`; - let useDB = `use ${db}`; - let createTable = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `jsonTag json` + - `);`; - let querySql = `select * from ${table};`; - let insertSql = `insert into ? using ${table} tags(?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?);` - - executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(useDB); - executeUpdate(createTable); - - // normal colum values. - let mbind = new taos.TaosMultiBind(); - let tsMBind = mbind.multiBindTimestamp([1642435200000, 1642435300000, 1642435400000, 1642435500000, 1642435600000]) - let boolMbind = mbind.multiBindBool([true, false, true, undefined, null]); - let tinyIntMbind = mbind.multiBindTinyInt([-127, 3, 127, null, undefined]); - let smallIntMbind = mbind.multiBindSmallInt([-256, 0, 256, null, undefined]); - let intMbind = mbind.multiBindInt([-1299, 0, 1233, null, undefined]); - let bigIntMbind = mbind.multiBindBigInt([16424352000002222n, -16424354000001111n, 0, null, undefined]); - let floatMbind = mbind.multiBindFloat([12.33, 0, -3.1415, null, undefined]); - let doubleMbind = mbind.multiBindDouble([3.141592653, 0, -3.141592653, null, undefined]); - let binaryMbind = mbind.multiBindBinary(['TDengine_Binary', '', 'taosdata涛思数据', null, undefined]); - let ncharMbind = mbind.multiBindNchar(['taos_data_nchar', 'taosdata涛思数据', '', null, undefined]); - let uTinyIntMbind = mbind.multiBindUTinyInt([0, 127, 254, null, undefined]); - let uSmallIntMbind = mbind.multiBindUSmallInt([0, 256, 512, null, undefined]); - let uIntMbind = mbind.multiBindUInt([0, 1233, 4294967294, null, undefined]); - let uBigIntMbind = mbind.multiBindUBigInt([16424352000002222n, 36424354000001111n, 0, null, undefined]); - - // tags value. - let tags = new taos.TaosBind(1); - tags.bindJson('{\"key1\":\"taosdata\",\"key2\":null,\"key3\":\"TDengine涛思数据\",\"key4\":3.2}'); - - cursor.stmtInit(); - cursor.stmtPrepare(insertSql); - cursor.stmtSetTbnameTags('s_01', tags.getBind()); - cursor.stmtBindSingleParamBatch(tsMBind, 0); - cursor.stmtBindSingleParamBatch(boolMbind, 1); - cursor.stmtBindSingleParamBatch(tinyIntMbind, 2); - cursor.stmtBindSingleParamBatch(smallIntMbind, 3); - cursor.stmtBindSingleParamBatch(intMbind, 4); - cursor.stmtBindSingleParamBatch(bigIntMbind, 5); - cursor.stmtBindSingleParamBatch(floatMbind, 6); - cursor.stmtBindSingleParamBatch(doubleMbind, 7); - cursor.stmtBindSingleParamBatch(binaryMbind, 8); - cursor.stmtBindSingleParamBatch(ncharMbind, 9); - cursor.stmtBindSingleParamBatch(uTinyIntMbind, 10); - cursor.stmtBindSingleParamBatch(uSmallIntMbind, 11); - cursor.stmtBindSingleParamBatch(uIntMbind, 12); - cursor.stmtBindSingleParamBatch(uBigIntMbind, 13); - - cursor.stmtAddBatch(); - cursor.stmtExecute(); - cursor.stmtClose(); - - executeQuery(querySql); - executeUpdate(dropDB); -} -stmtSingleParaBatchSample(); -setTimeout(() => { - conn.close(); -}, 2000); diff --git a/src/connector/nodejs/examples/stmtUseResultSample.js b/src/connector/nodejs/examples/stmtUseResultSample.js deleted file mode 100755 index 21e2fbf378e763c1e6f26692f31b1c85010c86fb..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/stmtUseResultSample.js +++ /dev/null @@ -1,100 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect({ host: "localhost" }); -var cursor = conn.cursor(); - -function executeUpdate(updateSql) { - console.log(updateSql); - cursor.execute(updateSql); -} -function executeQuery(querySql) { - let query = cursor.query(querySql); - query.execute().then((result => { - console.log(querySql); - result.pretty(); - })); -} - -function stmtUseResultSample() { - let db = 'node_test_db'; - let table = 'stmt_use_result'; - let subTable = 's1_0'; - - let createDB = `create database if not exists ${db} keep 3650;`; - let dropDB = `drop database if exists ${db};`; - let useDB = `use ${db}`; - let createTable = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `jsonTag json` + - `);`; - let createSubTable = `create table if not exists ${subTable} using ${table} tags('{\"key1\":\"taosdata\",\"key2\":null,\"key3\":\"TDengine涛思数据\",\"key4\":3.2}')`; - let querySql = `select * from ${table} where i32>? and bnr = ? `; - let insertSql = `insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?);`; - - let mBinds = new taos.TaosMultiBindArr(14); - mBinds.multiBindTimestamp([1642435200000,1642435300000,1642435400000,1642435500000,1642435600000]); - mBinds.multiBindBool([true,false,true,undefined,null]); - mBinds.multiBindTinyInt([-127,3,127,null,undefined]); - mBinds.multiBindSmallInt([-256,0,256,null,undefined]); - mBinds.multiBindInt([-1299,0,1233,null,undefined]); - mBinds.multiBindBigInt([16424352000002222n,-16424354000001111n,0,null,undefined]); - mBinds.multiBindFloat([12.33,0,-3.1415,null,undefined]); - mBinds.multiBindDouble([3.141592653,0,-3.141592653,null,undefined]); - mBinds.multiBindBinary(['TDengine_Binary','','taosdata涛思数据',null,undefined]); - mBinds.multiBindNchar(['taos_data_nchar','taosdata涛思数据','',null,undefined]); - mBinds.multiBindUTinyInt([0,127, 254,null,undefined]); - mBinds.multiBindUSmallInt([0,256,512,null,undefined]); - mBinds.multiBindUInt([0,1233,4294967294,null,undefined]); - mBinds.multiBindUBigInt([16424352000002222n,36424354000001111n,0,null,undefined]); - - // executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(useDB); - executeUpdate(createTable); - executeUpdate(createSubTable); - - //stmt bind values - cursor.stmtInit(); - cursor.stmtPrepare(insertSql); - cursor.loadTableInfo([subTable]); - cursor.stmtSetTbname(subTable); - cursor.stmtBindParamBatch(mBinds.getMultiBindArr()); - cursor.stmtAddBatch(); - cursor.stmtExecute(); - cursor.stmtClose(); - - // stmt select with normal column. - let condition1 = new taos.TaosBind(2); - condition1.bindInt(0); - condition1.bindNchar('taosdata涛思数据'); - cursor.stmtInit(); - cursor.stmtPrepare(querySql); - cursor.stmtBindParam(condition1.getBind()); - cursor.stmtExecute(); - cursor.stmtUseResult(); - cursor.stmtClose(); - - cursor.fetchall(); - console.log(cursor.fields); - console.log(cursor.data); - - executeUpdate(dropDB); -} - -stmtUseResultSample(); -setTimeout(() => { - conn.close(); -}, 2000); \ No newline at end of file diff --git a/src/connector/nodejs/examples/taosBindParamSample.js b/src/connector/nodejs/examples/taosBindParamSample.js deleted file mode 100644 index cf8f0a263555844535916f91b1492afb36ef536e..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/taosBindParamSample.js +++ /dev/null @@ -1,82 +0,0 @@ -// const TaosBind = require('../nodetaos/taosBind'); -const taos = require('../tdengine'); -var conn = taos.connect({ host: "localhost" }); -var cursor = conn.cursor(); - -function executeUpdate(updateSql){ - console.log(updateSql); - cursor.execute(updateSql); -} -function executeQuery(querySql){ - - let query = cursor.query(querySql); - query.execute().then((result=>{ - console.log(querySql); - result.pretty(); - })); -} - -function stmtBindParamSample(){ - let db = 'node_test_db'; - let table = 'stmt_taos_bind_sample'; - - let createDB = `create database if not exists ${db} keep 3650;`; - let dropDB = `drop database if exists ${db};`; - let useDB = `use ${db}`; - let createTable = `create table if not exists ${table} `+ - `(ts timestamp,`+ - `nil int,`+ - `bl bool,`+ - `i8 tinyint,`+ - `i16 smallint,`+ - `i32 int,`+ - `i64 bigint,`+ - `f32 float,`+ - `d64 double,`+ - `bnr binary(20),`+ - `nchr nchar(20),`+ - `u8 tinyint unsigned,`+ - `u16 smallint unsigned,`+ - `u32 int unsigned,`+ - `u64 bigint unsigned);`; - let querySql = `select * from ${table};`; - let insertSql = `insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);` - - executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(useDB); - executeUpdate(createTable); - - let binds = new taos.TaosBind(15); - binds.bindTimestamp(1642435200000); - binds.bindNil(); - binds.bindBool(true); - binds.bindTinyInt(127); - binds.bindSmallInt(32767); - binds.bindInt(1234555); - binds.bindBigInt(-164243520000011111n); - binds.bindFloat(214.02); - binds.bindDouble(2.01); - binds.bindBinary('taosdata涛思数据'); - binds.bindNchar('TDengine数据'); - binds.bindUTinyInt(254); - binds.bindUSmallInt(65534); - binds.bindUInt(4294967294); - binds.bindUBigInt(164243520000011111n); - - cursor.stmtInit(); - cursor.stmtPrepare(insertSql); - cursor.stmtSetTbname(table); - cursor.bindParam(binds.getBind()); - cursor.addBatch(); - cursor.stmtExecute(); - cursor.stmtClose(); - - executeQuery(querySql); - executeUpdate(dropDB); -} - -stmtBindParamSample(); -setTimeout(()=>{ - conn.close(); -},2000); \ No newline at end of file diff --git a/src/connector/nodejs/examples/testJsonTag.js b/src/connector/nodejs/examples/testJsonTag.js deleted file mode 100644 index a922afb8e6b6614b208a6ba7cd82a8d00f983282..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/testJsonTag.js +++ /dev/null @@ -1,280 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect({ host: "127.0.0.1", user: "root", password: "taosdata", config: "/etc/taos", port: 10 }); -var c1 = conn.cursor(); - -function executeUpdate(sql) { - console.log(sql); - c1.execute(sql); -} -function executeQuery(sql, flag = "all") { - console.log(sql); - c1.execute(sql) - var data = c1.fetchall(); - if (flag == "metadata" || flag == "all") { - // Latest query's Field metadata is stored in cursor.fields - console.log(c1.fields); - } 2 - if (flag == "data" || flag == "all") { - // Latest query's result data is stored in cursor.data, also returned by fetchall. - console.log(c1.data); - } - console.log(""); -} - -function prettyQuery(sql) { - try { - c1.query(sql).execute().then(function (result) { - result.pretty(); - }); - } - catch (err) { - conn.close(); - throw err; - } -} - -function executeError(sql) { - console.log(sql); - try { - c1.execute(sql) - } catch (e) { - console.log(e.message); - console.log(""); - } -} - -executeUpdate("create database if not exists nodedb keep 36500;"); -executeUpdate("use nodedb;"); -console.log("# STEP 1 prepare data & validate json string"); -executeUpdate("create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json);"); -executeUpdate("insert into jsons1_1 using jsons1 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 1, false, 'json1', '涛思数据') (1591060608000, 23, true, '涛思数据', 'json')"); -executeUpdate("insert into jsons1_2 using jsons1 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060628000, 2, true, 'json2', 'sss')"); -executeUpdate("insert into jsons1_3 using jsons1 tags('{\"tag1\":false,\"tag2\":\"beijing\"}') values (1591060668000, 3, false, 'json3', 'efwe')"); -executeUpdate("insert into jsons1_4 using jsons1 tags('{\"tag1\":null,\"tag2\":\"shanghai\",\"tag3\":\"hello\"}') values (1591060728000, 4, true, 'json4', '323sd')"); -executeUpdate("insert into jsons1_5 using jsons1 tags('{\"tag1\":1.232, \"tag2\":null}') values(1591060928000, 1, false, '涛思数据', 'ewe')"); -executeUpdate("insert into jsons1_6 using jsons1 tags('{\"tag1\":11,\"tag2\":\"\",\"tag2\":null}') values(1591061628000, 11, false, '涛思数据','')"); -executeUpdate("insert into jsons1_7 using jsons1 tags('{\"tag1\":\"涛思数据\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '涛思数据', 'dws')"); - -console.log("## test duplicate key using the first one. elimate empty key"); -executeUpdate("CREATE TABLE if not exists jsons1_8 using jsons1 tags('{\"tag1\":null, \"tag1\":true, \"tag1\":45, \"1tag$\":2, \" \":90}')"); - -console.log("## test empty json string, save as jtag is NULL"); -executeUpdate("insert into jsons1_9 using jsons1 tags('\t') values (1591062328000, 24, NULL, '涛思数据', '2sdw')"); -executeUpdate("CREATE TABLE if not exists jsons1_10 using jsons1 tags('')"); -executeUpdate("CREATE TABLE if not exists jsons1_11 using jsons1 tags(' ')"); -executeUpdate("CREATE TABLE if not exists jsons1_12 using jsons1 tags('{}')"); -executeUpdate("CREATE TABLE if not exists jsons1_13 using jsons1 tags('null')"); - -console.log("## test invalidate json"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('\"efwewf\"')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('3333')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('33.33')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('false')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('[1,true]')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{222}')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"fe\"}')"); -executeQuery("select * from jsons1;", "data"); - -console.log("## test invalidate json key, key must can be printed assic char="); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":[1,true]}')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":{}}')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"。loc\":\"fff\"}')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\":\"fff\"}')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\t\":\"fff\"}')"); -executeError("CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"涛思数据\":\"fff\"}')"); - -console.log("# STEP 2 alter table json tag"); -executeError("ALTER STABLE jsons1 add tag tag2 nchar(20)"); -executeError("ALTER STABLE jsons1 drop tag jtag"); -executeError("ALTER TABLE jsons1_1 SET TAG jtag=4"); -executeUpdate("ALTER TABLE jsons1_1 SET TAG jtag='{\"tag1\":\"femail\",\"tag2\":35,\"tag3\":true}'") - -console.log("# STEP 3 query table"); -console.log("## test error syntax"); -executeError("select * from jsons1 where jtag->tag1='beijing'"); -executeError("select * from jsons1 where jtag->'location'"); -executeError("select * from jsons1 where jtag->''"); -executeError("select * from jsons1 where jtag->''=9"); -executeError("select -> from jsons1"); -executeError("select * from jsons1 where contains"); -executeError("select * from jsons1 where jtag->"); -executeError("select jtag->location from jsons1"); -executeError("select jtag contains location from jsons1"); -executeError("select * from jsons1 where jtag contains location"); -executeError("select * from jsons1 where jtag contains''"); -executeError("select * from jsons1 where jtag contains 'location'='beijing'"); - -console.log("## test select normal column"); -executeQuery("select dataint from jsons1"); - -console.log("## test select json tag"); -executeQuery("select * from jsons1", "data") -executeQuery("select jtag from jsons1", "data"); -executeQuery("select jtag from jsons1 where jtag is null", "data"); -executeQuery("select jtag from jsons1 where jtag is not null", "data"); -executeQuery("select jtag from jsons1_8", "data"); -executeQuery("select jtag from jsons1_1", "data"); - -console.log("## test jtag is NULL"); -executeQuery("select jtag from jsons1_9", "data"); - -console.log("## test select json tag->'key', value is string"); -executeQuery("select jtag->'tag1' from jsons1_1", "data"); -executeQuery("select jtag->'tag2' from jsons1_6", "data"); - -console.log("### test select json tag->'key', value is int"); -executeQuery("select jtag->'tag2' from jsons1_1", "data"); - -console.log("### test select json tag->'key', value is bool"); -executeQuery("select jtag->'tag3' from jsons1_1", "data"); - -console.log("### test select json tag->'key', value is null"); -executeQuery("select jtag->'tag1' from jsons1_4", "data"); - -console.log("### test select json tag->'key', value is double"); -executeQuery("select jtag->'tag1' from jsons1_5", "data"); - -console.log("### test select json tag->'key', key is not exist"); -executeQuery("select jtag->'tag10' from jsons1_4", "data"); -executeQuery("select jtag->'tag1' from jsons1", "data"); - -console.log("### test header name"); -executeQuery("select jtag->'tag1' from jsons1", "metadata"); - -console.log("## test where with json tag"); -executeError("select * from jsons1_1 where jtag is not null"); -executeError("select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'"); -executeError("select * from jsons1 where jtag->'tag1'={}"); - -console.log("### where json value is string"); -executeQuery("select * from jsons1 where jtag->'tag2'='beijing'", "data"); -executeQuery("select dataint,tbname,jtag->'tag1',jtag from jsons1 where jtag->'tag2'='beijing'"); -executeQuery("select * from jsons1 where jtag->'tag1'='beijing'", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'='涛思数据'", "data"); -executeQuery("select * from jsons1 where jtag->'tag2'>'beijing'", "data"); -executeQuery("select * from jsons1 where jtag->'tag2'>='beijing'", "data"); -executeQuery("select * from jsons1 where jtag->'tag2'<'beijing'", "data"); -executeQuery("select * from jsons1 where jtag->'tag2'<='beijing'", "data"); -executeQuery("select * from jsons1 where jtag->'tag2'!='beijing'", "data"); -executeQuery("select * from jsons1 where jtag->'tag2'=''", "data"); - -console.log("### where json value is int"); -executeQuery("select * from jsons1 where jtag->'tag1'=5", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'=10", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'<54", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'<=11", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'>4", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'>=5", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'!=5", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'!=55", "data"); - -console.log("### where json value is double"); -executeQuery("select * from jsons1 where jtag->'tag1'=1.232", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'<1.232", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'<=1.232", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'>1.23", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'>=1.232", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'!=1.232", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'!=3.232", "data"); -executeError("select * from jsons1 where jtag->'tag1'/0=3", "data"); -executeError("select * from jsons1 where jtag->'tag1'/5=1", "data"); - -console.log("### where json value is bool"); -executeQuery("select * from jsons1 where jtag->'tag1'=true", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'=false", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'!=false", "data"); -executeError("select * from jsons1 where jtag->'tag1'>false"); - -console.log("### where json value is null"); -executeQuery("select * from jsons1 where jtag->'tag1'=null"); //only json suport =null. This synatx will change later. - -console.log("### where json is null"); -executeQuery("select * from jsons1 where jtag is null", "data"); -executeQuery("select * from jsons1 where jtag is not null", "data"); - -console.log("### where json key is null"); -executeQuery("select * from jsons1 where jtag->'tag_no_exist'=3", "data") - -console.log("### where json value is not exist"); -executeQuery("select * from jsons1 where jtag->'tag1' is null", "data"); -executeQuery("select * from jsons1 where jtag->'tag4' is null", "data"); -executeQuery("select * from jsons1 where jtag->'tag3' is not null", "data") - -console.log("### test contains"); -executeQuery("select * from jsons1 where jtag contains 'tag1'", "data") -executeQuery("select * from jsons1 where jtag contains 'tag3'", "data") -executeQuery("select * from jsons1 where jtag contains 'tag_no_exist'", "data") - -console.log("### test json tag in where condition with and/or"); -executeQuery("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='beijing'", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'=false or jtag->'tag2'='beijing'", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35", "data"); -executeQuery("select * from jsons1 where jtag->'tag1' is not null and jtag contains 'tag3'", "data"); -executeQuery("select * from jsons1 where jtag->'tag1'='femail' and jtag contains 'tag3'", "data"); - -console.log("### test with tbname/normal column"); -executeQuery("select * from jsons1 where tbname = 'jsons1_1'", "data") -executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3'", "data") -executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=3", "data") -executeQuery("select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=23", "data") - -console.log("### test where condition like"); -executeQuery("select *,tbname from jsons1 where jtag->'tag2' like 'bei%'", "data"); -executeQuery("select *,tbname from jsons1 where jtag->'tag1' like 'fe%' and jtag->'tag2' is not null", "data"); - -console.log("### test where condition in no support in"); -executeError("select * from jsons1 where jtag->'tag1' in ('beijing')"); - -console.log("### test where condition match"); -executeQuery("select * from jsons1 where jtag->'tag1' match 'ma'", "data"); -executeQuery("select * from jsons1 where jtag->'tag1' match 'ma$'", "data"); -executeQuery("select * from jsons1 where jtag->'tag2' match 'jing$'", "data"); -executeQuery("select * from jsons1 where jtag->'tag1' match '收到'", "data"); - -console.log("### test distinct"); -executeUpdate("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"涛思数据\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '涛思数据', 'dws')", "data"); -executeQuery("select distinct jtag->'tag1' from jsons1", "data"); -executeQuery("select distinct jtag from jsons1", "data"); - -console.log("### test dumplicate key with normal colomn"); -executeUpdate("INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"涛思数据\"}') values(1591060828000, 4, false, 'jjsf', \"涛思数据\")"); -executeQuery("select *,tbname,jtag from jsons1 where jtag->'datastr' match '涛思' and datastr match 'js'", "data"); -executeQuery("select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14'", "data"); - -console.log("## test join"); -executeUpdate("create table if not exists jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)") -executeUpdate("insert into jsons2_1 using jsons2 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 2, false, 'json2', '你是2')") -executeUpdate("insert into jsons2_2 using jsons2 tags('{\"tag1\":5,\"tag2\":null}') values (1591060628000, 2, true, 'json2', 'sss')") -executeUpdate("create table if not exists jsons3(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)") -executeUpdate("insert into jsons3_1 using jsons3 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 3, false, 'json3', '你是3')") -executeUpdate("insert into jsons3_2 using jsons3 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060638000, 2, true, 'json3', 'sss')") - -executeQuery("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'", "data"); -executeQuery("select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'", "metadata"); - -console.log("## test group by & order by json tag"); - -executeQuery("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc", "data"); -executeQuery("select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc", "data"); - -console.log("## test stddev with group by json tag"); -executeQuery("select stddev(dataint) from jsons1 group by jtag->'tag1'", "data"); -executeQuery("select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'", "metadata"); - -console.log("## test top/bottom with group by json tag"); -executeQuery("select top(dataint,100) from jsons1 group by jtag->'tag1'", "metadata"); - -console.log("## subquery with json tag"); -executeQuery("select * from (select jtag, dataint from jsons1)", "metadata"); -executeQuery("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)", "metadata"); -executeQuery("select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)", "metada"); -executeQuery("select ts,tbname,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts)", "data") - - -executeUpdate("drop database nodedb;"); - - -setTimeout(() => conn.close(), 2000); diff --git a/src/connector/nodejs/examples/testMicroseconds.js b/src/connector/nodejs/examples/testMicroseconds.js deleted file mode 100644 index cc65b3d919f92b3b4d7e0e216c6c8ac64a294d7f..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/testMicroseconds.js +++ /dev/null @@ -1,49 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect(); -var c1 = conn.cursor(); -let stime = new Date(); -let interval = 1000; - -function convertDateToTS(date) { - let tsArr = date.toISOString().split("T") - return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length - 1) + "\""; -} -function R(l, r) { - return Math.random() * (r - l) - r; -} -function randomBool() { - if (Math.random() < 0.5) { - return true; - } - return false; -} - -// Initialize -//c1.execute('drop database td_connector_test;'); -const dbname = 'nodejs_test_us'; -c1.execute('create database if not exists ' + dbname + ' precision "us"'); -c1.execute('use ' + dbname) -c1.execute('create table if not exists tstest (ts timestamp, _int int);'); -c1.execute('insert into tstest values(1625801548423914, 0)'); -// Select -console.log('select * from tstest'); -c1.execute('select * from tstest'); - -var d = c1.fetchall(); -console.log(c1.fields); -let ts = d[0][0]; -console.log(ts); - -if (ts.taosTimestamp() != 1625801548423914) { - throw "microseconds not match!"; -} -if (ts.getMicroseconds() % 1000 !== 914) { - throw "micronsecond precision error"; -} -setTimeout(function () { - c1.query('drop database nodejs_us_test;'); -}, 200); - -setTimeout(function () { - conn.close(); -}, 2000); diff --git a/src/connector/nodejs/examples/testNanoseconds.js b/src/connector/nodejs/examples/testNanoseconds.js deleted file mode 100644 index c3089aab3eaa4621b36297a70f2698dd08ed5988..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/testNanoseconds.js +++ /dev/null @@ -1,48 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect(); -var c1 = conn.cursor(); -let stime = new Date(); -let interval = 1000; -function convertDateToTS(date) { - let tsArr = date.toISOString().split("T") - return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length - 1) + "\""; -} -function R(l, r) { - return Math.random() * (r - l) - r; -} -function randomBool() { - if (Math.random() < 0.5) { - return true; - } - return false; -} - -// Initialize -//c1.execute('drop database td_connector_test;'); -const dbname = 'nodejs_test_ns'; -c1.execute('create database if not exists ' + dbname + ' precision "ns"'); -c1.execute('use ' + dbname) -c1.execute('create table if not exists tstest (ts timestamp, _int int);'); -c1.execute('insert into tstest values(1625801548423914405, 0)'); -// Select -console.log('select * from tstest'); -c1.execute('select * from tstest'); - -var d = c1.fetchall(); -console.log(c1.fields); -let ts = d[0][0]; -console.log(ts); - -if (ts.taosTimestamp() != 1625801548423914405) { - throw "nanosecond not match!"; -} -if (ts.getNanoseconds() % 1000000 !== 914405) { - throw "nanosecond precision error"; -} -setTimeout(function () { - c1.query('drop database nodejs_ns_test;'); -}, 200); - -setTimeout(function () { - conn.close(); -}, 2000); diff --git a/src/connector/nodejs/examples/testSchemalessInsert.js b/src/connector/nodejs/examples/testSchemalessInsert.js deleted file mode 100644 index 16998425ecda4226e56e5c2a9e49e83ba34bc34a..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/testSchemalessInsert.js +++ /dev/null @@ -1,84 +0,0 @@ -const _ = require('lodash'); -const taos = require('../tdengine'); - -var conn = taos.connect({ host: "127.0.0.1", user: "root", password: "taosdata", config: "/etc/taos", port: 10 }); -var c1 = conn.cursor(); -executeUpdate("drop database if exists nodedb;"); -executeUpdate("create database if not exists nodedb ;"); -executeUpdate("use nodedb;"); - -let tbname1 = "line_protocol_arr"; -let tbname2 = "json_protocol_arr"; -let tbname3 = "json_protocol_str"; -let tbname4 = "line_protocol_str"; - - -let line1 = [tbname1 + ",t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", -tbname1 + ",t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000" -]; -let line2 = ["{" - + "\"metric\": \"" + tbname2 + "\"," - + "\"timestamp\": 1626006833," - + "\"value\": 10," - + "\"tags\": {" - + " \"t1\": true," - + "\"t2\": false," - + "\"t3\": 10," - + "\"t4\": \"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>\"" - + "}" - + "}" -]; - -let line3 = "{" - + "\"metric\": \"" + tbname3 + "\"," - + "\"timestamp\": 1626006833000," - + "\"value\": 10," - + "\"tags\": {" - + " \"t1\": true," - + "\"t2\": false," - + "\"t3\": 10," - + "\"t4\": \"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>\"" - + "}" - + "}"; - -let line4 = tbname4 + ",t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639"; - - -try { - - c1.schemalessInsert(line1, taos.SCHEMALESS_PROTOCOL.TSDB_SML_LINE_PROTOCOL, taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_NANO_SECONDS); - testSchemaless(tbname1, line1.length); - - c1.schemalessInsert(line2, taos.SCHEMALESS_PROTOCOL.TSDB_SML_JSON_PROTOCOL, taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_SECONDS); - testSchemaless(tbname2, line2.length); - - c1.schemalessInsert(line3, taos.SCHEMALESS_PROTOCOL.TSDB_SML_JSON_PROTOCOL, taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_MILLI_SECONDS); - testSchemaless(tbname3, 1); - - c1.schemalessInsert(line4, taos.SCHEMALESS_PROTOCOL.TSDB_SML_LINE_PROTOCOL, taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_MILLI_SECONDS); - testSchemaless(tbname4, 1); - -} catch (err) { - console.log(err) -} -function executeUpdate(sql) { - console.log(sql); - c1.execute(sql); -} - -function testSchemaless(tbname, numLines) { - let sql = "select count(*) from " + tbname + ";"; - executeUpdate(sql); - let affectRows = _.first(c1.fetchall()); - if (affectRows != numLines) { - console.log(1); - console.log(line2); - throw "protocol " + tbname + " schemaless insert success,but can't select as expect." - } - else { - console.log("protocol " + tbname + " schemaless insert success, can select as expect.") - } - console.log("===================") -} - -setTimeout(() => conn.close(), 2000); diff --git a/src/connector/nodejs/examples/testSubscribe.js b/src/connector/nodejs/examples/testSubscribe.js deleted file mode 100644 index 30fb3f425683f0113873534f2b67255db811edcc..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/testSubscribe.js +++ /dev/null @@ -1,16 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:10}); -var c1 = conn.cursor(); -let stime = new Date(); -let interval = 1000; -c1.execute('use td_connector_test'); -let sub = c1.subscribe({ - restart: true, - sql: "select AVG(_int) from td_connector_test.all_Types;", - topic: 'all_Types', - interval: 1000 -}); - -c1.consumeData(sub, (data, fields) => { - console.log(data); -}); \ No newline at end of file diff --git a/src/connector/nodejs/examples/testUnsignedType.js b/src/connector/nodejs/examples/testUnsignedType.js deleted file mode 100644 index 3f0b0c20459959fe7ea863757220ea77fe377694..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/testUnsignedType.js +++ /dev/null @@ -1,40 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect({ host: "127.0.0.1", user: "root", password: "taosdata", config: "/etc/taos", port: 10 }); -var c1 = conn.cursor(); -function executeUpdate(sql) { - console.log(sql); - c1.execute(sql); -} -function executeQuery(sql) { - c1.execute(sql) - var data = c1.fetchall(); - // Latest query's Field metadata is stored in cursor.fields - console.log(c1.fields); - // Latest query's result data is stored in cursor.data, also returned by fetchall. - console.log(c1.data); -} - -function prettyQuery(sql){ - try { - c1.query(sql).execute().then(function(result){ - result.pretty(); - }); - } - catch (err) { - conn.close(); - throw err; - } -} - -executeUpdate("create database nodedb;"); -executeUpdate("use nodedb;"); -executeUpdate("create table unsigntest(ts timestamp,ut tinyint unsigned,us smallint unsigned,ui int unsigned,ub bigint unsigned,bi bigint);"); -executeUpdate("insert into unsigntest values (now, 254,65534,4294967294,18446744073709551614,9223372036854775807);"); -executeUpdate("insert into unsigntest values (now, 0,0,0,0,-9223372036854775807);"); -executeQuery("select * from unsigntest;"); -prettyQuery("select * from unsigntest;"); -executeUpdate("drop database nodedb;"); - - -setTimeout(()=>conn.close(),2000); - diff --git a/src/connector/nodejs/examples/testnchar.js b/src/connector/nodejs/examples/testnchar.js deleted file mode 100644 index 68fad89c22894ec358d55e9c03746fbd86ce0c99..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/testnchar.js +++ /dev/null @@ -1,33 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect({ host: "localhost" }); -var c1 = conn.cursor(); - - -function checkData(data, row, col, expect) { - let checkdata = data[row][col]; - if (checkdata == expect) { - // console.log('check pass') - } - else { - console.log('check failed, expect ' + expect + ', but is ' + checkdata) - } -} - -c1.execute('drop database if exists testnodejsnchar') -c1.execute('create database testnodejsnchar') -c1.execute('use testnodejsnchar'); -c1.execute('create table tb (ts timestamp, value float, text binary(200))') -c1.execute("insert into tb values('2021-06-10 00:00:00', 24.7, '中文10000000000000000000000');") - -c1.execute('insert into tb values(1623254400150, 24.7, NULL);') -c1.execute('import into tb values(1623254400300, 24.7, "中文3中文10000000000000000000000中文10000000000000000000000中文10000000000000000000000中文10000000000000000000000");') -sql = 'select * from tb;' - -console.log('*******************************************') - -c1.execute(sql); -data = c1.fetchall(); -console.log(data) -//check data about insert data -checkData(data, 0, 2, '中文10000000000000000000000') -checkData(data, 1, 2, null) -checkData(data, 2, 2, '中文3中文10000000000000000000000中文10000000000000000000000中文10000000000000000000000中文10000000000000000000000') \ No newline at end of file diff --git a/src/connector/nodejs/examples/tset.js b/src/connector/nodejs/examples/tset.js deleted file mode 100644 index 06adf912a57bfa369b9567d0b5b3a1c8fb105ce8..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/examples/tset.js +++ /dev/null @@ -1,170 +0,0 @@ -const taos = require('../tdengine'); -var conn = taos.connect(); -var c1 = conn.cursor(); -let stime = new Date(); -let interval = 1000; - -function convertDateToTS(date) { - let tsArr = date.toISOString().split("T") - return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length-1) + "\""; -} -function R(l,r) { - return Math.random() * (r - l) - r; -} -function randomBool() { - if (Math.random() < 0.5) { - return true; - } - return false; -} - -// Initialize -//c1.execute('drop database td_connector_test;'); -c1.execute('create database if not exists td_connector_test;'); -c1.execute('use td_connector_test;') -c1.execute('create table if not exists all_types (ts timestamp, _int int, _bigint bigint, _float float, _double double, _binary binary(40), _smallint smallint, _tinyint tinyint, _bool bool, _nchar nchar(40));'); -c1.execute('create table if not exists stabletest (ts timestamp, v1 int, v2 int, v3 int, v4 double) tags (id int, location binary(20));') - -// Shell Test : The following uses the cursor to imitate the taos shell - -// Insert -for (let i = 0; i < 10000; i++) { - let insertData = ["now+" + i + "s", // Timestamp - parseInt( R(-Math.pow(2,31) + 1 , Math.pow(2,31) - 1) ), // Int - parseInt( R(-Math.pow(2,31) + 1 , Math.pow(2,31) - 1) ), // BigInt - parseFloat( R(-3.4E38, 3.4E38) ), // Float - parseFloat( R(-1.7E30, 1.7E30) ), // Double - "\"Long Binary\"", // Binary - parseInt( R(-32767, 32767) ), // Small Int - parseInt( R(-127, 127) ), // Tiny Int - randomBool(), - "\"Nchars\""]; // Bool - c1.execute('insert into td_connector_test.all_types values(' + insertData.join(',') + ' );', {quiet:true}); - if (i % 1000 == 0) { - console.log("Insert # " , i); - } -} - -// Select -console.log('select * from td_connector_test.all_types limit 3 offset 100;'); -c1.execute('select * from td_connector_test.all_types limit 2 offset 100;'); - -var d = c1.fetchall(); -console.log(c1.fields); -console.log(d); - -// Functions -console.log('select count(*), avg(_int), sum(_float), max(_bigint), min(_double) from td_connector_test.all_types;') -c1.execute('select count(*), avg(_int), sum(_float), max(_bigint), min(_double) from td_connector_test.all_types;'); -var d = c1.fetchall(); -console.log(c1.fields); -console.log(d); - -// Immediate Execution like the Shell - -c1.query('select count(*), stddev(_double), min(_tinyint) from all_types where _tinyint > 50 and _int < 0;', true).then(function(result){ - result.pretty(); -}) - -c1.query('select _tinyint, _bool from all_types where _tinyint > 50 and _int < 0 limit 50;', true).then(function(result){ - result.pretty(); -}) - -c1.query('select stddev(_double), stddev(_bigint), stddev(_float) from all_types;', true).then(function(result){ - result.pretty(); -}) -c1.query('select stddev(_double), stddev(_bigint), stddev(_float) from all_types interval(1m) limit 100;', true).then(function(result){ - result.pretty(); -}) - -// Binding arguments, and then using promise -var q = c1.query('select _nchar from td_connector_test.all_types where ts >= ? and _int > ? limit 100 offset 40;').bind(new Date(1231), 100) -console.log(q.query); -q.execute().then(function(r) { - r.pretty(); -}); - - -// test query null value -c1.execute("create table if not exists td_connector_test.weather(ts timestamp, temperature float, humidity int) tags(location nchar(64))"); -c1.execute("insert into t1 using weather tags('北京') values(now, 11.11, 11)"); -c1.execute("insert into t1(ts, temperature) values(now, 22.22)"); -c1.execute("insert into t1(ts, humidity) values(now, 33)"); -c1.query('select * from td_connector_test.t1', true).then(function (result) { - result.pretty(); -}); - -var q = c1.query('select * from td_connector_test.weather'); -console.log(q.query); -q.execute().then(function(r) { - r.pretty(); -}); - -function sleep(sleepTime) { - for(var start = +new Date; +new Date - start <= sleepTime; ) { } -} - -sleep(10000); - -// Raw Async Testing (Callbacks, not promises) -function cb2(param, result, rowCount, rd) { - console.log('CB2 Callbacked!'); - console.log("RES *", result); - console.log("Async fetched", rowCount, " rows"); - console.log("Passed Param: ", param); - console.log("Fields ", rd.fields); - console.log("Data ", rd.data); -} -function cb1(param,result,code) { - console.log('CB1 Callbacked!'); - console.log("RES * ", result); - console.log("Status: ", code); - console.log("Passed Param ", param); - c1.fetchall_a(result, cb2, param); -} - -c1.execute_a("describe td_connector_test.all_types;", cb1, {myparam:3.141}); - -function cb4(param, result, rowCount, rd) { - console.log('CB4 Callbacked!'); - console.log("RES *", result); - console.log("Async fetched", rowCount, "rows"); - console.log("Passed Param: ", param); - console.log("Fields", rd.fields); - console.log("Data", rd.data); -} -// Without directly calling fetchall_a -var thisRes; -function cb3(param,result,code) { - console.log('CB3 Callbacked!'); - console.log("RES *", result); - console.log("Status:", code); - console.log("Passed Param", param); - thisRes = result; -} -//Test calling execute and fetchall seperately and not through callbacks -var param = c1.execute_a("describe td_connector_test.all_types;", cb3, {e:2.718}); -console.log("Passed Param outside of callback: ", param); -console.log(param); -setTimeout(function(){ - c1.fetchall_a(thisRes, cb4, param); -},100); - - -// Async through promises -var aq = c1.query('select count(*) from td_connector_test.all_types;',false); -aq.execute_a().then(function(data) { - data.pretty(); -}); - -c1.query('describe td_connector_test.stabletest').execute_a().then(function(r){ - r.pretty() -}); - -setTimeout(function(){ - c1.query('drop database td_connector_test;'); -},200); - -setTimeout(function(){ - conn.close(); -},2000); diff --git a/src/connector/nodejs/jest.config.js b/src/connector/nodejs/jest.config.js deleted file mode 100644 index c6ea66f0f08e952a02c76383c37a1ef461d34714..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/jest.config.js +++ /dev/null @@ -1,197 +0,0 @@ -/* - * For a detailed explanation regarding each configuration property, visit: - * https://jestjs.io/docs/configuration - */ - -module.exports = { - // All imported modules in your tests should be mocked automatically - // automock: false, - - // Stop running tests after `n` failures - // bail: 0, - - // The directory where Jest should store its cached dependency information - // cacheDirectory: "/tmp/jest_rt", - - // Automatically clear mock calls, instances and results before every test - // clearMocks: true, - - // Indicates whether the coverage information should be collected while executing the test - // collectCoverage: true, - - // An array of glob patterns indicating a set of files for which coverage information should be collected - // collectCoverageFrom: undefined, - - // The directory where Jest should output its coverage files - // coverageDirectory: "coverage", - - // An array of regexp pattern strings used to skip coverage collection - // coveragePathIgnorePatterns: [ - // "/node_modules/" - // ], - - // Indicates which provider should be used to instrument code for coverage - // coverageProvider: "v8", - - // A list of reporter names that Jest uses when writing coverage reports - // coverageReporters: [ - // "json", - // "text", - // "lcov", - // "clover" - // ], - - // An object that configures minimum threshold enforcement for coverage results - // coverageThreshold: undefined, - - // A path to a custom dependency extractor - // dependencyExtractor: undefined, - - // Make calling deprecated APIs throw helpful error messages - // errorOnDeprecated: false, - - // Force coverage collection from ignored files using an array of glob patterns - // forceCoverageMatch: [], - - // A path to a module which exports an async function that is triggered once before all test suites - // globalSetup: undefined, - - // A path to a module which exports an async function that is triggered once after all test suites - // globalTeardown: undefined, - - // A set of global variables that need to be available in all test environments - // globals: {}, - - // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. - // maxWorkers: "50%", - - // An array of directory names to be searched recursively up from the requiring module's location - // moduleDirectories: [ - // "node_modules" - // ], - - // An array of file extensions your modules use - // moduleFileExtensions: [ - // "js", - // "jsx", - // "ts", - // "tsx", - // "json", - // "node" - // ], - - // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module - // moduleNameMapper: {}, - - // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader - // modulePathIgnorePatterns: [], - - // Activates notifications for test results - // notify: false, - - // An enum that specifies notification mode. Requires { notify: true } - // notifyMode: "failure-change", - - // A preset that is used as a base for Jest's configuration - // preset: undefined, - - // Run tests from one or more projects - // projects: undefined, - - // Use this configuration option to add custom reporters to Jest - // reporters: undefined, - - // Automatically reset mock state before every test - // resetMocks: false, - - // Reset the module registry before running each individual test - // resetModules: false, - - // A path to a custom resolver - // resolver: undefined, - - // Automatically restore mock state and implementation before every test - // restoreMocks: false, - - // The root directory that Jest should scan for tests and modules within - // rootDir: undefined, - - // A list of paths to directories that Jest should use to search for files in - // roots: [ - // "" - // ], - - // Allows you to use a custom runner instead of Jest's default test runner - // runner: "jest-runner", - - // The paths to modules that run some code to configure or set up the testing environment before each test - // setupFiles: [], - - // A list of paths to modules that run some code to configure or set up the testing framework before each test - // setupFilesAfterEnv: [], - - // The number of seconds after which a test is considered as slow and reported as such in the results. - // slowTestThreshold: 5, - - // A list of paths to snapshot serializer modules Jest should use for snapshot testing - // snapshotSerializers: [], - - // The test environment that will be used for testing - // testEnvironment: "jest-environment-node", - - // Options that will be passed to the testEnvironment - // testEnvironmentOptions: {}, - - // Adds a location field to test results - // testLocationInResults: false, - - // The glob patterns Jest uses to detect test files - // testMatch: [ - // "**/__tests__/**/*.[jt]s?(x)", - // "**/?(*.)+(spec|test).[tj]s?(x)" - // ], - testMatch: [ - "**/test/cases/*.[jt]s?(x)" - ], - - // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped - // testPathIgnorePatterns: [ - // "/node_modules/" - // ], - - // The regexp pattern or array of patterns that Jest uses to detect test files - // testRegex: [], - - // This option allows the use of a custom results processor - // testResultsProcessor: undefined, - - // This option allows use of a custom test runner - // testRunner: "jest-circus/runner", - - // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href - // testURL: "http://localhost", - - // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" - // timers: "real", - - // A map from regular expressions to paths to transformers - // transform: undefined, - - // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation - // transformIgnorePatterns: [ - // "/node_modules/", - // "\\.pnp\\.[^\\/]+$" - // ], - - // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them - // unmockedModulePathPatterns: undefined, - - // Indicates whether each individual test should be reported during the run - // verbose: undefined, - - // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode - // watchPathIgnorePatterns: [], - - // Whether to use watchman for file crawling - // watchman: true, -}; diff --git a/src/connector/nodejs/nodetaos/cinterface.js b/src/connector/nodejs/nodetaos/cinterface.js deleted file mode 100644 index 0a81a0c79b21b2c2869e8e747df76e673c65b2eb..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/cinterface.js +++ /dev/null @@ -1,965 +0,0 @@ -/** - * C Interface with TDengine Module - * @module CTaosInterface - */ - -const ref = require('ref-napi'); -const os = require('os'); -const ffi = require('ffi-napi'); -const ArrayType = require('ref-array-di')(ref); -const Struct = require('ref-struct-di')(ref); -const FieldTypes = require('./constants'); -const errors = require('./error'); -const _ = require('lodash') -const TaosObjects = require('./taosobjects'); - -module.exports = CTaosInterface; -const TAOSFIELD = { - NAME_LENGTH: 65, - TYPE_OFFSET: 65, - BYTES_OFFSET: 66, - STRUCT_SIZE: 68, -} - -function convertTimestamp(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let time = data.readInt64LE(currOffset); - currOffset += nbytes; - res.push(new TaosObjects.TaosTimestamp(time, precision)); - } - return res; -} - -function convertBool(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = new Array(data.length); - for (let i = 0; i < data.length; i++) { - if (data[i] == 0) { - res[i] = false; - } - else if (data[i] == 1) { - res[i] = true; - } - else if (data[i] == FieldTypes.C_BOOL_NULL) { - res[i] = null; - } - } - return res; -} - -function convertTinyint(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = data.readIntLE(currOffset, 1); - res.push(d == FieldTypes.C_TINYINT_NULL ? null : d); - currOffset += nbytes; - } - return res; -} - -function convertTinyintUnsigned(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = data.readUIntLE(currOffset, 1); - res.push(d == FieldTypes.C_TINYINT_UNSIGNED_NULL ? null : d); - currOffset += nbytes; - } - return res; -} - -function convertSmallint(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = data.readIntLE(currOffset, 2); - res.push(d == FieldTypes.C_SMALLINT_NULL ? null : d); - currOffset += nbytes; - } - return res; -} - -function convertSmallintUnsigned(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = data.readUIntLE(currOffset, 2); - res.push(d == FieldTypes.C_SMALLINT_UNSIGNED_NULL ? null : d); - currOffset += nbytes; - } - return res; -} - -function convertInt(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = data.readInt32LE(currOffset); - res.push(d == FieldTypes.C_INT_NULL ? null : d); - currOffset += nbytes; - } - return res; -} - -function convertIntUnsigned(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = data.readUInt32LE(currOffset); - res.push(d == FieldTypes.C_INT_UNSIGNED_NULL ? null : d); - currOffset += nbytes; - } - return res; -} - -function convertBigint(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = data.readInt64LE(currOffset); - res.push(d == FieldTypes.C_BIGINT_NULL ? null : BigInt(d)); - currOffset += nbytes; - } - return res; -} - -function convertBigintUnsigned(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = data.readUInt64LE(currOffset); - res.push(d == FieldTypes.C_BIGINT_UNSIGNED_NULL ? null : BigInt(d)); - currOffset += nbytes; - } - return res; -} - -function convertFloat(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = parseFloat(data.readFloatLE(currOffset).toFixed(5)); - res.push(isNaN(d) ? null : d); - currOffset += nbytes; - } - return res; -} - -function convertDouble(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - let currOffset = 0; - while (currOffset < data.length) { - let d = parseFloat(data.readDoubleLE(currOffset).toFixed(16)); - res.push(isNaN(d) ? null : d); - currOffset += nbytes; - } - return res; -} - -function convertBinary(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - - let currOffset = 0; - while (currOffset < data.length) { - let len = data.readIntLE(currOffset, 2); - let dataEntry = data.slice(currOffset + 2, currOffset + len + 2); //one entry in a row under a column; - if (dataEntry[0] == 255) { - res.push(null) - } else { - res.push(dataEntry.toString("utf-8")); - } - currOffset += nbytes; - } - return res; -} - -function convertNchar(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - - let currOffset = 0; - while (currOffset < data.length) { - let len = data.readIntLE(currOffset, 2); - let dataEntry = data.slice(currOffset + 2, currOffset + len + 2); //one entry in a row under a column; - if (dataEntry[0] == 255 && dataEntry[1] == 255) { - res.push(null) - } else { - res.push(dataEntry.toString("utf-8")); - } - currOffset += nbytes; - } - return res; -} - -function convertJsonTag(data, num_of_rows, nbytes = 0, offset = 0, precision = 0) { - data = ref.reinterpret(data.deref(), nbytes * num_of_rows, offset); - let res = []; - - let currOffset = 0; - while (currOffset < data.length) { - let len = data.readIntLE(currOffset, 2); - let dataEntry = data.slice(currOffset + 2, currOffset + len + 2); //one entry in a row under a column; - if (dataEntry[0] == 255 && dataEntry[1] == 255) { - res.push(null) - } else { - res.push(dataEntry.toString("utf-8")); - } - currOffset += nbytes; - } - return res; -} - -// Object with all the relevant converters from pblock data to javascript readable data -let convertFunctions = { - [FieldTypes.C_BOOL]: convertBool, - [FieldTypes.C_TINYINT]: convertTinyint, - [FieldTypes.C_SMALLINT]: convertSmallint, - [FieldTypes.C_INT]: convertInt, - [FieldTypes.C_BIGINT]: convertBigint, - [FieldTypes.C_FLOAT]: convertFloat, - [FieldTypes.C_DOUBLE]: convertDouble, - [FieldTypes.C_BINARY]: convertBinary, - [FieldTypes.C_TIMESTAMP]: convertTimestamp, - [FieldTypes.C_NCHAR]: convertNchar, - [FieldTypes.C_TINYINT_UNSIGNED]: convertTinyintUnsigned, - [FieldTypes.C_SMALLINT_UNSIGNED]: convertSmallintUnsigned, - [FieldTypes.C_INT_UNSIGNED]: convertIntUnsigned, - [FieldTypes.C_BIGINT_UNSIGNED]: convertBigintUnsigned, - [FieldTypes.C_JSON_TAG]: convertJsonTag, -} - -// Define TaosField structure -var char_arr = ArrayType(ref.types.char); -var TaosField = Struct({ - 'name': char_arr, -}); -TaosField.fields.name.type.size = 65; -TaosField.defineProperty('type', ref.types.uint8); -TaosField.defineProperty('bytes', ref.types.int16); - -//define schemaless line array -var smlLine = ArrayType(ref.coerceType('char *')) - -/** - * - * @param {Object} config - Configuration options for the interface - * @return {CTaosInterface} - * @class CTaosInterface - * @classdesc The CTaosInterface is the interface through which Node.JS communicates data back and forth with TDengine. It is not advised to - * access this class directly and use it unless you understand what these functions do. - */ -function CTaosInterface(config = null, pass = false) { - ref.types.char_ptr = ref.refType(ref.types.char); - ref.types.void_ptr = ref.refType(ref.types.void); - ref.types.void_ptr2 = ref.refType(ref.types.void_ptr); - /*Declare a bunch of functions first*/ - /* Note, pointers to TAOS_RES, TAOS, are ref.types.void_ptr. The connection._conn buffer is supplied for pointers to TAOS * */ - if ('win32' == os.platform()) { - taoslibname = 'taos'; - } else { - taoslibname = 'libtaos'; - } - this.libtaos = ffi.Library(taoslibname, { - 'taos_options': [ref.types.int, [ref.types.int, ref.types.void_ptr]], - 'taos_init': [ref.types.void, []], - //TAOS *taos_connect(char *ip, char *user, char *pass, char *db, int port) - 'taos_connect': [ref.types.void_ptr, [ref.types.char_ptr, ref.types.char_ptr, ref.types.char_ptr, ref.types.char_ptr, ref.types.int]], - //void taos_close(TAOS *taos) - 'taos_close': [ref.types.void, [ref.types.void_ptr]], - //int *taos_fetch_lengths(TAOS_RES *res); - 'taos_fetch_lengths': [ref.types.void_ptr, [ref.types.void_ptr]], - //int taos_query(TAOS *taos, char *sqlstr) - 'taos_query': [ref.types.void_ptr, [ref.types.void_ptr, ref.types.char_ptr]], - //int taos_affected_rows(TAOS_RES *res) - 'taos_affected_rows': [ref.types.int, [ref.types.void_ptr]], - //int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) - 'taos_fetch_block': [ref.types.int, [ref.types.void_ptr, ref.types.void_ptr]], - //int taos_num_fields(TAOS_RES *res); - 'taos_num_fields': [ref.types.int, [ref.types.void_ptr]], - //TAOS_ROW taos_fetch_row(TAOS_RES *res) - //TAOS_ROW is void **, but we set the return type as a reference instead to get the row - 'taos_fetch_row': [ref.refType(ref.types.void_ptr2), [ref.types.void_ptr]], - 'taos_print_row': [ref.types.int, [ref.types.char_ptr, ref.types.void_ptr, ref.types.void_ptr, ref.types.int]], - //int taos_result_precision(TAOS_RES *res) - 'taos_result_precision': [ref.types.int, [ref.types.void_ptr]], - //void taos_free_result(TAOS_RES *res) - 'taos_free_result': [ref.types.void, [ref.types.void_ptr]], - //int taos_field_count(TAOS *taos) - 'taos_field_count': [ref.types.int, [ref.types.void_ptr]], - //TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) - 'taos_fetch_fields': [ref.refType(TaosField), [ref.types.void_ptr]], - //int taos_errno(TAOS *taos) - 'taos_errno': [ref.types.int, [ref.types.void_ptr]], - //char *taos_errstr(TAOS *taos) - 'taos_errstr': [ref.types.char_ptr, [ref.types.void_ptr]], - //void taos_stop_query(TAOS_RES *res); - 'taos_stop_query': [ref.types.void, [ref.types.void_ptr]], - //char *taos_get_server_info(TAOS *taos); - 'taos_get_server_info': [ref.types.char_ptr, [ref.types.void_ptr]], - //char *taos_get_client_info(); - 'taos_get_client_info': [ref.types.char_ptr, []], - - // ASYNC - // void taos_query_a(TAOS *taos, char *sqlstr, void (*fp)(void *, TAOS_RES *, int), void *param) - 'taos_query_a': [ref.types.void, [ref.types.void_ptr, ref.types.char_ptr, ref.types.void_ptr, ref.types.void_ptr]], - // void taos_fetch_rows_a(TAOS_RES *res, void (*fp)(void *param, TAOS_RES *, int numOfRows), void *param); - 'taos_fetch_rows_a': [ref.types.void, [ref.types.void_ptr, ref.types.void_ptr, ref.types.void_ptr]], - - // Subscription - //TAOS_SUB *taos_subscribe(TAOS* taos, int restart, const char* topic, const char *sql, TAOS_SUBSCRIBE_CALLBACK fp, void *param, int interval) - 'taos_subscribe': [ref.types.void_ptr, [ref.types.void_ptr, ref.types.int, ref.types.char_ptr, ref.types.char_ptr, ref.types.void_ptr, ref.types.void_ptr, ref.types.int]], - // TAOS_RES *taos_consume(TAOS_SUB *tsub) - 'taos_consume': [ref.types.void_ptr, [ref.types.void_ptr]], - //void taos_unsubscribe(TAOS_SUB *tsub); - 'taos_unsubscribe': [ref.types.void, [ref.types.void_ptr]], - - // Continuous Query - //TAOS_STREAM *taos_open_stream(TAOS *taos, char *sqlstr, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), - // int64_t stime, void *param, void (*callback)(void *)); - 'taos_open_stream': [ref.types.void_ptr, [ref.types.void_ptr, ref.types.char_ptr, ref.types.void_ptr, ref.types.int64, ref.types.void_ptr, ref.types.void_ptr]], - //void taos_close_stream(TAOS_STREAM *tstr); - 'taos_close_stream': [ref.types.void, [ref.types.void_ptr]], - - //Schemaless insert - //TAOS_RES* taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol,int precision) - // 'taos_schemaless_insert': [ref.types.void_ptr, [ref.types.void_ptr, ref.types.char_ptr, ref.types.int, ref.types.int, ref.types.int]] - 'taos_schemaless_insert': [ref.types.void_ptr, [ref.types.void_ptr, smlLine, 'int', 'int', 'int']] - - //stmt APIs - // TAOS_STMT* taos_stmt_init(TAOS *taos) - , 'taos_stmt_init': [ref.types.void_ptr, [ref.types.void_ptr]] - - // int taos_stmt_prepare(TAOS_STMT *stmt, const char *sql, unsigned long length) - , 'taos_stmt_prepare': [ref.types.int, [ref.types.void_ptr, ref.types.char_ptr, ref.types.ulong]] - - // int taos_stmt_set_tbname(TAOS_STMT* stmt, const char* name) - , 'taos_stmt_set_tbname': [ref.types.int, [ref.types.void_ptr, ref.types.char_ptr]] - - // int taos_stmt_set_tbname_tags(TAOS_STMT* stmt, const char* name, TAOS_BIND* tags) - , 'taos_stmt_set_tbname_tags': [ref.types.int, [ref.types.void_ptr, ref.types.char_ptr, ref.types.void_ptr]] - - // int taos_stmt_set_sub_tbname(TAOS_STMT* stmt, const char* name) - , 'taos_stmt_set_sub_tbname': [ref.types.int, [ref.types.void_ptr, ref.types.char_ptr]] - - // int taos_stmt_bind_param(TAOS_STMT *stmt, TAOS_BIND *bind) - // , 'taos_stmt_bind_param': [ref.types.int, [ref.types.void_ptr, ref.refType(TAOS_BIND)]] - , 'taos_stmt_bind_param': [ref.types.int, [ref.types.void_ptr, ref.types.void_ptr]] - - - // int taos_stmt_bind_single_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int colIdx) - , 'taos_stmt_bind_single_param_batch': [ref.types.int, [ref.types.void_ptr, ref.types.void_ptr, ref.types.int]] - // int taos_stmt_bind_param_batch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind) - , 'taos_stmt_bind_param_batch': [ref.types.int, [ref.types.void_ptr, ref.types.void_ptr]] - - // int taos_stmt_add_batch(TAOS_STMT *stmt) - , 'taos_stmt_add_batch': [ref.types.int, [ref.types.void_ptr]] - - // int taos_stmt_execute(TAOS_STMT *stmt) - , 'taos_stmt_execute': [ref.types.int, [ref.types.void_ptr]] - - // TAOS_RES* taos_stmt_use_result(TAOS_STMT *stmt) - , 'taos_stmt_use_result': [ref.types.void_ptr, [ref.types.void_ptr]] - - // int taos_stmt_close(TAOS_STMT *stmt) - , 'taos_stmt_close': [ref.types.int, [ref.types.void_ptr]] - - // char * taos_stmt_errstr(TAOS_STMT *stmt) - , 'taos_stmt_errstr': [ref.types.char_ptr, [ref.types.void_ptr]] - - // int taos_load_table_info(TAOS *taos, const char* tableNameList) - , 'taos_load_table_info': [ref.types.int, [ref.types.void_ptr, ref.types.char_ptr]] - }); - - if (pass == false) { - if (config == null) { - this._config = ref.alloc(ref.types.char_ptr, ref.NULL); - } - else { - try { - this._config = ref.allocCString(config); - } - catch (err) { - throw "Attribute Error: config is expected as a str"; - } - } - if (config != null) { - this.libtaos.taos_options(3, this._config); - } - this.libtaos.taos_init(); - } - return this; -} - -CTaosInterface.prototype.config = function config() { - return this._config; -} - -CTaosInterface.prototype.connect = function connect(host = null, user = "root", password = "taosdata", db = null, port = 0) { - let _host, _user, _password, _db, _port; - try { - _host = host != null ? ref.allocCString(host) : ref.NULL; - } - catch (err) { - throw "Attribute Error: host is expected as a str"; - } - try { - _user = ref.allocCString(user) - } - catch (err) { - throw "Attribute Error: user is expected as a str"; - } - try { - _password = ref.allocCString(password); - } - catch (err) { - throw "Attribute Error: password is expected as a str"; - } - try { - _db = db != null ? ref.allocCString(db) : ref.NULL; - } - catch (err) { - throw "Attribute Error: db is expected as a str"; - } - try { - _port = ref.alloc(ref.types.int, port); - } - catch (err) { - throw TypeError("port is expected as an int") - } - let connection = this.libtaos.taos_connect(_host, _user, _password, _db, _port); - if (ref.isNull(connection)) { - throw new errors.TDError('Failed to connect to TDengine'); - } - else { - console.log('Successfully connected to TDengine'); - } - return connection; -} - -CTaosInterface.prototype.close = function close(connection) { - this.libtaos.taos_close(connection); - console.log("Connection is closed"); -} - -CTaosInterface.prototype.query = function query(connection, sql) { - return this.libtaos.taos_query(connection, ref.allocCString(sql)); -} - -CTaosInterface.prototype.affectedRows = function affectedRows(result) { - return this.libtaos.taos_affected_rows(result); -} - -CTaosInterface.prototype.useResult = function useResult(result) { - - let fields = []; - let pfields = this.fetchFields(result); - - if (ref.isNull(pfields) == false) { - pfields = ref.reinterpret(pfields, this.fieldsCount(result) * TAOSFIELD.STRUCT_SIZE, 0); - for (let i = 0; i < pfields.length; i += TAOSFIELD.STRUCT_SIZE) { - fields.push({ - name: ref.readCString(ref.reinterpret(pfields, TAOSFIELD.NAME_LENGTH, i)), - type: pfields[i + TAOSFIELD.TYPE_OFFSET], - bytes: pfields[i + TAOSFIELD.BYTES_OFFSET] + pfields[i + TAOSFIELD.BYTES_OFFSET + 1] * 256 - }) - } - } - return fields; -} - -CTaosInterface.prototype.fetchBlock = function fetchBlock(result, fields) { - let pblock = ref.NULL_POINTER; - let num_of_rows = this.libtaos.taos_fetch_block(result, pblock); - if (ref.isNull(pblock.deref()) == true) { - return { block: null, num_of_rows: 0 }; - } - - var fieldL = this.libtaos.taos_fetch_lengths(result); - let precision = this.libtaos.taos_result_precision(result); - - var fieldlens = []; - - if (ref.isNull(fieldL) == false) { - for (let i = 0; i < fields.length; i++) { - let plen = ref.reinterpret(fieldL, 4, i * 4); - let len = plen.readInt32LE(0); - fieldlens.push(len); - } - } - - let blocks = new Array(fields.length); - blocks.fill(null); - num_of_rows = Math.abs(num_of_rows); - let offset = 0; - let ptr = pblock.deref(); - - for (let i = 0; i < fields.length; i++) { - pdata = ref.reinterpret(ptr, 8, i * 8); - if (ref.isNull(pdata.readPointer())) { - blocks[i] = new Array(); - } else { - pdata = ref.ref(pdata.readPointer()); - if (!convertFunctions[fields[i]['type']]) { - throw new errors.DatabaseError("Invalid data type returned from database"); - } - blocks[i] = convertFunctions[fields[i]['type']](pdata, num_of_rows, fieldlens[i], offset, precision); - } - } - return { blocks: blocks, num_of_rows } -} - -CTaosInterface.prototype.fetchRow = function fetchRow(result, fields) { - let row = this.libtaos.taos_fetch_row(result); - return row; -} - -CTaosInterface.prototype.freeResult = function freeResult(result) { - this.libtaos.taos_free_result(result); - result = null; -} - -/** Number of fields returned in this result handle, must use with async */ -CTaosInterface.prototype.numFields = function numFields(result) { - return this.libtaos.taos_num_fields(result); -} - -// Fetch fields count by connection, the latest query -CTaosInterface.prototype.fieldsCount = function fieldsCount(result) { - return this.libtaos.taos_field_count(result); -} - -CTaosInterface.prototype.fetchFields = function fetchFields(result) { - return this.libtaos.taos_fetch_fields(result); -} - -CTaosInterface.prototype.errno = function errno(result) { - return this.libtaos.taos_errno(result); -} - -CTaosInterface.prototype.errStr = function errStr(result) { - return ref.readCString(this.libtaos.taos_errstr(result)); -} - -// Async -CTaosInterface.prototype.query_a = function query_a(connection, sql, callback, param = ref.ref(ref.NULL)) { - // void taos_query_a(TAOS *taos, char *sqlstr, void (*fp)(void *param, TAOS_RES *, int), void *param) - callback = ffi.Callback(ref.types.void, [ref.types.void_ptr, ref.types.void_ptr, ref.types.int], callback); - this.libtaos.taos_query_a(connection, ref.allocCString(sql), callback, param); - return param; -} - -/** Asynchrnously fetches the next block of rows. Wraps callback and transfers a 4th argument to the cursor, the row data as blocks in javascript form - * Note: This isn't a recursive function, in order to fetch all data either use the TDengine cursor object, TaosQuery object, or implement a recrusive - * function yourself using the libtaos.taos_fetch_rows_a function - */ -CTaosInterface.prototype.fetch_rows_a = function fetch_rows_a(result, callback, param = ref.ref(ref.NULL)) { - // void taos_fetch_rows_a(TAOS_RES *res, void (*fp)(void *param, TAOS_RES *, int numOfRows), void *param); - var cti = this; - // wrap callback with a function so interface can access the numOfRows value, needed in order to properly process the binary data - let asyncCallbackWrapper = function (param2, result2, numOfRows2) { - // Data preparation to pass to cursor. Could be bottleneck in query execution callback times. - let row = cti.libtaos.taos_fetch_row(result2); - let fields = cti.fetchFields_a(result2); - - let precision = cti.libtaos.taos_result_precision(result2); - let blocks = new Array(fields.length); - blocks.fill(null); - numOfRows2 = Math.abs(numOfRows2); - let offset = 0; - var fieldL = cti.libtaos.taos_fetch_lengths(result); - var fieldlens = []; - if (ref.isNull(fieldL) == false) { - - for (let i = 0; i < fields.length; i++) { - let plen = ref.reinterpret(fieldL, 8, i * 8); - let len = ref.get(plen, 0, ref.types.int32); - fieldlens.push(len); - } - } - if (numOfRows2 > 0) { - for (let i = 0; i < fields.length; i++) { - if (ref.isNull(pdata.readPointer())) { - blocks[i] = new Array(); - } else { - if (!convertFunctions[fields[i]['type']]) { - throw new errors.DatabaseError("Invalid data type returned from database"); - } - let prow = ref.reinterpret(row, 8, i * 8); - prow = prow.readPointer(); - prow = ref.ref(prow); - blocks[i] = convertFunctions[fields[i]['type']](prow, 1, fieldlens[i], offset, precision); - //offset += fields[i]['bytes'] * numOfRows2; - } - } - } - callback(param2, result2, numOfRows2, blocks); - } - asyncCallbackWrapper = ffi.Callback(ref.types.void, [ref.types.void_ptr, ref.types.void_ptr, ref.types.int], asyncCallbackWrapper); - this.libtaos.taos_fetch_rows_a(result, asyncCallbackWrapper, param); - return param; -} - -// Fetch field meta data by result handle -CTaosInterface.prototype.fetchFields_a = function fetchFields_a(result) { - let pfields = this.fetchFields(result); - let pfieldscount = this.numFields(result); - let fields = []; - if (ref.isNull(pfields) == false) { - pfields = ref.reinterpret(pfields, pfieldscount * TAOSFIELD.STRUCT_SIZE, 0); - for (let i = 0; i < pfields.length; i += TAOSFIELD.STRUCT_SIZE) { - fields.push({ - name: ref.readCString(ref.reinterpret(pfields, TAOSFIELD.NAME_LENGTH, i)), - type: pfields[i + TAOSFIELD.TYPE_OFFSET], - bytes: pfields[i + TAOSFIELD.BYTES_OFFSET] + pfields[i + TAOSFIELD.BYTES_OFFSET + 1] * 256 - }) - } - } - return fields; -} - -// Stop a query by result handle -CTaosInterface.prototype.stopQuery = function stopQuery(result) { - if (result != null) { - this.libtaos.taos_stop_query(result); - } - else { - throw new errors.ProgrammingError("No result handle passed to stop query"); - } -} - -CTaosInterface.prototype.getServerInfo = function getServerInfo(connection) { - return ref.readCString(this.libtaos.taos_get_server_info(connection)); -} - -CTaosInterface.prototype.getClientInfo = function getClientInfo() { - return ref.readCString(this.libtaos.taos_get_client_info()); -} - -// Subscription -CTaosInterface.prototype.subscribe = function subscribe(connection, restart, topic, sql, interval) { - let topicOrig = topic; - let sqlOrig = sql; - try { - sql = sql != null ? ref.allocCString(sql) : ref.alloc(ref.types.char_ptr, ref.NULL); - } - catch (err) { - throw "Attribute Error: sql is expected as a str"; - } - try { - topic = topic != null ? ref.allocCString(topic) : ref.alloc(ref.types.char_ptr, ref.NULL); - } - catch (err) { - throw TypeError("topic is expected as a str"); - } - - restart = ref.alloc(ref.types.int, restart); - - let subscription = this.libtaos.taos_subscribe(connection, restart, topic, sql, null, null, interval); - if (ref.isNull(subscription)) { - throw new errors.TDError('Failed to subscribe to TDengine | Database: ' + dbOrig + ', Table: ' + tableOrig); - } - else { - console.log('Successfully subscribed to TDengine - Topic: ' + topicOrig); - } - return subscription; -} - -CTaosInterface.prototype.consume = function consume(subscription) { - let result = this.libtaos.taos_consume(subscription); - let fields = []; - let pfields = this.fetchFields(result); - if (ref.isNull(pfields) == false) { - pfields = ref.reinterpret(pfields, this.numFields(result) * TAOSFIELD.STRUCT_SIZE, 0); - for (let i = 0; i < pfields.length; i += TAOSFIELD.STRUCT_SIZE) { - fields.push({ - name: ref.readCString(ref.reinterpret(pfields, TAOSFIELD.NAME_LENGTH, i)), - bytes: pfields[TAOSFIELD.TYPE_OFFSET], - type: pfields[i + TAOSFIELD.BYTES_OFFSET] + pfields[i + TAOSFIELD.BYTES_OFFSET + 1] * 256 - }) - } - } - - let data = []; - while (true) { - let { blocks, num_of_rows } = this.fetchBlock(result, fields); - if (num_of_rows == 0) { - break; - } - for (let i = 0; i < num_of_rows; i++) { - data.push([]); - let rowBlock = new Array(fields.length); - for (let j = 0; j < fields.length; j++) { - rowBlock[j] = blocks[j][i]; - } - data[data.length - 1] = (rowBlock); - } - } - return { data: data, fields: fields, result: result }; -} - -CTaosInterface.prototype.unsubscribe = function unsubscribe(subscription) { - //void taos_unsubscribe(TAOS_SUB *tsub); - this.libtaos.taos_unsubscribe(subscription); -} - -// Continuous Query -CTaosInterface.prototype.openStream = function openStream(connection, sql, callback, stime, stoppingCallback, param = ref.ref(ref.NULL)) { - try { - sql = ref.allocCString(sql); - } - catch (err) { - throw "Attribute Error: sql string is expected as a str"; - } - var cti = this; - let asyncCallbackWrapper = function (param2, result2, row) { - let fields = cti.fetchFields_a(result2); - let precision = cti.libtaos.taos_result_precision(result2); - let blocks = new Array(fields.length); - blocks.fill(null); - let numOfRows2 = 1; - let offset = 0; - if (numOfRows2 > 0) { - for (let i = 0; i < fields.length; i++) { - if (!convertFunctions[fields[i]['type']]) { - throw new errors.DatabaseError("Invalid data type returned from database"); - } - blocks[i] = convertFunctions[fields[i]['type']](row, numOfRows2, fields[i]['bytes'], offset, precision); - offset += fields[i]['bytes'] * numOfRows2; - } - } - callback(param2, result2, blocks, fields); - } - asyncCallbackWrapper = ffi.Callback(ref.types.void, [ref.types.void_ptr, ref.types.void_ptr, ref.refType(ref.types.void_ptr2)], asyncCallbackWrapper); - asyncStoppingCallbackWrapper = ffi.Callback(ref.types.void, [ref.types.void_ptr], stoppingCallback); - let streamHandle = this.libtaos.taos_open_stream(connection, sql, asyncCallbackWrapper, stime, param, asyncStoppingCallbackWrapper); - if (ref.isNull(streamHandle)) { - throw new errors.TDError('Failed to open a stream with TDengine'); - return false; - } - else { - console.log("Succesfully opened stream"); - return streamHandle; - } -} - -CTaosInterface.prototype.closeStream = function closeStream(stream) { - this.libtaos.taos_close_stream(stream); - console.log("Closed stream"); -} - -//Schemaless insert API -/** - * TAOS* taos, char* lines[], int numLines, int protocol,int precision) - * using taos_errstr get error info, taos_errno get error code. Remember - * to release taos_res, otherwise will lead memory leak. - * TAOS schemaless insert api - * @param {*} connection a valid database connection - * @param {*} lines string data, which satisfied with line protocol - * @param {*} numLines number of rows in param lines. - * @param {*} protocol Line protocol, enum type (0,1,2,3),indicate different line protocol - * @param {*} precision timestamp precision in lines, enum type (0,1,2,3,4,5,6) - * @returns TAOS_RES - * - */ -CTaosInterface.prototype.schemalessInsert = function schemalessInsert(connection, lines, protocal, precision) { - let _numLines = null; - let _lines = null; - - if (_.isString(lines)) { - _numLines = 1; - _lines = Buffer.alloc(_numLines * ref.sizeof.pointer); - ref.set(_lines, 0, ref.allocCString(lines), ref.types.char_ptr); - } - else if (_.isArray(lines)) { - _numLines = lines.length; - _lines = Buffer.alloc(_numLines * ref.sizeof.pointer); - for (let i = 0; i < _numLines; i++) { - ref.set(_lines, i * ref.sizeof.pointer, ref.allocCString(lines[i]), ref.types.char_ptr) - } - } - else { - throw new errors.InterfaceError("Unsupport lines input") - } - return this.libtaos.taos_schemaless_insert(connection, _lines, _numLines, protocal, precision); -} - -//stmt APIs - -/** - * init a TAOS_STMT object for later use.it should be freed with stmtClose. - * @param {*} connection valid taos connection - * @returns Not NULL returned for success, and NULL for failure. - * - */ -CTaosInterface.prototype.stmtInit = function stmtInit(connection) { - return this.libtaos.taos_stmt_init(connection) -} - -/** - * prepare a sql statement,'sql' should be a valid INSERT/SELECT statement, 'length' is not used. - * @param {*} stmt - * @param {string} sql a valid INSERT/SELECT statement - * @param {ulong} length not used - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.stmtPrepare = function stmtPrepare(stmt, sql, length) { - return this.libtaos.taos_stmt_prepare(stmt, ref.allocCString(sql), 0); -} - -/** - * For INSERT only. Used to bind table name as a parmeter for the input stmt object. - * @param {*} stmt could be the value returned by 'stmtInit', - * that may be a valid object or NULL. - * @param {TaosBind} tableName target table name you want to bind - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.stmtSetTbname = function stmtSetTbname(stmt, tableName) { - return this.libtaos.taos_stmt_set_tbname(stmt, ref.allocCString(tableName)); -} - -/** - * For INSERT only. - * Set a table name for binding table name as parameter and tag values for all tag parameters. - * @param {*} stmt could be the value returned by 'stmtInit', that may be a valid object or NULL. - * @param {*} tableName use to set target table name - * @param {TaosMultiBind} tags use to set tag value for target table. - * @returns - */ -CTaosInterface.prototype.stmtSetTbnameTags = function stmtSetTbnameTags(stmt, tableName, tags) { - return this.libtaos.taos_stmt_set_tbname_tags(stmt, ref.allocCString(tableName), tags); -} - -/** - * For INSERT only. - * Set a table name for binding table name as parameter. Only used for binding all tables - * in one stable, user application must call 'loadTableInfo' API to load all table - * meta before calling this API. If the table meta is not cached locally, it will return error. - * @param {*} stmt could be the value returned by 'StmtInit', that may be a valid object or NULL. - * @param {*} subTableName table name which is belong to an stable - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.stmtSetSubTbname = function stmtSetSubTbname(stmt, subTableName) { - return this.libtaos.taos_stmt_set_sub_tbname(stmt, subTableName); -} - -/** - * bind a whole line data, for both INSERT and SELECT. The parameter 'bind' points to an array - * contains the whole line data. Each item in array represents a column's value, the item - * number and sequence should keep consistence with columns in sql statement. The usage of - * structure TAOS_BIND is the same with MYSQL_BIND in MySQL. - * @param {*} stmt could be the value returned by 'stmtInit', that may be a valid object or NULL. - * @param {*} binds points to an array contains the whole line data. - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.bindParam = function bindParam(stmt, binds) { - return this.libtaos.taos_stmt_bind_param(stmt, binds); -} - -/** - * Bind a single column's data, INTERNAL used and for INSERT only. - * @param {*} stmt could be the value returned by 'stmtInit', that may be a valid object or NULL. - * @param {TaosMultiBind} mbind points to a column's data which could be the one or more lines. - * @param {*} colIndex the column's index in prepared sql statement, it starts from 0. - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.stmtBindSingleParamBatch = function stmtBindSingleParamBatch(stmt, mbind, colIndex) { - return this.libtaos.taos_stmt_bind_single_param_batch(stmt, mbind.ref(), colIndex); -} - -/** - * For INSERT only. - * Bind one or multiple lines data. - * @param {*} stmt could be the value returned by 'stmtInit', - * that may be a valid object or NULL. - * @param {*} mbinds Points to an array contains one or more lines data.The item - * number and sequence should keep consistence with columns - * n sql statement. - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.stmtBindParamBatch = function stmtBindParamBatch(stmt, mbinds) { - return this.libtaos.taos_stmt_bind_param_batch(stmt, mbinds); -} -/** - * add all current bound parameters to batch process, for INSERT only. - * Must be called after each call to bindParam/bindSingleParamBatch, - * or all columns binds for one or more lines with bindSingleParamBatch. User - * application can call any bind parameter API again to bind more data lines after calling - * to this API. - * @param {*} stmt - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.addBatch = function addBatch(stmt) { - return this.libtaos.taos_stmt_add_batch(stmt); -} -/** - * actually execute the INSERT/SELECT sql statement. User application can continue - * to bind new data after calling to this API. - * @param {*} stmt - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.stmtExecute = function stmtExecute(stmt) { - return this.libtaos.taos_stmt_execute(stmt); -} - -/** - * For SELECT only,getting the query result. - * User application should free it with API 'FreeResult' at the end. - * @param {*} stmt could be the value returned by 'stmtInit', that may be a valid object or NULL. - * @returns Not NULL for success, NULL for failure. - */ -CTaosInterface.prototype.stmtUseResult = function stmtUseResult(stmt) { - return this.libtaos.taos_stmt_use_result(stmt); -} - -/** - * user application call this API to load all tables meta info. - * This method must be called before stmtSetSubTbname(IntPtr stmt, string name); - * @param {*} taos taos connection - * @param {*} tableList tables need to load meta info are form in an array - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.loadTableInfo = function loadTableInfo(taos, tableList) { - let _tableListBuf = Buffer.alloc(ref.sizeof.pointer); - let _listStr = tableList.toString(); - - if ((_.isString(tableList) )|| (_.isArray(tableList))) { - ref.set(_tableListBuf, 0, ref.allocCString(_listStr), ref.types.char_ptr); - return this.libtaos.taos_load_table_info(taos, _tableListBuf); - } else { - throw new errors.InterfaceError("Unspport tableLis input"); - } -} - -/** - * Close STMT object and free resources. - * @param {*} stmt could be the value returned by 'stmtInit', that may be a valid object or NULL. - * @returns 0 for success, non-zero for failure. - */ -CTaosInterface.prototype.closeStmt = function closeStmt(stmt) { - return this.libtaos.taos_stmt_close(stmt); -} - -/** - * Get detail error message when got failure for any stmt API call. - * If not failure, the result returned by this API is unknown. - * @param {*} stmt Could be the value returned by 'stmtInit', that may be a valid object or NULL. - * @returns error string - */ -CTaosInterface.prototype.stmtErrStr = function stmtErrStr(stmt) { - return ref.readCString(this.libtaos.taos_stmt_errstr(stmt)); -} \ No newline at end of file diff --git a/src/connector/nodejs/nodetaos/connection.js b/src/connector/nodejs/nodetaos/connection.js deleted file mode 100644 index 08186f87053ad0ed0982ec8941f0cf38c4ad0467..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/connection.js +++ /dev/null @@ -1,84 +0,0 @@ -const TDengineCursor = require('./cursor') -const CTaosInterface = require('./cinterface') -module.exports = TDengineConnection; - -/** - * TDengine Connection Class - * @param {object} options - Options for configuring the connection with TDengine - * @return {TDengineConnection} - * @class TDengineConnection - * @constructor - * @example - * //Initialize a new connection - * var conn = new TDengineConnection({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0}) - * - */ -function TDengineConnection(options) { - this._conn = null; - this._host = null; - this._user = "root"; //The default user - this._password = "taosdata"; //The default password - this._database = null; - this._port = 0; - this._config = null; - this._chandle = null; - this._configConn(options) - return this; -} -/** - * Configure the connection to TDengine - * @private - * @memberof TDengineConnection - */ -TDengineConnection.prototype._configConn = function _configConn(options) { - if (options['host']) { - this._host = options['host']; - } - if (options['user']) { - this._user = options['user']; - } - if (options['password']) { - this._password = options['password']; - } - if (options['database']) { - this._database = options['database']; - } - if (options['port']) { - this._port = options['port']; - } - if (options['config']) { - this._config = options['config']; - } - this._chandle = new CTaosInterface(this._config); - this._conn = this._chandle.connect(this._host, this._user, this._password, this._database, this._port); -} -/** Close the connection to TDengine */ -TDengineConnection.prototype.close = function close() { - this._chandle.close(this._conn); -} -/** - * Initialize a new cursor to interact with TDengine with - * @return {TDengineCursor} - */ -TDengineConnection.prototype.cursor = function cursor() { - //Pass the connection object to the cursor - return new TDengineCursor(this); -} -TDengineConnection.prototype.commit = function commit() { - return this; -} -TDengineConnection.prototype.rollback = function rollback() { - return this; -} -/** - * Clear the results from connector - * @private - */ -/* - TDengineConnection.prototype._clearResultSet = function _clearResultSet() { - var result = this._chandle.useResult(this._conn).result; - if (result) { - this._chandle.freeResult(result) - } -} -*/ diff --git a/src/connector/nodejs/nodetaos/constants.js b/src/connector/nodejs/nodetaos/constants.js deleted file mode 100644 index b055e0ed01522348556475fa72e8bf34a9d3fe70..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/constants.js +++ /dev/null @@ -1,106 +0,0 @@ - -const SCHEMALESS_PROTOCOL = { - TSDB_SML_UNKNOWN_PROTOCOL: 0, - TSDB_SML_LINE_PROTOCOL: 1, - TSDB_SML_TELNET_PROTOCOL: 2, - TSDB_SML_JSON_PROTOCOL: 3 -} -const SCHEMALESS_PRECISION = { - TSDB_SML_TIMESTAMP_NOT_CONFIGURED: 0, - TSDB_SML_TIMESTAMP_HOURS: 1, - TSDB_SML_TIMESTAMP_MINUTES: 2, - TSDB_SML_TIMESTAMP_SECONDS: 3, - TSDB_SML_TIMESTAMP_MILLI_SECONDS: 4, - TSDB_SML_TIMESTAMP_MICRO_SECONDS: 5, - TSDB_SML_TIMESTAMP_NANO_SECONDS: 6 -} -const typeCodesToName = { - 0: 'Null', - 1: 'Boolean', - 2: 'Tiny Int', - 3: 'Small Int', - 4: 'Int', - 5: 'Big Int', - 6: 'Float', - 7: 'Double', - 8: 'Binary', - 9: 'Timestamp', - 10: 'Nchar', - 11: 'Tinyint Unsigned', - 12: 'Smallint Unsigned', - 13: 'Int Unsigned', - 14: 'Bigint Unsigned', - 15: 'Json', -} - -/** - * @function - * @param {number} typecode - The code to get the name of the type for - * @return {string} Name of the field type - */ -function getType(typecode) { - return typeCodesToName[typecode]; -} -/** - * Contains the the definitions/values assigned to various field types - * @module FieldTypes - */ -/** - * TDengine Field Types and their type codes - * @typedef {Object} FieldTypes - * @global - * @property {number} C_NULL - Null - * @property {number} C_BOOL - Boolean. Note, 0x02 is the C_BOOL_NULL value. - * @property {number} C_TINYINT - Tiny Int, values in the range [-2^7+1, 2^7-1]. Note, -2^7 has been used as the C_TINYINT_NULL value - * @property {number} C_SMALLINT - Small Int, values in the range [-2^15+1, 2^15-1]. Note, -2^15 has been used as the C_SMALLINT_NULL value - * @property {number} C_INT - Int, values in the range [-2^31+1, 2^31-1]. Note, -2^31 has been used as the C_INT_NULL value - * @property {number} C_BIGINT - Big Int, values in the range [-2^59, 2^59]. - * @property {number} C_FLOAT - Float, values in the range [-3.4E38, 3.4E38], accurate up to 6-7 decimal places. - * @property {number} C_DOUBLE - Double, values in the range [-1.7E308, 1.7E308], accurate up to 15-16 decimal places. - * @property {number} C_BINARY - Binary, encoded in utf-8. - * @property {number} C_TIMESTAMP - Timestamp in format "YYYY:MM:DD HH:MM:SS.MMM". Measured in number of milliseconds passed after - 1970-01-01 08:00:00.000 GMT. - * @property {number} C_NCHAR - NChar field type encoded in ASCII, a wide string. - * - * @property {number} C_TIMESTAMP_MILLI - The code for millisecond timestamps, as returned by libtaos.taos_result_precision(result). - * @property {number} C_TIMESTAMP_MICRO - The code for microsecond timestamps, as returned by libtaos.taos_result_precision(result). - */ -module.exports = { - C_NULL: 0, - C_BOOL: 1, - C_TINYINT: 2, - C_SMALLINT: 3, - C_INT: 4, - C_BIGINT: 5, - C_FLOAT: 6, - C_DOUBLE: 7, - C_BINARY: 8, - C_TIMESTAMP: 9, - C_NCHAR: 10, - C_TINYINT_UNSIGNED: 11, - C_SMALLINT_UNSIGNED: 12, - C_INT_UNSIGNED: 13, - C_BIGINT_UNSIGNED: 14, - C_JSON_TAG: 15, - // NULL value definition - // NOTE: These values should change according to C definition in tsdb.h - C_BOOL_NULL: 2, - C_TINYINT_NULL: -128, - C_TINYINT_UNSIGNED_NULL: 255, - C_SMALLINT_NULL: -32768, - C_SMALLINT_UNSIGNED_NULL: 65535, - C_INT_NULL: -2147483648, - C_INT_UNSIGNED_NULL: 4294967295, - C_BIGINT_NULL: -9223372036854775808n, - C_BIGINT_UNSIGNED_NULL: 18446744073709551615n, - C_FLOAT_NULL: 2146435072, - C_DOUBLE_NULL: -9223370937343148032, - C_NCHAR_NULL: 4294967295, - C_BINARY_NULL: 255, - C_TIMESTAMP_MILLI: 0, - C_TIMESTAMP_MICRO: 1, - getType, - SCHEMALESS_PROTOCOL, - SCHEMALESS_PRECISION -} - diff --git a/src/connector/nodejs/nodetaos/cursor.js b/src/connector/nodejs/nodetaos/cursor.js deleted file mode 100644 index 5969d4f344affa49ebbf81329729bff4733e116b..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/cursor.js +++ /dev/null @@ -1,752 +0,0 @@ -const ref = require('ref-napi'); -require('./globalfunc.js') -const CTaosInterface = require('./cinterface') -const errors = require('./error') -const TaosQuery = require('./taosquery') -const { PerformanceObserver, performance } = require('perf_hooks'); -module.exports = TDengineCursor; - -/** - * @typedef {Object} Buffer - A Node.js buffer. Please refer to {@link https://nodejs.org/api/buffer.html} for more details - * @global - */ - -/** - * @class TDengineCursor - * @classdesc The TDengine Cursor works directly with the C Interface which works with TDengine. It refrains from - * returning parsed data and majority of functions return the raw data such as cursor.fetchall() as compared to the TaosQuery class which - * has functions that "prettify" the data and add more functionality and can be used through cursor.query("your query"). Instead of - * promises, the class and its functions use callbacks. - * @param {TDengineConnection} - The TDengine Connection this cursor uses to interact with TDengine - * @property {data} - Latest retrieved data from query execution. It is an empty array by default - * @property {fields} - Array of the field objects in order from left to right of the latest data retrieved - * @since 1.0.0 - */ -function TDengineCursor(connection = null) { - //All parameters are store for sync queries only. - this._rowcount = -1; - this._connection = null; - this._result = null; - this._fields = null; - this.data = []; - this.fields = null; - this._stmt = null; - if (connection != null) { - this._connection = connection - this._chandle = connection._chandle //pass through, just need library loaded. - } - else { - throw new errors.ProgrammingError("A TDengineConnection object is required to be passed to the TDengineCursor"); - } - -} -/** - * Get the row counts of the latest query - * @since 1.0.0 - * @return {number} Rowcount - */ -TDengineCursor.prototype.rowcount = function rowcount() { - return this._rowcount; -} -/** - * Close the cursor by setting its connection to null and freeing results from the connection and resetting the results it has stored - * @return {boolean} Whether or not the cursor was succesfully closed - * @since 1.0.0 - */ -TDengineCursor.prototype.close = function close() { - if (this._connection == null) { - return false; - } - this._connection._clearResultSet(); - this._reset_result(); - this._connection = null; - return true; -} -/** - * Create a TaosQuery object to perform a query to TDengine and retrieve data. - * @param {string} operation - The operation string to perform a query on - * @param {boolean} execute - Whether or not to immedietely perform the query. Default is false. - * @return {TaosQuery | Promise} A TaosQuery object - * @example - * var query = cursor.query("select count(*) from meterinfo.meters"); - * query.execute(); - * @since 1.0.6 - */ -TDengineCursor.prototype.query = function query(operation, execute = false) { - return new TaosQuery(operation, this, execute); -} - -/** - * Execute a query. Also stores all the field meta data returned from the query into cursor.fields. It is preferable to use cursor.query() to create - * queries and execute them instead of using the cursor object directly. - * @param {string} operation - The query operation to execute in the taos shell - * @param {Object} options - Execution options object. quiet : true turns off logging from queries - * @param {boolean} options.quiet - True if you want to surpress logging such as "Query OK, 1 row(s) ..." - * @param {function} callback - A callback function to execute after the query is made to TDengine - * @return {number | Buffer} Number of affected rows or a Buffer that points to the results of the query - * @since 1.0.0 - */ -TDengineCursor.prototype.execute = function execute(operation, options, callback) { - if (operation == undefined) { - throw new errors.ProgrammingError('No operation passed as argument'); - return null; - } - - if (typeof options == 'function') { - callback = options; - } - if (typeof options != 'object') options = {} - if (this._connection == null) { - throw new errors.ProgrammingError('Cursor is not connected'); - } - - this._reset_result(); - - let stmt = operation; - let time = 0; - let res; - if (options['quiet'] != true) { - const obs = new PerformanceObserver((items) => { - time = items.getEntries()[0].duration; - performance.clearMarks(); - }); - obs.observe({ entryTypes: ['measure'] }); - performance.mark('A'); - this._result = this._chandle.query(this._connection._conn, stmt); - performance.mark('B'); - performance.measure('query', 'A', 'B'); - } - else { - this._result = this._chandle.query(this._connection._conn, stmt); - } - res = this._chandle.errno(this._result); - if (res == 0) { - let fieldCount = this._chandle.fieldsCount(this._result); - if (fieldCount == 0) { - let affectedRowCount = this._chandle.affectedRows(this._result); - let response = this._createAffectedResponse(affectedRowCount, time) - if (options['quiet'] != true) { - console.log(response); - } - wrapCB(callback); - return affectedRowCount; //return num of affected rows, common with insert, use statements - } - else { - this._fields = this._chandle.useResult(this._result); - this.fields = this._fields; - wrapCB(callback); - - return this._result; //return a pointer to the result - } - } - else { - throw new errors.ProgrammingError(this._chandle.errStr(this._result)) - } - -} -TDengineCursor.prototype._createAffectedResponse = function (num, time) { - return "Query OK, " + num + " row(s) affected (" + (time * 0.001).toFixed(8) + "s)"; -} -TDengineCursor.prototype._createSetResponse = function (num, time) { - return "Query OK, " + num + " row(s) in set (" + (time * 0.001).toFixed(8) + "s)"; -} -TDengineCursor.prototype.executemany = function executemany() { - -} -TDengineCursor.prototype.fetchone = function fetchone() { - -} -TDengineCursor.prototype.fetchmany = function fetchmany() { - -} -/** - * Fetches all results from a query and also stores results into cursor.data. It is preferable to use cursor.query() to create - * queries and execute them instead of using the cursor object directly. - * @param {function} callback - callback function executing on the complete fetched data - * @return {Array} The resultant array, with entries corresponding to each retreived row from the query results, sorted in - * order by the field name ordering in the table. - * @since 1.0.0 - * @example - * cursor.execute('select * from db.table'); - * var data = cursor.fetchall(function(results) { - * results.forEach(row => console.log(row)); - * }) - */ -TDengineCursor.prototype.fetchall = function fetchall(options, callback) { - if (this._result == null || this._fields == null) { - throw new errors.OperationalError("Invalid use of fetchall, either result or fields from query are null. First execute a query first"); - } - - let num_of_rows = this._chandle.affectedRows(this._result); - let data = new Array(num_of_rows); - - this._rowcount = 0; - - let time = 0; - const obs = new PerformanceObserver((items) => { - time += items.getEntries()[0].duration; - performance.clearMarks(); - }); - obs.observe({ entryTypes: ['measure'] }); - performance.mark('A'); - while (true) { - let blockAndRows = this._chandle.fetchBlock(this._result, this._fields); - // console.log(blockAndRows); - // break; - let block = blockAndRows.blocks; - let num_of_rows = blockAndRows.num_of_rows; - if (num_of_rows == 0) { - break; - } - this._rowcount += num_of_rows; - let numoffields = this._fields.length; - for (let i = 0; i < num_of_rows; i++) { - // data.push([]); - - let rowBlock = new Array(numoffields); - for (let j = 0; j < numoffields; j++) { - rowBlock[j] = block[j][i]; - } - data[this._rowcount - num_of_rows + i] = (rowBlock); - // data.push(rowBlock); - } - - } - - performance.mark('B'); - performance.measure('query', 'A', 'B'); - let response = this._createSetResponse(this._rowcount, time) - console.log(response); - - // this._connection._clearResultSet(); - let fields = this.fields; - this._reset_result(); - this.data = data; - this.fields = fields; - - wrapCB(callback, data); - - return data; -} -/** - * Asynchrnously execute a query to TDengine. NOTE, insertion requests must be done in sync if on the same table. - * @param {string} operation - The query operation to execute in the taos shell - * @param {Object} options - Execution options object. quiet : true turns off logging from queries - * @param {boolean} options.quiet - True if you want to surpress logging such as "Query OK, 1 row(s) ..." - * @param {function} callback - A callback function to execute after the query is made to TDengine - * @return {number | Buffer} Number of affected rows or a Buffer that points to the results of the query - * @since 1.0.0 - */ -TDengineCursor.prototype.execute_a = function execute_a(operation, options, callback, param) { - if (operation == undefined) { - throw new errors.ProgrammingError('No operation passed as argument'); - return null; - } - if (typeof options == 'function') { - //we expect the parameter after callback to be param - param = callback; - callback = options; - } - if (typeof options != 'object') options = {} - if (this._connection == null) { - throw new errors.ProgrammingError('Cursor is not connected'); - } - if (typeof callback != 'function') { - throw new errors.ProgrammingError("No callback function passed to execute_a function"); - } - // Async wrapper for callback; - var cr = this; - - let asyncCallbackWrapper = function (param2, res2, resCode) { - if (typeof callback == 'function') { - callback(param2, res2, resCode); - } - - if (resCode >= 0) { - // let fieldCount = cr._chandle.numFields(res2); - // if (fieldCount == 0) { - // //cr._chandle.freeResult(res2); - // return res2; - // } - // else { - // return res2; - // } - return res2; - - } - else { - throw new errors.ProgrammingError("Error occuring with use of execute_a async function. Status code was returned with failure"); - } - } - - let stmt = operation; - let time = 0; - - // Use ref module to write to buffer in cursor.js instead of taosquery to maintain a difference in levels. Have taosquery stay high level - // through letting it pass an object as param - var buf = ref.alloc('Object'); - ref.writeObject(buf, 0, param); - const obs = new PerformanceObserver((items) => { - time = items.getEntries()[0].duration; - performance.clearMarks(); - }); - obs.observe({ entryTypes: ['measure'] }); - performance.mark('A'); - this._chandle.query_a(this._connection._conn, stmt, asyncCallbackWrapper, buf); - performance.mark('B'); - performance.measure('query', 'A', 'B'); - return param; - - -} -/** - * Fetches all results from an async query. It is preferable to use cursor.query_a() to create - * async queries and execute them instead of using the cursor object directly. - * @param {Object} options - An options object containing options for this function - * @param {function} callback - callback function that is callbacked on the COMPLETE fetched data (it is calledback only once!). - * Must be of form function (param, result, rowCount, rowData) - * @param {Object} param - A parameter that is also passed to the main callback function. Important! Param must be an object, and the key "data" cannot be used - * @return {{param:Object, result:Buffer}} An object with the passed parameters object and the buffer instance that is a pointer to the result handle. - * @since 1.2.0 - * @example - * cursor.execute('select * from db.table'); - * var data = cursor.fetchall(function(results) { - * results.forEach(row => console.log(row)); - * }) - */ -TDengineCursor.prototype.fetchall_a = function fetchall_a(result, options, callback, param = {}) { - if (typeof options == 'function') { - //we expect the parameter after callback to be param - param = callback; - callback = options; - } - if (typeof options != 'object') options = {} - if (this._connection == null) { - throw new errors.ProgrammingError('Cursor is not connected'); - } - if (typeof callback != 'function') { - throw new errors.ProgrammingError('No callback function passed to fetchall_a function') - } - if (param.data) { - throw new errors.ProgrammingError("You aren't allowed to set the key 'data' for the parameters object"); - } - let buf = ref.alloc('Object'); - param.data = []; - var cr = this; - - // This callback wrapper accumulates the data from the fetch_rows_a function from the cinterface. It is accumulated by passing the param2 - // object which holds accumulated data in the data key. - let asyncCallbackWrapper = function asyncCallbackWrapper(param2, result2, numOfRows2, rowData) { - param2 = ref.readObject(param2); //return the object back from the pointer - if (numOfRows2 > 0 && rowData.length != 0) { - // Keep fetching until now rows left. - let buf2 = ref.alloc('Object'); - param2.data.push(rowData); - ref.writeObject(buf2, 0, param2); - cr._chandle.fetch_rows_a(result2, asyncCallbackWrapper, buf2); - } - else { - let finalData = param2.data; - let fields = cr._chandle.fetchFields_a(result2); - let data = []; - for (let i = 0; i < finalData.length; i++) { - let num_of_rows = finalData[i][0].length; //fetched block number i; - let block = finalData[i]; - for (let j = 0; j < num_of_rows; j++) { - data.push([]); - let rowBlock = new Array(fields.length); - for (let k = 0; k < fields.length; k++) { - rowBlock[k] = block[k][j]; - } - data[data.length - 1] = rowBlock; - } - } - cr._chandle.freeResult(result2); // free result, avoid seg faults and mem leaks! - callback(param2, result2, numOfRows2, { data: data, fields: fields }); - - } - } - ref.writeObject(buf, 0, param); - param = this._chandle.fetch_rows_a(result, asyncCallbackWrapper, buf); //returned param - return { param: param, result: result }; -} -/** - * Stop a query given the result handle. - * @param {Buffer} result - The buffer that acts as the result handle - * @since 1.3.0 - */ -TDengineCursor.prototype.stopQuery = function stopQuery(result) { - this._chandle.stopQuery(result); -} -TDengineCursor.prototype._reset_result = function _reset_result() { - this._rowcount = -1; - if (this._result != null) { - this._chandle.freeResult(this._result); - } - this._result = null; - this._fields = null; - this.data = []; - this.fields = null; -} -/** - * Get server info such as version number - * @return {string} - * @since 1.3.0 - */ -TDengineCursor.prototype.getServerInfo = function getServerInfo() { - return this._chandle.getServerInfo(this._connection._conn); -} -/** - * Get client info such as version number - * @return {string} - * @since 1.3.0 - */ -TDengineCursor.prototype.getClientInfo = function getClientInfo() { - return this._chandle.getClientInfo(); -} -/** - * Subscribe to a table from a database in TDengine. - * @param {Object} config - A configuration object containing the configuration options for the subscription - * @param {string} config.restart - whether or not to continue a subscription if it already exits, otherwise start from beginning - * @param {string} config.topic - The unique identifier of a subscription - * @param {string} config.sql - A sql statement for data query - * @param {string} config.interval - The pulling interval - * @return {Buffer} A buffer pointing to the subscription session handle - * @since 1.3.0 - */ -TDengineCursor.prototype.subscribe = function subscribe(config) { - let restart = config.restart ? 1 : 0; - return this._chandle.subscribe(this._connection._conn, restart, config.topic, config.sql, config.interval); -}; -/** - * An infinite loop that consumes the latest data and calls a callback function that is provided. - * @param {Buffer} subscription - A buffer object pointing to the subscription session handle - * @param {function} callback - The callback function that takes the row data, field/column meta data, and the subscription session handle as input - * @since 1.3.0 - */ -TDengineCursor.prototype.consumeData = async function consumeData(subscription, callback) { - while (true) { - let { data, fields, result } = this._chandle.consume(subscription); - callback(data, fields, result); - } -} -/** - * Unsubscribe the provided buffer object pointing to the subscription session handle - * @param {Buffer} subscription - A buffer object pointing to the subscription session handle that is to be unsubscribed - * @since 1.3.0 - */ -TDengineCursor.prototype.unsubscribe = function unsubscribe(subscription) { - this._chandle.unsubscribe(subscription); -} -/** - * Open a stream with TDengine to run the sql query periodically in the background - * @param {string} sql - The query to run - * @param {function} callback - The callback function to run after each query, accepting inputs as param, result handle, data, fields meta data - * @param {number} stime - The time of the stream starts in the form of epoch milliseconds. If 0 is given, the start time is set as the current time. - * @param {function} stoppingCallback - The callback function to run when the continuous query stops. It takes no inputs - * @param {object} param - A parameter that is passed to the main callback function - * @return {Buffer} A buffer pointing to the stream handle - * @since 1.3.0 - */ -TDengineCursor.prototype.openStream = function openStream(sql, callback, stime = 0, stoppingCallback, param = {}) { - let buf = ref.alloc('Object'); - ref.writeObject(buf, 0, param); - - let asyncCallbackWrapper = function (param2, result2, blocks, fields) { - let data = []; - let num_of_rows = blocks[0].length; - for (let j = 0; j < num_of_rows; j++) { - data.push([]); - let rowBlock = new Array(fields.length); - for (let k = 0; k < fields.length; k++) { - rowBlock[k] = blocks[k][j]; - } - data[data.length - 1] = rowBlock; - } - callback(param2, result2, blocks, fields); - } - return this._chandle.openStream(this._connection._conn, sql, asyncCallbackWrapper, stime, stoppingCallback, buf); -} -/** - * Close a stream - * @param {Buffer} - A buffer pointing to the handle of the stream to be closed - * @since 1.3.0 - */ -TDengineCursor.prototype.closeStream = function closeStream(stream) { - this._chandle.closeStream(stream); -} -/** - * schemaless insert - * @param {*} connection a valid database connection - * @param {*} lines string data, which statisfied with line proctocol - * @param {*} protocal Line protocol, enum type (0,1,2,3),indicate different line protocol - * @param {*} precision timestamp precision in lines, enum type (0,1,2,3,4,5,6) - * @returns TAOS_RES - * - */ -TDengineCursor.prototype.schemalessInsert = function schemalessInsert(lines, protocol, precision) { - this._result = this._chandle.schemalessInsert(this._connection._conn, lines, protocol, precision); - let errorNo = this._chandle.errno(this._result); - if (errorNo != 0) { - throw new errors.InterfaceError(errorNo + ":" + this._chandle.errStr(this._result)); - } - this._chandle.freeResult(this._result); -} - -//STMT -/** - * init a TAOS_STMT object for later use.it should be freed with stmtClose. - * @returns Not NULL returned for success, and NULL for failure. - * - */ -TDengineCursor.prototype.stmtInit = function stmtInit() { - let stmt = null - stmt = this._chandle.stmtInit(this._connection._conn); - if (stmt == null || stmt == undefined) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(stmt)); - } else { - this._stmt = stmt; - } -} - -/** - * prepare a sql statement,'sql' should be a valid INSERT/SELECT statement - * @param {string} sql a valid INSERT/SELECT statement - * @returns {int} 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtPrepare = function stmtPrepare(sql) { - if (this._stmt == null) { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } else { - let stmtPrepare = this._chandle.stmtPrepare(this._stmt, sql, null); - if (stmtPrepare != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } else { - console.log("stmtPrepare success."); - } - } -} - -/** - * For INSERT only. Used to bind table name as a parmeter for the input stmt object. - * @param {TaosBind} tableName target table name you want to bind - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtSetTbname = function stmtSetTbname(tableName) { - if (this._stmt == null) { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } else { - let stmtPrepare = this._chandle.stmtSetTbname(this._stmt, tableName); - if (stmtPrepare != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } else { - console.log("stmtSetTbname success."); - } - } -} - -/** - * For INSERT only. - * Set a table name for binding table name as parameter and tag values for all tag parameters. - * @param {*} tableName use to set target table name - * @param {TaosMultiBind} tags use to set tag value for target table. - * @returns - */ -TDengineCursor.prototype.stmtSetTbnameTags = function stmtSetTbnameTags(tableName, tags) { - if (this._stmt == null) { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } else { - let stmtPrepare = this._chandle.stmtSetTbnameTags(this._stmt, tableName, tags); - if (stmtPrepare != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } else { - console.log("stmtSetTbnameTags success."); - } - } -} - -/** - * For INSERT only. - * Set a table name for binding table name as parameter. Only used for binding all tables - * in one stable, user application must call 'loadTableInfo' API to load all table - * meta before calling this API. If the table meta is not cached locally, it will return error. - * @param {*} subTableName table name which is belong to an stable - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtSetSubTbname = function stmtSetSubTbname(subTableName) { - if (this._stmt == null) { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } else { - let stmtPrepare = this._chandle.stmtSetSubTbname(this._stmt, subTableName); - if (stmtPrepare != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } else { - console.log("stmtSetSubTbname success."); - } - } -} - -/** - * bind a whole line data, for both INSERT and SELECT. The parameter 'bind' points to an array - * contains the whole line data. Each item in array represents a column's value, the item - * number and sequence should keep consistence with columns in sql statement. The usage of - * structure TAOS_BIND is the same with MYSQL_BIND in MySQL. - * @param {*} binds points to an array contains the whole line data. - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtBindParam = function stmtBindParam(binds) { - if (this._stmt == null) { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } else { - let stmtPrepare = this._chandle.bindParam(this._stmt, binds); - if (stmtPrepare != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } else { - console.log("bindParam success."); - } - } -} - -/** - * Bind a single column's data, INTERNAL used and for INSERT only. - * @param {TaosMultiBind} mbind points to a column's data which could be the one or more lines. - * @param {*} colIndex the column's index in prepared sql statement, it starts from 0. - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtBindSingleParamBatch = function stmtBindSingleParamBatch(mbind, colIndex) { - if (this._stmt == null) { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } else { - let stmtPrepare = this._chandle.stmtBindSingleParamBatch(this._stmt, mbind, colIndex); - if (stmtPrepare != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } else { - console.log("stmtBindSingleParamBatch success."); - } - } -} - -/** - * For INSERT only. - * Bind one or multiple lines data. - * @param {*} mbinds Points to an array contains one or more lines data.The item - * number and sequence should keep consistence with columns - * n sql statement. - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtBindParamBatch = function stmtBindParamBatch(mbinds) { - if (this._stmt == null) { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } else { - let stmtPrepare = this._chandle.stmtBindParamBatch(this._stmt, mbinds); - if (stmtPrepare != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } else { - console.log("stmtBindParamBatch success."); - } - } -} - -/** - * add all current bound parameters to batch process, for INSERT only. - * Must be called after each call to bindParam/bindSingleParamBatch, - * or all columns binds for one or more lines with bindSingleParamBatch. User - * application can call any bind parameter API again to bind more data lines after calling - * to this API. - * @param {*} stmt - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtAddBatch = function stmtAddBatch() { - if (this._stmt == null) { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } else { - let addBatchRes = this._chandle.addBatch(this._stmt); - if (addBatchRes != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } - else { - console.log("addBatch success."); - } - } -} - -/** - * actually execute the INSERT/SELECT sql statement. User application can continue - * to bind new data after calling to this API. - * @param {*} stmt - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtExecute = function stmtExecute() { - if (this._stmt != null) { - let stmtExecRes = this._chandle.stmtExecute(this._stmt); - if (stmtExecRes != 0) { - throw new errors.DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } else { - console.log("stmtExecute success.") - } - } else { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } -} - -/** - * For SELECT only,getting the query result. - * User application should free it with API 'FreeResult' at the end. - * @returns Not NULL for success, NULL for failure. - */ -TDengineCursor.prototype.stmtUseResult = function stmtUseResult() { - if (this._stmt != null) { - this._result = this._chandle.stmtUseResult(this._stmt); - let res = this._chandle.errno(this._result); - if (res != 0) { - throw new errors.DatabaseError(this._chandle.errStr(this._stmt)); - } else { - console.log("stmtUseResult success."); - let fieldCount = this._chandle.fieldsCount(this._result); - if (fieldCount != 0) { - this._fields = this._chandle.useResult(this._result); - this.fields = this._fields; - } - } - } else { - throw new errors.DatabaseError("stmt is null,init stmt first"); - } -} - -/** - * user application call this API to load all tables meta info. - * This method must be called before stmtSetSubTbname(IntPtr stmt, string name); - * @param {*} tableList tables need to load meta info are form in an array - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.loadTableInfo = function loadTableInfo(tableList) { - if (this._connection._conn != null) { - let stmtExecRes = this._chandle.loadTableInfo(this._connection._conn, tableList); - if (stmtExecRes != 0) { - throw new errors.DatabaseError(`loadTableInfo() failed,code ${stmtExecRes}`); - } else { - console.log("loadTableInfo success.") - } - } else { - throw new errors.DatabaseError("taos connection is null."); - } -} - -/** - * close STMT object and free resources. - * @param {*} stmt - * @returns 0 for success, non-zero for failure. - */ -TDengineCursor.prototype.stmtClose = function stmtClose() { - if (this._stmt == null) { - throw new DatabaseError("stmt is null,init stmt first"); - } else { - let closeStmtRes = this._chandle.closeStmt(this._stmt); - if (closeStmtRes != 0) { - throw new DatabaseError(this._chandle.stmtErrStr(this._stmt)); - } - else { - console.log("closeStmt success."); - } - } -} \ No newline at end of file diff --git a/src/connector/nodejs/nodetaos/error.js b/src/connector/nodejs/nodetaos/error.js deleted file mode 100644 index 8ab91a50c7d81a4675246617e0969ee8c81c514e..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/error.js +++ /dev/null @@ -1,96 +0,0 @@ - -/** - * TDengine Error Class - * @ignore - */ -class TDError extends Error { - constructor(args) { - super(args) - this.name = "TDError"; - } -} -/** Exception raised for important warnings like data truncations while inserting. - * @ignore - */ -class Warning extends Error { - constructor(args) { - super(args) - this.name = "Warning"; - } -} -/** Exception raised for errors that are related to the database interface rather than the database itself. - * @ignore - */ -class InterfaceError extends TDError { - constructor(args) { - super(args) - this.name = "TDError.InterfaceError"; - } -} -/** Exception raised for errors that are related to the database. - * @ignore - */ -class DatabaseError extends TDError { - constructor(args) { - super(args) - this.name = "TDError.DatabaseError"; - } -} -/** Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range. - * @ignore - */ -class DataError extends DatabaseError { - constructor(args) { - super(args) - this.name = "TDError.DatabaseError.DataError"; - } -} -/** Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer - * @ignore - */ -class OperationalError extends DatabaseError { - constructor(args) { - super(args) - this.name = "TDError.DatabaseError.OperationalError"; - } -} -/** Exception raised when the relational integrity of the database is affected. - * @ignore - */ -class IntegrityError extends DatabaseError { - constructor(args) { - super(args) - this.name = "TDError.DatabaseError.IntegrityError"; - } -} -/** Exception raised when the database encounters an internal error. - * @ignore - */ -class InternalError extends DatabaseError { - constructor(args) { - super(args) - this.name = "TDError.DatabaseError.InternalError"; - } -} -/** Exception raised for programming errors. - * @ignore - */ -class ProgrammingError extends DatabaseError { - constructor(args) { - super(args) - this.name = "TDError.DatabaseError.ProgrammingError"; - } -} -/** Exception raised in case a method or database API was used which is not supported by the database. - * @ignore - */ -class NotSupportedError extends DatabaseError { - constructor(args) { - super(args) - this.name = "TDError.DatabaseError.NotSupportedError"; - } -} - -module.exports = { - TDError, Warning, InterfaceError, DatabaseError, DataError, OperationalError, IntegrityError, InternalError, ProgrammingError, NotSupportedError -}; diff --git a/src/connector/nodejs/nodetaos/globalfunc.js b/src/connector/nodejs/nodetaos/globalfunc.js deleted file mode 100644 index cf7344c868ee94831eba47ff55369a684e34b02f..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/globalfunc.js +++ /dev/null @@ -1,14 +0,0 @@ -/* Wrap a callback, reduce code amount */ -function wrapCB(callback, input) { - if (typeof callback === 'function') { - callback(input); - } - return; -} -global.wrapCB = wrapCB; -function toTaosTSString(date) { - date = new Date(date); - let tsArr = date.toISOString().split("T") - return tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length-1); -} -global.toTaosTSString = toTaosTSString; diff --git a/src/connector/nodejs/nodetaos/taosBind.js b/src/connector/nodejs/nodetaos/taosBind.js deleted file mode 100644 index b70d035b9fcf2eff5d0d1edb7114b5549eda83d4..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/taosBind.js +++ /dev/null @@ -1,377 +0,0 @@ -const ref = require('ref-napi'); -const StructType = require('ref-struct-di')(ref); -const taosConst = require('./constants'); -const { TDError } = require('./error'); - -var bufferType = ref.types.int32; -var buffer = ref.refType(ref.types.void); -var bufferLength = ref.types.uint64; -var length = ref.refType(ref.types.uint64); -var isNull = ref.refType(ref.types.int32); -var is_unsigned = ref.types.int; -var error = ref.refType(ref.types.void); -var u = ref.types.int64; -var allocated = ref.types.uint32; - -var TAOS_BIND = StructType({ - buffer_type: bufferType, - buffer: buffer, - buffer_length: bufferLength, - length: length, - is_null: isNull, - is_unsigned: is_unsigned, - error: error, - u: u, - allocated: allocated, -}); - -class TaosBind { - constructor(num) { - this.buf = Buffer.alloc(TAOS_BIND.size * num); - this.num = num; - this.index = 0; - } - /** - * Used to bind null value for all data types that tdengine supports. - */ - bindNil() { - if (!this._isOutOfBound()) { - let nil = new TAOS_BIND({ - buffer_type: taosConst.C_NULL, - is_null: ref.alloc(ref.types.int32, 1), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, nil); - this.index++ - } else { - throw new TDError(`bindNil() failed,since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {bool} val is not null bool value,true or false. - */ - bindBool(val) { - if (!this._isOutOfBound()) { - let bl = new TAOS_BIND({ - buffer_type: taosConst.C_BOOL, - buffer: ref.alloc(ref.types.bool, val), - buffer_length: ref.types.bool.size, - length: ref.alloc(ref.types.uint64, ref.types.bool.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, bl); - this.index++ - } else { - throw new TDError(`bindBool() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - - } - - /** - * - * @param {int8} val is a not null tinyint value. - */ - bindTinyInt(val) { - if (!this._isOutOfBound()) { - let tinnyInt = new TAOS_BIND({ - buffer_type: taosConst.C_TINYINT, - buffer: ref.alloc(ref.types.int8, val), - buffer_length: ref.types.int8.size, - length: ref.alloc(ref.types.uint64, ref.types.int8.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, tinnyInt); - this.index++ - } else { - throw new TDError(`bindTinyInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {short} val is a not null small int value. - */ - bindSmallInt(val) { - if (!this._isOutOfBound()) { - let samllint = new TAOS_BIND({ - buffer_type: taosConst.C_SMALLINT, - buffer: ref.alloc(ref.types.int16, val), - buffer_length: ref.types.int16.size, - length: ref.alloc(ref.types.uint64, ref.types.int16.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, samllint); - this.index++ - } else { - throw new TDError(`bindSmallInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - - } - - /** - * - * @param {int} val is a not null int value. - */ - bindInt(val) { - if (!this._isOutOfBound()) { - let int = new TAOS_BIND({ - buffer_type: taosConst.C_INT, - buffer: ref.alloc(ref.types.int32, val), - buffer_length: ref.types.int32.size, - length: ref.alloc(ref.types.uint64, ref.types.int32.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, int); - this.index++ - } else { - throw new TDError(`bindInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - - } - - /** - * - * @param {long} val is not null big int value. - */ - bindBigInt(val) { - if (!this._isOutOfBound()) { - let bigint = new TAOS_BIND({ - buffer_type: taosConst.C_BIGINT, - buffer: ref.alloc(ref.types.int64, val.toString()), - buffer_length: ref.types.int64.size, - length: ref.alloc(ref.types.uint64, ref.types.int64.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, bigint); - this.index++ - } else { - throw new TDError(`bindBigInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {float} val is a not null float value - */ - bindFloat(val) { - if (!this._isOutOfBound()) { - let float = new TAOS_BIND({ - buffer_type: taosConst.C_FLOAT, - buffer: ref.alloc(ref.types.float, val), - buffer_length: ref.types.float.size, - length: ref.alloc(ref.types.uint64, ref.types.float.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, float); - this.index++ - } else { - throw new TDError(`bindFloat() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - /** - * - * @param {double} val is a not null double value - */ - bindDouble(val) { - if (!this._isOutOfBound()) { - let double = new TAOS_BIND({ - buffer_type: taosConst.C_DOUBLE, - buffer: ref.alloc(ref.types.double, val), - buffer_length: ref.types.double.size, - length: ref.alloc(ref.types.uint64, ref.types.double.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, double); - this.index++ - } else { - throw new TDError(`bindDouble() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {string} val is a string. - */ - bindBinary(val) { - let cstringBuf = ref.allocCString(val, 'utf-8'); - if (!this._isOutOfBound()) { - let binary = new TAOS_BIND({ - buffer_type: taosConst.C_BINARY, - buffer: cstringBuf, - buffer_length: cstringBuf.length, - length: ref.alloc(ref.types.uint64, cstringBuf.length - 1), - is_null: ref.alloc(ref.types.int32, 0), - }); - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, binary); - this.index++ - } else { - throw new TDError(`bindBinary() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {long} val is a not null timestamp(long) values. - */ - bindTimestamp(val) { - let ts = new TAOS_BIND({ - buffer_type: taosConst.C_TIMESTAMP, - buffer: ref.alloc(ref.types.int64, val), - buffer_length: ref.types.int64.size, - length: ref.alloc(ref.types.uint64, ref.types.int64.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, ts); - this.index++ - } - - /** - * - * @param {string} val is a string. - */ - bindNchar(val) { - let cstringBuf = ref.allocCString(val, 'utf-8'); - if (!this._isOutOfBound()) { - let nchar = new TAOS_BIND({ - buffer_type: taosConst.C_NCHAR, - buffer: cstringBuf, - buffer_length: cstringBuf.length, - length: ref.alloc(ref.types.uint64, cstringBuf.length - 1), - is_null: ref.alloc(ref.types.int32, 0), - }); - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, nchar); - this.index++ - } else { - throw new TDError(`bindNchar() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {uint8} val is a not null unsinged tinyint value. - */ - bindUTinyInt(val) { - if (!this._isOutOfBound()) { - let uTinyInt = new TAOS_BIND({ - buffer_type: taosConst.C_TINYINT_UNSIGNED, - buffer: ref.alloc(ref.types.uint8, val), - buffer_length: ref.types.uint8.size, - length: ref.alloc(ref.types.uint64, ref.types.uint8.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, uTinyInt); - this.index++ - } else { - throw new TDError(`bindUTinyInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {uint16} val is a not null unsinged smallint value. - */ - bindUSmallInt(val) { - if (!this._isOutOfBound()) { - let uSmallInt = new TAOS_BIND({ - buffer_type: taosConst.C_SMALLINT_UNSIGNED, - buffer: ref.alloc(ref.types.uint16, val), - buffer_length: ref.types.uint16.size, - length: ref.alloc(ref.types.uint64, ref.types.uint16.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, uSmallInt); - this.index++ - } else { - throw new TDError(`bindUSmallInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {uint32} val is a not null unsinged int value. - */ - bindUInt(val) { - if (!this._isOutOfBound()) { - let uInt = new TAOS_BIND({ - buffer_type: taosConst.C_INT_UNSIGNED, - buffer: ref.alloc(ref.types.uint32, val), - buffer_length: ref.types.uint32.size, - length: ref.alloc(ref.types.uint64, ref.types.uint32.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, uInt); - this.index++ - } else { - throw new TDError(`bindUInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {uint64} val is a not null unsinged bigint value. - */ - bindUBigInt(val) { - if (!this._isOutOfBound()) { - let uBigInt = new TAOS_BIND({ - buffer_type: taosConst.C_BIGINT_UNSIGNED, - buffer: ref.alloc(ref.types.uint64, val.toString()), - buffer_length: ref.types.uint64.size, - length: ref.alloc(ref.types.uint64, ref.types.uint64.size), - is_null: ref.alloc(ref.types.int32, 0), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, uBigInt); - this.index++ - } else { - throw new TDError(`bindUBigInt() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - } - - /** - * - * @param {jsonStr} val is a json string. Such as '{\"key1\":\"taosdata\"}' - */ - bindJson(val) { - let cstringBuf = ref.allocCString(val, 'utf-8'); - if (!this._isOutOfBound()) { - let jsonType = new TAOS_BIND({ - buffer_type: taosConst.C_JSON_TAG, - buffer: cstringBuf, - buffer_length: cstringBuf.length, - length: ref.alloc(ref.types.uint64, cstringBuf.length - 1), - is_null: ref.alloc(ref.types.int32, 0), - }); - - TAOS_BIND.set(this.buf, this.index * TAOS_BIND.size, jsonType); - this.index++ - } else { - throw new TDError(`bindJson() failed with ${val},since index:${this.index} is out of Buffer bound ${this.num}.`); - } - - } - - /** - * - * @returns binded buffer. - */ - getBind() { - return this.buf; - } - - _isOutOfBound() { - if (this.num > this.index) { - return false; - } else { - return true; - } - } -} -module.exports = TaosBind; diff --git a/src/connector/nodejs/nodetaos/taosMultiBind.js b/src/connector/nodejs/nodetaos/taosMultiBind.js deleted file mode 100755 index d4134a9ef6df29f196e9b573a5f8e2e524de21ed..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/taosMultiBind.js +++ /dev/null @@ -1,531 +0,0 @@ -const ref = require('ref-napi'); -const StructType = require('ref-struct-di')(ref); -const taosConst = require('./constants'); - -var TAOS_MULTI_BIND = StructType({ - 'buffer_type': ref.types.int, - 'buffer': ref.refType(ref.types.void), - 'buffer_length': ref.types.ulong, - 'length': ref.refType(ref.types.int), - 'is_null': ref.refType(ref.types.char), - 'num': ref.types.int, -}) - -class TaosMultiBind { - constructor() { - } - - /** - * To bind bool through an array. - * @param {*} boolArray is an boolean array that stores one column's value. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with bool type. - */ - multiBindBool(boolArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.bool.size * boolArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * boolArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * boolArray.length); - - boolArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.bool.size, ref.types.int) - if (element == null || element == undefined) { - // ref.set(mbindBufferBuf,index * ref.types.int64.size,taosConst.C_BIGINT_NULL,ref.types.int64); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.bool.size, element, ref.types.bool); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_BOOL, - buffer: mbindBufferBuf, - buffer_length: ref.types.bool.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: boolArray.length, - }) - return mbind; - } - - /** - * to bind tiny int through an array. - * @param {*} tinyIntArray is an array that stores tiny int. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with tiny int. - */ - multiBindTinyInt(tinyIntArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.int8.size * tinyIntArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * tinyIntArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * tinyIntArray.length); - - tinyIntArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.int8.size, ref.types.int) - if (element == null || element == undefined) { - // ref.set(mbindBufferBuf,index * ref.types.int64.size,taosConst.C_BIGINT_NULL,ref.types.int64); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.int8.size, element, ref.types.int8); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_TINYINT, - buffer: mbindBufferBuf, - buffer_length: ref.types.int8.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: tinyIntArray.length, - }) - return mbind; - } - - /** - * To bind small int through an array. - * @param {*} smallIntArray is an array that stores small int. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with small int. - */ - multiBindSmallInt(smallIntArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.int16.size * smallIntArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * smallIntArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * smallIntArray.length); - - smallIntArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.int16.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.int16.size, element, ref.types.int16); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_SMALLINT, - buffer: mbindBufferBuf, - buffer_length: ref.types.int16.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: smallIntArray.length, - }) - return mbind; - } - - /** - * To bind int through an array. - * @param {*} intArray is an array that stores int. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with int. - */ - multiBindInt(intArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.int.size * intArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * intArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * intArray.length); - - intArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.int.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.int.size, element, ref.types.int); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_INT, - buffer: mbindBufferBuf, - buffer_length: ref.types.int.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: intArray.length, - }) - return mbind; - } - - /** - * To bind big int through an array. - * @param {*} bigIntArray is an array that stores big int. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with big int. - */ - multiBindBigInt(bigIntArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.int64.size * bigIntArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * bigIntArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * bigIntArray.length); - - bigIntArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.int64.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.writeInt64LE(mbindBufferBuf, index * ref.types.int64.size, element.toString()) - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_BIGINT, - buffer: mbindBufferBuf, - buffer_length: ref.types.int64.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: bigIntArray.length, - }) - return mbind; - } - - /** - * To bind float through an array. - * @param {*} floatArray is an array that stores float. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with float. - */ - multiBindFloat(floatArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.float.size * floatArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * floatArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * floatArray.length); - - floatArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.float.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.float.size, element, ref.types.float); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_FLOAT, - buffer: mbindBufferBuf, - buffer_length: ref.types.float.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: floatArray.length, - }) - return mbind; - } - - /** - * To bind double through an array. - * @param {*} doubleArray is an array that stores double. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with double. - */ - multiBindDouble(doubleArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.double.size * doubleArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * doubleArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * doubleArray.length); - - doubleArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.double.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.double.size, element, ref.types.double); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_DOUBLE, - buffer: mbindBufferBuf, - buffer_length: ref.types.double.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: doubleArray.length, - }) - return mbind; - } - - /** - * To bind tdengine's binary through an array. - * @param {*} strArr is an array that stores string. - * (Null string can be defined as undefined or null,notice '' is not null.) - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with binary. - */ - multiBindBinary(strArr) { - let maxStrUFT8Length = this._maxUTF8StrArrLength(strArr); - console.log(`maxStrUFT8Length * strArr.length=${maxStrUFT8Length * strArr.length}`); - let mbindBufferBuf = Buffer.alloc(maxStrUFT8Length * strArr.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * strArr.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * strArr.length); - - strArr.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, this._stringUTF8Length(element), ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.writeCString(mbindBufferBuf, index * maxStrUFT8Length, element, 'utf8'); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_BINARY, - buffer: mbindBufferBuf, - buffer_length: maxStrUFT8Length, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: strArr.length, - }) - return mbind; - } - - /** - * To bind timestamp through an array. - * @param {*} timestampArray is an array that stores timestamp. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with timestamp. - */ - multiBindTimestamp(timestampArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.int64.size * timestampArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * timestampArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * timestampArray.length); - - timestampArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.int64.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.writeInt64LE(mbindBufferBuf, index * ref.types.int64.size, element.toString()) - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_TIMESTAMP, - buffer: mbindBufferBuf, - buffer_length: ref.types.int64.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: timestampArray.length, - }) - return mbind; - } - - /** - * To bind tdengine's nchar through an array. - * @param {*} strArr is an array that stores string. - * (Null string can be defined as undefined or null,notice '' is not null.) - * @returns A instance of struct TAOS_MULTI_BIND that contains one nchar column's data with nchar. - */ - multiBindNchar(strArr) { - let maxStrUFT8Length = this._maxUTF8StrArrLength(strArr); - // console.log(`maxStrUFT8Length * strArr.length=${maxStrUFT8Length * strArr.length}`); - let mbindBufferBuf = Buffer.alloc(maxStrUFT8Length * strArr.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * strArr.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * strArr.length); - - strArr.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, this._stringUTF8Length(element), ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.writeCString(mbindBufferBuf, index * maxStrUFT8Length, element, 'utf8'); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_NCHAR, - buffer: mbindBufferBuf, - buffer_length: maxStrUFT8Length, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: strArr.length, - }) - return mbind; - } - - /** - * to bind unsigned tiny int through an array. - * @param {*} uTinyIntArray is an array that stores unsigned tiny int. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with unsigned tiny int. - */ - multiBindUTinyInt(uTinyIntArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.uint8.size * uTinyIntArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * uTinyIntArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * uTinyIntArray.length); - - uTinyIntArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.uint8.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.uint8.size, element, ref.types.uint8); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_TINYINT_UNSIGNED, - buffer: mbindBufferBuf, - buffer_length: ref.types.uint8.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: uTinyIntArray.length, - }) - return mbind; - } - - /** - * To bind unsigned small int through an array. - * @param {*} uSmallIntArray is an array that stores unsigned small int. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with unsigned small int. - */ - multiBindUSmallInt(uSmallIntArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.uint16.size * uSmallIntArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * uSmallIntArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * uSmallIntArray.length); - - uSmallIntArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.uint16.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.uint16.size, element, ref.types.uint16); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_SMALLINT_UNSIGNED, - buffer: mbindBufferBuf, - buffer_length: ref.types.uint16.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: uSmallIntArray.length, - }) - return mbind; - } - - /** - * To bind unsigned int through an array. - * @param {*} uIntArray is an array that stores unsigned int. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with unsigned int. - */ - multiBindUInt(uIntArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.uint.size * uIntArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * uIntArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * uIntArray.length); - - uIntArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.uint.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - ref.set(mbindBufferBuf, index * ref.types.uint.size, element, ref.types.uint); - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_INT_UNSIGNED, - buffer: mbindBufferBuf, - buffer_length: ref.types.uint.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: uIntArray.length, - }) - return mbind; - } - - /** - * To bind unsigned big int through an array. - * @param {*} uBigIntArray is an array that stores unsigned big int. - * @returns A instance of struct TAOS_MULTI_BIND that contains one column's data with unsigned big int. - */ - multiBindUBigInt(uBigIntArray) { - let mbindBufferBuf = Buffer.alloc(ref.types.uint64.size * uBigIntArray.length); - let mbindLengBuf = Buffer.alloc(ref.types.int.size * uBigIntArray.length); - let mbindIsNullBuf = Buffer.alloc(ref.types.char.size * uBigIntArray.length); - - uBigIntArray.forEach((element, index) => { - ref.set(mbindLengBuf, index * ref.types.int.size, ref.types.uint64.size, ref.types.int) - if (element == null || element == undefined) { - ref.set(mbindIsNullBuf, index * ref.types.char.size, 1, ref.types.char); - } else { - - ref.writeUInt64LE(mbindBufferBuf, index * ref.types.uint64.size, element.toString()) - ref.set(mbindIsNullBuf, index * ref.types.char.size, 0, ref.types.char); - } - - }); - - let mbind = new TAOS_MULTI_BIND({ - buffer_type: taosConst.C_BIGINT_UNSIGNED, - buffer: mbindBufferBuf, - buffer_length: ref.types.uint64.size, - length: mbindLengBuf, - is_null: mbindIsNullBuf, - num: uBigIntArray.length, - }) - return mbind; - } - - - // multiBJson(jsonArray) no need to support.Since till now TDengine only support json tag - // and there is no need to support bind json tag in TAOS_MULTI_BIND. - - /** - * - * @param {*} strArr an string array - * @returns return the max length of the element in strArr in "UFT-8" encoding. - */ - _maxUTF8StrArrLength(strArr) { - let max = 0; - strArr.forEach((item) => { - let realLeng = 0; - let itemLength = -1; - if (item == null || item == undefined) { - itemLength = 0; - } else { - itemLength = item.length; - } - - let charCode = -1; - for (let i = 0; i < itemLength; i++) { - charCode = item.charCodeAt(i); - if (charCode >= 0 && charCode <= 128) { - realLeng += 1; - } else { - realLeng += 3; - } - } - if (max < realLeng) { - max = realLeng - }; - }); - return max; - } - - /** - * - * @param {*} str a string. - * @returns return the length of the input string encoding with utf-8. - */ - _stringUTF8Length(str) { - let leng = 0; - if (str == null || str == undefined) { - leng = 0; - } else { - for (let i = 0; i < str.length; i++) { - if (str.charCodeAt(i) >= 0 && str.charCodeAt(i) <= 128) { - leng += 1; - } else { - leng += 3; - } - } - } - return leng; - } -} -// console.log(TAOS_MULTI_BIND.size) -module.exports = { TaosMultiBind, TAOS_MULTI_BIND }; \ No newline at end of file diff --git a/src/connector/nodejs/nodetaos/taosMultiBindArr.js b/src/connector/nodejs/nodetaos/taosMultiBindArr.js deleted file mode 100755 index 68c9c95bddad725b6dc10fe7766c1ad46adc2919..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/taosMultiBindArr.js +++ /dev/null @@ -1,250 +0,0 @@ -const ref = require('ref-napi'); -const { TDError } = require('./error'); -const { TAOS_MULTI_BIND, TaosMultiBind } = require('./taosMultiBind'); - -const TAOS_MULTI_BIND_SIZE = TAOS_MULTI_BIND.size; - -class TaosMultiBindArr extends TaosMultiBind { - /** - * The constructor,initial basic parameters and alloc buffer. - * @param {*} numOfColumns the number of column that you want to bind parameters. - */ - constructor(numOfColumns) { - super(); - this.taosMBindArrBuf = Buffer.alloc(numOfColumns * TAOS_MULTI_BIND_SIZE); - this.index = 0; - this.bound = numOfColumns; - } - - /** - * Used to bind boolean column's values. - * @param {*} boolArray An array of bool value, - * represents the bool values you want to bind. - */ - multiBindBool(boolArray) { - if (this.bound > this.index) { - let mBindBool = super.multiBindBool(boolArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindBool); - this.index += 1; - } else { - throw new TDError(`multiBindArrBool() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - /** - * Used to bind tiny int column's values. - * @param {*} tinyIntArray An array of tiny int value. - * represents the tiny int values you want to bind. - */ - multiBindTinyInt(tinyIntArray) { - if (this.bound > this.index) { - let mBindTinyInt = super.multiBindTinyInt(tinyIntArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindTinyInt); - this.index += 1; - } else { - throw new TDError(`multiBindArrTinyInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - /** - * Used to bind small int column's value. - * @param {*} smallIntArray An array of small int values, - * represents the small int values you want to bind. - */ - multiBindSmallInt(smallIntArray) { - if (this.bound > this.index) { - let mBindSmallInt = super.multiBindSmallInt(smallIntArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindSmallInt); - this.index += 1; - } else { - throw new TDError(`multiBindSmallInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - - } - - /** - * Used to bind int column's value. - * @param {*} intArray An array of int values, - * represents the int values you want to bind. - */ - multiBindInt(intArray) { - if (this.bound > this.index) { - let mBindInt = super.multiBindInt(intArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindInt); - this.index += 1; - } else { - throw new TDError(`multiBindInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - - } - - /** - * Used to bind big int column's value. - * @param {*} bigIntArray An array of big int values, - * represents the big int values you want to bind. - */ - multiBindBigInt(bigIntArray) { - if (this.bound > this.index) { - let mBindBigInt = super.multiBindBigInt(bigIntArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindBigInt); - this.index += 1; - } else { - throw new TDError(`multiBindBigInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - - } - - /** - * Used to bind float column's value. - * @param {*} floatArray An array of float values, - * represents the float values you want to bind. - */ - multiBindFloat(floatArray) { - if (this.bound > this.index) { - let mBindFloat = super.multiBindFloat(floatArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindFloat); - this.index += 1; - } else { - throw new TDError(`multiBindFloat() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - - } - - /** - * Used to bind double column's value. - * @param {*} doubleArray An array of double values, - * represents the double values you want to bind. - */ - multiBindDouble(doubleArray) { - if (this.bound > this.index) { - let mBindDouble = super.multiBindDouble(doubleArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindDouble); - this.index += 1; - } else { - throw new TDError(`multiBindDouble() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - - } - - /** - * Used to bind binary column's value. - * @param {*} strArr An array of binary(string) values, - * represents the binary values you want to bind. - * Notice '' is not equal to TDengine's "null" value. - */ - multiBindBinary(strArr) { - if (this.bound > this.index) { - let mBindBinary = super.multiBindBinary(strArr); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindBinary); - this.index += 1; - } else { - throw new TDError(`multiBindBinary() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - /** - * Used to bind timestamp column's values. - * @param {*} timestampArray An array of timestamp values, - * represents the timestamp values you want to bind. - */ - multiBindTimestamp(timestampArray) { - if (this.bound > this.index) { - let mBindTimestamp = super.multiBindTimestamp(timestampArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindTimestamp); - this.index += 1; - } else { - throw new TDError(`multiBindArrTimestamp() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - /** - * Used to bind nchar column's value. - * @param {*} strArr An array of nchar(string) values, - * represents the nchar values you want to bind. - * Notice '' is not equal to TDengine's "null" value. - */ - multiBindNchar(strArr) { - if (this.bound > this.index) { - let mBindNchar = super.multiBindNchar(strArr); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindNchar); - this.index += 1; - } else { - throw new TDError(`multiBindNchar() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - /** - * Used to bind unsigned tiny int column's value. - * @param {*} uTinyIntArray An array of unsigned tiny int values, - * represents the unsigned tiny int values you want to bind. - */ - multiBindUTinyInt(uTinyIntArray) { - if (this.bound > this.index) { - let mBindNchar = super.multiBindUTinyInt(uTinyIntArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindNchar); - this.index += 1; - } else { - throw new TDError(`multiBindUTinyInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - /** - * Used to bind unsigned small int column's value. - * @param {*} uSmallIntArray An array of unsigned small int value, - * represents the unsigned small int values you want to bind. - */ - multiBindUSmallInt(uSmallIntArray) { - if (this.bound > this.index) { - let mBindUSmallInt = super.multiBindUSmallInt(uSmallIntArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindUSmallInt); - this.index += 1; - } else { - throw new TDError(`multiBindUSmallInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - /** - * Used to bind unsigned int column's value. - * @param {*} uIntArray An array of unsigned int column's value, - * represents the unsigned int values you want to bind. - */ - multiBindUInt(uIntArray) { - if (this.bound > this.index) { - let mBindUInt = super.multiBindUInt(uIntArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindUInt); - this.index += 1; - } else { - throw new TDError(`multiBindUInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - /** - * Used to bind unsigned big int column's value. - * @param {*} uBigIntArray An array of unsigned big int column's value, - * represents the unsigned big int values you want to bind. - */ - multiBindUBigInt(uBigIntArray) { - if (this.bound > this.index) { - let mBindUBigInt = super.multiBindUBigInt(uBigIntArray); - TAOS_MULTI_BIND.set(this.taosMBindArrBuf, this.index * TAOS_MULTI_BIND_SIZE, mBindUBigInt); - this.index += 1; - } else { - throw new TDError(`multiBindUBigInt() failed,since index:${this.index} is out of Buffer bound ${this.bound}.`) - } - } - - // multiBJson(jsonArray) no need to support.Since till now TDengine only support json tag - // and there is no need to support bind json tag in TAOS_MULTI_BIND. - - - /** - * After all the parameters have been prepared and stored - * in the buffer, Call this method to get the buffer. - * @returns return the buffer which stores all the parameters. - */ - getMultiBindArr() { - return this.taosMBindArrBuf; - } - -} -module.exports = TaosMultiBindArr; \ No newline at end of file diff --git a/src/connector/nodejs/nodetaos/taosobjects.js b/src/connector/nodejs/nodetaos/taosobjects.js deleted file mode 100644 index 3bc0fe0aca060a32daa7a5cebd2dbfb99ac29a7c..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/taosobjects.js +++ /dev/null @@ -1,152 +0,0 @@ -const FieldTypes = require('./constants'); -const util = require('util'); -/** - * Various objects such as TaosRow and TaosColumn that help make parsing data easier - * @module TaosObjects - * - */ - -/** - * The TaosRow object. Contains the data from a retrieved row from a database and functions that parse the data. - * @typedef {Object} TaosRow - A row of data retrieved from a table. - * @global - * @example - * var trow = new TaosRow(row); - * console.log(trow.data); - */ -function TaosRow(row) { - this.data = row; - this.length = row.length; - return this; -} - -/** - * @typedef {Object} TaosField - A field/column's metadata from a table. - * @global - * @example - * var tfield = new TaosField(field); - * console.log(tfield.name); - */ - -function TaosField(field) { - this._field = field; - this.name = field.name; - this.type = FieldTypes.getType(field.type); - return this; -} - -/** - * A TaosTimestamp object, which is the standard date object with added functionality - * @global - * @memberof TaosObjects - * @param {Date} date - A Javascript date time object or the time in milliseconds past 1970-1-1 00:00:00.000 - */ -class TaosTimestamp extends Date { - constructor(date, precision = 0) { - if (precision === 1) { - super(Math.floor(date / 1000)); - this.precisionExtras = date % 1000; - } else if (precision === 2) { - // use BigInt to fix: 1623254400999999999 / 1000000 = 1623254401000 which not expected - super(parseInt(BigInt(date) / 1000000n)); - // use BigInt to fix: 1625801548423914405 % 1000000 = 914496 which not expected (914405) - this.precisionExtras = parseInt(BigInt(date) % 1000000n); - } else { - super(parseInt(date)); - } - this.precision = precision; - } - - /** - * TDengine raw timestamp. - * @returns raw taos timestamp (int64) - */ - taosTimestamp() { - if (this.precision == 1) { - return (this * 1000 + this.precisionExtras); - } else if (this.precision == 2) { - return (this * 1000000 + this.precisionExtras); - } else { - return Math.floor(this); - } - } - - /** - * Gets the microseconds of a Date. - * @return {Int} A microseconds integer - */ - getMicroseconds() { - if (this.precision == 1) { - return this.getMilliseconds() * 1000 + this.precisionExtras; - } else if (this.precision == 2) { - return this.getMilliseconds() * 1000 + this.precisionExtras / 1000; - } else { - return 0; - } - } - /** - * Gets the nanoseconds of a TaosTimestamp. - * @return {Int} A nanoseconds integer - */ - getNanoseconds() { - if (this.precision == 1) { - return this.getMilliseconds() * 1000000 + this.precisionExtras * 1000; - } else if (this.precision == 2) { - return this.getMilliseconds() * 1000000 + this.precisionExtras; - } else { - return 0; - } - } - - /** - * @returns {String} a string for timestamp string format - */ - _precisionExtra() { - if (this.precision == 1) { - return String(this.precisionExtras).padStart(3, '0'); - } else if (this.precision == 2) { - return String(this.precisionExtras).padStart(6, '0'); - } else { - return ''; - } - } - /** - * @function Returns the date into a string usable by TDengine - * @return {string} A Taos Timestamp String - */ - toTaosString() { - var tzo = -this.getTimezoneOffset(), - dif = tzo >= 0 ? '+' : '-', - pad = function (num) { - var norm = Math.floor(Math.abs(num)); - return (norm < 10 ? '0' : '') + norm; - }, - pad2 = function (num) { - var norm = Math.floor(Math.abs(num)); - if (norm < 10) return '00' + norm; - if (norm < 100) return '0' + norm; - if (norm < 1000) return norm; - }; - return this.getFullYear() + - '-' + pad(this.getMonth() + 1) + - '-' + pad(this.getDate()) + - ' ' + pad(this.getHours()) + - ':' + pad(this.getMinutes()) + - ':' + pad(this.getSeconds()) + - '.' + pad2(this.getMilliseconds()) + - '' + this._precisionExtra(); - } - - /** - * Custom console.log - * @returns {String} string format for debug - */ - [util.inspect.custom](depth, opts) { - return this.toTaosString() + JSON.stringify({ precision: this.precision, precisionExtras: this.precisionExtras }, opts); - } - toString() { - return this.toTaosString(); - } -} - -module.exports = { TaosRow, TaosField, TaosTimestamp } diff --git a/src/connector/nodejs/nodetaos/taosquery.js b/src/connector/nodejs/nodetaos/taosquery.js deleted file mode 100644 index 5a6d08fb8f5e74c102ebafaad6d0b1d29a9b741f..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/taosquery.js +++ /dev/null @@ -1,111 +0,0 @@ -var TaosResult = require('./taosresult') -require('./globalfunc.js') -module.exports = TaosQuery; - - -/** - * @class TaosQuery - * @classdesc The TaosQuery class is one level above the TDengine Cursor in that it makes sure to generally return promises from functions, and wrap - * all data with objects such as wrapping a row of data with Taos Row. This is meant to enable an higher level API that allows additional - * functionality and save time whilst also making it easier to debug and enter less problems with the use of promises. - * @param {string} query - Query to construct object from - * @param {TDengineCursor} cursor - The cursor from which this query will execute from - * @param {boolean} execute - Whether or not to immedietely execute the query synchronously and fetch all results. Default is false. - * @property {string} query - The current query in string format the TaosQuery object represents - * @return {TaosQuery} - * @since 1.0.6 - */ -function TaosQuery(query = "", cursor = null, execute = false) { - this.query = query; - this._cursor = cursor; - if (execute == true) { - return this.execute(); - } - return this; -} - -/** - * Executes the query object and returns a Promise - * @memberof TaosQuery - * @return {Promise} A promise that resolves with a TaosResult object, or rejects with an error - * @since 1.0.6 - */ -TaosQuery.prototype.execute = async function execute() { - var taosQuery = this; //store the current instance of taosQuery to avoid async issues? - var executionPromise = new Promise(function(resolve, reject) { - let data = []; - let fields = []; - let result; - try { - taosQuery._cursor.execute(taosQuery.query); - if (taosQuery._cursor._fields) fields = taosQuery._cursor._fields; - if (taosQuery._cursor._result != null) data = taosQuery._cursor.fetchall(); - result = new TaosResult(data, fields) - } - catch(err) { - reject(err); - } - resolve(result) - }); - return executionPromise; -} - -/** - * Executes the query object asynchronously and returns a Promise. Completes query to completion. - * @memberof TaosQuery - * @param {Object} options - Execution options - * @return {Promise} A promise that resolves with a TaosResult object, or rejects with an error - * @since 1.2.0 - */ -TaosQuery.prototype.execute_a = async function execute_a(options = {}) { - var executionPromise = new Promise( (resolve, reject) => { - - }); - var fres; - var frej; - var fetchPromise = new Promise( (resolve, reject) => { - fres = resolve; - frej = reject; - }); - let asyncCallbackFetchall = async function(param, res, numOfRows, blocks) { - if (numOfRows > 0) { - // Likely a query like insert - fres(); - } - else { - fres(new TaosResult(blocks.data, blocks.fields)); - } - } - let asyncCallback = async function(param, res, code) { - //upon success, we fetchall results - this._cursor.fetchall_a(res, options, asyncCallbackFetchall, {}); - } - this._cursor.execute_a(this.query, asyncCallback.bind(this), {}); - return fetchPromise; -} - -/** - * Bind arguments to the query and automatically parses them into the right format - * @param {array | ...args} args - A number of arguments to bind to each ? in the query - * @return {TaosQuery} - * @example - * // An example of binding a javascript date and a number to a query - * var query = cursor.query("select count(*) from meterinfo.meters where ts <= ? and areaid = ?").bind(new Date(), 3); - * var promise1 = query.execute(); - * promise1.then(function(result) { - * result.pretty(); // Log the prettified version of the results. - * }); - * @since 1.0.6 - */ -TaosQuery.prototype.bind = function bind(f, ...args) { - if (typeof f == 'object' && f.constructor.name != 'Array') args.unshift(f); //param is not an array object - else if (typeof f != 'object') args.unshift(f); - else { args = f; } - args.forEach(function(arg) { - if (arg.constructor.name == 'TaosTimestamp') arg = "\"" + arg.toTaosString() + "\""; - else if (arg.constructor.name == 'Date') arg = "\"" + toTaosTSString(arg) + "\""; - else if (typeof arg == 'string') arg = "\"" + arg + "\""; - this.query = this.query.replace(/\?/,arg); - }, this); - return this; -} diff --git a/src/connector/nodejs/nodetaos/taosresult.js b/src/connector/nodejs/nodetaos/taosresult.js deleted file mode 100644 index 1ea5abee9f6c3c2754081ad82ecdb51c3b5bd4d3..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/nodetaos/taosresult.js +++ /dev/null @@ -1,90 +0,0 @@ -require('./globalfunc.js') -const TaosObjects = require('./taosobjects'); -const TaosRow = TaosObjects.TaosRow; -const TaosField = TaosObjects.TaosField; - -module.exports = TaosResult; -/** - * @class TaosResult - * @classdesc A TaosResult class consts of the row data and the fields metadata, all wrapped under various objects for higher functionality. - * @param {Array} data - Array of result rows - * @param {Array} fields - Array of field meta data - * @property {Array} data - Array of TaosRows forming the result data (this does not include field meta data) - * @property {Array} fields - Array of TaosFields forming the fields meta data array. - * @return {TaosResult} - * @since 1.0.6 - */ -function TaosResult(data, fields) { - this.data = data.map(row => new TaosRow(row)); - this.rowcount = this.data.length; - this.fields = fields.map(field => new TaosField(field)); -} -/** - * Pretty print data and the fields meta data as if you were using the taos shell - * @memberof TaosResult - * @function pretty - * @since 1.0.6 - */ - -TaosResult.prototype.pretty = function pretty() { - let fieldsStr = ""; - let sizing = []; - this.fields.forEach((field, i) => { - if (field._field.type == 8 || field._field.type == 10 ) { - sizing.push(Math.max(field.name.length, field._field.bytes)); - } - else { - sizing.push(Math.max(field.name.length, suggestedMinWidths[field._field.type])); - } - fieldsStr += fillEmpty(Math.floor(sizing[i] / 2 - field.name.length / 2)) + field.name + fillEmpty(Math.ceil(sizing[i] / 2 - field.name.length / 2)) + " | "; - }); - var sumLengths = sizing.reduce((a, b) => a += b, (0)) + sizing.length * 3; - - console.log("\n" + fieldsStr); - console.log(printN("=", sumLengths)); - this.data.forEach(row => { - let rowStr = ""; - row.data.forEach((entry, i) => { - if (this.fields[i]._field.type == 9) { - entry = entry.toTaosString(); - } else { - entry = entry == null ? 'null' : entry.toString(); - } - rowStr += entry - rowStr += fillEmpty(sizing[i] - entry.length) + " | "; - }); - console.log(rowStr); - }); -} -const suggestedMinWidths = { - 0: 4, - 1: 4, - 2: 4, - 3: 6, - 4: 11, - 5: 20, - 6: 24, - 7: 24, - 8: 10, - 9: 25, - 10: 10, - 11: 4, - 12: 6, - 13: 11, - 14: 20, - 15: 20, -} -function printN(s, n) { - let f = ""; - for (let i = 0; i < n; i++) { - f += s; - } - return f; -} -function fillEmpty(n) { - let str = ""; - for (let i = 0; i < n; i++) { - str += " "; - } - return str; -} diff --git a/src/connector/nodejs/package.json b/src/connector/nodejs/package.json deleted file mode 100644 index 398ed59522ae9c31a26ee7db73dca5b02b517c9e..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "td2.0-connector", - "version": "2.0.10", - "description": "A Node.js connector for TDengine.", - "main": "tdengine.js", - "directories": { - "example": "examples", - "test": "test" - }, - "scripts": { - "test": "jest", - "catalog": "jest --json" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/taosdata/tdengine.git" - }, - "keywords": [ - "TDengine", - "TAOS Data", - "Time Series Database", - "Connector" - ], - "author": "TaosData Inc.", - "license": "AGPL-3.0-or-later", - "bugs": { - "url": "https://github.com/taosdata/tdengine/issues" - }, - "homepage": "https://github.com/taosdata/tdengine#readme", - "dependencies": { - "ffi-napi": "^3.1.0", - "lodash": "^4.17.21", - "ref-array-di": "^1.2.1", - "ref-napi": "^3.0.2", - "ref-struct-di": "^1.1.1" - }, - "devDependencies": { - "jest": "^27.4.7" - } -} diff --git a/src/connector/nodejs/tdengine.js b/src/connector/nodejs/tdengine.js deleted file mode 100644 index 275834bd4f2b5ba5a903049a5973a34287132175..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/tdengine.js +++ /dev/null @@ -1,16 +0,0 @@ -var TDengineConnection = require('./nodetaos/connection.js') -const TDengineConstant = require('./nodetaos/constants.js') -const TaosBind = require('./nodetaos/taosBind') -const { TaosMultiBind } = require('./nodetaos/taosMultiBind') -const TaosMultiBindArr = require('./nodetaos/taosMultiBindArr') - -module.exports = { - connect: function (connection = {}) { - return new TDengineConnection(connection); - }, - SCHEMALESS_PROTOCOL: TDengineConstant.SCHEMALESS_PROTOCOL, - SCHEMALESS_PRECISION: TDengineConstant.SCHEMALESS_PRECISION, - TaosBind, - TaosMultiBind, - TaosMultiBindArr, -} \ No newline at end of file diff --git a/src/connector/nodejs/test/cases/test.cases.js b/src/connector/nodejs/test/cases/test.cases.js deleted file mode 100644 index 6cf723331ef4330d56ee5d0db38e0a30b57eadb3..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/test/cases/test.cases.js +++ /dev/null @@ -1,805 +0,0 @@ -// const { testMatch } = require('../../jest.config'); -const taos = require('../../tdengine'); -const { getFeildsFromDll, buildInsertSql, getFieldArr, getResData } = require('../utils/utilTools') - -const author = 'xiaolei'; -const result = 'passed'; -const fileName = __filename.slice(__dirname.length + 1); - -// This is a taos connection -let conn; -// This is a Cursor -let c1; - -function executeUpdate(sql) { - console.log(sql); - c1.execute(sql); -} - -function executeQuery(sql) { - c1.execute(sql, { quiet: true }) - var data = c1.fetchall(); - let fields = c1.fields; - let resArr = []; - - data.forEach(row => { - row.forEach(data => { - if (data instanceof Date) { - // console.log("date obejct:"+data.valueOf()); - resArr.push(data.taosTimestamp()); - } else { - // console.log("not date:"+data); - resArr.push(data); - } - // console.log(data instanceof Date) - }) - }) - return { resData: resArr, resFeilds: fields }; -} - -beforeAll(() => { - conn = taos.connect({ host: "127.0.0.1", user: "root", password: "taosdata", config: "/etc/taos", port: 10 }); - c1 = conn.cursor(); - executeUpdate("create database if not exists node_test_db keep 3650;"); - executeUpdate("use node_test_db;"); -}); - -// Clears the database and adds some testing data. -// Jest will wait for this promise to resolve before running tests. -afterAll(() => { - executeUpdate("drop database if exists node_test_db;"); - conn.close(); -}); - -describe("test unsigned type", () => { - - test(`name:test unsinged tinnyint ntable;` + - `author:${author};` + - `desc:create,insert,query with unsigned tinnyint;` + - `filename:${fileName};` + - `result:${result}`, () => { - let createSql = "create table if not exists utinnytest(ts timestamp,ut tinyint unsigned,i4 int,rownum nchar(20));"; - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = [1641827743305, 254, 124, 'row1' - , 1641827743306, 0, -123, 'row2' - , 1641827743307, 54, 0, 'row3']; - let insertSql = buildInsertSql('utinnytest', '', expectResData, [], 4); - - executeUpdate(insertSql); - let result = executeQuery("select * from utinnytest;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:test unsinged smallint ntable;` + - `author:${author};` + - `desc:create,insert,query with unsigned smallint;` + - `filename:${fileName};` + - `result:${result}`, () => { - let createSql = "create table if not exists usmalltest(ts timestamp,ut smallint unsigned,i4 int,rownum nchar(20));"; - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = [1641827743305, 65534, 124, 'row1', 1641827743306, 0, -123, 'row2', 1641827743307, 79, 0, 'row3']; - let insertSql = buildInsertSql('usmalltest', '', expectResData, [], 4); - - executeUpdate(insertSql); - let result = executeQuery("select * from usmalltest;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:test unsinged int ntable;` + - `author:${author};` + - `desc:create,insert,query with unsigned int;` + - `filename:${fileName};` + - `result:${result}`, () => { - let createSql = "create table if not exists uinttest(ts timestamp,ui int unsigned,i4 int,rownum nchar(20));"; - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = [1641827743305, 4294967294, 2147483647, 'row1', 1641827743306, 0, -2147483647, 'row2', 1641827743307, 105, 0, 'row3']; - let insertSql = buildInsertSql('uinttest', '', expectResData, [], 4); - - executeUpdate(insertSql); - let result = executeQuery("select * from uinttest;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:test unsinged bigint ntable;` + - `author:${author};` + - `desc:create,insert,query with unsigned bigint;` + - `filename:${fileName};` + - `result:${result}`, () => { - let createSql = "create table if not exists ubigtest(ts timestamp,ui bigint unsigned,i8 bigint,rownum nchar(20));"; - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = [1641827743305, 18446744073709551614n, 9223372036854775807n, 'row1', - 1641827743306, 0n, -9223372036854775807n, 'row2', - 1641827743307, 130n, 0n, 'row3']; - let insertSql = buildInsertSql('ubigtest', '', expectResData, [], 4); - - executeUpdate(insertSql); - let result = executeQuery("select * from ubigtest;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:test unsinged type ntable;` + - `author:${author};` + - `desc:create,insert,query with mutiple unsinged type;` + - `filename:${fileName};` + - `result:${result}`, () => { - let createSql = "create table if not exists unsigntest(ts timestamp,ut tinyint unsigned,us smallint unsigned,ui int unsigned,ub bigint unsigned,bi bigint);"; - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = [1641827743305, 254, 65534, 4294967294, 18446744073709551614n, 9223372036854775807n, - 1641827743306, 0, 0, 0, 0n, -9223372036854775807n]; - let insertSql = buildInsertSql('unsigntest', '', expectResData, [], 6); - - executeUpdate(insertSql); - let result = executeQuery("select * from unsigntest;"); - // console.log(`result.data:${result.resData}`); - // console.log(`result.feilds:${result.resFeilds}`); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:test unsinged type stable max value;` + - `author:${author};` + - `desc:this is a description;` + - `filename:${fileName};` + - `result:${result}`, () => { - let createSql = "create table if not exists max_unsigned_tag_test" + - "(ts timestamp" + - ",ut tinyint unsigned" + - ",us smallint unsigned" + - ",ui int unsigned" + - ",ub bigint unsigned" + - ",bi bigint)" + - "tags(" + - "ut1 tinyint unsigned" + - ",us2 smallint unsigned" + - ",ui4 int unsigned" + - ",ubi8 bigint unsigned" + - ",desc_nchr nchar(200)" + - ");"; - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData = [1641827743305, 254, 65534, 4294967294, 18446744073709551614n, 9223372036854775807n, - 1641827743306, 0, 0, 0, 0n, -9223372036854775807n, - 1641827743307, 201, 44, 2, 8n, 1531n]; - let tagData = [254, 65534, 4294967294, 18446744073709551614n, 'max value of unsinged type tag'] - let insertSql = buildInsertSql('max_unsigned_tag_test_sub1', 'max_unsigned_tag_test', colData, tagData, 6); - let expectResData = getResData(colData, tagData, 6); - - executeUpdate(insertSql); - let result = executeQuery("select * from max_unsigned_tag_test;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:test unsinged type stable minimal value;` + - `author:${author};` + - `desc:this is a description;` + - `filename:${fileName};` + - `result:${result}`, () => { - let createSql = "create table if not exists min_unsigned_tag_test" + - "(ts timestamp" + - ",ut tinyint unsigned" + - ",us smallint unsigned" + - ",ui int unsigned" + - ",ub bigint unsigned" + - ",bi bigint)" + - "tags(" + - "ut1 tinyint unsigned" + - ",us2 smallint unsigned" + - ",ui4 int unsigned" + - ",ubi8 bigint unsigned" + - ",desc_nchr nchar(200)" + - ");"; - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData = [1641827743305, 254, 65534, 4294967294, 18446744073709551614n, 9223372036854775807n, - 1641827743306, 0, 0, 0, 0n, -9223372036854775807n, - 1641827743307, 201, 44, 2, 8n, 1531n]; - let tagData = [0, 0, 0, 0n, 'minimal value of unsinged type tag'] - let insertSql = buildInsertSql('min_unsigned_tag_test_sub1', 'min_unsigned_tag_test', colData, tagData, 6); - let expectResData = getResData(colData, tagData, 6); - - executeUpdate(insertSql); - let result = executeQuery("select * from min_unsigned_tag_test;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - console.log("expectResData.length:" + expectResData.length + " actualResData.length:" + actualResData.length); - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:test unsinged type stable mixed value;` + - `author:${author};` + - `desc:this is a description;` + - `filename:${fileName};` + - `result:${result}`, () => { - let createSql = "create table if not exists mix_unsigned_tag_test" + - "(ts timestamp" + - ",ut tinyint unsigned" + - ",us smallint unsigned" + - ",ui int unsigned" + - ",ub bigint unsigned" + - ",bi bigint)" + - "tags(" + - "ut1 tinyint unsigned" + - ",us2 smallint unsigned" + - ",ui4 int unsigned" + - ",ubi8 bigint unsigned" + - ",desc_nchr nchar(200)" + - ");"; - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData = [1641827743305, 254, 65534, 4294967294, 18446744073709551614n, 9223372036854775807n, - 1641827743306, 0, 0, 0, 0n, -9223372036854775807n, - 1641827743307, 201, 44, 2, 8n, 1531n]; - let tagData = [1, 20, 300, 4000n, 'mixed value of unsinged type tag'] - let insertSql = buildInsertSql('mix_unsigned_tag_test_sub1', 'mix_unsigned_tag_test', colData, tagData, 6); - let expectResData = getResData(colData, tagData, 6); - - executeUpdate(insertSql); - let result = executeQuery("select * from mix_unsigned_tag_test;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - -}) - -describe("test cn character", () => { - test(`name:test cn ntable;` + - `author:${author};` + - `desc:create,insert,query with cn characters;` + - `filename:${fileName};` + - `result:${result}`, () => { - createSql = "create table if not exists nchartest(ts timestamp,value int,text binary(200),detail nchar(200));" - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = [1641827743305, 1, 'taosdata', 'tdengine' - , 1641827743306, 2, 'tasdata', '涛思数据' - , 1641827743307, 3, '涛思数据', 'tdengine' - , 1641827743308, 4, '涛思数据taosdata', 'tdengine' - , 1641827743309, 5, '涛思数据taosdata', 'tdengine涛思数据']; - let insertSql = buildInsertSql('nchartest', '', expectResData, [], 4); - - executeUpdate(insertSql); - let result = executeQuery("select * from nchartest;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }) - - test(`name:test cn stable;` + - `author:${author};` + - `desc:create,insert,query with cn characters;` + - `filename:${fileName};` + - `result:${result}`, () => { - createSql = "create table if not exists nchartest_s(ts timestamp,value int,text binary(200),detail nchar(200))tags(tag_bi binary(50),tag_nchr nchar(50));" - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData = [1641827743305, 1, 'taosdata', 'tdengine' - , 1641827743306, 2, 'tasdata', '涛思数据' - , 1641827743307, 3, '涛思数据', 'tdengine' - , 1641827743308, 4, '涛思数据taosdata', 'tdengine' - , 1641827743309, 5, '涛思数据taosdata', 'tdengine涛思数据']; - let tagData = ['tags涛思', '数据tags']; - let insertSql = buildInsertSql('sb_1', 'nchartest_s', colData, tagData, 4); - let expectResData = getResData(colData, tagData, 4); - - executeUpdate(insertSql); - let result = executeQuery("select * from nchartest_s;"); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }) -}) - -describe("test schemaless", () => { - test(`name:sml line protocal using string;` + - `author:${author};` + - `desc:using line protocal to schemaless insert with a string;` + - `filename:${fileName};` + - `result:${result}`, () => { - let stablename = 'line_protocal_string'; - createSql = `create table if not exists ${stablename}(ts timestamp,c1 bigint,c3 nchar(6),c2 bool,c4 double)` - + `tags(t1 nchar(4),t2 nchar(4),t3 nchar(4));` - - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData = [1626006833639, 3n, 'passit', false, 4.000000000]; - let tagData = ['3i64', '4f64', '\"t3\"']; - let expectResData = getResData(colData, tagData, 5); - let lineStr = stablename + ",t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639"; - - - c1.schemalessInsert(lineStr, taos.SCHEMALESS_PROTOCOL.TSDB_SML_LINE_PROTOCOL, taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_MILLI_SECONDS); - let result = executeQuery(`select * from ${stablename};`); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }) - - test(`name:sml line protocal using Array;` + - `author:${author};` + - `desc:using line protocal to schemaless insert with an Array;` + - `filename:${fileName};` + - `result:${result}`, () => { - let stablename = 'line_protocol_arr'; - - createSql = `create table if not exists ${stablename}(ts timestamp,c1 bigint,c3 nchar(10),c2 bool,c4 double,c5 double)` - + `tags(t1 nchar(4),t2 nchar(4),t3 nchar(4),t4 nchar(4));` - - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData1 = [1626006833641, 3n, 'passitagin', true, 5, 5] - let colData2 = [1626006833639, 3n, 'passit', false, 4, null]; - let tagData1 = ['4i64', '5f64', '\"t4\"', '5f64']; - let tagData2 = ['3i64', '4f64', '\"t3\"', null]; - let expectResDataTable1 = getResData(colData1, tagData1, 6); - let expectResDataTable2 = getResData(colData2, tagData2, 6); - let expectResData = expectResDataTable1.concat(expectResDataTable2); - - let lineStr = [stablename + ",t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", - stablename + ",t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000" - ]; - - c1.schemalessInsert(lineStr, taos.SCHEMALESS_PROTOCOL.TSDB_SML_LINE_PROTOCOL, taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_NANO_SECONDS); - let result = executeQuery(`select * from ${stablename};`); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }) - - test(`name:sml json protocal using string;` + - `author:${author};` + - `desc:using json protocal to schemaless insert with a json string;` + - `filename:${fileName};` + - `result:${result}`, () => { - let stablename = 'json_protocol_str'; - - createSql = `create table if not exists ${stablename}(ts timestamp,value double)` - + `tags(t1 bool,t2 bool,t3 double,t4 nchar(35));` - - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData1 = [1626006833000, 10] - let tagData1 = [true, false, 10, '123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>']; - let expectResData = getResData(colData1, tagData1, 2); - - let jsonStr = "{" - + "\"metric\": \"" + stablename + "\"," - + "\"timestamp\": 1626006833000," - + "\"value\": 10," - + "\"tags\": {" - + " \"t1\": true," - + "\"t2\": false," - + "\"t3\": 10," - + "\"t4\": \"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>\"" - + "}" - + "}"; - - c1.schemalessInsert(jsonStr, taos.SCHEMALESS_PROTOCOL.TSDB_SML_JSON_PROTOCOL, taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_MILLI_SECONDS); - - let result = executeQuery(`select * from ${stablename};`); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }) - - test(`name:sml json protocal using Array;` + - `author:${author};` + - `desc:using json protocal to schemaless insert with a json array;` + - `filename:${fileName};` + - `result:${result}`, () => { - let stablename = 'json_protocol_arr'; - - createSql = `create table if not exists ${stablename}(ts timestamp,value double)` - + `tags(t1 bool,t2 bool,t3 double,t4 nchar(35));` - - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData1 = [1626006833000, 10] - let tagData1 = [true, false, 10, '123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>']; - let expectResData = getResData(colData1, tagData1, 2); - - let jsonArr = ["{" - + "\"metric\": \"" + stablename + "\"," - + "\"timestamp\": 1626006833," - + "\"value\": 10," - + "\"tags\": {" - + " \"t1\": true," - + "\"t2\": false," - + "\"t3\": 10," - + "\"t4\": \"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>\"" - + "}" - + "}" - ]; - - c1.schemalessInsert(jsonArr, taos.SCHEMALESS_PROTOCOL.TSDB_SML_JSON_PROTOCOL, taos.SCHEMALESS_PRECISION.TSDB_SML_TIMESTAMP_SECONDS); - - let result = executeQuery(`select * from ${stablename};`); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }) -}) - -describe("test support microsecond", () => { - test(`name:ms support ntable;` + - `author:${author};` + - `desc:test normal table supports microseconds;` + - `filename:${fileName};` + - `result:${result}`, () => { - let db = 'nodejs_support_ms_ntable'; - let table = 'us_test_ntable'; - let expectResData = [1625801548423914, 1, 1625801548423914, - 1625801548423915, 2, 1625801548423914, - 1625801548423916, 3, 1625801548423914, - 1625801548423917, 4, 1625801548423914]; - - let createDB = `create database if not exists ${db} keep 3650 precision \'us\';`; - let createSql = `create table if not exists ${db}.${table} (ts timestamp, seq int,record_date timestamp);`; - let dropDB = `drop database if exists ${db};`; - let insertSql = buildInsertSql(db + '.' + table, '',expectResData, [], 3); - let querySql = `select * from ${db}.${table};`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - - executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(createSql); - executeUpdate(insertSql); - let result = executeQuery(querySql); - - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - executeUpdate(dropDB); - - }); - - test(`name:ms support stable;` + - `author:${author};` + - `desc:test stable supports microseconds;` + - `filename:${fileName};` + - `result:${result}`, () => { - let db = 'nodejs_support_ms_stable'; - let stable = 'us_test_stable'; - let table = "sub_1"; - let colData = [1625801548423914, 1, 1625801548423914, - 1625801548423915, 2, 1625801548423914, - 1625801548423916, 3, 1625801548423914, - 1625801548423917, 4, 1625801548423914]; - let tagData = [1,1625801548423914]; - let createDB = `create database if not exists ${db} keep 3650 precision \'us\';`; - let createSql = `create table if not exists ${db}.${stable} (ts timestamp,seq int,`+ - `record_date timestamp)tags(id int,htime timestamp);`; - let dropDB = `drop database if exists ${db};`; - let insertSql = buildInsertSql(db + '.' + table, db + '.' + stable, colData,tagData, 3); - let querySql = `select * from ${db}.${stable};`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = getResData(colData, tagData, 3); - - executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(createSql); - executeUpdate(insertSql); - let result = executeQuery(querySql); - - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - executeUpdate(dropDB); - }) -}) - -describe("test support nanosecond", () => { - test(`name:ns support ntable;` + - `author:${author};` + - `desc:test normal table supports nanoseconds;` + - `filename:${fileName};` + - `result:${result}`, () => { - let db = 'nodejs_support_ns_ntable'; - let table = 'ns_test_ntable'; - let expectResData = [1625801548423914100, 1, 1625801548423914 - ,1625801548423914200, 2, 1625801548423914 - ]; - - let createDB = `create database if not exists ${db} keep 3650 precision \'ns\';`; - let createSql = `create table if not exists ${db}.${table} (ts timestamp, seq int,record_date timestamp);`; - let dropDB = `drop database if exists ${db};`; - let insertSql = buildInsertSql(db + '.' + table, '',expectResData, [], 3); - let querySql = `select * from ${db}.${table};`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - - executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(createSql); - executeUpdate(insertSql); - console.log(querySql); - let result = executeQuery(querySql); - - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - console.log((index)); - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - executeUpdate(dropDB); - }); - - test(`name:ns support stable;` + - `author:${author};` + - `desc:test stable supports nanoseconds;` + - `filename:${fileName};` + - `result:${result}`, () => { - let db = 'nodejs_support_ns_stable'; - let stable = 'ns_test_stable'; - let table = "sub_1"; - let colData = [1625801548423914100, 1, 1625801548423914, - 1625801548423914200, 2, 1625801548423914]; - let tagData = [1,1625801548423914100]; - let createDB = `create database if not exists ${db} keep 3650 precision \'ns\';`; - let createSql = `create table if not exists ${db}.${stable} (ts timestamp,seq int,`+ - `record_date timestamp)tags(id int,htime timestamp);`; - let dropDB = `drop database if exists ${db};`; - let insertSql = buildInsertSql(db + '.' + table, db + '.' + stable, colData,tagData, 3); - let querySql = `select * from ${db}.${stable};`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = getResData(colData, tagData, 3); - - executeUpdate(dropDB); - executeUpdate(createDB); - executeUpdate(createSql); - executeUpdate(insertSql); - let result = executeQuery(querySql); - - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - executeUpdate(dropDB); - }) -}) - -describe("test json tag", () => { - test(`name:json tag;` + - `author:${author};` + - `desc:create,insert,query with json tag;` + - `filename:${fileName};` + - `result:${result}`, () => { - let tableName = 'jsons1'; - let createSql = `create table if not exists ${tableName}(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json);`; - - executeUpdate(createSql); - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let colData = [1591060618000, 1, false, 'json1', '涛思数据' - , 1591060628000, 23, true, '涛思数据', 'json' - , 1591060638000, 54, false, 'tdengine', 'taosdata']; - let tagData = ['{\"tag1\":\"fff\",\"tag2\":5,\"tag3\":true}'] - let insertSql = buildInsertSql('json_sub_1', tableName, colData, tagData, 5); - let expectResData = getResData(colData, tagData, 5); - - executeUpdate(insertSql); - let result = executeQuery(`select * from ${tableName};`); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }) -}) \ No newline at end of file diff --git a/src/connector/nodejs/test/cases/test.stmt.js b/src/connector/nodejs/test/cases/test.stmt.js deleted file mode 100644 index 235178bb7c59ad5b6f15d179a55979f71a9e268a..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/test/cases/test.stmt.js +++ /dev/null @@ -1,915 +0,0 @@ -const taos = require('../../tdengine'); -const { getFeildsFromDll, buildInsertSql, getFieldArr, getResData } = require('../utils/utilTools') - -const author = 'xiaolei'; -const result = 'passed'; -const fileName = __filename.slice(__dirname.length + 1); - -// This is a taos connection -let conn; -// This is a Cursor -let c1; - -// prepare data -let dbName = 'node_test_stmt_db'; -let tsArr = [1642435200000, 1642435300000, 1642435400000, 1642435500000, 1642435600000]; -let boolArr = [true, false, true, false, null]; -let tinyIntArr = [-127, 3, 127, 0, null]; -let smallIntArr = [-32767, 16, 32767, 0, null]; -let intArr = [-2147483647, 17, 2147483647, 0, null]; -let bigIntArr = [-9223372036854775807n, 9223372036854775807n, 18n, 0n, null]; -let floatArr = [3.4028234663852886e+38, -3.4028234663852886e+38, 19, 0, null]; -let doubleArr = [1.7976931348623157e+308, -1.7976931348623157e+308, 20, 0, null]; -let binaryArr = ['TDengine_Binary', 'taosdata涛思数据', '~!@#$%^&*()', '', null]; -let ncharArr = ['TDengine_Nchar', 'taosdata涛思数据', '~!@#$$%^&*()', '', null]; -let uTinyIntArr = [0, 127, 254, 23, null]; -let uSmallIntArr = [0, 256, 65534, 24, null]; -let uIntArr = [0, 1233, 4294967294, 25, null]; -let uBigIntArr = [0n, 36424354000001111n, 18446744073709551614n, 26n, null]; - -//prepare tag data. -let tagData1 = [true, 1, 32767, 1234555, -164243520000011111n, 214.02, 2.01, 'taosdata涛思数据', 'TDengine数据', 254, 65534, 4294967290 / 2, 164243520000011111n]; -let tagData2 = [true, 2, 32767, 1234555, -164243520000011111n, 214.02, 2.01, 'taosdata涛思数据', 'TDengine数据', 254, 65534, 4294967290 / 2, 164243520000011111n]; -let tagData3 = [true, 3, 32767, 1234555, -164243520000011111n, 214.02, 2.01, 'taosdata涛思数据', 'TDengine数据', 254, 65534, 4294967290 / 2, 164243520000011111n]; - -/** - * Combine individual array of every tdengine type that - * has been declared and then return a new array. - * @returns return data array. - */ -function getBindData() { - let bindDataArr = []; - for (let i = 0; i < 5; i++) { - bindDataArr.push(tsArr[i]); - bindDataArr.push(boolArr[i]); - bindDataArr.push(tinyIntArr[i]); - bindDataArr.push(smallIntArr[i]); - bindDataArr.push(intArr[i]); - bindDataArr.push(bigIntArr[i]); - bindDataArr.push(floatArr[i]); - bindDataArr.push(doubleArr[i]); - bindDataArr.push(binaryArr[i]); - bindDataArr.push(ncharArr[i]); - bindDataArr.push(uTinyIntArr[i]); - bindDataArr.push(uSmallIntArr[i]); - bindDataArr.push(uIntArr[i]); - bindDataArr.push(uBigIntArr[i]); - } - return bindDataArr; -} - -function executeUpdate(sql) { - console.log(sql); - c1.execute(sql); -} - -function executeQuery(sql) { - c1.execute(sql, { quiet: true }) - var data = c1.fetchall(); - let fields = c1.fields; - let resArr = []; - - data.forEach(row => { - row.forEach(data => { - if (data instanceof Date) { - // console.log("date obejct:"+data.valueOf()); - resArr.push(data.taosTimestamp()); - } else { - // console.log("not date:"+data); - resArr.push(data); - } - // console.log(data instanceof Date) - }) - }) - return { resData: resArr, resFeilds: fields }; -} - -beforeAll(() => { - conn = taos.connect({ host: "127.0.0.1", user: "root", password: "taosdata", config: "/etc/taos", port: 10 }); - c1 = conn.cursor(); - executeUpdate(`create database if not exists ${dbName} keep 3650;`); - executeUpdate(`use ${dbName};`); -}); - -// Clears the database and adds some testing data. -// Jest will wait for this promise to resolve before running tests. -afterAll(() => { - executeUpdate(`drop database if exists ${dbName};`); - conn.close(); -}); - -describe("stmt_bind_single_param", () => { - test(`name:bindSingleParamWithOneTable;` + - `author:${author};` + - `desc:Using stmtBindSingleParam() bind one table in a batch;` + - `filename:${fileName};` + - `result:${result}`, () => { - let table = 'bindsingleparambatch_121'; - let createSql = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `t_bl bool,` + - `t_i8 tinyint,` + - `t_i16 smallint,` + - `t_i32 int,` + - `t_i64 bigint,` + - `t_f32 float,` + - `t_d64 double,` + - `t_bnr binary(20),` + - `t_nchr nchar(20),` + - `t_u8 tinyint unsigned,` + - `t_u16 smallint unsigned,` + - `t_u32 int unsigned,` + - `t_u64 bigint unsigned` + - `);`; - let insertSql = `insert into ? using ${table} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?);`; - let querySql = `select * from ${table}`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = getResData(getBindData(), tagData1, 14); - - // prepare tag TAOS_BIND - let tagBind1 = new taos.TaosBind(14); - tagBind1.bindBool(true); - tagBind1.bindTinyInt(1); - tagBind1.bindSmallInt(32767); - tagBind1.bindInt(1234555); - tagBind1.bindBigInt(-164243520000011111n); - tagBind1.bindFloat(214.02); - tagBind1.bindDouble(2.01); - tagBind1.bindBinary('taosdata涛思数据'); - tagBind1.bindNchar('TDengine数据'); - tagBind1.bindUTinyInt(254); - tagBind1.bindUSmallInt(65534); - tagBind1.bindUInt(4294967290 / 2); - tagBind1.bindUBigInt(164243520000011111n); - - //Prepare TAOS_MULTI_BIND data - let mBind1 = new taos.TaosMultiBind(); - - executeUpdate(createSql); - c1.stmtInit(); - c1.stmtPrepare(insertSql); - c1.stmtSetTbnameTags(`${table}_s01`, tagBind1.getBind()); - c1.stmtBindSingleParamBatch(mBind1.multiBindTimestamp(tsArr), 0); - c1.stmtBindSingleParamBatch(mBind1.multiBindBool(boolArr), 1); - c1.stmtBindSingleParamBatch(mBind1.multiBindTinyInt(tinyIntArr), 2); - c1.stmtBindSingleParamBatch(mBind1.multiBindSmallInt(smallIntArr), 3); - c1.stmtBindSingleParamBatch(mBind1.multiBindInt(intArr), 4); - c1.stmtBindSingleParamBatch(mBind1.multiBindBigInt(bigIntArr), 5); - c1.stmtBindSingleParamBatch(mBind1.multiBindFloat(floatArr), 6); - c1.stmtBindSingleParamBatch(mBind1.multiBindDouble(doubleArr), 7); - c1.stmtBindSingleParamBatch(mBind1.multiBindBinary(binaryArr), 8); - c1.stmtBindSingleParamBatch(mBind1.multiBindNchar(ncharArr), 9); - c1.stmtBindSingleParamBatch(mBind1.multiBindUTinyInt(uTinyIntArr), 10); - c1.stmtBindSingleParamBatch(mBind1.multiBindUSmallInt(uSmallIntArr), 11); - c1.stmtBindSingleParamBatch(mBind1.multiBindUInt(uIntArr), 12); - c1.stmtBindSingleParamBatch(mBind1.multiBindUBigInt(uBigIntArr), 13); - c1.stmtAddBatch(); - c1.stmtExecute(); - c1.stmtClose(); - - let result = executeQuery(querySql); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:bindSingleParamWithMultiTable;` + - `author:${author};` + - `desc:Using stmtBindSingleParam() bind multiple tables in a batch;` + - `filename:${fileName};` + - `result:${result}`, () => { - let table = 'bindsingleparambatch_m21';//bind multiple table to one batch - let createSql = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `t_bl bool,` + - `t_i8 tinyint,` + - `t_i16 smallint,` + - `t_i32 int,` + - `t_i64 bigint,` + - `t_f32 float,` + - `t_d64 double,` + - `t_bnr binary(20),` + - `t_nchr nchar(20),` + - `t_u8 tinyint unsigned,` + - `t_u16 smallint unsigned,` + - `t_u32 int unsigned,` + - `t_u64 bigint unsigned` + - `);`; - let insertSql = `insert into ? using ${table} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?);`; - let querySql = `select * from ${table}`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = getResData(getBindData(), tagData1, 14).concat(getResData(getBindData(), tagData2, 14)).concat(getResData(getBindData(), tagData3, 14)); - - // prepare tag TAOS_BIND - let tagBind1 = new taos.TaosBind(14); - tagBind1.bindBool(true); - tagBind1.bindTinyInt(1); - tagBind1.bindSmallInt(32767); - tagBind1.bindInt(1234555); - tagBind1.bindBigInt(-164243520000011111n); - tagBind1.bindFloat(214.02); - tagBind1.bindDouble(2.01); - tagBind1.bindBinary('taosdata涛思数据'); - tagBind1.bindNchar('TDengine数据'); - tagBind1.bindUTinyInt(254); - tagBind1.bindUSmallInt(65534); - tagBind1.bindUInt(4294967290 / 2); - tagBind1.bindUBigInt(164243520000011111n); - - let tagBind2 = new taos.TaosBind(14); - tagBind2.bindBool(true); - tagBind2.bindTinyInt(2); - tagBind2.bindSmallInt(32767); - tagBind2.bindInt(1234555); - tagBind2.bindBigInt(-164243520000011111n); - tagBind2.bindFloat(214.02); - tagBind2.bindDouble(2.01); - tagBind2.bindBinary('taosdata涛思数据'); - tagBind2.bindNchar('TDengine数据'); - tagBind2.bindUTinyInt(254); - tagBind2.bindUSmallInt(65534); - tagBind2.bindUInt(4294967290 / 2); - tagBind2.bindUBigInt(164243520000011111n); - - let tagBind3 = new taos.TaosBind(14); - tagBind3.bindBool(true); - tagBind3.bindTinyInt(3); - tagBind3.bindSmallInt(32767); - tagBind3.bindInt(1234555); - tagBind3.bindBigInt(-164243520000011111n); - tagBind3.bindFloat(214.02); - tagBind3.bindDouble(2.01); - tagBind3.bindBinary('taosdata涛思数据'); - tagBind3.bindNchar('TDengine数据'); - tagBind3.bindUTinyInt(254); - tagBind3.bindUSmallInt(65534); - tagBind3.bindUInt(4294967290 / 2); - tagBind3.bindUBigInt(164243520000011111n); - - //Prepare TAOS_MULTI_BIND data - let mBind = new taos.TaosMultiBind(); - - executeUpdate(createSql); - c1.stmtInit(); - c1.stmtPrepare(insertSql); - // ========bind for 1st table ============= - c1.stmtSetTbnameTags(`${table}_s01`, tagBind1.getBind()); - c1.stmtBindSingleParamBatch(mBind.multiBindTimestamp(tsArr), 0); - c1.stmtBindSingleParamBatch(mBind.multiBindBool(boolArr), 1); - c1.stmtBindSingleParamBatch(mBind.multiBindTinyInt(tinyIntArr), 2); - c1.stmtBindSingleParamBatch(mBind.multiBindSmallInt(smallIntArr), 3); - c1.stmtBindSingleParamBatch(mBind.multiBindInt(intArr), 4); - c1.stmtBindSingleParamBatch(mBind.multiBindBigInt(bigIntArr), 5); - c1.stmtBindSingleParamBatch(mBind.multiBindFloat(floatArr), 6); - c1.stmtBindSingleParamBatch(mBind.multiBindDouble(doubleArr), 7); - c1.stmtBindSingleParamBatch(mBind.multiBindBinary(binaryArr), 8); - c1.stmtBindSingleParamBatch(mBind.multiBindNchar(ncharArr), 9); - c1.stmtBindSingleParamBatch(mBind.multiBindUTinyInt(uTinyIntArr), 10); - c1.stmtBindSingleParamBatch(mBind.multiBindUSmallInt(uSmallIntArr), 11); - c1.stmtBindSingleParamBatch(mBind.multiBindUInt(uIntArr), 12); - c1.stmtBindSingleParamBatch(mBind.multiBindUBigInt(uBigIntArr), 13); - c1.stmtAddBatch(); - // c1.stmtExecute(); - - // ========bind for 2nd table ============= - c1.stmtSetTbnameTags(`${table}_s02`, tagBind2.getBind()); - c1.stmtBindSingleParamBatch(mBind.multiBindTimestamp(tsArr), 0); - c1.stmtBindSingleParamBatch(mBind.multiBindBool(boolArr), 1); - c1.stmtBindSingleParamBatch(mBind.multiBindTinyInt(tinyIntArr), 2); - c1.stmtBindSingleParamBatch(mBind.multiBindSmallInt(smallIntArr), 3); - c1.stmtBindSingleParamBatch(mBind.multiBindInt(intArr), 4); - c1.stmtBindSingleParamBatch(mBind.multiBindBigInt(bigIntArr), 5); - c1.stmtBindSingleParamBatch(mBind.multiBindFloat(floatArr), 6); - c1.stmtBindSingleParamBatch(mBind.multiBindDouble(doubleArr), 7); - c1.stmtBindSingleParamBatch(mBind.multiBindBinary(binaryArr), 8); - c1.stmtBindSingleParamBatch(mBind.multiBindNchar(ncharArr), 9); - c1.stmtBindSingleParamBatch(mBind.multiBindUTinyInt(uTinyIntArr), 10); - c1.stmtBindSingleParamBatch(mBind.multiBindUSmallInt(uSmallIntArr), 11); - c1.stmtBindSingleParamBatch(mBind.multiBindUInt(uIntArr), 12); - c1.stmtBindSingleParamBatch(mBind.multiBindUBigInt(uBigIntArr), 13); - c1.stmtAddBatch(); - // c1.stmtExecute(); - - // ========bind for 3rd table ============= - c1.stmtSetTbnameTags(`${table}_s0`, tagBind3.getBind()); - c1.stmtBindSingleParamBatch(mBind.multiBindTimestamp(tsArr), 0); - c1.stmtBindSingleParamBatch(mBind.multiBindBool(boolArr), 1); - c1.stmtBindSingleParamBatch(mBind.multiBindTinyInt(tinyIntArr), 2); - c1.stmtBindSingleParamBatch(mBind.multiBindSmallInt(smallIntArr), 3); - c1.stmtBindSingleParamBatch(mBind.multiBindInt(intArr), 4); - c1.stmtBindSingleParamBatch(mBind.multiBindBigInt(bigIntArr), 5); - c1.stmtBindSingleParamBatch(mBind.multiBindFloat(floatArr), 6); - c1.stmtBindSingleParamBatch(mBind.multiBindDouble(doubleArr), 7); - c1.stmtBindSingleParamBatch(mBind.multiBindBinary(binaryArr), 8); - c1.stmtBindSingleParamBatch(mBind.multiBindNchar(ncharArr), 9); - c1.stmtBindSingleParamBatch(mBind.multiBindUTinyInt(uTinyIntArr), 10); - c1.stmtBindSingleParamBatch(mBind.multiBindUSmallInt(uSmallIntArr), 11); - c1.stmtBindSingleParamBatch(mBind.multiBindUInt(uIntArr), 12); - c1.stmtBindSingleParamBatch(mBind.multiBindUBigInt(uBigIntArr), 13); - c1.stmtAddBatch(); - c1.stmtExecute(); - c1.stmtClose(); - - let result = executeQuery(querySql); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); -}) - -describe("stmt_bind_para_batch", () => { - test(`name:bindParamBatchWithOneTable;` + - `author:${author};` + - `desc:Using stmtBindParamBatch() bind one table in a batch;` + - `filename:${fileName};` + - `result:${result}`, () => { - let table = 'bindparambatch_121';//bind one table to one batch - let createSql = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `t_bl bool,` + - `t_i8 tinyint,` + - `t_i16 smallint,` + - `t_i32 int,` + - `t_i64 bigint,` + - `t_f32 float,` + - `t_d64 double,` + - `t_bnr binary(20),` + - `t_nchr nchar(20),` + - `t_u8 tinyint unsigned,` + - `t_u16 smallint unsigned,` + - `t_u32 int unsigned,` + - `t_u64 bigint unsigned` + - `);`; - let insertSql = `insert into ? using ${table} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?);`; - let querySql = `select * from ${table}`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = getResData(getBindData(), tagData1, 14); - - //prepare tag TAO_BIND - let tagBind = new taos.TaosBind(14); - tagBind.bindBool(true); - tagBind.bindTinyInt(1); - tagBind.bindSmallInt(32767); - tagBind.bindInt(1234555); - tagBind.bindBigInt(-164243520000011111n); - tagBind.bindFloat(214.02); - tagBind.bindDouble(2.01); - tagBind.bindBinary('taosdata涛思数据'); - tagBind.bindNchar('TDengine数据'); - tagBind.bindUTinyInt(254); - tagBind.bindUSmallInt(65534); - tagBind.bindUInt(4294967290 / 2); - tagBind.bindUBigInt(164243520000011111n); - - //Prepare TAOS_MULTI_BIND data array - let mBinds = new taos.TaosMultiBindArr(14); - mBinds.multiBindTimestamp(tsArr); - mBinds.multiBindBool(boolArr); - mBinds.multiBindTinyInt(tinyIntArr); - mBinds.multiBindSmallInt(smallIntArr); - mBinds.multiBindInt(intArr); - mBinds.multiBindBigInt(bigIntArr); - mBinds.multiBindFloat(floatArr); - mBinds.multiBindDouble(doubleArr); - mBinds.multiBindBinary(binaryArr); - mBinds.multiBindNchar(ncharArr); - mBinds.multiBindUTinyInt(uTinyIntArr); - mBinds.multiBindUSmallInt(uSmallIntArr); - mBinds.multiBindUInt(uIntArr); - mBinds.multiBindUBigInt(uBigIntArr); - - executeUpdate(createSql); - c1.stmtInit(); - c1.stmtPrepare(insertSql); - c1.stmtSetTbnameTags(`${table}_s01`, tagBind.getBind()); - c1.stmtBindParamBatch(mBinds.getMultiBindArr()); - c1.stmtAddBatch(); - c1.stmtExecute(); - c1.stmtClose(); - - let result = executeQuery(querySql); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:bindParamBatchWithMultiTable;` + - `author:${author};` + - `desc:Using stmtBindParamBatch() bind multiple tables in a batch;` + - `filename:${fileName};` + - `result:${result}`, () => { - let table = 'bindparambatch_m21';//bind multiple tables to one batch - let createSql = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `t_bl bool,` + - `t_i8 tinyint,` + - `t_i16 smallint,` + - `t_i32 int,` + - `t_i64 bigint,` + - `t_f32 float,` + - `t_d64 double,` + - `t_bnr binary(20),` + - `t_nchr nchar(20),` + - `t_u8 tinyint unsigned,` + - `t_u16 smallint unsigned,` + - `t_u32 int unsigned,` + - `t_u64 bigint unsigned` + - `);`; - let insertSql = `insert into ? using ${table} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?);`; - let querySql = `select * from ${table}`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let expectResData = getResData(getBindData(), tagData1, 14).concat(getResData(getBindData(), tagData2, 14)).concat(getResData(getBindData(), tagData3, 14)); - - - // prepare tag TAOS_BIND - let tagBind1 = new taos.TaosBind(14); - tagBind1.bindBool(true); - tagBind1.bindTinyInt(1); - tagBind1.bindSmallInt(32767); - tagBind1.bindInt(1234555); - tagBind1.bindBigInt(-164243520000011111n); - tagBind1.bindFloat(214.02); - tagBind1.bindDouble(2.01); - tagBind1.bindBinary('taosdata涛思数据'); - tagBind1.bindNchar('TDengine数据'); - tagBind1.bindUTinyInt(254); - tagBind1.bindUSmallInt(65534); - tagBind1.bindUInt(4294967290 / 2); - tagBind1.bindUBigInt(164243520000011111n); - - let tagBind2 = new taos.TaosBind(14); - tagBind2.bindBool(true); - tagBind2.bindTinyInt(2); - tagBind2.bindSmallInt(32767); - tagBind2.bindInt(1234555); - tagBind2.bindBigInt(-164243520000011111n); - tagBind2.bindFloat(214.02); - tagBind2.bindDouble(2.01); - tagBind2.bindBinary('taosdata涛思数据'); - tagBind2.bindNchar('TDengine数据'); - tagBind2.bindUTinyInt(254); - tagBind2.bindUSmallInt(65534); - tagBind2.bindUInt(4294967290 / 2); - tagBind2.bindUBigInt(164243520000011111n); - - let tagBind3 = new taos.TaosBind(14); - tagBind3.bindBool(true); - tagBind3.bindTinyInt(3); - tagBind3.bindSmallInt(32767); - tagBind3.bindInt(1234555); - tagBind3.bindBigInt(-164243520000011111n); - tagBind3.bindFloat(214.02); - tagBind3.bindDouble(2.01); - tagBind3.bindBinary('taosdata涛思数据'); - tagBind3.bindNchar('TDengine数据'); - tagBind3.bindUTinyInt(254); - tagBind3.bindUSmallInt(65534); - tagBind3.bindUInt(4294967290 / 2); - tagBind3.bindUBigInt(164243520000011111n); - - //Prepare TAOS_MULTI_BIND data array - let mBinds = new taos.TaosMultiBindArr(14); - mBinds.multiBindTimestamp(tsArr); - mBinds.multiBindBool(boolArr); - mBinds.multiBindTinyInt(tinyIntArr); - mBinds.multiBindSmallInt(smallIntArr); - mBinds.multiBindInt(intArr); - mBinds.multiBindBigInt(bigIntArr); - mBinds.multiBindFloat(floatArr); - mBinds.multiBindDouble(doubleArr); - mBinds.multiBindBinary(binaryArr); - mBinds.multiBindNchar(ncharArr); - mBinds.multiBindUTinyInt(uTinyIntArr); - mBinds.multiBindUSmallInt(uSmallIntArr); - mBinds.multiBindUInt(uIntArr); - mBinds.multiBindUBigInt(uBigIntArr); - - executeUpdate(createSql); - c1.stmtInit(); - c1.stmtPrepare(insertSql); - // ===========bind for 1st table ========== - c1.stmtSetTbnameTags(`${table}_s01`, tagBind1.getBind()); - c1.stmtBindParamBatch(mBinds.getMultiBindArr()); - c1.stmtAddBatch(); - // c1.stmtExecute(); - - // ===========bind for 2nd table ========== - c1.stmtSetTbnameTags(`${table}_s02`, tagBind2.getBind()); - c1.stmtBindParamBatch(mBinds.getMultiBindArr()); - c1.stmtAddBatch(); - // c1.stmtExecute(); - - // ===========bind for 3rd table ========== - c1.stmtSetTbnameTags(`${table}_s03`, tagBind3.getBind()); - c1.stmtBindParamBatch(mBinds.getMultiBindArr()); - c1.stmtAddBatch(); - c1.stmtExecute(); - c1.stmtClose(); - - let result = executeQuery(querySql); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - - - }); -}) - -describe("stmt_bind_param", () => { - test(`name:bindParamWithOneTable;` + - `author:${author};` + - `desc:using stmtBindParam() bind one table in a batch;` + - `filename:${fileName};` + - `result:${result}`, () => { - let table = 'bindparam_121';//bind one table to one batch - let createSql = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `t_bl bool,` + - `t_i8 tinyint,` + - `t_i16 smallint,` + - `t_i32 int,` + - `t_i64 bigint,` + - `t_f32 float,` + - `t_d64 double,` + - `t_bnr binary(20),` + - `t_nchr nchar(20),` + - `t_u8 tinyint unsigned,` + - `t_u16 smallint unsigned,` + - `t_u32 int unsigned,` + - `t_u64 bigint unsigned` + - `);`; - let insertSql = `insert into ? using ${table} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?);`; - let querySql = `select * from ${table}`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let data = getBindData(); - let expectResData = getResData(data, tagData1, 14); - - //prepare tag data - let tags = new taos.TaosBind(13); - tags.bindBool(true); - tags.bindTinyInt(1); - tags.bindSmallInt(32767); - tags.bindInt(1234555); - tags.bindBigInt(-164243520000011111n); - tags.bindFloat(214.02); - tags.bindDouble(2.01); - tags.bindBinary('taosdata涛思数据'); - tags.bindNchar('TDengine数据'); - tags.bindUTinyInt(254); - tags.bindUSmallInt(65534); - tags.bindUInt(4294967290 / 2); - tags.bindUBigInt(164243520000011111n); - executeUpdate(createSql); - - c1.stmtInit(); - c1.stmtPrepare(insertSql); - c1.stmtSetTbnameTags(`${table}_s01`, tags.getBind()); - for (let i = 0; i < data.length - 14; i += 14) { - let bind = new taos.TaosBind(14); - bind.bindTimestamp(data[i]); - bind.bindBool(data[i + 1]); - bind.bindTinyInt(data[i + 2]); - bind.bindSmallInt(data[i + 3]); - bind.bindInt(data[i + 4]); - bind.bindBigInt(data[i + 5]); - bind.bindFloat(data[i + 6]); - bind.bindDouble(data[i + 7]); - bind.bindBinary(data[i + 8]); - bind.bindNchar(data[i + 9]); - bind.bindUTinyInt(data[i + 10]); - bind.bindUSmallInt(data[i + 11]); - bind.bindUInt(data[i + 12]); - bind.bindUBigInt(data[i + 13]); - c1.stmtBindParam(bind.getBind()); - c1.stmtAddBatch(); - } - let bind2 = new taos.TaosBind(14); - bind2.bindTimestamp(data[14 * 4]); - for (let j = 0; j < 13; j++) { - bind2.bindNil(); - } - c1.stmtBindParam(bind2.getBind()); - c1.stmtAddBatch(); - c1.stmtExecute(); - c1.stmtClose(); - - let result = executeQuery(querySql); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); - - test(`name:bindParamWithMultiTable;` + - `author:${author};` + - `desc:using stmtBindParam() bind multiple tables in a batch;` + - `filename:${fileName};` + - `result:${result}`, () => { - let table = 'bindparam_m21';//bind one table to one batch - let createSql = `create table if not exists ${table} ` + - `(ts timestamp,` + - `bl bool,` + - `i8 tinyint,` + - `i16 smallint,` + - `i32 int,` + - `i64 bigint,` + - `f32 float,` + - `d64 double,` + - `bnr binary(20),` + - `nchr nchar(20),` + - `u8 tinyint unsigned,` + - `u16 smallint unsigned,` + - `u32 int unsigned,` + - `u64 bigint unsigned` + - `)tags(` + - `t_bl bool,` + - `t_i8 tinyint,` + - `t_i16 smallint,` + - `t_i32 int,` + - `t_i64 bigint,` + - `t_f32 float,` + - `t_d64 double,` + - `t_bnr binary(20),` + - `t_nchr nchar(20),` + - `t_u8 tinyint unsigned,` + - `t_u16 smallint unsigned,` + - `t_u32 int unsigned,` + - `t_u64 bigint unsigned` + - `);`; - let insertSql = `insert into ? using ${table} tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?);`; - let querySql = `select * from ${table}`; - let expectResField = getFieldArr(getFeildsFromDll(createSql)); - let data = getBindData(); - let expectResData = getResData(data, tagData1, 14).concat(getResData(data, tagData2, 14)).concat(getResData(data, tagData3, 14)); - - // prepare tag TAOS_BIND - let tagBind1 = new taos.TaosBind(14); - tagBind1.bindBool(true); - tagBind1.bindTinyInt(1); - tagBind1.bindSmallInt(32767); - tagBind1.bindInt(1234555); - tagBind1.bindBigInt(-164243520000011111n); - tagBind1.bindFloat(214.02); - tagBind1.bindDouble(2.01); - tagBind1.bindBinary('taosdata涛思数据'); - tagBind1.bindNchar('TDengine数据'); - tagBind1.bindUTinyInt(254); - tagBind1.bindUSmallInt(65534); - tagBind1.bindUInt(4294967290 / 2); - tagBind1.bindUBigInt(164243520000011111n); - - let tagBind2 = new taos.TaosBind(14); - tagBind2.bindBool(true); - tagBind2.bindTinyInt(2); - tagBind2.bindSmallInt(32767); - tagBind2.bindInt(1234555); - tagBind2.bindBigInt(-164243520000011111n); - tagBind2.bindFloat(214.02); - tagBind2.bindDouble(2.01); - tagBind2.bindBinary('taosdata涛思数据'); - tagBind2.bindNchar('TDengine数据'); - tagBind2.bindUTinyInt(254); - tagBind2.bindUSmallInt(65534); - tagBind2.bindUInt(4294967290 / 2); - tagBind2.bindUBigInt(164243520000011111n); - - let tagBind3 = new taos.TaosBind(14); - tagBind3.bindBool(true); - tagBind3.bindTinyInt(3); - tagBind3.bindSmallInt(32767); - tagBind3.bindInt(1234555); - tagBind3.bindBigInt(-164243520000011111n); - tagBind3.bindFloat(214.02); - tagBind3.bindDouble(2.01); - tagBind3.bindBinary('taosdata涛思数据'); - tagBind3.bindNchar('TDengine数据'); - tagBind3.bindUTinyInt(254); - tagBind3.bindUSmallInt(65534); - tagBind3.bindUInt(4294967290 / 2); - tagBind3.bindUBigInt(164243520000011111n); - - executeUpdate(createSql); - c1.stmtInit(); - c1.stmtPrepare(insertSql); - // ========= bind for 1st table ================= - c1.stmtSetTbnameTags(`${table}_s01`, tagBind1.getBind()); - for (let i = 0; i < data.length - 14; i += 14) { - let bind = new taos.TaosBind(14); - bind.bindTimestamp(data[i]); - bind.bindBool(data[i + 1]); - bind.bindTinyInt(data[i + 2]); - bind.bindSmallInt(data[i + 3]); - bind.bindInt(data[i + 4]); - bind.bindBigInt(data[i + 5]); - bind.bindFloat(data[i + 6]); - bind.bindDouble(data[i + 7]); - bind.bindBinary(data[i + 8]); - bind.bindNchar(data[i + 9]); - bind.bindUTinyInt(data[i + 10]); - bind.bindUSmallInt(data[i + 11]); - bind.bindUInt(data[i + 12]); - bind.bindUBigInt(data[i + 13]); - c1.stmtBindParam(bind.getBind()); - c1.stmtAddBatch(); - } - let bind2 = new taos.TaosBind(14); - bind2.bindTimestamp(data[14 * 4]); - for (let j = 0; j < 13; j++) { - bind2.bindNil(); - } - c1.stmtBindParam(bind2.getBind()); - c1.stmtAddBatch(); - // c1.stmtExecute(); - - // ========= bind for 2nd table ================= - c1.stmtSetTbnameTags(`${table}_s02`, tagBind2.getBind()); - for (let i = 0; i < data.length - 14; i += 14) { - let bind = new taos.TaosBind(14); - bind.bindTimestamp(data[i]); - bind.bindBool(data[i + 1]); - bind.bindTinyInt(data[i + 2]); - bind.bindSmallInt(data[i + 3]); - bind.bindInt(data[i + 4]); - bind.bindBigInt(data[i + 5]); - bind.bindFloat(data[i + 6]); - bind.bindDouble(data[i + 7]); - bind.bindBinary(data[i + 8]); - bind.bindNchar(data[i + 9]); - bind.bindUTinyInt(data[i + 10]); - bind.bindUSmallInt(data[i + 11]); - bind.bindUInt(data[i + 12]); - bind.bindUBigInt(data[i + 13]); - c1.stmtBindParam(bind.getBind()); - c1.stmtAddBatch(); - } - c1.stmtBindParam(bind2.getBind()); - c1.stmtAddBatch(); - // c1.stmtExecute(); - - // ========= bind for 3rd table ================= - c1.stmtSetTbnameTags(`${table}_s03`, tagBind3.getBind()); - for (let i = 0; i < data.length - 14; i += 14) { - let bind = new taos.TaosBind(14); - bind.bindTimestamp(data[i]); - bind.bindBool(data[i + 1]); - bind.bindTinyInt(data[i + 2]); - bind.bindSmallInt(data[i + 3]); - bind.bindInt(data[i + 4]); - bind.bindBigInt(data[i + 5]); - bind.bindFloat(data[i + 6]); - bind.bindDouble(data[i + 7]); - bind.bindBinary(data[i + 8]); - bind.bindNchar(data[i + 9]); - bind.bindUTinyInt(data[i + 10]); - bind.bindUSmallInt(data[i + 11]); - bind.bindUInt(data[i + 12]); - bind.bindUBigInt(data[i + 13]); - c1.stmtBindParam(bind.getBind()); - c1.stmtAddBatch(); - } - c1.stmtBindParam(bind2.getBind()); - c1.stmtAddBatch(); - c1.stmtExecute(); - c1.stmtClose(); - - let result = executeQuery(querySql); - let actualResData = result.resData; - let actualResFields = result.resFeilds; - - //assert result data length - expect(expectResData.length).toEqual(actualResData.length); - //assert result data - expectResData.forEach((item, index) => { - expect(item).toEqual(actualResData[index]); - }); - - //assert result meta data - expectResField.forEach((item, index) => { - expect(item).toEqual(actualResFields[index]) - }) - }); -}) - diff --git a/src/connector/nodejs/test/utils/utilTools.js b/src/connector/nodejs/test/utils/utilTools.js deleted file mode 100644 index ae057b2dd106559d021f738e1a6046572aad5afb..0000000000000000000000000000000000000000 --- a/src/connector/nodejs/test/utils/utilTools.js +++ /dev/null @@ -1,177 +0,0 @@ -/** - * This is an util function will return the column info based on the create sql. - * @param {*} sql - * @returns Return an Array about the column names and column type. - * - */ -function getFeildsFromDll(sql) { - let fields = []; - - let firstBracket = sql.indexOf('('); - let lastBracket = sql.lastIndexOf(')') - - let metaStr = sql.slice(firstBracket, lastBracket + 1); - let splitTags = metaStr.split("tags"); - - splitTags.forEach((item, index, arr) => { - arr[index] = item.slice(1, item.length - 1) - }) - splitTags.forEach((item) => { - let tmp = item.split(","); - tmp.forEach((item) => { - let newItem = item.trim(); - let spaceInd = newItem.indexOf(' ', 1) - fields.push(newItem.slice(0, spaceInd)); - fields.push(newItem.slice(spaceInd + 1, newItem.length)) - }) - }) - return fields; -} - -/** - * Based on the input array, it will generate sql that could be used to insert the data of array into the db. - * @param {*} tableName It could be the table name that you want to insert data. - * @param {*} stable If you want to using stable as template to create table automatically, - * set this to your stable name. Deault if ''; - * @param {*} dataArr An Array of data that you want insert (it could be mutilple lines) - * @param {*} tagArr An Array used to store one sub table's tag info - * @param {*} numOfColumn The number of columns that the target table has. - * @returns Return an insert sql string. - */ -function buildInsertSql(tableName, stable = '', dataArr, tagArr = [], numOfColumn) { - let insertSql = ""; - let dataPartial = "("; - let tagPart = "("; - - dataArr.forEach((item, index) => { - // let item = dataArr[index]; - if (typeof item == "string") { - dataPartial += '\'' + item + '\''; - } else { - dataPartial += item; - } - if ((index + 1) % numOfColumn == 0 && (index + 1) != dataArr.length) { - dataPartial += ")(" - } else if ((index + 1) % numOfColumn == 0 && (index + 1) == dataArr.length) { - dataPartial += ")" - } else { - dataPartial += "," - } - - }) - if (stable != '') { - tagArr.forEach((item, index) => { - if (typeof item == "string") { - tagPart += '\'' + item + '\''; - } else { - tagPart += item; - } - - if (index != tagArr.length - 1) { - tagPart += ","; - } else { - tagPart += ")"; - } - }) - } - - if (stable == '') { - insertSql += `insert into ${tableName} values ${dataPartial};` - } else { - insertSql += `insert into ${tableName} using ${stable} tags ${tagPart} values ${dataPartial};` - } - - return insertSql; -} -/** - * used to mapping the data type of an create clause into TDengine's datatype code - */ -const TDengineTypeCode = { - 'null': 0, - 'bool': 1, - 'tinyint': 2, - 'smallint': 3, - 'int': 4, - 'bigint': 5, - 'float': 6, - 'double': 7, - 'binary': 8, - 'timestamp': 9, - 'nchar': 10, - 'tinyint unsigned': 11, - 'smallint unsigned': 12, - 'int unsigned': 13, - 'bigint unsigned': 14, - 'json': 15, -} - -/** - * Mapping the data type with corresponing size that has defined in tdengine - */ -const TDengineTypeBytes = { - 'null': 0, - 'bool': 1, - 'tinyint': 1, - 'smallint': 2, - 'int': 4, - 'bigint': 8, - 'float': 4, - 'double': 8, - 'timestamp': 8, - 'tinyint unsigned': 1, - 'smallint unsigned': 2, - 'int unsigned': 4, - 'bigint unsigned': 8, - 'json': 4096, -} - -/** - * Used to create an array of taos feilds object. - * @param {*} arr This should be the return array from the method getFeildsFromDll() - * @returns Return an array of taosFeild Object - */ -function getFieldArr(arr) { - let feild = []; - for (let i = 0; i < arr.length;) { - let bracetPosi = arr[i + 1].indexOf('('); - let type = ''; - let size = -1; - - if (bracetPosi == -1) { - type = TDengineTypeCode[arr[i + 1]]; - size = TDengineTypeBytes[arr[i + 1]]; - }else{ - type = TDengineTypeCode[arr[i + 1].slice(0, bracetPosi)]; - size = Number(arr[i + 1].slice(bracetPosi + 1, arr[i + 1].indexOf(')'))); - } - let fieldObj = { - name: arr[i].toLowerCase(), - type: type, - bytes: size - } - feild.push(fieldObj); - i = i + 2; - } - return feild; -} -/** - * Conbine arrays of data info and tag info together, and return a new array. This array construction is simmilar with query result - * from the tdengine by taos shell.This method only can be used by a subtable. - * @param {*} dataArr An array holds columns' data that will be insert into the db. - * @param {*} tagArr An array holds tags' data that is belong to a sub table. - * @param {*} numOfcolumn - * @returns return the an array of column data and tag data. - */ -function getResData(dataArr, tagArr, numOfcolumn) { - let resData = []; - dataArr.forEach((item, index) => { - resData.push(item); - if ((index + 1) % numOfcolumn == 0) { - tagArr.forEach((element) => { - resData.push(element); - }) ; - } - }); - return resData; -} -module.exports = { getFeildsFromDll, buildInsertSql, getFieldArr, getResData }; \ No newline at end of file diff --git a/src/connector/python/LICENSE b/src/connector/python/LICENSE deleted file mode 100644 index 79a9d730868bfe5d3fa01d679a4abfe9ee7811f0..0000000000000000000000000000000000000000 --- a/src/connector/python/LICENSE +++ /dev/null @@ -1,12 +0,0 @@ - Copyright (c) 2019 TAOS Data, Inc. - -This program is free software: you can use, redistribute, and/or modify -it under the terms of the GNU Affero General Public License, version 3 -or later ("AGPL"), as published by the Free Software Foundation. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. - -You should have received a copy of the GNU Affero General Public License -along with this program. If not, see . diff --git a/src/connector/python/README.md b/src/connector/python/README.md index e4fce45a59bea74ea64a5da082767579459d4196..c48a2dac4ba52324f761e29ea4fc72d186a30309 100644 --- a/src/connector/python/README.md +++ b/src/connector/python/README.md @@ -17,12 +17,6 @@ Or with git url: pip install git+https://github.com/taosdata/taos-connector-python.git ``` -If you have installed TDengine server or client with prebuilt packages, then you can install the connector from path: - -```bash -pip install /usr/local/taos/connector/python -``` - ## Source Code [TDengine](https://github.com/taosdata/TDengine) connector for Python source code is hosted on [GitHub](https://github.com/taosdata/taos-connector-python). @@ -361,71 +355,6 @@ if __name__ == "__main__": test_subscribe_callback(connect()) ``` -### Stream - -```python -from taos import * -from ctypes import * -import time - -def stream_callback(p_param, p_result, p_row): - # type: (c_void_p, c_void_p, c_void_p) -> None - if p_result is None or p_row is None: - return - result = TaosResult(p_result) - row = TaosRow(result, p_row) - try: - ts, count = row() - p = cast(p_param, POINTER(Counter)) - p.contents.count += count - print("[%s] inserted %d in 5s, total count: %d" % (ts.strftime("%Y-%m-%d %H:%M:%S"), count, p.contents.count)) - except Exception as err: - print(err) - raise err - - -class Counter(Structure): - _fields_ = [ - ("count", c_int), - ] - - def __str__(self): - return "%d" % self.count - - -def test_stream(conn): - # type: (TaosConnection) -> None - dbname = "pytest_taos_stream" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) - conn.execute("create table if not exists log(ts timestamp, n int)") - - result = conn.query("select count(*) from log interval(5s)") - assert result.field_count == 2 - counter = Counter() - counter.count = 0 - stream = conn.stream("select count(*) from log interval(5s)", stream_callback, param=byref(counter)) - - for _ in range(0, 20): - conn.execute("insert into log values(now,0)(now+1s, 1)(now + 2s, 2)") - time.sleep(2) - - stream.close() - conn.execute("drop database if exists %s" % dbname) - conn.close() - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - raise err - - -if __name__ == "__main__": - test_stream(connect()) - -``` - ### Insert with line protocol ```python diff --git a/src/connector/python/examples/bind-multi.py b/src/connector/python/examples/bind-multi.py deleted file mode 100644 index 8530253aef58079e01f5eb71d8e12ab1649b7731..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/bind-multi.py +++ /dev/null @@ -1,50 +0,0 @@ -# encoding:UTF-8 -from taos import * - -conn = connect() - -dbname = "pytest_taos_stmt_multi" -conn.execute("drop database if exists %s" % dbname) -conn.execute("create database if not exists %s" % dbname) -conn.select_db(dbname) - -conn.execute( - "create table if not exists log(ts timestamp, bo bool, nil tinyint, \ - ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \ - su smallint unsigned, iu int unsigned, bu bigint unsigned, \ - ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", -) - -stmt = conn.statement("insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") - -params = new_multi_binds(16) -params[0].timestamp((1626861392589, 1626861392590, 1626861392591)) -params[1].bool((True, None, False)) -params[2].tinyint([-128, -128, None]) # -128 is tinyint null -params[3].tinyint([0, 127, None]) -params[4].smallint([3, None, 2]) -params[5].int([3, 4, None]) -params[6].bigint([3, 4, None]) -params[7].tinyint_unsigned([3, 4, None]) -params[8].smallint_unsigned([3, 4, None]) -params[9].int_unsigned([3, 4, None]) -params[10].bigint_unsigned([3, 4, None]) -params[11].float([3, None, 1]) -params[12].double([3, None, 1.2]) -params[13].binary(["abc", "dddafadfadfadfadfa", None]) -params[14].nchar(["涛思数据", None, "a long string with 中文字符"]) -params[15].timestamp([None, None, 1626861392591]) -stmt.bind_param_batch(params) -stmt.execute() - - -result = stmt.use_result() -assert result.affected_rows == 3 -result.close() - -result = conn.query("select * from log") -for row in result: - print(row) -result.close() -stmt.close() -conn.close() \ No newline at end of file diff --git a/src/connector/python/examples/bind-row.py b/src/connector/python/examples/bind-row.py deleted file mode 100644 index 4ab9a9167ad23a6167c6586aac30ae6941dcee6d..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/bind-row.py +++ /dev/null @@ -1,57 +0,0 @@ -from taos import * - -conn = connect() - -dbname = "pytest_taos_stmt" -conn.execute("drop database if exists %s" % dbname) -conn.execute("create database if not exists %s" % dbname) -conn.select_db(dbname) - -conn.execute( - "create table if not exists log(ts timestamp, bo bool, nil tinyint, \ - ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \ - su smallint unsigned, iu int unsigned, bu bigint unsigned, \ - ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", -) - -stmt = conn.statement("insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") - -params = new_bind_params(16) -params[0].timestamp(1626861392589) -params[1].bool(True) -params[2].null() -params[3].tinyint(2) -params[4].smallint(3) -params[5].int(4) -params[6].bigint(5) -params[7].tinyint_unsigned(6) -params[8].smallint_unsigned(7) -params[9].int_unsigned(8) -params[10].bigint_unsigned(9) -params[11].float(10.1) -params[12].double(10.11) -params[13].binary("hello") -params[14].nchar("stmt") -params[15].timestamp(1626861392589) -stmt.bind_param(params) - -params[0].timestamp(1626861392590) -params[15].null() -stmt.bind_param(params) -stmt.execute() - - -result = stmt.use_result() -assert result.affected_rows == 2 -# No need to explicitly close, but ok for you -# result.close() - -result = conn.query("select * from log") - -for row in result: - print(row) - -# No need to explicitly close, but ok for you -# result.close() -# stmt.close() -# conn.close() diff --git a/src/connector/python/examples/demo.py b/src/connector/python/examples/demo.py deleted file mode 100644 index 3bc09046f3a33557e513425c06373c66958f2a2f..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/demo.py +++ /dev/null @@ -1,12 +0,0 @@ -import taos - -conn = taos.connect(host='127.0.0.1', - user='root', - password='taosdata', - database='log') -cursor = conn.cursor() - -sql = "select * from log.log limit 10" -cursor.execute(sql) -for row in cursor: - print(row) diff --git a/src/connector/python/examples/insert-lines.py b/src/connector/python/examples/insert-lines.py deleted file mode 100644 index 1d20af7e9bcac23deb70c1dbd058bb86dd5585a5..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/insert-lines.py +++ /dev/null @@ -1,23 +0,0 @@ -import taos -from taos import SmlProtocol, SmlPrecision - -conn = taos.connect() -dbname = "pytest_line" -conn.execute("drop database if exists %s" % dbname) -conn.execute("create database if not exists %s precision 'us'" % dbname) -conn.select_db(dbname) - -lines = [ - 'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"pass",c2=false,c4=4f64 1626006833639000000', -] -conn.schemaless_insert(lines, taos.SmlProtocol.LINE_PROTOCOL, taos.SmlPrecision.NOT_CONFIGURED) -print("inserted") - -conn.schemaless_insert(lines, taos.SmlProtocol.LINE_PROTOCOL, taos.SmlPrecision.NOT_CONFIGURED) - -result = conn.query("show tables") -for row in result: - print(row) - - -conn.execute("drop database if exists %s" % dbname) diff --git a/src/connector/python/examples/pep-249.py b/src/connector/python/examples/pep-249.py deleted file mode 100644 index 971a3c401f00b982096b8d429f65bce73cca4760..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/pep-249.py +++ /dev/null @@ -1,9 +0,0 @@ -import taos - -conn = taos.connect() -cursor = conn.cursor() - -cursor.execute("show databases") -results = cursor.fetchall() -for row in results: - print(row) diff --git a/src/connector/python/examples/query-objectively.py b/src/connector/python/examples/query-objectively.py deleted file mode 100644 index 104347cbf91e29e62fef26477b475053a8b8bc3e..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/query-objectively.py +++ /dev/null @@ -1,12 +0,0 @@ -import taos - -conn = taos.connect() -conn.execute("create database if not exists pytest") - -result = conn.query("show databases") -num_of_fields = result.field_count -for field in result.fields: - print(field) -for row in result: - print(row) -conn.execute("drop database pytest") diff --git a/src/connector/python/examples/stream.py b/src/connector/python/examples/stream.py deleted file mode 100644 index 73cbd03c493f4441d661f924bf648bc8992aeb0a..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/stream.py +++ /dev/null @@ -1,59 +0,0 @@ -from taos import * -from ctypes import * -import time - -def stream_callback(p_param, p_result, p_row): - # type: (c_void_p, c_void_p, c_void_p) -> None - if p_result is None or p_row is None: - return - result = TaosResult(p_result) - row = TaosRow(result, p_row) - try: - ts, count = row() - p = cast(p_param, POINTER(Counter)) - p.contents.count += count - print("[%s] inserted %d in 5s, total count: %d" % (ts.strftime("%Y-%m-%d %H:%M:%S"), count, p.contents.count)) - except Exception as err: - print(err) - raise err - - -class Counter(Structure): - _fields_ = [ - ("count", c_int), - ] - - def __str__(self): - return "%d" % self.count - - -def test_stream(conn): - # type: (TaosConnection) -> None - dbname = "pytest_taos_stream" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) - conn.execute("create table if not exists log(ts timestamp, n int)") - - result = conn.query("select count(*) from log interval(5s)") - assert result.field_count == 2 - counter = Counter() - counter.count = 0 - stream = conn.stream("select count(*) from log interval(5s)", stream_callback, param=byref(counter)) - - for _ in range(0, 20): - conn.execute("insert into log values(now,0)(now+1s, 1)(now + 2s, 2)") - time.sleep(2) - - stream.close() - conn.execute("drop database if exists %s" % dbname) - conn.close() - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - raise err - - -if __name__ == "__main__": - test_stream(connect()) diff --git a/src/connector/python/examples/subscribe-async.py b/src/connector/python/examples/subscribe-async.py deleted file mode 100644 index 49156de7edfb4322d7888727c28b76868cf6a16a..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/subscribe-async.py +++ /dev/null @@ -1,46 +0,0 @@ -from taos import * -from ctypes import * - -import time - - -def subscribe_callback(p_sub, p_result, p_param, errno): - # type: (c_void_p, c_void_p, c_void_p, c_int) -> None - print("# fetch in callback") - result = TaosResult(c_void_p(p_result)) - result.check_error(errno) - for row in result.rows_iter(): - ts, n = row() - print(ts, n) - - -def test_subscribe_callback(conn): - # type: (TaosConnection) -> None - dbname = "pytest_taos_subscribe_callback" - try: - print("drop if exists") - conn.execute("drop database if exists %s" % dbname) - print("create database") - conn.execute("create database if not exists %s" % dbname) - print("create table") - # conn.execute("use %s" % dbname) - conn.execute("create table if not exists %s.log(ts timestamp, n int)" % dbname) - - print("# subscribe with callback") - sub = conn.subscribe(False, "test", "select * from %s.log" % dbname, 1000, subscribe_callback) - - for i in range(10): - conn.execute("insert into %s.log values(now, %d)" % (dbname, i)) - time.sleep(0.7) - sub.close() - - conn.execute("drop database if exists %s" % dbname) - # conn.close() - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - # conn.close() - raise err - - -if __name__ == "__main__": - test_subscribe_callback(connect()) diff --git a/src/connector/python/examples/subscribe-sync.py b/src/connector/python/examples/subscribe-sync.py deleted file mode 100644 index 3a7f65f460280924ed3a577fe55b975fbf12c1a3..0000000000000000000000000000000000000000 --- a/src/connector/python/examples/subscribe-sync.py +++ /dev/null @@ -1,53 +0,0 @@ -import taos -import random - -conn = taos.connect() -dbname = "pytest_taos_subscribe" -conn.execute("drop database if exists %s" % dbname) -conn.execute("create database if not exists %s" % dbname) -conn.select_db(dbname) -conn.execute("create table if not exists log(ts timestamp, n int)") -for i in range(10): - conn.execute("insert into log values(now, %d)" % i) - -sub = conn.subscribe(False, "test", "select * from log", 1000) -print("# consume from begin") -for ts, n in sub.consume(): - print(ts, n) - -print("# consume new data") -for i in range(5): - conn.execute("insert into log values(now, %d)(now+1s, %d)" % (i, i)) - result = sub.consume() - for ts, n in result: - print(ts, n) - -sub.close(True) -print("# keep progress consume") -sub = conn.subscribe(False, "test", "select * from log", 1000) -result = sub.consume() -rows = result.fetch_all() -# consume from latest subscription needs root privilege(for /var/lib/taos). -assert result.row_count == 0 -print("## consumed ", len(rows), "rows") - -print("# consume with a stop condition") -for i in range(10): - conn.execute("insert into log values(now, %d)" % random.randint(0, 10)) - result = sub.consume() - try: - ts, n = next(result) - print(ts, n) - if n > 5: - result.stop_query() - print("## stopped") - break - except StopIteration: - continue - -sub.close() - -# sub.close() - -conn.execute("drop database if exists %s" % dbname) -# conn.close() diff --git a/src/connector/python/pyproject.toml b/src/connector/python/pyproject.toml deleted file mode 100644 index 69e3351712b647712a88d7067545ea12ed86506d..0000000000000000000000000000000000000000 --- a/src/connector/python/pyproject.toml +++ /dev/null @@ -1,30 +0,0 @@ -[tool.poetry] -name = "taospy" -version = "2.1.2" -description = "TDengine connector for python" -authors = ["Taosdata Inc. "] -license = "AGPL-3.0" -readme = "README.md" -packages = [ - {include = "taos"} -] - -[tool.poetry.dependencies] -python = "^2.7 || ^3.4" -typing = "*" - -[tool.poetry.dev-dependencies] -pytest = [ - { version = "^4.6", python = ">=2.7,<3.0" }, - { version = "^6.2", python = ">=3.7,<4.0" } -] -pdoc = { version = "^7.1.1", python = "^3.7" } -mypy = { version = "^0.910", python = "^3.6" } -black = [{ version = "^21.*", python = ">=3.6.2,<4.0" }] - -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" - -[tool.black] -line-length = 119 diff --git a/src/connector/python/setup.py b/src/connector/python/setup.py deleted file mode 100644 index 8f1dfafe4762e4a55a6d3e7c645c945a67a10f68..0000000000000000000000000000000000000000 --- a/src/connector/python/setup.py +++ /dev/null @@ -1,34 +0,0 @@ -import setuptools - -with open("README.md", "r") as fh: - long_description = fh.read() - -setuptools.setup( - name="taos", - version="2.1.1", - author="Taosdata Inc.", - author_email="support@taosdata.com", - description="TDengine python client package", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/taosdata/TDengine/tree/develop/src/connector/python", - packages=setuptools.find_packages(), - classifiers=[ - "Environment :: Console", - "Environment :: MacOS X", - "Environment :: Win32 (MS Windows)", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", - "Operating System :: MacOS", - "Programming Language :: Python :: 2.7", - "Operating System :: Linux", - "Operating System :: POSIX :: Linux", - "Operating System :: Microsoft :: Windows", - "Operating System :: Microsoft :: Windows :: Windows 10", - ], -) diff --git a/src/connector/python/taos/__init__.py b/src/connector/python/taos/__init__.py deleted file mode 100644 index 739265ef579b6a5127df8ee592b73293f113a2ef..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/__init__.py +++ /dev/null @@ -1,485 +0,0 @@ -# encoding:UTF-8 -""" -# TDengine Connector for Python - -[TDengine](https://github.com/taosdata/TDengine) connector for Python enables python programs to access TDengine, - using an API which is compliant with the Python DB API 2.0 (PEP-249). It uses TDengine C client library for client server communications. - -## Install - -```sh -git clone --depth 1 https://github.com/taosdata/TDengine.git -pip install ./TDengine/src/connector/python -``` - -## Source Code - -[TDengine](https://github.com/taosdata/TDengine) connector for Python source code is hosted on [GitHub](https://github.com/taosdata/TDengine/tree/develop/src/connector/python). - -## Examples - -### Query with PEP-249 API - -```python -import taos - -conn = taos.connect() -cursor = conn.cursor() - -cursor.execute("show databases") -results = cursor.fetchall() -for row in results: - print(row) -cursor.close() -conn.close() -``` - -### Query with objective API - -```python -import taos - -conn = taos.connect() -conn.exec("create database if not exists pytest") - -result = conn.query("show databases") -num_of_fields = result.field_count -for field in result.fields: - print(field) -for row in result: - print(row) -result.close() -conn.exec("drop database pytest") -conn.close() -``` - -### Query with async API - -```python -from taos import * -from ctypes import * -import time - -def fetch_callback(p_param, p_result, num_of_rows): - print("fetched ", num_of_rows, "rows") - p = cast(p_param, POINTER(Counter)) - result = TaosResult(p_result) - - if num_of_rows == 0: - print("fetching completed") - p.contents.done = True - result.close() - return - if num_of_rows < 0: - p.contents.done = True - result.check_error(num_of_rows) - result.close() - return None - - for row in result.rows_iter(num_of_rows): - # print(row) - None - p.contents.count += result.row_count - result.fetch_rows_a(fetch_callback, p_param) - - - -def query_callback(p_param, p_result, code): - # type: (c_void_p, c_void_p, c_int) -> None - if p_result is None: - return - result = TaosResult(p_result) - if code == 0: - result.fetch_rows_a(fetch_callback, p_param) - result.check_error(code) - - -class Counter(Structure): - _fields_ = [("count", c_int), ("done", c_bool)] - - def __str__(self): - return "{ count: %d, done: %s }" % (self.count, self.done) - - -def test_query(conn): - # type: (TaosConnection) -> None - counter = Counter(count=0) - conn.query_a("select * from log.log", query_callback, byref(counter)) - - while not counter.done: - print("wait query callback") - time.sleep(1) - print(counter) - conn.close() - - -if __name__ == "__main__": - test_query(connect()) -``` - -### Statement API - Bind row after row - -```python -from taos import * - -conn = connect() - -dbname = "pytest_taos_stmt" -conn.exec("drop database if exists %s" % dbname) -conn.exec("create database if not exists %s" % dbname) -conn.select_db(dbname) - -conn.exec( - "create table if not exists log(ts timestamp, bo bool, nil tinyint, \\ - ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \\ - su smallint unsigned, iu int unsigned, bu bigint unsigned, \\ - ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", -) - -stmt = conn.statement("insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") - -params = new_bind_params(16) -params[0].timestamp(1626861392589) -params[1].bool(True) -params[2].null() -params[3].tinyint(2) -params[4].smallint(3) -params[5].int(4) -params[6].bigint(5) -params[7].tinyint_unsigned(6) -params[8].smallint_unsigned(7) -params[9].int_unsigned(8) -params[10].bigint_unsigned(9) -params[11].float(10.1) -params[12].double(10.11) -params[13].binary("hello") -params[14].nchar("stmt") -params[15].timestamp(1626861392589) -stmt.bind_param(params) - -params[0].timestamp(1626861392590) -params[15].null() -stmt.bind_param(params) -stmt.execute() - - -result = stmt.use_result() -assert result.affected_rows == 2 -result.close() - -result = conn.query("select * from log") - -for row in result: - print(row) -result.close() -stmt.close() -conn.close() - -``` - -### Statement API - Bind multi rows - -```python -from taos import * - -conn = connect() - -dbname = "pytest_taos_stmt" -conn.exec("drop database if exists %s" % dbname) -conn.exec("create database if not exists %s" % dbname) -conn.select_db(dbname) - -conn.exec( - "create table if not exists log(ts timestamp, bo bool, nil tinyint, \\ - ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \\ - su smallint unsigned, iu int unsigned, bu bigint unsigned, \\ - ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", -) - -stmt = conn.statement("insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") - -params = new_multi_binds(16) -params[0].timestamp((1626861392589, 1626861392590, 1626861392591)) -params[1].bool((True, None, False)) -params[2].tinyint([-128, -128, None]) # -128 is tinyint null -params[3].tinyint([0, 127, None]) -params[4].smallint([3, None, 2]) -params[5].int([3, 4, None]) -params[6].bigint([3, 4, None]) -params[7].tinyint_unsigned([3, 4, None]) -params[8].smallint_unsigned([3, 4, None]) -params[9].int_unsigned([3, 4, None]) -params[10].bigint_unsigned([3, 4, None]) -params[11].float([3, None, 1]) -params[12].double([3, None, 1.2]) -params[13].binary(["abc", "dddafadfadfadfadfa", None]) -params[14].nchar(["涛思数据", None, "a long string with 中文字符"]) -params[15].timestamp([None, None, 1626861392591]) -stmt.bind_param_batch(params) -stmt.execute() - - -result = stmt.use_result() -assert result.affected_rows == 3 -result.close() - -result = conn.query("select * from log") -for row in result: - print(row) -result.close() -stmt.close() -conn.close() -``` - -### Statement API - Subscribe - -```python -import taos - -conn = taos.connect() -dbname = "pytest_taos_subscribe_callback" -conn.exec("drop database if exists %s" % dbname) -conn.exec("create database if not exists %s" % dbname) -conn.select_db(dbname) -conn.exec("create table if not exists log(ts timestamp, n int)") -for i in range(10): - conn.exec("insert into log values(now, %d)" % i) - -sub = conn.subscribe(True, "test", "select * from log", 1000) -print("# consume from begin") -for ts, n in sub.consume(): - print(ts, n) - -print("# consume new data") -for i in range(5): - conn.exec("insert into log values(now, %d)(now+1s, %d)" % (i, i)) - result = sub.consume() - for ts, n in result: - print(ts, n) - -print("# consume with a stop condition") -for i in range(10): - conn.exec("insert into log values(now, %d)" % int(random() * 10)) - result = sub.consume() - try: - ts, n = next(result) - print(ts, n) - if n > 5: - result.stop_query() - print("## stopped") - break - except StopIteration: - continue - -sub.close() - -conn.exec("drop database if exists %s" % dbname) -conn.close() -``` - -### Statement API - Subscribe asynchronously with callback - -```python -from taos import * -from ctypes import * - -import time - - -def subscribe_callback(p_sub, p_result, p_param, errno): - # type: (c_void_p, c_void_p, c_void_p, c_int) -> None - print("# fetch in callback") - result = TaosResult(p_result) - result.check_error(errno) - for row in result.rows_iter(): - ts, n = row() - print(ts, n) - - -def test_subscribe_callback(conn): - # type: (TaosConnection) -> None - dbname = "pytest_taos_subscribe_callback" - try: - conn.exec("drop database if exists %s" % dbname) - conn.exec("create database if not exists %s" % dbname) - conn.select_db(dbname) - conn.exec("create table if not exists log(ts timestamp, n int)") - - print("# subscribe with callback") - sub = conn.subscribe(False, "test", "select * from log", 1000, subscribe_callback) - - for i in range(10): - conn.exec("insert into log values(now, %d)" % i) - time.sleep(0.7) - sub.close() - - conn.exec("drop database if exists %s" % dbname) - conn.close() - except Exception as err: - conn.exec("drop database if exists %s" % dbname) - conn.close() - raise err - - -if __name__ == "__main__": - test_subscribe_callback(connect()) - -``` - -### Statement API - Stream - -```python -from taos import * -from ctypes import * - -def stream_callback(p_param, p_result, p_row): - # type: (c_void_p, c_void_p, c_void_p) -> None - - if p_result is None or p_row is None: - return - result = TaosResult(p_result) - row = TaosRow(result, p_row) - try: - ts, count = row() - p = cast(p_param, POINTER(Counter)) - p.contents.count += count - print("[%s] inserted %d in 5s, total count: %d" % (ts.strftime("%Y-%m-%d %H:%M:%S"), count, p.contents.count)) - - except Exception as err: - print(err) - raise err - - -class Counter(ctypes.Structure): - _fields_ = [ - ("count", c_int), - ] - - def __str__(self): - return "%d" % self.count - - -def test_stream(conn): - # type: (TaosConnection) -> None - dbname = "pytest_taos_stream" - try: - conn.exec("drop database if exists %s" % dbname) - conn.exec("create database if not exists %s" % dbname) - conn.select_db(dbname) - conn.exec("create table if not exists log(ts timestamp, n int)") - - result = conn.query("select count(*) from log interval(5s)") - assert result.field_count == 2 - counter = Counter() - counter.count = 0 - stream = conn.stream("select count(*) from log interval(5s)", stream_callback, param=byref(counter)) - - for _ in range(0, 20): - conn.exec("insert into log values(now,0)(now+1s, 1)(now + 2s, 2)") - time.sleep(2) - stream.close() - conn.exec("drop database if exists %s" % dbname) - conn.close() - except Exception as err: - conn.exec("drop database if exists %s" % dbname) - conn.close() - raise err - - -if __name__ == "__main__": - test_stream(connect()) -``` - -### Insert with line protocol - -```python -import taos - -conn = taos.connect() -dbname = "pytest_line" -conn.exec("drop database if exists %s" % dbname) -conn.exec("create database if not exists %s precision 'us'" % dbname) -conn.select_db(dbname) - -lines = [ - 'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000', - 'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000', - 'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000', -] -conn.schemaless_insert(lines, 0, "ns") -print("inserted") - -lines = [ - 'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000', -] -conn.schemaless_insert(lines, 0, "ns") - -result = conn.query("show tables") -for row in result: - print(row) -result.close() - - -conn.exec("drop database if exists %s" % dbname) -conn.close() - -``` - -## License - AGPL-3.0 - -Keep same with [TDengine](https://github.com/taosdata/TDengine). -""" -from .connection import TaosConnection - -# For some reason, the following is needed for VS Code (through PyLance) to -# recognize that "error" is a valid module of the "taos" package. -from .error import * -from .bind import * -from .field import * -from .cursor import * -from .result import * -from .statement import * -from .subscription import * -from .schemaless import * - -from taos._version import __version__ - -# Globals -threadsafety = 0 -paramstyle = "pyformat" - -__all__ = [ - "__version__", - # functions - "connect", - "new_bind_param", - "new_bind_params", - "new_multi_binds", - "new_multi_bind", - # objects - "TaosBind", - "TaosConnection", - "TaosCursor", - "TaosResult", - "TaosRows", - "TaosRow", - "TaosStmt", - "PrecisionEnum", - "SmlPrecision", - "SmlProtocol" -] - -def connect(*args, **kwargs): - # type: (..., ...) -> TaosConnection - """Function to return a TDengine connector object - - Current supporting keyword parameters: - @dsn: Data source name as string - @user: Username as string(optional) - @password: Password as string(optional) - @host: Hostname(optional) - @database: Database name(optional) - - @rtype: TDengineConnector - """ - return TaosConnection(*args, **kwargs) diff --git a/src/connector/python/taos/_version.py b/src/connector/python/taos/_version.py deleted file mode 100644 index f811561263c557cf534e90ff763373bccacb20b6..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '2.1.2' diff --git a/src/connector/python/taos/bind.py b/src/connector/python/taos/bind.py deleted file mode 100644 index 8f39278c960c285f4a8c0bfc1d8b198bb4a56f4c..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/bind.py +++ /dev/null @@ -1,457 +0,0 @@ -# encoding:UTF-8 -import ctypes -from .constants import FieldType -from .error import * -from .precision import * -from datetime import datetime -from ctypes import * -import sys - -_datetime_epoch = datetime.utcfromtimestamp(0) - -def _is_not_none(obj): - return obj != None - -class TaosBind(ctypes.Structure): - _fields_ = [ - ("buffer_type", c_int), - ("buffer", c_void_p), - ("buffer_length", c_size_t), - ("length", POINTER(c_size_t)), - ("is_null", POINTER(c_int)), - ("is_unsigned", c_int), - ("error", POINTER(c_int)), - ("u", c_int64), - ("allocated", c_int), - ] - - def null(self): - self.buffer_type = FieldType.C_NULL - self.is_null = pointer(c_int(1)) - - def bool(self, value): - self.buffer_type = FieldType.C_BOOL - self.buffer = cast(pointer(c_bool(value)), c_void_p) - self.buffer_length = sizeof(c_bool) - - def tinyint(self, value): - self.buffer_type = FieldType.C_TINYINT - self.buffer = cast(pointer(c_int8(value)), c_void_p) - self.buffer_length = sizeof(c_int8) - - def smallint(self, value): - self.buffer_type = FieldType.C_SMALLINT - self.buffer = cast(pointer(c_int16(value)), c_void_p) - self.buffer_length = sizeof(c_int16) - - def int(self, value): - self.buffer_type = FieldType.C_INT - self.buffer = cast(pointer(c_int32(value)), c_void_p) - self.buffer_length = sizeof(c_int32) - - def bigint(self, value): - self.buffer_type = FieldType.C_BIGINT - self.buffer = cast(pointer(c_int64(value)), c_void_p) - self.buffer_length = sizeof(c_int64) - - def float(self, value): - self.buffer_type = FieldType.C_FLOAT - self.buffer = cast(pointer(c_float(value)), c_void_p) - self.buffer_length = sizeof(c_float) - - def double(self, value): - self.buffer_type = FieldType.C_DOUBLE - self.buffer = cast(pointer(c_double(value)), c_void_p) - self.buffer_length = sizeof(c_double) - - def binary(self, value): - buffer = None - length = 0 - if isinstance(value, str): - bytes = value.encode("utf-8") - buffer = create_string_buffer(bytes) - length = len(bytes) - else: - buffer = value - length = len(value) - self.buffer_type = FieldType.C_BINARY - self.buffer = cast(buffer, c_void_p) - self.buffer_length = length - self.length = pointer(c_size_t(self.buffer_length)) - - def timestamp(self, value, precision=PrecisionEnum.Milliseconds): - if type(value) is datetime: - if precision == PrecisionEnum.Milliseconds: - ts = int(round((value - _datetime_epoch).total_seconds() * 1000)) - elif precision == PrecisionEnum.Microseconds: - ts = int(round((value - _datetime_epoch).total_seconds() * 10000000)) - else: - raise PrecisionError("datetime do not support nanosecond precision") - elif type(value) is float: - if precision == PrecisionEnum.Milliseconds: - ts = int(round(value * 1000)) - elif precision == PrecisionEnum.Microseconds: - ts = int(round(value * 10000000)) - else: - raise PrecisionError("time float do not support nanosecond precision") - elif isinstance(value, int) and not isinstance(value, bool): - ts = value - elif isinstance(value, str): - value = datetime.fromisoformat(value) - if precision == PrecisionEnum.Milliseconds: - ts = int(round(value * 1000)) - elif precision == PrecisionEnum.Microseconds: - ts = int(round(value * 10000000)) - else: - raise PrecisionError("datetime do not support nanosecond precision") - - self.buffer_type = FieldType.C_TIMESTAMP - self.buffer = cast(pointer(c_int64(ts)), c_void_p) - self.buffer_length = sizeof(c_int64) - - def nchar(self, value): - buffer = None - length = 0 - if isinstance(value, str): - bytes = value.encode("utf-8") - buffer = create_string_buffer(bytes) - length = len(bytes) - else: - buffer = value - length = len(value) - self.buffer_type = FieldType.C_NCHAR - self.buffer = cast(buffer, c_void_p) - self.buffer_length = length - self.length = pointer(c_size_t(self.buffer_length)) - - def json(self, value): - buffer = None - length = 0 - if isinstance(value, str): - bytes = value.encode("utf-8") - buffer = create_string_buffer(bytes) - length = len(bytes) - else: - buffer = value - length = len(value) - self.buffer_type = FieldType.C_JSON - self.buffer = cast(buffer, c_void_p) - self.buffer_length = length - self.length = pointer(c_size_t(self.buffer_length)) - - def tinyint_unsigned(self, value): - self.buffer_type = FieldType.C_TINYINT_UNSIGNED - self.buffer = cast(pointer(c_uint8(value)), c_void_p) - self.buffer_length = sizeof(c_uint8) - - def smallint_unsigned(self, value): - self.buffer_type = FieldType.C_SMALLINT_UNSIGNED - self.buffer = cast(pointer(c_uint16(value)), c_void_p) - self.buffer_length = sizeof(c_uint16) - - def int_unsigned(self, value): - self.buffer_type = FieldType.C_INT_UNSIGNED - self.buffer = cast(pointer(c_uint32(value)), c_void_p) - self.buffer_length = sizeof(c_uint32) - - def bigint_unsigned(self, value): - self.buffer_type = FieldType.C_BIGINT_UNSIGNED - self.buffer = cast(pointer(c_uint64(value)), c_void_p) - self.buffer_length = sizeof(c_uint64) - - -def _datetime_to_timestamp(value, precision): - # type: (datetime | float | int | str | c_int64, PrecisionEnum) -> c_int64 - if value is None: - return FieldType.C_BIGINT_NULL - if type(value) is datetime: - if precision == PrecisionEnum.Milliseconds: - return int(round((value - _datetime_epoch).total_seconds() * 1000)) - elif precision == PrecisionEnum.Microseconds: - return int(round((value - _datetime_epoch).total_seconds() * 10000000)) - else: - raise PrecisionError("datetime do not support nanosecond precision") - elif type(value) is float: - if precision == PrecisionEnum.Milliseconds: - return int(round(value * 1000)) - elif precision == PrecisionEnum.Microseconds: - return int(round(value * 10000000)) - else: - raise PrecisionError("time float do not support nanosecond precision") - elif isinstance(value, int) and not isinstance(value, bool): - return c_int64(value) - elif isinstance(value, str): - value = datetime.fromisoformat(value) - if precision == PrecisionEnum.Milliseconds: - return int(round(value * 1000)) - elif precision == PrecisionEnum.Microseconds: - return int(round(value * 10000000)) - else: - raise PrecisionError("datetime do not support nanosecond precision") - elif isinstance(value, c_int64): - return value - return FieldType.C_BIGINT_NULL - - -class TaosMultiBind(ctypes.Structure): - _fields_ = [ - ("buffer_type", c_int), - ("buffer", c_void_p), - ("buffer_length", c_size_t), - ("length", POINTER(c_int32)), - ("is_null", c_char_p), - ("num", c_int), - ] - - def null(self, num): - self.buffer_type = FieldType.C_NULL - self.is_null = cast((c_char * num)(*[1 for _ in range(num)]), c_char_p) - self.buffer = c_void_p(None) - self.num = num - - def bool(self, values): - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_int8 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_BOOL_NULL for v in values]) - - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - self.buffer_type = FieldType.C_BOOL - self.buffer_length = sizeof(c_bool) - - def tinyint(self, values): - self.buffer_type = FieldType.C_TINYINT - self.buffer_length = sizeof(c_int8) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_int8 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_TINYINT_NULL for v in values]) - - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def smallint(self, values): - self.buffer_type = FieldType.C_SMALLINT - self.buffer_length = sizeof(c_int16) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_int16 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_SMALLINT_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def int(self, values): - self.buffer_type = FieldType.C_INT - self.buffer_length = sizeof(c_int32) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_int32 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_INT_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def bigint(self, values): - self.buffer_type = FieldType.C_BIGINT - self.buffer_length = sizeof(c_int64) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_int64 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_BIGINT_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def float(self, values): - self.buffer_type = FieldType.C_FLOAT - self.buffer_length = sizeof(c_float) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_float * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_FLOAT_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def double(self, values): - self.buffer_type = FieldType.C_DOUBLE - self.buffer_length = sizeof(c_double) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_double * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_DOUBLE_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def _str_to_buffer(self, values): - self.num = len(values) - is_null = [1 if v is None else 0 for v in values] - self.is_null = cast((c_byte * self.num)(*is_null), c_char_p) - - if sum(is_null) == self.num: - self.length = (c_int32 * len(values))(0 * self.num) - return - if sys.version_info < (3, 0): - _bytes = [bytes(value) if value is not None else None for value in values] - buffer_length = max(len(b) + 1 for b in _bytes if b is not None) - buffers = [ - create_string_buffer(b, buffer_length) if b is not None else create_string_buffer(buffer_length) - for b in _bytes - ] - buffer_all = b''.join(v[:] for v in buffers) - self.buffer = cast(c_char_p(buffer_all), c_void_p) - else: - _bytes = [value.encode("utf-8") if value is not None else None for value in values] - buffer_length = max(len(b) for b in _bytes if b is not None) - self.buffer = cast( - c_char_p( - b"".join( - [ - create_string_buffer(b, buffer_length) - if b is not None - else create_string_buffer(buffer_length) - for b in _bytes - ] - ) - ), - c_void_p, - ) - self.length = (c_int32 * len(values))(*[len(b) if b is not None else 0 for b in _bytes]) - self.buffer_length = buffer_length - def binary(self, values): - self.buffer_type = FieldType.C_BINARY - self._str_to_buffer(values) - - def timestamp(self, values, precision=PrecisionEnum.Milliseconds): - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_int64 * len(values) - buffer = buffer_type(*[_datetime_to_timestamp(value, precision) for value in values]) - - self.buffer_type = FieldType.C_TIMESTAMP - self.buffer = cast(buffer, c_void_p) - self.buffer_length = sizeof(c_int64) - self.num = len(values) - - def nchar(self, values): - # type: (list[str]) -> None - self.buffer_type = FieldType.C_NCHAR - self._str_to_buffer(values) - - def json(self, values): - # type: (list[str]) -> None - self.buffer_type = FieldType.C_JSON - self._str_to_buffer(values) - - def tinyint_unsigned(self, values): - self.buffer_type = FieldType.C_TINYINT_UNSIGNED - self.buffer_length = sizeof(c_uint8) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_uint8 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_TINYINT_UNSIGNED_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def smallint_unsigned(self, values): - self.buffer_type = FieldType.C_SMALLINT_UNSIGNED - self.buffer_length = sizeof(c_uint16) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_uint16 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_SMALLINT_UNSIGNED_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def int_unsigned(self, values): - self.buffer_type = FieldType.C_INT_UNSIGNED - self.buffer_length = sizeof(c_uint32) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_uint32 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_INT_UNSIGNED_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - def bigint_unsigned(self, values): - self.buffer_type = FieldType.C_BIGINT_UNSIGNED - self.buffer_length = sizeof(c_uint64) - - try: - buffer = cast(values, c_void_p) - except: - buffer_type = c_uint64 * len(values) - try: - buffer = buffer_type(*values) - except: - buffer = buffer_type(*[v if v is not None else FieldType.C_BIGINT_UNSIGNED_NULL for v in values]) - self.buffer = cast(buffer, c_void_p) - self.num = len(values) - - -def new_bind_param(): - # type: () -> TaosBind - return TaosBind() - - -def new_bind_params(size): - # type: (int) -> Array[TaosBind] - return (TaosBind * size)() - - -def new_multi_bind(): - # type: () -> TaosMultiBind - return TaosMultiBind() - - -def new_multi_binds(size): - # type: (int) -> Array[TaosMultiBind] - return (TaosMultiBind * size)() diff --git a/src/connector/python/taos/cinterface.py b/src/connector/python/taos/cinterface.py deleted file mode 100644 index be39d2291a908b9349599ba13e92a205696516c7..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/cinterface.py +++ /dev/null @@ -1,921 +0,0 @@ -# encoding:UTF-8 - -import ctypes -import platform -import inspect -from ctypes import * - -try: - from typing import Any -except: - pass - -from .error import * -from .bind import * -from .field import * -from .schemaless import * - -_UNSUPPORTED = {} - -# stream callback -stream_callback_type = CFUNCTYPE(None, c_void_p, c_void_p, c_void_p) -stream_callback2_type = CFUNCTYPE(None, c_void_p) - -# C interface class -class TaosOption: - Locale = (0,) - Charset = (1,) - Timezone = (2,) - ConfigDir = (3,) - ShellActivityTimer = (4,) - MaxOptions = (5,) - - -def _load_taos_linux(): - return ctypes.CDLL("libtaos.so") - - -def _load_taos_darwin(): - return ctypes.CDLL("libtaos.dylib") - - -def _load_taos_windows(): - return ctypes.windll.LoadLibrary("taos") - - -def _load_taos(): - load_func = { - "Linux": _load_taos_linux, - "Darwin": _load_taos_darwin, - "Windows": _load_taos_windows, - } - pf = platform.system() - if load_func[pf] is None: - raise InterfaceError("unsupported platform: %s" % pf) - try: - return load_func[pf]() - except Exception as err: - raise InterfaceError("unable to load taos C library: %s" % err) - - -_libtaos = _load_taos() - -_libtaos.taos_fetch_fields.restype = ctypes.POINTER(TaosField) -_libtaos.taos_init.restype = None -_libtaos.taos_connect.restype = ctypes.c_void_p -_libtaos.taos_fetch_row.restype = ctypes.POINTER(ctypes.c_void_p) -_libtaos.taos_errstr.restype = ctypes.c_char_p -_libtaos.taos_subscribe.restype = ctypes.c_void_p -_libtaos.taos_consume.restype = ctypes.c_void_p -_libtaos.taos_fetch_lengths.restype = ctypes.POINTER(ctypes.c_int) -_libtaos.taos_free_result.restype = None -_libtaos.taos_query.restype = ctypes.POINTER(ctypes.c_void_p) - -try: - _libtaos.taos_stmt_errstr.restype = c_char_p -except AttributeError: - None -finally: - None - - -_libtaos.taos_options.restype = None - - -def taos_options(option, *args): - # type: (TaosOption, Any) -> None - _libtaos.taos_options(option, *args) - - -def taos_init(): - # type: () -> None - """ - C: taos_init - """ - _libtaos.taos_init() - - -_libtaos.taos_cleanup.restype = None - - -def taos_cleanup(): - # type: () -> None - """Cleanup workspace.""" - _libtaos.taos_cleanup() - - -_libtaos.taos_get_client_info.restype = c_char_p - - -def taos_get_client_info(): - # type: () -> str - """Get client version info.""" - return _libtaos.taos_get_client_info().decode("utf-8") - - -_libtaos.taos_get_server_info.restype = c_char_p -_libtaos.taos_get_server_info.argtypes = (c_void_p,) - - -def taos_get_server_info(connection): - # type: (c_void_p) -> str - """Get server version as string.""" - return _libtaos.taos_get_server_info(connection).decode("utf-8") - - -_libtaos.taos_close.restype = None -_libtaos.taos_close.argtypes = (c_void_p,) - - -def taos_close(connection): - # type: (c_void_p) -> None - """Close the TAOS* connection""" - _libtaos.taos_close(connection) - - -_libtaos.taos_connect.restype = c_void_p -_libtaos.taos_connect.argtypes = c_char_p, c_char_p, c_char_p, c_char_p, c_uint16 - - -def taos_connect(host=None, user="root", password="taosdata", db=None, port=0): - # type: (None|str, str, str, None|str, int) -> c_void_p - """Create TDengine database connection. - - - host: server hostname/FQDN - - user: user name - - password: user password - - db: database name (optional) - - port: server port - - @rtype: c_void_p, TDengine handle - """ - # host - try: - _host = c_char_p(host.encode("utf-8")) if host is not None else None - except AttributeError: - raise AttributeError("host is expected as a str") - - # user - try: - _user = c_char_p(user.encode("utf-8")) - except AttributeError: - raise AttributeError("user is expected as a str") - - # password - try: - _password = c_char_p(password.encode("utf-8")) - except AttributeError: - raise AttributeError("password is expected as a str") - - # db - try: - _db = c_char_p(db.encode("utf-8")) if db is not None else None - except AttributeError: - raise AttributeError("db is expected as a str") - - # port - try: - _port = c_uint16(port) - except TypeError: - raise TypeError("port is expected as an uint16") - - connection = cast(_libtaos.taos_connect(_host, _user, _password, _db, _port), c_void_p) - - if connection.value is None: - raise ConnectionError("connect to TDengine failed") - return connection - - -_libtaos.taos_connect_auth.restype = c_void_p -_libtaos.taos_connect_auth.argtypes = c_char_p, c_char_p, c_char_p, c_char_p, c_uint16 - -_libtaos.taos_connect_auth.restype = c_void_p -_libtaos.taos_connect_auth.argtypes = c_char_p, c_char_p, c_char_p, c_char_p, c_uint16 - - -def taos_connect_auth(host=None, user="root", auth="", db=None, port=0): - # type: (None|str, str, str, None|str, int) -> c_void_p - """Connect server with auth token. - - - host: server hostname/FQDN - - user: user name - - auth: base64 encoded auth token - - db: database name (optional) - - port: server port - - @rtype: c_void_p, TDengine handle - """ - # host - try: - _host = c_char_p(host.encode("utf-8")) if host is not None else None - except AttributeError: - raise AttributeError("host is expected as a str") - - # user - try: - _user = c_char_p(user.encode("utf-8")) - except AttributeError: - raise AttributeError("user is expected as a str") - - # auth - try: - _auth = c_char_p(auth.encode("utf-8")) - except AttributeError: - raise AttributeError("password is expected as a str") - - # db - try: - _db = c_char_p(db.encode("utf-8")) if db is not None else None - except AttributeError: - raise AttributeError("db is expected as a str") - - # port - try: - _port = c_int(port) - except TypeError: - raise TypeError("port is expected as an int") - - connection = c_void_p(_libtaos.taos_connect_auth(_host, _user, _auth, _db, _port)) - - if connection.value is None: - raise ConnectionError("connect to TDengine failed") - return connection - - -_libtaos.taos_query.restype = c_void_p -_libtaos.taos_query.argtypes = c_void_p, c_char_p - - -def taos_query(connection, sql): - # type: (c_void_p, str) -> c_void_p - """Run SQL - - - sql: str, sql string to run - - @return: TAOS_RES*, result pointer - - """ - try: - ptr = c_char_p(sql.encode("utf-8")) - res = c_void_p(_libtaos.taos_query(connection, ptr)) - errno = taos_errno(res) - if errno != 0: - errstr = taos_errstr(res) - taos_free_result(res) - raise ProgrammingError(errstr, errno) - return res - except AttributeError: - raise AttributeError("sql is expected as a string") - - -async_query_callback_type = CFUNCTYPE(None, c_void_p, c_void_p, c_int) -_libtaos.taos_query_a.restype = None -_libtaos.taos_query_a.argtypes = c_void_p, c_char_p, async_query_callback_type, c_void_p - - -def taos_query_a(connection, sql, callback, param): - # type: (c_void_p, str, async_query_callback_type, c_void_p) -> c_void_p - _libtaos.taos_query_a(connection, c_char_p(sql.encode("utf-8")), async_query_callback_type(callback), param) - - -async_fetch_rows_callback_type = CFUNCTYPE(None, c_void_p, c_void_p, c_int) -_libtaos.taos_fetch_rows_a.restype = None -_libtaos.taos_fetch_rows_a.argtypes = c_void_p, async_fetch_rows_callback_type, c_void_p - - -def taos_fetch_rows_a(result, callback, param): - # type: (c_void_p, async_fetch_rows_callback_type, c_void_p) -> c_void_p - _libtaos.taos_fetch_rows_a(result, async_fetch_rows_callback_type(callback), param) - - -def taos_affected_rows(result): - # type: (c_void_p) -> c_int - """The affected rows after runing query""" - return _libtaos.taos_affected_rows(result) - - -subscribe_callback_type = CFUNCTYPE(None, c_void_p, c_void_p, c_void_p, c_int) -_libtaos.taos_subscribe.restype = c_void_p -# _libtaos.taos_subscribe.argtypes = c_void_p, c_int, c_char_p, c_char_p, subscribe_callback_type, c_void_p, c_int - - -def taos_subscribe(connection, restart, topic, sql, interval, callback=None, param=None): - # type: (c_void_p, bool, str, str, c_int, subscribe_callback_type, c_void_p | None) -> c_void_p - """Create a subscription - @restart boolean, - @sql string, sql statement for data query, must be a 'select' statement. - @topic string, name of this subscription - """ - if callback != None: - callback = subscribe_callback_type(callback) - return c_void_p( - _libtaos.taos_subscribe( - connection, - 1 if restart else 0, - c_char_p(topic.encode("utf-8")), - c_char_p(sql.encode("utf-8")), - callback, - c_void_p(param), - interval, - ) - ) - - -_libtaos.taos_consume.restype = c_void_p -_libtaos.taos_consume.argstype = (c_void_p,) - - -def taos_consume(sub): - """Consume data of a subscription""" - return c_void_p(_libtaos.taos_consume(sub)) - - -_libtaos.taos_unsubscribe.restype = None -_libtaos.taos_unsubscribe.argstype = c_void_p, c_int - - -def taos_unsubscribe(sub, keep_progress): - """Cancel a subscription""" - _libtaos.taos_unsubscribe(sub, 1 if keep_progress else 0) - - -def taos_use_result(result): - """Use result after calling self.query, it's just for 1.6.""" - fields = [] - pfields = taos_fetch_fields_raw(result) - for i in range(taos_field_count(result)): - fields.append( - { - "name": pfields[i].name, - "bytes": pfields[i].bytes, - "type": pfields[i].type, - } - ) - - return fields - - -_libtaos.taos_fetch_block.restype = c_int -_libtaos.taos_fetch_block.argtypes = c_void_p, c_void_p - - -def taos_fetch_block_raw(result): - pblock = ctypes.c_void_p(0) - num_of_rows = _libtaos.taos_fetch_block(result, ctypes.byref(pblock)) - if num_of_rows == 0: - return None, 0 - return pblock, abs(num_of_rows) - - -def taos_fetch_block(result, fields=None, field_count=None): - pblock = ctypes.c_void_p(0) - num_of_rows = _libtaos.taos_fetch_block(result, ctypes.byref(pblock)) - if num_of_rows == 0: - return None, 0 - precision = taos_result_precision(result) - if fields is None: - fields = taos_fetch_fields(result) - if field_count is None: - field_count = taos_field_count(result) - blocks = [None] * field_count - fieldLen = taos_fetch_lengths(result, field_count) - for i in range(len(fields)): - data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i] - if fields[i]["type"] not in CONVERT_FUNC: - raise DatabaseError("Invalid data type returned from database") - blocks[i] = CONVERT_FUNC_BLOCK[fields[i]["type"]](data, num_of_rows, fieldLen[i], precision) - - return blocks, abs(num_of_rows) - - -_libtaos.taos_fetch_row.restype = c_void_p -_libtaos.taos_fetch_row.argtypes = (c_void_p,) - - -def taos_fetch_row_raw(result): - # type: (c_void_p) -> c_void_p - row = c_void_p(_libtaos.taos_fetch_row(result)) - if row: - return row - return None - - -def taos_fetch_row(result, fields): - # type: (c_void_p, Array[TaosField]) -> tuple(c_void_p, int) - pblock = ctypes.c_void_p(0) - pblock = taos_fetch_row_raw(result) - if pblock: - num_of_rows = 1 - precision = taos_result_precision(result) - field_count = taos_field_count(result) - blocks = [None] * field_count - field_lens = taos_fetch_lengths(result, field_count) - for i in range(field_count): - data = ctypes.cast(pblock, ctypes.POINTER(ctypes.c_void_p))[i] - if fields[i].type not in CONVERT_FUNC: - raise DatabaseError("Invalid data type returned from database") - if data is None: - blocks[i] = [None] - else: - blocks[i] = CONVERT_FUNC[fields[i].type](data, num_of_rows, field_lens[i], precision) - else: - return None, 0 - return blocks, abs(num_of_rows) - - -_libtaos.taos_free_result.argtypes = (c_void_p,) - - -def taos_free_result(result): - # type: (c_void_p) -> None - if result != None: - _libtaos.taos_free_result(result) - - -_libtaos.taos_field_count.restype = c_int -_libtaos.taos_field_count.argstype = (c_void_p,) - - -def taos_field_count(result): - # type: (c_void_p) -> int - return _libtaos.taos_field_count(result) - - -def taos_num_fields(result): - # type: (c_void_p) -> int - return _libtaos.taos_num_fields(result) - - -_libtaos.taos_fetch_fields.restype = c_void_p -_libtaos.taos_fetch_fields.argstype = (c_void_p,) - - -def taos_fetch_fields_raw(result): - # type: (c_void_p) -> c_void_p - return c_void_p(_libtaos.taos_fetch_fields(result)) - - -def taos_fetch_fields(result): - # type: (c_void_p) -> TaosFields - fields = taos_fetch_fields_raw(result) - count = taos_field_count(result) - return TaosFields(fields, count) - - -def taos_fetch_lengths(result, field_count=None): - # type: (c_void_p, int) -> Array[int] - """Make sure to call taos_fetch_row or taos_fetch_block before fetch_lengths""" - lens = _libtaos.taos_fetch_lengths(result) - if field_count is None: - field_count = taos_field_count(result) - if not lens: - raise OperationalError("field length empty, use taos_fetch_row/block before it") - return lens[:field_count] - - -def taos_result_precision(result): - # type: (c_void_p) -> c_int - return _libtaos.taos_result_precision(result) - - -_libtaos.taos_errno.restype = c_int -_libtaos.taos_errno.argstype = (c_void_p,) - - -def taos_errno(result): - # type: (ctypes.c_void_p) -> c_int - """Return the error number.""" - return _libtaos.taos_errno(result) - - -_libtaos.taos_errstr.restype = c_char_p -_libtaos.taos_errstr.argstype = (c_void_p,) - - -def taos_errstr(result=c_void_p(None)): - # type: (ctypes.c_void_p) -> str - """Return the error styring""" - return _libtaos.taos_errstr(result).decode("utf-8") - - -_libtaos.taos_stop_query.restype = None -_libtaos.taos_stop_query.argstype = (c_void_p,) - - -def taos_stop_query(result): - # type: (ctypes.c_void_p) -> None - """Stop current query""" - return _libtaos.taos_stop_query(result) - - -try: - _libtaos.taos_load_table_info.restype = c_int - _libtaos.taos_load_table_info.argstype = (c_void_p, c_char_p) -except Exception as err: - _UNSUPPORTED["taos_open_stream"] = err - - -def taos_load_table_info(connection, tables): - # type: (ctypes.c_void_p, str) -> None - """Stop current query""" - _check_if_supported() - errno = _libtaos.taos_load_table_info(connection, c_char_p(tables.encode("utf-8"))) - if errno != 0: - msg = taos_errstr() - raise OperationalError(msg, errno) - - -_libtaos.taos_validate_sql.restype = c_int -_libtaos.taos_validate_sql.argstype = (c_void_p, c_char_p) - - -def taos_validate_sql(connection, sql): - # type: (ctypes.c_void_p, str) -> None | str - """Get taosd server info""" - errno = _libtaos.taos_validate_sql(connection, ctypes.c_char_p(sql.encode("utf-8"))) - if errno != 0: - msg = taos_errstr() - return msg - return None - - -_libtaos.taos_print_row.restype = c_int -_libtaos.taos_print_row.argstype = (c_char_p, c_void_p, c_void_p, c_int) - - -def taos_print_row(row, fields, num_fields, buffer_size=4096): - # type: (ctypes.c_void_p, ctypes.c_void_p | TaosFields, int, int) -> str - """Print an row to string""" - p = ctypes.create_string_buffer(buffer_size) - if isinstance(fields, TaosFields): - _libtaos.taos_print_row(p, row, fields.as_ptr(), num_fields) - else: - _libtaos.taos_print_row(p, row, fields, num_fields) - if p: - return p.value.decode("utf-8") - raise OperationalError("taos_print_row failed") - - -_libtaos.taos_select_db.restype = c_int -_libtaos.taos_select_db.argstype = (c_void_p, c_char_p) - - -def taos_select_db(connection, db): - # type: (ctypes.c_void_p, str) -> None - """Select database, eq to sql: use """ - res = _libtaos.taos_select_db(connection, ctypes.c_char_p(db.encode("utf-8"))) - if res != 0: - raise DatabaseError("select database error", res) - - -try: - _libtaos.taos_open_stream.restype = c_void_p - _libtaos.taos_open_stream.argstype = c_void_p, c_char_p, stream_callback_type, c_int64, c_void_p, Any -except Exception as err: - _UNSUPPORTED["taos_open_stream"] = err - - -def taos_open_stream(connection, sql, callback, stime=0, param=None, callback2=None): - # type: (ctypes.c_void_p, str, stream_callback_type, c_int64, c_void_p, c_void_p) -> ctypes.pointer - _check_if_supported() - if callback2 != None: - callback2 = stream_callback2_type(callback2) - """Open an stream""" - return c_void_p( - _libtaos.taos_open_stream( - connection, ctypes.c_char_p(sql.encode("utf-8")), stream_callback_type(callback), stime, param, callback2 - ) - ) - - -_libtaos.taos_close_stream.restype = None -_libtaos.taos_close_stream.argstype = (c_void_p,) - - -def taos_close_stream(stream): - # type: (c_void_p) -> None - """Open an stream""" - return _libtaos.taos_close_stream(stream) - - -_libtaos.taos_stmt_init.restype = c_void_p -_libtaos.taos_stmt_init.argstype = (c_void_p,) - - -def taos_stmt_init(connection): - # type: (c_void_p) -> (c_void_p) - """Create a statement query - @param(connection): c_void_p TAOS* - @rtype: c_void_p, *TAOS_STMT - """ - return c_void_p(_libtaos.taos_stmt_init(connection)) - - -_libtaos.taos_stmt_prepare.restype = c_int -_libtaos.taos_stmt_prepare.argstype = (c_void_p, c_char_p, c_int) - - -def taos_stmt_prepare(stmt, sql): - # type: (ctypes.c_void_p, str) -> None - """Prepare a statement query - @stmt: c_void_p TAOS_STMT* - """ - buffer = sql.encode("utf-8") - res = _libtaos.taos_stmt_prepare(stmt, ctypes.c_char_p(buffer), len(buffer)) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -_libtaos.taos_stmt_close.restype = c_int -_libtaos.taos_stmt_close.argstype = (c_void_p,) - - -def taos_stmt_close(stmt): - # type: (ctypes.c_void_p) -> None - """Close a statement query - @stmt: c_void_p TAOS_STMT* - """ - res = _libtaos.taos_stmt_close(stmt) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -try: - _libtaos.taos_stmt_errstr.restype = c_char_p - _libtaos.taos_stmt_errstr.argstype = (c_void_p,) -except Exception as err: - _UNSUPPORTED["taos_stmt_set_tbname"] = err - - -def taos_stmt_errstr(stmt): - # type: (ctypes.c_void_p) -> str - """Get error message from stetement query - @stmt: c_void_p TAOS_STMT* - """ - _check_if_supported() - err = c_char_p(_libtaos.taos_stmt_errstr(stmt)) - if err: - return err.value.decode("utf-8") - - -try: - _libtaos.taos_stmt_set_tbname.restype = c_int - _libtaos.taos_stmt_set_tbname.argstype = (c_void_p, c_char_p) -except Exception as err: - _UNSUPPORTED["taos_stmt_set_tbname"] = err - - -def taos_stmt_set_tbname(stmt, name): - # type: (ctypes.c_void_p, str) -> None - """Set table name of a statement query if exists. - @stmt: c_void_p TAOS_STMT* - """ - _check_if_supported() - res = _libtaos.taos_stmt_set_tbname(stmt, c_char_p(name.encode("utf-8"))) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -try: - _libtaos.taos_stmt_set_tbname_tags.restype = c_int - _libtaos.taos_stmt_set_tbname_tags.argstype = (c_void_p, c_char_p, c_void_p) -except Exception as err: - _UNSUPPORTED["taos_stmt_set_tbname_tags"] = err - - -def taos_stmt_set_tbname_tags(stmt, name, tags): - # type: (c_void_p, str, c_void_p) -> None - """Set table name with tags bind params. - @stmt: c_void_p TAOS_STMT* - """ - _check_if_supported() - res = _libtaos.taos_stmt_set_tbname_tags(stmt, ctypes.c_char_p(name.encode("utf-8")), tags) - - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -_libtaos.taos_stmt_is_insert.restype = c_int -_libtaos.taos_stmt_is_insert.argstype = (c_void_p, POINTER(c_int)) - - -def taos_stmt_is_insert(stmt): - # type: (ctypes.c_void_p) -> bool - """Set table name with tags bind params. - @stmt: c_void_p TAOS_STMT* - """ - is_insert = ctypes.c_int() - res = _libtaos.taos_stmt_is_insert(stmt, ctypes.byref(is_insert)) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - return is_insert == 0 - - -_libtaos.taos_stmt_num_params.restype = c_int -_libtaos.taos_stmt_num_params.argstype = (c_void_p, POINTER(c_int)) - - -def taos_stmt_num_params(stmt): - # type: (ctypes.c_void_p) -> int - """Params number of the current statement query. - @stmt: TAOS_STMT* - """ - num_params = ctypes.c_int() - res = _libtaos.taos_stmt_num_params(stmt, ctypes.byref(num_params)) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - return num_params.value - - -_libtaos.taos_stmt_bind_param.restype = c_int -_libtaos.taos_stmt_bind_param.argstype = (c_void_p, c_void_p) - - -def taos_stmt_bind_param(stmt, bind): - # type: (ctypes.c_void_p, Array[TaosBind]) -> None - """Bind params in the statement query. - @stmt: TAOS_STMT* - @bind: TAOS_BIND* - """ - # ptr = ctypes.cast(bind, POINTER(TaosBind)) - # ptr = pointer(bind) - res = _libtaos.taos_stmt_bind_param(stmt, bind) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -try: - _libtaos.taos_stmt_bind_param_batch.restype = c_int - _libtaos.taos_stmt_bind_param_batch.argstype = (c_void_p, c_void_p) -except Exception as err: - _UNSUPPORTED["taos_stmt_bind_param_batch"] = err - - -def taos_stmt_bind_param_batch(stmt, bind): - # type: (ctypes.c_void_p, Array[TaosMultiBind]) -> None - """Bind params in the statement query. - @stmt: TAOS_STMT* - @bind: TAOS_BIND* - """ - # ptr = ctypes.cast(bind, POINTER(TaosMultiBind)) - # ptr = pointer(bind) - _check_if_supported() - res = _libtaos.taos_stmt_bind_param_batch(stmt, bind) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -try: - _libtaos.taos_stmt_bind_single_param_batch.restype = c_int - _libtaos.taos_stmt_bind_single_param_batch.argstype = (c_void_p, c_void_p, c_int) -except Exception as err: - _UNSUPPORTED["taos_stmt_bind_single_param_batch"] = err - - -def taos_stmt_bind_single_param_batch(stmt, bind, col): - # type: (ctypes.c_void_p, Array[TaosMultiBind], c_int) -> None - """Bind params in the statement query. - @stmt: TAOS_STMT* - @bind: TAOS_MULTI_BIND* - @col: column index - """ - _check_if_supported() - res = _libtaos.taos_stmt_bind_single_param_batch(stmt, bind, col) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -_libtaos.taos_stmt_add_batch.restype = c_int -_libtaos.taos_stmt_add_batch.argstype = (c_void_p,) - - -def taos_stmt_add_batch(stmt): - # type: (ctypes.c_void_p) -> None - """Add current params into batch - @stmt: TAOS_STMT* - """ - res = _libtaos.taos_stmt_add_batch(stmt) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -_libtaos.taos_stmt_execute.restype = c_int -_libtaos.taos_stmt_execute.argstype = (c_void_p,) - - -def taos_stmt_execute(stmt): - # type: (ctypes.c_void_p) -> None - """Execute a statement query - @stmt: TAOS_STMT* - """ - res = _libtaos.taos_stmt_execute(stmt) - if res != 0: - raise StatementError(msg=taos_stmt_errstr(stmt), errno=res) - - -_libtaos.taos_stmt_use_result.restype = c_void_p -_libtaos.taos_stmt_use_result.argstype = (c_void_p,) - - -def taos_stmt_use_result(stmt): - # type: (ctypes.c_void_p) -> None - """Get result of the statement. - @stmt: TAOS_STMT* - """ - result = c_void_p(_libtaos.taos_stmt_use_result(stmt)) - if result is None: - raise StatementError(taos_stmt_errstr(stmt)) - return result - - -try: - _libtaos.taos_schemaless_insert.restype = c_void_p - _libtaos.taos_schemaless_insert.argstype = c_void_p, c_void_p, c_int, c_int, c_int -except Exception as err: - _UNSUPPORTED["taos_schemaless_insert"] = err - - -def taos_schemaless_insert(connection, lines, protocol, precision): - # type: (c_void_p, list[str] | tuple(str), SmlProtocol, SmlPrecision) -> int - _check_if_supported() - num_of_lines = len(lines) - lines = (c_char_p(line.encode("utf-8")) for line in lines) - lines_type = ctypes.c_char_p * num_of_lines - p_lines = lines_type(*lines) - res = c_void_p(_libtaos.taos_schemaless_insert(connection, p_lines, num_of_lines, protocol, precision)) - errno = taos_errno(res) - affected_rows = taos_affected_rows(res) - if errno != 0: - errstr = taos_errstr(res) - taos_free_result(res) - raise SchemalessError(errstr, errno, affected_rows) - - taos_free_result(res) - return affected_rows - - -def _check_if_supported(): - func = inspect.stack()[1][3] - if func in _UNSUPPORTED: - raise InterfaceError("C function %s is not supported in v%s: %s" % (func, taos_get_client_info(), _UNSUPPORTED[func])) - - -def unsupported_methods(): - for m, e in range(_UNSUPPORTED): - print("unsupported %s: %s", m, e) - - -class CTaosInterface(object): - def __init__(self, config=None): - """ - Function to initialize the class - @host : str, hostname to connect - @user : str, username to connect to server - @password : str, password to connect to server - @db : str, default db to use when log in - @config : str, config directory - - @rtype : None - """ - if config is None: - self._config = ctypes.c_char_p(None) - else: - try: - self._config = ctypes.c_char_p(config.encode("utf-8")) - except AttributeError: - raise AttributeError("config is expected as a str") - - if config is not None: - taos_options(3, self._config) - - taos_init() - - @property - def config(self): - """Get current config""" - return self._config - - def connect(self, host=None, user="root", password="taosdata", db=None, port=0): - """ - Function to connect to server - - @rtype: c_void_p, TDengine handle - """ - return taos_connect(host, user, password, db, port) - - -if __name__ == "__main__": - cinter = CTaosInterface() - conn = cinter.connect() - result = cinter.query(conn, "show databases") - - print("Query Affected rows: {}".format(cinter.affected_rows(result))) - - fields = taos_fetch_fields_raw(result) - - data, num_of_rows = taos_fetch_block(result, fields) - - print(data) - - cinter.free_result(result) - cinter.close(conn) diff --git a/src/connector/python/taos/connection.py b/src/connector/python/taos/connection.py deleted file mode 100644 index dc8225ab33c84930214eb8f0d8ba47f6f31a5adf..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/connection.py +++ /dev/null @@ -1,204 +0,0 @@ -# encoding:UTF-8 -from types import FunctionType -from .cinterface import * -from .cursor import TaosCursor -from .subscription import TaosSubscription -from .statement import TaosStmt -from .stream import TaosStream -from .result import * - - -class TaosConnection(object): - """TDengine connection object""" - - def __init__(self, *args, **kwargs): - self._conn = None - self._host = None - self._user = "root" - self._password = "taosdata" - self._database = None - self._port = 0 - self._config = None - self._chandle = None - - self.config(**kwargs) - - def config(self, **kwargs): - # host - if "host" in kwargs: - self._host = kwargs["host"] - - # user - if "user" in kwargs: - self._user = kwargs["user"] - - # password - if "password" in kwargs: - self._password = kwargs["password"] - - # database - if "database" in kwargs: - self._database = kwargs["database"] - - # port - if "port" in kwargs: - self._port = kwargs["port"] - - # config - if "config" in kwargs: - self._config = kwargs["config"] - - self._chandle = CTaosInterface(self._config) - self._conn = self._chandle.connect(self._host, self._user, self._password, self._database, self._port) - - def close(self): - """Close current connection.""" - if self._conn: - taos_close(self._conn) - self._conn = None - - @property - def client_info(self): - # type: () -> str - return taos_get_client_info() - - @property - def server_info(self): - # type: () -> str - return taos_get_server_info(self._conn) - - def select_db(self, database): - # type: (str) -> None - taos_select_db(self._conn, database) - - def execute(self, sql): - # type: (str) -> int - """Simplely execute sql ignoring the results""" - return self.query(sql).affected_rows - - def query(self, sql): - # type: (str) -> TaosResult - result = taos_query(self._conn, sql) - return TaosResult(result, True, self) - - def query_a(self, sql, callback, param): - # type: (str, async_query_callback_type, c_void_p) -> None - """Asynchronously query a sql with callback function""" - taos_query_a(self._conn, sql, callback, param) - - def subscribe(self, restart, topic, sql, interval, callback=None, param=None): - # type: (bool, str, str, int, subscribe_callback_type, c_void_p) -> TaosSubscription - """Create a subscription.""" - if self._conn is None: - return None - sub = taos_subscribe(self._conn, restart, topic, sql, interval, callback, param) - return TaosSubscription(sub, callback != None) - - def statement(self, sql=None): - # type: (str | None) -> TaosStmt - if self._conn is None: - return None - stmt = taos_stmt_init(self._conn) - if sql != None: - taos_stmt_prepare(stmt, sql) - - return TaosStmt(stmt) - - def load_table_info(self, tables): - # type: (str) -> None - taos_load_table_info(self._conn, tables) - - def stream(self, sql, callback, stime=0, param=None, callback2=None): - # type: (str, Callable[[Any, TaosResult, TaosRows], None], int, Any, c_void_p) -> TaosStream - # cb = cast(callback, stream_callback_type) - # ref = byref(cb) - - stream = taos_open_stream(self._conn, sql, callback, stime, param, callback2) - return TaosStream(stream) - - def schemaless_insert(self, lines, protocol, precision): - # type: (list[str], SmlProtocol, SmlPrecision) -> int - """ - 1.Line protocol and schemaless support - - ## Example - - ```python - import taos - conn = taos.connect() - conn.exec("drop database if exists test") - conn.select_db("test") - lines = [ - 'ste,t2=5,t3=L"ste" c1=true,c2=4,c3="string" 1626056811855516532', - ] - conn.schemaless_insert(lines, 0, "ns") - ``` - - 2.OpenTSDB telnet style API format support - - ## Example - import taos - conn = taos.connect() - conn.exec("drop database if exists test") - conn.select_db("test") - lines = [ - 'cpu_load 1626056811855516532ns 2.0f32 id="tb1",host="host0",interface="eth0"', - ] - conn.schemaless_insert(lines, 1, None) - - - 3.OpenTSDB HTTP JSON format support - - ## Example - import taos - conn = taos.connect() - conn.exec("drop database if exists test") - conn.select_db("test") - payload = [''' - { - "metric": "cpu_load_0", - "timestamp": 1626006833610123, - "value": 55.5, - "tags": - { - "host": "ubuntu", - "interface": "eth0", - "Id": "tb0" - } - } - '''] - conn.schemaless_insert(lines, 2, None) - - """ - print(lines, protocol, precision) - return taos_schemaless_insert(self._conn, lines, protocol, precision) - - - def cursor(self): - # type: () -> TaosCursor - """Return a new Cursor object using the connection.""" - return TaosCursor(self) - - def commit(self): - """Commit any pending transaction to the database. - - Since TDengine do not support transactions, the implement is void functionality. - """ - pass - - def rollback(self): - """Void functionality""" - pass - - def clear_result_set(self): - """Clear unused result set on this connection.""" - pass - - def __del__(self): - self.close() - - -if __name__ == "__main__": - conn = TaosConnection() - conn.close() - print("Hello world") diff --git a/src/connector/python/taos/constants.py b/src/connector/python/taos/constants.py deleted file mode 100644 index 34044a15fc0cd73323552f1b4b8c280d6cad5a9b..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/constants.py +++ /dev/null @@ -1,47 +0,0 @@ -# encoding:UTF-8 - -"""Constants in TDengine python -""" - -import ctypes, struct - - -class FieldType(object): - """TDengine Field Types""" - - # type_code - C_NULL = 0 - C_BOOL = 1 - C_TINYINT = 2 - C_SMALLINT = 3 - C_INT = 4 - C_BIGINT = 5 - C_FLOAT = 6 - C_DOUBLE = 7 - C_BINARY = 8 - C_TIMESTAMP = 9 - C_NCHAR = 10 - C_TINYINT_UNSIGNED = 11 - C_SMALLINT_UNSIGNED = 12 - C_INT_UNSIGNED = 13 - C_BIGINT_UNSIGNED = 14 - C_JSON = 15 - # NULL value definition - # NOTE: These values should change according to C definition in tsdb.h - C_BOOL_NULL = 0x02 - C_TINYINT_NULL = -128 - C_TINYINT_UNSIGNED_NULL = 255 - C_SMALLINT_NULL = -32768 - C_SMALLINT_UNSIGNED_NULL = 65535 - C_INT_NULL = -2147483648 - C_INT_UNSIGNED_NULL = 4294967295 - C_BIGINT_NULL = -9223372036854775808 - C_BIGINT_UNSIGNED_NULL = 18446744073709551615 - C_FLOAT_NULL = ctypes.c_float(struct.unpack(" name (mandatory) - > type_code (mandatory) - > display_size - > internal_size - > precision - > scale - > null_ok - - This attribute will be None for operations that do not return rows or - if the cursor has not had an operation invoked via the .execute*() method yet. - - .rowcount:This read-only attribute specifies the number of rows that the last - .execute*() produced (for DQL statements like SELECT) or affected - """ - - def __init__(self, connection=None): - self._description = [] - self._rowcount = -1 - self._connection = None - self._result = None - self._fields = None - self._block = None - self._block_rows = -1 - self._block_iter = 0 - self._affected_rows = 0 - self._logfile = "" - - if connection is not None: - self._connection = connection - - def __iter__(self): - return self - - def __next__(self): - return self._taos_next() - - def next(self): - return self._taos_next() - - def _taos_next(self): - if self._result is None or self._fields is None: - raise OperationalError("Invalid use of fetch iterator") - - if self._block_rows <= self._block_iter: - block, self._block_rows = taos_fetch_row(self._result, self._fields) - if self._block_rows == 0: - raise StopIteration - self._block = list(map(tuple, zip(*block))) - self._block_iter = 0 - - data = self._block[self._block_iter] - self._block_iter += 1 - - return data - - @property - def description(self): - """Return the description of the object.""" - return self._description - - @property - def rowcount(self): - """Return the rowcount of the object""" - return self._rowcount - - @property - def affected_rows(self): - """Return the rowcount of insertion""" - return self._affected_rows - - def callproc(self, procname, *args): - """Call a stored database procedure with the given name. - - Void functionality since no stored procedures. - """ - pass - - def log(self, logfile): - self._logfile = logfile - - def close(self): - """Close the cursor.""" - if self._connection is None: - return False - - self._reset_result() - self._connection = None - - return True - - def execute(self, operation, params=None): - """Prepare and execute a database operation (query or command).""" - if not operation: - return None - - if not self._connection: - # TODO : change the exception raised here - raise ProgrammingError("Cursor is not connected") - - self._reset_result() - - stmt = operation - if params is not None: - pass - - # global querySeqNum - # querySeqNum += 1 - # localSeqNum = querySeqNum # avoid race condition - # print(" >> Exec Query ({}): {}".format(localSeqNum, str(stmt))) - self._result = taos_query(self._connection._conn, stmt) - # print(" << Query ({}) Exec Done".format(localSeqNum)) - if self._logfile: - with open(self._logfile, "a") as logfile: - logfile.write("%s;\n" % operation) - - if taos_field_count(self._result) == 0: - affected_rows = taos_affected_rows(self._result) - self._affected_rows += affected_rows - return affected_rows - else: - self._fields = taos_fetch_fields(self._result) - return self._handle_result() - - def executemany(self, operation, seq_of_parameters): - """Prepare a database operation (query or command) and then execute it against all parameter sequences or mappings found in the sequence seq_of_parameters.""" - pass - - def fetchone(self): - """Fetch the next row of a query result set, returning a single sequence, or None when no more data is available.""" - pass - - def fetchmany(self): - pass - - def istype(self, col, dataType): - if dataType.upper() == "BOOL": - if self._description[col][1] == FieldType.C_BOOL: - return True - if dataType.upper() == "TINYINT": - if self._description[col][1] == FieldType.C_TINYINT: - return True - if dataType.upper() == "TINYINT UNSIGNED": - if self._description[col][1] == FieldType.C_TINYINT_UNSIGNED: - return True - if dataType.upper() == "SMALLINT": - if self._description[col][1] == FieldType.C_SMALLINT: - return True - if dataType.upper() == "SMALLINT UNSIGNED": - if self._description[col][1] == FieldType.C_SMALLINT_UNSIGNED: - return True - if dataType.upper() == "INT": - if self._description[col][1] == FieldType.C_INT: - return True - if dataType.upper() == "INT UNSIGNED": - if self._description[col][1] == FieldType.C_INT_UNSIGNED: - return True - if dataType.upper() == "BIGINT": - if self._description[col][1] == FieldType.C_BIGINT: - return True - if dataType.upper() == "BIGINT UNSIGNED": - if self._description[col][1] == FieldType.C_BIGINT_UNSIGNED: - return True - if dataType.upper() == "FLOAT": - if self._description[col][1] == FieldType.C_FLOAT: - return True - if dataType.upper() == "DOUBLE": - if self._description[col][1] == FieldType.C_DOUBLE: - return True - if dataType.upper() == "BINARY": - if self._description[col][1] == FieldType.C_BINARY: - return True - if dataType.upper() == "TIMESTAMP": - if self._description[col][1] == FieldType.C_TIMESTAMP: - return True - if dataType.upper() == "NCHAR": - if self._description[col][1] == FieldType.C_NCHAR: - return True - if dataType.upper() == "JSON": - if self._description[col][1] == FieldType.C_JSON: - return True - - return False - - def fetchall_row(self): - """Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation.""" - if self._result is None or self._fields is None: - raise OperationalError("Invalid use of fetchall") - - buffer = [[] for i in range(len(self._fields))] - self._rowcount = 0 - while True: - block, num_of_fields = taos_fetch_row(self._result, self._fields) - errno = taos_errno(self._result) - if errno != 0: - raise ProgrammingError(taos_errstr(self._result), errno) - if num_of_fields == 0: - break - self._rowcount += num_of_fields - for i in range(len(self._fields)): - buffer[i].extend(block[i]) - return list(map(tuple, zip(*buffer))) - - def fetchall(self): - if self._result is None: - raise OperationalError("Invalid use of fetchall") - fields = self._fields if self._fields is not None else taos_fetch_fields(self._result) - buffer = [[] for i in range(len(fields))] - self._rowcount = 0 - while True: - block, num_of_fields = taos_fetch_block(self._result, self._fields) - errno = taos_errno(self._result) - if errno != 0: - raise ProgrammingError(taos_errstr(self._result), errno) - if num_of_fields == 0: - break - self._rowcount += num_of_fields - for i in range(len(self._fields)): - buffer[i].extend(block[i]) - return list(map(tuple, zip(*buffer))) - - def stop_query(self): - if self._result != None: - taos_stop_query(self._result) - - def nextset(self): - """ """ - pass - - def setinputsize(self, sizes): - pass - - def setutputsize(self, size, column=None): - pass - - def _reset_result(self): - """Reset the result to unused version.""" - self._description = [] - self._rowcount = -1 - if self._result is not None: - taos_free_result(self._result) - self._result = None - self._fields = None - self._block = None - self._block_rows = -1 - self._block_iter = 0 - self._affected_rows = 0 - - def _handle_result(self): - """Handle the return result from query.""" - self._description = [] - for ele in self._fields: - self._description.append((ele["name"], ele["type"], None, None, None, None, False)) - - return self._result - - def __del__(self): - self.close() diff --git a/src/connector/python/taos/error.py b/src/connector/python/taos/error.py deleted file mode 100644 index 122466fe3c448ec551fb910c402ad14bb6c93336..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/error.py +++ /dev/null @@ -1,111 +0,0 @@ -# encoding:UTF-8 -"""Python exceptions -""" - - -class Error(Exception): - def __init__(self, msg=None, errno=0xffff): - self.msg = msg - self.errno = errno - self._full_msg = "[0x%04x]: %s" % (self.errno & 0xffff, self.msg) - - def __str__(self): - return self._full_msg - - -class Warning(Exception): - """Exception raised for important warnings like data truncations while inserting.""" - - pass - - -class InterfaceError(Error): - """Exception raised for errors that are related to the database interface rather than the database itself.""" - - pass - - -class DatabaseError(Error): - """Exception raised for errors that are related to the database.""" - - pass - -class ConnectionError(Error): - """Exceptin raised for connection failed""" - pass - -class DataError(DatabaseError): - """Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range.""" - - pass - - -class OperationalError(DatabaseError): - """Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer""" - - pass - - -class IntegrityError(DatabaseError): - """Exception raised when the relational integrity of the database is affected.""" - - pass - - -class InternalError(DatabaseError): - """Exception raised when the database encounters an internal error.""" - - pass - - -class ProgrammingError(DatabaseError): - """Exception raised for programming errors.""" - - pass - - -class NotSupportedError(DatabaseError): - """Exception raised in case a method or database API was used which is not supported by the database,.""" - - pass - - -class StatementError(DatabaseError): - """Exception raised in STMT API.""" - - pass - -class ResultError(DatabaseError): - """Result related APIs.""" - - pass - -class SchemalessError(DatabaseError): - """taos_schemaless_insert errors.""" - - def __init__(self, msg=None, errno=0xffff, affected_rows=0): - DatabaseError.__init__(self, msg, errno) - self.affected_rows = affected_rows - - def __str__(self): - return self._full_msg + "(affected rows: %d)" % self.affected_rows - - # @property - # def affected_rows(self): - # return self.affected_rows - - -class StatementError(DatabaseError): - """Exception raised in STMT API.""" - - pass - -class ResultError(DatabaseError): - """Result related APIs.""" - - pass - -class LinesError(DatabaseError): - """taos_insert_lines errors.""" - - pass \ No newline at end of file diff --git a/src/connector/python/taos/field.py b/src/connector/python/taos/field.py deleted file mode 100644 index a6d64422e238b46b096a5ae62c42566666f226ad..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/field.py +++ /dev/null @@ -1,309 +0,0 @@ -# encoding:UTF-8 -import ctypes -import math -import datetime -from ctypes import * - -from .constants import FieldType -from .error import * - -_datetime_epoch = datetime.datetime.fromtimestamp(0) - -def _convert_millisecond_to_datetime(milli): - return _datetime_epoch + datetime.timedelta(seconds=milli / 1000.0) - - -def _convert_microsecond_to_datetime(micro): - return _datetime_epoch + datetime.timedelta(seconds=micro / 1000000.0) - - -def _convert_nanosecond_to_datetime(nanosec): - return nanosec - - -def _crow_timestamp_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C bool row to python row""" - _timestamp_converter = _convert_millisecond_to_datetime - if precision == FieldType.C_TIMESTAMP_MILLI: - _timestamp_converter = _convert_millisecond_to_datetime - elif precision == FieldType.C_TIMESTAMP_MICRO: - _timestamp_converter = _convert_microsecond_to_datetime - elif precision == FieldType.C_TIMESTAMP_NANO: - _timestamp_converter = _convert_nanosecond_to_datetime - else: - raise DatabaseError("Unknown precision returned from database") - - return [ - None if ele == FieldType.C_BIGINT_NULL else _timestamp_converter(ele) - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_int64))[: abs(num_of_rows)] - ] - - -def _crow_bool_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C bool row to python row""" - return [ - None if ele == FieldType.C_BOOL_NULL else bool(ele) - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_byte))[: abs(num_of_rows)] - ] - - -def _crow_tinyint_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C tinyint row to python row""" - return [ - None if ele == FieldType.C_TINYINT_NULL else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_byte))[: abs(num_of_rows)] - ] - - -def _crow_tinyint_unsigned_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C tinyint row to python row""" - return [ - None if ele == FieldType.C_TINYINT_UNSIGNED_NULL else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_ubyte))[: abs(num_of_rows)] - ] - - -def _crow_smallint_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C smallint row to python row""" - return [ - None if ele == FieldType.C_SMALLINT_NULL else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_short))[: abs(num_of_rows)] - ] - - -def _crow_smallint_unsigned_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C smallint row to python row""" - return [ - None if ele == FieldType.C_SMALLINT_UNSIGNED_NULL else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_ushort))[: abs(num_of_rows)] - ] - - -def _crow_int_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C int row to python row""" - return [ - None if ele == FieldType.C_INT_NULL else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_int))[: abs(num_of_rows)] - ] - - -def _crow_int_unsigned_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C int row to python row""" - return [ - None if ele == FieldType.C_INT_UNSIGNED_NULL else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_uint))[: abs(num_of_rows)] - ] - - -def _crow_bigint_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C bigint row to python row""" - return [ - None if ele == FieldType.C_BIGINT_NULL else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_int64))[: abs(num_of_rows)] - ] - - -def _crow_bigint_unsigned_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C bigint row to python row""" - return [ - None if ele == FieldType.C_BIGINT_UNSIGNED_NULL else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_uint64))[: abs(num_of_rows)] - ] - - -def _crow_float_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C float row to python row""" - return [ - None if math.isnan(ele) else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_float))[: abs(num_of_rows)] - ] - - -def _crow_double_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C double row to python row""" - return [ - None if math.isnan(ele) else ele - for ele in ctypes.cast(data, ctypes.POINTER(ctypes.c_double))[: abs(num_of_rows)] - ] - - -def _crow_binary_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C binary row to python row""" - assert nbytes is not None - return [ - None if ele.value[0:1] == FieldType.C_BINARY_NULL else ele.value.decode("utf-8") - for ele in (ctypes.cast(data, ctypes.POINTER(ctypes.c_char * nbytes)))[: abs(num_of_rows)] - ] - - -def _crow_nchar_to_python(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C nchar row to python row""" - assert nbytes is not None - res = [] - for i in range(abs(num_of_rows)): - try: - if num_of_rows >= 0: - tmpstr = ctypes.c_char_p(data) - res.append(tmpstr.value.decode("utf-8")) - else: - res.append( - ( - ctypes.cast( - data + nbytes * i, - ctypes.POINTER(ctypes.c_wchar * (nbytes // 4)), - ) - )[0].value - ) - except ValueError: - res.append(None) - - return res - - -def _crow_binary_to_python_block(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C binary row to python row""" - assert nbytes is not None - res = [] - for i in range(abs(num_of_rows)): - rbyte = ctypes.cast(data + nbytes * i, ctypes.POINTER(ctypes.c_short))[:1].pop() - chars = ctypes.cast(c_char_p(data + nbytes * i + 2), ctypes.POINTER(c_char * rbyte)) - buffer = create_string_buffer(rbyte + 1) - buffer[:rbyte] = chars[0][:rbyte] - if rbyte == 1 and buffer[0] == b'\xff': - res.append(None) - else: - res.append(cast(buffer, c_char_p).value.decode("utf-8")) - return res - - -def _crow_nchar_to_python_block(data, num_of_rows, nbytes=None, precision=FieldType.C_TIMESTAMP_UNKNOWN): - """Function to convert C nchar row to python row""" - assert nbytes is not None - res = [] - for i in range(abs(num_of_rows)): - rbyte = ctypes.cast(data + nbytes * i, ctypes.POINTER(ctypes.c_short))[:1].pop() - chars = ctypes.cast(c_char_p(data + nbytes * i + 2), ctypes.POINTER(c_char * rbyte)) - buffer = create_string_buffer(rbyte + 1) - buffer[:rbyte] = chars[0][:rbyte] - if rbyte == 4 and buffer[:4] == b'\xff'*4: - res.append(None) - else: - res.append(cast(buffer, c_char_p).value.decode("utf-8")) - return res - - -CONVERT_FUNC = { - FieldType.C_BOOL: _crow_bool_to_python, - FieldType.C_TINYINT: _crow_tinyint_to_python, - FieldType.C_SMALLINT: _crow_smallint_to_python, - FieldType.C_INT: _crow_int_to_python, - FieldType.C_BIGINT: _crow_bigint_to_python, - FieldType.C_FLOAT: _crow_float_to_python, - FieldType.C_DOUBLE: _crow_double_to_python, - FieldType.C_BINARY: _crow_binary_to_python, - FieldType.C_TIMESTAMP: _crow_timestamp_to_python, - FieldType.C_NCHAR: _crow_nchar_to_python, - FieldType.C_TINYINT_UNSIGNED: _crow_tinyint_unsigned_to_python, - FieldType.C_SMALLINT_UNSIGNED: _crow_smallint_unsigned_to_python, - FieldType.C_INT_UNSIGNED: _crow_int_unsigned_to_python, - FieldType.C_BIGINT_UNSIGNED: _crow_bigint_unsigned_to_python, - FieldType.C_JSON: _crow_nchar_to_python, -} - -CONVERT_FUNC_BLOCK = { - FieldType.C_BOOL: _crow_bool_to_python, - FieldType.C_TINYINT: _crow_tinyint_to_python, - FieldType.C_SMALLINT: _crow_smallint_to_python, - FieldType.C_INT: _crow_int_to_python, - FieldType.C_BIGINT: _crow_bigint_to_python, - FieldType.C_FLOAT: _crow_float_to_python, - FieldType.C_DOUBLE: _crow_double_to_python, - FieldType.C_BINARY: _crow_binary_to_python_block, - FieldType.C_TIMESTAMP: _crow_timestamp_to_python, - FieldType.C_NCHAR: _crow_nchar_to_python_block, - FieldType.C_TINYINT_UNSIGNED: _crow_tinyint_unsigned_to_python, - FieldType.C_SMALLINT_UNSIGNED: _crow_smallint_unsigned_to_python, - FieldType.C_INT_UNSIGNED: _crow_int_unsigned_to_python, - FieldType.C_BIGINT_UNSIGNED: _crow_bigint_unsigned_to_python, - FieldType.C_JSON: _crow_nchar_to_python_block, -} - -# Corresponding TAOS_FIELD structure in C - - -class TaosField(ctypes.Structure): - _fields_ = [ - ("_name", ctypes.c_char * 65), - ("_type", ctypes.c_uint8), - ("_bytes", ctypes.c_uint16), - ] - - @property - def name(self): - return self._name.decode("utf-8") - - @property - def length(self): - """alias to self.bytes""" - return self._bytes - - @property - def bytes(self): - return self._bytes - - @property - def type(self): - return self._type - - def __dict__(self): - return {"name": self.name, "type": self.type, "bytes": self.length} - - def __str__(self): - return "{name: %s, type: %d, bytes: %d}" % (self.name, self.type, self.length) - - def __getitem__(self, item): - return getattr(self, item) - - -class TaosFields(object): - def __init__(self, fields, count): - if isinstance(fields, c_void_p): - self._fields = cast(fields, POINTER(TaosField)) - if isinstance(fields, POINTER(TaosField)): - self._fields = fields - self._count = count - self._iter = 0 - - def as_ptr(self): - return self._fields - - @property - def count(self): - return self._count - - @property - def fields(self): - return self._fields - - def __next__(self): - return self._next_field() - - def next(self): - return self._next_field() - - def _next_field(self): - if self._iter < self.count: - field = self._fields[self._iter] - self._iter += 1 - return field - else: - raise StopIteration - - def __getitem__(self, item): - return self._fields[item] - - def __iter__(self): - return self - - def __len__(self): - return self.count diff --git a/src/connector/python/taos/precision.py b/src/connector/python/taos/precision.py deleted file mode 100644 index d67da592cce6d2121ec8f2eed78a30d6fa0c446b..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/precision.py +++ /dev/null @@ -1,12 +0,0 @@ -class PrecisionEnum(object): - """Precision enums""" - - Milliseconds = 0 - Microseconds = 1 - Nanoseconds = 2 - - -class PrecisionError(Exception): - """Python datetime does not support nanoseconds error""" - - pass diff --git a/src/connector/python/taos/result.py b/src/connector/python/taos/result.py deleted file mode 100644 index 05085a493eb8ffede536476f1ddf3bcb083d82f8..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/result.py +++ /dev/null @@ -1,263 +0,0 @@ -from .cinterface import * - -# from .connection import TaosConnection -from .error import * - -from ctypes import c_void_p - - -class TaosResult(object): - """TDengine result interface""" - - def __init__(self, result, close_after=False, conn=None): - # type: (c_void_p, bool, TaosConnection) -> TaosResult - # to make the __del__ order right - self._conn = conn - self._close_after = close_after - if isinstance(result, c_void_p): - self._result = result - else: - self._result = c_void_p(result) - - self._fields = None - self._field_count = None - self._precision = None - - self._block = None - self._block_length = None - self._row_count = 0 - - def __iter__(self): - return self - - def __next__(self): - return self._next_row() - - def next(self): - # fetch next row - return self._next_row() - - def _next_row(self): - if self._result is None or self.fields is None: - raise OperationalError("Invalid use of fetch iterator") - - if self._block is None or self._block_iter >= self._block_length: - self._block, self._block_length = self.fetch_block() - self._block_iter = 0 - # self._row_count += self._block_length - - raw = self._block[self._block_iter] - self._block_iter += 1 - return raw - - @property - def fields(self): - """fields definitions of the current result""" - if self._result is None: - raise ResultError("no result object setted") - if self._fields is None: - self._fields = taos_fetch_fields(self._result) - - return self._fields - - @property - def field_count(self): - """Field count of the current result, eq to taos_field_count(result)""" - return self.fields.count - - @property - def row_count(self): - """Return the rowcount of the object""" - return self._row_count - - @property - def precision(self): - if self._precision is None: - self._precision = taos_result_precision(self._result) - return self._precision - - @property - def affected_rows(self): - return taos_affected_rows(self._result) - - # @property - def field_lengths(self): - return taos_fetch_lengths(self._result, self.field_count) - - def rows_iter(self, num_of_rows=None): - return TaosRows(self, num_of_rows) - - def blocks_iter(self): - return TaosBlocks(self) - - def fetch_block(self): - if self._result is None: - raise OperationalError("Invalid use of fetch iterator") - - block, length = taos_fetch_block_raw(self._result) - if length == 0: - raise StopIteration - precision = self.precision - field_count = self.field_count - fields = self.fields - blocks = [None] * field_count - lengths = self.field_lengths() - for i in range(field_count): - data = ctypes.cast(block, ctypes.POINTER(ctypes.c_void_p))[i] - if fields[i].type not in CONVERT_FUNC_BLOCK: - raise DatabaseError("Invalid data type returned from database") - blocks[i] = CONVERT_FUNC_BLOCK[fields[i].type](data, length, lengths[i], precision) - - return list(map(tuple, zip(*blocks))), length - - def fetch_all(self): - if self._result is None: - raise OperationalError("Invalid use of fetchall") - - if self._fields is None: - self._fields = taos_fetch_fields(self._result) - buffer = [[] for i in range(len(self._fields))] - self._row_count = 0 - while True: - block, num_of_fields = taos_fetch_block(self._result, self._fields) - errno = taos_errno(self._result) - if errno != 0: - raise ProgrammingError(taos_errstr(self._result), errno) - if num_of_fields == 0: - break - self._row_count += num_of_fields - for i in range(len(self._fields)): - buffer[i].extend(block[i]) - return list(map(tuple, zip(*buffer))) - - def fetch_all_into_dict(self): - """Fetch all rows and convert it to dict""" - names = [field.name for field in self.fields] - rows = self.fetch_all() - return list(dict(zip(names, row)) for row in rows) - - def fetch_rows_a(self, callback, param): - taos_fetch_rows_a(self._result, callback, param) - - def stop_query(self): - return taos_stop_query(self._result) - - def errno(self): - """**DO NOT** use this directly unless you know what you are doing""" - return taos_errno(self._result) - - def errstr(self): - return taos_errstr(self._result) - - def check_error(self, errno=None, close=True): - if errno is None: - errno = self.errno() - if errno != 0: - msg = self.errstr() - self.close() - raise OperationalError(msg, errno) - - def close(self): - """free result object.""" - if self._result != None and self._close_after: - taos_free_result(self._result) - self._result = None - self._fields = None - self._field_count = None - self._field_lengths = None - - def __del__(self): - self.close() - - -class TaosRows: - """TDengine result rows iterator""" - - def __init__(self, result, num_of_rows=None): - self._result = result - self._num_of_rows = num_of_rows - - def __iter__(self): - return self - - def __next__(self): - return self._next_row() - - def next(self): - return self._next_row() - - def _next_row(self): - if self._result is None: - raise OperationalError("Invalid use of fetch iterator") - if self._num_of_rows != None and self._num_of_rows <= self._result._row_count: - raise StopIteration - - row = taos_fetch_row_raw(self._result._result) - if not row: - raise StopIteration - self._result._row_count += 1 - return TaosRow(self._result, row) - - @property - def row_count(self): - """Return the rowcount of the object""" - return self._result._row_count - - -class TaosRow: - def __init__(self, result, row): - self._result = result - self._row = row - - def __str__(self): - return taos_print_row(self._row, self._result.fields, self._result.field_count) - - def __call__(self): - return self.as_tuple() - - def _astuple(self): - return self.as_tuple() - - def __iter__(self): - return self.as_tuple() - - def as_ptr(self): - return self._row - - def as_tuple(self): - precision = self._result.precision - field_count = self._result.field_count - blocks = [None] * field_count - fields = self._result.fields - field_lens = self._result.field_lengths() - for i in range(field_count): - data = ctypes.cast(self._row, ctypes.POINTER(ctypes.c_void_p))[i] - if fields[i].type not in CONVERT_FUNC: - raise DatabaseError("Invalid data type returned from database") - if data is None: - blocks[i] = None - else: - blocks[i] = CONVERT_FUNC[fields[i].type](data, 1, field_lens[i], precision)[0] - return tuple(blocks) - - def as_dict(self): - values = self.as_tuple() - names = self._result.fields - dict(zip(names, values)) - - - -class TaosBlocks: - """TDengine result blocks iterator""" - - def __init__(self, result): - self._result = result - - def __iter__(self): - return self - - def __next__(self): - return self._result.fetch_block() - - def next(self): - return self._result.fetch_block() diff --git a/src/connector/python/taos/schemaless.py b/src/connector/python/taos/schemaless.py deleted file mode 100644 index 35967412f78a63e67d63f0e58bbf903f21fb275a..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/schemaless.py +++ /dev/null @@ -1,17 +0,0 @@ - -class SmlPrecision: - """Schemaless timestamp precision constants""" - NOT_CONFIGURED = 0 # C.TSDB_SML_TIMESTAMP_NOT_CONFIGURED - HOURS = 1 - MINUTES = 2 - SECONDS = 3 - MILLI_SECONDS = 4 - MICRO_SECONDS = 5 - NANO_SECONDS = 6 - -class SmlProtocol: - """Schemaless protocol constants""" - UNKNOWN_PROTOCOL = 0 - LINE_PROTOCOL = 1 - TELNET_PROTOCOL = 2 - JSON_PROTOCOL = 3 \ No newline at end of file diff --git a/src/connector/python/taos/statement.py b/src/connector/python/taos/statement.py deleted file mode 100644 index 155e98173b7f920640aa84d0fcda618d2669bb1e..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/statement.py +++ /dev/null @@ -1,85 +0,0 @@ -from taos.cinterface import * -from taos.error import * -from taos.result import * - - -class TaosStmt(object): - """TDengine STMT interface""" - - def __init__(self, stmt, conn = None): - self._conn = conn - self._stmt = stmt - - def set_tbname(self, name): - """Set table name if needed. - - Note that the set_tbname* method should only used in insert statement - """ - if self._stmt is None: - raise StatementError("Invalid use of set_tbname") - taos_stmt_set_tbname(self._stmt, name) - - def prepare(self, sql): - # type: (str) -> None - taos_stmt_prepare(self._stmt, sql) - - def set_tbname_tags(self, name, tags): - # type: (str, Array[TaosBind]) -> None - """Set table name with tags, tags is array of BindParams""" - if self._stmt is None: - raise StatementError("Invalid use of set_tbname") - taos_stmt_set_tbname_tags(self._stmt, name, tags) - - def bind_param(self, params, add_batch=True): - # type: (Array[TaosBind], bool) -> None - if self._stmt is None: - raise StatementError("Invalid use of stmt") - taos_stmt_bind_param(self._stmt, params) - if add_batch: - taos_stmt_add_batch(self._stmt) - - def bind_param_batch(self, binds, add_batch=True): - # type: (Array[TaosMultiBind], bool) -> None - if self._stmt is None: - raise StatementError("Invalid use of stmt") - taos_stmt_bind_param_batch(self._stmt, binds) - if add_batch: - taos_stmt_add_batch(self._stmt) - - def add_batch(self): - if self._stmt is None: - raise StatementError("Invalid use of stmt") - taos_stmt_add_batch(self._stmt) - - def execute(self): - if self._stmt is None: - raise StatementError("Invalid use of execute") - taos_stmt_execute(self._stmt) - - def use_result(self): - result = taos_stmt_use_result(self._stmt) - return TaosResult(result) - - def close(self): - """Close stmt.""" - if self._stmt is None: - return - taos_stmt_close(self._stmt) - self._stmt = None - - def __del__(self): - self.close() - - -if __name__ == "__main__": - from taos.connection import TaosConnection - - conn = TaosConnection() - - stmt = conn.statement("select * from log.log limit 10") - stmt.execute() - result = stmt.use_result() - for row in result: - print(row) - stmt.close() - conn.close() diff --git a/src/connector/python/taos/stream.py b/src/connector/python/taos/stream.py deleted file mode 100644 index fe3c8c85e3279511972293882224bf20c30dfa64..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/stream.py +++ /dev/null @@ -1,22 +0,0 @@ -from taos.cinterface import * -from taos.error import * -from taos.result import * - - -class TaosStream(object): - """TDengine Stream interface""" - - def __init__(self, stream): - self._raw = stream - - def as_ptr(self): - return self._raw - - def close(self): - """Close stmt.""" - if self._raw is not None: - taos_close_stream(self._raw) - self._raw = None - - def __del__(self): - self.close() diff --git a/src/connector/python/taos/subscription.py b/src/connector/python/taos/subscription.py deleted file mode 100644 index 3c6958b6f8d55791b9753a84a4bbd7653bdae780..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/subscription.py +++ /dev/null @@ -1,49 +0,0 @@ -from taos.result import TaosResult -from .cinterface import * -from .error import * - - -class TaosSubscription(object): - """TDengine subscription object""" - - def __init__(self, sub, with_callback = False): - self._sub = sub - self._with_callback = with_callback - - def consume(self): - """Consume rows of a subscription""" - if self._sub is None: - raise OperationalError("Invalid use of consume") - if self._with_callback: - raise OperationalError("DONOT use consume method in an subscription with callback") - result = taos_consume(self._sub) - return TaosResult(result) - - def close(self, keepProgress=True): - """Close the Subscription.""" - if self._sub is None: - return False - - taos_unsubscribe(self._sub, keepProgress) - self._sub = None - return True - - def __del__(self): - self.close() - - -if __name__ == "__main__": - from .connection import TaosConnection - - conn = TaosConnection(host="127.0.0.1", user="root", password="taosdata", database="test") - - # Generate a cursor object to run SQL commands - sub = conn.subscribe(True, "test", "select * from meters;", 1000) - - for i in range(0, 10): - data = sub.consume() - for d in data: - print(d) - - sub.close() - conn.close() diff --git a/src/connector/python/taos/timestamp.py b/src/connector/python/taos/timestamp.py deleted file mode 100644 index ab5679fdf12e2942aa94f76716ff98e6d2a88d69..0000000000000000000000000000000000000000 --- a/src/connector/python/taos/timestamp.py +++ /dev/null @@ -1,17 +0,0 @@ - -class TimestampType(object): - """Choose which type that parsing TDengine timestamp data to - - - DATETIME: use python datetime.datetime, note that it does not support nanosecond precision, - and python taos will use raw c_int64 as a fallback for nanosecond results. - - NUMPY: use numpy.datetime64 type. - - RAW: use raw c_int64. - - TAOS: use taos' TaosTimestamp. - """ - DATETIME = 0, - NUMPY = 1, - RAW = 2, - TAOS = 3, - -class TaosTimestamp: - pass diff --git a/src/connector/python/tests/test-td6231.py b/src/connector/python/tests/test-td6231.py deleted file mode 100644 index e55d22c10734eedcbd5be8012eaeb3fb3d51e381..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test-td6231.py +++ /dev/null @@ -1,50 +0,0 @@ -from taos import * - -conn = connect() - -dbname = "pytest_taos_stmt_multi" -conn.execute("drop database if exists %s" % dbname) -conn.execute("create database if not exists %s" % dbname) -conn.select_db(dbname) - -conn.execute( - "create table if not exists log(ts timestamp, bo bool, nil tinyint, \ - ti tinyint, si smallint, ii int, bi bigint, tu tinyint unsigned, \ - su smallint unsigned, iu int unsigned, bu bigint unsigned, \ - ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", -) - -stmt = conn.statement("insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") - -params = new_multi_binds(16) -params[0].timestamp((1626861392589, 1626861392590, 1626861392591)) -params[1].bool((True, None, False)) -params[2].tinyint([-128, -128, None]) # -128 is tinyint null -params[3].tinyint([0, 127, None]) -params[4].smallint([3, None, 2]) -params[5].int([3, 4, None]) -params[6].bigint([3, 4, None]) -params[7].tinyint_unsigned([3, 4, None]) -params[8].smallint_unsigned([3, 4, None]) -params[9].int_unsigned([3, 4, None]) -params[10].bigint_unsigned([3, 4, None]) -params[11].float([3, None, 1]) -params[12].double([3, None, 1.2]) -params[13].binary(["abc", "dddafadfadfadfadfa", None]) -# params[14].nchar(["涛思数据", None, "a long string with 中文字符"]) -params[14].nchar([None, None, None]) -params[15].timestamp([None, None, 1626861392591]) -stmt.bind_param_batch(params) -stmt.execute() - - -result = stmt.use_result() -assert result.affected_rows == 3 -result.close() - -result = conn.query("select * from log") -for row in result: - print(row) -result.close() -stmt.close() -conn.close() diff --git a/src/connector/python/tests/test_ctaos.py b/src/connector/python/tests/test_ctaos.py deleted file mode 100644 index 7b9566931f2b29dcbdc8646d2f087ebf40e716cc..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test_ctaos.py +++ /dev/null @@ -1,162 +0,0 @@ -from taos.cinterface import * -from taos.precision import * -from taos.bind import * - -import time -import datetime -import pytest - -@pytest.fixture -def conn(): - return CTaosInterface().connect() - - -def test_simple(conn, caplog): - dbname = "pytest_ctaos_simple" - try: - res = taos_query(conn, "create database if not exists %s" % dbname) - taos_free_result(res) - - taos_select_db(conn, dbname) - - res = taos_query( - conn, - "create table if not exists log(ts timestamp, level tinyint, content binary(100), ipaddr binary(134))", - ) - taos_free_result(res) - - res = taos_query(conn, "insert into log values(now, 1, 'hello', 'test')") - taos_free_result(res) - - res = taos_query(conn, "select level,content,ipaddr from log limit 1") - - fields = taos_fetch_fields_raw(res) - field_count = taos_field_count(res) - - fields = taos_fetch_fields(res) - for field in fields: - print(field) - - # field_lengths = taos_fetch_lengths(res, field_count) - # if not field_lengths: - # raise "fetch lengths error" - - row = taos_fetch_row_raw(res) - rowstr = taos_print_row(row, fields, field_count) - assert rowstr == "1 hello test" - - row, num = taos_fetch_row(res, fields) - print(row) - taos_free_result(res) - taos_query(conn, "drop database if exists " + dbname) - taos_close(conn) - except Exception as err: - taos_query(conn, "drop database if exists " + dbname) - raise err - - -def test_stmt(conn, caplog): - dbname = "pytest_ctaos_stmt" - try: - res = taos_query(conn, "drop database if exists %s" % dbname) - taos_free_result(res) - res = taos_query(conn, "create database if not exists %s" % dbname) - taos_free_result(res) - - taos_select_db(conn, dbname) - - res = taos_query( - conn, - "create table if not exists log(ts timestamp, nil tinyint, ti tinyint, si smallint, ii int,\ - bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned, \ - ff float, dd double, bb binary(100), nn nchar(100))", - ) - taos_free_result(res) - - stmt = taos_stmt_init(conn) - - taos_stmt_prepare(stmt, "insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)") - - params = new_bind_params(14) - params[0].timestamp(1626861392589, PrecisionEnum.Milliseconds) - params[1].null() - params[2].tinyint(2) - params[3].smallint(3) - params[4].int(4) - params[5].bigint(5) - params[6].tinyint_unsigned(6) - params[7].smallint_unsigned(7) - params[8].int_unsigned(8) - params[9].bigint_unsigned(9) - params[10].float(10.1) - params[11].double(10.11) - params[12].binary("hello") - params[13].nchar("stmt") - taos_stmt_bind_param(stmt, params) - taos_stmt_add_batch(stmt) - taos_stmt_execute(stmt) - - res = taos_query(conn, "select * from log limit 1") - - fields = taos_fetch_fields(res) - filed_count = taos_field_count(res) - - row = taos_fetch_row_raw(res) - rowstr = taos_print_row(row, fields, filed_count, 100) - - taos_free_result(res) - taos_query(conn, "drop database if exists " + dbname) - taos_close(conn) - - assert rowstr == "1626861392589 NULL 2 3 4 5 6 7 8 9 10.100000 10.110000 hello stmt" - except Exception as err: - taos_query(conn, "drop database if exists " + dbname) - raise err - -def stream_callback(param, result, row): - # type: (c_void_p, c_void_p, c_void_p) -> None - try: - if result == None or row == None: - return - result = c_void_p(result) - row = c_void_p(row) - fields = taos_fetch_fields_raw(result) - num_fields = taos_field_count(result) - s = taos_print_row(row, fields, num_fields) - print(s) - taos_stop_query(result) - except Exception as err: - print(err) - -def test_stream(conn, caplog): - dbname = "pytest_ctaos_stream" - try: - res = taos_query(conn, "create database if not exists %s" % dbname) - taos_free_result(res) - - taos_select_db(conn, dbname) - - res = taos_query( - conn, - "create table if not exists log(ts timestamp, n int)", - ) - taos_free_result(res) - - res = taos_query(conn, "select count(*) from log interval(5s)") - cc = taos_num_fields(res) - assert cc == 2 - - stream = taos_open_stream(conn, "select count(*) from log interval(5s)", stream_callback, 0, None, None) - print("waiting for data") - time.sleep(1) - - for i in range(0, 2): - res = taos_query(conn, "insert into log values(now,0)(now+1s, 1)(now + 2s, 2)") - taos_free_result(res) - time.sleep(2) - taos_close_stream(stream) - taos_query(conn, "drop database if exists " + dbname) - taos_close(conn) - except Exception as err: - taos_query(conn, "drop database if exists " + dbname) - raise err diff --git a/src/connector/python/tests/test_info.py b/src/connector/python/tests/test_info.py deleted file mode 100644 index bddfec7ef9ddbc203adfcadd262839048466592c..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test_info.py +++ /dev/null @@ -1,23 +0,0 @@ -from taos.cinterface import * - -from taos import * - -import pytest - -@pytest.fixture -def conn(): - return connect() - -def test_client_info(): - print(taos_get_client_info()) - None - -def test_server_info(conn): - # type: (TaosConnection) -> None - print(conn.client_info) - print(conn.server_info) - None - -if __name__ == "__main__": - test_client_info() - test_server_info(connect()) diff --git a/src/connector/python/tests/test_lines.py b/src/connector/python/tests/test_lines.py deleted file mode 100644 index 51d23b8e891d398b404086fdb2ff2910dcc1eb0a..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test_lines.py +++ /dev/null @@ -1,118 +0,0 @@ -from taos.error import OperationalError, SchemalessError -from taos import connect, new_bind_params, PrecisionEnum -from taos import * - -from ctypes import * -import taos -import pytest - - -@pytest.fixture -def conn(): - # type: () -> taos.TaosConnection - return connect() - - -def test_schemaless_insert_update_2(conn): - # type: (TaosConnection) -> None - - dbname = "test_schemaless_insert_update_2" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s update 2 precision 'ns'" % dbname) - conn.select_db(dbname) - - lines = [ - 'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin, abc",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000', - ] - res = conn.schemaless_insert(lines, 1, 0) - print("affected rows: ", res) - assert(res == 1) - - result = conn.query("select * from st") - [before] = result.fetch_all_into_dict() - assert(before["c3"] == "passitagin, abc") - - lines = [ - 'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000', - ] - res = conn.schemaless_insert(lines, 1, 0) - result = conn.query("select * from st") - [after] = result.fetch_all_into_dict() - assert(after["c3"] == "passitagin") - - conn.execute("drop database if exists %s" % dbname) - conn.close() - - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - print(err) - raise err - -def test_schemaless_insert(conn): - # type: (TaosConnection) -> None - - dbname = "pytest_taos_schemaless_insert" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s update 2 precision 'ns'" % dbname) - conn.select_db(dbname) - - lines = [ - 'st,t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000', - 'st,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin, abc",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000', - 'stf,t1=4i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000', - ] - res = conn.schemaless_insert(lines, 1, 0) - print("affected rows: ", res) - assert(res == 3) - - lines = [ - 'stf,t1=5i64,t3="t4",t2=5f64,t4=5f64 c1=3i64,c3=L"passitagin_stf",c2=false,c5=5f64,c6=7u64 1626006933641000000', - ] - res = conn.schemaless_insert(lines, 1, 0) - print("affected rows: ", res) - assert(res == 1) - result = conn.query("select * from st") - - dict2 = result.fetch_all_into_dict() - print(dict2) - result.row_count - all = result.rows_iter() - for row in all: - print(row) - result.close() - assert(result.row_count == 2) - - # error test - lines = [ - ',t1=3i64,t2=4f64,t3="t3" c1=3i64,c3=L"passit",c2=false,c4=4f64 1626006833639000000', - ] - try: - res = conn.schemaless_insert(lines, 1, 0) - print(res) - # assert(False) - except SchemalessError as err: - pass - - result = conn.query("select * from st") - result.row_count - all = result.rows_iter() - for row in all: - print(row) - result.close() - - conn.execute("drop database if exists %s" % dbname) - conn.close() - - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - print(err) - raise err - - -if __name__ == "__main__": - test_schemaless_insert(connect()) - test_schemaless_insert_update_2(connect()) diff --git a/src/connector/python/tests/test_query.py b/src/connector/python/tests/test_query.py deleted file mode 100644 index f4e139b1f14df29e8b6304dd2ca03519ea274f43..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test_query.py +++ /dev/null @@ -1,43 +0,0 @@ -from datetime import datetime -import taos -import pytest - -@pytest.fixture -def conn(): - return taos.connect() - -def test_query(conn): - """This test will use fetch_block for rows fetching, significantly faster than rows_iter""" - result = conn.query("select * from log.log limit 10000") - fields = result.fields - for field in fields: - print("field: %s" % field) - start = datetime.now() - for row in result: - # print(row) - None - end = datetime.now() - elapsed = end - start - print("elapsed time: ", elapsed) - result.close() - conn.close() - -def test_query_row_iter(conn): - """This test will use fetch_row for each row fetching, this is the only way in async callback""" - result = conn.query("select * from log.log limit 10000") - fields = result.fields - for field in fields: - print("field: %s" % field) - start = datetime.now() - for row in result.rows_iter(): - # print(row) - None - end = datetime.now() - elapsed = end - start - print("elapsed time: ", elapsed) - result.close() - conn.close() - -if __name__ == "__main__": - test_query(taos.connect(database = "log")) - test_query_row_iter(taos.connect(database = "log")) diff --git a/src/connector/python/tests/test_query_a.py b/src/connector/python/tests/test_query_a.py deleted file mode 100644 index 2b4be5695a87f1fd1017435b13983df7c4f70f06..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test_query_a.py +++ /dev/null @@ -1,66 +0,0 @@ -from taos import * -from ctypes import * -import taos -import pytest -import time - - -@pytest.fixture -def conn(): - return taos.connect() - -def fetch_callback(p_param, p_result, num_of_rows): - print("fetched ", num_of_rows, "rows") - p = cast(p_param, POINTER(Counter)) - result = TaosResult(p_result) - - if num_of_rows == 0: - print("fetching completed") - p.contents.done = True - result.close() - return - if num_of_rows < 0: - p.contents.done = True - result.check_error(num_of_rows) - result.close() - return None - - for row in result.rows_iter(num_of_rows): - # print(row) - None - p.contents.count += result.row_count - result.fetch_rows_a(fetch_callback, p_param) - - - -def query_callback(p_param, p_result, code): - # type: (c_void_p, c_void_p, c_int) -> None - if p_result == None: - return - result = TaosResult(p_result) - if code == 0: - result.fetch_rows_a(fetch_callback, p_param) - result.check_error(code) - - -class Counter(Structure): - _fields_ = [("count", c_int), ("done", c_bool)] - - def __str__(self): - return "{ count: %d, done: %s }" % (self.count, self.done) - - -def test_query(conn): - # type: (TaosConnection) -> None - counter = Counter(count=0) - conn.query_a("select * from log.log", query_callback, byref(counter)) - - while not counter.done: - print("wait query callback") - time.sleep(1) - print(counter) - conn.close() - - -if __name__ == "__main__": - test_query(taos.connect()) diff --git a/src/connector/python/tests/test_stmt.py b/src/connector/python/tests/test_stmt.py deleted file mode 100644 index 3368ecb6a9336a4295790f2cd55314ac9bb6290e..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test_stmt.py +++ /dev/null @@ -1,150 +0,0 @@ -# encoding:UTF-8 -from taos import * - -from ctypes import * -from datetime import datetime -import taos -import pytest - -@pytest.fixture -def conn(): - # type: () -> taos.TaosConnection - return connect() - -def test_stmt_insert(conn): - # type: (TaosConnection) -> None - - dbname = "pytest_taos_stmt" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) - - conn.execute( - "create table if not exists log(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,\ - bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned, \ - ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", - ) - conn.load_table_info("log") - - - stmt = conn.statement("insert into log values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)") - params = new_bind_params(16) - params[0].timestamp(1626861392589, PrecisionEnum.Milliseconds) - params[1].bool(True) - params[2].null() - params[3].tinyint(2) - params[4].smallint(3) - params[5].int(4) - params[6].bigint(5) - params[7].tinyint_unsigned(6) - params[8].smallint_unsigned(7) - params[9].int_unsigned(8) - params[10].bigint_unsigned(9) - params[11].float(10.1) - params[12].double(10.11) - params[13].binary("hello") - params[14].nchar("stmt") - params[15].timestamp(1626861392589, PrecisionEnum.Milliseconds) - - stmt.bind_param(params) - stmt.execute() - - result = stmt.use_result() - assert result.affected_rows == 1 - result.close() - stmt.close() - - stmt = conn.statement("select * from log") - stmt.execute() - result = stmt.use_result() - row = result.next() - print(row) - assert row[2] == None - for i in range(3, 11): - assert row[i] == i - 1 - #float == may not work as expected - # assert row[10] == c_float(10.1) - assert row[12] == 10.11 - assert row[13] == "hello" - assert row[14] == "stmt" - - conn.execute("drop database if exists %s" % dbname) - conn.close() - - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - raise err - -def test_stmt_insert_multi(conn): - # type: (TaosConnection) -> None - - dbname = "pytest_taos_stmt_multi" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) - - conn.execute( - "create table if not exists log(ts timestamp, bo bool, nil tinyint, ti tinyint, si smallint, ii int,\ - bi bigint, tu tinyint unsigned, su smallint unsigned, iu int unsigned, bu bigint unsigned, \ - ff float, dd double, bb binary(100), nn nchar(100), tt timestamp)", - ) - conn.load_table_info("log") - - start = datetime.now() - stmt = conn.statement("insert into log values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") - - params = new_multi_binds(16) - params[0].timestamp((1626861392589, 1626861392590, 1626861392591)) - params[1].bool((True, None, False)) - params[2].tinyint([-128, -128, None]) # -128 is tinyint null - params[3].tinyint([0, 127, None]) - params[4].smallint([3, None, 2]) - params[5].int([3, 4, None]) - params[6].bigint([3, 4, None]) - params[7].tinyint_unsigned([3, 4, None]) - params[8].smallint_unsigned([3, 4, None]) - params[9].int_unsigned([3, 4, None]) - params[10].bigint_unsigned([3, 4, None]) - params[11].float([3, None, 1]) - params[12].double([3, None, 1.2]) - params[13].binary(["abc", "dddafadfadfadfadfa", None]) - params[14].nchar(["涛思数据", None, "a long string with 中文字符"]) - params[15].timestamp([None, None, 1626861392591]) - stmt.bind_param_batch(params) - - stmt.execute() - end = datetime.now() - print("elapsed time: ", end - start) - result = stmt.use_result() - assert result.affected_rows == 3 - result.close() - stmt.close() - - stmt = conn.statement("select * from log") - stmt.execute() - result = stmt.use_result() - for row in result: - print(row) - result.close() - - stmt.close() - - # start = datetime.now() - # conn.query("insert into log values(1626861392660, true, NULL, 0, 3,3,3,3,3,3,3,3.0,3.0, 'abc','涛思数据',NULL)(1626861392661, true, NULL, 0, 3,3,3,3,3,3,3,3.0,3.0, 'abc','涛思数据',NULL)(1626861392662, true, NULL, 0, 3,3,3,3,3,3,3,3.0,3.0, 'abc','涛思数据',NULL)") - - # end = datetime.now() - # print("elapsed time: ", end - start) - - conn.execute("drop database if exists %s" % dbname) - conn.close() - - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - raise err -if __name__ == "__main__": - test_stmt_insert(connect()) - test_stmt_insert_multi(connect()) \ No newline at end of file diff --git a/src/connector/python/tests/test_stream.py b/src/connector/python/tests/test_stream.py deleted file mode 100644 index 32ec4c5999c975be907cf69a42a04b5f4dd5d54c..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test_stream.py +++ /dev/null @@ -1,71 +0,0 @@ -from taos.cinterface import * -from taos.precision import * -from taos.bind import * -from taos import * -from ctypes import * -import time -import pytest - - -@pytest.fixture -def conn(): - return connect() - - -def stream_callback(p_param, p_result, p_row): - # type: (c_void_p, c_void_p, c_void_p) -> None - - if p_result == None or p_row == None: - return - result = TaosResult(p_result) - row = TaosRow(result, p_row) - try: - ts, count = row.as_tuple() - print(ts, count) - p = cast(p_param, POINTER(Counter)) - p.contents.count += count - print("[%s] inserted %d in 5s, total count: %d" % (ts.strftime("%Y-%m-%d %H:%M:%S"), count, p.contents.count)) - - except Exception as err: - print(err) - raise err - - -class Counter(ctypes.Structure): - _fields_ = [ - ("count", c_int), - ] - - def __str__(self): - return "%d" % self.count - - -def test_stream(conn): - # type: (TaosConnection) -> None - dbname = "pytest_taos_stream" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) - conn.execute("create table if not exists log(ts timestamp, n int)") - - result = conn.query("select count(*) from log interval(5s)") - assert result.field_count == 2 - counter = Counter() - counter.count = 0 - stream = conn.stream("select count(*) from log interval(5s)", stream_callback, param=byref(counter)) - - for _ in range(0, 20): - conn.execute("insert into log values(now,0)(now+1s, 1)(now + 2s, 2)") - time.sleep(2) - stream.close() - conn.execute("drop database if exists %s" % dbname) - conn.close() - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - raise err - - -if __name__ == "__main__": - test_stream(connect()) diff --git a/src/connector/python/tests/test_subscribe.py b/src/connector/python/tests/test_subscribe.py deleted file mode 100644 index d8acd60e4f3b32bb87a9663b3f7dc43a73f2877b..0000000000000000000000000000000000000000 --- a/src/connector/python/tests/test_subscribe.py +++ /dev/null @@ -1,100 +0,0 @@ -from taos.subscription import TaosSubscription -from taos import * -from ctypes import * -import taos -import pytest -import time -from random import random - - -@pytest.fixture -def conn(): - return taos.connect() - - -def test_subscribe(conn): - # type: (TaosConnection) -> None - - dbname = "pytest_taos_subscribe_callback" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s" % dbname) - conn.select_db(dbname) - conn.execute("create table if not exists log(ts timestamp, n int)") - for i in range(10): - conn.execute("insert into log values(now, %d)" % i) - - sub = conn.subscribe(True, "test", "select * from log", 1000) - print("# consume from begin") - for ts, n in sub.consume(): - print(ts, n) - - print("# consume new data") - for i in range(5): - conn.execute("insert into log values(now, %d)(now+1s, %d)" % (i, i)) - result = sub.consume() - for ts, n in result: - print(ts, n) - - print("# consume with a stop condition") - for i in range(10): - conn.execute("insert into log values(now, %d)" % int(random() * 10)) - result = sub.consume() - try: - ts, n = next(result) - print(ts, n) - if n > 5: - result.stop_query() - print("## stopped") - break - except StopIteration: - continue - - sub.close() - - conn.execute("drop database if exists %s" % dbname) - conn.close() - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - raise err - - -def subscribe_callback(p_sub, p_result, p_param, errno): - # type: (c_void_p, c_void_p, c_void_p, c_int) -> None - print("callback") - result = TaosResult(c_void_p(p_result)) - result.check_error(errno) - for row in result.rows_iter(): - ts, n = row() - print(ts, n) - - -def test_subscribe_callback(conn): - # type: (TaosConnection) -> None - dbname = "pytest_taos_subscribe_callback" - try: - conn.execute("drop database if exists %s" % dbname) - conn.execute("create database if not exists %s" % dbname) - conn.execute("use %s" % dbname) - conn.execute("create table if not exists log(ts timestamp, n int)") - - print("# subscribe with callback") - sub = conn.subscribe(False, "test", "select * from log", 1000, subscribe_callback) - - for i in range(10): - conn.execute("insert into log values(now, %d)" % i) - time.sleep(0.7) - sub.close() - - conn.execute("drop database if exists %s" % dbname) - conn.close() - except Exception as err: - conn.execute("drop database if exists %s" % dbname) - conn.close() - raise err - - -if __name__ == "__main__": - test_subscribe(taos.connect()) - test_subscribe_callback(taos.connect()) diff --git a/src/cq/src/cqMain.c b/src/cq/src/cqMain.c index a1affc0869dca0a177ffafc6ab3309328652a696..e0576e2d8b5b23f9932b8893f2cd2d1db2d21115 100644 --- a/src/cq/src/cqMain.c +++ b/src/cq/src/cqMain.c @@ -54,6 +54,7 @@ typedef struct SCqObj { SCqContext * pContext; } SCqObj; +void taos_close_stream(TAOS_STREAM *handle); static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row); static void cqCreateStream(SCqContext *pContext, SCqObj *pObj); diff --git a/src/dnode/CMakeLists.txt b/src/dnode/CMakeLists.txt index ac91b498309bd951fab5860b223162ef40aff606..359f4534dfbeb3ea071f1301302a307121a60ef5 100644 --- a/src/dnode/CMakeLists.txt +++ b/src/dnode/CMakeLists.txt @@ -47,10 +47,6 @@ IF (TD_USB_DONGLE) TARGET_LINK_LIBRARIES(taosd usb_dongle) ENDIF () -IF (TD_MQTT) - TARGET_LINK_LIBRARIES(taosd mqtt) -ENDIF () - IF (TD_TOPIC) TARGET_LINK_LIBRARIES(taosd topic) ENDIF () diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index 39f9e352793ffcab885438309980c0c530e048ad..682d3f877d0350df76b4cceff50b283ac0c53d79 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -17,7 +17,6 @@ #include "os.h" #include "mnode.h" #include "http.h" -#include "tmqtt.h" #include "monitor.h" #include "dnodeModule.h" @@ -61,18 +60,6 @@ static void dnodeAllocModules() { } #endif -#ifdef _MQTT - tsModule[TSDB_MOD_MQTT].enable = (tsEnableMqttModule == 1); - tsModule[TSDB_MOD_MQTT].name = "mqtt"; - tsModule[TSDB_MOD_MQTT].initFp = mqttInitSystem; - tsModule[TSDB_MOD_MQTT].cleanUpFp = mqttCleanUpSystem; - tsModule[TSDB_MOD_MQTT].startFp = mqttStartSystem; - tsModule[TSDB_MOD_MQTT].stopFp = mqttStopSystem; - if (tsEnableMqttModule) { - dnodeSetModuleStatus(TSDB_MOD_MQTT); - } -#endif - tsModule[TSDB_MOD_MONITOR].enable = (tsEnableMonitorModule == 1); tsModule[TSDB_MOD_MONITOR].name = "monitor"; tsModule[TSDB_MOD_MONITOR].initFp = monInitSystem; diff --git a/src/inc/taos.h b/src/inc/taos.h index 80fbe4ef0846867d77d34ed9384e7bd3da9fe4db..481fc0f21d6819a623bcb6c947fcfa69086597bc 100644 --- a/src/inc/taos.h +++ b/src/inc/taos.h @@ -206,10 +206,6 @@ DLL_EXPORT TAOS_SUB *taos_subscribe(TAOS* taos, int restart, const char* topic, DLL_EXPORT TAOS_RES *taos_consume(TAOS_SUB *tsub); DLL_EXPORT void taos_unsubscribe(TAOS_SUB *tsub, int keepProgress); -DLL_EXPORT TAOS_STREAM *taos_open_stream(TAOS *taos, const char *sql, void (*fp)(void *param, TAOS_RES *, TAOS_ROW row), - int64_t stime, void *param, void (*callback)(void *)); -DLL_EXPORT void taos_close_stream(TAOS_STREAM *tstr); - DLL_EXPORT int taos_load_table_info(TAOS *taos, const char* tableNameList); DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS* taos, char* lines[], int numLines, int protocol, int precision); diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 436f6cc3abcd8b062d81810b0c426c3e7cf9c167..8f262252b05e0539ceed0b31b8598e249f9a68c6 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -183,10 +183,11 @@ do { \ #define TSDB_BINARY_OP_MULTIPLY 32 #define TSDB_BINARY_OP_DIVIDE 33 #define TSDB_BINARY_OP_REMAINDER 34 +#define TSDB_BINARY_OP_BITAND 35 #define IS_RELATION_OPTR(op) (((op) >= TSDB_RELATION_LESS) && ((op) < TSDB_RELATION_IN)) -#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_REMAINDER)) +#define IS_ARITHMETIC_OPTR(op) (((op) >= TSDB_BINARY_OP_ADD) && ((op) <= TSDB_BINARY_OP_BITAND)) #define TS_PATH_DELIMITER_LEN 1 @@ -249,13 +250,6 @@ do { \ #define TSDB_STEP_NAME_LEN 32 #define TSDB_STEP_DESC_LEN 128 -#define TSDB_MQTT_HOSTNAME_LEN 64 -#define TSDB_MQTT_PORT_LEN 8 -#define TSDB_MQTT_USER_LEN 24 -#define TSDB_MQTT_PASS_LEN 24 -#define TSDB_MQTT_TOPIC_LEN 64 -#define TSDB_MQTT_CLIENT_ID_LEN 32 - #define TSDB_DB_TYPE_DEFAULT 0 #define TSDB_DB_TYPE_TOPIC 1 @@ -461,8 +455,7 @@ typedef enum { TSDB_MOD_MNODE = 0, TSDB_MOD_HTTP = 1, TSDB_MOD_MONITOR = 2, - TSDB_MOD_MQTT = 3, - TSDB_MOD_MAX = 4 + TSDB_MOD_MAX = 3 } EModuleType; typedef enum { diff --git a/src/inc/tmqtt.h b/src/inc/tmqtt.h deleted file mode 100644 index 256e61fbae897cd77c1e7cc780c4c4c587293e28..0000000000000000000000000000000000000000 --- a/src/inc/tmqtt.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_MQTT_H -#define TDENGINE_MQTT_H - -#ifdef __cplusplus -extern "C" { -#endif - -int32_t mqttInitSystem(); -int32_t mqttStartSystem(); -void mqttStopSystem(); -void mqttCleanUpSystem(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/kit/taos-tools b/src/kit/taos-tools index 8145dd1713ab9e7652ea621ca7e6895fd0b21d65..9815e306333f4b0d8cf31499ba6c1e3a21fe104c 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit 8145dd1713ab9e7652ea621ca7e6895fd0b21d65 +Subproject commit 9815e306333f4b0d8cf31499ba6c1e3a21fe104c diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index c0793289b2b5d7dc9c01a274916f419de638cc14..80b8be7d833def37090f5fd54f7c73c2c6768b5c 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -1044,7 +1044,7 @@ int32_t mnodeRetrieveModules(SShowObj *pShow, char *data, int32_t rows, void *pC int32_t numOfRows = 0; char* pWrite; - char* moduleName[5] = { "MNODE", "HTTP", "MONITOR", "MQTT", "UNKNOWN" }; + char* moduleName[4] = { "MNODE", "HTTP", "MONITOR", "UNKNOWN" }; int32_t cols; while (numOfRows < rows) { @@ -1252,7 +1252,10 @@ static int32_t mnodeRetrieveVnodes(SShowObj *pShow, char *data, int32_t rows, vo char * pWrite; int32_t cols = 0; - if (0 == rows) return 0; + if (0 == rows) { + pShow->pIter = NULL; + return 0; + } pDnode = (SDnodeObj *)(pShow->pIter); if (pDnode != NULL) { diff --git a/src/mnode/src/mnodeShow.c b/src/mnode/src/mnodeShow.c index bebb73eca2c48b8920bcbdc6a22e70aaf509046f..169cd10b7e0bda62eb75c38e8ec241e6b9a76c40 100644 --- a/src/mnode/src/mnodeShow.c +++ b/src/mnode/src/mnodeShow.c @@ -121,7 +121,7 @@ static int32_t mnodeProcessShowMsg(SMnodeMsg *pMsg) { } if (!tsMnodeShowMetaFp[pShowMsg->type] || !tsMnodeShowRetrieveFp[pShowMsg->type]) { - mWarn("show type:%s is not support", mnodeGetShowType(pShowMsg->type)); + mWarn("show type:%s is not supported", mnodeGetShowType(pShowMsg->type)); return TSDB_CODE_COM_OPS_NOT_SUPPORT; } diff --git a/src/os/src/detail/osFile.c b/src/os/src/detail/osFile.c index f18fb6a6a8ebe0ae87811f0afbd37d44ff3dc02b..910e6f15be48e9a757b87939dd95b3541967f9c3 100644 --- a/src/os/src/detail/osFile.c +++ b/src/os/src/detail/osFile.c @@ -179,7 +179,7 @@ int64_t taosFSendFile(FILE *out_file, FILE *in_file, int64_t *offset, int64_t co fwrite(buffer, 1, rlen, out_file); return (int64_t)(writeLen + rlen); } else { - fwrite(buffer, 1, _SEND_FILE_STEP_, in_file); + fwrite(buffer, 1, _SEND_FILE_STEP_, out_file); writeLen += _SEND_FILE_STEP_; } } @@ -223,7 +223,7 @@ int64_t taosSendFile(SocketFd dfd, FileFd sfd, int64_t *offset, int64_t count) { if (rlen <= 0) { return writeLen; } else { - taosWriteSocket(sfd, buffer, (int32_t)remain); + taosWriteSocket(dfd, buffer, (int32_t)remain); writeLen += remain; } } diff --git a/src/os/tests/CMakeLists.txt b/src/os/tests/CMakeLists.txt index ef2c387e079b5b592c162b8533308c3dfd7ca07b..728648ba372ddc4ec9aa97296010535f58b47d13 100644 --- a/src/os/tests/CMakeLists.txt +++ b/src/os/tests/CMakeLists.txt @@ -12,7 +12,9 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) SET(CMAKE_CXX_STANDARD 11) INCLUDE_DIRECTORIES(/usr/include /usr/local/include) - LINK_DIRECTORIES(/usr/lib /usr/local/lib) + IF (NOT LIB_GTEST_STATIC_DIR) + LINK_DIRECTORIES(/usr/lib /usr/local/lib) + ENDIF() AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 097e7215d7c7abf01e459e6129ca0c445246dfa0..a91903630cbe75675f4c985f0906e6830d3cf2ff 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -95,7 +95,3 @@ ELSE () MESSAGE("${Yellow} Windows system still use original embedded httpd ${ColourReset}") ENDIF () ENDIF () - -IF (TD_LINUX AND TD_MQTT) - ADD_SUBDIRECTORY(mqtt) -ENDIF () diff --git a/src/plugins/http/src/httpParser.c b/src/plugins/http/src/httpParser.c index f3eaabf704dfc2949f2d321441a3f46f7a793eb4..7c68e6c98ea27c7156c508686f154eb2a1842c73 100644 --- a/src/plugins/http/src/httpParser.c +++ b/src/plugins/http/src/httpParser.c @@ -186,7 +186,7 @@ static int32_t httpOnRequestLine(HttpParser *pParser, char *method, char *target if (pContext->decodeMethod != NULL) { httpTrace("context:%p, fd:%d, decode method is %s", pContext, pContext->fd, pContext->decodeMethod->module); } else { - httpError("context:%p, fd:%d, the url is not support, target:%s", pContext, pContext->fd, target); + httpError("context:%p, fd:%d, the url is not supported, target:%s", pContext, pContext->fd, target); httpOnError(pParser, 0, TSDB_CODE_HTTP_UNSUPPORT_URL); return -1; } diff --git a/src/plugins/http/src/httpUtil.c b/src/plugins/http/src/httpUtil.c index f30ac7326eef20f4abf5558b288f16f6ee313b42..c49d561e2b552bd6dfdeb2a7d161da5ad75d3628 100644 --- a/src/plugins/http/src/httpUtil.c +++ b/src/plugins/http/src/httpUtil.c @@ -350,10 +350,10 @@ int32_t httpShrinkTableName(HttpContext *pContext, int32_t pos, char *name) { return pos; } - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)name, (uint32_t)len); - MD5Final(&context); + T_MD5_CTX context; + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)name, (uint32_t)len); + tMD5Final(&context); int32_t table_name = httpAddToSqlCmdBuffer( pContext, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], diff --git a/src/plugins/mqtt/CMakeLists.txt b/src/plugins/mqtt/CMakeLists.txt deleted file mode 100644 index 90d91e8bcbcb0cd26ba0a472469aed48b6049e39..0000000000000000000000000000000000000000 --- a/src/plugins/mqtt/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.0...3.20) -PROJECT(TDengine) - -INCLUDE_DIRECTORIES(inc) -INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/client/inc) -INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/query/inc) -INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/MQTT-C/include) -INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/deps/MQTT-C/examples/templates) -AUX_SOURCE_DIRECTORY(src SRC) - -IF (TD_LINUX) - ADD_LIBRARY(mqtt ${SRC}) - TARGET_LINK_LIBRARIES(mqtt cJson mqttc) - - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(mqtt taos_static) - ELSE () - TARGET_LINK_LIBRARIES(mqtt taos) - ENDIF () -ENDIF () - -IF (TD_DARWIN) - ADD_LIBRARY(mqtt ${SRC}) - TARGET_LINK_LIBRARIES(mqtt cJson mqttc) - - IF (TD_SOMODE_STATIC) - TARGET_LINK_LIBRARIES(mqtt taos_static) - ELSE () - TARGET_LINK_LIBRARIES(mqtt taos) - ENDIF () -ENDIF () - diff --git a/src/plugins/mqtt/inc/mqttInit.h b/src/plugins/mqtt/inc/mqttInit.h deleted file mode 100644 index 81a9a39a2ce04c66934c4bd25ed67bdb51c77ba3..0000000000000000000000000000000000000000 --- a/src/plugins/mqtt/inc/mqttInit.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_MQTT_INIT_H -#define TDENGINE_MQTT_INIT_H -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file - * A simple subscriber program that performs automatic reconnections. - */ -#include "mqtt.h" - -#define QOS 1 -#define TIMEOUT 10000L -#define MQTT_SEND_BUF_SIZE 102400 -#define MQTT_RECV_BUF_SIZE 102400 - -/** - * @brief A structure that I will use to keep track of some data needed - * to setup the connection to the broker. - * - * An instance of this struct will be created in my \c main(). Then, whenever - * \ref mqttReconnectClient is called, this instance will be passed. - */ -typedef struct SMqttReconnectState { - uint8_t* sendbuf; - size_t sendbufsz; - uint8_t* recvbuf; - size_t recvbufsz; -} SMqttReconnectState; - -/** - * @brief My reconnect callback. It will reestablish the connection whenever - * an error occurs. - */ -void mqttReconnectClient(struct mqtt_client* client, void** reconnect_state_vptr); - -/** - * @brief The function will be called whenever a PUBLISH message is received. - */ -void mqttPublishCallback(void** unused, struct mqtt_response_publish* published); - -/** - * @brief The client's refresher. This function triggers back-end routines to - * handle ingress/egress traffic to the broker. - * - * @note All this function needs to do is call \ref __mqtt_recv and - * \ref __mqtt_send every so often. I've picked 100 ms meaning that - * client ingress/egress traffic will be handled every 100 ms. - */ -void* mqttClientRefresher(void* client); - -/** - * @brief Safelty closes the \p sockfd and cancels the \p client_daemon before \c exit. - */ -void mqttCleanupRes(int status, int sockfd, pthread_t* client_daemon); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/plugins/mqtt/inc/mqttLog.h b/src/plugins/mqtt/inc/mqttLog.h deleted file mode 100644 index e186b8111220bd83f2f6833d84d1fdc19f744520..0000000000000000000000000000000000000000 --- a/src/plugins/mqtt/inc/mqttLog.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_MQTT_LOG_H -#define TDENGINE_MQTT_LOG_H - -#include "tlog.h" - -extern int32_t mqttDebugFlag; - -#define mqttFatal(...) { if (mqttDebugFlag & DEBUG_FATAL) { taosPrintLog("MQT FATAL ", 255, __VA_ARGS__); }} -#define mqttError(...) { if (mqttDebugFlag & DEBUG_ERROR) { taosPrintLog("MQT ERROR ", 255, __VA_ARGS__); }} -#define mqttWarn(...) { if (mqttDebugFlag & DEBUG_WARN) { taosPrintLog("MQT WARN ", 255, __VA_ARGS__); }} -#define mqttInfo(...) { if (mqttDebugFlag & DEBUG_INFO) { taosPrintLog("MQT ", 255, __VA_ARGS__); }} -#define mqttDebug(...) { if (mqttDebugFlag & DEBUG_DEBUG) { taosPrintLog("MQT ", mqttDebugFlag, __VA_ARGS__); }} -#define mqttTrace(...) { if (mqttDebugFlag & DEBUG_TRACE) { taosPrintLog("MQT ", mqttDebugFlag, __VA_ARGS__); }} - -#endif diff --git a/src/plugins/mqtt/inc/mqttPayload.h b/src/plugins/mqtt/inc/mqttPayload.h deleted file mode 100644 index 12a714afac52d1814f3cbf82ade610ec8af07953..0000000000000000000000000000000000000000 --- a/src/plugins/mqtt/inc/mqttPayload.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#ifndef TDENGINE_MQTT_PLYLOAD_H -#define TDENGINE_MQTT_PLYLOAD_H - -#ifdef __cplusplus -extern "C" { -#endif - -char* mqttConverJsonToSql(char* json, int maxSize); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/plugins/mqtt/src/mqttPayload.c b/src/plugins/mqtt/src/mqttPayload.c deleted file mode 100644 index 1af8b02fad7492da5664628b534b890732acbe3a..0000000000000000000000000000000000000000 --- a/src/plugins/mqtt/src/mqttPayload.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "os.h" -#include "cJSON.h" -#include "mqttLog.h" -#include "mqttPayload.h" - -// subscribe message like this - -/* -/test { - "timestamp": 1599121290, - "gateway": { - "name": "AcuLink 810 Gateway", - "model": "AcuLink810-868", - "serial": "S8P20200207" - }, - "device": { - "name": "Acuvim L V3 .221", - "model": "Acuvim-L-V3", - "serial": "221", - "online": true, - "readings": [ - { - "param": "Freq_Hz", - "value": "59.977539", - "unit": "Hz" - }, - { - "param": "Va_V", - "value": "122.002907", - "unit": "V" - }, - { - "param": "DI4", - "value": "5.000000", - "unit": "" - } - ] - } -} -*/ - -// send msg cmd -// mosquitto_pub -h test.mosquitto.org -t "/test" -m '{"timestamp": 1599121290,"gateway": {"name": "AcuLink 810 Gateway","model": "AcuLink810-868","serial": "S8P20200207"},"device": {"name": "Acuvim L V3 .221","model": "Acuvim-L-V3","serial": "221","online": true,"readings": [{"param": "Freq_Hz","value": "59.977539","unit": "Hz"},{"param": "Va_V","value": "122.002907","unit": "V"},{"param": "DI4","value": "5.000000","unit": ""}]}}' - -/* - * This is an example, this function needs to be implemented in order to parse the json file into a sql statement - * Note that you need to create a super table and database before writing data - * In this case: - * create database mqttdb; - * create table mqttdb.devices(ts timestamp, value bigint) tags(name binary(32), model binary(32), serial binary(16), param binary(16), unit binary(16)); - */ - -char* mqttConverJsonToSql(char* json, int maxSize) { - // const int32_t maxSize = 10240; - maxSize *= 5; - char* sql = malloc(maxSize); - - cJSON* root = cJSON_Parse(json); - if (root == NULL) { - mqttError("failed to parse msg, invalid json format"); - goto MQTT_PARSE_OVER; - } - - cJSON* timestamp = cJSON_GetObjectItem(root, "timestamp"); - if (!timestamp || timestamp->type != cJSON_Number) { - mqttError("failed to parse msg, timestamp not found"); - goto MQTT_PARSE_OVER; - } - - cJSON* device = cJSON_GetObjectItem(root, "device"); - if (!device) { - mqttError("failed to parse msg, device not found"); - goto MQTT_PARSE_OVER; - } - - cJSON* name = cJSON_GetObjectItem(device, "name"); - if (!name || name->type != cJSON_String) { - mqttError("failed to parse msg, name not found"); - goto MQTT_PARSE_OVER; - } - - cJSON* model = cJSON_GetObjectItem(device, "model"); - if (!model || model->type != cJSON_String) { - mqttError("failed to parse msg, model not found"); - goto MQTT_PARSE_OVER; - } - - cJSON* serial = cJSON_GetObjectItem(device, "serial"); - if (!serial || serial->type != cJSON_String) { - mqttError("failed to parse msg, serial not found"); - goto MQTT_PARSE_OVER; - } - - cJSON* readings = cJSON_GetObjectItem(device, "readings"); - if (!readings || readings->type != cJSON_Array) { - mqttError("failed to parse msg, readings not found"); - goto MQTT_PARSE_OVER; - } - - int count = cJSON_GetArraySize(readings); - if (count <= 0) { - mqttError("failed to parse msg, readings size smaller than 0"); - goto MQTT_PARSE_OVER; - } - - int len = snprintf(sql, maxSize, "insert into"); - - for (int i = 0; i < count; ++i) { - cJSON* reading = cJSON_GetArrayItem(readings, i); - if (reading == NULL) continue; - - cJSON* param = cJSON_GetObjectItem(reading, "param"); - if (!param || param->type != cJSON_String) { - mqttError("failed to parse msg, param not found"); - goto MQTT_PARSE_OVER; - } - - cJSON* value = cJSON_GetObjectItem(reading, "value"); - if (!value || value->type != cJSON_String) { - mqttError("failed to parse msg, value not found"); - goto MQTT_PARSE_OVER; - } - - cJSON* unit = cJSON_GetObjectItem(reading, "unit"); - if (!unit || unit->type != cJSON_String) { - mqttError("failed to parse msg, unit not found"); - goto MQTT_PARSE_OVER; - } - - len += snprintf(sql + len, maxSize - len, - " mqttdb.serial_%s_%s using mqttdb.devices tags('%s', '%s', '%s', '%s', '%s') values(%" PRId64 ", %s)", - serial->valuestring, param->valuestring, name->valuestring, model->valuestring, serial->valuestring, - param->valuestring, unit->valuestring, timestamp->valueint * 1000, value->valuestring); - } - - cJSON_free(root); - return sql; - -MQTT_PARSE_OVER: - cJSON_free(root); - free(sql); - return NULL; -} \ No newline at end of file diff --git a/src/plugins/mqtt/src/mqttSystem.c b/src/plugins/mqtt/src/mqttSystem.c deleted file mode 100644 index e0f2f393bb10706daadca35715d7e0ae68d7c436..0000000000000000000000000000000000000000 --- a/src/plugins/mqtt/src/mqttSystem.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#define _DEFAULT_SOURCE -#include "os.h" -#include "mqtt.h" -#include "mqttInit.h" -#include "mqttLog.h" -#include "mqttPayload.h" -#include "tmqtt.h" -#include "posix_sockets.h" -#include "taos.h" -#include "tglobal.h" -#include "taoserror.h" - -struct SMqttReconnectState tsMqttStatus = {0}; -struct mqtt_client tsMqttClient = {0}; -static pthread_t tsMqttClientDaemonThread = {0}; -static void* tsMqttConnect = NULL; -static bool tsMqttIsRuning = false; - -int32_t mqttInitSystem() { return 0; } - -int32_t mqttStartSystem() { - tsMqttStatus.sendbufsz = MQTT_SEND_BUF_SIZE; - tsMqttStatus.recvbufsz = MQTT_RECV_BUF_SIZE; - tsMqttStatus.sendbuf = malloc(MQTT_SEND_BUF_SIZE); - tsMqttStatus.recvbuf = malloc(MQTT_RECV_BUF_SIZE); - tsMqttIsRuning = true; - - mqtt_init_reconnect(&tsMqttClient, mqttReconnectClient, &tsMqttStatus, mqttPublishCallback); - if (pthread_create(&tsMqttClientDaemonThread, NULL, mqttClientRefresher, &tsMqttClient)) { - mqttError("mqtt failed to start daemon."); - mqttCleanupRes(EXIT_FAILURE, -1, NULL); - return -1; - } - - mqttInfo("mqtt listening for topic:%s messages", tsMqttTopic); - return 0; -} - -void mqttStopSystem() { - if (tsMqttIsRuning) { - tsMqttIsRuning = false; - tsMqttClient.error = MQTT_ERROR_SOCKET_ERROR; - - taosMsleep(300); - mqttCleanupRes(EXIT_SUCCESS, tsMqttClient.socketfd, &tsMqttClientDaemonThread); - - mqttInfo("mqtt is stopped"); - } -} - -void mqttCleanUpSystem() { - mqttStopSystem(); - mqttInfo("mqtt is cleaned up"); -} - -void mqttPublishCallback(void** unused, struct mqtt_response_publish* published) { - const char* content = published->application_message; - mqttDebug("receive mqtt message, size:%d", (int)published->application_message_size); - - if (tsMqttConnect == NULL) { - tsMqttConnect = taos_connect(NULL, "_root", tsInternalPass, "", 0); - if (tsMqttConnect == NULL) { - mqttError("failed to connect to tdengine, reason:%s", tstrerror(terrno)); - return; - } else { - mqttInfo("successfully connected to the tdengine"); - } - } - - mqttTrace("receive mqtt message, content:%s", content); - - char* sql = mqttConverJsonToSql((char*)content, (int)published->application_message_size); - if (sql != NULL) { - void* res = taos_query(tsMqttConnect, sql); - int code = taos_errno(res); - if (code != 0) { - mqttError("failed to exec sql, reason:%s sql:%s", tstrerror(code), sql); - } else { - mqttTrace("successfully to exec sql:%s", sql); - } - taos_free_result(res); - } else { - mqttError("failed to parse mqtt message"); - } -} - -void* mqttClientRefresher(void* client) { - setThreadName("mqttCliRefresh"); - - while (tsMqttIsRuning) { - mqtt_sync((struct mqtt_client*)client); - taosMsleep(100); - } - - mqttDebug("mqtt quit refresher"); - return NULL; -} - -void mqttCleanupRes(int status, int sockfd, pthread_t* client_daemon) { - mqttInfo("clean up mqtt module"); - if (sockfd != -1) { - close(sockfd); - } - - if (client_daemon != NULL) { - pthread_cancel(*client_daemon); - } -} - -void mqttReconnectClient(struct mqtt_client* client, void** unused) { - mqttInfo("mqtt tries to connect to the mqtt server"); - - if (client->error != MQTT_ERROR_INITIAL_RECONNECT) { - close(client->socketfd); - } - - if (client->error != MQTT_ERROR_INITIAL_RECONNECT) { - mqttError("mqtt client was in error state %s", mqtt_error_str(client->error)); - } - - int sockfd = open_nb_socket(tsMqttHostName, tsMqttPort); - if (sockfd < 0) { - mqttError("mqtt client failed to open socket %s:%s", tsMqttHostName, tsMqttPort); - //mqttCleanupRes(EXIT_FAILURE, sockfd, NULL); - return; - } - - mqtt_reinit(client, sockfd, tsMqttStatus.sendbuf, tsMqttStatus.sendbufsz, tsMqttStatus.recvbuf, tsMqttStatus.recvbufsz); - mqtt_connect(client, tsMqttClientId, NULL, NULL, 0, tsMqttUser, tsMqttPass, MQTT_CONNECT_CLEAN_SESSION, 400); - mqtt_subscribe(client, tsMqttTopic, 0); -} diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index db92d8db891dc520582544651eb5f055dcd5839e..bde9b11601b3053ec58aacc3828ec5be1653a803 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -550,10 +550,17 @@ typedef struct SFillOperatorInfo { bool multigroupResult; } SFillOperatorInfo; +typedef struct SGroupbyDataInfo { + int32_t index; // index of col in dataBlock + int32_t type; + int32_t bytes; +} SGroupbyDataInfo; + typedef struct SGroupbyOperatorInfo { SOptrBasicInfo binfo; - int32_t colIndex; - char *prevData; // previous group by value + SArray *pGroupbyDataInfo; + int32_t totalBytes; + char *prevData; // previous data buf } SGroupbyOperatorInfo; typedef struct SSWindowOperatorInfo { diff --git a/src/query/inc/qResultbuf.h b/src/query/inc/qResultbuf.h index 5191ddab46411032e25f4663122b04931281b132..7c33f729acca052b6123b5139c235195231bb9f2 100644 --- a/src/query/inc/qResultbuf.h +++ b/src/query/inc/qResultbuf.h @@ -79,9 +79,9 @@ typedef struct SDiskbasedResultBuf { #define DEFAULT_INTERN_BUF_PAGE_SIZE (1024L) // in bytes #define PAGE_INFO_INITIALIZER (SPageDiskInfo){-1, -1} #define MAX_UNIQUE_RESULT_ROWS (10000) -#define MAX_UNIQUE_RESULT_SIZE (1024*1024*10) -#define MAX_MODE_INNER_RESULT_ROWS (1000000) -#define MAX_MODE_INNER_RESULT_SIZE (1024*1024*10) +#define MAX_UNIQUE_RESULT_SIZE (1024*1024) +#define MAX_MODE_INNER_RESULT_ROWS (10000) +#define MAX_MODE_INNER_RESULT_SIZE (1024*1024) /** * create disk-based result buffer * @param pResultBuf diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 8d20a9df5dc17ed74c882f4ddb171d23ac9c7931..a0519a1b483aefba65b168921a37c1eaa5eaa55e 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -801,6 +801,7 @@ expr(A) ::= expr(X) MINUS expr(Y). {A = tSqlExprCreate(X, Y, TK_MINUS); } expr(A) ::= expr(X) STAR expr(Y). {A = tSqlExprCreate(X, Y, TK_STAR); } expr(A) ::= expr(X) SLASH expr(Y). {A = tSqlExprCreate(X, Y, TK_DIVIDE);} expr(A) ::= expr(X) REM expr(Y). {A = tSqlExprCreate(X, Y, TK_REM); } +expr(A) ::= expr(X) BITAND expr(Y). {A = tSqlExprCreate(X, Y, TK_BITAND);} // like expression expr(A) ::= expr(X) LIKE expr(Y). {A = tSqlExprCreate(X, Y, TK_LIKE); } diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 7026a32cf3bfa093beb9b18d90e974d6b18794e0..b9834b45b0d89c66e886365bd525001b995ca7a6 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -345,7 +345,7 @@ static uint64_t hllCountCnt(uint8_t *buckets) { z *= 0.5; } z += m * hllSigma(buckethisto[0]/(double)m); - double E = llroundl(HLL_ALPHA_INF*m*m/z); + double E = (double)llroundl(HLL_ALPHA_INF*m*m/z); return (uint64_t) E; } diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 5dad98840b88355d970a967c9615c481c972fc39..1facab0b34e271394c37486ee2b900ec89c8f71c 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -253,7 +253,7 @@ static void getAlignQueryTimeWindow(SQueryAttr *pQueryAttr, int64_t key, int64_t static void setResultBufSize(SQueryAttr* pQueryAttr, SRspResultInfo* pResultInfo); static void setCtxTagForJoin(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, SExprInfo* pExprInfo, void* pTable); static void setParamForStableStddev(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput, SExprInfo* pExpr); -static void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput, SExprInfo* pExpr, char* val, int16_t bytes); +static void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput, SExprInfo* pExpr, SGroupbyOperatorInfo *pInfo); static void doSetTableGroupOutputBuf(SQueryRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, SQLFunctionCtx* pCtx, int32_t* rowCellInfoOffset, int32_t numOfOutput, int32_t tableGroupId); @@ -330,11 +330,11 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO int64_t tmp = idata.info.bytes; tmp *= numOfRows; - if (tmp >= 1024*1024*1024) { // 1G - qError("size is too large, failed to allocate column buffer for output buffer"); + if (tmp >= INT32_MAX) { + qError("size is too large, failed to allocate column buffer for output buffer:%" PRId64, tmp); tmp = 128*1024*1024; } - int32_t size = (int32_t)MAX(tmp, minSize); + size_t size = (size_t)MAX(tmp, minSize); idata.pData = calloc(1, size); // at least to hold a pointer on x64 platform if (idata.pData == NULL) { qError("failed to allocate column buffer for output buffer"); @@ -1582,56 +1582,133 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul updateResultRowInfoActiveIndex(pResultRowInfo, pQueryAttr, pRuntimeEnv->current->lastKey); } +static bool initGroupbyInfo(const SSDataBlock *pSDataBlock, const SGroupbyExpr *pGroupbyExpr, SGroupbyOperatorInfo *pInfo) { + if (pInfo->pGroupbyDataInfo != NULL) { + // no need build group-by info + return true; + } + pInfo->pGroupbyDataInfo = taosArrayInit(pGroupbyExpr->numOfGroupCols, sizeof(SGroupbyDataInfo)); + + for (int32_t k = 0; k < pGroupbyExpr->numOfGroupCols; ++k) { + SColIndex* pColIndex = taosArrayGet(pGroupbyExpr->columnInfo, k); + if (TSDB_COL_IS_TAG(pColIndex->flag)) { + continue; + } + for (int32_t i = 0; i < pSDataBlock->info.numOfCols; ++i) { + SColumnInfoData* pColInfo = taosArrayGet(pSDataBlock->pDataBlock, i); + if (pColInfo->info.colId == pColIndex->colId) { + int32_t type = pColInfo->info.type; + if (type == TSDB_DATA_TYPE_FLOAT || type == TSDB_DATA_TYPE_DOUBLE) { + return false; + } + pInfo->totalBytes += pColInfo->info.bytes; + + SGroupbyDataInfo info = {.index = i, .type = pColInfo->info.type, .bytes = pColInfo->info.bytes}; + taosArrayInsert(pInfo->pGroupbyDataInfo, k, &info); + break; + } + if (i == pSDataBlock->info.numOfCols - 1) { + // not found groupby col in dataBlock, error + return false; + } + } + } + pInfo->totalBytes += (int32_t)strlen(MULTI_KEY_DELIM) * pGroupbyExpr->numOfGroupCols; + + return true; +} + +static void buildGroupbyKeyBuf(const SSDataBlock *pSDataBlock, SGroupbyOperatorInfo *pInfo, int32_t rowId, char **buf) { + char *p = calloc(1, pInfo->totalBytes); + if (p == NULL) { + *buf = NULL; + return; + } + *buf = p; + for (int32_t i = 0; i < taosArrayGetSize(pInfo->pGroupbyDataInfo); i++) { + SGroupbyDataInfo *pDataInfo = taosArrayGet(pInfo->pGroupbyDataInfo, i); + + SColumnInfoData* pColData = taosArrayGet(pSDataBlock->pDataBlock, pDataInfo->index); + //TODO(yihaoDeng): handle float & double + char *val = ((char *)pColData->pData) + pDataInfo->bytes * rowId; + if (isNull(val, pDataInfo->type)) { + p += pDataInfo->bytes; + continue; + } + if (IS_VAR_DATA_TYPE(pDataInfo->type)) { + memcpy(p, varDataVal(val), varDataLen(val)); + p += varDataLen(val); + } else { + memcpy(p, val, pDataInfo->bytes); + p += pDataInfo->bytes; + } + + memcpy(p, MULTI_KEY_DELIM, strlen(MULTI_KEY_DELIM)); + p += strlen(MULTI_KEY_DELIM); + } +} + +static bool isGroupbyKeyEqual(void *a, void *b, void *ext) { + SGroupbyOperatorInfo *pInfo = (SGroupbyOperatorInfo *)ext; + if (memcmp(a, b, pInfo->totalBytes) == 0) { + return true; + } + int32_t offset = 0; + for (int32_t i = 0; i < taosArrayGetSize(pInfo->pGroupbyDataInfo); i++) { + SGroupbyDataInfo *pDataInfo = taosArrayGet(pInfo->pGroupbyDataInfo, i); + + char *k1 = (char *)a + offset; + char *k2 = (char *)b + offset; + if (getComparFunc(pDataInfo->type, 0)(k1, k2) != 0) { + return false; + } + offset += pDataInfo->bytes; + offset += (int32_t)strlen(MULTI_KEY_DELIM); + } + return true; +} + static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pInfo, SSDataBlock *pSDataBlock) { SQueryRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; STableQueryInfo* item = pRuntimeEnv->current; - SColumnInfoData* pColInfoData = taosArrayGet(pSDataBlock->pDataBlock, pInfo->colIndex); - SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - int16_t bytes = pColInfoData->info.bytes; - int16_t type = pColInfoData->info.type; - if (type == TSDB_DATA_TYPE_FLOAT || type == TSDB_DATA_TYPE_DOUBLE) { + if (!initGroupbyInfo(pSDataBlock, pRuntimeEnv->pQueryAttr->pGroupbyExpr, pInfo)) { qError("QInfo:0x%"PRIx64" group by not supported on double/float columns, abort", GET_QID(pRuntimeEnv)); return; } + //realloc pRuntimeEnv->keyBuf + pRuntimeEnv->keyBuf = realloc(pRuntimeEnv->keyBuf, pInfo->totalBytes + sizeof(int64_t) + POINTER_BYTES); SColumnInfoData* pFirstColData = taosArrayGet(pSDataBlock->pDataBlock, 0); int64_t* tsList = (pFirstColData->info.type == TSDB_DATA_TYPE_TIMESTAMP)? (int64_t*) pFirstColData->pData:NULL; STimeWindow w = TSWINDOW_INITIALIZER; - int32_t num = 0; + char *key = NULL; + int16_t num = 0; + int32_t type = 0; for (int32_t j = 0; j < pSDataBlock->info.rows; ++j) { - char* val = ((char*)pColInfoData->pData) + bytes * j; + buildGroupbyKeyBuf(pSDataBlock, pInfo, j, &key); + if (!key) { continue; } - // Compare with the previous row of this column, and do not set the output buffer again if they are identical. if (pInfo->prevData == NULL) { - pInfo->prevData = malloc(bytes); - memcpy(pInfo->prevData, val, bytes); + // first row of + pInfo->prevData = key; num++; continue; - } - - if (IS_VAR_DATA_TYPE(type)) { - int32_t len = varDataLen(val); - if(len == varDataLen(pInfo->prevData) && memcmp(varDataVal(pInfo->prevData), varDataVal(val), len) == 0) { - num++; - continue; - } - } else { - if (memcmp(pInfo->prevData, val, bytes) == 0) { - num++; - continue; - } + } else if (isGroupbyKeyEqual(pInfo->prevData, key, pInfo)) { + num++; + tfree(key); + continue; } if (pQueryAttr->stableQuery && pQueryAttr->stabledev && (pRuntimeEnv->prevResult != NULL)) { - setParamForStableStddevByColData(pRuntimeEnv, pInfo->binfo.pCtx, pOperator->numOfOutput, pOperator->pExpr, pInfo->prevData, bytes); + setParamForStableStddevByColData(pRuntimeEnv, pInfo->binfo.pCtx, pOperator->numOfOutput, pOperator->pExpr, pInfo); } - int32_t ret = setGroupResultOutputBuf(pRuntimeEnv, &(pInfo->binfo), pOperator->numOfOutput, pInfo->prevData, type, bytes, item->groupIndex); + int32_t ret = setGroupResultOutputBuf(pRuntimeEnv, &(pInfo->binfo), pOperator->numOfOutput, pInfo->prevData, type, pInfo->totalBytes, item->groupIndex); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_APP_ERROR); } @@ -1639,23 +1716,25 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, j - num, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput); num = 1; - memcpy(pInfo->prevData, val, bytes); + + tfree(pInfo->prevData); + pInfo->prevData = key; } if (num > 0) { - char* val = ((char*)pColInfoData->pData) + bytes * (pSDataBlock->info.rows - num); - memcpy(pInfo->prevData, val, bytes); - - if (pQueryAttr->stableQuery && pQueryAttr->stabledev && (pRuntimeEnv->prevResult != NULL)) { - setParamForStableStddevByColData(pRuntimeEnv, pInfo->binfo.pCtx, pOperator->numOfOutput, pOperator->pExpr, val, bytes); - } - - int32_t ret = setGroupResultOutputBuf(pRuntimeEnv, &(pInfo->binfo), pOperator->numOfOutput, val, type, bytes, item->groupIndex); - if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code - longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_APP_ERROR); + buildGroupbyKeyBuf(pSDataBlock, pInfo, pSDataBlock->info.rows - num, &key); + if (key) { + tfree(pInfo->prevData); + pInfo->prevData = key; + if (pQueryAttr->stableQuery && pQueryAttr->stabledev && (pRuntimeEnv->prevResult != NULL)) { + setParamForStableStddevByColData(pRuntimeEnv, pInfo->binfo.pCtx, pOperator->numOfOutput, pOperator->pExpr, pInfo); + } + int32_t ret = setGroupResultOutputBuf(pRuntimeEnv, &(pInfo->binfo), pOperator->numOfOutput, pInfo->prevData, type, pInfo->totalBytes, item->groupIndex); + if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code + longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_APP_ERROR); + } + doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, pSDataBlock->info.rows - num, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput); } - - doApplyFunctions(pRuntimeEnv, pInfo->binfo.pCtx, &w, pSDataBlock->info.rows - num, num, tsList, pSDataBlock->info.rows, pOperator->numOfOutput); } tfree(pInfo->prevData); @@ -1728,23 +1807,6 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInf pSDataBlock->info.rows, pOperator->numOfOutput); } -static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) { - if (IS_VAR_DATA_TYPE(type)) { - if (pResultRow->key == NULL) { - pResultRow->key = malloc(varDataTLen(pData)); - varDataCopy(pResultRow->key, pData); - } else { - assert(memcmp(pResultRow->key, pData, varDataTLen(pData)) == 0); - } - } else { - int64_t v = -1; - GET_TYPED_DATA(v, int64_t, type, pData); - - pResultRow->win.skey = v; - pResultRow->win.ekey = v; - } -} - static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *binfo, int32_t numOfCols, char *pData, int16_t type, int16_t bytes, int32_t groupIndex) { SDiskbasedResultBuf *pResultBuf = pRuntimeEnv->pResultBuf; @@ -1755,16 +1817,11 @@ static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SOptrBasic // not assign result buffer yet, add new result buffer, TODO remove it char* d = pData; int16_t len = bytes; - if (IS_VAR_DATA_TYPE(type)) { - d = varDataVal(pData); - len = varDataLen(pData); - } int64_t tid = 0; SResultRow *pResultRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, d, len, true, groupIndex); assert (pResultRow != NULL); - setResultRowKey(pResultRow, pData, type); if (pResultRow->pageId == -1) { int32_t ret = addNewWindowResultBuf(pResultRow, pResultBuf, groupIndex, pRuntimeEnv->pQueryAttr->resultRowSize); if (ret != 0) { @@ -2074,7 +2131,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int32_t numOf pRuntimeEnv->sasArray = calloc(pQueryAttr->numOfOutput, sizeof(SScalarExprSupport)); if (pRuntimeEnv->sasArray == NULL || pRuntimeEnv->pResultRowHashTable == NULL || pRuntimeEnv->keyBuf == NULL || - pRuntimeEnv->prevRow == NULL || pRuntimeEnv->tagVal == NULL) { + pRuntimeEnv->prevRow == NULL || pRuntimeEnv->tagVal == NULL || pRuntimeEnv->pool == NULL) { goto _clean; } @@ -4203,7 +4260,7 @@ void setParamForStableStddev(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx } -void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput, SExprInfo* pExpr, char* val, int16_t bytes) { +void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunctionCtx* pCtx, int32_t numOfOutput, SExprInfo* pExpr, SGroupbyOperatorInfo *pInfo) { SQueryAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; int32_t numOfExprs = pQueryAttr->numOfOutput; @@ -4216,6 +4273,20 @@ void setParamForStableStddevByColData(SQueryRuntimeEnv* pRuntimeEnv, SQLFunction pCtx[i].param[0].arr = NULL; pCtx[i].param[0].nType = TSDB_DATA_TYPE_INT; // avoid freeing the memory by setting the type to be int + // find colid in dataBlock + int32_t bytes, offset = 0; + char* val = NULL; + for (int32_t idx = 0; idx < taosArrayGetSize(pInfo->pGroupbyDataInfo); idx++) { + SGroupbyDataInfo *pDataInfo = taosArrayGet(pInfo->pGroupbyDataInfo, idx); + if (pDataInfo->index == pExpr1->colInfo.colId) { + bytes = pDataInfo->bytes; + val = pInfo->prevData + offset; + break; + } + offset += pDataInfo->bytes; + } + if (val == NULL) { continue; } + // TODO use hash to speedup this loop int32_t numOfGroup = (int32_t)taosArrayGetSize(pRuntimeEnv->prevResult); for (int32_t j = 0; j < numOfGroup; ++j) { @@ -7106,9 +7177,6 @@ static SSDataBlock* hashGroupbyAggregate(void* param, bool* newgroup) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, pRuntimeEnv->pQueryAttr->order.order); setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->binfo.pCtx, pOperator->numOfOutput); - if (pInfo->colIndex == -1) { - pInfo->colIndex = getGroupbyColumnIndex(pRuntimeEnv->pQueryAttr->pGroupbyExpr, pBlock); - } doHashGroupbyAgg(pOperator, pInfo, pBlock); } @@ -7384,6 +7452,7 @@ static void destroySFillOperatorInfo(void* param, int32_t numOfOutput) { static void destroyGroupbyOperatorInfo(void* param, int32_t numOfOutput) { SGroupbyOperatorInfo* pInfo = (SGroupbyOperatorInfo*) param; doDestroyBasicInfo(&pInfo->binfo, numOfOutput); + taosArrayDestroy(&pInfo->pGroupbyDataInfo); if (pInfo->prevData) { tfree(pInfo->prevData); @@ -7863,7 +7932,6 @@ SOperatorInfo* createGroupbyOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperato return NULL; } - pInfo->colIndex = -1; // group by column index pInfo->binfo.pCtx = createSQLFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset, pRuntimeEnv->resultInfo.capacity); diff --git a/src/query/src/qFilter.c b/src/query/src/qFilter.c index d6a7dac7fcb6f525f6bf599d9d45b72f3d8c60f5..4fcf6fdef03940fe4a3bdb853fb25ff0a0f17fb5 100644 --- a/src/query/src/qFilter.c +++ b/src/query/src/qFilter.c @@ -3609,16 +3609,11 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar for (int32_t j = 0; j < rows; ++j) { char *src = FILTER_GET_COL_FIELD_DATA(fi, j); char *dst = FILTER_GET_COL_FIELD_DATA(&nfi, j); - int32_t len = 0; - char *varSrc = varDataVal(src); - size_t k = 0, varSrcLen = varDataLen(src); - while (k < varSrcLen && varSrc[k++] == -1) {} - if (k == varSrcLen) { - /* NULL */ - varDataLen(dst) = (VarDataLenT) varSrcLen; + if(isNull(src, TSDB_DATA_TYPE_NCHAR)){ varDataCopy(dst, src); continue; } + int32_t len = 0; bool ret = taosMbsToUcs4(varDataVal(src), varDataLen(src), varDataVal(dst), bufSize, &len); if(!ret) { qError("filterConverNcharColumns taosMbsToUcs4 error"); diff --git a/src/query/src/qTsbuf.c b/src/query/src/qTsbuf.c index bb124dec06e49be23f3a1572d8a878a694811977..2c7e09b84408beae3814cdd943388eb031639257 100644 --- a/src/query/src/qTsbuf.c +++ b/src/query/src/qTsbuf.c @@ -125,6 +125,13 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { ret = fseek(pTSBuf->f, 0, SEEK_END); UNUSED(ret); + + // file meta data may be cached, close and reopen the file for accurate file size. + fclose(pTSBuf->f); + pTSBuf->f = fopen(pTSBuf->path, "rb+"); + if (pTSBuf->f == NULL) { + return pTSBuf; + } struct stat fileStat; if (fstat(fileno(pTSBuf->f), &fileStat) != 0) { diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c index 67dfc130ed58d416500d278c60945114ef8a3fe4..1628c2d5111268111ca88cbe511095e8334453ed 100644 --- a/src/query/src/qUtil.c +++ b/src/query/src/qUtil.c @@ -204,9 +204,9 @@ SResultRowPool* initResultRowPool(size_t size) { p->elemSize = (int32_t) size; int64_t tmp = p->elemSize; tmp *= p->numOfElemPerBlock; - if (tmp > 1024*1024*1024){ + if (tmp > INT32_MAX){ qError("ResultRow blockSize is too large:%" PRId64, tmp); - tmp = 128*1024*1024; + return NULL; } p->blockSize = (int32_t)tmp; p->position.pos = 0; @@ -223,6 +223,7 @@ SResultRow* getNewResultRow(SResultRowPool* p) { void* ptr = NULL; if (p->position.pos == 0) { ptr = calloc(1, p->blockSize); + if(ptr == NULL) return NULL; taosArrayPush(p->pData, &ptr); } else { diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 7dbe846060b6671a422905a4e4907fd3f5fbb1c5..44a3cb667cb4572d226c5b8a52ffb859cf27bfa3 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -23,7 +23,6 @@ ** input grammar file: */ #include -#include /************ Begin %include sections from the grammar ************************/ #include @@ -77,10 +76,8 @@ ** zero the stack is dynamically sized using realloc() ** ParseARG_SDECL A static variable declaration for the %extra_argument ** ParseARG_PDECL A parameter declaration for the %extra_argument -** ParseARG_PARAM Code to pass %extra_argument as a subroutine parameter ** ParseARG_STORE Code to store %extra_argument into yypParser ** ParseARG_FETCH Code to extract %extra_argument from yypParser -** ParseCTX_* As ParseARG_ except for %extra_context ** YYERRORSYMBOL is the code number of the error symbol. If not ** defined, then do no error processing. ** YYNSTATE the combined number of states. @@ -100,59 +97,51 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 290 +#define YYNOCODE 292 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SRelationInfo* yy84; - SArray* yy161; - SSessionWindowVal yy219; - TAOS_FIELD yy223; - SCreateAcctInfo yy231; - SSqlNode* yy276; - SIntervalVal yy300; - SCreateDbInfo yy302; - SCreatedTableInfo yy356; - int64_t yy369; - SLimitVal yy394; - SRangeVal yy420; - int yy452; - SCreateTableSql* yy462; - int32_t yy520; - tVariant yy526; - tSqlExpr* yy546; - SWindowStateVal yy548; + SLimitVal yy6; + SSqlNode* yy86; + tVariant yy110; + TAOS_FIELD yy115; + tSqlExpr* yy142; + SIntervalVal yy238; + SSessionWindowVal yy319; + SRelationInfo* yy328; + SRangeVal yy330; + SCreateDbInfo yy436; + SCreatedTableInfo yy480; + int32_t yy508; + SCreateAcctInfo yy517; + SArray* yy525; + int64_t yy543; + SWindowStateVal yy546; + SCreateTableSql* yy572; + int yy580; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 #endif #define ParseARG_SDECL SSqlInfo* pInfo; #define ParseARG_PDECL ,SSqlInfo* pInfo -#define ParseARG_PARAM ,pInfo -#define ParseARG_FETCH SSqlInfo* pInfo=yypParser->pInfo; -#define ParseARG_STORE yypParser->pInfo=pInfo; -#define ParseCTX_SDECL -#define ParseCTX_PDECL -#define ParseCTX_PARAM -#define ParseCTX_FETCH -#define ParseCTX_STORE +#define ParseARG_FETCH SSqlInfo* pInfo = yypParser->pInfo +#define ParseARG_STORE yypParser->pInfo = pInfo #define YYFALLBACK 1 -#define YYNSTATE 398 -#define YYNRULE 320 -#define YYNRULE_WITH_ACTION 320 +#define YYNSTATE 400 +#define YYNRULE 321 #define YYNTOKEN 204 -#define YY_MAX_SHIFT 397 -#define YY_MIN_SHIFTREDUCE 625 -#define YY_MAX_SHIFTREDUCE 944 -#define YY_ERROR_ACTION 945 -#define YY_ACCEPT_ACTION 946 -#define YY_NO_ACTION 947 -#define YY_MIN_REDUCE 948 -#define YY_MAX_REDUCE 1267 +#define YY_MAX_SHIFT 399 +#define YY_MIN_SHIFTREDUCE 627 +#define YY_MAX_SHIFTREDUCE 947 +#define YY_ERROR_ACTION 948 +#define YY_ACCEPT_ACTION 949 +#define YY_NO_ACTION 950 +#define YY_MIN_REDUCE 951 +#define YY_MAX_REDUCE 1271 /************* End control #defines *******************************************/ -#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) /* Define the yytestcase() macro to be a no-op if is not already defined ** otherwise. @@ -217,318 +206,322 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (865) +#define YY_ACTTAB_COUNT (882) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 105, 676, 1097, 1131, 946, 397, 262, 760, 676, 677, - /* 10 */ 1183, 712, 1184, 314, 37, 38, 677, 41, 42, 396, - /* 20 */ 243, 265, 31, 30, 29, 1089, 163, 40, 347, 45, - /* 30 */ 43, 46, 44, 1086, 1087, 55, 1090, 36, 35, 372, - /* 40 */ 371, 34, 33, 32, 37, 38, 252, 41, 42, 258, - /* 50 */ 85, 265, 31, 30, 29, 24, 1122, 40, 347, 45, - /* 60 */ 43, 46, 44, 318, 100, 1241, 99, 36, 35, 218, - /* 70 */ 214, 34, 33, 32, 288, 1128, 131, 125, 136, 1241, - /* 80 */ 1241, 1243, 1244, 135, 1088, 141, 144, 134, 37, 38, - /* 90 */ 88, 41, 42, 51, 138, 265, 31, 30, 29, 295, - /* 100 */ 294, 40, 347, 45, 43, 46, 44, 343, 34, 33, - /* 110 */ 32, 36, 35, 343, 216, 34, 33, 32, 37, 38, - /* 120 */ 58, 41, 42, 59, 1241, 265, 31, 30, 29, 275, - /* 130 */ 676, 40, 347, 45, 43, 46, 44, 880, 677, 883, - /* 140 */ 185, 36, 35, 676, 217, 34, 33, 32, 13, 37, - /* 150 */ 39, 677, 41, 42, 1241, 382, 265, 31, 30, 29, - /* 160 */ 1106, 874, 40, 347, 45, 43, 46, 44, 245, 395, - /* 170 */ 393, 653, 36, 35, 59, 1104, 34, 33, 32, 209, - /* 180 */ 207, 205, 107, 86, 390, 1034, 204, 151, 150, 149, - /* 190 */ 148, 626, 627, 628, 629, 630, 631, 632, 633, 634, - /* 200 */ 635, 636, 637, 638, 639, 160, 250, 244, 38, 1263, - /* 210 */ 41, 42, 345, 1107, 265, 31, 30, 29, 280, 255, - /* 220 */ 40, 347, 45, 43, 46, 44, 1104, 284, 283, 317, - /* 230 */ 36, 35, 1, 187, 34, 33, 32, 223, 41, 42, - /* 240 */ 268, 178, 265, 31, 30, 29, 1255, 1241, 40, 347, - /* 250 */ 45, 43, 46, 44, 879, 296, 882, 888, 36, 35, - /* 260 */ 304, 94, 34, 33, 32, 67, 341, 389, 388, 340, - /* 270 */ 339, 338, 387, 337, 336, 335, 386, 334, 385, 384, - /* 280 */ 25, 59, 1065, 1053, 1054, 1055, 1056, 1057, 1058, 1059, - /* 290 */ 1060, 1061, 1062, 1063, 1064, 1066, 1067, 222, 224, 237, - /* 300 */ 890, 68, 297, 878, 230, 881, 352, 884, 1241, 1122, - /* 310 */ 147, 146, 145, 229, 181, 237, 890, 355, 94, 878, - /* 320 */ 269, 881, 267, 884, 358, 357, 256, 246, 59, 45, - /* 330 */ 43, 46, 44, 1104, 225, 241, 242, 36, 35, 349, - /* 340 */ 261, 34, 33, 32, 1241, 59, 5, 62, 189, 1194, - /* 350 */ 1122, 241, 242, 188, 114, 119, 110, 118, 68, 788, - /* 360 */ 274, 1233, 785, 257, 786, 108, 787, 266, 247, 1232, - /* 370 */ 1107, 1241, 330, 359, 889, 67, 1193, 389, 388, 1241, - /* 380 */ 1104, 287, 387, 84, 47, 285, 386, 822, 385, 384, - /* 390 */ 238, 825, 1231, 346, 270, 271, 1073, 1103, 1071, 1072, - /* 400 */ 47, 1091, 1241, 1074, 218, 59, 59, 1075, 59, 1076, - /* 410 */ 1077, 59, 161, 895, 1241, 345, 1244, 239, 79, 300, - /* 420 */ 301, 891, 885, 887, 36, 35, 59, 1241, 34, 33, - /* 430 */ 32, 218, 264, 159, 157, 156, 133, 891, 885, 887, - /* 440 */ 276, 1241, 273, 1244, 367, 366, 886, 59, 382, 59, - /* 450 */ 360, 361, 806, 362, 6, 240, 368, 1104, 1104, 220, - /* 460 */ 1104, 80, 886, 1104, 221, 1241, 226, 219, 275, 1241, - /* 470 */ 854, 369, 227, 228, 1241, 232, 1241, 1241, 1104, 186, - /* 480 */ 789, 272, 1241, 1241, 91, 1241, 233, 92, 234, 275, - /* 490 */ 259, 275, 370, 231, 374, 215, 1241, 1107, 1241, 1104, - /* 500 */ 348, 1104, 1105, 1241, 996, 1241, 248, 834, 835, 1006, - /* 510 */ 1181, 199, 1182, 102, 997, 101, 199, 103, 3, 200, - /* 520 */ 289, 199, 803, 831, 291, 299, 298, 291, 841, 842, - /* 530 */ 853, 76, 89, 770, 60, 322, 772, 165, 324, 771, - /* 540 */ 810, 54, 71, 48, 919, 892, 351, 60, 263, 60, - /* 550 */ 71, 10, 106, 71, 15, 675, 14, 83, 9, 9, - /* 560 */ 124, 17, 123, 16, 795, 793, 796, 794, 350, 9, - /* 570 */ 364, 363, 253, 19, 325, 18, 77, 130, 21, 129, - /* 580 */ 20, 143, 142, 1190, 1189, 254, 373, 162, 877, 759, - /* 590 */ 1102, 1130, 26, 1173, 1141, 1138, 1172, 1139, 1123, 292, - /* 600 */ 1143, 164, 169, 1098, 310, 1171, 1170, 180, 182, 1096, - /* 610 */ 183, 184, 1011, 158, 821, 327, 328, 303, 329, 332, - /* 620 */ 333, 69, 212, 65, 344, 1005, 249, 170, 356, 1262, - /* 630 */ 305, 307, 121, 1261, 1258, 190, 81, 365, 1254, 1120, - /* 640 */ 127, 1253, 78, 1250, 191, 1031, 66, 319, 171, 61, - /* 650 */ 70, 213, 28, 993, 315, 173, 137, 309, 313, 991, - /* 660 */ 139, 311, 140, 172, 306, 989, 988, 277, 202, 203, - /* 670 */ 985, 984, 983, 982, 302, 981, 980, 27, 979, 206, - /* 680 */ 208, 971, 210, 968, 211, 964, 87, 331, 290, 1100, - /* 690 */ 90, 95, 308, 383, 376, 132, 375, 377, 378, 379, - /* 700 */ 82, 380, 381, 260, 391, 944, 326, 279, 943, 282, - /* 710 */ 942, 278, 235, 236, 281, 925, 924, 115, 1010, 1009, - /* 720 */ 116, 286, 321, 291, 11, 293, 987, 93, 798, 52, - /* 730 */ 96, 830, 986, 193, 1032, 194, 195, 192, 196, 198, - /* 740 */ 197, 152, 828, 153, 978, 977, 320, 1069, 154, 1033, - /* 750 */ 155, 74, 176, 174, 175, 177, 970, 53, 179, 969, - /* 760 */ 1079, 2, 4, 824, 823, 75, 166, 827, 832, 843, - /* 770 */ 167, 168, 837, 97, 251, 839, 98, 312, 63, 350, - /* 780 */ 316, 12, 104, 49, 22, 23, 323, 64, 107, 109, - /* 790 */ 56, 111, 50, 112, 690, 725, 723, 722, 721, 57, - /* 800 */ 113, 719, 718, 717, 714, 680, 342, 117, 7, 916, - /* 810 */ 914, 894, 917, 893, 915, 8, 896, 354, 120, 72, - /* 820 */ 122, 60, 353, 792, 73, 762, 126, 128, 761, 758, - /* 830 */ 706, 704, 696, 702, 791, 698, 700, 694, 692, 728, - /* 840 */ 727, 726, 724, 720, 716, 715, 201, 643, 948, 678, - /* 850 */ 652, 392, 650, 947, 947, 947, 947, 947, 947, 947, - /* 860 */ 947, 947, 947, 947, 394, + /* 0 */ 219, 678, 1100, 164, 949, 399, 24, 762, 1134, 679, + /* 10 */ 1245, 678, 1247, 252, 38, 39, 1245, 42, 43, 679, + /* 20 */ 1110, 267, 31, 30, 29, 398, 245, 41, 349, 46, + /* 30 */ 44, 47, 45, 32, 109, 1109, 217, 37, 36, 374, + /* 40 */ 373, 35, 34, 33, 38, 39, 1245, 42, 43, 260, + /* 50 */ 179, 267, 31, 30, 29, 254, 1125, 41, 349, 46, + /* 60 */ 44, 47, 45, 32, 35, 34, 33, 37, 36, 306, + /* 70 */ 1094, 35, 34, 33, 290, 678, 297, 296, 38, 39, + /* 80 */ 1131, 42, 43, 679, 714, 267, 31, 30, 29, 60, + /* 90 */ 89, 41, 349, 46, 44, 47, 45, 32, 397, 395, + /* 100 */ 655, 37, 36, 218, 223, 35, 34, 33, 38, 39, + /* 110 */ 13, 42, 43, 1245, 1245, 267, 31, 30, 29, 224, + /* 120 */ 59, 41, 349, 46, 44, 47, 45, 32, 882, 1245, + /* 130 */ 885, 37, 36, 345, 247, 35, 34, 33, 60, 38, + /* 140 */ 40, 1107, 42, 43, 108, 87, 267, 31, 30, 29, + /* 150 */ 277, 876, 41, 349, 46, 44, 47, 45, 32, 86, + /* 160 */ 52, 186, 37, 36, 225, 678, 35, 34, 33, 39, + /* 170 */ 236, 42, 43, 679, 1245, 267, 31, 30, 29, 1236, + /* 180 */ 1245, 41, 349, 46, 44, 47, 45, 32, 60, 1245, + /* 190 */ 1106, 37, 36, 1091, 95, 35, 34, 33, 68, 343, + /* 200 */ 391, 390, 342, 341, 340, 389, 339, 338, 337, 388, + /* 210 */ 336, 387, 386, 628, 629, 630, 631, 632, 633, 634, + /* 220 */ 635, 636, 637, 638, 639, 640, 641, 161, 881, 246, + /* 230 */ 884, 42, 43, 257, 69, 267, 31, 30, 29, 1235, + /* 240 */ 1107, 41, 349, 46, 44, 47, 45, 32, 890, 1245, + /* 250 */ 384, 37, 36, 60, 1267, 35, 34, 33, 25, 1068, + /* 260 */ 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, + /* 270 */ 1066, 1067, 1069, 1070, 1125, 229, 1259, 239, 892, 836, + /* 280 */ 837, 880, 231, 883, 1186, 886, 1187, 316, 148, 147, + /* 290 */ 146, 230, 248, 239, 892, 357, 95, 880, 258, 883, + /* 300 */ 1184, 886, 1185, 264, 103, 1107, 102, 46, 44, 47, + /* 310 */ 45, 32, 1234, 243, 244, 37, 36, 351, 282, 35, + /* 320 */ 34, 33, 1245, 1092, 5, 63, 190, 286, 285, 243, + /* 330 */ 244, 189, 115, 120, 111, 119, 69, 790, 320, 101, + /* 340 */ 787, 100, 788, 298, 789, 132, 126, 137, 891, 353, + /* 350 */ 332, 60, 136, 106, 142, 145, 135, 259, 261, 289, + /* 360 */ 241, 85, 48, 139, 1110, 1110, 270, 215, 240, 277, + /* 370 */ 1245, 352, 272, 273, 210, 208, 206, 1245, 48, 1248, + /* 380 */ 187, 205, 152, 151, 150, 149, 1089, 1090, 56, 1093, + /* 390 */ 276, 68, 263, 391, 390, 277, 361, 268, 389, 893, + /* 400 */ 887, 889, 388, 1107, 387, 386, 350, 1076, 60, 1074, + /* 410 */ 1075, 345, 60, 104, 1077, 893, 887, 889, 1078, 299, + /* 420 */ 1079, 1080, 824, 348, 888, 32, 827, 134, 90, 37, + /* 430 */ 36, 60, 1197, 35, 34, 33, 1196, 37, 36, 384, + /* 440 */ 888, 35, 34, 33, 60, 347, 271, 1125, 269, 60, + /* 450 */ 360, 359, 60, 362, 302, 303, 219, 363, 791, 274, + /* 460 */ 1107, 219, 266, 60, 1107, 249, 1245, 808, 1248, 354, + /* 470 */ 278, 1245, 275, 1248, 369, 368, 364, 160, 158, 157, + /* 480 */ 242, 221, 222, 1107, 6, 226, 856, 277, 291, 370, + /* 490 */ 1245, 1245, 1245, 220, 371, 1245, 1107, 372, 1108, 227, + /* 500 */ 228, 1107, 61, 1245, 1107, 805, 233, 234, 376, 1245, + /* 510 */ 1245, 235, 232, 999, 216, 1107, 1245, 1245, 1009, 1000, + /* 520 */ 200, 1245, 1245, 92, 1245, 200, 200, 392, 1037, 1, + /* 530 */ 188, 3, 201, 93, 10, 301, 300, 833, 843, 844, + /* 540 */ 347, 250, 77, 80, 772, 324, 855, 774, 326, 265, + /* 550 */ 773, 166, 72, 49, 922, 812, 894, 319, 61, 61, + /* 560 */ 55, 72, 107, 293, 72, 677, 84, 15, 9, 14, + /* 570 */ 9, 182, 125, 293, 124, 17, 897, 16, 797, 9, + /* 580 */ 798, 795, 287, 796, 366, 365, 81, 78, 19, 879, + /* 590 */ 18, 255, 131, 327, 130, 144, 143, 21, 761, 20, + /* 600 */ 1193, 1192, 256, 375, 162, 26, 163, 1126, 294, 1105, + /* 610 */ 1133, 181, 1144, 1176, 1141, 1142, 1146, 165, 1175, 170, + /* 620 */ 312, 1174, 1101, 1173, 159, 183, 1123, 1099, 184, 823, + /* 630 */ 185, 1014, 329, 173, 330, 331, 334, 335, 70, 213, + /* 640 */ 66, 346, 305, 251, 1008, 358, 307, 1266, 309, 82, + /* 650 */ 122, 171, 1265, 79, 1262, 191, 367, 321, 172, 28, + /* 660 */ 174, 1258, 128, 1257, 317, 315, 1254, 313, 311, 192, + /* 670 */ 308, 1034, 67, 62, 304, 71, 88, 214, 996, 138, + /* 680 */ 994, 178, 140, 141, 992, 175, 991, 27, 279, 203, + /* 690 */ 204, 988, 987, 986, 985, 984, 983, 982, 207, 209, + /* 700 */ 333, 974, 211, 971, 212, 385, 967, 378, 133, 292, + /* 710 */ 1103, 91, 96, 377, 310, 379, 380, 381, 382, 383, + /* 720 */ 393, 83, 947, 281, 262, 328, 280, 946, 283, 284, + /* 730 */ 945, 928, 927, 237, 288, 238, 116, 1013, 293, 1012, + /* 740 */ 117, 323, 11, 94, 800, 53, 295, 97, 832, 75, + /* 750 */ 830, 990, 826, 195, 194, 1035, 153, 193, 989, 197, + /* 760 */ 196, 198, 199, 154, 981, 829, 155, 322, 1072, 1036, + /* 770 */ 980, 825, 156, 973, 54, 176, 177, 180, 972, 2, + /* 780 */ 76, 4, 834, 167, 1082, 845, 168, 169, 839, 98, + /* 790 */ 253, 841, 99, 314, 64, 352, 318, 65, 105, 22, + /* 800 */ 12, 23, 50, 325, 57, 51, 113, 108, 110, 692, + /* 810 */ 112, 727, 58, 114, 725, 724, 723, 721, 720, 719, + /* 820 */ 716, 344, 682, 118, 7, 919, 917, 896, 920, 895, + /* 830 */ 918, 8, 898, 356, 355, 73, 121, 123, 61, 74, + /* 840 */ 794, 764, 763, 127, 129, 760, 708, 706, 698, 704, + /* 850 */ 700, 702, 793, 696, 694, 730, 729, 728, 726, 722, + /* 860 */ 718, 717, 202, 680, 645, 951, 654, 652, 950, 394, + /* 870 */ 950, 950, 950, 950, 950, 950, 950, 950, 950, 950, + /* 880 */ 950, 396, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 214, 1, 206, 206, 204, 205, 213, 5, 1, 9, - /* 10 */ 285, 5, 287, 288, 14, 15, 9, 17, 18, 206, - /* 20 */ 207, 21, 22, 23, 24, 0, 206, 27, 28, 29, - /* 30 */ 30, 31, 32, 247, 248, 249, 250, 37, 38, 37, - /* 40 */ 38, 41, 42, 43, 14, 15, 1, 17, 18, 253, - /* 50 */ 214, 21, 22, 23, 24, 277, 256, 27, 28, 29, - /* 60 */ 30, 31, 32, 284, 285, 287, 287, 37, 38, 277, - /* 70 */ 277, 41, 42, 43, 274, 278, 66, 67, 68, 287, - /* 80 */ 287, 289, 289, 73, 248, 75, 76, 77, 14, 15, - /* 90 */ 90, 17, 18, 86, 84, 21, 22, 23, 24, 279, - /* 100 */ 280, 27, 28, 29, 30, 31, 32, 88, 41, 42, - /* 110 */ 43, 37, 38, 88, 277, 41, 42, 43, 14, 15, - /* 120 */ 90, 17, 18, 206, 287, 21, 22, 23, 24, 206, - /* 130 */ 1, 27, 28, 29, 30, 31, 32, 5, 9, 7, - /* 140 */ 217, 37, 38, 1, 277, 41, 42, 43, 86, 14, - /* 150 */ 15, 9, 17, 18, 287, 94, 21, 22, 23, 24, - /* 160 */ 259, 87, 27, 28, 29, 30, 31, 32, 251, 69, - /* 170 */ 70, 71, 37, 38, 206, 258, 41, 42, 43, 66, - /* 180 */ 67, 68, 120, 121, 228, 229, 73, 74, 75, 76, - /* 190 */ 77, 49, 50, 51, 52, 53, 54, 55, 56, 57, - /* 200 */ 58, 59, 60, 61, 62, 63, 252, 65, 15, 259, - /* 210 */ 17, 18, 47, 259, 21, 22, 23, 24, 150, 251, - /* 220 */ 27, 28, 29, 30, 31, 32, 258, 159, 160, 64, - /* 230 */ 37, 38, 215, 216, 41, 42, 43, 277, 17, 18, - /* 240 */ 72, 264, 21, 22, 23, 24, 259, 287, 27, 28, - /* 250 */ 29, 30, 31, 32, 5, 282, 7, 125, 37, 38, - /* 260 */ 283, 86, 41, 42, 43, 102, 103, 104, 105, 106, - /* 270 */ 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, - /* 280 */ 48, 206, 230, 231, 232, 233, 234, 235, 236, 237, - /* 290 */ 238, 239, 240, 241, 242, 243, 244, 65, 277, 1, - /* 300 */ 2, 126, 282, 5, 72, 7, 16, 9, 287, 256, - /* 310 */ 78, 79, 80, 81, 254, 1, 2, 85, 86, 5, - /* 320 */ 152, 7, 154, 9, 156, 157, 251, 274, 206, 29, - /* 330 */ 30, 31, 32, 258, 277, 37, 38, 37, 38, 41, - /* 340 */ 213, 41, 42, 43, 287, 206, 66, 67, 68, 246, - /* 350 */ 256, 37, 38, 73, 74, 75, 76, 77, 126, 2, - /* 360 */ 72, 277, 5, 252, 7, 214, 9, 213, 274, 277, - /* 370 */ 259, 287, 92, 251, 125, 102, 246, 104, 105, 287, - /* 380 */ 258, 149, 109, 151, 86, 206, 113, 5, 115, 116, - /* 390 */ 158, 9, 277, 25, 37, 38, 230, 258, 232, 233, - /* 400 */ 86, 250, 287, 237, 277, 206, 206, 241, 206, 243, - /* 410 */ 244, 206, 206, 123, 287, 47, 289, 277, 101, 37, - /* 420 */ 38, 123, 124, 125, 37, 38, 206, 287, 41, 42, - /* 430 */ 43, 277, 64, 66, 67, 68, 82, 123, 124, 125, - /* 440 */ 152, 287, 154, 289, 156, 157, 148, 206, 94, 206, - /* 450 */ 251, 251, 41, 251, 86, 277, 251, 258, 258, 277, - /* 460 */ 258, 144, 148, 258, 277, 287, 277, 277, 206, 287, - /* 470 */ 80, 251, 277, 277, 287, 277, 287, 287, 258, 217, - /* 480 */ 123, 124, 287, 287, 87, 287, 277, 87, 277, 206, - /* 490 */ 252, 206, 251, 277, 251, 277, 287, 259, 287, 258, - /* 500 */ 217, 258, 217, 287, 212, 287, 124, 132, 133, 212, - /* 510 */ 285, 219, 287, 285, 212, 287, 219, 260, 210, 211, - /* 520 */ 87, 219, 101, 87, 127, 37, 38, 127, 87, 87, - /* 530 */ 140, 101, 275, 87, 101, 87, 87, 101, 87, 87, - /* 540 */ 129, 86, 101, 101, 87, 87, 25, 101, 1, 101, - /* 550 */ 101, 130, 101, 101, 153, 87, 155, 86, 101, 101, - /* 560 */ 153, 153, 155, 155, 5, 5, 7, 7, 47, 101, - /* 570 */ 37, 38, 246, 153, 119, 155, 146, 153, 153, 155, - /* 580 */ 155, 82, 83, 246, 246, 246, 246, 206, 41, 118, - /* 590 */ 206, 206, 276, 286, 206, 206, 286, 206, 256, 256, - /* 600 */ 206, 206, 206, 256, 206, 286, 286, 261, 206, 206, - /* 610 */ 206, 206, 206, 64, 125, 206, 206, 281, 206, 206, - /* 620 */ 206, 206, 206, 206, 206, 206, 281, 272, 206, 206, - /* 630 */ 281, 281, 206, 206, 206, 206, 143, 206, 206, 273, - /* 640 */ 206, 206, 145, 206, 206, 206, 206, 138, 271, 206, - /* 650 */ 206, 206, 142, 206, 141, 269, 206, 134, 136, 206, - /* 660 */ 206, 135, 206, 270, 137, 206, 206, 206, 206, 206, - /* 670 */ 206, 206, 206, 206, 131, 206, 206, 147, 206, 206, - /* 680 */ 206, 206, 206, 206, 206, 206, 122, 93, 208, 208, - /* 690 */ 208, 208, 208, 117, 55, 100, 99, 96, 98, 59, - /* 700 */ 208, 97, 95, 208, 88, 5, 208, 5, 5, 5, - /* 710 */ 5, 161, 208, 208, 161, 104, 103, 214, 218, 218, - /* 720 */ 214, 150, 119, 127, 86, 101, 208, 128, 87, 86, - /* 730 */ 101, 87, 208, 225, 227, 221, 224, 226, 222, 220, - /* 740 */ 223, 209, 125, 209, 208, 208, 255, 245, 209, 229, - /* 750 */ 209, 101, 266, 268, 267, 265, 208, 263, 262, 208, - /* 760 */ 245, 215, 210, 5, 5, 86, 86, 125, 87, 87, - /* 770 */ 86, 101, 87, 86, 1, 87, 86, 86, 101, 47, - /* 780 */ 1, 86, 90, 86, 139, 139, 119, 101, 120, 82, - /* 790 */ 91, 90, 86, 74, 5, 9, 5, 5, 5, 91, - /* 800 */ 90, 5, 5, 5, 5, 89, 16, 82, 86, 9, - /* 810 */ 9, 87, 9, 87, 9, 86, 123, 63, 155, 17, - /* 820 */ 155, 101, 28, 125, 17, 5, 155, 155, 5, 87, - /* 830 */ 5, 5, 5, 5, 125, 5, 5, 5, 5, 5, - /* 840 */ 5, 5, 5, 5, 5, 5, 101, 64, 0, 89, - /* 850 */ 9, 22, 9, 290, 290, 290, 290, 290, 290, 290, - /* 860 */ 290, 290, 290, 290, 22, 290, 290, 290, 290, 290, - /* 870 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 880 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 890 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 900 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 910 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 920 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 930 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 940 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 950 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 960 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 970 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 980 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 990 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 1000 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 1010 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 1020 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 1030 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 1040 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 1050 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, - /* 1060 */ 290, 290, 290, 290, 290, 290, 290, 290, 290, + /* 0 */ 278, 1, 207, 207, 205, 206, 278, 5, 207, 9, + /* 10 */ 288, 1, 290, 253, 14, 15, 288, 17, 18, 9, + /* 20 */ 260, 21, 22, 23, 24, 207, 208, 27, 28, 29, + /* 30 */ 30, 31, 32, 33, 215, 260, 278, 37, 38, 37, + /* 40 */ 38, 41, 42, 43, 14, 15, 288, 17, 18, 254, + /* 50 */ 265, 21, 22, 23, 24, 1, 257, 27, 28, 29, + /* 60 */ 30, 31, 32, 33, 41, 42, 43, 37, 38, 284, + /* 70 */ 251, 41, 42, 43, 275, 1, 280, 281, 14, 15, + /* 80 */ 279, 17, 18, 9, 5, 21, 22, 23, 24, 207, + /* 90 */ 90, 27, 28, 29, 30, 31, 32, 33, 69, 70, + /* 100 */ 71, 37, 38, 278, 278, 41, 42, 43, 14, 15, + /* 110 */ 86, 17, 18, 288, 288, 21, 22, 23, 24, 278, + /* 120 */ 90, 27, 28, 29, 30, 31, 32, 33, 5, 288, + /* 130 */ 7, 37, 38, 88, 252, 41, 42, 43, 207, 14, + /* 140 */ 15, 259, 17, 18, 120, 121, 21, 22, 23, 24, + /* 150 */ 207, 87, 27, 28, 29, 30, 31, 32, 33, 215, + /* 160 */ 86, 218, 37, 38, 278, 1, 41, 42, 43, 15, + /* 170 */ 278, 17, 18, 9, 288, 21, 22, 23, 24, 278, + /* 180 */ 288, 27, 28, 29, 30, 31, 32, 33, 207, 288, + /* 190 */ 259, 37, 38, 249, 86, 41, 42, 43, 102, 103, + /* 200 */ 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, + /* 210 */ 114, 115, 116, 49, 50, 51, 52, 53, 54, 55, + /* 220 */ 56, 57, 58, 59, 60, 61, 62, 63, 5, 65, + /* 230 */ 7, 17, 18, 252, 126, 21, 22, 23, 24, 278, + /* 240 */ 259, 27, 28, 29, 30, 31, 32, 33, 125, 288, + /* 250 */ 94, 37, 38, 207, 260, 41, 42, 43, 48, 231, + /* 260 */ 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, + /* 270 */ 242, 243, 244, 245, 257, 65, 260, 1, 2, 132, + /* 280 */ 133, 5, 72, 7, 286, 9, 288, 289, 78, 79, + /* 290 */ 80, 81, 275, 1, 2, 85, 86, 5, 252, 7, + /* 300 */ 286, 9, 288, 214, 286, 259, 288, 29, 30, 31, + /* 310 */ 32, 33, 278, 37, 38, 37, 38, 41, 150, 41, + /* 320 */ 42, 43, 288, 0, 66, 67, 68, 159, 160, 37, + /* 330 */ 38, 73, 74, 75, 76, 77, 126, 2, 285, 286, + /* 340 */ 5, 288, 7, 283, 9, 66, 67, 68, 125, 25, + /* 350 */ 92, 207, 73, 215, 75, 76, 77, 253, 253, 149, + /* 360 */ 278, 151, 86, 84, 260, 260, 72, 278, 158, 207, + /* 370 */ 288, 47, 37, 38, 66, 67, 68, 288, 86, 290, + /* 380 */ 218, 73, 74, 75, 76, 77, 248, 249, 250, 251, + /* 390 */ 72, 102, 214, 104, 105, 207, 252, 214, 109, 123, + /* 400 */ 124, 125, 113, 259, 115, 116, 218, 231, 207, 233, + /* 410 */ 234, 88, 207, 261, 238, 123, 124, 125, 242, 283, + /* 420 */ 244, 245, 5, 25, 148, 33, 9, 82, 276, 37, + /* 430 */ 38, 207, 247, 41, 42, 43, 247, 37, 38, 94, + /* 440 */ 148, 41, 42, 43, 207, 47, 152, 257, 154, 207, + /* 450 */ 156, 157, 207, 252, 37, 38, 278, 252, 123, 124, + /* 460 */ 259, 278, 64, 207, 259, 275, 288, 41, 290, 16, + /* 470 */ 152, 288, 154, 290, 156, 157, 252, 66, 67, 68, + /* 480 */ 278, 278, 278, 259, 86, 278, 80, 207, 87, 252, + /* 490 */ 288, 288, 288, 278, 252, 288, 259, 252, 218, 278, + /* 500 */ 278, 259, 101, 288, 259, 101, 278, 278, 252, 288, + /* 510 */ 288, 278, 278, 213, 278, 259, 288, 288, 213, 213, + /* 520 */ 220, 288, 288, 87, 288, 220, 220, 229, 230, 216, + /* 530 */ 217, 211, 212, 87, 130, 37, 38, 87, 87, 87, + /* 540 */ 47, 124, 101, 101, 87, 87, 140, 87, 87, 1, + /* 550 */ 87, 101, 101, 101, 87, 129, 87, 64, 101, 101, + /* 560 */ 86, 101, 101, 127, 101, 87, 86, 153, 101, 155, + /* 570 */ 101, 255, 153, 127, 155, 153, 123, 155, 5, 101, + /* 580 */ 7, 5, 207, 7, 37, 38, 144, 146, 153, 41, + /* 590 */ 155, 247, 153, 119, 155, 82, 83, 153, 118, 155, + /* 600 */ 247, 247, 247, 247, 207, 277, 207, 257, 257, 207, + /* 610 */ 207, 262, 207, 287, 207, 207, 207, 207, 287, 207, + /* 620 */ 207, 287, 257, 287, 64, 207, 274, 207, 207, 125, + /* 630 */ 207, 207, 207, 271, 207, 207, 207, 207, 207, 207, + /* 640 */ 207, 207, 282, 282, 207, 207, 282, 207, 282, 143, + /* 650 */ 207, 273, 207, 145, 207, 207, 207, 138, 272, 142, + /* 660 */ 270, 207, 207, 207, 141, 136, 207, 135, 134, 207, + /* 670 */ 137, 207, 207, 207, 131, 207, 122, 207, 207, 207, + /* 680 */ 207, 266, 207, 207, 207, 269, 207, 147, 207, 207, + /* 690 */ 207, 207, 207, 207, 207, 207, 207, 207, 207, 207, + /* 700 */ 93, 207, 207, 207, 207, 117, 207, 55, 100, 209, + /* 710 */ 209, 209, 209, 99, 209, 96, 98, 59, 97, 95, + /* 720 */ 88, 209, 5, 5, 209, 209, 161, 5, 161, 5, + /* 730 */ 5, 104, 103, 209, 150, 209, 215, 219, 127, 219, + /* 740 */ 215, 119, 86, 128, 87, 86, 101, 101, 87, 101, + /* 750 */ 125, 209, 5, 222, 226, 228, 210, 227, 209, 223, + /* 760 */ 225, 224, 221, 210, 209, 125, 210, 256, 246, 230, + /* 770 */ 209, 5, 210, 209, 264, 268, 267, 263, 209, 216, + /* 780 */ 86, 211, 87, 86, 246, 87, 86, 101, 87, 86, + /* 790 */ 1, 87, 86, 86, 101, 47, 1, 101, 90, 139, + /* 800 */ 86, 139, 86, 119, 91, 86, 74, 120, 82, 5, + /* 810 */ 90, 9, 91, 90, 5, 5, 5, 5, 5, 5, + /* 820 */ 5, 16, 89, 82, 86, 9, 9, 87, 9, 87, + /* 830 */ 9, 86, 123, 63, 28, 17, 155, 155, 101, 17, + /* 840 */ 125, 5, 5, 155, 155, 87, 5, 5, 5, 5, + /* 850 */ 5, 5, 125, 5, 5, 5, 5, 5, 5, 5, + /* 860 */ 5, 5, 101, 89, 64, 0, 9, 9, 291, 22, + /* 870 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 880 */ 291, 22, 291, 291, 291, 291, 291, 291, 291, 291, + /* 890 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 900 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 910 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 920 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 930 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 940 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 950 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 960 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 970 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 980 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 990 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1000 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1010 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1020 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1030 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1040 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1050 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1060 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1070 */ 291, 291, 291, 291, 291, 291, 291, 291, 291, 291, + /* 1080 */ 291, 291, 291, 291, 291, 291, }; -#define YY_SHIFT_COUNT (397) +#define YY_SHIFT_COUNT (399) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (848) +#define YY_SHIFT_MAX (865) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 232, 163, 163, 273, 273, 19, 298, 314, 314, 314, - /* 10 */ 7, 129, 129, 129, 129, 129, 129, 129, 129, 129, - /* 20 */ 129, 129, 45, 45, 0, 142, 314, 314, 314, 314, - /* 30 */ 314, 314, 314, 314, 314, 314, 314, 314, 314, 314, - /* 40 */ 314, 314, 314, 314, 314, 314, 314, 314, 357, 357, - /* 50 */ 357, 175, 175, 375, 129, 25, 129, 129, 129, 129, - /* 60 */ 129, 354, 19, 45, 45, 61, 61, 6, 865, 865, - /* 70 */ 865, 357, 357, 357, 382, 382, 2, 2, 2, 2, - /* 80 */ 2, 2, 62, 2, 129, 129, 129, 129, 129, 411, - /* 90 */ 129, 129, 129, 175, 175, 129, 129, 129, 129, 390, - /* 100 */ 390, 390, 390, 421, 175, 129, 129, 129, 129, 129, - /* 110 */ 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - /* 120 */ 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - /* 130 */ 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - /* 140 */ 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - /* 150 */ 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, - /* 160 */ 129, 549, 549, 549, 549, 489, 489, 489, 489, 549, - /* 170 */ 493, 497, 509, 510, 513, 522, 526, 523, 527, 543, - /* 180 */ 530, 564, 549, 549, 549, 594, 594, 576, 19, 19, - /* 190 */ 549, 549, 595, 597, 639, 601, 600, 640, 604, 607, - /* 200 */ 576, 6, 549, 549, 616, 616, 549, 616, 549, 616, - /* 210 */ 549, 549, 865, 865, 30, 74, 104, 104, 104, 135, - /* 220 */ 193, 221, 280, 300, 300, 300, 300, 300, 300, 10, - /* 230 */ 113, 387, 387, 387, 387, 168, 288, 368, 68, 67, - /* 240 */ 67, 132, 249, 100, 367, 433, 397, 400, 488, 436, - /* 250 */ 441, 442, 165, 430, 317, 446, 448, 449, 451, 452, - /* 260 */ 455, 457, 458, 521, 547, 290, 468, 401, 407, 408, - /* 270 */ 559, 560, 533, 420, 424, 471, 425, 499, 700, 550, - /* 280 */ 702, 703, 553, 704, 705, 611, 613, 571, 596, 603, - /* 290 */ 638, 599, 641, 643, 624, 629, 644, 650, 617, 642, - /* 300 */ 758, 759, 679, 681, 680, 682, 684, 685, 670, 687, - /* 310 */ 688, 690, 773, 691, 677, 645, 732, 779, 686, 646, - /* 320 */ 692, 695, 603, 697, 667, 706, 668, 707, 699, 701, - /* 330 */ 719, 789, 708, 710, 786, 791, 792, 793, 796, 797, - /* 340 */ 798, 799, 716, 790, 725, 800, 801, 722, 724, 726, - /* 350 */ 803, 805, 693, 729, 794, 754, 802, 663, 665, 720, - /* 360 */ 720, 720, 720, 698, 709, 807, 671, 672, 720, 720, - /* 370 */ 720, 820, 823, 742, 720, 825, 826, 827, 828, 830, - /* 380 */ 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, - /* 390 */ 745, 760, 841, 829, 843, 842, 783, 848, + /* 0 */ 210, 96, 96, 289, 289, 45, 276, 292, 292, 292, + /* 10 */ 74, 10, 10, 10, 10, 10, 10, 10, 10, 10, + /* 20 */ 10, 10, 54, 54, 0, 164, 292, 292, 292, 292, + /* 30 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, + /* 40 */ 292, 292, 292, 292, 292, 292, 292, 292, 292, 335, + /* 50 */ 335, 335, 108, 108, 147, 10, 323, 10, 10, 10, + /* 60 */ 10, 10, 345, 45, 54, 54, 156, 156, 79, 882, + /* 70 */ 882, 882, 335, 335, 335, 417, 417, 2, 2, 2, + /* 80 */ 2, 2, 2, 24, 2, 10, 10, 10, 10, 10, + /* 90 */ 426, 10, 10, 10, 108, 108, 10, 10, 10, 10, + /* 100 */ 406, 406, 406, 406, 404, 108, 10, 10, 10, 10, + /* 110 */ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + /* 120 */ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + /* 130 */ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + /* 140 */ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + /* 150 */ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + /* 160 */ 10, 10, 560, 560, 560, 560, 504, 504, 504, 504, + /* 170 */ 560, 506, 508, 519, 517, 523, 529, 532, 534, 533, + /* 180 */ 543, 540, 554, 560, 560, 560, 607, 607, 588, 45, + /* 190 */ 45, 560, 560, 608, 614, 652, 619, 618, 658, 621, + /* 200 */ 624, 588, 79, 560, 560, 632, 632, 560, 632, 560, + /* 210 */ 632, 560, 560, 882, 882, 30, 64, 94, 94, 94, + /* 220 */ 125, 154, 214, 278, 278, 278, 278, 278, 278, 258, + /* 230 */ 279, 308, 392, 392, 392, 392, 400, 294, 318, 398, + /* 240 */ 168, 23, 23, 123, 223, 29, 411, 401, 436, 446, + /* 250 */ 498, 450, 451, 452, 493, 441, 442, 457, 458, 460, + /* 260 */ 461, 463, 474, 467, 469, 324, 548, 453, 478, 414, + /* 270 */ 419, 422, 573, 576, 547, 435, 439, 480, 444, 513, + /* 280 */ 717, 565, 718, 722, 567, 724, 725, 627, 629, 584, + /* 290 */ 611, 622, 656, 615, 657, 659, 645, 646, 661, 648, + /* 300 */ 625, 640, 747, 766, 694, 695, 697, 698, 700, 701, + /* 310 */ 686, 703, 704, 706, 789, 707, 693, 660, 748, 795, + /* 320 */ 696, 662, 708, 714, 622, 716, 684, 719, 687, 726, + /* 330 */ 713, 720, 732, 804, 721, 723, 802, 809, 810, 811, + /* 340 */ 812, 813, 814, 815, 733, 805, 741, 816, 817, 738, + /* 350 */ 740, 742, 819, 821, 709, 745, 806, 770, 818, 681, + /* 360 */ 682, 737, 737, 737, 737, 715, 727, 822, 688, 689, + /* 370 */ 737, 737, 737, 836, 837, 758, 737, 841, 842, 843, + /* 380 */ 844, 845, 846, 848, 849, 850, 851, 852, 853, 854, + /* 390 */ 855, 856, 761, 774, 857, 847, 858, 859, 800, 865, }; -#define YY_REDUCE_COUNT (213) -#define YY_REDUCE_MIN (-275) -#define YY_REDUCE_MAX (552) +#define YY_REDUCE_COUNT (214) +#define YY_REDUCE_MIN (-278) +#define YY_REDUCE_MAX (570) static const short yy_reduce_ofst[] = { - /* 0 */ -200, 52, 52, 166, 166, -214, -207, 127, 154, -208, - /* 10 */ -180, -83, -32, 75, 122, 199, 200, 202, 205, 220, - /* 20 */ 241, 243, -275, -221, -203, -187, -222, -163, -133, -40, - /* 30 */ 21, 57, 84, 92, 115, 140, 178, 182, 187, 189, - /* 40 */ 190, 195, 196, 198, 209, 211, 216, 218, -46, 111, - /* 50 */ 238, 53, 94, -23, -204, 151, -77, 262, 283, 285, - /* 60 */ 139, 292, -164, 225, 228, 297, 302, -44, 257, 17, - /* 70 */ 308, -99, -50, -13, -27, 20, 103, 130, 326, 337, - /* 80 */ 338, 339, 60, 340, 179, 206, 381, 384, 385, 316, - /* 90 */ 388, 389, 391, 342, 343, 394, 395, 396, 398, 307, - /* 100 */ 310, 319, 320, 346, 347, 402, 403, 404, 405, 406, - /* 110 */ 409, 410, 412, 413, 414, 415, 416, 417, 418, 419, - /* 120 */ 422, 423, 426, 427, 428, 429, 431, 432, 434, 435, - /* 130 */ 437, 438, 439, 440, 443, 444, 445, 447, 450, 453, - /* 140 */ 454, 456, 459, 460, 461, 462, 463, 464, 465, 466, - /* 150 */ 467, 469, 470, 472, 473, 474, 475, 476, 477, 478, - /* 160 */ 479, 480, 481, 482, 483, 336, 345, 349, 350, 484, - /* 170 */ 366, 355, 377, 393, 386, 485, 487, 486, 490, 494, - /* 180 */ 496, 491, 492, 495, 498, 500, 501, 502, 503, 506, - /* 190 */ 504, 505, 507, 511, 508, 514, 512, 516, 517, 519, - /* 200 */ 515, 520, 518, 524, 532, 534, 536, 539, 537, 541, - /* 210 */ 548, 551, 546, 552, + /* 0 */ -201, 28, 28, 176, 176, 138, 89, 178, 183, -278, + /* 10 */ -204, -118, -19, 46, 144, 201, 205, 224, 237, 242, + /* 20 */ 245, 256, -2, 53, -199, -182, -272, -242, -175, -174, + /* 30 */ -159, -114, -108, -99, -39, 34, 82, 202, 203, 204, + /* 40 */ 207, 215, 221, 222, 228, 229, 233, 234, 236, -240, + /* 50 */ 104, 105, 17, 190, -215, -205, -181, -57, 162, 188, + /* 60 */ 280, -69, 300, -56, 14, 18, 305, 306, 298, 152, + /* 70 */ 313, 320, -225, -6, 16, 60, 136, 185, 189, 344, + /* 80 */ 353, 354, 355, 316, 356, 375, 397, 399, 402, 403, + /* 90 */ 328, 405, 407, 408, 350, 351, 409, 410, 412, 413, + /* 100 */ 326, 331, 334, 336, 349, 365, 418, 420, 421, 423, + /* 110 */ 424, 425, 427, 428, 429, 430, 431, 432, 433, 434, + /* 120 */ 437, 438, 440, 443, 445, 447, 448, 449, 454, 455, + /* 130 */ 456, 459, 462, 464, 465, 466, 468, 470, 471, 472, + /* 140 */ 473, 475, 476, 477, 479, 481, 482, 483, 484, 485, + /* 150 */ 486, 487, 488, 489, 490, 491, 492, 494, 495, 496, + /* 160 */ 497, 499, 500, 501, 502, 503, 360, 361, 364, 366, + /* 170 */ 505, 352, 378, 386, 362, 390, 416, 507, 509, 415, + /* 180 */ 510, 514, 511, 512, 515, 516, 518, 520, 522, 521, + /* 190 */ 525, 524, 526, 527, 530, 528, 531, 535, 536, 537, + /* 200 */ 541, 538, 539, 542, 549, 546, 553, 555, 556, 561, + /* 210 */ 562, 564, 569, 563, 570, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 945, 1068, 1007, 1078, 994, 1004, 1246, 1246, 1246, 1246, - /* 10 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 20 */ 945, 945, 945, 945, 1132, 965, 945, 945, 945, 945, - /* 30 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 40 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 50 */ 945, 945, 945, 1156, 945, 1004, 945, 945, 945, 945, - /* 60 */ 945, 1014, 1004, 945, 945, 1014, 1014, 945, 1127, 1052, - /* 70 */ 1070, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 80 */ 945, 945, 1099, 945, 945, 945, 945, 945, 945, 1134, - /* 90 */ 1140, 1137, 945, 945, 945, 1142, 945, 945, 945, 1178, - /* 100 */ 1178, 1178, 1178, 1125, 945, 945, 945, 945, 945, 945, - /* 110 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 120 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 130 */ 945, 945, 945, 945, 945, 945, 945, 992, 945, 990, - /* 140 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 150 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 160 */ 963, 967, 967, 967, 967, 945, 945, 945, 945, 967, - /* 170 */ 1187, 1191, 1168, 1185, 1179, 1163, 1161, 1159, 1167, 1152, - /* 180 */ 1195, 1101, 967, 967, 967, 1012, 1012, 1008, 1004, 1004, - /* 190 */ 967, 967, 1030, 1028, 1026, 1018, 1024, 1020, 1022, 1016, - /* 200 */ 995, 945, 967, 967, 1002, 1002, 967, 1002, 967, 1002, - /* 210 */ 967, 967, 1052, 1070, 1245, 945, 1196, 1186, 1245, 945, - /* 220 */ 1228, 1227, 945, 1236, 1235, 1234, 1226, 1225, 1224, 945, - /* 230 */ 945, 1220, 1223, 1222, 1221, 945, 945, 1198, 945, 1230, - /* 240 */ 1229, 945, 945, 945, 945, 945, 945, 945, 1149, 945, - /* 250 */ 945, 945, 1174, 1192, 1188, 945, 945, 945, 945, 945, - /* 260 */ 945, 945, 945, 1199, 945, 945, 945, 945, 945, 945, - /* 270 */ 945, 945, 1113, 945, 945, 1080, 945, 945, 945, 945, - /* 280 */ 945, 945, 945, 945, 945, 945, 945, 945, 1124, 945, - /* 290 */ 945, 945, 945, 945, 1136, 1135, 945, 945, 945, 945, - /* 300 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 310 */ 945, 945, 945, 945, 1180, 945, 1175, 945, 1169, 945, - /* 320 */ 945, 945, 1092, 945, 945, 945, 945, 945, 945, 945, - /* 330 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 340 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 350 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 1264, - /* 360 */ 1259, 1260, 1257, 945, 945, 945, 945, 945, 1256, 1251, - /* 370 */ 1252, 945, 945, 945, 1249, 945, 945, 945, 945, 945, - /* 380 */ 945, 945, 945, 945, 945, 945, 945, 945, 945, 945, - /* 390 */ 1036, 945, 945, 974, 945, 972, 945, 945, + /* 0 */ 948, 1071, 1010, 1081, 997, 1007, 1250, 1250, 1250, 1250, + /* 10 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 20 */ 948, 948, 948, 948, 1135, 968, 948, 948, 948, 948, + /* 30 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 40 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 50 */ 948, 948, 948, 948, 1159, 948, 1007, 948, 948, 948, + /* 60 */ 948, 948, 1017, 1007, 948, 948, 1017, 1017, 948, 1130, + /* 70 */ 1055, 1073, 948, 948, 948, 948, 948, 948, 948, 948, + /* 80 */ 948, 948, 948, 1102, 948, 948, 948, 948, 948, 948, + /* 90 */ 1137, 1143, 1140, 948, 948, 948, 1145, 948, 948, 948, + /* 100 */ 1181, 1181, 1181, 1181, 1128, 948, 948, 948, 948, 948, + /* 110 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 120 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 130 */ 948, 948, 948, 948, 948, 948, 948, 948, 995, 948, + /* 140 */ 993, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 150 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 160 */ 948, 966, 970, 970, 970, 970, 948, 948, 948, 948, + /* 170 */ 970, 1190, 1194, 1171, 1188, 1182, 1166, 1164, 1162, 1170, + /* 180 */ 1155, 1198, 1104, 970, 970, 970, 1015, 1015, 1011, 1007, + /* 190 */ 1007, 970, 970, 1033, 1031, 1029, 1021, 1027, 1023, 1025, + /* 200 */ 1019, 998, 948, 970, 970, 1005, 1005, 970, 1005, 970, + /* 210 */ 1005, 970, 970, 1055, 1073, 1249, 948, 1199, 1189, 1249, + /* 220 */ 948, 1231, 1230, 1240, 1239, 1238, 1229, 1228, 1227, 948, + /* 230 */ 948, 948, 1223, 1226, 1225, 1224, 1237, 948, 948, 1201, + /* 240 */ 948, 1233, 1232, 948, 948, 948, 948, 948, 948, 948, + /* 250 */ 1152, 948, 948, 948, 1177, 1195, 1191, 948, 948, 948, + /* 260 */ 948, 948, 948, 948, 948, 1202, 948, 948, 948, 948, + /* 270 */ 948, 948, 948, 948, 1116, 948, 948, 1083, 948, 948, + /* 280 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 290 */ 1127, 948, 948, 948, 948, 948, 1139, 1138, 948, 948, + /* 300 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 310 */ 948, 948, 948, 948, 948, 948, 1183, 948, 1178, 948, + /* 320 */ 1172, 948, 948, 948, 1095, 948, 948, 948, 948, 948, + /* 330 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 340 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 350 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 360 */ 948, 1268, 1263, 1264, 1261, 948, 948, 948, 948, 948, + /* 370 */ 1260, 1255, 1256, 948, 948, 948, 1253, 948, 948, 948, + /* 380 */ 948, 948, 948, 948, 948, 948, 948, 948, 948, 948, + /* 390 */ 948, 948, 1039, 948, 948, 977, 948, 975, 948, 948, }; /********** End of lemon-generated parsing tables *****************************/ @@ -791,7 +784,6 @@ struct yyParser { int yyerrcnt; /* Shifts left before out of the error */ #endif ParseARG_SDECL /* A place to hold %extra_argument */ - ParseCTX_SDECL /* A place to hold %extra_context */ #if YYSTACKDEPTH<=0 int yystksz; /* Current side of the stack */ yyStackEntry *yystack; /* The parser's stack */ @@ -1043,92 +1035,93 @@ static const char *const yyTokenName[] = { /* 201 */ "INTO", /* 202 */ "VALUES", /* 203 */ "FILE", - /* 204 */ "program", - /* 205 */ "cmd", - /* 206 */ "ids", - /* 207 */ "dbPrefix", - /* 208 */ "cpxName", - /* 209 */ "ifexists", - /* 210 */ "alter_db_optr", - /* 211 */ "alter_topic_optr", - /* 212 */ "acct_optr", - /* 213 */ "exprlist", - /* 214 */ "ifnotexists", - /* 215 */ "db_optr", - /* 216 */ "topic_optr", - /* 217 */ "typename", - /* 218 */ "bufsize", - /* 219 */ "pps", - /* 220 */ "tseries", - /* 221 */ "dbs", - /* 222 */ "streams", - /* 223 */ "storage", - /* 224 */ "qtime", - /* 225 */ "users", - /* 226 */ "conns", - /* 227 */ "state", - /* 228 */ "intitemlist", - /* 229 */ "intitem", - /* 230 */ "keep", - /* 231 */ "cache", - /* 232 */ "replica", - /* 233 */ "quorum", - /* 234 */ "days", - /* 235 */ "minrows", - /* 236 */ "maxrows", - /* 237 */ "blocks", - /* 238 */ "ctime", - /* 239 */ "wal", - /* 240 */ "fsync", - /* 241 */ "comp", - /* 242 */ "prec", - /* 243 */ "update", - /* 244 */ "cachelast", - /* 245 */ "partitions", - /* 246 */ "signed", - /* 247 */ "create_table_args", - /* 248 */ "create_stable_args", - /* 249 */ "create_table_list", - /* 250 */ "create_from_stable", - /* 251 */ "columnlist", - /* 252 */ "tagitemlist", - /* 253 */ "tagNamelist", - /* 254 */ "to_opt", - /* 255 */ "split_opt", - /* 256 */ "select", - /* 257 */ "to_split", - /* 258 */ "column", - /* 259 */ "tagitem", - /* 260 */ "selcollist", - /* 261 */ "from", - /* 262 */ "where_opt", - /* 263 */ "range_option", - /* 264 */ "interval_option", - /* 265 */ "sliding_opt", - /* 266 */ "session_option", - /* 267 */ "windowstate_option", - /* 268 */ "fill_opt", - /* 269 */ "groupby_opt", - /* 270 */ "having_opt", - /* 271 */ "orderby_opt", - /* 272 */ "slimit_opt", - /* 273 */ "limit_opt", - /* 274 */ "union", - /* 275 */ "sclp", - /* 276 */ "distinct", - /* 277 */ "expr", - /* 278 */ "as", - /* 279 */ "tablelist", - /* 280 */ "sub", - /* 281 */ "tmvar", - /* 282 */ "timestamp", - /* 283 */ "intervalKey", - /* 284 */ "sortlist", - /* 285 */ "item", - /* 286 */ "sortorder", - /* 287 */ "arrow", - /* 288 */ "grouplist", - /* 289 */ "expritem", + /* 204 */ "error", + /* 205 */ "program", + /* 206 */ "cmd", + /* 207 */ "ids", + /* 208 */ "dbPrefix", + /* 209 */ "cpxName", + /* 210 */ "ifexists", + /* 211 */ "alter_db_optr", + /* 212 */ "alter_topic_optr", + /* 213 */ "acct_optr", + /* 214 */ "exprlist", + /* 215 */ "ifnotexists", + /* 216 */ "db_optr", + /* 217 */ "topic_optr", + /* 218 */ "typename", + /* 219 */ "bufsize", + /* 220 */ "pps", + /* 221 */ "tseries", + /* 222 */ "dbs", + /* 223 */ "streams", + /* 224 */ "storage", + /* 225 */ "qtime", + /* 226 */ "users", + /* 227 */ "conns", + /* 228 */ "state", + /* 229 */ "intitemlist", + /* 230 */ "intitem", + /* 231 */ "keep", + /* 232 */ "cache", + /* 233 */ "replica", + /* 234 */ "quorum", + /* 235 */ "days", + /* 236 */ "minrows", + /* 237 */ "maxrows", + /* 238 */ "blocks", + /* 239 */ "ctime", + /* 240 */ "wal", + /* 241 */ "fsync", + /* 242 */ "comp", + /* 243 */ "prec", + /* 244 */ "update", + /* 245 */ "cachelast", + /* 246 */ "partitions", + /* 247 */ "signed", + /* 248 */ "create_table_args", + /* 249 */ "create_stable_args", + /* 250 */ "create_table_list", + /* 251 */ "create_from_stable", + /* 252 */ "columnlist", + /* 253 */ "tagitemlist", + /* 254 */ "tagNamelist", + /* 255 */ "to_opt", + /* 256 */ "split_opt", + /* 257 */ "select", + /* 258 */ "to_split", + /* 259 */ "column", + /* 260 */ "tagitem", + /* 261 */ "selcollist", + /* 262 */ "from", + /* 263 */ "where_opt", + /* 264 */ "range_option", + /* 265 */ "interval_option", + /* 266 */ "sliding_opt", + /* 267 */ "session_option", + /* 268 */ "windowstate_option", + /* 269 */ "fill_opt", + /* 270 */ "groupby_opt", + /* 271 */ "having_opt", + /* 272 */ "orderby_opt", + /* 273 */ "slimit_opt", + /* 274 */ "limit_opt", + /* 275 */ "union", + /* 276 */ "sclp", + /* 277 */ "distinct", + /* 278 */ "expr", + /* 279 */ "as", + /* 280 */ "tablelist", + /* 281 */ "sub", + /* 282 */ "tmvar", + /* 283 */ "timestamp", + /* 284 */ "intervalKey", + /* 285 */ "sortlist", + /* 286 */ "item", + /* 287 */ "sortorder", + /* 288 */ "arrow", + /* 289 */ "grouplist", + /* 290 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1422,40 +1415,41 @@ static const char *const yyRuleName[] = { /* 283 */ "expr ::= expr STAR expr", /* 284 */ "expr ::= expr SLASH expr", /* 285 */ "expr ::= expr REM expr", - /* 286 */ "expr ::= expr LIKE expr", - /* 287 */ "expr ::= expr MATCH expr", - /* 288 */ "expr ::= expr NMATCH expr", - /* 289 */ "expr ::= ID CONTAINS STRING", - /* 290 */ "expr ::= ID DOT ID CONTAINS STRING", - /* 291 */ "arrow ::= ID ARROW STRING", - /* 292 */ "arrow ::= ID DOT ID ARROW STRING", - /* 293 */ "expr ::= arrow", - /* 294 */ "expr ::= expr IN LP exprlist RP", - /* 295 */ "exprlist ::= exprlist COMMA expritem", - /* 296 */ "exprlist ::= expritem", - /* 297 */ "expritem ::= expr", - /* 298 */ "expritem ::=", - /* 299 */ "cmd ::= RESET QUERY CACHE", - /* 300 */ "cmd ::= SYNCDB ids REPLICA", - /* 301 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", - /* 302 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", - /* 303 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", - /* 304 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", - /* 305 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", - /* 306 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", - /* 307 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", - /* 308 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", - /* 309 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", - /* 310 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", - /* 311 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", - /* 312 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", - /* 313 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", - /* 314 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", - /* 315 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", - /* 316 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", - /* 317 */ "cmd ::= KILL CONNECTION INTEGER", - /* 318 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", - /* 319 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", + /* 286 */ "expr ::= expr BITAND expr", + /* 287 */ "expr ::= expr LIKE expr", + /* 288 */ "expr ::= expr MATCH expr", + /* 289 */ "expr ::= expr NMATCH expr", + /* 290 */ "expr ::= ID CONTAINS STRING", + /* 291 */ "expr ::= ID DOT ID CONTAINS STRING", + /* 292 */ "arrow ::= ID ARROW STRING", + /* 293 */ "arrow ::= ID DOT ID ARROW STRING", + /* 294 */ "expr ::= arrow", + /* 295 */ "expr ::= expr IN LP exprlist RP", + /* 296 */ "exprlist ::= exprlist COMMA expritem", + /* 297 */ "exprlist ::= expritem", + /* 298 */ "expritem ::= expr", + /* 299 */ "expritem ::=", + /* 300 */ "cmd ::= RESET QUERY CACHE", + /* 301 */ "cmd ::= SYNCDB ids REPLICA", + /* 302 */ "cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist", + /* 303 */ "cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids", + /* 304 */ "cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist", + /* 305 */ "cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist", + /* 306 */ "cmd ::= ALTER TABLE ids cpxName DROP TAG ids", + /* 307 */ "cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids", + /* 308 */ "cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem", + /* 309 */ "cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist", + /* 310 */ "cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist", + /* 311 */ "cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids", + /* 312 */ "cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist", + /* 313 */ "cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist", + /* 314 */ "cmd ::= ALTER STABLE ids cpxName DROP TAG ids", + /* 315 */ "cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids", + /* 316 */ "cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem", + /* 317 */ "cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist", + /* 318 */ "cmd ::= KILL CONNECTION INTEGER", + /* 319 */ "cmd ::= KILL STREAM INTEGER COLON INTEGER", + /* 320 */ "cmd ::= KILL QUERY INTEGER COLON INTEGER", }; #endif /* NDEBUG */ @@ -1504,29 +1498,28 @@ static int yyGrowStack(yyParser *p){ /* Initialize a new parser that has already been allocated. */ -void ParseInit(void *yypRawParser ParseCTX_PDECL){ - yyParser *yypParser = (yyParser*)yypRawParser; - ParseCTX_STORE +void ParseInit(void *yypParser){ + yyParser *pParser = (yyParser*)yypParser; #ifdef YYTRACKMAXSTACKDEPTH - yypParser->yyhwm = 0; + pParser->yyhwm = 0; #endif #if YYSTACKDEPTH<=0 - yypParser->yytos = NULL; - yypParser->yystack = NULL; - yypParser->yystksz = 0; - if( yyGrowStack(yypParser) ){ - yypParser->yystack = &yypParser->yystk0; - yypParser->yystksz = 1; + pParser->yytos = NULL; + pParser->yystack = NULL; + pParser->yystksz = 0; + if( yyGrowStack(pParser) ){ + pParser->yystack = &pParser->yystk0; + pParser->yystksz = 1; } #endif #ifndef YYNOERRORRECOVERY - yypParser->yyerrcnt = -1; + pParser->yyerrcnt = -1; #endif - yypParser->yytos = yypParser->yystack; - yypParser->yystack[0].stateno = 0; - yypParser->yystack[0].major = 0; + pParser->yytos = pParser->yystack; + pParser->yystack[0].stateno = 0; + pParser->yystack[0].major = 0; #if YYSTACKDEPTH>0 - yypParser->yystackEnd = &yypParser->yystack[YYSTACKDEPTH-1]; + pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH-1]; #endif } @@ -1543,14 +1536,11 @@ void ParseInit(void *yypRawParser ParseCTX_PDECL){ ** A pointer to a parser. This pointer is used in subsequent calls ** to Parse and ParseFree. */ -void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE) ParseCTX_PDECL){ - yyParser *yypParser; - yypParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); - if( yypParser ){ - ParseCTX_STORE - ParseInit(yypParser ParseCTX_PARAM); - } - return (void*)yypParser; +void *ParseAlloc(void *(*mallocProc)(YYMALLOCARGTYPE)){ + yyParser *pParser; + pParser = (yyParser*)(*mallocProc)( (YYMALLOCARGTYPE)sizeof(yyParser) ); + if( pParser ) ParseInit(pParser); + return pParser; } #endif /* Parse_ENGINEALWAYSONSTACK */ @@ -1567,8 +1557,7 @@ static void yy_destructor( YYCODETYPE yymajor, /* Type code for object to destroy */ YYMINORTYPE *yypminor /* The object to be destroyed */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; switch( yymajor ){ /* Here is inserted the actions which take place when a ** terminal or non-terminal is destroyed. This can happen @@ -1581,57 +1570,57 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 213: /* exprlist */ - case 260: /* selcollist */ - case 275: /* sclp */ + case 214: /* exprlist */ + case 261: /* selcollist */ + case 276: /* sclp */ { -tSqlExprListDestroy((yypminor->yy161)); +tSqlExprListDestroy((yypminor->yy525)); } break; - case 228: /* intitemlist */ - case 230: /* keep */ - case 251: /* columnlist */ - case 252: /* tagitemlist */ - case 253: /* tagNamelist */ - case 268: /* fill_opt */ - case 269: /* groupby_opt */ - case 271: /* orderby_opt */ - case 284: /* sortlist */ - case 288: /* grouplist */ -{ -taosArrayDestroy(&(yypminor->yy161)); + case 229: /* intitemlist */ + case 231: /* keep */ + case 252: /* columnlist */ + case 253: /* tagitemlist */ + case 254: /* tagNamelist */ + case 269: /* fill_opt */ + case 270: /* groupby_opt */ + case 272: /* orderby_opt */ + case 285: /* sortlist */ + case 289: /* grouplist */ +{ +taosArrayDestroy(&(yypminor->yy525)); } break; - case 249: /* create_table_list */ + case 250: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy462)); +destroyCreateTableSql((yypminor->yy572)); } break; - case 256: /* select */ + case 257: /* select */ { -destroySqlNode((yypminor->yy276)); +destroySqlNode((yypminor->yy86)); } break; - case 261: /* from */ - case 279: /* tablelist */ - case 280: /* sub */ + case 262: /* from */ + case 280: /* tablelist */ + case 281: /* sub */ { -destroyRelationInfo((yypminor->yy84)); +destroyRelationInfo((yypminor->yy328)); } break; - case 262: /* where_opt */ - case 270: /* having_opt */ - case 277: /* expr */ - case 282: /* timestamp */ - case 287: /* arrow */ - case 289: /* expritem */ + case 263: /* where_opt */ + case 271: /* having_opt */ + case 278: /* expr */ + case 283: /* timestamp */ + case 288: /* arrow */ + case 290: /* expritem */ { -tSqlExprDestroy((yypminor->yy546)); +tSqlExprDestroy((yypminor->yy142)); } break; - case 274: /* union */ + case 275: /* union */ { -destroyAllSqlNode((yypminor->yy161)); +destroyAllSqlNode((yypminor->yy525)); } break; /********* End destructor definitions *****************************************/ @@ -1743,12 +1732,13 @@ int ParseCoverage(FILE *out){ ** Find the appropriate action for a parser given the terminal ** look-ahead token iLookAhead. */ -static YYACTIONTYPE yy_find_shift_action( - YYCODETYPE iLookAhead, /* The look-ahead token */ - YYACTIONTYPE stateno /* Current state number */ +static unsigned int yy_find_shift_action( + yyParser *pParser, /* The parser */ + YYCODETYPE iLookAhead /* The look-ahead token */ ){ int i; - + int stateno = pParser->yytos->stateno; + if( stateno>YY_MAX_SHIFT ) return stateno; assert( stateno <= YY_SHIFT_COUNT ); #if defined(YYCOVERAGE) @@ -1756,19 +1746,15 @@ static YYACTIONTYPE yy_find_shift_action( #endif do{ i = yy_shift_ofst[stateno]; - assert( i>=0 ); - assert( i<=YY_ACTTAB_COUNT ); - assert( i+YYNTOKEN<=(int)YY_NLOOKAHEAD ); + assert( i>=0 && i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) ); assert( iLookAhead!=YYNOCODE ); assert( iLookAhead < YYNTOKEN ); i += iLookAhead; - assert( i<(int)YY_NLOOKAHEAD ); if( yy_lookahead[i]!=iLookAhead ){ #ifdef YYFALLBACK YYCODETYPE iFallback; /* Fallback token */ - assert( iLookAhead %s\n", @@ -1783,8 +1769,15 @@ static YYACTIONTYPE yy_find_shift_action( #ifdef YYWILDCARD { int j = i - iLookAhead + YYWILDCARD; - assert( j<(int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])) ); - if( yy_lookahead[j]==YYWILDCARD && iLookAhead>0 ){ + if( +#if YY_SHIFT_MIN+YYWILDCARD<0 + j>=0 && +#endif +#if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT + j0 + ){ #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", @@ -1798,7 +1791,6 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && iyytos; - yytos->stateno = yyNewState; - yytos->major = yyMajor; + yytos->stateno = (YYACTIONTYPE)yyNewState; + yytos->major = (YYCODETYPE)yyMajor; yytos->minor.yy0 = yyMinor; yyTraceShift(yypParser, yyNewState, "Shift"); } -/* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side -** of that rule */ -static const YYCODETYPE yyRuleInfoLhs[] = { - 204, /* (0) program ::= cmd */ - 205, /* (1) cmd ::= SHOW DATABASES */ - 205, /* (2) cmd ::= SHOW TOPICS */ - 205, /* (3) cmd ::= SHOW FUNCTIONS */ - 205, /* (4) cmd ::= SHOW MNODES */ - 205, /* (5) cmd ::= SHOW DNODES */ - 205, /* (6) cmd ::= SHOW ACCOUNTS */ - 205, /* (7) cmd ::= SHOW USERS */ - 205, /* (8) cmd ::= SHOW MODULES */ - 205, /* (9) cmd ::= SHOW QUERIES */ - 205, /* (10) cmd ::= SHOW CONNECTIONS */ - 205, /* (11) cmd ::= SHOW STREAMS */ - 205, /* (12) cmd ::= SHOW VARIABLES */ - 205, /* (13) cmd ::= SHOW SCORES */ - 205, /* (14) cmd ::= SHOW GRANTS */ - 205, /* (15) cmd ::= SHOW VNODES */ - 205, /* (16) cmd ::= SHOW VNODES ids */ - 207, /* (17) dbPrefix ::= */ - 207, /* (18) dbPrefix ::= ids DOT */ - 208, /* (19) cpxName ::= */ - 208, /* (20) cpxName ::= DOT ids */ - 205, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ - 205, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ - 205, /* (23) cmd ::= SHOW CREATE DATABASE ids */ - 205, /* (24) cmd ::= SHOW dbPrefix TABLES */ - 205, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE STRING */ - 205, /* (26) cmd ::= SHOW dbPrefix STABLES */ - 205, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE STRING */ - 205, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ - 205, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ - 205, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ - 205, /* (31) cmd ::= DROP DATABASE ifexists ids */ - 205, /* (32) cmd ::= DROP TOPIC ifexists ids */ - 205, /* (33) cmd ::= DROP FUNCTION ids */ - 205, /* (34) cmd ::= DROP DNODE ids */ - 205, /* (35) cmd ::= DROP USER ids */ - 205, /* (36) cmd ::= DROP ACCOUNT ids */ - 205, /* (37) cmd ::= USE ids */ - 205, /* (38) cmd ::= DESCRIBE ids cpxName */ - 205, /* (39) cmd ::= DESC ids cpxName */ - 205, /* (40) cmd ::= ALTER USER ids PASS ids */ - 205, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ - 205, /* (42) cmd ::= ALTER DNODE ids ids */ - 205, /* (43) cmd ::= ALTER DNODE ids ids ids */ - 205, /* (44) cmd ::= ALTER LOCAL ids */ - 205, /* (45) cmd ::= ALTER LOCAL ids ids */ - 205, /* (46) cmd ::= ALTER DATABASE ids alter_db_optr */ - 205, /* (47) cmd ::= ALTER TOPIC ids alter_topic_optr */ - 205, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ - 205, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - 205, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ - 206, /* (51) ids ::= ID */ - 206, /* (52) ids ::= STRING */ - 209, /* (53) ifexists ::= IF EXISTS */ - 209, /* (54) ifexists ::= */ - 214, /* (55) ifnotexists ::= IF NOT EXISTS */ - 214, /* (56) ifnotexists ::= */ - 205, /* (57) cmd ::= CREATE DNODE ids */ - 205, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - 205, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - 205, /* (60) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - 205, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - 205, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - 205, /* (63) cmd ::= CREATE USER ids PASS ids */ - 218, /* (64) bufsize ::= */ - 218, /* (65) bufsize ::= BUFSIZE INTEGER */ - 219, /* (66) pps ::= */ - 219, /* (67) pps ::= PPS INTEGER */ - 220, /* (68) tseries ::= */ - 220, /* (69) tseries ::= TSERIES INTEGER */ - 221, /* (70) dbs ::= */ - 221, /* (71) dbs ::= DBS INTEGER */ - 222, /* (72) streams ::= */ - 222, /* (73) streams ::= STREAMS INTEGER */ - 223, /* (74) storage ::= */ - 223, /* (75) storage ::= STORAGE INTEGER */ - 224, /* (76) qtime ::= */ - 224, /* (77) qtime ::= QTIME INTEGER */ - 225, /* (78) users ::= */ - 225, /* (79) users ::= USERS INTEGER */ - 226, /* (80) conns ::= */ - 226, /* (81) conns ::= CONNS INTEGER */ - 227, /* (82) state ::= */ - 227, /* (83) state ::= STATE ids */ - 212, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - 228, /* (85) intitemlist ::= intitemlist COMMA intitem */ - 228, /* (86) intitemlist ::= intitem */ - 229, /* (87) intitem ::= INTEGER */ - 230, /* (88) keep ::= KEEP intitemlist */ - 231, /* (89) cache ::= CACHE INTEGER */ - 232, /* (90) replica ::= REPLICA INTEGER */ - 233, /* (91) quorum ::= QUORUM INTEGER */ - 234, /* (92) days ::= DAYS INTEGER */ - 235, /* (93) minrows ::= MINROWS INTEGER */ - 236, /* (94) maxrows ::= MAXROWS INTEGER */ - 237, /* (95) blocks ::= BLOCKS INTEGER */ - 238, /* (96) ctime ::= CTIME INTEGER */ - 239, /* (97) wal ::= WAL INTEGER */ - 240, /* (98) fsync ::= FSYNC INTEGER */ - 241, /* (99) comp ::= COMP INTEGER */ - 242, /* (100) prec ::= PRECISION STRING */ - 243, /* (101) update ::= UPDATE INTEGER */ - 244, /* (102) cachelast ::= CACHELAST INTEGER */ - 245, /* (103) partitions ::= PARTITIONS INTEGER */ - 215, /* (104) db_optr ::= */ - 215, /* (105) db_optr ::= db_optr cache */ - 215, /* (106) db_optr ::= db_optr replica */ - 215, /* (107) db_optr ::= db_optr quorum */ - 215, /* (108) db_optr ::= db_optr days */ - 215, /* (109) db_optr ::= db_optr minrows */ - 215, /* (110) db_optr ::= db_optr maxrows */ - 215, /* (111) db_optr ::= db_optr blocks */ - 215, /* (112) db_optr ::= db_optr ctime */ - 215, /* (113) db_optr ::= db_optr wal */ - 215, /* (114) db_optr ::= db_optr fsync */ - 215, /* (115) db_optr ::= db_optr comp */ - 215, /* (116) db_optr ::= db_optr prec */ - 215, /* (117) db_optr ::= db_optr keep */ - 215, /* (118) db_optr ::= db_optr update */ - 215, /* (119) db_optr ::= db_optr cachelast */ - 216, /* (120) topic_optr ::= db_optr */ - 216, /* (121) topic_optr ::= topic_optr partitions */ - 210, /* (122) alter_db_optr ::= */ - 210, /* (123) alter_db_optr ::= alter_db_optr replica */ - 210, /* (124) alter_db_optr ::= alter_db_optr quorum */ - 210, /* (125) alter_db_optr ::= alter_db_optr keep */ - 210, /* (126) alter_db_optr ::= alter_db_optr blocks */ - 210, /* (127) alter_db_optr ::= alter_db_optr comp */ - 210, /* (128) alter_db_optr ::= alter_db_optr update */ - 210, /* (129) alter_db_optr ::= alter_db_optr cachelast */ - 211, /* (130) alter_topic_optr ::= alter_db_optr */ - 211, /* (131) alter_topic_optr ::= alter_topic_optr partitions */ - 217, /* (132) typename ::= ids */ - 217, /* (133) typename ::= ids LP signed RP */ - 217, /* (134) typename ::= ids UNSIGNED */ - 246, /* (135) signed ::= INTEGER */ - 246, /* (136) signed ::= PLUS INTEGER */ - 246, /* (137) signed ::= MINUS INTEGER */ - 205, /* (138) cmd ::= CREATE TABLE create_table_args */ - 205, /* (139) cmd ::= CREATE TABLE create_stable_args */ - 205, /* (140) cmd ::= CREATE STABLE create_stable_args */ - 205, /* (141) cmd ::= CREATE TABLE create_table_list */ - 249, /* (142) create_table_list ::= create_from_stable */ - 249, /* (143) create_table_list ::= create_table_list create_from_stable */ - 247, /* (144) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - 248, /* (145) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - 250, /* (146) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - 250, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - 253, /* (148) tagNamelist ::= tagNamelist COMMA ids */ - 253, /* (149) tagNamelist ::= ids */ - 247, /* (150) create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ - 254, /* (151) to_opt ::= */ - 254, /* (152) to_opt ::= TO ids cpxName */ - 255, /* (153) split_opt ::= */ - 255, /* (154) split_opt ::= SPLIT ids */ - 251, /* (155) columnlist ::= columnlist COMMA column */ - 251, /* (156) columnlist ::= column */ - 258, /* (157) column ::= ids typename */ - 252, /* (158) tagitemlist ::= tagitemlist COMMA tagitem */ - 252, /* (159) tagitemlist ::= tagitem */ - 259, /* (160) tagitem ::= INTEGER */ - 259, /* (161) tagitem ::= FLOAT */ - 259, /* (162) tagitem ::= STRING */ - 259, /* (163) tagitem ::= BOOL */ - 259, /* (164) tagitem ::= NULL */ - 259, /* (165) tagitem ::= NOW */ - 259, /* (166) tagitem ::= NOW PLUS VARIABLE */ - 259, /* (167) tagitem ::= NOW MINUS VARIABLE */ - 259, /* (168) tagitem ::= MINUS INTEGER */ - 259, /* (169) tagitem ::= MINUS FLOAT */ - 259, /* (170) tagitem ::= PLUS INTEGER */ - 259, /* (171) tagitem ::= PLUS FLOAT */ - 256, /* (172) select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - 256, /* (173) select ::= LP select RP */ - 274, /* (174) union ::= select */ - 274, /* (175) union ::= union UNION ALL select */ - 205, /* (176) cmd ::= union */ - 256, /* (177) select ::= SELECT selcollist */ - 275, /* (178) sclp ::= selcollist COMMA */ - 275, /* (179) sclp ::= */ - 260, /* (180) selcollist ::= sclp distinct expr as */ - 260, /* (181) selcollist ::= sclp STAR */ - 278, /* (182) as ::= AS ids */ - 278, /* (183) as ::= ids */ - 278, /* (184) as ::= */ - 276, /* (185) distinct ::= DISTINCT */ - 276, /* (186) distinct ::= */ - 261, /* (187) from ::= FROM tablelist */ - 261, /* (188) from ::= FROM sub */ - 280, /* (189) sub ::= LP union RP */ - 280, /* (190) sub ::= LP union RP ids */ - 280, /* (191) sub ::= sub COMMA LP union RP ids */ - 279, /* (192) tablelist ::= ids cpxName */ - 279, /* (193) tablelist ::= ids cpxName ids */ - 279, /* (194) tablelist ::= tablelist COMMA ids cpxName */ - 279, /* (195) tablelist ::= tablelist COMMA ids cpxName ids */ - 281, /* (196) tmvar ::= VARIABLE */ - 282, /* (197) timestamp ::= INTEGER */ - 282, /* (198) timestamp ::= MINUS INTEGER */ - 282, /* (199) timestamp ::= PLUS INTEGER */ - 282, /* (200) timestamp ::= STRING */ - 282, /* (201) timestamp ::= NOW */ - 282, /* (202) timestamp ::= NOW PLUS VARIABLE */ - 282, /* (203) timestamp ::= NOW MINUS VARIABLE */ - 263, /* (204) range_option ::= */ - 263, /* (205) range_option ::= RANGE LP timestamp COMMA timestamp RP */ - 264, /* (206) interval_option ::= intervalKey LP tmvar RP */ - 264, /* (207) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - 264, /* (208) interval_option ::= */ - 283, /* (209) intervalKey ::= INTERVAL */ - 283, /* (210) intervalKey ::= EVERY */ - 266, /* (211) session_option ::= */ - 266, /* (212) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 267, /* (213) windowstate_option ::= */ - 267, /* (214) windowstate_option ::= STATE_WINDOW LP ids RP */ - 268, /* (215) fill_opt ::= */ - 268, /* (216) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - 268, /* (217) fill_opt ::= FILL LP ID RP */ - 265, /* (218) sliding_opt ::= SLIDING LP tmvar RP */ - 265, /* (219) sliding_opt ::= */ - 271, /* (220) orderby_opt ::= */ - 271, /* (221) orderby_opt ::= ORDER BY sortlist */ - 284, /* (222) sortlist ::= sortlist COMMA item sortorder */ - 284, /* (223) sortlist ::= sortlist COMMA arrow sortorder */ - 284, /* (224) sortlist ::= item sortorder */ - 284, /* (225) sortlist ::= arrow sortorder */ - 285, /* (226) item ::= ID */ - 285, /* (227) item ::= ID DOT ID */ - 286, /* (228) sortorder ::= ASC */ - 286, /* (229) sortorder ::= DESC */ - 286, /* (230) sortorder ::= */ - 269, /* (231) groupby_opt ::= */ - 269, /* (232) groupby_opt ::= GROUP BY grouplist */ - 288, /* (233) grouplist ::= grouplist COMMA item */ - 288, /* (234) grouplist ::= grouplist COMMA arrow */ - 288, /* (235) grouplist ::= item */ - 288, /* (236) grouplist ::= arrow */ - 270, /* (237) having_opt ::= */ - 270, /* (238) having_opt ::= HAVING expr */ - 273, /* (239) limit_opt ::= */ - 273, /* (240) limit_opt ::= LIMIT signed */ - 273, /* (241) limit_opt ::= LIMIT signed OFFSET signed */ - 273, /* (242) limit_opt ::= LIMIT signed COMMA signed */ - 272, /* (243) slimit_opt ::= */ - 272, /* (244) slimit_opt ::= SLIMIT signed */ - 272, /* (245) slimit_opt ::= SLIMIT signed SOFFSET signed */ - 272, /* (246) slimit_opt ::= SLIMIT signed COMMA signed */ - 262, /* (247) where_opt ::= */ - 262, /* (248) where_opt ::= WHERE expr */ - 277, /* (249) expr ::= LP expr RP */ - 277, /* (250) expr ::= ID */ - 277, /* (251) expr ::= ID DOT ID */ - 277, /* (252) expr ::= ID DOT STAR */ - 277, /* (253) expr ::= INTEGER */ - 277, /* (254) expr ::= MINUS INTEGER */ - 277, /* (255) expr ::= PLUS INTEGER */ - 277, /* (256) expr ::= FLOAT */ - 277, /* (257) expr ::= MINUS FLOAT */ - 277, /* (258) expr ::= PLUS FLOAT */ - 277, /* (259) expr ::= STRING */ - 277, /* (260) expr ::= NOW */ - 277, /* (261) expr ::= TODAY */ - 277, /* (262) expr ::= VARIABLE */ - 277, /* (263) expr ::= PLUS VARIABLE */ - 277, /* (264) expr ::= MINUS VARIABLE */ - 277, /* (265) expr ::= BOOL */ - 277, /* (266) expr ::= NULL */ - 277, /* (267) expr ::= ID LP exprlist RP */ - 277, /* (268) expr ::= ID LP STAR RP */ - 277, /* (269) expr ::= ID LP expr AS typename RP */ - 277, /* (270) expr ::= expr IS NULL */ - 277, /* (271) expr ::= expr IS NOT NULL */ - 277, /* (272) expr ::= expr LT expr */ - 277, /* (273) expr ::= expr GT expr */ - 277, /* (274) expr ::= expr LE expr */ - 277, /* (275) expr ::= expr GE expr */ - 277, /* (276) expr ::= expr NE expr */ - 277, /* (277) expr ::= expr EQ expr */ - 277, /* (278) expr ::= expr BETWEEN expr AND expr */ - 277, /* (279) expr ::= expr AND expr */ - 277, /* (280) expr ::= expr OR expr */ - 277, /* (281) expr ::= expr PLUS expr */ - 277, /* (282) expr ::= expr MINUS expr */ - 277, /* (283) expr ::= expr STAR expr */ - 277, /* (284) expr ::= expr SLASH expr */ - 277, /* (285) expr ::= expr REM expr */ - 277, /* (286) expr ::= expr LIKE expr */ - 277, /* (287) expr ::= expr MATCH expr */ - 277, /* (288) expr ::= expr NMATCH expr */ - 277, /* (289) expr ::= ID CONTAINS STRING */ - 277, /* (290) expr ::= ID DOT ID CONTAINS STRING */ - 287, /* (291) arrow ::= ID ARROW STRING */ - 287, /* (292) arrow ::= ID DOT ID ARROW STRING */ - 277, /* (293) expr ::= arrow */ - 277, /* (294) expr ::= expr IN LP exprlist RP */ - 213, /* (295) exprlist ::= exprlist COMMA expritem */ - 213, /* (296) exprlist ::= expritem */ - 289, /* (297) expritem ::= expr */ - 289, /* (298) expritem ::= */ - 205, /* (299) cmd ::= RESET QUERY CACHE */ - 205, /* (300) cmd ::= SYNCDB ids REPLICA */ - 205, /* (301) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - 205, /* (302) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - 205, /* (303) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - 205, /* (304) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - 205, /* (305) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - 205, /* (306) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - 205, /* (307) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - 205, /* (308) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - 205, /* (309) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - 205, /* (310) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - 205, /* (311) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - 205, /* (312) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - 205, /* (313) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - 205, /* (314) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - 205, /* (315) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - 205, /* (316) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - 205, /* (317) cmd ::= KILL CONNECTION INTEGER */ - 205, /* (318) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - 205, /* (319) cmd ::= KILL QUERY INTEGER COLON INTEGER */ -}; - -/* For rule J, yyRuleInfoNRhs[J] contains the negative of the number -** of symbols on the right-hand side of that rule. */ -static const signed char yyRuleInfoNRhs[] = { - -1, /* (0) program ::= cmd */ - -2, /* (1) cmd ::= SHOW DATABASES */ - -2, /* (2) cmd ::= SHOW TOPICS */ - -2, /* (3) cmd ::= SHOW FUNCTIONS */ - -2, /* (4) cmd ::= SHOW MNODES */ - -2, /* (5) cmd ::= SHOW DNODES */ - -2, /* (6) cmd ::= SHOW ACCOUNTS */ - -2, /* (7) cmd ::= SHOW USERS */ - -2, /* (8) cmd ::= SHOW MODULES */ - -2, /* (9) cmd ::= SHOW QUERIES */ - -2, /* (10) cmd ::= SHOW CONNECTIONS */ - -2, /* (11) cmd ::= SHOW STREAMS */ - -2, /* (12) cmd ::= SHOW VARIABLES */ - -2, /* (13) cmd ::= SHOW SCORES */ - -2, /* (14) cmd ::= SHOW GRANTS */ - -2, /* (15) cmd ::= SHOW VNODES */ - -3, /* (16) cmd ::= SHOW VNODES ids */ - 0, /* (17) dbPrefix ::= */ - -2, /* (18) dbPrefix ::= ids DOT */ - 0, /* (19) cpxName ::= */ - -2, /* (20) cpxName ::= DOT ids */ - -5, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ - -5, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ - -4, /* (23) cmd ::= SHOW CREATE DATABASE ids */ - -3, /* (24) cmd ::= SHOW dbPrefix TABLES */ - -5, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE STRING */ - -3, /* (26) cmd ::= SHOW dbPrefix STABLES */ - -5, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE STRING */ - -3, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ - -5, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ - -5, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ - -4, /* (31) cmd ::= DROP DATABASE ifexists ids */ - -4, /* (32) cmd ::= DROP TOPIC ifexists ids */ - -3, /* (33) cmd ::= DROP FUNCTION ids */ - -3, /* (34) cmd ::= DROP DNODE ids */ - -3, /* (35) cmd ::= DROP USER ids */ - -3, /* (36) cmd ::= DROP ACCOUNT ids */ - -2, /* (37) cmd ::= USE ids */ - -3, /* (38) cmd ::= DESCRIBE ids cpxName */ - -3, /* (39) cmd ::= DESC ids cpxName */ - -5, /* (40) cmd ::= ALTER USER ids PASS ids */ - -5, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ - -4, /* (42) cmd ::= ALTER DNODE ids ids */ - -5, /* (43) cmd ::= ALTER DNODE ids ids ids */ - -3, /* (44) cmd ::= ALTER LOCAL ids */ - -4, /* (45) cmd ::= ALTER LOCAL ids ids */ - -4, /* (46) cmd ::= ALTER DATABASE ids alter_db_optr */ - -4, /* (47) cmd ::= ALTER TOPIC ids alter_topic_optr */ - -4, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ - -6, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - -6, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ - -1, /* (51) ids ::= ID */ - -1, /* (52) ids ::= STRING */ - -2, /* (53) ifexists ::= IF EXISTS */ - 0, /* (54) ifexists ::= */ - -3, /* (55) ifnotexists ::= IF NOT EXISTS */ - 0, /* (56) ifnotexists ::= */ - -3, /* (57) cmd ::= CREATE DNODE ids */ - -6, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - -5, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - -5, /* (60) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - -8, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - -9, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ - -5, /* (63) cmd ::= CREATE USER ids PASS ids */ - 0, /* (64) bufsize ::= */ - -2, /* (65) bufsize ::= BUFSIZE INTEGER */ - 0, /* (66) pps ::= */ - -2, /* (67) pps ::= PPS INTEGER */ - 0, /* (68) tseries ::= */ - -2, /* (69) tseries ::= TSERIES INTEGER */ - 0, /* (70) dbs ::= */ - -2, /* (71) dbs ::= DBS INTEGER */ - 0, /* (72) streams ::= */ - -2, /* (73) streams ::= STREAMS INTEGER */ - 0, /* (74) storage ::= */ - -2, /* (75) storage ::= STORAGE INTEGER */ - 0, /* (76) qtime ::= */ - -2, /* (77) qtime ::= QTIME INTEGER */ - 0, /* (78) users ::= */ - -2, /* (79) users ::= USERS INTEGER */ - 0, /* (80) conns ::= */ - -2, /* (81) conns ::= CONNS INTEGER */ - 0, /* (82) state ::= */ - -2, /* (83) state ::= STATE ids */ - -9, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - -3, /* (85) intitemlist ::= intitemlist COMMA intitem */ - -1, /* (86) intitemlist ::= intitem */ - -1, /* (87) intitem ::= INTEGER */ - -2, /* (88) keep ::= KEEP intitemlist */ - -2, /* (89) cache ::= CACHE INTEGER */ - -2, /* (90) replica ::= REPLICA INTEGER */ - -2, /* (91) quorum ::= QUORUM INTEGER */ - -2, /* (92) days ::= DAYS INTEGER */ - -2, /* (93) minrows ::= MINROWS INTEGER */ - -2, /* (94) maxrows ::= MAXROWS INTEGER */ - -2, /* (95) blocks ::= BLOCKS INTEGER */ - -2, /* (96) ctime ::= CTIME INTEGER */ - -2, /* (97) wal ::= WAL INTEGER */ - -2, /* (98) fsync ::= FSYNC INTEGER */ - -2, /* (99) comp ::= COMP INTEGER */ - -2, /* (100) prec ::= PRECISION STRING */ - -2, /* (101) update ::= UPDATE INTEGER */ - -2, /* (102) cachelast ::= CACHELAST INTEGER */ - -2, /* (103) partitions ::= PARTITIONS INTEGER */ - 0, /* (104) db_optr ::= */ - -2, /* (105) db_optr ::= db_optr cache */ - -2, /* (106) db_optr ::= db_optr replica */ - -2, /* (107) db_optr ::= db_optr quorum */ - -2, /* (108) db_optr ::= db_optr days */ - -2, /* (109) db_optr ::= db_optr minrows */ - -2, /* (110) db_optr ::= db_optr maxrows */ - -2, /* (111) db_optr ::= db_optr blocks */ - -2, /* (112) db_optr ::= db_optr ctime */ - -2, /* (113) db_optr ::= db_optr wal */ - -2, /* (114) db_optr ::= db_optr fsync */ - -2, /* (115) db_optr ::= db_optr comp */ - -2, /* (116) db_optr ::= db_optr prec */ - -2, /* (117) db_optr ::= db_optr keep */ - -2, /* (118) db_optr ::= db_optr update */ - -2, /* (119) db_optr ::= db_optr cachelast */ - -1, /* (120) topic_optr ::= db_optr */ - -2, /* (121) topic_optr ::= topic_optr partitions */ - 0, /* (122) alter_db_optr ::= */ - -2, /* (123) alter_db_optr ::= alter_db_optr replica */ - -2, /* (124) alter_db_optr ::= alter_db_optr quorum */ - -2, /* (125) alter_db_optr ::= alter_db_optr keep */ - -2, /* (126) alter_db_optr ::= alter_db_optr blocks */ - -2, /* (127) alter_db_optr ::= alter_db_optr comp */ - -2, /* (128) alter_db_optr ::= alter_db_optr update */ - -2, /* (129) alter_db_optr ::= alter_db_optr cachelast */ - -1, /* (130) alter_topic_optr ::= alter_db_optr */ - -2, /* (131) alter_topic_optr ::= alter_topic_optr partitions */ - -1, /* (132) typename ::= ids */ - -4, /* (133) typename ::= ids LP signed RP */ - -2, /* (134) typename ::= ids UNSIGNED */ - -1, /* (135) signed ::= INTEGER */ - -2, /* (136) signed ::= PLUS INTEGER */ - -2, /* (137) signed ::= MINUS INTEGER */ - -3, /* (138) cmd ::= CREATE TABLE create_table_args */ - -3, /* (139) cmd ::= CREATE TABLE create_stable_args */ - -3, /* (140) cmd ::= CREATE STABLE create_stable_args */ - -3, /* (141) cmd ::= CREATE TABLE create_table_list */ - -1, /* (142) create_table_list ::= create_from_stable */ - -2, /* (143) create_table_list ::= create_table_list create_from_stable */ - -6, /* (144) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - -10, /* (145) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - -10, /* (146) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - -13, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - -3, /* (148) tagNamelist ::= tagNamelist COMMA ids */ - -1, /* (149) tagNamelist ::= ids */ - -7, /* (150) create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ - 0, /* (151) to_opt ::= */ - -3, /* (152) to_opt ::= TO ids cpxName */ - 0, /* (153) split_opt ::= */ - -2, /* (154) split_opt ::= SPLIT ids */ - -3, /* (155) columnlist ::= columnlist COMMA column */ - -1, /* (156) columnlist ::= column */ - -2, /* (157) column ::= ids typename */ - -3, /* (158) tagitemlist ::= tagitemlist COMMA tagitem */ - -1, /* (159) tagitemlist ::= tagitem */ - -1, /* (160) tagitem ::= INTEGER */ - -1, /* (161) tagitem ::= FLOAT */ - -1, /* (162) tagitem ::= STRING */ - -1, /* (163) tagitem ::= BOOL */ - -1, /* (164) tagitem ::= NULL */ - -1, /* (165) tagitem ::= NOW */ - -3, /* (166) tagitem ::= NOW PLUS VARIABLE */ - -3, /* (167) tagitem ::= NOW MINUS VARIABLE */ - -2, /* (168) tagitem ::= MINUS INTEGER */ - -2, /* (169) tagitem ::= MINUS FLOAT */ - -2, /* (170) tagitem ::= PLUS INTEGER */ - -2, /* (171) tagitem ::= PLUS FLOAT */ - -15, /* (172) select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ - -3, /* (173) select ::= LP select RP */ - -1, /* (174) union ::= select */ - -4, /* (175) union ::= union UNION ALL select */ - -1, /* (176) cmd ::= union */ - -2, /* (177) select ::= SELECT selcollist */ - -2, /* (178) sclp ::= selcollist COMMA */ - 0, /* (179) sclp ::= */ - -4, /* (180) selcollist ::= sclp distinct expr as */ - -2, /* (181) selcollist ::= sclp STAR */ - -2, /* (182) as ::= AS ids */ - -1, /* (183) as ::= ids */ - 0, /* (184) as ::= */ - -1, /* (185) distinct ::= DISTINCT */ - 0, /* (186) distinct ::= */ - -2, /* (187) from ::= FROM tablelist */ - -2, /* (188) from ::= FROM sub */ - -3, /* (189) sub ::= LP union RP */ - -4, /* (190) sub ::= LP union RP ids */ - -6, /* (191) sub ::= sub COMMA LP union RP ids */ - -2, /* (192) tablelist ::= ids cpxName */ - -3, /* (193) tablelist ::= ids cpxName ids */ - -4, /* (194) tablelist ::= tablelist COMMA ids cpxName */ - -5, /* (195) tablelist ::= tablelist COMMA ids cpxName ids */ - -1, /* (196) tmvar ::= VARIABLE */ - -1, /* (197) timestamp ::= INTEGER */ - -2, /* (198) timestamp ::= MINUS INTEGER */ - -2, /* (199) timestamp ::= PLUS INTEGER */ - -1, /* (200) timestamp ::= STRING */ - -1, /* (201) timestamp ::= NOW */ - -3, /* (202) timestamp ::= NOW PLUS VARIABLE */ - -3, /* (203) timestamp ::= NOW MINUS VARIABLE */ - 0, /* (204) range_option ::= */ - -6, /* (205) range_option ::= RANGE LP timestamp COMMA timestamp RP */ - -4, /* (206) interval_option ::= intervalKey LP tmvar RP */ - -6, /* (207) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ - 0, /* (208) interval_option ::= */ - -1, /* (209) intervalKey ::= INTERVAL */ - -1, /* (210) intervalKey ::= EVERY */ - 0, /* (211) session_option ::= */ - -7, /* (212) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - 0, /* (213) windowstate_option ::= */ - -4, /* (214) windowstate_option ::= STATE_WINDOW LP ids RP */ - 0, /* (215) fill_opt ::= */ - -6, /* (216) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - -4, /* (217) fill_opt ::= FILL LP ID RP */ - -4, /* (218) sliding_opt ::= SLIDING LP tmvar RP */ - 0, /* (219) sliding_opt ::= */ - 0, /* (220) orderby_opt ::= */ - -3, /* (221) orderby_opt ::= ORDER BY sortlist */ - -4, /* (222) sortlist ::= sortlist COMMA item sortorder */ - -4, /* (223) sortlist ::= sortlist COMMA arrow sortorder */ - -2, /* (224) sortlist ::= item sortorder */ - -2, /* (225) sortlist ::= arrow sortorder */ - -1, /* (226) item ::= ID */ - -3, /* (227) item ::= ID DOT ID */ - -1, /* (228) sortorder ::= ASC */ - -1, /* (229) sortorder ::= DESC */ - 0, /* (230) sortorder ::= */ - 0, /* (231) groupby_opt ::= */ - -3, /* (232) groupby_opt ::= GROUP BY grouplist */ - -3, /* (233) grouplist ::= grouplist COMMA item */ - -3, /* (234) grouplist ::= grouplist COMMA arrow */ - -1, /* (235) grouplist ::= item */ - -1, /* (236) grouplist ::= arrow */ - 0, /* (237) having_opt ::= */ - -2, /* (238) having_opt ::= HAVING expr */ - 0, /* (239) limit_opt ::= */ - -2, /* (240) limit_opt ::= LIMIT signed */ - -4, /* (241) limit_opt ::= LIMIT signed OFFSET signed */ - -4, /* (242) limit_opt ::= LIMIT signed COMMA signed */ - 0, /* (243) slimit_opt ::= */ - -2, /* (244) slimit_opt ::= SLIMIT signed */ - -4, /* (245) slimit_opt ::= SLIMIT signed SOFFSET signed */ - -4, /* (246) slimit_opt ::= SLIMIT signed COMMA signed */ - 0, /* (247) where_opt ::= */ - -2, /* (248) where_opt ::= WHERE expr */ - -3, /* (249) expr ::= LP expr RP */ - -1, /* (250) expr ::= ID */ - -3, /* (251) expr ::= ID DOT ID */ - -3, /* (252) expr ::= ID DOT STAR */ - -1, /* (253) expr ::= INTEGER */ - -2, /* (254) expr ::= MINUS INTEGER */ - -2, /* (255) expr ::= PLUS INTEGER */ - -1, /* (256) expr ::= FLOAT */ - -2, /* (257) expr ::= MINUS FLOAT */ - -2, /* (258) expr ::= PLUS FLOAT */ - -1, /* (259) expr ::= STRING */ - -1, /* (260) expr ::= NOW */ - -1, /* (261) expr ::= TODAY */ - -1, /* (262) expr ::= VARIABLE */ - -2, /* (263) expr ::= PLUS VARIABLE */ - -2, /* (264) expr ::= MINUS VARIABLE */ - -1, /* (265) expr ::= BOOL */ - -1, /* (266) expr ::= NULL */ - -4, /* (267) expr ::= ID LP exprlist RP */ - -4, /* (268) expr ::= ID LP STAR RP */ - -6, /* (269) expr ::= ID LP expr AS typename RP */ - -3, /* (270) expr ::= expr IS NULL */ - -4, /* (271) expr ::= expr IS NOT NULL */ - -3, /* (272) expr ::= expr LT expr */ - -3, /* (273) expr ::= expr GT expr */ - -3, /* (274) expr ::= expr LE expr */ - -3, /* (275) expr ::= expr GE expr */ - -3, /* (276) expr ::= expr NE expr */ - -3, /* (277) expr ::= expr EQ expr */ - -5, /* (278) expr ::= expr BETWEEN expr AND expr */ - -3, /* (279) expr ::= expr AND expr */ - -3, /* (280) expr ::= expr OR expr */ - -3, /* (281) expr ::= expr PLUS expr */ - -3, /* (282) expr ::= expr MINUS expr */ - -3, /* (283) expr ::= expr STAR expr */ - -3, /* (284) expr ::= expr SLASH expr */ - -3, /* (285) expr ::= expr REM expr */ - -3, /* (286) expr ::= expr LIKE expr */ - -3, /* (287) expr ::= expr MATCH expr */ - -3, /* (288) expr ::= expr NMATCH expr */ - -3, /* (289) expr ::= ID CONTAINS STRING */ - -5, /* (290) expr ::= ID DOT ID CONTAINS STRING */ - -3, /* (291) arrow ::= ID ARROW STRING */ - -5, /* (292) arrow ::= ID DOT ID ARROW STRING */ - -1, /* (293) expr ::= arrow */ - -5, /* (294) expr ::= expr IN LP exprlist RP */ - -3, /* (295) exprlist ::= exprlist COMMA expritem */ - -1, /* (296) exprlist ::= expritem */ - -1, /* (297) expritem ::= expr */ - 0, /* (298) expritem ::= */ - -3, /* (299) cmd ::= RESET QUERY CACHE */ - -3, /* (300) cmd ::= SYNCDB ids REPLICA */ - -7, /* (301) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (302) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - -7, /* (303) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (304) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - -7, /* (305) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - -8, /* (306) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (307) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (308) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ - -7, /* (309) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - -7, /* (310) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - -7, /* (311) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ - -7, /* (312) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - -7, /* (313) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - -8, /* (314) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - -9, /* (315) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ - -7, /* (316) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ - -3, /* (317) cmd ::= KILL CONNECTION INTEGER */ - -5, /* (318) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - -5, /* (319) cmd ::= KILL QUERY INTEGER COLON INTEGER */ +/* The following table contains information about every rule that +** is used during the reduce. +*/ +static const struct { + YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + signed char nrhs; /* Negative of the number of RHS symbols in the rule */ +} yyRuleInfo[] = { + { 205, -1 }, /* (0) program ::= cmd */ + { 206, -2 }, /* (1) cmd ::= SHOW DATABASES */ + { 206, -2 }, /* (2) cmd ::= SHOW TOPICS */ + { 206, -2 }, /* (3) cmd ::= SHOW FUNCTIONS */ + { 206, -2 }, /* (4) cmd ::= SHOW MNODES */ + { 206, -2 }, /* (5) cmd ::= SHOW DNODES */ + { 206, -2 }, /* (6) cmd ::= SHOW ACCOUNTS */ + { 206, -2 }, /* (7) cmd ::= SHOW USERS */ + { 206, -2 }, /* (8) cmd ::= SHOW MODULES */ + { 206, -2 }, /* (9) cmd ::= SHOW QUERIES */ + { 206, -2 }, /* (10) cmd ::= SHOW CONNECTIONS */ + { 206, -2 }, /* (11) cmd ::= SHOW STREAMS */ + { 206, -2 }, /* (12) cmd ::= SHOW VARIABLES */ + { 206, -2 }, /* (13) cmd ::= SHOW SCORES */ + { 206, -2 }, /* (14) cmd ::= SHOW GRANTS */ + { 206, -2 }, /* (15) cmd ::= SHOW VNODES */ + { 206, -3 }, /* (16) cmd ::= SHOW VNODES ids */ + { 208, 0 }, /* (17) dbPrefix ::= */ + { 208, -2 }, /* (18) dbPrefix ::= ids DOT */ + { 209, 0 }, /* (19) cpxName ::= */ + { 209, -2 }, /* (20) cpxName ::= DOT ids */ + { 206, -5 }, /* (21) cmd ::= SHOW CREATE TABLE ids cpxName */ + { 206, -5 }, /* (22) cmd ::= SHOW CREATE STABLE ids cpxName */ + { 206, -4 }, /* (23) cmd ::= SHOW CREATE DATABASE ids */ + { 206, -3 }, /* (24) cmd ::= SHOW dbPrefix TABLES */ + { 206, -5 }, /* (25) cmd ::= SHOW dbPrefix TABLES LIKE STRING */ + { 206, -3 }, /* (26) cmd ::= SHOW dbPrefix STABLES */ + { 206, -5 }, /* (27) cmd ::= SHOW dbPrefix STABLES LIKE STRING */ + { 206, -3 }, /* (28) cmd ::= SHOW dbPrefix VGROUPS */ + { 206, -5 }, /* (29) cmd ::= DROP TABLE ifexists ids cpxName */ + { 206, -5 }, /* (30) cmd ::= DROP STABLE ifexists ids cpxName */ + { 206, -4 }, /* (31) cmd ::= DROP DATABASE ifexists ids */ + { 206, -4 }, /* (32) cmd ::= DROP TOPIC ifexists ids */ + { 206, -3 }, /* (33) cmd ::= DROP FUNCTION ids */ + { 206, -3 }, /* (34) cmd ::= DROP DNODE ids */ + { 206, -3 }, /* (35) cmd ::= DROP USER ids */ + { 206, -3 }, /* (36) cmd ::= DROP ACCOUNT ids */ + { 206, -2 }, /* (37) cmd ::= USE ids */ + { 206, -3 }, /* (38) cmd ::= DESCRIBE ids cpxName */ + { 206, -3 }, /* (39) cmd ::= DESC ids cpxName */ + { 206, -5 }, /* (40) cmd ::= ALTER USER ids PASS ids */ + { 206, -5 }, /* (41) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 206, -4 }, /* (42) cmd ::= ALTER DNODE ids ids */ + { 206, -5 }, /* (43) cmd ::= ALTER DNODE ids ids ids */ + { 206, -3 }, /* (44) cmd ::= ALTER LOCAL ids */ + { 206, -4 }, /* (45) cmd ::= ALTER LOCAL ids ids */ + { 206, -4 }, /* (46) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 206, -4 }, /* (47) cmd ::= ALTER TOPIC ids alter_topic_optr */ + { 206, -4 }, /* (48) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 206, -6 }, /* (49) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 206, -6 }, /* (50) cmd ::= COMPACT VNODES IN LP exprlist RP */ + { 207, -1 }, /* (51) ids ::= ID */ + { 207, -1 }, /* (52) ids ::= STRING */ + { 210, -2 }, /* (53) ifexists ::= IF EXISTS */ + { 210, 0 }, /* (54) ifexists ::= */ + { 215, -3 }, /* (55) ifnotexists ::= IF NOT EXISTS */ + { 215, 0 }, /* (56) ifnotexists ::= */ + { 206, -3 }, /* (57) cmd ::= CREATE DNODE ids */ + { 206, -6 }, /* (58) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 206, -5 }, /* (59) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 206, -5 }, /* (60) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ + { 206, -8 }, /* (61) cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + { 206, -9 }, /* (62) cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ + { 206, -5 }, /* (63) cmd ::= CREATE USER ids PASS ids */ + { 219, 0 }, /* (64) bufsize ::= */ + { 219, -2 }, /* (65) bufsize ::= BUFSIZE INTEGER */ + { 220, 0 }, /* (66) pps ::= */ + { 220, -2 }, /* (67) pps ::= PPS INTEGER */ + { 221, 0 }, /* (68) tseries ::= */ + { 221, -2 }, /* (69) tseries ::= TSERIES INTEGER */ + { 222, 0 }, /* (70) dbs ::= */ + { 222, -2 }, /* (71) dbs ::= DBS INTEGER */ + { 223, 0 }, /* (72) streams ::= */ + { 223, -2 }, /* (73) streams ::= STREAMS INTEGER */ + { 224, 0 }, /* (74) storage ::= */ + { 224, -2 }, /* (75) storage ::= STORAGE INTEGER */ + { 225, 0 }, /* (76) qtime ::= */ + { 225, -2 }, /* (77) qtime ::= QTIME INTEGER */ + { 226, 0 }, /* (78) users ::= */ + { 226, -2 }, /* (79) users ::= USERS INTEGER */ + { 227, 0 }, /* (80) conns ::= */ + { 227, -2 }, /* (81) conns ::= CONNS INTEGER */ + { 228, 0 }, /* (82) state ::= */ + { 228, -2 }, /* (83) state ::= STATE ids */ + { 213, -9 }, /* (84) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 229, -3 }, /* (85) intitemlist ::= intitemlist COMMA intitem */ + { 229, -1 }, /* (86) intitemlist ::= intitem */ + { 230, -1 }, /* (87) intitem ::= INTEGER */ + { 231, -2 }, /* (88) keep ::= KEEP intitemlist */ + { 232, -2 }, /* (89) cache ::= CACHE INTEGER */ + { 233, -2 }, /* (90) replica ::= REPLICA INTEGER */ + { 234, -2 }, /* (91) quorum ::= QUORUM INTEGER */ + { 235, -2 }, /* (92) days ::= DAYS INTEGER */ + { 236, -2 }, /* (93) minrows ::= MINROWS INTEGER */ + { 237, -2 }, /* (94) maxrows ::= MAXROWS INTEGER */ + { 238, -2 }, /* (95) blocks ::= BLOCKS INTEGER */ + { 239, -2 }, /* (96) ctime ::= CTIME INTEGER */ + { 240, -2 }, /* (97) wal ::= WAL INTEGER */ + { 241, -2 }, /* (98) fsync ::= FSYNC INTEGER */ + { 242, -2 }, /* (99) comp ::= COMP INTEGER */ + { 243, -2 }, /* (100) prec ::= PRECISION STRING */ + { 244, -2 }, /* (101) update ::= UPDATE INTEGER */ + { 245, -2 }, /* (102) cachelast ::= CACHELAST INTEGER */ + { 246, -2 }, /* (103) partitions ::= PARTITIONS INTEGER */ + { 216, 0 }, /* (104) db_optr ::= */ + { 216, -2 }, /* (105) db_optr ::= db_optr cache */ + { 216, -2 }, /* (106) db_optr ::= db_optr replica */ + { 216, -2 }, /* (107) db_optr ::= db_optr quorum */ + { 216, -2 }, /* (108) db_optr ::= db_optr days */ + { 216, -2 }, /* (109) db_optr ::= db_optr minrows */ + { 216, -2 }, /* (110) db_optr ::= db_optr maxrows */ + { 216, -2 }, /* (111) db_optr ::= db_optr blocks */ + { 216, -2 }, /* (112) db_optr ::= db_optr ctime */ + { 216, -2 }, /* (113) db_optr ::= db_optr wal */ + { 216, -2 }, /* (114) db_optr ::= db_optr fsync */ + { 216, -2 }, /* (115) db_optr ::= db_optr comp */ + { 216, -2 }, /* (116) db_optr ::= db_optr prec */ + { 216, -2 }, /* (117) db_optr ::= db_optr keep */ + { 216, -2 }, /* (118) db_optr ::= db_optr update */ + { 216, -2 }, /* (119) db_optr ::= db_optr cachelast */ + { 217, -1 }, /* (120) topic_optr ::= db_optr */ + { 217, -2 }, /* (121) topic_optr ::= topic_optr partitions */ + { 211, 0 }, /* (122) alter_db_optr ::= */ + { 211, -2 }, /* (123) alter_db_optr ::= alter_db_optr replica */ + { 211, -2 }, /* (124) alter_db_optr ::= alter_db_optr quorum */ + { 211, -2 }, /* (125) alter_db_optr ::= alter_db_optr keep */ + { 211, -2 }, /* (126) alter_db_optr ::= alter_db_optr blocks */ + { 211, -2 }, /* (127) alter_db_optr ::= alter_db_optr comp */ + { 211, -2 }, /* (128) alter_db_optr ::= alter_db_optr update */ + { 211, -2 }, /* (129) alter_db_optr ::= alter_db_optr cachelast */ + { 212, -1 }, /* (130) alter_topic_optr ::= alter_db_optr */ + { 212, -2 }, /* (131) alter_topic_optr ::= alter_topic_optr partitions */ + { 218, -1 }, /* (132) typename ::= ids */ + { 218, -4 }, /* (133) typename ::= ids LP signed RP */ + { 218, -2 }, /* (134) typename ::= ids UNSIGNED */ + { 247, -1 }, /* (135) signed ::= INTEGER */ + { 247, -2 }, /* (136) signed ::= PLUS INTEGER */ + { 247, -2 }, /* (137) signed ::= MINUS INTEGER */ + { 206, -3 }, /* (138) cmd ::= CREATE TABLE create_table_args */ + { 206, -3 }, /* (139) cmd ::= CREATE TABLE create_stable_args */ + { 206, -3 }, /* (140) cmd ::= CREATE STABLE create_stable_args */ + { 206, -3 }, /* (141) cmd ::= CREATE TABLE create_table_list */ + { 250, -1 }, /* (142) create_table_list ::= create_from_stable */ + { 250, -2 }, /* (143) create_table_list ::= create_table_list create_from_stable */ + { 248, -6 }, /* (144) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 249, -10 }, /* (145) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 251, -10 }, /* (146) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 251, -13 }, /* (147) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + { 254, -3 }, /* (148) tagNamelist ::= tagNamelist COMMA ids */ + { 254, -1 }, /* (149) tagNamelist ::= ids */ + { 248, -7 }, /* (150) create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ + { 255, 0 }, /* (151) to_opt ::= */ + { 255, -3 }, /* (152) to_opt ::= TO ids cpxName */ + { 256, 0 }, /* (153) split_opt ::= */ + { 256, -2 }, /* (154) split_opt ::= SPLIT ids */ + { 252, -3 }, /* (155) columnlist ::= columnlist COMMA column */ + { 252, -1 }, /* (156) columnlist ::= column */ + { 259, -2 }, /* (157) column ::= ids typename */ + { 253, -3 }, /* (158) tagitemlist ::= tagitemlist COMMA tagitem */ + { 253, -1 }, /* (159) tagitemlist ::= tagitem */ + { 260, -1 }, /* (160) tagitem ::= INTEGER */ + { 260, -1 }, /* (161) tagitem ::= FLOAT */ + { 260, -1 }, /* (162) tagitem ::= STRING */ + { 260, -1 }, /* (163) tagitem ::= BOOL */ + { 260, -1 }, /* (164) tagitem ::= NULL */ + { 260, -1 }, /* (165) tagitem ::= NOW */ + { 260, -3 }, /* (166) tagitem ::= NOW PLUS VARIABLE */ + { 260, -3 }, /* (167) tagitem ::= NOW MINUS VARIABLE */ + { 260, -2 }, /* (168) tagitem ::= MINUS INTEGER */ + { 260, -2 }, /* (169) tagitem ::= MINUS FLOAT */ + { 260, -2 }, /* (170) tagitem ::= PLUS INTEGER */ + { 260, -2 }, /* (171) tagitem ::= PLUS FLOAT */ + { 257, -15 }, /* (172) select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ + { 257, -3 }, /* (173) select ::= LP select RP */ + { 275, -1 }, /* (174) union ::= select */ + { 275, -4 }, /* (175) union ::= union UNION ALL select */ + { 206, -1 }, /* (176) cmd ::= union */ + { 257, -2 }, /* (177) select ::= SELECT selcollist */ + { 276, -2 }, /* (178) sclp ::= selcollist COMMA */ + { 276, 0 }, /* (179) sclp ::= */ + { 261, -4 }, /* (180) selcollist ::= sclp distinct expr as */ + { 261, -2 }, /* (181) selcollist ::= sclp STAR */ + { 279, -2 }, /* (182) as ::= AS ids */ + { 279, -1 }, /* (183) as ::= ids */ + { 279, 0 }, /* (184) as ::= */ + { 277, -1 }, /* (185) distinct ::= DISTINCT */ + { 277, 0 }, /* (186) distinct ::= */ + { 262, -2 }, /* (187) from ::= FROM tablelist */ + { 262, -2 }, /* (188) from ::= FROM sub */ + { 281, -3 }, /* (189) sub ::= LP union RP */ + { 281, -4 }, /* (190) sub ::= LP union RP ids */ + { 281, -6 }, /* (191) sub ::= sub COMMA LP union RP ids */ + { 280, -2 }, /* (192) tablelist ::= ids cpxName */ + { 280, -3 }, /* (193) tablelist ::= ids cpxName ids */ + { 280, -4 }, /* (194) tablelist ::= tablelist COMMA ids cpxName */ + { 280, -5 }, /* (195) tablelist ::= tablelist COMMA ids cpxName ids */ + { 282, -1 }, /* (196) tmvar ::= VARIABLE */ + { 283, -1 }, /* (197) timestamp ::= INTEGER */ + { 283, -2 }, /* (198) timestamp ::= MINUS INTEGER */ + { 283, -2 }, /* (199) timestamp ::= PLUS INTEGER */ + { 283, -1 }, /* (200) timestamp ::= STRING */ + { 283, -1 }, /* (201) timestamp ::= NOW */ + { 283, -3 }, /* (202) timestamp ::= NOW PLUS VARIABLE */ + { 283, -3 }, /* (203) timestamp ::= NOW MINUS VARIABLE */ + { 264, 0 }, /* (204) range_option ::= */ + { 264, -6 }, /* (205) range_option ::= RANGE LP timestamp COMMA timestamp RP */ + { 265, -4 }, /* (206) interval_option ::= intervalKey LP tmvar RP */ + { 265, -6 }, /* (207) interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ + { 265, 0 }, /* (208) interval_option ::= */ + { 284, -1 }, /* (209) intervalKey ::= INTERVAL */ + { 284, -1 }, /* (210) intervalKey ::= EVERY */ + { 267, 0 }, /* (211) session_option ::= */ + { 267, -7 }, /* (212) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 268, 0 }, /* (213) windowstate_option ::= */ + { 268, -4 }, /* (214) windowstate_option ::= STATE_WINDOW LP ids RP */ + { 269, 0 }, /* (215) fill_opt ::= */ + { 269, -6 }, /* (216) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 269, -4 }, /* (217) fill_opt ::= FILL LP ID RP */ + { 266, -4 }, /* (218) sliding_opt ::= SLIDING LP tmvar RP */ + { 266, 0 }, /* (219) sliding_opt ::= */ + { 272, 0 }, /* (220) orderby_opt ::= */ + { 272, -3 }, /* (221) orderby_opt ::= ORDER BY sortlist */ + { 285, -4 }, /* (222) sortlist ::= sortlist COMMA item sortorder */ + { 285, -4 }, /* (223) sortlist ::= sortlist COMMA arrow sortorder */ + { 285, -2 }, /* (224) sortlist ::= item sortorder */ + { 285, -2 }, /* (225) sortlist ::= arrow sortorder */ + { 286, -1 }, /* (226) item ::= ID */ + { 286, -3 }, /* (227) item ::= ID DOT ID */ + { 287, -1 }, /* (228) sortorder ::= ASC */ + { 287, -1 }, /* (229) sortorder ::= DESC */ + { 287, 0 }, /* (230) sortorder ::= */ + { 270, 0 }, /* (231) groupby_opt ::= */ + { 270, -3 }, /* (232) groupby_opt ::= GROUP BY grouplist */ + { 289, -3 }, /* (233) grouplist ::= grouplist COMMA item */ + { 289, -3 }, /* (234) grouplist ::= grouplist COMMA arrow */ + { 289, -1 }, /* (235) grouplist ::= item */ + { 289, -1 }, /* (236) grouplist ::= arrow */ + { 271, 0 }, /* (237) having_opt ::= */ + { 271, -2 }, /* (238) having_opt ::= HAVING expr */ + { 274, 0 }, /* (239) limit_opt ::= */ + { 274, -2 }, /* (240) limit_opt ::= LIMIT signed */ + { 274, -4 }, /* (241) limit_opt ::= LIMIT signed OFFSET signed */ + { 274, -4 }, /* (242) limit_opt ::= LIMIT signed COMMA signed */ + { 273, 0 }, /* (243) slimit_opt ::= */ + { 273, -2 }, /* (244) slimit_opt ::= SLIMIT signed */ + { 273, -4 }, /* (245) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 273, -4 }, /* (246) slimit_opt ::= SLIMIT signed COMMA signed */ + { 263, 0 }, /* (247) where_opt ::= */ + { 263, -2 }, /* (248) where_opt ::= WHERE expr */ + { 278, -3 }, /* (249) expr ::= LP expr RP */ + { 278, -1 }, /* (250) expr ::= ID */ + { 278, -3 }, /* (251) expr ::= ID DOT ID */ + { 278, -3 }, /* (252) expr ::= ID DOT STAR */ + { 278, -1 }, /* (253) expr ::= INTEGER */ + { 278, -2 }, /* (254) expr ::= MINUS INTEGER */ + { 278, -2 }, /* (255) expr ::= PLUS INTEGER */ + { 278, -1 }, /* (256) expr ::= FLOAT */ + { 278, -2 }, /* (257) expr ::= MINUS FLOAT */ + { 278, -2 }, /* (258) expr ::= PLUS FLOAT */ + { 278, -1 }, /* (259) expr ::= STRING */ + { 278, -1 }, /* (260) expr ::= NOW */ + { 278, -1 }, /* (261) expr ::= TODAY */ + { 278, -1 }, /* (262) expr ::= VARIABLE */ + { 278, -2 }, /* (263) expr ::= PLUS VARIABLE */ + { 278, -2 }, /* (264) expr ::= MINUS VARIABLE */ + { 278, -1 }, /* (265) expr ::= BOOL */ + { 278, -1 }, /* (266) expr ::= NULL */ + { 278, -4 }, /* (267) expr ::= ID LP exprlist RP */ + { 278, -4 }, /* (268) expr ::= ID LP STAR RP */ + { 278, -6 }, /* (269) expr ::= ID LP expr AS typename RP */ + { 278, -3 }, /* (270) expr ::= expr IS NULL */ + { 278, -4 }, /* (271) expr ::= expr IS NOT NULL */ + { 278, -3 }, /* (272) expr ::= expr LT expr */ + { 278, -3 }, /* (273) expr ::= expr GT expr */ + { 278, -3 }, /* (274) expr ::= expr LE expr */ + { 278, -3 }, /* (275) expr ::= expr GE expr */ + { 278, -3 }, /* (276) expr ::= expr NE expr */ + { 278, -3 }, /* (277) expr ::= expr EQ expr */ + { 278, -5 }, /* (278) expr ::= expr BETWEEN expr AND expr */ + { 278, -3 }, /* (279) expr ::= expr AND expr */ + { 278, -3 }, /* (280) expr ::= expr OR expr */ + { 278, -3 }, /* (281) expr ::= expr PLUS expr */ + { 278, -3 }, /* (282) expr ::= expr MINUS expr */ + { 278, -3 }, /* (283) expr ::= expr STAR expr */ + { 278, -3 }, /* (284) expr ::= expr SLASH expr */ + { 278, -3 }, /* (285) expr ::= expr REM expr */ + { 278, -3 }, /* (286) expr ::= expr BITAND expr */ + { 278, -3 }, /* (287) expr ::= expr LIKE expr */ + { 278, -3 }, /* (288) expr ::= expr MATCH expr */ + { 278, -3 }, /* (289) expr ::= expr NMATCH expr */ + { 278, -3 }, /* (290) expr ::= ID CONTAINS STRING */ + { 278, -5 }, /* (291) expr ::= ID DOT ID CONTAINS STRING */ + { 288, -3 }, /* (292) arrow ::= ID ARROW STRING */ + { 288, -5 }, /* (293) arrow ::= ID DOT ID ARROW STRING */ + { 278, -1 }, /* (294) expr ::= arrow */ + { 278, -5 }, /* (295) expr ::= expr IN LP exprlist RP */ + { 214, -3 }, /* (296) exprlist ::= exprlist COMMA expritem */ + { 214, -1 }, /* (297) exprlist ::= expritem */ + { 290, -1 }, /* (298) expritem ::= expr */ + { 290, 0 }, /* (299) expritem ::= */ + { 206, -3 }, /* (300) cmd ::= RESET QUERY CACHE */ + { 206, -3 }, /* (301) cmd ::= SYNCDB ids REPLICA */ + { 206, -7 }, /* (302) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 206, -7 }, /* (303) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 206, -7 }, /* (304) cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + { 206, -7 }, /* (305) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 206, -7 }, /* (306) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 206, -8 }, /* (307) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 206, -9 }, /* (308) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 206, -7 }, /* (309) cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + { 206, -7 }, /* (310) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 206, -7 }, /* (311) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 206, -7 }, /* (312) cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + { 206, -7 }, /* (313) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 206, -7 }, /* (314) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 206, -8 }, /* (315) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 206, -9 }, /* (316) cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + { 206, -7 }, /* (317) cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + { 206, -3 }, /* (318) cmd ::= KILL CONNECTION INTEGER */ + { 206, -5 }, /* (319) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 206, -5 }, /* (320) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2579,34 +2249,30 @@ static void yy_accept(yyParser*); /* Forward Declaration */ ** only called from one place, optimizing compilers will in-line it, which ** means that the extra parameters have no performance impact. */ -static YYACTIONTYPE yy_reduce( +static void yy_reduce( yyParser *yypParser, /* The parser */ unsigned int yyruleno, /* Number of the rule by which to reduce */ int yyLookahead, /* Lookahead token, or YYNOCODE if none */ ParseTOKENTYPE yyLookaheadToken /* Value of the lookahead token */ - ParseCTX_PDECL /* %extra_context */ ){ int yygoto; /* The next state */ - YYACTIONTYPE yyact; /* The next action */ + int yyact; /* The next action */ yyStackEntry *yymsp; /* The top of the parser's stack */ int yysize; /* Amount to pop the stack */ - ParseARG_FETCH + ParseARG_FETCH; (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; #ifndef NDEBUG if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; + yysize = yyRuleInfo[yyruleno].nrhs; if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + fprintf(yyTraceFILE, "%sReduce %d [%s], go to state %d.\n", yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ yypParser->yyhwm++; @@ -2624,19 +2290,13 @@ static YYACTIONTYPE yy_reduce( #if YYSTACKDEPTH>0 if( yypParser->yytos>=yypParser->yystackEnd ){ yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; + return; } #else if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ if( yyGrowStack(yypParser) ){ yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; + return; } yymsp = yypParser->yytos; } @@ -2827,16 +2487,16 @@ static YYACTIONTYPE yy_reduce( break; case 46: /* cmd ::= ALTER DATABASE ids alter_db_optr */ case 47: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==47); -{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy302, &t);} +{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy436, &t);} break; case 48: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy231);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy517);} break; case 49: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy231);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy517);} break; case 50: /* cmd ::= COMPACT VNODES IN LP exprlist RP */ -{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy161);} +{ setCompactVnodeSql(pInfo, TSDB_SQL_COMPACT_VNODE, yymsp[-1].minor.yy525);} break; case 51: /* ids ::= ID */ case 52: /* ids ::= STRING */ yytestcase(yyruleno==52); @@ -2858,17 +2518,17 @@ static YYACTIONTYPE yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; case 58: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy231);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy517);} break; case 59: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ case 60: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==60); -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy302, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy436, &yymsp[-2].minor.yy0);} break; case 61: /* cmd ::= CREATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy223, &yymsp[0].minor.yy0, 1);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy115, &yymsp[0].minor.yy0, 1);} break; case 62: /* cmd ::= CREATE AGGREGATE FUNCTION ids AS ids OUTPUTTYPE typename bufsize */ -{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy223, &yymsp[0].minor.yy0, 2);} +{ setCreateFuncInfo(pInfo, TSDB_SQL_CREATE_FUNCTION, &yymsp[-5].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy115, &yymsp[0].minor.yy0, 2);} break; case 63: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -2899,38 +2559,38 @@ static YYACTIONTYPE yy_reduce( break; case 84: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy231.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy231.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy231.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy231.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy231.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy231.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy231.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy231.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy231.stat = yymsp[0].minor.yy0; + yylhsminor.yy517.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy517.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy517.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy517.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy517.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy517.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy517.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy517.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy517.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy231 = yylhsminor.yy231; + yymsp[-8].minor.yy517 = yylhsminor.yy517; break; case 85: /* intitemlist ::= intitemlist COMMA intitem */ case 158: /* tagitemlist ::= tagitemlist COMMA tagitem */ yytestcase(yyruleno==158); -{ yylhsminor.yy161 = tVariantListAppend(yymsp[-2].minor.yy161, &yymsp[0].minor.yy526, -1); } - yymsp[-2].minor.yy161 = yylhsminor.yy161; +{ yylhsminor.yy525 = tVariantListAppend(yymsp[-2].minor.yy525, &yymsp[0].minor.yy110, -1); } + yymsp[-2].minor.yy525 = yylhsminor.yy525; break; case 86: /* intitemlist ::= intitem */ case 159: /* tagitemlist ::= tagitem */ yytestcase(yyruleno==159); -{ yylhsminor.yy161 = tVariantListAppend(NULL, &yymsp[0].minor.yy526, -1); } - yymsp[0].minor.yy161 = yylhsminor.yy161; +{ yylhsminor.yy525 = tVariantListAppend(NULL, &yymsp[0].minor.yy110, -1); } + yymsp[0].minor.yy525 = yylhsminor.yy525; break; case 87: /* intitem ::= INTEGER */ case 160: /* tagitem ::= INTEGER */ yytestcase(yyruleno==160); case 161: /* tagitem ::= FLOAT */ yytestcase(yyruleno==161); case 162: /* tagitem ::= STRING */ yytestcase(yyruleno==162); case 163: /* tagitem ::= BOOL */ yytestcase(yyruleno==163); -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy526, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy526 = yylhsminor.yy526; +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy110, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 88: /* keep ::= KEEP intitemlist */ -{ yymsp[-1].minor.yy161 = yymsp[0].minor.yy161; } +{ yymsp[-1].minor.yy525 = yymsp[0].minor.yy525; } break; case 89: /* cache ::= CACHE INTEGER */ case 90: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==90); @@ -2950,200 +2610,200 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 104: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy302); yymsp[1].minor.yy302.dbType = TSDB_DB_TYPE_DEFAULT;} +{setDefaultCreateDbOption(&yymsp[1].minor.yy436); yymsp[1].minor.yy436.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 105: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 106: /* db_optr ::= db_optr replica */ case 123: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==123); -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 107: /* db_optr ::= db_optr quorum */ case 124: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==124); -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 108: /* db_optr ::= db_optr days */ -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 109: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 110: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 111: /* db_optr ::= db_optr blocks */ case 126: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==126); -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 112: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 113: /* db_optr ::= db_optr wal */ -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 114: /* db_optr ::= db_optr fsync */ -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 115: /* db_optr ::= db_optr comp */ case 127: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==127); -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 116: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 117: /* db_optr ::= db_optr keep */ case 125: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==125); -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.keep = yymsp[0].minor.yy161; } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.keep = yymsp[0].minor.yy525; } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 118: /* db_optr ::= db_optr update */ case 128: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==128); -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 119: /* db_optr ::= db_optr cachelast */ case 129: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==129); -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 120: /* topic_optr ::= db_optr */ case 130: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==130); -{ yylhsminor.yy302 = yymsp[0].minor.yy302; yylhsminor.yy302.dbType = TSDB_DB_TYPE_TOPIC; } - yymsp[0].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[0].minor.yy436; yylhsminor.yy436.dbType = TSDB_DB_TYPE_TOPIC; } + yymsp[0].minor.yy436 = yylhsminor.yy436; break; case 121: /* topic_optr ::= topic_optr partitions */ case 131: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==131); -{ yylhsminor.yy302 = yymsp[-1].minor.yy302; yylhsminor.yy302.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy302 = yylhsminor.yy302; +{ yylhsminor.yy436 = yymsp[-1].minor.yy436; yylhsminor.yy436.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy436 = yylhsminor.yy436; break; case 122: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy302); yymsp[1].minor.yy302.dbType = TSDB_DB_TYPE_DEFAULT;} +{ setDefaultCreateDbOption(&yymsp[1].minor.yy436); yymsp[1].minor.yy436.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 132: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy223, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy115, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy223 = yylhsminor.yy223; + yymsp[0].minor.yy115 = yylhsminor.yy115; break; case 133: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy369 <= 0) { + if (yymsp[-1].minor.yy543 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy223, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy115, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy369; // negative value of name length - tSetColumnType(&yylhsminor.yy223, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy543; // negative value of name length + tSetColumnType(&yylhsminor.yy115, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy223 = yylhsminor.yy223; + yymsp[-3].minor.yy115 = yylhsminor.yy115; break; case 134: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSetColumnType (&yylhsminor.yy223, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy115, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy223 = yylhsminor.yy223; + yymsp[-1].minor.yy115 = yylhsminor.yy115; break; case 135: /* signed ::= INTEGER */ -{ yylhsminor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy369 = yylhsminor.yy369; +{ yylhsminor.yy543 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy543 = yylhsminor.yy543; break; case 136: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy369 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy543 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; case 137: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy369 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} +{ yymsp[-1].minor.yy543 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; case 141: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy462;} +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy572;} break; case 142: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy356); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy480); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy462 = pCreateTable; + yylhsminor.yy572 = pCreateTable; } - yymsp[0].minor.yy462 = yylhsminor.yy462; + yymsp[0].minor.yy572 = yylhsminor.yy572; break; case 143: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy462->childTableInfo, &yymsp[0].minor.yy356); - yylhsminor.yy462 = yymsp[-1].minor.yy462; + taosArrayPush(yymsp[-1].minor.yy572->childTableInfo, &yymsp[0].minor.yy480); + yylhsminor.yy572 = yymsp[-1].minor.yy572; } - yymsp[-1].minor.yy462 = yylhsminor.yy462; + yymsp[-1].minor.yy572 = yylhsminor.yy572; break; case 144: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy462 = tSetCreateTableInfo(yymsp[-1].minor.yy161, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy462, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy572 = tSetCreateTableInfo(yymsp[-1].minor.yy525, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy572, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy462 = yylhsminor.yy462; + yymsp[-5].minor.yy572 = yylhsminor.yy572; break; case 145: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy462 = tSetCreateTableInfo(yymsp[-5].minor.yy161, yymsp[-1].minor.yy161, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy462, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy572 = tSetCreateTableInfo(yymsp[-5].minor.yy525, yymsp[-1].minor.yy525, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy572, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy462 = yylhsminor.yy462; + yymsp[-9].minor.yy572 = yylhsminor.yy572; break; case 146: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy356 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy161, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy480 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy525, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy356 = yylhsminor.yy356; + yymsp[-9].minor.yy480 = yylhsminor.yy480; break; case 147: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy356 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy161, yymsp[-1].minor.yy161, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy480 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy525, yymsp[-1].minor.yy525, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy356 = yylhsminor.yy356; + yymsp[-12].minor.yy480 = yylhsminor.yy480; break; case 148: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy161, &yymsp[0].minor.yy0); yylhsminor.yy161 = yymsp[-2].minor.yy161; } - yymsp[-2].minor.yy161 = yylhsminor.yy161; +{taosArrayPush(yymsp[-2].minor.yy525, &yymsp[0].minor.yy0); yylhsminor.yy525 = yymsp[-2].minor.yy525; } + yymsp[-2].minor.yy525 = yylhsminor.yy525; break; case 149: /* tagNamelist ::= ids */ -{yylhsminor.yy161 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy161, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy161 = yylhsminor.yy161; +{yylhsminor.yy525 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy525, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy525 = yylhsminor.yy525; break; case 150: /* create_table_args ::= ifnotexists ids cpxName to_opt split_opt AS select */ { - yylhsminor.yy462 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy276, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy462, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy572 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy86, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy572, NULL, TSDB_SQL_CREATE_TABLE); setCreatedStreamOpt(pInfo, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0); yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-5].minor.yy0, &yymsp[-6].minor.yy0); } - yymsp[-6].minor.yy462 = yylhsminor.yy462; + yymsp[-6].minor.yy572 = yylhsminor.yy572; break; case 151: /* to_opt ::= */ case 153: /* split_opt ::= */ yytestcase(yyruleno==153); @@ -3159,37 +2819,37 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0;} break; case 155: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy161, &yymsp[0].minor.yy223); yylhsminor.yy161 = yymsp[-2].minor.yy161; } - yymsp[-2].minor.yy161 = yylhsminor.yy161; +{taosArrayPush(yymsp[-2].minor.yy525, &yymsp[0].minor.yy115); yylhsminor.yy525 = yymsp[-2].minor.yy525; } + yymsp[-2].minor.yy525 = yylhsminor.yy525; break; case 156: /* columnlist ::= column */ -{yylhsminor.yy161 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy161, &yymsp[0].minor.yy223);} - yymsp[0].minor.yy161 = yylhsminor.yy161; +{yylhsminor.yy525 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy525, &yymsp[0].minor.yy115);} + yymsp[0].minor.yy525 = yylhsminor.yy525; break; case 157: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy223, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy223); + tSetColumnInfo(&yylhsminor.yy115, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy115); } - yymsp[-1].minor.yy223 = yylhsminor.yy223; + yymsp[-1].minor.yy115 = yylhsminor.yy115; break; case 164: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy526, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy526 = yylhsminor.yy526; +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy110, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 165: /* tagitem ::= NOW */ -{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreateExt(&yylhsminor.yy526, &yymsp[0].minor.yy0, TK_NOW, true);} - yymsp[0].minor.yy526 = yylhsminor.yy526; +{ yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; tVariantCreateExt(&yylhsminor.yy110, &yymsp[0].minor.yy0, TK_NOW, true);} + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 166: /* tagitem ::= NOW PLUS VARIABLE */ { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; - tVariantCreateExt(&yymsp[-2].minor.yy526, &yymsp[0].minor.yy0, TK_PLUS, true); + tVariantCreateExt(&yymsp[-2].minor.yy110, &yymsp[0].minor.yy0, TK_PLUS, true); } break; case 167: /* tagitem ::= NOW MINUS VARIABLE */ { yymsp[0].minor.yy0.type = TSDB_DATA_TYPE_TIMESTAMP; - tVariantCreateExt(&yymsp[-2].minor.yy526, &yymsp[0].minor.yy0, TK_MINUS, true); + tVariantCreateExt(&yymsp[-2].minor.yy110, &yymsp[0].minor.yy0, TK_MINUS, true); } break; case 168: /* tagitem ::= MINUS INTEGER */ @@ -3200,56 +2860,56 @@ static YYACTIONTYPE yy_reduce( yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - tVariantCreate(&yylhsminor.yy526, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy110, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; + yymsp[-1].minor.yy110 = yylhsminor.yy110; break; case 172: /* select ::= SELECT selcollist from where_opt range_option interval_option sliding_opt session_option windowstate_option fill_opt groupby_opt having_opt orderby_opt slimit_opt limit_opt */ { - yylhsminor.yy276 = tSetQuerySqlNode(&yymsp[-14].minor.yy0, yymsp[-13].minor.yy161, yymsp[-12].minor.yy84, yymsp[-11].minor.yy546, yymsp[-4].minor.yy161, yymsp[-2].minor.yy161, &yymsp[-9].minor.yy300, &yymsp[-7].minor.yy219, &yymsp[-6].minor.yy548, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy161, &yymsp[0].minor.yy394, &yymsp[-1].minor.yy394, yymsp[-3].minor.yy546, &yymsp[-10].minor.yy420); + yylhsminor.yy86 = tSetQuerySqlNode(&yymsp[-14].minor.yy0, yymsp[-13].minor.yy525, yymsp[-12].minor.yy328, yymsp[-11].minor.yy142, yymsp[-4].minor.yy525, yymsp[-2].minor.yy525, &yymsp[-9].minor.yy238, &yymsp[-7].minor.yy319, &yymsp[-6].minor.yy546, &yymsp[-8].minor.yy0, yymsp[-5].minor.yy525, &yymsp[0].minor.yy6, &yymsp[-1].minor.yy6, yymsp[-3].minor.yy142, &yymsp[-10].minor.yy330); } - yymsp[-14].minor.yy276 = yylhsminor.yy276; + yymsp[-14].minor.yy86 = yylhsminor.yy86; break; case 173: /* select ::= LP select RP */ -{yymsp[-2].minor.yy276 = yymsp[-1].minor.yy276;} +{yymsp[-2].minor.yy86 = yymsp[-1].minor.yy86;} break; case 174: /* union ::= select */ -{ yylhsminor.yy161 = setSubclause(NULL, yymsp[0].minor.yy276); } - yymsp[0].minor.yy161 = yylhsminor.yy161; +{ yylhsminor.yy525 = setSubclause(NULL, yymsp[0].minor.yy86); } + yymsp[0].minor.yy525 = yylhsminor.yy525; break; case 175: /* union ::= union UNION ALL select */ -{ yylhsminor.yy161 = appendSelectClause(yymsp[-3].minor.yy161, yymsp[0].minor.yy276); } - yymsp[-3].minor.yy161 = yylhsminor.yy161; +{ yylhsminor.yy525 = appendSelectClause(yymsp[-3].minor.yy525, yymsp[0].minor.yy86); } + yymsp[-3].minor.yy525 = yylhsminor.yy525; break; case 176: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy161, NULL, TSDB_SQL_SELECT); } +{ setSqlInfo(pInfo, yymsp[0].minor.yy525, NULL, TSDB_SQL_SELECT); } break; case 177: /* select ::= SELECT selcollist */ { - yylhsminor.yy276 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy161, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy86 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy525, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy276 = yylhsminor.yy276; + yymsp[-1].minor.yy86 = yylhsminor.yy86; break; case 178: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy161 = yymsp[-1].minor.yy161;} - yymsp[-1].minor.yy161 = yylhsminor.yy161; +{yylhsminor.yy525 = yymsp[-1].minor.yy525;} + yymsp[-1].minor.yy525 = yylhsminor.yy525; break; case 179: /* sclp ::= */ case 220: /* orderby_opt ::= */ yytestcase(yyruleno==220); -{yymsp[1].minor.yy161 = 0;} +{yymsp[1].minor.yy525 = 0;} break; case 180: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy161 = tSqlExprListAppend(yymsp[-3].minor.yy161, yymsp[-1].minor.yy546, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy525 = tSqlExprListAppend(yymsp[-3].minor.yy525, yymsp[-1].minor.yy142, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy161 = yylhsminor.yy161; + yymsp[-3].minor.yy525 = yylhsminor.yy525; break; case 181: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(pInfo, NULL, TK_ALL); - yylhsminor.yy161 = tSqlExprListAppend(yymsp[-1].minor.yy161, pNode, 0, 0); + yylhsminor.yy525 = tSqlExprListAppend(yymsp[-1].minor.yy525, pNode, 0, 0); } - yymsp[-1].minor.yy161 = yylhsminor.yy161; + yymsp[-1].minor.yy525 = yylhsminor.yy525; break; case 182: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } @@ -3267,114 +2927,114 @@ static YYACTIONTYPE yy_reduce( break; case 187: /* from ::= FROM tablelist */ case 188: /* from ::= FROM sub */ yytestcase(yyruleno==188); -{yymsp[-1].minor.yy84 = yymsp[0].minor.yy84;} +{yymsp[-1].minor.yy328 = yymsp[0].minor.yy328;} break; case 189: /* sub ::= LP union RP */ -{yymsp[-2].minor.yy84 = addSubqueryElem(NULL, yymsp[-1].minor.yy161, NULL);} +{yymsp[-2].minor.yy328 = addSubqueryElem(NULL, yymsp[-1].minor.yy525, NULL);} break; case 190: /* sub ::= LP union RP ids */ -{yymsp[-3].minor.yy84 = addSubqueryElem(NULL, yymsp[-2].minor.yy161, &yymsp[0].minor.yy0);} +{yymsp[-3].minor.yy328 = addSubqueryElem(NULL, yymsp[-2].minor.yy525, &yymsp[0].minor.yy0);} break; case 191: /* sub ::= sub COMMA LP union RP ids */ -{yylhsminor.yy84 = addSubqueryElem(yymsp[-5].minor.yy84, yymsp[-2].minor.yy161, &yymsp[0].minor.yy0);} - yymsp[-5].minor.yy84 = yylhsminor.yy84; +{yylhsminor.yy328 = addSubqueryElem(yymsp[-5].minor.yy328, yymsp[-2].minor.yy525, &yymsp[0].minor.yy0);} + yymsp[-5].minor.yy328 = yylhsminor.yy328; break; case 192: /* tablelist ::= ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy84 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy328 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy84 = yylhsminor.yy84; + yymsp[-1].minor.yy328 = yylhsminor.yy328; break; case 193: /* tablelist ::= ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy84 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy328 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy84 = yylhsminor.yy84; + yymsp[-2].minor.yy328 = yylhsminor.yy328; break; case 194: /* tablelist ::= tablelist COMMA ids cpxName */ { yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy84 = setTableNameList(yymsp[-3].minor.yy84, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy328 = setTableNameList(yymsp[-3].minor.yy328, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy84 = yylhsminor.yy84; + yymsp[-3].minor.yy328 = yylhsminor.yy328; break; case 195: /* tablelist ::= tablelist COMMA ids cpxName ids */ { yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy84 = setTableNameList(yymsp[-4].minor.yy84, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy328 = setTableNameList(yymsp[-4].minor.yy328, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy84 = yylhsminor.yy84; + yymsp[-4].minor.yy328 = yylhsminor.yy328; break; case 196: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 197: /* timestamp ::= INTEGER */ -{ yylhsminor.yy546 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 198: /* timestamp ::= MINUS INTEGER */ case 199: /* timestamp ::= PLUS INTEGER */ yytestcase(yyruleno==199); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy546 = tSqlExprCreateTimestamp(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy546 = yylhsminor.yy546; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy142 = tSqlExprCreateTimestamp(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy142 = yylhsminor.yy142; break; case 200: /* timestamp ::= STRING */ -{ yylhsminor.yy546 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 201: /* timestamp ::= NOW */ -{ yylhsminor.yy546 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 202: /* timestamp ::= NOW PLUS VARIABLE */ -{yymsp[-2].minor.yy546 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_PLUS); } +{yymsp[-2].minor.yy142 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_PLUS); } break; case 203: /* timestamp ::= NOW MINUS VARIABLE */ -{yymsp[-2].minor.yy546 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_MINUS); } +{yymsp[-2].minor.yy142 = tSqlExprCreateTimestamp(&yymsp[0].minor.yy0, TK_MINUS); } break; case 204: /* range_option ::= */ -{yymsp[1].minor.yy420.start = 0; yymsp[1].minor.yy420.end = 0;} +{yymsp[1].minor.yy330.start = 0; yymsp[1].minor.yy330.end = 0;} break; case 205: /* range_option ::= RANGE LP timestamp COMMA timestamp RP */ -{yymsp[-5].minor.yy420.start = yymsp[-3].minor.yy546; yymsp[-5].minor.yy420.end = yymsp[-1].minor.yy546;} +{yymsp[-5].minor.yy330.start = yymsp[-3].minor.yy142; yymsp[-5].minor.yy330.end = yymsp[-1].minor.yy142;} break; case 206: /* interval_option ::= intervalKey LP tmvar RP */ -{yylhsminor.yy300.interval = yymsp[-1].minor.yy0; yylhsminor.yy300.offset.n = 0; yylhsminor.yy300.token = yymsp[-3].minor.yy520;} - yymsp[-3].minor.yy300 = yylhsminor.yy300; +{yylhsminor.yy238.interval = yymsp[-1].minor.yy0; yylhsminor.yy238.offset.n = 0; yylhsminor.yy238.token = yymsp[-3].minor.yy508;} + yymsp[-3].minor.yy238 = yylhsminor.yy238; break; case 207: /* interval_option ::= intervalKey LP tmvar COMMA tmvar RP */ -{yylhsminor.yy300.interval = yymsp[-3].minor.yy0; yylhsminor.yy300.offset = yymsp[-1].minor.yy0; yylhsminor.yy300.token = yymsp[-5].minor.yy520;} - yymsp[-5].minor.yy300 = yylhsminor.yy300; +{yylhsminor.yy238.interval = yymsp[-3].minor.yy0; yylhsminor.yy238.offset = yymsp[-1].minor.yy0; yylhsminor.yy238.token = yymsp[-5].minor.yy508;} + yymsp[-5].minor.yy238 = yylhsminor.yy238; break; case 208: /* interval_option ::= */ -{memset(&yymsp[1].minor.yy300, 0, sizeof(yymsp[1].minor.yy300));} +{memset(&yymsp[1].minor.yy238, 0, sizeof(yymsp[1].minor.yy238));} break; case 209: /* intervalKey ::= INTERVAL */ -{yymsp[0].minor.yy520 = TK_INTERVAL;} +{yymsp[0].minor.yy508 = TK_INTERVAL;} break; case 210: /* intervalKey ::= EVERY */ -{yymsp[0].minor.yy520 = TK_EVERY; } +{yymsp[0].minor.yy508 = TK_EVERY; } break; case 211: /* session_option ::= */ -{yymsp[1].minor.yy219.col.n = 0; yymsp[1].minor.yy219.gap.n = 0;} +{yymsp[1].minor.yy319.col.n = 0; yymsp[1].minor.yy319.gap.n = 0;} break; case 212: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy219.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy219.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy319.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy319.gap = yymsp[-1].minor.yy0; } break; case 213: /* windowstate_option ::= */ -{ yymsp[1].minor.yy548.col.n = 0; yymsp[1].minor.yy548.col.z = NULL;} +{ yymsp[1].minor.yy546.col.n = 0; yymsp[1].minor.yy546.col.z = NULL;} break; case 214: /* windowstate_option ::= STATE_WINDOW LP ids RP */ -{ yymsp[-3].minor.yy548.col = yymsp[-1].minor.yy0; } +{ yymsp[-3].minor.yy546.col = yymsp[-1].minor.yy0; } break; case 215: /* fill_opt ::= */ -{ yymsp[1].minor.yy161 = 0; } +{ yymsp[1].minor.yy525 = 0; } break; case 216: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { @@ -3382,14 +3042,14 @@ static YYACTIONTYPE yy_reduce( toTSDBType(yymsp[-3].minor.yy0.type); tVariantCreate(&A, &yymsp[-3].minor.yy0); - tVariantListInsert(yymsp[-1].minor.yy161, &A, -1, 0); - yymsp[-5].minor.yy161 = yymsp[-1].minor.yy161; + tVariantListInsert(yymsp[-1].minor.yy525, &A, -1, 0); + yymsp[-5].minor.yy525 = yymsp[-1].minor.yy525; } break; case 217: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy161 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1, true); + yymsp[-3].minor.yy525 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1, true); } break; case 218: /* sliding_opt ::= SLIDING LP tmvar RP */ @@ -3399,313 +3059,317 @@ static YYACTIONTYPE yy_reduce( {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; case 221: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy161 = yymsp[0].minor.yy161;} +{yymsp[-2].minor.yy525 = yymsp[0].minor.yy525;} break; case 222: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy161 = commonItemAppend(yymsp[-3].minor.yy161, &yymsp[-1].minor.yy526, NULL, false, yymsp[0].minor.yy452); + yylhsminor.yy525 = commonItemAppend(yymsp[-3].minor.yy525, &yymsp[-1].minor.yy110, NULL, false, yymsp[0].minor.yy580); } - yymsp[-3].minor.yy161 = yylhsminor.yy161; + yymsp[-3].minor.yy525 = yylhsminor.yy525; break; case 223: /* sortlist ::= sortlist COMMA arrow sortorder */ { - yylhsminor.yy161 = commonItemAppend(yymsp[-3].minor.yy161, NULL, yymsp[-1].minor.yy546, true, yymsp[0].minor.yy452); + yylhsminor.yy525 = commonItemAppend(yymsp[-3].minor.yy525, NULL, yymsp[-1].minor.yy142, true, yymsp[0].minor.yy580); } - yymsp[-3].minor.yy161 = yylhsminor.yy161; + yymsp[-3].minor.yy525 = yylhsminor.yy525; break; case 224: /* sortlist ::= item sortorder */ { - yylhsminor.yy161 = commonItemAppend(NULL, &yymsp[-1].minor.yy526, NULL, false, yymsp[0].minor.yy452); + yylhsminor.yy525 = commonItemAppend(NULL, &yymsp[-1].minor.yy110, NULL, false, yymsp[0].minor.yy580); } - yymsp[-1].minor.yy161 = yylhsminor.yy161; + yymsp[-1].minor.yy525 = yylhsminor.yy525; break; case 225: /* sortlist ::= arrow sortorder */ { - yylhsminor.yy161 = commonItemAppend(NULL, NULL, yymsp[-1].minor.yy546, true, yymsp[0].minor.yy452); + yylhsminor.yy525 = commonItemAppend(NULL, NULL, yymsp[-1].minor.yy142, true, yymsp[0].minor.yy580); } - yymsp[-1].minor.yy161 = yylhsminor.yy161; + yymsp[-1].minor.yy525 = yylhsminor.yy525; break; case 226: /* item ::= ID */ { toTSDBType(yymsp[0].minor.yy0.type); - tVariantCreate(&yylhsminor.yy526, &yymsp[0].minor.yy0); + tVariantCreate(&yylhsminor.yy110, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy526 = yylhsminor.yy526; + yymsp[0].minor.yy110 = yylhsminor.yy110; break; case 227: /* item ::= ID DOT ID */ { toTSDBType(yymsp[-2].minor.yy0.type); yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); - tVariantCreate(&yylhsminor.yy526, &yymsp[-2].minor.yy0); + tVariantCreate(&yylhsminor.yy110, &yymsp[-2].minor.yy0); } - yymsp[-2].minor.yy526 = yylhsminor.yy526; + yymsp[-2].minor.yy110 = yylhsminor.yy110; break; case 228: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy452 = TSDB_ORDER_ASC; } +{ yymsp[0].minor.yy580 = TSDB_ORDER_ASC; } break; case 229: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy452 = TSDB_ORDER_DESC;} +{ yymsp[0].minor.yy580 = TSDB_ORDER_DESC;} break; case 230: /* sortorder ::= */ -{ yymsp[1].minor.yy452 = TSDB_ORDER_ASC; } +{ yymsp[1].minor.yy580 = TSDB_ORDER_ASC; } break; case 231: /* groupby_opt ::= */ -{ yymsp[1].minor.yy161 = 0;} +{ yymsp[1].minor.yy525 = 0;} break; case 232: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy161 = yymsp[0].minor.yy161;} +{ yymsp[-2].minor.yy525 = yymsp[0].minor.yy525;} break; case 233: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy161 = commonItemAppend(yymsp[-2].minor.yy161, &yymsp[0].minor.yy526, NULL, false, -1); + yylhsminor.yy525 = commonItemAppend(yymsp[-2].minor.yy525, &yymsp[0].minor.yy110, NULL, false, -1); } - yymsp[-2].minor.yy161 = yylhsminor.yy161; + yymsp[-2].minor.yy525 = yylhsminor.yy525; break; case 234: /* grouplist ::= grouplist COMMA arrow */ { - yylhsminor.yy161 = commonItemAppend(yymsp[-2].minor.yy161, NULL, yymsp[0].minor.yy546, true, -1); + yylhsminor.yy525 = commonItemAppend(yymsp[-2].minor.yy525, NULL, yymsp[0].minor.yy142, true, -1); } - yymsp[-2].minor.yy161 = yylhsminor.yy161; + yymsp[-2].minor.yy525 = yylhsminor.yy525; break; case 235: /* grouplist ::= item */ { - yylhsminor.yy161 = commonItemAppend(NULL, &yymsp[0].minor.yy526, NULL, false, -1); + yylhsminor.yy525 = commonItemAppend(NULL, &yymsp[0].minor.yy110, NULL, false, -1); } - yymsp[0].minor.yy161 = yylhsminor.yy161; + yymsp[0].minor.yy525 = yylhsminor.yy525; break; case 236: /* grouplist ::= arrow */ { - yylhsminor.yy161 = commonItemAppend(NULL, NULL, yymsp[0].minor.yy546, true, -1); + yylhsminor.yy525 = commonItemAppend(NULL, NULL, yymsp[0].minor.yy142, true, -1); } - yymsp[0].minor.yy161 = yylhsminor.yy161; + yymsp[0].minor.yy525 = yylhsminor.yy525; break; case 237: /* having_opt ::= */ case 247: /* where_opt ::= */ yytestcase(yyruleno==247); - case 298: /* expritem ::= */ yytestcase(yyruleno==298); -{yymsp[1].minor.yy546 = 0;} + case 299: /* expritem ::= */ yytestcase(yyruleno==299); +{yymsp[1].minor.yy142 = 0;} break; case 238: /* having_opt ::= HAVING expr */ case 248: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==248); -{yymsp[-1].minor.yy546 = yymsp[0].minor.yy546;} +{yymsp[-1].minor.yy142 = yymsp[0].minor.yy142;} break; case 239: /* limit_opt ::= */ case 243: /* slimit_opt ::= */ yytestcase(yyruleno==243); -{yymsp[1].minor.yy394.limit = -1; yymsp[1].minor.yy394.offset = 0;} +{yymsp[1].minor.yy6.limit = -1; yymsp[1].minor.yy6.offset = 0;} break; case 240: /* limit_opt ::= LIMIT signed */ case 244: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==244); -{yymsp[-1].minor.yy394.limit = yymsp[0].minor.yy369; yymsp[-1].minor.yy394.offset = 0;} +{yymsp[-1].minor.yy6.limit = yymsp[0].minor.yy543; yymsp[-1].minor.yy6.offset = 0;} break; case 241: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy394.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy394.offset = yymsp[0].minor.yy369;} +{ yymsp[-3].minor.yy6.limit = yymsp[-2].minor.yy543; yymsp[-3].minor.yy6.offset = yymsp[0].minor.yy543;} break; case 242: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy394.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy394.offset = yymsp[-2].minor.yy369;} +{ yymsp[-3].minor.yy6.limit = yymsp[0].minor.yy543; yymsp[-3].minor.yy6.offset = yymsp[-2].minor.yy543;} break; case 245: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy394.limit = yymsp[-2].minor.yy369; yymsp[-3].minor.yy394.offset = yymsp[0].minor.yy369;} +{yymsp[-3].minor.yy6.limit = yymsp[-2].minor.yy543; yymsp[-3].minor.yy6.offset = yymsp[0].minor.yy543;} break; case 246: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy394.limit = yymsp[0].minor.yy369; yymsp[-3].minor.yy394.offset = yymsp[-2].minor.yy369;} +{yymsp[-3].minor.yy6.limit = yymsp[0].minor.yy543; yymsp[-3].minor.yy6.offset = yymsp[-2].minor.yy543;} break; case 249: /* expr ::= LP expr RP */ -{yylhsminor.yy546 = yymsp[-1].minor.yy546; yylhsminor.yy546->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy546->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = yymsp[-1].minor.yy142; yylhsminor.yy142->exprToken.z = yymsp[-2].minor.yy0.z; yylhsminor.yy142->exprToken.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 250: /* expr ::= ID */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 251: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 252: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 253: /* expr ::= INTEGER */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 254: /* expr ::= MINUS INTEGER */ case 255: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==255); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy546 = yylhsminor.yy546; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy142 = yylhsminor.yy142; break; case 256: /* expr ::= FLOAT */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 257: /* expr ::= MINUS FLOAT */ case 258: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==258); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy546 = yylhsminor.yy546; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy142 = yylhsminor.yy142; break; case 259: /* expr ::= STRING */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 260: /* expr ::= NOW */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 261: /* expr ::= TODAY */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_TODAY); } - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_TODAY); } + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 262: /* expr ::= VARIABLE */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 263: /* expr ::= PLUS VARIABLE */ case 264: /* expr ::= MINUS VARIABLE */ yytestcase(yyruleno==264); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_VARIABLE);} - yymsp[-1].minor.yy546 = yylhsminor.yy546; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_VARIABLE; yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[-1].minor.yy0, TK_VARIABLE);} + yymsp[-1].minor.yy142 = yylhsminor.yy142; break; case 265: /* expr ::= BOOL */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 266: /* expr ::= NULL */ -{ yylhsminor.yy546 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NULL);} - yymsp[0].minor.yy546 = yylhsminor.yy546; +{ yylhsminor.yy142 = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_NULL);} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; case 267: /* expr ::= ID LP exprlist RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy546 = tSqlExprCreateFunction(yymsp[-1].minor.yy161, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy546 = yylhsminor.yy546; +{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy142 = tSqlExprCreateFunction(yymsp[-1].minor.yy525, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy142 = yylhsminor.yy142; break; case 268: /* expr ::= ID LP STAR RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy546 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy546 = yylhsminor.yy546; +{ tStrTokenAppend(pInfo->funcs, &yymsp[-3].minor.yy0); yylhsminor.yy142 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy142 = yylhsminor.yy142; break; case 269: /* expr ::= ID LP expr AS typename RP */ -{ tStrTokenAppend(pInfo->funcs, &yymsp[-5].minor.yy0); yylhsminor.yy546 = tSqlExprCreateFuncWithParams(pInfo, yymsp[-3].minor.yy546, &yymsp[-1].minor.yy223, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, yymsp[-5].minor.yy0.type); } - yymsp[-5].minor.yy546 = yylhsminor.yy546; +{ tStrTokenAppend(pInfo->funcs, &yymsp[-5].minor.yy0); yylhsminor.yy142 = tSqlExprCreateFuncWithParams(pInfo, yymsp[-3].minor.yy142, &yymsp[-1].minor.yy115, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, yymsp[-5].minor.yy0.type); } + yymsp[-5].minor.yy142 = yylhsminor.yy142; break; case 270: /* expr ::= expr IS NULL */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, NULL, TK_ISNULL);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, NULL, TK_ISNULL);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 271: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-3].minor.yy546, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-3].minor.yy142, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy142 = yylhsminor.yy142; break; case 272: /* expr ::= expr LT expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_LT);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_LT);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 273: /* expr ::= expr GT expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_GT);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_GT);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 274: /* expr ::= expr LE expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_LE);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_LE);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 275: /* expr ::= expr GE expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_GE);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_GE);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 276: /* expr ::= expr NE expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_NE);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_NE);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 277: /* expr ::= expr EQ expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_EQ);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_EQ);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 278: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy546); yylhsminor.yy546 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy546, yymsp[-2].minor.yy546, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy546, TK_LE), TK_AND);} - yymsp[-4].minor.yy546 = yylhsminor.yy546; +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy142); yylhsminor.yy142 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy142, yymsp[-2].minor.yy142, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy142, TK_LE), TK_AND);} + yymsp[-4].minor.yy142 = yylhsminor.yy142; break; case 279: /* expr ::= expr AND expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_AND);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_AND);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 280: /* expr ::= expr OR expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_OR); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_OR); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 281: /* expr ::= expr PLUS expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_PLUS); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_PLUS); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 282: /* expr ::= expr MINUS expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_MINUS); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_MINUS); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 283: /* expr ::= expr STAR expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_STAR); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_STAR); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 284: /* expr ::= expr SLASH expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_DIVIDE);} - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_DIVIDE);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; case 285: /* expr ::= expr REM expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_REM); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_REM); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; + break; + case 286: /* expr ::= expr BITAND expr */ +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_BITAND);} + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; - case 286: /* expr ::= expr LIKE expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_LIKE); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; + case 287: /* expr ::= expr LIKE expr */ +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_LIKE); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; - case 287: /* expr ::= expr MATCH expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_MATCH); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; + case 288: /* expr ::= expr MATCH expr */ +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_MATCH); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; - case 288: /* expr ::= expr NMATCH expr */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-2].minor.yy546, yymsp[0].minor.yy546, TK_NMATCH); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; + case 289: /* expr ::= expr NMATCH expr */ +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-2].minor.yy142, yymsp[0].minor.yy142, TK_NMATCH); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; - case 289: /* expr ::= ID CONTAINS STRING */ -{ tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy546 = tSqlExprCreate(S, M, TK_CONTAINS); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; + case 290: /* expr ::= ID CONTAINS STRING */ +{ tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy142 = tSqlExprCreate(S, M, TK_CONTAINS); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; - case 290: /* expr ::= ID DOT ID CONTAINS STRING */ -{ yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy546 = tSqlExprCreate(S, M, TK_CONTAINS); } - yymsp[-4].minor.yy546 = yylhsminor.yy546; + case 291: /* expr ::= ID DOT ID CONTAINS STRING */ +{ yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy142 = tSqlExprCreate(S, M, TK_CONTAINS); } + yymsp[-4].minor.yy142 = yylhsminor.yy142; break; - case 291: /* arrow ::= ID ARROW STRING */ -{tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy546 = tSqlExprCreate(S, M, TK_ARROW); } - yymsp[-2].minor.yy546 = yylhsminor.yy546; + case 292: /* arrow ::= ID ARROW STRING */ +{tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-2].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy142 = tSqlExprCreate(S, M, TK_ARROW); } + yymsp[-2].minor.yy142 = yylhsminor.yy142; break; - case 292: /* arrow ::= ID DOT ID ARROW STRING */ -{yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy546 = tSqlExprCreate(S, M, TK_ARROW); } - yymsp[-4].minor.yy546 = yylhsminor.yy546; + case 293: /* arrow ::= ID DOT ID ARROW STRING */ +{yymsp[-4].minor.yy0.n += (1+yymsp[-2].minor.yy0.n); tSqlExpr* S = tSqlExprCreateIdValue(pInfo, &yymsp[-4].minor.yy0, TK_ID); tSqlExpr* M = tSqlExprCreateIdValue(pInfo, &yymsp[0].minor.yy0, TK_STRING); yylhsminor.yy142 = tSqlExprCreate(S, M, TK_ARROW); } + yymsp[-4].minor.yy142 = yylhsminor.yy142; break; - case 293: /* expr ::= arrow */ - case 297: /* expritem ::= expr */ yytestcase(yyruleno==297); -{yylhsminor.yy546 = yymsp[0].minor.yy546;} - yymsp[0].minor.yy546 = yylhsminor.yy546; + case 294: /* expr ::= arrow */ + case 298: /* expritem ::= expr */ yytestcase(yyruleno==298); +{yylhsminor.yy142 = yymsp[0].minor.yy142;} + yymsp[0].minor.yy142 = yylhsminor.yy142; break; - case 294: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy546 = tSqlExprCreate(yymsp[-4].minor.yy546, (tSqlExpr*)yymsp[-1].minor.yy161, TK_IN); } - yymsp[-4].minor.yy546 = yylhsminor.yy546; + case 295: /* expr ::= expr IN LP exprlist RP */ +{yylhsminor.yy142 = tSqlExprCreate(yymsp[-4].minor.yy142, (tSqlExpr*)yymsp[-1].minor.yy525, TK_IN); } + yymsp[-4].minor.yy142 = yylhsminor.yy142; break; - case 295: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy161 = tSqlExprListAppend(yymsp[-2].minor.yy161,yymsp[0].minor.yy546,0, 0);} - yymsp[-2].minor.yy161 = yylhsminor.yy161; + case 296: /* exprlist ::= exprlist COMMA expritem */ +{yylhsminor.yy525 = tSqlExprListAppend(yymsp[-2].minor.yy525,yymsp[0].minor.yy142,0, 0);} + yymsp[-2].minor.yy525 = yylhsminor.yy525; break; - case 296: /* exprlist ::= expritem */ -{yylhsminor.yy161 = tSqlExprListAppend(0,yymsp[0].minor.yy546,0, 0);} - yymsp[0].minor.yy161 = yylhsminor.yy161; + case 297: /* exprlist ::= expritem */ +{yylhsminor.yy525 = tSqlExprListAppend(0,yymsp[0].minor.yy142,0, 0);} + yymsp[0].minor.yy525 = yylhsminor.yy525; break; - case 299: /* cmd ::= RESET QUERY CACHE */ + case 300: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} break; - case 300: /* cmd ::= SYNCDB ids REPLICA */ + case 301: /* cmd ::= SYNCDB ids REPLICA */ { setDCLSqlElems(pInfo, TSDB_SQL_SYNC_DB_REPLICA, 1, &yymsp[-1].minor.yy0);} break; - case 301: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + case 302: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy161, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy525, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 302: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + case 303: /* cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3716,21 +3380,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 303: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ + case 304: /* cmd ::= ALTER TABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy161, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy525, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 304: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + case 305: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy161, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy525, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 305: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + case 306: /* cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3741,7 +3405,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 306: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + case 307: /* cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3755,33 +3419,33 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 307: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + case 308: /* cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1, false); - A = tVariantListAppend(A, &yymsp[0].minor.yy526, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy110, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 308: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ + case 309: /* cmd ::= ALTER TABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy161, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy525, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 309: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + case 310: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy161, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy525, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 310: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + case 311: /* cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3792,21 +3456,21 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 311: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ + case 312: /* cmd ::= ALTER STABLE ids cpxName MODIFY COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy161, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy525, NULL, TSDB_ALTER_TABLE_CHANGE_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 312: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + case 313: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy161, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy525, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 313: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + case 314: /* cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; @@ -3817,7 +3481,7 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 314: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + case 315: /* cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; @@ -3831,41 +3495,41 @@ static YYACTIONTYPE yy_reduce( setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 315: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ + case 316: /* cmd ::= ALTER STABLE ids cpxName SET TAG ids EQ tagitem */ { yymsp[-6].minor.yy0.n += yymsp[-5].minor.yy0.n; toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1, false); - A = tVariantListAppend(A, &yymsp[0].minor.yy526, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy110, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 316: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ + case 317: /* cmd ::= ALTER STABLE ids cpxName MODIFY TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy161, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy525, NULL, TSDB_ALTER_TABLE_MODIFY_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; - case 317: /* cmd ::= KILL CONNECTION INTEGER */ + case 318: /* cmd ::= KILL CONNECTION INTEGER */ {setKillSql(pInfo, TSDB_SQL_KILL_CONNECTION, &yymsp[0].minor.yy0);} break; - case 318: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ + case 319: /* cmd ::= KILL STREAM INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_STREAM, &yymsp[-2].minor.yy0);} break; - case 319: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ + case 320: /* cmd ::= KILL QUERY INTEGER COLON INTEGER */ {yymsp[-2].minor.yy0.n += (yymsp[-1].minor.yy0.n + yymsp[0].minor.yy0.n); setKillSql(pInfo, TSDB_SQL_KILL_QUERY, &yymsp[-2].minor.yy0);} break; default: break; /********** End reduce actions ************************************************/ }; - assert( yyrulenostateno = (YYACTIONTYPE)yyact; yymsp->major = (YYCODETYPE)yygoto; yyTraceShift(yypParser, yyact, "... then shift"); - return yyact; } /* @@ -3890,8 +3553,7 @@ static YYACTIONTYPE yy_reduce( static void yy_parse_failed( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); @@ -3902,8 +3564,7 @@ static void yy_parse_failed( ** parser fails */ /************ Begin %parse_failure code ***************************************/ /************ End %parse_failure code *****************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } #endif /* YYNOERRORRECOVERY */ @@ -3915,8 +3576,7 @@ static void yy_syntax_error( int yymajor, /* The major type of the error token */ ParseTOKENTYPE yyminor /* The minor type of the error token */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ @@ -3942,8 +3602,7 @@ static void yy_syntax_error( assert(len <= outputBufLen); /************ End %syntax_error code ******************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* @@ -3952,8 +3611,7 @@ static void yy_syntax_error( static void yy_accept( yyParser *yypParser /* The parser */ ){ - ParseARG_FETCH - ParseCTX_FETCH + ParseARG_FETCH; #ifndef NDEBUG if( yyTraceFILE ){ fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); @@ -3968,8 +3626,7 @@ static void yy_accept( /*********** Begin %parse_accept code *****************************************/ /*********** End %parse_accept code *******************************************/ - ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ - ParseCTX_STORE + ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ } /* The main parser program. @@ -3998,47 +3655,45 @@ void Parse( ParseARG_PDECL /* Optional %extra_argument parameter */ ){ YYMINORTYPE yyminorunion; - YYACTIONTYPE yyact; /* The parser action. */ + unsigned int yyact; /* The parser action. */ #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ #endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif - yyParser *yypParser = (yyParser*)yyp; /* The parser */ - ParseCTX_FETCH - ParseARG_STORE + yyParser *yypParser; /* The parser */ + yypParser = (yyParser*)yyp; assert( yypParser->yytos!=0 ); #if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); #endif + ParseARG_STORE; - yyact = yypParser->yytos->stateno; #ifndef NDEBUG if( yyTraceFILE ){ - if( yyact < YY_MIN_REDUCE ){ + int stateno = yypParser->yytos->stateno; + if( stateno < YY_MIN_REDUCE ){ fprintf(yyTraceFILE,"%sInput '%s' in state %d\n", - yyTracePrompt,yyTokenName[yymajor],yyact); + yyTracePrompt,yyTokenName[yymajor],stateno); }else{ fprintf(yyTraceFILE,"%sInput '%s' with pending reduce %d\n", - yyTracePrompt,yyTokenName[yymajor],yyact-YY_MIN_REDUCE); + yyTracePrompt,yyTokenName[yymajor],stateno-YY_MIN_REDUCE); } } #endif do{ - assert( yyact==yypParser->yytos->stateno ); - yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); + yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); if( yyact >= YY_MIN_REDUCE ){ - yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, - yyminor ParseCTX_PARAM); + yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor,yyminor); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ - yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); + yy_shift(yypParser,yyact,yymajor,yyminor); #ifndef YYNOERRORRECOVERY yypParser->yyerrcnt--; #endif - break; + yymajor = YYNOCODE; }else if( yyact==YY_ACCEPT_ACTION ){ yypParser->yytos--; yy_accept(yypParser); @@ -4089,9 +3744,10 @@ void Parse( yymajor = YYNOCODE; }else{ while( yypParser->yytos >= yypParser->yystack + && yymx != YYERRORSYMBOL && (yyact = yy_find_reduce_action( yypParser->yytos->stateno, - YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE + YYERRORSYMBOL)) >= YY_MIN_REDUCE ){ yy_pop_parser_stack(yypParser); } @@ -4108,8 +3764,6 @@ void Parse( } yypParser->yyerrcnt = 3; yyerrorhit = 1; - if( yymajor==YYNOCODE ) break; - yyact = yypParser->yytos->stateno; #elif defined(YYNOERRORRECOVERY) /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to ** do any kind of error recovery. Instead, simply invoke the syntax @@ -4120,7 +3774,8 @@ void Parse( */ yy_syntax_error(yypParser,yymajor, yyminor); yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); - break; + yymajor = YYNOCODE; + #else /* YYERRORSYMBOL is not defined */ /* This is what we do if the grammar does not define ERROR: ** @@ -4142,10 +3797,10 @@ void Parse( yypParser->yyerrcnt = -1; #endif } - break; + yymajor = YYNOCODE; #endif } - }while( yypParser->yytos>yypParser->yystack ); + }while( yymajor!=YYNOCODE && yypParser->yytos>yypParser->yystack ); #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; @@ -4160,17 +3815,3 @@ void Parse( #endif return; } - -/* -** Return the fallback token corresponding to canonical token iToken, or -** 0 if iToken has no fallback. -*/ -int ParseFallback(int iToken){ -#ifdef YYFALLBACK - assert( iToken<(int)(sizeof(yyFallback)/sizeof(yyFallback[0])) ); - return yyFallback[iToken]; -#else - (void)iToken; - return 0; -#endif -} diff --git a/src/query/tests/CMakeLists.txt b/src/query/tests/CMakeLists.txt index 6f3268377cd816bdc9f8e3bedf5eb0484519840a..6a77cc148f6453c37e40eaabfa32c1a08f45094a 100644 --- a/src/query/tests/CMakeLists.txt +++ b/src/query/tests/CMakeLists.txt @@ -12,7 +12,9 @@ IF (HEADER_GTEST_INCLUDE_DIR AND (LIB_GTEST_STATIC_DIR OR LIB_GTEST_SHARED_DIR)) SET(CMAKE_CXX_STANDARD 11) INCLUDE_DIRECTORIES(/usr/include /usr/local/include) - LINK_DIRECTORIES(/usr/lib /usr/local/lib) + IF (NOT LIB_GTEST_STATIC_DIR) + LINK_DIRECTORIES(/usr/lib /usr/local/lib) + ENDIF() INCLUDE_DIRECTORIES(${HEADER_GTEST_INCLUDE_DIR}) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index dfeca03826d0bb36c4840ef01ad5acb05bf55ec3..47ee0d8e229c3b4e692f4472e7f15cbd72ceb40e 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1541,14 +1541,14 @@ static SRpcHead *rpcDecompressRpcMsg(SRpcHead *pHead) { } static int rpcAuthenticateMsg(void *pMsg, int msgLen, void *pAuth, void *pKey) { - MD5_CTX context; + T_MD5_CTX context; int ret = -1; - MD5Init(&context); - MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - MD5Update(&context, (uint8_t *)pMsg, msgLen); - MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - MD5Final(&context); + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + tMD5Update(&context, (uint8_t *)pMsg, msgLen); + tMD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + tMD5Final(&context); if (memcmp(context.digest, pAuth, sizeof(context.digest)) == 0) ret = 0; @@ -1556,13 +1556,13 @@ static int rpcAuthenticateMsg(void *pMsg, int msgLen, void *pAuth, void *pKey) { } static void rpcBuildAuthHead(void *pMsg, int msgLen, void *pAuth, void *pKey) { - MD5_CTX context; + T_MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - MD5Update(&context, (uint8_t *)pMsg, msgLen); - MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - MD5Final(&context); + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + tMD5Update(&context, (uint8_t *)pMsg, msgLen); + tMD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + tMD5Final(&context); memcpy(pAuth, context.digest, sizeof(context.digest)); } diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index a8b5a8f403cb9ca0c897d77db280e5a331c1f32e..be35f3aaf9ed80fb66414e918e920fcd714620e1 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -871,7 +871,7 @@ static void syncRestartPeer(SSyncPeer *pPeer) { int32_t ret = strcmp(pPeer->fqdn, tsNodeFqdn); if (pPeer->nodeId == 0 || ret > 0 || (ret == 0 && pPeer->port > tsSyncPort)) { sDebug("%s, check peer connection in 1000 ms", pPeer->id); - taosTmrReset(syncCheckPeerConnection, SYNC_CHECK_INTERVAL, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); + taosTmrReset(syncCheckPeerConnection, tsSyncCheckInterval, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); } } @@ -976,7 +976,7 @@ static void syncRecoverFromMaster(SSyncPeer *pPeer) { SSyncMsg msg; syncBuildSyncReqMsg(&msg, pNode->vgId); - taosTmrReset(syncNotStarted, SYNC_CHECK_INTERVAL, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); + taosTmrReset(syncNotStarted, tsSyncCheckInterval, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); if (taosWriteMsg(pPeer->peerFd, &msg, sizeof(SSyncMsg)) != sizeof(SSyncMsg)) { sError("%s, failed to send sync-req to peer", pPeer->id); @@ -1149,14 +1149,14 @@ static void syncSetupPeerConnection(SSyncPeer *pPeer) { uint32_t ip = syncResolvePeerFqdn(pPeer); if (!ip) { - taosTmrReset(syncCheckPeerConnection, SYNC_CHECK_INTERVAL, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); + taosTmrReset(syncCheckPeerConnection, tsSyncCheckInterval, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); return; } SOCKET connFd = taosOpenTcpClientSocket(ip, pPeer->port, 0); if (connFd <= 0) { sDebug("%s, failed to open tcp socket since %s", pPeer->id, strerror(errno)); - taosTmrReset(syncCheckPeerConnection, SYNC_CHECK_INTERVAL, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); + taosTmrReset(syncCheckPeerConnection, tsSyncCheckInterval, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); return; } @@ -1177,7 +1177,7 @@ static void syncSetupPeerConnection(SSyncPeer *pPeer) { } else { sDebug("%s, failed to setup peer connection to server since %s, try later", pPeer->id, strerror(errno)); taosCloseSocket(connFd); - taosTmrReset(syncCheckPeerConnection, SYNC_CHECK_INTERVAL, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); + taosTmrReset(syncCheckPeerConnection, tsSyncCheckInterval, (void *)pPeer->rid, tsSyncTmrCtrl, &pPeer->timer); } } diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index d432c951dd1d91e12c7338aeda9b0619bd949b6d..911eb5e2792bd7321d2a6ed1ed45b2d89636ce80 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -44,6 +44,14 @@ typedef struct { SDataCols * pDataCols; } SCommitH; +/* + * millisecond by default + * for TSDB_TIME_PRECISION_MILLI: 3600000L + * TSDB_TIME_PRECISION_MICRO: 3600000000L + * TSDB_TIME_PRECISION_NANO: 3600000000000L + */ +static int64_t tsTickPerHour[] = {3600000L, 3600000000L, 3600000000000L}; + #define TSDB_COMMIT_REPO(ch) TSDB_READ_REPO(&(ch->readh)) #define TSDB_COMMIT_REPO_ID(ch) REPO_ID(TSDB_READ_REPO(&(ch->readh))) #define TSDB_COMMIT_WRITE_FSET(ch) (&((ch)->wSet)) @@ -397,7 +405,7 @@ void tsdbGetRtnSnap(STsdbRepo *pRepo, SRtn *pRtn) { STsdbCfg *pCfg = REPO_CFG(pRepo); TSKEY minKey, midKey, maxKey, now; - now = taosGetTimestamp(pCfg->precision); + now = taosGetTimestamp(pCfg->precision) - tsKeepTimeOffset * tsTickPerHour[pCfg->precision]; minKey = now - pCfg->keep * tsTickPerDay[pCfg->precision]; midKey = now - pCfg->keep2 * tsTickPerDay[pCfg->precision]; maxKey = now - pCfg->keep1 * tsTickPerDay[pCfg->precision]; diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 2619266193c3010af8bc23ba2ca423086fad7b79..381320826e73e2a314234d7fd9244f827498b737 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -189,6 +189,8 @@ static void* destroyTableCheckInfo(SArray* pTableCheckInfo); static bool tsdbGetExternalRow(TsdbQueryHandleT pHandle); static int32_t tsdbQueryTableList(STable* pTable, SArray* pRes, void* filterInfo); static STableBlockInfo* moveToNextDataBlockInCurrentFile(STsdbQueryHandle* pQueryHandle); +static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCheckInfo); +static SMemRow getSMemRowInTableMem(STableCheckInfo* pCheckInfo, int32_t order, int32_t update, SMemRow* extraRow); static void tsdbInitDataBlockLoadInfo(SDataBlockLoadInfo* pBlockLoadInfo) { pBlockLoadInfo->slot = -1; @@ -632,12 +634,53 @@ static int32_t lazyLoadCacheLast(STsdbQueryHandle* pQueryHandle) { if (pTable->cacheLastConfigVersion == pRepo->cacheLastConfigVersion) { continue; } + + if (!pCheckInfo->initBuf) { + initTableMemIterator(pQueryHandle, pCheckInfo); + } + code = tsdbLoadLastCache(pRepo, pTable); if (code != 0) { tsdbError("%p uid:%" PRId64 ", tid:%d, failed to load last cache since %s", pQueryHandle, pTable->tableId.uid, pTable->tableId.tid, tstrerror(terrno)); break; } + + STsdbCfg *pCfg = &pQueryHandle->pTsdb->config; + bool cacheLastRow = CACHE_LAST_ROW(&(pRepo->config)); + if (!cacheLastRow) continue; + + SMemRow row = getSMemRowInTableMem(pCheckInfo, pQueryHandle->order, pCfg->update, NULL); + if (row == NULL) continue; + TSKEY key = memRowKey(row); + + if (!pTable->lastRow) { + STSchema *pSchema = tsdbGetTableSchema(pTable); + SMemRow lastRow = taosTMalloc(memRowMaxBytesFromSchema(pSchema)); + if (lastRow == NULL) { + return TSDB_CODE_TDB_OUT_OF_MEMORY; + } + + memRowCpy(lastRow, row); + pTable->lastRow = lastRow; + pTable->lastKey = key; + } else { + TSKEY lastRowKey = memRowKey(pTable->lastRow); + if (key <= lastRowKey) continue; + + if (memRowTLen(pTable->lastRow) < memRowTLen(row)) { + SMemRow lastRow = taosTRealloc(pTable->lastRow, memRowTLen(row)); + if (lastRow == NULL) { + taosTZfree(pTable->lastRow); + pTable->lastRow = NULL; + + return TSDB_CODE_TDB_OUT_OF_MEMORY; + } + pTable->lastRow = lastRow; + } + memRowCpy(pTable->lastRow, row); + pTable->lastKey = key; + } } return code; @@ -2895,7 +2938,7 @@ static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) { return false; } -//todo not unref yet, since it is not support multi-group interpolation query +//todo not unref yet, since it does not support multi-group interpolation query static UNUSED_FUNC void changeQueryHandleForInterpQuery(TsdbQueryHandleT pHandle) { // filter the queried time stamp in the first place STsdbQueryHandle* pQueryHandle = (STsdbQueryHandle*) pHandle; diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index c0a4986936f7d43d48aa4fac0be6f427f5db32f5..fd9a340a25a752b18ab07a8fbb2691038af3b71b 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define TSDB_CFG_MAX_NUM 133 +#define TSDB_CFG_MAX_NUM 131 #define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_VALUE_LEN 41 diff --git a/src/util/inc/tmd5.h b/src/util/inc/tmd5.h index d7fd038f37c9e1698394c90e07aaf9ac6a23590c..d73b6df55626bc9d63d3a4325326d36fbe9ab2ad 100644 --- a/src/util/inc/tmd5.h +++ b/src/util/inc/tmd5.h @@ -31,11 +31,11 @@ typedef struct { uint32_t i[2]; /* number of _bits_ handled mod 2^64 */ uint32_t buf[4]; /* scratch buffer */ uint8_t in[64]; /* input buffer */ - uint8_t digest[16]; /* actual digest after MD5Final call */ -} MD5_CTX; + uint8_t digest[16]; /* actual digest after tMD5Final call */ +} T_MD5_CTX; -void MD5Init(MD5_CTX *mdContext); -void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen); -void MD5Final(MD5_CTX *mdContext); +void tMD5Init(T_MD5_CTX *mdContext); +void tMD5Update(T_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen); +void tMD5Final(T_MD5_CTX *mdContext); #endif diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index a97b731f93c214536c009e94d05edc5c3d6e7ee9..60faa4d5a24082f0c1cf3e5967ece07d68a74e4e 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -47,10 +47,10 @@ void jsonKeyMd5(void *pMsg, int msgLen, void *pKey); bool isValidateTag(char *input); static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) { - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, inBuf, (unsigned int)inLen); - MD5Final(&context); + T_MD5_CTX context; + tMD5Init(&context); + tMD5Update(&context, inBuf, (unsigned int)inLen); + tMD5Final(&context); memcpy(target, context.digest, TSDB_KEY_LEN); } diff --git a/src/util/src/tcache.c b/src/util/src/tcache.c index 2583cdd3427838fc36584d8ac8fc19044f8e6d3d..39b674fe4f23b1e5f4ef034df7d5bb1f654d80e7 100644 --- a/src/util/src/tcache.c +++ b/src/util/src/tcache.c @@ -85,7 +85,7 @@ static void doInitRefreshThread(void) { pthread_attr_destroy(&thattr); } -pthread_t doRegisterCacheObj(SCacheObj* pCacheObj) { +static pthread_t doRegisterCacheObj(SCacheObj* pCacheObj) { pthread_once(&cacheThreadInit, doInitRefreshThread); pthread_mutex_lock(&guard); @@ -184,36 +184,44 @@ static FORCE_INLINE void doDestroyTrashcanElem(SCacheObj* pCacheObj, STrashElem } SCacheObj *taosCacheInit(int32_t keyType, int64_t refreshTimeInSeconds, bool extendLifespan, __cache_free_fn_t fn, const char* cacheName) { - const int32_t SLEEP_DURATION = 500; //500 ms + const int32_t SLEEP_DURATION_IN_MS = 500; if (refreshTimeInSeconds <= 0) { return NULL; } - + SCacheObj *pCacheObj = (SCacheObj *)calloc(1, sizeof(SCacheObj)); if (pCacheObj == NULL) { uError("failed to allocate memory, reason:%s", strerror(errno)); return NULL; } - + pCacheObj->pHashTable = taosHashInit(4096, taosGetDefaultHashFunction(keyType), false, HASH_ENTRY_LOCK); - pCacheObj->name = strdup(cacheName); if (pCacheObj->pHashTable == NULL) { free(pCacheObj); uError("failed to allocate memory, reason:%s", strerror(errno)); return NULL; } - + + pCacheObj->name = strdup(cacheName); + if (pCacheObj->name == NULL) { + taosHashCleanup(pCacheObj->pHashTable); + free(pCacheObj); + uError("failed to allocate memory, reason:%s", strerror(errno)); + return NULL; + } + // set free cache node callback function pCacheObj->freeFp = fn; pCacheObj->refreshTime = refreshTimeInSeconds * 1000; - pCacheObj->checkTick = pCacheObj->refreshTime / SLEEP_DURATION; + pCacheObj->checkTick = pCacheObj->refreshTime / SLEEP_DURATION_IN_MS; pCacheObj->extendLifespan = extendLifespan; // the TTL after the last access if (__cache_lock_init(pCacheObj) != 0) { taosHashCleanup(pCacheObj->pHashTable); + free(pCacheObj->name); free(pCacheObj); - + uError("failed to init lock, reason:%s", strerror(errno)); return NULL; } @@ -323,10 +331,10 @@ void *taosCacheAcquireByKey(SCacheObj *pCacheObj, const void *key, size_t keyLen void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data) { if (pCacheObj == NULL || data == NULL) return NULL; - + size_t offset = offsetof(SCacheDataNode, data); SCacheDataNode *ptNode = (SCacheDataNode *)((char *)data - offset); - + if (ptNode->signature != (uint64_t)ptNode) { uError("cache:%s, key: %p the data from cache is invalid", pCacheObj->name, ptNode); return NULL; @@ -342,22 +350,22 @@ void *taosCacheAcquireByData(SCacheObj *pCacheObj, void *data) { void *taosCacheTransfer(SCacheObj *pCacheObj, void **data) { if (pCacheObj == NULL || data == NULL || (*data) == NULL) return NULL; - + size_t offset = offsetof(SCacheDataNode, data); SCacheDataNode *ptNode = (SCacheDataNode *)((char *)(*data) - offset); - + if (ptNode->signature != (uint64_t)ptNode) { uError("cache:%s, key: %p the data from cache is invalid", pCacheObj->name, ptNode); return NULL; } - + assert(T_REF_VAL_GET(ptNode) >= 1); - + char *d = *data; - + // clear its reference to old area *data = NULL; - + return d; } @@ -377,7 +385,7 @@ void taosCacheRelease(SCacheObj *pCacheObj, void **data, bool _remove) { // It happens when there is only one object in the cache, and two threads which has referenced this object // start to free the it simultaneously [TD-1569]. size_t offset = offsetof(SCacheDataNode, data); - + SCacheDataNode *pNode = (SCacheDataNode *)((char *)(*data) - offset); if (pNode->signature != (uint64_t)pNode) { uError("cache:%s, %p, release invalid cache data", pCacheObj->name, pNode); @@ -542,8 +550,8 @@ void taosCacheCleanup(SCacheObj *pCacheObj) { // wait for the refresh thread quit before destroying the cache object. // But in the dll, the child thread will be killed before atexit takes effect. while(atomic_load_8(&pCacheObj->deleting) != 0) { - if (refreshWorkerNormalStopped) break; - if (refreshWorkerUnexpectedStopped) return; + if (refreshWorkerNormalStopped) break; + if (refreshWorkerUnexpectedStopped) return; taosMsleep(50); } @@ -649,7 +657,7 @@ void doCleanupDataCache(SCacheObj *pCacheObj) { taosTrashcanEmpty(pCacheObj, true); __cache_lock_destroy(pCacheObj); - + tfree(pCacheObj->name); memset(pCacheObj, 0, sizeof(SCacheObj)); free(pCacheObj); @@ -694,12 +702,12 @@ void* taosCacheTimedRefresh(void *handle) { setThreadName("cacheRefresh"); - const int32_t SLEEP_DURATION = 500; //500 ms + const int32_t SLEEP_DURATION_IN_MS = 500; int64_t count = 0; atexit(taosCacheRefreshWorkerUnexpectedStopped); while(1) { - taosMsleep(SLEEP_DURATION); + taosMsleep(SLEEP_DURATION_IN_MS); if (stopRefreshWorker) { goto _end; } @@ -778,4 +786,4 @@ void taosCacheRefresh(SCacheObj *pCacheObj, __cache_trav_fn_t fp, void* param1) void taosStopCacheRefreshWorker(void) { stopRefreshWorker = true; -} \ No newline at end of file +} diff --git a/src/util/src/terror.c b/src/util/src/terror.c index 159ae7cd1d336bdf4ff2b1d58598ab4fd164f35a..cee9245ec79abce96d8990e179cfd457791bf318 100644 --- a/src/util/src/terror.c +++ b/src/util/src/terror.c @@ -334,9 +334,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_WAL_FILE_CORRUPTED, "WAL file is corrupted TAOS_DEFINE_ERROR(TSDB_CODE_WAL_SIZE_LIMIT, "WAL size exceeds limit") // http -TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_SERVER_OFFLINE, "http server is not onlin") -TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_UNSUPPORT_URL, "url is not support") -TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_INVALID_URL, "invalid url format") +TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_SERVER_OFFLINE, "http server is not online") +TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_UNSUPPORT_URL, "url is not supported") +TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_INVALID_URL, "invalid url format") TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_NO_ENOUGH_MEMORY, "no enough memory") TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_REQUSET_TOO_BIG, "request size is too big") TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_NO_AUTH_INFO, "no auth info input") diff --git a/src/util/src/tmd5.c b/src/util/src/tmd5.c index a1fdcc6a0539ad8f7bd804ab039e0e639d20ad3e..4549c95aae855fbcf98a06003940fa86ab4fb461 100644 --- a/src/util/src/tmd5.c +++ b/src/util/src/tmd5.c @@ -2,9 +2,9 @@ *********************************************************************** ** Message-digest routines: ** ** To form the message digest for a message M ** - ** (1) Initialize a context buffer mdContext using MD5Init ** - ** (2) Call MD5Update on mdContext and M ** - ** (3) Call MD5Final on mdContext ** + ** (1) Initialize a context buffer mdContext using tMD5Init ** + ** (2) Call tMD5Update on mdContext and M ** + ** (3) Call tMD5Final on mdContext ** ** The message digest is now in mdContext->digest[0...15] ** *********************************************************************** */ @@ -82,11 +82,11 @@ static uint8_t PADDING[64] = {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x (a) += (b); \ } -/* The routine MD5Init initializes the message-digest context +/* The routine tMD5Init initializes the message-digest context mdContext. All fields are set to zero. */ -void MD5Init(MD5_CTX *mdContext) { - memset(mdContext, 0, sizeof(MD5_CTX)); +void tMD5Init(T_MD5_CTX *mdContext) { + memset(mdContext, 0, sizeof(T_MD5_CTX)); /* Load magic initialization constants. */ mdContext->buf[0] = (uint32_t)0x67452301; @@ -95,11 +95,11 @@ void MD5Init(MD5_CTX *mdContext) { mdContext->buf[3] = (uint32_t)0x10325476; } -/* The routine MD5Update updates the message-digest context to +/* The routine tMD5Update updates the message-digest context to account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed. */ -void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { +void tMD5Update(T_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { uint32_t in[16]; int mdi; unsigned int i, ii; @@ -127,10 +127,10 @@ void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { } } -/* The routine MD5Final terminates the message-digest computation and +/* The routine tMD5Final terminates the message-digest computation and ends with the desired message digest in mdContext->digest[0...15]. */ -void MD5Final(MD5_CTX *mdContext) { +void tMD5Final(T_MD5_CTX *mdContext) { uint32_t in[16]; int mdi; unsigned int i, ii; @@ -145,7 +145,7 @@ void MD5Final(MD5_CTX *mdContext) { /* pad out to 56 mod 64 */ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); - MD5Update(mdContext, PADDING, padLen); + tMD5Update(mdContext, PADDING, padLen); /* append length in bits and transform */ for (i = 0, ii = 0; i < 14; i++, ii += 4) diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index 8d69a87e77bff594e7a99b2a63d4d849214eebe9..0ebe9c8f8af23186fb4cd60824bfa5641d2090a9 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -17,6 +17,7 @@ #include "tulog.h" #include "tsocket.h" #include "taoserror.h" +#include "tglobal.h" #ifndef SIGPIPE #define SIGPIPE EPIPE @@ -362,7 +363,7 @@ SOCKET taosOpenTcpClientSocket(uint32_t destIp, uint16_t destPort, uint32_t clie wfd[0].fd = sockFd; wfd[0].events = POLLOUT; - int res = poll(wfd, 1, TCP_CONN_TIMEOUT); + int res = poll(wfd, 1, tsTcpConnTimeout); if (res == -1 || res == 0) { uError("failed to connect socket, ip:0x%x, port:%hu(poll error/conn timeout)", destIp, destPort); taosCloseSocket(sockFd); // diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 8bcef9f32b152082c7ab715ededc996b63558562..7e08178c42cbb7e34a0aec340352916d874a7094 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -455,11 +455,11 @@ char *taosIpStr(uint32_t ipInt) { } void jsonKeyMd5(void *pMsg, int msgLen, void *pKey) { - MD5_CTX context; + T_MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)pMsg, msgLen); - MD5Final(&context); + tMD5Init(&context); + tMD5Update(&context, (uint8_t *)pMsg, msgLen); + tMD5Final(&context); memcpy(pKey, context.digest, sizeof(context.digest)); } diff --git a/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md b/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md index 9874b137dae611e0b7b82868a65b0ef4668b8f7d..377ea66d274ff4f3d4bc3613bf9379462941ca33 100644 --- a/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md +++ b/tests/How-To-Run-Test-And-How-To-Add-New-Test-Case.md @@ -1,76 +1,98 @@ -### Prepare development environment +# Prepare development environment -1. sudo apt install - build-essential cmake net-tools python-pip python-setuptools python3-pip - python3-setuptools valgrind psmisc curl +```shell +sudo apt install build-essential cmake net-tools python-pip python-setuptools \ + python3-pip python3-setuptools valgrind psmisc curl -2. git clone ; cd TDengine +git clone https://github.com/taosdata/TDengine -3. mkdir debug; cd debug; cmake ..; make ; sudo make install +cd TDengine -4. cd ../tests && pip3 install -r requirements.txt +git submodule update --init --recursive +mkdir debug +cd debug -> Note: Both Python2 and Python3 are currently supported by the Python test -> framework. Since Python2 is no longer officially supported by Python Software -> Foundation since January 1, 2020, it is recommended that subsequent test case -> development be guaranteed to run correctly on Python3. +cmake .. -DBUILD_TOOLS=true -DBUILD_HTTP=false -> For Python2, please consider being compatible if appropriate without -> additional burden. +make + +sudo make install + +cd ../tests + +pip3 install -r requirements.txt +``` + +> Note: Both Python2 and Python3 are currently supported by the Python test +> framework. Since Python2 is no longer officially supported by Python Software +> Foundation since January 1, 2020, it is recommended that subsequent test case +> development be guaranteed to run correctly on Python3. > -> If you use some new Linux distribution like Ubuntu 20.04 which already do not -> include Python2, please do not install Python2-related packages. +> For Python2, please consider being compatible if appropriate without +> additional burden. > ->   - -### How to run Python test suite +> If you use some new Linux distribution like Ubuntu 20.04 which already do not +> include Python2, please do not install Python2-related packages. +> +>   -1. cd \/tests/pytest +## How to run Python test suite -2. ./smoketest.sh \# for smoke test +``` +cd TDengine/tests/pytest -3. ./smoketest.sh -g \# for memory leak detection test with valgrind +# for smoke test +./smoketest.sh -4. ./fulltest.sh \# for full test +# for memory leak detection test with valgrind +./smoketest.sh -g -> Note1: TDengine daemon's configuration and data files are stored in -> \/sim directory. As a historical design, it's same place with -> TSIM script. So after the TSIM script ran with sudo privilege, the directory -> has been used by TSIM then the python script cannot write it by a normal -> user. You need to remove the directory completely first before running the -> Python test case. We should consider using two different locations to store -> for TSIM and Python script. +# for full test +./fulltest.sh +``` -> Note2: if you need to debug crash problem with a core dump, you need -> manually edit smoketest.sh or fulltest.sh to add "ulimit -c unlimited" -> before the script line. Then you can look for the core file in -> \/tests/pytest after the program crash. +> Note1: TDengine daemon's configuration and data files are stored in +> \/sim directory. As a historical design, it's same place with +> TSIM script. So after the TSIM script ran with sudo privilege, the directory +> has been used by TSIM then the python script cannot write it by a normal +> user. You need to remove the directory completely first before running the +> Python test case. We should consider using two different locations to store +> for TSIM and Python script. +> +> Note2: if you need to debug crash problem with a core dump, you need +> manually edit smoketest.sh or fulltest.sh to add "ulimit -c unlimited" +> before the script line. Then you can look for the core file in +> \/tests/pytest after the program crash. +## How to add a new test case -### How to add a new test case +### 1. TSIM test cases -**1. TSIM test cases:** +TSIM was the testing framework has been used internally. Now it still be used + to run the test cases we develop in the past as a legacy system. We are + turning to use Python to develop new test case and are abandoning TSIM + gradually. -TSIM was the testing framework has been used internally. Now it still be used to run the test cases we develop in the past as a legacy system. We are turning to use Python to develop new test case and are abandoning TSIM gradually. +### 2. Python test cases -**2. Python test cases:** +#### 2.1 Add a new Python test case -**2.1 Please refer to \/tests/pytest/insert/basic.py to add a new -test case.** The new test case must implement 3 functions, where self.init() -and self.stop() simply copy the contents of insert/basic.py and the test -logic is implemented in self.run(). You can refer to the code in the util +Please refer to `TDengine/tests/pytest/insert/basic.py` to add a new +test case. The new test case must implement 3 functions, where `self.init()` +and `self.stop()` simply copy the contents of `insert/basic.py` and the test +logic is implemented in `self.run()`. You can refer to the code in the `util` directory for more information. -**2.2 Edit smoketest.sh to add the path and filename of the new test case** +#### 2.2 Edit smoketest.sh to add the path and filename of the new test case Note: The Python test framework may continue to be improved in the future, hopefully, to provide more functionality and ease of writing test cases. The method of writing the test case above does not exclude that it will also be affected. -**2.3 What test.py does in detail:** +#### 2.3 What test.py does in detail test.py is the entry program for test case execution and monitoring. @@ -79,7 +101,7 @@ test.py has the following functions. \-f --file, Specifies the test case file name to be executed -p --path, Specifies deployment path -\-m --master, Specifies the master server IP for cluster deployment +\-m --master, Specifies the master server IP for cluster deployment -c--cluster, test cluster function -s--stop, terminates all running nodes @@ -87,156 +109,129 @@ test.py has the following functions. \-h--help, display help -**2.4 What util/log.py does in detail:** +#### 2.4 What util/log.py does in detail -log.py is quite simple, the main thing is that you can print the output in -different colors as needed. The success() should be called for successful -test case execution and the success() will print green text. The exit() will -print red text and exit the program, exit() should be called for test +`log.py` is quite simple, the main thing is that you can print the output in +different colors as needed. The `success()` should be called for successful +test case execution and the `success()` will print green text. The `exit()` will +print red text and exit the program, `exit()` should be called for test failure. -**util/log.py** - -... - -    def info(self, info): - -        print("%s %s" % (datetime.datetime.now(), info)) - -  - -    def sleep(self, sec): - -        print("%s sleep %d seconds" % (datetime.datetime.now(), sec)) - -        time.sleep(sec) - -  - -    def debug(self, err): - -        print("\\033[1;36m%s %s\\033[0m" % (datetime.datetime.now(), err)) - -  - -    def success(self, info): +- util/log.py -        printf("\\033[1;32m%s %s\\033[0m" % (datetime.datetime.now(), info)) +```python + def info(self, info): + print("%s %s" % (datetime.datetime.now(), info)) -  + def sleep(self, sec): + print("%s sleep %d seconds" % (datetime.datetime.now(), sec)) + time.sleep(sec) -    def notice(self, err): + def debug(self, err): + print("\\033[1;36m%s %s\\033[0m" % (datetime.datetime.now(), err)) -        printf("\\033[1;33m%s %s\\033[0m" % (datetime.datetime.now(), err)) + def success(self, info): + printf("\\033[1;32m%s %s\\033[0m" % (datetime.datetime.now(), info)) -  + def notice(self, err): + printf("\\033[1;33m%s %s\\033[0m" % (datetime.datetime.now(), err)) -    def exit(self, err): + def exit(self, err): + printf("\\033[1;31m%s %s\\033[0m" % (datetime.datetime.now(), err)) + sys.exit(1) -        printf("\\033[1;31m%s %s\\033[0m" % (datetime.datetime.now(), err)) + def printNoPrefix(self, info): + printf("\\033[1;36m%s\\033[0m" % (info) +``` -        sys.exit(1) - -  - -    def printNoPrefix(self, info): - -        printf("\\033[1;36m%s\\033[0m" % (info) - -... - -**2.5 What util/sql.py does in detail:** +#### 2.5 What util/sql.py does in detail SQL.py is mainly used to execute SQL statements to manipulate the database, and the code is extracted and commented as follows: -**util/sql.py** +- util/sql.py -\# prepare() is mainly used to set up the environment for testing table and -data, and to set up the database db for testing. do not call prepare() if you +\# `prepare()` is mainly used to set up the environment for testing table and +data, and to set up the database db for testing. do not call `prepare()` if you need to test the database operation command. +```python def prepare(self): + tdLog.info("prepare database:db") + self.cursor.execute('reset query cache') + self.cursor.execute('drop database if exists db') + self.cursor.execute('create database db') + self.cursor.execute('use db') +``` -tdLog.info("prepare database:db") - -self.cursor.execute('reset query cache') - -self.cursor.execute('drop database if exists db') - -self.cursor.execute('create database db') - -self.cursor.execute('use db') - -... - -\# query() is mainly used to execute select statements for normal syntax input +\# `query()` is mainly used to execute select statements for normal syntax input +```python def query(self, sql): -... +``` -\# error() is mainly used to execute the select statement with the wrong syntax +\# `error()` is mainly used to execute the select statement with the wrong syntax input, the error will be caught as a reasonable behavior, if not caught it will prove that the test failed +```python def error() +``` -... - -\# checkRows() is used to check the number of returned lines after calling -query(select ...) after calling the query(select ...) to check the number of +\# `checkRows()` is used to check the number of returned lines after calling +`query(select ...)` after calling the `query(select ...)` to check the number of rows of returned results. +```python def checkRows(self, expectRows): +``` -... - -\# checkData() is used to check the returned result data after calling -query(select ...) after the query(select ...) is called, failure to meet +\# `checkData()` is used to check the returned result data after calling +`query(select ...)` after the `query(select ...)` is called, failure to meet expectation is +```python def checkData(self, row, col, data): +``` -... - -\# getData() returns the result data after calling query(select ...) to return -the resulting data after calling query(select ...) +\# `getData()` returns the result data after calling `query(select ...)` to return +the resulting data after calling `query(select ...)` +```python def getData(self, row, col): +``` -... - -\# execute() used to execute sql and return the number of affected rows +\# `execute()` used to execute SQL command and return the number of affected rows +```python def execute(self, sql): +``` -... - -\# executeTimes() Multiple executions of the same sql statement +\# `executeTimes()` Multiple executions of the same sql statement +```python def executeTimes(self, sql, times): +``` -... - -\# CheckAffectedRows() Check if the number of affected rows is as expected +\# `checkAffectedRows()` to check if the number of affected rows is as expected +```python def checkAffectedRows(self, expectAffectedRows): +``` -... - -### CI submission adoption principle. +## CI submission adoption principle -- Every commit / PR compilation must pass. Currently, the warning is treated +- Every commit / PR compilation must pass. Currently, the warning is treated as an error, so the warning must also be resolved. -- Test cases that already exist must pass. +- Test cases that already exist must pass. -- Because CI is very important to support build and automatically test +- Because CI is very important to support build and automatically test procedure, it is necessary to manually test the test case before adding it and do as many iterations as possible to ensure that the test case provides stable and reliable test results when added. -> Note: In the future, according to the requirements and test development -> progress will add stress testing, performance testing, code style, -> and other features based on functional testing. +> Note: In the future, according to the requirements and test development +> progress will add stress testing, performance testing, code style, +> and other features based on functional testing. diff --git a/tests/auto_crash_gen_script/auto_crash_gen_script.py b/tests/auto_crash_gen_script/auto_crash_gen_script.py new file mode 100644 index 0000000000000000000000000000000000000000..547526c8ccaa710f88d4ad2d64bd1d1cd6d31e9b --- /dev/null +++ b/tests/auto_crash_gen_script/auto_crash_gen_script.py @@ -0,0 +1,273 @@ +################################################################### +# Copyright (c) 2020 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +import os ,sys +import random +import argparse +import subprocess +import time + +# set path about run instance + +core_path = '/home/coredump/' +base_dir = os.path.dirname(os.path.realpath(__file__)) +if base_dir.find("community")>0: + repo = "community" +elif base_dir.find("TDengine")>0: + repo = "TDengine" +else: + repo ="TDengine" +print("base_dir:",base_dir) +home_dir = base_dir[:base_dir.find(repo)] +print("home_dir:",home_dir) +run_dir = os.path.join(home_dir,'run_dir') +run_dir = os.path.abspath(run_dir) +print("run dir is set at :",run_dir) +if not os.path.exists(run_dir): + os.mkdir(run_dir) +run_log_file = run_dir+'/crash_gen_run.log' +crash_gen_cmds_file = os.path.join(run_dir, 'crash_gen_cmds.sh') +exit_status_logs = os.path.join(run_dir, 'crash_exit.log') + +def get_path(): + buildPath='' + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + +def random_args(args_list): + nums_args_list = ["--max-dbs","--num-replicas","--num-dnodes","--max-steps","--num-threads",] # record int type arguments + bools_args_list = ["--auto-start-service" , "--debug","--run-tdengine","--ignore-errors","--track-memory-leaks","--larger-data","--mix-oos-data","--dynamic-db-table-names", + "--per-thread-db-connection","--record-ops","--verify-data","--use-shadow-db","--continue-on-exception" + ] # record bool type arguments + strs_args_list = ["--connector-type"] # record str type arguments + + args_list["--auto-start-service"]= True + args_list["--continue-on-exception"]=True + # connect_types=['native','rest','mixed'] # restful interface has change ,we should trans dbnames to connection or change sql such as "db.test" + connect_types=['native'] + # args_list["--connector-type"]=connect_types[random.randint(0,2)] + args_list["--connector-type"]= connect_types[0] + args_list["--max-dbs"]= random.randint(1,10) + + dnodes = [1,3] # set single dnodes; + + args_list["--num-dnodes"]= random.sample(dnodes,1)[0] + args_list["--num-replicas"]= random.randint(1,args_list["--num-dnodes"]) + args_list["--debug"]=False + args_list["--per-thread-db-connection"]=True + args_list["--track-memory-leaks"]=False + + num = random.randint(1, 10) # set --track-memory-leaks randomly + if num > 8 : + args_list["--track-memory-leaks"]=True + + + args_list["--max-steps"]=random.randint(300,500) + + threads = [32,64,128] + args_list["--num-threads"]=random.sample(threads,1)[0] #$ debug + args_list["--ignore-errors"]=[] ## can add error codes for detail + + + args_list["--run-tdengine"]= False + args_list["--use-shadow-db"]= False + args_list["--dynamic-db-table-names"]= False + args_list["--verify-data"]= False + args_list["--record-ops"] = False + + for key in bools_args_list: + set_bool_value = [True,False] + if key == "--auto-start-service" : + continue + elif key =="--run-tdengine": + continue + elif key == "--ignore-errors": + continue + elif key == "--debug": + continue + elif key == "--per-thread-db-connection": + continue + elif key == "--continue-on-exception": + continue + elif key == "--use-shadow-db": + continue + elif key =="--track-memory-leaks": + continue + elif key == "--dynamic-db-table-names": + continue + elif key == "--verify-data": + continue + elif key == "--record-ops": + continue + else: + args_list[key]=set_bool_value[random.randint(0,1)] + return args_list + +def limits(args_list): + if args_list["--use-shadow-db"]==True: + if args_list["--max-dbs"] > 1: + print("Cannot combine use-shadow-db with max-dbs of more than 1 ,set max-dbs=1") + args_list["--max-dbs"]=1 + else: + pass + + elif args_list["--num-replicas"]==0: + print(" make sure num-replicas is at least 1 ") + args_list["--num-replicas"]=1 + elif args_list["--num-replicas"]==1: + pass + + elif args_list["--num-replicas"]>1: + if not args_list["--auto-start-service"]: + print("it should be deployed by crash_gen auto-start-service for multi replicas") + + else: + pass + + return args_list + +def get_cmds(args_list): + build_path = get_path() + if repo == "community": + crash_gen_path = build_path[:-5]+"community/tests/pytest/" + elif repo == "TDengine": + crash_gen_path = build_path[:-5]+"/tests/pytest/" + else: + pass + + bools_args_list = ["--auto-start-service" , "--debug","--run-tdengine","--ignore-errors","--track-memory-leaks","--larger-data","--mix-oos-data","--dynamic-db-table-names", + "--per-thread-db-connection","--record-ops","--verify-data","--use-shadow-db","--continue-on-exception"] + arguments = "" + for k ,v in args_list.items(): + if k == "--ignore-errors": + if v: + arguments+=(k+"="+str(v)+" ") + else: + arguments+="" + elif k in bools_args_list and v==True: + arguments+=(k+" ") + elif k in bools_args_list and v==False: + arguments+="" + else: + arguments+=(k+"="+str(v)+" ") + crash_gen_cmd = 'cd %s && ./crash_gen.sh %s '%(crash_gen_path ,arguments) + return crash_gen_cmd + +def run_crash_gen(crash_cmds,result_file): + os.system('echo "%s">>%s'%(crash_cmds,crash_gen_cmds_file)) + os.system("cp %s %s"%(crash_gen_cmds_file, core_path)) + os.system("%s>>%s"%(crash_cmds,result_file)) + +def check_status(result_file): + run_code = subprocess.Popen("tail -n 50 %s"%result_file, shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") + os.system("tail -n 50 %s>>%s"%(result_file,exit_status_logs)) + mem_status = check_memory(run_dir) + if mem_status >0: + return mem_status + if "Crash_Gen is now exiting with status code: 1" in run_code: + return 1 + elif "Crash_Gen is now exiting with status code: 0" in run_code: + return 0 + else: + return 2 + +def check_memory(run_dir): + ''' + invalid read, invalid write + ''' + mem_report_path = os.path.join(run_dir , "reporter") + if not os.path.exists(mem_report_path): + os.mkdir(mem_report_path) + status = 0 + stderr_files = subprocess.Popen("find %s -name \"stderr.log\" "%run_dir , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") + stderr_list = stderr_files.split("\n")[:-1] + for stderr_file in stderr_list: + print(stderr_file) + grep_res = subprocess.Popen("grep -i 'Invalid read' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") + dnode_name = stderr_file.split("/")[-3] + back_path = os.path.join(core_path,"reporter",dnode_name) + if not os.path.exists(back_path): + os.system("mkdir -p %s"%back_path) + + if grep_res: + os.system("cp %s %s"%(stderr_file , back_path)) + status = 4 + break + + grep_res = subprocess.Popen("grep -i 'Invalid write' %s "%stderr_file , shell=True, stdout=subprocess.PIPE,stderr=subprocess.STDOUT).stdout.read().decode("utf-8") + if grep_res: + status = 4 + os.system("cp %s %s"%(stderr_file , back_path)) + break + return status + +def main(): + args_list = {"--auto-start-service":False ,"--max-dbs":0,"--connector-type":"native","--debug":False,"--run-tdengine":False,"--ignore-errors":[], + "--num-replicas":1 ,"--track-memory-leaks":False , "--larger-data":False, "--mix-oos-data":False, "--dynamic-db-table-names":False,"--num-dnodes":1, + "--per-thread-db-connection":False , "--record-ops":False , "--max-steps":100, "--num-threads":10, "--verify-data":False,"--use-shadow-db":False , + "--continue-on-exception":False } + + build_path = get_path() + os.system("pip3 install taospy") + if repo =="community": + crash_gen_path = build_path[:-5]+"community/tests/pytest/" + elif repo =="TDengine": + crash_gen_path = build_path[:-5]+"/tests/pytest/" + else: + pass + print(crash_gen_path) + if os.path.exists(crash_gen_path+"crash_gen.sh"): + print(" make sure crash_gen.sh is ready") + else: + print( " crash_gen.sh is not exists ") + sys.exit(1) + + # set value args + + args = random_args(args_list) + args = limits(args) + crash_cmds = get_cmds(args) + crash_cmds= crash_cmds+"--set-path="+"%s"%run_dir + # clean run_dir + os.system('rm -rf %s'%run_dir ) + if not os.path.exists(run_dir): + os.mkdir(run_dir) + print(crash_cmds) + run_crash_gen(crash_cmds,run_log_file) + status = check_status(run_log_file) + + print("exit status : ", status) + if status ==4: + print('======== crash_gen found memory bugs at reporter ========') + if status >0: + print('======== crash_gen run failed and not exit as expected ========') + else: + print('======== crash_gen run sucess and exit as expected ========') + exit(status) + + +if __name__ == '__main__': + main() + + diff --git a/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml index 55fc281f58544a317f2e423e47b6a7d821296b09..4f963c0812a5cd95ca755736d531db17ab18f704 100644 --- a/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml +++ b/tests/comparisonTest/opentsdb/opentsdbtest/pom.xml @@ -118,7 +118,7 @@ com.fasterxml.jackson.core jackson-databind - 2.10.0.pr1 + 2.12.6.1 diff --git a/tests/develop-test/0-others/json_tag.py b/tests/develop-test/0-others/json_tag.py index d3891a796a675da54d7180dadd2621b5ec7caae9..c78e48b6d19bc1b977db417233b6e12c61a66112 100644 --- a/tests/develop-test/0-others/json_tag.py +++ b/tests/develop-test/0-others/json_tag.py @@ -530,6 +530,26 @@ class TDTestCase: tdSql.checkData(5, 2, 4096) tdSql.query("describe jsons1_1") tdSql.checkData(5, 2, 4096) + + #test TD-13918 + tdSql.execute("drop table if exists jsons_13918_1") + tdSql.execute("drop table if exists jsons_13918_2") + tdSql.execute("drop table if exists jsons_13918_3") + tdSql.execute("drop table if exists jsons_13918_4") + tdSql.execute("drop table if exists jsons_stb") + tdSql.execute("create table jsons_stb (ts timestamp, dataInt int) tags (jtag json)") + tdSql.error("create table jsons_13918_1 using jsons_stb tags ('nullx')") + tdSql.error("create table jsons_13918_2 using jsons_stb tags (nullx)") + tdSql.error("insert into jsons_13918_3 using jsons_stb tags('NULLx') values(1591061628001, 11)") + tdSql.error("insert into jsons_13918_4 using jsons_stb tags(NULLx) values(1591061628002, 11)") + tdSql.execute("create table jsons_13918_1 using jsons_stb tags ('null')") + tdSql.execute("create table jsons_13918_2 using jsons_stb tags (null)") + tdSql.execute("insert into jsons_13918_1 values(1591061628003, 11)") + tdSql.execute("insert into jsons_13918_2 values(1591061628004, 11)") + tdSql.execute("insert into jsons_13918_3 using jsons_stb tags('NULL') values(1591061628005, 11)") + tdSql.execute("insert into jsons_13918_4 using jsons_stb tags(\"NULL\") values(1591061628006, 11)") + tdSql.query("select * from jsons_stb") + tdSql.checkRows(4) def stop(self): tdSql.close() diff --git a/tests/develop-test/2-query/function_histogram.py b/tests/develop-test/2-query/function_histogram.py index 87c38f35c91c54473653d2881936b033a555bbff..b16db06850f2e5cce537231ecca48279642d5112 100644 --- a/tests/develop-test/2-query/function_histogram.py +++ b/tests/develop-test/2-query/function_histogram.py @@ -2535,21 +2535,21 @@ class TDTestCase: tdSql.checkData(4, 0, '{"lower_bin":9, "upper_bin":15, "count":2}'); #select session - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1w);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1w);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1d);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1d);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1h);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1h);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1m);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1m);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb session (col_timestamp, 1s);') #tdSql.checkRows(16) @@ -2602,100 +2602,100 @@ class TDTestCase: tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb state_window(col_nchar);') #select interval/sliding/fill - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1y);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1n);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1y);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1w);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1n);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1d);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1w);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1h);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1s);') - tdSql.checkRows(16) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(1, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(2, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(3, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(4, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(5, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(6, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(7, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(8, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(9, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(10, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(11, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(12, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(13, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(14, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(15, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1a);') - tdSql.checkRows(16) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(1, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(2, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(3, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(4, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(5, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(6, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(7, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(8, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(9, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(10, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(11, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(12, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(13, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(14, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(15, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1w) sliding(1w);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1d);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1d) sliding(1d);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1h);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1h) sliding(1h);') - tdSql.checkRows(1) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); - - tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1s) sliding(1s);') - tdSql.checkRows(16) - tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(1, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(2, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(3, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(4, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(5, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(6, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(7, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(8, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(9, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(10, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(11, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); - tdSql.checkData(12, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(13, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(14, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - tdSql.checkData(15, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); - - tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1w and col_timestamp < now + 1w interval(1w) fill(NULL);') - tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1d and col_timestamp < now + 1d interval(1d) fill(None);') - tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1h and col_timestamp < now + 1h interval(1h) fill(Prev);') - tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1m and col_timestamp < now + 1m interval(1m) fill(Next);') - tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1s and col_timestamp < now + 1s interval(1s) fill(Linear);') - tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1a and col_timestamp < now + 1a interval(1a) fill(Value, 1);') + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1s);') + #tdSql.checkRows(16) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(1, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(2, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(3, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(4, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(5, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(6, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(7, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(8, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(9, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(10, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(11, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(12, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(13, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(14, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(15, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1a);') + #tdSql.checkRows(16) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(1, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(2, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(3, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(4, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(5, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(6, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(7, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(8, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(9, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(10, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(11, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(12, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(13, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(14, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(15, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1w) sliding(1w);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1d) sliding(1d);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1h) sliding(1h);') + #tdSql.checkRows(1) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":10}'); + + #tdSql.query('select histogram(col_int, "user_input", "[0,10]", 0) from tb interval(1s) sliding(1s);') + #tdSql.checkRows(16) + #tdSql.checkData(0, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(1, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(2, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(3, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(4, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(5, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(6, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(7, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(8, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(9, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(10, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(11, 1, '{"lower_bin":0, "upper_bin":10, "count":1}'); + #tdSql.checkData(12, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(13, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(14, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + #tdSql.checkData(15, 1, '{"lower_bin":0, "upper_bin":10, "count":0}'); + + #tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1w and col_timestamp < now + 1w interval(1w) fill(NULL);') + #tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1d and col_timestamp < now + 1d interval(1d) fill(None);') + #tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1h and col_timestamp < now + 1h interval(1h) fill(Prev);') + #tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1m and col_timestamp < now + 1m interval(1m) fill(Next);') + #tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1s and col_timestamp < now + 1s interval(1s) fill(Linear);') + #tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from tb where col_timestamp > now - 1a and col_timestamp < now + 1a interval(1a) fill(Value, 1);') #select group by tdSql.error('select histogram(col_int, "user_input", "[0,10]", 0) from stb group by col_tinyint;') diff --git a/tests/develop-test/2-query/function_unique.py b/tests/develop-test/2-query/function_unique.py index cb6f372ffb48dcd098db0e9f21752d3dd57ba1e9..8a8e0bef2b737e09cea99754dad948b72b12f232 100644 --- a/tests/develop-test/2-query/function_unique.py +++ b/tests/develop-test/2-query/function_unique.py @@ -276,7 +276,7 @@ class TDTestCase: tdSql.checkData(0, 1, 1) tdSql.checkData(3, 1, 1) - tdSql.execute('create table unique1 (ts timestamp, voltage bigint,num smallint, dbool bool, dtiny tinyint unsigned, dfloat float, ddouble double, dchar nchar(4093), dbinary binary(64), dtime timestamp) tags (jtag json)') + tdSql.execute('create table unique1 (ts timestamp, voltage bigint,num smallint, dbool bool, dtiny tinyint unsigned, dfloat float, ddouble double, dchar nchar(64), dbinary binary(64), dtime timestamp) tags (jtag json)') tdSql.execute('create table D011 using unique1 tags (\'{"k1":"v1"}\')') tdSql.execute('create table D012 using unique1 tags (\'{"k1":"v1","k2":7}\')') tdSql.execute('create table D013 using unique1 tags (\'{"k3":"v3"}\')') diff --git a/tests/develop-test/2-query/math_funcs.py b/tests/develop-test/2-query/math_funcs.py index d7ea3b5b05ac51ed5f830fd10df06587f0aa0550..14949537a08ab39324667095da51b66983d807b4 100644 --- a/tests/develop-test/2-query/math_funcs.py +++ b/tests/develop-test/2-query/math_funcs.py @@ -1,22 +1,23 @@ -import sys +import sys from util.log import * from util.cases import * from util.sql import * from util.dnodes import tdDnodes -from math import inf +from math import inf, nan + class TDTestCase: def caseDescription(self): - ''' - case1: [TD-11204]Difference improvement that can ignore negative - ''' + """ + case1: [TD-11204]Difference improvement that can ignore negative + """ return - + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) self._conn = conn - + def restartTaosd(self, index=1, dbname="db"): tdDnodes.stop(index) tdDnodes.startWithoutSleep(index) @@ -26,8 +27,10 @@ class TDTestCase: print("running {}".format(__file__)) tdSql.execute("drop database if exists math_funcs") tdSql.execute("create database if not exists math_funcs") - tdSql.execute('use math_funcs') - tdSql.execute('create table stb1 (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);') + tdSql.execute("use math_funcs") + tdSql.execute( + "create table stb1 (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);" + ) tdSql.execute("create table tb1 using stb1 tags(1,'1',1.0);") @@ -35,52 +38,96 @@ class TDTestCase: tdSql.execute("create table tb3 using stb1 tags(3,'3',3.0);") - tdSql.execute('insert into tb1 values (\'2021-11-11 09:00:00\',true,1,1,1,1,1,1,"123","1234",1,1,1,1);') + tdSql.execute( + 'insert into tb1 values (\'2021-11-11 09:00:00\',true,1,1,1,1,1,1,"123","1234",1,1,1,1);' + ) - tdSql.execute("insert into tb1 values ('2021-11-11 09:00:01',true,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);") + tdSql.execute( + "insert into tb1 values ('2021-11-11 09:00:01',true,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);" + ) - tdSql.execute('insert into tb1 values (\'2021-11-11 09:00:02\',true,2,NULL,2,NULL,2,NULL,"234",NULL,2,NULL,2,NULL);') + tdSql.execute( + "insert into tb1 values ('2021-11-11 09:00:02',true,2,NULL,2,NULL,2,NULL,\"234\",NULL,2,NULL,2,NULL);" + ) - tdSql.execute('insert into tb1 values (\'2021-11-11 09:00:03\',false,NULL,3,NULL,3,NULL,3,NULL,"3456",NULL,3,NULL,3);') + tdSql.execute( + "insert into tb1 values ('2021-11-11 09:00:03',false,NULL,3,NULL,3,NULL,3,NULL,\"3456\",NULL,3,NULL,3);" + ) - tdSql.execute('insert into tb1 values (\'2021-11-11 09:00:04\',true,4,4,4,4,4,4,"456","4567",4,4,4,4);') + tdSql.execute( + 'insert into tb1 values (\'2021-11-11 09:00:04\',true,4,4,4,4,4,4,"456","4567",4,4,4,4);' + ) - tdSql.execute('insert into tb1 values (\'2021-11-11 09:00:05\',true,127,32767,2147483647,9223372036854775807,3.402823466e+38,1.79769e+308,"567","5678",254,65534,4294967294,9223372036854775807);') + tdSql.execute( + 'insert into tb1 values (\'2021-11-11 09:00:05\',true,127,32767,2147483647,9223372036854775807,3.402823466e+38,1.79769e+308,"567","5678",254,65534,4294967294,9223372036854775807);' + ) - tdSql.execute('insert into tb1 values (\'2021-11-11 09:00:06\',true,-127,-32767,-2147483647,-9223372036854775807,-3.402823466e+38,-1.79769e+308,"678","6789",0,0,0,0);') + tdSql.execute( + 'insert into tb1 values (\'2021-11-11 09:00:06\',true,-127,-32767,-2147483647,-9223372036854775807,-3.402823466e+38,-1.79769e+308,"678","6789",0,0,0,0);' + ) - tdSql.execute('insert into tb2 values (\'2021-11-11 09:00:00\',true,1,1,1,1,1,1,"111","1111",1,1,1,1);') + tdSql.execute( + 'insert into tb2 values (\'2021-11-11 09:00:00\',true,1,1,1,1,1,1,"111","1111",1,1,1,1);' + ) - tdSql.execute('insert into tb2 values (\'2021-11-11 09:00:01\',true,2,2,2,2,2,2,"222","2222",2,2,2,2);') + tdSql.execute( + 'insert into tb2 values (\'2021-11-11 09:00:01\',true,2,2,2,2,2,2,"222","2222",2,2,2,2);' + ) - tdSql.execute('insert into tb2 values (\'2021-11-11 09:00:02\',true,3,3,2,3,3,3,"333","3333",3,3,3,3);') + tdSql.execute( + 'insert into tb2 values (\'2021-11-11 09:00:02\',true,3,3,2,3,3,3,"333","3333",3,3,3,3);' + ) - tdSql.execute('insert into tb2 values (\'2021-11-11 09:00:03\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);') + tdSql.execute( + 'insert into tb2 values (\'2021-11-11 09:00:03\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);' + ) - tdSql.execute('insert into tb2 values (\'2021-11-11 09:00:04\',true,5,5,5,5,5,5,"555","5555",5,5,5,5);') + tdSql.execute( + 'insert into tb2 values (\'2021-11-11 09:00:04\',true,5,5,5,5,5,5,"555","5555",5,5,5,5);' + ) - tdSql.execute('insert into tb2 values (\'2021-11-11 09:00:05\',true,6,6,6,6,6,6,"666","6666",6,6,6,6);') + tdSql.execute( + 'insert into tb2 values (\'2021-11-11 09:00:05\',true,6,6,6,6,6,6,"666","6666",6,6,6,6);' + ) - tdSql.execute('insert into tb2 values (\'2021-11-11 09:00:06\',true,7,7,7,7,7,7,"777","7777",7,7,7,7);') + tdSql.execute( + 'insert into tb2 values (\'2021-11-11 09:00:06\',true,7,7,7,7,7,7,"777","7777",7,7,7,7);' + ) - tdSql.execute('create table tbn (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned);') + tdSql.execute( + "create table tbn (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned);" + ) - tdSql.execute('insert into tbn values (\'2021-11-11 09:00:00\',true,1,1,1,1,1,1,"111","1111",1,1,1,1);') + tdSql.execute( + 'insert into tbn values (\'2021-11-11 09:00:00\',true,1,1,1,1,1,1,"111","1111",1,1,1,1);' + ) - tdSql.execute('insert into tbn values (\'2021-11-11 09:00:01\',true,2,2,2,2,2,2,"222","2222",2,2,2,2);') + tdSql.execute( + 'insert into tbn values (\'2021-11-11 09:00:01\',true,2,2,2,2,2,2,"222","2222",2,2,2,2);' + ) - tdSql.execute('insert into tbn values (\'2021-11-11 09:00:02\',true,3,3,2,3,3,3,"333","3333",3,3,3,3);') + tdSql.execute( + 'insert into tbn values (\'2021-11-11 09:00:02\',true,3,3,2,3,3,3,"333","3333",3,3,3,3);' + ) - tdSql.execute('insert into tbn values (\'2021-11-11 09:00:03\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);') + tdSql.execute( + 'insert into tbn values (\'2021-11-11 09:00:03\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);' + ) - tdSql.execute('insert into tbn values (\'2021-11-11 09:00:04\',true,5,5,5,5,5,5,"555","5555",5,5,5,5);') + tdSql.execute( + 'insert into tbn values (\'2021-11-11 09:00:04\',true,5,5,5,5,5,5,"555","5555",5,5,5,5);' + ) - tdSql.execute('insert into tbn values (\'2021-11-11 09:00:05\',true,6,6,6,6,6,6,"666","6666",6,6,6,6);') + tdSql.execute( + 'insert into tbn values (\'2021-11-11 09:00:05\',true,6,6,6,6,6,6,"666","6666",6,6,6,6);' + ) - tdSql.execute('insert into tbn values (\'2021-11-11 09:00:06\',true,7,7,7,7,7,7,"777","7777",7,7,7,7);') + tdSql.execute( + 'insert into tbn values (\'2021-11-11 09:00:06\',true,7,7,7,7,7,7,"777","7777",7,7,7,7);' + ) - #=========== begin math_sqrt ========== - tdSql.query('select sqrt(13) from tb1;') + # =========== begin math_sqrt ========== + tdSql.query("select sqrt(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 3.605551275463989) tdSql.checkData(1, 0, 3.605551275463989) @@ -90,7 +137,7 @@ class TDTestCase: tdSql.checkData(5, 0, 3.605551275463989) tdSql.checkData(6, 0, 3.605551275463989) - tdSql.query('select sqrt(c2) from tb1;') + tdSql.query("select sqrt(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -98,9 +145,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 11.269427669584644) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c3) from tb1;') + tdSql.query("select sqrt(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -108,9 +155,9 @@ class TDTestCase: tdSql.checkData(3, 0, 1.7320508075688772) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 181.01657382681842) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c4) from tb1;') + tdSql.query("select sqrt(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -118,9 +165,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 46340.950001051984) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c5) from tb1;') + tdSql.query("select sqrt(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -128,29 +175,29 @@ class TDTestCase: tdSql.checkData(3, 0, 1.7320508075688772) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 3037000499.97605) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c6) from tb1;') + tdSql.query("select sqrt(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.4142135623730951) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) - tdSql.checkData(5, 0, 1.844674352395373e+19) - tdSql.checkData(6, 0, None) + tdSql.checkData(5, 0, 1.844674352395373e19) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c7) from tb1;') + tdSql.query("select sqrt(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, 1.7320508075688772) tdSql.checkData(4, 0, 2.0) - tdSql.checkData(5, 0, 1.3407796239501852e+154) - tdSql.checkData(6, 0, None) + tdSql.checkData(5, 0, 1.3407796239501852e154) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c10) from tb1;') + tdSql.query("select sqrt(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -160,7 +207,7 @@ class TDTestCase: tdSql.checkData(5, 0, 15.937377450509228) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sqrt(c11) from tb1;') + tdSql.query("select sqrt(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -170,7 +217,7 @@ class TDTestCase: tdSql.checkData(5, 0, 255.99609372019722) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sqrt(c12) from tb1;') + tdSql.query("select sqrt(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -180,7 +227,7 @@ class TDTestCase: tdSql.checkData(5, 0, 65535.99998474121) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sqrt(c13) from tb1;') + tdSql.query("select sqrt(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -190,7 +237,7 @@ class TDTestCase: tdSql.checkData(5, 0, 3037000499.97605) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sqrt(a) from (select sqrt(c2) as a from tb1);') + tdSql.query("select sqrt(a) from (select sqrt(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -198,9 +245,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.4142135623730951) tdSql.checkData(5, 0, 3.3569968229929326) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c2 + c3) from tb1;') + tdSql.query("select sqrt(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.4142135623730951) tdSql.checkData(1, 0, None) @@ -208,9 +255,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.8284271247461903) tdSql.checkData(5, 0, 181.36703118262702) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt((c2 + c3)) from tb1;') + tdSql.query("select sqrt((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.4142135623730951) tdSql.checkData(1, 0, None) @@ -218,19 +265,19 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.8284271247461903) tdSql.checkData(5, 0, 181.36703118262702) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt((c2 * c3)+c4-6) from tb1;') + tdSql.query("select sqrt((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 3.7416573867739413) tdSql.checkData(5, 0, 46385.82811592351) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(11)+c2 from tb1;') + tdSql.query("select sqrt(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 4.3166247903554) tdSql.checkData(1, 0, None) @@ -240,7 +287,7 @@ class TDTestCase: tdSql.checkData(5, 0, 130.3166247903554) tdSql.checkData(6, 0, -123.6833752096446) - tdSql.query('select sqrt(c2)+11 from tb1;') + tdSql.query("select sqrt(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.0) tdSql.checkData(1, 0, None) @@ -248,18 +295,20 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 13.0) tdSql.checkData(5, 0, 22.269427669584644) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select sqrt(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 1.4142135623730951) tdSql.checkData(1, 0, 2.8284271247461903) tdSql.checkData(2, 0, 181.36703118262702) - tdSql.checkData(3, 0, None) + tdSql.checkData(3, 0, nan) - tdSql.query('select sqrt(c2) from tb1 order by ts desc;') + tdSql.query("select sqrt(c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 11.269427669584644) tdSql.checkData(2, 0, 2.0) tdSql.checkData(3, 0, None) @@ -267,9 +316,9 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.0) - tdSql.query('select sqrt(c2+c3) from tb1 order by ts desc;') + tdSql.query("select sqrt(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 181.36703118262702) tdSql.checkData(2, 0, 2.8284271247461903) tdSql.checkData(3, 0, None) @@ -277,13 +326,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.4142135623730951) - tdSql.query('select sqrt(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select sqrt(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 2.8284271247461903) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select sqrt(c2) from stb1;') + tdSql.query("select sqrt(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -291,7 +340,7 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 11.269427669584644) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.7320508075688772) @@ -300,59 +349,59 @@ class TDTestCase: tdSql.checkData(12, 0, 2.449489742783178) tdSql.checkData(13, 0, 2.6457513110645907) - tdSql.query('select sqrt(c2) from stb1 order by ts desc;') + tdSql.query("select sqrt(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select sqrt(c4),t1,c4 from stb1 order by ts desc;') + tdSql.query("select sqrt(c4),t1,c4 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select sqrt(c3),tbname from stb1;') + tdSql.query("select sqrt(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, 1.7320508075688772) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 2.0) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 181.01657382681842) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1.0) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 1.4142135623730951) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 1.7320508075688772) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 2.0) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 2.23606797749979) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 2.449489742783178) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 2.6457513110645907) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select sqrt(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select sqrt(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 1.4142135623730951) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 1.7320508075688772) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 2.0) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 2.23606797749979) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 2.449489742783178) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 2.6457513110645907) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select sqrt(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 1.4142135623730951) @@ -360,9 +409,9 @@ class TDTestCase: tdSql.checkData(3, 0, 2.0) tdSql.checkData(4, 0, 2.1213203435596424) tdSql.checkData(5, 0, 8.154753215150045) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c2) from (select * from stb1);') + tdSql.query("select sqrt(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -370,7 +419,7 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 11.269427669584644) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.7320508075688772) @@ -379,7 +428,9 @@ class TDTestCase: tdSql.checkData(12, 0, 2.449489742783178) tdSql.checkData(13, 0, 2.6457513110645907) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 1.4142135623730951) @@ -387,12 +438,14 @@ class TDTestCase: tdSql.checkData(3, 0, 2.0) tdSql.checkData(4, 0, 2.1213203435596424) tdSql.checkData(5, 0, 8.154753215150045) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 1.4142135623730951) @@ -400,17 +453,19 @@ class TDTestCase: tdSql.checkData(3, 0, 2.0) tdSql.checkData(4, 0, 2.1213203435596424) tdSql.checkData(5, 0, 8.154753215150045) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) + tdSql.checkData(3, 0, nan) tdSql.checkData(4, 0, 8.154753215150045) tdSql.checkData(5, 0, 2.1213203435596424) tdSql.checkData(6, 0, 2.0) @@ -418,7 +473,9 @@ class TDTestCase: tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.0) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -429,11 +486,13 @@ class TDTestCase: tdSql.checkData(6, 0, 1.5811388300841898) tdSql.checkData(7, 0, 1.4142135623730951) tdSql.checkData(8, 0, 1.0) - tdSql.checkData(9, 0, None) + tdSql.checkData(9, 0, nan) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 1.0) tdSql.checkData(2, 0, 1.4142135623730951) tdSql.checkData(3, 0, 1.5811388300841898) @@ -444,7 +503,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select sqrt(a) from (select sqrt(c2) as a from tb1);') + tdSql.query("select sqrt(a) from (select sqrt(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -452,9 +511,11 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.4142135623730951) tdSql.checkData(5, 0, 3.3569968229929326) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(tb1.c3),sqrt(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query( + "select sqrt(tb1.c3),sqrt(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(0, 1, 1.0) @@ -468,10 +529,10 @@ class TDTestCase: tdSql.checkData(4, 1, 2.23606797749979) tdSql.checkData(5, 0, 181.01657382681842) tdSql.checkData(5, 1, 2.449489742783178) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(6, 1, 2.6457513110645907) - tdSql.query('select sqrt(c3) from tb1 union all select sqrt(c3) from tb2;') + tdSql.query("select sqrt(c3) from tb1 union all select sqrt(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -479,7 +540,7 @@ class TDTestCase: tdSql.checkData(3, 0, 1.7320508075688772) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 181.01657382681842) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.7320508075688772) @@ -488,11 +549,10 @@ class TDTestCase: tdSql.checkData(12, 0, 2.449489742783178) tdSql.checkData(13, 0, 2.6457513110645907) - #=========== end math_sqrt ========== + # =========== end math_sqrt ========== - - #=========== begin math_abs ========== - tdSql.query('select abs(13) from tb1;') + # =========== begin math_abs ========== + tdSql.query("select abs(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 13) tdSql.checkData(1, 0, 13) @@ -502,7 +562,7 @@ class TDTestCase: tdSql.checkData(5, 0, 13) tdSql.checkData(6, 0, 13) - tdSql.query('select abs(c2) from tb1;') + tdSql.query("select abs(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -512,7 +572,7 @@ class TDTestCase: tdSql.checkData(5, 0, 127) tdSql.checkData(6, 0, 127) - tdSql.query('select abs(c3) from tb1;') + tdSql.query("select abs(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -522,7 +582,7 @@ class TDTestCase: tdSql.checkData(5, 0, 32767) tdSql.checkData(6, 0, 32767) - tdSql.query('select abs(c4) from tb1;') + tdSql.query("select abs(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -532,7 +592,7 @@ class TDTestCase: tdSql.checkData(5, 0, 2147483647) tdSql.checkData(6, 0, 2147483647) - tdSql.query('select abs(c5) from tb1;') + tdSql.query("select abs(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -542,27 +602,27 @@ class TDTestCase: tdSql.checkData(5, 0, 9223372036854775807) tdSql.checkData(6, 0, 9223372036854775807) - tdSql.query('select abs(c6) from tb1;') + tdSql.query("select abs(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 2.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 4.0) - tdSql.checkData(5, 0, 3.4028234663852886e+38) - tdSql.checkData(6, 0, 3.4028234663852886e+38) + tdSql.checkData(5, 0, 3.4028234663852886e38) + tdSql.checkData(6, 0, 3.4028234663852886e38) - tdSql.query('select abs(c7) from tb1;') + tdSql.query("select abs(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, 3.0) tdSql.checkData(4, 0, 4.0) - tdSql.checkData(5, 0, 1.79769e+308) - tdSql.checkData(6, 0, 1.79769e+308) + tdSql.checkData(5, 0, 1.79769e308) + tdSql.checkData(6, 0, 1.79769e308) - tdSql.query('select abs(c10) from tb1;') + tdSql.query("select abs(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -572,7 +632,7 @@ class TDTestCase: tdSql.checkData(5, 0, 254) tdSql.checkData(6, 0, 0) - tdSql.query('select abs(c11) from tb1;') + tdSql.query("select abs(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -582,7 +642,7 @@ class TDTestCase: tdSql.checkData(5, 0, 65534) tdSql.checkData(6, 0, 0) - tdSql.query('select abs(c12) from tb1;') + tdSql.query("select abs(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -592,7 +652,7 @@ class TDTestCase: tdSql.checkData(5, 0, 4294967294) tdSql.checkData(6, 0, 0) - tdSql.query('select abs(c13) from tb1;') + tdSql.query("select abs(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -602,7 +662,7 @@ class TDTestCase: tdSql.checkData(5, 0, 9223372036854775807) tdSql.checkData(6, 0, 0) - tdSql.query('select abs(a) from (select abs(c2) as a from tb1);') + tdSql.query("select abs(a) from (select abs(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -612,7 +672,7 @@ class TDTestCase: tdSql.checkData(5, 0, 127) tdSql.checkData(6, 0, 127) - tdSql.query('select abs(c2 + c3) from tb1;') + tdSql.query("select abs(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 2.0) tdSql.checkData(1, 0, None) @@ -622,7 +682,7 @@ class TDTestCase: tdSql.checkData(5, 0, 32894.0) tdSql.checkData(6, 0, 32894.0) - tdSql.query('select abs((c2 + c3)) from tb1;') + tdSql.query("select abs((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 2.0) tdSql.checkData(1, 0, None) @@ -632,7 +692,7 @@ class TDTestCase: tdSql.checkData(5, 0, 32894.0) tdSql.checkData(6, 0, 32894.0) - tdSql.query('select abs((c2 * c3)+c4-6) from tb1;') + tdSql.query("select abs((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 4.0) tdSql.checkData(1, 0, None) @@ -642,7 +702,7 @@ class TDTestCase: tdSql.checkData(5, 0, 2151645050.0) tdSql.checkData(6, 0, 2143322244.0) - tdSql.query('select abs(11)+c2 from tb1;') + tdSql.query("select abs(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.0) tdSql.checkData(1, 0, None) @@ -652,7 +712,7 @@ class TDTestCase: tdSql.checkData(5, 0, 138.0) tdSql.checkData(6, 0, -116.0) - tdSql.query('select abs(c2)+11 from tb1;') + tdSql.query("select abs(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.0) tdSql.checkData(1, 0, None) @@ -662,14 +722,16 @@ class TDTestCase: tdSql.checkData(5, 0, 138.0) tdSql.checkData(6, 0, 138.0) - tdSql.query('select abs(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select abs(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 2.0) tdSql.checkData(1, 0, 8.0) tdSql.checkData(2, 0, 32894.0) tdSql.checkData(3, 0, 32894.0) - tdSql.query('select abs(c2) from tb1 order by ts desc;') + tdSql.query("select abs(c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 127) tdSql.checkData(1, 0, 127) @@ -679,7 +741,7 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1) - tdSql.query('select abs(c2+c3) from tb1 order by ts desc;') + tdSql.query("select abs(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 32894.0) tdSql.checkData(1, 0, 32894.0) @@ -689,13 +751,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 2.0) - tdSql.query('select abs(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select abs(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 8.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select abs(c2) from stb1;') + tdSql.query("select abs(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -712,59 +774,59 @@ class TDTestCase: tdSql.checkData(12, 0, 6) tdSql.checkData(13, 0, 7) - tdSql.query('select abs(c2) from stb1 order by ts desc;') + tdSql.query("select abs(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select abs(c4),t1 from stb1 order by ts desc;') + tdSql.query("select abs(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select abs(c3),tbname from stb1;') + tdSql.query("select abs(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, 3) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 4) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 32767) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, 32767) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 2) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 3) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 4) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 5) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 6) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 7) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select abs(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select abs(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 2) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 3) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 4) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 5) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 6) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 7) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select abs(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select abs(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 2.0) @@ -774,7 +836,7 @@ class TDTestCase: tdSql.checkData(5, 0, 66.5) tdSql.checkData(6, 0, 60.0) - tdSql.query('select abs(c2) from (select * from stb1);') + tdSql.query("select abs(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -791,7 +853,9 @@ class TDTestCase: tdSql.checkData(12, 0, 6) tdSql.checkData(13, 0, 7) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 2.0) @@ -804,7 +868,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 2.0) @@ -817,7 +883,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -830,7 +898,9 @@ class TDTestCase: tdSql.checkData(8, 0, 2.0) tdSql.checkData(9, 0, 1.0) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -843,7 +913,9 @@ class TDTestCase: tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 60.0) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 60.0) tdSql.checkData(1, 0, 1.0) @@ -856,7 +928,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select abs(a) from (select abs(c2) as a from tb1);') + tdSql.query("select abs(a) from (select abs(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -866,7 +938,7 @@ class TDTestCase: tdSql.checkData(5, 0, 127) tdSql.checkData(6, 0, 127) - tdSql.query('select abs(tb1.c3),abs(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query("select abs(tb1.c3),abs(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(0, 1, 1) @@ -883,7 +955,7 @@ class TDTestCase: tdSql.checkData(6, 0, 32767) tdSql.checkData(6, 1, 7) - tdSql.query('select abs(c3) from tb1 union all select abs(c3) from tb2;') + tdSql.query("select abs(c3) from tb1 union all select abs(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -900,1247 +972,1285 @@ class TDTestCase: tdSql.checkData(12, 0, 6) tdSql.checkData(13, 0, 7) - #=========== end math_abs ========== - + # =========== end math_abs ========== - #=========== begin math_asin ========== - tdSql.query('select asin(13) from tb1;') + # =========== begin math_asin ========== + tdSql.query("select asin(13) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2) from tb1;') + tdSql.query("select asin(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c3) from tb1;') + tdSql.query("select asin(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c4) from tb1;') + tdSql.query("select asin(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c5) from tb1;') + tdSql.query("select asin(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c6) from tb1;') + tdSql.query("select asin(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c7) from tb1;') + tdSql.query("select asin(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c10) from tb1;') + tdSql.query("select asin(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 0.0) - tdSql.query('select asin(c11) from tb1;') + tdSql.query("select asin(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 0.0) - tdSql.query('select asin(c12) from tb1;') + tdSql.query("select asin(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 0.0) - tdSql.query('select asin(c13) from tb1;') + tdSql.query("select asin(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 0.0) - tdSql.query('select asin(a) from (select asin(c2) as a from tb1);') + tdSql.query("select asin(a) from (select asin(c2) as a from tb1);") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2 + c3) from tb1;') + tdSql.query("select asin(c2 + c3) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin((c2 + c3)) from tb1;') + tdSql.query("select asin((c2 + c3)) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin((c2 * c3)+c4-6) from tb1;') + tdSql.query("select asin((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(11)+c2 from tb1;') + tdSql.query("select asin(11)+c2 from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2)+11 from tb1;') + tdSql.query("select asin(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.570796326794897) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select asin(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) - tdSql.query('select asin(c2) from tb1 order by ts desc;') + tdSql.query("select asin(c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) + tdSql.checkData(4, 0, nan) tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select asin(c2+c3) from tb1 order by ts desc;') + tdSql.query("select asin(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, None) tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select asin(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select asin(c2) from stb1;') + tdSql.query("select asin(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query('select asin(c2) from stb1 order by ts desc;') + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query("select asin(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select asin(c4),t1 from stb1 order by ts desc;') + tdSql.query("select asin(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select asin(c3),tbname from stb1;') + tdSql.query("select asin(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(0, 1, 'tb1') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb1') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") + tdSql.checkData(1, 0, None) + tdSql.checkData(1, 1, "tb1") + tdSql.checkData(2, 0, None) + tdSql.checkData(2, 1, "tb1") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb1") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb1") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(7, 1, 'tb2') - tdSql.checkData(8, 0, None) - tdSql.checkData(8, 1, 'tb2') - tdSql.checkData(9, 0, None) - tdSql.checkData(9, 1, 'tb2') - tdSql.checkData(10, 0, None) - tdSql.checkData(10, 1, 'tb2') - tdSql.checkData(11, 0, None) - tdSql.checkData(11, 1, 'tb2') - tdSql.checkData(12, 0, None) - tdSql.checkData(12, 1, 'tb2') - tdSql.checkData(13, 0, None) - tdSql.checkData(13, 1, 'tb2') - - tdSql.query('select asin(c3),tbname from stb1 where t1 > 1;') + tdSql.checkData(7, 1, "tb2") + tdSql.checkData(8, 0, nan) + tdSql.checkData(8, 1, "tb2") + tdSql.checkData(9, 0, nan) + tdSql.checkData(9, 1, "tb2") + tdSql.checkData(10, 0, nan) + tdSql.checkData(10, 1, "tb2") + tdSql.checkData(11, 0, nan) + tdSql.checkData(11, 1, "tb2") + tdSql.checkData(12, 0, nan) + tdSql.checkData(12, 1, "tb2") + tdSql.checkData(13, 0, nan) + tdSql.checkData(13, 1, "tb2") + + tdSql.query("select asin(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(0, 1, 'tb2') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb2') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb2') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb2') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb2') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb2') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb2') - - tdSql.query('select asin(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.checkData(0, 1, "tb2") + tdSql.checkData(1, 0, nan) + tdSql.checkData(1, 1, "tb2") + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, "tb2") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb2") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb2") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb2") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb2") + + tdSql.query("select asin(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - - tdSql.query('select asin(c2) from (select * from stb1);') + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + + tdSql.query("select asin(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 1.5707963267948966) - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.5707963267948966) - tdSql.checkData(9, 0, None) + tdSql.checkData(9, 0, nan) - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 1.5707963267948966) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select asin(a) from (select asin(c2) as a from tb1);') + tdSql.query("select asin(a) from (select asin(c2) as a from tb1);") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(tb1.c3),asin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query( + "select asin(tb1.c3),asin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(0, 1, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) - tdSql.query('select asin(c3) from tb1 union all select asin(c3) from tb2;') + tdSql.query("select asin(c3) from tb1 union all select asin(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) - #=========== end math_asin ========== + # =========== end math_asin ========== - - #=========== begin math_acos ========== - tdSql.query('select acos(13) from tb1;') + # =========== begin math_acos ========== + tdSql.query("select acos(13) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2) from tb1;') + tdSql.query("select acos(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c3) from tb1;') + tdSql.query("select acos(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c4) from tb1;') + tdSql.query("select acos(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c5) from tb1;') + tdSql.query("select acos(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c6) from tb1;') + tdSql.query("select acos(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c7) from tb1;') + tdSql.query("select acos(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c10) from tb1;') + tdSql.query("select acos(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c11) from tb1;') + tdSql.query("select acos(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c12) from tb1;') + tdSql.query("select acos(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c13) from tb1;') + tdSql.query("select acos(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(a) from (select acos(c2) as a from tb1);') + tdSql.query("select acos(a) from (select acos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2 + c3) from tb1;') + tdSql.query("select acos(c2 + c3) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos((c2 + c3)) from tb1;') + tdSql.query("select acos((c2 + c3)) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos((c2 * c3)+c4-6) from tb1;') + tdSql.query("select acos((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(11)+c2 from tb1;') + tdSql.query("select acos(11)+c2 from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2)+11 from tb1;') + tdSql.query("select acos(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 11.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select acos(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) - tdSql.query('select acos(c2) from tb1 order by ts desc;') + tdSql.query("select acos(c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) + tdSql.checkData(4, 0, nan) tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.0) - tdSql.query('select acos(c2+c3) from tb1 order by ts desc;') + tdSql.query("select acos(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, None) tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select acos(c2) from stb1;') + tdSql.query("select acos(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query('select acos(c2) from stb1 order by ts desc;') + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query("select acos(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select acos(c4),t1 from stb1 order by ts desc;') + tdSql.query("select acos(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select acos(c3),tbname from stb1;') + tdSql.query("select acos(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(0, 1, 'tb1') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb1') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") + tdSql.checkData(1, 0, None) + tdSql.checkData(1, 1, "tb1") + tdSql.checkData(2, 0, None) + tdSql.checkData(2, 1, "tb1") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb1") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb1") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 0.0) - tdSql.checkData(7, 1, 'tb2') - tdSql.checkData(8, 0, None) - tdSql.checkData(8, 1, 'tb2') - tdSql.checkData(9, 0, None) - tdSql.checkData(9, 1, 'tb2') - tdSql.checkData(10, 0, None) - tdSql.checkData(10, 1, 'tb2') - tdSql.checkData(11, 0, None) - tdSql.checkData(11, 1, 'tb2') - tdSql.checkData(12, 0, None) - tdSql.checkData(12, 1, 'tb2') - tdSql.checkData(13, 0, None) - tdSql.checkData(13, 1, 'tb2') - - tdSql.query('select acos(c3),tbname from stb1 where t1 > 1;') + tdSql.checkData(7, 1, "tb2") + tdSql.checkData(8, 0, nan) + tdSql.checkData(8, 1, "tb2") + tdSql.checkData(9, 0, nan) + tdSql.checkData(9, 1, "tb2") + tdSql.checkData(10, 0, nan) + tdSql.checkData(10, 1, "tb2") + tdSql.checkData(11, 0, nan) + tdSql.checkData(11, 1, "tb2") + tdSql.checkData(12, 0, nan) + tdSql.checkData(12, 1, "tb2") + tdSql.checkData(13, 0, nan) + tdSql.checkData(13, 1, "tb2") + + tdSql.query("select acos(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(0, 1, 'tb2') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb2') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb2') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb2') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb2') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb2') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb2') - - tdSql.query('select acos(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.checkData(0, 1, "tb2") + tdSql.checkData(1, 0, nan) + tdSql.checkData(1, 1, "tb2") + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, "tb2") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb2") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb2") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb2") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb2") + + tdSql.query("select acos(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - - tdSql.query('select acos(c2) from (select * from stb1);') + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + + tdSql.query("select acos(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) + tdSql.checkRows(10) + tdSql.checkData(0, 0, 0.0) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, 0.0) + tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") - tdSql.checkRows(10) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 0.0) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 0.0) - tdSql.checkData(9, 0, None) + tdSql.checkData(9, 0, nan) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 0.0) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select acos(a) from (select acos(c2) as a from tb1);') + tdSql.query("select acos(a) from (select acos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query( + "select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(0, 1, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) - tdSql.query('select acos(c3) from tb1 union all select acos(c3) from tb2;') + tdSql.query("select acos(c3) from tb1 union all select acos(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) - #=========== end math_acos ========== + # =========== end math_acos ========== - - #=========== begin math_atan ========== - tdSql.query('select acos(13) from tb1;') + # =========== begin math_atan ========== + tdSql.query("select acos(13) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2) from tb1;') + tdSql.query("select acos(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c3) from tb1;') + tdSql.query("select acos(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c4) from tb1;') + tdSql.query("select acos(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c5) from tb1;') + tdSql.query("select acos(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c6) from tb1;') + tdSql.query("select acos(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c7) from tb1;') + tdSql.query("select acos(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c10) from tb1;') + tdSql.query("select acos(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c11) from tb1;') + tdSql.query("select acos(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c12) from tb1;') + tdSql.query("select acos(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c13) from tb1;') + tdSql.query("select acos(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(a) from (select acos(c2) as a from tb1);') + tdSql.query("select acos(a) from (select acos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2 + c3) from tb1;') + tdSql.query("select acos(c2 + c3) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos((c2 + c3)) from tb1;') + tdSql.query("select acos((c2 + c3)) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos((c2 * c3)+c4-6) from tb1;') + tdSql.query("select acos((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(11)+c2 from tb1;') + tdSql.query("select acos(11)+c2 from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2)+11 from tb1;') + tdSql.query("select acos(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 11.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select acos(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) - tdSql.query('select acos(c2) from tb1 order by ts desc;') + tdSql.query("select acos(c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) + tdSql.checkData(4, 0, nan) tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.0) - tdSql.query('select acos(c2+c3) from tb1 order by ts desc;') + tdSql.query("select acos(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, None) tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select acos(c2) from stb1;') + tdSql.query("select acos(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query('select acos(c2) from stb1 order by ts desc;') + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query("select acos(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select acos(c4),t1 from stb1 order by ts desc;') + tdSql.query("select acos(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select acos(c3),tbname from stb1;') + tdSql.query("select acos(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(0, 1, 'tb1') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb1') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") + tdSql.checkData(1, 0, None) + tdSql.checkData(1, 1, "tb1") + tdSql.checkData(2, 0, None) + tdSql.checkData(2, 1, "tb1") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb1") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb1") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 0.0) - tdSql.checkData(7, 1, 'tb2') - tdSql.checkData(8, 0, None) - tdSql.checkData(8, 1, 'tb2') - tdSql.checkData(9, 0, None) - tdSql.checkData(9, 1, 'tb2') - tdSql.checkData(10, 0, None) - tdSql.checkData(10, 1, 'tb2') - tdSql.checkData(11, 0, None) - tdSql.checkData(11, 1, 'tb2') - tdSql.checkData(12, 0, None) - tdSql.checkData(12, 1, 'tb2') - tdSql.checkData(13, 0, None) - tdSql.checkData(13, 1, 'tb2') - - tdSql.query('select acos(c3),tbname from stb1 where t1 > 1;') + tdSql.checkData(7, 1, "tb2") + tdSql.checkData(8, 0, nan) + tdSql.checkData(8, 1, "tb2") + tdSql.checkData(9, 0, nan) + tdSql.checkData(9, 1, "tb2") + tdSql.checkData(10, 0, nan) + tdSql.checkData(10, 1, "tb2") + tdSql.checkData(11, 0, nan) + tdSql.checkData(11, 1, "tb2") + tdSql.checkData(12, 0, nan) + tdSql.checkData(12, 1, "tb2") + tdSql.checkData(13, 0, nan) + tdSql.checkData(13, 1, "tb2") + + tdSql.query("select acos(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(0, 1, 'tb2') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb2') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb2') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb2') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb2') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb2') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb2') - - tdSql.query('select acos(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.checkData(0, 1, "tb2") + tdSql.checkData(1, 0, nan) + tdSql.checkData(1, 1, "tb2") + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, "tb2") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb2") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb2") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb2") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb2") + + tdSql.query("select acos(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - - tdSql.query('select acos(c2) from (select * from stb1);') + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + + tdSql.query("select acos(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 0.0) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 0.0) - tdSql.checkData(9, 0, None) + tdSql.checkData(9, 0, nan) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 0.0) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select acos(a) from (select acos(c2) as a from tb1);') + tdSql.query("select acos(a) from (select acos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query( + "select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(0, 1, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) - tdSql.query('select acos(c3) from tb1 union all select acos(c3) from tb2;') + tdSql.query("select acos(c3) from tb1 union all select acos(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) - #=========== end math_atan ========== + # =========== end math_atan ========== - - #=========== begin math_sin ========== - tdSql.query('select sin(13) from tb1;') + # =========== begin math_sin ========== + tdSql.query("select sin(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.4201670368266409) tdSql.checkData(1, 0, 0.4201670368266409) @@ -2150,7 +2260,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.4201670368266409) tdSql.checkData(6, 0, 0.4201670368266409) - tdSql.query('select sin(c2) from tb1;') + tdSql.query("select sin(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2160,7 +2270,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.972630067242408) tdSql.checkData(6, 0, -0.972630067242408) - tdSql.query('select sin(c3) from tb1;') + tdSql.query("select sin(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2170,7 +2280,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.18750655394138943) tdSql.checkData(6, 0, -0.18750655394138943) - tdSql.query('select sin(c4) from tb1;') + tdSql.query("select sin(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2180,7 +2290,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.7249165551445564) tdSql.checkData(6, 0, 0.7249165551445564) - tdSql.query('select sin(c5) from tb1;') + tdSql.query("select sin(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2190,7 +2300,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9999303766734422) tdSql.checkData(6, 0, -0.9999303766734422) - tdSql.query('select sin(c6) from tb1;') + tdSql.query("select sin(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2200,7 +2310,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.5218765233336585) tdSql.checkData(6, 0, 0.5218765233336585) - tdSql.query('select sin(c7) from tb1;') + tdSql.query("select sin(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2210,7 +2320,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.8728292970885063) tdSql.checkData(6, 0, -0.8728292970885063) - tdSql.query('select sin(c10) from tb1;') + tdSql.query("select sin(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2220,7 +2330,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.45199889806298343) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sin(c11) from tb1;') + tdSql.query("select sin(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2230,7 +2340,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.3683616323063538) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sin(c12) from tb1;') + tdSql.query("select sin(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2240,7 +2350,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9986982434666626) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sin(c13) from tb1;') + tdSql.query("select sin(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2250,7 +2360,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9999303766734422) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sin(a) from (select sin(c2) as a from tb1);') + tdSql.query("select sin(a) from (select sin(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.7456241416655579) tdSql.checkData(1, 0, None) @@ -2260,7 +2370,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.8263696344332049) tdSql.checkData(6, 0, -0.8263696344332049) - tdSql.query('select sin(c2 + c3) from tb1;') + tdSql.query("select sin(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.9092974268256817) tdSql.checkData(1, 0, None) @@ -2270,7 +2380,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9989477243796069) tdSql.checkData(6, 0, -0.9989477243796069) - tdSql.query('select sin((c2 + c3)) from tb1;') + tdSql.query("select sin((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.9092974268256817) tdSql.checkData(1, 0, None) @@ -2280,7 +2390,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9989477243796069) tdSql.checkData(6, 0, -0.9989477243796069) - tdSql.query('select sin((c2 * c3)+c4-6) from tb1;') + tdSql.query("select sin((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.7568024953079282) tdSql.checkData(1, 0, None) @@ -2290,7 +2400,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.08341720348826624) tdSql.checkData(6, 0, 0.9909625452221539) - tdSql.query('select sin(11)+c2 from tb1;') + tdSql.query("select sin(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 9.793449296524592e-06) tdSql.checkData(1, 0, None) @@ -2300,7 +2410,7 @@ class TDTestCase: tdSql.checkData(5, 0, 126.0000097934493) tdSql.checkData(6, 0, -127.9999902065507) - tdSql.query('select sin(c2)+11 from tb1;') + tdSql.query("select sin(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 11.841470984807897) tdSql.checkData(1, 0, None) @@ -2310,14 +2420,16 @@ class TDTestCase: tdSql.checkData(5, 0, 11.972630067242408) tdSql.checkData(6, 0, 10.027369932757592) - tdSql.query('select sin(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select sin(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 0.9092974268256817) tdSql.checkData(1, 0, 0.9893582466233818) tdSql.checkData(2, 0, 0.9989477243796069) tdSql.checkData(3, 0, -0.9989477243796069) - tdSql.query('select sin(c2) from tb1 order by ts desc;') + tdSql.query("select sin(c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.972630067242408) tdSql.checkData(1, 0, 0.972630067242408) @@ -2327,7 +2439,7 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.8414709848078965) - tdSql.query('select sin(c2+c3) from tb1 order by ts desc;') + tdSql.query("select sin(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.9989477243796069) tdSql.checkData(1, 0, 0.9989477243796069) @@ -2337,13 +2449,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.9092974268256817) - tdSql.query('select sin(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select sin(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 0.9893582466233818) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select sin(c2) from stb1;') + tdSql.query("select sin(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2360,59 +2472,59 @@ class TDTestCase: tdSql.checkData(12, 0, -0.27941549819892586) tdSql.checkData(13, 0, 0.6569865987187891) - tdSql.query('select sin(c2) from stb1 order by ts desc;') + tdSql.query("select sin(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select sin(c4),t1 from stb1 order by ts desc;') + tdSql.query("select sin(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select sin(c3),tbname from stb1;') + tdSql.query("select sin(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.8414709848078965) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, 0.1411200080598672) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, -0.7568024953079282) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 0.18750655394138943) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, -0.18750655394138943) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 0.8414709848078965) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 0.9092974268256817) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 0.1411200080598672) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, -0.7568024953079282) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, -0.9589242746631385) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, -0.27941549819892586) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 0.6569865987187891) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select sin(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select sin(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 0.9092974268256817) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 0.1411200080598672) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, -0.7568024953079282) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, -0.9589242746631385) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, -0.27941549819892586) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 0.6569865987187891) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select sin(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select sin(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, 0.9092974268256817) @@ -2422,7 +2534,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.5025573497604873) tdSql.checkData(6, 0, 0.3048106211022167) - tdSql.query('select sin(c2) from (select * from stb1);') + tdSql.query("select sin(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2439,7 +2551,9 @@ class TDTestCase: tdSql.checkData(12, 0, -0.27941549819892586) tdSql.checkData(13, 0, 0.6569865987187891) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, 0.9092974268256817) @@ -2452,7 +2566,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, 0.9092974268256817) @@ -2465,7 +2581,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -2478,7 +2596,9 @@ class TDTestCase: tdSql.checkData(8, 0, 0.9092974268256817) tdSql.checkData(9, 0, 0.8414709848078965) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -2491,7 +2611,9 @@ class TDTestCase: tdSql.checkData(8, 0, 0.8414709848078965) tdSql.checkData(9, 0, 0.3048106211022167) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.3048106211022167) tdSql.checkData(1, 0, 0.8414709848078965) @@ -2504,7 +2626,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select sin(a) from (select sin(c2) as a from tb1);') + tdSql.query("select sin(a) from (select sin(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.7456241416655579) tdSql.checkData(1, 0, None) @@ -2514,7 +2636,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.8263696344332049) tdSql.checkData(6, 0, -0.8263696344332049) - tdSql.query('select sin(tb1.c3),sin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query("select sin(tb1.c3),sin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(0, 1, 0.8414709848078965) @@ -2531,7 +2653,7 @@ class TDTestCase: tdSql.checkData(6, 0, -0.18750655394138943) tdSql.checkData(6, 1, 0.6569865987187891) - tdSql.query('select sin(c3) from tb1 union all select sin(c3) from tb2;') + tdSql.query("select sin(c3) from tb1 union all select sin(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -2548,11 +2670,10 @@ class TDTestCase: tdSql.checkData(12, 0, -0.27941549819892586) tdSql.checkData(13, 0, 0.6569865987187891) - #=========== end math_sin ========== - + # =========== end math_sin ========== - #=========== begin math_cos ========== - tdSql.query('select cos(13) from tb1;') + # =========== begin math_cos ========== + tdSql.query("select cos(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.9074467814501962) tdSql.checkData(1, 0, 0.9074467814501962) @@ -2562,7 +2683,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9074467814501962) tdSql.checkData(6, 0, 0.9074467814501962) - tdSql.query('select cos(c2) from tb1;') + tdSql.query("select cos(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2572,7 +2693,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.23235910202965793) tdSql.checkData(6, 0, 0.23235910202965793) - tdSql.query('select cos(c3) from tb1;') + tdSql.query("select cos(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2582,7 +2703,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9822633517692823) tdSql.checkData(6, 0, 0.9822633517692823) - tdSql.query('select cos(c4) from tb1;') + tdSql.query("select cos(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2592,7 +2713,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.6888366918779438) tdSql.checkData(6, 0, -0.6888366918779438) - tdSql.query('select cos(c5) from tb1;') + tdSql.query("select cos(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2602,7 +2723,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.011800076512800236) tdSql.checkData(6, 0, 0.011800076512800236) - tdSql.query('select cos(c6) from tb1;') + tdSql.query("select cos(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2612,7 +2733,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.8530210398303042) tdSql.checkData(6, 0, 0.8530210398303042) - tdSql.query('select cos(c7) from tb1;') + tdSql.query("select cos(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2622,7 +2743,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.4880256326710555) tdSql.checkData(6, 0, 0.4880256326710555) - tdSql.query('select cos(c10) from tb1;') + tdSql.query("select cos(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2632,7 +2753,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.892018495407942) tdSql.checkData(6, 0, 1.0) - tdSql.query('select cos(c11) from tb1;') + tdSql.query("select cos(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2642,7 +2763,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9296825844580496) tdSql.checkData(6, 0, 1.0) - tdSql.query('select cos(c12) from tb1;') + tdSql.query("select cos(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2652,7 +2773,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.051008023845301335) tdSql.checkData(6, 0, 1.0) - tdSql.query('select cos(c13) from tb1;') + tdSql.query("select cos(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2662,7 +2783,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.011800076512800236) tdSql.checkData(6, 0, 1.0) - tdSql.query('select cos(a) from (select cos(c2) as a from tb1);') + tdSql.query("select cos(a) from (select cos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8575532158463934) tdSql.checkData(1, 0, None) @@ -2672,7 +2793,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9731258638638398) tdSql.checkData(6, 0, 0.9731258638638398) - tdSql.query('select cos(c2 + c3) from tb1;') + tdSql.query("select cos(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.4161468365471424) tdSql.checkData(1, 0, None) @@ -2682,7 +2803,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.04586331820534665) tdSql.checkData(6, 0, 0.04586331820534665) - tdSql.query('select cos((c2 + c3)) from tb1;') + tdSql.query("select cos((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.4161468365471424) tdSql.checkData(1, 0, None) @@ -2692,7 +2813,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.04586331820534665) tdSql.checkData(6, 0, 0.04586331820534665) - tdSql.query('select cos((c2 * c3)+c4-6) from tb1;') + tdSql.query("select cos((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.6536436208636119) tdSql.checkData(1, 0, None) @@ -2702,7 +2823,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.9965147114630055) tdSql.checkData(6, 0, 0.13413886076313122) - tdSql.query('select cos(11)+c2 from tb1;') + tdSql.query("select cos(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0044256979880508) tdSql.checkData(1, 0, None) @@ -2712,7 +2833,7 @@ class TDTestCase: tdSql.checkData(5, 0, 127.00442569798805) tdSql.checkData(6, 0, -126.99557430201195) - tdSql.query('select cos(c2)+11 from tb1;') + tdSql.query("select cos(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 11.54030230586814) tdSql.checkData(1, 0, None) @@ -2722,14 +2843,16 @@ class TDTestCase: tdSql.checkData(5, 0, 11.232359102029658) tdSql.checkData(6, 0, 11.232359102029658) - tdSql.query('select cos(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select cos(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, -0.4161468365471424) tdSql.checkData(1, 0, -0.14550003380861354) tdSql.checkData(2, 0, 0.04586331820534665) tdSql.checkData(3, 0, 0.04586331820534665) - tdSql.query('select cos(c2) from tb1 order by ts desc;') + tdSql.query("select cos(c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.23235910202965793) tdSql.checkData(1, 0, 0.23235910202965793) @@ -2739,7 +2862,7 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.5403023058681398) - tdSql.query('select cos(c2+c3) from tb1 order by ts desc;') + tdSql.query("select cos(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.04586331820534665) tdSql.checkData(1, 0, 0.04586331820534665) @@ -2749,13 +2872,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, -0.4161468365471424) - tdSql.query('select cos(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select cos(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, -0.14550003380861354) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select cos(c2) from stb1;') + tdSql.query("select cos(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2772,59 +2895,59 @@ class TDTestCase: tdSql.checkData(12, 0, 0.960170286650366) tdSql.checkData(13, 0, 0.7539022543433046) - tdSql.query('select cos(c2) from stb1 order by ts desc;') + tdSql.query("select cos(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select cos(c4),t1 from stb1 order by ts desc;') + tdSql.query("select cos(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select cos(c3),tbname from stb1;') + tdSql.query("select cos(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.5403023058681398) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, -0.9899924966004454) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, -0.6536436208636119) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 0.9822633517692823) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, 0.9822633517692823) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 0.5403023058681398) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, -0.4161468365471424) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, -0.9899924966004454) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, -0.6536436208636119) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 0.28366218546322625) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 0.960170286650366) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 0.7539022543433046) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select cos(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select cos(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, -0.4161468365471424) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, -0.9899924966004454) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, -0.6536436208636119) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 0.28366218546322625) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 0.960170286650366) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 0.7539022543433046) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select cos(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select cos(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, -0.4161468365471424) @@ -2834,7 +2957,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.8645438740756395) tdSql.checkData(6, 0, -0.9524129804151563) - tdSql.query('select cos(c2) from (select * from stb1);') + tdSql.query("select cos(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2851,7 +2974,9 @@ class TDTestCase: tdSql.checkData(12, 0, 0.960170286650366) tdSql.checkData(13, 0, 0.7539022543433046) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, -0.4161468365471424) @@ -2864,7 +2989,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, -0.4161468365471424) @@ -2877,7 +3004,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -2890,7 +3019,9 @@ class TDTestCase: tdSql.checkData(8, 0, -0.4161468365471424) tdSql.checkData(9, 0, 0.5403023058681398) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -2903,7 +3034,9 @@ class TDTestCase: tdSql.checkData(8, 0, 0.5403023058681398) tdSql.checkData(9, 0, -0.9524129804151563) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, -0.9524129804151563) tdSql.checkData(1, 0, 0.5403023058681398) @@ -2916,7 +3049,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select cos(a) from (select cos(c2) as a from tb1);') + tdSql.query("select cos(a) from (select cos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8575532158463934) tdSql.checkData(1, 0, None) @@ -2926,7 +3059,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9731258638638398) tdSql.checkData(6, 0, 0.9731258638638398) - tdSql.query('select cos(tb1.c3),cos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query("select cos(tb1.c3),cos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(0, 1, 0.5403023058681398) @@ -2943,7 +3076,7 @@ class TDTestCase: tdSql.checkData(6, 0, 0.9822633517692823) tdSql.checkData(6, 1, 0.7539022543433046) - tdSql.query('select cos(c3) from tb1 union all select cos(c3) from tb2;') + tdSql.query("select cos(c3) from tb1 union all select cos(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -2960,11 +3093,10 @@ class TDTestCase: tdSql.checkData(12, 0, 0.960170286650366) tdSql.checkData(13, 0, 0.7539022543433046) - #=========== end math_cos ========== + # =========== end math_cos ========== - - #=========== begin math_tan ========== - tdSql.query('select tan(13) from tb1;') + # =========== begin math_tan ========== + tdSql.query("select tan(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.4630211329364896) tdSql.checkData(1, 0, 0.4630211329364896) @@ -2974,7 +3106,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.4630211329364896) tdSql.checkData(6, 0, 0.4630211329364896) - tdSql.query('select tan(c2) from tb1;') + tdSql.query("select tan(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -2984,7 +3116,7 @@ class TDTestCase: tdSql.checkData(5, 0, 4.185891831851989) tdSql.checkData(6, 0, -4.185891831851989) - tdSql.query('select tan(c3) from tb1;') + tdSql.query("select tan(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -2994,7 +3126,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.19089234430221486) tdSql.checkData(6, 0, -0.19089234430221486) - tdSql.query('select tan(c4) from tb1;') + tdSql.query("select tan(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3004,7 +3136,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1.0523779637351338) tdSql.checkData(6, 0, -1.0523779637351338) - tdSql.query('select tan(c5) from tb1;') + tdSql.query("select tan(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3014,7 +3146,7 @@ class TDTestCase: tdSql.checkData(5, 0, 84.73931296875567) tdSql.checkData(6, 0, -84.73931296875567) - tdSql.query('select tan(c6) from tb1;') + tdSql.query("select tan(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3024,7 +3156,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.6117979498342481) tdSql.checkData(6, 0, 0.6117979498342481) - tdSql.query('select tan(c7) from tb1;') + tdSql.query("select tan(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3034,7 +3166,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1.7884906829818519) tdSql.checkData(6, 0, -1.7884906829818519) - tdSql.query('select tan(c10) from tb1;') + tdSql.query("select tan(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3044,7 +3176,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.5067147154345417) tdSql.checkData(6, 0, 0.0) - tdSql.query('select tan(c11) from tb1;') + tdSql.query("select tan(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3054,7 +3186,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.39622301037411284) tdSql.checkData(6, 0, 0.0) - tdSql.query('select tan(c12) from tb1;') + tdSql.query("select tan(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3064,7 +3196,7 @@ class TDTestCase: tdSql.checkData(5, 0, -19.579238091943036) tdSql.checkData(6, 0, 0.0) - tdSql.query('select tan(c13) from tb1;') + tdSql.query("select tan(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3074,7 +3206,7 @@ class TDTestCase: tdSql.checkData(5, 0, 84.73931296875567) tdSql.checkData(6, 0, 0.0) - tdSql.query('select tan(a) from (select tan(c2) as a from tb1);') + tdSql.query("select tan(a) from (select tan(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 74.68593339876537) tdSql.checkData(1, 0, None) @@ -3084,7 +3216,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1.7205151938006633) tdSql.checkData(6, 0, -1.7205151938006633) - tdSql.query('select tan(c2 + c3) from tb1;') + tdSql.query("select tan(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -2.185039863261519) tdSql.checkData(1, 0, None) @@ -3094,7 +3226,7 @@ class TDTestCase: tdSql.checkData(5, 0, 21.780973629229287) tdSql.checkData(6, 0, -21.780973629229287) - tdSql.query('select tan((c2 + c3)) from tb1;') + tdSql.query("select tan((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -2.185039863261519) tdSql.checkData(1, 0, None) @@ -3104,7 +3236,7 @@ class TDTestCase: tdSql.checkData(5, 0, 21.780973629229287) tdSql.checkData(6, 0, -21.780973629229287) - tdSql.query('select tan((c2 * c3)+c4-6) from tb1;') + tdSql.query("select tan((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -1.1578212823495775) tdSql.checkData(1, 0, None) @@ -3114,7 +3246,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.08370895334379919) tdSql.checkData(6, 0, 7.387587307544252) - tdSql.query('select tan(11)+c2 from tb1;') + tdSql.query("select tan(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -224.95084645419513) tdSql.checkData(1, 0, None) @@ -3124,7 +3256,7 @@ class TDTestCase: tdSql.checkData(5, 0, -98.95084645419513) tdSql.checkData(6, 0, -352.95084645419513) - tdSql.query('select tan(c2)+11 from tb1;') + tdSql.query("select tan(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.557407724654903) tdSql.checkData(1, 0, None) @@ -3134,14 +3266,16 @@ class TDTestCase: tdSql.checkData(5, 0, 15.18589183185199) tdSql.checkData(6, 0, 6.814108168148011) - tdSql.query('select tan(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select tan(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, -2.185039863261519) tdSql.checkData(1, 0, -6.799711455220379) tdSql.checkData(2, 0, 21.780973629229287) tdSql.checkData(3, 0, -21.780973629229287) - tdSql.query('select tan(c2) from tb1 order by ts desc;') + tdSql.query("select tan(c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -4.185891831851989) tdSql.checkData(1, 0, 4.185891831851989) @@ -3151,7 +3285,7 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.5574077246549023) - tdSql.query('select tan(c2+c3) from tb1 order by ts desc;') + tdSql.query("select tan(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -21.780973629229287) tdSql.checkData(1, 0, 21.780973629229287) @@ -3161,13 +3295,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, -2.185039863261519) - tdSql.query('select tan(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select tan(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, -6.799711455220379) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select tan(c2) from stb1;') + tdSql.query("select tan(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3184,59 +3318,59 @@ class TDTestCase: tdSql.checkData(12, 0, -0.29100619138474915) tdSql.checkData(13, 0, 0.8714479827243188) - tdSql.query('select tan(c2) from stb1 order by ts desc;') + tdSql.query("select tan(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select tan(c4),t1 from stb1 order by ts desc;') + tdSql.query("select tan(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select tan(c3),tbname from stb1;') + tdSql.query("select tan(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5574077246549023) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, -0.1425465430742778) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 1.1578212823495775) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 0.19089234430221486) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, -0.19089234430221486) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1.5574077246549023) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, -2.185039863261519) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, -0.1425465430742778) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 1.1578212823495775) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, -3.380515006246586) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, -0.29100619138474915) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 0.8714479827243188) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select tan(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select tan(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, -2.185039863261519) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, -0.1425465430742778) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 1.1578212823495775) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, -3.380515006246586) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, -0.29100619138474915) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 0.8714479827243188) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select tan(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select tan(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, -2.185039863261519) @@ -3246,7 +3380,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.5812976817374548) tdSql.checkData(6, 0, -0.320040389379563) - tdSql.query('select tan(c2) from (select * from stb1);') + tdSql.query("select tan(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3263,7 +3397,9 @@ class TDTestCase: tdSql.checkData(12, 0, -0.29100619138474915) tdSql.checkData(13, 0, 0.8714479827243188) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, -2.185039863261519) @@ -3276,7 +3412,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, -2.185039863261519) @@ -3289,7 +3427,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -3302,7 +3442,9 @@ class TDTestCase: tdSql.checkData(8, 0, -2.185039863261519) tdSql.checkData(9, 0, 1.5574077246549023) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -3315,7 +3457,9 @@ class TDTestCase: tdSql.checkData(8, 0, 1.5574077246549023) tdSql.checkData(9, 0, -0.320040389379563) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, -0.320040389379563) tdSql.checkData(1, 0, 1.5574077246549023) @@ -3328,7 +3472,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select tan(a) from (select tan(c2) as a from tb1);') + tdSql.query("select tan(a) from (select tan(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 74.68593339876537) tdSql.checkData(1, 0, None) @@ -3338,7 +3482,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1.7205151938006633) tdSql.checkData(6, 0, -1.7205151938006633) - tdSql.query('select tan(tb1.c3),tan(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query("select tan(tb1.c3),tan(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(0, 1, 1.5574077246549023) @@ -3355,7 +3499,7 @@ class TDTestCase: tdSql.checkData(6, 0, -0.19089234430221486) tdSql.checkData(6, 1, 0.8714479827243188) - tdSql.query('select tan(c3) from tb1 union all select tan(c3) from tb2;') + tdSql.query("select tan(c3) from tb1 union all select tan(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -3372,31 +3516,30 @@ class TDTestCase: tdSql.checkData(12, 0, -0.29100619138474915) tdSql.checkData(13, 0, 0.8714479827243188) - #=========== end math_tan ========== - + # =========== end math_tan ========== - #=========== begin math_pow ========== - tdSql.query('select pow(c2,13) from tb1;') + # =========== begin math_pow ========== + tdSql.query("select pow(c2,13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 8192.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 67108864.0) - tdSql.checkData(5, 0, 2.235879388560037e+27) - tdSql.checkData(6, 0, -2.235879388560037e+27) + tdSql.checkData(5, 0, 2.235879388560037e27) + tdSql.checkData(6, 0, -2.235879388560037e27) - tdSql.query('select pow(c2,c2) from tb1;') + tdSql.query("select pow(c2,c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 4.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 256.0) - tdSql.checkData(5, 0, 1.5243074119957227e+267) + tdSql.checkData(5, 0, 1.5243074119957227e267) tdSql.checkData(6, 0, -6.560356474884124e-268) - tdSql.query('select pow(c2,c3) from tb1;') + tdSql.query("select pow(c2,c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3406,7 +3549,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, -0.0) - tdSql.query('select pow(c2,c4) from tb1;') + tdSql.query("select pow(c2,c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3416,7 +3559,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, -0.0) - tdSql.query('select pow(c2,c5) from tb1;') + tdSql.query("select pow(c2,c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3426,7 +3569,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,c6) from tb1;') + tdSql.query("select pow(c2,c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3436,7 +3579,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,c7) from tb1;') + tdSql.query("select pow(c2,c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3446,7 +3589,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,c10) from tb1;') + tdSql.query("select pow(c2,c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3456,7 +3599,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c11) from tb1;') + tdSql.query("select pow(c2,c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3466,7 +3609,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c12) from tb1;') + tdSql.query("select pow(c2,c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3476,7 +3619,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c13) from tb1;') + tdSql.query("select pow(c2,c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3486,7 +3629,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c2 + c3) from tb1;') + tdSql.query("select pow(c2,c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3496,7 +3639,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,(c2 + c3)) from tb1;') + tdSql.query("select pow(c2,(c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3506,7 +3649,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,(c2 * c3)+c4-6) from tb1;') + tdSql.query("select pow(c2,(c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3516,44 +3659,46 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,11)+c2 from tb1;') + tdSql.query("select pow(c2,11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 2.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 2050.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 4194308.0) - tdSql.checkData(5, 0, 1.3862479934032099e+23) - tdSql.checkData(6, 0, -1.3862479934032099e+23) + tdSql.checkData(5, 0, 1.3862479934032099e23) + tdSql.checkData(6, 0, -1.3862479934032099e23) - tdSql.query('select pow(c2,c2)+11 from tb1;') + tdSql.query("select pow(c2,c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 15.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 267.0) - tdSql.checkData(5, 0, 1.5243074119957227e+267) + tdSql.checkData(5, 0, 1.5243074119957227e267) tdSql.checkData(6, 0, 11.0) - tdSql.query('select pow(c2,c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select pow(c2,c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 65536.0) tdSql.checkData(2, 0, inf) tdSql.checkData(3, 0, 0.0) - tdSql.query('select pow(c2,c2) from tb1 order by ts desc;') + tdSql.query("select pow(c2,c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -6.560356474884124e-268) - tdSql.checkData(1, 0, 1.5243074119957227e+267) + tdSql.checkData(1, 0, 1.5243074119957227e267) tdSql.checkData(2, 0, 256.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 4.0) tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c2+c3) from tb1 order by ts desc;') + tdSql.query("select pow(c2,c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, inf) @@ -3563,20 +3708,20 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select pow(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 65536.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select pow(c2,c2) from stb1;') + tdSql.query("select pow(c2,c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 4.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 256.0) - tdSql.checkData(5, 0, 1.5243074119957227e+267) + tdSql.checkData(5, 0, 1.5243074119957227e267) tdSql.checkData(6, 0, -6.560356474884124e-268) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 4.0) @@ -3586,66 +3731,66 @@ class TDTestCase: tdSql.checkData(12, 0, 46656.0) tdSql.checkData(13, 0, 823543.0) - tdSql.query('select pow(c2,c2) from stb1 order by ts desc;') + tdSql.query("select pow(c2,c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select pow(c2,c4),t1 from stb1 order by ts desc;') + tdSql.query("select pow(c2,c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select pow(c2,c3),tbname from stb1;') + tdSql.query("select pow(c2,c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 256.0) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, inf) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, -0.0) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1.0) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 4.0) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 27.0) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 256.0) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 3125.0) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 46656.0) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 823543.0) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select pow(c2,c3),tbname from stb1 where t1 > 1;') + tdSql.query("select pow(c2,c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 4.0) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 27.0) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 256.0) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 3125.0) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 46656.0) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 823543.0) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select pow(c2,c2) from (select * from stb1);') + tdSql.query("select pow(c2,c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 4.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 256.0) - tdSql.checkData(5, 0, 1.5243074119957227e+267) + tdSql.checkData(5, 0, 1.5243074119957227e267) tdSql.checkData(6, 0, -6.560356474884124e-268) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 4.0) @@ -3655,7 +3800,7 @@ class TDTestCase: tdSql.checkData(12, 0, 46656.0) tdSql.checkData(13, 0, 823543.0) - tdSql.query('select pow(c2,c3) from tb1 union all select pow(c2,c3) from tb2;') + tdSql.query("select pow(c2,c3) from tb1 union all select pow(c2,c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3672,11 +3817,10 @@ class TDTestCase: tdSql.checkData(12, 0, 46656.0) tdSql.checkData(13, 0, 823543.0) - #=========== end math_pow ========== + # =========== end math_pow ========== - - #=========== begin math_log ========== - tdSql.query('select log(c2,13) from tb1;') + # =========== begin math_log ========== + tdSql.query("select log(c2,13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) @@ -3684,109 +3828,109 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 0.5404763088546395) tdSql.checkData(5, 0, 1.8886092516277813) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2) from tb1;') + tdSql.query("select log(c2,c2) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 1.0) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c3) from tb1;') + tdSql.query("select log(c2,c3) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.465913680008469) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c4) from tb1;') + tdSql.query("select log(c2,c4) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.22544144151366513) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c5) from tb1;') + tdSql.query("select log(c2,c5) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.11093150296463757) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c6) from tb1;') + tdSql.query("select log(c2,c6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.05459909915208762) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c7) from tb1;') + tdSql.query("select log(c2,c7) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.006824887406193638) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c10) from tb1;') + tdSql.query("select log(c2,c10) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.8748229478056855) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c11) from tb1;') + tdSql.query("select log(c2,c11) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.4367939948774267) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c12) from tb1;') + tdSql.query("select log(c2,c12) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.2183963964662152) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c13) from tb1;') + tdSql.query("select log(c2,c13) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.11093150296463757) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2 + c3) from tb1;') + tdSql.query("select log(c2,c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) @@ -3794,9 +3938,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 0.6666666666666667) tdSql.checkData(5, 0, 0.4657403972991969) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,(c2 + c3)) from tb1;') + tdSql.query("select log(c2,(c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) @@ -3804,19 +3948,19 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 0.6666666666666667) tdSql.checkData(5, 0, 0.4657403972991969) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,(c2 * c3)+c4-6) from tb1;') + tdSql.query("select log(c2,(c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 0.5252990700743871) tdSql.checkData(5, 0, 0.22542113212116985) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,11)+c2 from tb1;') + tdSql.query("select log(c2,11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -3824,38 +3968,40 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 4.578129652635775) tdSql.checkData(5, 0, 129.02018292517226) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2)+11 from tb1;') + tdSql.query("select log(c2,c2)+11 from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 12.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 12.0) tdSql.checkData(5, 0, 12.0) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select log(c2,c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, 0.6666666666666667) tdSql.checkData(2, 0, 0.4657403972991969) - tdSql.checkData(3, 0, None) + tdSql.checkData(3, 0, nan) - tdSql.query('select log(c2,c2) from tb1 order by ts desc;') + tdSql.query("select log(c2,c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 1.0) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2+c3) from tb1 order by ts desc;') + tdSql.query("select log(c2,c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 0.4657403972991969) tdSql.checkData(2, 0, 0.6666666666666667) tdSql.checkData(3, 0, None) @@ -3863,22 +4009,22 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.0) - tdSql.query('select log(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select log(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 0.6666666666666667) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select log(c2,c2) from stb1;') + tdSql.query("select log(c2,c2) from stb1;") tdSql.checkRows(14) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 1.0) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 1.0) tdSql.checkData(10, 0, 1.0) @@ -3886,68 +4032,68 @@ class TDTestCase: tdSql.checkData(12, 0, 1.0) tdSql.checkData(13, 0, 1.0) - tdSql.query('select log(c2,c2) from stb1 order by ts desc;') + tdSql.query("select log(c2,c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select log(c2,c4),t1 from stb1 order by ts desc;') + tdSql.query("select log(c2,c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select log(c2,c3),tbname from stb1;') + tdSql.query("select log(c2,c3),tbname from stb1;") tdSql.checkRows(14) - tdSql.checkData(0, 0, None) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 0, nan) + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 1.0) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 0.465913680008469) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') - tdSql.checkData(7, 0, None) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") + tdSql.checkData(7, 0, nan) + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 1.0) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 1.0) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 1.0) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 1.0) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 1.0) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 1.0) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select log(c2,c3),tbname from stb1 where t1 > 1;') + tdSql.query("select log(c2,c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 0, nan) + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 1.0) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 1.0) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 1.0) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 1.0) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 1.0) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 1.0) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select log(c2,c2) from (select * from stb1);') + tdSql.query("select log(c2,c2) from (select * from stb1);") tdSql.checkRows(14) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 1.0) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 1.0) tdSql.checkData(10, 0, 1.0) @@ -3955,16 +4101,16 @@ class TDTestCase: tdSql.checkData(12, 0, 1.0) tdSql.checkData(13, 0, 1.0) - tdSql.query('select log(c2,c3) from tb1 union all select log(c2,c3) from tb2;') + tdSql.query("select log(c2,c3) from tb1 union all select log(c2,c3) from tb2;") tdSql.checkRows(14) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.465913680008469) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 1.0) tdSql.checkData(10, 0, 1.0) @@ -3972,80 +4118,140 @@ class TDTestCase: tdSql.checkData(12, 0, 1.0) tdSql.checkData(13, 0, 1.0) - #=========== end math_log ========== - + # =========== end math_log ========== - - tdSql.execute('create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);') + tdSql.execute( + "create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);" + ) tdSql.execute("create table tba1 using stba tags(1,'1',1.0);") - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:00\',true, 1,1,1,1,1,1,"111","1111",1,1,1,1);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:00\',true, 1,1,1,1,1,1,"111","1111",1,1,1,1);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:01\',true, 2,2,2,2,2,2,"222","2222",2,2,2,2);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:01\',true, 2,2,2,2,2,2,"222","2222",2,2,2,2);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:02\',true, 3,3,2,3,3,3,"333","3333",3,3,3,3);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:02\',true, 3,3,2,3,3,3,"333","3333",3,3,3,3);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:03\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:03\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:04\',true, 5,5,5,5,5,5,"555","5555",5,5,5,5);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:04\',true, 5,5,5,5,5,5,"555","5555",5,5,5,5);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:05\',true, 6,6,6,6,6,6,"666","6666",6,6,6,6);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:05\',true, 6,6,6,6,6,6,"666","6666",6,6,6,6);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:06\',true, 7,7,7,7,7,7,"777","7777",7,7,7,7);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:06\',true, 7,7,7,7,7,7,"777","7777",7,7,7,7);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:07\',true, 8,8,8,8,8,8,"888","8888",8,8,8,8);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:07\',true, 8,8,8,8,8,8,"888","8888",8,8,8,8);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:08\',true, 9,9,9,9,9,9,"999","9999",9,9,9,9);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:08\',true, 9,9,9,9,9,9,"999","9999",9,9,9,9);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:09\',true, 0,0,0,0,0,0,"000","0000",0,0,0,0);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:09\',true, 0,0,0,0,0,0,"000","0000",0,0,0,0);' + ) - self.restartTaosd(1, dbname='math_funcs') + self.restartTaosd(1, dbname="math_funcs") - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:10\',true, 1,1,1,1,1,1,"111","1111",1,1,1,1);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:10\',true, 1,1,1,1,1,1,"111","1111",1,1,1,1);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:11\',true, 2,2,2,2,2,2,"222","2222",2,2,2,2);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:11\',true, 2,2,2,2,2,2,"222","2222",2,2,2,2);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:12\',true, 3,3,2,3,3,3,"333","3333",3,3,3,3);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:12\',true, 3,3,2,3,3,3,"333","3333",3,3,3,3);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:13\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:13\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:14\',true, 5,5,5,5,5,5,"555","5555",5,5,5,5);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:14\',true, 5,5,5,5,5,5,"555","5555",5,5,5,5);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:15\',true, 6,6,6,6,6,6,"666","6666",6,6,6,6);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:15\',true, 6,6,6,6,6,6,"666","6666",6,6,6,6);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:16\',true, 7,7,7,7,7,7,"777","7777",7,7,7,7);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:16\',true, 7,7,7,7,7,7,"777","7777",7,7,7,7);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:17\',true, 8,8,8,8,8,8,"888","8888",8,8,8,8);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:17\',true, 8,8,8,8,8,8,"888","8888",8,8,8,8);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:18\',true, 9,9,9,9,9,9,"999","9999",9,9,9,9);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:18\',true, 9,9,9,9,9,9,"999","9999",9,9,9,9);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:19\',true, 0,0,0,0,0,0,"000","0000",0,0,0,0);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:19\',true, 0,0,0,0,0,0,"000","0000",0,0,0,0);' + ) - self.restartTaosd(1, dbname='math_funcs') + self.restartTaosd(1, dbname="math_funcs") - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:20\',true, 1,1,1,1,1,1,"111","1111",1,1,1,1);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:20\',true, 1,1,1,1,1,1,"111","1111",1,1,1,1);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:21\',true, 2,2,2,2,2,2,"222","2222",2,2,2,2);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:21\',true, 2,2,2,2,2,2,"222","2222",2,2,2,2);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:22\',true, 3,3,2,3,3,3,"333","3333",3,3,3,3);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:22\',true, 3,3,2,3,3,3,"333","3333",3,3,3,3);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:23\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:23\',false,4,4,4,4,4,4,"444","4444",4,4,4,4);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:24\',true, 5,5,5,5,5,5,"555","5555",5,5,5,5);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:24\',true, 5,5,5,5,5,5,"555","5555",5,5,5,5);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:25\',true, 6,6,6,6,6,6,"666","6666",6,6,6,6);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:25\',true, 6,6,6,6,6,6,"666","6666",6,6,6,6);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:26\',true, 7,7,7,7,7,7,"777","7777",7,7,7,7);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:26\',true, 7,7,7,7,7,7,"777","7777",7,7,7,7);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:27\',true, 8,8,8,8,8,8,"888","8888",8,8,8,8);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:27\',true, 8,8,8,8,8,8,"888","8888",8,8,8,8);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:28\',true, 9,9,9,9,9,9,"999","9999",9,9,9,9);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:28\',true, 9,9,9,9,9,9,"999","9999",9,9,9,9);' + ) - tdSql.execute('insert into tba1 values (\'2021-11-11 09:00:29\',true, 0,0,0,0,0,0,"000","0000",0,0,0,0);') + tdSql.execute( + 'insert into tba1 values (\'2021-11-11 09:00:29\',true, 0,0,0,0,0,0,"000","0000",0,0,0,0);' + ) - #=========== begin math_sqrt ========== - tdSql.query('select sqrt(13) from tb1;') + # =========== begin math_sqrt ========== + tdSql.query("select sqrt(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 3.605551275463989) tdSql.checkData(1, 0, 3.605551275463989) @@ -4055,7 +4261,7 @@ class TDTestCase: tdSql.checkData(5, 0, 3.605551275463989) tdSql.checkData(6, 0, 3.605551275463989) - tdSql.query('select sqrt(c2) from tb1;') + tdSql.query("select sqrt(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4063,9 +4269,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 11.269427669584644) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c3) from tb1;') + tdSql.query("select sqrt(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4073,9 +4279,9 @@ class TDTestCase: tdSql.checkData(3, 0, 1.7320508075688772) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 181.01657382681842) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c4) from tb1;') + tdSql.query("select sqrt(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4083,9 +4289,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 46340.950001051984) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c5) from tb1;') + tdSql.query("select sqrt(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4093,29 +4299,29 @@ class TDTestCase: tdSql.checkData(3, 0, 1.7320508075688772) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 3037000499.97605) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c6) from tb1;') + tdSql.query("select sqrt(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.4142135623730951) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) - tdSql.checkData(5, 0, 1.844674352395373e+19) - tdSql.checkData(6, 0, None) + tdSql.checkData(5, 0, 1.844674352395373e19) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c7) from tb1;') + tdSql.query("select sqrt(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, 1.7320508075688772) tdSql.checkData(4, 0, 2.0) - tdSql.checkData(5, 0, 1.3407796239501852e+154) - tdSql.checkData(6, 0, None) + tdSql.checkData(5, 0, 1.3407796239501852e154) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c10) from tb1;') + tdSql.query("select sqrt(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4125,7 +4331,7 @@ class TDTestCase: tdSql.checkData(5, 0, 15.937377450509228) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sqrt(c11) from tb1;') + tdSql.query("select sqrt(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4135,7 +4341,7 @@ class TDTestCase: tdSql.checkData(5, 0, 255.99609372019722) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sqrt(c12) from tb1;') + tdSql.query("select sqrt(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4145,7 +4351,7 @@ class TDTestCase: tdSql.checkData(5, 0, 65535.99998474121) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sqrt(c13) from tb1;') + tdSql.query("select sqrt(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4155,7 +4361,7 @@ class TDTestCase: tdSql.checkData(5, 0, 3037000499.97605) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sqrt(a) from (select sqrt(c2) as a from tb1);') + tdSql.query("select sqrt(a) from (select sqrt(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4163,9 +4369,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.4142135623730951) tdSql.checkData(5, 0, 3.3569968229929326) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c2 + c3) from tb1;') + tdSql.query("select sqrt(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.4142135623730951) tdSql.checkData(1, 0, None) @@ -4173,9 +4379,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.8284271247461903) tdSql.checkData(5, 0, 181.36703118262702) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt((c2 + c3)) from tb1;') + tdSql.query("select sqrt((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.4142135623730951) tdSql.checkData(1, 0, None) @@ -4183,19 +4389,19 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.8284271247461903) tdSql.checkData(5, 0, 181.36703118262702) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt((c2 * c3)+c4-6) from tb1;') + tdSql.query("select sqrt((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 3.7416573867739413) tdSql.checkData(5, 0, 46385.82811592351) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(11)+c2 from tb1;') + tdSql.query("select sqrt(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 4.3166247903554) tdSql.checkData(1, 0, None) @@ -4205,7 +4411,7 @@ class TDTestCase: tdSql.checkData(5, 0, 130.3166247903554) tdSql.checkData(6, 0, -123.6833752096446) - tdSql.query('select sqrt(c2)+11 from tb1;') + tdSql.query("select sqrt(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.0) tdSql.checkData(1, 0, None) @@ -4213,18 +4419,20 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 13.0) tdSql.checkData(5, 0, 22.269427669584644) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select sqrt(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 1.4142135623730951) tdSql.checkData(1, 0, 2.8284271247461903) tdSql.checkData(2, 0, 181.36703118262702) - tdSql.checkData(3, 0, None) + tdSql.checkData(3, 0, nan) - tdSql.query('select sqrt(c2) from tb1 order by ts desc;') + tdSql.query("select sqrt(c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 11.269427669584644) tdSql.checkData(2, 0, 2.0) tdSql.checkData(3, 0, None) @@ -4232,9 +4440,9 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.0) - tdSql.query('select sqrt(c2+c3) from tb1 order by ts desc;') + tdSql.query("select sqrt(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 181.36703118262702) tdSql.checkData(2, 0, 2.8284271247461903) tdSql.checkData(3, 0, None) @@ -4242,13 +4450,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.4142135623730951) - tdSql.query('select sqrt(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select sqrt(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 2.8284271247461903) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select sqrt(c2) from stb1;') + tdSql.query("select sqrt(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4256,7 +4464,7 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 11.269427669584644) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.7320508075688772) @@ -4265,59 +4473,59 @@ class TDTestCase: tdSql.checkData(12, 0, 2.449489742783178) tdSql.checkData(13, 0, 2.6457513110645907) - tdSql.query('select sqrt(c2) from stb1 order by ts desc;') + tdSql.query("select sqrt(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select sqrt(c4),t1,c4 from stb1 order by ts desc;') + tdSql.query("select sqrt(c4),t1,c4 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select sqrt(c3),tbname from stb1;') + tdSql.query("select sqrt(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, 1.7320508075688772) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 2.0) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 181.01657382681842) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1.0) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 1.4142135623730951) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 1.7320508075688772) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 2.0) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 2.23606797749979) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 2.449489742783178) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 2.6457513110645907) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select sqrt(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select sqrt(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 1.4142135623730951) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 1.7320508075688772) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 2.0) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 2.23606797749979) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 2.449489742783178) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 2.6457513110645907) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select sqrt(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 1.4142135623730951) @@ -4325,9 +4533,9 @@ class TDTestCase: tdSql.checkData(3, 0, 2.0) tdSql.checkData(4, 0, 2.1213203435596424) tdSql.checkData(5, 0, 8.154753215150045) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(c2) from (select * from stb1);') + tdSql.query("select sqrt(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4335,7 +4543,7 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 11.269427669584644) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.7320508075688772) @@ -4344,7 +4552,9 @@ class TDTestCase: tdSql.checkData(12, 0, 2.449489742783178) tdSql.checkData(13, 0, 2.6457513110645907) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 1.4142135623730951) @@ -4352,12 +4562,14 @@ class TDTestCase: tdSql.checkData(3, 0, 2.0) tdSql.checkData(4, 0, 2.1213203435596424) tdSql.checkData(5, 0, 8.154753215150045) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 1.4142135623730951) @@ -4365,17 +4577,19 @@ class TDTestCase: tdSql.checkData(3, 0, 2.0) tdSql.checkData(4, 0, 2.1213203435596424) tdSql.checkData(5, 0, 8.154753215150045) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) + tdSql.checkData(3, 0, nan) tdSql.checkData(4, 0, 8.154753215150045) tdSql.checkData(5, 0, 2.1213203435596424) tdSql.checkData(6, 0, 2.0) @@ -4383,7 +4597,9 @@ class TDTestCase: tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.0) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -4394,11 +4610,13 @@ class TDTestCase: tdSql.checkData(6, 0, 1.5811388300841898) tdSql.checkData(7, 0, 1.4142135623730951) tdSql.checkData(8, 0, 1.0) - tdSql.checkData(9, 0, None) + tdSql.checkData(9, 0, nan) - tdSql.query("select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select sqrt(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 1.0) tdSql.checkData(2, 0, 1.4142135623730951) tdSql.checkData(3, 0, 1.5811388300841898) @@ -4409,7 +4627,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select sqrt(a) from (select sqrt(c2) as a from tb1);') + tdSql.query("select sqrt(a) from (select sqrt(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4417,9 +4635,11 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.4142135623730951) tdSql.checkData(5, 0, 3.3569968229929326) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select sqrt(tb1.c3),sqrt(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query( + "select sqrt(tb1.c3),sqrt(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(0, 1, 1.0) @@ -4433,10 +4653,10 @@ class TDTestCase: tdSql.checkData(4, 1, 2.23606797749979) tdSql.checkData(5, 0, 181.01657382681842) tdSql.checkData(5, 1, 2.449489742783178) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(6, 1, 2.6457513110645907) - tdSql.query('select sqrt(c3) from tb1 union all select sqrt(c3) from tb2;') + tdSql.query("select sqrt(c3) from tb1 union all select sqrt(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4444,7 +4664,7 @@ class TDTestCase: tdSql.checkData(3, 0, 1.7320508075688772) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 181.01657382681842) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.7320508075688772) @@ -4453,11 +4673,12 @@ class TDTestCase: tdSql.checkData(12, 0, 2.449489742783178) tdSql.checkData(13, 0, 2.6457513110645907) - #=========== end math_sqrt ========== + # =========== end math_sqrt ========== - - #=========== begin math_sqrt2 ========== - tdSql.query('select sqrt(stb1.c4),sqrt(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;') + # =========== begin math_sqrt2 ========== + tdSql.query( + "select sqrt(stb1.c4),sqrt(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(0, 1, 1.0) @@ -4471,10 +4692,12 @@ class TDTestCase: tdSql.checkData(4, 1, 2.23606797749979) tdSql.checkData(5, 0, 46340.950001051984) tdSql.checkData(5, 1, 2.449489742783178) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(6, 1, 2.6457513110645907) - tdSql.query('select sqrt(c4) as a from stb1 union all select sqrt(c5) as a from stba;') + tdSql.query( + "select sqrt(c4) as a from stb1 union all select sqrt(c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -4482,7 +4705,7 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 2.0) tdSql.checkData(5, 0, 46340.950001051984) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 1.4142135623730951) tdSql.checkData(9, 0, 1.4142135623730951) @@ -4521,7 +4744,7 @@ class TDTestCase: tdSql.checkData(42, 0, 3.0) tdSql.checkData(43, 0, 0.0) - tdSql.query('select sqrt(c2) from stba;') + tdSql.query("select sqrt(c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 1.4142135623730951) @@ -4554,47 +4777,47 @@ class TDTestCase: tdSql.checkData(28, 0, 3.0) tdSql.checkData(29, 0, 0.0) - tdSql.query('select sqrt(min(c2)) from tba1;') + tdSql.query("select sqrt(min(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select sqrt(max(c2)) from tba1;') + tdSql.query("select sqrt(max(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 3.0) - tdSql.query('select sqrt(count(c2)) from tba1;') + tdSql.query("select sqrt(count(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 5.477225575051661) - tdSql.query('select sqrt(sum(c2)) from tba1;') + tdSql.query("select sqrt(sum(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 11.61895003862225) - tdSql.query('select sqrt(avg(c2)) from tba1;') + tdSql.query("select sqrt(avg(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 2.1213203435596424) - tdSql.query('select sqrt(percentile(c2, 10)) from tba1;') + tdSql.query("select sqrt(percentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.9486832980505138) - tdSql.query('select sqrt(apercentile(c2, 10)) from tba1;') + tdSql.query("select sqrt(apercentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select sqrt(stddev(c2)) from tba1;') + tdSql.query("select sqrt(stddev(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.694780612135097) - tdSql.query('select sqrt(spread(c2)) from tba1;') + tdSql.query("select sqrt(spread(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 3.0) - tdSql.query('select sqrt(twa(c2)) from tba1;') + tdSql.query("select sqrt(twa(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 2.1535856227423973) - tdSql.query('select sqrt(interp(c2)) from tba1 every(1s)') + tdSql.query("select sqrt(interp(c2)) from tba1 every(1s)") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 1.0) @@ -4657,128 +4880,127 @@ class TDTestCase: tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0.0) - tdSql.query('select sqrt(interp(c2)) from stba every(1s) group by tbname;') + tdSql.query("select sqrt(interp(c2)) from stba every(1s) group by tbname;") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 1.0) - tdSql.checkData(0, 2, 'tba1') + tdSql.checkData(0, 2, "tba1") tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) tdSql.checkData(1, 1, 1.4142135623730951) - tdSql.checkData(1, 2, 'tba1') + tdSql.checkData(1, 2, "tba1") tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) tdSql.checkData(2, 1, 1.7320508075688772) - tdSql.checkData(2, 2, 'tba1') + tdSql.checkData(2, 2, "tba1") tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) tdSql.checkData(3, 1, 2.0) - tdSql.checkData(3, 2, 'tba1') + tdSql.checkData(3, 2, "tba1") tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) tdSql.checkData(4, 1, 2.23606797749979) - tdSql.checkData(4, 2, 'tba1') + tdSql.checkData(4, 2, "tba1") tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) tdSql.checkData(5, 1, 2.449489742783178) - tdSql.checkData(5, 2, 'tba1') + tdSql.checkData(5, 2, "tba1") tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) tdSql.checkData(6, 1, 2.6457513110645907) - tdSql.checkData(6, 2, 'tba1') + tdSql.checkData(6, 2, "tba1") tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) tdSql.checkData(7, 1, 2.8284271247461903) - tdSql.checkData(7, 2, 'tba1') + tdSql.checkData(7, 2, "tba1") tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) tdSql.checkData(8, 1, 3.0) - tdSql.checkData(8, 2, 'tba1') + tdSql.checkData(8, 2, "tba1") tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 0.0) - tdSql.checkData(9, 2, 'tba1') + tdSql.checkData(9, 2, "tba1") tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 1.0) - tdSql.checkData(10, 2, 'tba1') + tdSql.checkData(10, 2, "tba1") tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) tdSql.checkData(11, 1, 1.4142135623730951) - tdSql.checkData(11, 2, 'tba1') + tdSql.checkData(11, 2, "tba1") tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) tdSql.checkData(12, 1, 1.7320508075688772) - tdSql.checkData(12, 2, 'tba1') + tdSql.checkData(12, 2, "tba1") tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) tdSql.checkData(13, 1, 2.0) - tdSql.checkData(13, 2, 'tba1') + tdSql.checkData(13, 2, "tba1") tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) tdSql.checkData(14, 1, 2.23606797749979) - tdSql.checkData(14, 2, 'tba1') + tdSql.checkData(14, 2, "tba1") tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) tdSql.checkData(15, 1, 2.449489742783178) - tdSql.checkData(15, 2, 'tba1') + tdSql.checkData(15, 2, "tba1") tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) tdSql.checkData(16, 1, 2.6457513110645907) - tdSql.checkData(16, 2, 'tba1') + tdSql.checkData(16, 2, "tba1") tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) tdSql.checkData(17, 1, 2.8284271247461903) - tdSql.checkData(17, 2, 'tba1') + tdSql.checkData(17, 2, "tba1") tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) tdSql.checkData(18, 1, 3.0) - tdSql.checkData(18, 2, 'tba1') + tdSql.checkData(18, 2, "tba1") tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 0.0) - tdSql.checkData(19, 2, 'tba1') + tdSql.checkData(19, 2, "tba1") tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 1.0) - tdSql.checkData(20, 2, 'tba1') + tdSql.checkData(20, 2, "tba1") tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) tdSql.checkData(21, 1, 1.4142135623730951) - tdSql.checkData(21, 2, 'tba1') + tdSql.checkData(21, 2, "tba1") tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) tdSql.checkData(22, 1, 1.7320508075688772) - tdSql.checkData(22, 2, 'tba1') + tdSql.checkData(22, 2, "tba1") tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) tdSql.checkData(23, 1, 2.0) - tdSql.checkData(23, 2, 'tba1') + tdSql.checkData(23, 2, "tba1") tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) tdSql.checkData(24, 1, 2.23606797749979) - tdSql.checkData(24, 2, 'tba1') + tdSql.checkData(24, 2, "tba1") tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) tdSql.checkData(25, 1, 2.449489742783178) - tdSql.checkData(25, 2, 'tba1') + tdSql.checkData(25, 2, "tba1") tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) tdSql.checkData(26, 1, 2.6457513110645907) - tdSql.checkData(26, 2, 'tba1') + tdSql.checkData(26, 2, "tba1") tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) tdSql.checkData(27, 1, 2.8284271247461903) - tdSql.checkData(27, 2, 'tba1') + tdSql.checkData(27, 2, "tba1") tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) tdSql.checkData(28, 1, 3.0) - tdSql.checkData(28, 2, 'tba1') + tdSql.checkData(28, 2, "tba1") tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0.0) - tdSql.checkData(29, 2, 'tba1') + tdSql.checkData(29, 2, "tba1") - tdSql.query('select sqrt(elapsed(ts)) from tba1;') + tdSql.query("select sqrt(elapsed(ts)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 170.29386365926402) - tdSql.query('select sqrt(rate(c2)) from tba1;') + tdSql.query("select sqrt(rate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.9468641529479986) - tdSql.query('select sqrt(irate(c2)) from tba1;') + tdSql.query("select sqrt(irate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select sqrt(first(c2)) from tba1;') + tdSql.query("select sqrt(first(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.0) - tdSql.query('select sqrt(last(c2)) from tba1;') + tdSql.query("select sqrt(last(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select sqrt(last_row(c2)) from tba1;') + tdSql.query("select sqrt(last_row(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - #=========== end math_sqrt2 ========== - + # =========== end math_sqrt2 ========== - #=========== begin math_abs ========== - tdSql.query('select abs(13) from tb1;') + # =========== begin math_abs ========== + tdSql.query("select abs(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 13) tdSql.checkData(1, 0, 13) @@ -4788,7 +5010,7 @@ class TDTestCase: tdSql.checkData(5, 0, 13) tdSql.checkData(6, 0, 13) - tdSql.query('select abs(c2) from tb1;') + tdSql.query("select abs(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4798,7 +5020,7 @@ class TDTestCase: tdSql.checkData(5, 0, 127) tdSql.checkData(6, 0, 127) - tdSql.query('select abs(c3) from tb1;') + tdSql.query("select abs(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4808,7 +5030,7 @@ class TDTestCase: tdSql.checkData(5, 0, 32767) tdSql.checkData(6, 0, 32767) - tdSql.query('select abs(c4) from tb1;') + tdSql.query("select abs(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4818,7 +5040,7 @@ class TDTestCase: tdSql.checkData(5, 0, 2147483647) tdSql.checkData(6, 0, 2147483647) - tdSql.query('select abs(c5) from tb1;') + tdSql.query("select abs(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4828,27 +5050,27 @@ class TDTestCase: tdSql.checkData(5, 0, 9223372036854775807) tdSql.checkData(6, 0, 9223372036854775807) - tdSql.query('select abs(c6) from tb1;') + tdSql.query("select abs(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 2.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 4.0) - tdSql.checkData(5, 0, 3.4028234663852886e+38) - tdSql.checkData(6, 0, 3.4028234663852886e+38) + tdSql.checkData(5, 0, 3.4028234663852886e38) + tdSql.checkData(6, 0, 3.4028234663852886e38) - tdSql.query('select abs(c7) from tb1;') + tdSql.query("select abs(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, 3.0) tdSql.checkData(4, 0, 4.0) - tdSql.checkData(5, 0, 1.79769e+308) - tdSql.checkData(6, 0, 1.79769e+308) + tdSql.checkData(5, 0, 1.79769e308) + tdSql.checkData(6, 0, 1.79769e308) - tdSql.query('select abs(c10) from tb1;') + tdSql.query("select abs(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4858,7 +5080,7 @@ class TDTestCase: tdSql.checkData(5, 0, 254) tdSql.checkData(6, 0, 0) - tdSql.query('select abs(c11) from tb1;') + tdSql.query("select abs(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4868,7 +5090,7 @@ class TDTestCase: tdSql.checkData(5, 0, 65534) tdSql.checkData(6, 0, 0) - tdSql.query('select abs(c12) from tb1;') + tdSql.query("select abs(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4878,7 +5100,7 @@ class TDTestCase: tdSql.checkData(5, 0, 4294967294) tdSql.checkData(6, 0, 0) - tdSql.query('select abs(c13) from tb1;') + tdSql.query("select abs(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4888,7 +5110,7 @@ class TDTestCase: tdSql.checkData(5, 0, 9223372036854775807) tdSql.checkData(6, 0, 0) - tdSql.query('select abs(a) from (select abs(c2) as a from tb1);') + tdSql.query("select abs(a) from (select abs(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4898,7 +5120,7 @@ class TDTestCase: tdSql.checkData(5, 0, 127) tdSql.checkData(6, 0, 127) - tdSql.query('select abs(c2 + c3) from tb1;') + tdSql.query("select abs(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 2.0) tdSql.checkData(1, 0, None) @@ -4908,7 +5130,7 @@ class TDTestCase: tdSql.checkData(5, 0, 32894.0) tdSql.checkData(6, 0, 32894.0) - tdSql.query('select abs((c2 + c3)) from tb1;') + tdSql.query("select abs((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 2.0) tdSql.checkData(1, 0, None) @@ -4918,7 +5140,7 @@ class TDTestCase: tdSql.checkData(5, 0, 32894.0) tdSql.checkData(6, 0, 32894.0) - tdSql.query('select abs((c2 * c3)+c4-6) from tb1;') + tdSql.query("select abs((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 4.0) tdSql.checkData(1, 0, None) @@ -4928,7 +5150,7 @@ class TDTestCase: tdSql.checkData(5, 0, 2151645050.0) tdSql.checkData(6, 0, 2143322244.0) - tdSql.query('select abs(11)+c2 from tb1;') + tdSql.query("select abs(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.0) tdSql.checkData(1, 0, None) @@ -4938,7 +5160,7 @@ class TDTestCase: tdSql.checkData(5, 0, 138.0) tdSql.checkData(6, 0, -116.0) - tdSql.query('select abs(c2)+11 from tb1;') + tdSql.query("select abs(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.0) tdSql.checkData(1, 0, None) @@ -4948,14 +5170,16 @@ class TDTestCase: tdSql.checkData(5, 0, 138.0) tdSql.checkData(6, 0, 138.0) - tdSql.query('select abs(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select abs(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 2.0) tdSql.checkData(1, 0, 8.0) tdSql.checkData(2, 0, 32894.0) tdSql.checkData(3, 0, 32894.0) - tdSql.query('select abs(c2) from tb1 order by ts desc;') + tdSql.query("select abs(c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 127) tdSql.checkData(1, 0, 127) @@ -4965,7 +5189,7 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1) - tdSql.query('select abs(c2+c3) from tb1 order by ts desc;') + tdSql.query("select abs(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 32894.0) tdSql.checkData(1, 0, 32894.0) @@ -4975,13 +5199,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 2.0) - tdSql.query('select abs(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select abs(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 8.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select abs(c2) from stb1;') + tdSql.query("select abs(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -4998,59 +5222,59 @@ class TDTestCase: tdSql.checkData(12, 0, 6) tdSql.checkData(13, 0, 7) - tdSql.query('select abs(c2) from stb1 order by ts desc;') + tdSql.query("select abs(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select abs(c4),t1 from stb1 order by ts desc;') + tdSql.query("select abs(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select abs(c3),tbname from stb1;') + tdSql.query("select abs(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, 3) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 4) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 32767) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, 32767) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 2) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 3) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 4) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 5) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 6) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 7) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select abs(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select abs(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 2) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 3) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 4) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 5) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 6) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 7) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select abs(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select abs(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 2.0) @@ -5060,7 +5284,7 @@ class TDTestCase: tdSql.checkData(5, 0, 66.5) tdSql.checkData(6, 0, 60.0) - tdSql.query('select abs(c2) from (select * from stb1);') + tdSql.query("select abs(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -5077,7 +5301,9 @@ class TDTestCase: tdSql.checkData(12, 0, 6) tdSql.checkData(13, 0, 7) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 2.0) @@ -5090,7 +5316,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 2.0) @@ -5103,7 +5331,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -5116,7 +5346,9 @@ class TDTestCase: tdSql.checkData(8, 0, 2.0) tdSql.checkData(9, 0, 1.0) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -5129,7 +5361,9 @@ class TDTestCase: tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 60.0) - tdSql.query("select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select abs(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 60.0) tdSql.checkData(1, 0, 1.0) @@ -5142,7 +5376,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select abs(a) from (select abs(c2) as a from tb1);') + tdSql.query("select abs(a) from (select abs(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -5152,7 +5386,7 @@ class TDTestCase: tdSql.checkData(5, 0, 127) tdSql.checkData(6, 0, 127) - tdSql.query('select abs(tb1.c3),abs(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query("select abs(tb1.c3),abs(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(0, 1, 1) @@ -5169,7 +5403,7 @@ class TDTestCase: tdSql.checkData(6, 0, 32767) tdSql.checkData(6, 1, 7) - tdSql.query('select abs(c3) from tb1 union all select abs(c3) from tb2;') + tdSql.query("select abs(c3) from tb1 union all select abs(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -5186,11 +5420,12 @@ class TDTestCase: tdSql.checkData(12, 0, 6) tdSql.checkData(13, 0, 7) - #=========== end math_abs ========== + # =========== end math_abs ========== - - #=========== begin math_abs2 ========== - tdSql.query('select abs(stb1.c4),abs(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;') + # =========== begin math_abs2 ========== + tdSql.query( + "select abs(stb1.c4),abs(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 1) tdSql.checkData(0, 1, 1) @@ -5207,7 +5442,9 @@ class TDTestCase: tdSql.checkData(6, 0, 2147483647) tdSql.checkData(6, 1, 7) - tdSql.query('select abs(c4) as a from stb1 union all select abs(c5) as a from stba;') + tdSql.query( + "select abs(c4) as a from stb1 union all select abs(c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, None) @@ -5254,7 +5491,7 @@ class TDTestCase: tdSql.checkData(42, 0, 9) tdSql.checkData(43, 0, 0) - tdSql.query('select abs(c2) from stba;') + tdSql.query("select abs(c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 1) tdSql.checkData(1, 0, 2) @@ -5287,47 +5524,47 @@ class TDTestCase: tdSql.checkData(28, 0, 9) tdSql.checkData(29, 0, 0) - tdSql.query('select abs(min(c2)) from tba1;') + tdSql.query("select abs(min(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0) - tdSql.query('select abs(max(c2)) from tba1;') + tdSql.query("select abs(max(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 9) - tdSql.query('select abs(count(c2)) from tba1;') + tdSql.query("select abs(count(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 30) - tdSql.query('select abs(sum(c2)) from tba1;') + tdSql.query("select abs(sum(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 135) - tdSql.query('select abs(avg(c2)) from tba1;') + tdSql.query("select abs(avg(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 4.5) - tdSql.query('select abs(percentile(c2, 10)) from tba1;') + tdSql.query("select abs(percentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.8999999999999999) - tdSql.query('select abs(apercentile(c2, 10)) from tba1;') + tdSql.query("select abs(apercentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select abs(stddev(c2)) from tba1;') + tdSql.query("select abs(stddev(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 2.8722813232690143) - tdSql.query('select abs(spread(c2)) from tba1;') + tdSql.query("select abs(spread(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 9.0) - tdSql.query('select abs(twa(c2)) from tba1;') + tdSql.query("select abs(twa(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 4.637931034482759) - tdSql.query('select abs(interp(c2)) from tba1 every(1s)') + tdSql.query("select abs(interp(c2)) from tba1 every(1s)") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 1) @@ -5390,2327 +5627,2374 @@ class TDTestCase: tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0) - tdSql.query('select abs(interp(c2)) from stba every(1s) group by tbname;') + tdSql.query("select abs(interp(c2)) from stba every(1s) group by tbname;") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 1) - tdSql.checkData(0, 2, 'tba1') + tdSql.checkData(0, 2, "tba1") tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) tdSql.checkData(1, 1, 2) - tdSql.checkData(1, 2, 'tba1') + tdSql.checkData(1, 2, "tba1") tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) tdSql.checkData(2, 1, 3) - tdSql.checkData(2, 2, 'tba1') + tdSql.checkData(2, 2, "tba1") tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) tdSql.checkData(3, 1, 4) - tdSql.checkData(3, 2, 'tba1') + tdSql.checkData(3, 2, "tba1") tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) tdSql.checkData(4, 1, 5) - tdSql.checkData(4, 2, 'tba1') + tdSql.checkData(4, 2, "tba1") tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) tdSql.checkData(5, 1, 6) - tdSql.checkData(5, 2, 'tba1') + tdSql.checkData(5, 2, "tba1") tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) tdSql.checkData(6, 1, 7) - tdSql.checkData(6, 2, 'tba1') + tdSql.checkData(6, 2, "tba1") tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) tdSql.checkData(7, 1, 8) - tdSql.checkData(7, 2, 'tba1') + tdSql.checkData(7, 2, "tba1") tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) tdSql.checkData(8, 1, 9) - tdSql.checkData(8, 2, 'tba1') + tdSql.checkData(8, 2, "tba1") tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 0) - tdSql.checkData(9, 2, 'tba1') + tdSql.checkData(9, 2, "tba1") tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 1) - tdSql.checkData(10, 2, 'tba1') + tdSql.checkData(10, 2, "tba1") tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) tdSql.checkData(11, 1, 2) - tdSql.checkData(11, 2, 'tba1') + tdSql.checkData(11, 2, "tba1") tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) tdSql.checkData(12, 1, 3) - tdSql.checkData(12, 2, 'tba1') + tdSql.checkData(12, 2, "tba1") tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) tdSql.checkData(13, 1, 4) - tdSql.checkData(13, 2, 'tba1') + tdSql.checkData(13, 2, "tba1") tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) tdSql.checkData(14, 1, 5) - tdSql.checkData(14, 2, 'tba1') + tdSql.checkData(14, 2, "tba1") tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) tdSql.checkData(15, 1, 6) - tdSql.checkData(15, 2, 'tba1') + tdSql.checkData(15, 2, "tba1") tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) tdSql.checkData(16, 1, 7) - tdSql.checkData(16, 2, 'tba1') + tdSql.checkData(16, 2, "tba1") tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) tdSql.checkData(17, 1, 8) - tdSql.checkData(17, 2, 'tba1') + tdSql.checkData(17, 2, "tba1") tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) tdSql.checkData(18, 1, 9) - tdSql.checkData(18, 2, 'tba1') + tdSql.checkData(18, 2, "tba1") tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 0) - tdSql.checkData(19, 2, 'tba1') + tdSql.checkData(19, 2, "tba1") tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 1) - tdSql.checkData(20, 2, 'tba1') + tdSql.checkData(20, 2, "tba1") tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) tdSql.checkData(21, 1, 2) - tdSql.checkData(21, 2, 'tba1') + tdSql.checkData(21, 2, "tba1") tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) tdSql.checkData(22, 1, 3) - tdSql.checkData(22, 2, 'tba1') + tdSql.checkData(22, 2, "tba1") tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) tdSql.checkData(23, 1, 4) - tdSql.checkData(23, 2, 'tba1') + tdSql.checkData(23, 2, "tba1") tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) tdSql.checkData(24, 1, 5) - tdSql.checkData(24, 2, 'tba1') + tdSql.checkData(24, 2, "tba1") tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) tdSql.checkData(25, 1, 6) - tdSql.checkData(25, 2, 'tba1') + tdSql.checkData(25, 2, "tba1") tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) tdSql.checkData(26, 1, 7) - tdSql.checkData(26, 2, 'tba1') + tdSql.checkData(26, 2, "tba1") tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) tdSql.checkData(27, 1, 8) - tdSql.checkData(27, 2, 'tba1') + tdSql.checkData(27, 2, "tba1") tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) tdSql.checkData(28, 1, 9) - tdSql.checkData(28, 2, 'tba1') + tdSql.checkData(28, 2, "tba1") tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0) - tdSql.checkData(29, 2, 'tba1') + tdSql.checkData(29, 2, "tba1") - tdSql.query('select abs(elapsed(ts)) from tba1;') + tdSql.query("select abs(elapsed(ts)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 29000.0) - tdSql.query('select abs(rate(c2)) from tba1;') + tdSql.query("select abs(rate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.896551724137931) - tdSql.query('select abs(irate(c2)) from tba1;') + tdSql.query("select abs(irate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select abs(first(c2)) from tba1;') + tdSql.query("select abs(first(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1) - tdSql.query('select abs(last(c2)) from tba1;') + tdSql.query("select abs(last(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0) - tdSql.query('select abs(last_row(c2)) from tba1;') + tdSql.query("select abs(last_row(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0) - #=========== end math_abs2 ========== - + # =========== end math_abs2 ========== - #=========== begin math_asin ========== - tdSql.query('select asin(13) from tb1;') + # =========== begin math_asin ========== + tdSql.query("select asin(13) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2) from tb1;') + tdSql.query("select asin(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c3) from tb1;') + tdSql.query("select asin(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c4) from tb1;') + tdSql.query("select asin(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c5) from tb1;') + tdSql.query("select asin(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c6) from tb1;') + tdSql.query("select asin(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c7) from tb1;') + tdSql.query("select asin(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c10) from tb1;') + tdSql.query("select asin(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 0.0) - tdSql.query('select asin(c11) from tb1;') + tdSql.query("select asin(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 0.0) - tdSql.query('select asin(c12) from tb1;') + tdSql.query("select asin(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 0.0) - tdSql.query('select asin(c13) from tb1;') + tdSql.query("select asin(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 0.0) - tdSql.query('select asin(a) from (select asin(c2) as a from tb1);') + tdSql.query("select asin(a) from (select asin(c2) as a from tb1);") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2 + c3) from tb1;') + tdSql.query("select asin(c2 + c3) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin((c2 + c3)) from tb1;') + tdSql.query("select asin((c2 + c3)) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin((c2 * c3)+c4-6) from tb1;') + tdSql.query("select asin((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(11)+c2 from tb1;') + tdSql.query("select asin(11)+c2 from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2)+11 from tb1;') + tdSql.query("select asin(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.570796326794897) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select asin(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) - tdSql.query('select asin(c2) from tb1 order by ts desc;') + tdSql.query("select asin(c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) + tdSql.checkData(4, 0, nan) tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select asin(c2+c3) from tb1 order by ts desc;') + tdSql.query("select asin(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, None) tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select asin(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select asin(c2) from stb1;') + tdSql.query("select asin(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query('select asin(c2) from stb1 order by ts desc;') + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query("select asin(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select asin(c4),t1 from stb1 order by ts desc;') + tdSql.query("select asin(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select asin(c3),tbname from stb1;') + tdSql.query("select asin(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(0, 1, 'tb1') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb1') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") + tdSql.checkData(1, 0, None) + tdSql.checkData(1, 1, "tb1") + tdSql.checkData(2, 0, None) + tdSql.checkData(2, 1, "tb1") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb1") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb1") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(7, 1, 'tb2') - tdSql.checkData(8, 0, None) - tdSql.checkData(8, 1, 'tb2') - tdSql.checkData(9, 0, None) - tdSql.checkData(9, 1, 'tb2') - tdSql.checkData(10, 0, None) - tdSql.checkData(10, 1, 'tb2') - tdSql.checkData(11, 0, None) - tdSql.checkData(11, 1, 'tb2') - tdSql.checkData(12, 0, None) - tdSql.checkData(12, 1, 'tb2') - tdSql.checkData(13, 0, None) - tdSql.checkData(13, 1, 'tb2') - - tdSql.query('select asin(c3),tbname from stb1 where t1 > 1;') + tdSql.checkData(7, 1, "tb2") + tdSql.checkData(8, 0, nan) + tdSql.checkData(8, 1, "tb2") + tdSql.checkData(9, 0, nan) + tdSql.checkData(9, 1, "tb2") + tdSql.checkData(10, 0, nan) + tdSql.checkData(10, 1, "tb2") + tdSql.checkData(11, 0, nan) + tdSql.checkData(11, 1, "tb2") + tdSql.checkData(12, 0, nan) + tdSql.checkData(12, 1, "tb2") + tdSql.checkData(13, 0, nan) + tdSql.checkData(13, 1, "tb2") + + tdSql.query("select asin(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(0, 1, 'tb2') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb2') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb2') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb2') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb2') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb2') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb2') - - tdSql.query('select asin(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.checkData(0, 1, "tb2") + tdSql.checkData(1, 0, nan) + tdSql.checkData(1, 1, "tb2") + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, "tb2") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb2") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb2") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb2") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb2") + + tdSql.query("select asin(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - - tdSql.query('select asin(c2) from (select * from stb1);') + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + + tdSql.query("select asin(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 1.5707963267948966) - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.5707963267948966) - tdSql.checkData(9, 0, None) + tdSql.checkData(9, 0, nan) - tdSql.query("select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select asin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 1.5707963267948966) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select asin(a) from (select asin(c2) as a from tb1);') + tdSql.query("select asin(a) from (select asin(c2) as a from tb1);") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select asin(tb1.c3),asin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query( + "select asin(tb1.c3),asin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(0, 1, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) - tdSql.query('select asin(c3) from tb1 union all select asin(c3) from tb2;') + tdSql.query("select asin(c3) from tb1 union all select asin(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - #=========== end math_asin ========== + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + # =========== end math_asin ========== - #=========== begin math_asin2 ========== - tdSql.query('select asin(stb1.c4),asin(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;') + # =========== begin math_asin2 ========== + tdSql.query( + "select asin(stb1.c4),asin(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(0, 1, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) - - tdSql.query('select asin(c4) as a from stb1 union all select asin(c5) as a from stba;') + tdSql.checkData(1, 1, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, None) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) + + tdSql.query( + "select asin(c4) as a from stb1 union all select asin(c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 1.5707963267948966) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) tdSql.checkData(14, 0, 1.5707963267948966) - tdSql.checkData(15, 0, None) - tdSql.checkData(16, 0, None) - tdSql.checkData(17, 0, None) - tdSql.checkData(18, 0, None) - tdSql.checkData(19, 0, None) - tdSql.checkData(20, 0, None) - tdSql.checkData(21, 0, None) - tdSql.checkData(22, 0, None) + tdSql.checkData(15, 0, nan) + tdSql.checkData(16, 0, nan) + tdSql.checkData(17, 0, nan) + tdSql.checkData(18, 0, nan) + tdSql.checkData(19, 0, nan) + tdSql.checkData(20, 0, nan) + tdSql.checkData(21, 0, nan) + tdSql.checkData(22, 0, nan) tdSql.checkData(23, 0, 0.0) tdSql.checkData(24, 0, 1.5707963267948966) - tdSql.checkData(25, 0, None) - tdSql.checkData(26, 0, None) - tdSql.checkData(27, 0, None) - tdSql.checkData(28, 0, None) - tdSql.checkData(29, 0, None) - tdSql.checkData(30, 0, None) - tdSql.checkData(31, 0, None) - tdSql.checkData(32, 0, None) + tdSql.checkData(25, 0, nan) + tdSql.checkData(26, 0, nan) + tdSql.checkData(27, 0, nan) + tdSql.checkData(28, 0, nan) + tdSql.checkData(29, 0, nan) + tdSql.checkData(30, 0, nan) + tdSql.checkData(31, 0, nan) + tdSql.checkData(32, 0, nan) tdSql.checkData(33, 0, 0.0) tdSql.checkData(34, 0, 1.5707963267948966) - tdSql.checkData(35, 0, None) - tdSql.checkData(36, 0, None) - tdSql.checkData(37, 0, None) - tdSql.checkData(38, 0, None) - tdSql.checkData(39, 0, None) - tdSql.checkData(40, 0, None) - tdSql.checkData(41, 0, None) - tdSql.checkData(42, 0, None) + tdSql.checkData(35, 0, nan) + tdSql.checkData(36, 0, nan) + tdSql.checkData(37, 0, nan) + tdSql.checkData(38, 0, nan) + tdSql.checkData(39, 0, nan) + tdSql.checkData(40, 0, nan) + tdSql.checkData(41, 0, nan) + tdSql.checkData(42, 0, nan) tdSql.checkData(43, 0, 0.0) - tdSql.query('select asin(c2) from stba;') + tdSql.query("select asin(c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 0.0) tdSql.checkData(10, 0, 1.5707963267948966) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - tdSql.checkData(14, 0, None) - tdSql.checkData(15, 0, None) - tdSql.checkData(16, 0, None) - tdSql.checkData(17, 0, None) - tdSql.checkData(18, 0, None) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + tdSql.checkData(14, 0, nan) + tdSql.checkData(15, 0, nan) + tdSql.checkData(16, 0, nan) + tdSql.checkData(17, 0, nan) + tdSql.checkData(18, 0, nan) tdSql.checkData(19, 0, 0.0) tdSql.checkData(20, 0, 1.5707963267948966) - tdSql.checkData(21, 0, None) - tdSql.checkData(22, 0, None) - tdSql.checkData(23, 0, None) - tdSql.checkData(24, 0, None) - tdSql.checkData(25, 0, None) - tdSql.checkData(26, 0, None) - tdSql.checkData(27, 0, None) - tdSql.checkData(28, 0, None) + tdSql.checkData(21, 0, nan) + tdSql.checkData(22, 0, nan) + tdSql.checkData(23, 0, nan) + tdSql.checkData(24, 0, nan) + tdSql.checkData(25, 0, nan) + tdSql.checkData(26, 0, nan) + tdSql.checkData(27, 0, nan) + tdSql.checkData(28, 0, nan) tdSql.checkData(29, 0, 0.0) - tdSql.query('select asin(min(c2)) from tba1;') + tdSql.query("select asin(min(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select asin(max(c2)) from tba1;') + tdSql.query("select asin(max(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select asin(count(c2)) from tba1;') + tdSql.query("select asin(count(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select asin(sum(c2)) from tba1;') + tdSql.query("select asin(sum(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select asin(avg(c2)) from tba1;') + tdSql.query("select asin(avg(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select asin(percentile(c2, 10)) from tba1;') + tdSql.query("select asin(percentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.119769514998634) - tdSql.query('select asin(apercentile(c2, 10)) from tba1;') + tdSql.query("select asin(apercentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select asin(stddev(c2)) from tba1;') + tdSql.query("select asin(stddev(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select asin(spread(c2)) from tba1;') + tdSql.query("select asin(spread(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select asin(twa(c2)) from tba1;') + tdSql.query("select asin(twa(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select asin(interp(c2)) from tba1 every(1s)') + tdSql.query("select asin(interp(c2)) from tba1 every(1s)") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 1.5707963267948966) tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) - tdSql.checkData(2, 1, None) + tdSql.checkData(2, 1, nan) tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) - tdSql.checkData(3, 1, None) + tdSql.checkData(3, 1, nan) tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) - tdSql.checkData(4, 1, None) + tdSql.checkData(4, 1, nan) tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) - tdSql.checkData(5, 1, None) + tdSql.checkData(5, 1, nan) tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) - tdSql.checkData(6, 1, None) + tdSql.checkData(6, 1, nan) tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) - tdSql.checkData(7, 1, None) + tdSql.checkData(7, 1, nan) tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) - tdSql.checkData(8, 1, None) + tdSql.checkData(8, 1, nan) tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 0.0) tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 1.5707963267948966) tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) - tdSql.checkData(11, 1, None) + tdSql.checkData(11, 1, nan) tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) - tdSql.checkData(12, 1, None) + tdSql.checkData(12, 1, nan) tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) - tdSql.checkData(13, 1, None) + tdSql.checkData(13, 1, nan) tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) - tdSql.checkData(14, 1, None) + tdSql.checkData(14, 1, nan) tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) - tdSql.checkData(15, 1, None) + tdSql.checkData(15, 1, nan) tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) - tdSql.checkData(16, 1, None) + tdSql.checkData(16, 1, nan) tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) - tdSql.checkData(17, 1, None) + tdSql.checkData(17, 1, nan) tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) - tdSql.checkData(18, 1, None) + tdSql.checkData(18, 1, nan) tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 0.0) tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 1.5707963267948966) tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) - tdSql.checkData(21, 1, None) + tdSql.checkData(21, 1, nan) tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) - tdSql.checkData(22, 1, None) + tdSql.checkData(22, 1, nan) tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) - tdSql.checkData(23, 1, None) + tdSql.checkData(23, 1, nan) tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) - tdSql.checkData(24, 1, None) + tdSql.checkData(24, 1, nan) tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) - tdSql.checkData(25, 1, None) + tdSql.checkData(25, 1, nan) tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) - tdSql.checkData(26, 1, None) + tdSql.checkData(26, 1, nan) tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) - tdSql.checkData(27, 1, None) + tdSql.checkData(27, 1, nan) tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) - tdSql.checkData(28, 1, None) + tdSql.checkData(28, 1, nan) tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0.0) - tdSql.query('select asin(interp(c2)) from stba every(1s) group by tbname;') + tdSql.query("select asin(interp(c2)) from stba every(1s) group by tbname;") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 1.5707963267948966) - tdSql.checkData(0, 2, 'tba1') + tdSql.checkData(0, 2, "tba1") tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) - tdSql.checkData(1, 1, None) - tdSql.checkData(1, 2, 'tba1') + tdSql.checkData(1, 1, nan) + tdSql.checkData(1, 2, "tba1") tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) - tdSql.checkData(2, 1, None) - tdSql.checkData(2, 2, 'tba1') + tdSql.checkData(2, 1, nan) + tdSql.checkData(2, 2, "tba1") tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) - tdSql.checkData(3, 1, None) - tdSql.checkData(3, 2, 'tba1') + tdSql.checkData(3, 1, nan) + tdSql.checkData(3, 2, "tba1") tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) - tdSql.checkData(4, 1, None) - tdSql.checkData(4, 2, 'tba1') + tdSql.checkData(4, 1, nan) + tdSql.checkData(4, 2, "tba1") tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) - tdSql.checkData(5, 1, None) - tdSql.checkData(5, 2, 'tba1') + tdSql.checkData(5, 1, nan) + tdSql.checkData(5, 2, "tba1") tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) - tdSql.checkData(6, 1, None) - tdSql.checkData(6, 2, 'tba1') + tdSql.checkData(6, 1, nan) + tdSql.checkData(6, 2, "tba1") tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) - tdSql.checkData(7, 1, None) - tdSql.checkData(7, 2, 'tba1') + tdSql.checkData(7, 1, nan) + tdSql.checkData(7, 2, "tba1") tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) - tdSql.checkData(8, 1, None) - tdSql.checkData(8, 2, 'tba1') + tdSql.checkData(8, 1, nan) + tdSql.checkData(8, 2, "tba1") tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 0.0) - tdSql.checkData(9, 2, 'tba1') + tdSql.checkData(9, 2, "tba1") tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 1.5707963267948966) - tdSql.checkData(10, 2, 'tba1') + tdSql.checkData(10, 2, "tba1") tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) - tdSql.checkData(11, 1, None) - tdSql.checkData(11, 2, 'tba1') + tdSql.checkData(11, 1, nan) + tdSql.checkData(11, 2, "tba1") tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) - tdSql.checkData(12, 1, None) - tdSql.checkData(12, 2, 'tba1') + tdSql.checkData(12, 1, nan) + tdSql.checkData(12, 2, "tba1") tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) - tdSql.checkData(13, 1, None) - tdSql.checkData(13, 2, 'tba1') + tdSql.checkData(13, 1, nan) + tdSql.checkData(13, 2, "tba1") tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) - tdSql.checkData(14, 1, None) - tdSql.checkData(14, 2, 'tba1') + tdSql.checkData(14, 1, nan) + tdSql.checkData(14, 2, "tba1") tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) - tdSql.checkData(15, 1, None) - tdSql.checkData(15, 2, 'tba1') + tdSql.checkData(15, 1, nan) + tdSql.checkData(15, 2, "tba1") tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) - tdSql.checkData(16, 1, None) - tdSql.checkData(16, 2, 'tba1') + tdSql.checkData(16, 1, nan) + tdSql.checkData(16, 2, "tba1") tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) - tdSql.checkData(17, 1, None) - tdSql.checkData(17, 2, 'tba1') + tdSql.checkData(17, 1, nan) + tdSql.checkData(17, 2, "tba1") tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) - tdSql.checkData(18, 1, None) - tdSql.checkData(18, 2, 'tba1') + tdSql.checkData(18, 1, nan) + tdSql.checkData(18, 2, "tba1") tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 0.0) - tdSql.checkData(19, 2, 'tba1') + tdSql.checkData(19, 2, "tba1") tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 1.5707963267948966) - tdSql.checkData(20, 2, 'tba1') + tdSql.checkData(20, 2, "tba1") tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) - tdSql.checkData(21, 1, None) - tdSql.checkData(21, 2, 'tba1') + tdSql.checkData(21, 1, nan) + tdSql.checkData(21, 2, "tba1") tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) - tdSql.checkData(22, 1, None) - tdSql.checkData(22, 2, 'tba1') + tdSql.checkData(22, 1, nan) + tdSql.checkData(22, 2, "tba1") tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) - tdSql.checkData(23, 1, None) - tdSql.checkData(23, 2, 'tba1') + tdSql.checkData(23, 1, nan) + tdSql.checkData(23, 2, "tba1") tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) - tdSql.checkData(24, 1, None) - tdSql.checkData(24, 2, 'tba1') + tdSql.checkData(24, 1, nan) + tdSql.checkData(24, 2, "tba1") tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) - tdSql.checkData(25, 1, None) - tdSql.checkData(25, 2, 'tba1') + tdSql.checkData(25, 1, nan) + tdSql.checkData(25, 2, "tba1") tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) - tdSql.checkData(26, 1, None) - tdSql.checkData(26, 2, 'tba1') + tdSql.checkData(26, 1, nan) + tdSql.checkData(26, 2, "tba1") tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) - tdSql.checkData(27, 1, None) - tdSql.checkData(27, 2, 'tba1') + tdSql.checkData(27, 1, nan) + tdSql.checkData(27, 2, "tba1") tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) - tdSql.checkData(28, 1, None) - tdSql.checkData(28, 2, 'tba1') + tdSql.checkData(28, 1, nan) + tdSql.checkData(28, 2, "tba1") tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0.0) - tdSql.checkData(29, 2, 'tba1') + tdSql.checkData(29, 2, "tba1") - tdSql.query('select asin(elapsed(ts)) from tba1;') + tdSql.query("select asin(elapsed(ts)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select asin(rate(c2)) from tba1;') + tdSql.query("select asin(rate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.1119221217807869) - tdSql.query('select asin(irate(c2)) from tba1;') + tdSql.query("select asin(irate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select asin(first(c2)) from tba1;') + tdSql.query("select asin(first(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select asin(last(c2)) from tba1;') + tdSql.query("select asin(last(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select asin(last_row(c2)) from tba1;') + tdSql.query("select asin(last_row(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - #=========== end math_asin2 ========== - + # =========== end math_asin2 ========== - #=========== begin math_acos ========== - tdSql.query('select acos(13) from tb1;') + # =========== begin math_acos ========== + tdSql.query("select acos(13) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2) from tb1;') + tdSql.query("select acos(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c3) from tb1;') + tdSql.query("select acos(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c4) from tb1;') + tdSql.query("select acos(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c5) from tb1;') + tdSql.query("select acos(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c6) from tb1;') + tdSql.query("select acos(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c7) from tb1;') + tdSql.query("select acos(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c10) from tb1;') + tdSql.query("select acos(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c11) from tb1;') + tdSql.query("select acos(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c12) from tb1;') + tdSql.query("select acos(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c13) from tb1;') + tdSql.query("select acos(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(a) from (select acos(c2) as a from tb1);') + tdSql.query("select acos(a) from (select acos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2 + c3) from tb1;') + tdSql.query("select acos(c2 + c3) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos((c2 + c3)) from tb1;') + tdSql.query("select acos((c2 + c3)) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos((c2 * c3)+c4-6) from tb1;') + tdSql.query("select acos((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(11)+c2 from tb1;') + tdSql.query("select acos(11)+c2 from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2)+11 from tb1;') + tdSql.query("select acos(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 11.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select acos(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) - tdSql.query('select acos(c2) from tb1 order by ts desc;') + tdSql.query("select acos(c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) + tdSql.checkData(4, 0, nan) tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.0) - tdSql.query('select acos(c2+c3) from tb1 order by ts desc;') + tdSql.query("select acos(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, None) tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select acos(c2) from stb1;') + tdSql.query("select acos(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query('select acos(c2) from stb1 order by ts desc;') + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query("select acos(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select acos(c4),t1 from stb1 order by ts desc;') + tdSql.query("select acos(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select acos(c3),tbname from stb1;') + tdSql.query("select acos(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(0, 1, 'tb1') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb1') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") + tdSql.checkData(1, 0, None) + tdSql.checkData(1, 1, "tb1") + tdSql.checkData(2, 0, None) + tdSql.checkData(2, 1, "tb1") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb1") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb1") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 0.0) - tdSql.checkData(7, 1, 'tb2') - tdSql.checkData(8, 0, None) - tdSql.checkData(8, 1, 'tb2') - tdSql.checkData(9, 0, None) - tdSql.checkData(9, 1, 'tb2') - tdSql.checkData(10, 0, None) - tdSql.checkData(10, 1, 'tb2') - tdSql.checkData(11, 0, None) - tdSql.checkData(11, 1, 'tb2') - tdSql.checkData(12, 0, None) - tdSql.checkData(12, 1, 'tb2') - tdSql.checkData(13, 0, None) - tdSql.checkData(13, 1, 'tb2') - - tdSql.query('select acos(c3),tbname from stb1 where t1 > 1;') + tdSql.checkData(7, 1, "tb2") + tdSql.checkData(8, 0, nan) + tdSql.checkData(8, 1, "tb2") + tdSql.checkData(9, 0, nan) + tdSql.checkData(9, 1, "tb2") + tdSql.checkData(10, 0, nan) + tdSql.checkData(10, 1, "tb2") + tdSql.checkData(11, 0, nan) + tdSql.checkData(11, 1, "tb2") + tdSql.checkData(12, 0, nan) + tdSql.checkData(12, 1, "tb2") + tdSql.checkData(13, 0, nan) + tdSql.checkData(13, 1, "tb2") + + tdSql.query("select acos(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(0, 1, 'tb2') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb2') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb2') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb2') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb2') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb2') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb2') - - tdSql.query('select acos(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.checkData(0, 1, "tb2") + tdSql.checkData(1, 0, nan) + tdSql.checkData(1, 1, "tb2") + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, "tb2") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb2") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb2") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb2") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb2") + + tdSql.query("select acos(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - - tdSql.query('select acos(c2) from (select * from stb1);') + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + + tdSql.query("select acos(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") - tdSql.checkRows(10) - tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) + tdSql.checkRows(10) + tdSql.checkData(0, 0, 0.0) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 0.0) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 0.0) - tdSql.checkData(9, 0, None) + tdSql.checkData(9, 0, nan) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 0.0) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select acos(a) from (select acos(c2) as a from tb1);') + tdSql.query("select acos(a) from (select acos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query( + "select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(0, 1, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) - tdSql.query('select acos(c3) from tb1 union all select acos(c3) from tb2;') + tdSql.query("select acos(c3) from tb1 union all select acos(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - #=========== end math_acos ========== + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + # =========== end math_acos ========== - #=========== begin math_acos2 ========== - tdSql.query('select acos(stb1.c4),acos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;') + # =========== begin math_acos2 ========== + tdSql.query( + "select acos(stb1.c4),acos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(0, 1, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) - - tdSql.query('select acos(c4) as a from stb1 union all select acos(c5) as a from stba;') + tdSql.checkData(1, 1, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, None) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) + + tdSql.query( + "select acos(c4) as a from stb1 union all select acos(c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) tdSql.checkData(14, 0, 0.0) - tdSql.checkData(15, 0, None) - tdSql.checkData(16, 0, None) - tdSql.checkData(17, 0, None) - tdSql.checkData(18, 0, None) - tdSql.checkData(19, 0, None) - tdSql.checkData(20, 0, None) - tdSql.checkData(21, 0, None) - tdSql.checkData(22, 0, None) + tdSql.checkData(15, 0, nan) + tdSql.checkData(16, 0, nan) + tdSql.checkData(17, 0, nan) + tdSql.checkData(18, 0, nan) + tdSql.checkData(19, 0, nan) + tdSql.checkData(20, 0, nan) + tdSql.checkData(21, 0, nan) + tdSql.checkData(22, 0, nan) tdSql.checkData(23, 0, 1.5707963267948966) tdSql.checkData(24, 0, 0.0) - tdSql.checkData(25, 0, None) - tdSql.checkData(26, 0, None) - tdSql.checkData(27, 0, None) - tdSql.checkData(28, 0, None) - tdSql.checkData(29, 0, None) - tdSql.checkData(30, 0, None) - tdSql.checkData(31, 0, None) - tdSql.checkData(32, 0, None) + tdSql.checkData(25, 0, nan) + tdSql.checkData(26, 0, nan) + tdSql.checkData(27, 0, nan) + tdSql.checkData(28, 0, nan) + tdSql.checkData(29, 0, nan) + tdSql.checkData(30, 0, nan) + tdSql.checkData(31, 0, nan) + tdSql.checkData(32, 0, nan) tdSql.checkData(33, 0, 1.5707963267948966) tdSql.checkData(34, 0, 0.0) - tdSql.checkData(35, 0, None) - tdSql.checkData(36, 0, None) - tdSql.checkData(37, 0, None) - tdSql.checkData(38, 0, None) - tdSql.checkData(39, 0, None) - tdSql.checkData(40, 0, None) - tdSql.checkData(41, 0, None) - tdSql.checkData(42, 0, None) + tdSql.checkData(35, 0, nan) + tdSql.checkData(36, 0, nan) + tdSql.checkData(37, 0, nan) + tdSql.checkData(38, 0, nan) + tdSql.checkData(39, 0, nan) + tdSql.checkData(40, 0, nan) + tdSql.checkData(41, 0, nan) + tdSql.checkData(42, 0, nan) tdSql.checkData(43, 0, 1.5707963267948966) - tdSql.query('select acos(c2) from stba;') + tdSql.query("select acos(c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 1.5707963267948966) tdSql.checkData(10, 0, 0.0) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - tdSql.checkData(14, 0, None) - tdSql.checkData(15, 0, None) - tdSql.checkData(16, 0, None) - tdSql.checkData(17, 0, None) - tdSql.checkData(18, 0, None) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + tdSql.checkData(14, 0, nan) + tdSql.checkData(15, 0, nan) + tdSql.checkData(16, 0, nan) + tdSql.checkData(17, 0, nan) + tdSql.checkData(18, 0, nan) tdSql.checkData(19, 0, 1.5707963267948966) tdSql.checkData(20, 0, 0.0) - tdSql.checkData(21, 0, None) - tdSql.checkData(22, 0, None) - tdSql.checkData(23, 0, None) - tdSql.checkData(24, 0, None) - tdSql.checkData(25, 0, None) - tdSql.checkData(26, 0, None) - tdSql.checkData(27, 0, None) - tdSql.checkData(28, 0, None) + tdSql.checkData(21, 0, nan) + tdSql.checkData(22, 0, nan) + tdSql.checkData(23, 0, nan) + tdSql.checkData(24, 0, nan) + tdSql.checkData(25, 0, nan) + tdSql.checkData(26, 0, nan) + tdSql.checkData(27, 0, nan) + tdSql.checkData(28, 0, nan) tdSql.checkData(29, 0, 1.5707963267948966) - tdSql.query('select acos(min(c2)) from tba1;') + tdSql.query("select acos(min(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select acos(max(c2)) from tba1;') + tdSql.query("select acos(max(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(count(c2)) from tba1;') + tdSql.query("select acos(count(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(sum(c2)) from tba1;') + tdSql.query("select acos(sum(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(avg(c2)) from tba1;') + tdSql.query("select acos(avg(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(percentile(c2, 10)) from tba1;') + tdSql.query("select acos(percentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.45102681179626264) - tdSql.query('select acos(apercentile(c2, 10)) from tba1;') + tdSql.query("select acos(apercentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select acos(stddev(c2)) from tba1;') + tdSql.query("select acos(stddev(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(spread(c2)) from tba1;') + tdSql.query("select acos(spread(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(twa(c2)) from tba1;') + tdSql.query("select acos(twa(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(interp(c2)) from tba1 every(1s)') + tdSql.query("select acos(interp(c2)) from tba1 every(1s)") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 0.0) tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) - tdSql.checkData(2, 1, None) + tdSql.checkData(2, 1, nan) tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) - tdSql.checkData(3, 1, None) + tdSql.checkData(3, 1, nan) tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) - tdSql.checkData(4, 1, None) + tdSql.checkData(4, 1, nan) tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) - tdSql.checkData(5, 1, None) + tdSql.checkData(5, 1, nan) tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) - tdSql.checkData(6, 1, None) + tdSql.checkData(6, 1, nan) tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) - tdSql.checkData(7, 1, None) + tdSql.checkData(7, 1, nan) tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) - tdSql.checkData(8, 1, None) + tdSql.checkData(8, 1, nan) tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 1.5707963267948966) tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 0.0) tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) - tdSql.checkData(11, 1, None) + tdSql.checkData(11, 1, nan) tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) - tdSql.checkData(12, 1, None) + tdSql.checkData(12, 1, nan) tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) - tdSql.checkData(13, 1, None) + tdSql.checkData(13, 1, nan) tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) - tdSql.checkData(14, 1, None) + tdSql.checkData(14, 1, nan) tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) - tdSql.checkData(15, 1, None) + tdSql.checkData(15, 1, nan) tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) - tdSql.checkData(16, 1, None) + tdSql.checkData(16, 1, nan) tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) - tdSql.checkData(17, 1, None) + tdSql.checkData(17, 1, nan) tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) - tdSql.checkData(18, 1, None) + tdSql.checkData(18, 1, nan) tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 1.5707963267948966) tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 0.0) tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) - tdSql.checkData(21, 1, None) + tdSql.checkData(21, 1, nan) tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) - tdSql.checkData(22, 1, None) + tdSql.checkData(22, 1, nan) tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) - tdSql.checkData(23, 1, None) + tdSql.checkData(23, 1, nan) tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) - tdSql.checkData(24, 1, None) + tdSql.checkData(24, 1, nan) tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) - tdSql.checkData(25, 1, None) + tdSql.checkData(25, 1, nan) tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) - tdSql.checkData(26, 1, None) + tdSql.checkData(26, 1, nan) tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) - tdSql.checkData(27, 1, None) + tdSql.checkData(27, 1, nan) tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) - tdSql.checkData(28, 1, None) + tdSql.checkData(28, 1, nan) tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 1.5707963267948966) - tdSql.query('select acos(interp(c2)) from stba every(1s) group by tbname;') + tdSql.query("select acos(interp(c2)) from stba every(1s) group by tbname;") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 0.0) - tdSql.checkData(0, 2, 'tba1') + tdSql.checkData(0, 2, "tba1") tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) - tdSql.checkData(1, 1, None) - tdSql.checkData(1, 2, 'tba1') + tdSql.checkData(1, 1, nan) + tdSql.checkData(1, 2, "tba1") tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) - tdSql.checkData(2, 1, None) - tdSql.checkData(2, 2, 'tba1') + tdSql.checkData(2, 1, nan) + tdSql.checkData(2, 2, "tba1") tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) - tdSql.checkData(3, 1, None) - tdSql.checkData(3, 2, 'tba1') + tdSql.checkData(3, 1, nan) + tdSql.checkData(3, 2, "tba1") tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) - tdSql.checkData(4, 1, None) - tdSql.checkData(4, 2, 'tba1') + tdSql.checkData(4, 1, nan) + tdSql.checkData(4, 2, "tba1") tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) - tdSql.checkData(5, 1, None) - tdSql.checkData(5, 2, 'tba1') + tdSql.checkData(5, 1, nan) + tdSql.checkData(5, 2, "tba1") tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) - tdSql.checkData(6, 1, None) - tdSql.checkData(6, 2, 'tba1') + tdSql.checkData(6, 1, nan) + tdSql.checkData(6, 2, "tba1") tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) - tdSql.checkData(7, 1, None) - tdSql.checkData(7, 2, 'tba1') + tdSql.checkData(7, 1, nan) + tdSql.checkData(7, 2, "tba1") tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) - tdSql.checkData(8, 1, None) - tdSql.checkData(8, 2, 'tba1') + tdSql.checkData(8, 1, nan) + tdSql.checkData(8, 2, "tba1") tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 1.5707963267948966) - tdSql.checkData(9, 2, 'tba1') + tdSql.checkData(9, 2, "tba1") tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 0.0) - tdSql.checkData(10, 2, 'tba1') + tdSql.checkData(10, 2, "tba1") tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) - tdSql.checkData(11, 1, None) - tdSql.checkData(11, 2, 'tba1') + tdSql.checkData(11, 1, nan) + tdSql.checkData(11, 2, "tba1") tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) - tdSql.checkData(12, 1, None) - tdSql.checkData(12, 2, 'tba1') + tdSql.checkData(12, 1, nan) + tdSql.checkData(12, 2, "tba1") tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) - tdSql.checkData(13, 1, None) - tdSql.checkData(13, 2, 'tba1') + tdSql.checkData(13, 1, nan) + tdSql.checkData(13, 2, "tba1") tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) - tdSql.checkData(14, 1, None) - tdSql.checkData(14, 2, 'tba1') + tdSql.checkData(14, 1, nan) + tdSql.checkData(14, 2, "tba1") tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) - tdSql.checkData(15, 1, None) - tdSql.checkData(15, 2, 'tba1') + tdSql.checkData(15, 1, nan) + tdSql.checkData(15, 2, "tba1") tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) - tdSql.checkData(16, 1, None) - tdSql.checkData(16, 2, 'tba1') + tdSql.checkData(16, 1, nan) + tdSql.checkData(16, 2, "tba1") tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) - tdSql.checkData(17, 1, None) - tdSql.checkData(17, 2, 'tba1') + tdSql.checkData(17, 1, nan) + tdSql.checkData(17, 2, "tba1") tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) - tdSql.checkData(18, 1, None) - tdSql.checkData(18, 2, 'tba1') + tdSql.checkData(18, 1, nan) + tdSql.checkData(18, 2, "tba1") tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 1.5707963267948966) - tdSql.checkData(19, 2, 'tba1') + tdSql.checkData(19, 2, "tba1") tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 0.0) - tdSql.checkData(20, 2, 'tba1') + tdSql.checkData(20, 2, "tba1") tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) - tdSql.checkData(21, 1, None) - tdSql.checkData(21, 2, 'tba1') + tdSql.checkData(21, 1, nan) + tdSql.checkData(21, 2, "tba1") tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) - tdSql.checkData(22, 1, None) - tdSql.checkData(22, 2, 'tba1') + tdSql.checkData(22, 1, nan) + tdSql.checkData(22, 2, "tba1") tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) - tdSql.checkData(23, 1, None) - tdSql.checkData(23, 2, 'tba1') + tdSql.checkData(23, 1, nan) + tdSql.checkData(23, 2, "tba1") tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) - tdSql.checkData(24, 1, None) - tdSql.checkData(24, 2, 'tba1') + tdSql.checkData(24, 1, nan) + tdSql.checkData(24, 2, "tba1") tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) - tdSql.checkData(25, 1, None) - tdSql.checkData(25, 2, 'tba1') + tdSql.checkData(25, 1, nan) + tdSql.checkData(25, 2, "tba1") tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) - tdSql.checkData(26, 1, None) - tdSql.checkData(26, 2, 'tba1') + tdSql.checkData(26, 1, nan) + tdSql.checkData(26, 2, "tba1") tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) - tdSql.checkData(27, 1, None) - tdSql.checkData(27, 2, 'tba1') + tdSql.checkData(27, 1, nan) + tdSql.checkData(27, 2, "tba1") tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) - tdSql.checkData(28, 1, None) - tdSql.checkData(28, 2, 'tba1') + tdSql.checkData(28, 1, nan) + tdSql.checkData(28, 2, "tba1") tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 1.5707963267948966) - tdSql.checkData(29, 2, 'tba1') + tdSql.checkData(29, 2, "tba1") - tdSql.query('select acos(elapsed(ts)) from tba1;') + tdSql.query("select acos(elapsed(ts)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(rate(c2)) from tba1;') + tdSql.query("select acos(rate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.4588742050141097) - tdSql.query('select acos(irate(c2)) from tba1;') + tdSql.query("select acos(irate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select acos(first(c2)) from tba1;') + tdSql.query("select acos(first(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select acos(last(c2)) from tba1;') + tdSql.query("select acos(last(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select acos(last_row(c2)) from tba1;') + tdSql.query("select acos(last_row(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - #=========== end math_acos2 ========== - + # =========== end math_acos2 ========== - #=========== begin math_atan ========== - tdSql.query('select acos(13) from tb1;') + # =========== begin math_atan ========== + tdSql.query("select acos(13) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2) from tb1;') + tdSql.query("select acos(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c3) from tb1;') + tdSql.query("select acos(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c4) from tb1;') + tdSql.query("select acos(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c5) from tb1;') + tdSql.query("select acos(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c6) from tb1;') + tdSql.query("select acos(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c7) from tb1;') + tdSql.query("select acos(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c10) from tb1;') + tdSql.query("select acos(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c11) from tb1;') + tdSql.query("select acos(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c12) from tb1;') + tdSql.query("select acos(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(c13) from tb1;') + tdSql.query("select acos(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) tdSql.checkData(6, 0, 1.5707963267948966) - tdSql.query('select acos(a) from (select acos(c2) as a from tb1);') + tdSql.query("select acos(a) from (select acos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2 + c3) from tb1;') + tdSql.query("select acos(c2 + c3) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos((c2 + c3)) from tb1;') + tdSql.query("select acos((c2 + c3)) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos((c2 * c3)+c4-6) from tb1;') + tdSql.query("select acos((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(11)+c2 from tb1;') + tdSql.query("select acos(11)+c2 from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2)+11 from tb1;') + tdSql.query("select acos(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 11.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select acos(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) - tdSql.query('select acos(c2) from tb1 order by ts desc;') + tdSql.query("select acos(c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) + tdSql.checkData(4, 0, nan) tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.0) - tdSql.query('select acos(c2+c3) from tb1 order by ts desc;') + tdSql.query("select acos(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, None) tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select acos(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select acos(c2) from stb1;') + tdSql.query("select acos(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query('select acos(c2) from stb1 order by ts desc;') + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query("select acos(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select acos(c4),t1 from stb1 order by ts desc;') + tdSql.query("select acos(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select acos(c3),tbname from stb1;') + tdSql.query("select acos(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(0, 1, 'tb1') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb1') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") + tdSql.checkData(1, 0, None) + tdSql.checkData(1, 1, "tb1") + tdSql.checkData(2, 0, None) + tdSql.checkData(2, 1, "tb1") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb1") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb1") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 0.0) - tdSql.checkData(7, 1, 'tb2') - tdSql.checkData(8, 0, None) - tdSql.checkData(8, 1, 'tb2') - tdSql.checkData(9, 0, None) - tdSql.checkData(9, 1, 'tb2') - tdSql.checkData(10, 0, None) - tdSql.checkData(10, 1, 'tb2') - tdSql.checkData(11, 0, None) - tdSql.checkData(11, 1, 'tb2') - tdSql.checkData(12, 0, None) - tdSql.checkData(12, 1, 'tb2') - tdSql.checkData(13, 0, None) - tdSql.checkData(13, 1, 'tb2') - - tdSql.query('select acos(c3),tbname from stb1 where t1 > 1;') + tdSql.checkData(7, 1, "tb2") + tdSql.checkData(8, 0, nan) + tdSql.checkData(8, 1, "tb2") + tdSql.checkData(9, 0, nan) + tdSql.checkData(9, 1, "tb2") + tdSql.checkData(10, 0, nan) + tdSql.checkData(10, 1, "tb2") + tdSql.checkData(11, 0, nan) + tdSql.checkData(11, 1, "tb2") + tdSql.checkData(12, 0, nan) + tdSql.checkData(12, 1, "tb2") + tdSql.checkData(13, 0, nan) + tdSql.checkData(13, 1, "tb2") + + tdSql.query("select acos(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(0, 1, 'tb2') - tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb2') - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb2') - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb2') - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, 'tb2') - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, 'tb2') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb2') - - tdSql.query('select acos(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.checkData(0, 1, "tb2") + tdSql.checkData(1, 0, nan) + tdSql.checkData(1, 1, "tb2") + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, "tb2") + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, "tb2") + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, "tb2") + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, "tb2") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb2") + + tdSql.query("select acos(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - - tdSql.query('select acos(c2) from (select * from stb1);') + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + + tdSql.query("select acos(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 0.0) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 0.0) - tdSql.checkData(9, 0, None) + tdSql.checkData(9, 0, nan) - tdSql.query("select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select acos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 0.0) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, None) tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select acos(a) from (select acos(c2) as a from tb1);') + tdSql.query("select acos(a) from (select acos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5707963267948966) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) - tdSql.query('select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query( + "select acos(tb1.c3),acos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(0, 1, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) - tdSql.query('select acos(c3) from tb1 union all select acos(c3) from tb2;') + tdSql.query("select acos(c3) from tb1 union all select acos(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) - #=========== end math_atan ========== + # =========== end math_atan ========== - - #=========== begin math_atan2 ========== - tdSql.query('select acos(stb1.c4),acos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;') + # =========== begin math_atan2 ========== + tdSql.query( + "select acos(stb1.c4),acos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(0, 1, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(4, 1, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(5, 1, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, None) - - tdSql.query('select acos(c4) as a from stb1 union all select acos(c5) as a from stba;') + tdSql.checkData(1, 1, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(2, 1, nan) + tdSql.checkData(3, 0, None) + tdSql.checkData(3, 1, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(4, 1, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(5, 1, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, nan) + + tdSql.query( + "select acos(c4) as a from stb1 union all select acos(c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) + tdSql.checkData(2, 0, nan) tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) tdSql.checkData(7, 0, 0.0) - tdSql.checkData(8, 0, None) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) + tdSql.checkData(8, 0, nan) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) tdSql.checkData(14, 0, 0.0) - tdSql.checkData(15, 0, None) - tdSql.checkData(16, 0, None) - tdSql.checkData(17, 0, None) - tdSql.checkData(18, 0, None) - tdSql.checkData(19, 0, None) - tdSql.checkData(20, 0, None) - tdSql.checkData(21, 0, None) - tdSql.checkData(22, 0, None) + tdSql.checkData(15, 0, nan) + tdSql.checkData(16, 0, nan) + tdSql.checkData(17, 0, nan) + tdSql.checkData(18, 0, nan) + tdSql.checkData(19, 0, nan) + tdSql.checkData(20, 0, nan) + tdSql.checkData(21, 0, nan) + tdSql.checkData(22, 0, nan) tdSql.checkData(23, 0, 1.5707963267948966) tdSql.checkData(24, 0, 0.0) - tdSql.checkData(25, 0, None) - tdSql.checkData(26, 0, None) - tdSql.checkData(27, 0, None) - tdSql.checkData(28, 0, None) - tdSql.checkData(29, 0, None) - tdSql.checkData(30, 0, None) - tdSql.checkData(31, 0, None) - tdSql.checkData(32, 0, None) + tdSql.checkData(25, 0, nan) + tdSql.checkData(26, 0, nan) + tdSql.checkData(27, 0, nan) + tdSql.checkData(28, 0, nan) + tdSql.checkData(29, 0, nan) + tdSql.checkData(30, 0, nan) + tdSql.checkData(31, 0, nan) + tdSql.checkData(32, 0, nan) tdSql.checkData(33, 0, 1.5707963267948966) tdSql.checkData(34, 0, 0.0) - tdSql.checkData(35, 0, None) - tdSql.checkData(36, 0, None) - tdSql.checkData(37, 0, None) - tdSql.checkData(38, 0, None) - tdSql.checkData(39, 0, None) - tdSql.checkData(40, 0, None) - tdSql.checkData(41, 0, None) - tdSql.checkData(42, 0, None) + tdSql.checkData(35, 0, nan) + tdSql.checkData(36, 0, nan) + tdSql.checkData(37, 0, nan) + tdSql.checkData(38, 0, nan) + tdSql.checkData(39, 0, nan) + tdSql.checkData(40, 0, nan) + tdSql.checkData(41, 0, nan) + tdSql.checkData(42, 0, nan) tdSql.checkData(43, 0, 1.5707963267948966) - tdSql.query('select acos(c2) from stba;') + tdSql.query("select acos(c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 0.0) - tdSql.checkData(1, 0, None) - tdSql.checkData(2, 0, None) - tdSql.checkData(3, 0, None) - tdSql.checkData(4, 0, None) - tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) - tdSql.checkData(8, 0, None) + tdSql.checkData(1, 0, nan) + tdSql.checkData(2, 0, nan) + tdSql.checkData(3, 0, nan) + tdSql.checkData(4, 0, nan) + tdSql.checkData(5, 0, nan) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) + tdSql.checkData(8, 0, nan) tdSql.checkData(9, 0, 1.5707963267948966) tdSql.checkData(10, 0, 0.0) - tdSql.checkData(11, 0, None) - tdSql.checkData(12, 0, None) - tdSql.checkData(13, 0, None) - tdSql.checkData(14, 0, None) - tdSql.checkData(15, 0, None) - tdSql.checkData(16, 0, None) - tdSql.checkData(17, 0, None) - tdSql.checkData(18, 0, None) + tdSql.checkData(11, 0, nan) + tdSql.checkData(12, 0, nan) + tdSql.checkData(13, 0, nan) + tdSql.checkData(14, 0, nan) + tdSql.checkData(15, 0, nan) + tdSql.checkData(16, 0, nan) + tdSql.checkData(17, 0, nan) + tdSql.checkData(18, 0, nan) tdSql.checkData(19, 0, 1.5707963267948966) tdSql.checkData(20, 0, 0.0) - tdSql.checkData(21, 0, None) - tdSql.checkData(22, 0, None) - tdSql.checkData(23, 0, None) - tdSql.checkData(24, 0, None) - tdSql.checkData(25, 0, None) - tdSql.checkData(26, 0, None) - tdSql.checkData(27, 0, None) - tdSql.checkData(28, 0, None) + tdSql.checkData(21, 0, nan) + tdSql.checkData(22, 0, nan) + tdSql.checkData(23, 0, nan) + tdSql.checkData(24, 0, nan) + tdSql.checkData(25, 0, nan) + tdSql.checkData(26, 0, nan) + tdSql.checkData(27, 0, nan) + tdSql.checkData(28, 0, nan) tdSql.checkData(29, 0, 1.5707963267948966) - tdSql.query('select acos(min(c2)) from tba1;') + tdSql.query("select acos(min(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select acos(max(c2)) from tba1;') + tdSql.query("select acos(max(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(count(c2)) from tba1;') + tdSql.query("select acos(count(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(sum(c2)) from tba1;') + tdSql.query("select acos(sum(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(avg(c2)) from tba1;') + tdSql.query("select acos(avg(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(percentile(c2, 10)) from tba1;') + tdSql.query("select acos(percentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.45102681179626264) - tdSql.query('select acos(apercentile(c2, 10)) from tba1;') + tdSql.query("select acos(apercentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select acos(stddev(c2)) from tba1;') + tdSql.query("select acos(stddev(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(spread(c2)) from tba1;') + tdSql.query("select acos(spread(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(twa(c2)) from tba1;') + tdSql.query("select acos(twa(c2)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(interp(c2)) from tba1 every(1s)') + tdSql.query("select acos(interp(c2)) from tba1 every(1s)") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 0.0) tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) - tdSql.checkData(1, 1, None) + tdSql.checkData(1, 1, nan) tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) - tdSql.checkData(2, 1, None) + tdSql.checkData(2, 1, nan) tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) - tdSql.checkData(3, 1, None) + tdSql.checkData(3, 1, nan) tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) - tdSql.checkData(4, 1, None) + tdSql.checkData(4, 1, nan) tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) - tdSql.checkData(5, 1, None) + tdSql.checkData(5, 1, nan) tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) - tdSql.checkData(6, 1, None) + tdSql.checkData(6, 1, nan) tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) - tdSql.checkData(7, 1, None) + tdSql.checkData(7, 1, nan) tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) - tdSql.checkData(8, 1, None) + tdSql.checkData(8, 1, nan) tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 1.5707963267948966) tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 0.0) tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) - tdSql.checkData(11, 1, None) + tdSql.checkData(11, 1, nan) tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) - tdSql.checkData(12, 1, None) + tdSql.checkData(12, 1, nan) tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) - tdSql.checkData(13, 1, None) + tdSql.checkData(13, 1, nan) tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) - tdSql.checkData(14, 1, None) + tdSql.checkData(14, 1, nan) tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) - tdSql.checkData(15, 1, None) + tdSql.checkData(15, 1, nan) tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) - tdSql.checkData(16, 1, None) + tdSql.checkData(16, 1, nan) tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) - tdSql.checkData(17, 1, None) + tdSql.checkData(17, 1, nan) tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) - tdSql.checkData(18, 1, None) + tdSql.checkData(18, 1, nan) tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 1.5707963267948966) tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 0.0) tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) - tdSql.checkData(21, 1, None) + tdSql.checkData(21, 1, nan) tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) - tdSql.checkData(22, 1, None) + tdSql.checkData(22, 1, nan) tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) - tdSql.checkData(23, 1, None) + tdSql.checkData(23, 1, nan) tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) - tdSql.checkData(24, 1, None) + tdSql.checkData(24, 1, nan) tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) - tdSql.checkData(25, 1, None) + tdSql.checkData(25, 1, nan) tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) - tdSql.checkData(26, 1, None) + tdSql.checkData(26, 1, nan) tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) - tdSql.checkData(27, 1, None) + tdSql.checkData(27, 1, nan) tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) - tdSql.checkData(28, 1, None) + tdSql.checkData(28, 1, nan) tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 1.5707963267948966) - tdSql.query('select acos(interp(c2)) from stba every(1s) group by tbname;') + tdSql.query("select acos(interp(c2)) from stba every(1s) group by tbname;") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 0.0) - tdSql.checkData(0, 2, 'tba1') + tdSql.checkData(0, 2, "tba1") tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) - tdSql.checkData(1, 1, None) - tdSql.checkData(1, 2, 'tba1') + tdSql.checkData(1, 1, nan) + tdSql.checkData(1, 2, "tba1") tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) - tdSql.checkData(2, 1, None) - tdSql.checkData(2, 2, 'tba1') + tdSql.checkData(2, 1, nan) + tdSql.checkData(2, 2, "tba1") tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) - tdSql.checkData(3, 1, None) - tdSql.checkData(3, 2, 'tba1') + tdSql.checkData(3, 1, nan) + tdSql.checkData(3, 2, "tba1") tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) - tdSql.checkData(4, 1, None) - tdSql.checkData(4, 2, 'tba1') + tdSql.checkData(4, 1, nan) + tdSql.checkData(4, 2, "tba1") tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) - tdSql.checkData(5, 1, None) - tdSql.checkData(5, 2, 'tba1') + tdSql.checkData(5, 1, nan) + tdSql.checkData(5, 2, "tba1") tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) - tdSql.checkData(6, 1, None) - tdSql.checkData(6, 2, 'tba1') + tdSql.checkData(6, 1, nan) + tdSql.checkData(6, 2, "tba1") tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) - tdSql.checkData(7, 1, None) - tdSql.checkData(7, 2, 'tba1') + tdSql.checkData(7, 1, nan) + tdSql.checkData(7, 2, "tba1") tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) - tdSql.checkData(8, 1, None) - tdSql.checkData(8, 2, 'tba1') + tdSql.checkData(8, 1, nan) + tdSql.checkData(8, 2, "tba1") tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 1.5707963267948966) - tdSql.checkData(9, 2, 'tba1') + tdSql.checkData(9, 2, "tba1") tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 0.0) - tdSql.checkData(10, 2, 'tba1') + tdSql.checkData(10, 2, "tba1") tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) - tdSql.checkData(11, 1, None) - tdSql.checkData(11, 2, 'tba1') + tdSql.checkData(11, 1, nan) + tdSql.checkData(11, 2, "tba1") tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) - tdSql.checkData(12, 1, None) - tdSql.checkData(12, 2, 'tba1') + tdSql.checkData(12, 1, nan) + tdSql.checkData(12, 2, "tba1") tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) - tdSql.checkData(13, 1, None) - tdSql.checkData(13, 2, 'tba1') + tdSql.checkData(13, 1, nan) + tdSql.checkData(13, 2, "tba1") tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) - tdSql.checkData(14, 1, None) - tdSql.checkData(14, 2, 'tba1') + tdSql.checkData(14, 1, nan) + tdSql.checkData(14, 2, "tba1") tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) - tdSql.checkData(15, 1, None) - tdSql.checkData(15, 2, 'tba1') + tdSql.checkData(15, 1, nan) + tdSql.checkData(15, 2, "tba1") tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) - tdSql.checkData(16, 1, None) - tdSql.checkData(16, 2, 'tba1') + tdSql.checkData(16, 1, nan) + tdSql.checkData(16, 2, "tba1") tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) - tdSql.checkData(17, 1, None) - tdSql.checkData(17, 2, 'tba1') + tdSql.checkData(17, 1, nan) + tdSql.checkData(17, 2, "tba1") tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) - tdSql.checkData(18, 1, None) - tdSql.checkData(18, 2, 'tba1') + tdSql.checkData(18, 1, nan) + tdSql.checkData(18, 2, "tba1") tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 1.5707963267948966) - tdSql.checkData(19, 2, 'tba1') + tdSql.checkData(19, 2, "tba1") tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 0.0) - tdSql.checkData(20, 2, 'tba1') + tdSql.checkData(20, 2, "tba1") tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) - tdSql.checkData(21, 1, None) - tdSql.checkData(21, 2, 'tba1') + tdSql.checkData(21, 1, nan) + tdSql.checkData(21, 2, "tba1") tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) - tdSql.checkData(22, 1, None) - tdSql.checkData(22, 2, 'tba1') + tdSql.checkData(22, 1, nan) + tdSql.checkData(22, 2, "tba1") tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) - tdSql.checkData(23, 1, None) - tdSql.checkData(23, 2, 'tba1') + tdSql.checkData(23, 1, nan) + tdSql.checkData(23, 2, "tba1") tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) - tdSql.checkData(24, 1, None) - tdSql.checkData(24, 2, 'tba1') + tdSql.checkData(24, 1, nan) + tdSql.checkData(24, 2, "tba1") tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) - tdSql.checkData(25, 1, None) - tdSql.checkData(25, 2, 'tba1') + tdSql.checkData(25, 1, nan) + tdSql.checkData(25, 2, "tba1") tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) - tdSql.checkData(26, 1, None) - tdSql.checkData(26, 2, 'tba1') + tdSql.checkData(26, 1, nan) + tdSql.checkData(26, 2, "tba1") tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) - tdSql.checkData(27, 1, None) - tdSql.checkData(27, 2, 'tba1') + tdSql.checkData(27, 1, nan) + tdSql.checkData(27, 2, "tba1") tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) - tdSql.checkData(28, 1, None) - tdSql.checkData(28, 2, 'tba1') + tdSql.checkData(28, 1, nan) + tdSql.checkData(28, 2, "tba1") tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 1.5707963267948966) - tdSql.checkData(29, 2, 'tba1') + tdSql.checkData(29, 2, "tba1") - tdSql.query('select acos(elapsed(ts)) from tba1;') + tdSql.query("select acos(elapsed(ts)) from tba1;") tdSql.checkRows(1) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) - tdSql.query('select acos(rate(c2)) from tba1;') + tdSql.query("select acos(rate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.4588742050141097) - tdSql.query('select acos(irate(c2)) from tba1;') + tdSql.query("select acos(irate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select acos(first(c2)) from tba1;') + tdSql.query("select acos(first(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select acos(last(c2)) from tba1;') + tdSql.query("select acos(last(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - tdSql.query('select acos(last_row(c2)) from tba1;') + tdSql.query("select acos(last_row(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5707963267948966) - #=========== end math_atan2 ========== + # =========== end math_atan2 ========== - - #=========== begin math_sin ========== - tdSql.query('select sin(13) from tb1;') + # =========== begin math_sin ========== + tdSql.query("select sin(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.4201670368266409) tdSql.checkData(1, 0, 0.4201670368266409) @@ -7720,7 +8004,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.4201670368266409) tdSql.checkData(6, 0, 0.4201670368266409) - tdSql.query('select sin(c2) from tb1;') + tdSql.query("select sin(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7730,7 +8014,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.972630067242408) tdSql.checkData(6, 0, -0.972630067242408) - tdSql.query('select sin(c3) from tb1;') + tdSql.query("select sin(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7740,7 +8024,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.18750655394138943) tdSql.checkData(6, 0, -0.18750655394138943) - tdSql.query('select sin(c4) from tb1;') + tdSql.query("select sin(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7750,7 +8034,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.7249165551445564) tdSql.checkData(6, 0, 0.7249165551445564) - tdSql.query('select sin(c5) from tb1;') + tdSql.query("select sin(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7760,7 +8044,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9999303766734422) tdSql.checkData(6, 0, -0.9999303766734422) - tdSql.query('select sin(c6) from tb1;') + tdSql.query("select sin(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7770,7 +8054,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.5218765233336585) tdSql.checkData(6, 0, 0.5218765233336585) - tdSql.query('select sin(c7) from tb1;') + tdSql.query("select sin(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7780,7 +8064,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.8728292970885063) tdSql.checkData(6, 0, -0.8728292970885063) - tdSql.query('select sin(c10) from tb1;') + tdSql.query("select sin(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7790,7 +8074,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.45199889806298343) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sin(c11) from tb1;') + tdSql.query("select sin(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7800,7 +8084,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.3683616323063538) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sin(c12) from tb1;') + tdSql.query("select sin(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7810,7 +8094,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9986982434666626) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sin(c13) from tb1;') + tdSql.query("select sin(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7820,7 +8104,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9999303766734422) tdSql.checkData(6, 0, 0.0) - tdSql.query('select sin(a) from (select sin(c2) as a from tb1);') + tdSql.query("select sin(a) from (select sin(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.7456241416655579) tdSql.checkData(1, 0, None) @@ -7830,7 +8114,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.8263696344332049) tdSql.checkData(6, 0, -0.8263696344332049) - tdSql.query('select sin(c2 + c3) from tb1;') + tdSql.query("select sin(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.9092974268256817) tdSql.checkData(1, 0, None) @@ -7840,7 +8124,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9989477243796069) tdSql.checkData(6, 0, -0.9989477243796069) - tdSql.query('select sin((c2 + c3)) from tb1;') + tdSql.query("select sin((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.9092974268256817) tdSql.checkData(1, 0, None) @@ -7850,7 +8134,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9989477243796069) tdSql.checkData(6, 0, -0.9989477243796069) - tdSql.query('select sin((c2 * c3)+c4-6) from tb1;') + tdSql.query("select sin((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.7568024953079282) tdSql.checkData(1, 0, None) @@ -7860,7 +8144,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.08341720348826624) tdSql.checkData(6, 0, 0.9909625452221539) - tdSql.query('select sin(11)+c2 from tb1;') + tdSql.query("select sin(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 9.793449296524592e-06) tdSql.checkData(1, 0, None) @@ -7870,7 +8154,7 @@ class TDTestCase: tdSql.checkData(5, 0, 126.0000097934493) tdSql.checkData(6, 0, -127.9999902065507) - tdSql.query('select sin(c2)+11 from tb1;') + tdSql.query("select sin(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 11.841470984807897) tdSql.checkData(1, 0, None) @@ -7880,14 +8164,16 @@ class TDTestCase: tdSql.checkData(5, 0, 11.972630067242408) tdSql.checkData(6, 0, 10.027369932757592) - tdSql.query('select sin(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select sin(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 0.9092974268256817) tdSql.checkData(1, 0, 0.9893582466233818) tdSql.checkData(2, 0, 0.9989477243796069) tdSql.checkData(3, 0, -0.9989477243796069) - tdSql.query('select sin(c2) from tb1 order by ts desc;') + tdSql.query("select sin(c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.972630067242408) tdSql.checkData(1, 0, 0.972630067242408) @@ -7897,7 +8183,7 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.8414709848078965) - tdSql.query('select sin(c2+c3) from tb1 order by ts desc;') + tdSql.query("select sin(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.9989477243796069) tdSql.checkData(1, 0, 0.9989477243796069) @@ -7907,13 +8193,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.9092974268256817) - tdSql.query('select sin(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select sin(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 0.9893582466233818) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select sin(c2) from stb1;') + tdSql.query("select sin(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -7930,59 +8216,59 @@ class TDTestCase: tdSql.checkData(12, 0, -0.27941549819892586) tdSql.checkData(13, 0, 0.6569865987187891) - tdSql.query('select sin(c2) from stb1 order by ts desc;') + tdSql.query("select sin(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select sin(c4),t1 from stb1 order by ts desc;') + tdSql.query("select sin(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select sin(c3),tbname from stb1;') + tdSql.query("select sin(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.8414709848078965) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, 0.1411200080598672) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, -0.7568024953079282) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 0.18750655394138943) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, -0.18750655394138943) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 0.8414709848078965) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 0.9092974268256817) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 0.1411200080598672) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, -0.7568024953079282) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, -0.9589242746631385) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, -0.27941549819892586) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 0.6569865987187891) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select sin(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select sin(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 0.9092974268256817) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 0.1411200080598672) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, -0.7568024953079282) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, -0.9589242746631385) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, -0.27941549819892586) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 0.6569865987187891) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select sin(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select sin(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, 0.9092974268256817) @@ -7992,7 +8278,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.5025573497604873) tdSql.checkData(6, 0, 0.3048106211022167) - tdSql.query('select sin(c2) from (select * from stb1);') + tdSql.query("select sin(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -8009,7 +8295,9 @@ class TDTestCase: tdSql.checkData(12, 0, -0.27941549819892586) tdSql.checkData(13, 0, 0.6569865987187891) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, 0.9092974268256817) @@ -8022,7 +8310,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, 0.9092974268256817) @@ -8035,7 +8325,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -8048,7 +8340,9 @@ class TDTestCase: tdSql.checkData(8, 0, 0.9092974268256817) tdSql.checkData(9, 0, 0.8414709848078965) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -8061,7 +8355,9 @@ class TDTestCase: tdSql.checkData(8, 0, 0.8414709848078965) tdSql.checkData(9, 0, 0.3048106211022167) - tdSql.query("select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select sin(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.3048106211022167) tdSql.checkData(1, 0, 0.8414709848078965) @@ -8074,7 +8370,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select sin(a) from (select sin(c2) as a from tb1);') + tdSql.query("select sin(a) from (select sin(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.7456241416655579) tdSql.checkData(1, 0, None) @@ -8084,7 +8380,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.8263696344332049) tdSql.checkData(6, 0, -0.8263696344332049) - tdSql.query('select sin(tb1.c3),sin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query("select sin(tb1.c3),sin(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(0, 1, 0.8414709848078965) @@ -8101,7 +8397,7 @@ class TDTestCase: tdSql.checkData(6, 0, -0.18750655394138943) tdSql.checkData(6, 1, 0.6569865987187891) - tdSql.query('select sin(c3) from tb1 union all select sin(c3) from tb2;') + tdSql.query("select sin(c3) from tb1 union all select sin(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -8118,11 +8414,12 @@ class TDTestCase: tdSql.checkData(12, 0, -0.27941549819892586) tdSql.checkData(13, 0, 0.6569865987187891) - #=========== end math_sin ========== - + # =========== end math_sin ========== - #=========== begin math_sin2 ========== - tdSql.query('select sin(stb1.c4),sin(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;') + # =========== begin math_sin2 ========== + tdSql.query( + "select sin(stb1.c4),sin(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(0, 1, 0.8414709848078965) @@ -8139,7 +8436,9 @@ class TDTestCase: tdSql.checkData(6, 0, 0.7249165551445564) tdSql.checkData(6, 1, 0.6569865987187891) - tdSql.query('select sin(c4) as a from stb1 union all select sin(c5) as a from stba;') + tdSql.query( + "select sin(c4) as a from stb1 union all select sin(c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, None) @@ -8186,7 +8485,7 @@ class TDTestCase: tdSql.checkData(42, 0, 0.4121184852417566) tdSql.checkData(43, 0, 0.0) - tdSql.query('select sin(c2) from stba;') + tdSql.query("select sin(c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 0.8414709848078965) tdSql.checkData(1, 0, 0.9092974268256817) @@ -8219,47 +8518,47 @@ class TDTestCase: tdSql.checkData(28, 0, 0.4121184852417566) tdSql.checkData(29, 0, 0.0) - tdSql.query('select sin(min(c2)) from tba1;') + tdSql.query("select sin(min(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select sin(max(c2)) from tba1;') + tdSql.query("select sin(max(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.4121184852417566) - tdSql.query('select sin(count(c2)) from tba1;') + tdSql.query("select sin(count(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.9880316240928618) - tdSql.query('select sin(sum(c2)) from tba1;') + tdSql.query("select sin(sum(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.08836868610400143) - tdSql.query('select sin(avg(c2)) from tba1;') + tdSql.query("select sin(avg(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.977530117665097) - tdSql.query('select sin(percentile(c2, 10)) from tba1;') + tdSql.query("select sin(percentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.7833269096274833) - tdSql.query('select sin(apercentile(c2, 10)) from tba1;') + tdSql.query("select sin(apercentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select sin(stddev(c2)) from tba1;') + tdSql.query("select sin(stddev(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.266067653696438) - tdSql.query('select sin(spread(c2)) from tba1;') + tdSql.query("select sin(spread(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.4121184852417566) - tdSql.query('select sin(twa(c2)) from tba1;') + tdSql.query("select sin(twa(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.9972292875667882) - tdSql.query('select sin(interp(c2)) from tba1 every(1s)') + tdSql.query("select sin(interp(c2)) from tba1 every(1s)") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 0.8414709848078965) @@ -8322,128 +8621,127 @@ class TDTestCase: tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0.0) - tdSql.query('select sin(interp(c2)) from stba every(1s) group by tbname;') + tdSql.query("select sin(interp(c2)) from stba every(1s) group by tbname;") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 0.8414709848078965) - tdSql.checkData(0, 2, 'tba1') + tdSql.checkData(0, 2, "tba1") tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) tdSql.checkData(1, 1, 0.9092974268256817) - tdSql.checkData(1, 2, 'tba1') + tdSql.checkData(1, 2, "tba1") tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) tdSql.checkData(2, 1, 0.1411200080598672) - tdSql.checkData(2, 2, 'tba1') + tdSql.checkData(2, 2, "tba1") tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) tdSql.checkData(3, 1, -0.7568024953079282) - tdSql.checkData(3, 2, 'tba1') + tdSql.checkData(3, 2, "tba1") tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) tdSql.checkData(4, 1, -0.9589242746631385) - tdSql.checkData(4, 2, 'tba1') + tdSql.checkData(4, 2, "tba1") tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) tdSql.checkData(5, 1, -0.27941549819892586) - tdSql.checkData(5, 2, 'tba1') + tdSql.checkData(5, 2, "tba1") tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) tdSql.checkData(6, 1, 0.6569865987187891) - tdSql.checkData(6, 2, 'tba1') + tdSql.checkData(6, 2, "tba1") tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) tdSql.checkData(7, 1, 0.9893582466233818) - tdSql.checkData(7, 2, 'tba1') + tdSql.checkData(7, 2, "tba1") tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) tdSql.checkData(8, 1, 0.4121184852417566) - tdSql.checkData(8, 2, 'tba1') + tdSql.checkData(8, 2, "tba1") tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 0.0) - tdSql.checkData(9, 2, 'tba1') + tdSql.checkData(9, 2, "tba1") tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 0.8414709848078965) - tdSql.checkData(10, 2, 'tba1') + tdSql.checkData(10, 2, "tba1") tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) tdSql.checkData(11, 1, 0.9092974268256817) - tdSql.checkData(11, 2, 'tba1') + tdSql.checkData(11, 2, "tba1") tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) tdSql.checkData(12, 1, 0.1411200080598672) - tdSql.checkData(12, 2, 'tba1') + tdSql.checkData(12, 2, "tba1") tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) tdSql.checkData(13, 1, -0.7568024953079282) - tdSql.checkData(13, 2, 'tba1') + tdSql.checkData(13, 2, "tba1") tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) tdSql.checkData(14, 1, -0.9589242746631385) - tdSql.checkData(14, 2, 'tba1') + tdSql.checkData(14, 2, "tba1") tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) tdSql.checkData(15, 1, -0.27941549819892586) - tdSql.checkData(15, 2, 'tba1') + tdSql.checkData(15, 2, "tba1") tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) tdSql.checkData(16, 1, 0.6569865987187891) - tdSql.checkData(16, 2, 'tba1') + tdSql.checkData(16, 2, "tba1") tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) tdSql.checkData(17, 1, 0.9893582466233818) - tdSql.checkData(17, 2, 'tba1') + tdSql.checkData(17, 2, "tba1") tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) tdSql.checkData(18, 1, 0.4121184852417566) - tdSql.checkData(18, 2, 'tba1') + tdSql.checkData(18, 2, "tba1") tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 0.0) - tdSql.checkData(19, 2, 'tba1') + tdSql.checkData(19, 2, "tba1") tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 0.8414709848078965) - tdSql.checkData(20, 2, 'tba1') + tdSql.checkData(20, 2, "tba1") tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) tdSql.checkData(21, 1, 0.9092974268256817) - tdSql.checkData(21, 2, 'tba1') + tdSql.checkData(21, 2, "tba1") tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) tdSql.checkData(22, 1, 0.1411200080598672) - tdSql.checkData(22, 2, 'tba1') + tdSql.checkData(22, 2, "tba1") tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) tdSql.checkData(23, 1, -0.7568024953079282) - tdSql.checkData(23, 2, 'tba1') + tdSql.checkData(23, 2, "tba1") tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) tdSql.checkData(24, 1, -0.9589242746631385) - tdSql.checkData(24, 2, 'tba1') + tdSql.checkData(24, 2, "tba1") tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) tdSql.checkData(25, 1, -0.27941549819892586) - tdSql.checkData(25, 2, 'tba1') + tdSql.checkData(25, 2, "tba1") tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) tdSql.checkData(26, 1, 0.6569865987187891) - tdSql.checkData(26, 2, 'tba1') + tdSql.checkData(26, 2, "tba1") tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) tdSql.checkData(27, 1, 0.9893582466233818) - tdSql.checkData(27, 2, 'tba1') + tdSql.checkData(27, 2, "tba1") tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) tdSql.checkData(28, 1, 0.4121184852417566) - tdSql.checkData(28, 2, 'tba1') + tdSql.checkData(28, 2, "tba1") tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0.0) - tdSql.checkData(29, 2, 'tba1') + tdSql.checkData(29, 2, "tba1") - tdSql.query('select sin(elapsed(ts)) from tba1;') + tdSql.query("select sin(elapsed(ts)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.04177312885292625) - tdSql.query('select sin(rate(c2)) from tba1;') + tdSql.query("select sin(rate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.7811787741147804) - tdSql.query('select sin(irate(c2)) from tba1;') + tdSql.query("select sin(irate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select sin(first(c2)) from tba1;') + tdSql.query("select sin(first(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.8414709848078965) - tdSql.query('select sin(last(c2)) from tba1;') + tdSql.query("select sin(last(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select sin(last_row(c2)) from tba1;') + tdSql.query("select sin(last_row(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - #=========== end math_sin2 ========== + # =========== end math_sin2 ========== - - #=========== begin math_cos ========== - tdSql.query('select cos(13) from tb1;') + # =========== begin math_cos ========== + tdSql.query("select cos(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.9074467814501962) tdSql.checkData(1, 0, 0.9074467814501962) @@ -8453,7 +8751,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9074467814501962) tdSql.checkData(6, 0, 0.9074467814501962) - tdSql.query('select cos(c2) from tb1;') + tdSql.query("select cos(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8463,7 +8761,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.23235910202965793) tdSql.checkData(6, 0, 0.23235910202965793) - tdSql.query('select cos(c3) from tb1;') + tdSql.query("select cos(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8473,7 +8771,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9822633517692823) tdSql.checkData(6, 0, 0.9822633517692823) - tdSql.query('select cos(c4) from tb1;') + tdSql.query("select cos(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8483,7 +8781,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.6888366918779438) tdSql.checkData(6, 0, -0.6888366918779438) - tdSql.query('select cos(c5) from tb1;') + tdSql.query("select cos(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8493,7 +8791,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.011800076512800236) tdSql.checkData(6, 0, 0.011800076512800236) - tdSql.query('select cos(c6) from tb1;') + tdSql.query("select cos(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8503,7 +8801,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.8530210398303042) tdSql.checkData(6, 0, 0.8530210398303042) - tdSql.query('select cos(c7) from tb1;') + tdSql.query("select cos(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8513,7 +8811,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.4880256326710555) tdSql.checkData(6, 0, 0.4880256326710555) - tdSql.query('select cos(c10) from tb1;') + tdSql.query("select cos(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8523,7 +8821,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.892018495407942) tdSql.checkData(6, 0, 1.0) - tdSql.query('select cos(c11) from tb1;') + tdSql.query("select cos(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8533,7 +8831,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9296825844580496) tdSql.checkData(6, 0, 1.0) - tdSql.query('select cos(c12) from tb1;') + tdSql.query("select cos(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8543,7 +8841,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.051008023845301335) tdSql.checkData(6, 0, 1.0) - tdSql.query('select cos(c13) from tb1;') + tdSql.query("select cos(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8553,7 +8851,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.011800076512800236) tdSql.checkData(6, 0, 1.0) - tdSql.query('select cos(a) from (select cos(c2) as a from tb1);') + tdSql.query("select cos(a) from (select cos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8575532158463934) tdSql.checkData(1, 0, None) @@ -8563,7 +8861,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9731258638638398) tdSql.checkData(6, 0, 0.9731258638638398) - tdSql.query('select cos(c2 + c3) from tb1;') + tdSql.query("select cos(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.4161468365471424) tdSql.checkData(1, 0, None) @@ -8573,7 +8871,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.04586331820534665) tdSql.checkData(6, 0, 0.04586331820534665) - tdSql.query('select cos((c2 + c3)) from tb1;') + tdSql.query("select cos((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.4161468365471424) tdSql.checkData(1, 0, None) @@ -8583,7 +8881,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.04586331820534665) tdSql.checkData(6, 0, 0.04586331820534665) - tdSql.query('select cos((c2 * c3)+c4-6) from tb1;') + tdSql.query("select cos((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -0.6536436208636119) tdSql.checkData(1, 0, None) @@ -8593,7 +8891,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.9965147114630055) tdSql.checkData(6, 0, 0.13413886076313122) - tdSql.query('select cos(11)+c2 from tb1;') + tdSql.query("select cos(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0044256979880508) tdSql.checkData(1, 0, None) @@ -8603,7 +8901,7 @@ class TDTestCase: tdSql.checkData(5, 0, 127.00442569798805) tdSql.checkData(6, 0, -126.99557430201195) - tdSql.query('select cos(c2)+11 from tb1;') + tdSql.query("select cos(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 11.54030230586814) tdSql.checkData(1, 0, None) @@ -8613,14 +8911,16 @@ class TDTestCase: tdSql.checkData(5, 0, 11.232359102029658) tdSql.checkData(6, 0, 11.232359102029658) - tdSql.query('select cos(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select cos(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, -0.4161468365471424) tdSql.checkData(1, 0, -0.14550003380861354) tdSql.checkData(2, 0, 0.04586331820534665) tdSql.checkData(3, 0, 0.04586331820534665) - tdSql.query('select cos(c2) from tb1 order by ts desc;') + tdSql.query("select cos(c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.23235910202965793) tdSql.checkData(1, 0, 0.23235910202965793) @@ -8630,7 +8930,7 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.5403023058681398) - tdSql.query('select cos(c2+c3) from tb1 order by ts desc;') + tdSql.query("select cos(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.04586331820534665) tdSql.checkData(1, 0, 0.04586331820534665) @@ -8640,13 +8940,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, -0.4161468365471424) - tdSql.query('select cos(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select cos(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, -0.14550003380861354) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select cos(c2) from stb1;') + tdSql.query("select cos(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8663,59 +8963,59 @@ class TDTestCase: tdSql.checkData(12, 0, 0.960170286650366) tdSql.checkData(13, 0, 0.7539022543433046) - tdSql.query('select cos(c2) from stb1 order by ts desc;') + tdSql.query("select cos(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select cos(c4),t1 from stb1 order by ts desc;') + tdSql.query("select cos(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select cos(c3),tbname from stb1;') + tdSql.query("select cos(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.5403023058681398) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, -0.9899924966004454) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, -0.6536436208636119) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 0.9822633517692823) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, 0.9822633517692823) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 0.5403023058681398) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, -0.4161468365471424) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, -0.9899924966004454) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, -0.6536436208636119) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 0.28366218546322625) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 0.960170286650366) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 0.7539022543433046) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select cos(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select cos(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, -0.4161468365471424) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, -0.9899924966004454) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, -0.6536436208636119) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 0.28366218546322625) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 0.960170286650366) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 0.7539022543433046) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select cos(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select cos(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, -0.4161468365471424) @@ -8725,7 +9025,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.8645438740756395) tdSql.checkData(6, 0, -0.9524129804151563) - tdSql.query('select cos(c2) from (select * from stb1);') + tdSql.query("select cos(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8742,7 +9042,9 @@ class TDTestCase: tdSql.checkData(12, 0, 0.960170286650366) tdSql.checkData(13, 0, 0.7539022543433046) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, -0.4161468365471424) @@ -8755,7 +9057,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, -0.4161468365471424) @@ -8768,7 +9072,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -8781,7 +9087,9 @@ class TDTestCase: tdSql.checkData(8, 0, -0.4161468365471424) tdSql.checkData(9, 0, 0.5403023058681398) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -8794,7 +9102,9 @@ class TDTestCase: tdSql.checkData(8, 0, 0.5403023058681398) tdSql.checkData(9, 0, -0.9524129804151563) - tdSql.query("select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select cos(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, -0.9524129804151563) tdSql.checkData(1, 0, 0.5403023058681398) @@ -8807,7 +9117,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select cos(a) from (select cos(c2) as a from tb1);') + tdSql.query("select cos(a) from (select cos(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.8575532158463934) tdSql.checkData(1, 0, None) @@ -8817,7 +9127,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.9731258638638398) tdSql.checkData(6, 0, 0.9731258638638398) - tdSql.query('select cos(tb1.c3),cos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query("select cos(tb1.c3),cos(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(0, 1, 0.5403023058681398) @@ -8834,7 +9144,7 @@ class TDTestCase: tdSql.checkData(6, 0, 0.9822633517692823) tdSql.checkData(6, 1, 0.7539022543433046) - tdSql.query('select cos(c3) from tb1 union all select cos(c3) from tb2;') + tdSql.query("select cos(c3) from tb1 union all select cos(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8851,11 +9161,12 @@ class TDTestCase: tdSql.checkData(12, 0, 0.960170286650366) tdSql.checkData(13, 0, 0.7539022543433046) - #=========== end math_cos ========== - + # =========== end math_cos ========== - #=========== begin math_cos2 ========== - tdSql.query('select cos(stb1.c4),cos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;') + # =========== begin math_cos2 ========== + tdSql.query( + "select cos(stb1.c4),cos(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(0, 1, 0.5403023058681398) @@ -8872,7 +9183,9 @@ class TDTestCase: tdSql.checkData(6, 0, -0.6888366918779438) tdSql.checkData(6, 1, 0.7539022543433046) - tdSql.query('select cos(c4) as a from stb1 union all select cos(c5) as a from stba;') + tdSql.query( + "select cos(c4) as a from stb1 union all select cos(c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, None) @@ -8919,7 +9232,7 @@ class TDTestCase: tdSql.checkData(42, 0, -0.9111302618846769) tdSql.checkData(43, 0, 1.0) - tdSql.query('select cos(c2) from stba;') + tdSql.query("select cos(c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 0.5403023058681398) tdSql.checkData(1, 0, -0.4161468365471424) @@ -8952,47 +9265,47 @@ class TDTestCase: tdSql.checkData(28, 0, -0.9111302618846769) tdSql.checkData(29, 0, 1.0) - tdSql.query('select cos(min(c2)) from tba1;') + tdSql.query("select cos(min(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.0) - tdSql.query('select cos(max(c2)) from tba1;') + tdSql.query("select cos(max(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.9111302618846769) - tdSql.query('select cos(count(c2)) from tba1;') + tdSql.query("select cos(count(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.15425144988758405) - tdSql.query('select cos(sum(c2)) from tba1;') + tdSql.query("select cos(sum(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.9960878351411849) - tdSql.query('select cos(avg(c2)) from tba1;') + tdSql.query("select cos(avg(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.2107957994307797) - tdSql.query('select cos(percentile(c2, 10)) from tba1;') + tdSql.query("select cos(percentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.6216099682706645) - tdSql.query('select cos(apercentile(c2, 10)) from tba1;') + tdSql.query("select cos(apercentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.0) - tdSql.query('select cos(stddev(c2)) from tba1;') + tdSql.query("select cos(stddev(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.9639543576624737) - tdSql.query('select cos(spread(c2)) from tba1;') + tdSql.query("select cos(spread(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.9111302618846769) - tdSql.query('select cos(twa(c2)) from tba1;') + tdSql.query("select cos(twa(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.07438916600578388) - tdSql.query('select cos(interp(c2)) from tba1 every(1s)') + tdSql.query("select cos(interp(c2)) from tba1 every(1s)") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 0.5403023058681398) @@ -9055,128 +9368,127 @@ class TDTestCase: tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 1.0) - tdSql.query('select cos(interp(c2)) from stba every(1s) group by tbname;') + tdSql.query("select cos(interp(c2)) from stba every(1s) group by tbname;") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 0.5403023058681398) - tdSql.checkData(0, 2, 'tba1') + tdSql.checkData(0, 2, "tba1") tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) tdSql.checkData(1, 1, -0.4161468365471424) - tdSql.checkData(1, 2, 'tba1') + tdSql.checkData(1, 2, "tba1") tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) tdSql.checkData(2, 1, -0.9899924966004454) - tdSql.checkData(2, 2, 'tba1') + tdSql.checkData(2, 2, "tba1") tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) tdSql.checkData(3, 1, -0.6536436208636119) - tdSql.checkData(3, 2, 'tba1') + tdSql.checkData(3, 2, "tba1") tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) tdSql.checkData(4, 1, 0.28366218546322625) - tdSql.checkData(4, 2, 'tba1') + tdSql.checkData(4, 2, "tba1") tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) tdSql.checkData(5, 1, 0.960170286650366) - tdSql.checkData(5, 2, 'tba1') + tdSql.checkData(5, 2, "tba1") tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) tdSql.checkData(6, 1, 0.7539022543433046) - tdSql.checkData(6, 2, 'tba1') + tdSql.checkData(6, 2, "tba1") tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) tdSql.checkData(7, 1, -0.14550003380861354) - tdSql.checkData(7, 2, 'tba1') + tdSql.checkData(7, 2, "tba1") tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) tdSql.checkData(8, 1, -0.9111302618846769) - tdSql.checkData(8, 2, 'tba1') + tdSql.checkData(8, 2, "tba1") tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 1.0) - tdSql.checkData(9, 2, 'tba1') + tdSql.checkData(9, 2, "tba1") tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 0.5403023058681398) - tdSql.checkData(10, 2, 'tba1') + tdSql.checkData(10, 2, "tba1") tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) tdSql.checkData(11, 1, -0.4161468365471424) - tdSql.checkData(11, 2, 'tba1') + tdSql.checkData(11, 2, "tba1") tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) tdSql.checkData(12, 1, -0.9899924966004454) - tdSql.checkData(12, 2, 'tba1') + tdSql.checkData(12, 2, "tba1") tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) tdSql.checkData(13, 1, -0.6536436208636119) - tdSql.checkData(13, 2, 'tba1') + tdSql.checkData(13, 2, "tba1") tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) tdSql.checkData(14, 1, 0.28366218546322625) - tdSql.checkData(14, 2, 'tba1') + tdSql.checkData(14, 2, "tba1") tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) tdSql.checkData(15, 1, 0.960170286650366) - tdSql.checkData(15, 2, 'tba1') + tdSql.checkData(15, 2, "tba1") tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) tdSql.checkData(16, 1, 0.7539022543433046) - tdSql.checkData(16, 2, 'tba1') + tdSql.checkData(16, 2, "tba1") tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) tdSql.checkData(17, 1, -0.14550003380861354) - tdSql.checkData(17, 2, 'tba1') + tdSql.checkData(17, 2, "tba1") tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) tdSql.checkData(18, 1, -0.9111302618846769) - tdSql.checkData(18, 2, 'tba1') + tdSql.checkData(18, 2, "tba1") tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 1.0) - tdSql.checkData(19, 2, 'tba1') + tdSql.checkData(19, 2, "tba1") tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 0.5403023058681398) - tdSql.checkData(20, 2, 'tba1') + tdSql.checkData(20, 2, "tba1") tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) tdSql.checkData(21, 1, -0.4161468365471424) - tdSql.checkData(21, 2, 'tba1') + tdSql.checkData(21, 2, "tba1") tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) tdSql.checkData(22, 1, -0.9899924966004454) - tdSql.checkData(22, 2, 'tba1') + tdSql.checkData(22, 2, "tba1") tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) tdSql.checkData(23, 1, -0.6536436208636119) - tdSql.checkData(23, 2, 'tba1') + tdSql.checkData(23, 2, "tba1") tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) tdSql.checkData(24, 1, 0.28366218546322625) - tdSql.checkData(24, 2, 'tba1') + tdSql.checkData(24, 2, "tba1") tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) tdSql.checkData(25, 1, 0.960170286650366) - tdSql.checkData(25, 2, 'tba1') + tdSql.checkData(25, 2, "tba1") tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) tdSql.checkData(26, 1, 0.7539022543433046) - tdSql.checkData(26, 2, 'tba1') + tdSql.checkData(26, 2, "tba1") tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) tdSql.checkData(27, 1, -0.14550003380861354) - tdSql.checkData(27, 2, 'tba1') + tdSql.checkData(27, 2, "tba1") tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) tdSql.checkData(28, 1, -0.9111302618846769) - tdSql.checkData(28, 2, 'tba1') + tdSql.checkData(28, 2, "tba1") tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 1.0) - tdSql.checkData(29, 2, 'tba1') + tdSql.checkData(29, 2, "tba1") - tdSql.query('select cos(elapsed(ts)) from tba1;') + tdSql.query("select cos(elapsed(ts)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.9991271218948251) - tdSql.query('select cos(rate(c2)) from tba1;') + tdSql.query("select cos(rate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.6243073945361602) - tdSql.query('select cos(irate(c2)) from tba1;') + tdSql.query("select cos(irate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.0) - tdSql.query('select cos(first(c2)) from tba1;') + tdSql.query("select cos(first(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.5403023058681398) - tdSql.query('select cos(last(c2)) from tba1;') + tdSql.query("select cos(last(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.0) - tdSql.query('select cos(last_row(c2)) from tba1;') + tdSql.query("select cos(last_row(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.0) - #=========== end math_cos2 ========== + # =========== end math_cos2 ========== - - #=========== begin math_tan ========== - tdSql.query('select tan(13) from tb1;') + # =========== begin math_tan ========== + tdSql.query("select tan(13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.4630211329364896) tdSql.checkData(1, 0, 0.4630211329364896) @@ -9186,7 +9498,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.4630211329364896) tdSql.checkData(6, 0, 0.4630211329364896) - tdSql.query('select tan(c2) from tb1;') + tdSql.query("select tan(c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9196,7 +9508,7 @@ class TDTestCase: tdSql.checkData(5, 0, 4.185891831851989) tdSql.checkData(6, 0, -4.185891831851989) - tdSql.query('select tan(c3) from tb1;') + tdSql.query("select tan(c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9206,7 +9518,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.19089234430221486) tdSql.checkData(6, 0, -0.19089234430221486) - tdSql.query('select tan(c4) from tb1;') + tdSql.query("select tan(c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9216,7 +9528,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1.0523779637351338) tdSql.checkData(6, 0, -1.0523779637351338) - tdSql.query('select tan(c5) from tb1;') + tdSql.query("select tan(c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9226,7 +9538,7 @@ class TDTestCase: tdSql.checkData(5, 0, 84.73931296875567) tdSql.checkData(6, 0, -84.73931296875567) - tdSql.query('select tan(c6) from tb1;') + tdSql.query("select tan(c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9236,7 +9548,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.6117979498342481) tdSql.checkData(6, 0, 0.6117979498342481) - tdSql.query('select tan(c7) from tb1;') + tdSql.query("select tan(c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9246,7 +9558,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1.7884906829818519) tdSql.checkData(6, 0, -1.7884906829818519) - tdSql.query('select tan(c10) from tb1;') + tdSql.query("select tan(c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9256,7 +9568,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.5067147154345417) tdSql.checkData(6, 0, 0.0) - tdSql.query('select tan(c11) from tb1;') + tdSql.query("select tan(c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9266,7 +9578,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.39622301037411284) tdSql.checkData(6, 0, 0.0) - tdSql.query('select tan(c12) from tb1;') + tdSql.query("select tan(c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9276,7 +9588,7 @@ class TDTestCase: tdSql.checkData(5, 0, -19.579238091943036) tdSql.checkData(6, 0, 0.0) - tdSql.query('select tan(c13) from tb1;') + tdSql.query("select tan(c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9286,7 +9598,7 @@ class TDTestCase: tdSql.checkData(5, 0, 84.73931296875567) tdSql.checkData(6, 0, 0.0) - tdSql.query('select tan(a) from (select tan(c2) as a from tb1);') + tdSql.query("select tan(a) from (select tan(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 74.68593339876537) tdSql.checkData(1, 0, None) @@ -9296,7 +9608,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1.7205151938006633) tdSql.checkData(6, 0, -1.7205151938006633) - tdSql.query('select tan(c2 + c3) from tb1;') + tdSql.query("select tan(c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -2.185039863261519) tdSql.checkData(1, 0, None) @@ -9306,7 +9618,7 @@ class TDTestCase: tdSql.checkData(5, 0, 21.780973629229287) tdSql.checkData(6, 0, -21.780973629229287) - tdSql.query('select tan((c2 + c3)) from tb1;') + tdSql.query("select tan((c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -2.185039863261519) tdSql.checkData(1, 0, None) @@ -9316,7 +9628,7 @@ class TDTestCase: tdSql.checkData(5, 0, 21.780973629229287) tdSql.checkData(6, 0, -21.780973629229287) - tdSql.query('select tan((c2 * c3)+c4-6) from tb1;') + tdSql.query("select tan((c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -1.1578212823495775) tdSql.checkData(1, 0, None) @@ -9326,7 +9638,7 @@ class TDTestCase: tdSql.checkData(5, 0, -0.08370895334379919) tdSql.checkData(6, 0, 7.387587307544252) - tdSql.query('select tan(11)+c2 from tb1;') + tdSql.query("select tan(11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, -224.95084645419513) tdSql.checkData(1, 0, None) @@ -9336,7 +9648,7 @@ class TDTestCase: tdSql.checkData(5, 0, -98.95084645419513) tdSql.checkData(6, 0, -352.95084645419513) - tdSql.query('select tan(c2)+11 from tb1;') + tdSql.query("select tan(c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.557407724654903) tdSql.checkData(1, 0, None) @@ -9346,14 +9658,16 @@ class TDTestCase: tdSql.checkData(5, 0, 15.18589183185199) tdSql.checkData(6, 0, 6.814108168148011) - tdSql.query('select tan(c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select tan(c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, -2.185039863261519) tdSql.checkData(1, 0, -6.799711455220379) tdSql.checkData(2, 0, 21.780973629229287) tdSql.checkData(3, 0, -21.780973629229287) - tdSql.query('select tan(c2) from tb1 order by ts desc;') + tdSql.query("select tan(c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -4.185891831851989) tdSql.checkData(1, 0, 4.185891831851989) @@ -9363,7 +9677,7 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.5574077246549023) - tdSql.query('select tan(c2+c3) from tb1 order by ts desc;') + tdSql.query("select tan(c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -21.780973629229287) tdSql.checkData(1, 0, 21.780973629229287) @@ -9373,13 +9687,13 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, -2.185039863261519) - tdSql.query('select tan(c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select tan(c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, -6.799711455220379) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select tan(c2) from stb1;') + tdSql.query("select tan(c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9396,59 +9710,59 @@ class TDTestCase: tdSql.checkData(12, 0, -0.29100619138474915) tdSql.checkData(13, 0, 0.8714479827243188) - tdSql.query('select tan(c2) from stb1 order by ts desc;') + tdSql.query("select tan(c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select tan(c4),t1 from stb1 order by ts desc;') + tdSql.query("select tan(c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select tan(c3),tbname from stb1;') + tdSql.query("select tan(c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5574077246549023) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, -0.1425465430742778) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 1.1578212823495775) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 0.19089234430221486) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, -0.19089234430221486) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1.5574077246549023) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, -2.185039863261519) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, -0.1425465430742778) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 1.1578212823495775) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, -3.380515006246586) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, -0.29100619138474915) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 0.8714479827243188) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select tan(c3),tbname from stb1 where t1 > 1;') + tdSql.query("select tan(c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, -2.185039863261519) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, -0.1425465430742778) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 1.1578212823495775) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, -3.380515006246586) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, -0.29100619138474915) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 0.8714479827243188) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select tan(a) from (select avg(c2) as a from stb1 interval(1s));') + tdSql.query("select tan(a) from (select avg(c2) as a from stb1 interval(1s));") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, -2.185039863261519) @@ -9458,7 +9772,7 @@ class TDTestCase: tdSql.checkData(5, 0, 0.5812976817374548) tdSql.checkData(6, 0, -0.320040389379563) - tdSql.query('select tan(c2) from (select * from stb1);') + tdSql.query("select tan(c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9475,7 +9789,9 @@ class TDTestCase: tdSql.checkData(12, 0, -0.29100619138474915) tdSql.checkData(13, 0, 0.8714479827243188) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null));" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, -2.185039863261519) @@ -9488,7 +9804,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, -2.185039863261519) @@ -9501,7 +9819,9 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by ts desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -9514,7 +9834,9 @@ class TDTestCase: tdSql.checkData(8, 0, -2.185039863261519) tdSql.checkData(9, 0, 1.5574077246549023) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a desc;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, None) tdSql.checkData(1, 0, None) @@ -9527,7 +9849,9 @@ class TDTestCase: tdSql.checkData(8, 0, 1.5574077246549023) tdSql.checkData(9, 0, -0.320040389379563) - tdSql.query("select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;") + tdSql.query( + "select tan(a) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)) order by a;" + ) tdSql.checkRows(10) tdSql.checkData(0, 0, -0.320040389379563) tdSql.checkData(1, 0, 1.5574077246549023) @@ -9540,7 +9864,7 @@ class TDTestCase: tdSql.checkData(8, 0, None) tdSql.checkData(9, 0, None) - tdSql.query('select tan(a) from (select tan(c2) as a from tb1);') + tdSql.query("select tan(a) from (select tan(c2) as a from tb1);") tdSql.checkRows(7) tdSql.checkData(0, 0, 74.68593339876537) tdSql.checkData(1, 0, None) @@ -9550,7 +9874,7 @@ class TDTestCase: tdSql.checkData(5, 0, 1.7205151938006633) tdSql.checkData(6, 0, -1.7205151938006633) - tdSql.query('select tan(tb1.c3),tan(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;') + tdSql.query("select tan(tb1.c3),tan(tb2.c3) from tb1,tb2 where tb1.ts=tb2.ts;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(0, 1, 1.5574077246549023) @@ -9567,7 +9891,7 @@ class TDTestCase: tdSql.checkData(6, 0, -0.19089234430221486) tdSql.checkData(6, 1, 0.8714479827243188) - tdSql.query('select tan(c3) from tb1 union all select tan(c3) from tb2;') + tdSql.query("select tan(c3) from tb1 union all select tan(c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9584,11 +9908,12 @@ class TDTestCase: tdSql.checkData(12, 0, -0.29100619138474915) tdSql.checkData(13, 0, 0.8714479827243188) - #=========== end math_tan ========== - + # =========== end math_tan ========== - #=========== begin math_tan2 ========== - tdSql.query('select tan(stb1.c4),tan(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;') + # =========== begin math_tan2 ========== + tdSql.query( + "select tan(stb1.c4),tan(stba.c5) from stb1,stba where stb1.t1=stba.t1 and stb1.ts=stba.ts;" + ) tdSql.checkRows(7) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(0, 1, 1.5574077246549023) @@ -9605,7 +9930,9 @@ class TDTestCase: tdSql.checkData(6, 0, -1.0523779637351338) tdSql.checkData(6, 1, 0.8714479827243188) - tdSql.query('select tan(c4) as a from stb1 union all select tan(c5) as a from stba;') + tdSql.query( + "select tan(c4) as a from stb1 union all select tan(c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, None) @@ -9652,7 +9979,7 @@ class TDTestCase: tdSql.checkData(42, 0, -0.45231565944180985) tdSql.checkData(43, 0, 0.0) - tdSql.query('select tan(c2) from stba;') + tdSql.query("select tan(c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 1.5574077246549023) tdSql.checkData(1, 0, -2.185039863261519) @@ -9685,47 +10012,47 @@ class TDTestCase: tdSql.checkData(28, 0, -0.45231565944180985) tdSql.checkData(29, 0, 0.0) - tdSql.query('select tan(min(c2)) from tba1;') + tdSql.query("select tan(min(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select tan(max(c2)) from tba1;') + tdSql.query("select tan(max(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.45231565944180985) - tdSql.query('select tan(count(c2)) from tba1;') + tdSql.query("select tan(count(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -6.405331196646276) - tdSql.query('select tan(sum(c2)) from tba1;') + tdSql.query("select tan(sum(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.08871575677006045) - tdSql.query('select tan(avg(c2)) from tba1;') + tdSql.query("select tan(avg(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 4.637332054551185) - tdSql.query('select tan(percentile(c2, 10)) from tba1;') + tdSql.query("select tan(percentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.260158217550339) - tdSql.query('select tan(apercentile(c2, 10)) from tba1;') + tdSql.query("select tan(apercentile(c2, 10)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select tan(stddev(c2)) from tba1;') + tdSql.query("select tan(stddev(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.27601685866292947) - tdSql.query('select tan(spread(c2)) from tba1;') + tdSql.query("select tan(spread(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.45231565944180985) - tdSql.query('select tan(twa(c2)) from tba1;') + tdSql.query("select tan(twa(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 13.40557155176672) - tdSql.query('select tan(interp(c2)) from tba1 every(1s)') + tdSql.query("select tan(interp(c2)) from tba1 every(1s)") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 1.5574077246549023) @@ -9788,148 +10115,147 @@ class TDTestCase: tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0.0) - tdSql.query('select tan(interp(c2)) from stba every(1s) group by tbname;') + tdSql.query("select tan(interp(c2)) from stba every(1s) group by tbname;") tdSql.checkRows(30) tdSql.checkData(0, 0, datetime.datetime(2021, 11, 11, 9, 0)) tdSql.checkData(0, 1, 1.5574077246549023) - tdSql.checkData(0, 2, 'tba1') + tdSql.checkData(0, 2, "tba1") tdSql.checkData(1, 0, datetime.datetime(2021, 11, 11, 9, 0, 1)) tdSql.checkData(1, 1, -2.185039863261519) - tdSql.checkData(1, 2, 'tba1') + tdSql.checkData(1, 2, "tba1") tdSql.checkData(2, 0, datetime.datetime(2021, 11, 11, 9, 0, 2)) tdSql.checkData(2, 1, -0.1425465430742778) - tdSql.checkData(2, 2, 'tba1') + tdSql.checkData(2, 2, "tba1") tdSql.checkData(3, 0, datetime.datetime(2021, 11, 11, 9, 0, 3)) tdSql.checkData(3, 1, 1.1578212823495775) - tdSql.checkData(3, 2, 'tba1') + tdSql.checkData(3, 2, "tba1") tdSql.checkData(4, 0, datetime.datetime(2021, 11, 11, 9, 0, 4)) tdSql.checkData(4, 1, -3.380515006246586) - tdSql.checkData(4, 2, 'tba1') + tdSql.checkData(4, 2, "tba1") tdSql.checkData(5, 0, datetime.datetime(2021, 11, 11, 9, 0, 5)) tdSql.checkData(5, 1, -0.29100619138474915) - tdSql.checkData(5, 2, 'tba1') + tdSql.checkData(5, 2, "tba1") tdSql.checkData(6, 0, datetime.datetime(2021, 11, 11, 9, 0, 6)) tdSql.checkData(6, 1, 0.8714479827243188) - tdSql.checkData(6, 2, 'tba1') + tdSql.checkData(6, 2, "tba1") tdSql.checkData(7, 0, datetime.datetime(2021, 11, 11, 9, 0, 7)) tdSql.checkData(7, 1, -6.799711455220379) - tdSql.checkData(7, 2, 'tba1') + tdSql.checkData(7, 2, "tba1") tdSql.checkData(8, 0, datetime.datetime(2021, 11, 11, 9, 0, 8)) tdSql.checkData(8, 1, -0.45231565944180985) - tdSql.checkData(8, 2, 'tba1') + tdSql.checkData(8, 2, "tba1") tdSql.checkData(9, 0, datetime.datetime(2021, 11, 11, 9, 0, 9)) tdSql.checkData(9, 1, 0.0) - tdSql.checkData(9, 2, 'tba1') + tdSql.checkData(9, 2, "tba1") tdSql.checkData(10, 0, datetime.datetime(2021, 11, 11, 9, 0, 10)) tdSql.checkData(10, 1, 1.5574077246549023) - tdSql.checkData(10, 2, 'tba1') + tdSql.checkData(10, 2, "tba1") tdSql.checkData(11, 0, datetime.datetime(2021, 11, 11, 9, 0, 11)) tdSql.checkData(11, 1, -2.185039863261519) - tdSql.checkData(11, 2, 'tba1') + tdSql.checkData(11, 2, "tba1") tdSql.checkData(12, 0, datetime.datetime(2021, 11, 11, 9, 0, 12)) tdSql.checkData(12, 1, -0.1425465430742778) - tdSql.checkData(12, 2, 'tba1') + tdSql.checkData(12, 2, "tba1") tdSql.checkData(13, 0, datetime.datetime(2021, 11, 11, 9, 0, 13)) tdSql.checkData(13, 1, 1.1578212823495775) - tdSql.checkData(13, 2, 'tba1') + tdSql.checkData(13, 2, "tba1") tdSql.checkData(14, 0, datetime.datetime(2021, 11, 11, 9, 0, 14)) tdSql.checkData(14, 1, -3.380515006246586) - tdSql.checkData(14, 2, 'tba1') + tdSql.checkData(14, 2, "tba1") tdSql.checkData(15, 0, datetime.datetime(2021, 11, 11, 9, 0, 15)) tdSql.checkData(15, 1, -0.29100619138474915) - tdSql.checkData(15, 2, 'tba1') + tdSql.checkData(15, 2, "tba1") tdSql.checkData(16, 0, datetime.datetime(2021, 11, 11, 9, 0, 16)) tdSql.checkData(16, 1, 0.8714479827243188) - tdSql.checkData(16, 2, 'tba1') + tdSql.checkData(16, 2, "tba1") tdSql.checkData(17, 0, datetime.datetime(2021, 11, 11, 9, 0, 17)) tdSql.checkData(17, 1, -6.799711455220379) - tdSql.checkData(17, 2, 'tba1') + tdSql.checkData(17, 2, "tba1") tdSql.checkData(18, 0, datetime.datetime(2021, 11, 11, 9, 0, 18)) tdSql.checkData(18, 1, -0.45231565944180985) - tdSql.checkData(18, 2, 'tba1') + tdSql.checkData(18, 2, "tba1") tdSql.checkData(19, 0, datetime.datetime(2021, 11, 11, 9, 0, 19)) tdSql.checkData(19, 1, 0.0) - tdSql.checkData(19, 2, 'tba1') + tdSql.checkData(19, 2, "tba1") tdSql.checkData(20, 0, datetime.datetime(2021, 11, 11, 9, 0, 20)) tdSql.checkData(20, 1, 1.5574077246549023) - tdSql.checkData(20, 2, 'tba1') + tdSql.checkData(20, 2, "tba1") tdSql.checkData(21, 0, datetime.datetime(2021, 11, 11, 9, 0, 21)) tdSql.checkData(21, 1, -2.185039863261519) - tdSql.checkData(21, 2, 'tba1') + tdSql.checkData(21, 2, "tba1") tdSql.checkData(22, 0, datetime.datetime(2021, 11, 11, 9, 0, 22)) tdSql.checkData(22, 1, -0.1425465430742778) - tdSql.checkData(22, 2, 'tba1') + tdSql.checkData(22, 2, "tba1") tdSql.checkData(23, 0, datetime.datetime(2021, 11, 11, 9, 0, 23)) tdSql.checkData(23, 1, 1.1578212823495775) - tdSql.checkData(23, 2, 'tba1') + tdSql.checkData(23, 2, "tba1") tdSql.checkData(24, 0, datetime.datetime(2021, 11, 11, 9, 0, 24)) tdSql.checkData(24, 1, -3.380515006246586) - tdSql.checkData(24, 2, 'tba1') + tdSql.checkData(24, 2, "tba1") tdSql.checkData(25, 0, datetime.datetime(2021, 11, 11, 9, 0, 25)) tdSql.checkData(25, 1, -0.29100619138474915) - tdSql.checkData(25, 2, 'tba1') + tdSql.checkData(25, 2, "tba1") tdSql.checkData(26, 0, datetime.datetime(2021, 11, 11, 9, 0, 26)) tdSql.checkData(26, 1, 0.8714479827243188) - tdSql.checkData(26, 2, 'tba1') + tdSql.checkData(26, 2, "tba1") tdSql.checkData(27, 0, datetime.datetime(2021, 11, 11, 9, 0, 27)) tdSql.checkData(27, 1, -6.799711455220379) - tdSql.checkData(27, 2, 'tba1') + tdSql.checkData(27, 2, "tba1") tdSql.checkData(28, 0, datetime.datetime(2021, 11, 11, 9, 0, 28)) tdSql.checkData(28, 1, -0.45231565944180985) - tdSql.checkData(28, 2, 'tba1') + tdSql.checkData(28, 2, "tba1") tdSql.checkData(29, 0, datetime.datetime(2021, 11, 11, 9, 0, 29)) tdSql.checkData(29, 1, 0.0) - tdSql.checkData(29, 2, 'tba1') + tdSql.checkData(29, 2, "tba1") - tdSql.query('select tan(elapsed(ts)) from tba1;') + tdSql.query("select tan(elapsed(ts)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.04180962355791556) - tdSql.query('select tan(rate(c2)) from tba1;') + tdSql.query("select tan(rate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.2512726598331747) - tdSql.query('select tan(irate(c2)) from tba1;') + tdSql.query("select tan(irate(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select tan(first(c2)) from tba1;') + tdSql.query("select tan(first(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 1.5574077246549023) - tdSql.query('select tan(last(c2)) from tba1;') + tdSql.query("select tan(last(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select tan(last_row(c2)) from tba1;') + tdSql.query("select tan(last_row(c2)) from tba1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - #=========== end math_tan2 ========== + # =========== end math_tan2 ========== - - #=========== begin math_pow ========== - tdSql.query('select pow(c2,13) from tb1;') + # =========== begin math_pow ========== + tdSql.query("select pow(c2,13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 8192.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 67108864.0) - tdSql.checkData(5, 0, 2.235879388560037e+27) - tdSql.checkData(6, 0, -2.235879388560037e+27) + tdSql.checkData(5, 0, 2.235879388560037e27) + tdSql.checkData(6, 0, -2.235879388560037e27) - tdSql.query('select pow(c2,c2) from tb1;') + tdSql.query("select pow(c2,c2) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 4.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 256.0) - tdSql.checkData(5, 0, 1.5243074119957227e+267) + tdSql.checkData(5, 0, 1.5243074119957227e267) tdSql.checkData(6, 0, -6.560356474884124e-268) - tdSql.query('select pow(c2,c3) from tb1;') + tdSql.query("select pow(c2,c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -9939,7 +10265,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, -0.0) - tdSql.query('select pow(c2,c4) from tb1;') + tdSql.query("select pow(c2,c4) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -9949,7 +10275,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, -0.0) - tdSql.query('select pow(c2,c5) from tb1;') + tdSql.query("select pow(c2,c5) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -9959,7 +10285,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,c6) from tb1;') + tdSql.query("select pow(c2,c6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -9969,7 +10295,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,c7) from tb1;') + tdSql.query("select pow(c2,c7) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -9979,7 +10305,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,c10) from tb1;') + tdSql.query("select pow(c2,c10) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -9989,7 +10315,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c11) from tb1;') + tdSql.query("select pow(c2,c11) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -9999,7 +10325,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c12) from tb1;') + tdSql.query("select pow(c2,c12) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -10009,7 +10335,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c13) from tb1;') + tdSql.query("select pow(c2,c13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -10019,7 +10345,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c2 + c3) from tb1;') + tdSql.query("select pow(c2,c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -10029,7 +10355,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,(c2 + c3)) from tb1;') + tdSql.query("select pow(c2,(c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -10039,7 +10365,7 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,(c2 * c3)+c4-6) from tb1;') + tdSql.query("select pow(c2,(c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -10049,44 +10375,46 @@ class TDTestCase: tdSql.checkData(5, 0, inf) tdSql.checkData(6, 0, 0.0) - tdSql.query('select pow(c2,11)+c2 from tb1;') + tdSql.query("select pow(c2,11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 2.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 2050.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 4194308.0) - tdSql.checkData(5, 0, 1.3862479934032099e+23) - tdSql.checkData(6, 0, -1.3862479934032099e+23) + tdSql.checkData(5, 0, 1.3862479934032099e23) + tdSql.checkData(6, 0, -1.3862479934032099e23) - tdSql.query('select pow(c2,c2)+11 from tb1;') + tdSql.query("select pow(c2,c2)+11 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 12.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 15.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 267.0) - tdSql.checkData(5, 0, 1.5243074119957227e+267) + tdSql.checkData(5, 0, 1.5243074119957227e267) tdSql.checkData(6, 0, 11.0) - tdSql.query('select pow(c2,c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select pow(c2,c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 65536.0) tdSql.checkData(2, 0, inf) tdSql.checkData(3, 0, 0.0) - tdSql.query('select pow(c2,c2) from tb1 order by ts desc;') + tdSql.query("select pow(c2,c2) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, -6.560356474884124e-268) - tdSql.checkData(1, 0, 1.5243074119957227e+267) + tdSql.checkData(1, 0, 1.5243074119957227e267) tdSql.checkData(2, 0, 256.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 4.0) tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c2+c3) from tb1 order by ts desc;') + tdSql.query("select pow(c2,c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, inf) @@ -10096,20 +10424,20 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 1.0) - tdSql.query('select pow(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select pow(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 65536.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select pow(c2,c2) from stb1;') + tdSql.query("select pow(c2,c2) from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 4.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 256.0) - tdSql.checkData(5, 0, 1.5243074119957227e+267) + tdSql.checkData(5, 0, 1.5243074119957227e267) tdSql.checkData(6, 0, -6.560356474884124e-268) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 4.0) @@ -10119,66 +10447,66 @@ class TDTestCase: tdSql.checkData(12, 0, 46656.0) tdSql.checkData(13, 0, 823543.0) - tdSql.query('select pow(c2,c2) from stb1 order by ts desc;') + tdSql.query("select pow(c2,c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select pow(c2,c4),t1 from stb1 order by ts desc;') + tdSql.query("select pow(c2,c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select pow(c2,c3),tbname from stb1;') + tdSql.query("select pow(c2,c3),tbname from stb1;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 256.0) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, inf) - tdSql.checkData(5, 1, 'tb1') + tdSql.checkData(5, 1, "tb1") tdSql.checkData(6, 0, -0.0) - tdSql.checkData(6, 1, 'tb1') + tdSql.checkData(6, 1, "tb1") tdSql.checkData(7, 0, 1.0) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 4.0) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 27.0) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 256.0) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 3125.0) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 46656.0) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 823543.0) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select pow(c2,c3),tbname from stb1 where t1 > 1;') + tdSql.query("select pow(c2,c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 4.0) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 27.0) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 256.0) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 3125.0) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 46656.0) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 823543.0) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select pow(c2,c2) from (select * from stb1);') + tdSql.query("select pow(c2,c2) from (select * from stb1);") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 4.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 256.0) - tdSql.checkData(5, 0, 1.5243074119957227e+267) + tdSql.checkData(5, 0, 1.5243074119957227e267) tdSql.checkData(6, 0, -6.560356474884124e-268) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 4.0) @@ -10188,7 +10516,7 @@ class TDTestCase: tdSql.checkData(12, 0, 46656.0) tdSql.checkData(13, 0, 823543.0) - tdSql.query('select pow(c2,c3) from tb1 union all select pow(c2,c3) from tb2;') + tdSql.query("select pow(c2,c3) from tb1 union all select pow(c2,c3) from tb2;") tdSql.checkRows(14) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -10205,11 +10533,12 @@ class TDTestCase: tdSql.checkData(12, 0, 46656.0) tdSql.checkData(13, 0, 823543.0) - #=========== end math_pow ========== - + # =========== end math_pow ========== - #=========== begin math_pow2 ========== - tdSql.query('select pow(c2,c4) as a from stb1 union all select pow(c2,c5) as a from stba;') + # =========== begin math_pow2 ========== + tdSql.query( + "select pow(c2,c4) as a from stb1 union all select pow(c2,c5) as a from stba;" + ) tdSql.checkRows(44) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -10256,7 +10585,7 @@ class TDTestCase: tdSql.checkData(42, 0, 387420489.0) tdSql.checkData(43, 0, 1.0) - tdSql.query('select pow(c2,c2) from stba;') + tdSql.query("select pow(c2,c2) from stba;") tdSql.checkRows(30) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 4.0) @@ -10289,11 +10618,10 @@ class TDTestCase: tdSql.checkData(28, 0, 387420489.0) tdSql.checkData(29, 0, 1.0) - #=========== end math_pow2 ========== + # =========== end math_pow2 ========== - - #=========== begin math_log ========== - tdSql.query('select log(c2,13) from tb1;') + # =========== begin math_log ========== + tdSql.query("select log(c2,13) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) @@ -10301,109 +10629,109 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 0.5404763088546395) tdSql.checkData(5, 0, 1.8886092516277813) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2) from tb1;') + tdSql.query("select log(c2,c2) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 1.0) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c3) from tb1;') + tdSql.query("select log(c2,c3) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.465913680008469) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c4) from tb1;') + tdSql.query("select log(c2,c4) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.22544144151366513) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c5) from tb1;') + tdSql.query("select log(c2,c5) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.11093150296463757) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c6) from tb1;') + tdSql.query("select log(c2,c6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.05459909915208762) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c7) from tb1;') + tdSql.query("select log(c2,c7) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.006824887406193638) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c10) from tb1;') + tdSql.query("select log(c2,c10) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.8748229478056855) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c11) from tb1;') + tdSql.query("select log(c2,c11) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.4367939948774267) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c12) from tb1;') + tdSql.query("select log(c2,c12) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.2183963964662152) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c13) from tb1;') + tdSql.query("select log(c2,c13) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.11093150296463757) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2 + c3) from tb1;') + tdSql.query("select log(c2,c2 + c3) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) @@ -10411,9 +10739,9 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 0.6666666666666667) tdSql.checkData(5, 0, 0.4657403972991969) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,(c2 + c3)) from tb1;') + tdSql.query("select log(c2,(c2 + c3)) from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, None) @@ -10421,19 +10749,19 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 0.6666666666666667) tdSql.checkData(5, 0, 0.4657403972991969) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,(c2 * c3)+c4-6) from tb1;') + tdSql.query("select log(c2,(c2 * c3)+c4-6) from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 0.5252990700743871) tdSql.checkData(5, 0, 0.22542113212116985) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,11)+c2 from tb1;') + tdSql.query("select log(c2,11)+c2 from tb1;") tdSql.checkRows(7) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, None) @@ -10441,38 +10769,40 @@ class TDTestCase: tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 4.578129652635775) tdSql.checkData(5, 0, 129.02018292517226) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2)+11 from tb1;') + tdSql.query("select log(c2,c2)+11 from tb1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 12.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 12.0) tdSql.checkData(5, 0, 12.0) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2+c3) from tb1 where c2 is not null and c3 is not null;') + tdSql.query( + "select log(c2,c2+c3) from tb1 where c2 is not null and c3 is not null;" + ) tdSql.checkRows(4) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, 0.6666666666666667) tdSql.checkData(2, 0, 0.4657403972991969) - tdSql.checkData(3, 0, None) + tdSql.checkData(3, 0, nan) - tdSql.query('select log(c2,c2) from tb1 order by ts desc;') + tdSql.query("select log(c2,c2) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 1.0) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, None) - tdSql.checkData(6, 0, None) + tdSql.checkData(6, 0, nan) - tdSql.query('select log(c2,c2+c3) from tb1 order by ts desc;') + tdSql.query("select log(c2,c2+c3) from tb1 order by ts desc;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 0.4657403972991969) tdSql.checkData(2, 0, 0.6666666666666667) tdSql.checkData(3, 0, None) @@ -10480,22 +10810,22 @@ class TDTestCase: tdSql.checkData(5, 0, None) tdSql.checkData(6, 0, 0.0) - tdSql.query('select log(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2;') + tdSql.query("select log(c2,c2+c3) from tb1 order by ts desc limit 3 offset 2;") tdSql.checkRows(3) tdSql.checkData(0, 0, 0.6666666666666667) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) - tdSql.query('select log(c2,c2) from stb1;') + tdSql.query("select log(c2,c2) from stb1;") tdSql.checkRows(14) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 1.0) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 1.0) tdSql.checkData(10, 0, 1.0) @@ -10503,68 +10833,68 @@ class TDTestCase: tdSql.checkData(12, 0, 1.0) tdSql.checkData(13, 0, 1.0) - tdSql.query('select log(c2,c2) from stb1 order by ts desc;') + tdSql.query("select log(c2,c2) from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select log(c2,c4),t1 from stb1 order by ts desc;') + tdSql.query("select log(c2,c4),t1 from stb1 order by ts desc;") tdSql.checkRows(14) - tdSql.query('select log(c2,c3),tbname from stb1;') + tdSql.query("select log(c2,c3),tbname from stb1;") tdSql.checkRows(14) - tdSql.checkData(0, 0, None) - tdSql.checkData(0, 1, 'tb1') + tdSql.checkData(0, 0, nan) + tdSql.checkData(0, 1, "tb1") tdSql.checkData(1, 0, None) - tdSql.checkData(1, 1, 'tb1') + tdSql.checkData(1, 1, "tb1") tdSql.checkData(2, 0, None) - tdSql.checkData(2, 1, 'tb1') + tdSql.checkData(2, 1, "tb1") tdSql.checkData(3, 0, None) - tdSql.checkData(3, 1, 'tb1') + tdSql.checkData(3, 1, "tb1") tdSql.checkData(4, 0, 1.0) - tdSql.checkData(4, 1, 'tb1') + tdSql.checkData(4, 1, "tb1") tdSql.checkData(5, 0, 0.465913680008469) - tdSql.checkData(5, 1, 'tb1') - tdSql.checkData(6, 0, None) - tdSql.checkData(6, 1, 'tb1') - tdSql.checkData(7, 0, None) - tdSql.checkData(7, 1, 'tb2') + tdSql.checkData(5, 1, "tb1") + tdSql.checkData(6, 0, nan) + tdSql.checkData(6, 1, "tb1") + tdSql.checkData(7, 0, nan) + tdSql.checkData(7, 1, "tb2") tdSql.checkData(8, 0, 1.0) - tdSql.checkData(8, 1, 'tb2') + tdSql.checkData(8, 1, "tb2") tdSql.checkData(9, 0, 1.0) - tdSql.checkData(9, 1, 'tb2') + tdSql.checkData(9, 1, "tb2") tdSql.checkData(10, 0, 1.0) - tdSql.checkData(10, 1, 'tb2') + tdSql.checkData(10, 1, "tb2") tdSql.checkData(11, 0, 1.0) - tdSql.checkData(11, 1, 'tb2') + tdSql.checkData(11, 1, "tb2") tdSql.checkData(12, 0, 1.0) - tdSql.checkData(12, 1, 'tb2') + tdSql.checkData(12, 1, "tb2") tdSql.checkData(13, 0, 1.0) - tdSql.checkData(13, 1, 'tb2') + tdSql.checkData(13, 1, "tb2") - tdSql.query('select log(c2,c3),tbname from stb1 where t1 > 1;') + tdSql.query("select log(c2,c3),tbname from stb1 where t1 > 1;") tdSql.checkRows(7) - tdSql.checkData(0, 0, None) - tdSql.checkData(0, 1, 'tb2') + tdSql.checkData(0, 0, nan) + tdSql.checkData(0, 1, "tb2") tdSql.checkData(1, 0, 1.0) - tdSql.checkData(1, 1, 'tb2') + tdSql.checkData(1, 1, "tb2") tdSql.checkData(2, 0, 1.0) - tdSql.checkData(2, 1, 'tb2') + tdSql.checkData(2, 1, "tb2") tdSql.checkData(3, 0, 1.0) - tdSql.checkData(3, 1, 'tb2') + tdSql.checkData(3, 1, "tb2") tdSql.checkData(4, 0, 1.0) - tdSql.checkData(4, 1, 'tb2') + tdSql.checkData(4, 1, "tb2") tdSql.checkData(5, 0, 1.0) - tdSql.checkData(5, 1, 'tb2') + tdSql.checkData(5, 1, "tb2") tdSql.checkData(6, 0, 1.0) - tdSql.checkData(6, 1, 'tb2') + tdSql.checkData(6, 1, "tb2") - tdSql.query('select log(c2,c2) from (select * from stb1);') + tdSql.query("select log(c2,c2) from (select * from stb1);") tdSql.checkRows(14) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 1.0) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 1.0) tdSql.checkData(10, 0, 1.0) @@ -10572,16 +10902,16 @@ class TDTestCase: tdSql.checkData(12, 0, 1.0) tdSql.checkData(13, 0, 1.0) - tdSql.query('select log(c2,c3) from tb1 union all select log(c2,c3) from tb2;') + tdSql.query("select log(c2,c3) from tb1 union all select log(c2,c3) from tb2;") tdSql.checkRows(14) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, None) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.465913680008469) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 1.0) tdSql.checkData(10, 0, 1.0) @@ -10589,27 +10919,28 @@ class TDTestCase: tdSql.checkData(12, 0, 1.0) tdSql.checkData(13, 0, 1.0) - #=========== end math_log ========== - + # =========== end math_log ========== - #=========== begin math_log2 ========== - tdSql.query('select log(c2,c4) as a from stb1 union all select log(c2,c5) as a from stba;') + # =========== begin math_log2 ========== + tdSql.query( + "select log(c2,c4) as a from stb1 union all select log(c2,c5) as a from stba;" + ) tdSql.checkRows(44) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, None) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, None) tdSql.checkData(4, 0, 1.0) tdSql.checkData(5, 0, 0.22544144151366513) - tdSql.checkData(6, 0, None) - tdSql.checkData(7, 0, None) + tdSql.checkData(6, 0, nan) + tdSql.checkData(7, 0, nan) tdSql.checkData(8, 0, 1.0) tdSql.checkData(9, 0, 1.5849625007211563) tdSql.checkData(10, 0, 1.0) tdSql.checkData(11, 0, 1.0) tdSql.checkData(12, 0, 1.0) tdSql.checkData(13, 0, 1.0) - tdSql.checkData(14, 0, None) + tdSql.checkData(14, 0, nan) tdSql.checkData(15, 0, 1.0) tdSql.checkData(16, 0, 1.0) tdSql.checkData(17, 0, 1.0) @@ -10618,8 +10949,8 @@ class TDTestCase: tdSql.checkData(20, 0, 1.0) tdSql.checkData(21, 0, 1.0) tdSql.checkData(22, 0, 1.0) - tdSql.checkData(23, 0, None) - tdSql.checkData(24, 0, None) + tdSql.checkData(23, 0, nan) + tdSql.checkData(24, 0, nan) tdSql.checkData(25, 0, 1.0) tdSql.checkData(26, 0, 1.0) tdSql.checkData(27, 0, 1.0) @@ -10628,8 +10959,8 @@ class TDTestCase: tdSql.checkData(30, 0, 1.0) tdSql.checkData(31, 0, 1.0) tdSql.checkData(32, 0, 1.0) - tdSql.checkData(33, 0, None) - tdSql.checkData(34, 0, None) + tdSql.checkData(33, 0, nan) + tdSql.checkData(34, 0, nan) tdSql.checkData(35, 0, 1.0) tdSql.checkData(36, 0, 1.0) tdSql.checkData(37, 0, 1.0) @@ -10638,11 +10969,11 @@ class TDTestCase: tdSql.checkData(40, 0, 1.0) tdSql.checkData(41, 0, 1.0) tdSql.checkData(42, 0, 1.0) - tdSql.checkData(43, 0, None) + tdSql.checkData(43, 0, nan) - tdSql.query('select log(c2,c2) from stba;') + tdSql.query("select log(c2,c2) from stba;") tdSql.checkRows(30) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 1.0) tdSql.checkData(2, 0, 1.0) tdSql.checkData(3, 0, 1.0) @@ -10651,8 +10982,8 @@ class TDTestCase: tdSql.checkData(6, 0, 1.0) tdSql.checkData(7, 0, 1.0) tdSql.checkData(8, 0, 1.0) - tdSql.checkData(9, 0, None) - tdSql.checkData(10, 0, None) + tdSql.checkData(9, 0, nan) + tdSql.checkData(10, 0, nan) tdSql.checkData(11, 0, 1.0) tdSql.checkData(12, 0, 1.0) tdSql.checkData(13, 0, 1.0) @@ -10661,8 +10992,8 @@ class TDTestCase: tdSql.checkData(16, 0, 1.0) tdSql.checkData(17, 0, 1.0) tdSql.checkData(18, 0, 1.0) - tdSql.checkData(19, 0, None) - tdSql.checkData(20, 0, None) + tdSql.checkData(19, 0, nan) + tdSql.checkData(20, 0, nan) tdSql.checkData(21, 0, 1.0) tdSql.checkData(22, 0, 1.0) tdSql.checkData(23, 0, 1.0) @@ -10671,16 +11002,16 @@ class TDTestCase: tdSql.checkData(26, 0, 1.0) tdSql.checkData(27, 0, 1.0) tdSql.checkData(28, 0, 1.0) - tdSql.checkData(29, 0, None) + tdSql.checkData(29, 0, nan) - #=========== end math_log2 ========== + # =========== end math_log2 ========== + tdSql.execute("drop database math_funcs") - - tdSql.execute('drop database math_funcs') def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) + tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/2-query/nchar_funcs.py b/tests/develop-test/2-query/nchar_funcs.py new file mode 100644 index 0000000000000000000000000000000000000000..9bb5aeb1d0a13277aba3996f2c34bf4746a6f44d --- /dev/null +++ b/tests/develop-test/2-query/nchar_funcs.py @@ -0,0 +1,462 @@ +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from math import inf + +class TDTestCase: + def caseDescription(self): + ''' + case1: nchar bugs on outer query, order by ts in outer query, and ucs4 mbs conversion + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def restartTaosd(self, index=1, dbname="db"): + tdDnodes.stop(index) + tdDnodes.startWithoutSleep(index) + tdSql.execute(f"use nchardb") + + def run(self): + print("running {}".format(__file__)) + tdSql.execute("drop database if exists nchardb") + tdSql.execute("create database if not exists nchardb") + tdSql.execute('use nchardb') + + + + tdSql.execute('create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) , q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);') + + tdSql.execute('create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) , q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);') + + tdSql.execute('create stable stable_null_data (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) , q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);') + + tdSql.execute('create stable stable_null_childtable (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) , q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);') + + tdSql.execute("create table stable_1_1 using stable_1 tags('stable_1_1', '0' , '0' , '0' , '0' , 0 , 'binary1' , 'nchar1' , '0' , '0' ,'0') ;") + + tdSql.execute("create table stable_1_2 using stable_1 tags('stable_1_2', '2147483647' , '9223372036854775807' , '32767' , '127' , 1 , 'binary2' , 'nchar2' , '2' , '22' , '1999-09-09 09:09:09.090') ;") + + tdSql.execute("create table stable_1_3 using stable_1 tags('stable_1_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , '2099-09-09 09:09:09.090') ;") + + tdSql.execute("create table stable_1_4 using stable_1 tags('stable_1_4', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;") + + tdSql.execute("create table stable_2_1 using stable_2 tags('stable_2_1' , '0' , '0' , '0' , '0' , 0 , 'binary21' , 'nchar21' , '0' , '0' ,'0') ;") + + tdSql.execute("create table stable_2_2 using stable_2 tags('stable_2_2' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;") + + tdSql.execute("create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;") + + tdSql.execute('create table regular_table_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) , q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;') + + tdSql.execute('create table regular_table_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) , q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;') + + tdSql.execute('create table regular_table_3 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) , q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;') + + tdSql.execute('create table regular_table_null (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_binary1 binary(100) , q_nchar1 nchar(100) ,q_binary2 binary(100) , q_nchar2 nchar(100) ,q_binary3 binary(100) , q_nchar3 nchar(100) ,q_binary4 binary(100) , q_nchar4 nchar(100) , q_binary5 binary(100) , q_nchar5 nchar(100) ,q_binary6 binary(100) , q_nchar6 nchar(100) ,q_binary7 binary(100) , q_nchar7 nchar(100) ,q_binary8 binary(100) , q_nchar8 nchar(100) , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;') + + tdSql.execute("insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000000, -439727522, 612301787638826993, 9533, -97, 3516.375596, -63.596320, 0, 'binary.PIhHdeegEoHadxQpLAQI', 'nchar.福建省辽阳县丰都熊街u座 233621', 1630000000000, 'binary1.JgnEFSLkRtzEQOZsUibN', 'nchar1.福建省宜都县海港王街M座 713195', 'binary2.tsCyNVyBJDCnIvUdjVev', 'nchar2.宁夏回族自治区兰州市淄川香港路Y座 213761', 'binary3.AlZhLGOLRoWDRvqbsWfC', 'nchar3.海南省静市江北海口路X座 702375', 'binary4.NdciuKObKZYwDVhtIOgB', 'nchar4.四川省桂荣市滨城林街m座 503259', 'binary5.BUEJHkTvXfstJGArxcBz', 'nchar5.贵州省大冶县滨城梧州街P座 554324', 'binary6.ArgeExOkcjzjHDtyQARL', 'nchar6.山东省建华市魏都南京街o座 326153', 'binary7.QvDuzpiSJhpNBmQKHeWb', 'nchar7.湖北省桂芳市高明邯郸路q座 413345', 'binary8.WglkhUkXHcTYoWgshnnp', 'nchar8.内蒙古自治区太原县萧山王路p座 322176') ;") + + tdSql.execute("insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000000, -1927728216, -6011044987062918899, 21730, 55, -379272379409.344971, 202621.613403, 0, 'binary.mgOAjgCfpIKVvJcFNMOc', 'nchar.上海市彬市丰都王路e座 634384', 1630000000000, 'binary1.cSVybMOLDLDvyNSJbRrc', 'nchar1.天津市潮州县金平胡街m座 378486', 'binary2.bdYIDYtteQeyjJkksUGK', 'nchar2.黑龙江省帅市崇文沈阳路Y座 103751', 'binary3.azSbzOjOyaUCFOTIsgHG', 'nchar3.河北省成都市东丽李街k座 303784', 'binary4.ohUNyPlQqkiMzpeTyOWS', 'nchar4.江苏省俊县西夏辛集街U座 593642', 'binary5.ENaKrNBgrArvKrFVzzlr', 'nchar5.北京市澳门县闵行杭州街L座 506999', 'binary6.VOHdDIsQoSrmQChGJvNB', 'nchar6.山西省敏县新城成都街b座 364960', 'binary7.SBvUJKRslUvmfsqGTtNO', 'nchar7.浙江省深圳市大东李路m座 882995', 'binary8.fcjjRXqwaSllnpvnvkYn', 'nchar8.云南省帅县城北香港街E座 477480') ;") + + tdSql.execute("insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000000, 896032926, 6023643830222415811, 21936, 49, -3817.697182, -641551013002.837036, 1, 'binary.qjCLjIApCPmxDrPLinCu', 'nchar.安徽省洁县翔安南宁路q座 420885', 1630000000000, 'binary1.cGMsWYzwmvbENGnODINP', 'nchar1.陕西省惠州县城东郑州街a座 702479', 'binary2.FeyVxiUQWvaCkYlzlfeG', 'nchar2.上海市宁德市淄川周路n座 803882', 'binary3.UkNjWBPyCBRgkpmvtpWw', 'nchar3.北京市峰市璧山刘路G座 746867', 'binary4.xqFUKKJYHIpPlfyNuhFF', 'nchar4.湖北省齐齐哈尔市静安蒋街w座 215779', 'binary5.CCRGhhIjzzUEyhmxALRL', 'nchar5.北京市桂香市城东淮安街K座 265859', 'binary6.gvlOwjDLsDuPaCcVqiIX', 'nchar6.四川省东县静安余路Y座 617110', 'binary7.UXOSeWwjOJAoMNtgvPQE', 'nchar7.江西省玉英市海港澳门路q座 945219', 'binary8.mDiEkZDpVpDrdKUbhvcT', 'nchar8.香港特别行政区太原市黄浦黄街P座 177199') ;") + + tdSql.execute("insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000000, 651177360, 1729081754117700025, 23056, 13, -6.636242, 82.921964, 1, 'binary.EoaIaneNQHMAUIbOidQe', 'nchar.广西壮族自治区天津县花溪魏街i座 376191', 1630000000000, 'binary1.HlIOKTKSbfaVAlClZuBh', 'nchar1.四川省柳县黄浦林路C座 108476', 'binary2.JLsEXPSzqGmcVHMLgAHh', 'nchar2.上海市济南市平山合山街Z座 778571', 'binary3.mxAFCDLuRGaHOqmLIJpE', 'nchar3.河南省沈阳市南溪潜江街A座 468196', 'binary4.oXDqUtayeNmHovscxiVq', 'nchar4.海南省亮市高港海门路K座 870267', 'binary5.BLksYIROpOJhmClgwqyK', 'nchar5.山东省宜都县滨城徐街N座 306711', 'binary6.CoRjxWPAzdBYFOgiZzeg', 'nchar6.广西壮族自治区霞市长寿沈阳路L座 914991', 'binary7.MLfTLPVrPGvrcJYFqfFC', 'nchar7.辽宁省合肥市高明李路l座 224862', 'binary8.IfxKkLWFTHNeNEflRfzY', 'nchar8.新疆维吾尔自治区沈阳县朝阳福州街q座 939080') ;") + + tdSql.execute("insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000001, -746014185, -6611210245469344058, -27252, -77, -243654741.301468, -8.444537, 1, 'binary.EVYMoxfQftKyeUxzjhIj', 'nchar.江苏省六安县上街祁街p座 147895', 1630000000001, 'binary1.EqegqpWNNQmNarUebJgx', 'nchar1.北京市石家庄县高明太原街V座 139496', 'binary2.CgjLFXASsqDMbqpClkyo', 'nchar2.江苏省合山县涪城重庆路Q座 428968', 'binary3.wxQqnqtofXGaaQDIcVCL', 'nchar3.河南省呼和浩特市锡山兴城街O座 840658', 'binary4.zyKhpKkjeZokFeegJQDi', 'nchar4.西藏自治区潜江县魏都钟街i座 919700', 'binary5.OrEfrEsydYTamaZkNkwk', 'nchar5.重庆市兰英县沙湾嘉禾街c座 775060', 'binary6.NIpeYChLyWNMVOoSuDQY', 'nchar6.天津市杨市萧山合肥街b座 371505', 'binary7.gYzZPgKZiebmbgARfhbW', 'nchar7.河北省西安市浔阳通辽街w座 546863', 'binary8.sGpPIgZTnhPvEqbASIzz', 'nchar8.宁夏回族自治区文市朝阳昆明街O座 933200') ;") + + tdSql.execute("insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000001, -1971853248, -1403199549636457306, -21922, -13, 77363611038104.703125, -458826.670338, 1, 'binary.dLopzuuaEkQyOKdwEkoF', 'nchar.浙江省深圳县涪城贵阳路L座 154418', 1630000000001, 'binary1.VsdtZMdFeVMRVgpklpmT', 'nchar1.澳门特别行政区佛山市闵行兴安盟路O座 197626', 'binary2.NDlRTlhCWMfVPcQUDEAU', 'nchar2.贵州省长沙县永川金街F座 263410', 'binary3.YySoOsWslJgqFFJLByXa', 'nchar3.辽宁省兴安盟市崇文崔街W座 740261', 'binary4.htDrNqFhPBUEgnwqUnJy', 'nchar4.上海市杨县西峰天津街A座 215633', 'binary5.PICqEmpTJMRRFMoLiAYL', 'nchar5.四川省拉萨县清浦戴路d座 807565', 'binary6.TcHUZlyIvOLzjzOLQVeY', 'nchar6.福建省玉市金平西宁路y座 216505', 'binary7.KVgSEZbApHVciiiHdmMv', 'nchar7.广东省香港市友好张路N座 530133', 'binary8.BbnDEmsmbuMsmARBrmaB', 'nchar8.陕西省淮安市西峰淮安路G座 471156') ;") + + tdSql.execute("insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000000, 1290384855, 6453496169647608559, 17237, 78, -4556903756831.950195, 8558137.310094, 0, 'binary.RicjHNdlJvZXcuIUCtwp', 'nchar.辽宁省小红县安次刘路I座 783067', 1630000000000, 'binary1.PZrbgCdVlhLuYWzJfpcQ', 'nchar1.澳门特别行政区武汉市璧山孔路Y座 467679', 'binary2.CCmnLmgCmPDGsacmypKr', 'nchar2.广东省哈尔滨市朝阳巢湖路P座 520015', 'binary3.xpmnymjjdbpefsJbXiaA', 'nchar3.宁夏回族自治区齐齐哈尔市长寿海门路s座 980357', 'binary4.MQQAGeTBCbbAFmyCdNdx', 'nchar4.天津市哈尔滨县新城杨路w座 877346', 'binary5.jcGNOXcvsteCwnVwZxkv', 'nchar5.青海省哈尔滨市蓟州雷路S座 774634', 'binary6.sFIopESAmZxNtpEAXvmh', 'nchar6.上海市琳市萧山朴路I座 857895', 'binary7.GJEBncpKznEVYlBjADXc', 'nchar7.内蒙古自治区永安县南湖王路m座 128263', 'binary8.bseliCaYePtOlhjBDKlA', 'nchar8.新疆维吾尔自治区畅市清浦惠州路Y座 221741') ;") + + tdSql.execute("insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000001, 1577644138, 5424290571527673071, 21765, 84, 592473004730.168945, 1461967845107.139893, 0, 'binary.REnSISlqmqqrnTVDsVuc', 'nchar.浙江省呼和浩特市丰都田街T座 149274', 1630000000000, 'binary1.QBTMVrRvMGcRSiUFpsnA', 'nchar1.甘肃省佛山县大兴石家庄街y座 699134', 'binary2.iaKGuopmHqqbANMmhQaB', 'nchar2.福建省杭州县闵行福州街e座 356019', 'binary3.pAdZtAJFuMQGiLYWCFzp', 'nchar3.天津市玲市梁平阜新路R座 699400', 'binary4.bJvTLLaAsMVnxxKragLA', 'nchar4.内蒙古自治区银川市萧山乌鲁木齐街p座 711931', 'binary5.ITFlhuZlVWIBJqLhkOey', 'nchar5.陕西省桂芳县南湖北镇路s座 173929', 'binary6.EZDRIMGNFYtddfbOlkvT', 'nchar6.四川省兴城市沙湾李街p座 370512', 'binary7.RunKOCOVDEkKXXLbQQwD', 'nchar7.河北省兴安盟市萧山张路n座 447381', 'binary8.YOTuRbbLIqBCEgLddPwI', 'nchar8.北京市文县浔阳澳门路h座 816162') ;") + + tdSql.execute("insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000000010, 2090912853, 6664951181911026762, 27365, 66, -584038.233035, -934072263.917529, 0, 'binary.aqhUfBvmuNqFySsMkMdt', 'nchar.湖南省瑞县沙市王街c座 200752', 1630000000000, 'binary1.MwStUNfrTBVbvhHjfNza', 'nchar1.河北省雪市魏都杜街i座 259384', 'binary2.DGmDtcyaEObwuQVxDpUP', 'nchar2.湖北省淑兰县普陀胡路n座 716038', 'binary3.IAounswvgoPxMXtsqnwU', 'nchar3.甘肃省永安县南湖银川街C座 330264', 'binary4.wPwqkMLYqzkhmRHRpKAy', 'nchar4.上海市通辽市浔阳北镇路H座 317911', 'binary5.iQoYVJdmAoSBlyGpJpXx', 'nchar5.浙江省建华市大兴永安街K座 644305', 'binary6.MmjmFrioKDTFoegthaRD', 'nchar6.澳门特别行政区楠市龙潭太原路f座 611785', 'binary7.aHloPsebqjkwcCRXAcGc', 'nchar7.北京市桂芝市高港许街N座 542112', 'binary8.xvNxozZWlsTvtweWXQrl', 'nchar8.山东省北镇市静安巢湖路N座 751441') ;") + + tdSql.execute("insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001000, 1154867532, -4617169670731049020, 21991, -24, 1168661238750.610107, -426107677972.705994, 0, 'binary.hRmglnSXuxUSvYIqDolS', 'nchar.天津市齐齐哈尔市兴山王路e座 440016', 1630000000001, 'binary1.rpZLfFIvigPxgWvEiTnf', 'nchar1.天津市欣县上街李街n座 110533', 'binary2.CWBcufneMDLIfNmMyDQD', 'nchar2.甘肃省利市房山姜路f座 539129', 'binary3.uhGROtaovBUWCsBUcRUS', 'nchar3.贵州省嘉禾县安次天津路a座 385203', 'binary4.iXwEQVdoHPejKHgtUcnp', 'nchar4.山西省乌鲁木齐县西峰王街z座 375814', 'binary5.YxaTiRVvJItsdEsMogEr', 'nchar5.陕西省金凤市静安邵街s座 349352', 'binary6.znhgdUaTGWcwjmZAsZtC', 'nchar6.澳门特别行政区宁德县朝阳苏路r座 964005', 'binary7.OaZVpQWKsvDQANUDbcVU', 'nchar7.云南省凯市淄川柳州路g座 551620', 'binary8.XKoaJcnvWGWgtmCHASlj', 'nchar8.山西省洋县吉区袁街k座 383085') ;") + + tdSql.execute("insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001000, -1295218132, -2795255426441574417, -25856, -79, 31169.428912, -33.958690, 0, 'binary.qhHqAnxdwJQzpAIOnKsM', 'nchar.黑龙江省海口县上街张街B座 580665', 1630000000001, 'binary1.dFkcGdPczduswPtesnoF', 'nchar1.台湾省杰县丰都汪路j座 804255', 'binary2.pYgofQUdjJTzXLHZcNSc', 'nchar2.黑龙江省南昌市朝阳纪路i座 993767', 'binary3.UXtZpmwhjyEPOHhZyUxJ', 'nchar3.内蒙古自治区红市和平潮州路m座 803939', 'binary4.PHswTmYqZhTldHjklJYF', 'nchar4.四川省淮安市怀柔荆门路B座 969808', 'binary5.dKzVSArjPVLJXGTDWuOn', 'nchar5.台湾省璐县吉区梧州路T座 112945', 'binary6.AQrpGtxOsELOgWzfUxBo', 'nchar6.宁夏回族自治区淑兰县江北包街K座 510189', 'binary7.nYDVRmWgROIOOrVqCOse', 'nchar7.湖北省玉兰县双滦王街V座 272885', 'binary8.VCfynbYrgaMmjRiXHdUK', 'nchar8.贵州省畅县孝南宁德路z座 172562') ;") + + tdSql.execute("insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001000, 1406358857, 3587109948379738474, 6769, 53, -6976945.888649, 7.677615, 1, 'binary.owVOUICouSTklPEhbivn', 'nchar.内蒙古自治区辽阳县普陀柳路a座 840131', 1630000000001, 'binary1.uJCOuTOBoHKrmxJuPjWe', 'nchar1.北京市帅市长寿王街h座 105426', 'binary2.XWXOVmhROrAgBbsXANmC', 'nchar2.澳门特别行政区金凤县海港荆门路x座 762691', 'binary3.gxCneIGHUGBNHhjKfxYi', 'nchar3.宁夏回族自治区惠州县长寿李路R座 863651', 'binary4.rRYTZlEWfyBoprvSjmrU', 'nchar4.宁夏回族自治区平县秀英马路e座 846867', 'binary5.dDdPBqkpKquoRoacZZda', 'nchar5.河南省凤兰市大兴兴城路n座 845990', 'binary6.iITctvWPvSZocnjfyaAT', 'nchar6.重庆市永安市崇文宁德路L座 343620', 'binary7.fcDNUjTjvwxhYLLCMLCL', 'nchar7.上海市淑华市安次杨街s座 495789', 'binary8.wVedqBcRAcpUPMTNhrHz', 'nchar8.陕西省军县丰都王街T座 625091') ;") + + tdSql.execute("insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001000, 529011547, 5833219696463195177, 1368, 65, 88870.197516, 99120299502.128296, 1, 'binary.UxevmcLToszoUNHugtyM', 'nchar.安徽省红县安次叶路T座 440225', 1630000000001, 'binary1.sjsxFPefdlFKrTRAVouS', 'nchar1.贵州省柳州县海陵关岭街j座 890479', 'binary2.VOmSguDBtwojjcfmekbK', 'nchar2.贵州省兰州市沈北新汕尾路C座 478355', 'binary3.lJyJEMVjrqMUsmoBpWRN', 'nchar3.浙江省银川市友好黄街n座 118384', 'binary4.dgfhUSYsixNpyrERBkHr', 'nchar4.四川省琴市华龙方街J座 391129', 'binary5.hOVSTUkubHIghBwgKwEG', 'nchar5.陕西省瑜市华龙六安路x座 164875', 'binary6.SjWSOGeaMjBWIpoZSAcU', 'nchar6.河北省大冶市双滦孙路p座 902942', 'binary7.yAJcsKTMIyIhZijNsPkS', 'nchar7.台湾省银川市上街天津街U座 414513', 'binary8.BDMFDVvENIJkyoakNOvS', 'nchar8.重庆市荆门县南长银川街K座 999033') ;") + + tdSql.execute("insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001001, -1866552988, -758901224671643352, -255, -64, -0.884551, -26.457607, 1, 'binary.draSVywTJWrxguXBtWEq', 'nchar.山东省上海县沙市翟街f座 172428', 1630000000002, 'binary1.nOXUZkAqDrnKxtwOxqtf', 'nchar1.辽宁省飞县牧野张路C座 379691', 'binary2.NKVuIxfhKuRiIGxqAQEh', 'nchar2.湖南省玉华市双滦王路Y座 106635', 'binary3.IWFsIUfCFJpynVEWFykw', 'nchar3.甘肃省宇县东城宜都路q座 883419', 'binary4.oYHgrkuMqsznJYiuMOGG', 'nchar4.台湾省邯郸市白云吴路H座 185871', 'binary5.DHSVcnCnLheJAOYMLLBJ', 'nchar5.新疆维吾尔自治区秀芳市怀柔巢湖路h座 193210', 'binary6.manaViLNdwzCBTxsJkdC', 'nchar6.辽宁省海门县大东马鞍山街q座 452562', 'binary7.ulrIznjySbFuIFWWjgnE', 'nchar7.新疆维吾尔自治区文市海陵刘街U座 979746', 'binary8.dAekCjvegomJekAMZOYY', 'nchar8.广西壮族自治区辽阳市城北李街c座 242662') ;") + + tdSql.execute("insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001001, -741599443, -2779047021078882907, -2391, -17, 4299185271508.240234, 604469850161.758057, 1, 'binary.fXHBNYpwPFvxpmfkIJKq', 'nchar.河南省郑州县金平张路s座 406855', 1630000000002, 'binary1.qMsKGcIfmJmzqrLkaMZW', 'nchar1.台湾省齐齐哈尔县淄川乌路r座 947114', 'binary2.gUenDGAMpsjwAoLzuAVX', 'nchar2.江西省张家港县清浦上海街i座 960744', 'binary3.bnaWRmgZlUyMPaePUnrA', 'nchar3.香港特别行政区柳市永川张街A座 685451', 'binary4.ItKAwCgHdhBbQKJPJuWl', 'nchar4.陕西省飞县房山台北街P座 773575', 'binary5.obrRlauJBKUQjZeeDKzk', 'nchar5.澳门特别行政区丹丹市清城巢湖路D座 164790', 'binary6.EHcbDRSkpFjfYgoAhipL', 'nchar6.辽宁省小红市沈河高路R座 491125', 'binary7.zBsdfSePYONCPTFpSxtd', 'nchar7.浙江省玉英县孝南潮州街Q座 240622', 'binary8.ktVwuMPStmephdhCyXpW', 'nchar8.广西壮族自治区晨市沙湾宋路n座 375716') ;") + + tdSql.execute("insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001000, 861043174, 5455100179131942803, 11627, 93, 4704891958.274140, -90663765201548.906250, 0, 'binary.mzefOJuVapGcOZRBPWSA', 'nchar.湖南省桂香市合川武汉路e座 190074', 1630000000001, 'binary1.OKSAdzYZtxmTYgUqDTUJ', 'nchar1.天津市西安市房山程路g座 201540', 'binary2.UVZXgaXnvsOFMyfQtxlk', 'nchar2.辽宁省武汉市清浦长春路C座 249816', 'binary3.cykuADWPZFQANvsqhRKX', 'nchar3.河北省刚市东城解路i座 865426', 'binary4.KJUftFRDQqQZOjPRbash', 'nchar4.辽宁省长沙县永川张路h座 794840', 'binary5.mzizxALkpwFvhsDKDZLX', 'nchar5.上海市哈尔滨市长寿阎街d座 505069', 'binary6.COpyPYrULAJYVDcSidce', 'nchar6.上海市桂英县沙湾魏街v座 727936', 'binary7.EraykZvYQkepZTyCLhrX', 'nchar7.新疆维吾尔自治区婷市兴山齐齐哈尔街T座 467826', 'binary8.qpqMrYpGgIWuzjCwqRtA', 'nchar8.辽宁省凤兰市魏都沈阳路D座 852593') ;") + + tdSql.execute("insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001001, 891559292, 8826812031501648951, 25495, 17, -2673857362.484810, -992615811880.187012, 0, 'binary.sUSMJvnrtyRGAdkofSRp', 'nchar.北京市乌鲁木齐县金平郑州街K座 565319', 1630000000001, 'binary1.bkypAUrybRZdjEAQpLaD', 'nchar1.香港特别行政区通辽市清城张家港街g座 456475', 'binary2.mTeRDPIPKIqXXaCKxZZg', 'nchar2.海南省潜江市六枝特张路D座 742115', 'binary3.pXNShlLsrfFhMkZVJmvJ', 'nchar3.内蒙古自治区成市海港重庆街z座 935702', 'binary4.ePZMxraOFLRUirwjYQgz', 'nchar4.甘肃省哈尔滨县南溪兴城路B座 464192', 'binary5.EnZjhIMsFGQHTNgGwlLY', 'nchar5.山东省天津市门头沟齐齐哈尔路H座 590367', 'binary6.OwvaiZKpWMEuXNefCdSd', 'nchar6.广西壮族自治区凯县高坪葛路i座 733075', 'binary7.eZvrAHwgOSpNfkWOheQK', 'nchar7.云南省佳县大兴刘街b座 134332', 'binary8.mmASwYqspmYxzgEQMScD', 'nchar8.福建省秀英市高明广州街S座 972859') ;") + + tdSql.execute("insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts,q_binary1 , q_nchar1 , q_binary2 , q_nchar2 , q_binary3 , q_nchar3 , q_binary4 , q_nchar4 , q_binary5 , q_nchar5 , q_binary6 , q_nchar6 , q_binary7 , q_nchar7, q_binary8 , q_nchar8) values(1630000001010, 1406420228, 3809984898292539483, 15475, 82, -96.706822, 944989.967705, 0, 'binary.ZeTYsWJUdikuGndNhdDg', 'nchar.四川省潜江县蓟州陈街G座 347914', 1630000000001, 'binary1.xWLSLgSXgNPMCtEqeIem', 'nchar1.山东省辽阳县锡山上海路R座 816023', 'binary2.vdRFTigUtJQpwmklHmqs', 'nchar2.浙江省彬县崇文尚街v座 145248', 'binary3.DuUfOKRvTmFXKPglEJLy', 'nchar3.山西省秀荣市崇文嘉禾路b座 658257', 'binary4.XdprBDmPQensCLNylpfX', 'nchar4.青海省柳州县沈北新张家港街A座 207436', 'binary5.trUYUEAEeXecKeYDqBGX', 'nchar5.台湾省东市新城张路Q座 187531', 'binary6.gQwmTXQOFCblFwaBGoFG', 'nchar6.澳门特别行政区秀珍市萧山长春路D座 398394', 'binary7.djQZYSGDCbforCnoDkRE', 'nchar7.安徽省兴安盟市和平丰街o座 702930', 'binary8.QIuisWlGYavgxfQjfnAd', 'nchar8.黑龙江省海燕县闵行沈阳街S座 986676') ;") + + tdSql.query('select CONCAT_WS(" , , abc, 123",q_nchar2, q_nchar1, q_nchar3, q_nchar6) from stable_1;') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'nchar2.宁夏回族自治区兰州市淄川香港路Y座 213761 , , abc, 123nchar1.福建省宜都县海港王街M座 713195 , , abc, 123nchar3.海南省静市江北海口路X座 702375 , , abc, 123nchar6.山东省建华市魏都南京街o座 326153') + tdSql.checkData(1, 0, 'nchar2.甘肃省利市房山姜路f座 539129 , , abc, 123nchar1.天津市欣县上街李街n座 110533 , , abc, 123nchar3.贵州省嘉禾县安次天津路a座 385203 , , abc, 123nchar6.澳门特别行政区宁德县朝阳苏路r座 964005') + tdSql.checkData(2, 0, 'nchar2.上海市宁德市淄川周路n座 803882 , , abc, 123nchar1.陕西省惠州县城东郑州街a座 702479 , , abc, 123nchar3.北京市峰市璧山刘路G座 746867 , , abc, 123nchar6.四川省东县静安余路Y座 617110') + tdSql.checkData(3, 0, 'nchar2.江苏省合山县涪城重庆路Q座 428968 , , abc, 123nchar1.北京市石家庄县高明太原街V座 139496 , , abc, 123nchar3.河南省呼和浩特市锡山兴城街O座 840658 , , abc, 123nchar6.天津市杨市萧山合肥街b座 371505') + tdSql.checkData(4, 0, 'nchar2.澳门特别行政区金凤县海港荆门路x座 762691 , , abc, 123nchar1.北京市帅市长寿王街h座 105426 , , abc, 123nchar3.宁夏回族自治区惠州县长寿李路R座 863651 , , abc, 123nchar6.重庆市永安市崇文宁德路L座 343620') + tdSql.checkData(5, 0, 'nchar2.湖南省玉华市双滦王路Y座 106635 , , abc, 123nchar1.辽宁省飞县牧野张路C座 379691 , , abc, 123nchar3.甘肃省宇县东城宜都路q座 883419 , , abc, 123nchar6.辽宁省海门县大东马鞍山街q座 452562') + + tdSql.query('select concat_ws(" , , abc, 山东省", q_nchar2, q_nchar1, q_nchar4, q_nchar6) from stable_1;') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'nchar2.宁夏回族自治区兰州市淄川香港路Y座 213761 , , abc, 山东省nchar1.福建省宜都县海港王街M座 713195 , , abc, 山东省nchar4.四川省桂荣市滨城林街m座 503259 , , abc, 山东省nchar6.山东省建华市魏都南京街o座 326153') + tdSql.checkData(1, 0, 'nchar2.甘肃省利市房山姜路f座 539129 , , abc, 山东省nchar1.天津市欣县上街李街n座 110533 , , abc, 山东省nchar4.山西省乌鲁木齐县西峰王街z座 375814 , , abc, 山东省nchar6.澳门特别行政区宁德县朝阳苏路r座 964005') + tdSql.checkData(2, 0, 'nchar2.上海市宁德市淄川周路n座 803882 , , abc, 山东省nchar1.陕西省惠州县城东郑州街a座 702479 , , abc, 山东省nchar4.湖北省齐齐哈尔市静安蒋街w座 215779 , , abc, 山东省nchar6.四川省东县静安余路Y座 617110') + tdSql.checkData(3, 0, 'nchar2.江苏省合山县涪城重庆路Q座 428968 , , abc, 山东省nchar1.北京市石家庄县高明太原街V座 139496 , , abc, 山东省nchar4.西藏自治区潜江县魏都钟街i座 919700 , , abc, 山东省nchar6.天津市杨市萧山合肥街b座 371505') + tdSql.checkData(4, 0, 'nchar2.澳门特别行政区金凤县海港荆门路x座 762691 , , abc, 山东省nchar1.北京市帅市长寿王街h座 105426 , , abc, 山东省nchar4.宁夏回族自治区平县秀英马路e座 846867 , , abc, 山东省nchar6.重庆市永安市崇文宁德路L座 343620') + tdSql.checkData(5, 0, 'nchar2.湖南省玉华市双滦王路Y座 106635 , , abc, 山东省nchar1.辽宁省飞县牧野张路C座 379691 , , abc, 山东省nchar4.台湾省邯郸市白云吴路H座 185871 , , abc, 山东省nchar6.辽宁省海门县大东马鞍山街q座 452562') + + tdSql.query('select concat_ws(" , , abc, 山东省", q_nchar2, q_nchar1, q_nchar4, q_nchar6) from (select * from stable_1);') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'nchar2.宁夏回族自治区兰州市淄川香港路Y座 213761 , , abc, 山东省nchar1.福建省宜都县海港王街M座 713195 , , abc, 山东省nchar4.四川省桂荣市滨城林街m座 503259 , , abc, 山东省nchar6.山东省建华市魏都南京街o座 326153') + tdSql.checkData(1, 0, 'nchar2.甘肃省利市房山姜路f座 539129 , , abc, 山东省nchar1.天津市欣县上街李街n座 110533 , , abc, 山东省nchar4.山西省乌鲁木齐县西峰王街z座 375814 , , abc, 山东省nchar6.澳门特别行政区宁德县朝阳苏路r座 964005') + tdSql.checkData(2, 0, 'nchar2.上海市宁德市淄川周路n座 803882 , , abc, 山东省nchar1.陕西省惠州县城东郑州街a座 702479 , , abc, 山东省nchar4.湖北省齐齐哈尔市静安蒋街w座 215779 , , abc, 山东省nchar6.四川省东县静安余路Y座 617110') + tdSql.checkData(3, 0, 'nchar2.江苏省合山县涪城重庆路Q座 428968 , , abc, 山东省nchar1.北京市石家庄县高明太原街V座 139496 , , abc, 山东省nchar4.西藏自治区潜江县魏都钟街i座 919700 , , abc, 山东省nchar6.天津市杨市萧山合肥街b座 371505') + tdSql.checkData(4, 0, 'nchar2.澳门特别行政区金凤县海港荆门路x座 762691 , , abc, 山东省nchar1.北京市帅市长寿王街h座 105426 , , abc, 山东省nchar4.宁夏回族自治区平县秀英马路e座 846867 , , abc, 山东省nchar6.重庆市永安市崇文宁德路L座 343620') + tdSql.checkData(5, 0, 'nchar2.湖南省玉华市双滦王路Y座 106635 , , abc, 山东省nchar1.辽宁省飞县牧野张路C座 379691 , , abc, 山东省nchar4.台湾省邯郸市白云吴路H座 185871 , , abc, 山东省nchar6.辽宁省海门县大东马鞍山街q座 452562') + + tdSql.query('select upper(q_nchar1),upper(q_nchar2),length(q_nchar1),char_length(q_nchar1),lower(q_nchar1) from (select * from stable_1);') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'NCHAR1.福建省宜都县海港王街M座 713195') + tdSql.checkData(0, 1, 'NCHAR2.宁夏回族自治区兰州市淄川香港路Y座 213761') + tdSql.checkData(0, 2, 104) + tdSql.checkData(0, 3, 26) + tdSql.checkData(0, 4, 'nchar1.福建省宜都县海港王街m座 713195') + tdSql.checkData(1, 0, 'NCHAR1.天津市欣县上街李街N座 110533') + tdSql.checkData(1, 1, 'NCHAR2.甘肃省利市房山姜路F座 539129') + tdSql.checkData(1, 2, 100) + tdSql.checkData(1, 3, 25) + tdSql.checkData(1, 4, 'nchar1.天津市欣县上街李街n座 110533') + tdSql.checkData(2, 0, 'NCHAR1.陕西省惠州县城东郑州街A座 702479') + tdSql.checkData(2, 1, 'NCHAR2.上海市宁德市淄川周路N座 803882') + tdSql.checkData(2, 2, 108) + tdSql.checkData(2, 3, 27) + tdSql.checkData(2, 4, 'nchar1.陕西省惠州县城东郑州街a座 702479') + tdSql.checkData(3, 0, 'NCHAR1.北京市石家庄县高明太原街V座 139496') + tdSql.checkData(3, 1, 'NCHAR2.江苏省合山县涪城重庆路Q座 428968') + tdSql.checkData(3, 2, 112) + tdSql.checkData(3, 3, 28) + tdSql.checkData(3, 4, 'nchar1.北京市石家庄县高明太原街v座 139496') + tdSql.checkData(4, 0, 'NCHAR1.北京市帅市长寿王街H座 105426') + tdSql.checkData(4, 1, 'NCHAR2.澳门特别行政区金凤县海港荆门路X座 762691') + tdSql.checkData(4, 2, 100) + tdSql.checkData(4, 3, 25) + tdSql.checkData(4, 4, 'nchar1.北京市帅市长寿王街h座 105426') + tdSql.checkData(5, 0, 'NCHAR1.辽宁省飞县牧野张路C座 379691') + tdSql.checkData(5, 1, 'NCHAR2.湖南省玉华市双滦王路Y座 106635') + tdSql.checkData(5, 2, 100) + tdSql.checkData(5, 3, 25) + tdSql.checkData(5, 4, 'nchar1.辽宁省飞县牧野张路c座 379691') + + tdSql.query('select upper(q_nchar1),upper(q_nchar2),length(q_nchar1),char_length(q_nchar1),lower(q_nchar1) from (select * from stable_1) order by ts;') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'NCHAR1.福建省宜都县海港王街M座 713195') + tdSql.checkData(0, 1, 'NCHAR2.宁夏回族自治区兰州市淄川香港路Y座 213761') + tdSql.checkData(0, 2, 104) + tdSql.checkData(0, 3, 26) + tdSql.checkData(0, 4, 'nchar1.福建省宜都县海港王街m座 713195') + tdSql.checkData(1, 0, 'NCHAR1.陕西省惠州县城东郑州街A座 702479') + tdSql.checkData(1, 1, 'NCHAR2.上海市宁德市淄川周路N座 803882') + tdSql.checkData(1, 2, 108) + tdSql.checkData(1, 3, 27) + tdSql.checkData(1, 4, 'nchar1.陕西省惠州县城东郑州街a座 702479') + tdSql.checkData(2, 0, 'NCHAR1.北京市石家庄县高明太原街V座 139496') + tdSql.checkData(2, 1, 'NCHAR2.江苏省合山县涪城重庆路Q座 428968') + tdSql.checkData(2, 2, 112) + tdSql.checkData(2, 3, 28) + tdSql.checkData(2, 4, 'nchar1.北京市石家庄县高明太原街v座 139496') + tdSql.checkData(3, 0, 'NCHAR1.天津市欣县上街李街N座 110533') + tdSql.checkData(3, 1, 'NCHAR2.甘肃省利市房山姜路F座 539129') + tdSql.checkData(3, 2, 100) + tdSql.checkData(3, 3, 25) + tdSql.checkData(3, 4, 'nchar1.天津市欣县上街李街n座 110533') + tdSql.checkData(4, 0, 'NCHAR1.北京市帅市长寿王街H座 105426') + tdSql.checkData(4, 1, 'NCHAR2.澳门特别行政区金凤县海港荆门路X座 762691') + tdSql.checkData(4, 2, 100) + tdSql.checkData(4, 3, 25) + tdSql.checkData(4, 4, 'nchar1.北京市帅市长寿王街h座 105426') + tdSql.checkData(5, 0, 'NCHAR1.辽宁省飞县牧野张路C座 379691') + tdSql.checkData(5, 1, 'NCHAR2.湖南省玉华市双滦王路Y座 106635') + tdSql.checkData(5, 2, 100) + tdSql.checkData(5, 3, 25) + tdSql.checkData(5, 4, 'nchar1.辽宁省飞县牧野张路c座 379691') + + tdSql.query('select upper(q_nchar1),upper(q_nchar2),length(q_nchar1),char_length(q_nchar1),lower(q_nchar1) from (select * from stable_1);') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'NCHAR1.福建省宜都县海港王街M座 713195') + tdSql.checkData(0, 1, 'NCHAR2.宁夏回族自治区兰州市淄川香港路Y座 213761') + tdSql.checkData(0, 2, 104) + tdSql.checkData(0, 3, 26) + tdSql.checkData(0, 4, 'nchar1.福建省宜都县海港王街m座 713195') + tdSql.checkData(1, 0, 'NCHAR1.天津市欣县上街李街N座 110533') + tdSql.checkData(1, 1, 'NCHAR2.甘肃省利市房山姜路F座 539129') + tdSql.checkData(1, 2, 100) + tdSql.checkData(1, 3, 25) + tdSql.checkData(1, 4, 'nchar1.天津市欣县上街李街n座 110533') + tdSql.checkData(2, 0, 'NCHAR1.陕西省惠州县城东郑州街A座 702479') + tdSql.checkData(2, 1, 'NCHAR2.上海市宁德市淄川周路N座 803882') + tdSql.checkData(2, 2, 108) + tdSql.checkData(2, 3, 27) + tdSql.checkData(2, 4, 'nchar1.陕西省惠州县城东郑州街a座 702479') + tdSql.checkData(3, 0, 'NCHAR1.北京市石家庄县高明太原街V座 139496') + tdSql.checkData(3, 1, 'NCHAR2.江苏省合山县涪城重庆路Q座 428968') + tdSql.checkData(3, 2, 112) + tdSql.checkData(3, 3, 28) + tdSql.checkData(3, 4, 'nchar1.北京市石家庄县高明太原街v座 139496') + tdSql.checkData(4, 0, 'NCHAR1.北京市帅市长寿王街H座 105426') + tdSql.checkData(4, 1, 'NCHAR2.澳门特别行政区金凤县海港荆门路X座 762691') + tdSql.checkData(4, 2, 100) + tdSql.checkData(4, 3, 25) + tdSql.checkData(4, 4, 'nchar1.北京市帅市长寿王街h座 105426') + tdSql.checkData(5, 0, 'NCHAR1.辽宁省飞县牧野张路C座 379691') + tdSql.checkData(5, 1, 'NCHAR2.湖南省玉华市双滦王路Y座 106635') + tdSql.checkData(5, 2, 100) + tdSql.checkData(5, 3, 25) + tdSql.checkData(5, 4, 'nchar1.辽宁省飞县牧野张路c座 379691') + + tdSql.query('select CONCAT_WS("abc, taos, , <, %, $, @, |",q_binary3, q_binary7, q_binary4, q_binary8, q_binary5, q_binary6, q_binary2, q_binary1) from stable_2;') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'binary3.xpmnymjjdbpefsJbXiaAabc, taos, , <, %, $, @, |binary7.GJEBncpKznEVYlBjADXcabc, taos, , <, %, $, @, |binary4.MQQAGeTBCbbAFmyCdNdxabc, taos, , <, %, $, @, |binary8.bseliCaYePtOlhjBDKlAabc, taos, , <, %, $, @, |binary5.jcGNOXcvsteCwnVwZxkvabc, taos, , <, %, $, @, |binary6.sFIopESAmZxNtpEAXvmhabc, taos, , <, %, $, @, |binary2.CCmnLmgCmPDGsacmypKrabc, taos, , <, %, $, @, |binary1.PZrbgCdVlhLuYWzJfpcQ') + tdSql.checkData(1, 0, 'binary3.pAdZtAJFuMQGiLYWCFzpabc, taos, , <, %, $, @, |binary7.RunKOCOVDEkKXXLbQQwDabc, taos, , <, %, $, @, |binary4.bJvTLLaAsMVnxxKragLAabc, taos, , <, %, $, @, |binary8.YOTuRbbLIqBCEgLddPwIabc, taos, , <, %, $, @, |binary5.ITFlhuZlVWIBJqLhkOeyabc, taos, , <, %, $, @, |binary6.EZDRIMGNFYtddfbOlkvTabc, taos, , <, %, $, @, |binary2.iaKGuopmHqqbANMmhQaBabc, taos, , <, %, $, @, |binary1.QBTMVrRvMGcRSiUFpsnA') + tdSql.checkData(2, 0, 'binary3.IAounswvgoPxMXtsqnwUabc, taos, , <, %, $, @, |binary7.aHloPsebqjkwcCRXAcGcabc, taos, , <, %, $, @, |binary4.wPwqkMLYqzkhmRHRpKAyabc, taos, , <, %, $, @, |binary8.xvNxozZWlsTvtweWXQrlabc, taos, , <, %, $, @, |binary5.iQoYVJdmAoSBlyGpJpXxabc, taos, , <, %, $, @, |binary6.MmjmFrioKDTFoegthaRDabc, taos, , <, %, $, @, |binary2.DGmDtcyaEObwuQVxDpUPabc, taos, , <, %, $, @, |binary1.MwStUNfrTBVbvhHjfNza') + tdSql.checkData(3, 0, 'binary3.cykuADWPZFQANvsqhRKXabc, taos, , <, %, $, @, |binary7.EraykZvYQkepZTyCLhrXabc, taos, , <, %, $, @, |binary4.KJUftFRDQqQZOjPRbashabc, taos, , <, %, $, @, |binary8.qpqMrYpGgIWuzjCwqRtAabc, taos, , <, %, $, @, |binary5.mzizxALkpwFvhsDKDZLXabc, taos, , <, %, $, @, |binary6.COpyPYrULAJYVDcSidceabc, taos, , <, %, $, @, |binary2.UVZXgaXnvsOFMyfQtxlkabc, taos, , <, %, $, @, |binary1.OKSAdzYZtxmTYgUqDTUJ') + tdSql.checkData(4, 0, 'binary3.pXNShlLsrfFhMkZVJmvJabc, taos, , <, %, $, @, |binary7.eZvrAHwgOSpNfkWOheQKabc, taos, , <, %, $, @, |binary4.ePZMxraOFLRUirwjYQgzabc, taos, , <, %, $, @, |binary8.mmASwYqspmYxzgEQMScDabc, taos, , <, %, $, @, |binary5.EnZjhIMsFGQHTNgGwlLYabc, taos, , <, %, $, @, |binary6.OwvaiZKpWMEuXNefCdSdabc, taos, , <, %, $, @, |binary2.mTeRDPIPKIqXXaCKxZZgabc, taos, , <, %, $, @, |binary1.bkypAUrybRZdjEAQpLaD') + tdSql.checkData(5, 0, 'binary3.DuUfOKRvTmFXKPglEJLyabc, taos, , <, %, $, @, |binary7.djQZYSGDCbforCnoDkREabc, taos, , <, %, $, @, |binary4.XdprBDmPQensCLNylpfXabc, taos, , <, %, $, @, |binary8.QIuisWlGYavgxfQjfnAdabc, taos, , <, %, $, @, |binary5.trUYUEAEeXecKeYDqBGXabc, taos, , <, %, $, @, |binary6.gQwmTXQOFCblFwaBGoFGabc, taos, , <, %, $, @, |binary2.vdRFTigUtJQpwmklHmqsabc, taos, , <, %, $, @, |binary1.xWLSLgSXgNPMCtEqeIem') + + tdSql.query('select * from (select CONCAT_WS("abc, taos, , <, %, $, @, |",q_binary3, q_binary7, q_binary4, q_binary8, q_binary5, q_binary6, q_binary2, q_binary1) from stable_2 where q_double <= 1.7E308 and q_int <= 2147483647 and t_tinyint != 128 and t_nchar is not null and q_nchar match \'nchar\' and (q_bool = true or q_bool = false));') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'binary3.xpmnymjjdbpefsJbXiaAabc, taos, , <, %, $, @, |binary7.GJEBncpKznEVYlBjADXcabc, taos, , <, %, $, @, |binary4.MQQAGeTBCbbAFmyCdNdxabc, taos, , <, %, $, @, |binary8.bseliCaYePtOlhjBDKlAabc, taos, , <, %, $, @, |binary5.jcGNOXcvsteCwnVwZxkvabc, taos, , <, %, $, @, |binary6.sFIopESAmZxNtpEAXvmhabc, taos, , <, %, $, @, |binary2.CCmnLmgCmPDGsacmypKrabc, taos, , <, %, $, @, |binary1.PZrbgCdVlhLuYWzJfpcQ') + tdSql.checkData(1, 0, 'binary3.pAdZtAJFuMQGiLYWCFzpabc, taos, , <, %, $, @, |binary7.RunKOCOVDEkKXXLbQQwDabc, taos, , <, %, $, @, |binary4.bJvTLLaAsMVnxxKragLAabc, taos, , <, %, $, @, |binary8.YOTuRbbLIqBCEgLddPwIabc, taos, , <, %, $, @, |binary5.ITFlhuZlVWIBJqLhkOeyabc, taos, , <, %, $, @, |binary6.EZDRIMGNFYtddfbOlkvTabc, taos, , <, %, $, @, |binary2.iaKGuopmHqqbANMmhQaBabc, taos, , <, %, $, @, |binary1.QBTMVrRvMGcRSiUFpsnA') + tdSql.checkData(2, 0, 'binary3.IAounswvgoPxMXtsqnwUabc, taos, , <, %, $, @, |binary7.aHloPsebqjkwcCRXAcGcabc, taos, , <, %, $, @, |binary4.wPwqkMLYqzkhmRHRpKAyabc, taos, , <, %, $, @, |binary8.xvNxozZWlsTvtweWXQrlabc, taos, , <, %, $, @, |binary5.iQoYVJdmAoSBlyGpJpXxabc, taos, , <, %, $, @, |binary6.MmjmFrioKDTFoegthaRDabc, taos, , <, %, $, @, |binary2.DGmDtcyaEObwuQVxDpUPabc, taos, , <, %, $, @, |binary1.MwStUNfrTBVbvhHjfNza') + tdSql.checkData(3, 0, 'binary3.cykuADWPZFQANvsqhRKXabc, taos, , <, %, $, @, |binary7.EraykZvYQkepZTyCLhrXabc, taos, , <, %, $, @, |binary4.KJUftFRDQqQZOjPRbashabc, taos, , <, %, $, @, |binary8.qpqMrYpGgIWuzjCwqRtAabc, taos, , <, %, $, @, |binary5.mzizxALkpwFvhsDKDZLXabc, taos, , <, %, $, @, |binary6.COpyPYrULAJYVDcSidceabc, taos, , <, %, $, @, |binary2.UVZXgaXnvsOFMyfQtxlkabc, taos, , <, %, $, @, |binary1.OKSAdzYZtxmTYgUqDTUJ') + tdSql.checkData(4, 0, 'binary3.pXNShlLsrfFhMkZVJmvJabc, taos, , <, %, $, @, |binary7.eZvrAHwgOSpNfkWOheQKabc, taos, , <, %, $, @, |binary4.ePZMxraOFLRUirwjYQgzabc, taos, , <, %, $, @, |binary8.mmASwYqspmYxzgEQMScDabc, taos, , <, %, $, @, |binary5.EnZjhIMsFGQHTNgGwlLYabc, taos, , <, %, $, @, |binary6.OwvaiZKpWMEuXNefCdSdabc, taos, , <, %, $, @, |binary2.mTeRDPIPKIqXXaCKxZZgabc, taos, , <, %, $, @, |binary1.bkypAUrybRZdjEAQpLaD') + tdSql.checkData(5, 0, 'binary3.DuUfOKRvTmFXKPglEJLyabc, taos, , <, %, $, @, |binary7.djQZYSGDCbforCnoDkREabc, taos, , <, %, $, @, |binary4.XdprBDmPQensCLNylpfXabc, taos, , <, %, $, @, |binary8.QIuisWlGYavgxfQjfnAdabc, taos, , <, %, $, @, |binary5.trUYUEAEeXecKeYDqBGXabc, taos, , <, %, $, @, |binary6.gQwmTXQOFCblFwaBGoFGabc, taos, , <, %, $, @, |binary2.vdRFTigUtJQpwmklHmqsabc, taos, , <, %, $, @, |binary1.xWLSLgSXgNPMCtEqeIem') + + tdSql.query('select CONCAT_WS("), <, ., ^, >, , |, /",q_nchar1, q_nchar6, q_nchar7, q_nchar, q_nchar5, q_nchar8, q_nchar4, q_nchar3) from stable_2;') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'nchar1.澳门特别行政区武汉市璧山孔路Y座 467679), <, ., ^, >, , |, /nchar6.上海市琳市萧山朴路I座 857895), <, ., ^, >, , |, /nchar7.内蒙古自治区永安县南湖王路m座 128263), <, ., ^, >, , |, /nchar.辽宁省小红县安次刘路I座 783067), <, ., ^, >, , |, /nchar5.青海省哈尔滨市蓟州雷路S座 774634), <, ., ^, >, , |, /nchar8.新疆维吾尔自治区畅市清浦惠州路Y座 221741), <, ., ^, >, , |, /nchar4.天津市哈尔滨县新城杨路w座 877346), <, ., ^, >, , |, /nchar3.宁夏回族自治区齐齐哈尔市长寿海门路s座 980357') + tdSql.checkData(1, 0, 'nchar1.甘肃省佛山县大兴石家庄街y座 699134), <, ., ^, >, , |, /nchar6.四川省兴城市沙湾李街p座 370512), <, ., ^, >, , |, /nchar7.河北省兴安盟市萧山张路n座 447381), <, ., ^, >, , |, /nchar.浙江省呼和浩特市丰都田街T座 149274), <, ., ^, >, , |, /nchar5.陕西省桂芳县南湖北镇路s座 173929), <, ., ^, >, , |, /nchar8.北京市文县浔阳澳门路h座 816162), <, ., ^, >, , |, /nchar4.内蒙古自治区银川市萧山乌鲁木齐街p座 711931), <, ., ^, >, , |, /nchar3.天津市玲市梁平阜新路R座 699400') + tdSql.checkData(2, 0, 'nchar1.河北省雪市魏都杜街i座 259384), <, ., ^, >, , |, /nchar6.澳门特别行政区楠市龙潭太原路f座 611785), <, ., ^, >, , |, /nchar7.北京市桂芝市高港许街N座 542112), <, ., ^, >, , |, /nchar.湖南省瑞县沙市王街c座 200752), <, ., ^, >, , |, /nchar5.浙江省建华市大兴永安街K座 644305), <, ., ^, >, , |, /nchar8.山东省北镇市静安巢湖路N座 751441), <, ., ^, >, , |, /nchar4.上海市通辽市浔阳北镇路H座 317911), <, ., ^, >, , |, /nchar3.甘肃省永安县南湖银川街C座 330264') + tdSql.checkData(3, 0, 'nchar1.天津市西安市房山程路g座 201540), <, ., ^, >, , |, /nchar6.上海市桂英县沙湾魏街v座 727936), <, ., ^, >, , |, /nchar7.新疆维吾尔自治区婷市兴山齐齐哈尔街T座 467826), <, ., ^, >, , |, /nchar.湖南省桂香市合川武汉路e座 190074), <, ., ^, >, , |, /nchar5.上海市哈尔滨市长寿阎街d座 505069), <, ., ^, >, , |, /nchar8.辽宁省凤兰市魏都沈阳路D座 852593), <, ., ^, >, , |, /nchar4.辽宁省长沙县永川张路h座 794840), <, ., ^, >, , |, /nchar3.河北省刚市东城解路i座 865426') + tdSql.checkData(4, 0, 'nchar1.香港特别行政区通辽市清城张家港街g座 456475), <, ., ^, >, , |, /nchar6.广西壮族自治区凯县高坪葛路i座 733075), <, ., ^, >, , |, /nchar7.云南省佳县大兴刘街b座 134332), <, ., ^, >, , |, /nchar.北京市乌鲁木齐县金平郑州街K座 565319), <, ., ^, >, , |, /nchar5.山东省天津市门头沟齐齐哈尔路H座 590367), <, ., ^, >, , |, /nchar8.福建省秀英市高明广州街S座 972859), <, ., ^, >, , |, /nchar4.甘肃省哈尔滨县南溪兴城路B座 464192), <, ., ^, >, , |, /nchar3.内蒙古自治区成市海港重庆街z座 935702') + tdSql.checkData(5, 0, 'nchar1.山东省辽阳县锡山上海路R座 816023), <, ., ^, >, , |, /nchar6.澳门特别行政区秀珍市萧山长春路D座 398394), <, ., ^, >, , |, /nchar7.安徽省兴安盟市和平丰街o座 702930), <, ., ^, >, , |, /nchar.四川省潜江县蓟州陈街G座 347914), <, ., ^, >, , |, /nchar5.台湾省东市新城张路Q座 187531), <, ., ^, >, , |, /nchar8.黑龙江省海燕县闵行沈阳街S座 986676), <, ., ^, >, , |, /nchar4.青海省柳州县沈北新张家港街A座 207436), <, ., ^, >, , |, /nchar3.山西省秀荣市崇文嘉禾路b座 658257') + + tdSql.query('select CONCAT_WS("), <, ., ^, >, , |, /",q_nchar1, q_nchar6, q_nchar7, q_nchar, q_nchar5, q_nchar8, q_nchar4, q_nchar3) from stable_2 where q_bigint is not null and t_ts is not null and q_binary nmatch \'binarynchar\';') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'nchar1.澳门特别行政区武汉市璧山孔路Y座 467679), <, ., ^, >, , |, /nchar6.上海市琳市萧山朴路I座 857895), <, ., ^, >, , |, /nchar7.内蒙古自治区永安县南湖王路m座 128263), <, ., ^, >, , |, /nchar.辽宁省小红县安次刘路I座 783067), <, ., ^, >, , |, /nchar5.青海省哈尔滨市蓟州雷路S座 774634), <, ., ^, >, , |, /nchar8.新疆维吾尔自治区畅市清浦惠州路Y座 221741), <, ., ^, >, , |, /nchar4.天津市哈尔滨县新城杨路w座 877346), <, ., ^, >, , |, /nchar3.宁夏回族自治区齐齐哈尔市长寿海门路s座 980357') + tdSql.checkData(1, 0, 'nchar1.甘肃省佛山县大兴石家庄街y座 699134), <, ., ^, >, , |, /nchar6.四川省兴城市沙湾李街p座 370512), <, ., ^, >, , |, /nchar7.河北省兴安盟市萧山张路n座 447381), <, ., ^, >, , |, /nchar.浙江省呼和浩特市丰都田街T座 149274), <, ., ^, >, , |, /nchar5.陕西省桂芳县南湖北镇路s座 173929), <, ., ^, >, , |, /nchar8.北京市文县浔阳澳门路h座 816162), <, ., ^, >, , |, /nchar4.内蒙古自治区银川市萧山乌鲁木齐街p座 711931), <, ., ^, >, , |, /nchar3.天津市玲市梁平阜新路R座 699400') + tdSql.checkData(2, 0, 'nchar1.河北省雪市魏都杜街i座 259384), <, ., ^, >, , |, /nchar6.澳门特别行政区楠市龙潭太原路f座 611785), <, ., ^, >, , |, /nchar7.北京市桂芝市高港许街N座 542112), <, ., ^, >, , |, /nchar.湖南省瑞县沙市王街c座 200752), <, ., ^, >, , |, /nchar5.浙江省建华市大兴永安街K座 644305), <, ., ^, >, , |, /nchar8.山东省北镇市静安巢湖路N座 751441), <, ., ^, >, , |, /nchar4.上海市通辽市浔阳北镇路H座 317911), <, ., ^, >, , |, /nchar3.甘肃省永安县南湖银川街C座 330264') + tdSql.checkData(3, 0, 'nchar1.天津市西安市房山程路g座 201540), <, ., ^, >, , |, /nchar6.上海市桂英县沙湾魏街v座 727936), <, ., ^, >, , |, /nchar7.新疆维吾尔自治区婷市兴山齐齐哈尔街T座 467826), <, ., ^, >, , |, /nchar.湖南省桂香市合川武汉路e座 190074), <, ., ^, >, , |, /nchar5.上海市哈尔滨市长寿阎街d座 505069), <, ., ^, >, , |, /nchar8.辽宁省凤兰市魏都沈阳路D座 852593), <, ., ^, >, , |, /nchar4.辽宁省长沙县永川张路h座 794840), <, ., ^, >, , |, /nchar3.河北省刚市东城解路i座 865426') + tdSql.checkData(4, 0, 'nchar1.香港特别行政区通辽市清城张家港街g座 456475), <, ., ^, >, , |, /nchar6.广西壮族自治区凯县高坪葛路i座 733075), <, ., ^, >, , |, /nchar7.云南省佳县大兴刘街b座 134332), <, ., ^, >, , |, /nchar.北京市乌鲁木齐县金平郑州街K座 565319), <, ., ^, >, , |, /nchar5.山东省天津市门头沟齐齐哈尔路H座 590367), <, ., ^, >, , |, /nchar8.福建省秀英市高明广州街S座 972859), <, ., ^, >, , |, /nchar4.甘肃省哈尔滨县南溪兴城路B座 464192), <, ., ^, >, , |, /nchar3.内蒙古自治区成市海港重庆街z座 935702') + tdSql.checkData(5, 0, 'nchar1.山东省辽阳县锡山上海路R座 816023), <, ., ^, >, , |, /nchar6.澳门特别行政区秀珍市萧山长春路D座 398394), <, ., ^, >, , |, /nchar7.安徽省兴安盟市和平丰街o座 702930), <, ., ^, >, , |, /nchar.四川省潜江县蓟州陈街G座 347914), <, ., ^, >, , |, /nchar5.台湾省东市新城张路Q座 187531), <, ., ^, >, , |, /nchar8.黑龙江省海燕县闵行沈阳街S座 986676), <, ., ^, >, , |, /nchar4.青海省柳州县沈北新张家港街A座 207436), <, ., ^, >, , |, /nchar3.山西省秀荣市崇文嘉禾路b座 658257') + + tdSql.query('select CONCAT_WS("$, , ~",q_nchar7, q_nchar5, q_nchar8) from stable_1;') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'nchar7.湖北省桂芳市高明邯郸路q座 413345$, , ~nchar5.贵州省大冶县滨城梧州街P座 554324$, , ~nchar8.内蒙古自治区太原县萧山王路p座 322176') + tdSql.checkData(1, 0, 'nchar7.云南省凯市淄川柳州路g座 551620$, , ~nchar5.陕西省金凤市静安邵街s座 349352$, , ~nchar8.山西省洋县吉区袁街k座 383085') + tdSql.checkData(2, 0, 'nchar7.江西省玉英市海港澳门路q座 945219$, , ~nchar5.北京市桂香市城东淮安街K座 265859$, , ~nchar8.香港特别行政区太原市黄浦黄街P座 177199') + tdSql.checkData(3, 0, 'nchar7.河北省西安市浔阳通辽街w座 546863$, , ~nchar5.重庆市兰英县沙湾嘉禾街c座 775060$, , ~nchar8.宁夏回族自治区文市朝阳昆明街O座 933200') + tdSql.checkData(4, 0, 'nchar7.上海市淑华市安次杨街s座 495789$, , ~nchar5.河南省凤兰市大兴兴城路n座 845990$, , ~nchar8.陕西省军县丰都王街T座 625091') + tdSql.checkData(5, 0, 'nchar7.新疆维吾尔自治区文市海陵刘街U座 979746$, , ~nchar5.新疆维吾尔自治区秀芳市怀柔巢湖路h座 193210$, , ~nchar8.广西壮族自治区辽阳市城北李街c座 242662') + + tdSql.query('select CONCAT_WS("taos, _, +",q_binary2, q_binary5, q_binary4) from (select * from stable_1) where q_nchar is not null;') + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'binary2.tsCyNVyBJDCnIvUdjVevtaos, _, +binary5.BUEJHkTvXfstJGArxcBztaos, _, +binary4.NdciuKObKZYwDVhtIOgB') + tdSql.checkData(1, 0, 'binary2.CWBcufneMDLIfNmMyDQDtaos, _, +binary5.YxaTiRVvJItsdEsMogErtaos, _, +binary4.iXwEQVdoHPejKHgtUcnp') + tdSql.checkData(2, 0, 'binary2.FeyVxiUQWvaCkYlzlfeGtaos, _, +binary5.CCRGhhIjzzUEyhmxALRLtaos, _, +binary4.xqFUKKJYHIpPlfyNuhFF') + tdSql.checkData(3, 0, 'binary2.CgjLFXASsqDMbqpClkyotaos, _, +binary5.OrEfrEsydYTamaZkNkwktaos, _, +binary4.zyKhpKkjeZokFeegJQDi') + tdSql.checkData(4, 0, 'binary2.XWXOVmhROrAgBbsXANmCtaos, _, +binary5.dDdPBqkpKquoRoacZZdataos, _, +binary4.rRYTZlEWfyBoprvSjmrU') + tdSql.checkData(5, 0, 'binary2.NKVuIxfhKuRiIGxqAQEhtaos, _, +binary5.DHSVcnCnLheJAOYMLLBJtaos, _, +binary4.oYHgrkuMqsznJYiuMOGG') + + tdSql.query("select UPPER(q_nchar),UPPER(q_nchar),LOWER(q_nchar),length(q_nchar),char_length(q_nchar) from stable_2 where tbname in ('stable_2_1') and q_tinyint <= 127 and t_smallint is not null and (q_binary like 'binary%' or q_nchar = '0' or q_binary = 'binary_' ) and t_bool in (0 , 1) ;") + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'NCHAR.辽宁省小红县安次刘路I座 783067') + tdSql.checkData(0, 1, 'NCHAR.辽宁省小红县安次刘路I座 783067') + tdSql.checkData(0, 2, 'nchar.辽宁省小红县安次刘路i座 783067') + tdSql.checkData(0, 3, 100) + tdSql.checkData(0, 4, 25) + tdSql.checkData(1, 0, 'NCHAR.浙江省呼和浩特市丰都田街T座 149274') + tdSql.checkData(1, 1, 'NCHAR.浙江省呼和浩特市丰都田街T座 149274') + tdSql.checkData(1, 2, 'nchar.浙江省呼和浩特市丰都田街t座 149274') + tdSql.checkData(1, 3, 108) + tdSql.checkData(1, 4, 27) + tdSql.checkData(2, 0, 'NCHAR.湖南省瑞县沙市王街C座 200752') + tdSql.checkData(2, 1, 'NCHAR.湖南省瑞县沙市王街C座 200752') + tdSql.checkData(2, 2, 'nchar.湖南省瑞县沙市王街c座 200752') + tdSql.checkData(2, 3, 96) + tdSql.checkData(2, 4, 24) + tdSql.checkData(3, 0, 'NCHAR.湖南省桂香市合川武汉路E座 190074') + tdSql.checkData(3, 1, 'NCHAR.湖南省桂香市合川武汉路E座 190074') + tdSql.checkData(3, 2, 'nchar.湖南省桂香市合川武汉路e座 190074') + tdSql.checkData(3, 3, 104) + tdSql.checkData(3, 4, 26) + tdSql.checkData(4, 0, 'NCHAR.北京市乌鲁木齐县金平郑州街K座 565319') + tdSql.checkData(4, 1, 'NCHAR.北京市乌鲁木齐县金平郑州街K座 565319') + tdSql.checkData(4, 2, 'nchar.北京市乌鲁木齐县金平郑州街k座 565319') + tdSql.checkData(4, 3, 112) + tdSql.checkData(4, 4, 28) + tdSql.checkData(5, 0, 'NCHAR.四川省潜江县蓟州陈街G座 347914') + tdSql.checkData(5, 1, 'NCHAR.四川省潜江县蓟州陈街G座 347914') + tdSql.checkData(5, 2, 'nchar.四川省潜江县蓟州陈街g座 347914') + tdSql.checkData(5, 3, 100) + tdSql.checkData(5, 4, 25) + + tdSql.query("select UPPER(q_nchar),UPPER(q_nchar),LOWER(q_nchar),length(q_nchar),char_length(q_nchar) from stable_2 where tbname in ('stable_2_1');") + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'NCHAR.辽宁省小红县安次刘路I座 783067') + tdSql.checkData(0, 1, 'NCHAR.辽宁省小红县安次刘路I座 783067') + tdSql.checkData(0, 2, 'nchar.辽宁省小红县安次刘路i座 783067') + tdSql.checkData(0, 3, 100) + tdSql.checkData(0, 4, 25) + tdSql.checkData(1, 0, 'NCHAR.浙江省呼和浩特市丰都田街T座 149274') + tdSql.checkData(1, 1, 'NCHAR.浙江省呼和浩特市丰都田街T座 149274') + tdSql.checkData(1, 2, 'nchar.浙江省呼和浩特市丰都田街t座 149274') + tdSql.checkData(1, 3, 108) + tdSql.checkData(1, 4, 27) + tdSql.checkData(2, 0, 'NCHAR.湖南省瑞县沙市王街C座 200752') + tdSql.checkData(2, 1, 'NCHAR.湖南省瑞县沙市王街C座 200752') + tdSql.checkData(2, 2, 'nchar.湖南省瑞县沙市王街c座 200752') + tdSql.checkData(2, 3, 96) + tdSql.checkData(2, 4, 24) + tdSql.checkData(3, 0, 'NCHAR.湖南省桂香市合川武汉路E座 190074') + tdSql.checkData(3, 1, 'NCHAR.湖南省桂香市合川武汉路E座 190074') + tdSql.checkData(3, 2, 'nchar.湖南省桂香市合川武汉路e座 190074') + tdSql.checkData(3, 3, 104) + tdSql.checkData(3, 4, 26) + tdSql.checkData(4, 0, 'NCHAR.北京市乌鲁木齐县金平郑州街K座 565319') + tdSql.checkData(4, 1, 'NCHAR.北京市乌鲁木齐县金平郑州街K座 565319') + tdSql.checkData(4, 2, 'nchar.北京市乌鲁木齐县金平郑州街k座 565319') + tdSql.checkData(4, 3, 112) + tdSql.checkData(4, 4, 28) + tdSql.checkData(5, 0, 'NCHAR.四川省潜江县蓟州陈街G座 347914') + tdSql.checkData(5, 1, 'NCHAR.四川省潜江县蓟州陈街G座 347914') + tdSql.checkData(5, 2, 'nchar.四川省潜江县蓟州陈街g座 347914') + tdSql.checkData(5, 3, 100) + tdSql.checkData(5, 4, 25) + + tdSql.query("select * from (select UPPER(q_nchar),UPPER(q_nchar),LOWER(q_nchar),length(q_nchar),char_length(q_nchar) from stable_2 where tbname in ('stable_2_1') and q_tinyint <= 127 and q_tinyint between -127 and 127 and (q_binary like 'binary%' or q_nchar = '0' or q_binary = 'binary_' ) and t_bool in (0 , 1) );") + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'NCHAR.辽宁省小红县安次刘路I座 783067') + tdSql.checkData(0, 1, 'NCHAR.辽宁省小红县安次刘路I座 783067') + tdSql.checkData(0, 2, 'nchar.辽宁省小红县安次刘路i座 783067') + tdSql.checkData(0, 3, 100) + tdSql.checkData(0, 4, 25) + tdSql.checkData(1, 0, 'NCHAR.浙江省呼和浩特市丰都田街T座 149274') + tdSql.checkData(1, 1, 'NCHAR.浙江省呼和浩特市丰都田街T座 149274') + tdSql.checkData(1, 2, 'nchar.浙江省呼和浩特市丰都田街t座 149274') + tdSql.checkData(1, 3, 108) + tdSql.checkData(1, 4, 27) + tdSql.checkData(2, 0, 'NCHAR.湖南省瑞县沙市王街C座 200752') + tdSql.checkData(2, 1, 'NCHAR.湖南省瑞县沙市王街C座 200752') + tdSql.checkData(2, 2, 'nchar.湖南省瑞县沙市王街c座 200752') + tdSql.checkData(2, 3, 96) + tdSql.checkData(2, 4, 24) + tdSql.checkData(3, 0, 'NCHAR.湖南省桂香市合川武汉路E座 190074') + tdSql.checkData(3, 1, 'NCHAR.湖南省桂香市合川武汉路E座 190074') + tdSql.checkData(3, 2, 'nchar.湖南省桂香市合川武汉路e座 190074') + tdSql.checkData(3, 3, 104) + tdSql.checkData(3, 4, 26) + tdSql.checkData(4, 0, 'NCHAR.北京市乌鲁木齐县金平郑州街K座 565319') + tdSql.checkData(4, 1, 'NCHAR.北京市乌鲁木齐县金平郑州街K座 565319') + tdSql.checkData(4, 2, 'nchar.北京市乌鲁木齐县金平郑州街k座 565319') + tdSql.checkData(4, 3, 112) + tdSql.checkData(4, 4, 28) + tdSql.checkData(5, 0, 'NCHAR.四川省潜江县蓟州陈街G座 347914') + tdSql.checkData(5, 1, 'NCHAR.四川省潜江县蓟州陈街G座 347914') + tdSql.checkData(5, 2, 'nchar.四川省潜江县蓟州陈街g座 347914') + tdSql.checkData(5, 3, 100) + tdSql.checkData(5, 4, 25) + + tdSql.query("select UPPER(q_nchar),LOWER(q_nchar),length(q_nchar),char_length(q_nchar) from stable_2 where tbname in ('stable_2_1');") + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'NCHAR.辽宁省小红县安次刘路I座 783067') + tdSql.checkData(0, 1, 'nchar.辽宁省小红县安次刘路i座 783067') + tdSql.checkData(0, 2, 100) + tdSql.checkData(0, 3, 25) + tdSql.checkData(1, 0, 'NCHAR.浙江省呼和浩特市丰都田街T座 149274') + tdSql.checkData(1, 1, 'nchar.浙江省呼和浩特市丰都田街t座 149274') + tdSql.checkData(1, 2, 108) + tdSql.checkData(1, 3, 27) + tdSql.checkData(2, 0, 'NCHAR.湖南省瑞县沙市王街C座 200752') + tdSql.checkData(2, 1, 'nchar.湖南省瑞县沙市王街c座 200752') + tdSql.checkData(2, 2, 96) + tdSql.checkData(2, 3, 24) + tdSql.checkData(3, 0, 'NCHAR.湖南省桂香市合川武汉路E座 190074') + tdSql.checkData(3, 1, 'nchar.湖南省桂香市合川武汉路e座 190074') + tdSql.checkData(3, 2, 104) + tdSql.checkData(3, 3, 26) + tdSql.checkData(4, 0, 'NCHAR.北京市乌鲁木齐县金平郑州街K座 565319') + tdSql.checkData(4, 1, 'nchar.北京市乌鲁木齐县金平郑州街k座 565319') + tdSql.checkData(4, 2, 112) + tdSql.checkData(4, 3, 28) + tdSql.checkData(5, 0, 'NCHAR.四川省潜江县蓟州陈街G座 347914') + tdSql.checkData(5, 1, 'nchar.四川省潜江县蓟州陈街g座 347914') + tdSql.checkData(5, 2, 100) + tdSql.checkData(5, 3, 25) + + tdSql.query("select UPPER(q_nchar) from stable_2 where tbname in ('stable_2_1') and q_tinyint <= 127 and q_tinyint between -127 and 127 and (q_binary like 'binary%' or q_nchar = '0' or q_binary = 'binary_' ) and t_bool in (0 , 1) ;") + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'NCHAR.辽宁省小红县安次刘路I座 783067') + tdSql.checkData(1, 0, 'NCHAR.浙江省呼和浩特市丰都田街T座 149274') + tdSql.checkData(2, 0, 'NCHAR.湖南省瑞县沙市王街C座 200752') + tdSql.checkData(3, 0, 'NCHAR.湖南省桂香市合川武汉路E座 190074') + tdSql.checkData(4, 0, 'NCHAR.北京市乌鲁木齐县金平郑州街K座 565319') + tdSql.checkData(5, 0, 'NCHAR.四川省潜江县蓟州陈街G座 347914') + + tdSql.query("select * from (select UPPER(q_binary),LOWER(q_binary),CONCAT(q_binary,q_binary) from stable_2 where tbname in ('stable_2_1') and q_int is not null and t_smallint >= -32767 and q_binary nmatch 'binarynchar' and (t_bool = true or t_bool = false) order by ts desc);") + tdSql.checkRows(6) + tdSql.checkData(0, 0, 'BINARY.ZETYSWJUDIKUGNDNHDDG') + tdSql.checkData(0, 1, 'binary.zetyswjudikugndnhddg') + tdSql.checkData(0, 2, 'binary.ZeTYsWJUdikuGndNhdDgbinary.ZeTYsWJUdikuGndNhdDg') + tdSql.checkData(1, 0, 'BINARY.SUSMJVNRTYRGADKOFSRP') + tdSql.checkData(1, 1, 'binary.susmjvnrtyrgadkofsrp') + tdSql.checkData(1, 2, 'binary.sUSMJvnrtyRGAdkofSRpbinary.sUSMJvnrtyRGAdkofSRp') + tdSql.checkData(2, 0, 'BINARY.MZEFOJUVAPGCOZRBPWSA') + tdSql.checkData(2, 1, 'binary.mzefojuvapgcozrbpwsa') + tdSql.checkData(2, 2, 'binary.mzefOJuVapGcOZRBPWSAbinary.mzefOJuVapGcOZRBPWSA') + tdSql.checkData(3, 0, 'BINARY.AQHUFBVMUNQFYSSMKMDT') + tdSql.checkData(3, 1, 'binary.aqhufbvmunqfyssmkmdt') + tdSql.checkData(3, 2, 'binary.aqhUfBvmuNqFySsMkMdtbinary.aqhUfBvmuNqFySsMkMdt') + tdSql.checkData(4, 0, 'BINARY.RENSISLQMQQRNTVDSVUC') + tdSql.checkData(4, 1, 'binary.rensislqmqqrntvdsvuc') + tdSql.checkData(4, 2, 'binary.REnSISlqmqqrnTVDsVucbinary.REnSISlqmqqrnTVDsVuc') + tdSql.checkData(5, 0, 'BINARY.RICJHNDLJVZXCUIUCTWP') + tdSql.checkData(5, 1, 'binary.ricjhndljvzxcuiuctwp') + tdSql.checkData(5, 2, 'binary.RicjHNdlJvZXcuIUCtwpbinary.RicjHNdlJvZXcuIUCtwp') + + tdSql.query("select * from (select ts, UPPER(q_binary), LOWER(q_binary) from stable_2 where tbname in ('stable_2_1') and q_int is not null and t_smallint >= -32767 and q_binary nmatch 'binarynchar' and (t_bool = true or t_bool = false)) order by ts desc;") + tdSql.checkRows(6) + tdSql.checkData(0, 0, datetime.datetime(2021, 8, 27, 1, 46, 41, 10000)) + tdSql.checkData(0, 1, 'BINARY.ZETYSWJUDIKUGNDNHDDG') + tdSql.checkData(0, 2, 'binary.zetyswjudikugndnhddg') + tdSql.checkData(1, 0, datetime.datetime(2021, 8, 27, 1, 46, 41, 1000)) + tdSql.checkData(1, 1, 'BINARY.SUSMJVNRTYRGADKOFSRP') + tdSql.checkData(1, 2, 'binary.susmjvnrtyrgadkofsrp') + tdSql.checkData(2, 0, datetime.datetime(2021, 8, 27, 1, 46, 41)) + tdSql.checkData(2, 1, 'BINARY.MZEFOJUVAPGCOZRBPWSA') + tdSql.checkData(2, 2, 'binary.mzefojuvapgcozrbpwsa') + tdSql.checkData(3, 0, datetime.datetime(2021, 8, 27, 1, 46, 40, 10000)) + tdSql.checkData(3, 1, 'BINARY.AQHUFBVMUNQFYSSMKMDT') + tdSql.checkData(3, 2, 'binary.aqhufbvmunqfyssmkmdt') + tdSql.checkData(4, 0, datetime.datetime(2021, 8, 27, 1, 46, 40, 1000)) + tdSql.checkData(4, 1, 'BINARY.RENSISLQMQQRNTVDSVUC') + tdSql.checkData(4, 2, 'binary.rensislqmqqrntvdsvuc') + tdSql.checkData(5, 0, datetime.datetime(2021, 8, 27, 1, 46, 40)) + tdSql.checkData(5, 1, 'BINARY.RICJHNDLJVZXCUIUCTWP') + tdSql.checkData(5, 2, 'binary.ricjhndljvzxcuiuctwp') + + tdSql.execute('drop database nchardb') + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/2-query/scalar_expression.py b/tests/develop-test/2-query/scalar_expression.py index 5ffe9d06da7a213f382527587396293f1d8dbc76..5e5aba6753ad2635d1fecd706732e7c9f61f4f76 100644 --- a/tests/develop-test/2-query/scalar_expression.py +++ b/tests/develop-test/2-query/scalar_expression.py @@ -1,22 +1,24 @@ -import sys +import sys from util.log import * from util.cases import * from util.sql import * from util.dnodes import tdDnodes -from math import inf +from math import inf, nan + class TDTestCase: def caseDescription(self): - ''' - case1: [TD-14123]: fix failed test on arm64 by converting from sim tst to python test to overcome NaN value and its string representation - ''' + """ + case1: [TD-14123]: fix failed test on arm64 by converting from sim tst to python test to overcome NaN value and its string representation + case2: [TD-14565]: log function default base param e + """ return - + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) self._conn = conn - + def restartTaosd(self, index=1, dbname="db"): tdDnodes.stop(index) tdDnodes.startWithoutSleep(index) @@ -26,33 +28,61 @@ class TDTestCase: print("running {}".format(__file__)) tdSql.execute("drop database if exists db0") tdSql.execute("create database if not exists db0") - tdSql.execute('use db0') - tdSql.execute('create table st0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int);') + tdSql.execute("use db0") + tdSql.execute( + "create table st0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int);" + ) + + tdSql.execute("create table ct0 using st0 tags( 0 );") - tdSql.execute('create table ct0 using st0 tags( 0 );') - tdSql.execute('insert into ct0 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );') + tdSql.execute( + "insert into ct0 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );" + ) for i in range(1, 50): - tdSql.execute('insert into ct0 values ({}, {}, {}, {}, {}, {}, {}, {}, {}, {});'.format(1601481600000 + i * 60000, - i , i , i , i , i , i , i , i , i )) + tdSql.execute( + "insert into ct0 values ({}, {}, {}, {}, {}, {}, {}, {}, {}, {});".format( + 1601481600000 + i * 60000, i, i, i, i, i, i, i, i, i + ) + ) - tdSql.execute('create table ct1 using st0 tags( 1 );') - tdSql.execute('insert into ct1 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );') + tdSql.execute("create table ct1 using st0 tags( 1 );") + + tdSql.execute( + "insert into ct1 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );" + ) for i in range(1, 50): - tdSql.execute('insert into ct1 values ({}, {}, {}, {}, {}, {}, {}, {}, {}, {});'.format(1601481600000 + i * 60000, - i , i , i , i , i , i , i , i , i )) + tdSql.execute( + "insert into ct1 values ({}, {}, {}, {}, {}, {}, {}, {}, {}, {});".format( + 1601481600000 + i * 60000, i, i, i, i, i, i, i, i, i + ) + ) + tdSql.execute( + "insert into ct1 values (1601484420000 , 47 , 47 , 47 , 47 , 47 , 47 , 47 , 47 , 47 );" + ) - tdSql.query('select floor(3.0)+ceil(4.0) from ct0;') - tdSql.checkRows(50) - for row in range(0, 50): - tdSql.checkData(row, 0, 7.0) + tdSql.execute( + "insert into ct1 values (1601484480000 , 48 , 48 , 48 , 48 , 48 , 48 , 48 , 48 , 48 );" + ) + tdSql.execute( + "insert into ct1 values (1601484540000 , 49 , 49 , 49 , 49 , 49 , 49 , 49 , 49 , 49 );" + ) - tdSql.query('select sum(c1)+3.0+4.0 from st0;') + tdSql.query("select floor(3.0)+ceil(4.0) from ct0;") + tdSql.checkRows(50) + for i in range(0, 50): + tdSql.checkData(i, 0, 7.0) + + tdSql.query("select sum(c1)+3.0+4.0 from st0;") tdSql.checkRows(1) tdSql.checkData(0, 0, 2457.0) - tdSql.query('select sin(log(avg(c1),sum(c2))+3)%4 from st0;') + tdSql.query("select sin(log(avg(c1))+3)%4 from st0;") + tdSql.checkRows(1) + tdSql.checkData(0, 0, -0.08441162350373656) + + tdSql.query("select sin(log(avg(c1),sum(c2))+3)%4 from st0;") tdSql.checkRows(1) tdSql.checkData(0, 0, -0.26507428560248714) @@ -159,7 +189,112 @@ class TDTestCase: tdSql.checkData(98, 0, 0.3581044635020827) tdSql.checkData(99, 0, 0.3562071871080222) - tdSql.query("select round(log(pow(length(concat('3','4')),2),c2)+floor(c3))+2 from st0;") + tdSql.query("select log(pow(length(concat('3','4')),2)) from st0;") + tdSql.checkRows(100) + tdSql.checkData(0, 0, 1.3862943611198906) + tdSql.checkData(1, 0, 1.3862943611198906) + tdSql.checkData(2, 0, 1.3862943611198906) + tdSql.checkData(3, 0, 1.3862943611198906) + tdSql.checkData(4, 0, 1.3862943611198906) + tdSql.checkData(5, 0, 1.3862943611198906) + tdSql.checkData(6, 0, 1.3862943611198906) + tdSql.checkData(7, 0, 1.3862943611198906) + tdSql.checkData(8, 0, 1.3862943611198906) + tdSql.checkData(9, 0, 1.3862943611198906) + tdSql.checkData(10, 0, 1.3862943611198906) + tdSql.checkData(11, 0, 1.3862943611198906) + tdSql.checkData(12, 0, 1.3862943611198906) + tdSql.checkData(13, 0, 1.3862943611198906) + tdSql.checkData(14, 0, 1.3862943611198906) + tdSql.checkData(15, 0, 1.3862943611198906) + tdSql.checkData(16, 0, 1.3862943611198906) + tdSql.checkData(17, 0, 1.3862943611198906) + tdSql.checkData(18, 0, 1.3862943611198906) + tdSql.checkData(19, 0, 1.3862943611198906) + tdSql.checkData(20, 0, 1.3862943611198906) + tdSql.checkData(21, 0, 1.3862943611198906) + tdSql.checkData(22, 0, 1.3862943611198906) + tdSql.checkData(23, 0, 1.3862943611198906) + tdSql.checkData(24, 0, 1.3862943611198906) + tdSql.checkData(25, 0, 1.3862943611198906) + tdSql.checkData(26, 0, 1.3862943611198906) + tdSql.checkData(27, 0, 1.3862943611198906) + tdSql.checkData(28, 0, 1.3862943611198906) + tdSql.checkData(29, 0, 1.3862943611198906) + tdSql.checkData(30, 0, 1.3862943611198906) + tdSql.checkData(31, 0, 1.3862943611198906) + tdSql.checkData(32, 0, 1.3862943611198906) + tdSql.checkData(33, 0, 1.3862943611198906) + tdSql.checkData(34, 0, 1.3862943611198906) + tdSql.checkData(35, 0, 1.3862943611198906) + tdSql.checkData(36, 0, 1.3862943611198906) + tdSql.checkData(37, 0, 1.3862943611198906) + tdSql.checkData(38, 0, 1.3862943611198906) + tdSql.checkData(39, 0, 1.3862943611198906) + tdSql.checkData(40, 0, 1.3862943611198906) + tdSql.checkData(41, 0, 1.3862943611198906) + tdSql.checkData(42, 0, 1.3862943611198906) + tdSql.checkData(43, 0, 1.3862943611198906) + tdSql.checkData(44, 0, 1.3862943611198906) + tdSql.checkData(45, 0, 1.3862943611198906) + tdSql.checkData(46, 0, 1.3862943611198906) + tdSql.checkData(47, 0, 1.3862943611198906) + tdSql.checkData(48, 0, 1.3862943611198906) + tdSql.checkData(49, 0, 1.3862943611198906) + tdSql.checkData(50, 0, 1.3862943611198906) + tdSql.checkData(51, 0, 1.3862943611198906) + tdSql.checkData(52, 0, 1.3862943611198906) + tdSql.checkData(53, 0, 1.3862943611198906) + tdSql.checkData(54, 0, 1.3862943611198906) + tdSql.checkData(55, 0, 1.3862943611198906) + tdSql.checkData(56, 0, 1.3862943611198906) + tdSql.checkData(57, 0, 1.3862943611198906) + tdSql.checkData(58, 0, 1.3862943611198906) + tdSql.checkData(59, 0, 1.3862943611198906) + tdSql.checkData(60, 0, 1.3862943611198906) + tdSql.checkData(61, 0, 1.3862943611198906) + tdSql.checkData(62, 0, 1.3862943611198906) + tdSql.checkData(63, 0, 1.3862943611198906) + tdSql.checkData(64, 0, 1.3862943611198906) + tdSql.checkData(65, 0, 1.3862943611198906) + tdSql.checkData(66, 0, 1.3862943611198906) + tdSql.checkData(67, 0, 1.3862943611198906) + tdSql.checkData(68, 0, 1.3862943611198906) + tdSql.checkData(69, 0, 1.3862943611198906) + tdSql.checkData(70, 0, 1.3862943611198906) + tdSql.checkData(71, 0, 1.3862943611198906) + tdSql.checkData(72, 0, 1.3862943611198906) + tdSql.checkData(73, 0, 1.3862943611198906) + tdSql.checkData(74, 0, 1.3862943611198906) + tdSql.checkData(75, 0, 1.3862943611198906) + tdSql.checkData(76, 0, 1.3862943611198906) + tdSql.checkData(77, 0, 1.3862943611198906) + tdSql.checkData(78, 0, 1.3862943611198906) + tdSql.checkData(79, 0, 1.3862943611198906) + tdSql.checkData(80, 0, 1.3862943611198906) + tdSql.checkData(81, 0, 1.3862943611198906) + tdSql.checkData(82, 0, 1.3862943611198906) + tdSql.checkData(83, 0, 1.3862943611198906) + tdSql.checkData(84, 0, 1.3862943611198906) + tdSql.checkData(85, 0, 1.3862943611198906) + tdSql.checkData(86, 0, 1.3862943611198906) + tdSql.checkData(87, 0, 1.3862943611198906) + tdSql.checkData(88, 0, 1.3862943611198906) + tdSql.checkData(89, 0, 1.3862943611198906) + tdSql.checkData(90, 0, 1.3862943611198906) + tdSql.checkData(91, 0, 1.3862943611198906) + tdSql.checkData(92, 0, 1.3862943611198906) + tdSql.checkData(93, 0, 1.3862943611198906) + tdSql.checkData(94, 0, 1.3862943611198906) + tdSql.checkData(95, 0, 1.3862943611198906) + tdSql.checkData(96, 0, 1.3862943611198906) + tdSql.checkData(97, 0, 1.3862943611198906) + tdSql.checkData(98, 0, 1.3862943611198906) + tdSql.checkData(99, 0, 1.3862943611198906) + + tdSql.query( + "select round(log(pow(length(concat('3','4')),2),c2)+floor(c3))+2 from st0;" + ) tdSql.checkRows(100) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, inf) @@ -262,9 +397,116 @@ class TDTestCase: tdSql.checkData(98, 0, 50.0) tdSql.checkData(99, 0, 51.0) - tdSql.query('select sin(pow(c1,log(c2,2))+pow(c2,2)) as val from ct0 union all select pow(c4,2)+tan(sin(c5)/cos(c6)) as val from ct1;') + tdSql.query( + "select round(log(pow(length(concat('3','4')),2))+floor(c3))+2 from st0;" + ) tdSql.checkRows(100) - tdSql.checkData(0, 0, None) + tdSql.checkData(0, 0, 3.0) + tdSql.checkData(1, 0, 4.0) + tdSql.checkData(2, 0, 5.0) + tdSql.checkData(3, 0, 6.0) + tdSql.checkData(4, 0, 7.0) + tdSql.checkData(5, 0, 8.0) + tdSql.checkData(6, 0, 9.0) + tdSql.checkData(7, 0, 10.0) + tdSql.checkData(8, 0, 11.0) + tdSql.checkData(9, 0, 12.0) + tdSql.checkData(10, 0, 13.0) + tdSql.checkData(11, 0, 14.0) + tdSql.checkData(12, 0, 15.0) + tdSql.checkData(13, 0, 16.0) + tdSql.checkData(14, 0, 17.0) + tdSql.checkData(15, 0, 18.0) + tdSql.checkData(16, 0, 19.0) + tdSql.checkData(17, 0, 20.0) + tdSql.checkData(18, 0, 21.0) + tdSql.checkData(19, 0, 22.0) + tdSql.checkData(20, 0, 23.0) + tdSql.checkData(21, 0, 24.0) + tdSql.checkData(22, 0, 25.0) + tdSql.checkData(23, 0, 26.0) + tdSql.checkData(24, 0, 27.0) + tdSql.checkData(25, 0, 28.0) + tdSql.checkData(26, 0, 29.0) + tdSql.checkData(27, 0, 30.0) + tdSql.checkData(28, 0, 31.0) + tdSql.checkData(29, 0, 32.0) + tdSql.checkData(30, 0, 33.0) + tdSql.checkData(31, 0, 34.0) + tdSql.checkData(32, 0, 35.0) + tdSql.checkData(33, 0, 36.0) + tdSql.checkData(34, 0, 37.0) + tdSql.checkData(35, 0, 38.0) + tdSql.checkData(36, 0, 39.0) + tdSql.checkData(37, 0, 40.0) + tdSql.checkData(38, 0, 41.0) + tdSql.checkData(39, 0, 42.0) + tdSql.checkData(40, 0, 43.0) + tdSql.checkData(41, 0, 44.0) + tdSql.checkData(42, 0, 45.0) + tdSql.checkData(43, 0, 46.0) + tdSql.checkData(44, 0, 47.0) + tdSql.checkData(45, 0, 48.0) + tdSql.checkData(46, 0, 49.0) + tdSql.checkData(47, 0, 50.0) + tdSql.checkData(48, 0, 51.0) + tdSql.checkData(49, 0, 52.0) + tdSql.checkData(50, 0, 3.0) + tdSql.checkData(51, 0, 4.0) + tdSql.checkData(52, 0, 5.0) + tdSql.checkData(53, 0, 6.0) + tdSql.checkData(54, 0, 7.0) + tdSql.checkData(55, 0, 8.0) + tdSql.checkData(56, 0, 9.0) + tdSql.checkData(57, 0, 10.0) + tdSql.checkData(58, 0, 11.0) + tdSql.checkData(59, 0, 12.0) + tdSql.checkData(60, 0, 13.0) + tdSql.checkData(61, 0, 14.0) + tdSql.checkData(62, 0, 15.0) + tdSql.checkData(63, 0, 16.0) + tdSql.checkData(64, 0, 17.0) + tdSql.checkData(65, 0, 18.0) + tdSql.checkData(66, 0, 19.0) + tdSql.checkData(67, 0, 20.0) + tdSql.checkData(68, 0, 21.0) + tdSql.checkData(69, 0, 22.0) + tdSql.checkData(70, 0, 23.0) + tdSql.checkData(71, 0, 24.0) + tdSql.checkData(72, 0, 25.0) + tdSql.checkData(73, 0, 26.0) + tdSql.checkData(74, 0, 27.0) + tdSql.checkData(75, 0, 28.0) + tdSql.checkData(76, 0, 29.0) + tdSql.checkData(77, 0, 30.0) + tdSql.checkData(78, 0, 31.0) + tdSql.checkData(79, 0, 32.0) + tdSql.checkData(80, 0, 33.0) + tdSql.checkData(81, 0, 34.0) + tdSql.checkData(82, 0, 35.0) + tdSql.checkData(83, 0, 36.0) + tdSql.checkData(84, 0, 37.0) + tdSql.checkData(85, 0, 38.0) + tdSql.checkData(86, 0, 39.0) + tdSql.checkData(87, 0, 40.0) + tdSql.checkData(88, 0, 41.0) + tdSql.checkData(89, 0, 42.0) + tdSql.checkData(90, 0, 43.0) + tdSql.checkData(91, 0, 44.0) + tdSql.checkData(92, 0, 45.0) + tdSql.checkData(93, 0, 46.0) + tdSql.checkData(94, 0, 47.0) + tdSql.checkData(95, 0, 48.0) + tdSql.checkData(96, 0, 49.0) + tdSql.checkData(97, 0, 50.0) + tdSql.checkData(98, 0, 51.0) + tdSql.checkData(99, 0, 52.0) + + tdSql.query( + "select sin(pow(c1,log(c2,2))+pow(c2,2)) as val from ct0 union all select pow(c4,2)+tan(sin(c5)/cos(c6)) as val from ct1;" + ) + tdSql.checkRows(100) + tdSql.checkData(0, 0, nan) tdSql.checkData(1, 0, 0.9092974268256817) tdSql.checkData(2, 0, -0.27941549819892586) tdSql.checkData(3, 0, 0.8433250578156978) @@ -365,15 +607,120 @@ class TDTestCase: tdSql.checkData(98, 0, 2306.5731210183926) tdSql.checkData(99, 0, 2400.9686738603973) - tdSql.query('select asin(c1) from st0 limit 1;') + tdSql.query( + "select sin(pow(c1,log(c2))+pow(c2,2)) as val from ct0 union all select pow(c4,2)+tan(sin(c5)/cos(c6)) as val from ct1;" + ) + tdSql.checkRows(100) + tdSql.checkData(0, 0, nan) + tdSql.checkData(1, 0, 0.9092974268256817) + tdSql.checkData(2, 0, -0.618143416955856) + tdSql.checkData(3, 0, -0.2212557848433586) + tdSql.checkData(4, 0, -0.7460971214044105) + tdSql.checkData(5, 0, 0.592800037732941) + tdSql.checkData(6, 0, -0.8906573525446361) + tdSql.checkData(7, 0, -0.9099160274536024) + tdSql.checkData(8, 0, 0.9538272638464387) + tdSql.checkData(9, 0, -0.9870736916693152) + tdSql.checkData(10, 0, -0.7678397236409038) + tdSql.checkData(11, 0, 0.9987895951483741) + tdSql.checkData(12, 0, 0.6508715058131205) + tdSql.checkData(13, 0, 0.27310147774290205) + tdSql.checkData(14, 0, -0.852597740468949) + tdSql.checkData(15, 0, 0.35731340778818926) + tdSql.checkData(16, 0, -0.9981208983068915) + tdSql.checkData(17, 0, 0.23713034837959204) + tdSql.checkData(18, 0, -0.9227979044693351) + tdSql.checkData(19, 0, 0.7969587979292067) + tdSql.checkData(20, 0, -0.9894078111821204) + tdSql.checkData(21, 0, 0.5159266172394235) + tdSql.checkData(22, 0, 0.04665947694609208) + tdSql.checkData(23, 0, -0.9057268036004363) + tdSql.checkData(24, 0, 0.5081537719119912) + tdSql.checkData(25, 0, 0.13392418253128227) + tdSql.checkData(26, 0, 0.22117745004778874) + tdSql.checkData(27, 0, 0.3454954775028113) + tdSql.checkData(28, 0, 0.5242670110408245) + tdSql.checkData(29, 0, 0.8951019564578349) + tdSql.checkData(30, 0, 0.9881770927793502) + tdSql.checkData(31, 0, 0.7074846709788886) + tdSql.checkData(32, 0, 0.9954576249796087) + tdSql.checkData(33, 0, -0.7704946306359923) + tdSql.checkData(34, 0, 0.9966097580600035) + tdSql.checkData(35, 0, -0.03188573219367) + tdSql.checkData(36, 0, 0.9672274483362059) + tdSql.checkData(37, 0, -0.5524968695809724) + tdSql.checkData(38, 0, 0.4230579655135496) + tdSql.checkData(39, 0, 0.21369691105494243) + tdSql.checkData(40, 0, -0.46608214968746425) + tdSql.checkData(41, 0, -0.2069391679125316) + tdSql.checkData(42, 0, -0.978130009430021) + tdSql.checkData(43, 0, -0.7145841372258956) + tdSql.checkData(44, 0, -0.07829036190548645) + tdSql.checkData(45, 0, -0.5852465890666977) + tdSql.checkData(46, 0, -0.6043735013959997) + tdSql.checkData(47, 0, 0.4866796582369138) + tdSql.checkData(48, 0, 0.06632187104835804) + tdSql.checkData(49, 0, 0.9288185068522878) + tdSql.checkData(50, 0, 0.0) + tdSql.checkData(51, 0, 75.68593339876413) + tdSql.checkData(52, 0, 5.417928575505387) + tdSql.checkData(53, 0, 8.85648005221507) + tdSql.checkData(54, 0, 18.282204450191365) + tdSql.checkData(55, 0, 24.756425180209273) + tdSql.checkData(56, 0, 35.7004910910186) + tdSql.checkData(57, 0, 50.188813241198766) + tdSql.checkData(58, 0, 63.43204170645191) + tdSql.checkData(59, 0, 80.51408573049088) + tdSql.checkData(60, 0, 100.75762114788726) + tdSql.checkData(61, 0, 121.24877416559158) + tdSql.checkData(62, 0, 143.26187154057212) + tdSql.checkData(63, 0, 169.49921715003558) + tdSql.checkData(64, 0, 197.43268735470073) + tdSql.checkData(65, 0, 223.84781294184071) + tdSql.checkData(66, 0, 256.31002912578884) + tdSql.checkData(67, 0, 289.36766325453783) + tdSql.checkData(68, 0, 321.83943972533865) + tdSql.checkData(69, 0, 361.1527613871425) + tdSql.checkData(70, 0, 398.72830803672844) + tdSql.checkData(71, 0, 417.9185722713414) + tdSql.checkData(72, 0, 484.00885188723004) + tdSql.checkData(73, 0, 471.3913348423639) + tdSql.checkData(74, 0, 577.5805869142416) + tdSql.checkData(75, 0, 624.8656743315343) + tdSql.checkData(76, 0, 678.4187022341146) + tdSql.checkData(77, 0, 728.8671148549121) + tdSql.checkData(78, 0, 783.7108972216736) + tdSql.checkData(79, 0, 842.2274126544997) + tdSql.checkData(80, 0, 899.877243006616) + tdSql.checkData(81, 0, 960.5271464519064) + tdSql.checkData(82, 0, 1024.7777181923664) + tdSql.checkData(83, 0, 1089.0854157079946) + tdSql.checkData(84, 0, 1155.2807954785546) + tdSql.checkData(85, 0, 1225.5127742681332) + tdSql.checkData(86, 0, 1305.6263061095037) + tdSql.checkData(87, 0, 1367.8826349729482) + tdSql.checkData(88, 0, 1444.32066897418) + tdSql.checkData(89, 0, 1521.5116974949854) + tdSql.checkData(90, 0, 1597.9486330581901) + tdSql.checkData(91, 0, 1681.1620533335488) + tdSql.checkData(92, 0, 1762.8611973159218) + tdSql.checkData(93, 0, 1835.2137045408574) + tdSql.checkData(94, 0, 1936.0177065493942) + tdSql.checkData(95, 0, 2004.599358732067) + tdSql.checkData(96, 0, 2117.763602992286) + tdSql.checkData(97, 0, 2208.874824726169) + tdSql.checkData(98, 0, 2306.5731210183926) + tdSql.checkData(99, 0, 2400.9686738603973) + + tdSql.query("select asin(c1) from st0 limit 1;") tdSql.checkRows(1) tdSql.checkData(0, 0, 0.0) - tdSql.query('select pow(c1,2) from st0 limit 1 offset 2;;') + tdSql.query("select pow(c1,2) from st0 limit 1 offset 2;;") tdSql.checkRows(1) tdSql.checkData(0, 0, 4.0) - tdSql.query('select cos(c1) from db0.ct0, db0.ct1 where ct0.ts==ct1.ts;') + tdSql.query("select cos(c1) from db0.ct0, db0.ct1 where ct0.ts==ct1.ts;") tdSql.checkRows(50) tdSql.checkData(0, 0, 1.0) tdSql.checkData(1, 0, 0.5403023058681398) @@ -426,7 +773,9 @@ class TDTestCase: tdSql.checkData(48, 0, -0.6401443394691997) tdSql.checkData(49, 0, 0.3005925437436371) - tdSql.query('select sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(c1)))))))))))))))) from st0;') + tdSql.query( + "select sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(sin(c1)))))))))))))))) from st0;" + ) tdSql.checkRows(100) tdSql.checkData(0, 0, 0.0) tdSql.checkData(1, 0, 0.38515571309652635) @@ -529,12 +878,12 @@ class TDTestCase: tdSql.checkData(98, 0, -0.3782246656581614) tdSql.checkData(99, 0, -0.392935768393244) - tdSql.execute('drop database db0;') - + tdSql.execute("drop database db0") def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) + tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/2-query/scalar_powlog.py b/tests/develop-test/2-query/scalar_powlog.py new file mode 100644 index 0000000000000000000000000000000000000000..3c8829b082d45995a7754fd4c5aad1f42cb74b28 --- /dev/null +++ b/tests/develop-test/2-query/scalar_powlog.py @@ -0,0 +1,3014 @@ +import sys +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import tdDnodes +from math import inf + + +class TDTestCase: + def caseDescription(self): + """ + case1: [TD-14565]power/log test case. log support default param e + """ + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self._conn = conn + + def restartTaosd(self, index=1, dbname="db"): + tdDnodes.stop(index) + tdDnodes.startWithoutSleep(index) + tdSql.execute(f"use db0") + + def run(self): + print("running {}".format(__file__)) + tdSql.execute("drop database if exists db0") + tdSql.execute("create database if not exists db0") + tdSql.execute("use db0") + + tdSql.execute( + "create table st0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int);" + ) + + tdSql.execute("create table ct0 using st0 tags( 0 );") + + tdSql.execute( + "insert into ct0 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );" + ) + + tdSql.execute( + "insert into ct0 values (1601481660000 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 );" + ) + + tdSql.execute( + "insert into ct0 values (1601481720000 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 );" + ) + + tdSql.execute( + "insert into ct0 values (1601481780000 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 );" + ) + + tdSql.execute( + "insert into ct0 values (1601481840000 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 );" + ) + + tdSql.execute( + "insert into ct0 values (1601481900000 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 );" + ) + + tdSql.execute( + "insert into ct0 values (1601481960000 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 );" + ) + + tdSql.execute( + "insert into ct0 values (1601482020000 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 );" + ) + + tdSql.execute( + "insert into ct0 values (1601482080000 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 );" + ) + + tdSql.execute( + "insert into ct0 values (1601482140000 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 );" + ) + + tdSql.execute("create table ct1 using st0 tags( 1 );") + + tdSql.execute( + "insert into ct1 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );" + ) + + tdSql.execute( + "insert into ct1 values (1601481660000 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 );" + ) + + tdSql.execute( + "insert into ct1 values (1601481720000 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 );" + ) + + tdSql.execute( + "insert into ct1 values (1601481780000 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 );" + ) + + tdSql.execute( + "insert into ct1 values (1601481840000 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 , 4 );" + ) + + tdSql.execute( + "insert into ct1 values (1601481900000 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 );" + ) + + tdSql.execute( + "insert into ct1 values (1601481960000 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 , 6 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482020000 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 7 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482080000 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482140000 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 , 9 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482200000 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 , 10 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482260000 , 11 , 11 , 11 , 11 , 11 , 11 , 11 , 11 , 11 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482320000 , 12 , 12 , 12 , 12 , 12 , 12 , 12 , 12 , 12 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482380000 , 13 , 13 , 13 , 13 , 13 , 13 , 13 , 13 , 13 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482440000 , 14 , 14 , 14 , 14 , 14 , 14 , 14 , 14 , 14 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482500000 , 15 , 15 , 15 , 15 , 15 , 15 , 15 , 15 , 15 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482560000 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 , 16 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482620000 , 17 , 17 , 17 , 17 , 17 , 17 , 17 , 17 , 17 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482680000 , 18 , 18 , 18 , 18 , 18 , 18 , 18 , 18 , 18 );" + ) + + tdSql.execute( + "insert into ct1 values (1601482740000 , 19 , 19 , 19 , 19 , 19 , 19 , 19 , 19 , 19 );" + ) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from ct1;" + ) + tdSql.checkRows(20) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + tdSql.checkData(2, 0, 2) + tdSql.checkData(2, 1, 1.0) + tdSql.checkData(2, 2, 4.0) + tdSql.checkData(2, 3, 6.0) + tdSql.checkData(2, 4, 13.0) + tdSql.checkData(2, 5, 26.627416997969522) + tdSql.checkData(2, 6, 10.464404506368993) + tdSql.checkData(3, 0, 3) + tdSql.checkData(3, 1, 1.5849625007211563) + tdSql.checkData(3, 2, 9.0) + tdSql.checkData(3, 3, 11.0) + tdSql.checkData(3, 4, 37.58496250072116) + tdSql.checkData(3, 5, 149.29611541307906) + tdSql.checkData(3, 6, 26.05146591860796) + tdSql.checkData(4, 0, 4) + tdSql.checkData(4, 1, 2.0) + tdSql.checkData(4, 2, 16.0) + tdSql.checkData(4, 3, 18.0) + tdSql.checkData(4, 4, 82.0) + tdSql.checkData(4, 5, 528.0) + tdSql.checkData(4, 6, 53.50293012833273) + tdSql.checkData(5, 0, 5) + tdSql.checkData(5, 1, 2.321928094887362) + tdSql.checkData(5, 2, 25.0) + tdSql.checkData(5, 3, 27.0) + tdSql.checkData(5, 4, 152.32192809488737) + tdSql.checkData(5, 5, 1422.5424859373686) + tdSql.checkData(5, 6, 96.08035010204296) + tdSql.checkData(6, 0, 6) + tdSql.checkData(6, 1, 2.584962500721156) + tdSql.checkData(6, 2, 36.0) + tdSql.checkData(6, 3, 38.0) + tdSql.checkData(6, 4, 254.58496250072116) + tdSql.checkData(6, 5, 3210.538706646999) + tdSql.checkData(6, 6, 156.8241014057428) + tdSql.checkData(7, 0, 7) + tdSql.checkData(7, 1, 2.807354922057604) + tdSql.checkData(7, 2, 49.0) + tdSql.checkData(7, 3, 51.0) + tdSql.checkData(7, 4, 394.8073549220576) + tdSql.checkData(7, 5, 6401.448897866082) + tdSql.checkData(7, 6, 238.6315756794513) + tdSql.checkData(8, 0, 8) + tdSql.checkData(8, 1, 3.0) + tdSql.checkData(8, 2, 64.0) + tdSql.checkData(8, 3, 66.0) + tdSql.checkData(8, 4, 579.0) + tdSql.checkData(8, 5, 11649.237502960395) + tdSql.checkData(8, 6, 344.2940251578608) + tdSql.checkData(9, 0, 9) + tdSql.checkData(9, 1, 3.1699250014423126) + tdSql.checkData(9, 2, 81.0) + tdSql.checkData(9, 3, 83.0) + tdSql.checkData(9, 4, 813.1699250014423) + tdSql.checkData(9, 5, 19764.0) + tdSql.checkData(9, 6, 476.5181244205816) + tdSql.checkData(10, 0, 10) + tdSql.checkData(10, 1, 3.3219280948873626) + tdSql.checkData(10, 2, 100.0) + tdSql.checkData(10, 3, 102.0) + tdSql.checkData(10, 4, 1103.3219280948874) + tdSql.checkData(10, 5, 31722.776601683792) + tdSql.checkData(10, 6, 637.940236622524) + tdSql.checkData(11, 0, 11) + tdSql.checkData(11, 1, 3.4594316186372978) + tdSql.checkData(11, 2, 121.0) + tdSql.checkData(11, 3, 123.0) + tdSql.checkData(11, 4, 1455.4594316186374) + tdSql.checkData(11, 5, 48679.70355559341) + tdSql.checkData(11, 6, 831.1366058581541) + tdSql.checkData(12, 0, 12) + tdSql.checkData(12, 1, 3.5849625007211565) + tdSql.checkData(12, 2, 144.0) + tdSql.checkData(12, 3, 146.0) + tdSql.checkData(12, 4, 1875.584962500721) + tdSql.checkData(12, 5, 71975.61109149648) + tdSql.checkData(12, 6, 1058.631026542541) + tdSql.checkData(13, 0, 13) + tdSql.checkData(13, 1, 3.700439718141092) + tdSql.checkData(13, 2, 169.0) + tdSql.checkData(13, 3, 171.0) + tdSql.checkData(13, 4, 2369.7004397181413) + tdSql.checkData(13, 5, 103147.149978527) + tdSql.checkData(13, 6, 1322.9008332018816) + tdSql.checkData(14, 0, 14) + tdSql.checkData(14, 1, 3.8073549220576037) + tdSql.checkData(14, 2, 196.0) + tdSql.checkData(14, 3, 198.0) + tdSql.checkData(14, 4, 2943.8073549220576) + tdSql.checkData(14, 5, 143935.51017030774) + tdSql.checkData(14, 6, 1626.3817114890194) + tdSql.checkData(15, 0, 15) + tdSql.checkData(15, 1, 3.9068905956085187) + tdSql.checkData(15, 2, 225.0) + tdSql.checkData(15, 3, 227.0) + tdSql.checkData(15, 4, 3603.9068905956087) + tdSql.checkData(15, 5, 196294.78190175048) + tdSql.checkData(15, 6, 1971.471648033734) + tdSql.checkData(16, 0, 16) + tdSql.checkData(16, 1, 4.0) + tdSql.checkData(16, 2, 256.0) + tdSql.checkData(16, 3, 258.0) + tdSql.checkData(16, 4, 4356.0) + tdSql.checkData(16, 5, 262400.0) + tdSql.checkData(16, 6, 2360.5342310339265) + tdSql.checkData(17, 0, 17) + tdSql.checkData(17, 1, 4.08746284125034) + tdSql.checkData(17, 2, 289.0) + tdSql.checkData(17, 3, 291.0) + tdSql.checkData(17, 4, 5206.08746284125) + tdSql.checkData(17, 5, 344654.9049572126) + tdSql.checkData(17, 6, 2795.901448766347) + tdSql.checkData(18, 0, 18) + tdSql.checkData(18, 1, 4.169925001442312) + tdSql.checkData(18, 2, 324.0) + tdSql.checkData(18, 3, 326.0) + tdSql.checkData(18, 4, 6160.169925001443) + tdSql.checkData(18, 5, 445699.4487710341) + tdSql.checkData(18, 6, 3279.8760916232795) + tdSql.checkData(19, 0, 19) + tdSql.checkData(19, 1, 4.247927513443585) + tdSql.checkData(19, 2, 361.0) + tdSql.checkData(19, 3, 363.0) + tdSql.checkData(19, 4, 7224.247927513444) + tdSql.checkData(19, 5, 568417.0692211641) + tdSql.checkData(19, 6, 3814.7338355198453) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from ct1 where ts == 1601481600000;" + ) + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from st0 where ts == 1601481600000;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 0) + tdSql.checkData(1, 1, -2.0) + tdSql.checkData(1, 2, 0.0) + tdSql.checkData(1, 3, 2.0625) + tdSql.checkData(1, 4, -inf) + tdSql.checkData(1, 5, 0.0) + tdSql.checkData(1, 6, -inf) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from st0 where c1 == 0;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 0) + tdSql.checkData(1, 1, -2.0) + tdSql.checkData(1, 2, 0.0) + tdSql.checkData(1, 3, 2.0625) + tdSql.checkData(1, 4, -inf) + tdSql.checkData(1, 5, 0.0) + tdSql.checkData(1, 6, -inf) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from st0 where c1 == 0;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 0) + tdSql.checkData(1, 1, -2.0) + tdSql.checkData(1, 2, 0.0) + tdSql.checkData(1, 3, 2.0625) + tdSql.checkData(1, 4, -inf) + tdSql.checkData(1, 5, 0.0) + tdSql.checkData(1, 6, -inf) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from st0 order by ts desc;" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 19) + tdSql.checkData(0, 1, 4.247927513443585) + tdSql.checkData(0, 2, 361.0) + tdSql.checkData(0, 3, 363.0) + tdSql.checkData(0, 4, 7224.247927513444) + tdSql.checkData(0, 5, 568417.0692211641) + tdSql.checkData(0, 6, 3814.7338355198453) + tdSql.checkData(1, 0, 18) + tdSql.checkData(1, 1, 4.169925001442312) + tdSql.checkData(1, 2, 324.0) + tdSql.checkData(1, 3, 326.0) + tdSql.checkData(1, 4, 6160.169925001443) + tdSql.checkData(1, 5, 445699.4487710341) + tdSql.checkData(1, 6, 3279.8760916232795) + tdSql.checkData(2, 0, 17) + tdSql.checkData(2, 1, 4.08746284125034) + tdSql.checkData(2, 2, 289.0) + tdSql.checkData(2, 3, 291.0) + tdSql.checkData(2, 4, 5206.08746284125) + tdSql.checkData(2, 5, 344654.9049572126) + tdSql.checkData(2, 6, 2795.901448766347) + tdSql.checkData(3, 0, 16) + tdSql.checkData(3, 1, 4.0) + tdSql.checkData(3, 2, 256.0) + tdSql.checkData(3, 3, 258.0) + tdSql.checkData(3, 4, 4356.0) + tdSql.checkData(3, 5, 262400.0) + tdSql.checkData(3, 6, 2360.5342310339265) + tdSql.checkData(4, 0, 15) + tdSql.checkData(4, 1, 3.9068905956085187) + tdSql.checkData(4, 2, 225.0) + tdSql.checkData(4, 3, 227.0) + tdSql.checkData(4, 4, 3603.9068905956087) + tdSql.checkData(4, 5, 196294.78190175048) + tdSql.checkData(4, 6, 1971.471648033734) + tdSql.checkData(5, 0, 14) + tdSql.checkData(5, 1, 3.8073549220576037) + tdSql.checkData(5, 2, 196.0) + tdSql.checkData(5, 3, 198.0) + tdSql.checkData(5, 4, 2943.8073549220576) + tdSql.checkData(5, 5, 143935.51017030774) + tdSql.checkData(5, 6, 1626.3817114890194) + tdSql.checkData(6, 0, 13) + tdSql.checkData(6, 1, 3.700439718141092) + tdSql.checkData(6, 2, 169.0) + tdSql.checkData(6, 3, 171.0) + tdSql.checkData(6, 4, 2369.7004397181413) + tdSql.checkData(6, 5, 103147.149978527) + tdSql.checkData(6, 6, 1322.9008332018816) + tdSql.checkData(7, 0, 12) + tdSql.checkData(7, 1, 3.5849625007211565) + tdSql.checkData(7, 2, 144.0) + tdSql.checkData(7, 3, 146.0) + tdSql.checkData(7, 4, 1875.584962500721) + tdSql.checkData(7, 5, 71975.61109149648) + tdSql.checkData(7, 6, 1058.631026542541) + tdSql.checkData(8, 0, 11) + tdSql.checkData(8, 1, 3.4594316186372978) + tdSql.checkData(8, 2, 121.0) + tdSql.checkData(8, 3, 123.0) + tdSql.checkData(8, 4, 1455.4594316186374) + tdSql.checkData(8, 5, 48679.70355559341) + tdSql.checkData(8, 6, 831.1366058581541) + tdSql.checkData(9, 0, 10) + tdSql.checkData(9, 1, 3.3219280948873626) + tdSql.checkData(9, 2, 100.0) + tdSql.checkData(9, 3, 102.0) + tdSql.checkData(9, 4, 1103.3219280948874) + tdSql.checkData(9, 5, 31722.776601683792) + tdSql.checkData(9, 6, 637.940236622524) + tdSql.checkData(10, 0, 9) + tdSql.checkData(10, 1, 3.1699250014423126) + tdSql.checkData(10, 2, 81.0) + tdSql.checkData(10, 3, 83.0) + tdSql.checkData(10, 4, 813.1699250014423) + tdSql.checkData(10, 5, 19764.0) + tdSql.checkData(10, 6, 476.5181244205816) + tdSql.checkData(11, 0, 9) + tdSql.checkData(11, 1, 3.1699250014423126) + tdSql.checkData(11, 2, 81.0) + tdSql.checkData(11, 3, 83.0) + tdSql.checkData(11, 4, 813.1699250014423) + tdSql.checkData(11, 5, 19764.0) + tdSql.checkData(11, 6, 476.5181244205816) + tdSql.checkData(12, 0, 8) + tdSql.checkData(12, 1, 3.0) + tdSql.checkData(12, 2, 64.0) + tdSql.checkData(12, 3, 66.0) + tdSql.checkData(12, 4, 579.0) + tdSql.checkData(12, 5, 11649.237502960395) + tdSql.checkData(12, 6, 344.2940251578608) + tdSql.checkData(13, 0, 8) + tdSql.checkData(13, 1, 3.0) + tdSql.checkData(13, 2, 64.0) + tdSql.checkData(13, 3, 66.0) + tdSql.checkData(13, 4, 579.0) + tdSql.checkData(13, 5, 11649.237502960395) + tdSql.checkData(13, 6, 344.2940251578608) + tdSql.checkData(14, 0, 7) + tdSql.checkData(14, 1, 2.807354922057604) + tdSql.checkData(14, 2, 49.0) + tdSql.checkData(14, 3, 51.0) + tdSql.checkData(14, 4, 394.8073549220576) + tdSql.checkData(14, 5, 6401.448897866082) + tdSql.checkData(14, 6, 238.6315756794513) + tdSql.checkData(15, 0, 7) + tdSql.checkData(15, 1, 2.807354922057604) + tdSql.checkData(15, 2, 49.0) + tdSql.checkData(15, 3, 51.0) + tdSql.checkData(15, 4, 394.8073549220576) + tdSql.checkData(15, 5, 6401.448897866082) + tdSql.checkData(15, 6, 238.6315756794513) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 2.584962500721156) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 254.58496250072116) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.8241014057428) + tdSql.checkData(17, 0, 6) + tdSql.checkData(17, 1, 2.584962500721156) + tdSql.checkData(17, 2, 36.0) + tdSql.checkData(17, 3, 38.0) + tdSql.checkData(17, 4, 254.58496250072116) + tdSql.checkData(17, 5, 3210.538706646999) + tdSql.checkData(17, 6, 156.8241014057428) + tdSql.checkData(18, 0, 5) + tdSql.checkData(18, 1, 2.321928094887362) + tdSql.checkData(18, 2, 25.0) + tdSql.checkData(18, 3, 27.0) + tdSql.checkData(18, 4, 152.32192809488737) + tdSql.checkData(18, 5, 1422.5424859373686) + tdSql.checkData(18, 6, 96.08035010204296) + tdSql.checkData(19, 0, 5) + tdSql.checkData(19, 1, 2.321928094887362) + tdSql.checkData(19, 2, 25.0) + tdSql.checkData(19, 3, 27.0) + tdSql.checkData(19, 4, 152.32192809488737) + tdSql.checkData(19, 5, 1422.5424859373686) + tdSql.checkData(19, 6, 96.08035010204296) + tdSql.checkData(20, 0, 4) + tdSql.checkData(20, 1, 2.0) + tdSql.checkData(20, 2, 16.0) + tdSql.checkData(20, 3, 18.0) + tdSql.checkData(20, 4, 82.0) + tdSql.checkData(20, 5, 528.0) + tdSql.checkData(20, 6, 53.50293012833273) + tdSql.checkData(21, 0, 4) + tdSql.checkData(21, 1, 2.0) + tdSql.checkData(21, 2, 16.0) + tdSql.checkData(21, 3, 18.0) + tdSql.checkData(21, 4, 82.0) + tdSql.checkData(21, 5, 528.0) + tdSql.checkData(21, 6, 53.50293012833273) + tdSql.checkData(22, 0, 3) + tdSql.checkData(22, 1, 1.5849625007211563) + tdSql.checkData(22, 2, 9.0) + tdSql.checkData(22, 3, 11.0) + tdSql.checkData(22, 4, 37.58496250072116) + tdSql.checkData(22, 5, 149.29611541307906) + tdSql.checkData(22, 6, 26.05146591860796) + tdSql.checkData(23, 0, 3) + tdSql.checkData(23, 1, 1.5849625007211563) + tdSql.checkData(23, 2, 9.0) + tdSql.checkData(23, 3, 11.0) + tdSql.checkData(23, 4, 37.58496250072116) + tdSql.checkData(23, 5, 149.29611541307906) + tdSql.checkData(23, 6, 26.05146591860796) + tdSql.checkData(24, 0, 2) + tdSql.checkData(24, 1, 1.0) + tdSql.checkData(24, 2, 4.0) + tdSql.checkData(24, 3, 6.0) + tdSql.checkData(24, 4, 13.0) + tdSql.checkData(24, 5, 26.627416997969522) + tdSql.checkData(24, 6, 10.464404506368993) + tdSql.checkData(25, 0, 2) + tdSql.checkData(25, 1, 1.0) + tdSql.checkData(25, 2, 4.0) + tdSql.checkData(25, 3, 6.0) + tdSql.checkData(25, 4, 13.0) + tdSql.checkData(25, 5, 26.627416997969522) + tdSql.checkData(25, 6, 10.464404506368993) + tdSql.checkData(26, 0, 1) + tdSql.checkData(26, 1, 0.0) + tdSql.checkData(26, 2, 1.0) + tdSql.checkData(26, 3, 3.0) + tdSql.checkData(26, 4, 2.0) + tdSql.checkData(26, 5, 2.0) + tdSql.checkData(26, 6, 3.0) + tdSql.checkData(27, 0, 1) + tdSql.checkData(27, 1, 0.0) + tdSql.checkData(27, 2, 1.0) + tdSql.checkData(27, 3, 3.0) + tdSql.checkData(27, 4, 2.0) + tdSql.checkData(27, 5, 2.0) + tdSql.checkData(27, 6, 3.0) + tdSql.checkData(28, 0, 0) + tdSql.checkData(28, 1, -2.0) + tdSql.checkData(28, 2, 0.0) + tdSql.checkData(28, 3, 2.0625) + tdSql.checkData(28, 4, -inf) + tdSql.checkData(28, 5, 0.0) + tdSql.checkData(28, 6, -inf) + tdSql.checkData(29, 0, 0) + tdSql.checkData(29, 1, -2.0) + tdSql.checkData(29, 2, 0.0) + tdSql.checkData(29, 3, 2.0625) + tdSql.checkData(29, 4, -inf) + tdSql.checkData(29, 5, 0.0) + tdSql.checkData(29, 6, -inf) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from ct1 order by ts limit 2;;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + + tdSql.query( + "select sqrt(abs(log(c1,2)-pow(c1,2)))+2 from ct1 order by ts limit 2;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, inf) + tdSql.checkData(1, 0, 3.0) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from st0 order by ts desc);" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 19) + tdSql.checkData(0, 1, 4.247927513443585) + tdSql.checkData(0, 2, 361.0) + tdSql.checkData(0, 3, 363.0) + tdSql.checkData(0, 4, 7224.247927513444) + tdSql.checkData(0, 5, 568417.0692211641) + tdSql.checkData(0, 6, 3814.7338355198453) + tdSql.checkData(1, 0, 18) + tdSql.checkData(1, 1, 4.169925001442312) + tdSql.checkData(1, 2, 324.0) + tdSql.checkData(1, 3, 326.0) + tdSql.checkData(1, 4, 6160.169925001443) + tdSql.checkData(1, 5, 445699.4487710341) + tdSql.checkData(1, 6, 3279.8760916232795) + tdSql.checkData(2, 0, 17) + tdSql.checkData(2, 1, 4.08746284125034) + tdSql.checkData(2, 2, 289.0) + tdSql.checkData(2, 3, 291.0) + tdSql.checkData(2, 4, 5206.08746284125) + tdSql.checkData(2, 5, 344654.9049572126) + tdSql.checkData(2, 6, 2795.901448766347) + tdSql.checkData(3, 0, 16) + tdSql.checkData(3, 1, 4.0) + tdSql.checkData(3, 2, 256.0) + tdSql.checkData(3, 3, 258.0) + tdSql.checkData(3, 4, 4356.0) + tdSql.checkData(3, 5, 262400.0) + tdSql.checkData(3, 6, 2360.5342310339265) + tdSql.checkData(4, 0, 15) + tdSql.checkData(4, 1, 3.9068905956085187) + tdSql.checkData(4, 2, 225.0) + tdSql.checkData(4, 3, 227.0) + tdSql.checkData(4, 4, 3603.9068905956087) + tdSql.checkData(4, 5, 196294.78190175048) + tdSql.checkData(4, 6, 1971.471648033734) + tdSql.checkData(5, 0, 14) + tdSql.checkData(5, 1, 3.8073549220576037) + tdSql.checkData(5, 2, 196.0) + tdSql.checkData(5, 3, 198.0) + tdSql.checkData(5, 4, 2943.8073549220576) + tdSql.checkData(5, 5, 143935.51017030774) + tdSql.checkData(5, 6, 1626.3817114890194) + tdSql.checkData(6, 0, 13) + tdSql.checkData(6, 1, 3.700439718141092) + tdSql.checkData(6, 2, 169.0) + tdSql.checkData(6, 3, 171.0) + tdSql.checkData(6, 4, 2369.7004397181413) + tdSql.checkData(6, 5, 103147.149978527) + tdSql.checkData(6, 6, 1322.9008332018816) + tdSql.checkData(7, 0, 12) + tdSql.checkData(7, 1, 3.5849625007211565) + tdSql.checkData(7, 2, 144.0) + tdSql.checkData(7, 3, 146.0) + tdSql.checkData(7, 4, 1875.584962500721) + tdSql.checkData(7, 5, 71975.61109149648) + tdSql.checkData(7, 6, 1058.631026542541) + tdSql.checkData(8, 0, 11) + tdSql.checkData(8, 1, 3.4594316186372978) + tdSql.checkData(8, 2, 121.0) + tdSql.checkData(8, 3, 123.0) + tdSql.checkData(8, 4, 1455.4594316186374) + tdSql.checkData(8, 5, 48679.70355559341) + tdSql.checkData(8, 6, 831.1366058581541) + tdSql.checkData(9, 0, 10) + tdSql.checkData(9, 1, 3.3219280948873626) + tdSql.checkData(9, 2, 100.0) + tdSql.checkData(9, 3, 102.0) + tdSql.checkData(9, 4, 1103.3219280948874) + tdSql.checkData(9, 5, 31722.776601683792) + tdSql.checkData(9, 6, 637.940236622524) + tdSql.checkData(10, 0, 9) + tdSql.checkData(10, 1, 3.1699250014423126) + tdSql.checkData(10, 2, 81.0) + tdSql.checkData(10, 3, 83.0) + tdSql.checkData(10, 4, 813.1699250014423) + tdSql.checkData(10, 5, 19764.0) + tdSql.checkData(10, 6, 476.5181244205816) + tdSql.checkData(11, 0, 9) + tdSql.checkData(11, 1, 3.1699250014423126) + tdSql.checkData(11, 2, 81.0) + tdSql.checkData(11, 3, 83.0) + tdSql.checkData(11, 4, 813.1699250014423) + tdSql.checkData(11, 5, 19764.0) + tdSql.checkData(11, 6, 476.5181244205816) + tdSql.checkData(12, 0, 8) + tdSql.checkData(12, 1, 3.0) + tdSql.checkData(12, 2, 64.0) + tdSql.checkData(12, 3, 66.0) + tdSql.checkData(12, 4, 579.0) + tdSql.checkData(12, 5, 11649.237502960395) + tdSql.checkData(12, 6, 344.2940251578608) + tdSql.checkData(13, 0, 8) + tdSql.checkData(13, 1, 3.0) + tdSql.checkData(13, 2, 64.0) + tdSql.checkData(13, 3, 66.0) + tdSql.checkData(13, 4, 579.0) + tdSql.checkData(13, 5, 11649.237502960395) + tdSql.checkData(13, 6, 344.2940251578608) + tdSql.checkData(14, 0, 7) + tdSql.checkData(14, 1, 2.807354922057604) + tdSql.checkData(14, 2, 49.0) + tdSql.checkData(14, 3, 51.0) + tdSql.checkData(14, 4, 394.8073549220576) + tdSql.checkData(14, 5, 6401.448897866082) + tdSql.checkData(14, 6, 238.6315756794513) + tdSql.checkData(15, 0, 7) + tdSql.checkData(15, 1, 2.807354922057604) + tdSql.checkData(15, 2, 49.0) + tdSql.checkData(15, 3, 51.0) + tdSql.checkData(15, 4, 394.8073549220576) + tdSql.checkData(15, 5, 6401.448897866082) + tdSql.checkData(15, 6, 238.6315756794513) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 2.584962500721156) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 254.58496250072116) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.8241014057428) + tdSql.checkData(17, 0, 6) + tdSql.checkData(17, 1, 2.584962500721156) + tdSql.checkData(17, 2, 36.0) + tdSql.checkData(17, 3, 38.0) + tdSql.checkData(17, 4, 254.58496250072116) + tdSql.checkData(17, 5, 3210.538706646999) + tdSql.checkData(17, 6, 156.8241014057428) + tdSql.checkData(18, 0, 5) + tdSql.checkData(18, 1, 2.321928094887362) + tdSql.checkData(18, 2, 25.0) + tdSql.checkData(18, 3, 27.0) + tdSql.checkData(18, 4, 152.32192809488737) + tdSql.checkData(18, 5, 1422.5424859373686) + tdSql.checkData(18, 6, 96.08035010204296) + tdSql.checkData(19, 0, 5) + tdSql.checkData(19, 1, 2.321928094887362) + tdSql.checkData(19, 2, 25.0) + tdSql.checkData(19, 3, 27.0) + tdSql.checkData(19, 4, 152.32192809488737) + tdSql.checkData(19, 5, 1422.5424859373686) + tdSql.checkData(19, 6, 96.08035010204296) + tdSql.checkData(20, 0, 4) + tdSql.checkData(20, 1, 2.0) + tdSql.checkData(20, 2, 16.0) + tdSql.checkData(20, 3, 18.0) + tdSql.checkData(20, 4, 82.0) + tdSql.checkData(20, 5, 528.0) + tdSql.checkData(20, 6, 53.50293012833273) + tdSql.checkData(21, 0, 4) + tdSql.checkData(21, 1, 2.0) + tdSql.checkData(21, 2, 16.0) + tdSql.checkData(21, 3, 18.0) + tdSql.checkData(21, 4, 82.0) + tdSql.checkData(21, 5, 528.0) + tdSql.checkData(21, 6, 53.50293012833273) + tdSql.checkData(22, 0, 3) + tdSql.checkData(22, 1, 1.5849625007211563) + tdSql.checkData(22, 2, 9.0) + tdSql.checkData(22, 3, 11.0) + tdSql.checkData(22, 4, 37.58496250072116) + tdSql.checkData(22, 5, 149.29611541307906) + tdSql.checkData(22, 6, 26.05146591860796) + tdSql.checkData(23, 0, 3) + tdSql.checkData(23, 1, 1.5849625007211563) + tdSql.checkData(23, 2, 9.0) + tdSql.checkData(23, 3, 11.0) + tdSql.checkData(23, 4, 37.58496250072116) + tdSql.checkData(23, 5, 149.29611541307906) + tdSql.checkData(23, 6, 26.05146591860796) + tdSql.checkData(24, 0, 2) + tdSql.checkData(24, 1, 1.0) + tdSql.checkData(24, 2, 4.0) + tdSql.checkData(24, 3, 6.0) + tdSql.checkData(24, 4, 13.0) + tdSql.checkData(24, 5, 26.627416997969522) + tdSql.checkData(24, 6, 10.464404506368993) + tdSql.checkData(25, 0, 2) + tdSql.checkData(25, 1, 1.0) + tdSql.checkData(25, 2, 4.0) + tdSql.checkData(25, 3, 6.0) + tdSql.checkData(25, 4, 13.0) + tdSql.checkData(25, 5, 26.627416997969522) + tdSql.checkData(25, 6, 10.464404506368993) + tdSql.checkData(26, 0, 1) + tdSql.checkData(26, 1, 0.0) + tdSql.checkData(26, 2, 1.0) + tdSql.checkData(26, 3, 3.0) + tdSql.checkData(26, 4, 2.0) + tdSql.checkData(26, 5, 2.0) + tdSql.checkData(26, 6, 3.0) + tdSql.checkData(27, 0, 1) + tdSql.checkData(27, 1, 0.0) + tdSql.checkData(27, 2, 1.0) + tdSql.checkData(27, 3, 3.0) + tdSql.checkData(27, 4, 2.0) + tdSql.checkData(27, 5, 2.0) + tdSql.checkData(27, 6, 3.0) + tdSql.checkData(28, 0, 0) + tdSql.checkData(28, 1, -2.0) + tdSql.checkData(28, 2, 0.0) + tdSql.checkData(28, 3, 2.0625) + tdSql.checkData(28, 4, -inf) + tdSql.checkData(28, 5, 0.0) + tdSql.checkData(28, 6, -inf) + tdSql.checkData(29, 0, 0) + tdSql.checkData(29, 1, -2.0) + tdSql.checkData(29, 2, 0.0) + tdSql.checkData(29, 3, 2.0625) + tdSql.checkData(29, 4, -inf) + tdSql.checkData(29, 5, 0.0) + tdSql.checkData(29, 6, -inf) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from ct1 order by ts limit 2);;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from st0 ) order by ts desc;" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 19) + tdSql.checkData(0, 1, 4.247927513443585) + tdSql.checkData(0, 2, 361.0) + tdSql.checkData(0, 3, 363.0) + tdSql.checkData(0, 4, 7224.247927513444) + tdSql.checkData(0, 5, 568417.0692211641) + tdSql.checkData(0, 6, 3814.7338355198453) + tdSql.checkData(1, 0, 18) + tdSql.checkData(1, 1, 4.169925001442312) + tdSql.checkData(1, 2, 324.0) + tdSql.checkData(1, 3, 326.0) + tdSql.checkData(1, 4, 6160.169925001443) + tdSql.checkData(1, 5, 445699.4487710341) + tdSql.checkData(1, 6, 3279.8760916232795) + tdSql.checkData(2, 0, 17) + tdSql.checkData(2, 1, 4.08746284125034) + tdSql.checkData(2, 2, 289.0) + tdSql.checkData(2, 3, 291.0) + tdSql.checkData(2, 4, 5206.08746284125) + tdSql.checkData(2, 5, 344654.9049572126) + tdSql.checkData(2, 6, 2795.901448766347) + tdSql.checkData(3, 0, 16) + tdSql.checkData(3, 1, 4.0) + tdSql.checkData(3, 2, 256.0) + tdSql.checkData(3, 3, 258.0) + tdSql.checkData(3, 4, 4356.0) + tdSql.checkData(3, 5, 262400.0) + tdSql.checkData(3, 6, 2360.5342310339265) + tdSql.checkData(4, 0, 15) + tdSql.checkData(4, 1, 3.9068905956085187) + tdSql.checkData(4, 2, 225.0) + tdSql.checkData(4, 3, 227.0) + tdSql.checkData(4, 4, 3603.9068905956087) + tdSql.checkData(4, 5, 196294.78190175048) + tdSql.checkData(4, 6, 1971.471648033734) + tdSql.checkData(5, 0, 14) + tdSql.checkData(5, 1, 3.8073549220576037) + tdSql.checkData(5, 2, 196.0) + tdSql.checkData(5, 3, 198.0) + tdSql.checkData(5, 4, 2943.8073549220576) + tdSql.checkData(5, 5, 143935.51017030774) + tdSql.checkData(5, 6, 1626.3817114890194) + tdSql.checkData(6, 0, 13) + tdSql.checkData(6, 1, 3.700439718141092) + tdSql.checkData(6, 2, 169.0) + tdSql.checkData(6, 3, 171.0) + tdSql.checkData(6, 4, 2369.7004397181413) + tdSql.checkData(6, 5, 103147.149978527) + tdSql.checkData(6, 6, 1322.9008332018816) + tdSql.checkData(7, 0, 12) + tdSql.checkData(7, 1, 3.5849625007211565) + tdSql.checkData(7, 2, 144.0) + tdSql.checkData(7, 3, 146.0) + tdSql.checkData(7, 4, 1875.584962500721) + tdSql.checkData(7, 5, 71975.61109149648) + tdSql.checkData(7, 6, 1058.631026542541) + tdSql.checkData(8, 0, 11) + tdSql.checkData(8, 1, 3.4594316186372978) + tdSql.checkData(8, 2, 121.0) + tdSql.checkData(8, 3, 123.0) + tdSql.checkData(8, 4, 1455.4594316186374) + tdSql.checkData(8, 5, 48679.70355559341) + tdSql.checkData(8, 6, 831.1366058581541) + tdSql.checkData(9, 0, 10) + tdSql.checkData(9, 1, 3.3219280948873626) + tdSql.checkData(9, 2, 100.0) + tdSql.checkData(9, 3, 102.0) + tdSql.checkData(9, 4, 1103.3219280948874) + tdSql.checkData(9, 5, 31722.776601683792) + tdSql.checkData(9, 6, 637.940236622524) + tdSql.checkData(10, 0, 9) + tdSql.checkData(10, 1, 3.1699250014423126) + tdSql.checkData(10, 2, 81.0) + tdSql.checkData(10, 3, 83.0) + tdSql.checkData(10, 4, 813.1699250014423) + tdSql.checkData(10, 5, 19764.0) + tdSql.checkData(10, 6, 476.5181244205816) + tdSql.checkData(11, 0, 9) + tdSql.checkData(11, 1, 3.1699250014423126) + tdSql.checkData(11, 2, 81.0) + tdSql.checkData(11, 3, 83.0) + tdSql.checkData(11, 4, 813.1699250014423) + tdSql.checkData(11, 5, 19764.0) + tdSql.checkData(11, 6, 476.5181244205816) + tdSql.checkData(12, 0, 8) + tdSql.checkData(12, 1, 3.0) + tdSql.checkData(12, 2, 64.0) + tdSql.checkData(12, 3, 66.0) + tdSql.checkData(12, 4, 579.0) + tdSql.checkData(12, 5, 11649.237502960395) + tdSql.checkData(12, 6, 344.2940251578608) + tdSql.checkData(13, 0, 8) + tdSql.checkData(13, 1, 3.0) + tdSql.checkData(13, 2, 64.0) + tdSql.checkData(13, 3, 66.0) + tdSql.checkData(13, 4, 579.0) + tdSql.checkData(13, 5, 11649.237502960395) + tdSql.checkData(13, 6, 344.2940251578608) + tdSql.checkData(14, 0, 7) + tdSql.checkData(14, 1, 2.807354922057604) + tdSql.checkData(14, 2, 49.0) + tdSql.checkData(14, 3, 51.0) + tdSql.checkData(14, 4, 394.8073549220576) + tdSql.checkData(14, 5, 6401.448897866082) + tdSql.checkData(14, 6, 238.6315756794513) + tdSql.checkData(15, 0, 7) + tdSql.checkData(15, 1, 2.807354922057604) + tdSql.checkData(15, 2, 49.0) + tdSql.checkData(15, 3, 51.0) + tdSql.checkData(15, 4, 394.8073549220576) + tdSql.checkData(15, 5, 6401.448897866082) + tdSql.checkData(15, 6, 238.6315756794513) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 2.584962500721156) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 254.58496250072116) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.8241014057428) + tdSql.checkData(17, 0, 6) + tdSql.checkData(17, 1, 2.584962500721156) + tdSql.checkData(17, 2, 36.0) + tdSql.checkData(17, 3, 38.0) + tdSql.checkData(17, 4, 254.58496250072116) + tdSql.checkData(17, 5, 3210.538706646999) + tdSql.checkData(17, 6, 156.8241014057428) + tdSql.checkData(18, 0, 5) + tdSql.checkData(18, 1, 2.321928094887362) + tdSql.checkData(18, 2, 25.0) + tdSql.checkData(18, 3, 27.0) + tdSql.checkData(18, 4, 152.32192809488737) + tdSql.checkData(18, 5, 1422.5424859373686) + tdSql.checkData(18, 6, 96.08035010204296) + tdSql.checkData(19, 0, 5) + tdSql.checkData(19, 1, 2.321928094887362) + tdSql.checkData(19, 2, 25.0) + tdSql.checkData(19, 3, 27.0) + tdSql.checkData(19, 4, 152.32192809488737) + tdSql.checkData(19, 5, 1422.5424859373686) + tdSql.checkData(19, 6, 96.08035010204296) + tdSql.checkData(20, 0, 4) + tdSql.checkData(20, 1, 2.0) + tdSql.checkData(20, 2, 16.0) + tdSql.checkData(20, 3, 18.0) + tdSql.checkData(20, 4, 82.0) + tdSql.checkData(20, 5, 528.0) + tdSql.checkData(20, 6, 53.50293012833273) + tdSql.checkData(21, 0, 4) + tdSql.checkData(21, 1, 2.0) + tdSql.checkData(21, 2, 16.0) + tdSql.checkData(21, 3, 18.0) + tdSql.checkData(21, 4, 82.0) + tdSql.checkData(21, 5, 528.0) + tdSql.checkData(21, 6, 53.50293012833273) + tdSql.checkData(22, 0, 3) + tdSql.checkData(22, 1, 1.5849625007211563) + tdSql.checkData(22, 2, 9.0) + tdSql.checkData(22, 3, 11.0) + tdSql.checkData(22, 4, 37.58496250072116) + tdSql.checkData(22, 5, 149.29611541307906) + tdSql.checkData(22, 6, 26.05146591860796) + tdSql.checkData(23, 0, 3) + tdSql.checkData(23, 1, 1.5849625007211563) + tdSql.checkData(23, 2, 9.0) + tdSql.checkData(23, 3, 11.0) + tdSql.checkData(23, 4, 37.58496250072116) + tdSql.checkData(23, 5, 149.29611541307906) + tdSql.checkData(23, 6, 26.05146591860796) + tdSql.checkData(24, 0, 2) + tdSql.checkData(24, 1, 1.0) + tdSql.checkData(24, 2, 4.0) + tdSql.checkData(24, 3, 6.0) + tdSql.checkData(24, 4, 13.0) + tdSql.checkData(24, 5, 26.627416997969522) + tdSql.checkData(24, 6, 10.464404506368993) + tdSql.checkData(25, 0, 2) + tdSql.checkData(25, 1, 1.0) + tdSql.checkData(25, 2, 4.0) + tdSql.checkData(25, 3, 6.0) + tdSql.checkData(25, 4, 13.0) + tdSql.checkData(25, 5, 26.627416997969522) + tdSql.checkData(25, 6, 10.464404506368993) + tdSql.checkData(26, 0, 1) + tdSql.checkData(26, 1, 0.0) + tdSql.checkData(26, 2, 1.0) + tdSql.checkData(26, 3, 3.0) + tdSql.checkData(26, 4, 2.0) + tdSql.checkData(26, 5, 2.0) + tdSql.checkData(26, 6, 3.0) + tdSql.checkData(27, 0, 1) + tdSql.checkData(27, 1, 0.0) + tdSql.checkData(27, 2, 1.0) + tdSql.checkData(27, 3, 3.0) + tdSql.checkData(27, 4, 2.0) + tdSql.checkData(27, 5, 2.0) + tdSql.checkData(27, 6, 3.0) + tdSql.checkData(28, 0, 0) + tdSql.checkData(28, 1, -2.0) + tdSql.checkData(28, 2, 0.0) + tdSql.checkData(28, 3, 2.0625) + tdSql.checkData(28, 4, -inf) + tdSql.checkData(28, 5, 0.0) + tdSql.checkData(28, 6, -inf) + tdSql.checkData(29, 0, 0) + tdSql.checkData(29, 1, -2.0) + tdSql.checkData(29, 2, 0.0) + tdSql.checkData(29, 3, 2.0625) + tdSql.checkData(29, 4, -inf) + tdSql.checkData(29, 5, 0.0) + tdSql.checkData(29, 6, -inf) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from st0 );" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + tdSql.checkData(2, 0, 2) + tdSql.checkData(2, 1, 1.0) + tdSql.checkData(2, 2, 4.0) + tdSql.checkData(2, 3, 6.0) + tdSql.checkData(2, 4, 13.0) + tdSql.checkData(2, 5, 26.627416997969522) + tdSql.checkData(2, 6, 10.464404506368993) + tdSql.checkData(3, 0, 3) + tdSql.checkData(3, 1, 1.5849625007211563) + tdSql.checkData(3, 2, 9.0) + tdSql.checkData(3, 3, 11.0) + tdSql.checkData(3, 4, 37.58496250072116) + tdSql.checkData(3, 5, 149.29611541307906) + tdSql.checkData(3, 6, 26.05146591860796) + tdSql.checkData(4, 0, 4) + tdSql.checkData(4, 1, 2.0) + tdSql.checkData(4, 2, 16.0) + tdSql.checkData(4, 3, 18.0) + tdSql.checkData(4, 4, 82.0) + tdSql.checkData(4, 5, 528.0) + tdSql.checkData(4, 6, 53.50293012833273) + tdSql.checkData(5, 0, 5) + tdSql.checkData(5, 1, 2.321928094887362) + tdSql.checkData(5, 2, 25.0) + tdSql.checkData(5, 3, 27.0) + tdSql.checkData(5, 4, 152.32192809488737) + tdSql.checkData(5, 5, 1422.5424859373686) + tdSql.checkData(5, 6, 96.08035010204296) + tdSql.checkData(6, 0, 6) + tdSql.checkData(6, 1, 2.584962500721156) + tdSql.checkData(6, 2, 36.0) + tdSql.checkData(6, 3, 38.0) + tdSql.checkData(6, 4, 254.58496250072116) + tdSql.checkData(6, 5, 3210.538706646999) + tdSql.checkData(6, 6, 156.8241014057428) + tdSql.checkData(7, 0, 7) + tdSql.checkData(7, 1, 2.807354922057604) + tdSql.checkData(7, 2, 49.0) + tdSql.checkData(7, 3, 51.0) + tdSql.checkData(7, 4, 394.8073549220576) + tdSql.checkData(7, 5, 6401.448897866082) + tdSql.checkData(7, 6, 238.6315756794513) + tdSql.checkData(8, 0, 8) + tdSql.checkData(8, 1, 3.0) + tdSql.checkData(8, 2, 64.0) + tdSql.checkData(8, 3, 66.0) + tdSql.checkData(8, 4, 579.0) + tdSql.checkData(8, 5, 11649.237502960395) + tdSql.checkData(8, 6, 344.2940251578608) + tdSql.checkData(9, 0, 9) + tdSql.checkData(9, 1, 3.1699250014423126) + tdSql.checkData(9, 2, 81.0) + tdSql.checkData(9, 3, 83.0) + tdSql.checkData(9, 4, 813.1699250014423) + tdSql.checkData(9, 5, 19764.0) + tdSql.checkData(9, 6, 476.5181244205816) + tdSql.checkData(10, 0, 0) + tdSql.checkData(10, 1, -2.0) + tdSql.checkData(10, 2, 0.0) + tdSql.checkData(10, 3, 2.0625) + tdSql.checkData(10, 4, -inf) + tdSql.checkData(10, 5, 0.0) + tdSql.checkData(10, 6, -inf) + tdSql.checkData(11, 0, 1) + tdSql.checkData(11, 1, 0.0) + tdSql.checkData(11, 2, 1.0) + tdSql.checkData(11, 3, 3.0) + tdSql.checkData(11, 4, 2.0) + tdSql.checkData(11, 5, 2.0) + tdSql.checkData(11, 6, 3.0) + tdSql.checkData(12, 0, 2) + tdSql.checkData(12, 1, 1.0) + tdSql.checkData(12, 2, 4.0) + tdSql.checkData(12, 3, 6.0) + tdSql.checkData(12, 4, 13.0) + tdSql.checkData(12, 5, 26.627416997969522) + tdSql.checkData(12, 6, 10.464404506368993) + tdSql.checkData(13, 0, 3) + tdSql.checkData(13, 1, 1.5849625007211563) + tdSql.checkData(13, 2, 9.0) + tdSql.checkData(13, 3, 11.0) + tdSql.checkData(13, 4, 37.58496250072116) + tdSql.checkData(13, 5, 149.29611541307906) + tdSql.checkData(13, 6, 26.05146591860796) + tdSql.checkData(14, 0, 4) + tdSql.checkData(14, 1, 2.0) + tdSql.checkData(14, 2, 16.0) + tdSql.checkData(14, 3, 18.0) + tdSql.checkData(14, 4, 82.0) + tdSql.checkData(14, 5, 528.0) + tdSql.checkData(14, 6, 53.50293012833273) + tdSql.checkData(15, 0, 5) + tdSql.checkData(15, 1, 2.321928094887362) + tdSql.checkData(15, 2, 25.0) + tdSql.checkData(15, 3, 27.0) + tdSql.checkData(15, 4, 152.32192809488737) + tdSql.checkData(15, 5, 1422.5424859373686) + tdSql.checkData(15, 6, 96.08035010204296) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 2.584962500721156) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 254.58496250072116) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.8241014057428) + tdSql.checkData(17, 0, 7) + tdSql.checkData(17, 1, 2.807354922057604) + tdSql.checkData(17, 2, 49.0) + tdSql.checkData(17, 3, 51.0) + tdSql.checkData(17, 4, 394.8073549220576) + tdSql.checkData(17, 5, 6401.448897866082) + tdSql.checkData(17, 6, 238.6315756794513) + tdSql.checkData(18, 0, 8) + tdSql.checkData(18, 1, 3.0) + tdSql.checkData(18, 2, 64.0) + tdSql.checkData(18, 3, 66.0) + tdSql.checkData(18, 4, 579.0) + tdSql.checkData(18, 5, 11649.237502960395) + tdSql.checkData(18, 6, 344.2940251578608) + tdSql.checkData(19, 0, 9) + tdSql.checkData(19, 1, 3.1699250014423126) + tdSql.checkData(19, 2, 81.0) + tdSql.checkData(19, 3, 83.0) + tdSql.checkData(19, 4, 813.1699250014423) + tdSql.checkData(19, 5, 19764.0) + tdSql.checkData(19, 6, 476.5181244205816) + tdSql.checkData(20, 0, 10) + tdSql.checkData(20, 1, 3.3219280948873626) + tdSql.checkData(20, 2, 100.0) + tdSql.checkData(20, 3, 102.0) + tdSql.checkData(20, 4, 1103.3219280948874) + tdSql.checkData(20, 5, 31722.776601683792) + tdSql.checkData(20, 6, 637.940236622524) + tdSql.checkData(21, 0, 11) + tdSql.checkData(21, 1, 3.4594316186372978) + tdSql.checkData(21, 2, 121.0) + tdSql.checkData(21, 3, 123.0) + tdSql.checkData(21, 4, 1455.4594316186374) + tdSql.checkData(21, 5, 48679.70355559341) + tdSql.checkData(21, 6, 831.1366058581541) + tdSql.checkData(22, 0, 12) + tdSql.checkData(22, 1, 3.5849625007211565) + tdSql.checkData(22, 2, 144.0) + tdSql.checkData(22, 3, 146.0) + tdSql.checkData(22, 4, 1875.584962500721) + tdSql.checkData(22, 5, 71975.61109149648) + tdSql.checkData(22, 6, 1058.631026542541) + tdSql.checkData(23, 0, 13) + tdSql.checkData(23, 1, 3.700439718141092) + tdSql.checkData(23, 2, 169.0) + tdSql.checkData(23, 3, 171.0) + tdSql.checkData(23, 4, 2369.7004397181413) + tdSql.checkData(23, 5, 103147.149978527) + tdSql.checkData(23, 6, 1322.9008332018816) + tdSql.checkData(24, 0, 14) + tdSql.checkData(24, 1, 3.8073549220576037) + tdSql.checkData(24, 2, 196.0) + tdSql.checkData(24, 3, 198.0) + tdSql.checkData(24, 4, 2943.8073549220576) + tdSql.checkData(24, 5, 143935.51017030774) + tdSql.checkData(24, 6, 1626.3817114890194) + tdSql.checkData(25, 0, 15) + tdSql.checkData(25, 1, 3.9068905956085187) + tdSql.checkData(25, 2, 225.0) + tdSql.checkData(25, 3, 227.0) + tdSql.checkData(25, 4, 3603.9068905956087) + tdSql.checkData(25, 5, 196294.78190175048) + tdSql.checkData(25, 6, 1971.471648033734) + tdSql.checkData(26, 0, 16) + tdSql.checkData(26, 1, 4.0) + tdSql.checkData(26, 2, 256.0) + tdSql.checkData(26, 3, 258.0) + tdSql.checkData(26, 4, 4356.0) + tdSql.checkData(26, 5, 262400.0) + tdSql.checkData(26, 6, 2360.5342310339265) + tdSql.checkData(27, 0, 17) + tdSql.checkData(27, 1, 4.08746284125034) + tdSql.checkData(27, 2, 289.0) + tdSql.checkData(27, 3, 291.0) + tdSql.checkData(27, 4, 5206.08746284125) + tdSql.checkData(27, 5, 344654.9049572126) + tdSql.checkData(27, 6, 2795.901448766347) + tdSql.checkData(28, 0, 18) + tdSql.checkData(28, 1, 4.169925001442312) + tdSql.checkData(28, 2, 324.0) + tdSql.checkData(28, 3, 326.0) + tdSql.checkData(28, 4, 6160.169925001443) + tdSql.checkData(28, 5, 445699.4487710341) + tdSql.checkData(28, 6, 3279.8760916232795) + tdSql.checkData(29, 0, 19) + tdSql.checkData(29, 1, 4.247927513443585) + tdSql.checkData(29, 2, 361.0) + tdSql.checkData(29, 3, 363.0) + tdSql.checkData(29, 4, 7224.247927513444) + tdSql.checkData(29, 5, 568417.0692211641) + tdSql.checkData(29, 6, 3814.7338355198453) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from ct1 ) order by ts limit 2;;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + + tdSql.query( + "select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from ct1 ) limit 2;;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + + tdSql.query( + "select * from (select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6, ts from st0 order by ts desc);" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 19) + tdSql.checkData(0, 1, 4.247927513443585) + tdSql.checkData(0, 2, 361.0) + tdSql.checkData(0, 3, 363.0) + tdSql.checkData(0, 4, 7224.247927513444) + tdSql.checkData(0, 5, 568417.0692211641) + tdSql.checkData(0, 6, 3814.7338355198453) + tdSql.checkData(0, 7, datetime.datetime(2020, 10, 1, 0, 19)) + tdSql.checkData(1, 0, 18) + tdSql.checkData(1, 1, 4.169925001442312) + tdSql.checkData(1, 2, 324.0) + tdSql.checkData(1, 3, 326.0) + tdSql.checkData(1, 4, 6160.169925001443) + tdSql.checkData(1, 5, 445699.4487710341) + tdSql.checkData(1, 6, 3279.8760916232795) + tdSql.checkData(1, 7, datetime.datetime(2020, 10, 1, 0, 18)) + tdSql.checkData(2, 0, 17) + tdSql.checkData(2, 1, 4.08746284125034) + tdSql.checkData(2, 2, 289.0) + tdSql.checkData(2, 3, 291.0) + tdSql.checkData(2, 4, 5206.08746284125) + tdSql.checkData(2, 5, 344654.9049572126) + tdSql.checkData(2, 6, 2795.901448766347) + tdSql.checkData(2, 7, datetime.datetime(2020, 10, 1, 0, 17)) + tdSql.checkData(3, 0, 16) + tdSql.checkData(3, 1, 4.0) + tdSql.checkData(3, 2, 256.0) + tdSql.checkData(3, 3, 258.0) + tdSql.checkData(3, 4, 4356.0) + tdSql.checkData(3, 5, 262400.0) + tdSql.checkData(3, 6, 2360.5342310339265) + tdSql.checkData(3, 7, datetime.datetime(2020, 10, 1, 0, 16)) + tdSql.checkData(4, 0, 15) + tdSql.checkData(4, 1, 3.9068905956085187) + tdSql.checkData(4, 2, 225.0) + tdSql.checkData(4, 3, 227.0) + tdSql.checkData(4, 4, 3603.9068905956087) + tdSql.checkData(4, 5, 196294.78190175048) + tdSql.checkData(4, 6, 1971.471648033734) + tdSql.checkData(4, 7, datetime.datetime(2020, 10, 1, 0, 15)) + tdSql.checkData(5, 0, 14) + tdSql.checkData(5, 1, 3.8073549220576037) + tdSql.checkData(5, 2, 196.0) + tdSql.checkData(5, 3, 198.0) + tdSql.checkData(5, 4, 2943.8073549220576) + tdSql.checkData(5, 5, 143935.51017030774) + tdSql.checkData(5, 6, 1626.3817114890194) + tdSql.checkData(5, 7, datetime.datetime(2020, 10, 1, 0, 14)) + tdSql.checkData(6, 0, 13) + tdSql.checkData(6, 1, 3.700439718141092) + tdSql.checkData(6, 2, 169.0) + tdSql.checkData(6, 3, 171.0) + tdSql.checkData(6, 4, 2369.7004397181413) + tdSql.checkData(6, 5, 103147.149978527) + tdSql.checkData(6, 6, 1322.9008332018816) + tdSql.checkData(6, 7, datetime.datetime(2020, 10, 1, 0, 13)) + tdSql.checkData(7, 0, 12) + tdSql.checkData(7, 1, 3.5849625007211565) + tdSql.checkData(7, 2, 144.0) + tdSql.checkData(7, 3, 146.0) + tdSql.checkData(7, 4, 1875.584962500721) + tdSql.checkData(7, 5, 71975.61109149648) + tdSql.checkData(7, 6, 1058.631026542541) + tdSql.checkData(7, 7, datetime.datetime(2020, 10, 1, 0, 12)) + tdSql.checkData(8, 0, 11) + tdSql.checkData(8, 1, 3.4594316186372978) + tdSql.checkData(8, 2, 121.0) + tdSql.checkData(8, 3, 123.0) + tdSql.checkData(8, 4, 1455.4594316186374) + tdSql.checkData(8, 5, 48679.70355559341) + tdSql.checkData(8, 6, 831.1366058581541) + tdSql.checkData(8, 7, datetime.datetime(2020, 10, 1, 0, 11)) + tdSql.checkData(9, 0, 10) + tdSql.checkData(9, 1, 3.3219280948873626) + tdSql.checkData(9, 2, 100.0) + tdSql.checkData(9, 3, 102.0) + tdSql.checkData(9, 4, 1103.3219280948874) + tdSql.checkData(9, 5, 31722.776601683792) + tdSql.checkData(9, 6, 637.940236622524) + tdSql.checkData(9, 7, datetime.datetime(2020, 10, 1, 0, 10)) + tdSql.checkData(10, 0, 9) + tdSql.checkData(10, 1, 3.1699250014423126) + tdSql.checkData(10, 2, 81.0) + tdSql.checkData(10, 3, 83.0) + tdSql.checkData(10, 4, 813.1699250014423) + tdSql.checkData(10, 5, 19764.0) + tdSql.checkData(10, 6, 476.5181244205816) + tdSql.checkData(10, 7, datetime.datetime(2020, 10, 1, 0, 9)) + tdSql.checkData(11, 0, 9) + tdSql.checkData(11, 1, 3.1699250014423126) + tdSql.checkData(11, 2, 81.0) + tdSql.checkData(11, 3, 83.0) + tdSql.checkData(11, 4, 813.1699250014423) + tdSql.checkData(11, 5, 19764.0) + tdSql.checkData(11, 6, 476.5181244205816) + tdSql.checkData(11, 7, datetime.datetime(2020, 10, 1, 0, 9)) + tdSql.checkData(12, 0, 8) + tdSql.checkData(12, 1, 3.0) + tdSql.checkData(12, 2, 64.0) + tdSql.checkData(12, 3, 66.0) + tdSql.checkData(12, 4, 579.0) + tdSql.checkData(12, 5, 11649.237502960395) + tdSql.checkData(12, 6, 344.2940251578608) + tdSql.checkData(12, 7, datetime.datetime(2020, 10, 1, 0, 8)) + tdSql.checkData(13, 0, 8) + tdSql.checkData(13, 1, 3.0) + tdSql.checkData(13, 2, 64.0) + tdSql.checkData(13, 3, 66.0) + tdSql.checkData(13, 4, 579.0) + tdSql.checkData(13, 5, 11649.237502960395) + tdSql.checkData(13, 6, 344.2940251578608) + tdSql.checkData(13, 7, datetime.datetime(2020, 10, 1, 0, 8)) + tdSql.checkData(14, 0, 7) + tdSql.checkData(14, 1, 2.807354922057604) + tdSql.checkData(14, 2, 49.0) + tdSql.checkData(14, 3, 51.0) + tdSql.checkData(14, 4, 394.8073549220576) + tdSql.checkData(14, 5, 6401.448897866082) + tdSql.checkData(14, 6, 238.6315756794513) + tdSql.checkData(14, 7, datetime.datetime(2020, 10, 1, 0, 7)) + tdSql.checkData(15, 0, 7) + tdSql.checkData(15, 1, 2.807354922057604) + tdSql.checkData(15, 2, 49.0) + tdSql.checkData(15, 3, 51.0) + tdSql.checkData(15, 4, 394.8073549220576) + tdSql.checkData(15, 5, 6401.448897866082) + tdSql.checkData(15, 6, 238.6315756794513) + tdSql.checkData(15, 7, datetime.datetime(2020, 10, 1, 0, 7)) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 2.584962500721156) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 254.58496250072116) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.8241014057428) + tdSql.checkData(16, 7, datetime.datetime(2020, 10, 1, 0, 6)) + tdSql.checkData(17, 0, 6) + tdSql.checkData(17, 1, 2.584962500721156) + tdSql.checkData(17, 2, 36.0) + tdSql.checkData(17, 3, 38.0) + tdSql.checkData(17, 4, 254.58496250072116) + tdSql.checkData(17, 5, 3210.538706646999) + tdSql.checkData(17, 6, 156.8241014057428) + tdSql.checkData(17, 7, datetime.datetime(2020, 10, 1, 0, 6)) + tdSql.checkData(18, 0, 5) + tdSql.checkData(18, 1, 2.321928094887362) + tdSql.checkData(18, 2, 25.0) + tdSql.checkData(18, 3, 27.0) + tdSql.checkData(18, 4, 152.32192809488737) + tdSql.checkData(18, 5, 1422.5424859373686) + tdSql.checkData(18, 6, 96.08035010204296) + tdSql.checkData(18, 7, datetime.datetime(2020, 10, 1, 0, 5)) + tdSql.checkData(19, 0, 5) + tdSql.checkData(19, 1, 2.321928094887362) + tdSql.checkData(19, 2, 25.0) + tdSql.checkData(19, 3, 27.0) + tdSql.checkData(19, 4, 152.32192809488737) + tdSql.checkData(19, 5, 1422.5424859373686) + tdSql.checkData(19, 6, 96.08035010204296) + tdSql.checkData(19, 7, datetime.datetime(2020, 10, 1, 0, 5)) + tdSql.checkData(20, 0, 4) + tdSql.checkData(20, 1, 2.0) + tdSql.checkData(20, 2, 16.0) + tdSql.checkData(20, 3, 18.0) + tdSql.checkData(20, 4, 82.0) + tdSql.checkData(20, 5, 528.0) + tdSql.checkData(20, 6, 53.50293012833273) + tdSql.checkData(20, 7, datetime.datetime(2020, 10, 1, 0, 4)) + tdSql.checkData(21, 0, 4) + tdSql.checkData(21, 1, 2.0) + tdSql.checkData(21, 2, 16.0) + tdSql.checkData(21, 3, 18.0) + tdSql.checkData(21, 4, 82.0) + tdSql.checkData(21, 5, 528.0) + tdSql.checkData(21, 6, 53.50293012833273) + tdSql.checkData(21, 7, datetime.datetime(2020, 10, 1, 0, 4)) + tdSql.checkData(22, 0, 3) + tdSql.checkData(22, 1, 1.5849625007211563) + tdSql.checkData(22, 2, 9.0) + tdSql.checkData(22, 3, 11.0) + tdSql.checkData(22, 4, 37.58496250072116) + tdSql.checkData(22, 5, 149.29611541307906) + tdSql.checkData(22, 6, 26.05146591860796) + tdSql.checkData(22, 7, datetime.datetime(2020, 10, 1, 0, 3)) + tdSql.checkData(23, 0, 3) + tdSql.checkData(23, 1, 1.5849625007211563) + tdSql.checkData(23, 2, 9.0) + tdSql.checkData(23, 3, 11.0) + tdSql.checkData(23, 4, 37.58496250072116) + tdSql.checkData(23, 5, 149.29611541307906) + tdSql.checkData(23, 6, 26.05146591860796) + tdSql.checkData(23, 7, datetime.datetime(2020, 10, 1, 0, 3)) + tdSql.checkData(24, 0, 2) + tdSql.checkData(24, 1, 1.0) + tdSql.checkData(24, 2, 4.0) + tdSql.checkData(24, 3, 6.0) + tdSql.checkData(24, 4, 13.0) + tdSql.checkData(24, 5, 26.627416997969522) + tdSql.checkData(24, 6, 10.464404506368993) + tdSql.checkData(24, 7, datetime.datetime(2020, 10, 1, 0, 2)) + tdSql.checkData(25, 0, 2) + tdSql.checkData(25, 1, 1.0) + tdSql.checkData(25, 2, 4.0) + tdSql.checkData(25, 3, 6.0) + tdSql.checkData(25, 4, 13.0) + tdSql.checkData(25, 5, 26.627416997969522) + tdSql.checkData(25, 6, 10.464404506368993) + tdSql.checkData(25, 7, datetime.datetime(2020, 10, 1, 0, 2)) + tdSql.checkData(26, 0, 1) + tdSql.checkData(26, 1, 0.0) + tdSql.checkData(26, 2, 1.0) + tdSql.checkData(26, 3, 3.0) + tdSql.checkData(26, 4, 2.0) + tdSql.checkData(26, 5, 2.0) + tdSql.checkData(26, 6, 3.0) + tdSql.checkData(26, 7, datetime.datetime(2020, 10, 1, 0, 1)) + tdSql.checkData(27, 0, 1) + tdSql.checkData(27, 1, 0.0) + tdSql.checkData(27, 2, 1.0) + tdSql.checkData(27, 3, 3.0) + tdSql.checkData(27, 4, 2.0) + tdSql.checkData(27, 5, 2.0) + tdSql.checkData(27, 6, 3.0) + tdSql.checkData(27, 7, datetime.datetime(2020, 10, 1, 0, 1)) + tdSql.checkData(28, 0, 0) + tdSql.checkData(28, 1, -2.0) + tdSql.checkData(28, 2, 0.0) + tdSql.checkData(28, 3, 2.0625) + tdSql.checkData(28, 4, -inf) + tdSql.checkData(28, 5, 0.0) + tdSql.checkData(28, 6, -inf) + tdSql.checkData(28, 7, datetime.datetime(2020, 10, 1, 0, 0)) + tdSql.checkData(29, 0, 0) + tdSql.checkData(29, 1, -2.0) + tdSql.checkData(29, 2, 0.0) + tdSql.checkData(29, 3, 2.0625) + tdSql.checkData(29, 4, -inf) + tdSql.checkData(29, 5, 0.0) + tdSql.checkData(29, 6, -inf) + tdSql.checkData(29, 7, datetime.datetime(2020, 10, 1, 0, 0)) + + tdSql.query( + "select * from (select c1, log(c2, 2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3, 2)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1,2)+log(c3,4)+pow(c6,2.8)+2 as v6, ts from ct1 order by ts limit 2);;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -2.0) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(0, 7, datetime.datetime(2020, 10, 1, 0, 0)) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + tdSql.checkData(1, 7, datetime.datetime(2020, 10, 1, 0, 1)) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from ct1;" + ) + tdSql.checkRows(20) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + tdSql.checkData(2, 0, 2) + tdSql.checkData(2, 1, 0.6931471805599453) + tdSql.checkData(2, 2, 4.0) + tdSql.checkData(2, 3, 6.0) + tdSql.checkData(2, 4, 12.693147180559945) + tdSql.checkData(2, 5, 26.627416997969522) + tdSql.checkData(2, 6, 10.157551686928937) + tdSql.checkData(3, 0, 3) + tdSql.checkData(3, 1, 1.0986122886681098) + tdSql.checkData(3, 2, 9.0) + tdSql.checkData(3, 3, 11.0) + tdSql.checkData(3, 4, 37.09861228866811) + tdSql.checkData(3, 5, 149.29611541307906) + tdSql.checkData(3, 6, 25.565115706554913) + tdSql.checkData(4, 0, 4) + tdSql.checkData(4, 1, 1.3862943611198906) + tdSql.checkData(4, 2, 16.0) + tdSql.checkData(4, 3, 18.0) + tdSql.checkData(4, 4, 81.3862943611199) + tdSql.checkData(4, 5, 528.0) + tdSql.checkData(4, 6, 52.889224489452616) + tdSql.checkData(5, 0, 5) + tdSql.checkData(5, 1, 1.6094379124341003) + tdSql.checkData(5, 2, 25.0) + tdSql.checkData(5, 3, 27.0) + tdSql.checkData(5, 4, 151.6094379124341) + tdSql.checkData(5, 5, 1422.5424859373686) + tdSql.checkData(5, 6, 95.3678599195897) + tdSql.checkData(6, 0, 6) + tdSql.checkData(6, 1, 1.791759469228055) + tdSql.checkData(6, 2, 36.0) + tdSql.checkData(6, 3, 38.0) + tdSql.checkData(6, 4, 253.79175946922805) + tdSql.checkData(6, 5, 3210.538706646999) + tdSql.checkData(6, 6, 156.0308983742497) + tdSql.checkData(7, 0, 7) + tdSql.checkData(7, 1, 1.9459101490553132) + tdSql.checkData(7, 2, 49.0) + tdSql.checkData(7, 3, 51.0) + tdSql.checkData(7, 4, 393.9459101490553) + tdSql.checkData(7, 5, 6401.448897866082) + tdSql.checkData(7, 6, 237.770130906449) + tdSql.checkData(8, 0, 8) + tdSql.checkData(8, 1, 2.0794415416798357) + tdSql.checkData(8, 2, 64.0) + tdSql.checkData(8, 3, 66.0) + tdSql.checkData(8, 4, 578.0794415416798) + tdSql.checkData(8, 5, 11649.237502960395) + tdSql.checkData(8, 6, 343.37346669954064) + tdSql.checkData(9, 0, 9) + tdSql.checkData(9, 1, 2.1972245773362196) + tdSql.checkData(9, 2, 81.0) + tdSql.checkData(9, 3, 83.0) + tdSql.checkData(9, 4, 812.1972245773362) + tdSql.checkData(9, 5, 19764.0) + tdSql.checkData(9, 6, 475.5454239964755) + tdSql.checkData(10, 0, 10) + tdSql.checkData(10, 1, 2.302585092994046) + tdSql.checkData(10, 2, 100.0) + tdSql.checkData(10, 3, 102.0) + tdSql.checkData(10, 4, 1102.302585092994) + tdSql.checkData(10, 5, 31722.776601683792) + tdSql.checkData(10, 6, 636.9208936206307) + tdSql.checkData(11, 0, 11) + tdSql.checkData(11, 1, 2.3978952727983707) + tdSql.checkData(11, 2, 121.0) + tdSql.checkData(11, 3, 123.0) + tdSql.checkData(11, 4, 1454.3978952727985) + tdSql.checkData(11, 5, 48679.70355559341) + tdSql.checkData(11, 6, 830.0750695123152) + tdSql.checkData(12, 0, 12) + tdSql.checkData(12, 1, 2.4849066497880004) + tdSql.checkData(12, 2, 144.0) + tdSql.checkData(12, 3, 146.0) + tdSql.checkData(12, 4, 1874.484906649788) + tdSql.checkData(12, 5, 71975.61109149648) + tdSql.checkData(12, 6, 1057.5309706916078) + tdSql.checkData(13, 0, 13) + tdSql.checkData(13, 1, 2.5649493574615367) + tdSql.checkData(13, 2, 169.0) + tdSql.checkData(13, 3, 171.0) + tdSql.checkData(13, 4, 2368.5649493574615) + tdSql.checkData(13, 5, 103147.149978527) + tdSql.checkData(13, 6, 1321.765342841202) + tdSql.checkData(14, 0, 14) + tdSql.checkData(14, 1, 2.6390573296152584) + tdSql.checkData(14, 2, 196.0) + tdSql.checkData(14, 3, 198.0) + tdSql.checkData(14, 4, 2942.6390573296153) + tdSql.checkData(14, 5, 143935.51017030774) + tdSql.checkData(14, 6, 1625.213413896577) + tdSql.checkData(15, 0, 15) + tdSql.checkData(15, 1, 2.70805020110221) + tdSql.checkData(15, 2, 225.0) + tdSql.checkData(15, 3, 227.0) + tdSql.checkData(15, 4, 3602.708050201102) + tdSql.checkData(15, 5, 196294.78190175048) + tdSql.checkData(15, 6, 1970.2728076392277) + tdSql.checkData(16, 0, 16) + tdSql.checkData(16, 1, 2.772588722239781) + tdSql.checkData(16, 2, 256.0) + tdSql.checkData(16, 3, 258.0) + tdSql.checkData(16, 4, 4354.77258872224) + tdSql.checkData(16, 5, 262400.0) + tdSql.checkData(16, 6, 2359.306819756166) + tdSql.checkData(17, 0, 17) + tdSql.checkData(17, 1, 2.833213344056216) + tdSql.checkData(17, 2, 289.0) + tdSql.checkData(17, 3, 291.0) + tdSql.checkData(17, 4, 5204.833213344056) + tdSql.checkData(17, 5, 344654.9049572126) + tdSql.checkData(17, 6, 2794.647199269153) + tdSql.checkData(18, 0, 18) + tdSql.checkData(18, 1, 2.8903717578961645) + tdSql.checkData(18, 2, 324.0) + tdSql.checkData(18, 3, 326.0) + tdSql.checkData(18, 4, 6158.890371757896) + tdSql.checkData(18, 5, 445699.4487710341) + tdSql.checkData(18, 6, 3278.5965383797334) + tdSql.checkData(19, 0, 19) + tdSql.checkData(19, 1, 2.9444389791664403) + tdSql.checkData(19, 2, 361.0) + tdSql.checkData(19, 3, 363.0) + tdSql.checkData(19, 4, 7222.944438979166) + tdSql.checkData(19, 5, 568417.0692211641) + tdSql.checkData(19, 6, 3813.4303469855686) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from ct1 where ts == 1601481600000;" + ) + tdSql.checkRows(1) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from st0 where ts == 1601481600000;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 0) + tdSql.checkData(1, 1, -1.3862943611198906) + tdSql.checkData(1, 2, 0.0) + tdSql.checkData(1, 3, 2.0625) + tdSql.checkData(1, 4, -inf) + tdSql.checkData(1, 5, 0.0) + tdSql.checkData(1, 6, -inf) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from st0 where c1 == 0;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 0) + tdSql.checkData(1, 1, -1.3862943611198906) + tdSql.checkData(1, 2, 0.0) + tdSql.checkData(1, 3, 2.0625) + tdSql.checkData(1, 4, -inf) + tdSql.checkData(1, 5, 0.0) + tdSql.checkData(1, 6, -inf) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from st0 where c1 == 0;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 0) + tdSql.checkData(1, 1, -1.3862943611198906) + tdSql.checkData(1, 2, 0.0) + tdSql.checkData(1, 3, 2.0625) + tdSql.checkData(1, 4, -inf) + tdSql.checkData(1, 5, 0.0) + tdSql.checkData(1, 6, -inf) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from st0 order by ts desc;" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 19) + tdSql.checkData(0, 1, 2.9444389791664403) + tdSql.checkData(0, 2, 361.0) + tdSql.checkData(0, 3, 363.0) + tdSql.checkData(0, 4, 7222.944438979166) + tdSql.checkData(0, 5, 568417.0692211641) + tdSql.checkData(0, 6, 3813.4303469855686) + tdSql.checkData(1, 0, 18) + tdSql.checkData(1, 1, 2.8903717578961645) + tdSql.checkData(1, 2, 324.0) + tdSql.checkData(1, 3, 326.0) + tdSql.checkData(1, 4, 6158.890371757896) + tdSql.checkData(1, 5, 445699.4487710341) + tdSql.checkData(1, 6, 3278.5965383797334) + tdSql.checkData(2, 0, 17) + tdSql.checkData(2, 1, 2.833213344056216) + tdSql.checkData(2, 2, 289.0) + tdSql.checkData(2, 3, 291.0) + tdSql.checkData(2, 4, 5204.833213344056) + tdSql.checkData(2, 5, 344654.9049572126) + tdSql.checkData(2, 6, 2794.647199269153) + tdSql.checkData(3, 0, 16) + tdSql.checkData(3, 1, 2.772588722239781) + tdSql.checkData(3, 2, 256.0) + tdSql.checkData(3, 3, 258.0) + tdSql.checkData(3, 4, 4354.77258872224) + tdSql.checkData(3, 5, 262400.0) + tdSql.checkData(3, 6, 2359.306819756166) + tdSql.checkData(4, 0, 15) + tdSql.checkData(4, 1, 2.70805020110221) + tdSql.checkData(4, 2, 225.0) + tdSql.checkData(4, 3, 227.0) + tdSql.checkData(4, 4, 3602.708050201102) + tdSql.checkData(4, 5, 196294.78190175048) + tdSql.checkData(4, 6, 1970.2728076392277) + tdSql.checkData(5, 0, 14) + tdSql.checkData(5, 1, 2.6390573296152584) + tdSql.checkData(5, 2, 196.0) + tdSql.checkData(5, 3, 198.0) + tdSql.checkData(5, 4, 2942.6390573296153) + tdSql.checkData(5, 5, 143935.51017030774) + tdSql.checkData(5, 6, 1625.213413896577) + tdSql.checkData(6, 0, 13) + tdSql.checkData(6, 1, 2.5649493574615367) + tdSql.checkData(6, 2, 169.0) + tdSql.checkData(6, 3, 171.0) + tdSql.checkData(6, 4, 2368.5649493574615) + tdSql.checkData(6, 5, 103147.149978527) + tdSql.checkData(6, 6, 1321.765342841202) + tdSql.checkData(7, 0, 12) + tdSql.checkData(7, 1, 2.4849066497880004) + tdSql.checkData(7, 2, 144.0) + tdSql.checkData(7, 3, 146.0) + tdSql.checkData(7, 4, 1874.484906649788) + tdSql.checkData(7, 5, 71975.61109149648) + tdSql.checkData(7, 6, 1057.5309706916078) + tdSql.checkData(8, 0, 11) + tdSql.checkData(8, 1, 2.3978952727983707) + tdSql.checkData(8, 2, 121.0) + tdSql.checkData(8, 3, 123.0) + tdSql.checkData(8, 4, 1454.3978952727985) + tdSql.checkData(8, 5, 48679.70355559341) + tdSql.checkData(8, 6, 830.0750695123152) + tdSql.checkData(9, 0, 10) + tdSql.checkData(9, 1, 2.302585092994046) + tdSql.checkData(9, 2, 100.0) + tdSql.checkData(9, 3, 102.0) + tdSql.checkData(9, 4, 1102.302585092994) + tdSql.checkData(9, 5, 31722.776601683792) + tdSql.checkData(9, 6, 636.9208936206307) + tdSql.checkData(10, 0, 9) + tdSql.checkData(10, 1, 2.1972245773362196) + tdSql.checkData(10, 2, 81.0) + tdSql.checkData(10, 3, 83.0) + tdSql.checkData(10, 4, 812.1972245773362) + tdSql.checkData(10, 5, 19764.0) + tdSql.checkData(10, 6, 475.5454239964755) + tdSql.checkData(11, 0, 9) + tdSql.checkData(11, 1, 2.1972245773362196) + tdSql.checkData(11, 2, 81.0) + tdSql.checkData(11, 3, 83.0) + tdSql.checkData(11, 4, 812.1972245773362) + tdSql.checkData(11, 5, 19764.0) + tdSql.checkData(11, 6, 475.5454239964755) + tdSql.checkData(12, 0, 8) + tdSql.checkData(12, 1, 2.0794415416798357) + tdSql.checkData(12, 2, 64.0) + tdSql.checkData(12, 3, 66.0) + tdSql.checkData(12, 4, 578.0794415416798) + tdSql.checkData(12, 5, 11649.237502960395) + tdSql.checkData(12, 6, 343.37346669954064) + tdSql.checkData(13, 0, 8) + tdSql.checkData(13, 1, 2.0794415416798357) + tdSql.checkData(13, 2, 64.0) + tdSql.checkData(13, 3, 66.0) + tdSql.checkData(13, 4, 578.0794415416798) + tdSql.checkData(13, 5, 11649.237502960395) + tdSql.checkData(13, 6, 343.37346669954064) + tdSql.checkData(14, 0, 7) + tdSql.checkData(14, 1, 1.9459101490553132) + tdSql.checkData(14, 2, 49.0) + tdSql.checkData(14, 3, 51.0) + tdSql.checkData(14, 4, 393.9459101490553) + tdSql.checkData(14, 5, 6401.448897866082) + tdSql.checkData(14, 6, 237.770130906449) + tdSql.checkData(15, 0, 7) + tdSql.checkData(15, 1, 1.9459101490553132) + tdSql.checkData(15, 2, 49.0) + tdSql.checkData(15, 3, 51.0) + tdSql.checkData(15, 4, 393.9459101490553) + tdSql.checkData(15, 5, 6401.448897866082) + tdSql.checkData(15, 6, 237.770130906449) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 1.791759469228055) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 253.79175946922805) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.0308983742497) + tdSql.checkData(17, 0, 6) + tdSql.checkData(17, 1, 1.791759469228055) + tdSql.checkData(17, 2, 36.0) + tdSql.checkData(17, 3, 38.0) + tdSql.checkData(17, 4, 253.79175946922805) + tdSql.checkData(17, 5, 3210.538706646999) + tdSql.checkData(17, 6, 156.0308983742497) + tdSql.checkData(18, 0, 5) + tdSql.checkData(18, 1, 1.6094379124341003) + tdSql.checkData(18, 2, 25.0) + tdSql.checkData(18, 3, 27.0) + tdSql.checkData(18, 4, 151.6094379124341) + tdSql.checkData(18, 5, 1422.5424859373686) + tdSql.checkData(18, 6, 95.3678599195897) + tdSql.checkData(19, 0, 5) + tdSql.checkData(19, 1, 1.6094379124341003) + tdSql.checkData(19, 2, 25.0) + tdSql.checkData(19, 3, 27.0) + tdSql.checkData(19, 4, 151.6094379124341) + tdSql.checkData(19, 5, 1422.5424859373686) + tdSql.checkData(19, 6, 95.3678599195897) + tdSql.checkData(20, 0, 4) + tdSql.checkData(20, 1, 1.3862943611198906) + tdSql.checkData(20, 2, 16.0) + tdSql.checkData(20, 3, 18.0) + tdSql.checkData(20, 4, 81.3862943611199) + tdSql.checkData(20, 5, 528.0) + tdSql.checkData(20, 6, 52.889224489452616) + tdSql.checkData(21, 0, 4) + tdSql.checkData(21, 1, 1.3862943611198906) + tdSql.checkData(21, 2, 16.0) + tdSql.checkData(21, 3, 18.0) + tdSql.checkData(21, 4, 81.3862943611199) + tdSql.checkData(21, 5, 528.0) + tdSql.checkData(21, 6, 52.889224489452616) + tdSql.checkData(22, 0, 3) + tdSql.checkData(22, 1, 1.0986122886681098) + tdSql.checkData(22, 2, 9.0) + tdSql.checkData(22, 3, 11.0) + tdSql.checkData(22, 4, 37.09861228866811) + tdSql.checkData(22, 5, 149.29611541307906) + tdSql.checkData(22, 6, 25.565115706554913) + tdSql.checkData(23, 0, 3) + tdSql.checkData(23, 1, 1.0986122886681098) + tdSql.checkData(23, 2, 9.0) + tdSql.checkData(23, 3, 11.0) + tdSql.checkData(23, 4, 37.09861228866811) + tdSql.checkData(23, 5, 149.29611541307906) + tdSql.checkData(23, 6, 25.565115706554913) + tdSql.checkData(24, 0, 2) + tdSql.checkData(24, 1, 0.6931471805599453) + tdSql.checkData(24, 2, 4.0) + tdSql.checkData(24, 3, 6.0) + tdSql.checkData(24, 4, 12.693147180559945) + tdSql.checkData(24, 5, 26.627416997969522) + tdSql.checkData(24, 6, 10.157551686928937) + tdSql.checkData(25, 0, 2) + tdSql.checkData(25, 1, 0.6931471805599453) + tdSql.checkData(25, 2, 4.0) + tdSql.checkData(25, 3, 6.0) + tdSql.checkData(25, 4, 12.693147180559945) + tdSql.checkData(25, 5, 26.627416997969522) + tdSql.checkData(25, 6, 10.157551686928937) + tdSql.checkData(26, 0, 1) + tdSql.checkData(26, 1, 0.0) + tdSql.checkData(26, 2, 1.0) + tdSql.checkData(26, 3, 3.0) + tdSql.checkData(26, 4, 2.0) + tdSql.checkData(26, 5, 2.0) + tdSql.checkData(26, 6, 3.0) + tdSql.checkData(27, 0, 1) + tdSql.checkData(27, 1, 0.0) + tdSql.checkData(27, 2, 1.0) + tdSql.checkData(27, 3, 3.0) + tdSql.checkData(27, 4, 2.0) + tdSql.checkData(27, 5, 2.0) + tdSql.checkData(27, 6, 3.0) + tdSql.checkData(28, 0, 0) + tdSql.checkData(28, 1, -1.3862943611198906) + tdSql.checkData(28, 2, 0.0) + tdSql.checkData(28, 3, 2.0625) + tdSql.checkData(28, 4, -inf) + tdSql.checkData(28, 5, 0.0) + tdSql.checkData(28, 6, -inf) + tdSql.checkData(29, 0, 0) + tdSql.checkData(29, 1, -1.3862943611198906) + tdSql.checkData(29, 2, 0.0) + tdSql.checkData(29, 3, 2.0625) + tdSql.checkData(29, 4, -inf) + tdSql.checkData(29, 5, 0.0) + tdSql.checkData(29, 6, -inf) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from ct1 order by ts limit 2;;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + + tdSql.query( + "select sqrt(abs(log(c1)-pow(c1,2)))+2 from ct1 order by ts limit 2;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, inf) + tdSql.checkData(1, 0, 3.0) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from st0 order by ts desc);" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 19) + tdSql.checkData(0, 1, 2.9444389791664403) + tdSql.checkData(0, 2, 361.0) + tdSql.checkData(0, 3, 363.0) + tdSql.checkData(0, 4, 7222.944438979166) + tdSql.checkData(0, 5, 568417.0692211641) + tdSql.checkData(0, 6, 3813.4303469855686) + tdSql.checkData(1, 0, 18) + tdSql.checkData(1, 1, 2.8903717578961645) + tdSql.checkData(1, 2, 324.0) + tdSql.checkData(1, 3, 326.0) + tdSql.checkData(1, 4, 6158.890371757896) + tdSql.checkData(1, 5, 445699.4487710341) + tdSql.checkData(1, 6, 3278.5965383797334) + tdSql.checkData(2, 0, 17) + tdSql.checkData(2, 1, 2.833213344056216) + tdSql.checkData(2, 2, 289.0) + tdSql.checkData(2, 3, 291.0) + tdSql.checkData(2, 4, 5204.833213344056) + tdSql.checkData(2, 5, 344654.9049572126) + tdSql.checkData(2, 6, 2794.647199269153) + tdSql.checkData(3, 0, 16) + tdSql.checkData(3, 1, 2.772588722239781) + tdSql.checkData(3, 2, 256.0) + tdSql.checkData(3, 3, 258.0) + tdSql.checkData(3, 4, 4354.77258872224) + tdSql.checkData(3, 5, 262400.0) + tdSql.checkData(3, 6, 2359.306819756166) + tdSql.checkData(4, 0, 15) + tdSql.checkData(4, 1, 2.70805020110221) + tdSql.checkData(4, 2, 225.0) + tdSql.checkData(4, 3, 227.0) + tdSql.checkData(4, 4, 3602.708050201102) + tdSql.checkData(4, 5, 196294.78190175048) + tdSql.checkData(4, 6, 1970.2728076392277) + tdSql.checkData(5, 0, 14) + tdSql.checkData(5, 1, 2.6390573296152584) + tdSql.checkData(5, 2, 196.0) + tdSql.checkData(5, 3, 198.0) + tdSql.checkData(5, 4, 2942.6390573296153) + tdSql.checkData(5, 5, 143935.51017030774) + tdSql.checkData(5, 6, 1625.213413896577) + tdSql.checkData(6, 0, 13) + tdSql.checkData(6, 1, 2.5649493574615367) + tdSql.checkData(6, 2, 169.0) + tdSql.checkData(6, 3, 171.0) + tdSql.checkData(6, 4, 2368.5649493574615) + tdSql.checkData(6, 5, 103147.149978527) + tdSql.checkData(6, 6, 1321.765342841202) + tdSql.checkData(7, 0, 12) + tdSql.checkData(7, 1, 2.4849066497880004) + tdSql.checkData(7, 2, 144.0) + tdSql.checkData(7, 3, 146.0) + tdSql.checkData(7, 4, 1874.484906649788) + tdSql.checkData(7, 5, 71975.61109149648) + tdSql.checkData(7, 6, 1057.5309706916078) + tdSql.checkData(8, 0, 11) + tdSql.checkData(8, 1, 2.3978952727983707) + tdSql.checkData(8, 2, 121.0) + tdSql.checkData(8, 3, 123.0) + tdSql.checkData(8, 4, 1454.3978952727985) + tdSql.checkData(8, 5, 48679.70355559341) + tdSql.checkData(8, 6, 830.0750695123152) + tdSql.checkData(9, 0, 10) + tdSql.checkData(9, 1, 2.302585092994046) + tdSql.checkData(9, 2, 100.0) + tdSql.checkData(9, 3, 102.0) + tdSql.checkData(9, 4, 1102.302585092994) + tdSql.checkData(9, 5, 31722.776601683792) + tdSql.checkData(9, 6, 636.9208936206307) + tdSql.checkData(10, 0, 9) + tdSql.checkData(10, 1, 2.1972245773362196) + tdSql.checkData(10, 2, 81.0) + tdSql.checkData(10, 3, 83.0) + tdSql.checkData(10, 4, 812.1972245773362) + tdSql.checkData(10, 5, 19764.0) + tdSql.checkData(10, 6, 475.5454239964755) + tdSql.checkData(11, 0, 9) + tdSql.checkData(11, 1, 2.1972245773362196) + tdSql.checkData(11, 2, 81.0) + tdSql.checkData(11, 3, 83.0) + tdSql.checkData(11, 4, 812.1972245773362) + tdSql.checkData(11, 5, 19764.0) + tdSql.checkData(11, 6, 475.5454239964755) + tdSql.checkData(12, 0, 8) + tdSql.checkData(12, 1, 2.0794415416798357) + tdSql.checkData(12, 2, 64.0) + tdSql.checkData(12, 3, 66.0) + tdSql.checkData(12, 4, 578.0794415416798) + tdSql.checkData(12, 5, 11649.237502960395) + tdSql.checkData(12, 6, 343.37346669954064) + tdSql.checkData(13, 0, 8) + tdSql.checkData(13, 1, 2.0794415416798357) + tdSql.checkData(13, 2, 64.0) + tdSql.checkData(13, 3, 66.0) + tdSql.checkData(13, 4, 578.0794415416798) + tdSql.checkData(13, 5, 11649.237502960395) + tdSql.checkData(13, 6, 343.37346669954064) + tdSql.checkData(14, 0, 7) + tdSql.checkData(14, 1, 1.9459101490553132) + tdSql.checkData(14, 2, 49.0) + tdSql.checkData(14, 3, 51.0) + tdSql.checkData(14, 4, 393.9459101490553) + tdSql.checkData(14, 5, 6401.448897866082) + tdSql.checkData(14, 6, 237.770130906449) + tdSql.checkData(15, 0, 7) + tdSql.checkData(15, 1, 1.9459101490553132) + tdSql.checkData(15, 2, 49.0) + tdSql.checkData(15, 3, 51.0) + tdSql.checkData(15, 4, 393.9459101490553) + tdSql.checkData(15, 5, 6401.448897866082) + tdSql.checkData(15, 6, 237.770130906449) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 1.791759469228055) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 253.79175946922805) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.0308983742497) + tdSql.checkData(17, 0, 6) + tdSql.checkData(17, 1, 1.791759469228055) + tdSql.checkData(17, 2, 36.0) + tdSql.checkData(17, 3, 38.0) + tdSql.checkData(17, 4, 253.79175946922805) + tdSql.checkData(17, 5, 3210.538706646999) + tdSql.checkData(17, 6, 156.0308983742497) + tdSql.checkData(18, 0, 5) + tdSql.checkData(18, 1, 1.6094379124341003) + tdSql.checkData(18, 2, 25.0) + tdSql.checkData(18, 3, 27.0) + tdSql.checkData(18, 4, 151.6094379124341) + tdSql.checkData(18, 5, 1422.5424859373686) + tdSql.checkData(18, 6, 95.3678599195897) + tdSql.checkData(19, 0, 5) + tdSql.checkData(19, 1, 1.6094379124341003) + tdSql.checkData(19, 2, 25.0) + tdSql.checkData(19, 3, 27.0) + tdSql.checkData(19, 4, 151.6094379124341) + tdSql.checkData(19, 5, 1422.5424859373686) + tdSql.checkData(19, 6, 95.3678599195897) + tdSql.checkData(20, 0, 4) + tdSql.checkData(20, 1, 1.3862943611198906) + tdSql.checkData(20, 2, 16.0) + tdSql.checkData(20, 3, 18.0) + tdSql.checkData(20, 4, 81.3862943611199) + tdSql.checkData(20, 5, 528.0) + tdSql.checkData(20, 6, 52.889224489452616) + tdSql.checkData(21, 0, 4) + tdSql.checkData(21, 1, 1.3862943611198906) + tdSql.checkData(21, 2, 16.0) + tdSql.checkData(21, 3, 18.0) + tdSql.checkData(21, 4, 81.3862943611199) + tdSql.checkData(21, 5, 528.0) + tdSql.checkData(21, 6, 52.889224489452616) + tdSql.checkData(22, 0, 3) + tdSql.checkData(22, 1, 1.0986122886681098) + tdSql.checkData(22, 2, 9.0) + tdSql.checkData(22, 3, 11.0) + tdSql.checkData(22, 4, 37.09861228866811) + tdSql.checkData(22, 5, 149.29611541307906) + tdSql.checkData(22, 6, 25.565115706554913) + tdSql.checkData(23, 0, 3) + tdSql.checkData(23, 1, 1.0986122886681098) + tdSql.checkData(23, 2, 9.0) + tdSql.checkData(23, 3, 11.0) + tdSql.checkData(23, 4, 37.09861228866811) + tdSql.checkData(23, 5, 149.29611541307906) + tdSql.checkData(23, 6, 25.565115706554913) + tdSql.checkData(24, 0, 2) + tdSql.checkData(24, 1, 0.6931471805599453) + tdSql.checkData(24, 2, 4.0) + tdSql.checkData(24, 3, 6.0) + tdSql.checkData(24, 4, 12.693147180559945) + tdSql.checkData(24, 5, 26.627416997969522) + tdSql.checkData(24, 6, 10.157551686928937) + tdSql.checkData(25, 0, 2) + tdSql.checkData(25, 1, 0.6931471805599453) + tdSql.checkData(25, 2, 4.0) + tdSql.checkData(25, 3, 6.0) + tdSql.checkData(25, 4, 12.693147180559945) + tdSql.checkData(25, 5, 26.627416997969522) + tdSql.checkData(25, 6, 10.157551686928937) + tdSql.checkData(26, 0, 1) + tdSql.checkData(26, 1, 0.0) + tdSql.checkData(26, 2, 1.0) + tdSql.checkData(26, 3, 3.0) + tdSql.checkData(26, 4, 2.0) + tdSql.checkData(26, 5, 2.0) + tdSql.checkData(26, 6, 3.0) + tdSql.checkData(27, 0, 1) + tdSql.checkData(27, 1, 0.0) + tdSql.checkData(27, 2, 1.0) + tdSql.checkData(27, 3, 3.0) + tdSql.checkData(27, 4, 2.0) + tdSql.checkData(27, 5, 2.0) + tdSql.checkData(27, 6, 3.0) + tdSql.checkData(28, 0, 0) + tdSql.checkData(28, 1, -1.3862943611198906) + tdSql.checkData(28, 2, 0.0) + tdSql.checkData(28, 3, 2.0625) + tdSql.checkData(28, 4, -inf) + tdSql.checkData(28, 5, 0.0) + tdSql.checkData(28, 6, -inf) + tdSql.checkData(29, 0, 0) + tdSql.checkData(29, 1, -1.3862943611198906) + tdSql.checkData(29, 2, 0.0) + tdSql.checkData(29, 3, 2.0625) + tdSql.checkData(29, 4, -inf) + tdSql.checkData(29, 5, 0.0) + tdSql.checkData(29, 6, -inf) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from ct1 order by ts limit 2);;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from st0 ) order by ts desc;" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 19) + tdSql.checkData(0, 1, 2.9444389791664403) + tdSql.checkData(0, 2, 361.0) + tdSql.checkData(0, 3, 363.0) + tdSql.checkData(0, 4, 7222.944438979166) + tdSql.checkData(0, 5, 568417.0692211641) + tdSql.checkData(0, 6, 3813.4303469855686) + tdSql.checkData(1, 0, 18) + tdSql.checkData(1, 1, 2.8903717578961645) + tdSql.checkData(1, 2, 324.0) + tdSql.checkData(1, 3, 326.0) + tdSql.checkData(1, 4, 6158.890371757896) + tdSql.checkData(1, 5, 445699.4487710341) + tdSql.checkData(1, 6, 3278.5965383797334) + tdSql.checkData(2, 0, 17) + tdSql.checkData(2, 1, 2.833213344056216) + tdSql.checkData(2, 2, 289.0) + tdSql.checkData(2, 3, 291.0) + tdSql.checkData(2, 4, 5204.833213344056) + tdSql.checkData(2, 5, 344654.9049572126) + tdSql.checkData(2, 6, 2794.647199269153) + tdSql.checkData(3, 0, 16) + tdSql.checkData(3, 1, 2.772588722239781) + tdSql.checkData(3, 2, 256.0) + tdSql.checkData(3, 3, 258.0) + tdSql.checkData(3, 4, 4354.77258872224) + tdSql.checkData(3, 5, 262400.0) + tdSql.checkData(3, 6, 2359.306819756166) + tdSql.checkData(4, 0, 15) + tdSql.checkData(4, 1, 2.70805020110221) + tdSql.checkData(4, 2, 225.0) + tdSql.checkData(4, 3, 227.0) + tdSql.checkData(4, 4, 3602.708050201102) + tdSql.checkData(4, 5, 196294.78190175048) + tdSql.checkData(4, 6, 1970.2728076392277) + tdSql.checkData(5, 0, 14) + tdSql.checkData(5, 1, 2.6390573296152584) + tdSql.checkData(5, 2, 196.0) + tdSql.checkData(5, 3, 198.0) + tdSql.checkData(5, 4, 2942.6390573296153) + tdSql.checkData(5, 5, 143935.51017030774) + tdSql.checkData(5, 6, 1625.213413896577) + tdSql.checkData(6, 0, 13) + tdSql.checkData(6, 1, 2.5649493574615367) + tdSql.checkData(6, 2, 169.0) + tdSql.checkData(6, 3, 171.0) + tdSql.checkData(6, 4, 2368.5649493574615) + tdSql.checkData(6, 5, 103147.149978527) + tdSql.checkData(6, 6, 1321.765342841202) + tdSql.checkData(7, 0, 12) + tdSql.checkData(7, 1, 2.4849066497880004) + tdSql.checkData(7, 2, 144.0) + tdSql.checkData(7, 3, 146.0) + tdSql.checkData(7, 4, 1874.484906649788) + tdSql.checkData(7, 5, 71975.61109149648) + tdSql.checkData(7, 6, 1057.5309706916078) + tdSql.checkData(8, 0, 11) + tdSql.checkData(8, 1, 2.3978952727983707) + tdSql.checkData(8, 2, 121.0) + tdSql.checkData(8, 3, 123.0) + tdSql.checkData(8, 4, 1454.3978952727985) + tdSql.checkData(8, 5, 48679.70355559341) + tdSql.checkData(8, 6, 830.0750695123152) + tdSql.checkData(9, 0, 10) + tdSql.checkData(9, 1, 2.302585092994046) + tdSql.checkData(9, 2, 100.0) + tdSql.checkData(9, 3, 102.0) + tdSql.checkData(9, 4, 1102.302585092994) + tdSql.checkData(9, 5, 31722.776601683792) + tdSql.checkData(9, 6, 636.9208936206307) + tdSql.checkData(10, 0, 9) + tdSql.checkData(10, 1, 2.1972245773362196) + tdSql.checkData(10, 2, 81.0) + tdSql.checkData(10, 3, 83.0) + tdSql.checkData(10, 4, 812.1972245773362) + tdSql.checkData(10, 5, 19764.0) + tdSql.checkData(10, 6, 475.5454239964755) + tdSql.checkData(11, 0, 9) + tdSql.checkData(11, 1, 2.1972245773362196) + tdSql.checkData(11, 2, 81.0) + tdSql.checkData(11, 3, 83.0) + tdSql.checkData(11, 4, 812.1972245773362) + tdSql.checkData(11, 5, 19764.0) + tdSql.checkData(11, 6, 475.5454239964755) + tdSql.checkData(12, 0, 8) + tdSql.checkData(12, 1, 2.0794415416798357) + tdSql.checkData(12, 2, 64.0) + tdSql.checkData(12, 3, 66.0) + tdSql.checkData(12, 4, 578.0794415416798) + tdSql.checkData(12, 5, 11649.237502960395) + tdSql.checkData(12, 6, 343.37346669954064) + tdSql.checkData(13, 0, 8) + tdSql.checkData(13, 1, 2.0794415416798357) + tdSql.checkData(13, 2, 64.0) + tdSql.checkData(13, 3, 66.0) + tdSql.checkData(13, 4, 578.0794415416798) + tdSql.checkData(13, 5, 11649.237502960395) + tdSql.checkData(13, 6, 343.37346669954064) + tdSql.checkData(14, 0, 7) + tdSql.checkData(14, 1, 1.9459101490553132) + tdSql.checkData(14, 2, 49.0) + tdSql.checkData(14, 3, 51.0) + tdSql.checkData(14, 4, 393.9459101490553) + tdSql.checkData(14, 5, 6401.448897866082) + tdSql.checkData(14, 6, 237.770130906449) + tdSql.checkData(15, 0, 7) + tdSql.checkData(15, 1, 1.9459101490553132) + tdSql.checkData(15, 2, 49.0) + tdSql.checkData(15, 3, 51.0) + tdSql.checkData(15, 4, 393.9459101490553) + tdSql.checkData(15, 5, 6401.448897866082) + tdSql.checkData(15, 6, 237.770130906449) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 1.791759469228055) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 253.79175946922805) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.0308983742497) + tdSql.checkData(17, 0, 6) + tdSql.checkData(17, 1, 1.791759469228055) + tdSql.checkData(17, 2, 36.0) + tdSql.checkData(17, 3, 38.0) + tdSql.checkData(17, 4, 253.79175946922805) + tdSql.checkData(17, 5, 3210.538706646999) + tdSql.checkData(17, 6, 156.0308983742497) + tdSql.checkData(18, 0, 5) + tdSql.checkData(18, 1, 1.6094379124341003) + tdSql.checkData(18, 2, 25.0) + tdSql.checkData(18, 3, 27.0) + tdSql.checkData(18, 4, 151.6094379124341) + tdSql.checkData(18, 5, 1422.5424859373686) + tdSql.checkData(18, 6, 95.3678599195897) + tdSql.checkData(19, 0, 5) + tdSql.checkData(19, 1, 1.6094379124341003) + tdSql.checkData(19, 2, 25.0) + tdSql.checkData(19, 3, 27.0) + tdSql.checkData(19, 4, 151.6094379124341) + tdSql.checkData(19, 5, 1422.5424859373686) + tdSql.checkData(19, 6, 95.3678599195897) + tdSql.checkData(20, 0, 4) + tdSql.checkData(20, 1, 1.3862943611198906) + tdSql.checkData(20, 2, 16.0) + tdSql.checkData(20, 3, 18.0) + tdSql.checkData(20, 4, 81.3862943611199) + tdSql.checkData(20, 5, 528.0) + tdSql.checkData(20, 6, 52.889224489452616) + tdSql.checkData(21, 0, 4) + tdSql.checkData(21, 1, 1.3862943611198906) + tdSql.checkData(21, 2, 16.0) + tdSql.checkData(21, 3, 18.0) + tdSql.checkData(21, 4, 81.3862943611199) + tdSql.checkData(21, 5, 528.0) + tdSql.checkData(21, 6, 52.889224489452616) + tdSql.checkData(22, 0, 3) + tdSql.checkData(22, 1, 1.0986122886681098) + tdSql.checkData(22, 2, 9.0) + tdSql.checkData(22, 3, 11.0) + tdSql.checkData(22, 4, 37.09861228866811) + tdSql.checkData(22, 5, 149.29611541307906) + tdSql.checkData(22, 6, 25.565115706554913) + tdSql.checkData(23, 0, 3) + tdSql.checkData(23, 1, 1.0986122886681098) + tdSql.checkData(23, 2, 9.0) + tdSql.checkData(23, 3, 11.0) + tdSql.checkData(23, 4, 37.09861228866811) + tdSql.checkData(23, 5, 149.29611541307906) + tdSql.checkData(23, 6, 25.565115706554913) + tdSql.checkData(24, 0, 2) + tdSql.checkData(24, 1, 0.6931471805599453) + tdSql.checkData(24, 2, 4.0) + tdSql.checkData(24, 3, 6.0) + tdSql.checkData(24, 4, 12.693147180559945) + tdSql.checkData(24, 5, 26.627416997969522) + tdSql.checkData(24, 6, 10.157551686928937) + tdSql.checkData(25, 0, 2) + tdSql.checkData(25, 1, 0.6931471805599453) + tdSql.checkData(25, 2, 4.0) + tdSql.checkData(25, 3, 6.0) + tdSql.checkData(25, 4, 12.693147180559945) + tdSql.checkData(25, 5, 26.627416997969522) + tdSql.checkData(25, 6, 10.157551686928937) + tdSql.checkData(26, 0, 1) + tdSql.checkData(26, 1, 0.0) + tdSql.checkData(26, 2, 1.0) + tdSql.checkData(26, 3, 3.0) + tdSql.checkData(26, 4, 2.0) + tdSql.checkData(26, 5, 2.0) + tdSql.checkData(26, 6, 3.0) + tdSql.checkData(27, 0, 1) + tdSql.checkData(27, 1, 0.0) + tdSql.checkData(27, 2, 1.0) + tdSql.checkData(27, 3, 3.0) + tdSql.checkData(27, 4, 2.0) + tdSql.checkData(27, 5, 2.0) + tdSql.checkData(27, 6, 3.0) + tdSql.checkData(28, 0, 0) + tdSql.checkData(28, 1, -1.3862943611198906) + tdSql.checkData(28, 2, 0.0) + tdSql.checkData(28, 3, 2.0625) + tdSql.checkData(28, 4, -inf) + tdSql.checkData(28, 5, 0.0) + tdSql.checkData(28, 6, -inf) + tdSql.checkData(29, 0, 0) + tdSql.checkData(29, 1, -1.3862943611198906) + tdSql.checkData(29, 2, 0.0) + tdSql.checkData(29, 3, 2.0625) + tdSql.checkData(29, 4, -inf) + tdSql.checkData(29, 5, 0.0) + tdSql.checkData(29, 6, -inf) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from st0 );" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + tdSql.checkData(2, 0, 2) + tdSql.checkData(2, 1, 0.6931471805599453) + tdSql.checkData(2, 2, 4.0) + tdSql.checkData(2, 3, 6.0) + tdSql.checkData(2, 4, 12.693147180559945) + tdSql.checkData(2, 5, 26.627416997969522) + tdSql.checkData(2, 6, 10.157551686928937) + tdSql.checkData(3, 0, 3) + tdSql.checkData(3, 1, 1.0986122886681098) + tdSql.checkData(3, 2, 9.0) + tdSql.checkData(3, 3, 11.0) + tdSql.checkData(3, 4, 37.09861228866811) + tdSql.checkData(3, 5, 149.29611541307906) + tdSql.checkData(3, 6, 25.565115706554913) + tdSql.checkData(4, 0, 4) + tdSql.checkData(4, 1, 1.3862943611198906) + tdSql.checkData(4, 2, 16.0) + tdSql.checkData(4, 3, 18.0) + tdSql.checkData(4, 4, 81.3862943611199) + tdSql.checkData(4, 5, 528.0) + tdSql.checkData(4, 6, 52.889224489452616) + tdSql.checkData(5, 0, 5) + tdSql.checkData(5, 1, 1.6094379124341003) + tdSql.checkData(5, 2, 25.0) + tdSql.checkData(5, 3, 27.0) + tdSql.checkData(5, 4, 151.6094379124341) + tdSql.checkData(5, 5, 1422.5424859373686) + tdSql.checkData(5, 6, 95.3678599195897) + tdSql.checkData(6, 0, 6) + tdSql.checkData(6, 1, 1.791759469228055) + tdSql.checkData(6, 2, 36.0) + tdSql.checkData(6, 3, 38.0) + tdSql.checkData(6, 4, 253.79175946922805) + tdSql.checkData(6, 5, 3210.538706646999) + tdSql.checkData(6, 6, 156.0308983742497) + tdSql.checkData(7, 0, 7) + tdSql.checkData(7, 1, 1.9459101490553132) + tdSql.checkData(7, 2, 49.0) + tdSql.checkData(7, 3, 51.0) + tdSql.checkData(7, 4, 393.9459101490553) + tdSql.checkData(7, 5, 6401.448897866082) + tdSql.checkData(7, 6, 237.770130906449) + tdSql.checkData(8, 0, 8) + tdSql.checkData(8, 1, 2.0794415416798357) + tdSql.checkData(8, 2, 64.0) + tdSql.checkData(8, 3, 66.0) + tdSql.checkData(8, 4, 578.0794415416798) + tdSql.checkData(8, 5, 11649.237502960395) + tdSql.checkData(8, 6, 343.37346669954064) + tdSql.checkData(9, 0, 9) + tdSql.checkData(9, 1, 2.1972245773362196) + tdSql.checkData(9, 2, 81.0) + tdSql.checkData(9, 3, 83.0) + tdSql.checkData(9, 4, 812.1972245773362) + tdSql.checkData(9, 5, 19764.0) + tdSql.checkData(9, 6, 475.5454239964755) + tdSql.checkData(10, 0, 0) + tdSql.checkData(10, 1, -1.3862943611198906) + tdSql.checkData(10, 2, 0.0) + tdSql.checkData(10, 3, 2.0625) + tdSql.checkData(10, 4, -inf) + tdSql.checkData(10, 5, 0.0) + tdSql.checkData(10, 6, -inf) + tdSql.checkData(11, 0, 1) + tdSql.checkData(11, 1, 0.0) + tdSql.checkData(11, 2, 1.0) + tdSql.checkData(11, 3, 3.0) + tdSql.checkData(11, 4, 2.0) + tdSql.checkData(11, 5, 2.0) + tdSql.checkData(11, 6, 3.0) + tdSql.checkData(12, 0, 2) + tdSql.checkData(12, 1, 0.6931471805599453) + tdSql.checkData(12, 2, 4.0) + tdSql.checkData(12, 3, 6.0) + tdSql.checkData(12, 4, 12.693147180559945) + tdSql.checkData(12, 5, 26.627416997969522) + tdSql.checkData(12, 6, 10.157551686928937) + tdSql.checkData(13, 0, 3) + tdSql.checkData(13, 1, 1.0986122886681098) + tdSql.checkData(13, 2, 9.0) + tdSql.checkData(13, 3, 11.0) + tdSql.checkData(13, 4, 37.09861228866811) + tdSql.checkData(13, 5, 149.29611541307906) + tdSql.checkData(13, 6, 25.565115706554913) + tdSql.checkData(14, 0, 4) + tdSql.checkData(14, 1, 1.3862943611198906) + tdSql.checkData(14, 2, 16.0) + tdSql.checkData(14, 3, 18.0) + tdSql.checkData(14, 4, 81.3862943611199) + tdSql.checkData(14, 5, 528.0) + tdSql.checkData(14, 6, 52.889224489452616) + tdSql.checkData(15, 0, 5) + tdSql.checkData(15, 1, 1.6094379124341003) + tdSql.checkData(15, 2, 25.0) + tdSql.checkData(15, 3, 27.0) + tdSql.checkData(15, 4, 151.6094379124341) + tdSql.checkData(15, 5, 1422.5424859373686) + tdSql.checkData(15, 6, 95.3678599195897) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 1.791759469228055) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 253.79175946922805) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.0308983742497) + tdSql.checkData(17, 0, 7) + tdSql.checkData(17, 1, 1.9459101490553132) + tdSql.checkData(17, 2, 49.0) + tdSql.checkData(17, 3, 51.0) + tdSql.checkData(17, 4, 393.9459101490553) + tdSql.checkData(17, 5, 6401.448897866082) + tdSql.checkData(17, 6, 237.770130906449) + tdSql.checkData(18, 0, 8) + tdSql.checkData(18, 1, 2.0794415416798357) + tdSql.checkData(18, 2, 64.0) + tdSql.checkData(18, 3, 66.0) + tdSql.checkData(18, 4, 578.0794415416798) + tdSql.checkData(18, 5, 11649.237502960395) + tdSql.checkData(18, 6, 343.37346669954064) + tdSql.checkData(19, 0, 9) + tdSql.checkData(19, 1, 2.1972245773362196) + tdSql.checkData(19, 2, 81.0) + tdSql.checkData(19, 3, 83.0) + tdSql.checkData(19, 4, 812.1972245773362) + tdSql.checkData(19, 5, 19764.0) + tdSql.checkData(19, 6, 475.5454239964755) + tdSql.checkData(20, 0, 10) + tdSql.checkData(20, 1, 2.302585092994046) + tdSql.checkData(20, 2, 100.0) + tdSql.checkData(20, 3, 102.0) + tdSql.checkData(20, 4, 1102.302585092994) + tdSql.checkData(20, 5, 31722.776601683792) + tdSql.checkData(20, 6, 636.9208936206307) + tdSql.checkData(21, 0, 11) + tdSql.checkData(21, 1, 2.3978952727983707) + tdSql.checkData(21, 2, 121.0) + tdSql.checkData(21, 3, 123.0) + tdSql.checkData(21, 4, 1454.3978952727985) + tdSql.checkData(21, 5, 48679.70355559341) + tdSql.checkData(21, 6, 830.0750695123152) + tdSql.checkData(22, 0, 12) + tdSql.checkData(22, 1, 2.4849066497880004) + tdSql.checkData(22, 2, 144.0) + tdSql.checkData(22, 3, 146.0) + tdSql.checkData(22, 4, 1874.484906649788) + tdSql.checkData(22, 5, 71975.61109149648) + tdSql.checkData(22, 6, 1057.5309706916078) + tdSql.checkData(23, 0, 13) + tdSql.checkData(23, 1, 2.5649493574615367) + tdSql.checkData(23, 2, 169.0) + tdSql.checkData(23, 3, 171.0) + tdSql.checkData(23, 4, 2368.5649493574615) + tdSql.checkData(23, 5, 103147.149978527) + tdSql.checkData(23, 6, 1321.765342841202) + tdSql.checkData(24, 0, 14) + tdSql.checkData(24, 1, 2.6390573296152584) + tdSql.checkData(24, 2, 196.0) + tdSql.checkData(24, 3, 198.0) + tdSql.checkData(24, 4, 2942.6390573296153) + tdSql.checkData(24, 5, 143935.51017030774) + tdSql.checkData(24, 6, 1625.213413896577) + tdSql.checkData(25, 0, 15) + tdSql.checkData(25, 1, 2.70805020110221) + tdSql.checkData(25, 2, 225.0) + tdSql.checkData(25, 3, 227.0) + tdSql.checkData(25, 4, 3602.708050201102) + tdSql.checkData(25, 5, 196294.78190175048) + tdSql.checkData(25, 6, 1970.2728076392277) + tdSql.checkData(26, 0, 16) + tdSql.checkData(26, 1, 2.772588722239781) + tdSql.checkData(26, 2, 256.0) + tdSql.checkData(26, 3, 258.0) + tdSql.checkData(26, 4, 4354.77258872224) + tdSql.checkData(26, 5, 262400.0) + tdSql.checkData(26, 6, 2359.306819756166) + tdSql.checkData(27, 0, 17) + tdSql.checkData(27, 1, 2.833213344056216) + tdSql.checkData(27, 2, 289.0) + tdSql.checkData(27, 3, 291.0) + tdSql.checkData(27, 4, 5204.833213344056) + tdSql.checkData(27, 5, 344654.9049572126) + tdSql.checkData(27, 6, 2794.647199269153) + tdSql.checkData(28, 0, 18) + tdSql.checkData(28, 1, 2.8903717578961645) + tdSql.checkData(28, 2, 324.0) + tdSql.checkData(28, 3, 326.0) + tdSql.checkData(28, 4, 6158.890371757896) + tdSql.checkData(28, 5, 445699.4487710341) + tdSql.checkData(28, 6, 3278.5965383797334) + tdSql.checkData(29, 0, 19) + tdSql.checkData(29, 1, 2.9444389791664403) + tdSql.checkData(29, 2, 361.0) + tdSql.checkData(29, 3, 363.0) + tdSql.checkData(29, 4, 7222.944438979166) + tdSql.checkData(29, 5, 568417.0692211641) + tdSql.checkData(29, 6, 3813.4303469855686) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from ct1 ) order by ts limit 2;;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + + tdSql.query( + "select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6 from (select * from ct1 ) limit 2;;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + + tdSql.query( + "select * from (select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6, ts from st0 order by ts desc);" + ) + tdSql.checkRows(30) + tdSql.checkData(0, 0, 19) + tdSql.checkData(0, 1, 2.9444389791664403) + tdSql.checkData(0, 2, 361.0) + tdSql.checkData(0, 3, 363.0) + tdSql.checkData(0, 4, 7222.944438979166) + tdSql.checkData(0, 5, 568417.0692211641) + tdSql.checkData(0, 6, 3813.4303469855686) + tdSql.checkData(0, 7, datetime.datetime(2020, 10, 1, 0, 19)) + tdSql.checkData(1, 0, 18) + tdSql.checkData(1, 1, 2.8903717578961645) + tdSql.checkData(1, 2, 324.0) + tdSql.checkData(1, 3, 326.0) + tdSql.checkData(1, 4, 6158.890371757896) + tdSql.checkData(1, 5, 445699.4487710341) + tdSql.checkData(1, 6, 3278.5965383797334) + tdSql.checkData(1, 7, datetime.datetime(2020, 10, 1, 0, 18)) + tdSql.checkData(2, 0, 17) + tdSql.checkData(2, 1, 2.833213344056216) + tdSql.checkData(2, 2, 289.0) + tdSql.checkData(2, 3, 291.0) + tdSql.checkData(2, 4, 5204.833213344056) + tdSql.checkData(2, 5, 344654.9049572126) + tdSql.checkData(2, 6, 2794.647199269153) + tdSql.checkData(2, 7, datetime.datetime(2020, 10, 1, 0, 17)) + tdSql.checkData(3, 0, 16) + tdSql.checkData(3, 1, 2.772588722239781) + tdSql.checkData(3, 2, 256.0) + tdSql.checkData(3, 3, 258.0) + tdSql.checkData(3, 4, 4354.77258872224) + tdSql.checkData(3, 5, 262400.0) + tdSql.checkData(3, 6, 2359.306819756166) + tdSql.checkData(3, 7, datetime.datetime(2020, 10, 1, 0, 16)) + tdSql.checkData(4, 0, 15) + tdSql.checkData(4, 1, 2.70805020110221) + tdSql.checkData(4, 2, 225.0) + tdSql.checkData(4, 3, 227.0) + tdSql.checkData(4, 4, 3602.708050201102) + tdSql.checkData(4, 5, 196294.78190175048) + tdSql.checkData(4, 6, 1970.2728076392277) + tdSql.checkData(4, 7, datetime.datetime(2020, 10, 1, 0, 15)) + tdSql.checkData(5, 0, 14) + tdSql.checkData(5, 1, 2.6390573296152584) + tdSql.checkData(5, 2, 196.0) + tdSql.checkData(5, 3, 198.0) + tdSql.checkData(5, 4, 2942.6390573296153) + tdSql.checkData(5, 5, 143935.51017030774) + tdSql.checkData(5, 6, 1625.213413896577) + tdSql.checkData(5, 7, datetime.datetime(2020, 10, 1, 0, 14)) + tdSql.checkData(6, 0, 13) + tdSql.checkData(6, 1, 2.5649493574615367) + tdSql.checkData(6, 2, 169.0) + tdSql.checkData(6, 3, 171.0) + tdSql.checkData(6, 4, 2368.5649493574615) + tdSql.checkData(6, 5, 103147.149978527) + tdSql.checkData(6, 6, 1321.765342841202) + tdSql.checkData(6, 7, datetime.datetime(2020, 10, 1, 0, 13)) + tdSql.checkData(7, 0, 12) + tdSql.checkData(7, 1, 2.4849066497880004) + tdSql.checkData(7, 2, 144.0) + tdSql.checkData(7, 3, 146.0) + tdSql.checkData(7, 4, 1874.484906649788) + tdSql.checkData(7, 5, 71975.61109149648) + tdSql.checkData(7, 6, 1057.5309706916078) + tdSql.checkData(7, 7, datetime.datetime(2020, 10, 1, 0, 12)) + tdSql.checkData(8, 0, 11) + tdSql.checkData(8, 1, 2.3978952727983707) + tdSql.checkData(8, 2, 121.0) + tdSql.checkData(8, 3, 123.0) + tdSql.checkData(8, 4, 1454.3978952727985) + tdSql.checkData(8, 5, 48679.70355559341) + tdSql.checkData(8, 6, 830.0750695123152) + tdSql.checkData(8, 7, datetime.datetime(2020, 10, 1, 0, 11)) + tdSql.checkData(9, 0, 10) + tdSql.checkData(9, 1, 2.302585092994046) + tdSql.checkData(9, 2, 100.0) + tdSql.checkData(9, 3, 102.0) + tdSql.checkData(9, 4, 1102.302585092994) + tdSql.checkData(9, 5, 31722.776601683792) + tdSql.checkData(9, 6, 636.9208936206307) + tdSql.checkData(9, 7, datetime.datetime(2020, 10, 1, 0, 10)) + tdSql.checkData(10, 0, 9) + tdSql.checkData(10, 1, 2.1972245773362196) + tdSql.checkData(10, 2, 81.0) + tdSql.checkData(10, 3, 83.0) + tdSql.checkData(10, 4, 812.1972245773362) + tdSql.checkData(10, 5, 19764.0) + tdSql.checkData(10, 6, 475.5454239964755) + tdSql.checkData(10, 7, datetime.datetime(2020, 10, 1, 0, 9)) + tdSql.checkData(11, 0, 9) + tdSql.checkData(11, 1, 2.1972245773362196) + tdSql.checkData(11, 2, 81.0) + tdSql.checkData(11, 3, 83.0) + tdSql.checkData(11, 4, 812.1972245773362) + tdSql.checkData(11, 5, 19764.0) + tdSql.checkData(11, 6, 475.5454239964755) + tdSql.checkData(11, 7, datetime.datetime(2020, 10, 1, 0, 9)) + tdSql.checkData(12, 0, 8) + tdSql.checkData(12, 1, 2.0794415416798357) + tdSql.checkData(12, 2, 64.0) + tdSql.checkData(12, 3, 66.0) + tdSql.checkData(12, 4, 578.0794415416798) + tdSql.checkData(12, 5, 11649.237502960395) + tdSql.checkData(12, 6, 343.37346669954064) + tdSql.checkData(12, 7, datetime.datetime(2020, 10, 1, 0, 8)) + tdSql.checkData(13, 0, 8) + tdSql.checkData(13, 1, 2.0794415416798357) + tdSql.checkData(13, 2, 64.0) + tdSql.checkData(13, 3, 66.0) + tdSql.checkData(13, 4, 578.0794415416798) + tdSql.checkData(13, 5, 11649.237502960395) + tdSql.checkData(13, 6, 343.37346669954064) + tdSql.checkData(13, 7, datetime.datetime(2020, 10, 1, 0, 8)) + tdSql.checkData(14, 0, 7) + tdSql.checkData(14, 1, 1.9459101490553132) + tdSql.checkData(14, 2, 49.0) + tdSql.checkData(14, 3, 51.0) + tdSql.checkData(14, 4, 393.9459101490553) + tdSql.checkData(14, 5, 6401.448897866082) + tdSql.checkData(14, 6, 237.770130906449) + tdSql.checkData(14, 7, datetime.datetime(2020, 10, 1, 0, 7)) + tdSql.checkData(15, 0, 7) + tdSql.checkData(15, 1, 1.9459101490553132) + tdSql.checkData(15, 2, 49.0) + tdSql.checkData(15, 3, 51.0) + tdSql.checkData(15, 4, 393.9459101490553) + tdSql.checkData(15, 5, 6401.448897866082) + tdSql.checkData(15, 6, 237.770130906449) + tdSql.checkData(15, 7, datetime.datetime(2020, 10, 1, 0, 7)) + tdSql.checkData(16, 0, 6) + tdSql.checkData(16, 1, 1.791759469228055) + tdSql.checkData(16, 2, 36.0) + tdSql.checkData(16, 3, 38.0) + tdSql.checkData(16, 4, 253.79175946922805) + tdSql.checkData(16, 5, 3210.538706646999) + tdSql.checkData(16, 6, 156.0308983742497) + tdSql.checkData(16, 7, datetime.datetime(2020, 10, 1, 0, 6)) + tdSql.checkData(17, 0, 6) + tdSql.checkData(17, 1, 1.791759469228055) + tdSql.checkData(17, 2, 36.0) + tdSql.checkData(17, 3, 38.0) + tdSql.checkData(17, 4, 253.79175946922805) + tdSql.checkData(17, 5, 3210.538706646999) + tdSql.checkData(17, 6, 156.0308983742497) + tdSql.checkData(17, 7, datetime.datetime(2020, 10, 1, 0, 6)) + tdSql.checkData(18, 0, 5) + tdSql.checkData(18, 1, 1.6094379124341003) + tdSql.checkData(18, 2, 25.0) + tdSql.checkData(18, 3, 27.0) + tdSql.checkData(18, 4, 151.6094379124341) + tdSql.checkData(18, 5, 1422.5424859373686) + tdSql.checkData(18, 6, 95.3678599195897) + tdSql.checkData(18, 7, datetime.datetime(2020, 10, 1, 0, 5)) + tdSql.checkData(19, 0, 5) + tdSql.checkData(19, 1, 1.6094379124341003) + tdSql.checkData(19, 2, 25.0) + tdSql.checkData(19, 3, 27.0) + tdSql.checkData(19, 4, 151.6094379124341) + tdSql.checkData(19, 5, 1422.5424859373686) + tdSql.checkData(19, 6, 95.3678599195897) + tdSql.checkData(19, 7, datetime.datetime(2020, 10, 1, 0, 5)) + tdSql.checkData(20, 0, 4) + tdSql.checkData(20, 1, 1.3862943611198906) + tdSql.checkData(20, 2, 16.0) + tdSql.checkData(20, 3, 18.0) + tdSql.checkData(20, 4, 81.3862943611199) + tdSql.checkData(20, 5, 528.0) + tdSql.checkData(20, 6, 52.889224489452616) + tdSql.checkData(20, 7, datetime.datetime(2020, 10, 1, 0, 4)) + tdSql.checkData(21, 0, 4) + tdSql.checkData(21, 1, 1.3862943611198906) + tdSql.checkData(21, 2, 16.0) + tdSql.checkData(21, 3, 18.0) + tdSql.checkData(21, 4, 81.3862943611199) + tdSql.checkData(21, 5, 528.0) + tdSql.checkData(21, 6, 52.889224489452616) + tdSql.checkData(21, 7, datetime.datetime(2020, 10, 1, 0, 4)) + tdSql.checkData(22, 0, 3) + tdSql.checkData(22, 1, 1.0986122886681098) + tdSql.checkData(22, 2, 9.0) + tdSql.checkData(22, 3, 11.0) + tdSql.checkData(22, 4, 37.09861228866811) + tdSql.checkData(22, 5, 149.29611541307906) + tdSql.checkData(22, 6, 25.565115706554913) + tdSql.checkData(22, 7, datetime.datetime(2020, 10, 1, 0, 3)) + tdSql.checkData(23, 0, 3) + tdSql.checkData(23, 1, 1.0986122886681098) + tdSql.checkData(23, 2, 9.0) + tdSql.checkData(23, 3, 11.0) + tdSql.checkData(23, 4, 37.09861228866811) + tdSql.checkData(23, 5, 149.29611541307906) + tdSql.checkData(23, 6, 25.565115706554913) + tdSql.checkData(23, 7, datetime.datetime(2020, 10, 1, 0, 3)) + tdSql.checkData(24, 0, 2) + tdSql.checkData(24, 1, 0.6931471805599453) + tdSql.checkData(24, 2, 4.0) + tdSql.checkData(24, 3, 6.0) + tdSql.checkData(24, 4, 12.693147180559945) + tdSql.checkData(24, 5, 26.627416997969522) + tdSql.checkData(24, 6, 10.157551686928937) + tdSql.checkData(24, 7, datetime.datetime(2020, 10, 1, 0, 2)) + tdSql.checkData(25, 0, 2) + tdSql.checkData(25, 1, 0.6931471805599453) + tdSql.checkData(25, 2, 4.0) + tdSql.checkData(25, 3, 6.0) + tdSql.checkData(25, 4, 12.693147180559945) + tdSql.checkData(25, 5, 26.627416997969522) + tdSql.checkData(25, 6, 10.157551686928937) + tdSql.checkData(25, 7, datetime.datetime(2020, 10, 1, 0, 2)) + tdSql.checkData(26, 0, 1) + tdSql.checkData(26, 1, 0.0) + tdSql.checkData(26, 2, 1.0) + tdSql.checkData(26, 3, 3.0) + tdSql.checkData(26, 4, 2.0) + tdSql.checkData(26, 5, 2.0) + tdSql.checkData(26, 6, 3.0) + tdSql.checkData(26, 7, datetime.datetime(2020, 10, 1, 0, 1)) + tdSql.checkData(27, 0, 1) + tdSql.checkData(27, 1, 0.0) + tdSql.checkData(27, 2, 1.0) + tdSql.checkData(27, 3, 3.0) + tdSql.checkData(27, 4, 2.0) + tdSql.checkData(27, 5, 2.0) + tdSql.checkData(27, 6, 3.0) + tdSql.checkData(27, 7, datetime.datetime(2020, 10, 1, 0, 1)) + tdSql.checkData(28, 0, 0) + tdSql.checkData(28, 1, -1.3862943611198906) + tdSql.checkData(28, 2, 0.0) + tdSql.checkData(28, 3, 2.0625) + tdSql.checkData(28, 4, -inf) + tdSql.checkData(28, 5, 0.0) + tdSql.checkData(28, 6, -inf) + tdSql.checkData(28, 7, datetime.datetime(2020, 10, 1, 0, 0)) + tdSql.checkData(29, 0, 0) + tdSql.checkData(29, 1, -1.3862943611198906) + tdSql.checkData(29, 2, 0.0) + tdSql.checkData(29, 3, 2.0625) + tdSql.checkData(29, 4, -inf) + tdSql.checkData(29, 5, 0.0) + tdSql.checkData(29, 6, -inf) + tdSql.checkData(29, 7, datetime.datetime(2020, 10, 1, 0, 0)) + + tdSql.query( + "select * from (select c1, log(c2), pow(c1,2), pow(c2,2)+2, pow(c2,3)+log(c3)+pow(c5,2) as v4, pow(c4, 4.5)+pow(c3, 2), log(c1)+log(c3,4)+pow(c6,2.8)+2 as v6, ts from ct1 order by ts limit 2);;" + ) + tdSql.checkRows(2) + tdSql.checkData(0, 0, 0) + tdSql.checkData(0, 1, -1.3862943611198906) + tdSql.checkData(0, 2, 0.0) + tdSql.checkData(0, 3, 2.0625) + tdSql.checkData(0, 4, -inf) + tdSql.checkData(0, 5, 0.0) + tdSql.checkData(0, 6, -inf) + tdSql.checkData(0, 7, datetime.datetime(2020, 10, 1, 0, 0)) + tdSql.checkData(1, 0, 1) + tdSql.checkData(1, 1, 0.0) + tdSql.checkData(1, 2, 1.0) + tdSql.checkData(1, 3, 3.0) + tdSql.checkData(1, 4, 2.0) + tdSql.checkData(1, 5, 2.0) + tdSql.checkData(1, 6, 3.0) + tdSql.checkData(1, 7, datetime.datetime(2020, 10, 1, 0, 1)) + + tdSql.execute("drop database db0") + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/2-query/scalar_triangle.py b/tests/develop-test/2-query/scalar_triangle.py index 0dbb55bc556c06afcfb243ada698b4eaca2a64f3..9ff3e5e63e0138f5a1bb90f228795ecaa0073fbd 100644 --- a/tests/develop-test/2-query/scalar_triangle.py +++ b/tests/develop-test/2-query/scalar_triangle.py @@ -1,22 +1,23 @@ -import sys +import sys from util.log import * from util.cases import * from util.sql import * from util.dnodes import tdDnodes -from math import inf +from math import inf, nan + class TDTestCase: def caseDescription(self): - ''' + """ case1: [TD-14122]: fix failed test on arm64 by converting from sim tst to python test to overcome NaN value and its string representation - ''' + """ return - + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) self._conn = conn - + def restartTaosd(self, index=1, dbname="db"): tdDnodes.stop(index) tdDnodes.startWithoutSleep(index) @@ -26,23 +27,36 @@ class TDTestCase: print("running {}".format(__file__)) tdSql.execute("drop database if exists db0") tdSql.execute("create database if not exists db0") - tdSql.execute('use db0') - tdSql.execute('create table st0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int);') + tdSql.execute("use db0") + tdSql.execute( + "create table st0 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int);" + ) - tdSql.execute('create table ct0 using st0 tags( 0 );') - tdSql.execute('insert into ct0 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );') + tdSql.execute("create table ct0 using st0 tags( 0 );") + tdSql.execute( + "insert into ct0 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );" + ) for i in range(1, 50): - tdSql.execute('insert into ct0 values ({}, {}, {}, {}, {}, {}, {}, {}, {}, {});'.format(1601481600000 + i * 60000, - i , i , i , i , i , i , i , i , i )) + tdSql.execute( + "insert into ct0 values ({}, {}, {}, {}, {}, {}, {}, {}, {}, {});".format( + 1601481600000 + i * 60000, i, i, i, i, i, i, i, i, i + ) + ) - tdSql.execute('create table ct1 using st0 tags( 1 );') - tdSql.execute('insert into ct1 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );') + tdSql.execute("create table ct1 using st0 tags( 1 );") + tdSql.execute( + "insert into ct1 values (1601481600000 , 0 , 0.25 , 0 , 0 , 0 , 0.25 , 0 , 0 , 0 );" + ) for i in range(1, 50): - tdSql.execute('insert into ct1 values ({}, {}, {}, {}, {}, {}, {}, {}, {}, {});'.format(1601481600000 + i * 60000, - i , i , i , i , i , i , i , i , i )) + tdSql.execute( + "insert into ct1 values ({}, {}, {}, {}, {}, {}, {}, {}, {}, {});".format( + 1601481600000 + i * 60000, i, i, i, i, i, i, i, i, i + ) + ) - - tdSql.query('select c1, sin(c1), cos(c1), tan(c1), asin(c1), acos(c1), atan(c1) from ct1;') + tdSql.query( + "select c1, sin(c1), cos(c1), tan(c1), asin(c1), acos(c1), atan(c1) from ct1;" + ) tdSql.checkRows(50) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 0.0) @@ -62,350 +76,354 @@ class TDTestCase: tdSql.checkData(2, 1, 0.9092974268256817) tdSql.checkData(2, 2, -0.4161468365471424) tdSql.checkData(2, 3, -2.185039863261519) - tdSql.checkData(2, 4, None) - tdSql.checkData(2, 5, None) + tdSql.checkData(2, 4, nan) + tdSql.checkData(2, 5, nan) tdSql.checkData(2, 6, 1.1071487177940904) tdSql.checkData(3, 0, 3) tdSql.checkData(3, 1, 0.1411200080598672) tdSql.checkData(3, 2, -0.9899924966004454) tdSql.checkData(3, 3, -0.1425465430742778) - tdSql.checkData(3, 4, None) - tdSql.checkData(3, 5, None) + tdSql.checkData(3, 4, nan) + tdSql.checkData(3, 5, nan) tdSql.checkData(3, 6, 1.2490457723982544) tdSql.checkData(4, 0, 4) tdSql.checkData(4, 1, -0.7568024953079282) tdSql.checkData(4, 2, -0.6536436208636119) tdSql.checkData(4, 3, 1.1578212823495775) - tdSql.checkData(4, 4, None) - tdSql.checkData(4, 5, None) + tdSql.checkData(4, 4, nan) + tdSql.checkData(4, 5, nan) tdSql.checkData(4, 6, 1.3258176636680326) tdSql.checkData(5, 0, 5) tdSql.checkData(5, 1, -0.9589242746631385) tdSql.checkData(5, 2, 0.28366218546322625) tdSql.checkData(5, 3, -3.380515006246586) - tdSql.checkData(5, 4, None) - tdSql.checkData(5, 5, None) + tdSql.checkData(5, 4, nan) + tdSql.checkData(5, 5, nan) tdSql.checkData(5, 6, 1.373400766945016) tdSql.checkData(6, 0, 6) tdSql.checkData(6, 1, -0.27941549819892586) tdSql.checkData(6, 2, 0.960170286650366) tdSql.checkData(6, 3, -0.29100619138474915) - tdSql.checkData(6, 4, None) - tdSql.checkData(6, 5, None) + tdSql.checkData(6, 4, nan) + tdSql.checkData(6, 5, nan) tdSql.checkData(6, 6, 1.4056476493802699) tdSql.checkData(7, 0, 7) tdSql.checkData(7, 1, 0.6569865987187891) tdSql.checkData(7, 2, 0.7539022543433046) tdSql.checkData(7, 3, 0.8714479827243188) - tdSql.checkData(7, 4, None) - tdSql.checkData(7, 5, None) + tdSql.checkData(7, 4, nan) + tdSql.checkData(7, 5, nan) tdSql.checkData(7, 6, 1.4288992721907328) tdSql.checkData(8, 0, 8) tdSql.checkData(8, 1, 0.9893582466233818) tdSql.checkData(8, 2, -0.14550003380861354) tdSql.checkData(8, 3, -6.799711455220379) - tdSql.checkData(8, 4, None) - tdSql.checkData(8, 5, None) + tdSql.checkData(8, 4, nan) + tdSql.checkData(8, 5, nan) tdSql.checkData(8, 6, 1.446441332248135) tdSql.checkData(9, 0, 9) tdSql.checkData(9, 1, 0.4121184852417566) tdSql.checkData(9, 2, -0.9111302618846769) tdSql.checkData(9, 3, -0.45231565944180985) - tdSql.checkData(9, 4, None) - tdSql.checkData(9, 5, None) + tdSql.checkData(9, 4, nan) + tdSql.checkData(9, 5, nan) tdSql.checkData(9, 6, 1.460139105621001) tdSql.checkData(10, 0, 10) tdSql.checkData(10, 1, -0.5440211108893698) tdSql.checkData(10, 2, -0.8390715290764524) tdSql.checkData(10, 3, 0.6483608274590866) - tdSql.checkData(10, 4, None) - tdSql.checkData(10, 5, None) + tdSql.checkData(10, 4, nan) + tdSql.checkData(10, 5, nan) tdSql.checkData(10, 6, 1.4711276743037347) tdSql.checkData(11, 0, 11) tdSql.checkData(11, 1, -0.9999902065507035) tdSql.checkData(11, 2, 0.004425697988050785) tdSql.checkData(11, 3, -225.95084645419513) - tdSql.checkData(11, 4, None) - tdSql.checkData(11, 5, None) + tdSql.checkData(11, 4, nan) + tdSql.checkData(11, 5, nan) tdSql.checkData(11, 6, 1.4801364395941514) tdSql.checkData(12, 0, 12) tdSql.checkData(12, 1, -0.5365729180004349) tdSql.checkData(12, 2, 0.8438539587324921) tdSql.checkData(12, 3, -0.6358599286615808) - tdSql.checkData(12, 4, None) - tdSql.checkData(12, 5, None) + tdSql.checkData(12, 4, nan) + tdSql.checkData(12, 5, nan) tdSql.checkData(12, 6, 1.4876550949064553) tdSql.checkData(13, 0, 13) tdSql.checkData(13, 1, 0.4201670368266409) tdSql.checkData(13, 2, 0.9074467814501962) tdSql.checkData(13, 3, 0.4630211329364896) - tdSql.checkData(13, 4, None) - tdSql.checkData(13, 5, None) + tdSql.checkData(13, 4, nan) + tdSql.checkData(13, 5, nan) tdSql.checkData(13, 6, 1.4940244355251187) tdSql.checkData(14, 0, 14) tdSql.checkData(14, 1, 0.9906073556948704) tdSql.checkData(14, 2, 0.1367372182078336) tdSql.checkData(14, 3, 7.2446066160948055) - tdSql.checkData(14, 4, None) - tdSql.checkData(14, 5, None) + tdSql.checkData(14, 4, nan) + tdSql.checkData(14, 5, nan) tdSql.checkData(14, 6, 1.4994888620096063) tdSql.checkData(15, 0, 15) tdSql.checkData(15, 1, 0.6502878401571168) tdSql.checkData(15, 2, -0.7596879128588213) tdSql.checkData(15, 3, -0.8559934009085187) - tdSql.checkData(15, 4, None) - tdSql.checkData(15, 5, None) + tdSql.checkData(15, 4, nan) + tdSql.checkData(15, 5, nan) tdSql.checkData(15, 6, 1.5042281630190728) tdSql.checkData(16, 0, 16) tdSql.checkData(16, 1, -0.2879033166650653) tdSql.checkData(16, 2, -0.9576594803233847) tdSql.checkData(16, 3, 0.3006322420239034) - tdSql.checkData(16, 4, None) - tdSql.checkData(16, 5, None) + tdSql.checkData(16, 4, nan) + tdSql.checkData(16, 5, nan) tdSql.checkData(16, 6, 1.5083775167989393) tdSql.checkData(17, 0, 17) tdSql.checkData(17, 1, -0.9613974918795568) tdSql.checkData(17, 2, -0.27516333805159693) tdSql.checkData(17, 3, 3.49391564547484) - tdSql.checkData(17, 4, None) - tdSql.checkData(17, 5, None) + tdSql.checkData(17, 4, nan) + tdSql.checkData(17, 5, nan) tdSql.checkData(17, 6, 1.512040504079174) tdSql.checkData(18, 0, 18) tdSql.checkData(18, 1, -0.750987246771676) tdSql.checkData(18, 2, 0.6603167082440802) tdSql.checkData(18, 3, -1.1373137123376869) - tdSql.checkData(18, 4, None) - tdSql.checkData(18, 5, None) + tdSql.checkData(18, 4, nan) + tdSql.checkData(18, 5, nan) tdSql.checkData(18, 6, 1.5152978215491797) tdSql.checkData(19, 0, 19) tdSql.checkData(19, 1, 0.14987720966295234) tdSql.checkData(19, 2, 0.9887046181866692) tdSql.checkData(19, 3, 0.15158947061240008) - tdSql.checkData(19, 4, None) - tdSql.checkData(19, 5, None) + tdSql.checkData(19, 4, nan) + tdSql.checkData(19, 5, nan) tdSql.checkData(19, 6, 1.5182132651839548) tdSql.checkData(20, 0, 20) tdSql.checkData(20, 1, 0.9129452507276277) tdSql.checkData(20, 2, 0.40808206181339196) tdSql.checkData(20, 3, 2.237160944224742) - tdSql.checkData(20, 4, None) - tdSql.checkData(20, 5, None) + tdSql.checkData(20, 4, nan) + tdSql.checkData(20, 5, nan) tdSql.checkData(20, 6, 1.5208379310729538) tdSql.checkData(21, 0, 21) tdSql.checkData(21, 1, 0.8366556385360561) tdSql.checkData(21, 2, -0.5477292602242684) tdSql.checkData(21, 3, -1.5274985276366035) - tdSql.checkData(21, 4, None) - tdSql.checkData(21, 5, None) + tdSql.checkData(21, 4, nan) + tdSql.checkData(21, 5, nan) tdSql.checkData(21, 6, 1.5232132235179132) tdSql.checkData(22, 0, 22) tdSql.checkData(22, 1, -0.008851309290403876) tdSql.checkData(22, 2, -0.9999608263946371) tdSql.checkData(22, 3, 0.00885165604168446) - tdSql.checkData(22, 4, None) - tdSql.checkData(22, 5, None) + tdSql.checkData(22, 4, nan) + tdSql.checkData(22, 5, nan) tdSql.checkData(22, 6, 1.5253730473733196) tdSql.checkData(23, 0, 23) tdSql.checkData(23, 1, -0.8462204041751706) tdSql.checkData(23, 2, -0.5328330203333975) tdSql.checkData(23, 3, 1.5881530833912738) - tdSql.checkData(23, 4, None) - tdSql.checkData(23, 5, None) + tdSql.checkData(23, 4, nan) + tdSql.checkData(23, 5, nan) tdSql.checkData(23, 6, 1.5273454314033659) tdSql.checkData(24, 0, 24) tdSql.checkData(24, 1, -0.9055783620066239) tdSql.checkData(24, 2, 0.424179007336997) tdSql.checkData(24, 3, -2.1348966977217008) - tdSql.checkData(24, 4, None) - tdSql.checkData(24, 5, None) + tdSql.checkData(24, 4, nan) + tdSql.checkData(24, 5, nan) tdSql.checkData(24, 6, 1.5291537476963082) tdSql.checkData(25, 0, 25) tdSql.checkData(25, 1, -0.13235175009777303) tdSql.checkData(25, 2, 0.9912028118634736) tdSql.checkData(25, 3, -0.13352640702153587) - tdSql.checkData(25, 4, None) - tdSql.checkData(25, 5, None) + tdSql.checkData(25, 4, nan) + tdSql.checkData(25, 5, nan) tdSql.checkData(25, 6, 1.5308176396716067) tdSql.checkData(26, 0, 26) tdSql.checkData(26, 1, 0.7625584504796027) tdSql.checkData(26, 2, 0.6469193223286404) tdSql.checkData(26, 3, 1.1787535542062797) - tdSql.checkData(26, 4, None) - tdSql.checkData(26, 5, None) + tdSql.checkData(26, 4, nan) + tdSql.checkData(26, 5, nan) tdSql.checkData(26, 6, 1.5323537367737086) tdSql.checkData(27, 0, 27) tdSql.checkData(27, 1, 0.956375928404503) tdSql.checkData(27, 2, -0.2921388087338362) tdSql.checkData(27, 3, -3.273703800428119) - tdSql.checkData(27, 4, None) - tdSql.checkData(27, 5, None) + tdSql.checkData(27, 4, nan) + tdSql.checkData(27, 5, nan) tdSql.checkData(27, 6, 1.5337762109209665) tdSql.checkData(28, 0, 28) tdSql.checkData(28, 1, 0.27090578830786904) tdSql.checkData(28, 2, -0.9626058663135666) tdSql.checkData(28, 3, -0.28142960456426525) - tdSql.checkData(28, 4, None) - tdSql.checkData(28, 5, None) + tdSql.checkData(28, 4, nan) + tdSql.checkData(28, 5, nan) tdSql.checkData(28, 6, 1.5350972141155725) tdSql.checkData(29, 0, 29) tdSql.checkData(29, 1, -0.6636338842129675) tdSql.checkData(29, 2, -0.7480575296890003) tdSql.checkData(29, 3, 0.8871428437982151) - tdSql.checkData(29, 4, None) - tdSql.checkData(29, 5, None) + tdSql.checkData(29, 4, nan) + tdSql.checkData(29, 5, nan) tdSql.checkData(29, 6, 1.5363272257953886) tdSql.checkData(30, 0, 30) tdSql.checkData(30, 1, -0.9880316240928618) tdSql.checkData(30, 2, 0.15425144988758405) tdSql.checkData(30, 3, -6.405331196646276) - tdSql.checkData(30, 4, None) - tdSql.checkData(30, 5, None) + tdSql.checkData(30, 4, nan) + tdSql.checkData(30, 5, nan) tdSql.checkData(30, 6, 1.5374753309166493) tdSql.checkData(31, 0, 31) tdSql.checkData(31, 1, -0.404037645323065) tdSql.checkData(31, 2, 0.9147423578045313) tdSql.checkData(31, 3, -0.441695568020698) - tdSql.checkData(31, 4, None) - tdSql.checkData(31, 5, None) + tdSql.checkData(31, 4, nan) + tdSql.checkData(31, 5, nan) tdSql.checkData(31, 6, 1.5385494443596428) tdSql.checkData(32, 0, 32) tdSql.checkData(32, 1, 0.5514266812416906) tdSql.checkData(32, 2, 0.8342233605065102) tdSql.checkData(32, 3, 0.6610060414837631) - tdSql.checkData(32, 4, None) - tdSql.checkData(32, 5, None) + tdSql.checkData(32, 4, nan) + tdSql.checkData(32, 5, nan) tdSql.checkData(32, 6, 1.5395564933646284) tdSql.checkData(33, 0, 33) tdSql.checkData(33, 1, 0.9999118601072672) tdSql.checkData(33, 2, -0.013276747223059479) tdSql.checkData(33, 3, -75.31301480008509) - tdSql.checkData(33, 4, None) - tdSql.checkData(33, 5, None) + tdSql.checkData(33, 4, nan) + tdSql.checkData(33, 5, nan) tdSql.checkData(33, 6, 1.5405025668761214) tdSql.checkData(34, 0, 34) tdSql.checkData(34, 1, 0.5290826861200238) tdSql.checkData(34, 2, -0.8485702747846052) tdSql.checkData(34, 3, -0.6234989627162255) - tdSql.checkData(34, 4, None) - tdSql.checkData(34, 5, None) + tdSql.checkData(34, 4, nan) + tdSql.checkData(34, 5, nan) tdSql.checkData(34, 6, 1.5413930385908916) tdSql.checkData(35, 0, 35) tdSql.checkData(35, 1, -0.428182669496151) tdSql.checkData(35, 2, -0.9036922050915067) tdSql.checkData(35, 3, 0.473814720414451) - tdSql.checkData(35, 4, None) - tdSql.checkData(35, 5, None) + tdSql.checkData(35, 4, nan) + tdSql.checkData(35, 5, nan) tdSql.checkData(35, 6, 1.5422326689561365) tdSql.checkData(36, 0, 36) tdSql.checkData(36, 1, -0.9917788534431158) tdSql.checkData(36, 2, -0.12796368962740468) tdSql.checkData(36, 3, 7.750470905699148) - tdSql.checkData(36, 4, None) - tdSql.checkData(36, 5, None) + tdSql.checkData(36, 4, nan) + tdSql.checkData(36, 5, nan) tdSql.checkData(36, 6, 1.5430256902014756) tdSql.checkData(37, 0, 37) tdSql.checkData(37, 1, -0.6435381333569995) tdSql.checkData(37, 2, 0.7654140519453434) tdSql.checkData(37, 3, -0.8407712554027597) - tdSql.checkData(37, 4, None) - tdSql.checkData(37, 5, None) + tdSql.checkData(37, 4, nan) + tdSql.checkData(37, 5, nan) tdSql.checkData(37, 6, 1.5437758776076318) tdSql.checkData(38, 0, 38) tdSql.checkData(38, 1, 0.2963685787093853) tdSql.checkData(38, 2, 0.9550736440472949) tdSql.checkData(38, 3, 0.310309660994801) - tdSql.checkData(38, 4, None) - tdSql.checkData(38, 5, None) + tdSql.checkData(38, 4, nan) + tdSql.checkData(38, 5, nan) tdSql.checkData(38, 6, 1.5444866095419745) tdSql.checkData(39, 0, 39) tdSql.checkData(39, 1, 0.9637953862840878) tdSql.checkData(39, 2, 0.26664293235993725) tdSql.checkData(39, 3, 3.614554407101535) - tdSql.checkData(39, 4, None) - tdSql.checkData(39, 5, None) + tdSql.checkData(39, 4, nan) + tdSql.checkData(39, 5, nan) tdSql.checkData(39, 6, 1.545160918273219) tdSql.checkData(40, 0, 40) tdSql.checkData(40, 1, 0.7451131604793488) tdSql.checkData(40, 2, -0.6669380616522619) tdSql.checkData(40, 3, -1.117214930923896) - tdSql.checkData(40, 4, None) - tdSql.checkData(40, 5, None) + tdSql.checkData(40, 4, nan) + tdSql.checkData(40, 5, nan) tdSql.checkData(40, 6, 1.5458015331759765) tdSql.checkData(41, 0, 41) tdSql.checkData(41, 1, -0.158622668804709) tdSql.checkData(41, 2, -0.9873392775238264) tdSql.checkData(41, 3, 0.16065669868064283) - tdSql.checkData(41, 4, None) - tdSql.checkData(41, 5, None) + tdSql.checkData(41, 4, nan) + tdSql.checkData(41, 5, nan) tdSql.checkData(41, 6, 1.546410917622178) tdSql.checkData(42, 0, 42) tdSql.checkData(42, 1, -0.9165215479156338) tdSql.checkData(42, 2, -0.39998531498835127) tdSql.checkData(42, 3, 2.2913879924374863) - tdSql.checkData(42, 4, None) - tdSql.checkData(42, 5, None) + tdSql.checkData(42, 4, nan) + tdSql.checkData(42, 5, nan) tdSql.checkData(42, 6, 1.5469913006098266) tdSql.checkData(43, 0, 43) tdSql.checkData(43, 1, -0.8317747426285983) tdSql.checkData(43, 2, 0.5551133015206257) tdSql.checkData(43, 3, -1.4983873388551707) - tdSql.checkData(43, 4, None) - tdSql.checkData(43, 5, None) + tdSql.checkData(43, 4, nan) + tdSql.checkData(43, 5, nan) tdSql.checkData(43, 6, 1.5475447039844337) tdSql.checkData(44, 0, 44) tdSql.checkData(44, 1, 0.017701925105413577) tdSql.checkData(44, 2, 0.9998433086476912) tdSql.checkData(44, 3, 0.017704699278685777) - tdSql.checkData(44, 4, None) - tdSql.checkData(44, 5, None) + tdSql.checkData(44, 4, nan) + tdSql.checkData(44, 5, nan) tdSql.checkData(44, 6, 1.5480729659532555) tdSql.checkData(45, 0, 45) tdSql.checkData(45, 1, 0.8509035245341184) tdSql.checkData(45, 2, 0.5253219888177297) tdSql.checkData(45, 3, 1.6197751905438615) - tdSql.checkData(45, 4, None) - tdSql.checkData(45, 5, None) + tdSql.checkData(45, 4, nan) + tdSql.checkData(45, 5, nan) tdSql.checkData(45, 6, 1.5485777614681775) tdSql.checkData(46, 0, 46) tdSql.checkData(46, 1, 0.9017883476488092) tdSql.checkData(46, 2, -0.4321779448847783) tdSql.checkData(46, 3, -2.086613531121382) - tdSql.checkData(46, 4, None) - tdSql.checkData(46, 5, None) + tdSql.checkData(46, 4, nan) + tdSql.checkData(46, 5, nan) tdSql.checkData(46, 6, 1.5490606199531038) tdSql.checkData(47, 0, 47) tdSql.checkData(47, 1, 0.123573122745224) tdSql.checkData(47, 2, -0.9923354691509287) tdSql.checkData(47, 3, -0.12452756813273719) - tdSql.checkData(47, 4, None) - tdSql.checkData(47, 5, None) + tdSql.checkData(47, 4, nan) + tdSql.checkData(47, 5, nan) tdSql.checkData(47, 6, 1.5495229407708355) tdSql.checkData(48, 0, 48) tdSql.checkData(48, 1, -0.7682546613236668) tdSql.checkData(48, 2, -0.6401443394691997) tdSql.checkData(48, 3, 1.2001272431162864) - tdSql.checkData(48, 4, None) - tdSql.checkData(48, 5, None) + tdSql.checkData(48, 4, nan) + tdSql.checkData(48, 5, nan) tdSql.checkData(48, 6, 1.5499660067586796) tdSql.checkData(49, 0, 49) tdSql.checkData(49, 1, -0.9537526527594719) tdSql.checkData(49, 2, 0.3005925437436371) tdSql.checkData(49, 3, -3.172908552159191) - tdSql.checkData(49, 4, None) - tdSql.checkData(49, 5, None) + tdSql.checkData(49, 4, nan) + tdSql.checkData(49, 5, nan) tdSql.checkData(49, 6, 1.5503909961083586) - tdSql.query('select c1, sin(c2)+2, cos(c2)+2, cos(pow(c2,2)+2), tan(pow(c2,3)+log(c3, 2)+pow(c5,2)) as v4, asin(pow(c4, 4.5)+pow(c3, 2)), acos(log(c1,2)+log(c3,4)+pow(c6,2.8)+2) as v6 from ct1 where ts == 1601481600000;') + tdSql.query( + "select c1, sin(c2)+2, cos(c2)+2, cos(pow(c2,2)+2), tan(pow(c2,3)+log(c3, 2)+pow(c5,2)) as v4, asin(pow(c4, 4.5)+pow(c3, 2)), acos(log(c1,2)+log(c3,4)+pow(c6,2.8)+2) as v6 from ct1 where ts == 1601481600000;" + ) tdSql.checkRows(1) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 2.2474039592545227) tdSql.checkData(0, 2, 2.9689124217106446) tdSql.checkData(0, 3, -0.4721284112969602) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.0) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) - tdSql.query('select c1, sin(c2), cos(c1+2), tan(c2+2)+2, sin(c2+3)+cos(c3+2)+tan(c5+2) as v4, sin(c4+4.5)+tan(c3+2), sin(c1+2)+cos(c3+4)+acos(c6+2.8)+2 as v6 from st0 where ts == 1601481600000;') + tdSql.query( + "select c1, sin(c2), cos(c1+2), tan(c2+2)+2, sin(c2+3)+cos(c3+2)+tan(c5+2) as v4, sin(c4+4.5)+tan(c3+2), sin(c1+2)+cos(c3+4)+acos(c6+2.8)+2 as v6 from st0 where ts == 1601481600000;" + ) tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 0.24740395925452294) @@ -413,50 +431,56 @@ class TDTestCase: tdSql.checkData(0, 3, 0.7613723837759034) tdSql.checkData(0, 4, -2.7093818343387697) tdSql.checkData(0, 5, -3.162569980926616) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) tdSql.checkData(1, 0, 0) tdSql.checkData(1, 1, 0.24740395925452294) tdSql.checkData(1, 2, -0.4161468365471424) tdSql.checkData(1, 3, 0.7613723837759034) tdSql.checkData(1, 4, -2.7093818343387697) tdSql.checkData(1, 5, -3.162569980926616) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 6, nan) - tdSql.query('select c1, tan(c2+ 2), sin(pow(c1,2)), cos(pow(c2,2)+2), tan(pow(c2,3)+log(c3, 2)+pow(c5,2)) as v4, asin(pow(c4, 4.5)+pow(c3, 2)), acos(log(c1,2)+log(c3,4)+pow(c6,2.8)+2) as v6 from st0 where c1 == 0;') + tdSql.query( + "select c1, tan(c2+ 2), sin(pow(c1,2)), cos(pow(c2,2)+2), tan(pow(c2,3)+log(c3, 2)+pow(c5,2)) as v4, asin(pow(c4, 4.5)+pow(c3, 2)), acos(log(c1,2)+log(c3,4)+pow(c6,2.8)+2) as v6 from st0 where c1 == 0;" + ) tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, -1.2386276162240966) tdSql.checkData(0, 2, 0.0) tdSql.checkData(0, 3, -0.4721284112969602) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.0) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) tdSql.checkData(1, 0, 0) tdSql.checkData(1, 1, -1.2386276162240966) tdSql.checkData(1, 2, 0.0) tdSql.checkData(1, 3, -0.4721284112969602) - tdSql.checkData(1, 4, None) + tdSql.checkData(1, 4, nan) tdSql.checkData(1, 5, 0.0) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 6, nan) - tdSql.query('select c1, atan(c2+2), asin(c1+2), acos(c2+c1)+2, acos(c2+c3)+asin(c3+c2)+pow(c5,2) as v4, acos(c4/4.5)+asin(c3-2), asin(c1/2)+log(c3,c4)+pow(c6, 2.8)+2 as v6 from st0 where c1 == 0;') + tdSql.query( + "select c1, atan(c2+2), asin(c1+2), acos(c2+c1)+2, acos(c2+c3)+asin(c3+c2)+pow(c5,2) as v4, acos(c4/4.5)+asin(c3-2), asin(c1/2)+log(c3,c4)+pow(c6, 2.8)+2 as v6 from st0 where c1 == 0;" + ) tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 1.1525719972156676) - tdSql.checkData(0, 2, None) + tdSql.checkData(0, 2, nan) tdSql.checkData(0, 3, 3.3181160716528177) tdSql.checkData(0, 4, 1.5707963267948966) - tdSql.checkData(0, 5, None) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 5, nan) + tdSql.checkData(0, 6, nan) tdSql.checkData(1, 0, 0) tdSql.checkData(1, 1, 1.1525719972156676) - tdSql.checkData(1, 2, None) + tdSql.checkData(1, 2, nan) tdSql.checkData(1, 3, 3.3181160716528177) tdSql.checkData(1, 4, 1.5707963267948966) - tdSql.checkData(1, 5, None) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 5, nan) + tdSql.checkData(1, 6, nan) - tdSql.query('select c1, cos(c2+2), cos(ceil(pow(c1,2))), sin(floor(pow(c2,2)+2)), sin(ceil(c2)+floor(c3+c2)+round(c5+c2)) as v4, atan(pow(c4, 4.5)+pow(c3, 2)), tan(log(c1,2)+cos(c3+4)+pow(c6,2.8)+2) as v6 from st0 order by ts desc;') + tdSql.query( + "select c1, cos(c2+2), cos(ceil(pow(c1,2))), sin(floor(pow(c2,2)+2)), sin(ceil(c2)+floor(c3+c2)+round(c5+c2)) as v4, atan(pow(c4, 4.5)+pow(c3, 2)), tan(log(c1,2)+cos(c3+4)+pow(c6,2.8)+2) as v6 from st0 order by ts desc;" + ) tdSql.checkRows(100) tdSql.checkData(0, 0, 49) tdSql.checkData(0, 1, 0.7421541968137826) @@ -1150,704 +1174,708 @@ class TDTestCase: tdSql.checkData(98, 3, 0.9092974268256817) tdSql.checkData(98, 4, 0.8414709848078965) tdSql.checkData(98, 5, 0.0) - tdSql.checkData(98, 6, None) + tdSql.checkData(98, 6, nan) tdSql.checkData(99, 0, 0) tdSql.checkData(99, 1, -0.6281736227227391) tdSql.checkData(99, 2, 1.0) tdSql.checkData(99, 3, 0.9092974268256817) tdSql.checkData(99, 4, 0.8414709848078965) tdSql.checkData(99, 5, 0.0) - tdSql.checkData(99, 6, None) + tdSql.checkData(99, 6, nan) - tdSql.query('select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5+c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from ct1 order by ts limit 2;;') + tdSql.query( + "select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5+c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from ct1 order by ts limit 2;;" + ) tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 0.7780731968879212) tdSql.checkData(0, 2, 0.6143002821164822) tdSql.checkData(0, 3, 3.2037266279837113) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.02246988233490299) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) tdSql.checkData(1, 0, 1) tdSql.checkData(1, 1, 0.1411200080598672) tdSql.checkData(1, 2, 0.6663667453928805) tdSql.checkData(1, 3, 1.558041126155035) tdSql.checkData(1, 4, 2.1543462689906883) tdSql.checkData(1, 5, 0.17204223631998083) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 6, nan) - tdSql.query('select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 order by ts desc);') + tdSql.query( + "select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 order by ts desc);" + ) tdSql.checkRows(100) tdSql.checkData(0, 0, 49) tdSql.checkData(0, 1, 0.6702291758433747) tdSql.checkData(0, 2, 0.9923745526637894) tdSql.checkData(0, 3, 0.9298143670243166) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.7136182821549459) tdSql.checkData(0, 6, -0.7462904241496138) tdSql.checkData(1, 0, 49) tdSql.checkData(1, 1, 0.6702291758433747) tdSql.checkData(1, 2, 0.9923745526637894) tdSql.checkData(1, 3, 0.9298143670243166) - tdSql.checkData(1, 4, None) + tdSql.checkData(1, 4, nan) tdSql.checkData(1, 5, 0.7136182821549459) tdSql.checkData(1, 6, -0.7462904241496138) tdSql.checkData(2, 0, 48) tdSql.checkData(2, 1, -0.26237485370392877) tdSql.checkData(2, 2, 0.6202081141679935) tdSql.checkData(2, 3, 1.8175857333771335) - tdSql.checkData(2, 4, None) + tdSql.checkData(2, 4, nan) tdSql.checkData(2, 5, 1.211884234321115) tdSql.checkData(2, 6, 5.183714988550632) tdSql.checkData(3, 0, 48) tdSql.checkData(3, 1, -0.26237485370392877) tdSql.checkData(3, 2, 0.6202081141679935) tdSql.checkData(3, 3, 1.8175857333771335) - tdSql.checkData(3, 4, None) + tdSql.checkData(3, 4, nan) tdSql.checkData(3, 5, 1.211884234321115) tdSql.checkData(3, 6, 5.183714988550632) tdSql.checkData(4, 0, 47) tdSql.checkData(4, 1, -0.9537526527594719) tdSql.checkData(4, 2, 0.6593040763085178) tdSql.checkData(4, 3, 3.4575106745458637) - tdSql.checkData(4, 4, None) + tdSql.checkData(4, 4, nan) tdSql.checkData(4, 5, 0.8820838187306987) tdSql.checkData(4, 6, 2.6302204463996084) tdSql.checkData(5, 0, 47) tdSql.checkData(5, 1, -0.9537526527594719) tdSql.checkData(5, 2, 0.6593040763085178) tdSql.checkData(5, 3, 3.4575106745458637) - tdSql.checkData(5, 4, None) + tdSql.checkData(5, 4, nan) tdSql.checkData(5, 5, 0.8820838187306987) tdSql.checkData(5, 6, 2.6302204463996084) tdSql.checkData(6, 0, 46) tdSql.checkData(6, 1, -0.7682546613236668) tdSql.checkData(6, 2, 0.9998433250151273) tdSql.checkData(6, 3, 1.2763169256468458) - tdSql.checkData(6, 4, None) + tdSql.checkData(6, 4, nan) tdSql.checkData(6, 5, -0.300459258677913) tdSql.checkData(6, 6, 0.13392039926281352) tdSql.checkData(7, 0, 46) tdSql.checkData(7, 1, -0.7682546613236668) tdSql.checkData(7, 2, 0.9998433250151273) tdSql.checkData(7, 3, 1.2763169256468458) - tdSql.checkData(7, 4, None) + tdSql.checkData(7, 4, nan) tdSql.checkData(7, 5, -0.300459258677913) tdSql.checkData(7, 6, 0.13392039926281352) tdSql.checkData(8, 0, 45) tdSql.checkData(8, 1, 0.123573122745224) tdSql.checkData(8, 2, 0.6735650596658175) tdSql.checkData(8, 3, 1.5193186190030223) - tdSql.checkData(8, 4, None) + tdSql.checkData(8, 4, nan) tdSql.checkData(8, 5, -1.5661895943272113) tdSql.checkData(8, 6, 5.513771854144419) tdSql.checkData(9, 0, 45) tdSql.checkData(9, 1, 0.123573122745224) tdSql.checkData(9, 2, 0.6735650596658175) tdSql.checkData(9, 3, 1.5193186190030223) - tdSql.checkData(9, 4, None) + tdSql.checkData(9, 4, nan) tdSql.checkData(9, 5, -1.5661895943272113) tdSql.checkData(9, 6, 5.513771854144419) tdSql.checkData(10, 0, 44) tdSql.checkData(10, 1, 0.9017883476488092) tdSql.checkData(10, 2, 0.6085839480802863) tdSql.checkData(10, 3, 3.5552629892514687) - tdSql.checkData(10, 4, None) + tdSql.checkData(10, 4, nan) tdSql.checkData(10, 5, -1.9810692649977342) tdSql.checkData(10, 6, 3.0531030020123464) tdSql.checkData(11, 0, 44) tdSql.checkData(11, 1, 0.9017883476488092) tdSql.checkData(11, 2, 0.6085839480802863) tdSql.checkData(11, 3, 3.5552629892514687) - tdSql.checkData(11, 4, None) + tdSql.checkData(11, 4, nan) tdSql.checkData(11, 5, -1.9810692649977342) tdSql.checkData(11, 6, 3.0531030020123464) tdSql.checkData(12, 0, 43) tdSql.checkData(12, 1, 0.8509035245341184) tdSql.checkData(12, 2, 0.9874457808369176) tdSql.checkData(12, 3, 1.5962924548219202) - tdSql.checkData(12, 4, None) + tdSql.checkData(12, 4, nan) tdSql.checkData(12, 5, -1.2490970766755156) tdSql.checkData(12, 6, 0.5781542141407696) tdSql.checkData(13, 0, 43) tdSql.checkData(13, 1, 0.8509035245341184) tdSql.checkData(13, 2, 0.9874457808369176) tdSql.checkData(13, 3, 1.5962924548219202) - tdSql.checkData(13, 4, None) + tdSql.checkData(13, 4, nan) tdSql.checkData(13, 5, -1.2490970766755156) tdSql.checkData(13, 6, 0.5781542141407696) tdSql.checkData(14, 0, 42) tdSql.checkData(14, 1, 0.017701925105413577) tdSql.checkData(14, 2, 0.7350111780599404) tdSql.checkData(14, 3, 1.1912997639866574) - tdSql.checkData(14, 4, None) + tdSql.checkData(14, 4, nan) tdSql.checkData(14, 5, 0.036467324189017214) tdSql.checkData(14, 6, 6.024578312510778) tdSql.checkData(15, 0, 42) tdSql.checkData(15, 1, 0.017701925105413577) tdSql.checkData(15, 2, 0.7350111780599404) tdSql.checkData(15, 3, 1.1912997639866574) - tdSql.checkData(15, 4, None) + tdSql.checkData(15, 4, nan) tdSql.checkData(15, 5, 0.036467324189017214) tdSql.checkData(15, 6, 6.024578312510778) tdSql.checkData(16, 0, 41) tdSql.checkData(16, 1, -0.8317747426285983) tdSql.checkData(16, 2, 0.5704067143341829) tdSql.checkData(16, 3, 3.397430462894578) - tdSql.checkData(16, 4, None) + tdSql.checkData(16, 4, nan) tdSql.checkData(16, 5, 0.9190273051332304) tdSql.checkData(16, 6, 3.473885481113728) tdSql.checkData(17, 0, 41) tdSql.checkData(17, 1, -0.8317747426285983) tdSql.checkData(17, 2, 0.5704067143341829) tdSql.checkData(17, 3, 3.397430462894578) - tdSql.checkData(17, 4, None) + tdSql.checkData(17, 4, nan) tdSql.checkData(17, 5, 0.9190273051332304) tdSql.checkData(17, 6, 3.473885481113728) tdSql.checkData(18, 0, 40) tdSql.checkData(18, 1, -0.9165215479156338) tdSql.checkData(18, 2, 0.9564033460276342) tdSql.checkData(18, 3, 1.889162191085516) - tdSql.checkData(18, 4, None) + tdSql.checkData(18, 4, nan) tdSql.checkData(18, 5, 0.90296737936602) tdSql.checkData(18, 6, 0.888896415152729) tdSql.checkData(19, 0, 40) tdSql.checkData(19, 1, -0.9165215479156338) tdSql.checkData(19, 2, 0.9564033460276342) tdSql.checkData(19, 3, 1.889162191085516) - tdSql.checkData(19, 4, None) + tdSql.checkData(19, 4, nan) tdSql.checkData(19, 5, 0.90296737936602) tdSql.checkData(19, 6, 0.888896415152729) tdSql.checkData(20, 0, 39) tdSql.checkData(20, 1, -0.158622668804709) tdSql.checkData(20, 2, 0.7999777847134487) tdSql.checkData(20, 3, 0.8435920138756074) - tdSql.checkData(20, 4, None) + tdSql.checkData(20, 4, nan) tdSql.checkData(20, 5, 0.3319994538301167) tdSql.checkData(20, 6, 7.12853286308907) tdSql.checkData(21, 0, 39) tdSql.checkData(21, 1, -0.158622668804709) tdSql.checkData(21, 2, 0.7999777847134487) tdSql.checkData(21, 3, 0.8435920138756074) - tdSql.checkData(21, 4, None) + tdSql.checkData(21, 4, nan) tdSql.checkData(21, 5, 0.3319994538301167) tdSql.checkData(21, 6, 7.12853286308907) tdSql.checkData(22, 0, 38) tdSql.checkData(22, 1, 0.7451131604793488) tdSql.checkData(22, 2, 0.5472018255605284) tdSql.checkData(22, 3, 3.081063350979351) - tdSql.checkData(22, 4, None) + tdSql.checkData(22, 4, nan) tdSql.checkData(22, 5, -0.007381884932924798) tdSql.checkData(22, 6, 3.8764172978929814) tdSql.checkData(23, 0, 38) tdSql.checkData(23, 1, 0.7451131604793488) tdSql.checkData(23, 2, 0.5472018255605284) tdSql.checkData(23, 3, 3.081063350979351) - tdSql.checkData(23, 4, None) + tdSql.checkData(23, 4, nan) tdSql.checkData(23, 5, -0.007381884932924798) tdSql.checkData(23, 6, 3.8764172978929814) tdSql.checkData(24, 0, 37) tdSql.checkData(24, 1, 0.9637953862840878) tdSql.checkData(24, 2, 0.909721840267583) tdSql.checkData(24, 3, 2.1734252903776303) - tdSql.checkData(24, 4, None) + tdSql.checkData(24, 4, nan) tdSql.checkData(24, 5, 0.32696474077278626) tdSql.checkData(24, 6, 1.174082484128993) tdSql.checkData(25, 0, 37) tdSql.checkData(25, 1, 0.9637953862840878) tdSql.checkData(25, 2, 0.909721840267583) tdSql.checkData(25, 3, 2.1734252903776303) - tdSql.checkData(25, 4, None) + tdSql.checkData(25, 4, nan) tdSql.checkData(25, 5, 0.32696474077278626) tdSql.checkData(25, 6, 1.174082484128993) tdSql.checkData(26, 0, 36) tdSql.checkData(26, 1, 0.2963685787093853) tdSql.checkData(26, 2, 0.8632704401895588) tdSql.checkData(26, 3, 0.5493681603601657) - tdSql.checkData(26, 4, None) + tdSql.checkData(26, 4, nan) tdSql.checkData(26, 5, 0.9944678850925007) tdSql.checkData(26, 6, 11.004294268461184) tdSql.checkData(27, 0, 36) tdSql.checkData(27, 1, 0.2963685787093853) tdSql.checkData(27, 2, 0.8632704401895588) tdSql.checkData(27, 3, 0.5493681603601657) - tdSql.checkData(27, 4, None) + tdSql.checkData(27, 4, nan) tdSql.checkData(27, 5, 0.9944678850925007) tdSql.checkData(27, 6, 11.004294268461184) tdSql.checkData(28, 0, 35) tdSql.checkData(28, 1, -0.6435381333569995) tdSql.checkData(28, 2, 0.5403764709316752) tdSql.checkData(28, 3, 2.734210799811235) - tdSql.checkData(28, 4, None) + tdSql.checkData(28, 4, nan) tdSql.checkData(28, 5, 1.1930854189064375) tdSql.checkData(28, 6, 4.24770540197234) tdSql.checkData(29, 0, 35) tdSql.checkData(29, 1, -0.6435381333569995) tdSql.checkData(29, 2, 0.5403764709316752) tdSql.checkData(29, 3, 2.734210799811235) - tdSql.checkData(29, 4, None) + tdSql.checkData(29, 4, nan) tdSql.checkData(29, 5, 1.1930854189064375) tdSql.checkData(29, 6, 4.24770540197234) tdSql.checkData(30, 0, 34) tdSql.checkData(30, 1, -0.9917788534431158) tdSql.checkData(30, 2, 0.8517779466253769) tdSql.checkData(30, 3, 2.470955260231499) - tdSql.checkData(30, 4, None) + tdSql.checkData(30, 4, nan) tdSql.checkData(30, 5, 0.4428112547200472) tdSql.checkData(30, 6, 1.4785733565944832) tdSql.checkData(31, 0, 34) tdSql.checkData(31, 1, -0.9917788534431158) tdSql.checkData(31, 2, 0.8517779466253769) tdSql.checkData(31, 3, 2.470955260231499) - tdSql.checkData(31, 4, None) + tdSql.checkData(31, 4, nan) tdSql.checkData(31, 5, 0.4428112547200472) tdSql.checkData(31, 6, 1.4785733565944832) tdSql.checkData(32, 0, 33) tdSql.checkData(32, 1, -0.428182669496151) tdSql.checkData(32, 2, 0.9194811573015673) tdSql.checkData(32, 3, 0.4437992589174107) - tdSql.checkData(32, 4, None) + tdSql.checkData(32, 4, nan) tdSql.checkData(32, 5, -0.9001958571391758) tdSql.checkData(32, 6, -72.33956595410905) tdSql.checkData(33, 0, 33) tdSql.checkData(33, 1, -0.428182669496151) tdSql.checkData(33, 2, 0.9194811573015673) tdSql.checkData(33, 3, 0.4437992589174107) - tdSql.checkData(33, 4, None) + tdSql.checkData(33, 4, nan) tdSql.checkData(33, 5, -0.9001958571391758) tdSql.checkData(33, 6, -72.33956595410905) tdSql.checkData(34, 0, 32) tdSql.checkData(34, 1, 0.5290826861200238) tdSql.checkData(34, 2, 0.5503344099628432) tdSql.checkData(34, 3, 2.413227615833899) - tdSql.checkData(34, 4, None) + tdSql.checkData(34, 4, nan) tdSql.checkData(34, 5, -1.8893763681780902) tdSql.checkData(34, 6, 4.581032079680554) tdSql.checkData(35, 0, 32) tdSql.checkData(35, 1, 0.5290826861200238) tdSql.checkData(35, 2, 0.5503344099628432) tdSql.checkData(35, 3, 2.413227615833899) - tdSql.checkData(35, 4, None) + tdSql.checkData(35, 4, nan) tdSql.checkData(35, 5, -1.8893763681780902) tdSql.checkData(35, 6, 4.581032079680554) tdSql.checkData(36, 0, 31) tdSql.checkData(36, 1, 0.9999118601072672) tdSql.checkData(36, 2, 0.7877590247885756) tdSql.checkData(36, 3, 2.7979785951133604) - tdSql.checkData(36, 4, None) + tdSql.checkData(36, 4, nan) tdSql.checkData(36, 5, -1.7874722290307907) tdSql.checkData(36, 6, 1.8191237353300793) tdSql.checkData(37, 0, 31) tdSql.checkData(37, 1, 0.9999118601072672) tdSql.checkData(37, 2, 0.7877590247885756) tdSql.checkData(37, 3, 2.7979785951133604) - tdSql.checkData(37, 4, None) + tdSql.checkData(37, 4, nan) tdSql.checkData(37, 5, -1.7874722290307907) tdSql.checkData(37, 6, 1.8191237353300793) tdSql.checkData(38, 0, 30) tdSql.checkData(38, 1, 0.5514266812416906) tdSql.checkData(38, 2, 0.9635288988181601) tdSql.checkData(38, 3, 0.5944617511422015) - tdSql.checkData(38, 4, None) + tdSql.checkData(38, 4, nan) tdSql.checkData(38, 5, -0.7022004347538967) tdSql.checkData(38, 6, -3.710141817748492) tdSql.checkData(39, 0, 30) tdSql.checkData(39, 1, 0.5514266812416906) tdSql.checkData(39, 2, 0.9635288988181601) tdSql.checkData(39, 3, 0.5944617511422015) - tdSql.checkData(39, 4, None) + tdSql.checkData(39, 4, nan) tdSql.checkData(39, 5, -0.7022004347538967) tdSql.checkData(39, 6, -3.710141817748492) tdSql.checkData(40, 0, 29) tdSql.checkData(40, 1, -0.404037645323065) tdSql.checkData(40, 2, 0.5764850221962442) tdSql.checkData(40, 3, 2.1197476343754156) - tdSql.checkData(40, 4, None) + tdSql.checkData(40, 4, nan) tdSql.checkData(40, 5, 0.5162157333804713) tdSql.checkData(40, 6, 4.8800154918827525) tdSql.checkData(41, 0, 29) tdSql.checkData(41, 1, -0.404037645323065) tdSql.checkData(41, 2, 0.5764850221962442) tdSql.checkData(41, 3, 2.1197476343754156) - tdSql.checkData(41, 4, None) + tdSql.checkData(41, 4, nan) tdSql.checkData(41, 5, 0.5162157333804713) tdSql.checkData(41, 6, 4.8800154918827525) tdSql.checkData(42, 0, 28) tdSql.checkData(42, 1, -0.9880316240928618) tdSql.checkData(42, 2, 0.7230710689951642) tdSql.checkData(42, 3, 3.1457526648156393) - tdSql.checkData(42, 4, None) + tdSql.checkData(42, 4, nan) tdSql.checkData(42, 5, 1.0206076417536643) tdSql.checkData(42, 6, 2.197019393348823) tdSql.checkData(43, 0, 28) tdSql.checkData(43, 1, -0.9880316240928618) tdSql.checkData(43, 2, 0.7230710689951642) tdSql.checkData(43, 3, 3.1457526648156393) - tdSql.checkData(43, 4, None) + tdSql.checkData(43, 4, nan) tdSql.checkData(43, 5, 1.0206076417536643) tdSql.checkData(43, 6, 2.197019393348823) tdSql.checkData(44, 0, 27) tdSql.checkData(44, 1, -0.6636338842129675) tdSql.checkData(44, 2, 0.9912542848596704) tdSql.checkData(44, 3, 0.9080812682077812) - tdSql.checkData(44, 4, None) + tdSql.checkData(44, 4, nan) tdSql.checkData(44, 5, 0.6788951190016388) tdSql.checkData(44, 6, -0.8324928492797357) tdSql.checkData(45, 0, 27) tdSql.checkData(45, 1, -0.6636338842129675) tdSql.checkData(45, 2, 0.9912542848596704) tdSql.checkData(45, 3, 0.9080812682077812) - tdSql.checkData(45, 4, None) + tdSql.checkData(45, 4, nan) tdSql.checkData(45, 5, 0.6788951190016388) tdSql.checkData(45, 6, -0.8324928492797357) tdSql.checkData(46, 0, 26) tdSql.checkData(46, 1, 0.27090578830786904) tdSql.checkData(46, 2, 0.6172306382193644) tdSql.checkData(46, 3, 1.835550377607515) - tdSql.checkData(46, 4, None) + tdSql.checkData(46, 4, nan) tdSql.checkData(46, 5, 0.11431954199291106) tdSql.checkData(46, 6, 5.165381146246765) tdSql.checkData(47, 0, 26) tdSql.checkData(47, 1, 0.27090578830786904) tdSql.checkData(47, 2, 0.6172306382193644) tdSql.checkData(47, 3, 1.835550377607515) - tdSql.checkData(47, 4, None) + tdSql.checkData(47, 4, nan) tdSql.checkData(47, 5, 0.11431954199291106) tdSql.checkData(47, 6, 5.165381146246765) tdSql.checkData(48, 0, 25) tdSql.checkData(48, 1, 0.956375928404503) tdSql.checkData(48, 2, 0.6628179613691831) tdSql.checkData(48, 3, 3.4435632194258416) - tdSql.checkData(48, 4, None) + tdSql.checkData(48, 4, nan) tdSql.checkData(48, 5, 0.05676687083562715) tdSql.checkData(48, 6, 2.6040987392745354) tdSql.checkData(49, 0, 25) tdSql.checkData(49, 1, 0.956375928404503) tdSql.checkData(49, 2, 0.6628179613691831) tdSql.checkData(49, 3, 3.4435632194258416) - tdSql.checkData(49, 4, None) + tdSql.checkData(49, 4, nan) tdSql.checkData(49, 5, 0.05676687083562715) tdSql.checkData(49, 6, 2.6040987392745354) tdSql.checkData(50, 0, 24) tdSql.checkData(50, 1, 0.7625584504796027) tdSql.checkData(50, 2, 0.999960827417674) tdSql.checkData(50, 3, 1.2552318002593996) - tdSql.checkData(50, 4, None) + tdSql.checkData(50, 4, nan) tdSql.checkData(50, 5, 0.6200983185456957) tdSql.checkData(50, 6, 0.09684864095463253) tdSql.checkData(51, 0, 24) tdSql.checkData(51, 1, 0.7625584504796027) tdSql.checkData(51, 2, 0.999960827417674) tdSql.checkData(51, 3, 1.2552318002593996) - tdSql.checkData(51, 4, None) + tdSql.checkData(51, 4, nan) tdSql.checkData(51, 5, 0.6200983185456957) tdSql.checkData(51, 6, 0.09684864095463253) tdSql.checkData(52, 0, 23) tdSql.checkData(52, 1, -0.13235175009777303) tdSql.checkData(52, 2, 0.6699494442536529) tdSql.checkData(52, 3, 1.5387402975985367) - tdSql.checkData(52, 4, None) + tdSql.checkData(52, 4, nan) tdSql.checkData(52, 5, 1.1825447904081037) tdSql.checkData(52, 6, 5.489941431040083) tdSql.checkData(53, 0, 23) tdSql.checkData(53, 1, -0.13235175009777303) tdSql.checkData(53, 2, 0.6699494442536529) tdSql.checkData(53, 3, 1.5387402975985367) - tdSql.checkData(53, 4, None) + tdSql.checkData(53, 4, nan) tdSql.checkData(53, 5, 1.1825447904081037) tdSql.checkData(53, 6, 5.489941431040083) tdSql.checkData(54, 0, 22) tdSql.checkData(54, 1, -0.9055783620066239) tdSql.checkData(54, 2, 0.6114178044194122) tdSql.checkData(54, 3, 3.5568711064263105) - tdSql.checkData(54, 4, None) + tdSql.checkData(54, 4, nan) tdSql.checkData(54, 5, 0.9837833410919679) tdSql.checkData(54, 6, 3.0265535811470983) tdSql.checkData(55, 0, 22) tdSql.checkData(55, 1, -0.9055783620066239) tdSql.checkData(55, 2, 0.6114178044194122) tdSql.checkData(55, 3, 3.5568711064263105) - tdSql.checkData(55, 4, None) + tdSql.checkData(55, 4, nan) tdSql.checkData(55, 5, 0.9837833410919679) tdSql.checkData(55, 6, 3.0265535811470983) tdSql.checkData(56, 0, 21) tdSql.checkData(56, 1, -0.8462204041751706) tdSql.checkData(56, 2, 0.9887894200405688) tdSql.checkData(56, 3, 1.5772240911721418) - tdSql.checkData(56, 4, None) + tdSql.checkData(56, 4, nan) tdSql.checkData(56, 5, -0.11647857397382422) tdSql.checkData(56, 6, 0.5559799244477626) tdSql.checkData(57, 0, 21) tdSql.checkData(57, 1, -0.8462204041751706) tdSql.checkData(57, 2, 0.9887894200405688) tdSql.checkData(57, 3, 1.5772240911721418) - tdSql.checkData(57, 4, None) + tdSql.checkData(57, 4, nan) tdSql.checkData(57, 5, -0.11647857397382422) tdSql.checkData(57, 6, 0.5559799244477626) tdSql.checkData(58, 0, 20) tdSql.checkData(58, 1, -0.008851309290403876) tdSql.checkData(58, 2, 0.7310155667453407) tdSql.checkData(58, 3, 1.2127175951404974) - tdSql.checkData(58, 4, None) + tdSql.checkData(58, 4, nan) tdSql.checkData(58, 5, -1.4304290589415767) tdSql.checkData(58, 6, 5.982274104704091) tdSql.checkData(59, 0, 20) tdSql.checkData(59, 1, -0.008851309290403876) tdSql.checkData(59, 2, 0.7310155667453407) tdSql.checkData(59, 3, 1.2127175951404974) - tdSql.checkData(59, 4, None) + tdSql.checkData(59, 4, nan) tdSql.checkData(59, 5, -1.4304290589415767) tdSql.checkData(59, 6, 5.982274104704091) tdSql.checkData(60, 0, 19) tdSql.checkData(60, 1, 0.8366556385360561) tdSql.checkData(60, 2, 0.5723746128431292) tdSql.checkData(60, 3, 3.413484890511323) - tdSql.checkData(60, 4, None) + tdSql.checkData(60, 4, nan) tdSql.checkData(60, 5, -1.9952541841757747) tdSql.checkData(60, 6, 3.4479580493217856) tdSql.checkData(61, 0, 19) tdSql.checkData(61, 1, 0.8366556385360561) tdSql.checkData(61, 2, 0.5723746128431292) tdSql.checkData(61, 3, 3.413484890511323) - tdSql.checkData(61, 4, None) + tdSql.checkData(61, 4, nan) tdSql.checkData(61, 5, -1.9952541841757747) tdSql.checkData(61, 6, 3.4479580493217856) tdSql.checkData(62, 0, 18) tdSql.checkData(62, 1, 0.9129452507276277) tdSql.checkData(62, 2, 0.9588413200803038) tdSql.checkData(62, 3, 1.8713332491184997) - tdSql.checkData(62, 4, None) + tdSql.checkData(62, 4, nan) tdSql.checkData(62, 5, -1.3983047743451864) tdSql.checkData(62, 6, 0.8709074342191974) tdSql.checkData(63, 0, 18) tdSql.checkData(63, 1, 0.9129452507276277) tdSql.checkData(63, 2, 0.9588413200803038) tdSql.checkData(63, 3, 1.8713332491184997) - tdSql.checkData(63, 4, None) + tdSql.checkData(63, 4, nan) tdSql.checkData(63, 5, -1.3983047743451864) tdSql.checkData(63, 6, 0.8709074342191974) tdSql.checkData(64, 0, 17) tdSql.checkData(64, 1, 0.14987720966295234) tdSql.checkData(64, 2, 0.7959095686227995) tdSql.checkData(64, 3, 0.864944320724419) - tdSql.checkData(64, 4, None) + tdSql.checkData(64, 4, nan) tdSql.checkData(64, 5, -0.13037289959062748) tdSql.checkData(64, 6, 7.022998331594864) tdSql.checkData(65, 0, 17) tdSql.checkData(65, 1, 0.14987720966295234) tdSql.checkData(65, 2, 0.7959095686227995) tdSql.checkData(65, 3, 0.864944320724419) - tdSql.checkData(65, 4, None) + tdSql.checkData(65, 4, nan) tdSql.checkData(65, 5, -0.13037289959062748) tdSql.checkData(65, 6, 7.022998331594864) tdSql.checkData(66, 0, 16) tdSql.checkData(66, 1, -0.750987246771676) tdSql.checkData(66, 2, 0.5481819942730298) tdSql.checkData(66, 3, 3.102748784455539) - tdSql.checkData(66, 4, None) + tdSql.checkData(66, 4, nan) tdSql.checkData(66, 5, 0.8513297604701857) tdSql.checkData(66, 6, 3.852058923265594) tdSql.checkData(67, 0, 16) tdSql.checkData(67, 1, -0.750987246771676) tdSql.checkData(67, 2, 0.5481819942730298) tdSql.checkData(67, 3, 3.102748784455539) - tdSql.checkData(67, 4, None) + tdSql.checkData(67, 4, nan) tdSql.checkData(67, 5, 0.8513297604701857) tdSql.checkData(67, 6, 3.852058923265594) tdSql.checkData(68, 0, 15) tdSql.checkData(68, 1, -0.9613974918795568) tdSql.checkData(68, 2, 0.9130208165623314) tdSql.checkData(68, 3, 2.1554866011151765) - tdSql.checkData(68, 4, None) + tdSql.checkData(68, 4, nan) tdSql.checkData(68, 5, 0.9521751875546269) tdSql.checkData(68, 6, 1.1559749749986195) tdSql.checkData(69, 0, 15) tdSql.checkData(69, 1, -0.9613974918795568) tdSql.checkData(69, 2, 0.9130208165623314) tdSql.checkData(69, 3, 2.1554866011151765) - tdSql.checkData(69, 4, None) + tdSql.checkData(69, 4, nan) tdSql.checkData(69, 5, 0.9521751875546269) tdSql.checkData(69, 6, 1.1559749749986195) tdSql.checkData(70, 0, 14) tdSql.checkData(70, 1, -0.2879033166650653) tdSql.checkData(70, 2, 0.859465627274523) tdSql.checkData(70, 3, 0.5636905248139659) - tdSql.checkData(70, 4, None) + tdSql.checkData(70, 4, nan) tdSql.checkData(70, 5, 0.41142163587369207) tdSql.checkData(70, 6, 10.515512404402676) tdSql.checkData(71, 0, 14) tdSql.checkData(71, 1, -0.2879033166650653) tdSql.checkData(71, 2, 0.859465627274523) tdSql.checkData(71, 3, 0.5636905248139659) - tdSql.checkData(71, 4, None) + tdSql.checkData(71, 4, nan) tdSql.checkData(71, 5, 0.41142163587369207) tdSql.checkData(71, 6, 10.515512404402676) tdSql.checkData(72, 0, 13) tdSql.checkData(72, 1, 0.6502878401571168) tdSql.checkData(72, 2, 0.5403105467456532) tdSql.checkData(72, 3, 2.75535470715349) - tdSql.checkData(72, 4, None) + tdSql.checkData(72, 4, nan) tdSql.checkData(72, 5, 0.0009616202598659029) tdSql.checkData(72, 6, 4.225579583416092) tdSql.checkData(73, 0, 13) tdSql.checkData(73, 1, 0.6502878401571168) tdSql.checkData(73, 2, 0.5403105467456532) tdSql.checkData(73, 3, 2.75535470715349) - tdSql.checkData(73, 4, None) + tdSql.checkData(73, 4, nan) tdSql.checkData(73, 5, 0.0009616202598659029) tdSql.checkData(73, 6, 4.225579583416092) tdSql.checkData(74, 0, 12) tdSql.checkData(74, 1, 0.9906073556948704) tdSql.checkData(74, 2, 0.8556343548213666) tdSql.checkData(74, 3, 2.451594361777497) - tdSql.checkData(74, 4, None) + tdSql.checkData(74, 4, nan) tdSql.checkData(74, 5, 0.24838494428124291) tdSql.checkData(74, 6, 1.4585617093317953) tdSql.checkData(75, 0, 12) tdSql.checkData(75, 1, 0.9906073556948704) tdSql.checkData(75, 2, 0.8556343548213666) tdSql.checkData(75, 3, 2.451594361777497) - tdSql.checkData(75, 4, None) + tdSql.checkData(75, 4, nan) tdSql.checkData(75, 5, 0.24838494428124291) tdSql.checkData(75, 6, 1.4585617093317953) tdSql.checkData(76, 0, 11) tdSql.checkData(76, 1, 0.4201670368266409) tdSql.checkData(76, 2, 0.9162743174606308) tdSql.checkData(76, 3, 0.44272645708128566) - tdSql.checkData(76, 4, None) + tdSql.checkData(76, 4, nan) tdSql.checkData(76, 5, 0.9151372562290566) tdSql.checkData(76, 6, -222.95969776348554) tdSql.checkData(77, 0, 11) tdSql.checkData(77, 1, 0.4201670368266409) tdSql.checkData(77, 2, 0.9162743174606308) tdSql.checkData(77, 3, 0.44272645708128566) - tdSql.checkData(77, 4, None) + tdSql.checkData(77, 4, nan) tdSql.checkData(77, 5, 0.9151372562290566) tdSql.checkData(77, 6, -222.95969776348554) tdSql.checkData(78, 0, 10) tdSql.checkData(78, 1, -0.5365729180004349) tdSql.checkData(78, 2, 0.549226270051226) tdSql.checkData(78, 3, 2.432352856101439) - tdSql.checkData(78, 4, None) + tdSql.checkData(78, 4, nan) tdSql.checkData(78, 5, 1.2185572409879093) tdSql.checkData(78, 6, 4.561306078186714) tdSql.checkData(79, 0, 10) tdSql.checkData(79, 1, -0.5365729180004349) tdSql.checkData(79, 2, 0.549226270051226) tdSql.checkData(79, 3, 2.432352856101439) - tdSql.checkData(79, 4, None) + tdSql.checkData(79, 4, nan) tdSql.checkData(79, 5, 1.2185572409879093) tdSql.checkData(79, 6, 4.561306078186714) tdSql.checkData(80, 0, 9) tdSql.checkData(80, 1, -0.9999902065507035) tdSql.checkData(80, 2, 0.7918362090144786) tdSql.checkData(80, 3, 2.776612511546888) - tdSql.checkData(80, 4, None) + tdSql.checkData(80, 4, nan) tdSql.checkData(80, 5, 0.5929886271208413) tdSql.checkData(80, 6, 1.796697093786514) tdSql.checkData(81, 0, 9) tdSql.checkData(81, 1, -0.9999902065507035) tdSql.checkData(81, 2, 0.7918362090144786) tdSql.checkData(81, 3, 2.776612511546888) - tdSql.checkData(81, 4, None) + tdSql.checkData(81, 4, nan) tdSql.checkData(81, 5, 0.5929886271208413) tdSql.checkData(81, 6, 1.796697093786514) tdSql.checkData(82, 0, 8) tdSql.checkData(82, 1, -0.5440211108893698) tdSql.checkData(82, 2, 0.9612168045072789) tdSql.checkData(82, 3, 0.5787344727995947) - tdSql.checkData(82, 4, None) + tdSql.checkData(82, 4, nan) tdSql.checkData(82, 5, -0.7199655182148126) tdSql.checkData(82, 6, -4.087614771885445) tdSql.checkData(83, 0, 8) tdSql.checkData(83, 1, -0.5440211108893698) tdSql.checkData(83, 2, 0.9612168045072789) tdSql.checkData(83, 3, 0.5787344727995947) - tdSql.checkData(83, 4, None) + tdSql.checkData(83, 4, nan) tdSql.checkData(83, 5, -0.7199655182148126) tdSql.checkData(83, 6, -4.087614771885445) tdSql.checkData(84, 0, 7) tdSql.checkData(84, 1, 0.4121184852417566) tdSql.checkData(84, 2, 0.574400879193934) tdSql.checkData(84, 3, 2.137595835197328) - tdSql.checkData(84, 4, None) + tdSql.checkData(84, 4, nan) tdSql.checkData(84, 5, -1.8119088619792247) tdSql.checkData(84, 6, 4.862055338419189) tdSql.checkData(85, 0, 7) tdSql.checkData(85, 1, 0.4121184852417566) tdSql.checkData(85, 2, 0.574400879193934) tdSql.checkData(85, 3, 2.137595835197328) - tdSql.checkData(85, 4, None) + tdSql.checkData(85, 4, nan) tdSql.checkData(85, 5, -1.8119088619792247) tdSql.checkData(85, 6, 4.862055338419189) tdSql.checkData(86, 0, 6) tdSql.checkData(86, 1, 0.9893582466233818) tdSql.checkData(86, 2, 0.7270351311688125) tdSql.checkData(86, 3, 3.1243204798042576) - tdSql.checkData(86, 4, None) + tdSql.checkData(86, 4, nan) tdSql.checkData(86, 5, -1.8696882565721156) tdSql.checkData(86, 6, 2.172420890614816) tdSql.checkData(87, 0, 6) tdSql.checkData(87, 1, 0.9893582466233818) tdSql.checkData(87, 2, 0.7270351311688125) tdSql.checkData(87, 3, 3.1243204798042576) - tdSql.checkData(87, 4, None) + tdSql.checkData(87, 4, nan) tdSql.checkData(87, 5, -1.8696882565721156) tdSql.checkData(87, 6, 2.172420890614816) tdSql.checkData(88, 0, 5) tdSql.checkData(88, 1, 0.6569865987187891) tdSql.checkData(88, 2, 0.9900590857598653) tdSql.checkData(88, 3, 0.8864495743441427) - tdSql.checkData(88, 4, None) + tdSql.checkData(88, 4, nan) tdSql.checkData(88, 5, -0.876294736008743) tdSql.checkData(88, 6, -0.9245361171359558) tdSql.checkData(89, 0, 5) tdSql.checkData(89, 1, 0.6569865987187891) tdSql.checkData(89, 2, 0.9900590857598653) tdSql.checkData(89, 3, 0.8864495743441427) - tdSql.checkData(89, 4, None) + tdSql.checkData(89, 4, nan) tdSql.checkData(89, 5, -0.876294736008743) tdSql.checkData(89, 6, -0.9245361171359558) tdSql.checkData(90, 0, 4) tdSql.checkData(90, 1, -0.27941549819892586) tdSql.checkData(90, 2, 0.6143002821164822) tdSql.checkData(90, 3, 1.853464438509776) - tdSql.checkData(90, 4, None) + tdSql.checkData(90, 4, nan) tdSql.checkData(90, 5, 0.38234027607634785) tdSql.checkData(90, 6, 5.147179528972959) tdSql.checkData(91, 0, 4) tdSql.checkData(91, 1, -0.27941549819892586) tdSql.checkData(91, 2, 0.6143002821164822) tdSql.checkData(91, 3, 1.853464438509776) - tdSql.checkData(91, 4, None) + tdSql.checkData(91, 4, nan) tdSql.checkData(91, 5, 0.38234027607634785) tdSql.checkData(91, 6, 5.147179528972959) tdSql.checkData(92, 0, 3) tdSql.checkData(92, 1, -0.9589242746631385) tdSql.checkData(92, 2, 0.6663667453928805) tdSql.checkData(92, 3, 3.4288753232277074) - tdSql.checkData(92, 4, None) + tdSql.checkData(92, 4, nan) tdSql.checkData(92, 5, 1.0087371784424417) tdSql.checkData(92, 6, 2.5780379587267963) tdSql.checkData(93, 0, 3) tdSql.checkData(93, 1, -0.9589242746631385) tdSql.checkData(93, 2, 0.6663667453928805) tdSql.checkData(93, 3, 3.4288753232277074) - tdSql.checkData(93, 4, None) + tdSql.checkData(93, 4, nan) tdSql.checkData(93, 5, 1.0087371784424417) tdSql.checkData(93, 6, 2.5780379587267963) tdSql.checkData(94, 0, 2) tdSql.checkData(94, 1, -0.7568024953079282) tdSql.checkData(94, 2, 1.0) tdSql.checkData(94, 3, 1.2340302976078754) - tdSql.checkData(94, 4, None) + tdSql.checkData(94, 4, nan) tdSql.checkData(94, 5, 0.7554222939559553) tdSql.checkData(94, 6, 0.05815764143055291) tdSql.checkData(95, 0, 2) tdSql.checkData(95, 1, -0.7568024953079282) tdSql.checkData(95, 2, 1.0) tdSql.checkData(95, 3, 1.2340302976078754) - tdSql.checkData(95, 4, None) + tdSql.checkData(95, 4, nan) tdSql.checkData(95, 5, 0.7554222939559553) tdSql.checkData(95, 6, 0.05815764143055291) tdSql.checkData(96, 0, 1) @@ -1856,718 +1884,722 @@ class TDTestCase: tdSql.checkData(96, 3, 1.558041126155035) tdSql.checkData(96, 4, 1.8325957145940461) tdSql.checkData(96, 5, 0.17204223631998083) - tdSql.checkData(96, 6, None) + tdSql.checkData(96, 6, nan) tdSql.checkData(97, 0, 1) tdSql.checkData(97, 1, 0.1411200080598672) tdSql.checkData(97, 2, 0.6663667453928805) tdSql.checkData(97, 3, 1.558041126155035) tdSql.checkData(97, 4, 1.8325957145940461) tdSql.checkData(97, 5, 0.17204223631998083) - tdSql.checkData(97, 6, None) + tdSql.checkData(97, 6, nan) tdSql.checkData(98, 0, 0) tdSql.checkData(98, 1, 0.7780731968879212) tdSql.checkData(98, 2, 0.6143002821164822) tdSql.checkData(98, 3, 3.2037266279837113) - tdSql.checkData(98, 4, None) + tdSql.checkData(98, 4, nan) tdSql.checkData(98, 5, 0.02246988233490299) - tdSql.checkData(98, 6, None) + tdSql.checkData(98, 6, nan) tdSql.checkData(99, 0, 0) tdSql.checkData(99, 1, 0.7780731968879212) tdSql.checkData(99, 2, 0.6143002821164822) tdSql.checkData(99, 3, 3.2037266279837113) - tdSql.checkData(99, 4, None) + tdSql.checkData(99, 4, nan) tdSql.checkData(99, 5, 0.02246988233490299) - tdSql.checkData(99, 6, None) + tdSql.checkData(99, 6, nan) - tdSql.query('select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 order by ts limit 2);;') + tdSql.query( + "select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 order by ts limit 2);;" + ) tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 0.7780731968879212) tdSql.checkData(0, 2, 0.6143002821164822) tdSql.checkData(0, 3, 3.2037266279837113) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.02246988233490299) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) tdSql.checkData(1, 0, 1) tdSql.checkData(1, 1, 0.1411200080598672) tdSql.checkData(1, 2, 0.6663667453928805) tdSql.checkData(1, 3, 1.558041126155035) tdSql.checkData(1, 4, 1.8325957145940461) tdSql.checkData(1, 5, 0.17204223631998083) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 6, nan) - tdSql.query('select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 ) order by ts desc;') + tdSql.query( + "select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 ) order by ts desc;" + ) tdSql.checkRows(100) tdSql.checkData(0, 0, 49) tdSql.checkData(0, 1, 0.6702291758433747) tdSql.checkData(0, 2, 0.9923745526637894) tdSql.checkData(0, 3, 0.9298143670243166) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.7136182821549459) tdSql.checkData(0, 6, -0.7462904241496138) tdSql.checkData(1, 0, 49) tdSql.checkData(1, 1, 0.6702291758433747) tdSql.checkData(1, 2, 0.9923745526637894) tdSql.checkData(1, 3, 0.9298143670243166) - tdSql.checkData(1, 4, None) + tdSql.checkData(1, 4, nan) tdSql.checkData(1, 5, 0.7136182821549459) tdSql.checkData(1, 6, -0.7462904241496138) tdSql.checkData(2, 0, 48) tdSql.checkData(2, 1, -0.26237485370392877) tdSql.checkData(2, 2, 0.6202081141679935) tdSql.checkData(2, 3, 1.8175857333771335) - tdSql.checkData(2, 4, None) + tdSql.checkData(2, 4, nan) tdSql.checkData(2, 5, 1.211884234321115) tdSql.checkData(2, 6, 5.183714988550632) tdSql.checkData(3, 0, 48) tdSql.checkData(3, 1, -0.26237485370392877) tdSql.checkData(3, 2, 0.6202081141679935) tdSql.checkData(3, 3, 1.8175857333771335) - tdSql.checkData(3, 4, None) + tdSql.checkData(3, 4, nan) tdSql.checkData(3, 5, 1.211884234321115) tdSql.checkData(3, 6, 5.183714988550632) tdSql.checkData(4, 0, 47) tdSql.checkData(4, 1, -0.9537526527594719) tdSql.checkData(4, 2, 0.6593040763085178) tdSql.checkData(4, 3, 3.4575106745458637) - tdSql.checkData(4, 4, None) + tdSql.checkData(4, 4, nan) tdSql.checkData(4, 5, 0.8820838187306987) tdSql.checkData(4, 6, 2.6302204463996084) tdSql.checkData(5, 0, 47) tdSql.checkData(5, 1, -0.9537526527594719) tdSql.checkData(5, 2, 0.6593040763085178) tdSql.checkData(5, 3, 3.4575106745458637) - tdSql.checkData(5, 4, None) + tdSql.checkData(5, 4, nan) tdSql.checkData(5, 5, 0.8820838187306987) tdSql.checkData(5, 6, 2.6302204463996084) tdSql.checkData(6, 0, 46) tdSql.checkData(6, 1, -0.7682546613236668) tdSql.checkData(6, 2, 0.9998433250151273) tdSql.checkData(6, 3, 1.2763169256468458) - tdSql.checkData(6, 4, None) + tdSql.checkData(6, 4, nan) tdSql.checkData(6, 5, -0.300459258677913) tdSql.checkData(6, 6, 0.13392039926281352) tdSql.checkData(7, 0, 46) tdSql.checkData(7, 1, -0.7682546613236668) tdSql.checkData(7, 2, 0.9998433250151273) tdSql.checkData(7, 3, 1.2763169256468458) - tdSql.checkData(7, 4, None) + tdSql.checkData(7, 4, nan) tdSql.checkData(7, 5, -0.300459258677913) tdSql.checkData(7, 6, 0.13392039926281352) tdSql.checkData(8, 0, 45) tdSql.checkData(8, 1, 0.123573122745224) tdSql.checkData(8, 2, 0.6735650596658175) tdSql.checkData(8, 3, 1.5193186190030223) - tdSql.checkData(8, 4, None) + tdSql.checkData(8, 4, nan) tdSql.checkData(8, 5, -1.5661895943272113) tdSql.checkData(8, 6, 5.513771854144419) tdSql.checkData(9, 0, 45) tdSql.checkData(9, 1, 0.123573122745224) tdSql.checkData(9, 2, 0.6735650596658175) tdSql.checkData(9, 3, 1.5193186190030223) - tdSql.checkData(9, 4, None) + tdSql.checkData(9, 4, nan) tdSql.checkData(9, 5, -1.5661895943272113) tdSql.checkData(9, 6, 5.513771854144419) tdSql.checkData(10, 0, 44) tdSql.checkData(10, 1, 0.9017883476488092) tdSql.checkData(10, 2, 0.6085839480802863) tdSql.checkData(10, 3, 3.5552629892514687) - tdSql.checkData(10, 4, None) + tdSql.checkData(10, 4, nan) tdSql.checkData(10, 5, -1.9810692649977342) tdSql.checkData(10, 6, 3.0531030020123464) tdSql.checkData(11, 0, 44) tdSql.checkData(11, 1, 0.9017883476488092) tdSql.checkData(11, 2, 0.6085839480802863) tdSql.checkData(11, 3, 3.5552629892514687) - tdSql.checkData(11, 4, None) + tdSql.checkData(11, 4, nan) tdSql.checkData(11, 5, -1.9810692649977342) tdSql.checkData(11, 6, 3.0531030020123464) tdSql.checkData(12, 0, 43) tdSql.checkData(12, 1, 0.8509035245341184) tdSql.checkData(12, 2, 0.9874457808369176) tdSql.checkData(12, 3, 1.5962924548219202) - tdSql.checkData(12, 4, None) + tdSql.checkData(12, 4, nan) tdSql.checkData(12, 5, -1.2490970766755156) tdSql.checkData(12, 6, 0.5781542141407696) tdSql.checkData(13, 0, 43) tdSql.checkData(13, 1, 0.8509035245341184) tdSql.checkData(13, 2, 0.9874457808369176) tdSql.checkData(13, 3, 1.5962924548219202) - tdSql.checkData(13, 4, None) + tdSql.checkData(13, 4, nan) tdSql.checkData(13, 5, -1.2490970766755156) tdSql.checkData(13, 6, 0.5781542141407696) tdSql.checkData(14, 0, 42) tdSql.checkData(14, 1, 0.017701925105413577) tdSql.checkData(14, 2, 0.7350111780599404) tdSql.checkData(14, 3, 1.1912997639866574) - tdSql.checkData(14, 4, None) + tdSql.checkData(14, 4, nan) tdSql.checkData(14, 5, 0.036467324189017214) tdSql.checkData(14, 6, 6.024578312510778) tdSql.checkData(15, 0, 42) tdSql.checkData(15, 1, 0.017701925105413577) tdSql.checkData(15, 2, 0.7350111780599404) tdSql.checkData(15, 3, 1.1912997639866574) - tdSql.checkData(15, 4, None) + tdSql.checkData(15, 4, nan) tdSql.checkData(15, 5, 0.036467324189017214) tdSql.checkData(15, 6, 6.024578312510778) tdSql.checkData(16, 0, 41) tdSql.checkData(16, 1, -0.8317747426285983) tdSql.checkData(16, 2, 0.5704067143341829) tdSql.checkData(16, 3, 3.397430462894578) - tdSql.checkData(16, 4, None) + tdSql.checkData(16, 4, nan) tdSql.checkData(16, 5, 0.9190273051332304) tdSql.checkData(16, 6, 3.473885481113728) tdSql.checkData(17, 0, 41) tdSql.checkData(17, 1, -0.8317747426285983) tdSql.checkData(17, 2, 0.5704067143341829) tdSql.checkData(17, 3, 3.397430462894578) - tdSql.checkData(17, 4, None) + tdSql.checkData(17, 4, nan) tdSql.checkData(17, 5, 0.9190273051332304) tdSql.checkData(17, 6, 3.473885481113728) tdSql.checkData(18, 0, 40) tdSql.checkData(18, 1, -0.9165215479156338) tdSql.checkData(18, 2, 0.9564033460276342) tdSql.checkData(18, 3, 1.889162191085516) - tdSql.checkData(18, 4, None) + tdSql.checkData(18, 4, nan) tdSql.checkData(18, 5, 0.90296737936602) tdSql.checkData(18, 6, 0.888896415152729) tdSql.checkData(19, 0, 40) tdSql.checkData(19, 1, -0.9165215479156338) tdSql.checkData(19, 2, 0.9564033460276342) tdSql.checkData(19, 3, 1.889162191085516) - tdSql.checkData(19, 4, None) + tdSql.checkData(19, 4, nan) tdSql.checkData(19, 5, 0.90296737936602) tdSql.checkData(19, 6, 0.888896415152729) tdSql.checkData(20, 0, 39) tdSql.checkData(20, 1, -0.158622668804709) tdSql.checkData(20, 2, 0.7999777847134487) tdSql.checkData(20, 3, 0.8435920138756074) - tdSql.checkData(20, 4, None) + tdSql.checkData(20, 4, nan) tdSql.checkData(20, 5, 0.3319994538301167) tdSql.checkData(20, 6, 7.12853286308907) tdSql.checkData(21, 0, 39) tdSql.checkData(21, 1, -0.158622668804709) tdSql.checkData(21, 2, 0.7999777847134487) tdSql.checkData(21, 3, 0.8435920138756074) - tdSql.checkData(21, 4, None) + tdSql.checkData(21, 4, nan) tdSql.checkData(21, 5, 0.3319994538301167) tdSql.checkData(21, 6, 7.12853286308907) tdSql.checkData(22, 0, 38) tdSql.checkData(22, 1, 0.7451131604793488) tdSql.checkData(22, 2, 0.5472018255605284) tdSql.checkData(22, 3, 3.081063350979351) - tdSql.checkData(22, 4, None) + tdSql.checkData(22, 4, nan) tdSql.checkData(22, 5, -0.007381884932924798) tdSql.checkData(22, 6, 3.8764172978929814) tdSql.checkData(23, 0, 38) tdSql.checkData(23, 1, 0.7451131604793488) tdSql.checkData(23, 2, 0.5472018255605284) tdSql.checkData(23, 3, 3.081063350979351) - tdSql.checkData(23, 4, None) + tdSql.checkData(23, 4, nan) tdSql.checkData(23, 5, -0.007381884932924798) tdSql.checkData(23, 6, 3.8764172978929814) tdSql.checkData(24, 0, 37) tdSql.checkData(24, 1, 0.9637953862840878) tdSql.checkData(24, 2, 0.909721840267583) tdSql.checkData(24, 3, 2.1734252903776303) - tdSql.checkData(24, 4, None) + tdSql.checkData(24, 4, nan) tdSql.checkData(24, 5, 0.32696474077278626) tdSql.checkData(24, 6, 1.174082484128993) tdSql.checkData(25, 0, 37) tdSql.checkData(25, 1, 0.9637953862840878) tdSql.checkData(25, 2, 0.909721840267583) tdSql.checkData(25, 3, 2.1734252903776303) - tdSql.checkData(25, 4, None) + tdSql.checkData(25, 4, nan) tdSql.checkData(25, 5, 0.32696474077278626) tdSql.checkData(25, 6, 1.174082484128993) tdSql.checkData(26, 0, 36) tdSql.checkData(26, 1, 0.2963685787093853) tdSql.checkData(26, 2, 0.8632704401895588) tdSql.checkData(26, 3, 0.5493681603601657) - tdSql.checkData(26, 4, None) + tdSql.checkData(26, 4, nan) tdSql.checkData(26, 5, 0.9944678850925007) tdSql.checkData(26, 6, 11.004294268461184) tdSql.checkData(27, 0, 36) tdSql.checkData(27, 1, 0.2963685787093853) tdSql.checkData(27, 2, 0.8632704401895588) tdSql.checkData(27, 3, 0.5493681603601657) - tdSql.checkData(27, 4, None) + tdSql.checkData(27, 4, nan) tdSql.checkData(27, 5, 0.9944678850925007) tdSql.checkData(27, 6, 11.004294268461184) tdSql.checkData(28, 0, 35) tdSql.checkData(28, 1, -0.6435381333569995) tdSql.checkData(28, 2, 0.5403764709316752) tdSql.checkData(28, 3, 2.734210799811235) - tdSql.checkData(28, 4, None) + tdSql.checkData(28, 4, nan) tdSql.checkData(28, 5, 1.1930854189064375) tdSql.checkData(28, 6, 4.24770540197234) tdSql.checkData(29, 0, 35) tdSql.checkData(29, 1, -0.6435381333569995) tdSql.checkData(29, 2, 0.5403764709316752) tdSql.checkData(29, 3, 2.734210799811235) - tdSql.checkData(29, 4, None) + tdSql.checkData(29, 4, nan) tdSql.checkData(29, 5, 1.1930854189064375) tdSql.checkData(29, 6, 4.24770540197234) tdSql.checkData(30, 0, 34) tdSql.checkData(30, 1, -0.9917788534431158) tdSql.checkData(30, 2, 0.8517779466253769) tdSql.checkData(30, 3, 2.470955260231499) - tdSql.checkData(30, 4, None) + tdSql.checkData(30, 4, nan) tdSql.checkData(30, 5, 0.4428112547200472) tdSql.checkData(30, 6, 1.4785733565944832) tdSql.checkData(31, 0, 34) tdSql.checkData(31, 1, -0.9917788534431158) tdSql.checkData(31, 2, 0.8517779466253769) tdSql.checkData(31, 3, 2.470955260231499) - tdSql.checkData(31, 4, None) + tdSql.checkData(31, 4, nan) tdSql.checkData(31, 5, 0.4428112547200472) tdSql.checkData(31, 6, 1.4785733565944832) tdSql.checkData(32, 0, 33) tdSql.checkData(32, 1, -0.428182669496151) tdSql.checkData(32, 2, 0.9194811573015673) tdSql.checkData(32, 3, 0.4437992589174107) - tdSql.checkData(32, 4, None) + tdSql.checkData(32, 4, nan) tdSql.checkData(32, 5, -0.9001958571391758) tdSql.checkData(32, 6, -72.33956595410905) tdSql.checkData(33, 0, 33) tdSql.checkData(33, 1, -0.428182669496151) tdSql.checkData(33, 2, 0.9194811573015673) tdSql.checkData(33, 3, 0.4437992589174107) - tdSql.checkData(33, 4, None) + tdSql.checkData(33, 4, nan) tdSql.checkData(33, 5, -0.9001958571391758) tdSql.checkData(33, 6, -72.33956595410905) tdSql.checkData(34, 0, 32) tdSql.checkData(34, 1, 0.5290826861200238) tdSql.checkData(34, 2, 0.5503344099628432) tdSql.checkData(34, 3, 2.413227615833899) - tdSql.checkData(34, 4, None) + tdSql.checkData(34, 4, nan) tdSql.checkData(34, 5, -1.8893763681780902) tdSql.checkData(34, 6, 4.581032079680554) tdSql.checkData(35, 0, 32) tdSql.checkData(35, 1, 0.5290826861200238) tdSql.checkData(35, 2, 0.5503344099628432) tdSql.checkData(35, 3, 2.413227615833899) - tdSql.checkData(35, 4, None) + tdSql.checkData(35, 4, nan) tdSql.checkData(35, 5, -1.8893763681780902) tdSql.checkData(35, 6, 4.581032079680554) tdSql.checkData(36, 0, 31) tdSql.checkData(36, 1, 0.9999118601072672) tdSql.checkData(36, 2, 0.7877590247885756) tdSql.checkData(36, 3, 2.7979785951133604) - tdSql.checkData(36, 4, None) + tdSql.checkData(36, 4, nan) tdSql.checkData(36, 5, -1.7874722290307907) tdSql.checkData(36, 6, 1.8191237353300793) tdSql.checkData(37, 0, 31) tdSql.checkData(37, 1, 0.9999118601072672) tdSql.checkData(37, 2, 0.7877590247885756) tdSql.checkData(37, 3, 2.7979785951133604) - tdSql.checkData(37, 4, None) + tdSql.checkData(37, 4, nan) tdSql.checkData(37, 5, -1.7874722290307907) tdSql.checkData(37, 6, 1.8191237353300793) tdSql.checkData(38, 0, 30) tdSql.checkData(38, 1, 0.5514266812416906) tdSql.checkData(38, 2, 0.9635288988181601) tdSql.checkData(38, 3, 0.5944617511422015) - tdSql.checkData(38, 4, None) + tdSql.checkData(38, 4, nan) tdSql.checkData(38, 5, -0.7022004347538967) tdSql.checkData(38, 6, -3.710141817748492) tdSql.checkData(39, 0, 30) tdSql.checkData(39, 1, 0.5514266812416906) tdSql.checkData(39, 2, 0.9635288988181601) tdSql.checkData(39, 3, 0.5944617511422015) - tdSql.checkData(39, 4, None) + tdSql.checkData(39, 4, nan) tdSql.checkData(39, 5, -0.7022004347538967) tdSql.checkData(39, 6, -3.710141817748492) tdSql.checkData(40, 0, 29) tdSql.checkData(40, 1, -0.404037645323065) tdSql.checkData(40, 2, 0.5764850221962442) tdSql.checkData(40, 3, 2.1197476343754156) - tdSql.checkData(40, 4, None) + tdSql.checkData(40, 4, nan) tdSql.checkData(40, 5, 0.5162157333804713) tdSql.checkData(40, 6, 4.8800154918827525) tdSql.checkData(41, 0, 29) tdSql.checkData(41, 1, -0.404037645323065) tdSql.checkData(41, 2, 0.5764850221962442) tdSql.checkData(41, 3, 2.1197476343754156) - tdSql.checkData(41, 4, None) + tdSql.checkData(41, 4, nan) tdSql.checkData(41, 5, 0.5162157333804713) tdSql.checkData(41, 6, 4.8800154918827525) tdSql.checkData(42, 0, 28) tdSql.checkData(42, 1, -0.9880316240928618) tdSql.checkData(42, 2, 0.7230710689951642) tdSql.checkData(42, 3, 3.1457526648156393) - tdSql.checkData(42, 4, None) + tdSql.checkData(42, 4, nan) tdSql.checkData(42, 5, 1.0206076417536643) tdSql.checkData(42, 6, 2.197019393348823) tdSql.checkData(43, 0, 28) tdSql.checkData(43, 1, -0.9880316240928618) tdSql.checkData(43, 2, 0.7230710689951642) tdSql.checkData(43, 3, 3.1457526648156393) - tdSql.checkData(43, 4, None) + tdSql.checkData(43, 4, nan) tdSql.checkData(43, 5, 1.0206076417536643) tdSql.checkData(43, 6, 2.197019393348823) tdSql.checkData(44, 0, 27) tdSql.checkData(44, 1, -0.6636338842129675) tdSql.checkData(44, 2, 0.9912542848596704) tdSql.checkData(44, 3, 0.9080812682077812) - tdSql.checkData(44, 4, None) + tdSql.checkData(44, 4, nan) tdSql.checkData(44, 5, 0.6788951190016388) tdSql.checkData(44, 6, -0.8324928492797357) tdSql.checkData(45, 0, 27) tdSql.checkData(45, 1, -0.6636338842129675) tdSql.checkData(45, 2, 0.9912542848596704) tdSql.checkData(45, 3, 0.9080812682077812) - tdSql.checkData(45, 4, None) + tdSql.checkData(45, 4, nan) tdSql.checkData(45, 5, 0.6788951190016388) tdSql.checkData(45, 6, -0.8324928492797357) tdSql.checkData(46, 0, 26) tdSql.checkData(46, 1, 0.27090578830786904) tdSql.checkData(46, 2, 0.6172306382193644) tdSql.checkData(46, 3, 1.835550377607515) - tdSql.checkData(46, 4, None) + tdSql.checkData(46, 4, nan) tdSql.checkData(46, 5, 0.11431954199291106) tdSql.checkData(46, 6, 5.165381146246765) tdSql.checkData(47, 0, 26) tdSql.checkData(47, 1, 0.27090578830786904) tdSql.checkData(47, 2, 0.6172306382193644) tdSql.checkData(47, 3, 1.835550377607515) - tdSql.checkData(47, 4, None) + tdSql.checkData(47, 4, nan) tdSql.checkData(47, 5, 0.11431954199291106) tdSql.checkData(47, 6, 5.165381146246765) tdSql.checkData(48, 0, 25) tdSql.checkData(48, 1, 0.956375928404503) tdSql.checkData(48, 2, 0.6628179613691831) tdSql.checkData(48, 3, 3.4435632194258416) - tdSql.checkData(48, 4, None) + tdSql.checkData(48, 4, nan) tdSql.checkData(48, 5, 0.05676687083562715) tdSql.checkData(48, 6, 2.6040987392745354) tdSql.checkData(49, 0, 25) tdSql.checkData(49, 1, 0.956375928404503) tdSql.checkData(49, 2, 0.6628179613691831) tdSql.checkData(49, 3, 3.4435632194258416) - tdSql.checkData(49, 4, None) + tdSql.checkData(49, 4, nan) tdSql.checkData(49, 5, 0.05676687083562715) tdSql.checkData(49, 6, 2.6040987392745354) tdSql.checkData(50, 0, 24) tdSql.checkData(50, 1, 0.7625584504796027) tdSql.checkData(50, 2, 0.999960827417674) tdSql.checkData(50, 3, 1.2552318002593996) - tdSql.checkData(50, 4, None) + tdSql.checkData(50, 4, nan) tdSql.checkData(50, 5, 0.6200983185456957) tdSql.checkData(50, 6, 0.09684864095463253) tdSql.checkData(51, 0, 24) tdSql.checkData(51, 1, 0.7625584504796027) tdSql.checkData(51, 2, 0.999960827417674) tdSql.checkData(51, 3, 1.2552318002593996) - tdSql.checkData(51, 4, None) + tdSql.checkData(51, 4, nan) tdSql.checkData(51, 5, 0.6200983185456957) tdSql.checkData(51, 6, 0.09684864095463253) tdSql.checkData(52, 0, 23) tdSql.checkData(52, 1, -0.13235175009777303) tdSql.checkData(52, 2, 0.6699494442536529) tdSql.checkData(52, 3, 1.5387402975985367) - tdSql.checkData(52, 4, None) + tdSql.checkData(52, 4, nan) tdSql.checkData(52, 5, 1.1825447904081037) tdSql.checkData(52, 6, 5.489941431040083) tdSql.checkData(53, 0, 23) tdSql.checkData(53, 1, -0.13235175009777303) tdSql.checkData(53, 2, 0.6699494442536529) tdSql.checkData(53, 3, 1.5387402975985367) - tdSql.checkData(53, 4, None) + tdSql.checkData(53, 4, nan) tdSql.checkData(53, 5, 1.1825447904081037) tdSql.checkData(53, 6, 5.489941431040083) tdSql.checkData(54, 0, 22) tdSql.checkData(54, 1, -0.9055783620066239) tdSql.checkData(54, 2, 0.6114178044194122) tdSql.checkData(54, 3, 3.5568711064263105) - tdSql.checkData(54, 4, None) + tdSql.checkData(54, 4, nan) tdSql.checkData(54, 5, 0.9837833410919679) tdSql.checkData(54, 6, 3.0265535811470983) tdSql.checkData(55, 0, 22) tdSql.checkData(55, 1, -0.9055783620066239) tdSql.checkData(55, 2, 0.6114178044194122) tdSql.checkData(55, 3, 3.5568711064263105) - tdSql.checkData(55, 4, None) + tdSql.checkData(55, 4, nan) tdSql.checkData(55, 5, 0.9837833410919679) tdSql.checkData(55, 6, 3.0265535811470983) tdSql.checkData(56, 0, 21) tdSql.checkData(56, 1, -0.8462204041751706) tdSql.checkData(56, 2, 0.9887894200405688) tdSql.checkData(56, 3, 1.5772240911721418) - tdSql.checkData(56, 4, None) + tdSql.checkData(56, 4, nan) tdSql.checkData(56, 5, -0.11647857397382422) tdSql.checkData(56, 6, 0.5559799244477626) tdSql.checkData(57, 0, 21) tdSql.checkData(57, 1, -0.8462204041751706) tdSql.checkData(57, 2, 0.9887894200405688) tdSql.checkData(57, 3, 1.5772240911721418) - tdSql.checkData(57, 4, None) + tdSql.checkData(57, 4, nan) tdSql.checkData(57, 5, -0.11647857397382422) tdSql.checkData(57, 6, 0.5559799244477626) tdSql.checkData(58, 0, 20) tdSql.checkData(58, 1, -0.008851309290403876) tdSql.checkData(58, 2, 0.7310155667453407) tdSql.checkData(58, 3, 1.2127175951404974) - tdSql.checkData(58, 4, None) + tdSql.checkData(58, 4, nan) tdSql.checkData(58, 5, -1.4304290589415767) tdSql.checkData(58, 6, 5.982274104704091) tdSql.checkData(59, 0, 20) tdSql.checkData(59, 1, -0.008851309290403876) tdSql.checkData(59, 2, 0.7310155667453407) tdSql.checkData(59, 3, 1.2127175951404974) - tdSql.checkData(59, 4, None) + tdSql.checkData(59, 4, nan) tdSql.checkData(59, 5, -1.4304290589415767) tdSql.checkData(59, 6, 5.982274104704091) tdSql.checkData(60, 0, 19) tdSql.checkData(60, 1, 0.8366556385360561) tdSql.checkData(60, 2, 0.5723746128431292) tdSql.checkData(60, 3, 3.413484890511323) - tdSql.checkData(60, 4, None) + tdSql.checkData(60, 4, nan) tdSql.checkData(60, 5, -1.9952541841757747) tdSql.checkData(60, 6, 3.4479580493217856) tdSql.checkData(61, 0, 19) tdSql.checkData(61, 1, 0.8366556385360561) tdSql.checkData(61, 2, 0.5723746128431292) tdSql.checkData(61, 3, 3.413484890511323) - tdSql.checkData(61, 4, None) + tdSql.checkData(61, 4, nan) tdSql.checkData(61, 5, -1.9952541841757747) tdSql.checkData(61, 6, 3.4479580493217856) tdSql.checkData(62, 0, 18) tdSql.checkData(62, 1, 0.9129452507276277) tdSql.checkData(62, 2, 0.9588413200803038) tdSql.checkData(62, 3, 1.8713332491184997) - tdSql.checkData(62, 4, None) + tdSql.checkData(62, 4, nan) tdSql.checkData(62, 5, -1.3983047743451864) tdSql.checkData(62, 6, 0.8709074342191974) tdSql.checkData(63, 0, 18) tdSql.checkData(63, 1, 0.9129452507276277) tdSql.checkData(63, 2, 0.9588413200803038) tdSql.checkData(63, 3, 1.8713332491184997) - tdSql.checkData(63, 4, None) + tdSql.checkData(63, 4, nan) tdSql.checkData(63, 5, -1.3983047743451864) tdSql.checkData(63, 6, 0.8709074342191974) tdSql.checkData(64, 0, 17) tdSql.checkData(64, 1, 0.14987720966295234) tdSql.checkData(64, 2, 0.7959095686227995) tdSql.checkData(64, 3, 0.864944320724419) - tdSql.checkData(64, 4, None) + tdSql.checkData(64, 4, nan) tdSql.checkData(64, 5, -0.13037289959062748) tdSql.checkData(64, 6, 7.022998331594864) tdSql.checkData(65, 0, 17) tdSql.checkData(65, 1, 0.14987720966295234) tdSql.checkData(65, 2, 0.7959095686227995) tdSql.checkData(65, 3, 0.864944320724419) - tdSql.checkData(65, 4, None) + tdSql.checkData(65, 4, nan) tdSql.checkData(65, 5, -0.13037289959062748) tdSql.checkData(65, 6, 7.022998331594864) tdSql.checkData(66, 0, 16) tdSql.checkData(66, 1, -0.750987246771676) tdSql.checkData(66, 2, 0.5481819942730298) tdSql.checkData(66, 3, 3.102748784455539) - tdSql.checkData(66, 4, None) + tdSql.checkData(66, 4, nan) tdSql.checkData(66, 5, 0.8513297604701857) tdSql.checkData(66, 6, 3.852058923265594) tdSql.checkData(67, 0, 16) tdSql.checkData(67, 1, -0.750987246771676) tdSql.checkData(67, 2, 0.5481819942730298) tdSql.checkData(67, 3, 3.102748784455539) - tdSql.checkData(67, 4, None) + tdSql.checkData(67, 4, nan) tdSql.checkData(67, 5, 0.8513297604701857) tdSql.checkData(67, 6, 3.852058923265594) tdSql.checkData(68, 0, 15) tdSql.checkData(68, 1, -0.9613974918795568) tdSql.checkData(68, 2, 0.9130208165623314) tdSql.checkData(68, 3, 2.1554866011151765) - tdSql.checkData(68, 4, None) + tdSql.checkData(68, 4, nan) tdSql.checkData(68, 5, 0.9521751875546269) tdSql.checkData(68, 6, 1.1559749749986195) tdSql.checkData(69, 0, 15) tdSql.checkData(69, 1, -0.9613974918795568) tdSql.checkData(69, 2, 0.9130208165623314) tdSql.checkData(69, 3, 2.1554866011151765) - tdSql.checkData(69, 4, None) + tdSql.checkData(69, 4, nan) tdSql.checkData(69, 5, 0.9521751875546269) tdSql.checkData(69, 6, 1.1559749749986195) tdSql.checkData(70, 0, 14) tdSql.checkData(70, 1, -0.2879033166650653) tdSql.checkData(70, 2, 0.859465627274523) tdSql.checkData(70, 3, 0.5636905248139659) - tdSql.checkData(70, 4, None) + tdSql.checkData(70, 4, nan) tdSql.checkData(70, 5, 0.41142163587369207) tdSql.checkData(70, 6, 10.515512404402676) tdSql.checkData(71, 0, 14) tdSql.checkData(71, 1, -0.2879033166650653) tdSql.checkData(71, 2, 0.859465627274523) tdSql.checkData(71, 3, 0.5636905248139659) - tdSql.checkData(71, 4, None) + tdSql.checkData(71, 4, nan) tdSql.checkData(71, 5, 0.41142163587369207) tdSql.checkData(71, 6, 10.515512404402676) tdSql.checkData(72, 0, 13) tdSql.checkData(72, 1, 0.6502878401571168) tdSql.checkData(72, 2, 0.5403105467456532) tdSql.checkData(72, 3, 2.75535470715349) - tdSql.checkData(72, 4, None) + tdSql.checkData(72, 4, nan) tdSql.checkData(72, 5, 0.0009616202598659029) tdSql.checkData(72, 6, 4.225579583416092) tdSql.checkData(73, 0, 13) tdSql.checkData(73, 1, 0.6502878401571168) tdSql.checkData(73, 2, 0.5403105467456532) tdSql.checkData(73, 3, 2.75535470715349) - tdSql.checkData(73, 4, None) + tdSql.checkData(73, 4, nan) tdSql.checkData(73, 5, 0.0009616202598659029) tdSql.checkData(73, 6, 4.225579583416092) tdSql.checkData(74, 0, 12) tdSql.checkData(74, 1, 0.9906073556948704) tdSql.checkData(74, 2, 0.8556343548213666) tdSql.checkData(74, 3, 2.451594361777497) - tdSql.checkData(74, 4, None) + tdSql.checkData(74, 4, nan) tdSql.checkData(74, 5, 0.24838494428124291) tdSql.checkData(74, 6, 1.4585617093317953) tdSql.checkData(75, 0, 12) tdSql.checkData(75, 1, 0.9906073556948704) tdSql.checkData(75, 2, 0.8556343548213666) tdSql.checkData(75, 3, 2.451594361777497) - tdSql.checkData(75, 4, None) + tdSql.checkData(75, 4, nan) tdSql.checkData(75, 5, 0.24838494428124291) tdSql.checkData(75, 6, 1.4585617093317953) tdSql.checkData(76, 0, 11) tdSql.checkData(76, 1, 0.4201670368266409) tdSql.checkData(76, 2, 0.9162743174606308) tdSql.checkData(76, 3, 0.44272645708128566) - tdSql.checkData(76, 4, None) + tdSql.checkData(76, 4, nan) tdSql.checkData(76, 5, 0.9151372562290566) tdSql.checkData(76, 6, -222.95969776348554) tdSql.checkData(77, 0, 11) tdSql.checkData(77, 1, 0.4201670368266409) tdSql.checkData(77, 2, 0.9162743174606308) tdSql.checkData(77, 3, 0.44272645708128566) - tdSql.checkData(77, 4, None) + tdSql.checkData(77, 4, nan) tdSql.checkData(77, 5, 0.9151372562290566) tdSql.checkData(77, 6, -222.95969776348554) tdSql.checkData(78, 0, 10) tdSql.checkData(78, 1, -0.5365729180004349) tdSql.checkData(78, 2, 0.549226270051226) tdSql.checkData(78, 3, 2.432352856101439) - tdSql.checkData(78, 4, None) + tdSql.checkData(78, 4, nan) tdSql.checkData(78, 5, 1.2185572409879093) tdSql.checkData(78, 6, 4.561306078186714) tdSql.checkData(79, 0, 10) tdSql.checkData(79, 1, -0.5365729180004349) tdSql.checkData(79, 2, 0.549226270051226) tdSql.checkData(79, 3, 2.432352856101439) - tdSql.checkData(79, 4, None) + tdSql.checkData(79, 4, nan) tdSql.checkData(79, 5, 1.2185572409879093) tdSql.checkData(79, 6, 4.561306078186714) tdSql.checkData(80, 0, 9) tdSql.checkData(80, 1, -0.9999902065507035) tdSql.checkData(80, 2, 0.7918362090144786) tdSql.checkData(80, 3, 2.776612511546888) - tdSql.checkData(80, 4, None) + tdSql.checkData(80, 4, nan) tdSql.checkData(80, 5, 0.5929886271208413) tdSql.checkData(80, 6, 1.796697093786514) tdSql.checkData(81, 0, 9) tdSql.checkData(81, 1, -0.9999902065507035) tdSql.checkData(81, 2, 0.7918362090144786) tdSql.checkData(81, 3, 2.776612511546888) - tdSql.checkData(81, 4, None) + tdSql.checkData(81, 4, nan) tdSql.checkData(81, 5, 0.5929886271208413) tdSql.checkData(81, 6, 1.796697093786514) tdSql.checkData(82, 0, 8) tdSql.checkData(82, 1, -0.5440211108893698) tdSql.checkData(82, 2, 0.9612168045072789) tdSql.checkData(82, 3, 0.5787344727995947) - tdSql.checkData(82, 4, None) + tdSql.checkData(82, 4, nan) tdSql.checkData(82, 5, -0.7199655182148126) tdSql.checkData(82, 6, -4.087614771885445) tdSql.checkData(83, 0, 8) tdSql.checkData(83, 1, -0.5440211108893698) tdSql.checkData(83, 2, 0.9612168045072789) tdSql.checkData(83, 3, 0.5787344727995947) - tdSql.checkData(83, 4, None) + tdSql.checkData(83, 4, nan) tdSql.checkData(83, 5, -0.7199655182148126) tdSql.checkData(83, 6, -4.087614771885445) tdSql.checkData(84, 0, 7) tdSql.checkData(84, 1, 0.4121184852417566) tdSql.checkData(84, 2, 0.574400879193934) tdSql.checkData(84, 3, 2.137595835197328) - tdSql.checkData(84, 4, None) + tdSql.checkData(84, 4, nan) tdSql.checkData(84, 5, -1.8119088619792247) tdSql.checkData(84, 6, 4.862055338419189) tdSql.checkData(85, 0, 7) tdSql.checkData(85, 1, 0.4121184852417566) tdSql.checkData(85, 2, 0.574400879193934) tdSql.checkData(85, 3, 2.137595835197328) - tdSql.checkData(85, 4, None) + tdSql.checkData(85, 4, nan) tdSql.checkData(85, 5, -1.8119088619792247) tdSql.checkData(85, 6, 4.862055338419189) tdSql.checkData(86, 0, 6) tdSql.checkData(86, 1, 0.9893582466233818) tdSql.checkData(86, 2, 0.7270351311688125) tdSql.checkData(86, 3, 3.1243204798042576) - tdSql.checkData(86, 4, None) + tdSql.checkData(86, 4, nan) tdSql.checkData(86, 5, -1.8696882565721156) tdSql.checkData(86, 6, 2.172420890614816) tdSql.checkData(87, 0, 6) tdSql.checkData(87, 1, 0.9893582466233818) tdSql.checkData(87, 2, 0.7270351311688125) tdSql.checkData(87, 3, 3.1243204798042576) - tdSql.checkData(87, 4, None) + tdSql.checkData(87, 4, nan) tdSql.checkData(87, 5, -1.8696882565721156) tdSql.checkData(87, 6, 2.172420890614816) tdSql.checkData(88, 0, 5) tdSql.checkData(88, 1, 0.6569865987187891) tdSql.checkData(88, 2, 0.9900590857598653) tdSql.checkData(88, 3, 0.8864495743441427) - tdSql.checkData(88, 4, None) + tdSql.checkData(88, 4, nan) tdSql.checkData(88, 5, -0.876294736008743) tdSql.checkData(88, 6, -0.9245361171359558) tdSql.checkData(89, 0, 5) tdSql.checkData(89, 1, 0.6569865987187891) tdSql.checkData(89, 2, 0.9900590857598653) tdSql.checkData(89, 3, 0.8864495743441427) - tdSql.checkData(89, 4, None) + tdSql.checkData(89, 4, nan) tdSql.checkData(89, 5, -0.876294736008743) tdSql.checkData(89, 6, -0.9245361171359558) tdSql.checkData(90, 0, 4) tdSql.checkData(90, 1, -0.27941549819892586) tdSql.checkData(90, 2, 0.6143002821164822) tdSql.checkData(90, 3, 1.853464438509776) - tdSql.checkData(90, 4, None) + tdSql.checkData(90, 4, nan) tdSql.checkData(90, 5, 0.38234027607634785) tdSql.checkData(90, 6, 5.147179528972959) tdSql.checkData(91, 0, 4) tdSql.checkData(91, 1, -0.27941549819892586) tdSql.checkData(91, 2, 0.6143002821164822) tdSql.checkData(91, 3, 1.853464438509776) - tdSql.checkData(91, 4, None) + tdSql.checkData(91, 4, nan) tdSql.checkData(91, 5, 0.38234027607634785) tdSql.checkData(91, 6, 5.147179528972959) tdSql.checkData(92, 0, 3) tdSql.checkData(92, 1, -0.9589242746631385) tdSql.checkData(92, 2, 0.6663667453928805) tdSql.checkData(92, 3, 3.4288753232277074) - tdSql.checkData(92, 4, None) + tdSql.checkData(92, 4, nan) tdSql.checkData(92, 5, 1.0087371784424417) tdSql.checkData(92, 6, 2.5780379587267963) tdSql.checkData(93, 0, 3) tdSql.checkData(93, 1, -0.9589242746631385) tdSql.checkData(93, 2, 0.6663667453928805) tdSql.checkData(93, 3, 3.4288753232277074) - tdSql.checkData(93, 4, None) + tdSql.checkData(93, 4, nan) tdSql.checkData(93, 5, 1.0087371784424417) tdSql.checkData(93, 6, 2.5780379587267963) tdSql.checkData(94, 0, 2) tdSql.checkData(94, 1, -0.7568024953079282) tdSql.checkData(94, 2, 1.0) tdSql.checkData(94, 3, 1.2340302976078754) - tdSql.checkData(94, 4, None) + tdSql.checkData(94, 4, nan) tdSql.checkData(94, 5, 0.7554222939559553) tdSql.checkData(94, 6, 0.05815764143055291) tdSql.checkData(95, 0, 2) tdSql.checkData(95, 1, -0.7568024953079282) tdSql.checkData(95, 2, 1.0) tdSql.checkData(95, 3, 1.2340302976078754) - tdSql.checkData(95, 4, None) + tdSql.checkData(95, 4, nan) tdSql.checkData(95, 5, 0.7554222939559553) tdSql.checkData(95, 6, 0.05815764143055291) tdSql.checkData(96, 0, 1) @@ -2576,773 +2608,781 @@ class TDTestCase: tdSql.checkData(96, 3, 1.558041126155035) tdSql.checkData(96, 4, 1.8325957145940461) tdSql.checkData(96, 5, 0.17204223631998083) - tdSql.checkData(96, 6, None) + tdSql.checkData(96, 6, nan) tdSql.checkData(97, 0, 1) tdSql.checkData(97, 1, 0.1411200080598672) tdSql.checkData(97, 2, 0.6663667453928805) tdSql.checkData(97, 3, 1.558041126155035) tdSql.checkData(97, 4, 1.8325957145940461) tdSql.checkData(97, 5, 0.17204223631998083) - tdSql.checkData(97, 6, None) + tdSql.checkData(97, 6, nan) tdSql.checkData(98, 0, 0) tdSql.checkData(98, 1, 0.7780731968879212) tdSql.checkData(98, 2, 0.6143002821164822) tdSql.checkData(98, 3, 3.2037266279837113) - tdSql.checkData(98, 4, None) + tdSql.checkData(98, 4, nan) tdSql.checkData(98, 5, 0.02246988233490299) - tdSql.checkData(98, 6, None) + tdSql.checkData(98, 6, nan) tdSql.checkData(99, 0, 0) tdSql.checkData(99, 1, 0.7780731968879212) tdSql.checkData(99, 2, 0.6143002821164822) tdSql.checkData(99, 3, 3.2037266279837113) - tdSql.checkData(99, 4, None) + tdSql.checkData(99, 4, nan) tdSql.checkData(99, 5, 0.02246988233490299) - tdSql.checkData(99, 6, None) + tdSql.checkData(99, 6, nan) - tdSql.query('select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 );') + tdSql.query( + "select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from st0 );" + ) tdSql.checkRows(100) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 0.7780731968879212) tdSql.checkData(0, 2, 0.6143002821164822) tdSql.checkData(0, 3, 3.2037266279837113) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.02246988233490299) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) tdSql.checkData(1, 0, 1) tdSql.checkData(1, 1, 0.1411200080598672) tdSql.checkData(1, 2, 0.6663667453928805) tdSql.checkData(1, 3, 1.558041126155035) tdSql.checkData(1, 4, 1.8325957145940461) tdSql.checkData(1, 5, 0.17204223631998083) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 6, nan) tdSql.checkData(2, 0, 2) tdSql.checkData(2, 1, -0.7568024953079282) tdSql.checkData(2, 2, 1.0) tdSql.checkData(2, 3, 1.2340302976078754) - tdSql.checkData(2, 4, None) + tdSql.checkData(2, 4, nan) tdSql.checkData(2, 5, 0.7554222939559553) tdSql.checkData(2, 6, 0.05815764143055291) tdSql.checkData(3, 0, 3) tdSql.checkData(3, 1, -0.9589242746631385) tdSql.checkData(3, 2, 0.6663667453928805) tdSql.checkData(3, 3, 3.4288753232277074) - tdSql.checkData(3, 4, None) + tdSql.checkData(3, 4, nan) tdSql.checkData(3, 5, 1.0087371784424417) tdSql.checkData(3, 6, 2.5780379587267963) tdSql.checkData(4, 0, 4) tdSql.checkData(4, 1, -0.27941549819892586) tdSql.checkData(4, 2, 0.6143002821164822) tdSql.checkData(4, 3, 1.853464438509776) - tdSql.checkData(4, 4, None) + tdSql.checkData(4, 4, nan) tdSql.checkData(4, 5, 0.38234027607634785) tdSql.checkData(4, 6, 5.147179528972959) tdSql.checkData(5, 0, 5) tdSql.checkData(5, 1, 0.6569865987187891) tdSql.checkData(5, 2, 0.9900590857598653) tdSql.checkData(5, 3, 0.8864495743441427) - tdSql.checkData(5, 4, None) + tdSql.checkData(5, 4, nan) tdSql.checkData(5, 5, -0.876294736008743) tdSql.checkData(5, 6, -0.9245361171359558) tdSql.checkData(6, 0, 6) tdSql.checkData(6, 1, 0.9893582466233818) tdSql.checkData(6, 2, 0.7270351311688125) tdSql.checkData(6, 3, 3.1243204798042576) - tdSql.checkData(6, 4, None) + tdSql.checkData(6, 4, nan) tdSql.checkData(6, 5, -1.8696882565721156) tdSql.checkData(6, 6, 2.172420890614816) tdSql.checkData(7, 0, 7) tdSql.checkData(7, 1, 0.4121184852417566) tdSql.checkData(7, 2, 0.574400879193934) tdSql.checkData(7, 3, 2.137595835197328) - tdSql.checkData(7, 4, None) + tdSql.checkData(7, 4, nan) tdSql.checkData(7, 5, -1.8119088619792247) tdSql.checkData(7, 6, 4.862055338419189) tdSql.checkData(8, 0, 8) tdSql.checkData(8, 1, -0.5440211108893698) tdSql.checkData(8, 2, 0.9612168045072789) tdSql.checkData(8, 3, 0.5787344727995947) - tdSql.checkData(8, 4, None) + tdSql.checkData(8, 4, nan) tdSql.checkData(8, 5, -0.7199655182148126) tdSql.checkData(8, 6, -4.087614771885445) tdSql.checkData(9, 0, 9) tdSql.checkData(9, 1, -0.9999902065507035) tdSql.checkData(9, 2, 0.7918362090144786) tdSql.checkData(9, 3, 2.776612511546888) - tdSql.checkData(9, 4, None) + tdSql.checkData(9, 4, nan) tdSql.checkData(9, 5, 0.5929886271208413) tdSql.checkData(9, 6, 1.796697093786514) tdSql.checkData(10, 0, 10) tdSql.checkData(10, 1, -0.5365729180004349) tdSql.checkData(10, 2, 0.549226270051226) tdSql.checkData(10, 3, 2.432352856101439) - tdSql.checkData(10, 4, None) + tdSql.checkData(10, 4, nan) tdSql.checkData(10, 5, 1.2185572409879093) tdSql.checkData(10, 6, 4.561306078186714) tdSql.checkData(11, 0, 11) tdSql.checkData(11, 1, 0.4201670368266409) tdSql.checkData(11, 2, 0.9162743174606308) tdSql.checkData(11, 3, 0.44272645708128566) - tdSql.checkData(11, 4, None) + tdSql.checkData(11, 4, nan) tdSql.checkData(11, 5, 0.9151372562290566) tdSql.checkData(11, 6, -222.95969776348554) tdSql.checkData(12, 0, 12) tdSql.checkData(12, 1, 0.9906073556948704) tdSql.checkData(12, 2, 0.8556343548213666) tdSql.checkData(12, 3, 2.451594361777497) - tdSql.checkData(12, 4, None) + tdSql.checkData(12, 4, nan) tdSql.checkData(12, 5, 0.24838494428124291) tdSql.checkData(12, 6, 1.4585617093317953) tdSql.checkData(13, 0, 13) tdSql.checkData(13, 1, 0.6502878401571168) tdSql.checkData(13, 2, 0.5403105467456532) tdSql.checkData(13, 3, 2.75535470715349) - tdSql.checkData(13, 4, None) + tdSql.checkData(13, 4, nan) tdSql.checkData(13, 5, 0.0009616202598659029) tdSql.checkData(13, 6, 4.225579583416092) tdSql.checkData(14, 0, 14) tdSql.checkData(14, 1, -0.2879033166650653) tdSql.checkData(14, 2, 0.859465627274523) tdSql.checkData(14, 3, 0.5636905248139659) - tdSql.checkData(14, 4, None) + tdSql.checkData(14, 4, nan) tdSql.checkData(14, 5, 0.41142163587369207) tdSql.checkData(14, 6, 10.515512404402676) tdSql.checkData(15, 0, 15) tdSql.checkData(15, 1, -0.9613974918795568) tdSql.checkData(15, 2, 0.9130208165623314) tdSql.checkData(15, 3, 2.1554866011151765) - tdSql.checkData(15, 4, None) + tdSql.checkData(15, 4, nan) tdSql.checkData(15, 5, 0.9521751875546269) tdSql.checkData(15, 6, 1.1559749749986195) tdSql.checkData(16, 0, 16) tdSql.checkData(16, 1, -0.750987246771676) tdSql.checkData(16, 2, 0.5481819942730298) tdSql.checkData(16, 3, 3.102748784455539) - tdSql.checkData(16, 4, None) + tdSql.checkData(16, 4, nan) tdSql.checkData(16, 5, 0.8513297604701857) tdSql.checkData(16, 6, 3.852058923265594) tdSql.checkData(17, 0, 17) tdSql.checkData(17, 1, 0.14987720966295234) tdSql.checkData(17, 2, 0.7959095686227995) tdSql.checkData(17, 3, 0.864944320724419) - tdSql.checkData(17, 4, None) + tdSql.checkData(17, 4, nan) tdSql.checkData(17, 5, -0.13037289959062748) tdSql.checkData(17, 6, 7.022998331594864) tdSql.checkData(18, 0, 18) tdSql.checkData(18, 1, 0.9129452507276277) tdSql.checkData(18, 2, 0.9588413200803038) tdSql.checkData(18, 3, 1.8713332491184997) - tdSql.checkData(18, 4, None) + tdSql.checkData(18, 4, nan) tdSql.checkData(18, 5, -1.3983047743451864) tdSql.checkData(18, 6, 0.8709074342191974) tdSql.checkData(19, 0, 19) tdSql.checkData(19, 1, 0.8366556385360561) tdSql.checkData(19, 2, 0.5723746128431292) tdSql.checkData(19, 3, 3.413484890511323) - tdSql.checkData(19, 4, None) + tdSql.checkData(19, 4, nan) tdSql.checkData(19, 5, -1.9952541841757747) tdSql.checkData(19, 6, 3.4479580493217856) tdSql.checkData(20, 0, 20) tdSql.checkData(20, 1, -0.008851309290403876) tdSql.checkData(20, 2, 0.7310155667453407) tdSql.checkData(20, 3, 1.2127175951404974) - tdSql.checkData(20, 4, None) + tdSql.checkData(20, 4, nan) tdSql.checkData(20, 5, -1.4304290589415767) tdSql.checkData(20, 6, 5.982274104704091) tdSql.checkData(21, 0, 21) tdSql.checkData(21, 1, -0.8462204041751706) tdSql.checkData(21, 2, 0.9887894200405688) tdSql.checkData(21, 3, 1.5772240911721418) - tdSql.checkData(21, 4, None) + tdSql.checkData(21, 4, nan) tdSql.checkData(21, 5, -0.11647857397382422) tdSql.checkData(21, 6, 0.5559799244477626) tdSql.checkData(22, 0, 22) tdSql.checkData(22, 1, -0.9055783620066239) tdSql.checkData(22, 2, 0.6114178044194122) tdSql.checkData(22, 3, 3.5568711064263105) - tdSql.checkData(22, 4, None) + tdSql.checkData(22, 4, nan) tdSql.checkData(22, 5, 0.9837833410919679) tdSql.checkData(22, 6, 3.0265535811470983) tdSql.checkData(23, 0, 23) tdSql.checkData(23, 1, -0.13235175009777303) tdSql.checkData(23, 2, 0.6699494442536529) tdSql.checkData(23, 3, 1.5387402975985367) - tdSql.checkData(23, 4, None) + tdSql.checkData(23, 4, nan) tdSql.checkData(23, 5, 1.1825447904081037) tdSql.checkData(23, 6, 5.489941431040083) tdSql.checkData(24, 0, 24) tdSql.checkData(24, 1, 0.7625584504796027) tdSql.checkData(24, 2, 0.999960827417674) tdSql.checkData(24, 3, 1.2552318002593996) - tdSql.checkData(24, 4, None) + tdSql.checkData(24, 4, nan) tdSql.checkData(24, 5, 0.6200983185456957) tdSql.checkData(24, 6, 0.09684864095463253) tdSql.checkData(25, 0, 25) tdSql.checkData(25, 1, 0.956375928404503) tdSql.checkData(25, 2, 0.6628179613691831) tdSql.checkData(25, 3, 3.4435632194258416) - tdSql.checkData(25, 4, None) + tdSql.checkData(25, 4, nan) tdSql.checkData(25, 5, 0.05676687083562715) tdSql.checkData(25, 6, 2.6040987392745354) tdSql.checkData(26, 0, 26) tdSql.checkData(26, 1, 0.27090578830786904) tdSql.checkData(26, 2, 0.6172306382193644) tdSql.checkData(26, 3, 1.835550377607515) - tdSql.checkData(26, 4, None) + tdSql.checkData(26, 4, nan) tdSql.checkData(26, 5, 0.11431954199291106) tdSql.checkData(26, 6, 5.165381146246765) tdSql.checkData(27, 0, 27) tdSql.checkData(27, 1, -0.6636338842129675) tdSql.checkData(27, 2, 0.9912542848596704) tdSql.checkData(27, 3, 0.9080812682077812) - tdSql.checkData(27, 4, None) + tdSql.checkData(27, 4, nan) tdSql.checkData(27, 5, 0.6788951190016388) tdSql.checkData(27, 6, -0.8324928492797357) tdSql.checkData(28, 0, 28) tdSql.checkData(28, 1, -0.9880316240928618) tdSql.checkData(28, 2, 0.7230710689951642) tdSql.checkData(28, 3, 3.1457526648156393) - tdSql.checkData(28, 4, None) + tdSql.checkData(28, 4, nan) tdSql.checkData(28, 5, 1.0206076417536643) tdSql.checkData(28, 6, 2.197019393348823) tdSql.checkData(29, 0, 29) tdSql.checkData(29, 1, -0.404037645323065) tdSql.checkData(29, 2, 0.5764850221962442) tdSql.checkData(29, 3, 2.1197476343754156) - tdSql.checkData(29, 4, None) + tdSql.checkData(29, 4, nan) tdSql.checkData(29, 5, 0.5162157333804713) tdSql.checkData(29, 6, 4.8800154918827525) tdSql.checkData(30, 0, 30) tdSql.checkData(30, 1, 0.5514266812416906) tdSql.checkData(30, 2, 0.9635288988181601) tdSql.checkData(30, 3, 0.5944617511422015) - tdSql.checkData(30, 4, None) + tdSql.checkData(30, 4, nan) tdSql.checkData(30, 5, -0.7022004347538967) tdSql.checkData(30, 6, -3.710141817748492) tdSql.checkData(31, 0, 31) tdSql.checkData(31, 1, 0.9999118601072672) tdSql.checkData(31, 2, 0.7877590247885756) tdSql.checkData(31, 3, 2.7979785951133604) - tdSql.checkData(31, 4, None) + tdSql.checkData(31, 4, nan) tdSql.checkData(31, 5, -1.7874722290307907) tdSql.checkData(31, 6, 1.8191237353300793) tdSql.checkData(32, 0, 32) tdSql.checkData(32, 1, 0.5290826861200238) tdSql.checkData(32, 2, 0.5503344099628432) tdSql.checkData(32, 3, 2.413227615833899) - tdSql.checkData(32, 4, None) + tdSql.checkData(32, 4, nan) tdSql.checkData(32, 5, -1.8893763681780902) tdSql.checkData(32, 6, 4.581032079680554) tdSql.checkData(33, 0, 33) tdSql.checkData(33, 1, -0.428182669496151) tdSql.checkData(33, 2, 0.9194811573015673) tdSql.checkData(33, 3, 0.4437992589174107) - tdSql.checkData(33, 4, None) + tdSql.checkData(33, 4, nan) tdSql.checkData(33, 5, -0.9001958571391758) tdSql.checkData(33, 6, -72.33956595410905) tdSql.checkData(34, 0, 34) tdSql.checkData(34, 1, -0.9917788534431158) tdSql.checkData(34, 2, 0.8517779466253769) tdSql.checkData(34, 3, 2.470955260231499) - tdSql.checkData(34, 4, None) + tdSql.checkData(34, 4, nan) tdSql.checkData(34, 5, 0.4428112547200472) tdSql.checkData(34, 6, 1.4785733565944832) tdSql.checkData(35, 0, 35) tdSql.checkData(35, 1, -0.6435381333569995) tdSql.checkData(35, 2, 0.5403764709316752) tdSql.checkData(35, 3, 2.734210799811235) - tdSql.checkData(35, 4, None) + tdSql.checkData(35, 4, nan) tdSql.checkData(35, 5, 1.1930854189064375) tdSql.checkData(35, 6, 4.24770540197234) tdSql.checkData(36, 0, 36) tdSql.checkData(36, 1, 0.2963685787093853) tdSql.checkData(36, 2, 0.8632704401895588) tdSql.checkData(36, 3, 0.5493681603601657) - tdSql.checkData(36, 4, None) + tdSql.checkData(36, 4, nan) tdSql.checkData(36, 5, 0.9944678850925007) tdSql.checkData(36, 6, 11.004294268461184) tdSql.checkData(37, 0, 37) tdSql.checkData(37, 1, 0.9637953862840878) tdSql.checkData(37, 2, 0.909721840267583) tdSql.checkData(37, 3, 2.1734252903776303) - tdSql.checkData(37, 4, None) + tdSql.checkData(37, 4, nan) tdSql.checkData(37, 5, 0.32696474077278626) tdSql.checkData(37, 6, 1.174082484128993) tdSql.checkData(38, 0, 38) tdSql.checkData(38, 1, 0.7451131604793488) tdSql.checkData(38, 2, 0.5472018255605284) tdSql.checkData(38, 3, 3.081063350979351) - tdSql.checkData(38, 4, None) + tdSql.checkData(38, 4, nan) tdSql.checkData(38, 5, -0.007381884932924798) tdSql.checkData(38, 6, 3.8764172978929814) tdSql.checkData(39, 0, 39) tdSql.checkData(39, 1, -0.158622668804709) tdSql.checkData(39, 2, 0.7999777847134487) tdSql.checkData(39, 3, 0.8435920138756074) - tdSql.checkData(39, 4, None) + tdSql.checkData(39, 4, nan) tdSql.checkData(39, 5, 0.3319994538301167) tdSql.checkData(39, 6, 7.12853286308907) tdSql.checkData(40, 0, 40) tdSql.checkData(40, 1, -0.9165215479156338) tdSql.checkData(40, 2, 0.9564033460276342) tdSql.checkData(40, 3, 1.889162191085516) - tdSql.checkData(40, 4, None) + tdSql.checkData(40, 4, nan) tdSql.checkData(40, 5, 0.90296737936602) tdSql.checkData(40, 6, 0.888896415152729) tdSql.checkData(41, 0, 41) tdSql.checkData(41, 1, -0.8317747426285983) tdSql.checkData(41, 2, 0.5704067143341829) tdSql.checkData(41, 3, 3.397430462894578) - tdSql.checkData(41, 4, None) + tdSql.checkData(41, 4, nan) tdSql.checkData(41, 5, 0.9190273051332304) tdSql.checkData(41, 6, 3.473885481113728) tdSql.checkData(42, 0, 42) tdSql.checkData(42, 1, 0.017701925105413577) tdSql.checkData(42, 2, 0.7350111780599404) tdSql.checkData(42, 3, 1.1912997639866574) - tdSql.checkData(42, 4, None) + tdSql.checkData(42, 4, nan) tdSql.checkData(42, 5, 0.036467324189017214) tdSql.checkData(42, 6, 6.024578312510778) tdSql.checkData(43, 0, 43) tdSql.checkData(43, 1, 0.8509035245341184) tdSql.checkData(43, 2, 0.9874457808369176) tdSql.checkData(43, 3, 1.5962924548219202) - tdSql.checkData(43, 4, None) + tdSql.checkData(43, 4, nan) tdSql.checkData(43, 5, -1.2490970766755156) tdSql.checkData(43, 6, 0.5781542141407696) tdSql.checkData(44, 0, 44) tdSql.checkData(44, 1, 0.9017883476488092) tdSql.checkData(44, 2, 0.6085839480802863) tdSql.checkData(44, 3, 3.5552629892514687) - tdSql.checkData(44, 4, None) + tdSql.checkData(44, 4, nan) tdSql.checkData(44, 5, -1.9810692649977342) tdSql.checkData(44, 6, 3.0531030020123464) tdSql.checkData(45, 0, 45) tdSql.checkData(45, 1, 0.123573122745224) tdSql.checkData(45, 2, 0.6735650596658175) tdSql.checkData(45, 3, 1.5193186190030223) - tdSql.checkData(45, 4, None) + tdSql.checkData(45, 4, nan) tdSql.checkData(45, 5, -1.5661895943272113) tdSql.checkData(45, 6, 5.513771854144419) tdSql.checkData(46, 0, 46) tdSql.checkData(46, 1, -0.7682546613236668) tdSql.checkData(46, 2, 0.9998433250151273) tdSql.checkData(46, 3, 1.2763169256468458) - tdSql.checkData(46, 4, None) + tdSql.checkData(46, 4, nan) tdSql.checkData(46, 5, -0.300459258677913) tdSql.checkData(46, 6, 0.13392039926281352) tdSql.checkData(47, 0, 47) tdSql.checkData(47, 1, -0.9537526527594719) tdSql.checkData(47, 2, 0.6593040763085178) tdSql.checkData(47, 3, 3.4575106745458637) - tdSql.checkData(47, 4, None) + tdSql.checkData(47, 4, nan) tdSql.checkData(47, 5, 0.8820838187306987) tdSql.checkData(47, 6, 2.6302204463996084) tdSql.checkData(48, 0, 48) tdSql.checkData(48, 1, -0.26237485370392877) tdSql.checkData(48, 2, 0.6202081141679935) tdSql.checkData(48, 3, 1.8175857333771335) - tdSql.checkData(48, 4, None) + tdSql.checkData(48, 4, nan) tdSql.checkData(48, 5, 1.211884234321115) tdSql.checkData(48, 6, 5.183714988550632) tdSql.checkData(49, 0, 49) tdSql.checkData(49, 1, 0.6702291758433747) tdSql.checkData(49, 2, 0.9923745526637894) tdSql.checkData(49, 3, 0.9298143670243166) - tdSql.checkData(49, 4, None) + tdSql.checkData(49, 4, nan) tdSql.checkData(49, 5, 0.7136182821549459) tdSql.checkData(49, 6, -0.7462904241496138) tdSql.checkData(50, 0, 0) tdSql.checkData(50, 1, 0.7780731968879212) tdSql.checkData(50, 2, 0.6143002821164822) tdSql.checkData(50, 3, 3.2037266279837113) - tdSql.checkData(50, 4, None) + tdSql.checkData(50, 4, nan) tdSql.checkData(50, 5, 0.02246988233490299) - tdSql.checkData(50, 6, None) + tdSql.checkData(50, 6, nan) tdSql.checkData(51, 0, 1) tdSql.checkData(51, 1, 0.1411200080598672) tdSql.checkData(51, 2, 0.6663667453928805) tdSql.checkData(51, 3, 1.558041126155035) tdSql.checkData(51, 4, 1.8325957145940461) tdSql.checkData(51, 5, 0.17204223631998083) - tdSql.checkData(51, 6, None) + tdSql.checkData(51, 6, nan) tdSql.checkData(52, 0, 2) tdSql.checkData(52, 1, -0.7568024953079282) tdSql.checkData(52, 2, 1.0) tdSql.checkData(52, 3, 1.2340302976078754) - tdSql.checkData(52, 4, None) + tdSql.checkData(52, 4, nan) tdSql.checkData(52, 5, 0.7554222939559553) tdSql.checkData(52, 6, 0.05815764143055291) tdSql.checkData(53, 0, 3) tdSql.checkData(53, 1, -0.9589242746631385) tdSql.checkData(53, 2, 0.6663667453928805) tdSql.checkData(53, 3, 3.4288753232277074) - tdSql.checkData(53, 4, None) + tdSql.checkData(53, 4, nan) tdSql.checkData(53, 5, 1.0087371784424417) tdSql.checkData(53, 6, 2.5780379587267963) tdSql.checkData(54, 0, 4) tdSql.checkData(54, 1, -0.27941549819892586) tdSql.checkData(54, 2, 0.6143002821164822) tdSql.checkData(54, 3, 1.853464438509776) - tdSql.checkData(54, 4, None) + tdSql.checkData(54, 4, nan) tdSql.checkData(54, 5, 0.38234027607634785) tdSql.checkData(54, 6, 5.147179528972959) tdSql.checkData(55, 0, 5) tdSql.checkData(55, 1, 0.6569865987187891) tdSql.checkData(55, 2, 0.9900590857598653) tdSql.checkData(55, 3, 0.8864495743441427) - tdSql.checkData(55, 4, None) + tdSql.checkData(55, 4, nan) tdSql.checkData(55, 5, -0.876294736008743) tdSql.checkData(55, 6, -0.9245361171359558) tdSql.checkData(56, 0, 6) tdSql.checkData(56, 1, 0.9893582466233818) tdSql.checkData(56, 2, 0.7270351311688125) tdSql.checkData(56, 3, 3.1243204798042576) - tdSql.checkData(56, 4, None) + tdSql.checkData(56, 4, nan) tdSql.checkData(56, 5, -1.8696882565721156) tdSql.checkData(56, 6, 2.172420890614816) tdSql.checkData(57, 0, 7) tdSql.checkData(57, 1, 0.4121184852417566) tdSql.checkData(57, 2, 0.574400879193934) tdSql.checkData(57, 3, 2.137595835197328) - tdSql.checkData(57, 4, None) + tdSql.checkData(57, 4, nan) tdSql.checkData(57, 5, -1.8119088619792247) tdSql.checkData(57, 6, 4.862055338419189) tdSql.checkData(58, 0, 8) tdSql.checkData(58, 1, -0.5440211108893698) tdSql.checkData(58, 2, 0.9612168045072789) tdSql.checkData(58, 3, 0.5787344727995947) - tdSql.checkData(58, 4, None) + tdSql.checkData(58, 4, nan) tdSql.checkData(58, 5, -0.7199655182148126) tdSql.checkData(58, 6, -4.087614771885445) tdSql.checkData(59, 0, 9) tdSql.checkData(59, 1, -0.9999902065507035) tdSql.checkData(59, 2, 0.7918362090144786) tdSql.checkData(59, 3, 2.776612511546888) - tdSql.checkData(59, 4, None) + tdSql.checkData(59, 4, nan) tdSql.checkData(59, 5, 0.5929886271208413) tdSql.checkData(59, 6, 1.796697093786514) tdSql.checkData(60, 0, 10) tdSql.checkData(60, 1, -0.5365729180004349) tdSql.checkData(60, 2, 0.549226270051226) tdSql.checkData(60, 3, 2.432352856101439) - tdSql.checkData(60, 4, None) + tdSql.checkData(60, 4, nan) tdSql.checkData(60, 5, 1.2185572409879093) tdSql.checkData(60, 6, 4.561306078186714) tdSql.checkData(61, 0, 11) tdSql.checkData(61, 1, 0.4201670368266409) tdSql.checkData(61, 2, 0.9162743174606308) tdSql.checkData(61, 3, 0.44272645708128566) - tdSql.checkData(61, 4, None) + tdSql.checkData(61, 4, nan) tdSql.checkData(61, 5, 0.9151372562290566) tdSql.checkData(61, 6, -222.95969776348554) tdSql.checkData(62, 0, 12) tdSql.checkData(62, 1, 0.9906073556948704) tdSql.checkData(62, 2, 0.8556343548213666) tdSql.checkData(62, 3, 2.451594361777497) - tdSql.checkData(62, 4, None) + tdSql.checkData(62, 4, nan) tdSql.checkData(62, 5, 0.24838494428124291) tdSql.checkData(62, 6, 1.4585617093317953) tdSql.checkData(63, 0, 13) tdSql.checkData(63, 1, 0.6502878401571168) tdSql.checkData(63, 2, 0.5403105467456532) tdSql.checkData(63, 3, 2.75535470715349) - tdSql.checkData(63, 4, None) + tdSql.checkData(63, 4, nan) tdSql.checkData(63, 5, 0.0009616202598659029) tdSql.checkData(63, 6, 4.225579583416092) tdSql.checkData(64, 0, 14) tdSql.checkData(64, 1, -0.2879033166650653) tdSql.checkData(64, 2, 0.859465627274523) tdSql.checkData(64, 3, 0.5636905248139659) - tdSql.checkData(64, 4, None) + tdSql.checkData(64, 4, nan) tdSql.checkData(64, 5, 0.41142163587369207) tdSql.checkData(64, 6, 10.515512404402676) tdSql.checkData(65, 0, 15) tdSql.checkData(65, 1, -0.9613974918795568) tdSql.checkData(65, 2, 0.9130208165623314) tdSql.checkData(65, 3, 2.1554866011151765) - tdSql.checkData(65, 4, None) + tdSql.checkData(65, 4, nan) tdSql.checkData(65, 5, 0.9521751875546269) tdSql.checkData(65, 6, 1.1559749749986195) tdSql.checkData(66, 0, 16) tdSql.checkData(66, 1, -0.750987246771676) tdSql.checkData(66, 2, 0.5481819942730298) tdSql.checkData(66, 3, 3.102748784455539) - tdSql.checkData(66, 4, None) + tdSql.checkData(66, 4, nan) tdSql.checkData(66, 5, 0.8513297604701857) tdSql.checkData(66, 6, 3.852058923265594) tdSql.checkData(67, 0, 17) tdSql.checkData(67, 1, 0.14987720966295234) tdSql.checkData(67, 2, 0.7959095686227995) tdSql.checkData(67, 3, 0.864944320724419) - tdSql.checkData(67, 4, None) + tdSql.checkData(67, 4, nan) tdSql.checkData(67, 5, -0.13037289959062748) tdSql.checkData(67, 6, 7.022998331594864) tdSql.checkData(68, 0, 18) tdSql.checkData(68, 1, 0.9129452507276277) tdSql.checkData(68, 2, 0.9588413200803038) tdSql.checkData(68, 3, 1.8713332491184997) - tdSql.checkData(68, 4, None) + tdSql.checkData(68, 4, nan) tdSql.checkData(68, 5, -1.3983047743451864) tdSql.checkData(68, 6, 0.8709074342191974) tdSql.checkData(69, 0, 19) tdSql.checkData(69, 1, 0.8366556385360561) tdSql.checkData(69, 2, 0.5723746128431292) tdSql.checkData(69, 3, 3.413484890511323) - tdSql.checkData(69, 4, None) + tdSql.checkData(69, 4, nan) tdSql.checkData(69, 5, -1.9952541841757747) tdSql.checkData(69, 6, 3.4479580493217856) tdSql.checkData(70, 0, 20) tdSql.checkData(70, 1, -0.008851309290403876) tdSql.checkData(70, 2, 0.7310155667453407) tdSql.checkData(70, 3, 1.2127175951404974) - tdSql.checkData(70, 4, None) + tdSql.checkData(70, 4, nan) tdSql.checkData(70, 5, -1.4304290589415767) tdSql.checkData(70, 6, 5.982274104704091) tdSql.checkData(71, 0, 21) tdSql.checkData(71, 1, -0.8462204041751706) tdSql.checkData(71, 2, 0.9887894200405688) tdSql.checkData(71, 3, 1.5772240911721418) - tdSql.checkData(71, 4, None) + tdSql.checkData(71, 4, nan) tdSql.checkData(71, 5, -0.11647857397382422) tdSql.checkData(71, 6, 0.5559799244477626) tdSql.checkData(72, 0, 22) tdSql.checkData(72, 1, -0.9055783620066239) tdSql.checkData(72, 2, 0.6114178044194122) tdSql.checkData(72, 3, 3.5568711064263105) - tdSql.checkData(72, 4, None) + tdSql.checkData(72, 4, nan) tdSql.checkData(72, 5, 0.9837833410919679) tdSql.checkData(72, 6, 3.0265535811470983) tdSql.checkData(73, 0, 23) tdSql.checkData(73, 1, -0.13235175009777303) tdSql.checkData(73, 2, 0.6699494442536529) tdSql.checkData(73, 3, 1.5387402975985367) - tdSql.checkData(73, 4, None) + tdSql.checkData(73, 4, nan) tdSql.checkData(73, 5, 1.1825447904081037) tdSql.checkData(73, 6, 5.489941431040083) tdSql.checkData(74, 0, 24) tdSql.checkData(74, 1, 0.7625584504796027) tdSql.checkData(74, 2, 0.999960827417674) tdSql.checkData(74, 3, 1.2552318002593996) - tdSql.checkData(74, 4, None) + tdSql.checkData(74, 4, nan) tdSql.checkData(74, 5, 0.6200983185456957) tdSql.checkData(74, 6, 0.09684864095463253) tdSql.checkData(75, 0, 25) tdSql.checkData(75, 1, 0.956375928404503) tdSql.checkData(75, 2, 0.6628179613691831) tdSql.checkData(75, 3, 3.4435632194258416) - tdSql.checkData(75, 4, None) + tdSql.checkData(75, 4, nan) tdSql.checkData(75, 5, 0.05676687083562715) tdSql.checkData(75, 6, 2.6040987392745354) tdSql.checkData(76, 0, 26) tdSql.checkData(76, 1, 0.27090578830786904) tdSql.checkData(76, 2, 0.6172306382193644) tdSql.checkData(76, 3, 1.835550377607515) - tdSql.checkData(76, 4, None) + tdSql.checkData(76, 4, nan) tdSql.checkData(76, 5, 0.11431954199291106) tdSql.checkData(76, 6, 5.165381146246765) tdSql.checkData(77, 0, 27) tdSql.checkData(77, 1, -0.6636338842129675) tdSql.checkData(77, 2, 0.9912542848596704) tdSql.checkData(77, 3, 0.9080812682077812) - tdSql.checkData(77, 4, None) + tdSql.checkData(77, 4, nan) tdSql.checkData(77, 5, 0.6788951190016388) tdSql.checkData(77, 6, -0.8324928492797357) tdSql.checkData(78, 0, 28) tdSql.checkData(78, 1, -0.9880316240928618) tdSql.checkData(78, 2, 0.7230710689951642) tdSql.checkData(78, 3, 3.1457526648156393) - tdSql.checkData(78, 4, None) + tdSql.checkData(78, 4, nan) tdSql.checkData(78, 5, 1.0206076417536643) tdSql.checkData(78, 6, 2.197019393348823) tdSql.checkData(79, 0, 29) tdSql.checkData(79, 1, -0.404037645323065) tdSql.checkData(79, 2, 0.5764850221962442) tdSql.checkData(79, 3, 2.1197476343754156) - tdSql.checkData(79, 4, None) + tdSql.checkData(79, 4, nan) tdSql.checkData(79, 5, 0.5162157333804713) tdSql.checkData(79, 6, 4.8800154918827525) tdSql.checkData(80, 0, 30) tdSql.checkData(80, 1, 0.5514266812416906) tdSql.checkData(80, 2, 0.9635288988181601) tdSql.checkData(80, 3, 0.5944617511422015) - tdSql.checkData(80, 4, None) + tdSql.checkData(80, 4, nan) tdSql.checkData(80, 5, -0.7022004347538967) tdSql.checkData(80, 6, -3.710141817748492) tdSql.checkData(81, 0, 31) tdSql.checkData(81, 1, 0.9999118601072672) tdSql.checkData(81, 2, 0.7877590247885756) tdSql.checkData(81, 3, 2.7979785951133604) - tdSql.checkData(81, 4, None) + tdSql.checkData(81, 4, nan) tdSql.checkData(81, 5, -1.7874722290307907) tdSql.checkData(81, 6, 1.8191237353300793) tdSql.checkData(82, 0, 32) tdSql.checkData(82, 1, 0.5290826861200238) tdSql.checkData(82, 2, 0.5503344099628432) tdSql.checkData(82, 3, 2.413227615833899) - tdSql.checkData(82, 4, None) + tdSql.checkData(82, 4, nan) tdSql.checkData(82, 5, -1.8893763681780902) tdSql.checkData(82, 6, 4.581032079680554) tdSql.checkData(83, 0, 33) tdSql.checkData(83, 1, -0.428182669496151) tdSql.checkData(83, 2, 0.9194811573015673) tdSql.checkData(83, 3, 0.4437992589174107) - tdSql.checkData(83, 4, None) + tdSql.checkData(83, 4, nan) tdSql.checkData(83, 5, -0.9001958571391758) tdSql.checkData(83, 6, -72.33956595410905) tdSql.checkData(84, 0, 34) tdSql.checkData(84, 1, -0.9917788534431158) tdSql.checkData(84, 2, 0.8517779466253769) tdSql.checkData(84, 3, 2.470955260231499) - tdSql.checkData(84, 4, None) + tdSql.checkData(84, 4, nan) tdSql.checkData(84, 5, 0.4428112547200472) tdSql.checkData(84, 6, 1.4785733565944832) tdSql.checkData(85, 0, 35) tdSql.checkData(85, 1, -0.6435381333569995) tdSql.checkData(85, 2, 0.5403764709316752) tdSql.checkData(85, 3, 2.734210799811235) - tdSql.checkData(85, 4, None) + tdSql.checkData(85, 4, nan) tdSql.checkData(85, 5, 1.1930854189064375) tdSql.checkData(85, 6, 4.24770540197234) tdSql.checkData(86, 0, 36) tdSql.checkData(86, 1, 0.2963685787093853) tdSql.checkData(86, 2, 0.8632704401895588) tdSql.checkData(86, 3, 0.5493681603601657) - tdSql.checkData(86, 4, None) + tdSql.checkData(86, 4, nan) tdSql.checkData(86, 5, 0.9944678850925007) tdSql.checkData(86, 6, 11.004294268461184) tdSql.checkData(87, 0, 37) tdSql.checkData(87, 1, 0.9637953862840878) tdSql.checkData(87, 2, 0.909721840267583) tdSql.checkData(87, 3, 2.1734252903776303) - tdSql.checkData(87, 4, None) + tdSql.checkData(87, 4, nan) tdSql.checkData(87, 5, 0.32696474077278626) tdSql.checkData(87, 6, 1.174082484128993) tdSql.checkData(88, 0, 38) tdSql.checkData(88, 1, 0.7451131604793488) tdSql.checkData(88, 2, 0.5472018255605284) tdSql.checkData(88, 3, 3.081063350979351) - tdSql.checkData(88, 4, None) + tdSql.checkData(88, 4, nan) tdSql.checkData(88, 5, -0.007381884932924798) tdSql.checkData(88, 6, 3.8764172978929814) tdSql.checkData(89, 0, 39) tdSql.checkData(89, 1, -0.158622668804709) tdSql.checkData(89, 2, 0.7999777847134487) tdSql.checkData(89, 3, 0.8435920138756074) - tdSql.checkData(89, 4, None) + tdSql.checkData(89, 4, nan) tdSql.checkData(89, 5, 0.3319994538301167) tdSql.checkData(89, 6, 7.12853286308907) tdSql.checkData(90, 0, 40) tdSql.checkData(90, 1, -0.9165215479156338) tdSql.checkData(90, 2, 0.9564033460276342) tdSql.checkData(90, 3, 1.889162191085516) - tdSql.checkData(90, 4, None) + tdSql.checkData(90, 4, nan) tdSql.checkData(90, 5, 0.90296737936602) tdSql.checkData(90, 6, 0.888896415152729) tdSql.checkData(91, 0, 41) tdSql.checkData(91, 1, -0.8317747426285983) tdSql.checkData(91, 2, 0.5704067143341829) tdSql.checkData(91, 3, 3.397430462894578) - tdSql.checkData(91, 4, None) + tdSql.checkData(91, 4, nan) tdSql.checkData(91, 5, 0.9190273051332304) tdSql.checkData(91, 6, 3.473885481113728) tdSql.checkData(92, 0, 42) tdSql.checkData(92, 1, 0.017701925105413577) tdSql.checkData(92, 2, 0.7350111780599404) tdSql.checkData(92, 3, 1.1912997639866574) - tdSql.checkData(92, 4, None) + tdSql.checkData(92, 4, nan) tdSql.checkData(92, 5, 0.036467324189017214) tdSql.checkData(92, 6, 6.024578312510778) tdSql.checkData(93, 0, 43) tdSql.checkData(93, 1, 0.8509035245341184) tdSql.checkData(93, 2, 0.9874457808369176) tdSql.checkData(93, 3, 1.5962924548219202) - tdSql.checkData(93, 4, None) + tdSql.checkData(93, 4, nan) tdSql.checkData(93, 5, -1.2490970766755156) tdSql.checkData(93, 6, 0.5781542141407696) tdSql.checkData(94, 0, 44) tdSql.checkData(94, 1, 0.9017883476488092) tdSql.checkData(94, 2, 0.6085839480802863) tdSql.checkData(94, 3, 3.5552629892514687) - tdSql.checkData(94, 4, None) + tdSql.checkData(94, 4, nan) tdSql.checkData(94, 5, -1.9810692649977342) tdSql.checkData(94, 6, 3.0531030020123464) tdSql.checkData(95, 0, 45) tdSql.checkData(95, 1, 0.123573122745224) tdSql.checkData(95, 2, 0.6735650596658175) tdSql.checkData(95, 3, 1.5193186190030223) - tdSql.checkData(95, 4, None) + tdSql.checkData(95, 4, nan) tdSql.checkData(95, 5, -1.5661895943272113) tdSql.checkData(95, 6, 5.513771854144419) tdSql.checkData(96, 0, 46) tdSql.checkData(96, 1, -0.7682546613236668) tdSql.checkData(96, 2, 0.9998433250151273) tdSql.checkData(96, 3, 1.2763169256468458) - tdSql.checkData(96, 4, None) + tdSql.checkData(96, 4, nan) tdSql.checkData(96, 5, -0.300459258677913) tdSql.checkData(96, 6, 0.13392039926281352) tdSql.checkData(97, 0, 47) tdSql.checkData(97, 1, -0.9537526527594719) tdSql.checkData(97, 2, 0.6593040763085178) tdSql.checkData(97, 3, 3.4575106745458637) - tdSql.checkData(97, 4, None) + tdSql.checkData(97, 4, nan) tdSql.checkData(97, 5, 0.8820838187306987) tdSql.checkData(97, 6, 2.6302204463996084) tdSql.checkData(98, 0, 48) tdSql.checkData(98, 1, -0.26237485370392877) tdSql.checkData(98, 2, 0.6202081141679935) tdSql.checkData(98, 3, 1.8175857333771335) - tdSql.checkData(98, 4, None) + tdSql.checkData(98, 4, nan) tdSql.checkData(98, 5, 1.211884234321115) tdSql.checkData(98, 6, 5.183714988550632) tdSql.checkData(99, 0, 49) tdSql.checkData(99, 1, 0.6702291758433747) tdSql.checkData(99, 2, 0.9923745526637894) tdSql.checkData(99, 3, 0.9298143670243166) - tdSql.checkData(99, 4, None) + tdSql.checkData(99, 4, nan) tdSql.checkData(99, 5, 0.7136182821549459) tdSql.checkData(99, 6, -0.7462904241496138) - tdSql.query('select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 ) order by ts limit 2;;') + tdSql.query( + "select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 ) order by ts limit 2;;" + ) tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 0.7780731968879212) tdSql.checkData(0, 2, 0.6143002821164822) tdSql.checkData(0, 3, 3.2037266279837113) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.02246988233490299) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) tdSql.checkData(1, 0, 1) tdSql.checkData(1, 1, 0.1411200080598672) tdSql.checkData(1, 2, 0.6663667453928805) tdSql.checkData(1, 3, 1.558041126155035) tdSql.checkData(1, 4, 1.8325957145940461) tdSql.checkData(1, 5, 0.17204223631998083) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 6, nan) - tdSql.query('select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 ) limit 2;;') + tdSql.query( + "select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6 from (select * from ct1 ) limit 2;;" + ) tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 0.7780731968879212) tdSql.checkData(0, 2, 0.6143002821164822) tdSql.checkData(0, 3, 3.2037266279837113) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.02246988233490299) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) tdSql.checkData(1, 0, 1) tdSql.checkData(1, 1, 0.1411200080598672) tdSql.checkData(1, 2, 0.6663667453928805) tdSql.checkData(1, 3, 1.558041126155035) tdSql.checkData(1, 4, 1.8325957145940461) tdSql.checkData(1, 5, 0.17204223631998083) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 6, nan) - tdSql.query('select * from (select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6, ts from st0 order by ts desc);') + tdSql.query( + "select * from (select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6, ts from st0 order by ts desc);" + ) tdSql.checkRows(100) tdSql.checkData(0, 0, 49) tdSql.checkData(0, 1, 0.6702291758433747) tdSql.checkData(0, 2, 0.9923745526637894) tdSql.checkData(0, 3, 0.9298143670243166) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.7136182821549459) tdSql.checkData(0, 6, -0.7462904241496138) tdSql.checkData(0, 7, datetime.datetime(2020, 10, 1, 0, 49)) @@ -3350,7 +3390,7 @@ class TDTestCase: tdSql.checkData(1, 1, 0.6702291758433747) tdSql.checkData(1, 2, 0.9923745526637894) tdSql.checkData(1, 3, 0.9298143670243166) - tdSql.checkData(1, 4, None) + tdSql.checkData(1, 4, nan) tdSql.checkData(1, 5, 0.7136182821549459) tdSql.checkData(1, 6, -0.7462904241496138) tdSql.checkData(1, 7, datetime.datetime(2020, 10, 1, 0, 49)) @@ -3358,7 +3398,7 @@ class TDTestCase: tdSql.checkData(2, 1, -0.26237485370392877) tdSql.checkData(2, 2, 0.6202081141679935) tdSql.checkData(2, 3, 1.8175857333771335) - tdSql.checkData(2, 4, None) + tdSql.checkData(2, 4, nan) tdSql.checkData(2, 5, 1.211884234321115) tdSql.checkData(2, 6, 5.183714988550632) tdSql.checkData(2, 7, datetime.datetime(2020, 10, 1, 0, 48)) @@ -3366,7 +3406,7 @@ class TDTestCase: tdSql.checkData(3, 1, -0.26237485370392877) tdSql.checkData(3, 2, 0.6202081141679935) tdSql.checkData(3, 3, 1.8175857333771335) - tdSql.checkData(3, 4, None) + tdSql.checkData(3, 4, nan) tdSql.checkData(3, 5, 1.211884234321115) tdSql.checkData(3, 6, 5.183714988550632) tdSql.checkData(3, 7, datetime.datetime(2020, 10, 1, 0, 48)) @@ -3374,7 +3414,7 @@ class TDTestCase: tdSql.checkData(4, 1, -0.9537526527594719) tdSql.checkData(4, 2, 0.6593040763085178) tdSql.checkData(4, 3, 3.4575106745458637) - tdSql.checkData(4, 4, None) + tdSql.checkData(4, 4, nan) tdSql.checkData(4, 5, 0.8820838187306987) tdSql.checkData(4, 6, 2.6302204463996084) tdSql.checkData(4, 7, datetime.datetime(2020, 10, 1, 0, 47)) @@ -3382,7 +3422,7 @@ class TDTestCase: tdSql.checkData(5, 1, -0.9537526527594719) tdSql.checkData(5, 2, 0.6593040763085178) tdSql.checkData(5, 3, 3.4575106745458637) - tdSql.checkData(5, 4, None) + tdSql.checkData(5, 4, nan) tdSql.checkData(5, 5, 0.8820838187306987) tdSql.checkData(5, 6, 2.6302204463996084) tdSql.checkData(5, 7, datetime.datetime(2020, 10, 1, 0, 47)) @@ -3390,7 +3430,7 @@ class TDTestCase: tdSql.checkData(6, 1, -0.7682546613236668) tdSql.checkData(6, 2, 0.9998433250151273) tdSql.checkData(6, 3, 1.2763169256468458) - tdSql.checkData(6, 4, None) + tdSql.checkData(6, 4, nan) tdSql.checkData(6, 5, -0.300459258677913) tdSql.checkData(6, 6, 0.13392039926281352) tdSql.checkData(6, 7, datetime.datetime(2020, 10, 1, 0, 46)) @@ -3398,7 +3438,7 @@ class TDTestCase: tdSql.checkData(7, 1, -0.7682546613236668) tdSql.checkData(7, 2, 0.9998433250151273) tdSql.checkData(7, 3, 1.2763169256468458) - tdSql.checkData(7, 4, None) + tdSql.checkData(7, 4, nan) tdSql.checkData(7, 5, -0.300459258677913) tdSql.checkData(7, 6, 0.13392039926281352) tdSql.checkData(7, 7, datetime.datetime(2020, 10, 1, 0, 46)) @@ -3406,7 +3446,7 @@ class TDTestCase: tdSql.checkData(8, 1, 0.123573122745224) tdSql.checkData(8, 2, 0.6735650596658175) tdSql.checkData(8, 3, 1.5193186190030223) - tdSql.checkData(8, 4, None) + tdSql.checkData(8, 4, nan) tdSql.checkData(8, 5, -1.5661895943272113) tdSql.checkData(8, 6, 5.513771854144419) tdSql.checkData(8, 7, datetime.datetime(2020, 10, 1, 0, 45)) @@ -3414,7 +3454,7 @@ class TDTestCase: tdSql.checkData(9, 1, 0.123573122745224) tdSql.checkData(9, 2, 0.6735650596658175) tdSql.checkData(9, 3, 1.5193186190030223) - tdSql.checkData(9, 4, None) + tdSql.checkData(9, 4, nan) tdSql.checkData(9, 5, -1.5661895943272113) tdSql.checkData(9, 6, 5.513771854144419) tdSql.checkData(9, 7, datetime.datetime(2020, 10, 1, 0, 45)) @@ -3422,7 +3462,7 @@ class TDTestCase: tdSql.checkData(10, 1, 0.9017883476488092) tdSql.checkData(10, 2, 0.6085839480802863) tdSql.checkData(10, 3, 3.5552629892514687) - tdSql.checkData(10, 4, None) + tdSql.checkData(10, 4, nan) tdSql.checkData(10, 5, -1.9810692649977342) tdSql.checkData(10, 6, 3.0531030020123464) tdSql.checkData(10, 7, datetime.datetime(2020, 10, 1, 0, 44)) @@ -3430,7 +3470,7 @@ class TDTestCase: tdSql.checkData(11, 1, 0.9017883476488092) tdSql.checkData(11, 2, 0.6085839480802863) tdSql.checkData(11, 3, 3.5552629892514687) - tdSql.checkData(11, 4, None) + tdSql.checkData(11, 4, nan) tdSql.checkData(11, 5, -1.9810692649977342) tdSql.checkData(11, 6, 3.0531030020123464) tdSql.checkData(11, 7, datetime.datetime(2020, 10, 1, 0, 44)) @@ -3438,7 +3478,7 @@ class TDTestCase: tdSql.checkData(12, 1, 0.8509035245341184) tdSql.checkData(12, 2, 0.9874457808369176) tdSql.checkData(12, 3, 1.5962924548219202) - tdSql.checkData(12, 4, None) + tdSql.checkData(12, 4, nan) tdSql.checkData(12, 5, -1.2490970766755156) tdSql.checkData(12, 6, 0.5781542141407696) tdSql.checkData(12, 7, datetime.datetime(2020, 10, 1, 0, 43)) @@ -3446,7 +3486,7 @@ class TDTestCase: tdSql.checkData(13, 1, 0.8509035245341184) tdSql.checkData(13, 2, 0.9874457808369176) tdSql.checkData(13, 3, 1.5962924548219202) - tdSql.checkData(13, 4, None) + tdSql.checkData(13, 4, nan) tdSql.checkData(13, 5, -1.2490970766755156) tdSql.checkData(13, 6, 0.5781542141407696) tdSql.checkData(13, 7, datetime.datetime(2020, 10, 1, 0, 43)) @@ -3454,7 +3494,7 @@ class TDTestCase: tdSql.checkData(14, 1, 0.017701925105413577) tdSql.checkData(14, 2, 0.7350111780599404) tdSql.checkData(14, 3, 1.1912997639866574) - tdSql.checkData(14, 4, None) + tdSql.checkData(14, 4, nan) tdSql.checkData(14, 5, 0.036467324189017214) tdSql.checkData(14, 6, 6.024578312510778) tdSql.checkData(14, 7, datetime.datetime(2020, 10, 1, 0, 42)) @@ -3462,7 +3502,7 @@ class TDTestCase: tdSql.checkData(15, 1, 0.017701925105413577) tdSql.checkData(15, 2, 0.7350111780599404) tdSql.checkData(15, 3, 1.1912997639866574) - tdSql.checkData(15, 4, None) + tdSql.checkData(15, 4, nan) tdSql.checkData(15, 5, 0.036467324189017214) tdSql.checkData(15, 6, 6.024578312510778) tdSql.checkData(15, 7, datetime.datetime(2020, 10, 1, 0, 42)) @@ -3470,7 +3510,7 @@ class TDTestCase: tdSql.checkData(16, 1, -0.8317747426285983) tdSql.checkData(16, 2, 0.5704067143341829) tdSql.checkData(16, 3, 3.397430462894578) - tdSql.checkData(16, 4, None) + tdSql.checkData(16, 4, nan) tdSql.checkData(16, 5, 0.9190273051332304) tdSql.checkData(16, 6, 3.473885481113728) tdSql.checkData(16, 7, datetime.datetime(2020, 10, 1, 0, 41)) @@ -3478,7 +3518,7 @@ class TDTestCase: tdSql.checkData(17, 1, -0.8317747426285983) tdSql.checkData(17, 2, 0.5704067143341829) tdSql.checkData(17, 3, 3.397430462894578) - tdSql.checkData(17, 4, None) + tdSql.checkData(17, 4, nan) tdSql.checkData(17, 5, 0.9190273051332304) tdSql.checkData(17, 6, 3.473885481113728) tdSql.checkData(17, 7, datetime.datetime(2020, 10, 1, 0, 41)) @@ -3486,7 +3526,7 @@ class TDTestCase: tdSql.checkData(18, 1, -0.9165215479156338) tdSql.checkData(18, 2, 0.9564033460276342) tdSql.checkData(18, 3, 1.889162191085516) - tdSql.checkData(18, 4, None) + tdSql.checkData(18, 4, nan) tdSql.checkData(18, 5, 0.90296737936602) tdSql.checkData(18, 6, 0.888896415152729) tdSql.checkData(18, 7, datetime.datetime(2020, 10, 1, 0, 40)) @@ -3494,7 +3534,7 @@ class TDTestCase: tdSql.checkData(19, 1, -0.9165215479156338) tdSql.checkData(19, 2, 0.9564033460276342) tdSql.checkData(19, 3, 1.889162191085516) - tdSql.checkData(19, 4, None) + tdSql.checkData(19, 4, nan) tdSql.checkData(19, 5, 0.90296737936602) tdSql.checkData(19, 6, 0.888896415152729) tdSql.checkData(19, 7, datetime.datetime(2020, 10, 1, 0, 40)) @@ -3502,7 +3542,7 @@ class TDTestCase: tdSql.checkData(20, 1, -0.158622668804709) tdSql.checkData(20, 2, 0.7999777847134487) tdSql.checkData(20, 3, 0.8435920138756074) - tdSql.checkData(20, 4, None) + tdSql.checkData(20, 4, nan) tdSql.checkData(20, 5, 0.3319994538301167) tdSql.checkData(20, 6, 7.12853286308907) tdSql.checkData(20, 7, datetime.datetime(2020, 10, 1, 0, 39)) @@ -3510,7 +3550,7 @@ class TDTestCase: tdSql.checkData(21, 1, -0.158622668804709) tdSql.checkData(21, 2, 0.7999777847134487) tdSql.checkData(21, 3, 0.8435920138756074) - tdSql.checkData(21, 4, None) + tdSql.checkData(21, 4, nan) tdSql.checkData(21, 5, 0.3319994538301167) tdSql.checkData(21, 6, 7.12853286308907) tdSql.checkData(21, 7, datetime.datetime(2020, 10, 1, 0, 39)) @@ -3518,7 +3558,7 @@ class TDTestCase: tdSql.checkData(22, 1, 0.7451131604793488) tdSql.checkData(22, 2, 0.5472018255605284) tdSql.checkData(22, 3, 3.081063350979351) - tdSql.checkData(22, 4, None) + tdSql.checkData(22, 4, nan) tdSql.checkData(22, 5, -0.007381884932924798) tdSql.checkData(22, 6, 3.8764172978929814) tdSql.checkData(22, 7, datetime.datetime(2020, 10, 1, 0, 38)) @@ -3526,7 +3566,7 @@ class TDTestCase: tdSql.checkData(23, 1, 0.7451131604793488) tdSql.checkData(23, 2, 0.5472018255605284) tdSql.checkData(23, 3, 3.081063350979351) - tdSql.checkData(23, 4, None) + tdSql.checkData(23, 4, nan) tdSql.checkData(23, 5, -0.007381884932924798) tdSql.checkData(23, 6, 3.8764172978929814) tdSql.checkData(23, 7, datetime.datetime(2020, 10, 1, 0, 38)) @@ -3534,7 +3574,7 @@ class TDTestCase: tdSql.checkData(24, 1, 0.9637953862840878) tdSql.checkData(24, 2, 0.909721840267583) tdSql.checkData(24, 3, 2.1734252903776303) - tdSql.checkData(24, 4, None) + tdSql.checkData(24, 4, nan) tdSql.checkData(24, 5, 0.32696474077278626) tdSql.checkData(24, 6, 1.174082484128993) tdSql.checkData(24, 7, datetime.datetime(2020, 10, 1, 0, 37)) @@ -3542,7 +3582,7 @@ class TDTestCase: tdSql.checkData(25, 1, 0.9637953862840878) tdSql.checkData(25, 2, 0.909721840267583) tdSql.checkData(25, 3, 2.1734252903776303) - tdSql.checkData(25, 4, None) + tdSql.checkData(25, 4, nan) tdSql.checkData(25, 5, 0.32696474077278626) tdSql.checkData(25, 6, 1.174082484128993) tdSql.checkData(25, 7, datetime.datetime(2020, 10, 1, 0, 37)) @@ -3550,7 +3590,7 @@ class TDTestCase: tdSql.checkData(26, 1, 0.2963685787093853) tdSql.checkData(26, 2, 0.8632704401895588) tdSql.checkData(26, 3, 0.5493681603601657) - tdSql.checkData(26, 4, None) + tdSql.checkData(26, 4, nan) tdSql.checkData(26, 5, 0.9944678850925007) tdSql.checkData(26, 6, 11.004294268461184) tdSql.checkData(26, 7, datetime.datetime(2020, 10, 1, 0, 36)) @@ -3558,7 +3598,7 @@ class TDTestCase: tdSql.checkData(27, 1, 0.2963685787093853) tdSql.checkData(27, 2, 0.8632704401895588) tdSql.checkData(27, 3, 0.5493681603601657) - tdSql.checkData(27, 4, None) + tdSql.checkData(27, 4, nan) tdSql.checkData(27, 5, 0.9944678850925007) tdSql.checkData(27, 6, 11.004294268461184) tdSql.checkData(27, 7, datetime.datetime(2020, 10, 1, 0, 36)) @@ -3566,7 +3606,7 @@ class TDTestCase: tdSql.checkData(28, 1, -0.6435381333569995) tdSql.checkData(28, 2, 0.5403764709316752) tdSql.checkData(28, 3, 2.734210799811235) - tdSql.checkData(28, 4, None) + tdSql.checkData(28, 4, nan) tdSql.checkData(28, 5, 1.1930854189064375) tdSql.checkData(28, 6, 4.24770540197234) tdSql.checkData(28, 7, datetime.datetime(2020, 10, 1, 0, 35)) @@ -3574,7 +3614,7 @@ class TDTestCase: tdSql.checkData(29, 1, -0.6435381333569995) tdSql.checkData(29, 2, 0.5403764709316752) tdSql.checkData(29, 3, 2.734210799811235) - tdSql.checkData(29, 4, None) + tdSql.checkData(29, 4, nan) tdSql.checkData(29, 5, 1.1930854189064375) tdSql.checkData(29, 6, 4.24770540197234) tdSql.checkData(29, 7, datetime.datetime(2020, 10, 1, 0, 35)) @@ -3582,7 +3622,7 @@ class TDTestCase: tdSql.checkData(30, 1, -0.9917788534431158) tdSql.checkData(30, 2, 0.8517779466253769) tdSql.checkData(30, 3, 2.470955260231499) - tdSql.checkData(30, 4, None) + tdSql.checkData(30, 4, nan) tdSql.checkData(30, 5, 0.4428112547200472) tdSql.checkData(30, 6, 1.4785733565944832) tdSql.checkData(30, 7, datetime.datetime(2020, 10, 1, 0, 34)) @@ -3590,7 +3630,7 @@ class TDTestCase: tdSql.checkData(31, 1, -0.9917788534431158) tdSql.checkData(31, 2, 0.8517779466253769) tdSql.checkData(31, 3, 2.470955260231499) - tdSql.checkData(31, 4, None) + tdSql.checkData(31, 4, nan) tdSql.checkData(31, 5, 0.4428112547200472) tdSql.checkData(31, 6, 1.4785733565944832) tdSql.checkData(31, 7, datetime.datetime(2020, 10, 1, 0, 34)) @@ -3598,7 +3638,7 @@ class TDTestCase: tdSql.checkData(32, 1, -0.428182669496151) tdSql.checkData(32, 2, 0.9194811573015673) tdSql.checkData(32, 3, 0.4437992589174107) - tdSql.checkData(32, 4, None) + tdSql.checkData(32, 4, nan) tdSql.checkData(32, 5, -0.9001958571391758) tdSql.checkData(32, 6, -72.33956595410905) tdSql.checkData(32, 7, datetime.datetime(2020, 10, 1, 0, 33)) @@ -3606,7 +3646,7 @@ class TDTestCase: tdSql.checkData(33, 1, -0.428182669496151) tdSql.checkData(33, 2, 0.9194811573015673) tdSql.checkData(33, 3, 0.4437992589174107) - tdSql.checkData(33, 4, None) + tdSql.checkData(33, 4, nan) tdSql.checkData(33, 5, -0.9001958571391758) tdSql.checkData(33, 6, -72.33956595410905) tdSql.checkData(33, 7, datetime.datetime(2020, 10, 1, 0, 33)) @@ -3614,7 +3654,7 @@ class TDTestCase: tdSql.checkData(34, 1, 0.5290826861200238) tdSql.checkData(34, 2, 0.5503344099628432) tdSql.checkData(34, 3, 2.413227615833899) - tdSql.checkData(34, 4, None) + tdSql.checkData(34, 4, nan) tdSql.checkData(34, 5, -1.8893763681780902) tdSql.checkData(34, 6, 4.581032079680554) tdSql.checkData(34, 7, datetime.datetime(2020, 10, 1, 0, 32)) @@ -3622,7 +3662,7 @@ class TDTestCase: tdSql.checkData(35, 1, 0.5290826861200238) tdSql.checkData(35, 2, 0.5503344099628432) tdSql.checkData(35, 3, 2.413227615833899) - tdSql.checkData(35, 4, None) + tdSql.checkData(35, 4, nan) tdSql.checkData(35, 5, -1.8893763681780902) tdSql.checkData(35, 6, 4.581032079680554) tdSql.checkData(35, 7, datetime.datetime(2020, 10, 1, 0, 32)) @@ -3630,7 +3670,7 @@ class TDTestCase: tdSql.checkData(36, 1, 0.9999118601072672) tdSql.checkData(36, 2, 0.7877590247885756) tdSql.checkData(36, 3, 2.7979785951133604) - tdSql.checkData(36, 4, None) + tdSql.checkData(36, 4, nan) tdSql.checkData(36, 5, -1.7874722290307907) tdSql.checkData(36, 6, 1.8191237353300793) tdSql.checkData(36, 7, datetime.datetime(2020, 10, 1, 0, 31)) @@ -3638,7 +3678,7 @@ class TDTestCase: tdSql.checkData(37, 1, 0.9999118601072672) tdSql.checkData(37, 2, 0.7877590247885756) tdSql.checkData(37, 3, 2.7979785951133604) - tdSql.checkData(37, 4, None) + tdSql.checkData(37, 4, nan) tdSql.checkData(37, 5, -1.7874722290307907) tdSql.checkData(37, 6, 1.8191237353300793) tdSql.checkData(37, 7, datetime.datetime(2020, 10, 1, 0, 31)) @@ -3646,7 +3686,7 @@ class TDTestCase: tdSql.checkData(38, 1, 0.5514266812416906) tdSql.checkData(38, 2, 0.9635288988181601) tdSql.checkData(38, 3, 0.5944617511422015) - tdSql.checkData(38, 4, None) + tdSql.checkData(38, 4, nan) tdSql.checkData(38, 5, -0.7022004347538967) tdSql.checkData(38, 6, -3.710141817748492) tdSql.checkData(38, 7, datetime.datetime(2020, 10, 1, 0, 30)) @@ -3654,7 +3694,7 @@ class TDTestCase: tdSql.checkData(39, 1, 0.5514266812416906) tdSql.checkData(39, 2, 0.9635288988181601) tdSql.checkData(39, 3, 0.5944617511422015) - tdSql.checkData(39, 4, None) + tdSql.checkData(39, 4, nan) tdSql.checkData(39, 5, -0.7022004347538967) tdSql.checkData(39, 6, -3.710141817748492) tdSql.checkData(39, 7, datetime.datetime(2020, 10, 1, 0, 30)) @@ -3662,7 +3702,7 @@ class TDTestCase: tdSql.checkData(40, 1, -0.404037645323065) tdSql.checkData(40, 2, 0.5764850221962442) tdSql.checkData(40, 3, 2.1197476343754156) - tdSql.checkData(40, 4, None) + tdSql.checkData(40, 4, nan) tdSql.checkData(40, 5, 0.5162157333804713) tdSql.checkData(40, 6, 4.8800154918827525) tdSql.checkData(40, 7, datetime.datetime(2020, 10, 1, 0, 29)) @@ -3670,7 +3710,7 @@ class TDTestCase: tdSql.checkData(41, 1, -0.404037645323065) tdSql.checkData(41, 2, 0.5764850221962442) tdSql.checkData(41, 3, 2.1197476343754156) - tdSql.checkData(41, 4, None) + tdSql.checkData(41, 4, nan) tdSql.checkData(41, 5, 0.5162157333804713) tdSql.checkData(41, 6, 4.8800154918827525) tdSql.checkData(41, 7, datetime.datetime(2020, 10, 1, 0, 29)) @@ -3678,7 +3718,7 @@ class TDTestCase: tdSql.checkData(42, 1, -0.9880316240928618) tdSql.checkData(42, 2, 0.7230710689951642) tdSql.checkData(42, 3, 3.1457526648156393) - tdSql.checkData(42, 4, None) + tdSql.checkData(42, 4, nan) tdSql.checkData(42, 5, 1.0206076417536643) tdSql.checkData(42, 6, 2.197019393348823) tdSql.checkData(42, 7, datetime.datetime(2020, 10, 1, 0, 28)) @@ -3686,7 +3726,7 @@ class TDTestCase: tdSql.checkData(43, 1, -0.9880316240928618) tdSql.checkData(43, 2, 0.7230710689951642) tdSql.checkData(43, 3, 3.1457526648156393) - tdSql.checkData(43, 4, None) + tdSql.checkData(43, 4, nan) tdSql.checkData(43, 5, 1.0206076417536643) tdSql.checkData(43, 6, 2.197019393348823) tdSql.checkData(43, 7, datetime.datetime(2020, 10, 1, 0, 28)) @@ -3694,7 +3734,7 @@ class TDTestCase: tdSql.checkData(44, 1, -0.6636338842129675) tdSql.checkData(44, 2, 0.9912542848596704) tdSql.checkData(44, 3, 0.9080812682077812) - tdSql.checkData(44, 4, None) + tdSql.checkData(44, 4, nan) tdSql.checkData(44, 5, 0.6788951190016388) tdSql.checkData(44, 6, -0.8324928492797357) tdSql.checkData(44, 7, datetime.datetime(2020, 10, 1, 0, 27)) @@ -3702,7 +3742,7 @@ class TDTestCase: tdSql.checkData(45, 1, -0.6636338842129675) tdSql.checkData(45, 2, 0.9912542848596704) tdSql.checkData(45, 3, 0.9080812682077812) - tdSql.checkData(45, 4, None) + tdSql.checkData(45, 4, nan) tdSql.checkData(45, 5, 0.6788951190016388) tdSql.checkData(45, 6, -0.8324928492797357) tdSql.checkData(45, 7, datetime.datetime(2020, 10, 1, 0, 27)) @@ -3710,7 +3750,7 @@ class TDTestCase: tdSql.checkData(46, 1, 0.27090578830786904) tdSql.checkData(46, 2, 0.6172306382193644) tdSql.checkData(46, 3, 1.835550377607515) - tdSql.checkData(46, 4, None) + tdSql.checkData(46, 4, nan) tdSql.checkData(46, 5, 0.11431954199291106) tdSql.checkData(46, 6, 5.165381146246765) tdSql.checkData(46, 7, datetime.datetime(2020, 10, 1, 0, 26)) @@ -3718,7 +3758,7 @@ class TDTestCase: tdSql.checkData(47, 1, 0.27090578830786904) tdSql.checkData(47, 2, 0.6172306382193644) tdSql.checkData(47, 3, 1.835550377607515) - tdSql.checkData(47, 4, None) + tdSql.checkData(47, 4, nan) tdSql.checkData(47, 5, 0.11431954199291106) tdSql.checkData(47, 6, 5.165381146246765) tdSql.checkData(47, 7, datetime.datetime(2020, 10, 1, 0, 26)) @@ -3726,7 +3766,7 @@ class TDTestCase: tdSql.checkData(48, 1, 0.956375928404503) tdSql.checkData(48, 2, 0.6628179613691831) tdSql.checkData(48, 3, 3.4435632194258416) - tdSql.checkData(48, 4, None) + tdSql.checkData(48, 4, nan) tdSql.checkData(48, 5, 0.05676687083562715) tdSql.checkData(48, 6, 2.6040987392745354) tdSql.checkData(48, 7, datetime.datetime(2020, 10, 1, 0, 25)) @@ -3734,7 +3774,7 @@ class TDTestCase: tdSql.checkData(49, 1, 0.956375928404503) tdSql.checkData(49, 2, 0.6628179613691831) tdSql.checkData(49, 3, 3.4435632194258416) - tdSql.checkData(49, 4, None) + tdSql.checkData(49, 4, nan) tdSql.checkData(49, 5, 0.05676687083562715) tdSql.checkData(49, 6, 2.6040987392745354) tdSql.checkData(49, 7, datetime.datetime(2020, 10, 1, 0, 25)) @@ -3742,7 +3782,7 @@ class TDTestCase: tdSql.checkData(50, 1, 0.7625584504796027) tdSql.checkData(50, 2, 0.999960827417674) tdSql.checkData(50, 3, 1.2552318002593996) - tdSql.checkData(50, 4, None) + tdSql.checkData(50, 4, nan) tdSql.checkData(50, 5, 0.6200983185456957) tdSql.checkData(50, 6, 0.09684864095463253) tdSql.checkData(50, 7, datetime.datetime(2020, 10, 1, 0, 24)) @@ -3750,7 +3790,7 @@ class TDTestCase: tdSql.checkData(51, 1, 0.7625584504796027) tdSql.checkData(51, 2, 0.999960827417674) tdSql.checkData(51, 3, 1.2552318002593996) - tdSql.checkData(51, 4, None) + tdSql.checkData(51, 4, nan) tdSql.checkData(51, 5, 0.6200983185456957) tdSql.checkData(51, 6, 0.09684864095463253) tdSql.checkData(51, 7, datetime.datetime(2020, 10, 1, 0, 24)) @@ -3758,7 +3798,7 @@ class TDTestCase: tdSql.checkData(52, 1, -0.13235175009777303) tdSql.checkData(52, 2, 0.6699494442536529) tdSql.checkData(52, 3, 1.5387402975985367) - tdSql.checkData(52, 4, None) + tdSql.checkData(52, 4, nan) tdSql.checkData(52, 5, 1.1825447904081037) tdSql.checkData(52, 6, 5.489941431040083) tdSql.checkData(52, 7, datetime.datetime(2020, 10, 1, 0, 23)) @@ -3766,7 +3806,7 @@ class TDTestCase: tdSql.checkData(53, 1, -0.13235175009777303) tdSql.checkData(53, 2, 0.6699494442536529) tdSql.checkData(53, 3, 1.5387402975985367) - tdSql.checkData(53, 4, None) + tdSql.checkData(53, 4, nan) tdSql.checkData(53, 5, 1.1825447904081037) tdSql.checkData(53, 6, 5.489941431040083) tdSql.checkData(53, 7, datetime.datetime(2020, 10, 1, 0, 23)) @@ -3774,7 +3814,7 @@ class TDTestCase: tdSql.checkData(54, 1, -0.9055783620066239) tdSql.checkData(54, 2, 0.6114178044194122) tdSql.checkData(54, 3, 3.5568711064263105) - tdSql.checkData(54, 4, None) + tdSql.checkData(54, 4, nan) tdSql.checkData(54, 5, 0.9837833410919679) tdSql.checkData(54, 6, 3.0265535811470983) tdSql.checkData(54, 7, datetime.datetime(2020, 10, 1, 0, 22)) @@ -3782,7 +3822,7 @@ class TDTestCase: tdSql.checkData(55, 1, -0.9055783620066239) tdSql.checkData(55, 2, 0.6114178044194122) tdSql.checkData(55, 3, 3.5568711064263105) - tdSql.checkData(55, 4, None) + tdSql.checkData(55, 4, nan) tdSql.checkData(55, 5, 0.9837833410919679) tdSql.checkData(55, 6, 3.0265535811470983) tdSql.checkData(55, 7, datetime.datetime(2020, 10, 1, 0, 22)) @@ -3790,7 +3830,7 @@ class TDTestCase: tdSql.checkData(56, 1, -0.8462204041751706) tdSql.checkData(56, 2, 0.9887894200405688) tdSql.checkData(56, 3, 1.5772240911721418) - tdSql.checkData(56, 4, None) + tdSql.checkData(56, 4, nan) tdSql.checkData(56, 5, -0.11647857397382422) tdSql.checkData(56, 6, 0.5559799244477626) tdSql.checkData(56, 7, datetime.datetime(2020, 10, 1, 0, 21)) @@ -3798,7 +3838,7 @@ class TDTestCase: tdSql.checkData(57, 1, -0.8462204041751706) tdSql.checkData(57, 2, 0.9887894200405688) tdSql.checkData(57, 3, 1.5772240911721418) - tdSql.checkData(57, 4, None) + tdSql.checkData(57, 4, nan) tdSql.checkData(57, 5, -0.11647857397382422) tdSql.checkData(57, 6, 0.5559799244477626) tdSql.checkData(57, 7, datetime.datetime(2020, 10, 1, 0, 21)) @@ -3806,7 +3846,7 @@ class TDTestCase: tdSql.checkData(58, 1, -0.008851309290403876) tdSql.checkData(58, 2, 0.7310155667453407) tdSql.checkData(58, 3, 1.2127175951404974) - tdSql.checkData(58, 4, None) + tdSql.checkData(58, 4, nan) tdSql.checkData(58, 5, -1.4304290589415767) tdSql.checkData(58, 6, 5.982274104704091) tdSql.checkData(58, 7, datetime.datetime(2020, 10, 1, 0, 20)) @@ -3814,7 +3854,7 @@ class TDTestCase: tdSql.checkData(59, 1, -0.008851309290403876) tdSql.checkData(59, 2, 0.7310155667453407) tdSql.checkData(59, 3, 1.2127175951404974) - tdSql.checkData(59, 4, None) + tdSql.checkData(59, 4, nan) tdSql.checkData(59, 5, -1.4304290589415767) tdSql.checkData(59, 6, 5.982274104704091) tdSql.checkData(59, 7, datetime.datetime(2020, 10, 1, 0, 20)) @@ -3822,7 +3862,7 @@ class TDTestCase: tdSql.checkData(60, 1, 0.8366556385360561) tdSql.checkData(60, 2, 0.5723746128431292) tdSql.checkData(60, 3, 3.413484890511323) - tdSql.checkData(60, 4, None) + tdSql.checkData(60, 4, nan) tdSql.checkData(60, 5, -1.9952541841757747) tdSql.checkData(60, 6, 3.4479580493217856) tdSql.checkData(60, 7, datetime.datetime(2020, 10, 1, 0, 19)) @@ -3830,7 +3870,7 @@ class TDTestCase: tdSql.checkData(61, 1, 0.8366556385360561) tdSql.checkData(61, 2, 0.5723746128431292) tdSql.checkData(61, 3, 3.413484890511323) - tdSql.checkData(61, 4, None) + tdSql.checkData(61, 4, nan) tdSql.checkData(61, 5, -1.9952541841757747) tdSql.checkData(61, 6, 3.4479580493217856) tdSql.checkData(61, 7, datetime.datetime(2020, 10, 1, 0, 19)) @@ -3838,7 +3878,7 @@ class TDTestCase: tdSql.checkData(62, 1, 0.9129452507276277) tdSql.checkData(62, 2, 0.9588413200803038) tdSql.checkData(62, 3, 1.8713332491184997) - tdSql.checkData(62, 4, None) + tdSql.checkData(62, 4, nan) tdSql.checkData(62, 5, -1.3983047743451864) tdSql.checkData(62, 6, 0.8709074342191974) tdSql.checkData(62, 7, datetime.datetime(2020, 10, 1, 0, 18)) @@ -3846,7 +3886,7 @@ class TDTestCase: tdSql.checkData(63, 1, 0.9129452507276277) tdSql.checkData(63, 2, 0.9588413200803038) tdSql.checkData(63, 3, 1.8713332491184997) - tdSql.checkData(63, 4, None) + tdSql.checkData(63, 4, nan) tdSql.checkData(63, 5, -1.3983047743451864) tdSql.checkData(63, 6, 0.8709074342191974) tdSql.checkData(63, 7, datetime.datetime(2020, 10, 1, 0, 18)) @@ -3854,7 +3894,7 @@ class TDTestCase: tdSql.checkData(64, 1, 0.14987720966295234) tdSql.checkData(64, 2, 0.7959095686227995) tdSql.checkData(64, 3, 0.864944320724419) - tdSql.checkData(64, 4, None) + tdSql.checkData(64, 4, nan) tdSql.checkData(64, 5, -0.13037289959062748) tdSql.checkData(64, 6, 7.022998331594864) tdSql.checkData(64, 7, datetime.datetime(2020, 10, 1, 0, 17)) @@ -3862,7 +3902,7 @@ class TDTestCase: tdSql.checkData(65, 1, 0.14987720966295234) tdSql.checkData(65, 2, 0.7959095686227995) tdSql.checkData(65, 3, 0.864944320724419) - tdSql.checkData(65, 4, None) + tdSql.checkData(65, 4, nan) tdSql.checkData(65, 5, -0.13037289959062748) tdSql.checkData(65, 6, 7.022998331594864) tdSql.checkData(65, 7, datetime.datetime(2020, 10, 1, 0, 17)) @@ -3870,7 +3910,7 @@ class TDTestCase: tdSql.checkData(66, 1, -0.750987246771676) tdSql.checkData(66, 2, 0.5481819942730298) tdSql.checkData(66, 3, 3.102748784455539) - tdSql.checkData(66, 4, None) + tdSql.checkData(66, 4, nan) tdSql.checkData(66, 5, 0.8513297604701857) tdSql.checkData(66, 6, 3.852058923265594) tdSql.checkData(66, 7, datetime.datetime(2020, 10, 1, 0, 16)) @@ -3878,7 +3918,7 @@ class TDTestCase: tdSql.checkData(67, 1, -0.750987246771676) tdSql.checkData(67, 2, 0.5481819942730298) tdSql.checkData(67, 3, 3.102748784455539) - tdSql.checkData(67, 4, None) + tdSql.checkData(67, 4, nan) tdSql.checkData(67, 5, 0.8513297604701857) tdSql.checkData(67, 6, 3.852058923265594) tdSql.checkData(67, 7, datetime.datetime(2020, 10, 1, 0, 16)) @@ -3886,7 +3926,7 @@ class TDTestCase: tdSql.checkData(68, 1, -0.9613974918795568) tdSql.checkData(68, 2, 0.9130208165623314) tdSql.checkData(68, 3, 2.1554866011151765) - tdSql.checkData(68, 4, None) + tdSql.checkData(68, 4, nan) tdSql.checkData(68, 5, 0.9521751875546269) tdSql.checkData(68, 6, 1.1559749749986195) tdSql.checkData(68, 7, datetime.datetime(2020, 10, 1, 0, 15)) @@ -3894,7 +3934,7 @@ class TDTestCase: tdSql.checkData(69, 1, -0.9613974918795568) tdSql.checkData(69, 2, 0.9130208165623314) tdSql.checkData(69, 3, 2.1554866011151765) - tdSql.checkData(69, 4, None) + tdSql.checkData(69, 4, nan) tdSql.checkData(69, 5, 0.9521751875546269) tdSql.checkData(69, 6, 1.1559749749986195) tdSql.checkData(69, 7, datetime.datetime(2020, 10, 1, 0, 15)) @@ -3902,7 +3942,7 @@ class TDTestCase: tdSql.checkData(70, 1, -0.2879033166650653) tdSql.checkData(70, 2, 0.859465627274523) tdSql.checkData(70, 3, 0.5636905248139659) - tdSql.checkData(70, 4, None) + tdSql.checkData(70, 4, nan) tdSql.checkData(70, 5, 0.41142163587369207) tdSql.checkData(70, 6, 10.515512404402676) tdSql.checkData(70, 7, datetime.datetime(2020, 10, 1, 0, 14)) @@ -3910,7 +3950,7 @@ class TDTestCase: tdSql.checkData(71, 1, -0.2879033166650653) tdSql.checkData(71, 2, 0.859465627274523) tdSql.checkData(71, 3, 0.5636905248139659) - tdSql.checkData(71, 4, None) + tdSql.checkData(71, 4, nan) tdSql.checkData(71, 5, 0.41142163587369207) tdSql.checkData(71, 6, 10.515512404402676) tdSql.checkData(71, 7, datetime.datetime(2020, 10, 1, 0, 14)) @@ -3918,7 +3958,7 @@ class TDTestCase: tdSql.checkData(72, 1, 0.6502878401571168) tdSql.checkData(72, 2, 0.5403105467456532) tdSql.checkData(72, 3, 2.75535470715349) - tdSql.checkData(72, 4, None) + tdSql.checkData(72, 4, nan) tdSql.checkData(72, 5, 0.0009616202598659029) tdSql.checkData(72, 6, 4.225579583416092) tdSql.checkData(72, 7, datetime.datetime(2020, 10, 1, 0, 13)) @@ -3926,7 +3966,7 @@ class TDTestCase: tdSql.checkData(73, 1, 0.6502878401571168) tdSql.checkData(73, 2, 0.5403105467456532) tdSql.checkData(73, 3, 2.75535470715349) - tdSql.checkData(73, 4, None) + tdSql.checkData(73, 4, nan) tdSql.checkData(73, 5, 0.0009616202598659029) tdSql.checkData(73, 6, 4.225579583416092) tdSql.checkData(73, 7, datetime.datetime(2020, 10, 1, 0, 13)) @@ -3934,7 +3974,7 @@ class TDTestCase: tdSql.checkData(74, 1, 0.9906073556948704) tdSql.checkData(74, 2, 0.8556343548213666) tdSql.checkData(74, 3, 2.451594361777497) - tdSql.checkData(74, 4, None) + tdSql.checkData(74, 4, nan) tdSql.checkData(74, 5, 0.24838494428124291) tdSql.checkData(74, 6, 1.4585617093317953) tdSql.checkData(74, 7, datetime.datetime(2020, 10, 1, 0, 12)) @@ -3942,7 +3982,7 @@ class TDTestCase: tdSql.checkData(75, 1, 0.9906073556948704) tdSql.checkData(75, 2, 0.8556343548213666) tdSql.checkData(75, 3, 2.451594361777497) - tdSql.checkData(75, 4, None) + tdSql.checkData(75, 4, nan) tdSql.checkData(75, 5, 0.24838494428124291) tdSql.checkData(75, 6, 1.4585617093317953) tdSql.checkData(75, 7, datetime.datetime(2020, 10, 1, 0, 12)) @@ -3950,7 +3990,7 @@ class TDTestCase: tdSql.checkData(76, 1, 0.4201670368266409) tdSql.checkData(76, 2, 0.9162743174606308) tdSql.checkData(76, 3, 0.44272645708128566) - tdSql.checkData(76, 4, None) + tdSql.checkData(76, 4, nan) tdSql.checkData(76, 5, 0.9151372562290566) tdSql.checkData(76, 6, -222.95969776348554) tdSql.checkData(76, 7, datetime.datetime(2020, 10, 1, 0, 11)) @@ -3958,7 +3998,7 @@ class TDTestCase: tdSql.checkData(77, 1, 0.4201670368266409) tdSql.checkData(77, 2, 0.9162743174606308) tdSql.checkData(77, 3, 0.44272645708128566) - tdSql.checkData(77, 4, None) + tdSql.checkData(77, 4, nan) tdSql.checkData(77, 5, 0.9151372562290566) tdSql.checkData(77, 6, -222.95969776348554) tdSql.checkData(77, 7, datetime.datetime(2020, 10, 1, 0, 11)) @@ -3966,7 +4006,7 @@ class TDTestCase: tdSql.checkData(78, 1, -0.5365729180004349) tdSql.checkData(78, 2, 0.549226270051226) tdSql.checkData(78, 3, 2.432352856101439) - tdSql.checkData(78, 4, None) + tdSql.checkData(78, 4, nan) tdSql.checkData(78, 5, 1.2185572409879093) tdSql.checkData(78, 6, 4.561306078186714) tdSql.checkData(78, 7, datetime.datetime(2020, 10, 1, 0, 10)) @@ -3974,7 +4014,7 @@ class TDTestCase: tdSql.checkData(79, 1, -0.5365729180004349) tdSql.checkData(79, 2, 0.549226270051226) tdSql.checkData(79, 3, 2.432352856101439) - tdSql.checkData(79, 4, None) + tdSql.checkData(79, 4, nan) tdSql.checkData(79, 5, 1.2185572409879093) tdSql.checkData(79, 6, 4.561306078186714) tdSql.checkData(79, 7, datetime.datetime(2020, 10, 1, 0, 10)) @@ -3982,7 +4022,7 @@ class TDTestCase: tdSql.checkData(80, 1, -0.9999902065507035) tdSql.checkData(80, 2, 0.7918362090144786) tdSql.checkData(80, 3, 2.776612511546888) - tdSql.checkData(80, 4, None) + tdSql.checkData(80, 4, nan) tdSql.checkData(80, 5, 0.5929886271208413) tdSql.checkData(80, 6, 1.796697093786514) tdSql.checkData(80, 7, datetime.datetime(2020, 10, 1, 0, 9)) @@ -3990,7 +4030,7 @@ class TDTestCase: tdSql.checkData(81, 1, -0.9999902065507035) tdSql.checkData(81, 2, 0.7918362090144786) tdSql.checkData(81, 3, 2.776612511546888) - tdSql.checkData(81, 4, None) + tdSql.checkData(81, 4, nan) tdSql.checkData(81, 5, 0.5929886271208413) tdSql.checkData(81, 6, 1.796697093786514) tdSql.checkData(81, 7, datetime.datetime(2020, 10, 1, 0, 9)) @@ -3998,7 +4038,7 @@ class TDTestCase: tdSql.checkData(82, 1, -0.5440211108893698) tdSql.checkData(82, 2, 0.9612168045072789) tdSql.checkData(82, 3, 0.5787344727995947) - tdSql.checkData(82, 4, None) + tdSql.checkData(82, 4, nan) tdSql.checkData(82, 5, -0.7199655182148126) tdSql.checkData(82, 6, -4.087614771885445) tdSql.checkData(82, 7, datetime.datetime(2020, 10, 1, 0, 8)) @@ -4006,7 +4046,7 @@ class TDTestCase: tdSql.checkData(83, 1, -0.5440211108893698) tdSql.checkData(83, 2, 0.9612168045072789) tdSql.checkData(83, 3, 0.5787344727995947) - tdSql.checkData(83, 4, None) + tdSql.checkData(83, 4, nan) tdSql.checkData(83, 5, -0.7199655182148126) tdSql.checkData(83, 6, -4.087614771885445) tdSql.checkData(83, 7, datetime.datetime(2020, 10, 1, 0, 8)) @@ -4014,7 +4054,7 @@ class TDTestCase: tdSql.checkData(84, 1, 0.4121184852417566) tdSql.checkData(84, 2, 0.574400879193934) tdSql.checkData(84, 3, 2.137595835197328) - tdSql.checkData(84, 4, None) + tdSql.checkData(84, 4, nan) tdSql.checkData(84, 5, -1.8119088619792247) tdSql.checkData(84, 6, 4.862055338419189) tdSql.checkData(84, 7, datetime.datetime(2020, 10, 1, 0, 7)) @@ -4022,7 +4062,7 @@ class TDTestCase: tdSql.checkData(85, 1, 0.4121184852417566) tdSql.checkData(85, 2, 0.574400879193934) tdSql.checkData(85, 3, 2.137595835197328) - tdSql.checkData(85, 4, None) + tdSql.checkData(85, 4, nan) tdSql.checkData(85, 5, -1.8119088619792247) tdSql.checkData(85, 6, 4.862055338419189) tdSql.checkData(85, 7, datetime.datetime(2020, 10, 1, 0, 7)) @@ -4030,7 +4070,7 @@ class TDTestCase: tdSql.checkData(86, 1, 0.9893582466233818) tdSql.checkData(86, 2, 0.7270351311688125) tdSql.checkData(86, 3, 3.1243204798042576) - tdSql.checkData(86, 4, None) + tdSql.checkData(86, 4, nan) tdSql.checkData(86, 5, -1.8696882565721156) tdSql.checkData(86, 6, 2.172420890614816) tdSql.checkData(86, 7, datetime.datetime(2020, 10, 1, 0, 6)) @@ -4038,7 +4078,7 @@ class TDTestCase: tdSql.checkData(87, 1, 0.9893582466233818) tdSql.checkData(87, 2, 0.7270351311688125) tdSql.checkData(87, 3, 3.1243204798042576) - tdSql.checkData(87, 4, None) + tdSql.checkData(87, 4, nan) tdSql.checkData(87, 5, -1.8696882565721156) tdSql.checkData(87, 6, 2.172420890614816) tdSql.checkData(87, 7, datetime.datetime(2020, 10, 1, 0, 6)) @@ -4046,7 +4086,7 @@ class TDTestCase: tdSql.checkData(88, 1, 0.6569865987187891) tdSql.checkData(88, 2, 0.9900590857598653) tdSql.checkData(88, 3, 0.8864495743441427) - tdSql.checkData(88, 4, None) + tdSql.checkData(88, 4, nan) tdSql.checkData(88, 5, -0.876294736008743) tdSql.checkData(88, 6, -0.9245361171359558) tdSql.checkData(88, 7, datetime.datetime(2020, 10, 1, 0, 5)) @@ -4054,7 +4094,7 @@ class TDTestCase: tdSql.checkData(89, 1, 0.6569865987187891) tdSql.checkData(89, 2, 0.9900590857598653) tdSql.checkData(89, 3, 0.8864495743441427) - tdSql.checkData(89, 4, None) + tdSql.checkData(89, 4, nan) tdSql.checkData(89, 5, -0.876294736008743) tdSql.checkData(89, 6, -0.9245361171359558) tdSql.checkData(89, 7, datetime.datetime(2020, 10, 1, 0, 5)) @@ -4062,7 +4102,7 @@ class TDTestCase: tdSql.checkData(90, 1, -0.27941549819892586) tdSql.checkData(90, 2, 0.6143002821164822) tdSql.checkData(90, 3, 1.853464438509776) - tdSql.checkData(90, 4, None) + tdSql.checkData(90, 4, nan) tdSql.checkData(90, 5, 0.38234027607634785) tdSql.checkData(90, 6, 5.147179528972959) tdSql.checkData(90, 7, datetime.datetime(2020, 10, 1, 0, 4)) @@ -4070,7 +4110,7 @@ class TDTestCase: tdSql.checkData(91, 1, -0.27941549819892586) tdSql.checkData(91, 2, 0.6143002821164822) tdSql.checkData(91, 3, 1.853464438509776) - tdSql.checkData(91, 4, None) + tdSql.checkData(91, 4, nan) tdSql.checkData(91, 5, 0.38234027607634785) tdSql.checkData(91, 6, 5.147179528972959) tdSql.checkData(91, 7, datetime.datetime(2020, 10, 1, 0, 4)) @@ -4078,7 +4118,7 @@ class TDTestCase: tdSql.checkData(92, 1, -0.9589242746631385) tdSql.checkData(92, 2, 0.6663667453928805) tdSql.checkData(92, 3, 3.4288753232277074) - tdSql.checkData(92, 4, None) + tdSql.checkData(92, 4, nan) tdSql.checkData(92, 5, 1.0087371784424417) tdSql.checkData(92, 6, 2.5780379587267963) tdSql.checkData(92, 7, datetime.datetime(2020, 10, 1, 0, 3)) @@ -4086,7 +4126,7 @@ class TDTestCase: tdSql.checkData(93, 1, -0.9589242746631385) tdSql.checkData(93, 2, 0.6663667453928805) tdSql.checkData(93, 3, 3.4288753232277074) - tdSql.checkData(93, 4, None) + tdSql.checkData(93, 4, nan) tdSql.checkData(93, 5, 1.0087371784424417) tdSql.checkData(93, 6, 2.5780379587267963) tdSql.checkData(93, 7, datetime.datetime(2020, 10, 1, 0, 3)) @@ -4094,7 +4134,7 @@ class TDTestCase: tdSql.checkData(94, 1, -0.7568024953079282) tdSql.checkData(94, 2, 1.0) tdSql.checkData(94, 3, 1.2340302976078754) - tdSql.checkData(94, 4, None) + tdSql.checkData(94, 4, nan) tdSql.checkData(94, 5, 0.7554222939559553) tdSql.checkData(94, 6, 0.05815764143055291) tdSql.checkData(94, 7, datetime.datetime(2020, 10, 1, 0, 2)) @@ -4102,7 +4142,7 @@ class TDTestCase: tdSql.checkData(95, 1, -0.7568024953079282) tdSql.checkData(95, 2, 1.0) tdSql.checkData(95, 3, 1.2340302976078754) - tdSql.checkData(95, 4, None) + tdSql.checkData(95, 4, nan) tdSql.checkData(95, 5, 0.7554222939559553) tdSql.checkData(95, 6, 0.05815764143055291) tdSql.checkData(95, 7, datetime.datetime(2020, 10, 1, 0, 2)) @@ -4112,7 +4152,7 @@ class TDTestCase: tdSql.checkData(96, 3, 1.558041126155035) tdSql.checkData(96, 4, 1.8325957145940461) tdSql.checkData(96, 5, 0.17204223631998083) - tdSql.checkData(96, 6, None) + tdSql.checkData(96, 6, nan) tdSql.checkData(96, 7, datetime.datetime(2020, 10, 1, 0, 1)) tdSql.checkData(97, 0, 1) tdSql.checkData(97, 1, 0.1411200080598672) @@ -4120,34 +4160,36 @@ class TDTestCase: tdSql.checkData(97, 3, 1.558041126155035) tdSql.checkData(97, 4, 1.8325957145940461) tdSql.checkData(97, 5, 0.17204223631998083) - tdSql.checkData(97, 6, None) + tdSql.checkData(97, 6, nan) tdSql.checkData(97, 7, datetime.datetime(2020, 10, 1, 0, 1)) tdSql.checkData(98, 0, 0) tdSql.checkData(98, 1, 0.7780731968879212) tdSql.checkData(98, 2, 0.6143002821164822) tdSql.checkData(98, 3, 3.2037266279837113) - tdSql.checkData(98, 4, None) + tdSql.checkData(98, 4, nan) tdSql.checkData(98, 5, 0.02246988233490299) - tdSql.checkData(98, 6, None) + tdSql.checkData(98, 6, nan) tdSql.checkData(98, 7, datetime.datetime(2020, 10, 1, 0, 0)) tdSql.checkData(99, 0, 0) tdSql.checkData(99, 1, 0.7780731968879212) tdSql.checkData(99, 2, 0.6143002821164822) tdSql.checkData(99, 3, 3.2037266279837113) - tdSql.checkData(99, 4, None) + tdSql.checkData(99, 4, nan) tdSql.checkData(99, 5, 0.02246988233490299) - tdSql.checkData(99, 6, None) + tdSql.checkData(99, 6, nan) tdSql.checkData(99, 7, datetime.datetime(2020, 10, 1, 0, 0)) - tdSql.query('select * from (select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6, ts from ct1 order by ts limit 2);;') + tdSql.query( + "select * from (select c1, sin(c2+2), cos(sin(c1-2)), tan(cos(c2*2))+2, asin(acos(c2%3))+acos(c3/2)+atan(c5*c2) as v4, sin(c4+4.5)+cos(c3/2), tan(c1)+log(c3, c4)+sin(c6+c3)+2 as v6, ts from ct1 order by ts limit 2);;" + ) tdSql.checkRows(2) tdSql.checkData(0, 0, 0) tdSql.checkData(0, 1, 0.7780731968879212) tdSql.checkData(0, 2, 0.6143002821164822) tdSql.checkData(0, 3, 3.2037266279837113) - tdSql.checkData(0, 4, None) + tdSql.checkData(0, 4, nan) tdSql.checkData(0, 5, 0.02246988233490299) - tdSql.checkData(0, 6, None) + tdSql.checkData(0, 6, nan) tdSql.checkData(0, 7, datetime.datetime(2020, 10, 1, 0, 0)) tdSql.checkData(1, 0, 1) tdSql.checkData(1, 1, 0.1411200080598672) @@ -4155,13 +4197,15 @@ class TDTestCase: tdSql.checkData(1, 3, 1.558041126155035) tdSql.checkData(1, 4, 1.8325957145940461) tdSql.checkData(1, 5, 0.17204223631998083) - tdSql.checkData(1, 6, None) + tdSql.checkData(1, 6, nan) tdSql.checkData(1, 7, datetime.datetime(2020, 10, 1, 0, 1)) - tdSql.execute('drop database db0') + tdSql.execute("drop database db0") + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) + tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/develop-test/3-connectors/TypeScript-REST/test.sh b/tests/develop-test/3-connectors/TypeScript-REST/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..18124644b6dc25779780a7e1956e2864aa021ebf --- /dev/null +++ b/tests/develop-test/3-connectors/TypeScript-REST/test.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +function stopProcess { + echo "Stop $1" + sudo systemctl stop $1 || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w $1 | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x $1 + sleep 1 + PID=`ps -ef|grep -w $1 | grep -v grep | awk '{print $2}'` + done +} + +stopProcess taosadapter +stopProcess taosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* + +nohup taosd > /dev/null 2>&1 & +nohup taosadapter > /dev/null 2>&1 & +sleep 10 + +# echo `pwd` +cd ../../ +WKC=`pwd` +echo ${WKC} +cd ${WKC}/src/connector/TypeScript-REST + +# test source code +npm install +npm run example +# npm run test + +# test published npm package td2.0-rest-connecto +cd ${WKC}/tests/examples/TypeScript-REST +npm install +npm run test + + diff --git a/tests/develop-test/3-connectors/c#/test.sh b/tests/develop-test/3-connectors/c#/test.sh index 75a55fb41be3cd96c24bebfe93b209b13c3d3df8..8cfb3fe4fcff6ab820b53698e508189e557676ca 100755 --- a/tests/develop-test/3-connectors/c#/test.sh +++ b/tests/develop-test/3-connectors/c#/test.sh @@ -19,8 +19,13 @@ cd ../../ WKC=`pwd` cd ${WKC}/src/connector/C# dotnet test +# run example under Driver +cd ${WKC}/src/connector/C#/examples +dotnet run + #dotnet run --project src/test/Cases/Cases.csproj +# run example with neuget package cd ${WKC}/tests/examples/C# dotnet run --project C#checker/C#checker.csproj dotnet run --project TDengineTest/TDengineTest.csproj diff --git a/docs-cn/04-connect/_connect_node.mdx b/tests/develop-test/3-connectors/php/.gitkeep similarity index 100% rename from docs-cn/04-connect/_connect_node.mdx rename to tests/develop-test/3-connectors/php/.gitkeep diff --git a/tests/develop-test/3-connectors/php/test.sh b/tests/develop-test/3-connectors/php/test.sh new file mode 100755 index 0000000000000000000000000000000000000000..ec58df121fa267ec6640e682156016f42cbd7064 --- /dev/null +++ b/tests/develop-test/3-connectors/php/test.sh @@ -0,0 +1,24 @@ +#!/bin/bash +function stopTaosd { + echo "Stop taosd" + sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + while [ -n "$PID" ] + do + pkill -TERM -x taosd + sleep 1 + PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` + done +} +stopTaosd +rm -rf /var/lib/taos/* +rm -rf /var/log/taos/* +nohup taosd -c /etc/taos/ > /dev/null 2>&1 & +sleep 10 +cd ../../ +WKC=`pwd` + +git clone https://github.com/Yurunsoft/php-tdengine.git +cd php-tdengine +./make.sh +./run-tests.sh diff --git a/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py new file mode 100644 index 0000000000000000000000000000000000000000..33ba4034ec07925574c5c8bd23a2d7951010980c --- /dev/null +++ b/tests/develop-test/5-taos-tools/taosdump/taosdumpTestInspect.py @@ -0,0 +1,123 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import sys +import os +from util.log import * +from util.cases import * +from util.sql import * +from util.dnodes import * +import subprocess + + +class TDTestCase: + def caseDescription(self): + ''' + case1: [TD-14544] taosdump data inspect + ''' + return + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.tmpdir = "tmp" + + def getPath(self, tool="taosdump"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + if (len(paths) == 0): + return "" + return paths[0] + + def run(self): + tdSql.prepare() + + tdSql.execute("drop database if exists db") + tdSql.execute("create database db days 11 keep 3649 blocks 8 ") + + tdSql.execute("use db") + tdSql.execute( + "create table st(ts timestamp, c1 INT, c2 BOOL, c3 TINYINT, c4 SMALLINT, c5 BIGINT, c6 FLOAT, c7 DOUBLE, c8 TIMESTAMP, c9 BINARY(10), c10 NCHAR(10), c11 TINYINT UNSIGNED, c12 SMALLINT UNSIGNED, c13 INT UNSIGNED, c14 BIGINT UNSIGNED) tags(n1 INT, w2 BOOL, t3 TINYINT, t4 SMALLINT, t5 BIGINT, t6 FLOAT, t7 DOUBLE, t8 TIMESTAMP, t9 BINARY(10), t10 NCHAR(10), t11 TINYINT UNSIGNED, t12 SMALLINT UNSIGNED, t13 INT UNSIGNED, t14 BIGINT UNSIGNED)") + tdSql.execute( + "create table t1 using st tags(1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)") + tdSql.execute( + "insert into t1 values(1640000000000, 1, true, 1, 1, 1, 1.0, 1.0, 1, '1', '一', 1, 1, 1, 1)") + tdSql.execute( + "create table t2 using st tags(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)") + tdSql.execute( + "insert into t2 values(1640000000000, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)") + +# sys.exit(1) + + binPath = self.getPath("taosdump") + if (binPath == ""): + tdLog.exit("taosdump not found!") + else: + tdLog.info("taosdump found in %s" % binPath) + + if not os.path.exists(self.tmpdir): + os.makedirs(self.tmpdir) + else: + print("directory exists") + os.system("rm -rf %s" % self.tmpdir) + os.makedirs(self.tmpdir) + + os.system( + "%s --databases db -o %s -T 1" % + (binPath, self.tmpdir)) + +# sys.exit(1) + + taosdumpInspectCmd = "%s -I %s/*.avro* -s | grep 'Schema:'|wc -l" % ( + binPath, self.tmpdir) + schemaTimes = subprocess.check_output( + taosdumpInspectCmd, shell=True).decode("utf-8") + print("schema found times: %d" % int(schemaTimes)) + + if (int(schemaTimes) != 3): + caller = inspect.getframeinfo(inspect.stack()[0][0]) + tdLog.exit( + "%s(%d) failed: expected schema found times 3, actual %d" % + (caller.filename, caller.lineno, int(schemaTimes))) + + taosdumpInspectCmd = "%s -I %s/*.avro* | grep '=== Records:'|wc -l" % ( + binPath, self.tmpdir) + recordsTimes = subprocess.check_output( + taosdumpInspectCmd, shell=True).decode("utf-8") + print("records found times: %d" % int(recordsTimes)) + + if (int(recordsTimes) != 3): + caller = inspect.getframeinfo(inspect.stack()[0][0]) + tdLog.exit( + "%s(%d) failed: expected records found times 3, actual %d" % + (caller.filename, caller.lineno, int(recordsTimes))) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/docs-examples-test/test_R.sh b/tests/docs-examples-test/test_R.sh new file mode 100755 index 0000000000000000000000000000000000000000..8d2db4546f47f55a61f2a96d37ec7d4dbd725a5b --- /dev/null +++ b/tests/docs-examples-test/test_R.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +pgrep taosd || taosd >> /dev/null 2>&1 & +pgrep taosadapter || taosadapter >> /dev/null 2>&1 & + +cd ../../docs-examples/R + +jar_path=`find ../../../debug/build -name taos-jdbcdriver-*-dist.jar` +echo jar_path=$jar_path +R -f connect_native.r --args $jar_path +# R -f connect_rest.r --args $jar_path # bug 14704 + diff --git a/tests/docs-examples-test/test_c.sh b/tests/docs-examples-test/test_c.sh new file mode 100755 index 0000000000000000000000000000000000000000..2d47eff585b26659cb90a1669317efe074f1adde --- /dev/null +++ b/tests/docs-examples-test/test_c.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e + +taosd >> /dev/null 2>&1 & +taosadapter >> /dev/null 2>&1 & + +cd ../../docs-examples/c + +# 1 +gcc connect_example.c -o connect_example -ltaos +./connect_example + +# 2 +taos -s "drop database if exists power" +gcc -o insert_example insert_example.c -ltaos +./insert_example + +gcc -o async_query_example async_query_example.c -ltaos +./async_query_example + +# 3 +taos -s "drop database if exists power" +gcc -o stmt_example stmt_example.c -ltaos +./stmt_example + +# 4 +taos -s "drop database if exists power" +gcc -o multi_bind_example multi_bind_example.c -ltaos +./multi_bind_example + +# 5 +gcc -o query_example query_example.c -ltaos +./query_example + +# 6 +taos -s "drop database if exists test" +gcc -o line_example line_example.c -ltaos +./line_example + +# 7 +taos -s "drop database if exists test" +gcc -o telnet_line_example telnet_line_example.c -ltaos +./telnet_line_example + +# 8 +taos -s "drop database if exists test" +gcc -o json_protocol_example json_protocol_example.c -ltaos +./json_protocol_example + diff --git a/tests/docs-examples-test/test_csharp.sh b/tests/docs-examples-test/test_csharp.sh new file mode 100755 index 0000000000000000000000000000000000000000..64d28d945f811db160c073643262f766e67fa59b --- /dev/null +++ b/tests/docs-examples-test/test_csharp.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +pgrep taosd || taosd >> /dev/null 2>&1 & +pgrep taosadapter || taosadapter >> /dev/null 2>&1 & +cd ../../docs-examples/csharp + +dotnet run --project connect.csproj + +taos -s "drop database if exists power" +dotnet run --project sqlinsert.csproj +dotnet run --project query.csproj +dotnet run --project asyncquery.csproj + +taos -s "drop database if exists power" +dotnet run --project stmtinsert.csproj + +taos -s "drop database if exists test" +dotnet run --project influxdbline.csproj + +taos -s "drop database if exists test" +dotnet run --project optstelnet.csproj + +taos -s "drop database if exists test" +dotnet run --project optsjson.csproj diff --git a/tests/docs-examples-test/test_go.sh b/tests/docs-examples-test/test_go.sh new file mode 100755 index 0000000000000000000000000000000000000000..d959d8c1ed646a130b5ffd8c3387e7abe965621e --- /dev/null +++ b/tests/docs-examples-test/test_go.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e + +taosd >> /dev/null 2>&1 & +taosadapter >> /dev/null 2>&1 & + +cd ../../docs-examples/go + +go mod tidy + +go run ./connect/restexample/main.go + +taos -s "drop database if exists power" +go run ./insert/sql/main.go + +taos -s "drop database if exists power" +go run ./insert/stmt/main.go + +taos -s "drop database if exists test" +go run ./insert/line/main.go + +taos -s "drop database if exists test" +go run ./insert/telnet/main.go + +taos -s "drop database if exists test" +go run ./insert/json/main.go + +go run ./query/sync/main.go diff --git a/tests/docs-examples-test/test_java.sh b/tests/docs-examples-test/test_java.sh new file mode 100755 index 0000000000000000000000000000000000000000..0e8e8266a18e3c1e403750f4a33c0fb765f8030f --- /dev/null +++ b/tests/docs-examples-test/test_java.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +taosd >> /dev/null 2>&1 & +taosadapter >> /dev/null 2>&1 & +cd ../../docs-examples/java + +mvn test \ No newline at end of file diff --git a/tests/docs-examples-test/test_node.sh b/tests/docs-examples-test/test_node.sh new file mode 100755 index 0000000000000000000000000000000000000000..14aab236f9f96b372f864384adf92cbc9c55559f --- /dev/null +++ b/tests/docs-examples-test/test_node.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e + +pgrep taosd || taosd >> /dev/null 2>&1 & +pgrep taosadapter || taosadapter >> /dev/null 2>&1 & + +cd ../../docs-examples/node + +npm install +cd restexample; + +node connect.js + +cd ../nativeexample + +node connect.js + +taos -s "drop database if exists power" +node insert_example.js + +node query_example.js + +taos -s "drop database if exists power" +node param_bind_example.js + +taos -s "drop database if exists power" +node multi_bind_example.js + +taos -s "drop database if exists test" +node influxdb_line_example.js + +taos -s "drop database if exists test" +node opentsdb_telnet_example.js + +taos -s "drop database if exists test" +node opentsdb_json_example.js diff --git a/tests/docs-examples-test/test_python.sh b/tests/docs-examples-test/test_python.sh new file mode 100755 index 0000000000000000000000000000000000000000..e145f1bd6dbb811c9888a51b912e14b01dd14a15 --- /dev/null +++ b/tests/docs-examples-test/test_python.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +set -e + +taosd >> /dev/null 2>&1 & +taosadapter >> /dev/null 2>&1 & + +cd ../../docs-examples/python + +# 1 +taos -s "create database if not exists log" +python3 connect_exmaple.py + +# 2 +taos -s "drop database if exists power" +python3 native_insert_example.py + +# 3 +taos -s "drop database power" +python3 bind_param_example.py + +# 4 +taos -s "drop database power" +python3 multi_bind_example.py + +# 5 +python3 query_example.py + +# 6 +python3 async_query_example.py + +# 7 +taos -s "drop database if exists test" +python3 line_protocol_example.py + +# 8 +taos -s "drop database test" +python3 telnet_line_protocol_example.py + +# 9 +taos -s "drop database test" +python3 json_protocol_example.py + +# 10 +python3 subscribe_demo.py + + diff --git a/tests/docs-examples-test/test_rust.sh b/tests/docs-examples-test/test_rust.sh new file mode 100755 index 0000000000000000000000000000000000000000..6bf0fe457af81d577cbc33c6a809717847b40c86 --- /dev/null +++ b/tests/docs-examples-test/test_rust.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e + +pgrep taosd || taosd >> /dev/null 2>&1 & +pgrep taosadapter || taosadapter >> /dev/null 2>&1 & + +cd ../../docs-examples/rust + +cargo run -p nativeexample --example connect +cargo run -p restexample --example connect + +taos -s "drop database if exists power" +cargo run -p restexample --example insert_example + +cargo run -p restexample --example query_example + + +taos -s "drop database if exists power" +cargo run -p nativeexample --example stmt_example + +taos -s "drop database if exists test" +cargo run -p schemalessexample --example influxdb_line_example + +taos -s "drop database if exists test" +cargo run -p schemalessexample --example opentsdb_telnet_example + +taos -s "drop database if exists test" +cargo run -p schemalessexample --example opentsdb_json_example \ No newline at end of file diff --git a/tests/examples/C#/.gitignore b/tests/examples/C#/.gitignore deleted file mode 100644 index 2a959a77c900524f996f3214446d37f34026c6e4..0000000000000000000000000000000000000000 --- a/tests/examples/C#/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -C#checker/bin/ -C#checker/obj/ -TDengineTest/bin/ -TDengineTest/obj/ -schemaless/bin/ -schemaless/obj/ -stmt/TDengineDriver.cs -stmt/TaosBind.cs -stmt/TaosMultiBind.cs -stmt/bin/ -stmt/obj/ -taosdemo/bin/ -taosdemo/obj/ -jsonTag/bin/ -jsonTag/obj/ -insertCn/bin/ -insertCn/obj/ \ No newline at end of file diff --git a/tests/examples/C#/C#checker/C#checker.cs b/tests/examples/C#/C#checker/C#checker.cs deleted file mode 100644 index 29ad290343bb4fbacade48a0b59e0350bd35f213..0000000000000000000000000000000000000000 --- a/tests/examples/C#/C#checker/C#checker.cs +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -using System; -using System.Text; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Collections; - -namespace TDengineDriver -{ - class TDengineTest - { - //connect parameters - private string host; - private string configDir; - private string user; - private string password; - private short port = 0; - - //sql parameters - private string dbName; - private string tbName; - private string precision; - - private bool isInsertData; - private bool isQueryData; - - private long tableCount; - private long totalRows; - private long batchRows; - private long beginTimestamp = 1551369600000L; - - private IntPtr conn = IntPtr.Zero; - private long rowsInserted = 0; - - static void Main(string[] args) - { - TDengineTest tester = new TDengineTest(); - tester.ReadArgument(args); - - - tester.InitTDengine(); - tester.ConnectTDengine(); - tester.createDatabase(); - tester.useDatabase(); - tester.checkDropTable(); - tester.createTable(); - tester.checkInsert(); - tester.checkSelect(); - tester.checkDropTable(); - tester.dropDatabase(); - tester.CloseConnection(); - tester.cleanup(); - - - } - - public long GetArgumentAsLong(String[] argv, String argName, int minVal, int maxVal, int defaultValue) - { - int argc = argv.Length; - for (int i = 0; i < argc; ++i) - { - if (argName != argv[i]) - { - continue; - } - if (i < argc - 1) - { - String tmp = argv[i + 1]; - if (tmp[0] == '-') - { - Console.WriteLine("option {0:G} requires an argument", tmp); - ExitProgram(); - } - - long tmpVal = Convert.ToInt64(tmp); - if (tmpVal < minVal || tmpVal > maxVal) - { - Console.WriteLine("option {0:G} should in range [{1:G}, {2:G}]", argName, minVal, maxVal); - ExitProgram(); - } - - return tmpVal; - } - } - - return defaultValue; - } - - public String GetArgumentAsString(String[] argv, String argName, String defaultValue) - { - int argc = argv.Length; - for (int i = 0; i < argc; ++i) - { - if (argName != argv[i]) - { - continue; - } - if (i < argc - 1) - { - String tmp = argv[i + 1]; - if (tmp[0] == '-') - { - Console.WriteLine("option {0:G} requires an argument", tmp); - ExitProgram(); - } - return tmp; - } - } - - return defaultValue; - } - - public void PrintHelp(String[] argv) - { - for (int i = 0; i < argv.Length; ++i) - { - if ("--help" == argv[i]) - { - String indent = " "; - Console.WriteLine("taosTest is simple example to operate TDengine use C# Language.\n"); - Console.WriteLine("{0:G}{1:G}", indent, "-h"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDEngine server IP address to connect"); - Console.WriteLine("{0:G}{1:G}", indent, "-u"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is root"); - Console.WriteLine("{0:G}{1:G}", indent, "-p"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is taosdata"); - Console.WriteLine("{0:G}{1:G}", indent, "-d"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Database used to create table or import data, default is db"); - Console.WriteLine("{0:G}{1:G}", indent, "-s"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Super Tables used to create table, default is mt"); - Console.WriteLine("{0:G}{1:G}", indent, "-t"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Table prefixs, default is t"); - Console.WriteLine("{0:G}{1:G}", indent, "-w"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to insert data"); - Console.WriteLine("{0:G}{1:G}", indent, "-r"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to query data"); - Console.WriteLine("{0:G}{1:G}", indent, "-n"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many Tables to create, default is 10"); - Console.WriteLine("{0:G}{1:G}", indent, "-b"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows per insert batch, default is 10"); - Console.WriteLine("{0:G}{1:G}", indent, "-i"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows to insert, default is 100"); - Console.WriteLine("{0:G}{1:G}", indent, "-c"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configuration directory"); - // - Console.WriteLine("{0:G}{1:G}", indent, "-ps"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configurate db precision,default millisecond"); - ExitProgram(); - } - } - } - - public void ReadArgument(String[] argv) - { - PrintHelp(argv); - host = this.GetArgumentAsString(argv, "-h", "127.0.0.1"); - user = this.GetArgumentAsString(argv, "-u", "root"); - password = this.GetArgumentAsString(argv, "-p", "taosdata"); - dbName = this.GetArgumentAsString(argv, "-d", "test"); - tbName = this.GetArgumentAsString(argv, "-s", "weather"); - precision = this.GetArgumentAsString(argv, "-ps", "ms"); - isInsertData = this.GetArgumentAsLong(argv, "-w", 0, 1, 1) != 0; - isQueryData = this.GetArgumentAsLong(argv, "-r", 0, 1, 1) != 0; - tableCount = this.GetArgumentAsLong(argv, "-n", 1, 10000, 10); - batchRows = this.GetArgumentAsLong(argv, "-b", 1, 1000, 500); - totalRows = this.GetArgumentAsLong(argv, "-i", 1, 10000000, 10000); - configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg"); - } - - public void InitTDengine() - { - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - Console.WriteLine("init..."); - TDengine.Init(); - Console.WriteLine("get connection starting..."); - } - - public void ConnectTDengine() - { - string db = ""; - this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port); - if (this.conn == IntPtr.Zero) - { - Console.WriteLine("connection failed: " + this.host); - ExitProgram(); - } - else - { - Console.WriteLine("[ OK ] Connection established."); - } - } - public void createDatabase() - { - StringBuilder sql = new StringBuilder(); - sql.Append("create database if not exists ").Append(this.dbName).Append(" precision '").Append(this.precision).Append("'"); - execute(sql.ToString()); - } - public void useDatabase() - { - StringBuilder sql = new StringBuilder(); - sql.Append("use ").Append(this.dbName); - execute(sql.ToString()); - } - public void checkSelect() - { - StringBuilder sql = new StringBuilder(); - sql.Append("select * from ").Append(this.dbName).Append(".").Append(this.tbName); - ExecuteQuery(sql.ToString()); - } - public void createTable() - { - StringBuilder sql = new StringBuilder(); - sql.Append("create table if not exists ").Append(this.dbName).Append(".").Append(this.tbName).Append("(ts timestamp, temperature float, humidity int)"); - execute(sql.ToString()); - } - public void checkInsert() - { - StringBuilder sql = new StringBuilder(); - sql.Append("insert into ").Append(this.dbName).Append(".").Append(this.tbName).Append("(ts, temperature, humidity) values(now, 20.5, 34)"); - execute(sql.ToString()); - } - public void checkDropTable() - { - StringBuilder sql = new StringBuilder(); - sql.Append("drop table if exists ").Append(this.dbName).Append(".").Append(this.tbName).Append(""); - execute(sql.ToString()); - } - public void dropDatabase() - { - StringBuilder sql = new StringBuilder(); - sql.Append("drop database if exists ").Append(this.dbName); - execute(sql.ToString()); - } - public void execute(string sql) - { - DateTime dt1 = DateTime.Now; - IntPtr res = TDengine.Query(this.conn, sql.ToString()); - DateTime dt2 = DateTime.Now; - TimeSpan span = dt2 - dt1; - - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - TDengine.FreeResult(res); - } - - public void ExecuteQuery(string sql) - { - - DateTime dt1 = DateTime.Now; - long queryRows = 0; - IntPtr res = TDengine.Query(conn, sql); - getPrecision(res); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - DateTime dt2 = DateTime.Now; - TimeSpan span = dt2 - dt1; - Console.WriteLine("[OK] time cost: " + span.ToString() + "ms, execute statement ====> " + sql.ToString()); - int fieldCount = TDengine.FieldCount(res); - - List metas = TDengine.FetchFields(res); - for (int j = 0; j < metas.Count; j++) - { - TDengineMeta meta = (TDengineMeta)metas[j]; - } - - IntPtr rowdata; - StringBuilder builder = new StringBuilder(); - while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) - { - queryRows++; - for (int fields = 0; fields < fieldCount; ++fields) - { - TDengineMeta meta = metas[fields]; - int offset = IntPtr.Size * fields; - IntPtr data = Marshal.ReadIntPtr(rowdata, offset); - - builder.Append("---"); - - if (data == IntPtr.Zero) - { - builder.Append("NULL"); - continue; - } - - switch ((TDengineDataType)meta.type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; - builder.Append(v1); - break; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - byte v2 = Marshal.ReadByte(data); - builder.Append(v2); - break; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - short v3 = Marshal.ReadInt16(data); - builder.Append(v3); - break; - case TDengineDataType.TSDB_DATA_TYPE_INT: - int v4 = Marshal.ReadInt32(data); - builder.Append(v4); - break; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - long v5 = Marshal.ReadInt64(data); - builder.Append(v5); - break; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); - builder.Append(v6); - break; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); - builder.Append(v7); - break; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - string v8 = Marshal.PtrToStringAnsi(data); - builder.Append(v8); - break; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - long v9 = Marshal.ReadInt64(data); - builder.Append(v9); - break; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - string v10 = Marshal.PtrToStringAnsi(data); - builder.Append(v10); - break; - } - } - builder.Append("---"); - - if (queryRows <= 10) - { - Console.WriteLine(builder.ToString()); - } - builder.Clear(); - } - - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - } - Console.WriteLine(""); - - TDengine.FreeResult(res); - - } - - public void CloseConnection() - { - if (this.conn != IntPtr.Zero) - { - TDengine.Close(this.conn); - Console.WriteLine("connection closed."); - } - } - - static void ExitProgram() - { - System.Environment.Exit(0); - } - - public void cleanup() - { - Console.WriteLine("clean up..."); - System.Environment.Exit(0); - } - // method to get db precision - public void getPrecision(IntPtr res) - { - int psc=TDengine.ResultPrecision(res); - switch(psc) - { - case 0: - Console.WriteLine("db:[{0:G}]'s precision is {1:G}",this.dbName,"millisecond"); - break; - case 1: - Console.WriteLine("db:[{0:G}]'s precision is {1:G}",this.dbName,"microsecond"); - break; - case 2: - Console.WriteLine("db:[{0:G}]'s precision is {1:G}",this.dbName,"nanosecond"); - break; - } - - } - } -} diff --git a/tests/examples/C#/TDengineTest/TDengineTest.cs b/tests/examples/C#/TDengineTest/TDengineTest.cs deleted file mode 100644 index 9f84634ffb400e5d891a9fdeaeee0c013829f969..0000000000000000000000000000000000000000 --- a/tests/examples/C#/TDengineTest/TDengineTest.cs +++ /dev/null @@ -1,504 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -using System; -using System.Text; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Collections; - -namespace TDengineDriver -{ - class TDengineTest - { - //connect parameters - private string host; - private string configDir; - private string user; - private string password; - private short port = 0; - - //sql parameters - private string dbName; - private string stableName; - private string tablePrefix; - - private bool isInsertData; - private bool isQueryData; - - private long tableCount; - private long totalRows; - private long batchRows; - private long beginTimestamp = 1551369600000L; - - private IntPtr conn = IntPtr.Zero; - private long rowsInserted = 0; - - static void Main(string[] args) - { - TDengineTest tester = new TDengineTest(); - tester.ReadArgument(args); - - Console.WriteLine("---------------------------------------------------------------"); - Console.WriteLine("Starting Testing..."); - Console.WriteLine("---------------------------------------------------------------"); - - tester.InitTDengine(); - tester.ConnectTDengine(); - tester.CreateDbAndTable(); - tester.ExecuteInsert(); - tester.ExecuteQuery(); - tester.CloseConnection(); - - Console.WriteLine("---------------------------------------------------------------"); - Console.WriteLine("Stop Testing..."); - Console.WriteLine("---------------------------------------------------------------"); - - } - - public long GetArgumentAsLong(String[] argv, String argName, int minVal, int maxVal, int defaultValue) - { - int argc = argv.Length; - for (int i = 0; i < argc; ++i) - { - if (argName != argv[i]) - { - continue; - } - if (i < argc - 1) - { - String tmp = argv[i + 1]; - if (tmp[0] == '-') - { - Console.WriteLine("option {0:G} requires an argument", tmp); - ExitProgram(); - } - - long tmpVal = Convert.ToInt64(tmp); - if (tmpVal < minVal || tmpVal > maxVal) - { - Console.WriteLine("option {0:G} should in range [{1:G}, {2:G}]", argName, minVal, maxVal); - ExitProgram(); - } - - return tmpVal; - } - } - - return defaultValue; - } - - public String GetArgumentAsString(String[] argv, String argName, String defaultValue) - { - int argc = argv.Length; - for (int i = 0; i < argc; ++i) - { - if (argName != argv[i]) - { - continue; - } - if (i < argc - 1) - { - String tmp = argv[i + 1]; - if (tmp[0] == '-') - { - Console.WriteLine("option {0:G} requires an argument", tmp); - ExitProgram(); - } - return tmp; - } - } - - return defaultValue; - } - - public void PrintHelp(String[] argv) - { - for (int i = 0; i < argv.Length; ++i) - { - if ("--help" == argv[i]) - { - String indent = " "; - Console.WriteLine("taosTest is simple example to operate TDengine use C# Language.\n"); - Console.WriteLine("{0:G}{1:G}", indent, "-h"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "TDEngine server IP address to connect"); - Console.WriteLine("{0:G}{1:G}", indent, "-u"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is root"); - Console.WriteLine("{0:G}{1:G}", indent, "-p"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "The TDEngine user name to use when connecting to the server, default is taosdata"); - Console.WriteLine("{0:G}{1:G}", indent, "-d"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Database used to create table or import data, default is db"); - Console.WriteLine("{0:G}{1:G}", indent, "-s"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Super Tables used to create table, default is mt"); - Console.WriteLine("{0:G}{1:G}", indent, "-t"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Table prefixs, default is t"); - Console.WriteLine("{0:G}{1:G}", indent, "-w"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to insert data"); - Console.WriteLine("{0:G}{1:G}", indent, "-r"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Whether to query data"); - Console.WriteLine("{0:G}{1:G}", indent, "-n"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many Tables to create, default is 10"); - Console.WriteLine("{0:G}{1:G}", indent, "-b"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows per insert batch, default is 10"); - Console.WriteLine("{0:G}{1:G}", indent, "-i"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "How many rows to insert, default is 100"); - Console.WriteLine("{0:G}{1:G}", indent, "-c"); - Console.WriteLine("{0:G}{1:G}{2:G}", indent, indent, "Configuration directory"); - - ExitProgram(); - } - } - } - - public void ReadArgument(String[] argv) - { - PrintHelp(argv); - host = this.GetArgumentAsString(argv, "-h", "127.0.0.1"); - user = this.GetArgumentAsString(argv, "-u", "root"); - password = this.GetArgumentAsString(argv, "-p", "taosdata"); - dbName = this.GetArgumentAsString(argv, "-d", "tdengint_test_cs"); - stableName = this.GetArgumentAsString(argv, "-s", "st"); - tablePrefix = this.GetArgumentAsString(argv, "-t", "t"); - isInsertData = this.GetArgumentAsLong(argv, "-w", 0, 1, 1) != 0; - isQueryData = this.GetArgumentAsLong(argv, "-r", 0, 1, 1) != 0; - tableCount = this.GetArgumentAsLong(argv, "-n", 1, 10000, 10); - batchRows = this.GetArgumentAsLong(argv, "-b", 1, 1000,500 ); - totalRows = this.GetArgumentAsLong(argv, "-i", 1, 10000000, 10000); - configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg"); - } - - public void InitTDengine() - { - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - TDengine.Init(); - Console.WriteLine("TDengine Initialization finished"); - } - - public void ConnectTDengine() - { - string db = ""; - Console.WriteLine("Host:{0}", this.host); - this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port); - if (this.conn == IntPtr.Zero) - { - Console.WriteLine("Connect to TDengine failed"); - ExitProgram(); - } - else - { - Console.WriteLine("Connect to TDengine success"); - } - } - - public void CreateDbAndTable() - { - if (!this.isInsertData) - { - return; - } - - StringBuilder sql = new StringBuilder(); - sql.Append("create database if not exists ").Append(this.dbName); - IntPtr res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - TDengine.FreeResult(res); - - sql.Clear(); - sql.Append("use ").Append(this.dbName); - res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - TDengine.FreeResult(res); - - sql.Clear(); - sql.Append("create table if not exists ").Append(this.stableName).Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10)) tags(t1 int)"); - res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - TDengine.FreeResult(res); - - for (int i = 0; i < this.tableCount; i++) - { - sql.Clear(); - sql = sql.Append("create table if not exists ").Append(this.tablePrefix).Append(i) - .Append(" using ").Append(this.stableName).Append(" tags(").Append(i).Append(")"); - res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - TDengine.FreeResult(res); - } - - Console.WriteLine("create db and table success"); - } - - public void ExecuteInsert() - { - if (!this.isInsertData) - { - return; - } - - System.DateTime start = new System.DateTime(); - long loopCount = this.totalRows / this.batchRows; - - for (int table = 0; table < this.tableCount; ++table) - { - for (long loop = 0; loop < loopCount; loop++) - { - StringBuilder sql = new StringBuilder(); - sql.Append("insert into ").Append(this.tablePrefix).Append(table).Append(" values"); - for (int batch = 0; batch < this.batchRows; ++batch) - { - - long rows = loop * this.batchRows + batch; - sql.Append("(") - .Append(this.beginTimestamp + rows) - .Append(", 1, 2, 3,") - .Append(rows) - .Append(", 5, 6, 7, 'abc', 'def')"); - } - IntPtr res = TDengine.Query(this.conn,sql.ToString() ); - - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - } - - int affectRows = TDengine.AffectRows(res); - this.rowsInserted += affectRows; - - TDengine.FreeResult(res); - } - } - - System.DateTime end = new System.DateTime(); - TimeSpan ts = end - start; - - Console.Write("Total {0:G} rows inserted, {1:G} rows failed, time spend {2:G} seconds.\n" - , this.rowsInserted, this.totalRows * this.tableCount - this.rowsInserted, ts.TotalSeconds); - } - - public void ExecuteQuery() - { - if (!this.isQueryData) - { - return; - } - - System.DateTime start = new System.DateTime(); - long queryRows = 0; - - for (int i = 0; i < 1/*this.tableCount*/; ++i) - { - String sql = "select * from " + this.dbName + "." + tablePrefix + i; - Console.WriteLine(sql); - - IntPtr res = TDengine.Query(conn, sql); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - - int fieldCount = TDengine.FieldCount(res); - Console.WriteLine("field count: " + fieldCount); - - List metas = TDengine.FetchFields(res); - for (int j = 0; j < metas.Count; j++) - { - TDengineMeta meta = (TDengineMeta)metas[j]; - Console.WriteLine("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size); - } - - IntPtr rowdata; - StringBuilder builder = new StringBuilder(); - while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) - { - queryRows++; - for (int fields = 0; fields < fieldCount; ++fields) - { - TDengineMeta meta = metas[fields]; - int offset = IntPtr.Size * fields; - IntPtr data = Marshal.ReadIntPtr(rowdata, offset); - - builder.Append("---"); - - if (data == IntPtr.Zero) - { - builder.Append("NULL"); - continue; - } - - switch ((TDengineDataType)meta.type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; - builder.Append(v1); - break; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - byte v2 = Marshal.ReadByte(data); - builder.Append(v2); - break; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - short v3 = Marshal.ReadInt16(data); - builder.Append(v3); - break; - case TDengineDataType.TSDB_DATA_TYPE_INT: - int v4 = Marshal.ReadInt32(data); - builder.Append(v4); - break; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - long v5 = Marshal.ReadInt64(data); - builder.Append(v5); - break; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); - builder.Append(v6); - break; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); - builder.Append(v7); - break; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - string v8 = Marshal.PtrToStringAnsi(data); - builder.Append(v8); - break; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - long v9 = Marshal.ReadInt64(data); - builder.Append(v9); - break; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - string v10 = Marshal.PtrToStringAnsi(data); - builder.Append(v10); - break; - case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: - byte v11 = Marshal.ReadByte(data); - builder.Append(v11); - break; - case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: - ushort v12 = (ushort)Marshal.ReadInt16(data); - builder.Append(v12); - break; - case TDengineDataType.TSDB_DATA_TYPE_UINT: - uint v13 = (uint)Marshal.ReadInt32(data); - builder.Append(v13); - break; - case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: - ulong v14 = (ulong)Marshal.ReadInt64(data); - builder.Append(v14); - break; - } - } - builder.Append("---"); - - if (queryRows <= 10) - { - Console.WriteLine(builder.ToString()); - } - builder.Clear(); - } - - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", - TDengine.ErrorNo(res), TDengine.Error(res)); - } - Console.WriteLine(""); - - TDengine.FreeResult(res); - } - - System.DateTime end = new System.DateTime(); - TimeSpan ts = end - start; - - Console.Write("Total {0:G} rows inserted, {1:G} rows query, time spend {2:G} seconds.\n" - , this.rowsInserted, queryRows, ts.TotalSeconds); - } - - public void CloseConnection() - { - if (this.conn != IntPtr.Zero) - { - TDengine.Close(this.conn); - } - } - - static void ExitProgram() - { - TDengine.Cleanup(); - System.Environment.Exit(0); - } - } -} diff --git a/tests/examples/C#/insertCn/Program.cs b/tests/examples/C#/insertCn/Program.cs deleted file mode 100644 index 85d3e42533897d5790f148a1e1f9ed286f56dbea..0000000000000000000000000000000000000000 --- a/tests/examples/C#/insertCn/Program.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using Test.UtilsTools; -using System.Runtime.InteropServices; -using System.Collections.Generic; -using Test.UtilsTools.ResultSet; - -namespace insertCn -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Hello World!"); - IntPtr conn = UtilsTools.TDConnection(); - string dbName = "insert_cn_to_nchar_sample_dotnet"; - string createDB = $"create database if not exists {dbName};"; - string dropDB = $"drop database if exists {dbName};"; - string useDB = $"use {dbName};"; - string table = "t1"; - string stable = "stb"; - UtilsTools.ExecuteUpdate(conn,createDB); - UtilsTools.ExecuteUpdate(conn,useDB); - - Console.WriteLine("=====================ntable===================="); - TestNtable(conn,table); - Console.WriteLine("=====================stable===================="); - TestStable(conn,stable); - - UtilsTools.ExecuteUpdate(conn,dropDB); - UtilsTools.CloseConnection(conn); - - } - - static void TestStable(IntPtr conn,string stable) - { - string createSql = $"create table if not exists {stable} (ts timestamp," + - $"v4 int," + - $"blob nchar(200)," + - $"locate nchar(200)," + - $"country binary(200)," + - $"city binary(50)" + - $")tags(" + - $"id int," + - $"name nchar(50)," + - $"addr nchar(200)," + - $"en_name binary(200));"; - - String dropTb = "drop table if exists " + stable; - String table = stable + "_subtable_1"; - var colData = new List{1637064040000,1,"涛思数据","保利广场","Beijing","China", - 1637064041000,2,"涛思数据taosdata","保利广场baoli","Beijing","China", - 1637064042000,3,"TDegnine涛思数据","time广场","NewYork","US", - 1637064043000,4,"4涛思数据","4广场南部","London","UK", - 1637064044000,5,"涛思数据5","!广场路中部123","Tokyo","JP", - 1637064045000,6,"taos涛思数据6","青年广场123号!","Washin","DC", - 1637064046000,7,"7涛思数据taos","asdf#壮年广场%#endregion","NewYork","US", - 1637064047000,8,"8&涛思数据taos","incluse阿斯顿发","NewYork","US", - 1637064048000,9,"&涛思数据taos9","123黑化肥werq会挥……&¥%发!afsdfa","NewYork","US", - }; - var tagData = new List{1,"涛思数据","中国北方&南方长江黄河!49wq","tdengine"}; - string insertSql = UtilsTools.ConstructInsertSql(table, stable, colData, tagData, 9); - string selectSql = $"select * from {stable};"; - List insertData = UtilsTools.CombineColAndTagData(colData,tagData,9); - - UtilsTools.ExecuteUpdate(conn,dropTb); - UtilsTools.ExecuteUpdate(conn,createSql); - UtilsTools.ExecuteUpdate(conn,insertSql); - IntPtr res = UtilsTools.ExecuteQuery(conn,selectSql); - - ResultSet resultSet = new ResultSet(res); - List queryResult = resultSet.GetResultData(); - - //display - int fieldsCount = resultSet.GetFieldsNum(); - for(int i = 0 ; i{1637064040000,1,"涛思数据","保利广场","Beijing","China", - 1637064041000,2,"涛思数据taosdata","保利广场baoli","Beijing","China", - 1637064042000,3,"TDegnine涛思数据","time广场","NewYork","US", - 1637064043000,4,"4涛思数据","4广场南部","London","UK", - 1637064044000,5,"涛思数据5","!广场路中部123","Tokyo","JP", - 1637064045000,6,"taos涛思数据6","青年广场123号!","Washin","DC", - 1637064046000,7,"7涛思数据taos","asdf#壮年广场%#endregion","NewYork","US", - 1637064047000,8,"8&涛思数据taos","incluse阿斯顿发","NewYork","US", - 1637064048000,9,"&涛思数据taos9","123黑化肥werq会挥……&¥%发!afsdfa","NewYork","US", - }; - - String dropTb = "drop table if exists " + tableName; - String createTb = $"create table if not exists {tableName} (ts timestamp,v4 int,blob nchar(200),location nchar(200),city binary(100),coutry nchar(200));"; - String insertSql = UtilsTools.ConstructInsertSql(tableName, "", colData, null, 9); - String selectSql = "select * from " + tableName; - - UtilsTools.ExecuteUpdate(conn, dropTb); - UtilsTools.ExecuteUpdate(conn, createTb); - UtilsTools.ExecuteUpdate(conn, insertSql); - IntPtr res = UtilsTools.ExecuteQuery(conn, selectSql); - - ResultSet resultSet = new ResultSet(res); - List queryResult = resultSet.GetResultData(); - int fieldsCount = resultSet.GetFieldsNum(); - - //display - for(int i = 0 ; i - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -namespace TDengineDriver -{ - public enum TDengineDataType - { - TSDB_DATA_TYPE_NULL = 0, // 1 bytes - TSDB_DATA_TYPE_BOOL = 1, // 1 bytes - TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes - TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes - TSDB_DATA_TYPE_INT = 4, // 4 bytes - TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes - TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes - TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes - TSDB_DATA_TYPE_BINARY = 8, // string - TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes - TSDB_DATA_TYPE_NCHAR = 10, // unicode string - TSDB_DATA_TYPE_UTINYINT = 11,// 1 byte - TSDB_DATA_TYPE_USMALLINT = 12,// 2 bytes - TSDB_DATA_TYPE_UINT = 13, // 4 bytes - TSDB_DATA_TYPE_UBIGINT = 14, // 8 bytes - TSDB_DATA_TYPE_JSONTAG = 15 //4096 bytes - } - - public enum TDengineInitOption - { - TSDB_OPTION_LOCALE = 0, - TSDB_OPTION_CHARSET = 1, - TSDB_OPTION_TIMEZONE = 2, - TDDB_OPTION_CONFIGDIR = 3, - TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4 - } - enum TaosField - { - STRUCT_SIZE = 68, - NAME_LENGTH = 65, - TYPE_OFFSET = 65, - BYTES_OFFSET = 66, - - } - public class TDengineMeta - { - public string name; - public short size; - public byte type; - public string TypeName() - { - switch ((TDengineDataType)type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - return "BOOL"; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - return "TINYINT"; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - return "SMALLINT"; - case TDengineDataType.TSDB_DATA_TYPE_INT: - return "INT"; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - return "BIGINT"; - case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: - return "TINYINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: - return "SMALLINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_UINT: - return "INT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: - return "BIGINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - return "FLOAT"; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - return "DOUBLE"; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - return "BINARY"; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - return "TIMESTAMP"; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - return "NCHAR"; - case TDengineDataType.TSDB_DATA_TYPE_JSONTAG: - return "JSON"; - default: - return "undefine"; - } - } - } - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] - public struct TAOS_BIND - { - // column type - public int buffer_type; - // one column value - public IntPtr buffer; - // unused - public Int32 buffer_length; - // actual value length in buffer - public IntPtr length; - // indicates the column value is null or not - public IntPtr is_null; - // unused - public int is_unsigned; - // unused - public IntPtr error; - public Int64 u; - public uint allocated; - } - - - [StructLayout(LayoutKind.Sequential)] - public struct TAOS_MULTI_BIND - { - // column type - public int buffer_type; - - // array, one or more lines column value - public IntPtr buffer; - - //length of element in TAOS_MULTI_BIND.buffer (for binary and nchar it is the longest element's length) - public ulong buffer_length; - - //array, actual data length for each value - public IntPtr length; - - //array, indicates each column value is null or not - public IntPtr is_null; - - // line number, or the values number in buffer - public int num; - } - - - public class TDengine - { - public const int TSDB_CODE_SUCCESS = 0; - - [DllImport("taos", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)] - static extern public void Init(); - - [DllImport("taos", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)] - static extern public void Cleanup(); - - [DllImport("taos", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)] - static extern public void Options(int option, string value); - - [DllImport("taos", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr Connect(string ip, string user, string password, string db, short port); - - [DllImport("taos", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr taos_errstr(IntPtr res); - static public string Error(IntPtr res) - { - IntPtr errPtr = taos_errstr(res); - return Marshal.PtrToStringAnsi(errPtr); - } - - [DllImport("taos", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)] - static extern public int ErrorNo(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)] - // static extern public IntPtr Query(IntPtr conn, string sqlstr); - static extern private IntPtr Query(IntPtr conn, IntPtr byteArr); - - static public IntPtr Query(IntPtr conn,string command) - { - IntPtr res = IntPtr.Zero; - - IntPtr commandBuffer = Marshal.StringToCoTaskMemUTF8(command); - res = Query(conn,commandBuffer); - return res; - } - - [DllImport("taos", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)] - static extern public int AffectRows(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)] - static extern public int FieldCount(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr taos_fetch_fields(IntPtr res); - static public List FetchFields(IntPtr res) - { - // const int fieldSize = 68; - - List metas = new List(); - if (res == IntPtr.Zero) - { - return metas; - } - - int fieldCount = FieldCount(res); - IntPtr fieldsPtr = taos_fetch_fields(res); - - for (int i = 0; i < fieldCount; ++i) - { - int offset = i * (int)TaosField.STRUCT_SIZE; - TDengineMeta meta = new TDengineMeta(); - meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset); - meta.type = Marshal.ReadByte(fieldsPtr + offset + (int)TaosField.TYPE_OFFSET); - meta.size = Marshal.ReadInt16(fieldsPtr + offset + (int)TaosField.BYTES_OFFSET); - metas.Add(meta); - } - - - return metas; - } - - [DllImport("taos", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr FetchRows(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr FreeResult(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] - static extern public int Close(IntPtr taos); - - //get precision of restultset - [DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)] - static extern public int ResultPrecision(IntPtr taos); - - - - //stmt APIs: - /// - /// init a TAOS_STMT object for later use. - /// - /// a valid taos connection - /// - /// Not NULL returned for success, NULL for failure. And it should be freed with taos_stmt_close. - /// - [DllImport("taos", EntryPoint = "taos_stmt_init", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr StmtInit(IntPtr taos); - - /// - /// prepare a sql statement,'sql' should be a valid INSERT/SELECT statement. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// sql string,used to bind parameters with - /// no used - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_prepare", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtPrepare(IntPtr stmt, string sql); - - /// - /// For INSERT only. Used to bind table name as a parmeter for the input stmt object. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// table name you want to bind - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_set_tbname", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtSetTbname(IntPtr stmt, string name); - - /// - /// For INSERT only. - /// Set a table name for binding table name as parameter. Only used for binding all tables - /// in one stable, user application must call 'loadTableInfo' API to load all table - /// meta before calling this API. If the table meta is not cached locally, it will return error. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// table name which is belong to an stable - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_set_sub_tbname", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtSetSubTbname(IntPtr stmt, string name); - - /// - /// For INSERT only. - /// set a table name for binding table name as parameter and tag values for all tag parameters. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// use to set table name - /// - /// is an array contains all tag values,each item in the array represents a tag column's value. - /// the item number and sequence should keep consistence with that in stable tag definition. - /// - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_set_tbname_tags", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtSetTbnameTags(IntPtr stmt, string name, TAOS_BIND[] tags); - - /// - /// For both INSERT and SELECT. - /// bind a whole line data. - /// The usage of structure TAOS_BIND is the same with MYSQL_BIND in MySQL. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// - /// points to an array contains the whole line data. - /// the item number and sequence should keep consistence with columns in sql statement. - /// - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_bind_param", CallingConvention = CallingConvention.Cdecl, SetLastError = true)] - static extern public int StmtBindParam(IntPtr stmt, TAOS_BIND[] bind); - - /// - /// bind a single column's data, INTERNAL used and for INSERT only. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// points to a column's data which could be the one or more lines. - /// the column's index in prepared sql statement, it starts from 0. - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_bind_single_param_batch", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtBindSingleParamBatch(IntPtr stmt, ref TAOS_MULTI_BIND bind, int colIdx); - - /// - /// for INSERT only - /// bind one or multiple lines data. The parameter 'bind' - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// - /// points to an array contains one or more lines data.Each item in array represents a column's value(s), - /// the item number and sequence should keep consistence with columns in sql statement. - /// - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_bind_param_batch", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtBindParamBatch(IntPtr stmt, [In, Out] TAOS_MULTI_BIND[] bind); - - /// - /// For INSERT only. - /// add all current bound parameters to batch process. Must be called after each call to - /// StmtBindParam/StmtBindSingleParamBatch, or all columns binds for one or more lines - /// with StmtBindSingleParamBatch. User application can call any bind parameter - /// API again to bind more data lines after calling to this API. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_add_batch", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtAddBatch(IntPtr stmt); - - /// - /// actually execute the INSERT/SELECT sql statement. - /// User application can continue to bind new data after calling to this API. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// - [DllImport("taos", EntryPoint = "taos_stmt_execute", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtExecute(IntPtr stmt); - - /// - /// For SELECT only,getting the query result. User application should free it with API 'FreeResult' at the end. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// Not NULL for success, NULL for failure. - [DllImport("taos", EntryPoint = "taos_stmt_use_result", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr StmtUseResult(IntPtr stmt); - - /// - /// close STMT object and free resources. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// 0 for success, non-zero for failure. - [DllImport("taos", EntryPoint = "taos_stmt_close", CallingConvention = CallingConvention.Cdecl)] - static extern public int StmtClose(IntPtr stmt); - - [DllImport("taos", EntryPoint = "taos_load_table_info", CallingConvention = CallingConvention.Cdecl)] - /// - /// user application must call this API to load all tables meta, - /// - /// taos connection - /// tablelist - /// - static extern private int LoadTableInfoDll(IntPtr taos, string tableList); - - /// - /// user application call this API to load all tables meta,this method call the native - /// method LoadTableInfoDll. - /// this method must be called before StmtSetSubTbname(IntPtr stmt, string name); - /// - /// taos connection - /// tables need to load meta info are form in an array - /// - static public int LoadTableInfo(IntPtr taos, string[] tableList) - { - string listStr = string.Join(",", tableList); - return LoadTableInfoDll(taos, listStr); - } - - /// - /// get detail error message when got failure for any stmt API call. If not failure, the result - /// returned in this API is unknown. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// piont the error message - [DllImport("taos", EntryPoint = "taos_stmt_errstr", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr StmtErrPtr(IntPtr stmt); - - /// - /// get detail error message when got failure for any stmt API call. If not failure, the result - /// returned in this API is unknown. - /// - /// could be the value returned by 'StmtInit', that may be a valid object or NULL. - /// error string - static public string StmtErrorStr(IntPtr stmt) - { - IntPtr stmtErrPrt = StmtErrPtr(stmt); - return Marshal.PtrToStringAnsi(stmtErrPrt); - } - - [DllImport("taos", EntryPoint = "taos_fetch_lengths", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr FetchLengths(IntPtr taos); - } -} diff --git a/tests/examples/C#/insertCn/insertCn.csproj b/tests/examples/C#/insertCn/insertCn.csproj deleted file mode 100644 index 69ddfdfbbff10fd9c26c92dcb8c8c2928b5c8511..0000000000000000000000000000000000000000 --- a/tests/examples/C#/insertCn/insertCn.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Exe - net5.0 - - - diff --git a/tests/examples/C#/insertCn/lib/ResultSetUtils.cs b/tests/examples/C#/insertCn/lib/ResultSetUtils.cs deleted file mode 100644 index e0fc4e2ccae00f38c5889f211d2d12a66bdaa31b..0000000000000000000000000000000000000000 --- a/tests/examples/C#/insertCn/lib/ResultSetUtils.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using TDengineDriver; -using System.Runtime.InteropServices; -using System.Text; -using System.Collections.Generic; -namespace Test.UtilsTools.ResultSet -{ - public class ResultSet - { - private List resultMeta; - private List resultData; - // private bool isValidResult = false; - public ResultSet(IntPtr res) - { - - resultMeta = UtilsTools.GetResField(res); - resultData = UtilsTools.GetResData(res); - } - - public ResultSet(List metas, List datas) - { - resultMeta = metas; - resultData = datas; - } - - public List GetResultData() - { - return resultData; - } - - public List GetResultMeta() - { - return resultMeta; - } - - public int GetFieldsNum() - { - return resultMeta.Count; - } - } - - -} \ No newline at end of file diff --git a/tests/examples/C#/insertCn/lib/Utils.cs b/tests/examples/C#/insertCn/lib/Utils.cs deleted file mode 100644 index b43268342fa17e2a690b21ab8c24246b1a653501..0000000000000000000000000000000000000000 --- a/tests/examples/C#/insertCn/lib/Utils.cs +++ /dev/null @@ -1,442 +0,0 @@ -using System; -using TDengineDriver; -using System.Runtime.InteropServices; -using System.Text; -using System.Collections.Generic; -namespace Test.UtilsTools -{ - public class UtilsTools - { - - static string ip = "127.0.0.1"; - static string user = "root"; - static string password = "taosdata"; - static string db = ""; - static short port = 0; - //get a tdengine connection - public static IntPtr TDConnection() - { - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, GetConfigPath()); - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - TDengine.Init(); - IntPtr conn = TDengine.Connect(ip, user, password, db, port); - return conn; - } - //get taos.cfg file based on different os - public static string GetConfigPath() - { - string configDir = "" ; - if(OperatingSystem.IsOSPlatform("Windows")) - { - configDir = "C:/TDengine/cfg"; - } - else if(OperatingSystem.IsOSPlatform("Linux")) - { - configDir = "/etc/taos"; - } - else if(OperatingSystem.IsOSPlatform("macOS")) - { - configDir = "/etc/taos"; - } - return configDir; - } - - public static IntPtr ExecuteQuery(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) - { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - return res; - } - - public static IntPtr ExecuteErrorQuery(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) - { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - - } - return res; - } - - public static void ExecuteUpdate(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if (!IsValidResult(res)) - { - Console.Write(sql.ToString() + " failure, "); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - - } - TDengine.FreeResult(res); - } - - - // public static List> GetResultSet(IntPtr res) - // { - // List> result = new List>(); - // List colName = new List(); - // List dataRaw = new List(); - // if (!IsValidResult(res)) - // { - // ExitProgram(); - // } - - // List metas = GetResField(res); - // result.Add(colName); - - // dataRaw = QueryRes(res, metas); - // result.Add(dataRaw); - - // if (TDengine.ErrorNo(res) != 0) - // { - // Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - // } - // return result; - // } - - public static bool IsValidResult(IntPtr res) - { - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - return false; - } - Console.WriteLine(""); - return false; - } - return true; - } - public static void CloseConnection(IntPtr conn) - { - if (conn != IntPtr.Zero) - { - if (TDengine.Close(conn) == 0) - { - Console.WriteLine("close connection sucess"); - } - else - { - Console.WriteLine("close Connection failed"); - } - } - TDengine.Cleanup(); - } - public static List GetResField(IntPtr res) - { - List metas = TDengine.FetchFields(res); - return metas; - } - public static void AssertEqual(string expectVal, string actualVal) - { - if (expectVal == actualVal) - { - Console.WriteLine("{0}=={1} pass", expectVal, actualVal); - } - else - { - Console.WriteLine("{0}=={1} failed", expectVal, actualVal); - ExitProgram(); - } - } - public static void ExitProgram() - { - TDengine.Cleanup(); - System.Environment.Exit(0); - } - public static List GetResData(IntPtr res) - { - List dataRaw = new List(); - if (!IsValidResult(res)) - { - ExitProgram(); - } - List metas = GetResField(res); - dataRaw = QueryRes(res, metas); - return dataRaw; - } - - public static TDengineMeta ConstructTDengineMeta(string name, string type) - { - - TDengineMeta _meta = new TDengineMeta(); - _meta.name = name; - char[] separators = new char[] { '(', ')' }; - string[] subs = type.Split(separators, StringSplitOptions.RemoveEmptyEntries); - - switch (subs[0].ToUpper()) - { - case "BOOL": - _meta.type = 1; - _meta.size = 1; - break; - case "TINYINT": - _meta.type = 2; - _meta.size = 1; - break; - case "SMALLINT": - _meta.type = 3; - _meta.size = 2; - break; - case "INT": - _meta.type = 4; - _meta.size = 4; - break; - case "BIGINT": - _meta.type = 5; - _meta.size = 8; - break; - case "TINYINT UNSIGNED": - _meta.type = 11; - _meta.size = 1; - break; - case "SMALLINT UNSIGNED": - _meta.type = 12; - _meta.size = 2; - break; - case "INT UNSIGNED": - _meta.type = 13; - _meta.size = 4; - break; - case "BIGINT UNSIGNED": - _meta.type = 14; - _meta.size = 8; - break; - case "FLOAT": - _meta.type = 6; - _meta.size = 4; - break; - case "DOUBLE": - _meta.type = 7; - _meta.size = 8; - break; - case "BINARY": - _meta.type = 8; - _meta.size = short.Parse(subs[1]); - break; - case "TIMESTAMP": - _meta.type = 9; - _meta.size = 8; - break; - case "NCHAR": - _meta.type = 10; - _meta.size = short.Parse(subs[1]); - break; - case "JSON": - _meta.type = 15; - _meta.size = 4096; - break; - default: - _meta.type = byte.MaxValue; - _meta.size = 0; - break; - } - return _meta; - } - - private static List QueryRes(IntPtr res, List metas) - { - IntPtr rowdata; - long queryRows = 0; - List dataRaw = new List(); - int fieldCount = metas.Count; - while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) - { - queryRows++; - IntPtr colLengthPtr = TDengine.FetchLengths(res); - int[] colLengthArr = new int[fieldCount]; - Marshal.Copy(colLengthPtr, colLengthArr, 0, fieldCount); - - for (int fields = 0; fields < fieldCount; ++fields) - { - TDengineMeta meta = metas[fields]; - int offset = IntPtr.Size * fields; - IntPtr data = Marshal.ReadIntPtr(rowdata, offset); - - if (data == IntPtr.Zero) - { - dataRaw.Add("NULL"); - continue; - } - - switch ((TDengineDataType)meta.type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; - dataRaw.Add(v1); - break; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - sbyte v2 = (sbyte)Marshal.ReadByte(data); - dataRaw.Add(v2); - break; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - short v3 = Marshal.ReadInt16(data); - dataRaw.Add(v3); - break; - case TDengineDataType.TSDB_DATA_TYPE_INT: - int v4 = Marshal.ReadInt32(data); - dataRaw.Add(v4); - break; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - long v5 = Marshal.ReadInt64(data); - dataRaw.Add(v5); - break; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); - dataRaw.Add(v6); - break; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); - dataRaw.Add(v7); - break; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - // string v8 = Marshal.PtrToStringAnsi(data, colLengthArr[fields]); - string v8 = Marshal.PtrToStringUTF8(data, colLengthArr[fields]); - dataRaw.Add(v8); - break; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - long v9 = Marshal.ReadInt64(data); - dataRaw.Add(v9); - break; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - // string v10 = Marshal.PtrToStringAnsi(data, colLengthArr[fields]); - string v10 = Marshal.PtrToStringUTF8(data, colLengthArr[fields]); - dataRaw.Add(v10); - break; - case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: - byte v12 = Marshal.ReadByte(data); - dataRaw.Add(v12); - break; - case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: - ushort v13 = (ushort)Marshal.ReadInt16(data); - dataRaw.Add(v13); - break; - case TDengineDataType.TSDB_DATA_TYPE_UINT: - uint v14 = (uint)Marshal.ReadInt32(data); - dataRaw.Add(v14); - break; - case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: - ulong v15 = (ulong)Marshal.ReadInt64(data); - dataRaw.Add(v15); - break; - default: - dataRaw.Add("unknown value"); - break; - } - } - - } - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - } - TDengine.FreeResult(res); - Console.WriteLine(""); - return dataRaw; - } - - // Generate insert sql for the with the coldata and tag data - public static string ConstructInsertSql(string table,string stable,List colData,List tagData,int numOfRows) - { - int numofFileds = colData.Count / numOfRows; - StringBuilder insertSql; - - if (stable == "") - { - insertSql = new StringBuilder($"insert into {table} values("); - } - else - { - insertSql = new StringBuilder($"insert into {table} using {stable} tags("); - - for (int j = 0; j < tagData.Count; j++) - { - if (tagData[j] is String) - { - insertSql.Append('\''); - insertSql.Append(tagData[j]); - insertSql.Append('\''); - } - else - { - insertSql.Append(tagData[j]); - } - if (j + 1 != tagData.Count) - { - insertSql.Append(','); - } - } - - insertSql.Append(")values("); - } - for (int i = 0; i < colData.Count; i++) - { - - if (colData[i] is String) - { - insertSql.Append('\''); - insertSql.Append(colData[i]); - insertSql.Append('\''); - } - else - { - insertSql.Append(colData[i]); - } - - if ((i + 1) % numofFileds == 0 && (i + 1) != colData.Count) - { - insertSql.Append(")("); - } - else if ((i + 1) == colData.Count) - { - insertSql.Append(')'); - } - else - { - insertSql.Append(','); - } - } - insertSql.Append(';'); - //Console.WriteLine(insertSql.ToString()); - - return insertSql.ToString(); - } - - public static List CombineColAndTagData(List colData,List tagData, int numOfRows) - { - var list = new List(); - for (int i = 0; i < colData.Count; i++) - { - list.Add(colData[i]); - if ((i + 1) % (colData.Count / numOfRows) == 0) - { - for (int j = 0; j < tagData.Count; j++) - { - list.Add(tagData[j]); - } - } - } - return list; - } - } -} - diff --git a/tests/examples/C#/jsonTag/JsonTag.cs b/tests/examples/C#/jsonTag/JsonTag.cs deleted file mode 100644 index 453e54eabdc9a4ec61cdc2a061af69ed64753416..0000000000000000000000000000000000000000 --- a/tests/examples/C#/jsonTag/JsonTag.cs +++ /dev/null @@ -1,365 +0,0 @@ -using System; -using Utils; - -namespace Cases -{ - - class Program - { - static void Main(string[] args) - { - IntPtr conn = IntPtr.Zero; - Console.WriteLine("===================JsonTagTest===================="); - conn = conn = UtilsTools.TDConnection("127.0.0.1", "root", "taosdata", "", 0); - UtilsTools.ExecuteUpdate(conn, "create database if not exists csharp_sample keep 3650"); - UtilsTools.ExecuteUpdate(conn, "use csharp"); - JsonTagSample jsonTagSample = new JsonTagSample(); - jsonTagSample.Test(conn); - } - - } - - public class JsonTagSample - { - public void Test(IntPtr conn) - { - Console.WriteLine("STEP 1 prepare data & validate json string===== "); - UtilsTools.ExecuteQuery(conn, "create table if not exists jsons1(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)"); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_1 using jsons1 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 1, false, 'json1', '涛思数据') (1591060608000, 23, true, '涛思数据', 'json')"); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_2 using jsons1 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060628000, 2, true, 'json2', 'sss')"); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_3 using jsons1 tags('{\"tag1\":false,\"tag2\":\"beijing\"}') values (1591060668000, 3, false, 'json3', 'efwe')"); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_4 using jsons1 tags('{\"tag1\":null,\"tag2\":\"shanghai\",\"tag3\":\"hello\"}') values (1591060728000, 4, true, 'json4', '323sd')"); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_5 using jsons1 tags('{\"tag1\":1.232, \"tag2\":null}') values(1591060928000, 1, false, '涛思数据', 'ewe')"); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_6 using jsons1 tags('{\"tag1\":11,\"tag2\":\"\",\"tag2\":null}') values(1591061628000, 11, false, '涛思数据','')"); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_7 using jsons1 tags('{\"tag1\":\"涛思数据\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '涛思数据', 'dws')"); - Console.WriteLine(""); - - Console.WriteLine("test duplicate key using the first one. elimate empty key======== "); - UtilsTools.ExecuteQuery(conn, "CREATE TABLE if not exists jsons1_8 using jsons1 tags('{\"tag1\":null, \"tag1\":true, \"tag1\":45, \"1tag$\":2, \" \":90}')"); - Console.WriteLine(""); - - Console.WriteLine("test empty json string, save as jtag is NULL========== "); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_9 using jsons1 tags('\t') values (1591062328000, 24, NULL, '涛思数据', '2sdw')"); - UtilsTools.ExecuteQuery(conn, "CREATE TABLE if not exists jsons1_10 using jsons1 tags('')"); - UtilsTools.ExecuteQuery(conn, "CREATE TABLE if not exists jsons1_11 using jsons1 tags(' ')"); - UtilsTools.ExecuteQuery(conn, "CREATE TABLE if not exists jsons1_12 using jsons1 tags('{}')"); - UtilsTools.ExecuteQuery(conn, "CREATE TABLE if not exists jsons1_13 using jsons1 tags('null')"); - Console.WriteLine(""); - - Console.WriteLine("test invalidate json==================== "); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('\"efwewf\"')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('3333')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('33.33')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('false')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('[1,true]')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{222}')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"fe\"}')"); - Console.WriteLine(""); - - Console.WriteLine("test invalidate json key, key must can be printed assic char========== "); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":[1,true]}')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"tag1\":{}}')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"。loc\":\"fff\"}')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\":\"fff\"}')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"\t\":\"fff\"}')"); - UtilsTools.ExecuteErrorQuery(conn, "CREATE TABLE if not exists jsons1_14 using jsons1 tags('{\"试试\":\"fff\"}')"); - Console.WriteLine(""); - - Console.WriteLine("STEP 2 alter table json tag============"); - UtilsTools.ExecuteErrorQuery(conn, "ALTER STABLE jsons1 add tag tag2 nchar(20)"); - UtilsTools.ExecuteErrorQuery(conn, "ALTER STABLE jsons1 drop tag jtag"); - UtilsTools.ExecuteErrorQuery(conn, "ALTER TABLE jsons1_1 SET TAG jtag=4"); - UtilsTools.ExecuteQuery(conn, "ALTER TABLE jsons1_1 SET TAG jtag='{\"tag1\":\"femail\",\"tag2\":35,\"tag3\":true}'"); - Console.WriteLine(""); - - Console.WriteLine("STEP 3 query table============"); - Console.WriteLine("test error syntax============"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->tag1='beijing'"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->'location'"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->''"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->''=9"); - UtilsTools.ExecuteErrorQuery(conn, "select -> from jsons1"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where contains"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->"); - UtilsTools.ExecuteErrorQuery(conn, "select jtag->location from jsons1"); - UtilsTools.ExecuteErrorQuery(conn, "select jtag contains location from jsons1"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag contains location"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag contains''"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag contains 'location'='beijing'"); - Console.WriteLine(""); - - Console.WriteLine("test select normal column==========="); - IntPtr res = IntPtr.Zero; - res = UtilsTools.ExecuteQuery(conn, "select dataint from jsons1"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test select json tag==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select jtag from jsons1"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select jtag from jsons1 where jtag is null"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select jtag from jsons1 where jtag is not null"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test #line 41==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag from jsons1_8"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test #line 72==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag from jsons1_1"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test jtag is NULL==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag from jsons1_9"); - UtilsTools.DisplayRes(res); - - - Console.WriteLine("test select json tag->'key', value is string ==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag1' from jsons1_1"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag2' from jsons1_6"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test select json tag->'key', value is int==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag2' from jsons1_1"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test select json tag->'key', value is bool==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag3' from jsons1_1"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test select json tag->'key', value is null==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag1' from jsons1_4"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test select json tag->'key', value is double==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag1' from jsons1_5"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test select json tag->'key', key is not exist==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag10' from jsons1_4"); - UtilsTools.DisplayRes(res); - - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag1' from jsons1"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test header name==========="); - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag1' from jsons1"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test where with json tag==========="); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1_1 where jtag is not null"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag='{\"tag1\":11,\"tag2\":\"\"}'"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->'tag1'={}"); - - Console.WriteLine("where json value is string==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag2'='beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select dataint,tbname,jtag->'tag1',jtag from jsons1 where jtag->'tag2'='beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'='beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'='涛思数据'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag2'>'beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag2'>='beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag2'<'beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag2'<='beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag2'!='beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag2'=''"); - UtilsTools.DisplayRes(res); - - - Console.WriteLine("where json value is int==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=5"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=10"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'<54"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'<=11"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'>4"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'>=5"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'!=5"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'!=55"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("where json value is double==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=1.232"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'<1.232"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'<=1.232"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'>1.23"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'>=1.232"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'!=1.232"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'!=3.232"); - UtilsTools.DisplayRes(res); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->'tag1'/0=3"); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->'tag1'/5=1"); - - Console.WriteLine("where json value is bool==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=true"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=false"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'!=false"); - UtilsTools.DisplayRes(res); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->'tag1'>false"); - - Console.WriteLine("where json value is null==========="); - Console.WriteLine("only json suport =null. This synatx will change later.==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=null"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("where json is null==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag is null"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag is not null"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("where json key is null==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag_no_exist'=3"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("where json value is not exist==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1' is null"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag4' is null"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag3' is not null"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test contains==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag contains 'tag1'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag contains 'tag3'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag contains 'tag_no_exist'"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test json tag in where condition with and/or==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=false or jtag->'tag2'='beijing'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=false and jtag->'tag2'='shanghai'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'=13 or jtag->'tag2'>35"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1' is not null and jtag contains 'tag3'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1'='femail' and jtag contains 'tag3'"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test with tbname/normal column==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where tbname = 'jsons1_1'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=3"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where tbname = 'jsons1_1' and jtag contains 'tag3' and dataint=23"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test where condition like==========="); - res = UtilsTools.ExecuteQuery(conn, "select *,tbname from jsons1 where jtag->'tag2' like 'bei%'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select *,tbname from jsons1 where jtag->'tag1' like 'fe%' and jtag->'tag2' is not null"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test where condition in no support in==========="); - UtilsTools.ExecuteErrorQuery(conn, "select * from jsons1 where jtag->'tag1' in ('beijing')"); - - Console.WriteLine("test where condition match==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1' match 'ma'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1' match 'ma$'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag2' match 'jing$'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select * from jsons1 where jtag->'tag1' match '收到'"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test distinct==========="); - UtilsTools.ExecuteQuery(conn, "insert into jsons1_14 using jsons1 tags('{\"tag1\":\"涛思数据\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '涛思数据', 'dws')"); - res = UtilsTools.ExecuteQuery(conn, "select distinct jtag->'tag1' from jsons1"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select distinct jtag from jsons1"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test dumplicate key with normal colomn==========="); - UtilsTools.ExecuteQuery(conn, "INSERT INTO jsons1_15 using jsons1 tags('{\"tbname\":\"tt\",\"databool\":true,\"datastr\":\"涛思数据\"}') values(1591060828000, 4, false, 'jjsf', \"你就会\")"); - res = UtilsTools.ExecuteQuery(conn, "select *,tbname,jtag from jsons1 where jtag->'datastr' match '涛思数据' and datastr match 'js'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select tbname,jtag->'tbname' from jsons1 where jtag->'tbname'='tt' and tbname='jsons1_14'"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test join==========="); - UtilsTools.ExecuteQuery(conn, "create table if not exists jsons2(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)"); - UtilsTools.ExecuteQuery(conn, "insert into jsons2_1 using jsons2 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 2, false, 'json2', '涛思数据2')"); - UtilsTools.ExecuteQuery(conn, "insert into jsons2_2 using jsons2 tags('{\"tag1\":5,\"tag2\":null}') values (1591060628000, 2, true, 'json2', 'sss')"); - UtilsTools.ExecuteQuery(conn, "create table if not exists jsons3(ts timestamp, dataInt int, dataBool bool, dataStr nchar(50), dataStrBin binary(150)) tags(jtag json)"); - UtilsTools.ExecuteQuery(conn, "insert into jsons3_1 using jsons3 tags('{\"tag1\":\"fff\",\"tag2\":5, \"tag3\":true}') values(1591060618000, 3, false, 'json3', '涛思数据3')"); - UtilsTools.ExecuteQuery(conn, "insert into jsons3_2 using jsons3 tags('{\"tag1\":5,\"tag2\":\"beijing\"}') values (1591060638000, 2, true, 'json3', 'sss')"); - - res = UtilsTools.ExecuteQuery(conn, "select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select 'sss',33,a.jtag->'tag3' from jsons2 a,jsons3 b where a.ts=b.ts and a.jtag->'tag1'=b.jtag->'tag1'"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test group by & order by json tag==========="); - res = UtilsTools.ExecuteQuery(conn, "select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' desc"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select count(*) from jsons1 group by jtag->'tag1' order by jtag->'tag1' asc"); - UtilsTools.DisplayRes(res); - - - Console.WriteLine("test stddev with group by json tag==========="); - res = UtilsTools.ExecuteQuery(conn, "select stddev(dataint) from jsons1 group by jtag->'tag1'"); - UtilsTools.DisplayRes(res); - res = UtilsTools.ExecuteQuery(conn, "select stddev(dataint) from jsons1 group by jsons1.jtag->'tag1'"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("test top/bottom with group by json tag==========="); - res = UtilsTools.ExecuteQuery(conn, "select top(dataint,100) from jsons1 group by jtag->'tag1'"); - UtilsTools.DisplayRes(res); - - Console.WriteLine("subquery with json tag==========="); - res = UtilsTools.ExecuteQuery(conn, "select * from (select jtag, dataint from jsons1)"); - UtilsTools.DisplayRes(res); - - - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)"); - UtilsTools.DisplayRes(res); - - res = UtilsTools.ExecuteQuery(conn, "select jtag->'tag1' from (select jtag->'tag1', dataint from jsons1)"); - UtilsTools.DisplayRes(res); - - res = UtilsTools.ExecuteQuery(conn, "select ts,tbname,jtag->'tag1' from (select jtag->'tag1',tbname,ts from jsons1 order by ts)"); - UtilsTools.DisplayRes(res); - Console.WriteLine(""); - - - } - } -} \ No newline at end of file diff --git a/tests/examples/C#/jsonTag/Util.cs b/tests/examples/C#/jsonTag/Util.cs deleted file mode 100644 index 5138938df60532616e75b45d8a95597c322dfd1a..0000000000000000000000000000000000000000 --- a/tests/examples/C#/jsonTag/Util.cs +++ /dev/null @@ -1,226 +0,0 @@ -using System; -using TDengineDriver; -using System.Runtime.InteropServices; -using System.Text; -using System.Collections.Generic; -namespace Utils -{ - public class UtilsTools - { - - static string configDir = "/etc/taos";//"C:/TDengine/cfg"; - - public static IntPtr TDConnection(string ip, string user, string password, string db, short port) - { - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, configDir); - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - TDengine.Init(); - return TDengine.Connect(ip, user, password, db, port); - } - - public static IntPtr ExecuteQuery(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - return res; - } - - public static IntPtr ExecuteErrorQuery(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - - } - Console.WriteLine(""); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - - } - return res; - } - - public static void ExecuteUpdate(IntPtr conn, String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - - } - TDengine.FreeResult(res); - } - - public static void DisplayRes(IntPtr res) - { - long queryRows = 0; - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - - int fieldCount = TDengine.FieldCount(res); - List metas = TDengine.FetchFields(res); - for (int j = 0; j < metas.Count; j++) - { - TDengineMeta meta = (TDengineMeta)metas[j]; - } - - IntPtr rowdata; - StringBuilder builder = new StringBuilder(); - - while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) - { - queryRows++; - IntPtr colLengthPtr = TDengine.FetchLengths(res); - int[] colLengthArr = new int[fieldCount]; - Marshal.Copy(colLengthPtr, colLengthArr, 0, fieldCount); - for (int fields = 0; fields < fieldCount; ++fields) - { - TDengineMeta meta = metas[fields]; - int offset = IntPtr.Size * fields; - IntPtr data = Marshal.ReadIntPtr(rowdata, offset); - - builder.Append("---"); - - if (data == IntPtr.Zero) - { - builder.Append("NULL"); - continue; - } - - switch ((TDengineDataType)meta.type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; - builder.Append(v1); - break; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - byte v2 = Marshal.ReadByte(data); - builder.Append(v2); - break; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - short v3 = Marshal.ReadInt16(data); - builder.Append(v3); - break; - case TDengineDataType.TSDB_DATA_TYPE_INT: - int v4 = Marshal.ReadInt32(data); - builder.Append(v4); - break; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - long v5 = Marshal.ReadInt64(data); - builder.Append(v5); - break; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); - builder.Append(v6); - break; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); - builder.Append(v7); - break; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - string v8 = Marshal.PtrToStringAnsi(data, colLengthArr[fields]); - builder.Append(v8); - break; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - long v9 = Marshal.ReadInt64(data); - builder.Append(v9); - break; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - string v10 = Marshal.PtrToStringAnsi(data, colLengthArr[fields]); - builder.Append(v10); - break; - case TDengineDataType.TSDB_DATA_TYPE_JSONTAG: - string v11 = Marshal.PtrToStringAnsi(data); - builder.Append(v11); - break; - } - } - builder.Append("---"); - - if (queryRows <= 10) - { - Console.WriteLine(builder.ToString()); - } - builder.Clear(); - } - - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - } - TDengine.FreeResult(res); Console.WriteLine(""); - } - - public static bool IsValidResult(IntPtr res) - { - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - return false; - } - Console.WriteLine(""); - return false; - } - return true; - } - public static void CloseConnection(IntPtr conn) - { - if (conn != IntPtr.Zero) - { - if (TDengine.Close(conn) == 0) - { - Console.WriteLine("close connection sucess"); - } - else - { - Console.WriteLine("close Connection failed"); - } - } - } - public static void ExitProgram() - { - TDengine.Cleanup(); - System.Environment.Exit(0); - } - } -} \ No newline at end of file diff --git a/tests/examples/C#/schemaless/TDengineDriver.cs b/tests/examples/C#/schemaless/TDengineDriver.cs deleted file mode 100644 index 8dd9ce0c929df66fd82bd40d6ff77a868c630efe..0000000000000000000000000000000000000000 --- a/tests/examples/C#/schemaless/TDengineDriver.cs +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; - -namespace TDengineDriver -{ - enum TDengineDataType - { - TSDB_DATA_TYPE_NULL = 0, // 1 bytes - TSDB_DATA_TYPE_BOOL = 1, // 1 bytes - TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes - TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes - TSDB_DATA_TYPE_INT = 4, // 4 bytes - TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes - TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes - TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes - TSDB_DATA_TYPE_BINARY = 8, // string - TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes - TSDB_DATA_TYPE_NCHAR = 10, // unicode string - TSDB_DATA_TYPE_UTINYINT = 11,// 1 byte - TSDB_DATA_TYPE_USMALLINT = 12,// 2 bytes - TSDB_DATA_TYPE_UINT = 13, // 4 bytes - TSDB_DATA_TYPE_UBIGINT = 14 // 8 bytes - } - - enum TDengineInitOption - { - TSDB_OPTION_LOCALE = 0, - TSDB_OPTION_CHARSET = 1, - TSDB_OPTION_TIMEZONE = 2, - TDDB_OPTION_CONFIGDIR = 3, - TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4 - } - enum TDengineSchemalessProtocol - { - TSDB_SML_UNKNOWN_PROTOCOL = 0, - TSDB_SML_LINE_PROTOCOL = 1, - TSDB_SML_TELNET_PROTOCOL = 2, - TSDB_SML_JSON_PROTOCOL = 3 - - } - enum TDengineSchemalessPrecision - { - TSDB_SML_TIMESTAMP_NOT_CONFIGURED = 0, - TSDB_SML_TIMESTAMP_HOURS = 1, - TSDB_SML_TIMESTAMP_MINUTES = 2, - TSDB_SML_TIMESTAMP_SECONDS = 3, - TSDB_SML_TIMESTAMP_MILLI_SECONDS = 4, - TSDB_SML_TIMESTAMP_MICRO_SECONDS = 5, - TSDB_SML_TIMESTAMP_NANO_SECONDS = 6 - } - - class TDengineMeta - { - public string name; - public short size; - public byte type; - public string TypeName() - { - switch ((TDengineDataType)type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - return "BOOL"; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - return "TINYINT"; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - return "SMALLINT"; - case TDengineDataType.TSDB_DATA_TYPE_INT: - return "INT"; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - return "BIGINT"; - case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: - return "TINYINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: - return "SMALLINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_UINT: - return "INT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: - return "BIGINT UNSIGNED"; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - return "FLOAT"; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - return "DOUBLE"; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - return "STRING"; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - return "TIMESTAMP"; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - return "NCHAR"; - default: - return "undefine"; - } - } - } - - class TDengine - { - public const int TSDB_CODE_SUCCESS = 0; - - [DllImport("taos", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)] - static extern public void Init(); - - [DllImport("taos", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)] - static extern public void Cleanup(); - - [DllImport("taos", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)] - static extern public void Options(int option, string value); - - [DllImport("taos", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr Connect(string ip, string user, string password, string db, short port); - - [DllImport("taos", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr taos_errstr(IntPtr res); - static public string Error(IntPtr res) - { - IntPtr errPtr = taos_errstr(res); - return Marshal.PtrToStringAnsi(errPtr); - } - - [DllImport("taos", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)] - static extern public int ErrorNo(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr Query(IntPtr conn, string sqlstr); - - [DllImport("taos", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)] - static extern public int AffectRows(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)] - static extern public int FieldCount(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)] - static extern private IntPtr taos_fetch_fields(IntPtr res); - static public List FetchFields(IntPtr res) - { - const int fieldSize = 68; - - List metas = new List(); - if (res == IntPtr.Zero) - { - return metas; - } - - int fieldCount = FieldCount(res); - IntPtr fieldsPtr = taos_fetch_fields(res); - - for (int i = 0; i < fieldCount; ++i) - { - int offset = i * fieldSize; - - TDengineMeta meta = new TDengineMeta(); - meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset); - meta.type = Marshal.ReadByte(fieldsPtr + offset + 65); - meta.size = Marshal.ReadInt16(fieldsPtr + offset + 66); - metas.Add(meta); - } - - return metas; - } - - [DllImport("taos", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr FetchRows(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr FreeResult(IntPtr res); - - [DllImport("taos", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)] - static extern public int Close(IntPtr taos); - - //get precision in restultset - [DllImport("taos", EntryPoint = "taos_result_precision", CallingConvention = CallingConvention.Cdecl)] - static extern public int ResultPrecision(IntPtr taos); - - //schemaless API - [DllImport("taos",SetLastError = true, EntryPoint = "taos_schemaless_insert", CallingConvention = CallingConvention.Cdecl)] - static extern public IntPtr SchemalessInsert(IntPtr taos, string[] lines, int numLines, int protocol, int precision); - } -} diff --git a/tests/examples/C#/schemaless/schemaless.csproj b/tests/examples/C#/schemaless/schemaless.csproj deleted file mode 100644 index d132e34589525826d5b0ff0f0055156fad2d5a38..0000000000000000000000000000000000000000 --- a/tests/examples/C#/schemaless/schemaless.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - net5.0 - - - - - - - diff --git a/tests/examples/C#/schemaless/schemalessSample.cs b/tests/examples/C#/schemaless/schemalessSample.cs deleted file mode 100644 index f27ac352a6fc8a3fbbaf84966ae3b82e6036e91a..0000000000000000000000000000000000000000 --- a/tests/examples/C#/schemaless/schemalessSample.cs +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -using System; -using System.Text; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Collections; - -namespace TDengineDriver -{ - class SchemalessSample - { - // connect parameters - private string host = "127.0.0.1"; - private string configDir = "C:/TDengine/cfg"; - private string user = "root"; - private string passwd = "taosdata"; - private short port = 0; - - private IntPtr conn = IntPtr.Zero; - private string dbName = "csharp"; - private string dbPrecision = "ms"; - - static void Main(string[] args) - { - string[] lines = { - "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", - "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000" - }; - string[] jsonStr = { - "{" - +"\"metric\": \"stb0_0\"," - +"\"timestamp\": 1626006833," - +"\"value\": 10," - +"\"tags\": {" - +" \"t1\": true," - +"\"t2\": false," - +"\"t3\": 10," - +"\"t4\": \"123_abc_.!@#$%^&*:;,./?|+-=()[]{}<>\"" - +"}" - +"}" - }; - - SchemalessSample sample = new SchemalessSample(); - sample.InitTDengine(); - sample.ConnectTDengine(); - sample.dropDatabase(); - sample.createDatabase(); - sample.useDatabase(); - sample.schemalessInsert(lines, 2, (int)TDengineSchemalessProtocol.TSDB_SML_LINE_PROTOCOL, (int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_NANO_SECONDS); - sample.checkSelect("stg"); - sample.schemalessInsert(jsonStr,1,(int)TDengineSchemalessProtocol.TSDB_SML_JSON_PROTOCOL,(int)TDengineSchemalessPrecision.TSDB_SML_TIMESTAMP_SECONDS); - sample.checkSelect("stb0_0"); - sample.CloseConnection(); - sample.cleanup(); - } - - public void InitTDengine() - { - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - Console.WriteLine("init..."); - TDengine.Init(); - Console.WriteLine("get connection starting..."); - } - - public void ConnectTDengine() - { - string db = ""; - this.conn = TDengine.Connect(host, this.user, this.passwd, db, this.port); - if (this.conn == IntPtr.Zero) - { - Console.WriteLine("connection failed: " + this.host); - ExitProgram(); - } - else - { - Console.WriteLine("[ OK ] Connection established."); - } - } - public void createDatabase() - { - StringBuilder sql = new StringBuilder(); - sql.Append("create database if not exists ").Append(this.dbName).Append(" precision '").Append(this.dbPrecision).Append("'"); - execute(sql.ToString()); - } - public void useDatabase() - { - StringBuilder sql = new StringBuilder(); - sql.Append("use ").Append(this.dbName); - execute(sql.ToString()); - } - public void checkSelect(String tableName) - { - StringBuilder sql = new StringBuilder(); - sql.Append("select * from ").Append(this.dbName).Append(".").Append(tableName); - ExecuteQuery(sql.ToString()); - } - - public void schemalessInsert(string[] sqlstr, int lineCnt, int protocol, int precision) - { - - IntPtr res = TDengine.SchemalessInsert(this.conn, sqlstr, lineCnt, protocol, precision); - - if (TDengine.ErrorNo(res) != 0) - { - Console.WriteLine("schemaless_insert failed:{0}", TDengine.Error(res)); - Console.WriteLine("line string:{0}", sqlstr); - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine("else"); - Console.WriteLine("schemaless insert success:{0}", TDengine.ErrorNo(res)); - } - DisplayRes(res); - } - public void dropDatabase() - { - StringBuilder sql = new StringBuilder(); - sql.Append("drop database if exists ").Append(this.dbName); - execute(sql.ToString()); - } - public void execute(string sql) - { - DateTime dt1 = DateTime.Now; - - IntPtr res = TDengine.Query(this.conn, sql.ToString()); - - DateTime dt2 = DateTime.Now; - TimeSpan span = dt2 - dt1; - - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - TDengine.FreeResult(res); - } - public void DisplayRes(IntPtr res) - { - long queryRows = 0; - int fieldCount = TDengine.FieldCount(res); - - List metas = TDengine.FetchFields(res); - for (int j = 0; j < metas.Count; j++) - { - TDengineMeta meta = (TDengineMeta)metas[j]; - } - - IntPtr rowdata; - StringBuilder builder = new StringBuilder(); - while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) - { - queryRows++; - for (int fields = 0; fields < fieldCount; ++fields) - { - TDengineMeta meta = metas[fields]; - int offset = IntPtr.Size * fields; - IntPtr data = Marshal.ReadIntPtr(rowdata, offset); - - builder.Append("---"); - - if (data == IntPtr.Zero) - { - builder.Append("NULL"); - continue; - } - - switch ((TDengineDataType)meta.type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; - builder.Append(v1); - break; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - byte v2 = Marshal.ReadByte(data); - builder.Append(v2); - break; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - short v3 = Marshal.ReadInt16(data); - builder.Append(v3); - break; - case TDengineDataType.TSDB_DATA_TYPE_INT: - int v4 = Marshal.ReadInt32(data); - builder.Append(v4); - break; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - long v5 = Marshal.ReadInt64(data); - builder.Append(v5); - break; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); - builder.Append(v6); - break; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); - builder.Append(v7); - break; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - string v8 = Marshal.PtrToStringAnsi(data); - builder.Append(v8); - break; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - long v9 = Marshal.ReadInt64(data); - builder.Append(v9); - break; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - string v10 = Marshal.PtrToStringAnsi(data); - builder.Append(v10); - break; - } - } - builder.Append("---"); - - if (queryRows <= 10) - { - Console.WriteLine(builder.ToString()); - } - builder.Clear(); - } - - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - } - Console.WriteLine(""); - - TDengine.FreeResult(res); - - } - public void ExecuteQuery(string sql) - { - - DateTime dt1 = DateTime.Now; - - IntPtr res = TDengine.Query(conn, sql); - - DateTime dt2 = DateTime.Now; - TimeSpan span = dt2 - dt1; - - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - - Console.WriteLine("[OK] time cost: " + span.ToString() + "ms, execute statement ====> " + sql.ToString()); - DisplayRes(res); - - } - - public void CloseConnection() - { - if (this.conn != IntPtr.Zero) - { - TDengine.Close(this.conn); - Console.WriteLine("connection closed."); - } - } - - static void ExitProgram() - { - System.Environment.Exit(0); - } - - public void cleanup() - { - Console.WriteLine("clean up..."); - System.Environment.Exit(0); - } - // method to get db precision - } -} diff --git a/tests/examples/C#/stmt/StmtDemo.cs b/tests/examples/C#/stmt/StmtDemo.cs deleted file mode 100644 index fdd647fdb5f9c4bb528a2e99acc6975adf4c30a3..0000000000000000000000000000000000000000 --- a/tests/examples/C#/stmt/StmtDemo.cs +++ /dev/null @@ -1,549 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -using System; -using System.Text; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Collections; -namespace TDengineDriver -{ - public class StmtDemo - { - //connection parameters - private string host = "127.0.0.1"; - private string configDir = "C:/TDengine/cfg"; - private string user = "root"; - private string passwd = "taosdata"; - private short port = 0; - - private IntPtr conn = IntPtr.Zero; - private IntPtr stmt = IntPtr.Zero; - - static void Main(string[] args) - { - string dropDB = "drop database if exists csharp"; - string createDB = "create database if not exists csharp keep 36500"; - string selectDB = "use csharp"; - string stmtSql = "insert into ? using stmtdemo tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - string createTable = "create stable stmtdemo (ts timestamp " - + ",b bool" - + ",v1 tinyint" - + ",v2 smallint" - + ",v4 int" - + ",v8 bigint" - + ",f4 float" - + ",f8 double" - + ",u1 tinyint unsigned" - + ",u2 smallint unsigned" - + ",u4 int unsigned" - + ",u8 bigint unsigned" - + ",bin binary(200)" - + ",blob nchar(200)" - + ")tags(" - + "bo bool" - + ",tt tinyint" - + ",si smallint" - + ",ii int" - + ",bi bigint" - + ",tu tinyint unsigned" - + ",su smallint unsigned" - + ",iu int unsigned" - + ",bu bigint unsigned" - + ",ff float " - + ",dd double " - + ",bb binary(200)" - + ",nc nchar(200)" - + ")"; - - string dropTable = "drop table if exists stmtdemo"; - - string tableName = "t1"; - StmtDemo stmtDemo = new StmtDemo(); - Console.WriteLine("---------------------------------------------------------------"); - Console.WriteLine("Start StmtDemo insert Testing..."); - Console.WriteLine("---------------------------------------------------------------"); - stmtDemo.InitTDengine(); - //TDengine connect - stmtDemo.ConnectTDengine(); - - //before stmt - stmtDemo.ExecuteQuery(dropDB); - stmtDemo.ExecuteQuery(createDB); - stmtDemo.ExecuteQuery(selectDB); - stmtDemo.ExecuteQuery(dropTable); - stmtDemo.ExecuteQuery(createTable); - - stmtDemo.StmtInit(); - // string[] tableList = { "stmtdemo" }; - // stmtDemo.loadTableInfo(tableList); - - stmtDemo.StmtPrepare(stmtSql); - TAOS_BIND[] binds = stmtDemo.InitBindArr(); - TAOS_MULTI_BIND[] mbinds = stmtDemo.InitMultBindArr(); - stmtDemo.SetTableNameTags(tableName, binds); - stmtDemo.BindParamBatch(mbinds); - stmtDemo.AddBatch(); - stmtDemo.StmtExecute(); - TaosBind.FreeTaosBind(binds); - TaosMultiBind.FreeTaosBind(mbinds); - stmtDemo.StmtClose(); - - Console.WriteLine("---------------------------------------------------------------"); - Console.WriteLine("start StmtDemo select Testing..."); - Console.WriteLine("---------------------------------------------------------------"); - - stmtDemo.StmtInit(); - string selectSql = "SELECT * FROM stmtdemo WHERE v1 > ? AND v4 < ?"; - - stmtDemo.StmtPrepare(selectSql); - - TAOS_BIND[] queryCondition = new TAOS_BIND[2]; - queryCondition[0] = TaosBind.BindTinyInt(0); - queryCondition[1] = TaosBind.BindInt(1000); - - Console.WriteLine(selectSql); - stmtDemo.BindParam(queryCondition); - stmtDemo.StmtExecute(); - - stmtDemo.StmtUseResult(); - - stmtDemo.StmtClose(); - TaosBind.FreeTaosBind(queryCondition); - Console.WriteLine("---------------------------------------------------------------"); - Console.WriteLine("Stop StmtDemo Testing..."); - Console.WriteLine("---------------------------------------------------------------"); - - stmtDemo.CloseConnection(); - } - public TAOS_BIND[] InitBindArr() - { - TAOS_BIND[] binds = new TAOS_BIND[13]; - binds[0] = TaosBind.BindBool(true); - binds[1] = TaosBind.BindTinyInt(-2); - binds[2] = TaosBind.BindSmallInt(short.MaxValue); - binds[3] = TaosBind.BindInt(int.MaxValue); - binds[4] = TaosBind.BindBigInt(Int64.MaxValue); - binds[5] = TaosBind.BindUTinyInt(byte.MaxValue - 1); - binds[6] = TaosBind.BindUSmallInt(UInt16.MaxValue - 1); - binds[7] = TaosBind.BindUInt(uint.MinValue + 1); - binds[8] = TaosBind.BindUBigInt(UInt64.MinValue + 1); - binds[9] = TaosBind.BindFloat(11.11F); - binds[10] = TaosBind.BindDouble(22.22D); - binds[11] = TaosBind.BindBinary("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); - binds[12] = TaosBind.BindNchar("qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKZXCVBNM`1234567890-=+_)(*&^%$#@!~[];,./<>?:{}"); - return binds; - } - - public TAOS_MULTI_BIND[] InitMultBindArr() - { - TAOS_MULTI_BIND[] mBinds = new TAOS_MULTI_BIND[14]; - long[] tsArr = new long[5] { 1637064040000, 1637064041000, 1637064042000, 1637064043000, 1637064044000 }; - bool?[] boolArr = new bool?[5] { true, false, null, true, true }; - sbyte?[] tinyIntArr = new sbyte?[5] { -127, 0, null, 8, 127 }; - short?[] shortArr = new short?[5] { short.MinValue + 1, -200, null, 100, short.MaxValue }; - int?[] intArr = new int?[5] { -200, -100, null, 0, 300 }; - long?[] longArr = new long?[5] { long.MinValue + 1, -2000, null, 1000, long.MaxValue }; - float?[] floatArr = new float?[5] { float.MinValue + 1, -12.1F, null, 0F, float.MaxValue }; - double?[] doubleArr = new double?[5] { double.MinValue + 1, -19.112D, null, 0D, double.MaxValue }; - byte?[] uTinyIntArr = new byte?[5] { byte.MinValue, 12, null, 89, byte.MaxValue - 1 }; - ushort?[] uShortArr = new ushort?[5] { ushort.MinValue, 200, null, 400, ushort.MaxValue - 1 }; - uint?[] uIntArr = new uint?[5] { uint.MinValue, 100, null, 2, uint.MaxValue - 1 }; - ulong?[] uLongArr = new ulong?[5] { ulong.MinValue, 2000, null, 1000, long.MaxValue - 1 }; - string[] binaryArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", String.Empty, null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?" }; - string[] ncharArr = new string[5] { "1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", null, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM", "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890~!@#$%^&*()_+=-`[]{}:,./<>?", string.Empty }; - mBinds[0] = TaosMultiBind.MultiBindTimestamp(tsArr); - mBinds[1] = TaosMultiBind.MultiBindBool(boolArr); - mBinds[2] = TaosMultiBind.MultiBindTinyInt(tinyIntArr); - mBinds[3] = TaosMultiBind.MultiBindSmallInt(shortArr); - mBinds[4] = TaosMultiBind.MultiBindInt(intArr); - mBinds[5] = TaosMultiBind.MultiBindBigint(longArr); - mBinds[6] = TaosMultiBind.MultiBindFloat(floatArr); - mBinds[7] = TaosMultiBind.MultiBindDouble(doubleArr); - mBinds[8] = TaosMultiBind.MultiBindUTinyInt(uTinyIntArr); - mBinds[9] = TaosMultiBind.MultiBindUSmallInt(uShortArr); - mBinds[10] = TaosMultiBind.MultiBindUInt(uIntArr); - mBinds[11] = TaosMultiBind.MultiBindUBigInt(uLongArr); - mBinds[12] = TaosMultiBind.MultiBindBinary(binaryArr); - mBinds[13] = TaosMultiBind.MultiBindNchar(ncharArr); - return mBinds; - } - - public void loadTableInfo(string[] arr) - { - if (TDengine.LoadTableInfo(this.conn, arr) == 0) - { - Console.WriteLine("load table info success"); - } - else - { - Console.WriteLine("load table info failed"); - ExitProgram(); - } - } - - public void InitTDengine() - { - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - TDengine.Init(); - Console.WriteLine("TDengine Initialization finished"); - } - - public void ConnectTDengine() - { - string db = ""; - this.conn = TDengine.Connect(this.host, this.user, this.passwd, db, this.port); - if (this.conn == IntPtr.Zero) - { - Console.WriteLine("Connect to TDengine failed"); - ExitProgram(); - } - else - { - Console.WriteLine("Connect to TDengine success"); - } - } - - public void ExecuteQuery(String sql) - { - IntPtr res = TDengine.Query(conn, sql); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - else - { - Console.WriteLine(sql.ToString() + " success"); - } - TDengine.FreeResult(res); - } - - public void StmtInit() - { - this.stmt = TDengine.StmtInit(conn); - if (this.stmt == IntPtr.Zero) - { - Console.WriteLine("Init stmt failed"); - ExitProgram(); - } - else - { - Console.WriteLine("Init stmt success"); - } - } - - public void StmtPrepare(string sql) - { - int res = TDengine.StmtPrepare(this.stmt, sql); - if (res == 0) - { - Console.WriteLine("stmt prepare success"); - } - else - { - Console.WriteLine("stmt prepare failed " + TDengine.StmtErrorStr(stmt)); - ExitProgram(); - } - } - - public void SetTableName(String tableName) - { - int res = TDengine.StmtSetTbname(this.stmt, tableName); - Console.WriteLine("setTableName():" + res); - if (res == 0) - { - Console.WriteLine("set_tbname success"); - } - else - { - Console.Write("set_tbname failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - } - - public void SetTableNameTags(String tableName, TAOS_BIND[] tags) - { - int res = TDengine.StmtSetTbnameTags(this.stmt, tableName, tags); - if (res == 0) - { - Console.WriteLine("set tbname && tags success"); - - } - else - { - Console.Write("set tbname && tags failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - } - - public void SetSubTableName(string name) - { - int res = TDengine.StmtSetSubTbname(this.stmt, name); - if (res == 0) - { - Console.WriteLine("set subtable name success"); - } - else - { - Console.Write("set subtable name failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - - } - - public void BindParam(TAOS_BIND[] binds) - { - Console.WriteLine("in bindParam()"); - - int res = TDengine.StmtBindParam(this.stmt, binds); - if (res == 0) - { - Console.WriteLine("bind para success"); - } - else - { - Console.Write("bind para failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - } - - public void BindSingleParamBatch(TAOS_MULTI_BIND bind, int index) - { - int res = TDengine.StmtBindSingleParamBatch(this.stmt,ref bind, index); - if (res == 0) - { - Console.WriteLine("single bind batch success"); - } - else - { - Console.Write("single bind batch failed: " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - } - - public void BindParamBatch(TAOS_MULTI_BIND[] bind) - { - int res = TDengine.StmtBindParamBatch(this.stmt, bind); - if (res == 0) - { - Console.WriteLine("bind parameter batch success"); - } - else - { - Console.WriteLine("bind parameter batch failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - } - - public void AddBatch() - { - int res = TDengine.StmtAddBatch(this.stmt); - if (res == 0) - { - Console.WriteLine("stmt add batch success"); - } - else - { - Console.Write("stmt add batch failed,reason: " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - } - public void StmtExecute() - { - int res = TDengine.StmtExecute(this.stmt); - if (res == 0) - { - Console.WriteLine("Execute stmt success"); - } - else - { - Console.Write("Execute stmt failed,reason: " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - } - public void StmtClose() - { - int res = TDengine.StmtClose(this.stmt); - if (res == 0) - { - Console.WriteLine("close stmt success"); - } - else - { - Console.WriteLine("close stmt failed, " + TDengine.StmtErrorStr(stmt)); - StmtClose(); - ExitProgram(); - } - } - public void CloseConnection() - { - if (this.conn != IntPtr.Zero) - { - if (TDengine.Close(this.conn) == 0) - { - Console.WriteLine("close connection sucess"); - } - else - { - Console.WriteLine("close Connection failed"); - } - } - } - - //select only - public void StmtUseResult() - { - IntPtr res = TDengine.StmtUseResult(this.stmt); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - StmtClose(); - CloseConnection(); - ExitProgram(); - } - else - { - Console.WriteLine("{0},query success"); - DisplayRes(res); - TDengine.FreeResult(res); - } - - } - - public void DisplayRes(IntPtr res) - { - - long queryRows = 0; - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - if (res != IntPtr.Zero) - { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - ExitProgram(); - } - - int fieldCount = TDengine.FieldCount(res); - List metas = TDengine.FetchFields(res); - for (int j = 0; j < metas.Count; j++) - { - TDengineMeta meta = (TDengineMeta)metas[j]; - } - - IntPtr rowdata; - StringBuilder builder = new StringBuilder(); - while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) - { - queryRows++; - for (int fields = 0; fields < fieldCount; ++fields) - { - TDengineMeta meta = metas[fields]; - int offset = IntPtr.Size * fields; - IntPtr data = Marshal.ReadIntPtr(rowdata, offset); - - builder.Append("---"); - - if (data == IntPtr.Zero) - { - builder.Append("NULL"); - continue; - } - - switch ((TDengineDataType)meta.type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; - builder.Append(v1); - break; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - byte v2 = Marshal.ReadByte(data); - builder.Append(v2); - break; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - short v3 = Marshal.ReadInt16(data); - builder.Append(v3); - break; - case TDengineDataType.TSDB_DATA_TYPE_INT: - int v4 = Marshal.ReadInt32(data); - builder.Append(v4); - break; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - long v5 = Marshal.ReadInt64(data); - builder.Append(v5); - break; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); - builder.Append(v6); - break; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); - builder.Append(v7); - break; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - string v8 = Marshal.PtrToStringAnsi(data); - builder.Append(v8); - break; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - long v9 = Marshal.ReadInt64(data); - builder.Append(v9); - break; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - string v10 = Marshal.PtrToStringAnsi(data); - builder.Append(v10); - break; - } - } - builder.Append("---"); - - if (queryRows <= 10) - { - Console.WriteLine(builder.ToString()); - } - builder.Clear(); - } - - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", TDengine.ErrorNo(res), TDengine.Error(res)); - } - Console.WriteLine(""); - - } - public static void ExitProgram() - { - TDengine.Cleanup(); - System.Environment.Exit(0); - } - } -} diff --git a/tests/examples/C#/stmt/stmt.csproj b/tests/examples/C#/stmt/stmt.csproj deleted file mode 100644 index f0370cbf5684418edb026b56e306d7d7295a6638..0000000000000000000000000000000000000000 --- a/tests/examples/C#/stmt/stmt.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - Exe - net5.0 - - - diff --git a/tests/examples/C#/taosdemo/Dockerfile b/tests/examples/C#/taosdemo/Dockerfile deleted file mode 100644 index 4eefc6c75248b1e1e1d6daf305386cca5b11e606..0000000000000000000000000000000000000000 --- a/tests/examples/C#/taosdemo/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM tdengine/tdengine-beta:latest - -ENV DEBIAN_FRONTEND=noninteractive -ARG MIRROR=archive.ubuntu.com -RUN sed -Ei 's/\w+.ubuntu.com/'${MIRROR}'/' /etc/apt/sources.list && apt update && apt install mono-devel -y -RUN apt-get install wget -y \ - && wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \ - && dpkg -i packages-microsoft-prod.deb \ - && rm packages-microsoft-prod.deb \ - && apt-get update && apt-get install -y dotnet-sdk-5.0 -COPY ./*.cs *.csproj /tmp/ -WORKDIR /tmp/ -RUN dotnet build -c Release && cp bin/Release/net5.0/taosdemo bin/Release/net5.0/taosdemo.* /usr/local/bin/ && rm -rf /tmp/* - -FROM tdengine/tdengine-beta:latest - -ENV DEBIAN_FRONTEND=noninteractive -RUN apt-get update && apt-get install wget -y \ - && wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \ - && dpkg -i packages-microsoft-prod.deb \ - && rm packages-microsoft-prod.deb \ - && apt-get update && apt-get install -y dotnet-runtime-5.0 -COPY --from=0 /usr/local/bin/taosdemo* /usr/local/bin/ -CMD ["/usr/local/bin/taosdemo"] diff --git a/tests/examples/C#/taosdemo/README.md b/tests/examples/C#/taosdemo/README.md deleted file mode 100644 index 3cba3529bf513e2bf3d4ab0c169e7f3d03b2e6a8..0000000000000000000000000000000000000000 --- a/tests/examples/C#/taosdemo/README.md +++ /dev/null @@ -1,65 +0,0 @@ -# C# Taosdemo - -## For Mono - -install build environment - -```sh -yum/apt install mono-complete -``` - -build C# version taosdemo. - -```sh -mcs -out:taosdemo *.cs -./taosdemo --help -``` - -## For DotNet - -install dotnet environment. - -```sh -wget https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \ - && dpkg -i packages-microsoft-prod.deb \ - && rm packages-microsoft-prod.deb \ - && apt-get update && apt-get install -y dotnet-sdk-5.0 -``` - -Build DotNet version taosdemo. - -```sh -dotnet build -c Release -./bin/Release/net5.0/taosdemo --help -``` - -## Usage - -``` -Usage: mono taosdemo.exe [OPTION...] - - --help Show usage. - - -h host, The host to connect to TDengine. Default is localhost. - -p port, The TCP/IP port number to use for the connection. Default is 0. - -u user, The user name to use when connecting to the server. Default is 'root'. - -P password, The password to use when connecting to the server. Default is 'taosdata'. - -d database, Destination database. Default is 'test'. - -a replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. - -m table_prefix, Table prefix name. Default is 't'. - -M stable, Use super table. - -s stable_prefix, STable prefix name. Default is 'st' - -Q query, Execute query command. set 'DEFAULT' means select * from each table - -T num_of_threads, The number of threads. Default is 10. - -r num_of_records_per_req, The number of records per request. Default is 1000. - -t num_of_tables, The number of tables. Default is 1. - -n num_of_records_per_table, The number of records per table. Default is 1. - -c config_directory, Configuration directory. Default is '/etc/taos/'. - -x flag, Insert only flag. - -O order, Insert mode--0: In order, 1: Out of order. Default is in order. - -R rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50. - -D Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database. - -v Print verbose output - -g Print debug output - -y Skip read key for continous test, default is not skip -``` diff --git a/tests/examples/C#/taosdemo/taosdemo.cs b/tests/examples/C#/taosdemo/taosdemo.cs deleted file mode 100644 index e62a502d1508c1339e559160b50da39e622a021f..0000000000000000000000000000000000000000 --- a/tests/examples/C#/taosdemo/taosdemo.cs +++ /dev/null @@ -1,908 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -using System; -using System.Text; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Collections; -using System.Threading; -using System.Diagnostics; - -namespace TDengineDriver -{ - class TDengineTest - { - //connect parameters - private string host = "127.0.0.1"; - private string configDir = "C:/TDengine/cfg"; - private string user = "root"; - private string password = "taosdata"; - private short port = 0; - - //sql parameters - private string dbName = "db"; - private string stablePrefix = "st"; - private string tablePrefix = "t"; - - private bool isInsertOnly = false; - private string query = "NONE"; - private short queryMode = 1; - - private long recordsPerTable = 1; - private int recordsPerRequest = 1; - private int colsPerRecord = 3; - private long batchRows = 1000; - private long numOfTables = 1; - private short replica = 1; - - private IntPtr conn = IntPtr.Zero; - // private long rowsInserted = 0; - private bool useStable = false; - private short methodOfDelete = 0; - private long numOfThreads = 1; - private short rateOfOutorder = 10; - private bool order = true; - private bool skipReadKey = false; - private bool verbose = false; - private bool debug = false; - - - static void HelpPrint(string arg, string desc) - { - string indent = " "; - Console.WriteLine("{0}{1}", indent, arg.PadRight(25) + desc); - } - - static void PrintHelp(String[] argv) - { - for (int i = 0; i < argv.Length; ++i) - { - if ("--help" == argv[i]) - { - Console.WriteLine("Usage: mono taosdemo.exe [OPTION...]"); - Console.WriteLine(""); - HelpPrint("--help", "Show usage."); - Console.WriteLine(""); - - HelpPrint("-h ", "host, The host to connect to TDengine. Default is localhost."); - HelpPrint("-p ", "port, The TCP/IP port number to use for the connection. Default is 0."); - HelpPrint("-u ", "user, The user name to use when connecting to the server. Default is 'root'."); - HelpPrint("-P ", "password, The password to use when connecting to the server. Default is 'taosdata'."); - HelpPrint("-d ", "database, Destination database. Default is 'test'."); - HelpPrint("-a ", "replica, Set the replica parameters of the database, Default 1, min: 1, max: 5."); - HelpPrint("-m
", "table_prefix, Table prefix name. Default is 't'."); - HelpPrint("-M", "stable, Use super table."); - HelpPrint("-s ", "stable_prefix, STable prefix name. Default is 'st'"); - HelpPrint("-Q ", "query, Execute query command. set 'DEFAULT' means select * from each table"); - /* NOT SUPPORT SO FAR - HelpPrint("-o", "outputfile, Direct output to the named file. Default is './output.txt'."); - HelpPrint("-q", "query_mode, Query mode--0: SYNC, 1: ASYNC. Default is SYNC."); - HelpPrint("-b", "type_of_cols, data_type of columns: 'INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'BINARY'. Default is 'INT'."); - HelpPrint("-w", "length_of_binary, The length of data_type 'BINARY'. Only applicable when type of cols is 'BINARY'. Default is 8"); - HelpPrint("-l", "num_of_cols_per_record, The number of columns per record. Default is 3."); - */ - HelpPrint("-T ", "num_of_threads, The number of threads. Default is 10."); - HelpPrint("-r ", "num_of_records_per_req, The number of records per request. Default is 1000."); - HelpPrint("-t ", "num_of_tables, The number of tables. Default is 1."); - HelpPrint("-n ", "num_of_records_per_table, The number of records per table. Default is 1."); - HelpPrint("-c ", "config_directory, Configuration directory. Default is '/etc/taos/'."); - HelpPrint("-x", "flag, Insert only flag."); - HelpPrint("-O", "order, Insert mode--0: In order, 1: Out of order. Default is in order."); - HelpPrint("-R ", "rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50."); - HelpPrint("-D ", "Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database."); - HelpPrint("-v", "Print verbose output"); - HelpPrint("-g", "Print debug output"); - HelpPrint("-y", "Skip read key for continous test, default is not skip"); - - System.Environment.Exit(0); - } - } - } - - public void ReadArgument(String[] argv) - { - host = this.GetArgumentAsString(argv, "-h", "127.0.0.1"); - port = (short)this.GetArgumentAsLong(argv, "-p", 0, 65535, 6030); - user = this.GetArgumentAsString(argv, "-u", "root"); - password = this.GetArgumentAsString(argv, "-P", "taosdata"); - dbName = this.GetArgumentAsString(argv, "-d", "taosdemo_cs"); - stablePrefix = this.GetArgumentAsString(argv, "-s", "st"); - tablePrefix = this.GetArgumentAsString(argv, "-m", "t"); - isInsertOnly = this.GetArgumentAsFlag(argv, "-x", true); - query = this.GetArgumentAsString(argv, "-Q", "NONE"); - queryMode = (short)this.GetArgumentAsLong(argv, "-q", 0, 1, 0); - numOfTables = this.GetArgumentAsLong(argv, "-t", 1, 1000000000, 1); - batchRows = this.GetArgumentAsLong(argv, "-r", 1, 10000, 1000); - recordsPerTable = this.GetArgumentAsLong(argv, "-n", 1, 100000000000, 1); - recordsPerRequest = (int)this.GetArgumentAsLong(argv, "-r", 1, 10000, 1); - colsPerRecord = (int)this.GetArgumentAsLong(argv, "-l", 1, 1024, 3); - configDir = this.GetArgumentAsString(argv, "-c", "C:/TDengine/cfg"); - useStable = this.GetArgumentAsFlag(argv, "-M", true); - - replica = (short)this.GetArgumentAsLong(argv, "-a", 1, 5, 1); - methodOfDelete = (short)this.GetArgumentAsLong(argv, "-D", 0, 3, 0); - numOfThreads = (short)this.GetArgumentAsLong(argv, "-T", 1, 10000, 1); - order = this.GetArgumentAsFlag(argv, "-O", false); - rateOfOutorder = (short)this.GetArgumentAsLong(argv, "-R", 0, 50, 10); - - skipReadKey = this.GetArgumentAsFlag(argv, "-y", true); - verbose = this.GetArgumentAsFlag(argv, "-v", true); - debug = this.GetArgumentAsFlag(argv, "-g", true); - - VerbosePrint("###################################################################\n"); - VerbosePrintFormat("# Server IP: {0}\n", host); - VerbosePrintFormat("# User: {0}\n", user); - VerbosePrintFormat("# Password: {0}\n", password); - VerbosePrintFormat("# Number of Columns per record: {0}\n", colsPerRecord); - VerbosePrintFormat("# Number of Threads: {0}\n", numOfThreads); - VerbosePrintFormat("# Number of Tables: {0}\n", numOfTables); - VerbosePrintFormat("# Number of records per Table: {0}\n", recordsPerTable); - VerbosePrintFormat("# Records/Request: {0}\n", recordsPerRequest); - VerbosePrintFormat("# Database name: {0}\n", dbName); - VerbosePrintFormat("# Replica: {0}\n", replica); - VerbosePrintFormat("# Use STable: {0}\n", useStable); - VerbosePrintFormat("# Table prefix: {0}\n", tablePrefix); - if (useStable == true) - { - VerbosePrintFormat("# STable prefix: {0}\n", stablePrefix); - } - VerbosePrintFormat("# Data order: {0}\n", order); - VerbosePrintFormat("# Data out of order rate: {0}\n", rateOfOutorder); - VerbosePrintFormat("# Delete method: {0}\n", methodOfDelete); - VerbosePrintFormat("# Query command: {0}\n", query); - VerbosePrintFormat("# Query Mode: {0}\n", queryMode); - VerbosePrintFormat("# Insert Only: {0}\n", isInsertOnly); - VerbosePrintFormat("# Verbose output {0}\n", verbose); - VerbosePrintFormat("# Test time: {0}\n", DateTime.Now.ToString("h:mm:ss tt")); - - VerbosePrint("###################################################################\n"); - - if (skipReadKey == false) - { - Console.Write("Press any key to continue..\n"); - Console.ReadKey(); - } - } - - public bool GetArgumentAsFlag(String[] argv, String argName, bool defaultValue) - { - int argc = argv.Length; - for (int i = 0; i < argc; ++i) - { - if (argName == argv[i]) - { - return defaultValue; - } - } - return !defaultValue; - } - - public long GetArgumentAsLong(String[] argv, String argName, int minVal, long maxVal, int defaultValue) - { - int argc = argv.Length; - for (int i = 0; i < argc; ++i) - { - if (argName != argv[i]) - { - continue; - } - if (i < argc - 1) - { - String tmp = argv[i + 1]; - if (tmp[0] == '-') - { - Console.WriteLine("option {0:G} requires an argument", argName); - ExitProgram(1); - } - - long tmpVal = Convert.ToInt64(tmp); - if (tmpVal < minVal || tmpVal > maxVal) - { - Console.WriteLine("option {0:G} value should in range [{1:G}, {2:G}]", argName, minVal, maxVal); - ExitProgram(1); - } - - return tmpVal; - } - } - - return defaultValue; - } - - public String GetArgumentAsString(String[] argv, String argName, String defaultValue) - { - int argc = argv.Length; - for (int i = 0; i < argc; ++i) - { - if (argName != argv[i]) - { - continue; - } - if (i < argc - 1) - { - String tmp = argv[i + 1]; - if (tmp[0] == '-') - { - Console.WriteLine("option {0:G} requires an argument", argName); - ExitProgram(1); - } - return tmp; - } - } - - return defaultValue; - } - - static void CleanAndExitProgram(int ret) - { - TDengine.Cleanup(); - System.Environment.Exit(ret); - } - - static void ExitProgram(int ret) - { - System.Environment.Exit(ret); - } - - private void VerbosePrintFormat(string format, params object[] parameters) - { - if (verbose == true) - { - Console.Write(format, parameters); - } - } - - private void VerbosePrint(string str) - { - if (verbose == true) - { - Console.Write(str); - } - } - - private void DebugPrintFormat(string format, params object[] parameters) - { - if (debug == true) - { - Console.Write(format, parameters); - } - } - - private void DebugPrint(string str) - { - if (debug == true) - { - Console.Write(str); - } - } - - public void InitTDengine() - { - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_CONFIGDIR, this.configDir); - TDengine.Options((int)TDengineInitOption.TDDB_OPTION_SHELL_ACTIVITY_TIMER, "60"); - TDengine.Init(); - VerbosePrint("TDengine Initialization finished\n"); - } - - public void ConnectTDengine() - { - string db = ""; - VerbosePrintFormat("host:{0} user:{1}, pass:{2}; db:{3}, port:{4}\n", - this.host, this.user, this.password, db, this.port); - this.conn = TDengine.Connect(this.host, this.user, this.password, db, this.port); - if (this.conn == IntPtr.Zero) - { - Console.WriteLine("Connect to TDengine failed"); - CleanAndExitProgram(1); - } - else - { - VerbosePrint("Connect to TDengine success\n"); - } - } - - public void CreateTablesByThreads() - { - Thread[] threadArr = new Thread[numOfThreads]; - - long quotition = numOfTables / numOfThreads; - if (quotition < 1) - { - numOfThreads = numOfTables; - quotition = 1; - } - - long remainder = 0; - if (numOfThreads != 0) - { - remainder = numOfTables % numOfThreads; - } - - long last = 0; - - for (int i = 0; i < numOfThreads; i++) - { - CreateTableThread createTableThread = new CreateTableThread(); - createTableThread.id = i; - createTableThread.verbose = verbose; - createTableThread.debug = debug; - createTableThread.dbName = this.dbName; - createTableThread.tablePrefix = this.tablePrefix; - createTableThread.useStable = useStable; - if (useStable) - { - createTableThread.stablePrefix = stablePrefix; - } - createTableThread.conn = conn; - - createTableThread.start = last; - if (i < remainder) - { - createTableThread.end = last + quotition; - } - else - { - createTableThread.end = last + quotition - 1; - } - last = createTableThread.end + 1; - - threadArr[i] = new Thread(createTableThread.ThreadMain); - threadArr[i].Start(); - } - for (int j = 0; j < numOfThreads; j++) - { - threadArr[j].Join(); - } - } - - public void dropDatabase() - { - StringBuilder sql = new StringBuilder(); - sql.Append("DROP DATABASE IF EXISTS ").Append(this.dbName); - IntPtr res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - CleanAndExitProgram(1); - } - else - { - VerbosePrint(sql.ToString() + " success\n"); - } - } - - public void CreateDb() - { - StringBuilder sql = new StringBuilder(); - sql.Append("CREATE DATABASE IF NOT EXISTS ").Append(this.dbName).Append(" replica ").Append(this.replica).Append(" keep 36500"); - IntPtr res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - CleanAndExitProgram(1); - } - else - { - VerbosePrint(sql.ToString() + " success\n"); - } - TDengine.FreeResult(res); - } - - public void CreateStable() - { - StringBuilder sql = new StringBuilder(); - - sql.Clear(); - sql.Append("CREATE TABLE IF NOT EXISTS "). - Append(this.dbName).Append(".").Append(this.stablePrefix). - Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10), v10 tinyint unsigned, v11 smallint unsigned, v12 int unsigned, v13 bigint unsigned) tags(t1 int)"); - IntPtr res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - CleanAndExitProgram(1); - } - else - { - VerbosePrint(sql.ToString() + " success\n"); - } - TDengine.FreeResult(res); - } - - public void InsertByThreads() - { - Thread[] threadArr = new Thread[numOfThreads]; - - long quotition = numOfTables / numOfThreads; - if (quotition < 1) - { - numOfThreads = numOfTables; - quotition = 1; - } - - long remainder = 0; - if (numOfThreads != 0) - { - remainder = numOfTables % numOfThreads; - } - - long last = 0; - - for (int i = 0; i < numOfThreads; i++) - { - InsertDataThread insertThread = new InsertDataThread(); - insertThread.id = i; - insertThread.recordsPerTable = recordsPerTable; - insertThread.batchRows = batchRows; - insertThread.numOfTables = numOfTables; - insertThread.verbose = verbose; - insertThread.debug = debug; - insertThread.dbName = this.dbName; - insertThread.tablePrefix = this.tablePrefix; - insertThread.order = this.order; - insertThread.rateOfOutorder = this.rateOfOutorder; - if (useStable) - { - insertThread.stablePrefix = stablePrefix; - } - insertThread.conn = conn; - - insertThread.start = last; - if (i < remainder) - { - insertThread.end = last + quotition; - } - else - { - insertThread.end = last + quotition - 1; - } - last = insertThread.end + 1; - - threadArr[i] = new Thread(insertThread.ThreadMain); - threadArr[i].Start(); - } - for (int j = 0; j < numOfThreads; j++) - { - threadArr[j].Join(); - } - } - - public void ExecuteQuery() - { - long queryRows = 0; - - for (int i = 0; i < this.numOfTables; ++i) - { - string sql; - - if (query == "DEFAULT") - { - sql = "select * from " + this.dbName + "." + tablePrefix + i; - } - else - { - sql = query; - } - DebugPrintFormat("query: {0}, sql:{1}\n", query, sql); - - IntPtr res = TDengine.Query(conn, sql); - DebugPrintFormat("res: {0}\n", res); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - CleanAndExitProgram(1); - } - - int fieldCount = TDengine.FieldCount(res); - DebugPrint("field count: " + fieldCount + "\n"); - - List metas = TDengine.FetchFields(res); - for (int j = 0; j < metas.Count; j++) - { - TDengineMeta meta = (TDengineMeta)metas[j]; - DebugPrint("index:" + j + ", type:" + meta.type + ", typename:" + meta.TypeName() + ", name:" + meta.name + ", size:" + meta.size + "\n"); - } - - IntPtr rowdata; - StringBuilder builder = new StringBuilder(); - - while ((rowdata = TDengine.FetchRows(res)) != IntPtr.Zero) - { - queryRows++; - for (int fields = 0; fields < fieldCount; ++fields) - { - TDengineMeta meta = metas[fields]; - int offset = IntPtr.Size * fields; - IntPtr data = Marshal.ReadIntPtr(rowdata, offset); - - builder.Append(" | "); - - if (data == IntPtr.Zero) - { - builder.Append("NULL"); - continue; - } - - switch ((TDengineDataType)meta.type) - { - case TDengineDataType.TSDB_DATA_TYPE_BOOL: - bool v1 = Marshal.ReadByte(data) == 0 ? false : true; - builder.Append(v1); - break; - case TDengineDataType.TSDB_DATA_TYPE_TINYINT: - sbyte v2 = (sbyte)Marshal.ReadByte(data); - builder.Append(v2); - break; - case TDengineDataType.TSDB_DATA_TYPE_SMALLINT: - short v3 = Marshal.ReadInt16(data); - builder.Append(v3); - break; - case TDengineDataType.TSDB_DATA_TYPE_INT: - int v4 = Marshal.ReadInt32(data); - builder.Append(v4); - break; - case TDengineDataType.TSDB_DATA_TYPE_BIGINT: - long v5 = Marshal.ReadInt64(data); - builder.Append(v5); - break; - case TDengineDataType.TSDB_DATA_TYPE_FLOAT: - float v6 = (float)Marshal.PtrToStructure(data, typeof(float)); - builder.Append(v6); - break; - case TDengineDataType.TSDB_DATA_TYPE_DOUBLE: - double v7 = (double)Marshal.PtrToStructure(data, typeof(double)); - builder.Append(v7); - break; - case TDengineDataType.TSDB_DATA_TYPE_BINARY: - string v8 = Marshal.PtrToStringAnsi(data); - builder.Append(v8); - break; - case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP: - long v9 = Marshal.ReadInt64(data); - builder.Append(v9); - break; - case TDengineDataType.TSDB_DATA_TYPE_NCHAR: - string v10 = Marshal.PtrToStringAnsi(data); - builder.Append(v10); - break; - case TDengineDataType.TSDB_DATA_TYPE_UTINYINT: - byte v11 = Marshal.ReadByte(data); - builder.Append(v11); - break; - case TDengineDataType.TSDB_DATA_TYPE_USMALLINT: - ushort v12 = (ushort)Marshal.ReadInt16(data); - builder.Append(v12); - break; - case TDengineDataType.TSDB_DATA_TYPE_UINT: - uint v13 = (uint)Marshal.ReadInt32(data); - builder.Append(v13); - break; - case TDengineDataType.TSDB_DATA_TYPE_UBIGINT: - ulong v14 = (ulong)Marshal.ReadInt64(data); - builder.Append(v14); - break; - } - } - builder.Append(" | "); - - VerbosePrint(builder.ToString() + "\n"); - builder.Clear(); - } - - if (TDengine.ErrorNo(res) != 0) - { - Console.Write("Query is not complete, Error {0:G}", - TDengine.ErrorNo(res), TDengine.Error(res)); - } - - TDengine.FreeResult(res); - } - } - - public void CloseConnection() - { - if (this.conn != IntPtr.Zero) - { - TDengine.Close(this.conn); - } - } - - // Main entry - static void Main(string[] args) - { - PrintHelp(args); - - TDengineTest tester = new TDengineTest(); - tester.ReadArgument(args); - - tester.InitTDengine(); - tester.ConnectTDengine(); - - if (tester.isInsertOnly == false) - { - tester.dropDatabase(); - tester.CreateDb(); - - - if (tester.useStable == true) - { - tester.CreateStable(); - } - - tester.CreateTablesByThreads(); - } - - Stopwatch watch = Stopwatch.StartNew(); - tester.InsertByThreads(); - watch.Stop(); - double elapsedMs = watch.Elapsed.TotalMilliseconds; - - Console.WriteLine("C# taosdemo: Spent {0} seconds to insert {1} records with {2} record(s) per request: {3} records/second", - elapsedMs / 1000, - tester.recordsPerTable * tester.numOfTables, - tester.batchRows, - (tester.recordsPerTable * tester.numOfTables * 1000) / elapsedMs); - - tester.DebugPrintFormat("query command:{0}\n", tester.query); - if (tester.query != "NONE") - { - watch = Stopwatch.StartNew(); - tester.ExecuteQuery(); - watch.Stop(); - elapsedMs = watch.Elapsed.TotalMilliseconds; - Console.WriteLine("C# taosdemo: Spent {0} seconds to query {1} records.\n", - elapsedMs / 1000, - tester.recordsPerTable * tester.numOfTables - ); - } - tester.CloseConnection(); - - Console.WriteLine("End."); - CleanAndExitProgram(0); - } - - public class InsertDataThread - { - public long id { set; get; } - public long start { set; get; } - public long end { set; get; } - public string dbName { set; get; } - public IntPtr conn { set; get; } - public string tablePrefix { set; get; } - public string stablePrefix { set; get; } - public long recordsPerTable { set; get; } - public long batchRows { set; get; } - public long numOfTables { set; get; } - public bool verbose { set; get; } - public bool debug { set; get; } - public bool order { set; get; } - public short rateOfOutorder { set; get; } - - private void VerbosePrintFormat(string format, params object[] parameters) - { - if (verbose == true) - { - Console.Write(format, parameters); - } - } - - private void VerbosePrint(string str) - { - if (verbose == true) - { - Console.Write(str); - } - } - - private void DebugPrintFormat(string format, params object[] parameters) - { - if (debug == true) - { - Console.Write(format, parameters); - } - } - - private void DebugPrint(string str) - { - if (debug == true) - { - Console.Write(str); - } - } - - public void ThreadMain() - { - VerbosePrintFormat("InsertDataThread {0} from {1} to {2}\n", id, start, end); - StringBuilder sql = new StringBuilder(); - - DateTime now = DateTime.Now; - int h = now.Hour; - int m = now.Minute; - int s = now.Second; - - long baseTimestamp = -16094340000; // 1969-06-29 01:21:00 - VerbosePrintFormat("beginTime is {0} + {1}h:{2}m:{3}s\n", baseTimestamp, h, m, s); - long beginTimestamp = baseTimestamp + ((h * 60 + m) * 60 + s) * 1000; - Random random = new Random(); - - long rowsInserted = 0; - - long i = 0; - while (i < recordsPerTable) - { - for (long table = start; table <= end; ++table) - { - long inserted = i; - - sql.Clear(); - sql.Append("INSERT INTO "). - Append(this.dbName).Append(".").Append(this.tablePrefix).Append(table). - Append(" VALUES"); - if (recordsPerTable < batchRows) - { - batchRows = recordsPerTable; - } - for (int batch = 0; batch < batchRows; ++batch) - { - long writeTimeStamp = beginTimestamp + i + batch; - int rnd = 100; - if (this.order == false) - { - rnd = random.Next(1, 100); - if (rnd <= this.rateOfOutorder) - { - writeTimeStamp = writeTimeStamp + rnd * 10000; - DebugPrint("### "); - } - DebugPrintFormat("order:{0} rnd:{1} timestamp:{2}\n", this.order, rnd, writeTimeStamp); - } - else - { - DebugPrintFormat("order:{0} timestamp:{1}\n", this.order, writeTimeStamp); - } - - sql.Append("(") - .Append(writeTimeStamp) - .Append(", 1, -2, -3,") - .Append(i + batch - 127) - .Append(", -5, -6, -7, 'abc', 'def', 254, 65534,") - .Append(4294967294 - (uint)i - (uint)batch) - .Append(",") - .Append(18446744073709551614 - (ulong)i - (ulong)batch) - .Append(")"); - - } - VerbosePrint(sql.ToString() + "\n"); - IntPtr res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - } - - inserted += this.batchRows; - - int affectRows = TDengine.AffectRows(res); - rowsInserted += affectRows; - - TDengine.FreeResult(res); - if (table == end) - { - i = inserted; - } - } - } - - } - } - - public class CreateTableThread - { - public long id { set; get; } - public long start { set; get; } - public long end { set; get; } - public string dbName { set; get; } - public IntPtr conn { set; get; } - public string tablePrefix { set; get; } - public string stablePrefix { set; get; } - public bool verbose { set; get; } - public bool debug { set; get; } - public bool useStable { set; get; } - - private void VerbosePrintFormat(string format, params object[] parameters) - { - if (verbose == true) - { - Console.Write(format, parameters); - } - } - - private void VerbosePrint(string str) - { - if (verbose == true) - { - Console.Write(str); - } - } - - private void DebugPrintFormat(string format, params object[] parameters) - { - if (debug == true) - { - Console.Write(format, parameters); - } - } - - public void ThreadMain() - { - VerbosePrintFormat("CreateTable {0} from {1} to {2}\n", id, start, end); - - StringBuilder sql = new StringBuilder(); - - for (long tableId = start; tableId <= end; tableId++) - { - sql.Clear(); - sql = sql.Append("CREATE TABLE IF NOT EXISTS "). - Append(this.dbName).Append(".").Append(this.tablePrefix).Append(tableId); - if (useStable == true) - { - sql = sql.Append(" USING ").Append(this.dbName).Append(".").Append(this.stablePrefix). - Append(" TAGS(").Append(tableId).Append(")"); - } - else - { - sql = sql.Append("(ts timestamp, v1 bool, v2 tinyint, v3 smallint, v4 int, v5 bigint, v6 float, v7 double, v8 binary(10), v9 nchar(10), v10 tinyint unsigned, v11 smallint unsigned, v12 int unsigned, v13 bigint unsigned)"); - } - IntPtr res = TDengine.Query(this.conn, sql.ToString()); - if ((res == IntPtr.Zero) || (TDengine.ErrorNo(res) != 0)) - { - Console.Write(sql.ToString() + " failure, "); - if (res != IntPtr.Zero) { - Console.Write("reason: " + TDengine.Error(res)); - } - Console.WriteLine(""); - CleanAndExitProgram(1); - } - else - { - VerbosePrint(sql.ToString() + " success\n"); - } - TDengine.FreeResult(res); - } - - } - } - } -} diff --git a/tests/examples/C#/taosdemo/taosdemo.csproj b/tests/examples/C#/taosdemo/taosdemo.csproj deleted file mode 100644 index 8d4b786ba3a99b600783a5b4ee55d99f03e47655..0000000000000000000000000000000000000000 --- a/tests/examples/C#/taosdemo/taosdemo.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - Exe - net5.0 - false - - - - - - - diff --git a/tests/examples/JDBC/JDBCDemo/.gitignore b/tests/examples/JDBC/JDBCDemo/.gitignore deleted file mode 100644 index b79f223d17fd22185243066700aede395f6328fd..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/.gitignore +++ /dev/null @@ -1,19 +0,0 @@ -# custom -/out/ -/logs/ -*.jar - -# Created by .ignore support plugin (hsz.mobi) -.gitignore - -# Build Artifacts -.gradle/* -build/* -target/* -bin/* -dependency-reduced-pom.xml - -# Eclipse Project Files -.classpath -.project -.settings/* diff --git a/tests/examples/JDBC/JDBCDemo/README-jdbc-windows.md b/tests/examples/JDBC/JDBCDemo/README-jdbc-windows.md deleted file mode 100644 index 17c5c8df00ab8727d1adfe493d3fbbd32891a676..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/README-jdbc-windows.md +++ /dev/null @@ -1,268 +0,0 @@ -# 如何在 windows环境下使用jdbc进行TDengine应用开发 - -本文以windows环境为例,介绍java如何进行TDengine开发应用 - -## 环境准备 - -(1)安装jdk - -官网下载jdk-1.8,下载页面:https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html - -安装,配置环境变量,把jdk加入到环境变量里。 - -命令行内查看java的版本。 - -```shell ->java -version -java version "1.8.0_131" -Java(TM) SE Runtime Environment (build 1.8.0_131-b11) -Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode) -``` - - -(2)安装配置maven - -官网下载maven,下载地址:http://maven.apache.org/download.cgi - -配置环境变量MAVEN_HOME,将MAVEN_HOME/bin添加到PATH - -命令行里查看maven的版本 - -```shell ->mvn --version -Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00) -Maven home: D:\apache-maven-3.5.0\bin\.. -Java version: 1.8.0_131, vendor: Oracle Corporation -Java home: C:\Program Files\Java\jdk1.8.0_131\jre -Default locale: zh_CN, platform encoding: GBK -OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows" -``` - -为了加快maven下载依赖的速度,可以为maven配置mirror,修改MAVEN_HOME\config\settings.xml文件 - -```xml - - - D:\apache-maven-localRepository - - - - - alimaven - aliyun maven - http://maven.aliyun.com/nexus/content/groups/public/ - central - - - - - - - jdk-1.8 - - true - 1.8 - - - 1.8 - 1.8 - 1.8 - - - - -``` - - - -(3)在linux服务器上安装TDengine-server - -在taosdata官网下载TDengine-server,下载地址:https://www.taosdata.com/cn/all-downloads/ - -在linux服务器上安装TDengine-server - -```shell -# tar -zxvf package/TDengine-server-2.0.1.1-Linux-x64.tar.gz -# cd TDengine-server/ -# ./install.sh -``` - -启动taosd - -```shell -# systemctl start taosd -``` - -在server上用taos连接taosd - -```shell -# taos -taos> show dnodes; - id | end_point | vnodes | cores | status | role | create_time | -================================================================================================================== - 1 | td01:6030 | 2 | 4 | ready | any | 2020-08-19 18:40:25.045 | -Query OK, 1 row(s) in set (0.005765s) -``` - -如果可以正确连接到taosd实例,并打印出databases的信息,说明TDengine的server已经正确启动。这里查看server的hostname - -```shell -# hostname -f -td01 -``` - -注意,如果安装TDengine后,使用默认的taos.cfg配置文件,taosd会使用当前server的hostname创建dnode实例。之后,在client也需要使用这个hostname来连接taosd。 - - - -(4)在windows上安装TDengine-client - -在taosdata官网下载taos客户端,下载地址: -https://www.taosdata.com/cn/all-downloads/ -下载后,双击exe安装。 - -修改client的hosts文件(C:\Windows\System32\drivers\etc\hosts),将server的hostname和ip配置到client的hosts文件中 - -``` -192.168.236.136 td01 -``` - -配置完成后,在命令行内使用taos shell连接server端 - -```shell -C:\TDengine>taos -h td01 -Welcome to the TDengine shell from Linux, Client Version:2.0.1.1 -Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. - -taos> show databases; - name | created_time | ntables | vgroups | replica | quorum | days | keep0,keep1,keep(D) | cache(MB) | blocks | minrows | maxrows | wallevel | fsync | comp | precision | status | -=================================================================================================================================================================================================================================================================== - test | 2020-08-19 18:43:50.731 | 1 | 1 | 1 | 1 | 2 | 3650,3650,3650 | 16 | 6 | 100 | 4096 | 1 | 3000 | 2 | ms | ready | - log | 2020-08-19 18:40:28.064 | 4 | 1 | 1 | 1 | 10 | 30,30,30 | 1 | 3 | 100 | 4096 | 1 | 3000 | 2 | us | ready | -Query OK, 2 row(s) in set (0.068000s) -``` - -如果windows上的client能够正常连接,并打印database信息,说明client可以正常连接server了。 - - - -## 应用开发 - -(1)新建maven工程,在pom.xml中引入taos-jdbcdriver依赖。 - -```xml - - - 4.0.0 - - com.taosdata.demo - JdbcDemo - 1.0-SNAPSHOT - - - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.8 - - - -``` - -(2)使用jdbc查询TDengine数据库 - -下面是示例代码: - -```java -public class JdbcDemo { - - public static void main(String[] args) throws Exception { - Connection conn = getConn(); - Statement stmt = conn.createStatement(); - // create database - stmt.executeUpdate("create database if not exists db"); - // use database - stmt.executeUpdate("use db"); - // create table - stmt.executeUpdate("create table if not exists tb (ts timestamp, temperature int, humidity float)"); - // insert data - int affectedRows = stmt.executeUpdate("insert into tb values(now, 23, 10.3) (now + 1s, 20, 9.3)"); - System.out.println("insert " + affectedRows + " rows."); - // query data - ResultSet resultSet = stmt.executeQuery("select * from tb"); - Timestamp ts = null; - int temperature = 0; - float humidity = 0; - while(resultSet.next()){ - ts = resultSet.getTimestamp(1); - temperature = resultSet.getInt(2); - humidity = resultSet.getFloat("humidity"); - System.out.printf("%s, %d, %s\n", ts, temperature, humidity); - } - } - - public static Connection getConn() throws Exception{ - Class.forName("com.taosdata.jdbc.TSDBDriver"); - String jdbcUrl = "jdbc:TAOS://td01:0/log?user=root&password=taosdata"; - Properties connProps = new Properties(); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - Connection conn = DriverManager.getConnection(jdbcUrl, connProps); - return conn; - } - -} -``` - -(3)测试jdbc访问tdengine的sever实例 - -console输出: - -``` -insert 2 rows. -2020-08-26 00:06:34.575, 23, 10.3 -2020-08-26 00:06:35.575, 20, 9.3 -``` - - - -## 指南 - -(1)如何设置主机名和hosts - -在server上查看hostname和fqdn -```shell -查看hostname -# hostname -taos-server - -查看fqdn -# hostname -f -taos-server -``` - -windows下hosts文件位于: -C:\\Windows\System32\drivers\etc\hosts -修改hosts文件,添加server的ip和hostname - -```s -192.168.56.101 node5 -``` - -(2)什么是fqdn? - - -> 什么是FQDN? -> -> FQDN(Full qualified domain name)全限定域名,fqdn由2部分组成:hostname+domainname。 -> -> 例如,一个邮件服务器的fqdn可能是:mymail.somecollege.edu,其中mymail是hostname(主机名),somcollege.edu是domainname(域名)。本例中,.edu是顶级域名,.somecollege是二级域名。 -> -> 当连接服务器时,必须指定fqdn,然后,dns服务器通过查看dns表,将hostname解析为相应的ip地址。如果只指定hostname(不指定domainname),应用程序可能服务解析主机名。因为如果你试图访问不在本地的远程服务器时,本地的dns服务器和可能没有远程服务器的hostname列表。 -> -> 参考:https://kb.iu.edu/d/aiuv diff --git a/tests/examples/JDBC/JDBCDemo/pom.xml b/tests/examples/JDBC/JDBCDemo/pom.xml deleted file mode 100644 index b0b07d58f4e59645e5ebe78a938d0043558a9c80..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/pom.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - 4.0.0 - - com.taosdata.jdbc - JDBCDemo - SNAPSHOT - jar - - - src/main/resources/assembly - - - - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.36 - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.3.0 - - - - JdbcDemo - - JdbcDemo - - - com.taosdata.example.JdbcDemo - - - - jar-with-dependencies - - - package - - single - - - - - JdbcRestfulDemo - - JdbcRestfulDemo - - - com.taosdata.example.JdbcRestfulDemo - - - - jar-with-dependencies - - - package - - single - - - - - SubscribeDemo - - SubscribeDemo - - - com.taosdata.example.SubscribeDemo - - - - jar-with-dependencies - - - package - - single - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - UTF-8 - - - - - - - diff --git a/tests/examples/JDBC/JDBCDemo/readme.md b/tests/examples/JDBC/JDBCDemo/readme.md deleted file mode 100644 index da638a0bcc485cb3d73f75b59348ec260cc871d2..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/readme.md +++ /dev/null @@ -1,37 +0,0 @@ -# How to Run the JDBC Demo Code On Linux OS -TDengine's JDBC demo project is organized in a Maven way so that users can easily compile, package and run the project. If you don't have Maven on your server, you may install it using -``` -sudo apt-get install maven -``` - -## Install TDengine Client -Make sure you have already installed a tdengine client on your current develop environment. -Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-downloads/`` and install the client. - -## Run jdbcDemo using mvn plugin -run command: -``` -mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -``` - -and run with your customed args -``` -mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -Dexec.args="-host [HOSTNAME]" -``` - -## Compile the Demo Code and Run It -To compile taos-jdbcdriver, go to the source directory ``TDengine/src/connector/jdbc`` and execute -``` -mvn clean package -Dmaven.test.skip=true -``` - -To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute -``` -mvn clean package assembly:single -``` - -To run JDBCDemo.jar, go to ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute -``` -java -Djava.ext.dirs=../../../../src/connector/jdbc/target:$JAVA_HOME/jre/lib/ext -jar target/JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host [HOSTNAME] -``` - diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/BatchInsert.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/BatchInsert.java deleted file mode 100644 index a2566bd07e96ddd245c9b548a3192d0e4f343147..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/BatchInsert.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.taosdata.example; - -import java.sql.*; -import java.util.*; - -public class BatchInsert { - - private static final String host = "127.0.0.1"; - private static final String user = "root"; - private static final String password = "taosdata"; - - - private static final String dbname = "test"; - private static final String stbname = "stb"; - private static final int tables= 100; - private static final int rows = 500; - private static final long ts = 1604877767000l; - - private Connection conn; - - private void init() { - // final String url = "jdbc:TAOS://" + host + ":6030/?user=" + user + "&password=" + password; - final String url = "jdbc:TAOS-RS://" + host + ":6041/?user=" + user + "&password=" + password; - - // get connection - try { - Properties properties = new Properties(); - properties.setProperty("charset", "UTF-8"); - properties.setProperty("locale", "en_US.UTF-8"); - properties.setProperty("timezone", "UTC-8"); - System.out.println("get connection starting..."); - conn = DriverManager.getConnection(url, properties); - if (conn != null){ - System.out.println("[ OK ] Connection established."); - } - - Statement stmt = conn.createStatement(); - - stmt.execute("drop database if exists " + dbname); - stmt.execute("create database if not exists " + dbname); - stmt.execute("use " + dbname); - stmt.execute("create table " + dbname + "." + stbname + "(ts timestamp, col int) tags(id int)"); - - } catch (SQLException e) { - e.printStackTrace(); - } - } - - private String generateSql() { - StringBuilder sb = new StringBuilder(); - Random rand = new Random(); - sb.append("insert into "); - for (int i = 0; i < tables; i++) { - sb.append(dbname + ".tb" + i + " using " + dbname + "." + stbname + " tags(" + i + ") values"); - for (int j = 0; j < rows; j++) { - sb.append("("); - sb.append(ts + j); - sb.append(","); - sb.append(rand.nextInt(1000)); - sb.append(") "); - } - } - return sb.toString(); - } - - private void executeQuery(String sql) { - try (Statement stmt = conn.createStatement()) { - long start = System.currentTimeMillis(); - stmt.execute(sql); - long end = System.currentTimeMillis(); - - System.out.println("insert " + tables * rows + " records, cost " + (end - start)+ "ms"); - } catch (SQLException ex) { - ex.printStackTrace(); - } - } - - public static void main(String[] args) { - BatchInsert bi = new BatchInsert(); - - String sql = bi.generateSql(); - bi.init(); - bi.executeQuery(sql); - } - - -} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ClientParameterSetting.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ClientParameterSetting.java deleted file mode 100644 index 09fb8f1b19f069305464a52df15f748d29ddd5d8..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ClientParameterSetting.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.taosdata.example; - -import com.taosdata.jdbc.TSDBDriver; - -import java.sql.*; -import java.util.Properties; - -public class ClientParameterSetting { - private static final String host = "127.0.0.1"; - - public static void main(String[] args) throws SQLException { - setParameterInJdbcUrl(); - - setParameterInProperties(); - } - - private static void setParameterInJdbcUrl() throws SQLException { - String jdbcUrl = "jdbc:TAOS://" + host + ":6030/?debugFlag=135&asyncLog=0"; - - Connection connection = DriverManager.getConnection(jdbcUrl, "root", "taosdata"); - - printDatabase(connection); - - connection.close(); - } - - private static void setParameterInProperties() throws SQLException { - String jdbcUrl = "jdbc:TAOS://" + host + ":6030/"; - Properties properties = new Properties(); - properties.setProperty("user", "root"); - properties.setProperty("password", "taosdata"); - properties.setProperty("debugFlag", "135"); - properties.setProperty("asyncLog", "0"); - properties.setProperty("maxSQLLength", "1048576"); - - try (Connection conn = DriverManager.getConnection(jdbcUrl, properties)) { - printDatabase(conn); - } - } - - private static void printDatabase(Connection connection) throws SQLException { - try (Statement stmt = connection.createStatement()) { - ResultSet rs = stmt.executeQuery("show databases"); - - ResultSetMetaData meta = rs.getMetaData(); - while (rs.next()) { - for (int i = 1; i <= meta.getColumnCount(); i++) { - System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); - } - System.out.println(); - } - } - } -} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcDemo.java deleted file mode 100644 index 5bc23403087578c0791b0a5e6fca74a47aad8184..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcDemo.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.taosdata.example; - -import java.sql.*; -import java.util.Properties; - -public class JdbcDemo { - private static String host; - private static final String dbName = "test"; - private static final String tbName = "weather"; - private static final String user = "root"; - private static final String password = "taosdata"; - - private Connection connection; - - public static void main(String[] args) { - for (int i = 0; i < args.length; i++) { - if ("-host".equalsIgnoreCase(args[i]) && i < args.length - 1) - host = args[++i]; - } - if (host == null) { - printHelp(); - } - JdbcDemo demo = new JdbcDemo(); - demo.init(); - demo.createDatabase(); - demo.useDatabase(); - demo.dropTable(); - demo.createTable(); - demo.insert(); - demo.select(); - demo.dropTable(); - demo.close(); - } - - private void init() { - final String url = "jdbc:TAOS://" + host + ":6030/?user=" + user + "&password=" + password; - // get connection - try { - Properties properties = new Properties(); - properties.setProperty("charset", "UTF-8"); - properties.setProperty("locale", "en_US.UTF-8"); - properties.setProperty("timezone", "UTC-8"); - System.out.println("get connection starting..."); - connection = DriverManager.getConnection(url, properties); - if (connection != null) - System.out.println("[ OK ] Connection established."); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - private void createDatabase() { - String sql = "create database if not exists " + dbName; - exuete(sql); - } - - private void useDatabase() { - String sql = "use " + dbName; - exuete(sql); - } - - private void dropTable() { - final String sql = "drop table if exists " + dbName + "." + tbName + ""; - exuete(sql); - } - - private void createTable() { - final String sql = "create table if not exists " + dbName + "." + tbName + " (ts timestamp, temperature float, humidity int)"; - exuete(sql); - } - - private void insert() { - final String sql = "insert into " + dbName + "." + tbName + " (ts, temperature, humidity) values(now, 20.5, 34)"; - exuete(sql); - } - - private void select() { - final String sql = "select * from " + dbName + "." + tbName; - executeQuery(sql); - } - - private void close() { - try { - if (connection != null) { - this.connection.close(); - System.out.println("connection closed."); - } - } catch (SQLException e) { - e.printStackTrace(); - } - } - - private void executeQuery(String sql) { - long start = System.currentTimeMillis(); - try (Statement statement = connection.createStatement()) { - ResultSet resultSet = statement.executeQuery(sql); - long end = System.currentTimeMillis(); - printSql(sql, true, (end - start)); - printResult(resultSet); - } catch (SQLException e) { - long end = System.currentTimeMillis(); - printSql(sql, false, (end - start)); - e.printStackTrace(); - } - } - - private void printResult(ResultSet resultSet) throws SQLException { - ResultSetMetaData metaData = resultSet.getMetaData(); - while (resultSet.next()) { - for (int i = 1; i <= metaData.getColumnCount(); i++) { - String columnLabel = metaData.getColumnLabel(i); - String value = resultSet.getString(i); - System.out.printf("%s: %s\t", columnLabel, value); - } - System.out.println(); - } - } - - private void printSql(String sql, boolean succeed, long cost) { - System.out.println("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql); - } - - private void exuete(String sql) { - long start = System.currentTimeMillis(); - try (Statement statement = connection.createStatement()) { - boolean execute = statement.execute(sql); - long end = System.currentTimeMillis(); - printSql(sql, true, (end - start)); - } catch (SQLException e) { - long end = System.currentTimeMillis(); - printSql(sql, false, (end - start)); - e.printStackTrace(); - } - } - - private static void printHelp() { - System.out.println("Usage: java -jar JDBCDemo.jar -host "); - System.exit(0); - } - -} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java deleted file mode 100644 index d89476b8ca718dab24202e2320e842366533a763..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcRestfulDemo.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.taosdata.example; - -import java.sql.*; -import java.util.Properties; - -public class JdbcRestfulDemo { - private static final String host = "localhost"; - private static final String dbname = "test"; - private static final String user = "root"; - private static final String password = "taosdata"; - - public static void main(String[] args) { - try { - // use port 6041 in url when use JDBC-restful - String url = "jdbc:TAOS-RS://" + host + ":6041/?user=" + user + "&password=" + password; - - Properties properties = new Properties(); - properties.setProperty("charset", "UTF-8"); - properties.setProperty("locale", "en_US.UTF-8"); - properties.setProperty("timezone", "UTC-8"); - - Connection conn = DriverManager.getConnection(url, properties); - Statement stmt = conn.createStatement(); - - stmt.execute("drop database if exists " + dbname); - stmt.execute("create database if not exists " + dbname); - stmt.execute("use " + dbname); - stmt.execute("create table " + dbname + ".weather(ts timestamp, temperature float) tags(location nchar(64))"); - stmt.executeUpdate("insert into t1 using " + dbname + ".weather tags('北京') values(now, 18.2)"); - ResultSet rs = stmt.executeQuery("select * from " + dbname + ".weather"); - ResultSetMetaData meta = rs.getMetaData(); - while (rs.next()) { - for (int i = 1; i <= meta.getColumnCount(); i++) { - System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); - } - System.out.println(); - } - - rs.close(); - stmt.close(); - conn.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } -} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ParameterBindingDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ParameterBindingDemo.java deleted file mode 100644 index 726b57b1465f678d703f0dc9c524f92b856e034e..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ParameterBindingDemo.java +++ /dev/null @@ -1,237 +0,0 @@ -package com.taosdata.example; - -import com.taosdata.jdbc.TSDBPreparedStatement; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Random; - -public class ParameterBindingDemo { - - private static final String host = "127.0.0.1"; - private static final Random random = new Random(System.currentTimeMillis()); - private static final int BINARY_COLUMN_SIZE = 20; - private static final String[] schemaList = { - "create table stable1(ts timestamp, f1 tinyint, f2 smallint, f3 int, f4 bigint) tags(t1 tinyint, t2 smallint, t3 int, t4 bigint)", - "create table stable2(ts timestamp, f1 float, f2 double) tags(t1 float, t2 double)", - "create table stable3(ts timestamp, f1 bool) tags(t1 bool)", - "create table stable4(ts timestamp, f1 binary(" + BINARY_COLUMN_SIZE + ")) tags(t1 binary(" + BINARY_COLUMN_SIZE + "))", - "create table stable5(ts timestamp, f1 nchar(" + BINARY_COLUMN_SIZE + ")) tags(t1 nchar(" + BINARY_COLUMN_SIZE + "))" - }; - private static final int numOfSubTable = 10, numOfRow = 10; - - public static void main(String[] args) throws SQLException { - - String jdbcUrl = "jdbc:TAOS://" + host + ":6030/"; - Connection conn = DriverManager.getConnection(jdbcUrl, "root", "taosdata"); - - init(conn); - - bindInteger(conn); - - bindFloat(conn); - - bindBoolean(conn); - - bindBytes(conn); - - bindString(conn); - - conn.close(); - } - - private static void init(Connection conn) throws SQLException { - try (Statement stmt = conn.createStatement()) { - stmt.execute("drop database if exists test_parabind"); - stmt.execute("create database if not exists test_parabind"); - stmt.execute("use test_parabind"); - for (int i = 0; i < schemaList.length; i++) { - stmt.execute(schemaList[i]); - } - } - } - - private static void bindInteger(Connection conn) throws SQLException { - String sql = "insert into ? using stable1 tags(?,?,?,?) values(?,?,?,?,?)"; - - try (TSDBPreparedStatement pstmt = conn.prepareStatement(sql).unwrap(TSDBPreparedStatement.class)) { - - for (int i = 1; i <= numOfSubTable; i++) { - // set table name - pstmt.setTableName("t1_" + i); - // set tags - pstmt.setTagByte(0, Byte.parseByte(Integer.toString(random.nextInt(Byte.MAX_VALUE)))); - pstmt.setTagShort(1, Short.parseShort(Integer.toString(random.nextInt(Short.MAX_VALUE)))); - pstmt.setTagInt(2, random.nextInt(Integer.MAX_VALUE)); - pstmt.setTagLong(3, random.nextLong()); - // set columns - ArrayList tsList = new ArrayList<>(); - long current = System.currentTimeMillis(); - for (int j = 0; j < numOfRow; j++) - tsList.add(current + j); - pstmt.setTimestamp(0, tsList); - - ArrayList f1List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) - f1List.add(Byte.parseByte(Integer.toString(random.nextInt(Byte.MAX_VALUE)))); - pstmt.setByte(1, f1List); - - ArrayList f2List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) - f2List.add(Short.parseShort(Integer.toString(random.nextInt(Short.MAX_VALUE)))); - pstmt.setShort(2, f2List); - - ArrayList f3List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) - f3List.add(random.nextInt(Integer.MAX_VALUE)); - pstmt.setInt(3, f3List); - - ArrayList f4List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) - f4List.add(random.nextLong()); - pstmt.setLong(4, f4List); - - // add column - pstmt.columnDataAddBatch(); - } - // execute column - pstmt.columnDataExecuteBatch(); - } - - } - - private static void bindFloat(Connection conn) throws SQLException { - String sql = "insert into ? using stable2 tags(?,?) values(?,?,?)"; - - TSDBPreparedStatement pstmt = conn.prepareStatement(sql).unwrap(TSDBPreparedStatement.class); - - for (int i = 1; i <= numOfSubTable; i++) { - // set table name - pstmt.setTableName("t2_" + i); - // set tags - pstmt.setTagFloat(0, random.nextFloat()); - pstmt.setTagDouble(1, random.nextDouble()); - // set columns - ArrayList tsList = new ArrayList<>(); - long current = System.currentTimeMillis(); - for (int j = 0; j < numOfRow; j++) - tsList.add(current + j); - pstmt.setTimestamp(0, tsList); - - ArrayList f1List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) - f1List.add(random.nextFloat()); - pstmt.setFloat(1, f1List); - - ArrayList f2List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) - f2List.add(random.nextDouble()); - pstmt.setDouble(2, f2List); - - // add column - pstmt.columnDataAddBatch(); - } - // execute - pstmt.columnDataExecuteBatch(); - // close if no try-with-catch statement is used - pstmt.close(); - } - - private static void bindBoolean(Connection conn) throws SQLException { - String sql = "insert into ? using stable3 tags(?) values(?,?)"; - - try (TSDBPreparedStatement pstmt = conn.prepareStatement(sql).unwrap(TSDBPreparedStatement.class)) { - for (int i = 1; i <= numOfSubTable; i++) { - // set table name - pstmt.setTableName("t3_" + i); - // set tags - pstmt.setTagBoolean(0, random.nextBoolean()); - // set columns - ArrayList tsList = new ArrayList<>(); - long current = System.currentTimeMillis(); - for (int j = 0; j < numOfRow; j++) - tsList.add(current + j); - pstmt.setTimestamp(0, tsList); - - ArrayList f1List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) - f1List.add(random.nextBoolean()); - pstmt.setBoolean(1, f1List); - - // add column - pstmt.columnDataAddBatch(); - } - // execute - pstmt.columnDataExecuteBatch(); - } - } - - private static void bindBytes(Connection conn) throws SQLException { - String sql = "insert into ? using stable4 tags(?) values(?,?)"; - - try (TSDBPreparedStatement pstmt = conn.prepareStatement(sql).unwrap(TSDBPreparedStatement.class)) { - - for (int i = 1; i <= numOfSubTable; i++) { - // set table name - pstmt.setTableName("t4_" + i); - // set tags - pstmt.setTagString(0, new String("abc")); - - // set columns - ArrayList tsList = new ArrayList<>(); - long current = System.currentTimeMillis(); - for (int j = 0; j < numOfRow; j++) - tsList.add(current + j); - pstmt.setTimestamp(0, tsList); - - ArrayList f1List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) { - f1List.add(new String("abc")); - } - pstmt.setString(1, f1List, BINARY_COLUMN_SIZE); - - // add column - pstmt.columnDataAddBatch(); - } - // execute - pstmt.columnDataExecuteBatch(); - } - } - - private static void bindString(Connection conn) throws SQLException { - String sql = "insert into ? using stable5 tags(?) values(?,?)"; - - try (TSDBPreparedStatement pstmt = conn.prepareStatement(sql).unwrap(TSDBPreparedStatement.class)) { - - for (int i = 1; i <= numOfSubTable; i++) { - // set table name - pstmt.setTableName("t5_" + i); - // set tags - pstmt.setTagNString(0, "北京-abc"); - - // set columns - ArrayList tsList = new ArrayList<>(); - long current = System.currentTimeMillis(); - for (int j = 0; j < numOfRow; j++) - tsList.add(current + j); - pstmt.setTimestamp(0, tsList); - - ArrayList f1List = new ArrayList<>(); - for (int j = 0; j < numOfRow; j++) { - f1List.add("北京-abc"); - } - pstmt.setNString(1, f1List, BINARY_COLUMN_SIZE); - - // add column - pstmt.columnDataAddBatch(); - } - // execute - pstmt.columnDataExecuteBatch(); - } - } - - -} diff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java deleted file mode 100644 index 4c499b0b3abb518b48b222eca9bbbcb388bd2008..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SubscribeDemo.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.taosdata.example; - -import com.taosdata.jdbc.TSDBConnection; -import com.taosdata.jdbc.TSDBDriver; -import com.taosdata.jdbc.TSDBResultSet; -import com.taosdata.jdbc.TSDBSubscribe; - -import java.sql.DriverManager; -import java.sql.ResultSetMetaData; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -public class SubscribeDemo { - private static final String usage = "java -jar SubscribeDemo.jar -host -database -topic -sql "; - - public static void main(String[] args) { - // parse args from command line - String host = "", database = "", topic = "", sql = ""; - for (int i = 0; i < args.length; i++) { - if ("-host".equalsIgnoreCase(args[i]) && i < args.length - 1) { - host = args[++i]; - } - if ("-database".equalsIgnoreCase(args[i]) && i < args.length - 1) { - database = args[++i]; - } - if ("-topic".equalsIgnoreCase(args[i]) && i < args.length - 1) { - topic = args[++i]; - } - if ("-sql".equalsIgnoreCase(args[i]) && i < args.length - 1) { - sql = args[++i]; - } - } - if (host.isEmpty() || database.isEmpty() || topic.isEmpty() || sql.isEmpty()) { - System.out.println(usage); - return; - } - - try { - Properties properties = new Properties(); - properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); - properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); - final String url = "jdbc:TAOS://" + host + ":6030/" + database + "?user=root&password=taosdata"; - // get TSDBConnection - TSDBConnection connection = (TSDBConnection) DriverManager.getConnection(url, properties); - // create TSDBSubscribe - TSDBSubscribe sub = connection.subscribe(topic, sql, false); - - int total = 0; - while (true) { - TSDBResultSet rs = sub.consume(); - int count = 0; - ResultSetMetaData meta = rs.getMetaData(); - while (rs.next()) { - for (int i = 1; i <= meta.getColumnCount(); i++) { - System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); - } - System.out.println(); - count++; - } - total += count; -// System.out.printf("%d rows consumed, total %d\n", count, total); - if (total >= 10) - break; - TimeUnit.SECONDS.sleep(1); - } - sub.close(false); - connection.close(); - } catch (Exception e) { - System.out.println("host: " + host + ", database: " + database + ", topic: " + topic + ", sql: " + sql); - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/SpringJdbcTemplate/.gitignore b/tests/examples/JDBC/SpringJdbcTemplate/.gitignore deleted file mode 100644 index 175de5c653d2f49b2ad1227764e60f741110592d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/.gitignore +++ /dev/null @@ -1,31 +0,0 @@ -HELP.md -target/ -.mvn/ -!**/src/main/** -!**/src/test/** - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ - -### VS Code ### -.vscode/ diff --git a/tests/examples/JDBC/SpringJdbcTemplate/pom.xml b/tests/examples/JDBC/SpringJdbcTemplate/pom.xml deleted file mode 100644 index eac3dec0a92a4c8aa519cd426b9c8d3895047be6..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/pom.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - 4.0.0 - - com.taosdata.jdbc - SpringJdbcTemplate - 1.0-SNAPSHOT - - SpringJdbcTemplate - http://www.taosdata.com - - - UTF-8 - 1.8 - 1.8 - - - - - - org.springframework - spring-context - 5.2.8.RELEASE - - - - org.springframework - spring-jdbc - 5.1.9.RELEASE - - - - org.springframework - spring-test - 5.1.9.RELEASE - - - - junit - junit - 4.13.1 - test - - - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.18 - - - - - - - - maven-compiler-plugin - 3.8.0 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.1.0 - - - - com.taosdata.example.jdbcTemplate.App - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - diff --git a/tests/examples/JDBC/SpringJdbcTemplate/readme.md b/tests/examples/JDBC/SpringJdbcTemplate/readme.md deleted file mode 100644 index b70a6565f88d0a08b8a26a60676e729ecdb39e2e..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/readme.md +++ /dev/null @@ -1,32 +0,0 @@ - -## TDengine Spring JDBC Template Demo - -`Spring JDBC Template` 简化了原生 JDBC Connection 获取释放等操作,使得操作数据库更加方便。 - -### 配置 - -修改 `src/main/resources/applicationContext.xml` 文件中 TDengine 的配置信息: - -```xml - - - - - - - - - - -``` - -### 打包运行 - -进入 `TDengine/tests/examples/JDBC/SpringJdbcTemplate` 目录下,执行以下命令可以生成可执行 jar 包。 -```shell -mvn clean package -``` -打包成功之后,进入 `target/` 目录下,执行以下命令就可运行测试: -```shell -java -jar SpringJdbcTemplate-1.0-SNAPSHOT-jar-with-dependencies.jar -``` \ No newline at end of file diff --git a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/App.java b/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/App.java deleted file mode 100644 index 6942d62a83adafb85496a81ce93866cd0d53611d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/App.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.taosdata.example.jdbcTemplate; - - -import com.taosdata.example.jdbcTemplate.dao.ExecuteAsStatement; -import com.taosdata.example.jdbcTemplate.dao.WeatherDao; -import com.taosdata.example.jdbcTemplate.domain.Weather; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import java.sql.Timestamp; -import java.util.Date; -import java.util.List; -import java.util.Random; - -public class App { - - private static Random random = new Random(System.currentTimeMillis()); - - public static void main(String[] args) { - - ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); - - ExecuteAsStatement executor = ctx.getBean(ExecuteAsStatement.class); - // drop database - executor.doExecute("drop database if exists test"); - // create database - executor.doExecute("create database if not exists test"); - //use database - executor.doExecute("use test"); - // create table - executor.doExecute("create table if not exists test.weather (ts timestamp, temperature int, humidity float)"); - - WeatherDao weatherDao = ctx.getBean(WeatherDao.class); - Weather weather = new Weather(new Timestamp(new Date().getTime()), random.nextFloat() * 50.0f, random.nextInt(100)); - // insert rows - int affectedRows = weatherDao.add(weather); - System.out.println("insert success " + affectedRows + " rows."); - - // query for list - int limit = 10, offset = 0; - List weatherList = weatherDao.queryForList(limit, offset); - for (Weather w : weatherList) { - System.out.println(w); - } - - } - -} diff --git a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/ExecuteAsStatement.java b/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/ExecuteAsStatement.java deleted file mode 100644 index 5947438e408b3b359b138bf989477f60fc327404..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/ExecuteAsStatement.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.taosdata.example.jdbcTemplate.dao; - -public interface ExecuteAsStatement{ - - void doExecute(String sql); -} diff --git a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/ExecuteAsStatementImpl.java b/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/ExecuteAsStatementImpl.java deleted file mode 100644 index 059e3dda15ea36bcaad4309a434a06f020d0301b..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/ExecuteAsStatementImpl.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.taosdata.example.jdbcTemplate.dao; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; - - -@Repository -public class ExecuteAsStatementImpl implements ExecuteAsStatement { - - @Autowired - private JdbcTemplate jdbcTemplate; - - @Override - public void doExecute(String sql) { - jdbcTemplate.execute(sql); - } -} diff --git a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/WeatherDao.java b/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/WeatherDao.java deleted file mode 100644 index 19a07597f8df869dada4e258c4951f67132107a0..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/WeatherDao.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.taosdata.example.jdbcTemplate.dao; - -import com.taosdata.example.jdbcTemplate.domain.Weather; - -import java.util.List; - -public interface WeatherDao { - - - int add(Weather weather); - - int[] batchInsert(List weatherList); - - List queryForList(int limit, int offset); - - int count(); -} diff --git a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/WeatherDaoImpl.java b/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/WeatherDaoImpl.java deleted file mode 100644 index 8d4ca47d5ee5d351a48bcc1554531566116f5a52..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/dao/WeatherDaoImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.taosdata.example.jdbcTemplate.dao; - -import com.taosdata.example.jdbcTemplate.domain.Weather; -import com.taosdata.example.jdbcTemplate.dao.WeatherDao; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.BatchPreparedStatementSetter; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; - -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.List; - -@Repository -public class WeatherDaoImpl implements WeatherDao { - - @Autowired - private JdbcTemplate jdbcTemplate; - - @Override - public int add(Weather weather) { - return jdbcTemplate.update( - "insert into test.weather(ts, temperature, humidity) VALUES(?,?,?)", - weather.getTs(), weather.getTemperature(), weather.getHumidity() - ); - } - - @Override - public int[] batchInsert(List weatherList) { - return jdbcTemplate.batchUpdate("insert into test.weather(ts, temperature, humidity) values( ?, ?, ?)", new BatchPreparedStatementSetter() { - @Override - public void setValues(PreparedStatement ps, int i) throws SQLException { - ps.setTimestamp(1, weatherList.get(i).getTs()); - ps.setFloat(2, weatherList.get(i).getTemperature()); - ps.setInt(3, weatherList.get(i).getHumidity()); - } - - @Override - public int getBatchSize() { - return weatherList.size(); - } - }); - } - - @Override - public List queryForList(int limit, int offset) { - return jdbcTemplate.query("select * from test.weather limit ? offset ?", (rs, rowNum) -> { - Timestamp ts = rs.getTimestamp("ts"); - float temperature = rs.getFloat("temperature"); - int humidity = rs.getInt("humidity"); - return new Weather(ts, temperature, humidity); - }, limit, offset); - } - - @Override - public int count() { - return jdbcTemplate.queryForObject("select count(*) from test.weather", Integer.class); - } -} diff --git a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/domain/Weather.java b/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/domain/Weather.java deleted file mode 100644 index 1787a08c3554e017645fefbd35d7c4fd1bc60bd4..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/src/main/java/com/taosdata/example/jdbcTemplate/domain/Weather.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.taosdata.example.jdbcTemplate.domain; - -import java.sql.Timestamp; - -public class Weather { - - private Timestamp ts; - private float temperature; - private int humidity; - - public Weather() { - } - - public Weather(Timestamp ts, float temperature, int humidity) { - this.ts = ts; - this.temperature = temperature; - this.humidity = humidity; - } - - @Override - public String toString() { - return "Weather{" + - "ts=" + ts + - ", temperature=" + temperature + - ", humidity=" + humidity + - '}'; - } - - public Timestamp getTs() { - return ts; - } - - public void setTs(Timestamp ts) { - this.ts = ts; - } - - public float getTemperature() { - return temperature; - } - - public void setTemperature(float temperature) { - this.temperature = temperature; - } - - public int getHumidity() { - return humidity; - } - - public void setHumidity(int humidity) { - this.humidity = humidity; - } - - -} diff --git a/tests/examples/JDBC/SpringJdbcTemplate/src/main/resources/applicationContext.xml b/tests/examples/JDBC/SpringJdbcTemplate/src/main/resources/applicationContext.xml deleted file mode 100644 index 6d6cf6047e2545256ffd6f39e1e6160a965a6fa8..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/src/main/resources/applicationContext.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/tests/examples/JDBC/SpringJdbcTemplate/src/test/java/com/taosdata/example/jdbcTemplate/BatcherInsertTest.java b/tests/examples/JDBC/SpringJdbcTemplate/src/test/java/com/taosdata/example/jdbcTemplate/BatcherInsertTest.java deleted file mode 100644 index 29d0f79fd4982d43078e590b4320c0df457ee44c..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/SpringJdbcTemplate/src/test/java/com/taosdata/example/jdbcTemplate/BatcherInsertTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.taosdata.example.jdbcTemplate; - - -import com.taosdata.example.jdbcTemplate.dao.ExecuteAsStatement; -import com.taosdata.example.jdbcTemplate.dao.WeatherDao; -import com.taosdata.example.jdbcTemplate.domain.Weather; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import static org.junit.Assert.assertEquals; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration({"classpath:applicationContext.xml"}) -public class BatcherInsertTest { - - - @Autowired - private WeatherDao weatherDao; - @Autowired - private ExecuteAsStatement executor; - - private static final int numOfRecordsPerTable = 1000; - private static long ts = 1496732686000l; - private static Random random = new Random(System.currentTimeMillis()); - - @Before - public void before() { - // drop database - executor.doExecute("drop database if exists test"); - // create database - executor.doExecute("create database if not exists test"); - //use database - executor.doExecute("use test"); - // create table - executor.doExecute("create table if not exists test.weather (ts timestamp, temperature int, humidity float)"); - } - - @Test - public void batchInsert() { - List weatherList = new ArrayList<>(); - for (int i = 0; i < numOfRecordsPerTable; i++) { - ts += 1000; - Weather weather = new Weather(new Timestamp(ts), random.nextFloat() * 50.0f, random.nextInt(100)); - weatherList.add(weather); - } - long start = System.currentTimeMillis(); - weatherDao.batchInsert(weatherList); - long end = System.currentTimeMillis(); - System.out.println("batch insert(" + numOfRecordsPerTable + " rows) time cost ==========> " + (end - start) + " ms"); - - int count = weatherDao.count(); - assertEquals(count, numOfRecordsPerTable); - } - -} diff --git a/tests/examples/JDBC/connectionPools/README-cn.md b/tests/examples/JDBC/connectionPools/README-cn.md deleted file mode 100644 index 9b26df3c2eb2c23171a673643891a292af4c920c..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/README-cn.md +++ /dev/null @@ -1,32 +0,0 @@ -这个example中,我们适配了java常见的连接池: -* HikariCP(默认) -* druid -* dbcp -* c3p0 - -### 说明 -ConnectionPoolDemo的程序逻辑: -1. 创建到host的connection连接池 -2. 创建名称为pool_test的database,创建表超级weather,创建tableSize个子表 -3. 总共插入totalNumber条数据。 - -### 如何运行这个例子: - -```shell script -mvn clean package assembly:single -java -jar target/connectionPools-1.0-SNAPSHOT-jar-with-dependencies.jar -host 127.0.0.1 -``` -使用mvn运行ConnectionPoolDemo的main方法,可以指定参数 -```shell script -Usage: -java -jar target/connectionPools-1.0-SNAPSHOT-jar-with-dependencies.jar --host : hostname --poolType --poolSize --tableSize --batchSize : 每条Insert SQL中values的数量 --sleep : 每次插入任务提交后的 -``` - -### 日志 -使用log4j,将日志和错误分别输出到了debug.log和error.log中 \ No newline at end of file diff --git a/tests/examples/JDBC/connectionPools/pom.xml b/tests/examples/JDBC/connectionPools/pom.xml deleted file mode 100644 index d50c7a20709e0d0471261a64365873814242a619..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - 4.0.0 - - - 1.8 - 1.8 - - - com.taosdata.demo - connectionPools - 1.0-SNAPSHOT - - - - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.34 - - - - com.alibaba - druid - 1.1.17 - - - - com.zaxxer - HikariCP - 3.2.0 - - - - commons-pool - commons-pool - 1.5.4 - - - commons-dbcp - commons-dbcp - 1.4 - - - - com.mchange - c3p0 - 0.9.5.4 - - - - org.apache.logging.log4j - log4j-core - 2.17.1 - - - - com.cloudhopper.proxool - proxool - 0.9.1 - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.3.0 - - - ConnectionPoolDemo - - ConnectionPoolDemo - - - com.taosdata.example.ConnectionPoolDemo - - - - jar-with-dependencies - - - package - - single - - - - - ProxoolDemo - - ProxoolDemo - - - com.taosdata.example.ProxoolDemo - - - - jar-with-dependencies - - - package - - single - - - - - - - - - diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java deleted file mode 100644 index 96ad65aa4fc10bf81f6107a4bb2e5a4224891298..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ConnectionPoolDemo.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.taosdata.example; - -import com.taosdata.example.common.InsertTask; -import com.taosdata.example.pool.C3p0Builder; -import com.taosdata.example.pool.DbcpBuilder; -import com.taosdata.example.pool.DruidPoolBuilder; -import com.taosdata.example.pool.HikariCpBuilder; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -public class ConnectionPoolDemo { - - private static Logger logger = LogManager.getLogger(DruidPoolBuilder.class); - private static final String dbName = "pool_test"; - - private static String poolType = "hikari"; - private static long totalSize = 1_000_000l; - private static long tableSize = 1; - private static long batchSize = 1; - - private static int poolSize = 50; - private static int threadCount = 50; - private static int sleep = 0; - - public static void main(String[] args) { - String host = null; - for (int i = 0; i < args.length; i++) { - if ("-host".equalsIgnoreCase(args[i]) && i < args.length - 1) { - host = args[++i]; - } - if ("-poolType".equalsIgnoreCase(args[i]) && i < args.length - 1) { - poolType = args[++i]; - } - if ("-recordNumber".equalsIgnoreCase(args[i]) && i < args.length - 1) { - totalSize = Long.parseLong(args[++i]); - } - if ("-tableNumber".equalsIgnoreCase(args[i]) && i < args.length - 1) { - tableSize = Long.parseLong(args[++i]); - } - if ("-batchNumber".equalsIgnoreCase(args[i]) && i < args.length - 1) { - batchSize = Long.parseLong(args[++i]); - } - - } - if (host == null) { - System.out.println("Usage: java -jar XXX.jar -host " + - "-poolType " + - "-recordNumber " + - "-tableNumber " + - "-batchNumber " + - "-sleep " - ); - return; - } - - DataSource dataSource; - switch (poolType) { - case "c3p0": - dataSource = C3p0Builder.getDataSource(host, poolSize); - break; - case "dbcp": - dataSource = DbcpBuilder.getDataSource(host, poolSize); - break; - case "druid": - dataSource = DruidPoolBuilder.getDataSource(host, poolSize); - break; - case "hikari": - default: - dataSource = HikariCpBuilder.getDataSource(host, poolSize); - poolType = "hikari"; - } - - logger.info(">>>>>>>>>>>>>> connection pool Type: " + poolType); - init(dataSource); - -// try { -// Connection connection = dataSource.getConnection(); -// Statement statement = connection.createStatement(); -// String sql = "insert into " + dbName + ".t_1 values('2020-01-01 00:00:00.000',12.12,111)"; -// int affectRows = statement.executeUpdate(sql); -// System.out.println("affectRows >>> " + affectRows); -// affectRows = statement.executeUpdate(sql); -// System.out.println("affectRows >>> " + affectRows); -// statement.close(); -// connection.close(); -// } catch (SQLException e) { -// e.printStackTrace(); -// } - - ExecutorService executor = Executors.newFixedThreadPool(threadCount); - for (long i = 0; i < totalSize / tableSize / batchSize; i++) { - executor.execute(new InsertTask(dataSource, dbName, tableSize, batchSize)); - // sleep few seconds - try { - if (sleep > 0) - TimeUnit.MILLISECONDS.sleep(sleep); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - executor.shutdown(); - - } - - private static void init(DataSource dataSource) { - try (Connection conn = dataSource.getConnection()) { - execute(conn, "drop database if exists " + dbName + ""); - execute(conn, "create database if not exists " + dbName + ""); - execute(conn, "use " + dbName + ""); - execute(conn, "create table weather(ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)"); - for (int tb_ind = 1; tb_ind <= tableSize; tb_ind++) { - execute(conn, "create table t_" + tb_ind + " using weather tags('beijing'," + (tb_ind + 1) + ")"); - } - logger.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>> init finished."); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - private static void execute(Connection con, String sql) { - try (Statement stmt = con.createStatement()) { - stmt.executeUpdate(sql); - logger.info("SQL >>> " + sql); - } catch (SQLException e) { - e.printStackTrace(); - } - } - -} diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ProxoolDemo.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ProxoolDemo.java deleted file mode 100644 index 632ad8c9bf69d13d137d06c1f23c964904c8e050..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/ProxoolDemo.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.taosdata.example; - -import org.logicalcobwebs.proxool.ProxoolException; -import org.logicalcobwebs.proxool.configuration.JAXPConfigurator; - -import java.sql.*; - -public class ProxoolDemo { - - - public static void main(String[] args) { - - String xml = parseConfigurationXml(args); - if (xml == null) { - printHelp(); - System.exit(0); - } - - try { - JAXPConfigurator.configure(xml, false); - Class.forName("org.logicalcobwebs.proxool.ProxoolDriver"); - Connection connection = DriverManager.getConnection("proxool.ds"); - - Statement stmt = connection.createStatement(); - - ResultSet rs = stmt.executeQuery("show databases"); - ResultSetMetaData metaData = rs.getMetaData(); - while (rs.next()) { - for (int i = 1; i <= metaData.getColumnCount(); i++) { - System.out.print(metaData.getColumnLabel(i) + ": " + rs.getString(i)); - } - System.out.println(); - } - - stmt.close(); - - } catch (ClassNotFoundException | SQLException | ProxoolException e) { - e.printStackTrace(); - } - } - - private static String parseConfigurationXml(String[] args) { - String host = null; - for (int i = 0; i < args.length; i++) { - if ("--xml".equalsIgnoreCase(args[i]) && i < args.length - 1) { - host = args[++i]; - } - } - return host; - } - - private static void printHelp() { - System.out.println("Usage: java -jar ProxoolDemo.jar --xml [xml]"); - } - -} diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java deleted file mode 100644 index f8f1555c08f1f5847bf0a34a56341ef6d22dde50..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/common/InsertTask.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.taosdata.example.common; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.Random; - -public class InsertTask implements Runnable { - private final Random random = new Random(System.currentTimeMillis()); - private static final Logger logger = LogManager.getLogger(InsertTask.class); - - private final DataSource ds; - private final String dbName; - private final long tableSize; - private final long batchSize; - - public InsertTask(DataSource ds, String dbName, long tableSize, long batchSize) { - this.ds = ds; - this.dbName = dbName; - this.tableSize = tableSize; - this.batchSize = batchSize; - } - - @Override - public void run() { - int affectedRows = 0; - long start = System.currentTimeMillis(); - try (Connection conn = ds.getConnection(); Statement stmt = conn.createStatement()) { - for (int tb_index = 1; tb_index <= tableSize; tb_index++) { - StringBuilder sb = new StringBuilder(); - sb.append("insert into ").append(dbName).append(".t_").append(tb_index).append("(ts, temperature, humidity) values "); - for (int i = 0; i < batchSize; i++) { - sb.append("(").append(start + i).append(", ").append(random.nextFloat() * 30).append(", ").append(random.nextInt(70)).append(") "); - } - logger.info("SQL >>> " + sb.toString()); - affectedRows += stmt.executeUpdate(sb.toString()); - } - } catch (SQLException e) { - e.printStackTrace(); - } - logger.info(">>> affectedRows:" + affectedRows + " TimeCost:" + (System.currentTimeMillis() - start) + " ms"); - } -} diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/C3p0Builder.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/C3p0Builder.java deleted file mode 100644 index 235db0bb796ee507b2d93838c8e7bfa7de870fcd..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/C3p0Builder.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.taosdata.example.pool; - -import com.mchange.v2.c3p0.ComboPooledDataSource; - -import javax.sql.DataSource; -import java.beans.PropertyVetoException; - -public class C3p0Builder { - - public static DataSource getDataSource(String host, int poolSize) { - ComboPooledDataSource ds = new ComboPooledDataSource(); - - try { - ds.setDriverClass("com.taosdata.jdbc.TSDBDriver"); - } catch (PropertyVetoException e) { - e.printStackTrace(); - } - ds.setJdbcUrl("jdbc:TAOS://" + host + ":6030"); - ds.setUser("root"); - ds.setPassword("taosdata"); - - ds.setMinPoolSize(poolSize); - ds.setMaxPoolSize(poolSize); - ds.setAcquireIncrement(5); - return ds; - } -} diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DbcpBuilder.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DbcpBuilder.java deleted file mode 100644 index 3aa9e4ebcf2d07ba1e6a51a2dae216cf44e88486..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DbcpBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.taosdata.example.pool; - -import org.apache.commons.dbcp.BasicDataSource; - -import javax.sql.DataSource; - -public class DbcpBuilder { - - public static DataSource getDataSource(String host, int poolSize) { - BasicDataSource ds = new BasicDataSource(); - ds.setDriverClassName("com.taosdata.jdbc.TSDBDriver"); - ds.setUrl("jdbc:TAOS://" + host + ":6030"); - ds.setUsername("root"); - ds.setPassword("taosdata"); - - ds.setMaxActive(poolSize); - ds.setMinIdle(poolSize); - ds.setInitialSize(poolSize); - return ds; - } -} diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DruidPoolBuilder.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DruidPoolBuilder.java deleted file mode 100644 index 500f0e9e97cc09c2c5e9990234f051d0bbc72044..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/DruidPoolBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.taosdata.example.pool; - -import com.alibaba.druid.pool.DruidDataSource; - -import javax.sql.DataSource; - -public class DruidPoolBuilder { - - public static DataSource getDataSource(String host, int poolSize) { - final String url = "jdbc:TAOS://" + host + ":6030"; - - DruidDataSource dataSource = new DruidDataSource(); - // jdbc properties - dataSource.setDriverClassName("com.taosdata.jdbc.TSDBDriver"); - dataSource.setUrl(url); - dataSource.setUsername("root"); - dataSource.setPassword("taosdata"); - // pool configurations - dataSource.setInitialSize(poolSize); - dataSource.setMinIdle(poolSize); - dataSource.setMaxActive(poolSize); - dataSource.setMaxWait(30000); - dataSource.setValidationQuery("select server_status()"); - return dataSource; - } - -} diff --git a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/HikariCpBuilder.java b/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/HikariCpBuilder.java deleted file mode 100644 index 7e151de3e052495b3ce50ffe042732717fcc38f4..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/java/com/taosdata/example/pool/HikariCpBuilder.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.taosdata.example.pool; - -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; - -import javax.sql.DataSource; - -public class HikariCpBuilder { - - public static DataSource getDataSource(String host, int poolSize) { - HikariConfig config = new HikariConfig(); - // jdbc properties - config.setDriverClassName("com.taosdata.jdbc.TSDBDriver"); - config.setJdbcUrl("jdbc:TAOS://" + host + ":6030"); - config.setUsername("root"); - config.setPassword("taosdata"); - // pool configurations - config.setMinimumIdle(poolSize); //minimum number of idle connection - config.setMaximumPoolSize(poolSize); //maximum number of connection in the pool - config.setConnectionTimeout(30000); //maximum wait milliseconds for get connection from pool - config.setMaxLifetime(0); // maximum life time for each connection - config.setIdleTimeout(0); // max idle time for recycle idle connection - config.setConnectionTestQuery("select server_status()"); //validation query - - HikariDataSource ds = new HikariDataSource(config); - return ds; - } -} diff --git a/tests/examples/JDBC/connectionPools/src/main/resources/log4j.properties b/tests/examples/JDBC/connectionPools/src/main/resources/log4j.properties deleted file mode 100644 index 1299357be3d2e99ca6b79227f14ca7a587718914..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/resources/log4j.properties +++ /dev/null @@ -1,21 +0,0 @@ -### 设置### -log4j.rootLogger=debug,stdout,DebugLog,ErrorLog -### 输出信息到控制抬 ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n -### 输出DEBUG 级别以上的日志到=logs/debug.log -log4j.appender.DebugLog=org.apache.log4j.DailyRollingFileAppender -log4j.appender.DebugLog.File=logs/debug.log -log4j.appender.DebugLog.Append=true -log4j.appender.DebugLog.Threshold=DEBUG -log4j.appender.DebugLog.layout=org.apache.log4j.PatternLayout -log4j.appender.DebugLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n -### 输出ERROR 级别以上的日志到=logs/error.log -log4j.appender.ErrorLog=org.apache.log4j.DailyRollingFileAppender -log4j.appender.ErrorLog.File=logs/error.log -log4j.appender.ErrorLog.Append=true -log4j.appender.ErrorLog.Threshold=ERROR -log4j.appender.ErrorLog.layout=org.apache.log4j.PatternLayout -log4j.appender.ErrorLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n \ No newline at end of file diff --git a/tests/examples/JDBC/connectionPools/src/main/resources/proxool.xml b/tests/examples/JDBC/connectionPools/src/main/resources/proxool.xml deleted file mode 100644 index 67baa1c3931aa57591af8fc306ed441328606978..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/connectionPools/src/main/resources/proxool.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - ds - - jdbc:TAOS-RS://127.0.0.1:6041/log - - com.taosdata.jdbc.rs.RestfulDriver - - - - - - - 100 - - 100 - - 1 - - 5 - - 30000 - - select server_status() - - \ No newline at end of file diff --git a/tests/examples/JDBC/mybatisplus-demo/.gitignore b/tests/examples/JDBC/mybatisplus-demo/.gitignore deleted file mode 100644 index b56f1dd0d04da4e03f710af3917e4fbdd9be4aa8..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -README.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/MavenWrapperDownloader.java b/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index a45eb6ba269cd38f8965cef786729790945d9537..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if (mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if (mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if (!outputFile.getParentFile().exists()) { - if (!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/maven-wrapper.jar b/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054..0000000000000000000000000000000000000000 Binary files a/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/maven-wrapper.properties b/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 642d572ce90e5085986bdd9c9204b9404f028084..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/tests/examples/JDBC/mybatisplus-demo/mvnw b/tests/examples/JDBC/mybatisplus-demo/mvnw deleted file mode 100755 index 3c8a5537314954d53ec2fb774b34fe5d5a5f253a..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/mvnw +++ /dev/null @@ -1,322 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ]; then - - if [ -f /etc/mavenrc ]; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ]; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false -darwin=false -mingw=false -case "$(uname)" in -CYGWIN*) cygwin=true ;; -MINGW*) mingw=true ;; -Darwin*) - darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="$(/usr/libexec/java_home)" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ]; then - if [ -r /etc/gentoo-release ]; then - JAVA_HOME=$(java-config --jre-home) - fi -fi - -if [ -z "$M2_HOME" ]; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ]; do - ls=$(ls -ld "$PRG") - link=$(expr "$ls" : '.*-> \(.*\)$') - if expr "$link" : '/.*' >/dev/null; then - PRG="$link" - else - PRG="$(dirname "$PRG")/$link" - fi - done - - saveddir=$(pwd) - - M2_HOME=$(dirname "$PRG")/.. - - # make it fully qualified - M2_HOME=$(cd "$M2_HOME" && pwd) - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=$(cygpath --unix "$M2_HOME") - [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --unix "$JAVA_HOME") - [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --unix "$CLASSPATH") -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw; then - [ -n "$M2_HOME" ] && - M2_HOME="$( ( - cd "$M2_HOME" - pwd - ))" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="$( ( - cd "$JAVA_HOME" - pwd - ))" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="$(which javac)" - if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=$(which readlink) - if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then - if $darwin; then - javaHome="$(dirname \"$javaExecutable\")" - javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac" - else - javaExecutable="$(readlink -f \"$javaExecutable\")" - fi - javaHome="$(dirname \"$javaExecutable\")" - javaHome=$(expr "$javaHome" : '\(.*\)/bin') - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ]; then - if [ -n "$JAVA_HOME" ]; then - if [ -x "$JAVA_HOME/jre/sh/java" ]; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="$(which java)" - fi -fi - -if [ ! -x "$JAVACMD" ]; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ]; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ]; then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ]; do - if [ -d "$wdir"/.mvn ]; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=$( - cd "$wdir/.." - pwd - ) - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' <"$1")" - fi -} - -BASE_DIR=$(find_maven_basedir "$(pwd)") -if [ -z "$BASE_DIR" ]; then - exit 1 -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in wrapperUrl) - jarUrl="$value" - break - ;; - esac - done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") - fi - - if command -v wget >/dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl >/dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=$(cygpath --path --windows "$javaClass") - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=$(cygpath --path --windows "$M2_HOME") - [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") - [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --windows "$CLASSPATH") - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/tests/examples/JDBC/mybatisplus-demo/mvnw.cmd b/tests/examples/JDBC/mybatisplus-demo/mvnw.cmd deleted file mode 100644 index c8d43372c986d97911cdc21bd87e0cbe3d83bdda..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/tests/examples/JDBC/mybatisplus-demo/pom.xml b/tests/examples/JDBC/mybatisplus-demo/pom.xml deleted file mode 100644 index ad6a63e800fb73dd3c768a8aca941f70cec235b3..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/pom.xml +++ /dev/null @@ -1,100 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.4.0 - - - com.taosdata.example - mybatisplus-demo - 0.0.1-SNAPSHOT - mybatisplus-demo - Demo project for tdengine - - - 1.8 - - - - - org.springframework.boot - spring-boot-starter - - - org.projectlombok - lombok - true - - - com.baomidou - mybatis-plus-boot-starter - 3.1.2 - - - com.h2database - h2 - runtime - - - com.alibaba - druid - 1.1.17 - - - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.18 - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - org.springframework.boot - spring-boot-starter-test - test - - - junit - junit - 4.13.1 - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.17 - - - **/*Test.java - - - **/Abstract*.java - - - - - - - - diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/MybatisplusDemoApplication.java b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/MybatisplusDemoApplication.java deleted file mode 100644 index 7aaebca0846c15c2055596c95ae76d0cee773e41..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/MybatisplusDemoApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.taosdata.example.mybatisplusdemo; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -@MapperScan("com.taosdata.example.mybatisplusdemo.mapper") -public class MybatisplusDemoApplication { - - public static void main(String[] args) { - SpringApplication.run(MybatisplusDemoApplication.class, args); - } - -} \ No newline at end of file diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/config/MybatisPlusConfig.java b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/config/MybatisPlusConfig.java deleted file mode 100644 index a6ac7f7fc247a361286333de4b3c03ffba306336..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/config/MybatisPlusConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.taosdata.example.mybatisplusdemo.config; - -import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MybatisPlusConfig { - - - /** mybatis 3.4.1 pagination config start ***/ -// @Bean -// public MybatisPlusInterceptor mybatisPlusInterceptor() { -// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); -// interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); -// return interceptor; -// } - -// @Bean -// public ConfigurationCustomizer configurationCustomizer() { -// return configuration -> configuration.setUseDeprecatedExecutor(false); -// } - - @Bean - public PaginationInterceptor paginationInterceptor() { -// return new PaginationInterceptor(); - PaginationInterceptor paginationInterceptor = new PaginationInterceptor(); - //TODO: mybatis-plus do not support TDengine, use postgresql Dialect - paginationInterceptor.setDialectType("postgresql"); - - return paginationInterceptor; - } - -} diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/domain/Temperature.java b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/domain/Temperature.java deleted file mode 100644 index 97e50b06f6b71c26d1edd65c5ae9e7ff29a03e4d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/domain/Temperature.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.taosdata.example.mybatisplusdemo.domain; - -import lombok.Data; - -import java.sql.Timestamp; - -@Data -public class Temperature { - - private Timestamp ts; - private float temperature; - private String location; - private int tbIndex; - -} diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/domain/Weather.java b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/domain/Weather.java deleted file mode 100644 index 361757411a15d29e742a07a92060e20190921223..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/domain/Weather.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.taosdata.example.mybatisplusdemo.domain; - -import lombok.Data; - -import java.sql.Timestamp; - -@Data -public class Weather { - - private Timestamp ts; - private float temperature; - private int humidity; - private String location; - -} diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/mapper/TemperatureMapper.java b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/mapper/TemperatureMapper.java deleted file mode 100644 index 3e122524d57b5a54e08ff1cfc54101d517f32c32..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/mapper/TemperatureMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.taosdata.example.mybatisplusdemo.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.taosdata.example.mybatisplusdemo.domain.Temperature; -import org.apache.ibatis.annotations.Insert; -import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Update; - -public interface TemperatureMapper extends BaseMapper { - - @Update("CREATE TABLE if not exists temperature(ts timestamp, temperature float) tags(location nchar(64), tbIndex int)") - int createSuperTable(); - - @Update("create table #{tbName} using temperature tags( #{location}, #{tbindex})") - int createTable(@Param("tbName") String tbName, @Param("location") String location, @Param("tbindex") int tbindex); - - @Update("drop table if exists temperature") - void dropSuperTable(); - - @Insert("insert into t${tbIndex}(ts, temperature) values(#{ts}, #{temperature})") - int insertOne(Temperature one); - -} diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapper.java b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapper.java deleted file mode 100644 index 6733cbded9d1d180408eccaad9e8badad7d39a3d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapper.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.taosdata.example.mybatisplusdemo.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.taosdata.example.mybatisplusdemo.domain.Weather; - -public interface WeatherMapper extends BaseMapper { - -} diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml b/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml deleted file mode 100644 index 38180c6d75a620a63bcaab9ec350d97e65f9dd16..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml +++ /dev/null @@ -1,24 +0,0 @@ -spring: - datasource: - driver-class-name: com.taosdata.jdbc.TSDBDriver - url: jdbc:TAOS://localhost:6030/mp_test?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8 - user: root - password: taosdata - - druid: - initial-size: 5 - min-idle: 5 - max-active: 5 - -mybatis-plus: - configuration: - map-underscore-to-camel-case: false - -logging: - level: - com: - taosdata: - example: - mybatisplusdemo: - mapper: debug - diff --git a/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/TemperatureMapperTest.java b/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/TemperatureMapperTest.java deleted file mode 100644 index 4331d15d3476d3428e72a186664ed77cc59aad3e..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/TemperatureMapperTest.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.taosdata.example.mybatisplusdemo.mapper; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.taosdata.example.mybatisplusdemo.domain.Temperature; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest -public class TemperatureMapperTest { - - private static Random random = new Random(System.currentTimeMillis()); - private static String[] locations = {"北京", "上海", "深圳", "广州", "杭州"}; - - @Before - public void before() { - mapper.dropSuperTable(); - // create table temperature - mapper.createSuperTable(); - // create table t_X using temperature - for (int i = 0; i < 10; i++) { - mapper.createTable("t" + i, locations[random.nextInt(locations.length)], i); - } - // insert into table - int affectRows = 0; - // insert 10 tables - for (int i = 0; i < 10; i++) { - // each table insert 5 rows - for (int j = 0; j < 5; j++) { - Temperature one = new Temperature(); - one.setTs(new Timestamp(1605024000000l)); - one.setTemperature(random.nextFloat() * 50); - one.setLocation("望京"); - one.setTbIndex(i); - affectRows += mapper.insertOne(one); - } - } - Assert.assertEquals(50, affectRows); - } - - @After - public void after() { - mapper.dropSuperTable(); - } - - @Autowired - private TemperatureMapper mapper; - - /*** - * test SelectList - * **/ - @Test - public void testSelectList() { - List temperatureList = mapper.selectList(null); - temperatureList.forEach(System.out::println); - } - - /*** - * test InsertOne which is a custom metheod - * ***/ - @Test - public void testInsert() { - Temperature one = new Temperature(); - one.setTs(new Timestamp(1605024000000l)); - one.setTemperature(random.nextFloat() * 50); - one.setLocation("望京"); - int affectRows = mapper.insertOne(one); - Assert.assertEquals(1, affectRows); - } - - /*** - * test SelectOne - * **/ - @Test - public void testSelectOne() { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("location", "beijing"); - Temperature one = mapper.selectOne(wrapper); - System.out.println(one); - Assert.assertNotNull(one); - } - - /*** - * test select By map - * ***/ - @Test - public void testSelectByMap() { - Map map = new HashMap<>(); - map.put("location", "beijing"); - List temperatures = mapper.selectByMap(map); - Assert.assertEquals(1, temperatures.size()); - } - - /*** - * test selectObjs - * **/ - @Test - public void testSelectObjs() { - List ts = mapper.selectObjs(null); - System.out.println(ts); - } - - /** - * test selectC ount - * **/ - @Test - public void testSelectCount() { - int count = mapper.selectCount(null); - Assert.assertEquals(5, count); - } - - /**** - * 分页 - */ - @Test - public void testSelectPage() { - IPage page = new Page(1, 2); - IPage temperatureIPage = mapper.selectPage(page, null); - System.out.println("total : " + temperatureIPage.getTotal()); - System.out.println("pages : " + temperatureIPage.getPages()); - for (Temperature temperature : temperatureIPage.getRecords()) { - System.out.println(temperature); - } - } - -} \ No newline at end of file diff --git a/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java b/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java deleted file mode 100644 index 1699344552f89e1595d1317019c992dcd3820e77..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.taosdata.example.mybatisplusdemo.mapper; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.taosdata.example.mybatisplusdemo.domain.Weather; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - -@RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest -public class WeatherMapperTest { - - private static Random random = new Random(System.currentTimeMillis()); - - @Autowired - private WeatherMapper mapper; - - @Test - public void testSelectList() { - List weathers = mapper.selectList(null); - weathers.forEach(System.out::println); - } - - @Test - public void testInsert() { - Weather one = new Weather(); - one.setTs(new Timestamp(1605024000000l)); - one.setTemperature(random.nextFloat() * 50); - one.setHumidity(random.nextInt(100)); - one.setLocation("望京"); - int affectRows = mapper.insert(one); - Assert.assertEquals(1, affectRows); - } - - @Test - public void testSelectOne() { - QueryWrapper wrapper = new QueryWrapper<>(); - wrapper.eq("location", "beijing"); - Weather one = mapper.selectOne(wrapper); - System.out.println(one); - Assert.assertEquals(12.22f, one.getTemperature(), 0.00f); - Assert.assertEquals("beijing", one.getLocation()); - } - - @Test - public void testSelectByMap() { - Map map = new HashMap<>(); - map.put("location", "beijing"); - List weathers = mapper.selectByMap(map); - Assert.assertEquals(1, weathers.size()); - } - - @Test - public void testSelectObjs() { - List ts = mapper.selectObjs(null); - System.out.println(ts); - } - - @Test - public void testSelectCount() { - int count = mapper.selectCount(null); -// Assert.assertEquals(5, count); - System.out.println(count); - } - - @Test - public void testSelectPage() { - IPage page = new Page(1, 2); - IPage weatherIPage = mapper.selectPage(page, null); - System.out.println("total : " + weatherIPage.getTotal()); - System.out.println("pages : " + weatherIPage.getPages()); - for (Weather weather : weatherIPage.getRecords()) { - System.out.println(weather); - } - } - -} \ No newline at end of file diff --git a/tests/examples/JDBC/readme.md b/tests/examples/JDBC/readme.md deleted file mode 100644 index 35dfb341d7d62bb283897523f928e04dabea962d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/readme.md +++ /dev/null @@ -1,13 +0,0 @@ -# TDengine examples - -| No. | Name | Describe | -| :--: | :----------------: | ------------------------------------------------------------ | -| 1 | JDBCDemo | Example codes for JDBC-JNI, JDBC-RESTful, Subscribe | -| 2 | connectionPools | Example codes for HikariCP, Druid, dbcp, c3p0 connection pools | -| 3 | SpringJdbcTemplate | Example codes for spring jdbcTemplate | -| 4 | mybatisplus-demo | Example codes for mybatis | -| 5 | springbootdemo | Example codes for springboot | -| 6 | taosdemo | This is an internal tool for testing Our JDBC-JNI, JDBC-RESTful, RESTful interfaces | - - -more detail: https://www.taosdata.com/cn/documentation20/connector/java diff --git a/tests/examples/JDBC/springbootdemo/.gitignore b/tests/examples/JDBC/springbootdemo/.gitignore deleted file mode 100644 index b8a47adccb623c653c547481ff9d3221210f31ef..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -.mvn/ -target/ -!**/src/main/** -!**/src/test/** - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ - -### VS Code ### -.vscode/ diff --git a/tests/examples/JDBC/springbootdemo/.mvn/wrapper/MavenWrapperDownloader.java b/tests/examples/JDBC/springbootdemo/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index 74f4de40122aca522184d5b1aac4f0ac29888b1a..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.5"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if (mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if (mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if (!outputFile.getParentFile().exists()) { - if (!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/tests/examples/JDBC/springbootdemo/.mvn/wrapper/maven-wrapper.jar b/tests/examples/JDBC/springbootdemo/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 0d5e649888a4843c1520054d9672f80c62ebbb48..0000000000000000000000000000000000000000 Binary files a/tests/examples/JDBC/springbootdemo/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/tests/examples/JDBC/springbootdemo/.mvn/wrapper/maven-wrapper.properties b/tests/examples/JDBC/springbootdemo/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 7d59a01f2594defa27705a493da0e4d57465aa2d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar diff --git a/tests/examples/JDBC/springbootdemo/mvnw b/tests/examples/JDBC/springbootdemo/mvnw deleted file mode 100755 index 21d3ee84568ff68c4712677da7c3b06f61ab5543..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/mvnw +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/tests/examples/JDBC/springbootdemo/mvnw.cmd b/tests/examples/JDBC/springbootdemo/mvnw.cmd deleted file mode 100644 index 84d60abc339b13f80f3300b00387f2d4cc4eb328..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/tests/examples/JDBC/springbootdemo/pom.xml b/tests/examples/JDBC/springbootdemo/pom.xml deleted file mode 100644 index 9126813b67e71691692109920f891a6fb4cc5ab5..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.2.1.RELEASE - - - com.taosdata.example - springbootdemo - 0.0.1-SNAPSHOT - springbootdemo - Demo project for using tdengine with Spring Boot - - - 1.8 - - - - - org.springframework.boot - spring-boot-starter-data-jdbc - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - org.springframework.boot - spring-boot-starter-web - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - 2.1.1 - - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - org.springframework.boot - spring-boot-configuration-processor - true - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - - org.springframework.boot - spring-boot-starter-aop - - - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.34 - - - - com.alibaba - druid-spring-boot-starter - 1.1.17 - - - - - - - src/main/resources - - **/*.properties - **/*.xml - - true - - - src/main/java - - **/*.properties - **/*.xml - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/tests/examples/JDBC/springbootdemo/readme.md b/tests/examples/JDBC/springbootdemo/readme.md deleted file mode 100644 index 67a28947d2dfb8fc069bf94fd139a7006d35a22b..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/readme.md +++ /dev/null @@ -1,96 +0,0 @@ -## TDengine SpringBoot + Mybatis Demo - -### 配置 application.properties -```properties -# datasource config -spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver -spring.datasource.url=jdbc:TAOS://127.0.0.1:6030/log -spring.datasource.username=root -spring.datasource.password=taosdata - -spring.datasource.druid.initial-size=5 -spring.datasource.druid.min-idle=5 -spring.datasource.druid.max-active=5 -# max wait time for get connection, ms -spring.datasource.druid.max-wait=60000 - -spring.datasource.druid.validation-query=select server_status(); -spring.datasource.druid.validation-query-timeout=5000 -spring.datasource.druid.test-on-borrow=false -spring.datasource.druid.test-on-return=false -spring.datasource.druid.test-while-idle=true -spring.datasource.druid.time-between-eviction-runs-millis=60000 -spring.datasource.druid.min-evictable-idle-time-millis=600000 -spring.datasource.druid.max-evictable-idle-time-millis=900000 - -# mybatis -mybatis.mapper-locations=classpath:mapper/*.xml - -# log -logging.level.com.taosdata.jdbc.springbootdemo.dao=debug -``` - -### 主要功能 - -* 创建数据库和表 -```xml - - - create database if not exists test; - - - - create table if not exists test.weather(ts timestamp, temperature int, humidity float); - -``` - -* 插入单条记录 -```xml - - - insert into test.weather (ts, temperature, humidity) values (now, #{temperature,jdbcType=INTEGER}, #{humidity,jdbcType=FLOAT}) - -``` -* 插入多条记录 -```xml - - - insert into test.weather (ts, temperature, humidity) values - - (now + #{index}a, #{weather.temperature}, #{weather.humidity}) - - -``` -* 分页查询 -```xml - - - - - - - - - - - - - - ts, temperature, humidity - - - - -``` - diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java deleted file mode 100644 index 53edaa5796cccc7e4a4f274048c83a9ca7bbc7bb..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/SpringbootdemoApplication.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.taosdata.example.springbootdemo; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@MapperScan(basePackages = {"com.taosdata.example.springbootdemo"}) -@SpringBootApplication -public class SpringbootdemoApplication { - - public static void main(String[] args) { - SpringApplication.run(SpringbootdemoApplication.class, args); - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java deleted file mode 100644 index ed720fe6c02dd3a7eba6e645ea1e76d704c04d0c..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.taosdata.example.springbootdemo.controller; - -import com.taosdata.example.springbootdemo.domain.Weather; -import com.taosdata.example.springbootdemo.service.WeatherService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; -import java.util.Map; - -@RequestMapping("/weather") -@RestController -public class WeatherController { - - @Autowired - private WeatherService weatherService; - - @GetMapping("/lastOne") - public Weather lastOne() { - return weatherService.lastOne(); - } - - @GetMapping("/init") - public int init() { - return weatherService.init(); - } - - @GetMapping("/{limit}/{offset}") - public List queryWeather(@PathVariable Long limit, @PathVariable Long offset) { - return weatherService.query(limit, offset); - } - - @PostMapping("/{temperature}/{humidity}") - public int saveWeather(@PathVariable float temperature, @PathVariable float humidity) { - return weatherService.save(temperature, humidity); - } - - @GetMapping("/count") - public int count() { - return weatherService.count(); - } - - @GetMapping("/subTables") - public List getSubTables() { - return weatherService.getSubTables(); - } - - @GetMapping("/avg") - public List avg() { - return weatherService.avg(); - } - -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java deleted file mode 100644 index d9202b45b4cc3dddf8e5a082ac339c1f88d4ec01..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.taosdata.example.springbootdemo.dao; - -import com.taosdata.example.springbootdemo.domain.Weather; -import org.apache.ibatis.annotations.Param; - -import java.util.List; -import java.util.Map; - -public interface WeatherMapper { - - Map lastOne(); - - void dropDB(); - - void createDB(); - - void createSuperTable(); - - void createTable(Weather weather); - - List select(@Param("limit") Long limit, @Param("offset") Long offset); - - int insert(Weather weather); - - int count(); - - List getSubTables(); - - List avg(); - -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml deleted file mode 100644 index 91938ca24e3cf9c3e0f2895cf40f214d484c55d5..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - drop - database if exists test - - - - create - database if not exists test - - - - create table if not exists test.weather - ( - ts - timestamp, - temperature - float, - humidity - float, - note - binary - ( - 64 - )) tags - ( - location nchar - ( - 64 - ), groupId int) - - - - create table if not exists test.t#{groupId} using test.weather tags - ( - #{location}, - #{groupId} - ) - - - - - - insert into test.t#{groupId} (ts, temperature, humidity, note) - values (#{ts}, ${temperature}, ${humidity}, #{note}) - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java deleted file mode 100644 index e4238127bd32b0f6ad21a514f3a1f07f6069b6d5..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.taosdata.example.springbootdemo.domain; - -import com.fasterxml.jackson.annotation.JsonFormat; - -import java.sql.Timestamp; - -public class Weather { - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8") - private Timestamp ts; - private Float temperature; - private Float humidity; - private String location; - private String note; - private int groupId; - - public Weather() { - } - - public Weather(Timestamp ts, float temperature, float humidity) { - this.ts = ts; - this.temperature = temperature; - this.humidity = humidity; - } - - public Timestamp getTs() { - return ts; - } - - public void setTs(Timestamp ts) { - this.ts = ts; - } - - public Float getTemperature() { - return temperature; - } - - public void setTemperature(Float temperature) { - this.temperature = temperature; - } - - public Float getHumidity() { - return humidity; - } - - public void setHumidity(Float humidity) { - this.humidity = humidity; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } - - public int getGroupId() { - return groupId; - } - - public void setGroupId(int groupId) { - this.groupId = groupId; - } - - public String getNote() { - return note; - } - - public void setNote(String note) { - this.note = note; - } -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java deleted file mode 100644 index 2264b200afc3e0c2b7dd8e496e607649f940581d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.taosdata.example.springbootdemo.service; - -import com.taosdata.example.springbootdemo.dao.WeatherMapper; -import com.taosdata.example.springbootdemo.domain.Weather; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.sql.Timestamp; -import java.util.List; -import java.util.Map; -import java.util.Random; - -@Service -public class WeatherService { - - @Autowired - private WeatherMapper weatherMapper; - private Random random = new Random(System.currentTimeMillis()); - private String[] locations = {"北京", "上海", "广州", "深圳", "天津"}; - - public int init() { - weatherMapper.dropDB(); - weatherMapper.createDB(); - weatherMapper.createSuperTable(); - long ts = System.currentTimeMillis(); - long thirtySec = 1000 * 30; - int count = 0; - for (int i = 0; i < 20; i++) { - Weather weather = new Weather(new Timestamp(ts + (thirtySec * i)), 30 * random.nextFloat(), random.nextInt(100)); - weather.setLocation(locations[random.nextInt(locations.length)]); - weather.setGroupId(i % locations.length); - weather.setNote("note-" + i); - weatherMapper.createTable(weather); - count += weatherMapper.insert(weather); - } - return count; - } - - public List query(Long limit, Long offset) { - return weatherMapper.select(limit, offset); - } - - public int save(float temperature, float humidity) { - Weather weather = new Weather(); - weather.setTemperature(temperature); - weather.setHumidity(humidity); - - return weatherMapper.insert(weather); - } - - public int count() { - return weatherMapper.count(); - } - - public List getSubTables() { - return weatherMapper.getSubTables(); - } - - public List avg() { - return weatherMapper.avg(); - } - - public Weather lastOne() { - Map result = weatherMapper.lastOne(); - - long ts = (long) result.get("ts"); - float temperature = (float) result.get("temperature"); - float humidity = (float) result.get("humidity"); - String note = (String) result.get("note"); - int groupId = (int) result.get("groupid"); - String location = (String) result.get("location"); - - Weather weather = new Weather(new Timestamp(ts), temperature, humidity); - weather.setNote(note); - weather.setGroupId(groupId); - weather.setLocation(location); - return weather; - } -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/util/TaosAspect.java b/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/util/TaosAspect.java deleted file mode 100644 index 80dad1bd7d669ba6b912c7e5fa816c29b7e37c87..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/util/TaosAspect.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.taosdata.example.springbootdemo.util; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.springframework.stereotype.Component; - -import java.sql.Timestamp; -import java.util.Map; - -@Aspect -@Component -public class TaosAspect { - - @Around("execution(java.util.Map com.taosdata.example.springbootdemo.dao.*.*(..))") - public Object handleType(ProceedingJoinPoint joinPoint) { - Map result = null; - try { - result = (Map) joinPoint.proceed(); - for (String key : result.keySet()) { - Object obj = result.get(key); - if (obj instanceof byte[]) { - obj = new String((byte[]) obj); - result.put(key, obj); - } - if (obj instanceof Timestamp) { - obj = ((Timestamp) obj).getTime(); - result.put(key, obj); - } - } - } catch (Throwable e) { - e.printStackTrace(); - } - return result; - } -} diff --git a/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties b/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties deleted file mode 100644 index 06daa81bbb06450d99ab3f6e640c9795c0ad5d2e..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/springbootdemo/src/main/resources/application.properties +++ /dev/null @@ -1,20 +0,0 @@ -# datasource config - JDBC-JNI -#spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver -#spring.datasource.url=jdbc:TAOS://localhost:6030/?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8 -#spring.datasource.username=root -#spring.datasource.password=taosdata -# datasource config - JDBC-RESTful -spring.datasource.driver-class-name=com.taosdata.jdbc.rs.RestfulDriver -spring.datasource.url=jdbc:TAOS-RS://localhsot:6041/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8 -spring.datasource.username=root -spring.datasource.password=taosdata -spring.datasource.druid.initial-size=5 -spring.datasource.druid.min-idle=5 -spring.datasource.druid.max-active=5 -spring.datasource.druid.max-wait=30000 -spring.datasource.druid.validation-query=select server_status(); -spring.aop.auto=true -spring.aop.proxy-target-class=true -#mybatis -mybatis.mapper-locations=classpath:mapper/*.xml -logging.level.com.taosdata.jdbc.springbootdemo.dao=debug diff --git a/tests/examples/JDBC/taosdemo/.gitignore b/tests/examples/JDBC/taosdemo/.gitignore deleted file mode 100644 index 549e00a2a96fa9d7c5dbc9859664a78d980158c2..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/tests/examples/JDBC/taosdemo/.mvn/wrapper/MavenWrapperDownloader.java b/tests/examples/JDBC/taosdemo/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index a45eb6ba269cd38f8965cef786729790945d9537..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2007-present the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.net.*; -import java.io.*; -import java.nio.channels.*; -import java.util.Properties; - -public class MavenWrapperDownloader { - - private static final String WRAPPER_VERSION = "0.5.6"; - /** - * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. - */ - private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; - - /** - * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to - * use instead of the default one. - */ - private static final String MAVEN_WRAPPER_PROPERTIES_PATH = - ".mvn/wrapper/maven-wrapper.properties"; - - /** - * Path where the maven-wrapper.jar will be saved to. - */ - private static final String MAVEN_WRAPPER_JAR_PATH = - ".mvn/wrapper/maven-wrapper.jar"; - - /** - * Name of the property which should be used to override the default download url for the wrapper. - */ - private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - - public static void main(String args[]) { - System.out.println("- Downloader started"); - File baseDirectory = new File(args[0]); - System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); - String url = DEFAULT_DOWNLOAD_URL; - if (mavenWrapperPropertyFile.exists()) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try { - mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); - url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); - } catch (IOException e) { - System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); - } finally { - try { - if (mavenWrapperPropertyFileInputStream != null) { - mavenWrapperPropertyFileInputStream.close(); - } - } catch (IOException e) { - // Ignore ... - } - } - } - System.out.println("- Downloading from: " + url); - - File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); - if (!outputFile.getParentFile().exists()) { - if (!outputFile.getParentFile().mkdirs()) { - System.out.println( - "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); - } - } - System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); - try { - downloadFileFromURL(url, outputFile); - System.out.println("Done"); - System.exit(0); - } catch (Throwable e) { - System.out.println("- Error downloading"); - e.printStackTrace(); - System.exit(1); - } - } - - private static void downloadFileFromURL(String urlString, File destination) throws Exception { - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - String username = System.getenv("MVNW_USERNAME"); - char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - URL website = new URL(urlString); - ReadableByteChannel rbc; - rbc = Channels.newChannel(website.openStream()); - FileOutputStream fos = new FileOutputStream(destination); - fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); - fos.close(); - rbc.close(); - } - -} diff --git a/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.jar b/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index 2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054..0000000000000000000000000000000000000000 Binary files a/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.properties b/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 642d572ce90e5085986bdd9c9204b9404f028084..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/tests/examples/JDBC/taosdemo/mvnw b/tests/examples/JDBC/taosdemo/mvnw deleted file mode 100755 index 3c8a5537314954d53ec2fb774b34fe5d5a5f253a..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/mvnw +++ /dev/null @@ -1,322 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ]; then - - if [ -f /etc/mavenrc ]; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ]; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false -darwin=false -mingw=false -case "$(uname)" in -CYGWIN*) cygwin=true ;; -MINGW*) mingw=true ;; -Darwin*) - darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="$(/usr/libexec/java_home)" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ]; then - if [ -r /etc/gentoo-release ]; then - JAVA_HOME=$(java-config --jre-home) - fi -fi - -if [ -z "$M2_HOME" ]; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ]; do - ls=$(ls -ld "$PRG") - link=$(expr "$ls" : '.*-> \(.*\)$') - if expr "$link" : '/.*' >/dev/null; then - PRG="$link" - else - PRG="$(dirname "$PRG")/$link" - fi - done - - saveddir=$(pwd) - - M2_HOME=$(dirname "$PRG")/.. - - # make it fully qualified - M2_HOME=$(cd "$M2_HOME" && pwd) - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=$(cygpath --unix "$M2_HOME") - [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --unix "$JAVA_HOME") - [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --unix "$CLASSPATH") -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw; then - [ -n "$M2_HOME" ] && - M2_HOME="$( ( - cd "$M2_HOME" - pwd - ))" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="$( ( - cd "$JAVA_HOME" - pwd - ))" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="$(which javac)" - if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=$(which readlink) - if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then - if $darwin; then - javaHome="$(dirname \"$javaExecutable\")" - javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac" - else - javaExecutable="$(readlink -f \"$javaExecutable\")" - fi - javaHome="$(dirname \"$javaExecutable\")" - javaHome=$(expr "$javaHome" : '\(.*\)/bin') - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ]; then - if [ -n "$JAVA_HOME" ]; then - if [ -x "$JAVA_HOME/jre/sh/java" ]; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="$(which java)" - fi -fi - -if [ ! -x "$JAVACMD" ]; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ]; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ]; then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ]; do - if [ -d "$wdir"/.mvn ]; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=$( - cd "$wdir/.." - pwd - ) - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' <"$1")" - fi -} - -BASE_DIR=$(find_maven_basedir "$(pwd)") -if [ -z "$BASE_DIR" ]; then - exit 1 -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in wrapperUrl) - jarUrl="$value" - break - ;; - esac - done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") - fi - - if command -v wget >/dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl >/dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=$(cygpath --path --windows "$javaClass") - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=$(cygpath --path --windows "$M2_HOME") - [ -n "$JAVA_HOME" ] && - JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") - [ -n "$CLASSPATH" ] && - CLASSPATH=$(cygpath --path --windows "$CLASSPATH") - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/tests/examples/JDBC/taosdemo/mvnw.cmd b/tests/examples/JDBC/taosdemo/mvnw.cmd deleted file mode 100644 index c8d43372c986d97911cdc21bd87e0cbe3d83bdda..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/tests/examples/JDBC/taosdemo/pom.xml b/tests/examples/JDBC/taosdemo/pom.xml deleted file mode 100644 index e249d83e16def830b61e9f8ab82197d30e7e0d33..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/pom.xml +++ /dev/null @@ -1,168 +0,0 @@ - - - 4.0.0 - com.taosdata - taosdemo - 2.0.1 - taosdemo - jar - Demo project for TDengine - - - 5.3.14 - - - - - - org.springframework - spring-context - ${spring.version} - - - org.springframework - spring-core - ${spring.version} - - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-expression - ${spring.version} - - - org.springframework - spring-aop - ${spring.version} - - - org.springframework - spring-aspects - ${spring.version} - - - org.springframework - spring-test - ${spring.version} - test - - - org.springframework - spring-jdbc - ${spring.version} - - - - - com.zaxxer - HikariCP - 3.4.5 - - - - com.taosdata.jdbc - taos-jdbcdriver - 2.0.20 - - - - - - com.alibaba - fastjson - 1.2.75 - - - - mysql - mysql-connector-java - 8.0.16 - test - - - - org.apache.logging.log4j - log4j-core - 2.17.1 - - - - junit - junit - 4.13.1 - test - - - - org.projectlombok - lombok - 1.18.16 - provided - - - - - - - src/main/resources - - **/*.properties - **/*.xml - **/*.jar - - true - - - src/main/java - - **/*.properties - **/*.xml - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - - - - org.apache.maven.plugins - maven-assembly-plugin - 3.1.0 - - - - - com.taosdata.taosdemo.TaosDemoApplication - - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - - - - diff --git a/tests/examples/JDBC/taosdemo/readme.md b/tests/examples/JDBC/taosdemo/readme.md deleted file mode 100644 index 451fa2960adb98e2deb8499732aefde11f4810a1..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/readme.md +++ /dev/null @@ -1,13 +0,0 @@ -``` -cd tests/examples/JDBC/taosdemo -mvn clean package -Dmaven.test.skip=true -# 先建表,再插入的 -java -jar target/taosdemo-2.0-jar-with-dependencies.jar -host [hostname] -database [database] -doCreateTable true -superTableSQL "create table weather(ts timestamp, f1 int) tags(t1 nchar(4))" -numOfTables 1000 -numOfRowsPerTable 100000000 -numOfThreadsForInsert 10 -numOfTablesPerSQL 10 -numOfValuesPerSQL 100 -# 不建表,直接插入的 -java -jar target/taosdemo-2.0-jar-with-dependencies.jar -host [hostname] -database [database] -doCreateTable false -superTableSQL "create table weather(ts timestamp, f1 int) tags(t1 nchar(4))" -numOfTables 1000 -numOfRowsPerTable 100000000 -numOfThreadsForInsert 10 -numOfTablesPerSQL 10 -numOfValuesPerSQL 100 -``` - -需求: -1. 可以读lowa的配置文件 -2. 支持JDBC-JNI和JDBC-restful -3. 读取配置文件,持续执行查询 \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java deleted file mode 100644 index d4f5ff26886b9f90a4235d47bfd004dae9de93f6..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/TaosDemoApplication.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.taosdata.taosdemo; - -import com.taosdata.taosdemo.components.DataSourceFactory; -import com.taosdata.taosdemo.components.JdbcTaosdemoConfig; -import com.taosdata.taosdemo.domain.SuperTableMeta; -import com.taosdata.taosdemo.service.DatabaseService; -import com.taosdata.taosdemo.service.SqlExecuteTask; -import com.taosdata.taosdemo.service.SubTableService; -import com.taosdata.taosdemo.service.SuperTableService; -import com.taosdata.taosdemo.service.data.SuperTableMetaGenerator; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -import javax.sql.DataSource; -import java.io.IOException; -import java.time.Duration; -import java.time.Instant; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -public class TaosDemoApplication { - - private static final Logger logger = LogManager.getLogger(TaosDemoApplication.class); - - public static void main(String[] args) throws IOException { - // 读配置参数 - JdbcTaosdemoConfig config = new JdbcTaosdemoConfig(args); - boolean isHelp = Arrays.asList(args).contains("--help"); - if (isHelp || config.host == null || config.host.isEmpty()) { - JdbcTaosdemoConfig.printHelp(); - System.exit(0); - } - // 初始化 - final DataSource dataSource = DataSourceFactory.getInstance(config.host, config.port, config.user, config.password); - if (config.executeSql != null && !config.executeSql.isEmpty() && !config.executeSql.replaceAll("\\s", "").isEmpty()) { - Thread task = new Thread(new SqlExecuteTask(dataSource, config.executeSql)); - task.start(); - try { - task.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return; - } - - final DatabaseService databaseService = new DatabaseService(dataSource); - final SuperTableService superTableService = new SuperTableService(dataSource); - final SubTableService subTableService = new SubTableService(dataSource); - - // 创建数据库 - long start = System.currentTimeMillis(); - Map databaseParam = new HashMap<>(); - databaseParam.put("database", config.database); - databaseParam.put("keep", Integer.toString(config.keep)); - databaseParam.put("days", Integer.toString(config.days)); - databaseParam.put("replica", Integer.toString(config.replica)); - //TODO: other database parameters - databaseService.createDatabase(databaseParam); - databaseService.useDatabase(config.database); - long end = System.currentTimeMillis(); - logger.info(">>> create database time cost : " + (end - start) + " ms."); - /**********************************************************************************/ - // 构造超级表的meta - SuperTableMeta superTableMeta; - // create super table - if (config.superTableSQL != null) { - // use a sql to create super table - superTableMeta = SuperTableMetaGenerator.generate(config.superTableSQL); - if (config.database != null && !config.database.isEmpty()) - superTableMeta.setDatabase(config.database); - } else if (config.numOfFields == 0) { - String sql = "create table " + config.database + "." + config.superTable + " (ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)"; - superTableMeta = SuperTableMetaGenerator.generate(sql); - } else { - // create super table with specified field size and tag size - superTableMeta = SuperTableMetaGenerator.generate(config.database, config.superTable, config.numOfFields, config.prefixOfFields, config.numOfTags, config.prefixOfTags); - } - /**********************************************************************************/ - // 建表 - start = System.currentTimeMillis(); - if (config.doCreateTable) { - superTableService.drop(superTableMeta.getDatabase(), superTableMeta.getName()); - superTableService.create(superTableMeta); - if (!config.autoCreateTable) { - // 批量建子表 - subTableService.createSubTable(superTableMeta, config.numOfTables, config.prefixOfTable, config.numOfThreadsForCreate); - } - } - end = System.currentTimeMillis(); - logger.info(">>> create table time cost : " + (end - start) + " ms."); - /**********************************************************************************/ - // 插入 - long tableSize = config.numOfTables; - int threadSize = config.numOfThreadsForInsert; - long startTime = getProperStartTime(config.startTime, config.keep); - - if (tableSize < threadSize) - threadSize = (int) tableSize; - long gap = (long) Math.ceil((0.0d + tableSize) / threadSize); - - start = System.currentTimeMillis(); - // multi threads to insert - int affectedRows = subTableService.insertMultiThreads(superTableMeta, threadSize, tableSize, startTime, gap, config); - end = System.currentTimeMillis(); - logger.info("insert " + affectedRows + " rows, time cost: " + (end - start) + " ms"); - /**********************************************************************************/ - // 查询 - - - /**********************************************************************************/ - // 删除表 - if (config.dropTable) { - superTableService.drop(config.database, config.superTable); - } - System.exit(0); - } - - private static long getProperStartTime(long startTime, int keep) { - Instant now = Instant.now(); - long earliest = now.minus(Duration.ofDays(keep - 1)).toEpochMilli(); - if (startTime == 0 || startTime < earliest) { - startTime = earliest; - } - return startTime; - } - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/DataSourceFactory.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/DataSourceFactory.java deleted file mode 100644 index a7d08e96ea373c4773e872bcaf9b3a7b98d5bf9a..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/DataSourceFactory.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.taosdata.taosdemo.components; - -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; -import org.springframework.stereotype.Component; - -import javax.sql.DataSource; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -@Component -public class DataSourceFactory { - - private static DataSource instance; - - public static DataSource getInstance(String host, int port, String user, String password) throws IOException { - if (instance == null) { - synchronized (DataSourceFactory.class) { - if (instance == null) { - InputStream is = DataSourceFactory.class.getClassLoader().getResourceAsStream("application.properties"); - Properties properties = new Properties(); - properties.load(is); - - HikariConfig config = new HikariConfig(); - if (properties.containsKey("jdbc.driver")) { -// String driverName = properties.getProperty("jdbc.driver"); -// System.out.println(">>> load driver : " + driverName); -// try { -// Class.forName(driverName); -// } catch (ClassNotFoundException e) { -// e.printStackTrace(); -// } - config.setDriverClassName(properties.getProperty("jdbc.driver")); - } else { - config.setDriverClassName("com.taosdata.jdbc.TSDBDriver"); - } - if ("com.taosdata.jdbc.rs.RestfulDriver".equalsIgnoreCase(properties.getProperty("jdbc.driver"))) - config.setJdbcUrl("jdbc:TAOS-RS://" + host + ":6041/?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8"); - else - config.setJdbcUrl("jdbc:TAOS://" + host + ":" + port + "/?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8"); - config.setUsername(user); - config.setPassword(password); - // maximum-pool-size - if (properties.containsKey("hikari.maximum-pool-size")) - config.setMaximumPoolSize(Integer.parseInt(properties.getProperty("hikari.maximum-pool-size"))); - else - config.setMaximumPoolSize(500); - // minimum-idle - if (properties.containsKey("hikari.minimum-idle")) - config.setMinimumIdle(Integer.parseInt(properties.getProperty("hikari.minimum-idle"))); - else - config.setMinimumIdle(100); - config.setMaxLifetime(0); - instance = new HikariDataSource(config); - } - } - } - return instance; - } - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/JdbcTaosdemoConfig.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/JdbcTaosdemoConfig.java deleted file mode 100644 index 974a2755a5a029d3a5fc681bc8c59b0aca1a7ca4..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/JdbcTaosdemoConfig.java +++ /dev/null @@ -1,221 +0,0 @@ -package com.taosdata.taosdemo.components; - -import com.taosdata.taosdemo.utils.TimeStampUtil; - -public final class JdbcTaosdemoConfig { - // instance - public String host; //host - public int port = 6030; //port - public String user = "root"; //user - public String password = "taosdata"; //password - // database - public String database = "jdbcdb"; //database - public int keep = 3650; //keep - public int days = 30; //days - public int replica = 1; //replica - public int blocks = 16; - public int cache = 8; - public String precision = "ms"; - - //super table - public boolean doCreateTable = true; - public String superTable = "weather"; //super table name - public String prefixOfFields = "col"; - public int numOfFields; - public String prefixOfTags = "tag"; - public int numOfTags; - public String superTableSQL; - //sub table - public String prefixOfTable = "t"; - // insert task - public boolean autoCreateTable; - public long numOfTables = 10; - public long numOfRowsPerTable = 10; - public int numOfTablesPerSQL = 1; - public int numOfValuesPerSQL = 1; - public int numOfThreadsForCreate = 1; - public int numOfThreadsForInsert = 1; - public long startTime; - public long timeGap = 1; - public int frequency; - public int order; - public int rate = 10; - public long range = 1000l; - // select task - public String executeSql; - // drop task - public boolean dropTable = false; - - public static void printHelp() { - System.out.println("Usage: java -jar jdbc-taosdemo-2.0.jar [OPTION...]"); - // instance - System.out.println("-host The host to connect to TDengine which you must specify"); - System.out.println("-port The TCP/IP port number to use for the connection. Default is 6030"); - System.out.println("-user The TDengine user name to use when connecting to the server. Default is 'root'"); - System.out.println("-password The password to use when connecting to the server.Default is 'taosdata'"); - // database - System.out.println("-database Destination database. Default is 'jdbcdb'"); - System.out.println("-keep database keep parameter. Default is 3650"); - System.out.println("-days database days parameter. Default is 30"); - System.out.println("-replica database replica parameter. Default 1, min: 1, max: 3"); - System.out.println("-blocks database blocks parameter. Default is 16"); - System.out.println("-cache database cache parameter. Default is 8"); - System.out.println("-precision database precision parameter. Default is ms"); - - // super table - System.out.println("-doCreateTable do create super table and sub table, true or false, Default true"); - System.out.println("-superTable super table name. Default 'weather'"); - System.out.println("-prefixOfFields The prefix of field in super table. Default is 'col'"); - System.out.println("-numOfFields The number of field in super table. Default is (ts timestamp, temperature float, humidity int)."); - System.out.println("-prefixOfTags The prefix of tag in super table. Default is 'tag'"); - System.out.println("-numOfTags The number of tag in super table. Default is (location nchar(64), groupId int)."); - System.out.println("-superTableSQL specify a sql statement for the super table.\n" + - " Default is 'create table weather(ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int). \n" + - " if you use this parameter, the numOfFields and numOfTags will be invalid'"); - // sub table - System.out.println("-prefixOfTable The prefix of sub tables. Default is 't'"); - System.out.println("-numOfTables The number of tables. Default is 1"); - System.out.println("-numOfThreadsForCreate The number of thread during create sub table. Default is 1"); - // insert task - System.out.println("-autoCreateTable Use auto Create sub tables SQL. Default is false"); - System.out.println("-numOfRowsPerTable The number of records per table. Default is 1"); - System.out.println("-numOfThreadsForInsert The number of threads during insert row. Default is 1"); - System.out.println("-numOfTablesPerSQL The number of table per SQL. Default is 1"); - System.out.println("-numOfValuesPerSQL The number of value per SQL. Default is 1"); - System.out.println("-startTime start time for insert task, The format is \"yyyy-MM-dd HH:mm:ss.SSS\"."); - System.out.println("-timeGap the number of time gap. Default is 1000 ms"); - System.out.println("-frequency the number of records per second inserted into one table. default is 0, do not control frequency"); - System.out.println("-order Insert mode--0: In order, 1: Out of order. Default is in order"); - System.out.println("-rate The proportion of data out of order. effective only if order is 1. min 0, max 100, default is 10"); - System.out.println("-range The range of data out of order. effective only if order is 1. default is 1000 ms"); - // query task - System.out.println("-executeSql execute a specific sql."); - // drop task - System.out.println("-dropTable Drop data before quit. Default is false"); - System.out.println("--help Give this help list"); - } - - /** - * parse args from command line - * - * @param args command line args - * @return JdbcTaosdemoConfig - */ - public JdbcTaosdemoConfig(String[] args) { - for (int i = 0; i < args.length; i++) { - // instance - if ("-host".equals(args[i]) && i < args.length - 1) { - host = args[++i]; - } - if ("-port".equals(args[i]) && i < args.length - 1) { - port = Integer.parseInt(args[++i]); - } - if ("-user".equals(args[i]) && i < args.length - 1) { - user = args[++i]; - } - if ("-password".equals(args[i]) && i < args.length - 1) { - password = args[++i]; - } - // database - if ("-database".equals(args[i]) && i < args.length - 1) { - database = args[++i]; - } - if ("-keep".equals(args[i]) && i < args.length - 1) { - keep = Integer.parseInt(args[++i]); - } - if ("-days".equals(args[i]) && i < args.length - 1) { - days = Integer.parseInt(args[++i]); - } - if ("-replica".equals(args[i]) && i < args.length - 1) { - replica = Integer.parseInt(args[++i]); - } - if ("-blocks".equals(args[i]) && i < args.length - 1) { - blocks = Integer.parseInt(args[++i]); - } - if ("-cache".equals(args[i]) && i < args.length - 1) { - cache = Integer.parseInt(args[++i]); - } - if ("-precision".equals(args[i]) && i < args.length - 1) { - precision = args[++i]; - } - // super table - if ("-doCreateTable".equals(args[i]) && i < args.length - 1) { - doCreateTable = Boolean.parseBoolean(args[++i]); - } - if ("-superTable".equals(args[i]) && i < args.length - 1) { - superTable = args[++i]; - } - if ("-prefixOfFields".equals(args[i]) && i < args.length - 1) { - prefixOfFields = args[++i]; - } - if ("-numOfFields".equals(args[i]) && i < args.length - 1) { - numOfFields = Integer.parseInt(args[++i]); - } - if ("-prefixOfTags".equals(args[i]) && i < args.length - 1) { - prefixOfTags = args[++i]; - } - if ("-numOfTags".equals(args[i]) && i < args.length - 1) { - numOfTags = Integer.parseInt(args[++i]); - } - if ("-superTableSQL".equals(args[i]) && i < args.length - 1) { - superTableSQL = args[++i]; - } - // sub table - if ("-prefixOfTable".equals(args[i]) && i < args.length - 1) { - prefixOfTable = args[++i]; - } - if ("-numOfTables".equals(args[i]) && i < args.length - 1) { - numOfTables = Long.parseLong(args[++i]); - } - if ("-autoCreateTable".equals(args[i]) && i < args.length - 1) { - autoCreateTable = Boolean.parseBoolean(args[++i]); - } - if ("-numOfThreadsForCreate".equals(args[i]) && i < args.length - 1) { - numOfThreadsForCreate = Integer.parseInt(args[++i]); - } - // insert task - if ("-numOfRowsPerTable".equals(args[i]) && i < args.length - 1) { - numOfRowsPerTable = Long.parseLong(args[++i]); - } - if ("-numOfThreadsForInsert".equals(args[i]) && i < args.length - 1) { - numOfThreadsForInsert = Integer.parseInt(args[++i]); - } - if ("-numOfTablesPerSQL".equals(args[i]) && i < args.length - 1) { - numOfTablesPerSQL = Integer.parseInt(args[++i]); - } - if ("-numOfValuesPerSQL".equals(args[i]) && i < args.length - 1) { - numOfValuesPerSQL = Integer.parseInt(args[++i]); - } - if ("-startTime".equals(args[i]) && i < args.length - 1) { - startTime = TimeStampUtil.datetimeToLong(args[++i]); - } - if ("-timeGap".equals(args[i]) && i < args.length - 1) { - timeGap = Long.parseLong(args[++i]); - } - if ("-frequency".equals(args[i]) && i < args.length - 1) { - frequency = Integer.parseInt(args[++i]); - } - if ("-order".equals(args[i]) && i < args.length - 1) { - order = Integer.parseInt(args[++i]); - } - if ("-rate".equals(args[i]) && i < args.length - 1) { - rate = Integer.parseInt(args[++i]); - if (rate < 0 || rate > 100) - throw new IllegalArgumentException("rate must between 0 and 100"); - } - if ("-range".equals(args[i]) && i < args.length - 1) { - range = Integer.parseInt(args[++i]); - } - // select task - if ("-executeSql".equals(args[i]) && i < args.length - 1) { - executeSql = args[++i]; - } - - // drop task - if ("-dropTable".equals(args[i]) && i < args.length - 1) { - dropTable = Boolean.parseBoolean(args[++i]); - } - } - } - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/JsonConfig.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/JsonConfig.java deleted file mode 100644 index 1c44610095f4b383f82a74dfdc11030a28afb246..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/components/JsonConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.taosdata.taosdemo.components; - -import com.alibaba.fastjson.JSONObject; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; - -public class JsonConfig { - - public static void main(String[] args) { - - JsonConfig config = new JsonConfig(); - String str = config.read("insert.json"); - JSONObject jsonObject = JSONObject.parseObject(str); - System.out.println(jsonObject); - - } - - private String read(String fileName) { - try { - BufferedReader reader = new BufferedReader( - new InputStreamReader(JsonConfig.class.getClassLoader().getResourceAsStream(fileName)) - ); - StringBuilder sb = new StringBuilder(); - String line = null; - while ((line = reader.readLine()) != null) { - sb.append(line); - } - return sb.toString(); - } catch (IOException e) { - e.printStackTrace(); - } - - return fileName; - } - - -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapper.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapper.java deleted file mode 100644 index 56e38d2bfce8ba5801d0f8dc48093d198852fbca..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.taosdata.taosdemo.dao; - -import java.util.Map; - -public interface DatabaseMapper { - - // create database if not exists XXX - void createDatabase(String dbname); - - // drop database if exists XXX - void dropDatabase(String dbname); - - // create database if not exists XXX keep XX days XX replica XX - void createDatabaseWithParameters(Map map); - - // use XXX - void useDatabase(String dbname); - - //TODO: alter database - - //TODO: show database - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java deleted file mode 100644 index 9340fc3fdd0ce7242d4121a5fb259af48f7ada5f..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/DatabaseMapperImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.taosdata.taosdemo.dao; - -import com.taosdata.taosdemo.utils.SqlSpeller; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.springframework.jdbc.core.JdbcTemplate; - -import javax.sql.DataSource; -import java.util.Map; - -public class DatabaseMapperImpl implements DatabaseMapper { - private static final Logger logger = LogManager.getLogger(DatabaseMapperImpl.class); - - private final JdbcTemplate jdbcTemplate; - - public DatabaseMapperImpl(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - - @Override - public void createDatabase(String dbname) { - String sql = "create database if not exists " + dbname; - jdbcTemplate.execute(sql); - logger.debug("SQL >>> " + sql); - } - - @Override - public void dropDatabase(String dbname) { - String sql = "drop database if exists " + dbname; - jdbcTemplate.update(sql); - logger.debug("SQL >>> " + sql); - } - - @Override - public void createDatabaseWithParameters(Map map) { - String sql = SqlSpeller.createDatabase(map); - jdbcTemplate.execute(sql); - logger.debug("SQL >>> " + sql); - } - - @Override - public void useDatabase(String dbname) { - String sql = "use " + dbname; - jdbcTemplate.execute(sql); - logger.debug("SQL >>> " + sql); - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapper.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapper.java deleted file mode 100644 index e0ddd220c19066afd1cc332f007a82e2fdab2b07..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.taosdata.taosdemo.dao; - -import com.taosdata.taosdemo.domain.SubTableMeta; -import com.taosdata.taosdemo.domain.SubTableValue; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface SubTableMapper { - - // 创建:子表 - void createUsingSuperTable(SubTableMeta subTableMeta); - - // 插入:一张子表多个values - int insertOneTableMultiValues(SubTableValue subTableValue); - - // 插入:一张子表多个values, 自动建表 - int insertOneTableMultiValuesUsingSuperTable(SubTableValue subTableValue); - - // 插入:多张表多个values - int insertMultiTableMultiValues(List tables); - - // 插入:多张表多个values,自动建表 - int insertMultiTableMultiValuesUsingSuperTable(List tables); - - // - -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java deleted file mode 100644 index db0d43ff05a56b673ed08a522b645d3388f8e091..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SubTableMapperImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.taosdata.taosdemo.dao; - -import com.taosdata.taosdemo.domain.SubTableMeta; -import com.taosdata.taosdemo.domain.SubTableValue; -import com.taosdata.taosdemo.utils.SqlSpeller; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.springframework.jdbc.core.JdbcTemplate; - -import javax.sql.DataSource; -import java.util.List; - -public class SubTableMapperImpl implements SubTableMapper { - - private static final Logger logger = LogManager.getLogger(SubTableMapperImpl.class); - private final JdbcTemplate jdbcTemplate; - - public SubTableMapperImpl(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - @Override - public void createUsingSuperTable(SubTableMeta subTableMeta) { - String sql = SqlSpeller.createTableUsingSuperTable(subTableMeta); - logger.debug("SQL >>> " + sql); - jdbcTemplate.execute(sql); - } - - @Override - public int insertOneTableMultiValues(SubTableValue subTableValue) { - String sql = SqlSpeller.insertOneTableMultiValues(subTableValue); - logger.debug("SQL >>> " + sql); - - int affectRows = 0; - try { - affectRows = jdbcTemplate.update(sql); - } catch (Exception e) { - e.printStackTrace(); - } - return affectRows; - } - - @Override - public int insertOneTableMultiValuesUsingSuperTable(SubTableValue subTableValue) { - String sql = SqlSpeller.insertOneTableMultiValuesUsingSuperTable(subTableValue); - logger.debug("SQL >>> " + sql); - - int affectRows = 0; - try { - affectRows = jdbcTemplate.update(sql); - } catch (Exception e) { - e.printStackTrace(); - } - return affectRows; - } - - @Override - public int insertMultiTableMultiValues(List tables) { - String sql = SqlSpeller.insertMultiSubTableMultiValues(tables); - logger.debug("SQL >>> " + sql); - int affectRows = 0; - try { - affectRows = jdbcTemplate.update(sql); - } catch (Exception e) { - e.printStackTrace(); - } - return affectRows; - } - - @Override - public int insertMultiTableMultiValuesUsingSuperTable(List tables) { - String sql = SqlSpeller.insertMultiTableMultiValuesUsingSuperTable(tables); - logger.debug("SQL >>> " + sql); - int affectRows = 0; - try { - affectRows = jdbcTemplate.update(sql); - } catch (Exception e) { - e.printStackTrace(); - } - return affectRows; - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapper.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapper.java deleted file mode 100644 index 9f8cec9e8fa5af8741d9efbdce72f240aa7a09aa..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.taosdata.taosdemo.dao; - -import com.taosdata.taosdemo.domain.SuperTableMeta; -import org.springframework.stereotype.Repository; - -@Repository -public interface SuperTableMapper { - - // 创建超级表 create table if not exists xxx.xxx (f1 type1, f2 type2, ... ) tags( t1 type1, t2 type2 ...) - void createSuperTable(SuperTableMeta tableMetadata); - - // 删除超级表 drop table if exists xxx; - void dropSuperTable(String database, String name); - - // - - // - - // - - // - - // - - // - - // - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java deleted file mode 100644 index 658a403a0ca3883831bca1ad2b6d579ef4713f7d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/SuperTableMapperImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.taosdata.taosdemo.dao; - -import com.taosdata.taosdemo.domain.SuperTableMeta; -import com.taosdata.taosdemo.utils.SqlSpeller; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.springframework.jdbc.core.JdbcTemplate; - -import javax.sql.DataSource; - -public class SuperTableMapperImpl implements SuperTableMapper { - private static final Logger logger = LogManager.getLogger(SuperTableMapperImpl.class); - private JdbcTemplate jdbcTemplate; - - public SuperTableMapperImpl(DataSource dataSource) { - this.jdbcTemplate = new JdbcTemplate(dataSource); - } - - @Override - public void createSuperTable(SuperTableMeta tableMetadata) { - String sql = SqlSpeller.createSuperTable(tableMetadata); - logger.debug("SQL >>> " + sql); - jdbcTemplate.execute(sql); - } - - @Override - public void dropSuperTable(String database, String name) { - String sql = "drop table if exists " + database + "." + name; - logger.debug("SQL >>> " + sql); - jdbcTemplate.execute(sql); - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapper.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapper.java deleted file mode 100644 index 32d1875e4d1a82f7dfb658d68ed0e63a5cbfa040..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.taosdata.taosdemo.dao; - -import com.taosdata.taosdemo.domain.TableMeta; -import com.taosdata.taosdemo.domain.TableValue; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface TableMapper { - - // 创建:普通表 - void create(TableMeta tableMeta); - - // 插入:一张表多个value - int insertOneTableMultiValues(TableValue values); - - // 插入: 一张表多个value,指定的列 - int insertOneTableMultiValuesWithColumns(TableValue values); - - // 插入:多个表多个value - int insertMultiTableMultiValues(List tables); - - // 插入:多个表多个value, 指定的列 - int insertMultiTableMultiValuesWithColumns(List tables); - -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java deleted file mode 100644 index 16bc094848f6ff585e826bf3181cc4e8c03ee822..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/dao/TableMapperImpl.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.taosdata.taosdemo.dao; - -import com.taosdata.taosdemo.domain.TableMeta; -import com.taosdata.taosdemo.domain.TableValue; -import com.taosdata.taosdemo.utils.SqlSpeller; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; -import org.springframework.jdbc.core.JdbcTemplate; - -import java.util.List; - -public class TableMapperImpl implements TableMapper { - private static final Logger logger = LogManager.getLogger(TableMapperImpl.class); - private JdbcTemplate template; - - @Override - public void create(TableMeta tableMeta) { - String sql = SqlSpeller.createTable(tableMeta); - logger.debug("SQL >>> " + sql); - template.execute(sql); - } - - @Override - public int insertOneTableMultiValues(TableValue values) { - String sql = SqlSpeller.insertOneTableMultiValues(values); - logger.debug("SQL >>> " + sql); - return template.update(sql); - } - - @Override - public int insertOneTableMultiValuesWithColumns(TableValue values) { - String sql = SqlSpeller.insertOneTableMultiValuesWithColumns(values); - logger.debug("SQL >>> " + sql); - return template.update(sql); - } - - @Override - public int insertMultiTableMultiValues(List tables) { - String sql = SqlSpeller.insertMultiTableMultiValues(tables); - logger.debug("SQL >>> " + sql); - return template.update(sql); - } - - @Override - public int insertMultiTableMultiValuesWithColumns(List tables) { - String sql = SqlSpeller.insertMultiTableMultiValuesWithColumns(tables); - logger.debug("SQL >>> " + sql); - return template.update(sql); - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldMeta.java deleted file mode 100644 index 8a45e99989821562fdf9333b90a2972388cf6003..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldMeta.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -@Data -public class FieldMeta { - private String name; - private String type; - - public FieldMeta() { - } - - public FieldMeta(String name, String type) { - this.name = name; - this.type = type; - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldValue.java deleted file mode 100644 index 44805c0d7c2f4e0df60d723afd598f2aa788ee65..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/FieldValue.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -@Data -public class FieldValue { - private String name; - private T value; - - public FieldValue() { - } - - public FieldValue(String name, T value) { - this.name = name; - this.value = value; - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/RowValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/RowValue.java deleted file mode 100644 index a444fa78dcdeb8f1bb76974a29051c98348a055b..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/RowValue.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -import java.util.List; - -@Data -public class RowValue { - private List fields; - - public RowValue(List fields) { - this.fields = fields; - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableMeta.java deleted file mode 100644 index 81de882448121532a3c840296702d1fb24c37326..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableMeta.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -import java.util.List; - -@Data -public class SubTableMeta { - - private String database; - private String supertable; - private String name; - private List tags; - private List fields; -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableValue.java deleted file mode 100644 index 74fb9598bc8e920123180f948b88fb98baf9218e..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SubTableValue.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -import java.util.List; - -@Data -public class SubTableValue { - - private String database; - private String supertable; - private String name; - private List tags; - private List values; -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SuperTableMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SuperTableMeta.java deleted file mode 100644 index c5c65a4599b776faeead19ffbf065361b293b44b..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/SuperTableMeta.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -import java.util.List; - -@Data -public class SuperTableMeta { - - private String database; - private String name; - private List fields; - private List tags; -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableMeta.java deleted file mode 100644 index 3ab0a75c0b8ddda46f016c93e0a4893ff1ef21fa..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableMeta.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -import java.util.List; - -@Data -public class TableMeta { - - private String database; - private String name; - private List fields; -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableValue.java deleted file mode 100644 index d5502aa46f3508d2f6dcc3668e741adde5b0a4f0..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TableValue.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -import java.util.List; - -@Data -public class TableValue { - - private String database; - private String name; - private List columns; - private List values; - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagMeta.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagMeta.java deleted file mode 100644 index a385bb4e125e46fe37c1f9542817a4d81301d72f..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagMeta.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -@Data -public class TagMeta { - private String name; - private String type; - - public TagMeta() { - - } - - public TagMeta(String name, String type) { - this.name = name; - this.type = type; - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagValue.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagValue.java deleted file mode 100644 index 98ea8c0dc97ebfd330c57f8852eaf2fa379aef50..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/domain/TagValue.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.taosdata.taosdemo.domain; - -import lombok.Data; - -@Data -public class TagValue { - private String name; - private T value; - - public TagValue() { - } - - public TagValue(String name, T value) { - this.name = name; - this.value = value; - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/AbstractService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/AbstractService.java deleted file mode 100644 index 4afbe9dae82516e050eb7d729d6ecb8eb1e59d6b..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/AbstractService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.taosdata.taosdemo.service; - -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -public class AbstractService { - - protected int getAffectRows(List> futureList) { - int count = 0; - for (Future future : futureList) { - try { - count += future.get(); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } - } - return count; - } - - protected int getAffectRows(Future future) { - int count = 0; - try { - count += future.get(); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } - return count; - } - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/DatabaseService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/DatabaseService.java deleted file mode 100644 index 3c8e9624066bf629a74ebcaa3959a2e15338c363..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/DatabaseService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.taosdemo.dao.DatabaseMapper; -import com.taosdata.taosdemo.dao.DatabaseMapperImpl; - -import javax.sql.DataSource; -import java.util.Map; - -public class DatabaseService { - - private final DatabaseMapper databaseMapper; - - public DatabaseService(DataSource dataSource) { - this.databaseMapper = new DatabaseMapperImpl(dataSource); - } - - // 建库,指定 name - public void createDatabase(String database) { - databaseMapper.createDatabase(database); - } - - // 建库,指定参数 keep,days,replica等 - public void createDatabase(Map map) { - if (map.isEmpty()) - return; - if (map.containsKey("database") && map.size() == 1) { - createDatabase(map.get("database")); - return; - } - databaseMapper.createDatabaseWithParameters(map); - } - - // drop database - public void dropDatabase(String dbname) { - databaseMapper.dropDatabase(dbname); - } - - // use database - public void useDatabase(String dbname) { - databaseMapper.useDatabase(dbname); - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/QueryService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/QueryService.java deleted file mode 100644 index efabff6afe904516ad9682cd7197412dc02765ef..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/QueryService.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.jdbc.utils.SqlSyntaxValidator; - -import javax.sql.DataSource; -import java.sql.*; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -public class QueryService { - - private final DataSource dataSource; - - public QueryService(DataSource dataSource) { - this.dataSource = dataSource; - } - - /* only select or show SQL Statement is valid for executeQuery */ - public Boolean[] areValidQueries(String[] sqls) { - Boolean[] ret = new Boolean[sqls.length]; - for (int i = 0; i < sqls.length; i++) { - ret[i] = true; - if (!SqlSyntaxValidator.isValidForExecuteQuery(sqls[i])) { - ret[i] = false; - continue; - } - try (Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement()) { - stmt.executeQuery(sqls[i]); - } catch (SQLException e) { - ret[i] = false; - continue; - } - } - return ret; - } - - public String[] generateSuperTableQueries(String dbName) { - List sqls = new ArrayList<>(); - try (Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement()) { - stmt.execute("use " + dbName); - ResultSet rs = stmt.executeQuery("show stables"); - while (rs.next()) { - String name = rs.getString("name"); - sqls.add("select count(*) from " + dbName + "." + name); - sqls.add("select first(*) from " + dbName + "." + name); - sqls.add("select last(*) from " + dbName + "." + name); - sqls.add("select last_row(*) from " + dbName + "." + name); - } - } catch (SQLException e) { - e.printStackTrace(); - } - String[] sqlArr = new String[sqls.size()]; - return sqls.toArray(sqlArr); - } - - public void querySuperTable(String[] sqls, int interval, int threadCount, long queryTimes) { - List threads = IntStream.range(0, threadCount).mapToObj(i -> new Thread(() -> { - // do query - try (Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement()) { - long count = queryTimes; - if (count == 0) - count = Long.MAX_VALUE; - while (count > 0) { - for (String sql : sqls) { - long start = System.currentTimeMillis(); - ResultSet rs = stmt.executeQuery(sql); - printResultSet(rs); - long end = System.currentTimeMillis(); - long timecost = end - start; - if (interval - timecost > 0) { - TimeUnit.MILLISECONDS.sleep(interval - timecost); - } - } - count--; - } - - } catch (SQLException | InterruptedException e) { - e.printStackTrace(); - } - - })).collect(Collectors.toList()); - threads.stream().forEach(Thread::start); - for (Thread thread : threads) { - try { - thread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - - private void printResultSet(ResultSet rs) throws SQLException { - ResultSetMetaData meta = rs.getMetaData(); - while (rs.next()) { - for (int i = 1; i <= meta.getColumnCount(); i++) { - System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); - } - System.out.println(); - } - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SqlExecuteTask.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SqlExecuteTask.java deleted file mode 100644 index ff2e4d0af068a10e62933837817d2d2df0712a4c..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SqlExecuteTask.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.taosdemo.utils.Printer; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -public class SqlExecuteTask implements Runnable { - private final DataSource dataSource; - private final String sql; - - public SqlExecuteTask(DataSource dataSource, String sql) { - this.dataSource = dataSource; - this.sql = sql; - } - - @Override - public void run() { - try (Connection conn = dataSource.getConnection(); Statement stmt = conn.createStatement()) { - long start = System.currentTimeMillis(); - boolean execute = stmt.execute(sql); - long end = System.currentTimeMillis(); - if (execute) { - ResultSet rs = stmt.getResultSet(); - Printer.printResult(rs); - } else { - Printer.printSql(sql, true, (end - start)); - } - } catch (SQLException e) { - e.printStackTrace(); - } - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java deleted file mode 100644 index b0a79dea78f429d85804bae4cb0bbec9e712ec1a..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SubTableService.java +++ /dev/null @@ -1,209 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.taosdemo.components.JdbcTaosdemoConfig; -import com.taosdata.taosdemo.dao.SubTableMapper; -import com.taosdata.taosdemo.dao.SubTableMapperImpl; -import com.taosdata.taosdemo.domain.SubTableMeta; -import com.taosdata.taosdemo.domain.SubTableValue; -import com.taosdata.taosdemo.domain.SuperTableMeta; -import com.taosdata.taosdemo.service.data.SubTableMetaGenerator; -import com.taosdata.taosdemo.service.data.SubTableValueGenerator; -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.LogManager; - -import javax.sql.DataSource; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.*; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -public class SubTableService extends AbstractService { - - private SubTableMapper mapper; - private static final Logger logger = LogManager.getLogger(SubTableService.class); - - public SubTableService(DataSource datasource) { - this.mapper = new SubTableMapperImpl(datasource); - } - - public void createSubTable(SuperTableMeta superTableMeta, long numOfTables, String prefixOfTable, int numOfThreadsForCreate) { - ExecutorService executor = Executors.newFixedThreadPool(numOfThreadsForCreate); - for (long i = 0; i < numOfTables; i++) { - long tableIndex = i; - executor.execute(() -> createSubTable(superTableMeta, prefixOfTable + (tableIndex + 1))); - } - executor.shutdown(); - try { - executor.awaitTermination(Long.MAX_VALUE,TimeUnit.NANOSECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - public void createSubTable(SuperTableMeta superTableMeta, String tableName) { - // 构造数据 - SubTableMeta meta = SubTableMetaGenerator.generate(superTableMeta, tableName); - createSubTable(meta); - } - - // 创建一张子表,可以指定database,supertable,tablename,tag值 - public void createSubTable(SubTableMeta subTableMeta) { - mapper.createUsingSuperTable(subTableMeta); - } - - /*************************************************************************************************************************/ - // 插入:多线程,多表 - public int insert(List subTableValues, int threadSize, int frequency) { - ExecutorService executor = Executors.newFixedThreadPool(threadSize); - Future future = executor.submit(() -> insert(subTableValues)); - executor.shutdown(); - //TODO:frequency - return getAffectRows(future); - } - - // 插入:单表,insert into xxx values(),()... - public int insert(SubTableValue subTableValue) { - return mapper.insertOneTableMultiValues(subTableValue); - } - - // 插入: 多表,insert into xxx values(),()... xxx values(),()... - public int insert(List subTableValues) { - return mapper.insertMultiTableMultiValues(subTableValues); - } - - // 插入:单表,自动建表, insert into xxx using xxx tags(...) values(),()... - public int insertAutoCreateTable(SubTableValue subTableValue) { - return mapper.insertOneTableMultiValuesUsingSuperTable(subTableValue); - } - - // 插入:多表,自动建表, insert into xxx using XXX tags(...) values(),()... xxx using XXX tags(...) values(),()... - public int insertAutoCreateTable(List subTableValues) { - return mapper.insertMultiTableMultiValuesUsingSuperTable(subTableValues); - } - - public int insertMultiThreads(SuperTableMeta superTableMeta, int threadSize, long tableSize, long startTime, long gap, JdbcTaosdemoConfig config) { - List taskList = new ArrayList<>(); - List threads = IntStream.range(0, threadSize) - .mapToObj(i -> { - long startInd = i * gap; - long endInd = (i + 1) * gap < tableSize ? (i + 1) * gap : tableSize; - FutureTask task = new FutureTask<>( - new InsertTask(superTableMeta, - startInd, endInd, - startTime, config.timeGap, - config.numOfRowsPerTable, config.numOfTablesPerSQL, config.numOfValuesPerSQL, - config.order, config.rate, config.range, - config.prefixOfTable, config.autoCreateTable) - ); - taskList.add(task); - return new Thread(task, "InsertThread-" + i); - }).collect(Collectors.toList()); - - threads.stream().forEach(Thread::start); - for (Thread thread : threads) { - try { - thread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - int affectedRows = 0; - for (FutureTask task : taskList) { - try { - affectedRows += task.get(); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } - } - - return affectedRows; - } - - private class InsertTask implements Callable { - - private final long startTableInd; // included - private final long endTableInd; // excluded - private final long startTime; - private final long timeGap; - private final long numOfRowsPerTable; - private long numOfTablesPerSQL; - private long numOfValuesPerSQL; - private final SuperTableMeta superTableMeta; - private final int order; - private final int rate; - private final long range; - private final String prefixOfTable; - private final boolean autoCreateTable; - - public InsertTask(SuperTableMeta superTableMeta, long startTableInd, long endTableInd, - long startTime, long timeGap, - long numOfRowsPerTable, long numOfTablesPerSQL, long numOfValuesPerSQL, - int order, int rate, long range, - String prefixOfTable, boolean autoCreateTable) { - this.superTableMeta = superTableMeta; - this.startTableInd = startTableInd; - this.endTableInd = endTableInd; - this.startTime = startTime; - this.timeGap = timeGap; - this.numOfRowsPerTable = numOfRowsPerTable; - this.numOfTablesPerSQL = numOfTablesPerSQL; - this.numOfValuesPerSQL = numOfValuesPerSQL; - this.order = order; - this.rate = rate; - this.range = range; - this.prefixOfTable = prefixOfTable; - this.autoCreateTable = autoCreateTable; - } - - - @Override - public Integer call() { - - long numOfTables = endTableInd - startTableInd; - if (numOfRowsPerTable < numOfValuesPerSQL) - numOfValuesPerSQL = (int) numOfRowsPerTable; - if (numOfTables < numOfTablesPerSQL) - numOfTablesPerSQL = (int) numOfTables; - - int affectRows = 0; - // row - for (long rowCnt = 0; rowCnt < numOfRowsPerTable; ) { - long rowSize = numOfValuesPerSQL; - if (rowCnt + rowSize > numOfRowsPerTable) { - rowSize = numOfRowsPerTable - rowCnt; - } - //table - for (long tableCnt = startTableInd; tableCnt < endTableInd; ) { - long tableSize = numOfTablesPerSQL; - if (tableCnt + tableSize > endTableInd) { - tableSize = endTableInd - tableCnt; - } - long startTime = this.startTime + rowCnt * timeGap; -// System.out.println(Thread.currentThread().getName() + " >>> " + "rowCnt: " + rowCnt + ", rowSize: " + rowSize + ", " + "tableCnt: " + tableCnt + ",tableSize: " + tableSize + ", " + "startTime: " + startTime + ",timeGap: " + timeGap + ""); - /***********************************************/ - // 生成数据 - List data = SubTableValueGenerator.generate(superTableMeta, prefixOfTable, tableCnt, tableSize, rowSize, startTime, timeGap); - // 乱序 - if (order != 0) - SubTableValueGenerator.disrupt(data, rate, range); - // insert - if (autoCreateTable) - affectRows += insertAutoCreateTable(data); - else - affectRows += insert(data); - /***********************************************/ - tableCnt += tableSize; - } - rowCnt += rowSize; - } - - return affectRows; - } - } - - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SuperTableService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SuperTableService.java deleted file mode 100644 index b91348e2d008bc1ac32faffc5912a8509adf42bd..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/SuperTableService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.taosdemo.dao.SuperTableMapper; -import com.taosdata.taosdemo.dao.SuperTableMapperImpl; -import com.taosdata.taosdemo.domain.SuperTableMeta; - -import javax.sql.DataSource; - -public class SuperTableService { - - private SuperTableMapper superTableMapper; - - public SuperTableService(DataSource dataSource) { - this.superTableMapper = new SuperTableMapperImpl(dataSource); - } - - // 创建超级表,指定每个field的名称和类型,每个tag的名称和类型 - public void create(SuperTableMeta superTableMeta) { - superTableMapper.createSuperTable(superTableMeta); - } - - public void drop(String database, String name) { - superTableMapper.dropSuperTable(database, name); - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/TableService.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/TableService.java deleted file mode 100644 index 2504fdb0b4cd48ec263d94ec377e1bb8902ea9a7..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/TableService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.taosdemo.dao.TableMapper; -import com.taosdata.taosdemo.domain.TableMeta; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -public class TableService extends AbstractService { - - private TableMapper tableMapper; - - //创建一张表 - public void create(TableMeta tableMeta) { - tableMapper.create(tableMeta); - } - - //创建多张表 - public void create(List tables) { - tables.stream().forEach(this::create); - } - - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/FieldValueGenerator.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/FieldValueGenerator.java deleted file mode 100644 index 73cd981a4651bf589d636b8f57c0af44979f09f1..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/FieldValueGenerator.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.FieldMeta; -import com.taosdata.taosdemo.domain.FieldValue; -import com.taosdata.taosdemo.domain.RowValue; -import com.taosdata.taosdemo.utils.DataGenerator; - -import java.util.*; - -public class FieldValueGenerator { - - public static Random random = new Random(System.currentTimeMillis()); - - // 生成start到end的时间序列,时间戳为顺序,不含有乱序,field的value为随机生成 - public static List generate(long start, long end, long timeGap, List fieldMetaList) { - List values = new ArrayList<>(); - - for (long ts = start; ts < end; ts += timeGap) { - List fieldValues = new ArrayList<>(); - // timestamp - fieldValues.add(new FieldValue(fieldMetaList.get(0).getName(), ts)); - // other values - for (int fieldInd = 1; fieldInd < fieldMetaList.size(); fieldInd++) { - FieldMeta fieldMeta = fieldMetaList.get(fieldInd); - fieldValues.add(new FieldValue(fieldMeta.getName(), DataGenerator.randomValue(fieldMeta.getType()))); - } - values.add(new RowValue(fieldValues)); - } - return values; - } - - // 生成start到end的时间序列,时间戳为顺序,含有乱序,rate为乱序的比例,range为乱序前跳范围,field的value为随机生成 - public static List disrupt(List values, int rate, long range) { - long timeGap = (long) (values.get(1).getFields().get(0).getValue()) - (long) (values.get(0).getFields().get(0).getValue()); - int bugSize = values.size() * rate / 100; - Set bugIndSet = new HashSet<>(); - while (bugIndSet.size() < bugSize) { - bugIndSet.add(random.nextInt(values.size())); - } - for (Integer bugInd : bugIndSet) { - Long timestamp = (Long) values.get(bugInd).getFields().get(0).getValue(); - Long newTimestamp = timestamp - timeGap - random.nextInt((int) range); - values.get(bugInd).getFields().get(0).setValue(newTimestamp); - } - - return values; - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SubTableMetaGenerator.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SubTableMetaGenerator.java deleted file mode 100644 index 88e3c0d26a5a7558c1c07f0fc38ae21710438dbe..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SubTableMetaGenerator.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.SubTableMeta; -import com.taosdata.taosdemo.domain.SuperTableMeta; -import com.taosdata.taosdemo.domain.TagValue; - -import java.util.ArrayList; -import java.util.List; - -public class SubTableMetaGenerator { - - // 创建tableSize张子表,使用tablePrefix作为子表名的前缀,使用superTableMeta的元数据 - // create table xxx using XXX tags(XXX) - public static List generate(SuperTableMeta superTableMeta, int tableSize, String tablePrefix) { - List subTableMetaList = new ArrayList<>(); - for (int i = 1; i <= tableSize; i++) { - SubTableMeta subTableMeta = new SubTableMeta(); - // create table xxx.xxx using xxx tags(...) - subTableMeta.setDatabase(superTableMeta.getDatabase()); - subTableMeta.setName(tablePrefix + i); - subTableMeta.setSupertable(superTableMeta.getName()); - subTableMeta.setFields(superTableMeta.getFields()); - List tagValues = TagValueGenerator.generate(superTableMeta.getTags()); - subTableMeta.setTags(tagValues); - subTableMetaList.add(subTableMeta); - } - return subTableMetaList; - } - - public static SubTableMeta generate(SuperTableMeta superTableMeta, String tableName) { - SubTableMeta subTableMeta = new SubTableMeta(); - // create table xxx.xxx using xxx tags(...) - subTableMeta.setDatabase(superTableMeta.getDatabase()); - subTableMeta.setName(tableName); - subTableMeta.setSupertable(superTableMeta.getName()); - subTableMeta.setFields(superTableMeta.getFields()); - List tagValues = TagValueGenerator.generate(superTableMeta.getTags()); - subTableMeta.setTags(tagValues); - return subTableMeta; - } - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SubTableValueGenerator.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SubTableValueGenerator.java deleted file mode 100644 index 8c318dbd3abf2ddfec8b51e83f32246421c49d51..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SubTableValueGenerator.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.*; -import com.taosdata.taosdemo.utils.TimeStampUtil; -import org.springframework.beans.BeanUtils; - -import java.util.ArrayList; -import java.util.List; - -public class SubTableValueGenerator { - - public static List generate(SuperTableMeta superTableMeta, String prefixOfTables, long tableIndex, long tableSize, long valueSize, long startTime, long timeGap) { - List subTableValues = new ArrayList<>(); - for (int i = 1; i <= tableSize; i++) { - SubTableValue subTableValue = new SubTableValue(); - subTableValue.setDatabase(superTableMeta.getDatabase()); - subTableValue.setName(prefixOfTables + (tableIndex + i)); - subTableValue.setSupertable(superTableMeta.getName()); - TimeStampUtil.TimeTuple tuple = TimeStampUtil.range(startTime, timeGap, valueSize); - List tags = TagValueGenerator.generate(superTableMeta.getTags()); - subTableValue.setTags(tags); - List values = FieldValueGenerator.generate(tuple.start, tuple.end, tuple.timeGap, superTableMeta.getFields()); - subTableValue.setValues(values); - - subTableValues.add(subTableValue); - } - return subTableValues; - } - - public static List generate(List subTableMetaList, int numOfRowsPerTable, long start, long timeGap) { - return generate(subTableMetaList, 0, subTableMetaList.size(), numOfRowsPerTable, start, timeGap); - } - - public static void disrupt(List subTableValueList, int rate, long range) { - subTableValueList.stream().forEach((tableValue) -> { - List values = tableValue.getValues(); - FieldValueGenerator.disrupt(values, rate, range); - }); - } - - public static List> split(List subTableValueList, int numOfTables, int numOfTablesPerSQL, int numOfRowsPerTable, int numOfValuesPerSQL) { - List> dataList = new ArrayList<>(); - if (numOfRowsPerTable < numOfValuesPerSQL) - numOfValuesPerSQL = numOfRowsPerTable; - if (numOfTables < numOfTablesPerSQL) - numOfTablesPerSQL = numOfTables; - //table - for (int tableCnt = 0; tableCnt < numOfTables; ) { - int tableSize = numOfTablesPerSQL; - if (tableCnt + tableSize > numOfTables) { - tableSize = numOfTables - tableCnt; - } - // row - for (int rowCnt = 0; rowCnt < numOfRowsPerTable; ) { - int rowSize = numOfValuesPerSQL; - if (rowCnt + rowSize > numOfRowsPerTable) { - rowSize = numOfRowsPerTable - rowCnt; - } - // System.out.println("rowCnt: " + rowCnt + ", rowSize: " + rowSize + ", tableCnt: " + tableCnt + ", tableSize: " + tableSize); - // split - List blocks = subTableValueList.subList(tableCnt, tableCnt + tableSize); - List newBlocks = new ArrayList<>(); - for (int i = 0; i < blocks.size(); i++) { - SubTableValue subTableValue = blocks.get(i); - SubTableValue newSubTableValue = new SubTableValue(); - BeanUtils.copyProperties(subTableValue, newSubTableValue); - List values = subTableValue.getValues().subList(rowCnt, rowCnt + rowSize); - newSubTableValue.setValues(values); - newBlocks.add(newSubTableValue); - } - dataList.add(newBlocks); - - rowCnt += rowSize; - } - tableCnt += tableSize; - } - return dataList; - } - - public static void main(String[] args) { - split(null, 99, 10, 99, 10); - } - - public static List generate(List subTableMetaList, int tableCnt, int tableSize, int rowSize, long startTime, long timeGap) { - List subTableValueList = new ArrayList<>(); - for (int i = 0; i < tableSize; i++) { - SubTableMeta subTableMeta = subTableMetaList.get(tableCnt + i); - SubTableValue subTableValue = new SubTableValue(); - subTableValue.setDatabase(subTableMeta.getDatabase()); - subTableValue.setName(subTableMeta.getName()); - subTableValue.setSupertable(subTableMeta.getSupertable()); - subTableValue.setTags(subTableMeta.getTags()); - TimeStampUtil.TimeTuple tuple = TimeStampUtil.range(startTime, timeGap, rowSize); - List values = FieldValueGenerator.generate(tuple.start, tuple.end, tuple.timeGap, subTableMeta.getFields()); - subTableValue.setValues(values); - subTableValueList.add(subTableValue); - } - return subTableValueList; - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SuperTableMetaGenerator.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SuperTableMetaGenerator.java deleted file mode 100644 index 05aefd01ac8ef5c0bd2d4952e16f557ee7aef8ce..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/SuperTableMetaGenerator.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.FieldMeta; -import com.taosdata.taosdemo.domain.SuperTableMeta; -import com.taosdata.taosdemo.domain.TagMeta; -import com.taosdata.taosdemo.utils.TaosConstants; - -import java.util.ArrayList; -import java.util.List; - -public class SuperTableMetaGenerator { - - // 创建超级表,使用指定SQL语句 - public static SuperTableMeta generate(String superTableSQL) { - SuperTableMeta tableMeta = new SuperTableMeta(); - // for example : create table superTable (ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int) - superTableSQL = superTableSQL.trim().toLowerCase(); - if (!superTableSQL.startsWith("create")) - throw new RuntimeException("invalid create super table SQL"); - - if (superTableSQL.contains("tags")) { - String tagSQL = superTableSQL.substring(superTableSQL.indexOf("tags") + 4).trim(); - tagSQL = tagSQL.substring(tagSQL.indexOf("(") + 1, tagSQL.lastIndexOf(")")); - String[] tagPairs = tagSQL.split(","); - List tagMetaList = new ArrayList<>(); - for (String tagPair : tagPairs) { - String name = tagPair.trim().split("\\s+")[0]; - String type = tagPair.trim().split("\\s+")[1]; - tagMetaList.add(new TagMeta(name, type)); - } - tableMeta.setTags(tagMetaList); - superTableSQL = superTableSQL.substring(0, superTableSQL.indexOf("tags")); - } - if (superTableSQL.contains("(")) { - String fieldSQL = superTableSQL.substring(superTableSQL.indexOf("(") + 1, superTableSQL.indexOf(")")); - String[] fieldPairs = fieldSQL.split(","); - List fieldList = new ArrayList<>(); - for (String fieldPair : fieldPairs) { - String name = fieldPair.trim().split("\\s+")[0]; - String type = fieldPair.trim().split("\\s+")[1]; - fieldList.add(new FieldMeta(name, type)); - } - tableMeta.setFields(fieldList); - superTableSQL = superTableSQL.substring(0, superTableSQL.indexOf("(")); - } - superTableSQL = superTableSQL.substring(superTableSQL.indexOf("table") + 5).trim(); - if (superTableSQL.contains(".")) { - String database = superTableSQL.split("\\.")[0]; - tableMeta.setDatabase(database); - superTableSQL = superTableSQL.substring(superTableSQL.indexOf(".") + 1); - } - tableMeta.setName(superTableSQL.trim()); - - return tableMeta; - } - - // 创建超级表,指定field和tag的个数 - public static SuperTableMeta generate(String database, String name, int fieldSize, String fieldPrefix, int tagSize, String tagPrefix) { - if (fieldSize < 2 || tagSize < 1) { - throw new RuntimeException("create super table but fieldSize less than 2 or tagSize less than 1"); - } - SuperTableMeta tableMetadata = new SuperTableMeta(); - tableMetadata.setDatabase(database); - tableMetadata.setName(name); - // fields - List fields = new ArrayList<>(); - fields.add(new FieldMeta("ts", "timestamp")); - for (int i = 1; i <= fieldSize; i++) { - fields.add(new FieldMeta(fieldPrefix + "" + i, TaosConstants.DATA_TYPES[i % TaosConstants.DATA_TYPES.length])); - } - tableMetadata.setFields(fields); - // tags - List tags = new ArrayList<>(); - for (int i = 1; i <= tagSize; i++) { - tags.add(new TagMeta(tagPrefix + "" + i, TaosConstants.DATA_TYPES[i % TaosConstants.DATA_TYPES.length])); - } - tableMetadata.setTags(tags); - return tableMetadata; - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/TagValueGenerator.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/TagValueGenerator.java deleted file mode 100644 index b8024fea45c000d7d0944f0ba2d47449d3907d89..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/service/data/TagValueGenerator.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.TagMeta; -import com.taosdata.taosdemo.domain.TagValue; -import com.taosdata.taosdemo.utils.DataGenerator; - -import java.util.ArrayList; -import java.util.List; - -public class TagValueGenerator { - - // 创建标签值:使用tagMetas - public static List generate(List tagMetas) { - List tagValues = new ArrayList<>(); - for (int i = 0; i < tagMetas.size(); i++) { - TagMeta tagMeta = tagMetas.get(i); - TagValue tagValue = new TagValue(); - tagValue.setName(tagMeta.getName()); - tagValue.setValue(DataGenerator.randomValue(tagMeta.getType())); - tagValues.add(tagValue); - } - return tagValues; - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/DataGenerator.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/DataGenerator.java deleted file mode 100644 index a200d17ef6c4c4987160c9966a50737773153bc9..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/DataGenerator.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.taosdata.taosdemo.utils; - -import java.util.Random; - -public class DataGenerator { - private static Random random = new Random(System.currentTimeMillis()); - private static final String alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - - // "timestamp", "int", "bigint", "float", "double", "binary(64)", "smallint", "tinyint", "bool", "nchar(64)", - - public static Object randomValue(String type) { - int length = 64; - if (type.contains("(")) { - length = Integer.parseInt(type.substring(type.indexOf("(") + 1, type.indexOf(")"))); - type = type.substring(0, type.indexOf("(")); - } - switch (type.trim().toLowerCase()) { - case "timestamp": - return randomTimestamp(); - case "int": - return randomInt(); - case "bigint": - return randomBigint(); - case "float": - return randomFloat(); - case "double": - return randomDouble(); - case "binary": - return randomBinary(length); - case "smallint": - return randomSmallint(); - case "tinyint": - return randomTinyint(); - case "bool": - return randomBoolean(); - case "nchar": - return randomNchar(length); - default: - throw new IllegalArgumentException("Unexpected value: " + type); - } - } - - public static Long randomTimestamp() { - long start = System.currentTimeMillis(); - return randomTimestamp(start, start + 60l * 60l * 1000l); - } - - public static Long randomTimestamp(Long start, Long end) { - return start + (long) random.nextInt((int) (end - start)); - } - - public static String randomNchar(int length) { - return randomChinese(length); - } - - public static Boolean randomBoolean() { - return random.nextBoolean(); - } - - public static Integer randomTinyint() { - return randomInt(-127, 127); - } - - public static Integer randomSmallint() { - return randomInt(-32767, 32767); - } - - public static String randomBinary(int length) { - return randomString(length); - } - - public static String randomString(int length) { - String zh_en = ""; - for (int i = 0; i < length; i++) { - zh_en += alphabet.charAt(random.nextInt(alphabet.length())); - } - return zh_en; - } - - public static String randomChinese(int length) { - String zh_cn = ""; - int bottom = Integer.parseInt("4e00", 16); - int top = Integer.parseInt("9fa5", 16); - - for (int i = 0; i < length; i++) { - char c = (char) (random.nextInt(top - bottom + 1) + bottom); - zh_cn += new String(new char[]{c}); - } - return zh_cn; - } - - public static Double randomDouble() { - return randomDouble(0, 100); - } - - public static Double randomDouble(double bottom, double top) { - return bottom + (top - bottom) * random.nextDouble(); - } - - public static Float randomFloat() { - return randomFloat(0, 100); - } - - public static Float randomFloat(float bottom, float top) { - return bottom + (top - bottom) * random.nextFloat(); - } - - public static Long randomBigint() { - return random.nextLong(); - } - - public static Integer randomInt(int bottom, int top) { - return bottom + random.nextInt((top - bottom)); - } - - public static Integer randomInt() { - return randomInt(0, 100); - } - -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/Printer.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/Printer.java deleted file mode 100644 index a4627463ec5cd1bbccdb64b67506ba38f712de8f..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/Printer.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.taosdata.taosdemo.utils; - -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; - -public class Printer { - - public static void printResult(ResultSet resultSet) throws SQLException { - ResultSetMetaData metaData = resultSet.getMetaData(); - while (resultSet.next()) { - for (int i = 1; i <= metaData.getColumnCount(); i++) { - String columnLabel = metaData.getColumnLabel(i); - String value = resultSet.getString(i); - System.out.printf("%s: %s\t", columnLabel, value); - } - System.out.println(); - } - } - - public static void printSql(String sql, boolean succeed, long cost) { - System.out.println("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql); - } - - private Printer() { - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/SqlSpeller.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/SqlSpeller.java deleted file mode 100644 index a60f0641d3a4441195c3a60639fbe3a197115dc3..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/SqlSpeller.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.taosdata.taosdemo.utils; - -import com.taosdata.taosdemo.domain.*; - -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -public class SqlSpeller { - - // create database if not exists xxx keep xx days xx replica xx cache xx... - public static String createDatabase(Map map) { - StringBuilder sb = new StringBuilder(); - sb.append("create database if not exists ").append(map.get("database")).append(" "); - if (map.containsKey("keep")) - sb.append("keep ").append(map.get("keep")).append(" "); - if (map.containsKey("days")) - sb.append("days ").append(map.get("days")).append(" "); - if (map.containsKey("replica")) - sb.append("replica ").append(map.get("replica")).append(" "); - if (map.containsKey("cache")) - sb.append("cache ").append(map.get("cache")).append(" "); - if (map.containsKey("blocks")) - sb.append("blocks ").append(map.get("blocks")).append(" "); - if (map.containsKey("minrows")) - sb.append("minrows ").append(map.get("minrows")).append(" "); - if (map.containsKey("maxrows")) - sb.append("maxrows ").append(map.get("maxrows")).append(" "); - if (map.containsKey("precision")) - sb.append("precision ").append(map.get("precision")).append(" "); - if (map.containsKey("comp")) - sb.append("comp ").append(map.get("comp")).append(" "); - if (map.containsKey("walLevel")) - sb.append("walLevel ").append(map.get("walLevel")).append(" "); - if (map.containsKey("quorum")) - sb.append("quorum ").append(map.get("quorum")).append(" "); - if (map.containsKey("fsync")) - sb.append("fsync ").append(map.get("fsync")).append(" "); - if (map.containsKey("update")) - sb.append("update ").append(map.get("update")).append(" "); - return sb.toString(); - } - - // create table if not exists xx.xx using xx.xx tags(x,x,x) - public static String createTableUsingSuperTable(SubTableMeta subTableMeta) { - StringBuilder sb = new StringBuilder(); - sb.append("create table if not exists ").append(subTableMeta.getDatabase()).append(".").append(subTableMeta.getName()).append(" "); - sb.append("using ").append(subTableMeta.getDatabase()).append(".").append(subTableMeta.getSupertable()).append(" "); -// String tagStr = subTableMeta.getTags().stream().filter(Objects::nonNull) -// .map(tagValue -> tagValue.getName() + " '" + tagValue.getValue() + "' ") -// .collect(Collectors.joining(",", "(", ")")); - sb.append("tags ").append(tagValues(subTableMeta.getTags())); - return sb.toString(); - } - - // insert into xx.xxx values(x,x,x),(x,x,x)... - public static String insertOneTableMultiValues(SubTableValue subTableValue) { - StringBuilder sb = new StringBuilder(); - sb.append("insert into ").append(subTableValue.getDatabase()).append(".").append(subTableValue.getName() + " "); - sb.append("values").append(rowValues(subTableValue.getValues())); - return sb.toString(); - } - - //f1, f2, f3 - private static String fieldValues(List fields) { - return IntStream.range(0, fields.size()).mapToObj(i -> { - if (i == 0) { - return "" + fields.get(i).getValue() + ""; - } else { - return "'" + fields.get(i).getValue() + "'"; - } - }).collect(Collectors.joining(",", "(", ")")); - -// return fields.stream() -// .filter(Objects::nonNull) -// .map(fieldValue -> "'" + fieldValue.getValue() + "'") -// .collect(Collectors.joining(",", "(", ")")); - } - - //(f1, f2, f3),(f1, f2, f3) - private static String rowValues(List rowValues) { - return rowValues.stream().filter(Objects::nonNull) - .map(rowValue -> fieldValues(rowValue.getFields())) - .collect(Collectors.joining(",", "", "")); - } - - // insert into xx.xxx using xx.xx tags(x,x,x) values(x,x,x),(x,x,x)... - public static String insertOneTableMultiValuesUsingSuperTable(SubTableValue subTableValue) { - StringBuilder sb = new StringBuilder(); - sb.append("insert into ").append(subTableValue.getDatabase()).append(".").append(subTableValue.getName()).append(" "); - sb.append("using ").append(subTableValue.getDatabase()).append(".").append(subTableValue.getSupertable()).append(" "); - sb.append("tags ").append(tagValues(subTableValue.getTags()) + " "); - sb.append("values ").append(rowValues(subTableValue.getValues())); - return sb.toString(); - } - - // (t1,t2,t3...) - private static String tagValues(List tags) { - return tags.stream().filter(Objects::nonNull) - .map(tagValue -> "'" + tagValue.getValue() + "'") - .collect(Collectors.joining(",", "(", ")")); - } - - // insert into xx.xx values(),(),()... xx.xx values(),()... - public static String insertMultiSubTableMultiValues(List tables) { - return "insert into " + tables.stream().filter(Objects::nonNull) - .map(table -> table.getDatabase() + "." + table.getName() + " values " + rowValues(table.getValues())) - .collect(Collectors.joining(" ", "", "")); - } - - // insert into xx.xx using xx.xx tags(xx,xx) values(),()... - public static String insertMultiTableMultiValuesUsingSuperTable(List tables) { - return "insert into " + tables.stream().filter(Objects::nonNull) - .map(table -> { - StringBuilder sb = new StringBuilder(); - sb.append(table.getDatabase()).append(".").append(table.getName()); - sb.append(" using ").append(table.getDatabase()).append(".").append(table.getSupertable()); - sb.append(" tags ").append(tagValues(table.getTags())); - sb.append(" values ").append(rowValues(table.getValues())); - return sb.toString(); - }).collect(Collectors.joining(" ")); - } - - // create table if not exists xx.xx (f1 xx,f2 xx...) tags(t1 xx, t2 xx...) - public static String createSuperTable(SuperTableMeta tableMetadata) { - StringBuilder sb = new StringBuilder(); - sb.append("create table if not exists ").append(tableMetadata.getDatabase()).append(".").append(tableMetadata.getName()); - String fields = tableMetadata.getFields().stream() - .filter(Objects::nonNull).map(field -> field.getName() + " " + field.getType() + " ") - .collect(Collectors.joining(",", "(", ")")); - sb.append(fields); - sb.append(" tags "); - String tags = tableMetadata.getTags().stream().filter(Objects::nonNull) - .map(tag -> tag.getName() + " " + tag.getType() + " ") - .collect(Collectors.joining(",", "(", ")")); - sb.append(tags); - return sb.toString(); - } - - - public static String createTable(TableMeta tableMeta) { - StringBuilder sb = new StringBuilder(); - sb.append("create table if not exists ").append(tableMeta.getDatabase()).append(".").append(tableMeta.getName()).append(" "); - String fields = tableMeta.getFields().stream() - .filter(Objects::nonNull).map(field -> field.getName() + " " + field.getType() + " ") - .collect(Collectors.joining(",", "(", ")")); - sb.append(fields); - return sb.toString(); - } - - // insert into xx.xx values() - public static String insertOneTableMultiValues(TableValue table) { - StringBuilder sb = new StringBuilder(); - sb.append("insert into ").append(table.getDatabase()).append(".").append(table.getName() + " "); - sb.append("values").append(rowValues(table.getValues())); - return sb.toString(); - - } - - // insert into xx.xx (f1, f2, f3...) values(xx,xx,xx),(xx,xx,xx)... - public static String insertOneTableMultiValuesWithColumns(TableValue table) { - StringBuilder sb = new StringBuilder(); - sb.append("insert into ").append(table.getDatabase()).append(".").append(table.getName()).append(" "); - sb.append(columnNames(table.getColumns())); - sb.append(" values ").append(rowValues(table.getValues())); - return sb.toString(); - } - - // (f1, f2, f3...) - private static String columnNames(List fields) { - return fields.stream() - .filter(Objects::nonNull) - .map(column -> column.getName() + " ") - .collect(Collectors.joining(",", "(", ")")); - } - - public static String insertMultiTableMultiValuesWithColumns(List tables) { - StringBuilder sb = new StringBuilder(); - sb.append("insert into ").append(tables.stream().filter(Objects::nonNull) - .map(table -> table.getDatabase() + "." + table.getName() + " " + columnNames(table.getColumns()) + " values " + rowValues(table.getValues())) - .collect(Collectors.joining(" "))); - return sb.toString(); - } - - public static String insertMultiTableMultiValues(List tables) { - StringBuilder sb = new StringBuilder(); - sb.append("insert into ").append(tables.stream().filter(Objects::nonNull).map(table -> - table.getDatabase() + "." + table.getName() + " values " + rowValues(table.getValues()) - ).collect(Collectors.joining(" "))); - return sb.toString(); - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/TaosConstants.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/TaosConstants.java deleted file mode 100644 index 23c3c5279a15a1dbe529c66398d1378c826ce99a..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/TaosConstants.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.taosdata.taosdemo.utils; - -public class TaosConstants { - public static final String[] DATA_TYPES = { - "timestamp", "int", "bigint", "float", "double", - "binary(64)", "smallint", "tinyint", "bool", "nchar(64)", - }; -} diff --git a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/TimeStampUtil.java b/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/TimeStampUtil.java deleted file mode 100644 index 9cfce16d828510be2c62a9a383e8e3d3badb622e..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/java/com/taosdata/taosdemo/utils/TimeStampUtil.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.taosdata.taosdemo.utils; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -public class TimeStampUtil { - - private static final String datetimeFormat = "yyyy-MM-dd HH:mm:ss.SSS"; - - public static long datetimeToLong(String dateTime) { - SimpleDateFormat sdf = new SimpleDateFormat(datetimeFormat); - try { - return sdf.parse(dateTime).getTime(); - } catch (ParseException e) { - throw new IllegalArgumentException("invalid datetime string >>> " + dateTime); - } - } - - public static String longToDatetime(long time) { - SimpleDateFormat sdf = new SimpleDateFormat(datetimeFormat); - return sdf.format(new Date(time)); - } - - public static class TimeTuple { - public Long start; - public Long end; - public Long timeGap; - - TimeTuple(long start, long end, long timeGap) { - this.start = start; - this.end = end; - this.timeGap = timeGap; - } - } - - public static TimeTuple range(long start, long timeGap, long size) { - long now = System.currentTimeMillis(); - if (timeGap < 1) - timeGap = 1; - if (start == 0) - start = now - size * timeGap; - - // 如果size小于1异常 - if (size < 1) - throw new IllegalArgumentException("size less than 1."); - // 如果timeGap为1,已经超长,需要前移start - if (start + size > now) { - start = now - size; - return new TimeTuple(start, now, 1); - } - long end = start + (long) (timeGap * size); - if (end > now) { - //压缩timeGap - end = now; - double gap = (end - start) / (size * 1.0f); - if (gap < 1.0f) { - timeGap = 1; - start = end - size; - } else { - timeGap = (long) gap; - end = start + (long) (timeGap * size); - } - } - return new TimeTuple(start, end, timeGap); - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/resources/application.properties b/tests/examples/JDBC/taosdemo/src/main/resources/application.properties deleted file mode 100644 index 488185196f1d2325fd9896d30068cbb202180a3f..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/resources/application.properties +++ /dev/null @@ -1,5 +0,0 @@ -jdbc.driver=com.taosdata.jdbc.rs.RestfulDriver -#jdbc.driver=com.taosdata.jdbc.TSDBDriver -hikari.maximum-pool-size=20 -hikari.minimum-idle=20 -hikari.max-lifetime=0 \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/resources/insert.json b/tests/examples/JDBC/taosdemo/src/main/resources/insert.json deleted file mode 100644 index 66b967202fd55cadefb2d10c2e4a7a9ad258d1e6..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/resources/insert.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "filetype": "insert", - "cfgdir": "/etc/taos", - "host": "127.0.0.1", - "port": 6030, - "user": "root", - "password": "taosdata", - "thread_count": 2, - "databases": [ - { - "dbinfo": { - "name": "db04", - "drop": "no", - "replica": 1, - "days": 2, - "cache": 16, - "blocks": 8, - "precision": "ms", - "keep": 36500, - "minRows": 100, - "maxRows": 4096, - "comp": 2, - "walLevel": 1, - "quorum": 1, - "fsync": 3000, - "update": 0 - }, - "super_tables": [ - { - "name": "stb04", - "child_table_exists": "no", - "childtable_count": 10, - "childtable_prefix": "stb01_", - "auto_create_table": "no", - "data_source": "rand", - "insert_mode": "taosc", - "insert_rate": 0, - "insert_rows": 100, - "interlace_rows": 3, - "max_sql_len": 1024, - "disorder_ratio": 0, - "disorder_range": 1000, - "timestamp_step": 10, - "start_timestamp": "2020-10-01 00:00:00.000", - "sample_format": "csv", - "sample_file": "./sample.csv", - "tags_file": "", - "columns": [ - { - "type": "TINYINT" - }, - { - "type": "SMALLINT" - }, - { - "type": "INT" - }, - { - "type": "BIGINT" - }, - { - "type": "BOOL" - }, - { - "type": "FLOAT" - }, - { - "type": "DOUBLE" - }, - { - "type": "TIMESTAMP" - }, - { - "type": "BINARY", - "len": 16 - }, - { - "type": "NCHAR", - "len": 4 - } - ], - "tags": [ - { - "type": "TINYINT" - }, - { - "type": "SMALLINT" - }, - { - "type": "INT" - }, - { - "type": "BIGINT" - }, - { - "type": "BOOL" - }, - { - "type": "FLOAT" - }, - { - "type": "DOUBLE" - }, - { - "type": "BINARY", - "len": 16 - }, - { - "type": "NCHAR", - "len": 4 - } - ] - } - ] - } - ] -} diff --git a/tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties b/tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties deleted file mode 100644 index 352545854d0f68f07e4da6a98504ffa7754b03b1..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/resources/log4j.properties +++ /dev/null @@ -1,21 +0,0 @@ -### 设置### -log4j.rootLogger=info,stdout -### 输出信息到控制抬 ### -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n -### 输出DEBUG 级别以上的日志到=logs/debug.log -log4j.appender.DebugLog=org.apache.log4j.DailyRollingFileAppender -log4j.appender.DebugLog.File=logs/debug.log -log4j.appender.DebugLog.Append=true -log4j.appender.DebugLog.Threshold=DEBUG -log4j.appender.DebugLog.layout=org.apache.log4j.PatternLayout -log4j.appender.DebugLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n -### 输出ERROR 级别以上的日志到=logs/error.log -log4j.appender.ErrorLog=org.apache.log4j.DailyRollingFileAppender -log4j.appender.ErrorLog.File=logs/error.log -log4j.appender.ErrorLog.Append=true -log4j.appender.ErrorLog.Threshold=ERROR -log4j.appender.ErrorLog.layout=org.apache.log4j.PatternLayout -log4j.appender.ErrorLog.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/main/resources/query.json b/tests/examples/JDBC/taosdemo/src/main/resources/query.json deleted file mode 100644 index cc6900d77c3941e6af3274efdfe782c42a557990..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/resources/query.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "filetype":"query", - "cfgdir": "/etc/taos", - "host": "127.0.0.1", - "port": 6030, - "user": "root", - "password": "taosdata", - "databases": "db01", - "super_table_query": - {"rate":1, "concurrent":1,"time":10000, - "sqls": [{"sql": "select count(*) from stb01", "result": "./query_res0.txt"}] - }, - "sub_table_query": - {"stblname": "stb01", "rate":1, "threads":1, - "sqls": [{"sql": "select count(*) from xxxx", "result": "./query_res1.txt"}] - } -} diff --git a/tests/examples/JDBC/taosdemo/src/main/resources/templates/index.html b/tests/examples/JDBC/taosdemo/src/main/resources/templates/index.html deleted file mode 100644 index 953a058032612c7eac8eacc68f738d5fef03ec39..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/main/resources/templates/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Index - - -

Developing~~~

- - \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/DatabaseServiceTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/DatabaseServiceTest.java deleted file mode 100644 index 621ba7df5da4bb29747a5a4af1f91d51f6a1d7d4..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/DatabaseServiceTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.taosdata.taosdemo.service; - -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -public class DatabaseServiceTest { - private DatabaseService service; - - @Test - public void testCreateDatabase1() { - service.createDatabase("testXXXX"); - } - - @Test - public void dropDatabase() { - service.dropDatabase("testXXXX"); - } - - @Test - public void useDatabase() { - service.useDatabase("test"); - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/QueryServiceTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/QueryServiceTest.java deleted file mode 100644 index f2ad25710c1a82136d6316ed69e379bc3925897d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/QueryServiceTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; -import org.junit.BeforeClass; -import org.junit.Test; - -public class QueryServiceTest { - private static QueryService queryService; - - @Test - public void areValidQueries() { - - } - - @Test - public void generateSuperTableQueries() { - String[] sqls = queryService.generateSuperTableQueries("restful_test"); - for (String sql : sqls) { - System.out.println(sql); - } - } - - @Test - public void querySuperTable() { - String[] sqls = queryService.generateSuperTableQueries("restful_test"); - queryService.querySuperTable(sqls, 1000, 10, 10); - } - - @BeforeClass - public static void beforeClass() throws ClassNotFoundException { - Class.forName("com.taosdata.jdbc.TSDBDriver"); - HikariConfig config = new HikariConfig(); - config.setJdbcUrl("jdbc:TAOS://127.0.0.1:6030/?charset=UTF-8&locale=en_US.UTF-8&timezone=UTC-8"); - config.setUsername("root"); - config.setPassword("taosdata"); - HikariDataSource dataSource = new HikariDataSource(config); - queryService = new QueryService(dataSource); - } - -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/SubTableServiceTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/SubTableServiceTest.java deleted file mode 100644 index f7e5cd45057472602ad6e7a43a8d8bdb31a02b40..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/SubTableServiceTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.taosdemo.domain.SubTableMeta; -import com.taosdata.taosdemo.domain.TagValue; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class SubTableServiceTest { - - private SubTableService service; - - private List subTables; - - @Before - public void before() { - subTables = new ArrayList<>(); - for (int i = 1; i <= 1; i++) { - SubTableMeta subTableMeta = new SubTableMeta(); - subTableMeta.setDatabase("test"); - subTableMeta.setSupertable("weather"); - subTableMeta.setName("t" + i); - List tags = new ArrayList<>(); - tags.add(new TagValue("location", "beijing")); - tags.add(new TagValue("groupId", i)); - subTableMeta.setTags(tags); - subTables.add(subTableMeta); - } - } - - @Test - public void testCreateSubTable() { - - } - - @Test - public void testCreateSubTableList() { - - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/SuperTableServiceTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/SuperTableServiceTest.java deleted file mode 100644 index 33e52af1eaa779e7ed402a63633bf0dbb9fbadd7..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/SuperTableServiceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.taosdemo.domain.FieldMeta; -import com.taosdata.taosdemo.domain.SuperTableMeta; -import com.taosdata.taosdemo.domain.TagMeta; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class SuperTableServiceTest { - - private SuperTableService service; - - @Test - public void testCreate() { - SuperTableMeta superTableMeta = new SuperTableMeta(); - superTableMeta.setDatabase("test"); - superTableMeta.setName("weather"); - List fields = new ArrayList<>(); - fields.add(new FieldMeta("ts", "timestamp")); - fields.add(new FieldMeta("temperature", "float")); - fields.add(new FieldMeta("humidity", "int")); - superTableMeta.setFields(fields); - List tags = new ArrayList<>(); - tags.add(new TagMeta("location", "nchar(64)")); - tags.add(new TagMeta("groupId", "int")); - superTableMeta.setTags(tags); - service.create(superTableMeta); - } - -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/TableServiceTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/TableServiceTest.java deleted file mode 100644 index 1f52198d68823326dd81d8c419fc02d89e15ef2d..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/TableServiceTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.taosdata.taosdemo.service; - -import com.taosdata.taosdemo.domain.TableMeta; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class TableServiceTest { - private TableService tableService; - - private List tables; - - @Before - public void before() { - tables = new ArrayList<>(); - for (int i = 0; i < 1; i++) { - TableMeta tableMeta = new TableMeta(); - tableMeta.setDatabase("test"); - tableMeta.setName("weather" + (i + 1)); - tables.add(tableMeta); - } - } - - @Test - public void testCreate() { - tableService.create(tables); - } - -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/FieldValueGeneratorTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/FieldValueGeneratorTest.java deleted file mode 100644 index aea3cc76ca74951a6bbcc91fe3c6b5c7e078f0df..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/FieldValueGeneratorTest.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.FieldMeta; -import com.taosdata.taosdemo.domain.RowValue; -import com.taosdata.taosdemo.utils.TimeStampUtil; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class FieldValueGeneratorTest { - - private List rowValues; - - @Test - public void generate() { - List fieldMetas = new ArrayList<>(); - fieldMetas.add(new FieldMeta("ts", "timestamp")); - fieldMetas.add(new FieldMeta("temperature", "float")); - fieldMetas.add(new FieldMeta("humidity", "int")); - - long start = TimeStampUtil.datetimeToLong("2020-01-01 00:00:00.000"); - long end = TimeStampUtil.datetimeToLong("2020-01-01 10:00:00.000"); - - rowValues = FieldValueGenerator.generate(start, end, 1000l * 3600, fieldMetas); - Assert.assertEquals(10, rowValues.size()); - } - - @Test - public void disrupt() { - List fieldMetas = new ArrayList<>(); - fieldMetas.add(new FieldMeta("ts", "timestamp")); - fieldMetas.add(new FieldMeta("temperature", "float")); - fieldMetas.add(new FieldMeta("humidity", "int")); - - long start = TimeStampUtil.datetimeToLong("2020-01-01 00:00:00.000"); - long end = TimeStampUtil.datetimeToLong("2020-01-01 10:00:00.000"); - - rowValues = FieldValueGenerator.generate(start, end, 1000l * 3600l, fieldMetas); - - FieldValueGenerator.disrupt(rowValues, 20, 1000); - Assert.assertEquals(10, rowValues.size()); - } - - @After - public void after() { - for (RowValue row : rowValues) { - row.getFields().stream().forEach(field -> { - if (field.getName().equals("ts")) { - System.out.print(TimeStampUtil.longToDatetime((Long) field.getValue())); - } else - System.out.print(" ," + field.getValue()); - }); - System.out.println(); - } - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/SubTableMetaGeneratorTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/SubTableMetaGeneratorTest.java deleted file mode 100644 index 78c8e9283f9a045b251419e5a07b1c97bd105254..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/SubTableMetaGeneratorTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.FieldMeta; -import com.taosdata.taosdemo.domain.SubTableMeta; -import com.taosdata.taosdemo.domain.SuperTableMeta; -import com.taosdata.taosdemo.domain.TagMeta; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class SubTableMetaGeneratorTest { - List subTableMetas; - - @Test - public void generate() { - SuperTableMeta superTableMeta = new SuperTableMeta(); - superTableMeta.setDatabase("test"); - superTableMeta.setName("weather"); - List fields = new ArrayList<>(); - fields.add(new FieldMeta("ts", "timestamp")); - fields.add(new FieldMeta("temperature", "float")); - fields.add(new FieldMeta("humidity", "int")); - superTableMeta.setFields(fields); - List tags = new ArrayList<>(); - tags.add(new TagMeta("location", "nchar(64)")); - tags.add(new TagMeta("groupId", "int")); - superTableMeta.setTags(tags); - - subTableMetas = SubTableMetaGenerator.generate(superTableMeta, 10, "t"); - Assert.assertEquals(10, subTableMetas.size()); - Assert.assertEquals("t1", subTableMetas.get(0).getName()); - Assert.assertEquals("t2", subTableMetas.get(1).getName()); - Assert.assertEquals("t3", subTableMetas.get(2).getName()); - Assert.assertEquals("t4", subTableMetas.get(3).getName()); - Assert.assertEquals("t5", subTableMetas.get(4).getName()); - Assert.assertEquals("t6", subTableMetas.get(5).getName()); - Assert.assertEquals("t7", subTableMetas.get(6).getName()); - Assert.assertEquals("t8", subTableMetas.get(7).getName()); - Assert.assertEquals("t9", subTableMetas.get(8).getName()); - Assert.assertEquals("t10", subTableMetas.get(9).getName()); - } - - @After - public void after() { - for (SubTableMeta subTableMeta : subTableMetas) { - System.out.println(subTableMeta); - } - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/SuperTableMetaGeneratorImplTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/SuperTableMetaGeneratorImplTest.java deleted file mode 100644 index 11c5312cf6c9b4893681728115519509985a42a2..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/SuperTableMetaGeneratorImplTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.FieldMeta; -import com.taosdata.taosdemo.domain.SuperTableMeta; -import com.taosdata.taosdemo.domain.TagMeta; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; - -public class SuperTableMetaGeneratorImplTest { - private SuperTableMeta meta; - - @Test - public void generate() { - String sql = "create table test.weather (ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)"; - meta = SuperTableMetaGenerator.generate(sql); - Assert.assertEquals("test", meta.getDatabase()); - Assert.assertEquals("weather", meta.getName()); - Assert.assertEquals(3, meta.getFields().size()); - Assert.assertEquals("ts", meta.getFields().get(0).getName()); - Assert.assertEquals("timestamp", meta.getFields().get(0).getType()); - Assert.assertEquals("temperature", meta.getFields().get(1).getName()); - Assert.assertEquals("float", meta.getFields().get(1).getType()); - Assert.assertEquals("humidity", meta.getFields().get(2).getName()); - Assert.assertEquals("int", meta.getFields().get(2).getType()); - - Assert.assertEquals("location", meta.getTags().get(0).getName()); - Assert.assertEquals("nchar(64)", meta.getTags().get(0).getType()); - Assert.assertEquals("groupid", meta.getTags().get(1).getName()); - Assert.assertEquals("int", meta.getTags().get(1).getType()); - } - - @Test - public void generate2() { - meta = SuperTableMetaGenerator.generate("test", "weather", 10, "col", 10, "tag"); - Assert.assertEquals("test", meta.getDatabase()); - Assert.assertEquals("weather", meta.getName()); - Assert.assertEquals(11, meta.getFields().size()); - for (FieldMeta fieldMeta : meta.getFields()) { - Assert.assertNotNull(fieldMeta.getName()); - Assert.assertNotNull(fieldMeta.getType()); - } - for (TagMeta tagMeta : meta.getTags()) { - Assert.assertNotNull(tagMeta.getName()); - Assert.assertNotNull(tagMeta.getType()); - } - } - - @After - public void after() { - System.out.println(meta.getDatabase()); - System.out.println(meta.getName()); - for (FieldMeta fieldMeta : meta.getFields()) { - System.out.println(fieldMeta); - } - for (TagMeta tagMeta : meta.getTags()) { - System.out.println(tagMeta); - } - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/TagValueGeneratorTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/TagValueGeneratorTest.java deleted file mode 100644 index 37c9051c941b3540fd24371cff20be426d4fecba..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/service/data/TagValueGeneratorTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.taosdata.taosdemo.service.data; - -import com.taosdata.taosdemo.domain.TagMeta; -import com.taosdata.taosdemo.domain.TagValue; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -public class TagValueGeneratorTest { - List tagvalues; - - @Test - public void generate() { - List tagMetaList = new ArrayList<>(); - tagMetaList.add(new TagMeta("location", "nchar(10)")); - tagMetaList.add(new TagMeta("groupId", "int")); - tagMetaList.add(new TagMeta("ts", "timestamp")); - tagMetaList.add(new TagMeta("temperature", "float")); - tagMetaList.add(new TagMeta("humidity", "double")); - tagMetaList.add(new TagMeta("text", "binary(10)")); - tagvalues = TagValueGenerator.generate(tagMetaList); - Assert.assertEquals("location", tagvalues.get(0).getName()); - Assert.assertEquals("groupId", tagvalues.get(1).getName()); - Assert.assertEquals("ts", tagvalues.get(2).getName()); - Assert.assertEquals("temperature", tagvalues.get(3).getName()); - Assert.assertEquals("humidity", tagvalues.get(4).getName()); - Assert.assertEquals("text", tagvalues.get(5).getName()); - } - - @After - public void after() { - tagvalues.stream().forEach(System.out::println); - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/DataGeneratorTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/DataGeneratorTest.java deleted file mode 100644 index 7d12782526e4d64e120ba5e4c72809846356cd00..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/DataGeneratorTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.taosdata.taosdemo.utils; - -import org.junit.Assert; -import org.junit.Test; - -public class DataGeneratorTest { - - @Test - public void randomValue() { - for (int i = 0; i < TaosConstants.DATA_TYPES.length; i++) { - System.out.println(TaosConstants.DATA_TYPES[i] + " >>> " + DataGenerator.randomValue(TaosConstants.DATA_TYPES[i])); - } - } - - @Test - public void randomNchar() { - String s = DataGenerator.randomNchar(10); - Assert.assertEquals(10, s.length()); - } -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/SqlSpellerTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/SqlSpellerTest.java deleted file mode 100644 index daabd51ca75a6c9f4bfeead0b747c4de69f40a7a..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/SqlSpellerTest.java +++ /dev/null @@ -1,254 +0,0 @@ -package com.taosdata.taosdemo.utils; - -import com.taosdata.taosdemo.domain.*; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -public class SqlSpellerTest { - - @Test - public void createDatabase() { - HashMap map = new HashMap<>(); - map.put("database", "jdbcdb"); - map.put("keep", "3650"); - map.put("days", "30"); - map.put("replica", "1"); - map.put("minRows", "100"); - map.put("maxRows", "1000"); - map.put("cache", "16"); - map.put("blocks", "8"); - map.put("precision", "ms"); - map.put("comp", "2"); - map.put("walLevel", "1"); - map.put("quorum", "1"); - map.put("fsync", "3000"); - map.put("update", "0"); - String sql = SqlSpeller.createDatabase(map); - System.out.println(sql); - } - - @Test - public void createTableUsingSuperTable() { - SubTableMeta subTableMeta = new SubTableMeta(); - subTableMeta.setDatabase("test"); - subTableMeta.setSupertable("weather"); - subTableMeta.setName("t1"); - List tags = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - tags.add(new TagValue("tag" + (i + 1), "nchar(64)")); - } - subTableMeta.setTags(tags); - String sql = SqlSpeller.createTableUsingSuperTable(subTableMeta); - System.out.println(sql); - } - - @Test - public void insertOneTableMultiValues() { - String sql = SqlSpeller.insertOneTableMultiValues(tables.get(0)); - System.out.println(sql); - } - - @Test - public void insertOneTableMultiValuesUsingSuperTable() { - String sql = SqlSpeller.insertOneTableMultiValuesUsingSuperTable(tables.get(0)); - System.out.println(sql); - } - - @Test - public void insertMultiTableMultiValues() { - String sql = SqlSpeller.insertMultiSubTableMultiValues(tables); - System.out.println(sql); - } - - @Test - public void insertMultiTableMultiValuesUsingSuperTable() { - String sql = SqlSpeller.insertMultiTableMultiValuesUsingSuperTable(tables); - System.out.println(sql); - } - - private List tables; - - @Before - public void before() { - tables = new ArrayList<>(); - for (int ind = 0; ind < 3; ind++) { - SubTableValue table = new SubTableValue(); - table.setDatabase("test"); - // supertable - table.setSupertable("weather"); - table.setName("t" + (ind + 1)); - // tags - List tags = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - tags.add(new TagValue("tag" + (i + 1), "beijing")); - } - table.setTags(tags); - // values - List values = new ArrayList<>(); - for (int i = 0; i < 2; i++) { - List fields = new ArrayList<>(); - for (int j = 0; j < 4; j++) { - fields.add(new FieldValue("f" + (j + 1), (j + 1) * 10)); - } - values.add(new RowValue(fields)); - } - table.setValues(values); - - tables.add(table); - } - } - - @Test - public void createSuperTable() { - SuperTableMeta superTableMeta = new SuperTableMeta(); - superTableMeta.setDatabase("test"); - superTableMeta.setName("weather"); - List fields = new ArrayList<>(); - for (int i = 0; i < 5; i++) { - fields.add(new FieldMeta("f" + (i + 1), "int")); - } - superTableMeta.setFields(fields); - List tags = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - tags.add(new TagMeta("t" + (i + 1), "nchar(64)")); - } - superTableMeta.setTags(tags); - - String sql = SqlSpeller.createSuperTable(superTableMeta); - System.out.println(sql); - } - - @Test - public void createTable() { - TableMeta table = new TableMeta(); - table.setDatabase("test"); - table.setName("t1"); - List fields = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - FieldMeta field = new FieldMeta(); - field.setName("f" + (i + 1)); - field.setType("nchar(64)"); - fields.add(field); - } - table.setFields(fields); - String sql = SqlSpeller.createTable(table); - System.out.println(sql); - } - - - @Test - public void testInsertOneTableMultiValues() { - TableValue table = new TableValue(); - table.setDatabase("test"); - table.setName("t1"); - List values = new ArrayList<>(); - for (int j = 0; j < 5; j++) { - List fields = new ArrayList<>(); - for (int k = 0; k < 2; k++) { - FieldValue field = new FieldValue<>(); - field.setValue((k + 1) * 100); - fields.add(field); - } - values.add(new RowValue(fields)); - } - table.setValues(values); - - String sql = SqlSpeller.insertOneTableMultiValues(table); - System.out.println(sql); - } - - @Test - public void insertOneTableMultiValuesWithColumns() { - TableValue tableValue = new TableValue(); - tableValue.setDatabase("test"); - tableValue.setName("weather"); - // columns - List columns = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - FieldMeta field = new FieldMeta(); - field.setName("f" + (i + 1)); - columns.add(field); - } - tableValue.setColumns(columns); - // values - List values = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - List fields = new ArrayList<>(); - for (int j = 0; j < 3; j++) { - FieldValue field = new FieldValue(); - field.setValue(j); - fields.add(field); - } - values.add(new RowValue(fields)); - } - tableValue.setValues(values); - - String sql = SqlSpeller.insertOneTableMultiValuesWithColumns(tableValue); - System.out.println(sql); - } - - @Test - public void insertMultiTableMultiValuesWithColumns() { - List tables = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - TableValue table = new TableValue(); - table.setDatabase("test"); - table.setName("t" + (i + 1)); - // columns - List columns = new ArrayList<>(); - for (int j = 0; j < 3; j++) { - FieldMeta field = new FieldMeta(); - field.setName("f" + (j + 1)); - columns.add(field); - } - table.setColumns(columns); - // values - List values = new ArrayList<>(); - for (int j = 0; j < 5; j++) { - List fields = new ArrayList<>(); - for (int k = 0; k < columns.size(); k++) { - FieldValue field = new FieldValue<>(); - field.setValue((k + 1) * 10); - fields.add(field); - } - values.add(new RowValue(fields)); - } - table.setValues(values); - tables.add(table); - } - - String sql = SqlSpeller.insertMultiTableMultiValuesWithColumns(tables); - System.out.println(sql); - } - - @Test - public void testInsertMultiTableMultiValues() { - List tables = new ArrayList<>(); - for (int i = 0; i < 3; i++) { - TableValue table = new TableValue(); - table.setDatabase("test"); - table.setName("t" + (i + 1)); - List values = new ArrayList<>(); - for (int j = 0; j < 5; j++) { - List fields = new ArrayList<>(); - for (int k = 0; k < 2; k++) { - FieldValue field = new FieldValue<>(); - field.setValue((k + 1) * 10); - fields.add(field); - } - values.add(new RowValue(fields)); - } - table.setValues(values); - - tables.add(table); - } - - String sql = SqlSpeller.insertMultiTableMultiValues(tables); - System.out.println(sql); - } - -} \ No newline at end of file diff --git a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/TimeStampUtilTest.java b/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/TimeStampUtilTest.java deleted file mode 100644 index a4845677c55897c71791eba40104ea23de644f5c..0000000000000000000000000000000000000000 --- a/tests/examples/JDBC/taosdemo/src/test/java/com/taosdata/taosdemo/utils/TimeStampUtilTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.taosdata.taosdemo.utils; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class TimeStampUtilTest { - - @Test - public void datetimeToLong() { - final String startTime = "2005-01-01 00:00:00.000"; - long start = TimeStampUtil.datetimeToLong(startTime); - assertEquals(1104508800000l, start); - String dateTimeStr = TimeStampUtil.longToDatetime(start); - assertEquals("2005-01-01 00:00:00.000", dateTimeStr); - } - - @Test - public void longToDatetime() { - System.out.println(TimeStampUtil.longToDatetime(1293334499006l)); - - String datetime = TimeStampUtil.longToDatetime(1510000000000L); - assertEquals("2017-11-07 04:26:40.000", datetime); - long timestamp = TimeStampUtil.datetimeToLong(datetime); - assertEquals(1510000000000L, timestamp); - } - - @Test - public void range() { - long start = TimeStampUtil.datetimeToLong("2020-10-01 00:00:00.000"); - long timeGap = 1000; - long numOfRowsPerTable = 1000l * 3600l * 24l * 90l; - TimeStampUtil.TimeTuple timeTuple = TimeStampUtil.range(start, timeGap, numOfRowsPerTable); - System.out.println(TimeStampUtil.longToDatetime(timeTuple.start)); - System.out.println(TimeStampUtil.longToDatetime(timeTuple.end)); - System.out.println(timeTuple.timeGap); - - } - -} \ No newline at end of file diff --git a/tests/examples/R/command.txt b/tests/examples/R/command.txt deleted file mode 100644 index 9a549ff200968d96336666c23999e13aa07dbb3f..0000000000000000000000000000000000000000 --- a/tests/examples/R/command.txt +++ /dev/null @@ -1,55 +0,0 @@ -# Linux Platform -install.packages('rJDBC', repos='http://cran.us.r-project.org') - -# Loading RJDBC packages -library('RJDBC') -# Set up working path and JDBC driver storage location -setwd('C:/TDengine') - -# Load JDBC Driver for TDengine -drv<-JDBC("com.taosdata.jdbc.TSDBDriver","JDBCDriver-1.0.0-dist.jar", identifier.quote="\"") - -# Connect to the database -conn<-dbConnect(drv,"jdbc:TSDB://192.168.1.114:0/?user=root&password=taosdata","root","taosdata") - -# Get connection information -dbGetInfo(conn) - -# Using database test -dbSendUpdate(conn, "use test") - -# Insert data -dbSendUpdate(conn, "insert into t1 values(now, 99)") - -# View all tables -table1<-dbGetQuery(conn,"show tables") - -# Functional support for RJDBC - -# List all tables -dbListTables(conn) - -# Is there table iris -dbExistsTable(conn,”iris”) - -# Connect summary information -summary(conn) -dbGetInfo(conn) - -# Read all the data from the T1 table -dbReadTable(conn, "t1") - -# Delete table t1 -dbRemoveTable(conn,"t1") - -# Execute any non-query SQL statements -dbSendUpdate(conn, "create table t1(a timestamp, b int, c nchar(12))"); - -# Write data -dbWriteTable(conn, "t1", t_demo_n, overwrite=FALSE, append=TRUE) - -# Extracting data on demand using SQL statements -dbGetQuery(conn, "select k from tu") - -# Close the connection -dbDisconnect(conn) diff --git a/tests/examples/bash/demo.csv b/tests/examples/bash/demo.csv deleted file mode 100644 index 5b9d6eb8117b20f209d3c94c3608bdedf0d7a469..0000000000000000000000000000000000000000 --- a/tests/examples/bash/demo.csv +++ /dev/null @@ -1,10 +0,0 @@ -1503851026421, 220, 1.10 -1503851026422, 221, 1.20 -1503851026423, 219, 1.09 -1503851026424, 222, 1.11 -1503851026425, 220, 1.08 -'2019-07-22 10:00:01.000', 219, 1.06 -'2019-07-22 10:00:02.000', 218, 1.04 -'2019-07-22 10:01:02.000', 220, 1.12 -'2019-07-22 11:01:02.000', 221, 1.11 -'2019-07-23 11:01:02.000', 220, 1.09 diff --git a/tests/examples/bash/demo.sql b/tests/examples/bash/demo.sql deleted file mode 100644 index 8c3c4124519ff3906cd4c7c39db57eac0c76f902..0000000000000000000000000000000000000000 --- a/tests/examples/bash/demo.sql +++ /dev/null @@ -1,14 +0,0 @@ -create database if not exists db0 -create table if not exists db0.tb0 (ts timestamp, voltage int, current float) -import into db0.tb0 file demo.csv - - -create database if not exists db1 -use db1 -create table if not exists tb1 (ts timestamp, temperature int, humidity float) -insert into tb1 values('2010-07-23 11:01:02.000', 37, 50.1) -insert into tb1 values(now, 36, 47.8); -insert into tb1 values(now+1a, 38, 65.3); -insert into tb1 values(now+1s, 38, 53.9 ); -insert into tb1 values(now+1m, 37, 45.6); -insert into tb1 values(now+1h, 35, 41.1); diff --git a/tests/examples/c/CMakeLists.txt b/tests/examples/c/CMakeLists.txt deleted file mode 100644 index 3c0a4d32db154a942fbc05183ed7379b3e2fe5ad..0000000000000000000000000000000000000000 --- a/tests/examples/c/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -PROJECT(TDengine) - -IF (TD_LINUX) - INCLUDE_DIRECTORIES(. ${TD_COMMUNITY_DIR}/src/inc ${TD_COMMUNITY_DIR}/src/client/inc ${TD_COMMUNITY_DIR}/inc) - AUX_SOURCE_DIRECTORY(. SRC) - ADD_EXECUTABLE(demo apitest.c) - TARGET_LINK_LIBRARIES(demo taos_static trpc tutil pthread ) - ADD_EXECUTABLE(sml schemaless.c) - TARGET_LINK_LIBRARIES(sml taos_static trpc tutil pthread ) - ADD_EXECUTABLE(sqlperf sqlperf.c) - TARGET_LINK_LIBRARIES(sqlperf taos_static trpc tutil pthread ) - ADD_EXECUTABLE(subscribe subscribe.c) - TARGET_LINK_LIBRARIES(subscribe taos_static trpc tutil pthread ) - ADD_EXECUTABLE(epoll epoll.c) - TARGET_LINK_LIBRARIES(epoll taos_static trpc tutil pthread ${LINK_LUA}) -ENDIF () -IF (TD_DARWIN) - INCLUDE_DIRECTORIES(. ${TD_COMMUNITY_DIR}/src/inc ${TD_COMMUNITY_DIR}/src/client/inc ${TD_COMMUNITY_DIR}/inc) - AUX_SOURCE_DIRECTORY(. SRC) - ADD_EXECUTABLE(demo demo.c) - TARGET_LINK_LIBRARIES(demo taos_static trpc tutil pthread ${LINK_LUA}) - ADD_EXECUTABLE(epoll epoll.c) - TARGET_LINK_LIBRARIES(epoll taos_static trpc tutil pthread ${LINK_LUA}) - - ADD_EXECUTABLE(parameter-binding parameter-binding.c) - TARGET_LINK_LIBRARIES(parameter-binding taos) -ENDIF () diff --git a/tests/examples/c/apitest.c b/tests/examples/c/apitest.c deleted file mode 100644 index 2c197887e7d7f1e6397213641a02ee8b37a84190..0000000000000000000000000000000000000000 --- a/tests/examples/c/apitest.c +++ /dev/null @@ -1,455 +0,0 @@ -// sample code to verify all TDengine API -// to compile: gcc -o apitest apitest.c -ltaos - -#include "taoserror.h" - -#include -#include -#include -#include -#include - - -static void prepare_data(TAOS* taos) { - TAOS_RES* result; - result = taos_query(taos, "drop database if exists test;"); - taos_free_result(result); - usleep(100000); - result = taos_query(taos, "create database test precision 'ns';"); - taos_free_result(result); - usleep(100000); - taos_select_db(taos, "test"); - - result = taos_query(taos, "create table meters(ts timestamp, a int) tags(area int);"); - taos_free_result(result); - - result = taos_query(taos, "create table t0 using meters tags(0);"); - taos_free_result(result); - result = taos_query(taos, "create table t1 using meters tags(1);"); - taos_free_result(result); - result = taos_query(taos, "create table t2 using meters tags(2);"); - taos_free_result(result); - result = taos_query(taos, "create table t3 using meters tags(3);"); - taos_free_result(result); - result = taos_query(taos, "create table t4 using meters tags(4);"); - taos_free_result(result); - result = taos_query(taos, "create table t5 using meters tags(5);"); - taos_free_result(result); - result = taos_query(taos, "create table t6 using meters tags(6);"); - taos_free_result(result); - result = taos_query(taos, "create table t7 using meters tags(7);"); - taos_free_result(result); - result = taos_query(taos, "create table t8 using meters tags(8);"); - taos_free_result(result); - result = taos_query(taos, "create table t9 using meters tags(9);"); - taos_free_result(result); - - result = taos_query(taos, - "insert into t0 values('2020-01-01 00:00:00.000', 0)" - " ('2020-01-01 00:01:00.000', 0)" - " ('2020-01-01 00:02:00.000', 0)" - " t1 values('2020-01-01 00:00:00.000', 0)" - " ('2020-01-01 00:01:00.000', 0)" - " ('2020-01-01 00:02:00.000', 0)" - " ('2020-01-01 00:03:00.000', 0)" - " t2 values('2020-01-01 00:00:00.000', 0)" - " ('2020-01-01 00:01:00.000', 0)" - " ('2020-01-01 00:01:01.000', 0)" - " ('2020-01-01 00:01:02.000', 0)" - " t3 values('2020-01-01 00:01:02.000', 0)" - " t4 values('2020-01-01 00:01:02.000', 0)" - " t5 values('2020-01-01 00:01:02.000', 0)" - " t6 values('2020-01-01 00:01:02.000', 0)" - " t7 values('2020-01-01 00:01:02.000', 0)" - " t8 values('2020-01-01 00:01:02.000', 0)" - " t9 values('2020-01-01 00:01:02.000', 0)"); - int affected = taos_affected_rows(result); - if (affected != 18) { - printf("\033[31m%d rows affected by last insert statement, but it should be 18\033[0m\n", affected); - } - taos_free_result(result); - // super tables subscription - usleep(1000000); -} - -static int print_result(TAOS_RES* res, int blockFetch) { - TAOS_ROW row = NULL; - int num_fields = taos_num_fields(res); - TAOS_FIELD* fields = taos_fetch_fields(res); - int nRows = 0; - - if (blockFetch) { - int rows = 0; - while ((rows = taos_fetch_block(res, &row))) { - // for (int i = 0; i < rows; i++) { - // char temp[256]; - // taos_print_row(temp, row + i, fields, num_fields); - // puts(temp); - //} - nRows += rows; - } - } else { - while ((row = taos_fetch_row(res))) { - char temp[256] = {0}; - taos_print_row(temp, row, fields, num_fields); - puts(temp); - nRows++; - } - } - - printf("%d rows consumed.\n", nRows); - return nRows; -} - -static void check_row_count(int line, TAOS_RES* res, int expected) { - int actual = print_result(res, expected % 2); - if (actual != expected) { - printf("\033[31mline %d: row count mismatch, expected: %d, actual: %d\033[0m\n", line, expected, actual); - } else { - printf("line %d: %d rows consumed as expected\n", line, actual); - } -} - -static void verify_query(TAOS* taos) { - prepare_data(taos); - - int code = taos_load_table_info(taos, "t0,t1,t2,t3,t4,t5,t6,t7,t8,t9"); - if (code != 0) { - printf("\033[31mfailed to load table info: 0x%08x\033[0m\n", code); - } - - code = taos_validate_sql(taos, "select * from nonexisttable"); - if (code == 0) { - printf("\033[31mimpossible, the table does not exists\033[0m\n"); - } - - code = taos_validate_sql(taos, "select * from meters"); - if (code != 0) { - printf("\033[31mimpossible, the table does exists: 0x%08x\033[0m\n", code); - } - - TAOS_RES* res = taos_query(taos, "select * from meters"); - check_row_count(__LINE__, res, 18); - printf("result precision is: %d\n", taos_result_precision(res)); - int c = taos_field_count(res); - printf("field count is: %d\n", c); - int* lengths = taos_fetch_lengths(res); - for (int i = 0; i < c; i++) { - printf("length of column %d is %d\n", i, lengths[i]); - } - taos_free_result(res); - - res = taos_query(taos, "select * from t0"); - check_row_count(__LINE__, res, 3); - taos_free_result(res); - - res = taos_query(taos, "select * from nonexisttable"); - code = taos_errno(res); - printf("code=%d, error msg=%s\n", code, taos_errstr(res)); - taos_free_result(res); - - res = taos_query(taos, "select * from meters"); - taos_stop_query(res); - taos_free_result(res); -} - -void subscribe_callback(TAOS_SUB* tsub, TAOS_RES* res, void* param, int code) { - int rows = print_result(res, *(int*)param); - printf("%d rows consumed in subscribe_callback\n", rows); -} - -static void verify_subscribe(TAOS* taos) { - prepare_data(taos); - - TAOS_SUB* tsub = taos_subscribe(taos, 0, "test", "select * from meters;", NULL, NULL, 0); - TAOS_RES* res = taos_consume(tsub); - check_row_count(__LINE__, res, 18); - - res = taos_consume(tsub); - check_row_count(__LINE__, res, 0); - - TAOS_RES* result; - result = taos_query(taos, "insert into t0 values('2020-01-01 00:02:00.001', 0);"); - taos_free_result(result); - result = taos_query(taos, "insert into t8 values('2020-01-01 00:01:03.000', 0);"); - taos_free_result(result); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 2); - - result = taos_query(taos, "insert into t2 values('2020-01-01 00:01:02.001', 0);"); - taos_free_result(result); - result = taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.001', 0);"); - taos_free_result(result); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 2); - - result = taos_query(taos, "insert into t1 values('2020-01-01 00:03:00.002', 0);"); - taos_free_result(result); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 1); - - // keep progress information and restart subscription - taos_unsubscribe(tsub, 1); - result = taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.000', 0);"); - taos_free_result(result); - tsub = taos_subscribe(taos, 1, "test", "select * from meters;", NULL, NULL, 0); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 24); - - // keep progress information and continue previous subscription - taos_unsubscribe(tsub, 1); - tsub = taos_subscribe(taos, 0, "test", "select * from meters;", NULL, NULL, 0); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 0); - - // don't keep progress information and continue previous subscription - taos_unsubscribe(tsub, 0); - tsub = taos_subscribe(taos, 0, "test", "select * from meters;", NULL, NULL, 0); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 24); - - // single meter subscription - - taos_unsubscribe(tsub, 0); - tsub = taos_subscribe(taos, 0, "test", "select * from t0;", NULL, NULL, 0); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 5); - - res = taos_consume(tsub); - check_row_count(__LINE__, res, 0); - - result = taos_query(taos, "insert into t0 values('2020-01-01 00:04:00.001', 0);"); - taos_free_result(result); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 1); - - taos_unsubscribe(tsub, 0); - - int blockFetch = 0; - tsub = taos_subscribe(taos, 1, "test", "select * from meters;", subscribe_callback, &blockFetch, 1000); - usleep(2000000); - result = taos_query(taos, "insert into t0 values('2020-01-01 00:05:00.001', 0);"); - taos_free_result(result); - usleep(2000000); - taos_unsubscribe(tsub, 0); -} - -void retrieve_callback(void* param, TAOS_RES* tres, int numOfRows) { - if (numOfRows > 0) { - printf("%d rows async retrieved\n", numOfRows); - taos_fetch_rows_a(tres, retrieve_callback, param); - } else { - if (numOfRows < 0) { - printf("\033[31masync retrieve failed, code: %d\033[0m\n", numOfRows); - } else { - printf("async retrieve completed\n"); - } - taos_free_result(tres); - } -} - -void select_callback(void* param, TAOS_RES* tres, int code) { - if (code == 0 && tres) { - taos_fetch_rows_a(tres, retrieve_callback, param); - } else { - printf("\033[31masync select failed, code: %d\033[0m\n", code); - } -} - -void verify_async(TAOS* taos) { - prepare_data(taos); - taos_query_a(taos, "select * from meters", select_callback, NULL); - usleep(1000000); -} - -void stream_callback(void* param, TAOS_RES* res, TAOS_ROW row) { - if (res == NULL || row == NULL) { - return; - } - - int num_fields = taos_num_fields(res); - TAOS_FIELD* fields = taos_fetch_fields(res); - - printf("got one row from stream_callback\n"); - char temp[256] = {0}; - taos_print_row(temp, row, fields, num_fields); - puts(temp); -} - -void verify_stream(TAOS* taos) { - prepare_data(taos); - TAOS_STREAM* strm = - taos_open_stream(taos, "select count(*) from meters interval(1m)", stream_callback, 0, NULL, NULL); - printf("waiting for stream data\n"); - usleep(100000); - TAOS_RES* result = taos_query(taos, "insert into t0 values(now, 0)(now+5s,1)(now+10s, 2);"); - taos_free_result(result); - usleep(200000000); - taos_close_stream(strm); -} - -void verify_schema_less(TAOS* taos) { - TAOS_RES* result; - result = taos_query(taos, "drop database if exists test;"); - taos_free_result(result); - usleep(100000); - result = taos_query(taos, "create database test precision 'ns' update 1 keep 36500;"); - taos_free_result(result); - usleep(100000); - - taos_select_db(taos, "test"); - result = taos_query(taos, "create stable ste(ts timestamp, f int) tags(t1 bigint)"); - taos_free_result(result); - usleep(100000); - - int code = 0, affected_rows = 0; - - char* lines[] = { - "st,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", - "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833640000000", - "ste,t2=5f64,t3=L\"ste\" c1=true,c2=4i64,c3=\"iam\" 1626056811823316532", - "st,t1=4i64,t2=5f64,t3=\"t4\" c1=3i64,c3=L\"passitagain\",c2=true,c4=5f64 1626006833642000000", - "ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false 1626056811843316532", - "ste,t2=5f64,t3=L\"ste2\" c3=\"iamszhou\",c4=false,c5=32i8,c6=64i16,c7=32i32,c8=88.88f32 1626056812843316532", - "st,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000", - "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64,c6=7u64 1626006933640000000", - "stf,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641000000" - }; - - result = taos_schemaless_insert(taos, lines , sizeof(lines)/sizeof(char*), TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - - char* lines2[] = { - "stg,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", - "stg,t1=4i64,t3=\"t4\",t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin\",c2=true,c4=5f64,c5=5f64 1626006833641000000" - }; - result = taos_schemaless_insert(taos, &lines2[0], 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines2_0]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - - result = taos_schemaless_insert(taos, &lines2[1], 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines2_1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - - char* lines3[] = { - "sth,t1=4i64,t2=5f64,t4=5f64,ID=childTable c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933641", - "sth,t1=4i64,t2=5f64,t4=5f64 c1=3i64,c3=L\"passitagin_stf\",c2=false,c5=5f64,c6=7u64 1626006933654" - }; - result = taos_schemaless_insert(taos, lines3, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_MILLI_SECONDS); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines3]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - - char* lines4[] = { - "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", - "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532" - }; - result = taos_schemaless_insert(taos, lines4, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines4]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - - - char* lines5[] = { - "zqlbgs,id=zqlbgs_39302_21680,t0=f,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=f,c1=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "zqlbgs,t9=f,id=zqlbgs_39302_21680,t0=f,t1=127i8,t11=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\",t10=L\"ncharTagValue\" c10=f,c0=f,c1=127i8,c12=127i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"binaryColValue\",c8=L\"ncharColValue\",c9=7u64,c11=L\"ncharColValue\" 1626006833639000000" - }; - result = taos_schemaless_insert(taos, &lines5[0], 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines5_0]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - - result = taos_schemaless_insert(taos, &lines5[1], 1, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines5_1]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - - char* lines6[] = { - "st123456,t1=3i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1626006833639000000", - "dgtyqodr,t2=5f64,t3=L\"ste\" c1=tRue,c2=4i64,c3=\"iam\" 1626056811823316532" - }; - result = taos_schemaless_insert(taos, lines6, 2, TSDB_SML_LINE_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines6]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - - //Test timestamp precision - char* lines7[] = { - "stts,t1=10i64,t2=4f64,t3=\"t3\" c1=3i64,c3=L\"passit\",c2=false,c4=4f64 1", - }; - - for (int precision = TSDB_SML_TIMESTAMP_HOURS; precision <= TSDB_SML_TIMESTAMP_NANO_SECONDS; ++precision) { - result = taos_schemaless_insert(taos, lines7, 1, TSDB_SML_LINE_PROTOCOL, precision); - code = taos_errno(result); - if (code != TSDB_CODE_SUCCESS) { - affected_rows = taos_affected_rows(result); - printf("\033[31m [lines7_%d]taos_schemaless_insert failed, code: %d,%s, affected rows:%d \033[0m\n", precision, code, taos_errstr(result), affected_rows); - } - taos_free_result(result); - } - -} - -int main(int argc, char* argv[]) { - const char* host = "127.0.0.1"; - const char* user = "root"; - const char* passwd = "taosdata"; - - taos_options(TSDB_OPTION_TIMEZONE, "GMT-8"); - TAOS* taos = taos_connect(host, user, passwd, "", 0); - if (taos == NULL) { - printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos)); - exit(1); - } - - char* info = taos_get_server_info(taos); - printf("server info: %s\n", info); - info = taos_get_client_info(taos); - printf("client info: %s\n", info); - - printf("************ verify schema-less *************\n"); - verify_schema_less(taos); - - printf("************ verify query *************\n"); - verify_query(taos); - - printf("********* verify async query **********\n"); - verify_async(taos); - - printf("*********** verify subscribe ************\n"); - verify_subscribe(taos); - - printf("************ verify stream *************\n"); - // verify_stream(taos); - printf("done\n"); - taos_close(taos); - taos_cleanup(); -} diff --git a/tests/examples/c/asyncdemo.c b/tests/examples/c/asyncdemo.c deleted file mode 100644 index 78e41ddf5cad70ddb430dfdd5832e92d2800d030..0000000000000000000000000000000000000000 --- a/tests/examples/c/asyncdemo.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -// TAOS asynchronous API example -// this example opens multiple tables, insert/retrieve multiple tables -// it is used by TAOS internally for one performance testing -// to compiple: gcc -o asyncdemo asyncdemo.c -ltaos - -#include -#include -#include -#include -#include - -#include - -int points = 5; -int numOfTables = 3; -int tablesInsertProcessed = 0; -int tablesSelectProcessed = 0; -int64_t st, et; - -typedef struct { - int id; - TAOS * taos; - char name[16]; - time_t timeStamp; - int value; - int rowsInserted; - int rowsTried; - int rowsRetrieved; -} STable; - -void taos_insert_call_back(void *param, TAOS_RES *tres, int code); -void taos_select_call_back(void *param, TAOS_RES *tres, int code); -void taos_error(TAOS *taos); - -static void queryDB(TAOS *taos, char *command) { - int i; - TAOS_RES *pSql = NULL; - int32_t code = -1; - - for (i = 0; i < 5; i++) { - if (NULL != pSql) { - taos_free_result(pSql); - pSql = NULL; - } - - pSql = taos_query(taos, command); - code = taos_errno(pSql); - if (0 == code) { - break; - } - } - - if (code != 0) { - fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql)); - taos_free_result(pSql); - taos_close(taos); - taos_cleanup(); - exit(EXIT_FAILURE); - } - - taos_free_result(pSql); -} - -int main(int argc, char *argv[]) { - TAOS * taos; - struct timeval systemTime; - int i; - char sql[1024] = {0}; - char prefix[20] = {0}; - char db[128] = {0}; - STable * tableList; - - if (argc != 5) { - printf("usage: %s server-ip dbname rowsPerTable numOfTables\n", argv[0]); - exit(0); - } - - // a simple way to parse input parameters - if (argc >= 3) strcpy(db, argv[2]); - if (argc >= 4) points = atoi(argv[3]); - if (argc >= 5) numOfTables = atoi(argv[4]); - - size_t size = sizeof(STable) * (size_t)numOfTables; - tableList = (STable *)malloc(size); - memset(tableList, 0, size); - - taos = taos_connect(argv[1], "root", "taosdata", NULL, 0); - if (taos == NULL) taos_error(taos); - - printf("success to connect to server\n"); - - sprintf(sql, "drop database if exists %s", db); - queryDB(taos, sql); - - sprintf(sql, "create database %s", db); - queryDB(taos, sql); - - sprintf(sql, "use %s", db); - queryDB(taos, sql); - - strcpy(prefix, "asytbl_"); - for (i = 0; i < numOfTables; ++i) { - tableList[i].id = i; - tableList[i].taos = taos; - sprintf(tableList[i].name, "%s%d", prefix, i); - sprintf(sql, "create table %s%d (ts timestamp, volume bigint)", prefix, i); - queryDB(taos, sql); - } - - gettimeofday(&systemTime, NULL); - for (i = 0; i < numOfTables; ++i) - tableList[i].timeStamp = (time_t)(systemTime.tv_sec) * 1000 + systemTime.tv_usec / 1000; - - printf("success to create tables, press any key to insert\n"); - getchar(); - - printf("start to insert...\n"); - gettimeofday(&systemTime, NULL); - st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - - tablesInsertProcessed = 0; - tablesSelectProcessed = 0; - - for (i = 0; i < numOfTables; ++i) { - // insert records in asynchronous API - sprintf(sql, "insert into %s values(%ld, 0)", tableList[i].name, 1546300800000 + i); - taos_query_a(taos, sql, taos_insert_call_back, (void *)(tableList + i)); - } - - printf("once insert finished, presse any key to query\n"); - getchar(); - - while (1) { - if (tablesInsertProcessed < numOfTables) { - printf("wait for process finished\n"); - sleep(1); - continue; - } - - break; - } - - printf("start to query...\n"); - gettimeofday(&systemTime, NULL); - st = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - - for (i = 0; i < numOfTables; ++i) { - // select records in asynchronous API - sprintf(sql, "select * from %s", tableList[i].name); - taos_query_a(taos, sql, taos_select_call_back, (void *)(tableList + i)); - } - - printf("\nonce finished, press any key to exit\n"); - getchar(); - - while (1) { - if (tablesSelectProcessed < numOfTables) { - printf("wait for process finished\n"); - sleep(1); - continue; - } - - break; - } - - for (i = 0; i < numOfTables; ++i) { - printf("%s inserted:%d retrieved:%d\n", tableList[i].name, tableList[i].rowsInserted, tableList[i].rowsRetrieved); - } - - taos_close(taos); - free(tableList); - - printf("==== async demo end====\n"); - printf("\n"); - return 0; -} - -void taos_error(TAOS *con) { - fprintf(stderr, "TDengine error: %s\n", taos_errstr(con)); - taos_close(con); - taos_cleanup(); - exit(1); -} - -void taos_insert_call_back(void *param, TAOS_RES *tres, int code) { - STable * pTable = (STable *)param; - struct timeval systemTime; - char sql[128]; - - pTable->rowsTried++; - - if (code < 0) { - printf("%s insert failed, code:%d, rows:%d\n", pTable->name, code, pTable->rowsTried); - } else if (code == 0) { - printf("%s not inserted\n", pTable->name); - } else { - pTable->rowsInserted++; - } - - if (pTable->rowsTried < points) { - // for this demo, insert another record - sprintf(sql, "insert into %s values(%ld, %d)", pTable->name, 1546300800000 + pTable->rowsTried * 1000, - pTable->rowsTried); - taos_query_a(pTable->taos, sql, taos_insert_call_back, (void *)pTable); - } else { - printf("%d rows data are inserted into %s\n", points, pTable->name); - tablesInsertProcessed++; - if (tablesInsertProcessed >= numOfTables) { - gettimeofday(&systemTime, NULL); - et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - printf("%lld mseconds to insert %d data points\n", (et - st) / 1000, points * numOfTables); - } - } - - taos_free_result(tres); -} - -void taos_retrieve_call_back(void *param, TAOS_RES *tres, int numOfRows) { - STable * pTable = (STable *)param; - struct timeval systemTime; - - if (numOfRows > 0) { - for (int i = 0; i < numOfRows; ++i) { - // synchronous API to retrieve a row from batch of records - /*TAOS_ROW row = */ (void)taos_fetch_row(tres); - // process row - } - - pTable->rowsRetrieved += numOfRows; - - // retrieve next batch of rows - taos_fetch_rows_a(tres, taos_retrieve_call_back, pTable); - - } else { - if (numOfRows < 0) printf("%s retrieve failed, code:%d\n", pTable->name, numOfRows); - - // taos_free_result(tres); - printf("%d rows data retrieved from %s\n", pTable->rowsRetrieved, pTable->name); - - tablesSelectProcessed++; - if (tablesSelectProcessed >= numOfTables) { - gettimeofday(&systemTime, NULL); - et = systemTime.tv_sec * 1000000 + systemTime.tv_usec; - printf("%lld mseconds to query %d data rows\n", (et - st) / 1000, points * numOfTables); - } - - taos_free_result(tres); - } -} - -void taos_select_call_back(void *param, TAOS_RES *tres, int code) { - STable *pTable = (STable *)param; - - if (code == 0 && tres) { - // asynchronous API to fetch a batch of records - taos_fetch_rows_a(tres, taos_retrieve_call_back, pTable); - } else { - printf("%s select failed, code:%d\n", pTable->name, code); - taos_free_result(tres); - taos_cleanup(); - exit(1); - } -} diff --git a/tests/examples/c/clientcfgtest-taosd.c b/tests/examples/c/clientcfgtest-taosd.c deleted file mode 100644 index fbfbd8935a34481c23e806bbe461882ed9a10437..0000000000000000000000000000000000000000 --- a/tests/examples/c/clientcfgtest-taosd.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#include -#include -#include "os.h" -#include "taosdef.h" -#include "taoserror.h" -#include "tconfig.h" -#include "tglobal.h" -#include "tulog.h" -#include "tsocket.h" -#include "tutil.h" -extern SGlobalCfg *taosGetConfigOption(const char *option) ; -int main( int argc, char *argv[]){ - - printf("start to test\n"); - - //case1: - //Test config to wrong type - const char config1[128] = "{\"cache\":\"4\"}";//input the parameter which want to be configured - taos_set_config(config1); //configure the parameter - - SGlobalCfg *cfg1 ; - - cfg1 = taosGetConfigOption("cache");//check the option result - if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config cache to '4'success!\n"); - else - printf("config cache failure!\n"); - return 0 ; - -} diff --git a/tests/examples/c/clientcfgtest-wrongjson.c b/tests/examples/c/clientcfgtest-wrongjson.c deleted file mode 100644 index eecb5dae6d27c213731afdea005af3fc265dd47f..0000000000000000000000000000000000000000 --- a/tests/examples/c/clientcfgtest-wrongjson.c +++ /dev/null @@ -1,62 +0,0 @@ -#include -#include -#include -#include -#include -#include "os.h" -#include "taosdef.h" -#include "taoserror.h" -#include "tconfig.h" -#include "tglobal.h" -#include "tulog.h" -#include "tsocket.h" -#include "tutil.h" -extern SGlobalCfg *taosGetConfigOption(const char *option) ; -int main( int argc, char *argv[]){ - - printf("start to test\n"); - - //case1: - //Test config with wrong JSON - //The result is failure - const char config1[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\135\"}";//input the parameter which want to be configured - taos_set_config(config1); //configure the parameter - - SGlobalCfg *cfg1 ; - cfg1 = taosGetConfigOption("firstEp");//check the option result - if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config firstEp 'BCC-2:6030'success!\n"); - else - printf("config firstEp failure!\n"); - SGlobalCfg *cfg2 ; - cfg2 = taosGetConfigOption("debugFlag");//check the option result - if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config debugFlag '135'success!\n"); - else - printf("config debugFlag failure!\n"); - - - //case2: - //repair the JSON and try again - //The result is success - const char config2[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\"135\"}";//input the parameter which want to be configured - taos_set_config(config2); //configure the parameter - - SGlobalCfg *cfg3 ; - - cfg3 = taosGetConfigOption("firstEp");//check the option result - if(cfg3->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config firstEp 'BCC-2:6030'success!\n"); - else - printf("config firstEp failure!\n"); - - SGlobalCfg *cfg4 ; - - cfg4 = taosGetConfigOption("debugFlag");//check the option result - if(cfg4->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config debugFlag '135'success!\n"); - else - printf("config debugFlag failure!\n"); - return 0 ; - -} diff --git a/tests/examples/c/clientcfgtest-wrongtype.c b/tests/examples/c/clientcfgtest-wrongtype.c deleted file mode 100644 index d88cbeebe8e5114ed4836e77b9494de1cc54aba8..0000000000000000000000000000000000000000 --- a/tests/examples/c/clientcfgtest-wrongtype.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include -#include -#include -#include "os.h" -#include "taosdef.h" -#include "taoserror.h" -#include "tconfig.h" -#include "tglobal.h" -#include "tulog.h" -#include "tsocket.h" -#include "tutil.h" -extern SGlobalCfg *taosGetConfigOption(const char *option) ; -int main( int argc, char *argv[]){ - - printf("start to test\n"); - - //case1: - //Test config to wrong type - //The result is failure - const char config1[128] = "{\"debugFlag\":\"9999999999999999999999999\"}";//input the parameter which want to be configured - taos_set_config(config1); //configure the parameter - - SGlobalCfg *cfg1 ; - - cfg1 = taosGetConfigOption("debugFlag");//check the option result - if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config debugFlag '9999999999999999999999999\n"); - else - printf("config debugFlag failure!\n"); - - //case2: - //Try again with right parameter - //The result is failure - const char config2[128] = "{\"debugFlag\":\"135\"}";//input the parameter which want to be configured - taos_set_config(config2); //configure the parameter - - SGlobalCfg *cfg2 ; - - cfg2 = taosGetConfigOption("debugFlag");//check the option result - if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config debugflag '135'success!\n"); - else - printf("config debugflag failure!\n"); - return 0 ; - -} diff --git a/tests/examples/c/clientcfgtest-wrongvalue.c b/tests/examples/c/clientcfgtest-wrongvalue.c deleted file mode 100644 index f0d44a47f62696d14844ea12276b74da7d0ff408..0000000000000000000000000000000000000000 --- a/tests/examples/c/clientcfgtest-wrongvalue.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include -#include -#include "os.h" -#include "taosdef.h" -#include "taoserror.h" -#include "tconfig.h" -#include "tglobal.h" -#include "tulog.h" -#include "tsocket.h" -#include "tutil.h" -extern SGlobalCfg *taosGetConfigOption(const char *option) ; -int main( int argc, char *argv[]){ - - printf("start to test\n"); - - //case1: - //Test config to wrong type - const char config1[128] = "{\"rpcTimer\":\"0\"}";//input the parameter which want to be configured - taos_set_config(config1); //configure the parameter - - SGlobalCfg *cfg1 ; - - cfg1 = taosGetConfigOption("rpcTimer");//check the option result - if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config rpcTimer to '0'success!\n"); - else - printf("config rpcTimer failure!\n"); - - //case2: - //Try again with right parameter - const char config2[128] = "{\"rpcTimer\":\"400\"}";//input the parameter which want to be configured - taos_set_config(config2); //configure the parameter - - SGlobalCfg *cfg2 ; - - cfg2 = taosGetConfigOption("rpcTimer");//check the option result - if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config rpcTimer '400'success!\n"); - else - printf("config rpcTimer failure!\n"); - return 0 ; - -} diff --git a/tests/examples/c/clientcfgtest.c b/tests/examples/c/clientcfgtest.c deleted file mode 100644 index 5f8f51cdb1156a25544273fc6419f65b86ea4ecc..0000000000000000000000000000000000000000 --- a/tests/examples/c/clientcfgtest.c +++ /dev/null @@ -1,55 +0,0 @@ -#include -#include -#include -#include -#include -#include "os.h" -#include "taosdef.h" -#include "taoserror.h" -#include "tconfig.h" -#include "tglobal.h" -#include "tulog.h" -#include "tsocket.h" -#include "tutil.h" -extern SGlobalCfg *taosGetConfigOption(const char *option) ; -int main( int argc, char *argv[]){ - - printf("start to test\n"); - - //case1: - //Test config firstEp success - const char config1[128] = "{\"firstEp\":\"BCC-2:6030\",\"debugFlag\":\"135\"}";//input the parameter which want to be configured - taos_set_config(config1); //configure the parameter - - SGlobalCfg *cfg1 ; - - cfg1 = taosGetConfigOption("firstEp");//check the option result - if(cfg1->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config firstEp 'BCC-2:6030'success!\n"); - else - printf("config firstEp failure!\n"); - - - SGlobalCfg *cfg2 ; - - cfg2 = taosGetConfigOption("debugFlag");//check the option result - if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config debugFlag '135' success!\n"); - else - printf("config debugFlag failure!\n"); - //case2: - //Test config only useful at the first time - //The result is failure - const char config2[128] = "{\"fqdn\":\"BCC-3\"}";//input the parameter which want to be configured - taos_set_config(config2); //configure the parameter - - SGlobalCfg *cfg3 ; - - cfg2 = taosGetConfigOption("fqdn");//check the option result - if(cfg2->cfgStatus == 3) //If cfgStatus is 3,it means configure is success - printf("config fqdn to 'BCC-3'success!\n"); - else - printf("config fqdn failure!\n"); - return 0 ; - -} diff --git a/tests/examples/c/connect_two_cluster.c b/tests/examples/c/connect_two_cluster.c deleted file mode 100644 index fa54dd437036f12915d62a60f96b90e6a7adc45f..0000000000000000000000000000000000000000 --- a/tests/examples/c/connect_two_cluster.c +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include -#include -#include -#include "taos.h" -int numOfThreads = 1; - -void* connectClusterAndDeal(void *arg) { - int port = *(int *)arg; - const char *host = "127.0.0.1"; - const char *user = "root"; - const char *passwd = "taosdata"; - TAOS* taos1 = taos_connect(host, user, passwd, "", port); - TAOS* taos2 = taos_connect(host, user, passwd, "", port + 1000); - if (NULL == taos1 || NULL == taos2) { - printf("connect to (%d/%d) failed \n", port, port + 1000); - return NULL; - } - TAOS_RES *result = NULL; - result = taos_query(taos1, "drop database if exists db"); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - taos_free_result(result); - - taos_query(taos2, "drop database if exists db"); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - - taos_free_result(result); - // ========= build database - { - result = taos_query(taos1, "create database db"); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - - taos_free_result(result); - } - { - result = taos_query(taos2, "create database db"); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - taos_free_result(result); - } - - //======== create table - { - result = taos_query(taos1, "create stable db.stest (ts timestamp, port int) tags(tport int)"); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - taos_free_result(result); - } - { - result = taos_query(taos2, "create stable db.stest (ts timestamp, port int) tags(tport int)"); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - taos_free_result(result); - - } - //======== create table - { - result = taos_query(taos1, "use db"); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - taos_free_result(result); - } - { - result = taos_query(taos2, "use db"); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - taos_free_result(result); - - } - { - char buf[1024] = {0}; - sprintf(buf, "insert into db.t1 using stest tags(%d) values(now, %d)", port, port); - for (int i = 0; i < 100000; i++) { - //printf("error here\t"); - result = taos_query(taos1, buf); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - taos_free_result(result); - //sleep(1); - } - } - - { - char buf[1024] = {0}; - sprintf(buf, "insert into db.t1 using stest tags(%d) values(now, %d)", port + 1000, port + 1000); - for (int i = 0; i < 100000; i++) { - result = taos_query(taos2, buf); - if (0 != taos_errno(result)) { - printf("failed %s\n", taos_errstr(result)); - } - taos_free_result(result); - //sleep(1); - } - } - // query result - { - result = taos_query(taos1, "select * from stest"); - if (result == NULL || taos_errno(result) != 0) { - printf("query failed %s\n", taos_errstr(result)); - taos_free_result(result); - } - TAOS_ROW row; - int rows = 0; - int num_fields = taos_field_count(result); - TAOS_FIELD *fields = taos_fetch_fields(result); - while ((row = taos_fetch_row(result))) { - char temp[1024] = {0}; - rows++; - taos_print_row(temp, row, fields , num_fields); - printf("%s\n", temp); - } - taos_free_result(result); - } - - // query result - { - result = taos_query(taos2, "select * from stest"); - if (result == NULL || taos_errno(result) != 0) { - printf("query failed %s\n", taos_errstr(result)); - taos_free_result(result); - } - TAOS_ROW row; - int rows = 0; - int num_fields = taos_field_count(result); - TAOS_FIELD *fields = taos_fetch_fields(result); - while ((row = taos_fetch_row(result))) { - char temp[1024] = {0}; - rows++; - taos_print_row(temp, row, fields , num_fields); - printf("%s\n", temp); - } - taos_free_result(result); - } - taos_close(taos1); - taos_close(taos2); - return NULL; -} -int main(int argc, char* argv[]) { - pthread_t *pthreads = malloc(sizeof(pthread_t) * numOfThreads); - - int *port = malloc(sizeof(int) * numOfThreads); - port[0] = 6030; - for (int i = 0; i < numOfThreads; i++) { - pthread_create(&pthreads[i], NULL, connectClusterAndDeal, (void *)&port[i]); - } - for (int i = 0; i < numOfThreads; i++) { - pthread_join(pthreads[i], NULL); - } - free(port); -} diff --git a/tests/examples/c/demo.c b/tests/examples/c/demo.c deleted file mode 100644 index 55d962888871c2ba175daef85f1084a1e28a0da1..0000000000000000000000000000000000000000 --- a/tests/examples/c/demo.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -// TAOS standard API example. The same syntax as MySQL, but only a subset -// to compile: gcc -o demo demo.c -ltaos - -#include -#include -#include -#include -#include // TAOS header file - -static void queryDB(TAOS *taos, char *command) { - int i; - TAOS_RES *pSql = NULL; - int32_t code = -1; - - for (i = 0; i < 5; i++) { - if (NULL != pSql) { - taos_free_result(pSql); - pSql = NULL; - } - - pSql = taos_query(taos, command); - code = taos_errno(pSql); - if (0 == code) { - break; - } - } - - if (code != 0) { - fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql)); - taos_free_result(pSql); - taos_close(taos); - exit(EXIT_FAILURE); - } - - taos_free_result(pSql); -} - -void Test(TAOS *taos, char *qstr, int i); - -int main(int argc, char *argv[]) { - char qstr[1024]; - - // connect to server - if (argc < 2) { - printf("please input server-ip \n"); - return 0; - } - - TAOS *taos = taos_connect(argv[1], "root", "taosdata", NULL, 0); - if (taos == NULL) { - printf("failed to connect to server, reason:%s\n", "null taos" /*taos_errstr(taos)*/); - exit(1); - } - for (int i = 0; i < 100; i++) { - Test(taos, qstr, i); - } - taos_close(taos); - taos_cleanup(); -} -void Test(TAOS *taos, char *qstr, int index) { - printf("==================test at %d\n================================", index); - queryDB(taos, "drop database if exists demo"); - queryDB(taos, "create database demo"); - TAOS_RES *result; - queryDB(taos, "use demo"); - - queryDB(taos, - "create table m1 (ts timestamp, ti tinyint, si smallint, i int, bi bigint, f float, d double, b binary(10))"); - printf("success to create table\n"); - - int i = 0; - for (i = 0; i < 10; ++i) { - sprintf(qstr, "insert into m1 values (%" PRId64 ", %d, %d, %d, %d, %f, %lf, '%s')", - (uint64_t)(1546300800000 + i * 1000), i, i, i, i * 10000000, i * 1.0, i * 2.0, "hello"); - printf("qstr: %s\n", qstr); - - // note: how do you wanna do if taos_query returns non-NULL - // if (taos_query(taos, qstr)) { - // printf("insert row: %i, reason:%s\n", i, taos_errstr(taos)); - // } - TAOS_RES *result1 = taos_query(taos, qstr); - if (result1 == NULL || taos_errno(result1) != 0) { - printf("failed to insert row, reason:%s\n", taos_errstr(result1)); - taos_free_result(result1); - exit(1); - } else { - printf("insert row: %i\n", i); - } - taos_free_result(result1); - } - printf("success to insert rows, total %d rows\n", i); - - // query the records - sprintf(qstr, "SELECT * FROM m1"); - result = taos_query(taos, qstr); - if (result == NULL || taos_errno(result) != 0) { - printf("failed to select, reason:%s\n", taos_errstr(result)); - taos_free_result(result); - exit(1); - } - - TAOS_ROW row; - int rows = 0; - int num_fields = taos_field_count(result); - TAOS_FIELD *fields = taos_fetch_fields(result); - - printf("num_fields = %d\n", num_fields); - printf("select * from table, result:\n"); - // fetch the records row by row - while ((row = taos_fetch_row(result))) { - char temp[1024] = {0}; - rows++; - taos_print_row(temp, row, fields, num_fields); - printf("%s\n", temp); - } - - taos_free_result(result); - printf("====demo end====\n\n"); -} diff --git a/tests/examples/c/epoll.c b/tests/examples/c/epoll.c deleted file mode 100644 index 05df33ffe6f0c08dd5608bb3ba30a21623f2ae45..0000000000000000000000000000000000000000 --- a/tests/examples/c/epoll.c +++ /dev/null @@ -1,301 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -// how to use to do a pressure-test upon eok -// tester: cat /dev/urandom | nc -c -// testee: ./debug/build/bin/epoll -l > /dev/null -// compare against: nc -l > /dev/null -// monitor and compare : glances - -#ifdef __APPLE__ -#include "osEok.h" -#else // __APPLE__ -#include -#endif // __APPLE__ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define D(fmt, ...) fprintf(stderr, "%s[%d]%s(): " fmt "\n", basename(__FILE__), __LINE__, __func__, ##__VA_ARGS__) -#define A(statement, fmt, ...) \ - do { \ - if (statement) break; \ - fprintf(stderr, "%s[%d]%s(): assert [%s] failed: %d[%s]: " fmt "\n", basename(__FILE__), __LINE__, __func__, \ - #statement, errno, strerror(errno), ##__VA_ARGS__); \ - abort(); \ - } while (0) - -#define E(fmt, ...) \ - do { \ - fprintf(stderr, "%s[%d]%s(): %d[%s]: " fmt "\n", basename(__FILE__), __LINE__, __func__, errno, strerror(errno), \ - ##__VA_ARGS__); \ - } while (0) - -#include "os.h" - -typedef struct ep_s ep_t; -struct ep_s { - int ep; - - pthread_mutex_t lock; - int sv[2]; // 0 for read, 1 for write; - pthread_t thread; - - volatile unsigned int stopping : 1; - volatile unsigned int waiting : 1; - volatile unsigned int wakenup : 1; -}; - -static int ep_dummy = 0; - -static ep_t *ep_create(void); -static void ep_destroy(ep_t *ep); -static void *routine(void *arg); -static int open_listen(unsigned short port); - -typedef struct fde_s fde_t; -struct fde_s { - int skt; - void (*on_event)(ep_t *ep, struct epoll_event *events, fde_t *client); -}; - -static void listen_event(ep_t *ep, struct epoll_event *ev, fde_t *client); -static void null_event(ep_t *ep, struct epoll_event *ev, fde_t *client); - -#define usage(arg0, fmt, ...) \ - do { \ - if (fmt[0]) { \ - fprintf(stderr, "" fmt "\n", ##__VA_ARGS__); \ - } \ - fprintf(stderr, "usage:\n"); \ - fprintf(stderr, " %s -l : specify listening port\n", arg0); \ - } while (0) - -int main(int argc, char *argv[]) { - char *prg = basename(argv[0]); - if (argc == 1) { - usage(prg, ""); - return 0; - } - ep_t *ep = ep_create(); - A(ep, "failed"); - for (int i = 1; i < argc; ++i) { - const char *arg = argv[i]; - if (0 == strcmp(arg, "-l")) { - ++i; - if (i >= argc) { - usage(prg, "expecting after -l, but got nothing"); - return 1; // confirmed potential leakage - } - arg = argv[i]; - int port = atoi(arg); - int skt = open_listen(port); - if (skt == -1) continue; - fde_t *client = (fde_t *)calloc(1, sizeof(*client)); - if (!client) { - E("out of memory"); - close(skt); - continue; - } - client->skt = skt; - client->on_event = listen_event; - struct epoll_event ev = {0}; - ev.events = EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLRDHUP; - ev.data.ptr = client; - A(0 == epoll_ctl(ep->ep, EPOLL_CTL_ADD, skt, &ev), ""); - continue; - } - usage(prg, "unknown argument: [%s]", arg); - return 1; - } - char * line = NULL; - size_t linecap = 0; - ssize_t linelen; - while ((linelen = getline(&line, &linecap, stdin)) > 0) { - line[strlen(line) - 1] = '\0'; - if (0 == strcmp(line, "exit")) break; - if (0 == strcmp(line, "quit")) break; - if (line == strstr(line, "close")) { - int fd = 0; - sscanf(line, "close %d", &fd); - if (fd <= 2) { - fprintf(stderr, "fd [%d] invalid\n", fd); - continue; - } - A(0 == epoll_ctl(ep->ep, EPOLL_CTL_DEL, fd, NULL), ""); - continue; - } - if (strlen(line) == 0) continue; - fprintf(stderr, "unknown cmd:[%s]\n", line); - } - ep_destroy(ep); - D(""); - return 0; -} - -ep_t *ep_create(void) { - ep_t *ep = (ep_t *)calloc(1, sizeof(*ep)); - A(ep, "out of memory"); - A(-1 != (ep->ep = epoll_create(1)), ""); - ep->sv[0] = -1; - ep->sv[1] = -1; - A(0 == socketpair(AF_LOCAL, SOCK_STREAM, 0, ep->sv), ""); - A(0 == pthread_mutex_init(&ep->lock, NULL), ""); - A(0 == pthread_mutex_lock(&ep->lock), ""); - struct epoll_event ev = {0}; - ev.events = EPOLLIN; - ev.data.ptr = &ep_dummy; - A(0 == epoll_ctl(ep->ep, EPOLL_CTL_ADD, ep->sv[0], &ev), ""); - A(0 == pthread_create(&ep->thread, NULL, routine, ep), ""); - A(0 == pthread_mutex_unlock(&ep->lock), ""); - return ep; -} - -static void ep_destroy(ep_t *ep) { - A(ep, "invalid argument"); - ep->stopping = 1; - A(1 == send(ep->sv[1], "1", 1, 0), ""); - A(0 == pthread_join(ep->thread, NULL), ""); - A(0 == pthread_mutex_destroy(&ep->lock), ""); - A(0 == close(ep->sv[0]), ""); - A(0 == close(ep->sv[1]), ""); - A(0 == close(ep->ep), ""); - free(ep); -} - -static void *routine(void *arg) { - A(arg, "invalid argument"); - ep_t *ep = (ep_t *)arg; - - while (!ep->stopping) { - struct epoll_event evs[10]; - memset(evs, 0, sizeof(evs)); - - A(0 == pthread_mutex_lock(&ep->lock), ""); - A(ep->waiting == 0, "internal logic error"); - ep->waiting = 1; - A(0 == pthread_mutex_unlock(&ep->lock), ""); - - int r = epoll_wait(ep->ep, evs, sizeof(evs) / sizeof(evs[0]), -1); - A(r > 0, "indefinite epoll_wait shall not timeout:[%d]", r); - - A(0 == pthread_mutex_lock(&ep->lock), ""); - A(ep->waiting == 1, "internal logic error"); - ep->waiting = 0; - A(0 == pthread_mutex_unlock(&ep->lock), ""); - - for (int i = 0; i < r; ++i) { - struct epoll_event *ev = evs + i; - if (ev->data.ptr == &ep_dummy) { - char c = '\0'; - A(1 == recv(ep->sv[0], &c, 1, 0), "internal logic error"); - A(0 == pthread_mutex_lock(&ep->lock), ""); - ep->wakenup = 0; - A(0 == pthread_mutex_unlock(&ep->lock), ""); - continue; - } - A(ev->data.ptr, "internal logic error"); - fde_t *client = (fde_t *)ev->data.ptr; - client->on_event(ep, ev, client); - continue; - } - } - return NULL; -} - -static int open_listen(unsigned short port) { - int r = 0; - int skt = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (skt == -1) { - E("socket() failed"); - return -1; - } - do { - struct sockaddr_in si = {0}; - si.sin_family = AF_INET; - si.sin_addr.s_addr = inet_addr("0.0.0.0"); - si.sin_port = htons(port); - r = bind(skt, (struct sockaddr *)&si, sizeof(si)); - if (r) { - E("bind(%u) failed", port); - break; - } - r = listen(skt, 100); - if (r) { - E("listen() failed"); - break; - } - memset(&si, 0, sizeof(si)); - socklen_t len = sizeof(si); - r = getsockname(skt, (struct sockaddr *)&si, &len); - if (r) { - E("getsockname() failed"); - } - A(len == sizeof(si), "internal logic error"); - D("listening at: %d", ntohs(si.sin_port)); - return skt; - } while (0); - close(skt); - return -1; -} - -static void listen_event(ep_t *ep, struct epoll_event *ev, fde_t *client) { - A(ev->events & EPOLLIN, "internal logic error"); - struct sockaddr_in si = {0}; - socklen_t silen = sizeof(si); - int skt = accept(client->skt, (struct sockaddr *)&si, &silen); - A(skt != -1, "internal logic error"); - fde_t *server = (fde_t *)calloc(1, sizeof(*server)); - if (!server) { - close(skt); - return; - } - server->skt = skt; - server->on_event = null_event; - struct epoll_event ee = {0}; - ee.events = EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLRDHUP; - ee.data.ptr = server; - A(0 == epoll_ctl(ep->ep, EPOLL_CTL_ADD, skt, &ee), ""); -} - -static void null_event(ep_t *ep, struct epoll_event *ev, fde_t *client) { - if (ev->events & EPOLLIN) { - char buf[8192]; - int n = recv(client->skt, buf, sizeof(buf), 0); - A(n >= 0 && n <= sizeof(buf), "internal logic error:[%d]", n); - A(n == fwrite(buf, 1, n, stdout), "internal logic error"); - } - if (ev->events & (EPOLLERR | EPOLLHUP | EPOLLRDHUP)) { - A(0 == pthread_mutex_lock(&ep->lock), ""); - A(0 == epoll_ctl(ep->ep, EPOLL_CTL_DEL, client->skt, NULL), ""); - A(0 == pthread_mutex_unlock(&ep->lock), ""); - close(client->skt); - client->skt = -1; - client->on_event = NULL; - free(client); - } -} diff --git a/tests/examples/c/makefile b/tests/examples/c/makefile deleted file mode 100644 index 355d1a2d54c1293e909309dafe986daa716ac293..0000000000000000000000000000000000000000 --- a/tests/examples/c/makefile +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2017 by TAOS Technologies, Inc. -# todo: library dependency, header file dependency - -ROOT=./ -TARGET=exe -LFLAGS = '-Wl,-rpath,/usr/local/taos/driver/' -ltaos -lpthread -lm -lrt -CFLAGS = -O3 -g -Wall -Wno-deprecated -fPIC -Wno-unused-result -Wconversion \ - -Wno-char-subscripts -D_REENTRANT -Wno-format -D_REENTRANT -DLINUX \ - -Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \ - -I../../../deps/cJson/inc \ - -Wno-unused-function -D_M_X64 -I/usr/local/taos/include -std=gnu99 \ - -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment - -all: $(TARGET) - -exe: - gcc $(CFLAGS) ./asyncdemo.c -o $(ROOT)asyncdemo $(LFLAGS) - gcc $(CFLAGS) ./demo.c -o $(ROOT)demo $(LFLAGS) - gcc $(CFLAGS) ./prepare.c -o $(ROOT)prepare $(LFLAGS) - gcc $(CFLAGS) ./stream.c -o $(ROOT)stream $(LFLAGS) - gcc $(CFLAGS) ./subscribe.c -o $(ROOT)subscribe $(LFLAGS) - gcc $(CFLAGS) ./apitest.c -o $(ROOT)apitest $(LFLAGS) - -clean: - rm $(ROOT)asyncdemo - rm $(ROOT)demo - rm $(ROOT)prepare - rm $(ROOT)stream - rm $(ROOT)subscribe - rm $(ROOT)apitest diff --git a/tests/examples/c/parameter-binding.c b/tests/examples/c/parameter-binding.c deleted file mode 100644 index 6034c66cbf21b1e3ae819d3f40ec032118a5b01c..0000000000000000000000000000000000000000 --- a/tests/examples/c/parameter-binding.c +++ /dev/null @@ -1,607 +0,0 @@ -#include -#include -#include -#include -#include - -bool isPrint = true; - -void one_batch_one_table_1(TAOS *conn, long totalRows, long batchRows); -void one_batch_one_table_2(TAOS *conn, long totalRows, long batchRows); -void one_batch_one_table_3(TAOS *conn, long totalRows, long batchRows); -void one_batch_one_table_4(TAOS *conn, long totalRows, long batchRows); -void one_batch_one_table_5(TAOS *conn, long totalRows, long batchRows); -void one_batch_one_table_6(TAOS *conn, long totalRows, long batchRows); -void one_batch_one_table_7(TAOS *conn, long totalRows, long batchRows); - -void one_batch_multi_table_1(TAOS *conn, long totalRows, long batchRows, int tables); -void one_batch_multi_table_2(TAOS *conn, long totalRows, long batchRows, int tables); -void one_batch_multi_table_3(TAOS *conn, long totalRows, long batchRows, int tables); - -void execute(TAOS *conn, char *sql); -void prepare_normal_table(TAOS *conn); -void prepare_super_and_sub_table(TAOS *conn, int subTables); -void prepare_super_table(TAOS *conn, int subTables); -int64_t getCurrentTimeMill(); - -TAOS_STMT *A(TAOS *); -void B(TAOS_STMT *stmt, char sql[]); -void C(TAOS_STMT *stmt, char sql[]); -void D(TAOS_STMT *stmt, char sql[], int tag); -void E(TAOS_STMT *stmt); -void F(TAOS_STMT *stmt, int64_t ts_start); -void G1(TAOS_STMT *stmt, int64_t ts_start, int rows); -void G2(TAOS_STMT *stmt, int rows); -void H(TAOS_STMT *stmt, int64_t ts_start, int rows); -void I(TAOS_STMT *stmt); -void J(TAOS_STMT *stmt); -void L(TAOS_STMT *stmt); - -int main() { - char host[] = "192.168.56.105"; - srand(time(NULL)); - - // connect - TAOS *conn = taos_connect(host, "root", "taosdata", NULL, 0); - if (conn == NULL) { - printf("failed to connect to:%s, reason:%s\n", host, "null taos"); - exit(-1); - } - execute(conn, "drop database if exists test"); - execute(conn, "create database if not exists test"); - execute(conn, "use test"); - - long totalRows = 1000000; - long batchRows = 32767; - int tables = 10; - - prepare_super_table(conn, 1); - // A -> B -> D -> [F -> I]... -> J -> L - // one_batch_one_table_1(conn, totalRows, batchRows); - // A -> B -> [D -> [F -> I]... -> J]... -> L - // one_batch_one_table_2(conn, totalRows, batchRows); - // A -> B -> D -> [F... -> I -> J]... -> L - // one_batch_one_table_3(conn, totalRows, batchRows); - // A -> B -> D -> [H -> I -> J]... -> L - // one_batch_one_table_4(conn, totalRows, batchRows); - // A -> B -> [D -> H -> I -> J]... -> L - // one_batch_one_table_5(conn, totalRows, batchRows); - // A -> B -> [D -> H -> I -> J]... -> L - // one_batch_one_table_6(conn, totalRows, batchRows); - // A -> B -> [D -> H -> I -> J]... -> L - // one_batch_one_table_7(conn, totalRows, batchRows); - - // A -> B -> [D -> [F -> I]... -> J]... -> L - // one_batch_multi_table_1(conn, totalRows, batchRows, tables); - // A -> B -> [D -> H -> I -> J]... -> L - // one_batch_multi_table_2(conn, totalRows, batchRows, tables); - // A -> B -> [D -> G1 -> G2 -> I -> J]... -> L - one_batch_multi_table_3(conn, totalRows, batchRows, tables); - - // close - taos_close(conn); - taos_cleanup(); - exit(0); -} - -// A -> B -> D -> [F -> I]... -> J -> L -void one_batch_one_table_1(TAOS *conn, long totalRows, long batchRows) { - // given - time_t current; - time(¤t); - current -= totalRows; - - int64_t start = getCurrentTimeMill(); - - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) (ts, f1) values(?, ?)"); - D(stmt, "t1", 1); - for (int i = 1; i <= totalRows; ++i) { - F(stmt, (current + i - 1) * 1000); - I(stmt); - if (i % batchRows == 0 || i == totalRows) { - J(stmt); - } - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, time cost: %lld ms\n", totalRows, batchRows, (end - start)); -} - -// A -> B -> D -> [F -> I]... -> J -> L -void one_batch_one_table_2(TAOS *conn, long totalRows, long batchRows) { - // given - time_t current; - time(¤t); - current -= totalRows; - - int64_t start = getCurrentTimeMill(); - - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) (ts, f1) values(?, ?)"); - for (int i = 1; i <= totalRows; ++i) { - if (i % batchRows == 1) { - D(stmt, "t1", 1); - } - - F(stmt, (current + i - 1) * 1000); - I(stmt); - if (i % batchRows == 0 || i == totalRows) { - J(stmt); - } - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, time cost: %lld ms\n", totalRows, batchRows, (end - start)); -} - -void one_batch_one_table_3(TAOS *conn, long totalRows, long batchRows) { - // given - time_t current; - time(¤t); - current -= totalRows; - - int64_t start = getCurrentTimeMill(); - - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) (ts, f1) values(?, ?)"); - D(stmt, "t1", 1); - for (int i = 1; i <= totalRows; ++i) { - F(stmt, (current + i - 1) * 1000); - if (i % batchRows == 0 || i == totalRows) { - I(stmt); - J(stmt); - } - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, time cost: %lld ms\n", totalRows, batchRows, (end - start)); -} - -void one_batch_one_table_4(TAOS *conn, long totalRows, long batchRows) { - // given - time_t current; - time(¤t); - current -= totalRows; - - int64_t start = getCurrentTimeMill(); - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) values(?,?)"); - D(stmt, "t1", 1); - for (int i = 1; i <= totalRows; i += batchRows) { - int rows = (i + batchRows) > totalRows ? (totalRows + 1 - i) : batchRows; - H(stmt, (current + i) * 1000, rows); - I(stmt); - J(stmt); - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, time cost: %lld ms\n", totalRows, batchRows, (end - start)); -} - -void one_batch_one_table_5(TAOS *conn, long totalRows, long batchRows) { - // given - time_t current; - time(¤t); - current -= totalRows; - - int64_t start = getCurrentTimeMill(); - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) values(?,?)"); - for (int i = 1; i <= totalRows; i += batchRows) { - D(stmt, "t1", 1); - int rows = (i + batchRows) > totalRows ? (totalRows + 1 - i) : batchRows; - H(stmt, (current + i) * 1000, rows); - I(stmt); - J(stmt); - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, time cost: %lld ms\n", totalRows, batchRows, (end - start)); -} - -void one_batch_one_table_6(TAOS *conn, long totalRows, long batchRows) { - // given - time_t current; - time(¤t); - current -= totalRows; - - int64_t start = getCurrentTimeMill(); - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) values(?,?)"); - D(stmt, "t1", 1); - for (int i = 1; i <= totalRows; i += batchRows) { - int rows = (i + batchRows) > totalRows ? (totalRows + 1 - i) : batchRows; - G1(stmt, (current + i) * 1000, rows); - G2(stmt, rows); - I(stmt); - J(stmt); - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, time cost: %lld ms\n", totalRows, batchRows, (end - start)); -} - -void one_batch_one_table_7(TAOS *conn, long totalRows, long batchRows) { - // given - time_t current; - time(¤t); - current -= totalRows; - - int64_t start = getCurrentTimeMill(); - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) values(?,?)"); - for (int i = 1; i <= totalRows; i += batchRows) { - if (i % batchRows == 1) { - D(stmt, "t1", 1); - } - int rows = (i + batchRows) > totalRows ? (totalRows + 1 - i) : batchRows; - G1(stmt, (current + i) * 1000, rows); - G2(stmt, rows); - I(stmt); - J(stmt); - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, time cost: %lld ms\n", totalRows, batchRows, (end - start)); -} - -void one_batch_multi_table_1(TAOS *conn, long totalRows, long batchRows, int tables) { - // given - time_t current; - time(¤t); - long eachTable = (totalRows - 1) / tables + 1; - current -= eachTable; - - int64_t start = getCurrentTimeMill(); - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) values(?, ?)"); - - for (int tbIndex = 0; tbIndex < tables; ++tbIndex) { - char tbname[10]; - sprintf(tbname, "t%d", tbIndex); - - eachTable = ((tbIndex + 1) * eachTable > totalRows) ? (totalRows - tbIndex * eachTable) : eachTable; - for (int rowIndex = 1; rowIndex <= eachTable; ++rowIndex) { - if (rowIndex % batchRows == 1) { - D(stmt, tbname, tbIndex); - if (isPrint) - printf("\ntbIndex: %d, table_rows: %ld, rowIndex: %d, batch_rows: %ld\n", tbIndex, eachTable, rowIndex, - batchRows); - } - F(stmt, (current + rowIndex - 1) * 1000); - I(stmt); - if (rowIndex % batchRows == 0 || rowIndex == eachTable) { - J(stmt); - } - } - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, table: %d, eachTableRows: %ld, time cost: %lld ms\n", totalRows, batchRows, - tables, eachTable, (end - start)); -} - -void one_batch_multi_table_2(TAOS *conn, long totalRows, long batchRows, int tables) { - // given - time_t current; - time(¤t); - long eachTable = (totalRows - 1) / tables + 1; - current -= eachTable; - - int64_t start = getCurrentTimeMill(); - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) values(?,?)"); - for (int tbIndex = 0; tbIndex < tables; ++tbIndex) { - char tbname[10]; - sprintf(tbname, "t%d", tbIndex); - - eachTable = ((tbIndex + 1) * eachTable > totalRows) ? (totalRows - tbIndex * eachTable) : eachTable; - for (int rowIndex = 1; rowIndex <= eachTable; rowIndex += batchRows) { - int rows = (rowIndex + batchRows) > eachTable ? (eachTable + 1 - rowIndex) : batchRows; - - if (rowIndex % batchRows == 1) { - D(stmt, tbname, tbIndex); - if (isPrint) - printf("\ntbIndex: %d, table_rows: %ld, rowIndex: %d, batch_rows: %d\n", tbIndex, eachTable, rowIndex, rows); - } - - H(stmt, (current + rowIndex) * 1000, rows); - I(stmt); - J(stmt); - } - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, table: %d, eachTableRows: %ld, time cost: %lld ms\n", totalRows, batchRows, - tables, eachTable, (end - start)); -} - -void one_batch_multi_table_3(TAOS *conn, long totalRows, long batchRows, int tables) { - // given - time_t current; - time(¤t); - long eachTable = (totalRows - 1) / tables + 1; - current -= eachTable; - - int64_t start = getCurrentTimeMill(); - // when - TAOS_STMT *stmt = A(conn); - B(stmt, "insert into ? using weather tags(?) values(?, ?)"); - for (int tbIndex = 0; tbIndex < tables; ++tbIndex) { - char tbname[10]; - sprintf(tbname, "t%d", tbIndex); - - eachTable = ((tbIndex + 1) * eachTable > totalRows) ? (totalRows - tbIndex * eachTable) : eachTable; - for (int rowIndex = 1; rowIndex <= eachTable; rowIndex += batchRows) { - int rows = (rowIndex + batchRows) > eachTable ? (eachTable + 1 - rowIndex) : batchRows; - - if (rowIndex % batchRows == 1) { - D(stmt, tbname, tbIndex); - if (isPrint) - printf("\ntbIndex: %d, table_rows: %ld, rowIndex: %d, batch_rows: %d\n", tbIndex, eachTable, rowIndex, rows); - } - G1(stmt, (current + rowIndex) * 1000, rows); - G2(stmt, rows); - I(stmt); - J(stmt); - } - } - L(stmt); - - int64_t end = getCurrentTimeMill(); - printf("totalRows: %ld, batchRows: %ld, table: %d, eachTableRows: %ld, time cost: %lld ms\n", totalRows, batchRows, - tables, eachTable, (end - start)); -} - -void execute(TAOS *conn, char *sql) { - TAOS_RES *psql = taos_query(conn, sql); - if (psql == NULL) { - printf("failed to execute: %s, reason: %s\n", sql, taos_errstr(psql)); - taos_free_result(psql); - taos_close(conn); - exit(-1); - } - taos_free_result(psql); -} - -TAOS_STMT *A(TAOS *conn) { - if (isPrint) printf("A -> "); - return taos_stmt_init(conn); -} - -void B(TAOS_STMT *stmt, char sql[]) { - if (isPrint) printf("B -> "); - - int code = taos_stmt_prepare(stmt, sql, 0); - if (code != 0) { - printf("failed to prepare stmt: %s, reason: %s\n", sql, taos_stmt_errstr(stmt)); - return; - } -} - -void C(TAOS_STMT *stmt, char tbname[]) { - if (isPrint) printf("C -> "); - - int code = taos_stmt_set_tbname(stmt, tbname); - if (code != 0) printf("failed to set_tbname_tags, reason: %s\n", taos_stmt_errstr(stmt)); -} - -void D(TAOS_STMT *stmt, char tbname[], int tag) { - if (isPrint) printf("D -> "); - - TAOS_BIND tags[1]; - tags[0].buffer_type = TSDB_DATA_TYPE_INT; - int tag_value = tag >= 0 ? tag : rand() % 100; - tags[0].buffer = &tag_value; - tags[0].buffer_length = sizeof(tag_value); - tags[0].length = &tags[0].buffer_length; - tags[0].is_null = NULL; - // set_tbname_tags - int code = taos_stmt_set_tbname_tags(stmt, tbname, tags); - if (code != 0) printf("failed to set_tbname_tags, reason: %s\n", taos_stmt_errstr(stmt)); -} - -void E(TAOS_STMT *stmt) { - // TODO -} - -void F(TAOS_STMT *stmt, int64_t ts) { - if (isPrint) printf("F -> "); - - TAOS_BIND params[2]; - // timestamp - params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; - params[0].buffer = &ts; - params[0].buffer_length = sizeof(ts); - params[0].length = ¶ms[0].buffer_length; - params[0].is_null = NULL; - // int - int value = rand() % 100; - params[1].buffer_type = TSDB_DATA_TYPE_INT; - params[1].buffer = &value; - params[1].buffer_length = sizeof(value); - params[1].length = ¶ms[1].buffer_length; - params[1].is_null = NULL; - - // bind - int code = taos_stmt_bind_param(stmt, params); - if (0 != code) printf("failed to bind_param, reason: %s\n", taos_stmt_errstr(stmt)); -} - -void H(TAOS_STMT *stmt, int64_t ts_start, int rows) { - if (isPrint) printf("H -> "); - - TAOS_MULTI_BIND params[2]; - // timestamp - int64_t ts[rows]; - for (int i = 0; i < rows; ++i) { - ts[i] = ts_start + i * 1000; - } - params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; - params[0].buffer = ts; - params[0].buffer_length = sizeof(ts[0]); - params[0].length = malloc(sizeof(int64_t) * rows); - char is_null[rows]; - for (int i = 0; i < rows; i++) { - is_null[i] = 0; - } - params[0].is_null = is_null; - params[0].num = rows; - // f1 - int32_t values[rows]; - for (int i = 0; i < rows; ++i) { - values[i] = rand() % 100; - } - params[1].buffer_type = TSDB_DATA_TYPE_INT; - params[1].buffer = values; - params[1].buffer_length = sizeof(int32_t); - params[1].length = malloc(sizeof(int32_t) * rows); - params[1].is_null = is_null; - params[1].num = rows; - - int code = taos_stmt_bind_param_batch(stmt, params); - if (code != 0) { - printf("failed to bind_param_batch, reason: %s\n", taos_stmt_errstr(stmt)); - return; - } -} - -void G1(TAOS_STMT *stmt, int64_t ts_start, int rows) { - if (isPrint) printf("G1 -> "); - - // timestamp - TAOS_MULTI_BIND param0[1]; - int64_t ts[rows]; - for (int i = 0; i < rows; ++i) { - ts[i] = ts_start + i * 1000; - } - param0[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; - param0[0].buffer = ts; - param0[0].buffer_length = sizeof(ts[0]); - param0[0].length = malloc(sizeof(int64_t) * rows); - char is_null[rows]; - for (int i = 0; i < rows; i++) { - is_null[i] = 0; - } - param0[0].is_null = is_null; - param0[0].num = rows; - int code = taos_stmt_bind_single_param_batch(stmt, param0, 0); - if (code != 0) { - printf("failed to bind_single_param_batch, reason: %s\n", taos_stmt_errstr(stmt)); - return; - } -} - -void G2(TAOS_STMT *stmt, int rows) { - if (isPrint) printf("G2 -> "); - - // f1 - TAOS_MULTI_BIND param1[1]; - int32_t values[rows]; - for (int i = 0; i < rows; ++i) { - values[i] = rand() % 100; - } - param1[0].buffer_type = TSDB_DATA_TYPE_INT; - param1[0].buffer = values; - param1[0].buffer_length = sizeof(int32_t); - param1[0].length = malloc(sizeof(int32_t) * rows); - char is_null[rows]; - for (int i = 0; i < rows; i++) { - is_null[i] = 0; - } - param1[0].is_null = is_null; - param1[0].num = rows; - - int code = taos_stmt_bind_single_param_batch(stmt, param1, 1); - if (code != 0) { - printf("failed to bind_single_param_batch, reason: %s\n", taos_stmt_errstr(stmt)); - return; - } -} - -void I(TAOS_STMT *stmt) { - if (isPrint) printf("I -> "); - - int code = taos_stmt_add_batch(stmt); - if (code != 0) { - printf("failed to add_batch, reason: %s\n", taos_stmt_errstr(stmt)); - return; - } -} - -void J(TAOS_STMT *stmt) { - if (isPrint) printf("J -> "); - - int code = taos_stmt_execute(stmt); - if (code != 0) { - printf("failed to execute, reason: %s\n", taos_stmt_errstr(stmt)); - return; - } -} - -void L(TAOS_STMT *stmt) { - if (isPrint) printf("L\n"); - - taos_stmt_close(stmt); -} - -void prepare_super_table(TAOS *conn, int subTables) { - char sql[100] = "drop table weather"; - execute(conn, sql); - if (isPrint) printf("sql>>> %s\n", sql); - - sprintf(sql, "create table weather(ts timestamp, f1 int) tags(t1 int)"); - execute(conn, sql); - if (isPrint) printf("sql>>> %s\n", sql); - - for (int i = 0; i < subTables; i++) { - sprintf(sql, "drop table t%d", i); - if (isPrint) printf("sql>>> %s\n", sql); - execute(conn, sql); - } -} - -void prepare_normal_table(TAOS *conn) { - execute(conn, "drop table weather"); - execute(conn, "create table weather(ts timestamp, f1 int) tags(t1 int)"); -} - -void prepare_super_and_sub_table(TAOS *conn, int subTables) { - execute(conn, "drop table weather"); - execute(conn, "create table weather(ts timestamp, f1 int) tags(t1 int)"); - for (int i = 0; i < subTables; i++) { - char sql[100]; - sprintf(sql, "drop table t%d", i); - if (isPrint) printf("sql>>> %s\n", sql); - execute(conn, sql); - - sprintf(sql, "create table t%d using weather tags(%d)", i, i); - if (isPrint) printf("sql>>> %s\n", sql); - execute(conn, sql); - } -} - -int64_t getCurrentTimeMill() { - struct timeval tv; - gettimeofday(&tv, NULL); - return ((unsigned long long)tv.tv_sec * 1000 + (unsigned long long)tv.tv_usec / 1000); -} \ No newline at end of file diff --git a/tests/examples/c/prepare.c b/tests/examples/c/prepare.c deleted file mode 100644 index 14acba3b0d691b4d9bb61db3d8bf95e10e6c20fe..0000000000000000000000000000000000000000 --- a/tests/examples/c/prepare.c +++ /dev/null @@ -1,1422 +0,0 @@ -// TAOS standard API example. The same syntax as MySQL, but only a subet -// to compile: gcc -o prepare prepare.c -ltaos - -#include -#include -#include -#include -#include - -void taosMsleep(int mseconds); - -void verify_prepare(TAOS* taos) { - TAOS_RES* result = taos_query(taos, "drop database if exists test;"); - taos_free_result(result); - - usleep(100000); - result = taos_query(taos, "create database test;"); - - int code = taos_errno(result); - if (code != 0) { - printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result)); - taos_free_result(result); - exit(EXIT_FAILURE); - } - - taos_free_result(result); - - usleep(100000); - taos_select_db(taos, "test"); - - // create table - const char* sql = - "create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin " - "binary(40), blob nchar(10), u1 tinyint unsigned, u2 smallint unsigned, u4 int unsigned, u8 bigint unsigned)"; - result = taos_query(taos, sql); - code = taos_errno(result); - if (code != 0) { - printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result)); - taos_free_result(result); - exit(EXIT_FAILURE); - } - taos_free_result(result); - - // insert 10 records - struct { - int64_t ts; - int8_t b; - int8_t v1; - int16_t v2; - int32_t v4; - int64_t v8; - float f4; - double f8; - char bin[40]; - char blob[80]; - uint8_t u1; - uint16_t u2; - uint32_t u4; - uint64_t u8; - } v = {0}; - - TAOS_STMT* stmt = taos_stmt_init(taos); - TAOS_BIND params[14]; - params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; - params[0].buffer_length = sizeof(v.ts); - params[0].buffer = &v.ts; - params[0].length = ¶ms[0].buffer_length; - params[0].is_null = NULL; - - params[1].buffer_type = TSDB_DATA_TYPE_BOOL; - params[1].buffer_length = sizeof(v.b); - params[1].buffer = &v.b; - params[1].length = ¶ms[1].buffer_length; - params[1].is_null = NULL; - - params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; - params[2].buffer_length = sizeof(v.v1); - params[2].buffer = &v.v1; - params[2].length = ¶ms[2].buffer_length; - params[2].is_null = NULL; - - params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; - params[3].buffer_length = sizeof(v.v2); - params[3].buffer = &v.v2; - params[3].length = ¶ms[3].buffer_length; - params[3].is_null = NULL; - - params[4].buffer_type = TSDB_DATA_TYPE_INT; - params[4].buffer_length = sizeof(v.v4); - params[4].buffer = &v.v4; - params[4].length = ¶ms[4].buffer_length; - params[4].is_null = NULL; - - params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; - params[5].buffer_length = sizeof(v.v8); - params[5].buffer = &v.v8; - params[5].length = ¶ms[5].buffer_length; - params[5].is_null = NULL; - - params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; - params[6].buffer_length = sizeof(v.f4); - params[6].buffer = &v.f4; - params[6].length = ¶ms[6].buffer_length; - params[6].is_null = NULL; - - params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; - params[7].buffer_length = sizeof(v.f8); - params[7].buffer = &v.f8; - params[7].length = ¶ms[7].buffer_length; - params[7].is_null = NULL; - - params[8].buffer_type = TSDB_DATA_TYPE_BINARY; - params[8].buffer_length = sizeof(v.bin); - params[8].buffer = v.bin; - params[8].length = ¶ms[8].buffer_length; - params[8].is_null = NULL; - - strcpy(v.blob, "一二三四五六七八九十"); - params[9].buffer_type = TSDB_DATA_TYPE_NCHAR; - params[9].buffer_length = strlen(v.blob); - params[9].buffer = v.blob; - params[9].length = ¶ms[9].buffer_length; - params[9].is_null = NULL; - - params[10].buffer_type = TSDB_DATA_TYPE_UTINYINT; - params[10].buffer_length = sizeof(v.u1); - params[10].buffer = &v.u1; - params[10].length = ¶ms[10].buffer_length; - params[10].is_null = NULL; - - params[11].buffer_type = TSDB_DATA_TYPE_USMALLINT; - params[11].buffer_length = sizeof(v.u2); - params[11].buffer = &v.u2; - params[11].length = ¶ms[11].buffer_length; - params[11].is_null = NULL; - - params[12].buffer_type = TSDB_DATA_TYPE_UINT; - params[12].buffer_length = sizeof(v.u4); - params[12].buffer = &v.u4; - params[12].length = ¶ms[12].buffer_length; - params[12].is_null = NULL; - - params[13].buffer_type = TSDB_DATA_TYPE_UBIGINT; - params[13].buffer_length = sizeof(v.u8); - params[13].buffer = &v.u8; - params[13].length = ¶ms[13].buffer_length; - params[13].is_null = NULL; - - int is_null = 1; - - sql = "insert into m1 values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - code = taos_stmt_prepare(stmt, sql, 0); - if (code != 0) { - printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - v.ts = 1591060628000; - for (int i = 0; i < 10; ++i) { - v.ts += 1; - for (int j = 1; j < 10; ++j) { - params[j].is_null = ((i == j) ? &is_null : 0); - } - v.b = (int8_t)i % 2; - v.v1 = (int8_t)i; - v.v2 = (int16_t)(i * 2); - v.v4 = (int32_t)(i * 4); - v.v8 = (int64_t)(i * 8); - v.f4 = (float)(i * 40); - v.f8 = (double)(i * 80); - for (int j = 0; j < sizeof(v.bin); ++j) { - v.bin[j] = (char)(i + '0'); - } - v.u1 = (uint8_t)i; - v.u2 = (uint16_t)(i * 2); - v.u4 = (uint32_t)(i * 4); - v.u8 = (uint64_t)(i * 8); - - taos_stmt_bind_param(stmt, params); - taos_stmt_add_batch(stmt); - } - if (taos_stmt_execute(stmt) != 0) { - printf("\033[31mfailed to execute insert statement.error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - int affectedRows = taos_stmt_affected_rows(stmt); - printf("sucessfully inserted %d rows\n", affectedRows); - - taos_stmt_close(stmt); - - // query the records - stmt = taos_stmt_init(taos); - taos_stmt_prepare(stmt, "SELECT * FROM m1 WHERE v1 > ? AND v2 < ?", 0); - v.v1 = 5; - v.v2 = 15; - taos_stmt_bind_param(stmt, params + 2); - if (taos_stmt_execute(stmt) != 0) { - printf("\033[31mfailed to execute select statement.error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - result = taos_stmt_use_result(stmt); - - TAOS_ROW row; - int rows = 0; - int num_fields = taos_num_fields(result); - TAOS_FIELD* fields = taos_fetch_fields(result); - - // fetch the records row by row - while ((row = taos_fetch_row(result))) { - char temp[256] = {0}; - rows++; - taos_print_row(temp, row, fields, num_fields); - printf("%s\n", temp); - } - - taos_free_result(result); - taos_stmt_close(stmt); -} - -void verify_prepare2(TAOS* taos) { - TAOS_RES* result = taos_query(taos, "drop database if exists test;"); - taos_free_result(result); - usleep(100000); - result = taos_query(taos, "create database test;"); - - int code = taos_errno(result); - if (code != 0) { - printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result)); - taos_free_result(result); - exit(EXIT_FAILURE); - } - taos_free_result(result); - - usleep(100000); - taos_select_db(taos, "test"); - - // create table - const char* sql = - "create table m1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin " - "binary(40), blob nchar(10), u1 tinyint unsigned, u2 smallint unsigned, u4 int unsigned, u8 bigint unsigned)"; - result = taos_query(taos, sql); - code = taos_errno(result); - if (code != 0) { - printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result)); - taos_free_result(result); - exit(EXIT_FAILURE); - } - taos_free_result(result); - - // insert 10 records - struct { - int64_t ts; - int8_t b; - int8_t v1; - int16_t v2; - int32_t v4; - int64_t v8; - float f4; - double f8; - char bin[40]; - char blob[80]; - uint8_t u1; - uint16_t u2; - uint32_t u4; - uint64_t u8; - } v = {0}; - - TAOS_STMT* stmt = taos_stmt_init(taos); - TAOS_BIND params[14]; - params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; - params[0].buffer_length = sizeof(v.ts); - params[0].buffer = &v.ts; - params[0].length = ¶ms[0].buffer_length; - params[0].is_null = NULL; - - params[1].buffer_type = TSDB_DATA_TYPE_BOOL; - params[1].buffer_length = sizeof(v.b); - params[1].buffer = &v.b; - params[1].length = ¶ms[1].buffer_length; - params[1].is_null = NULL; - - params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; - params[2].buffer_length = sizeof(v.v1); - params[2].buffer = &v.v1; - params[2].length = ¶ms[2].buffer_length; - params[2].is_null = NULL; - - params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; - params[3].buffer_length = sizeof(v.v2); - params[3].buffer = &v.v2; - params[3].length = ¶ms[3].buffer_length; - params[3].is_null = NULL; - - params[4].buffer_type = TSDB_DATA_TYPE_INT; - params[4].buffer_length = sizeof(v.v4); - params[4].buffer = &v.v4; - params[4].length = ¶ms[4].buffer_length; - params[4].is_null = NULL; - - params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; - params[5].buffer_length = sizeof(v.v8); - params[5].buffer = &v.v8; - params[5].length = ¶ms[5].buffer_length; - params[5].is_null = NULL; - - params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; - params[6].buffer_length = sizeof(v.f4); - params[6].buffer = &v.f4; - params[6].length = ¶ms[6].buffer_length; - params[6].is_null = NULL; - - params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; - params[7].buffer_length = sizeof(v.f8); - params[7].buffer = &v.f8; - params[7].length = ¶ms[7].buffer_length; - params[7].is_null = NULL; - - params[8].buffer_type = TSDB_DATA_TYPE_BINARY; - params[8].buffer_length = sizeof(v.bin); - params[8].buffer = v.bin; - params[8].length = ¶ms[8].buffer_length; - params[8].is_null = NULL; - - strcpy(v.blob, "一二三四五六七八九十"); - params[9].buffer_type = TSDB_DATA_TYPE_NCHAR; - params[9].buffer_length = strlen(v.blob); - params[9].buffer = v.blob; - params[9].length = ¶ms[9].buffer_length; - params[9].is_null = NULL; - - params[10].buffer_type = TSDB_DATA_TYPE_UTINYINT; - params[10].buffer_length = sizeof(v.u1); - params[10].buffer = &v.u1; - params[10].length = ¶ms[10].buffer_length; - params[10].is_null = NULL; - - params[11].buffer_type = TSDB_DATA_TYPE_USMALLINT; - params[11].buffer_length = sizeof(v.u2); - params[11].buffer = &v.u2; - params[11].length = ¶ms[11].buffer_length; - params[11].is_null = NULL; - - params[12].buffer_type = TSDB_DATA_TYPE_UINT; - params[12].buffer_length = sizeof(v.u4); - params[12].buffer = &v.u4; - params[12].length = ¶ms[12].buffer_length; - params[12].is_null = NULL; - - params[13].buffer_type = TSDB_DATA_TYPE_UBIGINT; - params[13].buffer_length = sizeof(v.u8); - params[13].buffer = &v.u8; - params[13].length = ¶ms[13].buffer_length; - params[13].is_null = NULL; - - sql = "insert into ? values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - code = taos_stmt_prepare(stmt, sql, 0); - if (code != 0) { - printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - code = taos_stmt_set_tbname(stmt, "m1"); - if (code != 0) { - printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - int is_null = 1; - - v.ts = 1591060628000; - for (int i = 0; i < 10; ++i) { - v.ts += 1; - for (int j = 1; j < 10; ++j) { - params[j].is_null = ((i == j) ? &is_null : 0); - } - v.b = (int8_t)i % 2; - v.v1 = (int8_t)i; - v.v2 = (int16_t)(i * 2); - v.v4 = (int32_t)(i * 4); - v.v8 = (int64_t)(i * 8); - v.f4 = (float)(i * 40); - v.f8 = (double)(i * 80); - for (int j = 0; j < sizeof(v.bin); ++j) { - v.bin[j] = (char)(i + '0'); - } - v.u1 = (uint8_t)i; - v.u2 = (uint16_t)(i * 2); - v.u4 = (uint32_t)(i * 4); - v.u8 = (uint64_t)(i * 8); - - taos_stmt_bind_param(stmt, params); - taos_stmt_add_batch(stmt); - } - - if (taos_stmt_execute(stmt) != 0) { - printf("\033[31mfailed to execute insert statement.error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - int affectedRows = taos_stmt_affected_rows(stmt); - printf("sucessfully inserted %d rows\n", affectedRows); - - taos_stmt_close(stmt); - - // query the records - stmt = taos_stmt_init(taos); - taos_stmt_prepare(stmt, "SELECT * FROM m1 WHERE v1 > ? AND v2 < ?", 0); - TAOS_BIND qparams[2]; - - int8_t v1 = 5; - int16_t v2 = 15; - qparams[0].buffer_type = TSDB_DATA_TYPE_TINYINT; - qparams[0].buffer_length = sizeof(v1); - qparams[0].buffer = &v1; - qparams[0].length = &qparams[0].buffer_length; - qparams[0].is_null = NULL; - - qparams[1].buffer_type = TSDB_DATA_TYPE_SMALLINT; - qparams[1].buffer_length = sizeof(v2); - qparams[1].buffer = &v2; - qparams[1].length = &qparams[1].buffer_length; - qparams[1].is_null = NULL; - - taos_stmt_bind_param(stmt, qparams); - if (taos_stmt_execute(stmt) != 0) { - printf("\033[31mfailed to execute select statement.error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - result = taos_stmt_use_result(stmt); - - TAOS_ROW row; - int rows = 0; - int num_fields = taos_num_fields(result); - TAOS_FIELD* fields = taos_fetch_fields(result); - - // fetch the records row by row - while ((row = taos_fetch_row(result))) { - char temp[256] = {0}; - rows++; - taos_print_row(temp, row, fields, num_fields); - printf("%s\n", temp); - } - - taos_free_result(result); - taos_stmt_close(stmt); -} - -void verify_prepare3(TAOS* taos) { - TAOS_RES* result = taos_query(taos, "drop database if exists test;"); - taos_free_result(result); - usleep(100000); - result = taos_query(taos, "create database test;"); - - int code = taos_errno(result); - if (code != 0) { - printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result)); - taos_free_result(result); - exit(EXIT_FAILURE); - } - taos_free_result(result); - - usleep(100000); - taos_select_db(taos, "test"); - - // create table - const char* sql = - "create stable st1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin " - "binary(40), blob nchar(10), u1 tinyint unsigned, u2 smallint unsigned, u4 int unsigned, u8 bigint unsigned) " - "tags " - "(b_tag bool, v1_tag tinyint, v2_tag smallint, v4_tag int, v8_tag bigint, f4_tag float, f8_tag double, bin_tag " - "binary(40), blob_tag nchar(10), u1_tag tinyint unsigned, u2_tag smallint unsigned, u4_tag int unsigned, u8_tag " - "bigint " - "unsigned)"; - result = taos_query(taos, sql); - code = taos_errno(result); - if (code != 0) { - printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result)); - taos_free_result(result); - exit(EXIT_FAILURE); - } - taos_free_result(result); - - TAOS_BIND tags[13]; - - struct { - int8_t b; - int8_t v1; - int16_t v2; - int32_t v4; - int64_t v8; - float f4; - double f8; - char bin[40]; - char blob[80]; - uint8_t u1; - uint16_t u2; - uint32_t u4; - uint64_t u8; - } id = {0}; - - id.b = (int8_t)1; - id.v1 = (int8_t)1; - id.v2 = (int16_t)2; - id.v4 = (int32_t)4; - id.v8 = (int64_t)8; - id.f4 = (float)40; - id.f8 = (double)80; - for (int j = 0; j < sizeof(id.bin); ++j) { - id.bin[j] = (char)('1' + '0'); - } - strcpy(id.blob, "一二三四五六七八九十"); - id.u1 = (uint8_t)1; - id.u2 = (uint16_t)2; - id.u4 = (uint32_t)4; - id.u8 = (uint64_t)8; - - tags[0].buffer_type = TSDB_DATA_TYPE_BOOL; - tags[0].buffer_length = sizeof(id.b); - tags[0].buffer = &id.b; - tags[0].length = &tags[0].buffer_length; - tags[0].is_null = NULL; - - tags[1].buffer_type = TSDB_DATA_TYPE_TINYINT; - tags[1].buffer_length = sizeof(id.v1); - tags[1].buffer = &id.v1; - tags[1].length = &tags[1].buffer_length; - tags[1].is_null = NULL; - - tags[2].buffer_type = TSDB_DATA_TYPE_SMALLINT; - tags[2].buffer_length = sizeof(id.v2); - tags[2].buffer = &id.v2; - tags[2].length = &tags[2].buffer_length; - tags[2].is_null = NULL; - - tags[3].buffer_type = TSDB_DATA_TYPE_INT; - tags[3].buffer_length = sizeof(id.v4); - tags[3].buffer = &id.v4; - tags[3].length = &tags[3].buffer_length; - tags[3].is_null = NULL; - - tags[4].buffer_type = TSDB_DATA_TYPE_BIGINT; - tags[4].buffer_length = sizeof(id.v8); - tags[4].buffer = &id.v8; - tags[4].length = &tags[4].buffer_length; - tags[4].is_null = NULL; - - tags[5].buffer_type = TSDB_DATA_TYPE_FLOAT; - tags[5].buffer_length = sizeof(id.f4); - tags[5].buffer = &id.f4; - tags[5].length = &tags[5].buffer_length; - tags[5].is_null = NULL; - - tags[6].buffer_type = TSDB_DATA_TYPE_DOUBLE; - tags[6].buffer_length = sizeof(id.f8); - tags[6].buffer = &id.f8; - tags[6].length = &tags[6].buffer_length; - tags[6].is_null = NULL; - - tags[7].buffer_type = TSDB_DATA_TYPE_BINARY; - tags[7].buffer_length = sizeof(id.bin); - tags[7].buffer = &id.bin; - tags[7].length = &tags[7].buffer_length; - tags[7].is_null = NULL; - - tags[8].buffer_type = TSDB_DATA_TYPE_NCHAR; - tags[8].buffer_length = strlen(id.blob); - tags[8].buffer = &id.blob; - tags[8].length = &tags[8].buffer_length; - tags[8].is_null = NULL; - - tags[9].buffer_type = TSDB_DATA_TYPE_UTINYINT; - tags[9].buffer_length = sizeof(id.u1); - tags[9].buffer = &id.u1; - tags[9].length = &tags[9].buffer_length; - tags[9].is_null = NULL; - - tags[10].buffer_type = TSDB_DATA_TYPE_USMALLINT; - tags[10].buffer_length = sizeof(id.u2); - tags[10].buffer = &id.u2; - tags[10].length = &tags[10].buffer_length; - tags[10].is_null = NULL; - - tags[11].buffer_type = TSDB_DATA_TYPE_UINT; - tags[11].buffer_length = sizeof(id.u4); - tags[11].buffer = &id.u4; - tags[11].length = &tags[11].buffer_length; - tags[11].is_null = NULL; - - tags[12].buffer_type = TSDB_DATA_TYPE_UBIGINT; - tags[12].buffer_length = sizeof(id.u8); - tags[12].buffer = &id.u8; - tags[12].length = &tags[12].buffer_length; - tags[12].is_null = NULL; - // insert 10 records - struct { - int64_t ts[10]; - int8_t b[10]; - int8_t v1[10]; - int16_t v2[10]; - int32_t v4[10]; - int64_t v8[10]; - float f4[10]; - double f8[10]; - char bin[10][40]; - char blob[10][80]; - uint8_t u1[10]; - uint16_t u2[10]; - uint32_t u4[10]; - uint64_t u8[10]; - } v; - - int32_t* t8_len = malloc(sizeof(int32_t) * 10); - int32_t* t16_len = malloc(sizeof(int32_t) * 10); - int32_t* t32_len = malloc(sizeof(int32_t) * 10); - int32_t* t64_len = malloc(sizeof(int32_t) * 10); - int32_t* float_len = malloc(sizeof(int32_t) * 10); - int32_t* double_len = malloc(sizeof(int32_t) * 10); - int32_t* bin_len = malloc(sizeof(int32_t) * 10); - int32_t* blob_len = malloc(sizeof(int32_t) * 10); - int32_t* u8_len = malloc(sizeof(int32_t) * 10); - int32_t* u16_len = malloc(sizeof(int32_t) * 10); - int32_t* u32_len = malloc(sizeof(int32_t) * 10); - int32_t* u64_len = malloc(sizeof(int32_t) * 10); - - TAOS_STMT* stmt = taos_stmt_init(taos); - TAOS_MULTI_BIND params[14]; - char is_null[10] = {0}; - - params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; - params[0].buffer_length = sizeof(v.ts[0]); - params[0].buffer = v.ts; - params[0].length = t64_len; - params[0].is_null = is_null; - params[0].num = 10; - - params[1].buffer_type = TSDB_DATA_TYPE_BOOL; - params[1].buffer_length = sizeof(v.b[0]); - params[1].buffer = v.b; - params[1].length = t8_len; - params[1].is_null = is_null; - params[1].num = 10; - - params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; - params[2].buffer_length = sizeof(v.v1[0]); - params[2].buffer = v.v1; - params[2].length = t8_len; - params[2].is_null = is_null; - params[2].num = 10; - - params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; - params[3].buffer_length = sizeof(v.v2[0]); - params[3].buffer = v.v2; - params[3].length = t16_len; - params[3].is_null = is_null; - params[3].num = 10; - - params[4].buffer_type = TSDB_DATA_TYPE_INT; - params[4].buffer_length = sizeof(v.v4[0]); - params[4].buffer = v.v4; - params[4].length = t32_len; - params[4].is_null = is_null; - params[4].num = 10; - - params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; - params[5].buffer_length = sizeof(v.v8[0]); - params[5].buffer = v.v8; - params[5].length = t64_len; - params[5].is_null = is_null; - params[5].num = 10; - - params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; - params[6].buffer_length = sizeof(v.f4[0]); - params[6].buffer = v.f4; - params[6].length = float_len; - params[6].is_null = is_null; - params[6].num = 10; - - params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; - params[7].buffer_length = sizeof(v.f8[0]); - params[7].buffer = v.f8; - params[7].length = double_len; - params[7].is_null = is_null; - params[7].num = 10; - - params[8].buffer_type = TSDB_DATA_TYPE_BINARY; - params[8].buffer_length = sizeof(v.bin[0]); - params[8].buffer = v.bin; - params[8].length = bin_len; - params[8].is_null = is_null; - params[8].num = 10; - - params[9].buffer_type = TSDB_DATA_TYPE_NCHAR; - params[9].buffer_length = sizeof(v.blob[0]); - params[9].buffer = v.blob; - params[9].length = blob_len; - params[9].is_null = is_null; - params[9].num = 10; - - params[10].buffer_type = TSDB_DATA_TYPE_UTINYINT; - params[10].buffer_length = sizeof(v.u1[0]); - params[10].buffer = v.u1; - params[10].length = u8_len; - params[10].is_null = is_null; - params[10].num = 10; - - params[11].buffer_type = TSDB_DATA_TYPE_USMALLINT; - params[11].buffer_length = sizeof(v.u2[0]); - params[11].buffer = v.u2; - params[11].length = u16_len; - params[11].is_null = is_null; - params[11].num = 10; - - params[12].buffer_type = TSDB_DATA_TYPE_UINT; - params[12].buffer_length = sizeof(v.u4[0]); - params[12].buffer = v.u4; - params[12].length = u32_len; - params[12].is_null = is_null; - params[12].num = 10; - - params[13].buffer_type = TSDB_DATA_TYPE_UBIGINT; - params[13].buffer_length = sizeof(v.u8[0]); - params[13].buffer = v.u8; - params[13].length = u64_len; - params[13].is_null = is_null; - params[13].num = 10; - - sql = "insert into ? using st1 tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - code = taos_stmt_prepare(stmt, sql, 0); - if (code != 0) { - printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - code = taos_stmt_set_tbname_tags(stmt, "m1", tags); - if (code != 0) { - printf("\033[31mfailed to execute taos_stmt_set_tbname_tags. error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - int64_t ts = 1591060628000; - for (int i = 0; i < 10; ++i) { - v.ts[i] = ts++; - is_null[i] = 0; - - v.b[i] = (int8_t)i % 2; - v.v1[i] = (int8_t)i; - v.v2[i] = (int16_t)(i * 2); - v.v4[i] = (int32_t)(i * 4); - v.v8[i] = (int64_t)(i * 8); - v.f4[i] = (float)(i * 40); - v.f8[i] = (double)(i * 80); - for (int j = 0; j < sizeof(v.bin[0]); ++j) { - v.bin[i][j] = (char)(i + '0'); - } - strcpy(v.blob[i], "一二三四五六七八九十"); - v.u1[i] = (uint8_t)i; - v.u2[i] = (uint16_t)(i * 2); - v.u4[i] = (uint32_t)(i * 4); - v.u8[i] = (uint64_t)(i * 8); - - t8_len[i] = sizeof(int8_t); - t16_len[i] = sizeof(int16_t); - t32_len[i] = sizeof(int32_t); - t64_len[i] = sizeof(int64_t); - float_len[i] = sizeof(float); - double_len[i] = sizeof(double); - bin_len[i] = sizeof(v.bin[0]); - blob_len[i] = (int32_t)strlen(v.blob[i]); - u8_len[i] = sizeof(uint8_t); - u16_len[i] = sizeof(uint16_t); - u32_len[i] = sizeof(uint32_t); - u64_len[i] = sizeof(uint64_t); - } - - taos_stmt_bind_param_batch(stmt, params); - taos_stmt_add_batch(stmt); - - if (taos_stmt_execute(stmt) != 0) { - printf("\033[31mfailed to execute insert statement.error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - int affectedRows = taos_stmt_affected_rows(stmt); - printf("successfully inserted %d rows\n", affectedRows); - - taos_stmt_close(stmt); - - // query the records - stmt = taos_stmt_init(taos); - taos_stmt_prepare(stmt, "SELECT * FROM m1 WHERE v1 > ? AND v2 < ?", 0); - - TAOS_BIND qparams[2]; - - int8_t v1 = 5; - int16_t v2 = 15; - qparams[0].buffer_type = TSDB_DATA_TYPE_TINYINT; - qparams[0].buffer_length = sizeof(v1); - qparams[0].buffer = &v1; - qparams[0].length = &qparams[0].buffer_length; - qparams[0].is_null = NULL; - - qparams[1].buffer_type = TSDB_DATA_TYPE_SMALLINT; - qparams[1].buffer_length = sizeof(v2); - qparams[1].buffer = &v2; - qparams[1].length = &qparams[1].buffer_length; - qparams[1].is_null = NULL; - - taos_stmt_bind_param(stmt, qparams); - if (taos_stmt_execute(stmt) != 0) { - printf("\033[31mfailed to execute select statement.error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - result = taos_stmt_use_result(stmt); - - TAOS_ROW row; - int rows = 0; - int num_fields = taos_num_fields(result); - TAOS_FIELD* fields = taos_fetch_fields(result); - - // fetch the records row by row - while ((row = taos_fetch_row(result))) { - char temp[256] = {0}; - rows++; - taos_print_row(temp, row, fields, num_fields); - printf("%s\n", temp); - } - - taos_free_result(result); - taos_stmt_close(stmt); - - free(t8_len); - free(t16_len); - free(t32_len); - free(t64_len); - free(float_len); - free(double_len); - free(bin_len); - free(blob_len); - free(u8_len); - free(u16_len); - free(u32_len); - free(u64_len); - -} - -/** - * @brief Verify the upper/lower case of tableName for create(by setTableName)/query/show/describe/drop. - * https://jira.taosdata.com:18080/browse/TS-904 - * https://jira.taosdata.com:18090/pages/viewpage.action?pageId=129140555 - * @param taos - */ -void verify_prepare4(TAOS* taos) { - printf("Verify the upper/lower case of tableName for create(by setTableName)/query/show/describe/drop etc.\n"); - - TAOS_RES* result = taos_query(taos, "drop database if exists test;"); - taos_free_result(result); - usleep(100000); - result = taos_query(taos, "create database test;"); - - int code = taos_errno(result); - if (code != 0) { - printf("\033[31mfailed to create database, reason:%s\033[0m\n", taos_errstr(result)); - taos_free_result(result); - exit(EXIT_FAILURE); - } - taos_free_result(result); - - usleep(100000); - taos_select_db(taos, "test"); - - // create table - const char* sql = - "create stable st1 (ts timestamp, b bool, v1 tinyint, v2 smallint, v4 int, v8 bigint, f4 float, f8 double, bin " - "binary(40), blob nchar(10), u1 tinyint unsigned, u2 smallint unsigned, u4 int unsigned, u8 bigint unsigned) " - "tags " - "(b_tag bool, v1_tag tinyint, v2_tag smallint, v4_tag int, v8_tag bigint, f4_tag float, f8_tag double, bin_tag " - "binary(40), blob_tag nchar(10), u1_tag tinyint unsigned, u2_tag smallint unsigned, u4_tag int unsigned, u8_tag " - "bigint " - "unsigned)"; - result = taos_query(taos, sql); - code = taos_errno(result); - if (code != 0) { - printf("\033[31mfailed to create table, reason:%s\033[0m\n", taos_errstr(result)); - taos_free_result(result); - exit(EXIT_FAILURE); - } - taos_free_result(result); - - TAOS_BIND tags[13]; - - struct { - int8_t b; - int8_t v1; - int16_t v2; - int32_t v4; - int64_t v8; - float f4; - double f8; - char bin[40]; - char blob[80]; - uint8_t u1; - uint16_t u2; - uint32_t u4; - uint64_t u8; - } id = {0}; - - id.b = (int8_t)1; - id.v1 = (int8_t)1; - id.v2 = (int16_t)2; - id.v4 = (int32_t)4; - id.v8 = (int64_t)8; - id.f4 = (float)40; - id.f8 = (double)80; - for (int j = 0; j < sizeof(id.bin); ++j) { - id.bin[j] = (char)('1' + '0'); - } - strcpy(id.blob, "一二三四五六七八九十"); - id.u1 = (uint8_t)1; - id.u2 = (uint16_t)2; - id.u4 = (uint32_t)4; - id.u8 = (uint64_t)8; - - tags[0].buffer_type = TSDB_DATA_TYPE_BOOL; - tags[0].buffer_length = sizeof(id.b); - tags[0].buffer = &id.b; - tags[0].length = &tags[0].buffer_length; - tags[0].is_null = NULL; - - tags[1].buffer_type = TSDB_DATA_TYPE_TINYINT; - tags[1].buffer_length = sizeof(id.v1); - tags[1].buffer = &id.v1; - tags[1].length = &tags[1].buffer_length; - tags[1].is_null = NULL; - - tags[2].buffer_type = TSDB_DATA_TYPE_SMALLINT; - tags[2].buffer_length = sizeof(id.v2); - tags[2].buffer = &id.v2; - tags[2].length = &tags[2].buffer_length; - tags[2].is_null = NULL; - - tags[3].buffer_type = TSDB_DATA_TYPE_INT; - tags[3].buffer_length = sizeof(id.v4); - tags[3].buffer = &id.v4; - tags[3].length = &tags[3].buffer_length; - tags[3].is_null = NULL; - - tags[4].buffer_type = TSDB_DATA_TYPE_BIGINT; - tags[4].buffer_length = sizeof(id.v8); - tags[4].buffer = &id.v8; - tags[4].length = &tags[4].buffer_length; - tags[4].is_null = NULL; - - tags[5].buffer_type = TSDB_DATA_TYPE_FLOAT; - tags[5].buffer_length = sizeof(id.f4); - tags[5].buffer = &id.f4; - tags[5].length = &tags[5].buffer_length; - tags[5].is_null = NULL; - - tags[6].buffer_type = TSDB_DATA_TYPE_DOUBLE; - tags[6].buffer_length = sizeof(id.f8); - tags[6].buffer = &id.f8; - tags[6].length = &tags[6].buffer_length; - tags[6].is_null = NULL; - - tags[7].buffer_type = TSDB_DATA_TYPE_BINARY; - tags[7].buffer_length = sizeof(id.bin); - tags[7].buffer = &id.bin; - tags[7].length = &tags[7].buffer_length; - tags[7].is_null = NULL; - - tags[8].buffer_type = TSDB_DATA_TYPE_NCHAR; - tags[8].buffer_length = strlen(id.blob); - tags[8].buffer = &id.blob; - tags[8].length = &tags[8].buffer_length; - tags[8].is_null = NULL; - - tags[9].buffer_type = TSDB_DATA_TYPE_UTINYINT; - tags[9].buffer_length = sizeof(id.u1); - tags[9].buffer = &id.u1; - tags[9].length = &tags[9].buffer_length; - tags[9].is_null = NULL; - - tags[10].buffer_type = TSDB_DATA_TYPE_USMALLINT; - tags[10].buffer_length = sizeof(id.u2); - tags[10].buffer = &id.u2; - tags[10].length = &tags[10].buffer_length; - tags[10].is_null = NULL; - - tags[11].buffer_type = TSDB_DATA_TYPE_UINT; - tags[11].buffer_length = sizeof(id.u4); - tags[11].buffer = &id.u4; - tags[11].length = &tags[11].buffer_length; - tags[11].is_null = NULL; - - tags[12].buffer_type = TSDB_DATA_TYPE_UBIGINT; - tags[12].buffer_length = sizeof(id.u8); - tags[12].buffer = &id.u8; - tags[12].length = &tags[12].buffer_length; - tags[12].is_null = NULL; - // insert 10 records - struct { - int64_t ts[10]; - int8_t b[10]; - int8_t v1[10]; - int16_t v2[10]; - int32_t v4[10]; - int64_t v8[10]; - float f4[10]; - double f8[10]; - char bin[10][40]; - char blob[10][80]; - uint8_t u1[10]; - uint16_t u2[10]; - uint32_t u4[10]; - uint64_t u8[10]; - } v; - - int32_t* t8_len = malloc(sizeof(int32_t) * 10); - int32_t* t16_len = malloc(sizeof(int32_t) * 10); - int32_t* t32_len = malloc(sizeof(int32_t) * 10); - int32_t* t64_len = malloc(sizeof(int32_t) * 10); - int32_t* float_len = malloc(sizeof(int32_t) * 10); - int32_t* double_len = malloc(sizeof(int32_t) * 10); - int32_t* bin_len = malloc(sizeof(int32_t) * 10); - int32_t* blob_len = malloc(sizeof(int32_t) * 10); - int32_t* u8_len = malloc(sizeof(int32_t) * 10); - int32_t* u16_len = malloc(sizeof(int32_t) * 10); - int32_t* u32_len = malloc(sizeof(int32_t) * 10); - int32_t* u64_len = malloc(sizeof(int32_t) * 10); - - TAOS_MULTI_BIND params[14]; - char is_null[10] = {0}; - params[0].buffer_type = TSDB_DATA_TYPE_TIMESTAMP; - params[0].buffer_length = sizeof(v.ts[0]); - params[0].buffer = v.ts; - params[0].length = t64_len; - params[0].is_null = is_null; - params[0].num = 10; - - params[1].buffer_type = TSDB_DATA_TYPE_BOOL; - params[1].buffer_length = sizeof(v.b[0]); - params[1].buffer = v.b; - params[1].length = t8_len; - params[1].is_null = is_null; - params[1].num = 10; - - params[2].buffer_type = TSDB_DATA_TYPE_TINYINT; - params[2].buffer_length = sizeof(v.v1[0]); - params[2].buffer = v.v1; - params[2].length = t8_len; - params[2].is_null = is_null; - params[2].num = 10; - - params[3].buffer_type = TSDB_DATA_TYPE_SMALLINT; - params[3].buffer_length = sizeof(v.v2[0]); - params[3].buffer = v.v2; - params[3].length = t16_len; - params[3].is_null = is_null; - params[3].num = 10; - - params[4].buffer_type = TSDB_DATA_TYPE_INT; - params[4].buffer_length = sizeof(v.v4[0]); - params[4].buffer = v.v4; - params[4].length = t32_len; - params[4].is_null = is_null; - params[4].num = 10; - - params[5].buffer_type = TSDB_DATA_TYPE_BIGINT; - params[5].buffer_length = sizeof(v.v8[0]); - params[5].buffer = v.v8; - params[5].length = t64_len; - params[5].is_null = is_null; - params[5].num = 10; - - params[6].buffer_type = TSDB_DATA_TYPE_FLOAT; - params[6].buffer_length = sizeof(v.f4[0]); - params[6].buffer = v.f4; - params[6].length = float_len; - params[6].is_null = is_null; - params[6].num = 10; - - params[7].buffer_type = TSDB_DATA_TYPE_DOUBLE; - params[7].buffer_length = sizeof(v.f8[0]); - params[7].buffer = v.f8; - params[7].length = double_len; - params[7].is_null = is_null; - params[7].num = 10; - - params[8].buffer_type = TSDB_DATA_TYPE_BINARY; - params[8].buffer_length = sizeof(v.bin[0]); - params[8].buffer = v.bin; - params[8].length = bin_len; - params[8].is_null = is_null; - params[8].num = 10; - - params[9].buffer_type = TSDB_DATA_TYPE_NCHAR; - params[9].buffer_length = sizeof(v.blob[0]); - params[9].buffer = v.blob; - params[9].length = blob_len; - params[9].is_null = is_null; - params[9].num = 10; - - params[10].buffer_type = TSDB_DATA_TYPE_UTINYINT; - params[10].buffer_length = sizeof(v.u1[0]); - params[10].buffer = v.u1; - params[10].length = u8_len; - params[10].is_null = is_null; - params[10].num = 10; - - params[11].buffer_type = TSDB_DATA_TYPE_USMALLINT; - params[11].buffer_length = sizeof(v.u2[0]); - params[11].buffer = v.u2; - params[11].length = u16_len; - params[11].is_null = is_null; - params[11].num = 10; - - params[12].buffer_type = TSDB_DATA_TYPE_UINT; - params[12].buffer_length = sizeof(v.u4[0]); - params[12].buffer = v.u4; - params[12].length = u32_len; - params[12].is_null = is_null; - params[12].num = 10; - - params[13].buffer_type = TSDB_DATA_TYPE_UBIGINT; - params[13].buffer_length = sizeof(v.u8[0]); - params[13].buffer = v.u8; - params[13].length = u64_len; - params[13].is_null = is_null; - params[13].num = 10; - -// verify table names for upper/lower case -#define VERIFY_CNT 5 - - typedef struct { - char setTbName[20]; - char showName[20]; - char describeName[20]; - char queryName[20]; - char dropName[20]; - } STbNames; - - /** - * @brief - * 0 - success expected - * NonZero - fail expected - */ - typedef struct { - int32_t setTbName; - int32_t showName; - int32_t describeName; - int32_t queryName; - int32_t dropName; - } STbNamesResult; - - STbNames tbName[VERIFY_CNT] = {0}; - STbNamesResult tbNameResult[VERIFY_CNT] = {0}; - - STbNames* pTbName = NULL; - STbNamesResult* pTbNameResult = NULL; - - pTbName = &tbName[0]; - pTbNameResult = &tbNameResult[0]; - strcpy(pTbName->setTbName, "Mn1"); - strcpy(pTbName->showName, "mn1"); - strcpy(pTbName->describeName, "mn1"); - strcpy(pTbName->queryName, "mn1"); - strcpy(pTbName->dropName, "mn1"); - - pTbName = &tbName[1]; - pTbNameResult = &tbNameResult[1]; - strcpy(pTbName->setTbName, "'Mn1'"); - strcpy(pTbName->showName, "'mn1'"); - strcpy(pTbName->describeName, "'mn1'"); - strcpy(pTbName->queryName, "'mn1'"); - strcpy(pTbName->dropName, "'mn1'"); - - pTbName = &tbName[2]; - pTbNameResult = &tbNameResult[2]; - strcpy(pTbName->setTbName, "\"Mn1\""); - strcpy(pTbName->showName, "\"mn1\""); - strcpy(pTbName->describeName, "\"mn1\""); - strcpy(pTbName->queryName, "\"mn1\""); - strcpy(pTbName->dropName, "\"mn1\""); - - pTbName = &tbName[3]; - pTbNameResult = &tbNameResult[3]; - strcpy(pTbName->setTbName, "\"Mn1\""); - strcpy(pTbName->showName, "'mn1'"); - strcpy(pTbName->describeName, "'mn1'"); - strcpy(pTbName->queryName, "mn1"); - strcpy(pTbName->dropName, "\"mn1\""); - - pTbName = &tbName[4]; - pTbNameResult = &tbNameResult[4]; - strcpy(pTbName->setTbName, "`Mn1`"); - strcpy(pTbName->showName, "Mn1"); // TODO support uniform of `` - strcpy(pTbName->describeName, "`Mn1`"); - strcpy(pTbName->queryName, "`Mn1`"); - strcpy(pTbName->dropName, "`Mn1`"); - - TAOS_STMT* stmt = NULL; - - for (int n = 0; n < VERIFY_CNT; ++n) { - printf("\033[31m[%d] ===================================\033[0m\n", n); - pTbName = &tbName[n]; - pTbNameResult = &tbNameResult[n]; - char tmpStr[256] = {0}; - - // set table name - stmt = taos_stmt_init(taos); - if (!stmt) { - printf("\033[31m[%d] failed to execute taos_stmt_init. error:%s\033[0m\n", n); - exit(EXIT_FAILURE); - } - - sql = "insert into ? using st1 tags(?,?,?,?,?,?,?,?,?,?,?,?,?) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; - code = taos_stmt_prepare(stmt, sql, 0); - if (code != 0) { - printf("\033[31mfailed to execute taos_stmt_prepare. error:%s\033[0m\n", taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - printf("[%d] taos_stmt_set_tbname_tags, tbname=%s\n", n, pTbName->setTbName); - code = taos_stmt_set_tbname_tags(stmt, pTbName->setTbName, tags); - if ((!pTbNameResult->setTbName && (0 != code)) || (pTbNameResult->setTbName && (0 == code))) { - printf("\033[31m[%d] failed to execute taos_stmt_set_tbname_tags. error:%s\033[0m\n", n, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - if (code == 0) { - int64_t ts = 1591060628000 + 1000 * n; - for (int i = 0; i < 10; ++i) { - v.ts[i] = ts++; - is_null[i] = 0; - - v.b[i] = (int8_t)i % 2; - v.v1[i] = (int8_t)i; - v.v2[i] = (int16_t)(i * 2); - v.v4[i] = (int32_t)(i * 4); - v.v8[i] = (int64_t)(i * 8); - v.f4[i] = (float)(i * 40); - v.f8[i] = (double)(i * 80); - for (int j = 0; j < sizeof(v.bin[0]); ++j) { - v.bin[i][j] = (char)(i + '0'); - } - strcpy(v.blob[i], "一二三四五六七八九十"); - v.u1[i] = (uint8_t)i; - v.u2[i] = (uint16_t)(i * 2); - v.u4[i] = (uint32_t)(i * 4); - v.u8[i] = (uint64_t)(i * 8); - - t8_len[i] = sizeof(int8_t); - t16_len[i] = sizeof(int16_t); - t32_len[i] = sizeof(int32_t); - t64_len[i] = sizeof(int64_t); - float_len[i] = sizeof(float); - double_len[i] = sizeof(double); - bin_len[i] = sizeof(v.bin[0]); - blob_len[i] = (int32_t)strlen(v.blob[i]); - u8_len[i] = sizeof(uint8_t); - u16_len[i] = sizeof(uint16_t); - u32_len[i] = sizeof(uint32_t); - u64_len[i] = sizeof(uint64_t); - } - - taos_stmt_bind_param_batch(stmt, params); - taos_stmt_add_batch(stmt); - - if (taos_stmt_execute(stmt) != 0) { - printf("\033[31m[%d] failed to execute insert statement.error:%s\033[0m\n", n, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - } - taos_stmt_close(stmt); - - // show the table - printf("[%d] show tables, tbName = %s\n", n, pTbName->showName); - stmt = taos_stmt_init(taos); - sprintf(tmpStr, "show tables like %s", pTbName->showName); - taos_stmt_prepare(stmt, tmpStr, 0); - code = taos_stmt_execute(stmt); - if ((!pTbNameResult->showName && (0 != code)) || (pTbNameResult->showName && (0 == code))) { - printf("\033[31m[%d] failed to execute show tables like. error:%s\033[0m\n", n, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - taos_stmt_close(stmt); - - // describe the table - printf("[%d] describe tables, tbName = %s\n", n, pTbName->describeName); - stmt = taos_stmt_init(taos); - sprintf(tmpStr, "describe %s", pTbName->describeName); - taos_stmt_prepare(stmt, tmpStr, 0); - code = taos_stmt_execute(stmt); - if ((!pTbNameResult->describeName && (0 != code)) || (pTbNameResult->describeName && (0 == code))) { - printf("\033[31m[%d] failed to execute describe tables. error:%s\033[0m\n", n, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - taos_stmt_close(stmt); - - // query the records - printf("[%d] select statement, tbName = %s\n", n, pTbName->queryName); - stmt = taos_stmt_init(taos); - sprintf(tmpStr, "SELECT * FROM %s", pTbName->queryName); - taos_stmt_prepare(stmt, tmpStr, 0); - - TAOS_BIND qparams[2]; - - int8_t v1 = 5; - int16_t v2 = 15; - qparams[0].buffer_type = TSDB_DATA_TYPE_TINYINT; - qparams[0].buffer_length = sizeof(v1); - qparams[0].buffer = &v1; - qparams[0].length = &qparams[0].buffer_length; - qparams[0].is_null = NULL; - - qparams[1].buffer_type = TSDB_DATA_TYPE_SMALLINT; - qparams[1].buffer_length = sizeof(v2); - qparams[1].buffer = &v2; - qparams[1].length = &qparams[1].buffer_length; - qparams[1].is_null = NULL; - - taos_stmt_bind_param(stmt, qparams); - - code = taos_stmt_execute(stmt); - if ((!pTbNameResult->queryName && (0 != code)) || (pTbNameResult->queryName && (0 == code))) { - printf("\033[31m[%d] failed to execute select statement.error:%s\033[0m\n", n, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - - result = taos_stmt_use_result(stmt); - - TAOS_ROW row; - int rows = 0; - int num_fields = taos_num_fields(result); - TAOS_FIELD* fields = taos_fetch_fields(result); - - // fetch the records row by row - while ((row = taos_fetch_row(result))) { - char temp[256] = {0}; - rows++; - taos_print_row(temp, row, fields, num_fields); - printf("[%d] row = %s\n", n, temp); - } - - taos_free_result(result); - taos_stmt_close(stmt); - - // drop table - printf("[%d] drop table, tbName = %s\n", n, pTbName->dropName); - stmt = taos_stmt_init(taos); - sprintf(tmpStr, "drop table %s", pTbName->dropName); - taos_stmt_prepare(stmt, tmpStr, 0); - code = taos_stmt_execute(stmt); - if ((!pTbNameResult->dropName && (0 != code)) || (pTbNameResult->dropName && (0 == code))) { - printf("\033[31m[%d] failed to drop table. error:%s\033[0m\n", n, taos_stmt_errstr(stmt)); - taos_stmt_close(stmt); - exit(EXIT_FAILURE); - } - taos_stmt_close(stmt); - } - - free(t8_len); - free(t16_len); - free(t32_len); - free(t64_len); - free(float_len); - free(double_len); - free(bin_len); - free(blob_len); - free(u8_len); - free(u16_len); - free(u32_len); - free(u64_len); -} - -int main(int argc, char* argv[]) { - const char* host = "127.0.0.1"; - const char* user = "root"; - const char* passwd = "taosdata"; - - taos_options(TSDB_OPTION_TIMEZONE, "GMT-8"); - TAOS* taos = taos_connect(host, user, passwd, "", 0); - if (taos == NULL) { - printf("\033[31mfailed to connect to db, reason:%s\033[0m\n", taos_errstr(taos)); - exit(1); - } - - char* info = taos_get_server_info(taos); - printf("server info: %s\n", info); - info = taos_get_client_info(taos); - printf("client info: %s\n", info); - printf("************ verify prepare *************\n"); - verify_prepare(taos); - printf("************ verify prepare2 *************\n"); - verify_prepare2(taos); - printf("************ verify prepare3 *************\n"); - verify_prepare3(taos); - printf("************ verify prepare4 *************\n"); - verify_prepare4(taos); - printf("************ verify end *************\n"); - exit(EXIT_SUCCESS); -} diff --git a/tests/examples/c/sqlperf.c b/tests/examples/c/sqlperf.c deleted file mode 100644 index bde69149651f2b2afffc9c4dffca6f42604f4f2c..0000000000000000000000000000000000000000 --- a/tests/examples/c/sqlperf.c +++ /dev/null @@ -1,141 +0,0 @@ -#include -#include -#include -#include -#include "taos.h" // TAOS header file -#include "taoserror.h" -#include "os.h" - -bool verbose = false; -bool describeTableFirst = false; - -typedef struct{ - TAOS* taos; - int numThreads; - int threadId; - int numSTables; -} SThreadArgs; - -static int executeSql(TAOS *taos, char *command) { - if (verbose) { - printf("sql: %s\n", command); - } - TAOS_RES *pSql = NULL; - int32_t code = TSDB_CODE_SUCCESS; - - pSql = taos_query(taos, command); - code = taos_errno(pSql); - - if (code != 0) { - if (verbose) fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(pSql)); - taos_free_result(pSql); - return code; - } - - taos_free_result(pSql); - return 0; -} - -void* threadFunc(void* args) { - char* sqlDescribeSTable = "describe st%d"; - char* sqlCreateSTable = "create table st%d (ts timestamp, value double) " - "tags(t0 nchar(20), t1 nchar(20), t2 nchar(20), t3 nchar(20), t4 nchar(20), " - "t5 nchar(20), t6 nchar(20), t7 nchar(20), t8 nchar(20), t9 nchar(20))"; - - char* sqlInsertData = "insert into t%d using st%d tags('t%d', 't%d', 't%d', 't%d', 't%d', 't%d', 't%d', 't%d', 't%d', 't%d') values(%lld, %d.%d)"; - - SThreadArgs* param = args; - - int interval = param->numSTables/param->numThreads; - if (param->numSTables % param->numThreads != 0) { - ++interval; - } - int start = param->threadId*interval; - int end = (param->threadId+1)*interval > param->numSTables ? param->numSTables : (param->threadId+1)*interval; - int r = rand(); - - for (int i = start; i < end; ++i) { - int tableId = i; - char sql0[1024] = {0}; - char sql1[1024] = {0}; - char sql2[1024] = {0}; - sprintf(sql0, sqlDescribeSTable, tableId); - sprintf(sql1, sqlCreateSTable, tableId); - time_t ct = time(0); - int64_t ts = ct * 1000; - sprintf(sql2, sqlInsertData, tableId, tableId, r, r, r, r, r, r, r, r, r, r, ts + tableId, r, r); - - if (describeTableFirst) { - executeSql(param->taos, sql0); - } - - executeSql(param->taos, sql1); - - executeSql(param->taos, sql2); - } - return NULL; -} - - -int main(int argc, char *argv[]) { - int numSTables = 20000; - int numThreads = 32; - - int opt; - while ((opt = getopt(argc, argv, "s:t:fvh")) != -1) { - switch (opt) { - case 's': - numSTables = atoi(optarg); - break; - case 't': - numThreads = atoi(optarg); - break; - case 'f': - describeTableFirst = true; - break; - case 'v': - verbose = true; - break; - case 'h': - fprintf(stderr, "Usage: %s -s supertable -t thread -FirstDescribeSTable -Verbose\n", argv[0]); - exit(0); - default: - fprintf(stderr, "Usage: %s -s supertable -t thread -FirstDescribeSTable -Verbose\n", argv[0]); - exit(-1); - } - } - - - // connect to server - TAOS *taos = taos_connect(NULL, "root", "taosdata", NULL, 0); - if (taos == NULL) { - printf("failed to connect to server, reason:%s\n", "null taos" /*taos_errstr(taos)*/); - exit(1); - } - executeSql(taos, "drop database if exists sqlsml"); - executeSql(taos, "create database sqlsml"); - executeSql(taos, "use sqlsml"); - pthread_t* tids = calloc(numThreads, sizeof(pthread_t)); - SThreadArgs* threadArgs = calloc(numThreads, sizeof(SThreadArgs)); - for (int i = 0; i < numThreads; ++i) { - threadArgs[i].numSTables = numSTables; - threadArgs[i].numThreads = numThreads; - threadArgs[i].threadId = i; - threadArgs[i].taos = taos; - } - - int64_t begin = taosGetTimestampUs(); - for (int i = 0; i < numThreads; ++i) { - pthread_create(tids+i, NULL, threadFunc, threadArgs+i); - } - for (int i = 0; i < numThreads; ++i) { - pthread_join(tids[i], NULL); - } - int64_t end = taosGetTimestampUs(); - printf("TIME: %d(ms)\n", (int)((end-begin)/1000)); - printf("THROUGHPUT: %d\n", (int)((numSTables * 1e6) / (end-begin))); - free(threadArgs); - free(tids); - taos_close(taos); - taos_cleanup(); -} diff --git a/tests/examples/c/stream.c b/tests/examples/c/stream.c deleted file mode 100644 index f759da4283bfca69d921f4bbfbb2e78e2123a70c..0000000000000000000000000000000000000000 --- a/tests/examples/c/stream.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include // include TDengine header file -#include - -typedef struct { - char server_ip[64]; - char db_name[64]; - char tbl_name[64]; -} param; - -int g_thread_exit_flag = 0; -void *insert_rows(void *sarg); - -void streamCallBack(void *param, TAOS_RES *res, TAOS_ROW row) { - // in this simple demo, it just print out the result - char temp[128]; - - TAOS_FIELD *fields = taos_fetch_fields(res); - int numFields = taos_num_fields(res); - - taos_print_row(temp, row, fields, numFields); - - printf("\n%s\n", temp); -} - -int main(int argc, char *argv[]) { - TAOS *taos; - char db_name[64]; - char tbl_name[64]; - char sql[1024] = {0}; - - if (argc != 4) { - printf("usage: %s server-ip dbname tblname\n", argv[0]); - exit(0); - } - - strcpy(db_name, argv[2]); - strcpy(tbl_name, argv[3]); - - // create pthread to insert into row per second for stream calc - param *t_param = (param *)malloc(sizeof(param)); - if (NULL == t_param) { - printf("failed to malloc\n"); - exit(1); - } - memset(t_param, 0, sizeof(param)); - strcpy(t_param->server_ip, argv[1]); - strcpy(t_param->db_name, db_name); - strcpy(t_param->tbl_name, tbl_name); - - pthread_t pid; - pthread_create(&pid, NULL, (void *(*)(void *))insert_rows, t_param); - - sleep(3); // waiting for database is created. - // open connection to database - taos = taos_connect(argv[1], "root", "taosdata", db_name, 0); - if (taos == NULL) { - printf("failed to connet to server:%s\n", argv[1]); - free(t_param); - exit(1); - } - - // starting stream calc, - printf("please input stream SQL:[e.g., select count(*) from tblname interval(5s) sliding(2s);]\n"); - fgets(sql, sizeof(sql), stdin); - if (sql[0] == 0) { - printf("input NULL stream SQL, so exit!\n"); - free(t_param); - exit(1); - } - - // param is set to NULL in this demo, it shall be set to the pointer to app context - TAOS_STREAM *pStream = taos_open_stream(taos, sql, streamCallBack, 0, NULL, NULL); - if (NULL == pStream) { - printf("failed to create stream\n"); - free(t_param); - exit(1); - } - - printf("press any key to exit\n"); - getchar(); - - taos_close_stream(pStream); - - g_thread_exit_flag = 1; - pthread_join(pid, NULL); - - taos_close(taos); - free(t_param); - - return 0; -} - -void *insert_rows(void *sarg) { - TAOS * taos; - char command[1024] = {0}; - param *winfo = (param *)sarg; - - if (NULL == winfo) { - printf("para is null!\n"); - exit(1); - } - - taos = taos_connect(winfo->server_ip, "root", "taosdata", NULL, 0); - if (taos == NULL) { - printf("failed to connet to server:%s\n", winfo->server_ip); - exit(1); - } - - // drop database - sprintf(command, "drop database %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to drop database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // create database - sprintf(command, "create database %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to create database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // use database - sprintf(command, "use %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to use database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // create table - sprintf(command, "create table %s (ts timestamp, speed int);", winfo->tbl_name); - if (taos_query(taos, command) != 0) { - printf("failed to create table, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // insert data - int64_t begin = (int64_t)time(NULL); - int index = 0; - while (1) { - if (g_thread_exit_flag) break; - - index++; - sprintf(command, "insert into %s values (%ld, %d)", winfo->tbl_name, (begin + index) * 1000, index); - if (taos_query(taos, command)) { - printf("failed to insert row [%s], reason:%s\n", command, taos_errstr(taos)); - } - sleep(1); - } - - taos_close(taos); - return 0; -} diff --git a/tests/examples/c/subscribe.c b/tests/examples/c/subscribe.c deleted file mode 100644 index d8b76c008f24a4ff1e7827e5b1cb167f013c81c5..0000000000000000000000000000000000000000 --- a/tests/examples/c/subscribe.c +++ /dev/null @@ -1,257 +0,0 @@ -// sample code for TDengine subscribe/consume API -// to compile: gcc -o subscribe subscribe.c -ltaos - -#include -#include -#include -#include // include TDengine header file -#include - -int nTotalRows; - -void print_result(TAOS_RES* res, int blockFetch) { - TAOS_ROW row = NULL; - int num_fields = taos_num_fields(res); - TAOS_FIELD* fields = taos_fetch_fields(res); - int nRows = 0; - - if (blockFetch) { - nRows = taos_fetch_block(res, &row); - // for (int i = 0; i < nRows; i++) { - // taos_print_row(buf, row + i, fields, num_fields); - // puts(buf); - //} - } else { - while ((row = taos_fetch_row(res))) { - char buf[4096] = {0}; - taos_print_row(buf, row, fields, num_fields); - puts(buf); - nRows++; - } - } - - nTotalRows += nRows; - printf("%d rows consumed.\n", nRows); -} - -void subscribe_callback(TAOS_SUB* tsub, TAOS_RES* res, void* param, int code) { print_result(res, *(int*)param); } - -void check_row_count(int line, TAOS_RES* res, int expected) { - int actual = 0; - TAOS_ROW row; - while ((row = taos_fetch_row(res))) { - actual++; - } - if (actual != expected) { - printf("line %d: row count mismatch, expected: %d, actual: %d\n", line, expected, actual); - } else { - printf("line %d: %d rows consumed as expected\n", line, actual); - } -} - -void do_query(TAOS* taos, const char* sql) { - TAOS_RES* res = taos_query(taos, sql); - taos_free_result(res); -} - -void run_test(TAOS* taos) { - do_query(taos, "drop database if exists test;"); - - usleep(100000); - do_query(taos, "create database test;"); - usleep(100000); - do_query(taos, "use test;"); - - usleep(100000); - do_query(taos, "create table meters(ts timestamp, a int) tags(area int);"); - - do_query(taos, "create table t0 using meters tags(0);"); - do_query(taos, "create table t1 using meters tags(1);"); - do_query(taos, "create table t2 using meters tags(2);"); - do_query(taos, "create table t3 using meters tags(3);"); - do_query(taos, "create table t4 using meters tags(4);"); - do_query(taos, "create table t5 using meters tags(5);"); - do_query(taos, "create table t6 using meters tags(6);"); - do_query(taos, "create table t7 using meters tags(7);"); - do_query(taos, "create table t8 using meters tags(8);"); - do_query(taos, "create table t9 using meters tags(9);"); - - do_query(taos, "insert into t0 values('2020-01-01 00:00:00.000', 0);"); - do_query(taos, "insert into t0 values('2020-01-01 00:01:00.000', 0);"); - do_query(taos, "insert into t0 values('2020-01-01 00:02:00.000', 0);"); - do_query(taos, "insert into t1 values('2020-01-01 00:00:00.000', 0);"); - do_query(taos, "insert into t1 values('2020-01-01 00:01:00.000', 0);"); - do_query(taos, "insert into t1 values('2020-01-01 00:02:00.000', 0);"); - do_query(taos, "insert into t1 values('2020-01-01 00:03:00.000', 0);"); - do_query(taos, "insert into t2 values('2020-01-01 00:00:00.000', 0);"); - do_query(taos, "insert into t2 values('2020-01-01 00:01:00.000', 0);"); - do_query(taos, "insert into t2 values('2020-01-01 00:01:01.000', 0);"); - do_query(taos, "insert into t2 values('2020-01-01 00:01:02.000', 0);"); - do_query(taos, "insert into t3 values('2020-01-01 00:01:02.000', 0);"); - do_query(taos, "insert into t4 values('2020-01-01 00:01:02.000', 0);"); - do_query(taos, "insert into t5 values('2020-01-01 00:01:02.000', 0);"); - do_query(taos, "insert into t6 values('2020-01-01 00:01:02.000', 0);"); - do_query(taos, "insert into t7 values('2020-01-01 00:01:02.000', 0);"); - do_query(taos, "insert into t8 values('2020-01-01 00:01:02.000', 0);"); - do_query(taos, "insert into t9 values('2020-01-01 00:01:02.000', 0);"); - - // super tables subscription - usleep(1000000); - - TAOS_SUB* tsub = taos_subscribe(taos, 0, "test", "select * from meters;", NULL, NULL, 0); - TAOS_RES* res = taos_consume(tsub); - check_row_count(__LINE__, res, 18); - - res = taos_consume(tsub); - check_row_count(__LINE__, res, 0); - - do_query(taos, "insert into t0 values('2020-01-01 00:02:00.001', 0);"); - do_query(taos, "insert into t8 values('2020-01-01 00:01:03.000', 0);"); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 2); - - do_query(taos, "insert into t2 values('2020-01-01 00:01:02.001', 0);"); - do_query(taos, "insert into t1 values('2020-01-01 00:03:00.001', 0);"); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 2); - - do_query(taos, "insert into t1 values('2020-01-01 00:03:00.002', 0);"); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 1); - - // keep progress information and restart subscription - taos_unsubscribe(tsub, 1); - do_query(taos, "insert into t0 values('2020-01-01 00:04:00.000', 0);"); - tsub = taos_subscribe(taos, 1, "test", "select * from meters;", NULL, NULL, 0); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 24); - - // keep progress information and continue previous subscription - taos_unsubscribe(tsub, 1); - tsub = taos_subscribe(taos, 0, "test", "select * from meters;", NULL, NULL, 0); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 0); - - // don't keep progress information and continue previous subscription - taos_unsubscribe(tsub, 0); - tsub = taos_subscribe(taos, 0, "test", "select * from meters;", NULL, NULL, 0); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 24); - - // single meter subscription - - taos_unsubscribe(tsub, 0); - tsub = taos_subscribe(taos, 0, "test", "select * from t0;", NULL, NULL, 0); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 5); - - res = taos_consume(tsub); - check_row_count(__LINE__, res, 0); - - do_query(taos, "insert into t0 values('2020-01-01 00:04:00.001', 0);"); - res = taos_consume(tsub); - check_row_count(__LINE__, res, 1); - - taos_unsubscribe(tsub, 0); -} - -int main(int argc, char* argv[]) { - const char* host = "127.0.0.1"; - const char* user = "root"; - const char* passwd = "taosdata"; - const char* sql = "select * from meters;"; - const char* topic = "test-multiple"; - int async = 1, restart = 0, keep = 1, test = 0, blockFetch = 0; - - for (int i = 1; i < argc; i++) { - if (strncmp(argv[i], "-h=", 3) == 0) { - host = argv[i] + 3; - continue; - } - if (strncmp(argv[i], "-u=", 3) == 0) { - user = argv[i] + 3; - continue; - } - if (strncmp(argv[i], "-p=", 3) == 0) { - passwd = argv[i] + 3; - continue; - } - if (strcmp(argv[i], "-sync") == 0) { - async = 0; - continue; - } - if (strcmp(argv[i], "-restart") == 0) { - restart = 1; - continue; - } - if (strcmp(argv[i], "-single") == 0) { - sql = "select * from t0;"; - topic = "test-single"; - continue; - } - if (strcmp(argv[i], "-nokeep") == 0) { - keep = 0; - continue; - } - if (strncmp(argv[i], "-sql=", 5) == 0) { - sql = argv[i] + 5; - topic = "test-custom"; - continue; - } - if (strcmp(argv[i], "-test") == 0) { - test = 1; - continue; - } - if (strcmp(argv[i], "-block-fetch") == 0) { - blockFetch = 1; - continue; - } - } - - TAOS* taos = taos_connect(host, user, passwd, "", 0); - if (taos == NULL) { - printf("failed to connect to db, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - if (test) { - run_test(taos); - taos_close(taos); - exit(0); - } - - taos_select_db(taos, "test"); - TAOS_SUB* tsub = NULL; - if (async) { - // create an asynchronized subscription, the callback function will be called every 1s - tsub = taos_subscribe(taos, restart, topic, sql, subscribe_callback, &blockFetch, 1000); - } else { - // create an synchronized subscription, need to call 'taos_consume' manually - tsub = taos_subscribe(taos, restart, topic, sql, NULL, NULL, 0); - } - - if (tsub == NULL) { - printf("failed to create subscription.\n"); - exit(0); - } - - if (async) { - getchar(); - } else - while (1) { - TAOS_RES* res = taos_consume(tsub); - if (res == NULL) { - printf("failed to consume data."); - break; - } else { - print_result(res, blockFetch); - getchar(); - } - } - - printf("total rows consumed: %d\n", nTotalRows); - taos_unsubscribe(tsub, keep); - taos_close(taos); - - return 0; -} diff --git a/tests/examples/go/taosdemo.go b/tests/examples/go/taosdemo.go deleted file mode 100644 index 543cfcc0f65aad154cc411891a76ae2fdb4e0e02..0000000000000000000000000000000000000000 --- a/tests/examples/go/taosdemo.go +++ /dev/null @@ -1,561 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ -package main - -import ( - "database/sql" - "flag" - "fmt" - "log" - "math/rand" - "os" - "runtime" - "strconv" - "sync" - "time" - - _ "github.com/taosdata/driver-go/taosSql" -) - -const ( - maxLocationSize = 32 - //maxSqlBufSize = 65480 -) - -var locations = [maxLocationSize]string{ - "Beijing", "Shanghai", "Guangzhou", "Shenzhen", - "HangZhou", "Tianjin", "Wuhan", "Changsha", - "Nanjing", "Xian"} - -type config struct { - hostName string - serverPort int - user string - password string - dbName string - supTblName string - tablePrefix string - mode string - numOftables int - numOfRecordsPerTable int - numOfRecordsPerReq int - numOfThreads int - startTimestamp string - startTs int64 - - keep int - days int -} - -var configPara config -var taosDriverName = "taosSql" -var url string - -func init() { - flag.StringVar(&configPara.hostName, "h", "127.0.0.1", "The host to connect to TDengine server.") - flag.IntVar(&configPara.serverPort, "p", 6030, "The TCP/IP port number to use for the connection to TDengine server.") - flag.StringVar(&configPara.user, "u", "root", "The TDengine user name to use when connecting to the server.") - flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.") - flag.StringVar(&configPara.dbName, "d", "test", "Destination database.") - flag.StringVar(&configPara.tablePrefix, "m", "d", "Table prefix name.") - flag.StringVar(&configPara.mode, "M", "r", "mode,r:raw,s:stmt") - flag.IntVar(&configPara.numOftables, "t", 2, "The number of tables.") - flag.IntVar(&configPara.numOfRecordsPerTable, "n", 10, "The number of records per table.") - flag.IntVar(&configPara.numOfRecordsPerReq, "r", 3, "The number of records per request.") - flag.IntVar(&configPara.numOfThreads, "T", 1, "The number of threads.") - flag.StringVar(&configPara.startTimestamp, "s", "2020-10-01 08:00:00", "The start timestamp for one table.") - flag.Parse() - - configPara.keep = 365 * 20 - configPara.days = 30 - configPara.supTblName = "meters" - - startTs, err := time.ParseInLocation("2006-01-02 15:04:05", configPara.startTimestamp, time.Local) - if err == nil { - configPara.startTs = startTs.UnixNano() / 1e6 - } -} - -func printAllArgs() { - fmt.Printf("\n============= args parse result: =============\n") - fmt.Printf("hostName: %v\n", configPara.hostName) - fmt.Printf("serverPort: %v\n", configPara.serverPort) - fmt.Printf("usr: %v\n", configPara.user) - fmt.Printf("password: %v\n", configPara.password) - fmt.Printf("dbName: %v\n", configPara.dbName) - fmt.Printf("mode: %v\n", configPara.mode) - fmt.Printf("tablePrefix: %v\n", configPara.tablePrefix) - fmt.Printf("numOftables: %v\n", configPara.numOftables) - fmt.Printf("numOfRecordsPerTable: %v\n", configPara.numOfRecordsPerTable) - fmt.Printf("numOfRecordsPerReq: %v\n", configPara.numOfRecordsPerReq) - fmt.Printf("numOfThreads: %v\n", configPara.numOfThreads) - fmt.Printf("startTimestamp: %v[%v]\n", configPara.startTimestamp, configPara.startTs) - fmt.Printf("================================================\n") -} - -func main() { - printAllArgs() - fmt.Printf("Please press enter key to continue....\n") - _, _ = fmt.Scanln() - - url = "root:taosdata@/tcp(" + configPara.hostName + ":" + strconv.Itoa(configPara.serverPort) + ")/" - //url = fmt.Sprintf("%s:%s@/tcp(%s:%d)/%s?interpolateParams=true", configPara.user, configPara.password, configPara.hostName, configPara.serverPort, configPara.dbName) - // open connect to taos server - //db, err := sql.Open(taosDriverName, url) - //if err != nil { - // fmt.Println("Open database error: %s\n", err) - // os.Exit(1) - //} - //defer db.Close() - rand.Seed(time.Now().Unix()) - - if configPara.mode == "s" { - fmt.Printf("\n======== start stmt mode test ========\n") - db, err := sql.Open("taosSql", url) - if err != nil { - log.Fatalf("Open database error: %s\n", err) - } - defer db.Close() - demodbStmt := configPara.dbName - demotStmt := "demotStmt" - drop_database_stmt(db, demodbStmt) - create_database_stmt(db, demodbStmt) - use_database_stmt(db, demodbStmt) - create_table_stmt(db, demotStmt) - insert_data_stmt(db, demotStmt) - select_data_stmt(db, demotStmt) - return - } - - createDatabase(configPara.dbName, configPara.supTblName) - fmt.Printf("======== create database success! ========\n\n") - - //create_table(db, stblName) - multiThreadCreateTable(configPara.numOfThreads, configPara.numOftables, configPara.dbName, configPara.tablePrefix) - fmt.Printf("======== create super table and child tables success! ========\n\n") - - //insert_data(db, demot) - multiThreadInsertData(configPara.numOfThreads, configPara.numOftables, configPara.dbName, configPara.tablePrefix) - fmt.Printf("======== insert data into child tables success! ========\n\n") - - //select_data(db, demot) - selectTest(configPara.dbName, configPara.tablePrefix, configPara.supTblName) - fmt.Printf("======== select data success! ========\n\n") - - fmt.Printf("======== end demo ========\n") -} - -func createDatabase(dbName string, supTblName string) { - db, err := sql.Open(taosDriverName, url) - if err != nil { - fmt.Printf("Open database error: %s\n", err) - os.Exit(1) - } - defer db.Close() - - // drop database if exists - sqlStr := "drop database if exists " + dbName - _, err = db.Exec(sqlStr) - checkErr(err, sqlStr) - - time.Sleep(time.Second) - - // create database - sqlStr = "create database " + dbName + " keep " + strconv.Itoa(configPara.keep) + " days " + strconv.Itoa(configPara.days) - _, err = db.Exec(sqlStr) - checkErr(err, sqlStr) - - // use database - //sqlStr = "use " + dbName - //_, err = db.Exec(sqlStr) - //checkErr(err, sqlStr) - - sqlStr = "create table if not exists " + dbName + "." + supTblName + " (ts timestamp, current float, voltage int, phase float) tags(location binary(64), groupId int);" - _, err = db.Exec(sqlStr) - checkErr(err, sqlStr) -} - -func multiThreadCreateTable(threads int, nTables int, dbName string, tablePrefix string) { - st := time.Now().UnixNano() - - if threads < 1 { - threads = 1 - } - - a := nTables / threads - if a < 1 { - threads = nTables - a = 1 - } - - b := nTables % threads - - last := 0 - endTblId := 0 - wg := sync.WaitGroup{} - for i := 0; i < threads; i++ { - startTblId := last - if i < b { - endTblId = last + a - } else { - endTblId = last + a - 1 - } - last = endTblId + 1 - wg.Add(1) - go createTable(dbName, tablePrefix, startTblId, endTblId, &wg) - } - wg.Wait() - - et := time.Now().UnixNano() - fmt.Printf("create tables spent duration: %6.6fs\n", (float32(et-st))/1e9) -} - -func createTable(dbName string, childTblPrefix string, startTblId int, endTblId int, wg *sync.WaitGroup) { - //fmt.Printf("subThread[%d]: create table from %d to %d \n", unix.Gettid(), startTblId, endTblId) - // windows.GetCurrentThreadId() - - db, err := sql.Open(taosDriverName, url) - if err != nil { - fmt.Printf("Open database error: %s\n", err) - os.Exit(1) - } - defer db.Close() - - for i := startTblId; i <= endTblId; i++ { - sqlStr := "create table if not exists " + dbName + "." + childTblPrefix + strconv.Itoa(i) + " using " + dbName + ".meters tags('" + locations[i%maxLocationSize] + "', " + strconv.Itoa(i) + ");" - //fmt.Printf("sqlStr: %v\n", sqlStr) - _, err = db.Exec(sqlStr) - checkErr(err, sqlStr) - } - wg.Done() - runtime.Goexit() -} - -func generateRowData(ts int64) string { - voltage := rand.Int() % 1000 - current := 200 + rand.Float32() - phase := rand.Float32() - values := "( " + strconv.FormatInt(ts, 10) + ", " + strconv.FormatFloat(float64(current), 'f', 6, 64) + ", " + strconv.Itoa(voltage) + ", " + strconv.FormatFloat(float64(phase), 'f', 6, 64) + " ) " - return values -} - -func insertData(dbName string, childTblPrefix string, startTblId int, endTblId int, wg *sync.WaitGroup) { - //fmt.Printf("subThread[%d]: insert data to table from %d to %d \n", unix.Gettid(), startTblId, endTblId) - // windows.GetCurrentThreadId() - - db, err := sql.Open(taosDriverName, url) - if err != nil { - fmt.Printf("Open database error: %s\n", err) - os.Exit(1) - } - defer db.Close() - - tmpTs := configPara.startTs - //rand.New(rand.NewSource(time.Now().UnixNano())) - for tID := startTblId; tID <= endTblId; tID++ { - totalNum := 0 - for { - sqlStr := "insert into " + dbName + "." + childTblPrefix + strconv.Itoa(tID) + " values " - currRowNum := 0 - for { - tmpTs += 1000 - valuesOfRow := generateRowData(tmpTs) - currRowNum += 1 - totalNum += 1 - - sqlStr = fmt.Sprintf("%s %s", sqlStr, valuesOfRow) - - if currRowNum >= configPara.numOfRecordsPerReq || totalNum >= configPara.numOfRecordsPerTable { - break - } - } - - res, err := db.Exec(sqlStr) - checkErr(err, sqlStr) - - count, err := res.RowsAffected() - checkErr(err, "rows affected") - - if count != int64(currRowNum) { - fmt.Printf("insert data, expect affected:%d, actual:%d\n", currRowNum, count) - os.Exit(1) - } - - if totalNum >= configPara.numOfRecordsPerTable { - break - } - } - } - - wg.Done() - runtime.Goexit() -} - -func multiThreadInsertData(threads int, nTables int, dbName string, tablePrefix string) { - st := time.Now().UnixNano() - - if threads < 1 { - threads = 1 - } - - a := nTables / threads - if a < 1 { - threads = nTables - a = 1 - } - - b := nTables % threads - - last := 0 - endTblId := 0 - wg := sync.WaitGroup{} - for i := 0; i < threads; i++ { - startTblId := last - if i < b { - endTblId = last + a - } else { - endTblId = last + a - 1 - } - last = endTblId + 1 - wg.Add(1) - go insertData(dbName, tablePrefix, startTblId, endTblId, &wg) - } - wg.Wait() - - et := time.Now().UnixNano() - fmt.Printf("insert data spent duration: %6.6fs\n", (float32(et-st))/1e9) -} - -func selectTest(dbName string, tbPrefix string, supTblName string) { - db, err := sql.Open(taosDriverName, url) - if err != nil { - fmt.Printf("Open database error: %s\n", err) - os.Exit(1) - } - defer db.Close() - - // select sql 1 - limit := 3 - offset := 0 - sqlStr := "select * from " + dbName + "." + supTblName + " limit " + strconv.Itoa(limit) + " offset " + strconv.Itoa(offset) - rows, err := db.Query(sqlStr) - checkErr(err, sqlStr) - - defer rows.Close() - fmt.Printf("query sql: %s\n", sqlStr) - for rows.Next() { - var ( - ts string - current float32 - voltage int - phase float32 - location string - groupid int - ) - err := rows.Scan(&ts, ¤t, &voltage, &phase, &location, &groupid) - if err != nil { - checkErr(err, "rows scan fail") - } - - fmt.Printf("ts:%s\t current:%f\t voltage:%d\t phase:%f\t location:%s\t groupid:%d\n", ts, current, voltage, phase, location, groupid) - } - // check iteration error - if rows.Err() != nil { - checkErr(err, "rows next iteration error") - } - - // select sql 2 - sqlStr = "select avg(voltage), min(voltage), max(voltage) from " + dbName + "." + tbPrefix + strconv.Itoa(rand.Int()%configPara.numOftables) - rows, err = db.Query(sqlStr) - checkErr(err, sqlStr) - - defer rows.Close() - fmt.Printf("\nquery sql: %s\n", sqlStr) - for rows.Next() { - var ( - voltageAvg float32 - voltageMin int - voltageMax int - ) - err := rows.Scan(&voltageAvg, &voltageMin, &voltageMax) - if err != nil { - checkErr(err, "rows scan fail") - } - - fmt.Printf("avg(voltage):%f\t min(voltage):%d\t max(voltage):%d\n", voltageAvg, voltageMin, voltageMax) - } - // check iteration error - if rows.Err() != nil { - checkErr(err, "rows next iteration error") - } - - // select sql 3 - sqlStr = "select last(*) from " + dbName + "." + supTblName - rows, err = db.Query(sqlStr) - checkErr(err, sqlStr) - - defer rows.Close() - fmt.Printf("\nquery sql: %s\n", sqlStr) - for rows.Next() { - var ( - lastTs string - lastCurrent float32 - lastVoltage int - lastPhase float32 - ) - err := rows.Scan(&lastTs, &lastCurrent, &lastVoltage, &lastPhase) - if err != nil { - checkErr(err, "rows scan fail") - } - - fmt.Printf("last(ts):%s\t last(current):%f\t last(voltage):%d\t last(phase):%f\n", lastTs, lastCurrent, lastVoltage, lastPhase) - } - // check iteration error - if rows.Err() != nil { - checkErr(err, "rows next iteration error") - } -} -func drop_database_stmt(db *sql.DB, demodb string) { - st := time.Now().Nanosecond() - // drop test db - res, err := db.Exec("drop database if exists " + demodb) - checkErr(err, "drop database "+demodb) - - affectd, err := res.RowsAffected() - checkErr(err, "drop db, res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) -} - -func create_database_stmt(db *sql.DB, demodb string) { - st := time.Now().Nanosecond() - // create database - //var stmt interface{} - stmt, err := db.Prepare("create database ?") - checkErr(err, "create db, db.Prepare") - - //var res driver.Result - res, err := stmt.Exec(demodb) - checkErr(err, "create db, stmt.Exec") - - //fmt.Printf("Query OK, %d row(s) affected()", res.RowsAffected()) - affectd, err := res.RowsAffected() - checkErr(err, "create db, res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) -} - -func use_database_stmt(db *sql.DB, demodb string) { - st := time.Now().Nanosecond() - // create database - //var stmt interface{} - stmt, err := db.Prepare("use " + demodb) - checkErr(err, "use db, db.Prepare") - - res, err := stmt.Exec() - checkErr(err, "use db, stmt.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "use db, res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) -} - -func create_table_stmt(db *sql.DB, demot string) { - st := time.Now().Nanosecond() - // create table - // (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double) - stmt, err := db.Prepare("create table ? (? timestamp, ? int, ? binary(10), ? tinyint, ? bool, ? binary(8), ? float, ? double)") - checkErr(err, "create table db.Prepare") - - res, err := stmt.Exec(demot, "ts", "id", "name", "len", "flag", "notes", "fv", "dv") - checkErr(err, "create table stmt.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "create table res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) -} - -func insert_data_stmt(db *sql.DB, demot string) { - st := time.Now().Nanosecond() - // insert data into table - stmt, err := db.Prepare("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?)") - checkErr(err, "insert db.Prepare") - - res, err := stmt.Exec(demot, "now", 1000, "'haidian'", 6, true, "'AI world'", 6987.654, 321.987, - "now+1s", 1001, "'changyang'", 7, false, "'DeepMode'", 12356.456, 128634.456, - "now+2s", 1002, "'chuangping'", 8, true, "'database'", 3879.456, 65433478.456) - checkErr(err, "insert data, stmt.Exec") - - affectd, err := res.RowsAffected() - checkErr(err, "res.RowsAffected") - - et := time.Now().Nanosecond() - fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) -} - -func select_data_stmt(db *sql.DB, demot string) { - st := time.Now().Nanosecond() - - stmt, err := db.Prepare("select ?, ?, ?, ?, ?, ?, ?, ? from ?") // go binary mode - checkErr(err, "db.Prepare") - - rows, err := stmt.Query("ts", "id", "name", "len", "flag", "notes", "fv", "dv", demot) - checkErr(err, "stmt.Query") - - fmt.Printf("%10s%s%8s %5s %8s%s %s %10s%s %7s%s %8s%s %11s%s %14s%s\n", " ", "ts", " ", "id", " ", "name", " ", "len", " ", "flag", " ", "notes", " ", "fv", " ", " ", "dv") - var affectd int - for rows.Next() { - var ts string - var name string - var id int - var len int8 - var flag bool - var notes string - var fv float32 - var dv float64 - - err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv) - //fmt.Println("start scan fields from row.rs, &fv:", &fv) - //err = rows.Scan(&fv) - checkErr(err, "rows.Scan") - - fmt.Printf("%s\t", ts) - fmt.Printf("%d\t", id) - fmt.Printf("%10s\t", name) - fmt.Printf("%d\t", len) - fmt.Printf("%t\t", flag) - fmt.Printf("%s\t", notes) - fmt.Printf("%06.3f\t", fv) - fmt.Printf("%09.6f\n", dv) - - affectd++ - - } - - et := time.Now().Nanosecond() - fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1e9) -} -func checkErr(err error, prompt string) { - if err != nil { - fmt.Printf("%s\n", prompt) - panic(err) - } -} diff --git a/tests/examples/lua/OpenResty/conf/nginx.conf b/tests/examples/lua/OpenResty/conf/nginx.conf deleted file mode 100644 index 960cac606a49e5964a900f815eb76e7f228078eb..0000000000000000000000000000000000000000 --- a/tests/examples/lua/OpenResty/conf/nginx.conf +++ /dev/null @@ -1,21 +0,0 @@ -worker_processes 1; -user root; -error_log logs/error.log; -events { - worker_connections 1024; -} - -http { - lua_package_path '$prefix/lua/?.lua;$prefix/rest/?.lua;$prefix/rest/?/init.lua;;'; - lua_package_cpath "$prefix/so/?.so;;"; - lua_code_cache on; - server { - listen 7000; - server_name restapi; - charset utf-8; - lua_need_request_body on; - location ~ ^/api/([-_a-zA-Z0-9/]+) { - content_by_lua_file rest/$1.lua; - } - } -} diff --git a/tests/examples/lua/OpenResty/logs/.gitignore b/tests/examples/lua/OpenResty/logs/.gitignore deleted file mode 100644 index ad8530e1c3e3c88fcce3b50abf7cc006333f5522..0000000000000000000000000000000000000000 --- a/tests/examples/lua/OpenResty/logs/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore diff --git a/tests/examples/lua/OpenResty/rest/config.lua b/tests/examples/lua/OpenResty/rest/config.lua deleted file mode 100644 index 72a4fd8ec687430e5f3d0a798dc4fb3b2d95a942..0000000000000000000000000000000000000000 --- a/tests/examples/lua/OpenResty/rest/config.lua +++ /dev/null @@ -1,10 +0,0 @@ -local config = { - host = "127.0.0.1", - port = 6030, - database = "", - user = "root", - password = "taosdata", - max_packet_size = 1024 * 1024 , - connection_pool_size = 64 -} -return config diff --git a/tests/examples/lua/OpenResty/rest/tdpool/init.lua b/tests/examples/lua/OpenResty/rest/tdpool/init.lua deleted file mode 100644 index ebf8e91756539cc8af5db38232a40bf42aeaa245..0000000000000000000000000000000000000000 --- a/tests/examples/lua/OpenResty/rest/tdpool/init.lua +++ /dev/null @@ -1,72 +0,0 @@ -local _M = {} -local driver = require "luaconnector51" -local water_mark = 0 -local occupied = 0 -local connection_pool = {} - -function _M.new(o,config) - o = o or {} - o.connection_pool = connection_pool - o.water_mark = water_mark - o.occupied = occupied - if #connection_pool == 0 then - - for i = 1, config.connection_pool_size do - local res = driver.connect(config) - if res.code ~= 0 then - ngx.log(ngx.ERR, "connect--- failed:"..res.error) - return nil - else - local object = {obj = res.conn, state = 0} - table.insert(o.connection_pool,i, object) - ngx.log(ngx.INFO, "add connection, now pool size:"..#(o.connection_pool)) - end - end - - end - - return setmetatable(o, { __index = _M }) -end - -function _M:get_connection() - - local connection_obj - - for i = 1, #connection_pool do - connection_obj = connection_pool[i] - if connection_obj.state == 0 then - connection_obj.state = 1 - occupied = occupied +1 - if occupied > water_mark then - water_mark = occupied - end - return connection_obj["obj"] - end - end - - ngx.log(ngx.ERR,"ALERT! NO FREE CONNECTION.") - - return nil -end - -function _M:get_water_mark() - - return water_mark -end - -function _M:release_connection(conn) - - local connection_obj - - for i = 1, #connection_pool do - connection_obj = connection_pool[i] - - if connection_obj["obj"] == conn then - connection_obj["state"] = 0 - occupied = occupied -1 - return - end - end -end - -return _M diff --git a/tests/examples/lua/OpenResty/rest/test.lua b/tests/examples/lua/OpenResty/rest/test.lua deleted file mode 100644 index 9b2169a2da656ea34f60e99c8904b5f224da3dd4..0000000000000000000000000000000000000000 --- a/tests/examples/lua/OpenResty/rest/test.lua +++ /dev/null @@ -1,91 +0,0 @@ -local driver = require "luaconnector51" -local cjson = require "cjson" -local Pool = require "tdpool" -local config = require "config" -ngx.say("start time:"..os.time()) - -local pool = Pool.new(Pool,config) -local conn = pool:get_connection() - -local res = driver.query(conn,"drop database if exists nginx") -if res.code ~=0 then - ngx.say("drop db--- failed: "..res.error) -else - ngx.say("drop db--- pass.") -end -res = driver.query(conn,"create database nginx") -if res.code ~=0 then - ngx.say("create db--- failed: "..res.error) - -else - ngx.say("create db--- pass.") -end - -res = driver.query(conn,"use nginx") -if res.code ~=0 then - ngx.say("select db--- failed: "..res.error) -else - ngx.say("select db--- pass.") -end - -res = driver.query(conn,"create table m1 (ts timestamp, speed int, owner binary(20), mark nchar(30))") -if res.code ~=0 then - ngx.say("create table---failed: "..res.error) - -else - ngx.say("create table--- pass.") -end - -res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 0, 'robotspace', '世界人民大团结万岁'), ('2019-09-01 00:00:00.002',1,'Hilink','⾾⾿⿀⿁⿂⿃⿄⿅⿆⿇⿈⿉⿊⿋⿌⿍⿎⿏⿐⿑⿒⿓⿔⿕'),('2019-09-01 00:00:00.003',2,'Harmony', '₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵')") -if res.code ~=0 then - ngx.say("insert records failed: "..res.error) - return -else - if(res.affected == 3) then - ngx.say("insert records--- pass") - else - ngx.say("insert records---failed: expect 3 affected records, actually affected "..res.affected) - end -end - -res = driver.query(conn,"select * from m1") - -if res.code ~=0 then - ngx.say("select failed: "..res.error) - return -else - ngx.say(cjson.encode(res)) - if (#(res.item) == 3) then - ngx.say("select--- pass") - else - ngx.say("select--- failed: expect 3 affected records, actually received "..#(res.item)) - end - -end ---[[ -local flag = false -function query_callback(res) - if res.code ~=0 then - ngx.say("async_query_callback--- failed:"..res.error) - else - if(res.affected == 3) then - ngx.say("async_query_callback, insert records--- pass") - else - ngx.say("async_query_callback, insert records---failed: expect 3 affected records, actually affected "..res.affected) - end - end - flag = true -end - -driver.query_a(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 3, 'robotspace'),('2019-09-01 00:00:00.006', 4, 'Hilink'),('2019-09-01 00:00:00.007', 6, 'Harmony')", query_callback) - -while not flag do - ngx.say("i am here once...") - ngx.sleep(0.001) -- time unit is second -end ---]] - -ngx.say("pool water_mark:"..pool:get_water_mark()) - -pool:release_connection(conn) -ngx.say("end time:"..os.time()) diff --git a/tests/examples/lua/OpenResty/so/luaconnector51.so b/tests/examples/lua/OpenResty/so/luaconnector51.so deleted file mode 100755 index a17c0318bd1e9196311ca97b20a8dde4fc1835a6..0000000000000000000000000000000000000000 Binary files a/tests/examples/lua/OpenResty/so/luaconnector51.so and /dev/null differ diff --git a/tests/examples/lua/README.md b/tests/examples/lua/README.md deleted file mode 100644 index bdc88edbd7b5d6798a8df6530ea82d24eb22915b..0000000000000000000000000000000000000000 --- a/tests/examples/lua/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# TDengine driver connector for Lua - -It's a Lua implementation for [TDengine](https://github.com/taosdata/TDengine), an open-sourced big data platform designed and optimized for the Internet of Things (IoT), Connected Cars, Industrial IoT, and IT Infrastructure and Application Monitoring. You may need to install Lua5.3 . -As TDengine is built with lua-enable, the built-in lua module conflicts with external lua. The following commands require TDengine built with lua-disable. -To disable built-in lua: -mkdir debug && cd debug -cmake .. -DBUILD_LUA=false && cmake --build . -## Lua Dependencies -- Lua: -``` -https://www.lua.org/ -``` - -## Run with Lua Sample - -Build driver lib: -``` -./build.sh -``` -Run lua sample: -``` -lua test.lua -``` - -## Run performance test: -``` -time lua benchmark.lua -``` -## OpenResty Dependencies -- OpenResty: -``` -http://openresty.org -``` -## Run with OpenResty Sample -**This section demonstrates how to get binary file for connector. To be convenient for trial, an connector has been put into OpenResty work directory. -Because of difference on C API between Lua5.3 and Lua5.1, the files needed by connector for OpenResty are stored in local source directory and configured in script build.sh.** - -Build driver lib: -``` -cd lua51 -./build.sh -``` -Run OpenResty sample: -``` -cd .. -cd OpenResty -sudo openresty -p . -curl http://127.0.0.1:7000/api/test -``` - diff --git a/tests/examples/lua/benchmark.lua b/tests/examples/lua/benchmark.lua deleted file mode 100644 index 900e7891d81d5de2d723a9ebd9accf3317b2413a..0000000000000000000000000000000000000000 --- a/tests/examples/lua/benchmark.lua +++ /dev/null @@ -1,67 +0,0 @@ -local driver = require "luaconnector" - -local config = { - password = "taosdata", - host = "127.0.0.1", - port = 6030, - database = "", - user = "root", - - max_packet_size = 1024 * 1024 -} - -local conn -local res = driver.connect(config) -if res.code ~=0 then - print("connect--- failed: "..res.error) - return -else - conn = res.conn - print("connect--- pass.") -end - -local res = driver.query(conn,"drop database if exists demo") - -res = driver.query(conn,"create database demo") -if res.code ~=0 then - print("create db--- failed: "..res.error) - return -else - print("create db--- pass.") -end - -res = driver.query(conn,"use demo") -if res.code ~=0 then - print("select db--- failed: "..res.error) - return -else - print("select db--- pass.") -end - -res = driver.query(conn,"create table m1 (ts timestamp, speed int,owner binary(20))") -if res.code ~=0 then - print("create table---failed: "..res.error) - return -else - print("create table--- pass.") -end - -local base = 1617330000000 -local index =0 -local count = 100000 -local t -while( index < count ) -do - t = base + index - local q=string.format([[insert into m1 values (%d,0,'robotspace')]],t) -res = driver.query(conn,q) -if res.code ~=0 then - print("insert records failed: "..res.error) - return -else - -end - index = index+1 -end -print(string.format([["Done. %d records has been stored."]],count)) -driver.close(conn) diff --git a/tests/examples/lua/build.sh b/tests/examples/lua/build.sh deleted file mode 100755 index 9d00c6842515415034ce0b5dc71d5d6af9ffc881..0000000000000000000000000000000000000000 --- a/tests/examples/lua/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -lua_header_installed=`apt-cache policy liblua5.3-dev|grep Installed|grep none > /dev/null; echo $?` -if [ "$lua_header_installed" = "0" ]; then - echo "If need, please input root password to install liblua5.3-dev for build the connector.." - sudo apt install -y liblua5.3-dev -fi - -gcc -std=c99 lua_connector.c -fPIC -shared -o luaconnector.so -Wall -ltaos -I/usr/include/lua5.3 - diff --git a/tests/examples/lua/lua51/build.sh b/tests/examples/lua/lua51/build.sh deleted file mode 100755 index 3b52ed14489a636fe7a867ed086199647fa650df..0000000000000000000000000000000000000000 --- a/tests/examples/lua/lua51/build.sh +++ /dev/null @@ -1,2 +0,0 @@ -gcc -std=c99 lua_connector51.c -fPIC -shared -o luaconnector51.so -Wall -ltaos - diff --git a/tests/examples/lua/lua51/lauxlib.h b/tests/examples/lua/lua51/lauxlib.h deleted file mode 100644 index a44f0272b3ab0745b0ce798d377b40d2cce113cd..0000000000000000000000000000000000000000 --- a/tests/examples/lua/lua51/lauxlib.h +++ /dev/null @@ -1,161 +0,0 @@ -/* -** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $ -** Auxiliary functions for building Lua libraries -** See Copyright Notice in lua.h -*/ - - -#ifndef lauxlib_h -#define lauxlib_h - - -#include -#include - -#include "lua.h" - - -/* extra error code for `luaL_load' */ -#define LUA_ERRFILE (LUA_ERRERR+1) - -typedef struct luaL_Reg { - const char *name; - lua_CFunction func; -} luaL_Reg; - -LUALIB_API void (luaL_openlib) (lua_State *L, const char *libname, - const luaL_Reg *l, int nup); -LUALIB_API void (luaL_register) (lua_State *L, const char *libname, - const luaL_Reg *l); -LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e); -LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e); -LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname); -LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg); -LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg, - size_t *l); -LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg, - const char *def, size_t *l); -LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg); -LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def); - -LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg); -LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg, - lua_Integer def); - -LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg); -LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t); -LUALIB_API void (luaL_checkany) (lua_State *L, int narg); - -LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname); -LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname); - -LUALIB_API void (luaL_where) (lua_State *L, int lvl); -LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...); - -LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def, - const char *const lst[]); - -/* pre-defined references */ -#define LUA_NOREF (-2) -#define LUA_REFNIL (-1) - -LUALIB_API int (luaL_ref) (lua_State *L, int t); -LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref); - -LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename); -LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz, - const char *name); -LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s); - -LUALIB_API lua_State *(luaL_newstate) (void); - - -LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p, - const char *r); - -LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx, - const char *fname, int szhint); - -/* From Lua 5.2. */ -LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname); -LUALIB_API int luaL_execresult(lua_State *L, int stat); -LUALIB_API int (luaL_loadfilex) (lua_State *L, const char *filename, - const char *mode); -LUALIB_API int (luaL_loadbufferx) (lua_State *L, const char *buff, size_t sz, - const char *name, const char *mode); -LUALIB_API void luaL_traceback (lua_State *L, lua_State *L1, const char *msg, - int level); -LUALIB_API void (luaL_setfuncs) (lua_State *L, const luaL_Reg *l, int nup); -LUALIB_API void (luaL_pushmodule) (lua_State *L, const char *modname, - int sizehint); -LUALIB_API void *(luaL_testudata) (lua_State *L, int ud, const char *tname); -LUALIB_API void (luaL_setmetatable) (lua_State *L, const char *tname); - - -/* -** =============================================================== -** some useful macros -** =============================================================== -*/ - -#define luaL_argcheck(L, cond,numarg,extramsg) \ - ((void)((cond) || luaL_argerror(L, (numarg), (extramsg)))) -#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) -#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) -#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n))) -#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d))) -#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n))) -#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d))) - -#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i))) - -#define luaL_dofile(L, fn) \ - (luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0)) - -#define luaL_dostring(L, s) \ - (luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) - -#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n))) - -#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n))) - -/* From Lua 5.2. */ -#define luaL_newlibtable(L, l) \ - lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) -#define luaL_newlib(L, l) (luaL_newlibtable(L, l), luaL_setfuncs(L, l, 0)) - -/* -** {====================================================== -** Generic Buffer manipulation -** ======================================================= -*/ - - - -typedef struct luaL_Buffer { - char *p; /* current position in buffer */ - int lvl; /* number of strings in the stack (level) */ - lua_State *L; - char buffer[LUAL_BUFFERSIZE]; -} luaL_Buffer; - -#define luaL_addchar(B,c) \ - ((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \ - (*(B)->p++ = (char)(c))) - -/* compatibility only */ -#define luaL_putchar(B,c) luaL_addchar(B,c) - -#define luaL_addsize(B,n) ((B)->p += (n)) - -LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B); -LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B); -LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l); -LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s); -LUALIB_API void (luaL_addvalue) (luaL_Buffer *B); -LUALIB_API void (luaL_pushresult) (luaL_Buffer *B); - - -/* }====================================================== */ - -#endif diff --git a/tests/examples/lua/lua51/lua.h b/tests/examples/lua/lua51/lua.h deleted file mode 100644 index 9dcafd690655868115ce53dff26599f5845b12c5..0000000000000000000000000000000000000000 --- a/tests/examples/lua/lua51/lua.h +++ /dev/null @@ -1,404 +0,0 @@ -/* -** $Id: lua.h,v 1.218.1.5 2008/08/06 13:30:12 roberto Exp $ -** Lua - An Extensible Extension Language -** Lua.org, PUC-Rio, Brazil (http://www.lua.org) -** See Copyright Notice at the end of this file -*/ - - -#ifndef lua_h -#define lua_h - -#include -#include - - -#include "luaconf.h" - - -#define LUA_VERSION "Lua 5.1" -#define LUA_RELEASE "Lua 5.1.4" -#define LUA_VERSION_NUM 501 -#define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio" -#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes" - - -/* mark for precompiled code (`Lua') */ -#define LUA_SIGNATURE "\033Lua" - -/* option for multiple returns in `lua_pcall' and `lua_call' */ -#define LUA_MULTRET (-1) - - -/* -** pseudo-indices -*/ -#define LUA_REGISTRYINDEX (-10000) -#define LUA_ENVIRONINDEX (-10001) -#define LUA_GLOBALSINDEX (-10002) -#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i)) - - -/* thread status */ -#define LUA_OK 0 -#define LUA_YIELD 1 -#define LUA_ERRRUN 2 -#define LUA_ERRSYNTAX 3 -#define LUA_ERRMEM 4 -#define LUA_ERRERR 5 - - -typedef struct lua_State lua_State; - -typedef int (*lua_CFunction) (lua_State *L); - - -/* -** functions that read/write blocks when loading/dumping Lua chunks -*/ -typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz); - -typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud); - - -/* -** prototype for memory-allocation functions -*/ -typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize); - - -/* -** basic types -*/ -#define LUA_TNONE (-1) - -#define LUA_TNIL 0 -#define LUA_TBOOLEAN 1 -#define LUA_TLIGHTUSERDATA 2 -#define LUA_TNUMBER 3 -#define LUA_TSTRING 4 -#define LUA_TTABLE 5 -#define LUA_TFUNCTION 6 -#define LUA_TUSERDATA 7 -#define LUA_TTHREAD 8 - - - -/* minimum Lua stack available to a C function */ -#define LUA_MINSTACK 20 - - -/* -** generic extra include file -*/ -#if defined(LUA_USER_H) -#include LUA_USER_H -#endif - - -/* type of numbers in Lua */ -typedef LUA_NUMBER lua_Number; - - -/* type for integer functions */ -typedef LUA_INTEGER lua_Integer; - - - -/* -** state manipulation -*/ -LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud); -LUA_API void (lua_close) (lua_State *L); -LUA_API lua_State *(lua_newthread) (lua_State *L); - -LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf); - - -/* -** basic stack manipulation -*/ -LUA_API int (lua_gettop) (lua_State *L); -LUA_API void (lua_settop) (lua_State *L, int idx); -LUA_API void (lua_pushvalue) (lua_State *L, int idx); -LUA_API void (lua_remove) (lua_State *L, int idx); -LUA_API void (lua_insert) (lua_State *L, int idx); -LUA_API void (lua_replace) (lua_State *L, int idx); -LUA_API int (lua_checkstack) (lua_State *L, int sz); - -LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n); - - -/* -** access functions (stack -> C) -*/ - -LUA_API int (lua_isnumber) (lua_State *L, int idx); -LUA_API int (lua_isstring) (lua_State *L, int idx); -LUA_API int (lua_iscfunction) (lua_State *L, int idx); -LUA_API int (lua_isuserdata) (lua_State *L, int idx); -LUA_API int (lua_type) (lua_State *L, int idx); -LUA_API const char *(lua_typename) (lua_State *L, int tp); - -LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2); -LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2); -LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2); - -LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); -LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); -LUA_API int (lua_toboolean) (lua_State *L, int idx); -LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); -LUA_API size_t (lua_objlen) (lua_State *L, int idx); -LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); -LUA_API void *(lua_touserdata) (lua_State *L, int idx); -LUA_API lua_State *(lua_tothread) (lua_State *L, int idx); -LUA_API const void *(lua_topointer) (lua_State *L, int idx); - - -/* -** push functions (C -> stack) -*/ -LUA_API void (lua_pushnil) (lua_State *L); -LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n); -LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n); -LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l); -LUA_API void (lua_pushstring) (lua_State *L, const char *s); -LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt, - va_list argp); -LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...); -LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n); -LUA_API void (lua_pushboolean) (lua_State *L, int b); -LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p); -LUA_API int (lua_pushthread) (lua_State *L); - - -/* -** get functions (Lua -> stack) -*/ -LUA_API void (lua_gettable) (lua_State *L, int idx); -LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k); -LUA_API void (lua_rawget) (lua_State *L, int idx); -LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n); -LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec); -LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz); -LUA_API int (lua_getmetatable) (lua_State *L, int objindex); -LUA_API void (lua_getfenv) (lua_State *L, int idx); - - -/* -** set functions (stack -> Lua) -*/ -LUA_API void (lua_settable) (lua_State *L, int idx); -LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k); -LUA_API void (lua_rawset) (lua_State *L, int idx); -LUA_API void (lua_rawseti) (lua_State *L, int idx, int n); -LUA_API int (lua_setmetatable) (lua_State *L, int objindex); -LUA_API int (lua_setfenv) (lua_State *L, int idx); - - -/* -** `load' and `call' functions (load and run Lua code) -*/ -LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); -LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); -LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); -LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt, - const char *chunkname); - -LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data); - - -/* -** coroutine functions -*/ -LUA_API int (lua_yield) (lua_State *L, int nresults); -LUA_API int (lua_resume) (lua_State *L, int narg); -LUA_API int (lua_status) (lua_State *L); - -/* -** garbage-collection function and options -*/ - -#define LUA_GCSTOP 0 -#define LUA_GCRESTART 1 -#define LUA_GCCOLLECT 2 -#define LUA_GCCOUNT 3 -#define LUA_GCCOUNTB 4 -#define LUA_GCSTEP 5 -#define LUA_GCSETPAUSE 6 -#define LUA_GCSETSTEPMUL 7 -#define LUA_GCISRUNNING 9 - -LUA_API int (lua_gc) (lua_State *L, int what, int data); - - -/* -** miscellaneous functions -*/ - -LUA_API int (lua_error) (lua_State *L); - -LUA_API int (lua_next) (lua_State *L, int idx); - -LUA_API void (lua_concat) (lua_State *L, int n); - -LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud); -LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); - -LUA_API void lua_setexdata(lua_State *L, void *exdata); -LUA_API void *lua_getexdata(lua_State *L); - - -/* -** =============================================================== -** some useful macros -** =============================================================== -*/ - -#define lua_pop(L,n) lua_settop(L, -(n)-1) - -#define lua_newtable(L) lua_createtable(L, 0, 0) - -#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n))) - -#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0) - -#define lua_strlen(L,i) lua_objlen(L, (i)) - -#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION) -#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) -#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) -#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) -#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) -#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) -#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE) -#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0) - -#define lua_pushliteral(L, s) \ - lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1) - -#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s)) -#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s)) - -#define lua_tostring(L,i) lua_tolstring(L, (i), NULL) - - - -/* -** compatibility macros and functions -*/ - -#define lua_open() luaL_newstate() - -#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX) - -#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) - -#define lua_Chunkreader lua_Reader -#define lua_Chunkwriter lua_Writer - - -/* hack */ -LUA_API void lua_setlevel (lua_State *from, lua_State *to); - - -/* -** {====================================================================== -** Debug API -** ======================================================================= -*/ - - -/* -** Event codes -*/ -#define LUA_HOOKCALL 0 -#define LUA_HOOKRET 1 -#define LUA_HOOKLINE 2 -#define LUA_HOOKCOUNT 3 -#define LUA_HOOKTAILRET 4 - - -/* -** Event masks -*/ -#define LUA_MASKCALL (1 << LUA_HOOKCALL) -#define LUA_MASKRET (1 << LUA_HOOKRET) -#define LUA_MASKLINE (1 << LUA_HOOKLINE) -#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT) - -typedef struct lua_Debug lua_Debug; /* activation record */ - - -/* Functions to be called by the debuger in specific events */ -typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); - - -LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar); -LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar); -LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n); -LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n); -LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n); -LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n); -LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count); -LUA_API lua_Hook lua_gethook (lua_State *L); -LUA_API int lua_gethookmask (lua_State *L); -LUA_API int lua_gethookcount (lua_State *L); - -/* From Lua 5.2. */ -LUA_API void *lua_upvalueid (lua_State *L, int idx, int n); -LUA_API void lua_upvaluejoin (lua_State *L, int idx1, int n1, int idx2, int n2); -LUA_API int lua_loadx (lua_State *L, lua_Reader reader, void *dt, - const char *chunkname, const char *mode); -LUA_API const lua_Number *lua_version (lua_State *L); -LUA_API void lua_copy (lua_State *L, int fromidx, int toidx); -LUA_API lua_Number lua_tonumberx (lua_State *L, int idx, int *isnum); -LUA_API lua_Integer lua_tointegerx (lua_State *L, int idx, int *isnum); - -/* From Lua 5.3. */ -LUA_API int lua_isyieldable (lua_State *L); - - -struct lua_Debug { - int event; - const char *name; /* (n) */ - const char *namewhat; /* (n) `global', `local', `field', `method' */ - const char *what; /* (S) `Lua', `C', `main', `tail' */ - const char *source; /* (S) */ - int currentline; /* (l) */ - int nups; /* (u) number of upvalues */ - int linedefined; /* (S) */ - int lastlinedefined; /* (S) */ - char short_src[LUA_IDSIZE]; /* (S) */ - /* private part */ - int i_ci; /* active function */ -}; - -/* }====================================================================== */ - - -/****************************************************************************** -* Copyright (C) 1994-2008 Lua.org, PUC-Rio. All rights reserved. -* -* Permission is hereby granted, free of charge, to any person obtaining -* a copy of this software and associated documentation files (the -* "Software"), to deal in the Software without restriction, including -* without limitation the rights to use, copy, modify, merge, publish, -* distribute, sublicense, and/or sell copies of the Software, and to -* permit persons to whom the Software is furnished to do so, subject to -* the following conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -******************************************************************************/ - - -#endif diff --git a/tests/examples/lua/lua51/lua_connector51.c b/tests/examples/lua/lua51/lua_connector51.c deleted file mode 100644 index 7aad42f29343306516c6d8973b76060f3e1e6dfe..0000000000000000000000000000000000000000 --- a/tests/examples/lua/lua51/lua_connector51.c +++ /dev/null @@ -1,387 +0,0 @@ -#include -#include -#include -#include -#include "lua.h" -#include "lauxlib.h" -#include "lualib.h" -#include - -struct cb_param{ - lua_State* state; - int callback; - void * stream; -}; - -struct async_query_callback_param{ - lua_State* state; - int callback; -}; - -static int l_connect(lua_State *L){ - TAOS * taos=NULL; - const char* host; - const char* database; - const char* user; - const char* password; - int port; - - luaL_checktype(L, 1, LUA_TTABLE); - - lua_getfield(L, 1,"host"); - if (lua_isstring(L,-1)){ - host = lua_tostring(L, -1); - // printf("host = %s\n", host); - } - - lua_getfield(L, 1, "port"); - if (lua_isnumber(L, -1)){ - port = lua_tonumber(L, -1); - //printf("port = %d\n", port); - } - - lua_getfield(L, 1, "database"); - if (lua_isstring(L, -1)){ - database = lua_tostring(L, -1); - //printf("database = %s\n", database); - } - - lua_getfield(L, 1, "user"); - if (lua_isstring(L, -1)){ - user = lua_tostring(L, -1); - //printf("user = %s\n", user); - } - - lua_getfield(L, 1, "password"); - if (lua_isstring(L, -1)){ - password = lua_tostring(L, -1); - //printf("password = %s\n", password); - } - - lua_settop(L,0); - - taos_init(); - - lua_newtable(L); - int table_index = lua_gettop(L); - - taos = taos_connect(host, user,password,database, port); - if (taos == NULL) { - printf("failed to connect server, reason:%s\n", taos_errstr(taos)); - - lua_pushinteger(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "conn"); - }else{ - // printf("success to connect server\n"); - lua_pushinteger(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,taos); - lua_setfield(L, table_index, "conn"); - } - - return 1; -} - -static int l_query(lua_State *L){ - TAOS *taos= (TAOS*)lua_topointer(L,1); - const char* s = lua_tostring(L, 2); - TAOS_RES *result; - lua_newtable(L); - int table_index = lua_gettop(L); - - // printf("receive command:%s\r\n",s); - result = taos_query(taos, s); - int32_t code = taos_errno(result); - if( code != 0){ - printf("failed, reason:%s\n", taos_errstr(result)); - lua_pushinteger(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(result)); - lua_setfield(L, table_index, "error"); - - return 1; - - }else{ - //printf("success to query.\n"); - TAOS_ROW row; - int rows = 0; - int num_fields = taos_field_count(result); - const TAOS_FIELD *fields = taos_fetch_fields(result); - - const int affectRows = taos_affected_rows(result); - // printf(" affect rows:%d\r\n", affectRows); - lua_pushinteger(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushinteger(L, affectRows); - lua_setfield(L, table_index, "affected"); - lua_newtable(L); - - while ((row = taos_fetch_row(result))) { - //printf("row index:%d\n",rows); - rows++; - - lua_pushnumber(L,rows); - lua_newtable(L); - - for (int i = 0; i < num_fields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - int32_t* length = taos_fetch_lengths(result); - switch (fields[i].type) { - case TSDB_DATA_TYPE_UTINYINT: - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_USMALLINT: - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_UINT: - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_UBIGINT: - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_JSON: - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]); - lua_pushlstring(L,(char *)row[i], length[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_NULL: - default: - lua_pushnil(L); - break; - } - - lua_settable(L,-3); - } - - lua_settable(L,-3); - } - taos_free_result(result); - } - - lua_setfield(L, table_index, "item"); - return 1; -} - -void async_query_callback(void *param, TAOS_RES *result, int code){ - struct async_query_callback_param* p = (struct async_query_callback_param*) param; - - //printf("\nin c,numfields:%d\n", numFields); - //printf("\nin c, code:%d\n", code); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - lua_newtable(L); - int table_index = lua_gettop(L); - if( code < 0){ - printf("failed, reason:%s\n", taos_errstr(result)); - lua_pushinteger(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L,"something is wrong");// taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - }else{ - //printf("success to async query.\n"); - const int affectRows = taos_affected_rows(result); - //printf(" affect rows:%d\r\n", affectRows); - lua_pushinteger(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushinteger(L, affectRows); - lua_setfield(L, table_index, "affected"); - } - - lua_call(L, 1, 0); -} - -static int l_async_query(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - // int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct async_query_callback_param *p = malloc(sizeof(struct async_query_callback_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - taos_query_a(taos,sqlstr,async_query_callback,p); - - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, "ok"); - lua_setfield(L, table_index, "error"); - - return 1; -} - -void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){ - struct cb_param* p = (struct cb_param*) param; - TAOS_FIELD *fields = taos_fetch_fields(result); - int numFields = taos_num_fields(result); - - // printf("\nnumfields:%d\n", numFields); - //printf("\n\r-----------------------------------------------------------------------------------\n"); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - - lua_newtable(L); - - for (int i = 0; i < numFields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - - switch (fields[i].type) { - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - default: - lua_pushnil(L); - break; - } - - lua_settable(L, -3); - } - - lua_call(L, 1, 0); - - // printf("-----------------------------------------------------------------------------------\n\r"); -} - -static int l_open_stream(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct cb_param *p = malloc(sizeof(struct cb_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL); - if (s == NULL) { - printf("failed to open stream, reason:%s\n", taos_errstr(taos)); - free(p); - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "stream"); - }else{ - // printf("success to open stream\n"); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - p->stream = s; - lua_pushlightuserdata(L,p); - lua_setfield(L, table_index, "stream");//stream has different content in lua and c. - } - - return 1; -} - -static int l_close_stream(lua_State *L){ - //TODO:get stream and free cb_param - struct cb_param *p = lua_touserdata(L,1); - taos_close_stream(p->stream); - free(p); - return 0; -} - -static int l_close(lua_State *L){ - TAOS *taos= (TAOS*)lua_topointer(L,1); - lua_newtable(L); - int table_index = lua_gettop(L); - - if(taos == NULL){ - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, "null pointer."); - lua_setfield(L, table_index, "error"); - }else{ - taos_close(taos); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, "done."); - lua_setfield(L, table_index, "error"); - } - return 1; -} - -static const struct luaL_Reg lib[] = { - {"connect", l_connect}, - {"query", l_query}, - {"query_a",l_async_query}, - {"close", l_close}, - {"open_stream", l_open_stream}, - {"close_stream", l_close_stream}, - {NULL, NULL} -}; - -extern int luaopen_luaconnector51(lua_State* L) -{ - // luaL_register(L, "luaconnector51", lib); - lua_newtable (L); - luaL_setfuncs(L,lib,0); - return 1; -} diff --git a/tests/examples/lua/lua51/luaconf.h b/tests/examples/lua/lua51/luaconf.h deleted file mode 100644 index c72893fd152e23c2a413c2da1d31be7b860b2a39..0000000000000000000000000000000000000000 --- a/tests/examples/lua/lua51/luaconf.h +++ /dev/null @@ -1,152 +0,0 @@ -/* -** Configuration header. -** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef luaconf_h -#define luaconf_h - -#ifndef WINVER -#define WINVER 0x0501 -#endif -#include -#include - -/* Default path for loading Lua and C modules with require(). */ -#if defined(_WIN32) -/* -** In Windows, any exclamation mark ('!') in the path is replaced by the -** path of the directory of the executable file of the current process. -*/ -#define LUA_LDIR "!\\lua\\" -#define LUA_CDIR "!\\" -#define LUA_PATH_DEFAULT \ - ".\\?.lua;" "!\\lualib\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" -#define LUA_CPATH_DEFAULT \ - ".\\?.dll;" "!\\lualib\\?.so;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" -#else -/* -** Note to distribution maintainers: do NOT patch the following lines! -** Please read ../doc/install.html#distro and pass PREFIX=/usr instead. -*/ -#ifndef LUA_MULTILIB -#define LUA_MULTILIB "lib" -#endif -#ifndef LUA_LMULTILIB -#define LUA_LMULTILIB "lib" -#endif -#define LUA_LROOT "/usr/local" -#define LUA_LUADIR "/lua/5.1/" -#define LUA_LJDIR "/luajit-2.1.0-beta3/" - -#ifdef LUA_ROOT -#define LUA_JROOT LUA_ROOT -#define LUA_RLDIR LUA_ROOT "/share" LUA_LUADIR -#define LUA_RCDIR LUA_ROOT "/" LUA_MULTILIB LUA_LUADIR -#define LUA_RLPATH ";" LUA_RLDIR "?.lua;" LUA_RLDIR "?/init.lua" -#define LUA_RCPATH ";" LUA_RCDIR "?.so" -#else -#define LUA_JROOT LUA_LROOT -#define LUA_RLPATH -#define LUA_RCPATH -#endif - -#define LUA_JPATH ";" LUA_JROOT "/share" LUA_LJDIR "?.lua" -#define LUA_LLDIR LUA_LROOT "/share" LUA_LUADIR -#define LUA_LCDIR LUA_LROOT "/" LUA_LMULTILIB LUA_LUADIR -#define LUA_LLPATH ";" LUA_LLDIR "?.lua;" LUA_LLDIR "?/init.lua" -#define LUA_LCPATH1 ";" LUA_LCDIR "?.so" -#define LUA_LCPATH2 ";" LUA_LCDIR "loadall.so" - -#define LUA_PATH_DEFAULT "./?.lua" LUA_JPATH LUA_LLPATH LUA_RLPATH -#define LUA_CPATH_DEFAULT "./?.so" LUA_LCPATH1 LUA_RCPATH LUA_LCPATH2 -#endif - -/* Environment variable names for path overrides and initialization code. */ -#define LUA_PATH "LUA_PATH" -#define LUA_CPATH "LUA_CPATH" -#define LUA_INIT "LUA_INIT" - -/* Special file system characters. */ -#if defined(_WIN32) -#define LUA_DIRSEP "\\" -#else -#define LUA_DIRSEP "/" -#endif -#define LUA_PATHSEP ";" -#define LUA_PATH_MARK "?" -#define LUA_EXECDIR "!" -#define LUA_IGMARK "-" -#define LUA_PATH_CONFIG \ - LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" \ - LUA_EXECDIR "\n" LUA_IGMARK "\n" - -/* Quoting in error messages. */ -#define LUA_QL(x) "'" x "'" -#define LUA_QS LUA_QL("%s") - -/* Various tunables. */ -#define LUAI_MAXSTACK 65500 /* Max. # of stack slots for a thread (<64K). */ -#define LUAI_MAXCSTACK 8000 /* Max. # of stack slots for a C func (<10K). */ -#define LUAI_GCPAUSE 200 /* Pause GC until memory is at 200%. */ -#define LUAI_GCMUL 200 /* Run GC at 200% of allocation speed. */ -#define LUA_MAXCAPTURES 32 /* Max. pattern captures. */ - -/* Configuration for the frontend (the luajit executable). */ -#if defined(luajit_c) -#define LUA_PROGNAME "luajit" /* Fallback frontend name. */ -#define LUA_PROMPT "> " /* Interactive prompt. */ -#define LUA_PROMPT2 ">> " /* Continuation prompt. */ -#define LUA_MAXINPUT 512 /* Max. input line length. */ -#endif - -/* Note: changing the following defines breaks the Lua 5.1 ABI. */ -#define LUA_INTEGER ptrdiff_t -#define LUA_IDSIZE 60 /* Size of lua_Debug.short_src. */ -/* -** Size of lauxlib and io.* on-stack buffers. Weird workaround to avoid using -** unreasonable amounts of stack space, but still retain ABI compatibility. -** Blame Lua for depending on BUFSIZ in the ABI, blame **** for wrecking it. -*/ -#define LUAL_BUFFERSIZE (BUFSIZ > 16384 ? 8192 : BUFSIZ) - -/* The following defines are here only for compatibility with luaconf.h -** from the standard Lua distribution. They must not be changed for LuaJIT. -*/ -#define LUA_NUMBER_DOUBLE -#define LUA_NUMBER double -#define LUAI_UACNUMBER double -#define LUA_NUMBER_SCAN "%lf" -#define LUA_NUMBER_FMT "%.14g" -#define lua_number2str(s, n) sprintf((s), LUA_NUMBER_FMT, (n)) -#define LUAI_MAXNUMBER2STR 32 -#define LUA_INTFRMLEN "l" -#define LUA_INTFRM_T long - -/* Linkage of public API functions. */ -#if defined(LUA_BUILD_AS_DLL) -#if defined(LUA_CORE) || defined(LUA_LIB) -#define LUA_API __declspec(dllexport) -#else -#define LUA_API __declspec(dllimport) -#endif -#else -#define LUA_API extern -#endif - -#define LUALIB_API LUA_API - -/* Support for internal assertions. */ -#if defined(LUA_USE_ASSERT) || defined(LUA_USE_APICHECK) -#include -#endif -#ifdef LUA_USE_ASSERT -#define lua_assert(x) assert(x) -#endif -#ifdef LUA_USE_APICHECK -#define luai_apicheck(L, o) { (void)L; assert(o); } -#else -#define luai_apicheck(L, o) { (void)L; } -#endif - -#endif diff --git a/tests/examples/lua/lua51/luajit.h b/tests/examples/lua/lua51/luajit.h deleted file mode 100644 index ae14c4ffebdff746b22b2274abf33b5c9d601b26..0000000000000000000000000000000000000000 --- a/tests/examples/lua/lua51/luajit.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -** LuaJIT -- a Just-In-Time Compiler for Lua. http://luajit.org/ -** -** Copyright (C) 2005-2017 Mike Pall. All rights reserved. -** -** Permission is hereby granted, free of charge, to any person obtaining -** a copy of this software and associated documentation files (the -** "Software"), to deal in the Software without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Software, and to -** permit persons to whom the Software is furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be -** included in all copies or substantial portions of the Software. -** -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -** -** [ MIT license: http://www.opensource.org/licenses/mit-license.php ] -*/ - -#ifndef _LUAJIT_H -#define _LUAJIT_H - -#include "lua.h" - -#define OPENRESTY_LUAJIT - -#define LUAJIT_VERSION "LuaJIT 2.1.0-beta3" -#define LUAJIT_VERSION_NUM 20100 /* Version 2.1.0 = 02.01.00. */ -#define LUAJIT_VERSION_SYM luaJIT_version_2_1_0_beta3 -#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2017 Mike Pall" -#define LUAJIT_URL "http://luajit.org/" - -/* Modes for luaJIT_setmode. */ -#define LUAJIT_MODE_MASK 0x00ff - -enum { - LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ - LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ - - LUAJIT_MODE_FUNC, /* Change mode for a function. */ - LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ - LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ - - LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ - - LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ - - LUAJIT_MODE_MAX -}; - -/* Flags or'ed in to the mode. */ -#define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ -#define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ -#define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ - -/* LuaJIT public C API. */ - -/* Control the JIT engine. */ -LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); - -/* Low-overhead profiling API. */ -typedef void (*luaJIT_profile_callback)(void *data, lua_State *L, - int samples, int vmstate); -LUA_API void luaJIT_profile_start(lua_State *L, const char *mode, - luaJIT_profile_callback cb, void *data); -LUA_API void luaJIT_profile_stop(lua_State *L); -LUA_API const char *luaJIT_profile_dumpstack(lua_State *L, const char *fmt, - int depth, size_t *len); - -/* Enforce (dynamic) linker error for version mismatches. Call from main. */ -LUA_API void LUAJIT_VERSION_SYM(void); - -#endif diff --git a/tests/examples/lua/lua51/lualib.h b/tests/examples/lua/lua51/lualib.h deleted file mode 100644 index 6aceabe59218d1863e6493bb77b9bed18bc18bdc..0000000000000000000000000000000000000000 --- a/tests/examples/lua/lua51/lualib.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -** Standard library header. -** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h -*/ - -#ifndef _LUALIB_H -#define _LUALIB_H - -#include "lua.h" - -#define LUA_FILEHANDLE "FILE*" - -#define LUA_COLIBNAME "coroutine" -#define LUA_MATHLIBNAME "math" -#define LUA_STRLIBNAME "string" -#define LUA_TABLIBNAME "table" -#define LUA_IOLIBNAME "io" -#define LUA_OSLIBNAME "os" -#define LUA_LOADLIBNAME "package" -#define LUA_DBLIBNAME "debug" -#define LUA_BITLIBNAME "bit" -#define LUA_JITLIBNAME "jit" -#define LUA_FFILIBNAME "ffi" -#define LUA_THRLIBNAME "thread" - -LUALIB_API int luaopen_base(lua_State *L); -LUALIB_API int luaopen_math(lua_State *L); -LUALIB_API int luaopen_string(lua_State *L); -LUALIB_API int luaopen_table(lua_State *L); -LUALIB_API int luaopen_io(lua_State *L); -LUALIB_API int luaopen_os(lua_State *L); -LUALIB_API int luaopen_package(lua_State *L); -LUALIB_API int luaopen_debug(lua_State *L); -LUALIB_API int luaopen_bit(lua_State *L); -LUALIB_API int luaopen_jit(lua_State *L); -LUALIB_API int luaopen_ffi(lua_State *L); - -LUALIB_API void luaL_openlibs(lua_State *L); - -#ifndef lua_assert -#define lua_assert(x) ((void)0) -#endif - -#endif diff --git a/tests/examples/lua/lua_connector.c b/tests/examples/lua/lua_connector.c deleted file mode 100644 index 035b17eb2a729c5267996fe7e3b7d3e1cf122d3e..0000000000000000000000000000000000000000 --- a/tests/examples/lua/lua_connector.c +++ /dev/null @@ -1,386 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -struct cb_param{ - lua_State* state; - int callback; - void * stream; -}; - -struct async_query_callback_param{ - lua_State* state; - int callback; -}; - -static int l_connect(lua_State *L){ - TAOS * taos=NULL; - const char* host; - const char* database; - const char* user; - const char* password; - int port; - - luaL_checktype(L, 1, LUA_TTABLE); - - lua_getfield(L, 1,"host"); - if (lua_isstring(L,-1)){ - host = lua_tostring(L, -1); - // printf("host = %s\n", host); - } - - lua_getfield(L, 1, "port"); - if (lua_isinteger(L, -1)){ - port = lua_tointeger(L, -1); - //printf("port = %d\n", port); - } - - lua_getfield(L, 1, "database"); - if (lua_isstring(L, -1)){ - database = lua_tostring(L, -1); - //printf("database = %s\n", database); - } - - lua_getfield(L, 1, "user"); - if (lua_isstring(L, -1)){ - user = lua_tostring(L, -1); - //printf("user = %s\n", user); - } - - lua_getfield(L, 1, "password"); - if (lua_isstring(L, -1)){ - password = lua_tostring(L, -1); - //printf("password = %s\n", password); - } - - lua_settop(L,0); - - taos_init(); - - lua_newtable(L); - int table_index = lua_gettop(L); - - taos = taos_connect(host, user,password,database, port); - if (taos == NULL) { - printf("failed to connect server, reason:%s\n", taos_errstr(taos)); - - lua_pushinteger(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "conn"); - }else{ - // printf("success to connect server\n"); - lua_pushinteger(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,taos); - lua_setfield(L, table_index, "conn"); - } - - return 1; -} - -static int l_query(lua_State *L){ - TAOS *taos= (TAOS*)lua_topointer(L,1); - const char* s = lua_tostring(L, 2); - TAOS_RES *result; - lua_newtable(L); - int table_index = lua_gettop(L); - - // printf("receive command:%s\r\n",s); - result = taos_query(taos, s); - int32_t code = taos_errno(result); - if( code != 0){ - printf("failed, reason:%s\n", taos_errstr(result)); - lua_pushinteger(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(result)); - lua_setfield(L, table_index, "error"); - - return 1; - - }else{ - //printf("success to query.\n"); - TAOS_ROW row; - int rows = 0; - int num_fields = taos_field_count(result); - const TAOS_FIELD *fields = taos_fetch_fields(result); - - const int affectRows = taos_affected_rows(result); - // printf(" affect rows:%d\r\n", affectRows); - lua_pushinteger(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushinteger(L, affectRows); - lua_setfield(L, table_index, "affected"); - lua_newtable(L); - - while ((row = taos_fetch_row(result))) { - //printf("row index:%d\n",rows); - rows++; - - lua_pushnumber(L,rows); - lua_newtable(L); - - for (int i = 0; i < num_fields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - int32_t* length = taos_fetch_lengths(result); - switch (fields[i].type) { - case TSDB_DATA_TYPE_UTINYINT: - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_USMALLINT: - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_UINT: - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_UBIGINT: - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_JSON: - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - //printf("type:%d, max len:%d, current len:%d\n",fields[i].type, fields[i].bytes, length[i]); - lua_pushlstring(L,(char *)row[i], length[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_NULL: - default: - lua_pushnil(L); - break; - } - - lua_settable(L,-3); - } - - lua_settable(L,-3); - } - taos_free_result(result); - } - - lua_setfield(L, table_index, "item"); - return 1; -} - -void async_query_callback(void *param, TAOS_RES *result, int code){ - struct async_query_callback_param* p = (struct async_query_callback_param*) param; - - //printf("\nin c,numfields:%d\n", numFields); - //printf("\nin c, code:%d\n", code); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - lua_newtable(L); - int table_index = lua_gettop(L); - if( code < 0){ - printf("failed, reason:%s\n", taos_errstr(result)); - lua_pushinteger(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L,"something is wrong");// taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - }else{ - //printf("success to async query.\n"); - const int affectRows = taos_affected_rows(result); - //printf(" affect rows:%d\r\n", affectRows); - lua_pushinteger(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushinteger(L, affectRows); - lua_setfield(L, table_index, "affected"); - } - - lua_call(L, 1, 0); -} - -static int l_async_query(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - // int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct async_query_callback_param *p = malloc(sizeof(struct async_query_callback_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - taos_query_a(taos,sqlstr,async_query_callback,p); - - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, "ok"); - lua_setfield(L, table_index, "error"); - - return 1; -} - -void stream_cb(void *param, TAOS_RES *result, TAOS_ROW row){ - struct cb_param* p = (struct cb_param*) param; - TAOS_FIELD *fields = taos_fetch_fields(result); - int numFields = taos_num_fields(result); - - // printf("\nnumfields:%d\n", numFields); - //printf("\n\r-----------------------------------------------------------------------------------\n"); - - lua_State *L = p->state; - lua_rawgeti(L, LUA_REGISTRYINDEX, p->callback); - - lua_newtable(L); - - for (int i = 0; i < numFields; ++i) { - if (row[i] == NULL) { - continue; - } - - lua_pushstring(L,fields[i].name); - - switch (fields[i].type) { - case TSDB_DATA_TYPE_TINYINT: - lua_pushinteger(L,*((char *)row[i])); - break; - case TSDB_DATA_TYPE_SMALLINT: - lua_pushinteger(L,*((short *)row[i])); - break; - case TSDB_DATA_TYPE_INT: - lua_pushinteger(L,*((int *)row[i])); - break; - case TSDB_DATA_TYPE_BIGINT: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_FLOAT: - lua_pushnumber(L,*((float *)row[i])); - break; - case TSDB_DATA_TYPE_DOUBLE: - lua_pushnumber(L,*((double *)row[i])); - break; - case TSDB_DATA_TYPE_BINARY: - case TSDB_DATA_TYPE_NCHAR: - lua_pushstring(L,(char *)row[i]); - break; - case TSDB_DATA_TYPE_TIMESTAMP: - lua_pushinteger(L,*((int64_t *)row[i])); - break; - case TSDB_DATA_TYPE_BOOL: - lua_pushinteger(L,*((char *)row[i])); - break; - default: - lua_pushnil(L); - break; - } - - lua_settable(L, -3); - } - - lua_call(L, 1, 0); - - // printf("-----------------------------------------------------------------------------------\n\r"); -} - -static int l_open_stream(lua_State *L){ - int r = luaL_ref(L, LUA_REGISTRYINDEX); - TAOS * taos = (TAOS*)lua_topointer(L,1); - const char * sqlstr = lua_tostring(L,2); - int stime = luaL_checknumber(L,3); - - lua_newtable(L); - int table_index = lua_gettop(L); - - struct cb_param *p = malloc(sizeof(struct cb_param)); - p->state = L; - p->callback=r; - // printf("r:%d, L:%d\n",r,L); - void * s = taos_open_stream(taos,sqlstr,stream_cb,stime,p,NULL); - if (s == NULL) { - printf("failed to open stream, reason:%s\n", taos_errstr(taos)); - free(p); - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - lua_pushlightuserdata(L,NULL); - lua_setfield(L, table_index, "stream"); - }else{ - // printf("success to open stream\n"); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, taos_errstr(taos)); - lua_setfield(L, table_index, "error"); - p->stream = s; - lua_pushlightuserdata(L,p); - lua_setfield(L, table_index, "stream");//stream has different content in lua and c. - } - - return 1; -} - -static int l_close_stream(lua_State *L){ - //TODO:get stream and free cb_param - struct cb_param *p = lua_touserdata(L,1); - taos_close_stream(p->stream); - free(p); - return 0; -} - -static int l_close(lua_State *L){ - TAOS *taos= (TAOS*)lua_topointer(L,1); - lua_newtable(L); - int table_index = lua_gettop(L); - - if(taos == NULL){ - lua_pushnumber(L, -1); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, "null pointer."); - lua_setfield(L, table_index, "error"); - }else{ - taos_close(taos); - lua_pushnumber(L, 0); - lua_setfield(L, table_index, "code"); - lua_pushstring(L, "done."); - lua_setfield(L, table_index, "error"); - } - return 1; -} - -static const struct luaL_Reg lib[] = { - {"connect", l_connect}, - {"query", l_query}, - {"query_a",l_async_query}, - {"close", l_close}, - {"open_stream", l_open_stream}, - {"close_stream", l_close_stream}, - {NULL, NULL} -}; - -extern int luaopen_luaconnector(lua_State* L) -{ - luaL_newlib(L, lib); - - return 1; -} diff --git a/tests/examples/lua/test.lua b/tests/examples/lua/test.lua deleted file mode 100644 index c124b50a4dbd954ab47098e527bd2d35ee44384e..0000000000000000000000000000000000000000 --- a/tests/examples/lua/test.lua +++ /dev/null @@ -1,172 +0,0 @@ -local driver = require "luaconnector" - -local config = { - host = "127.0.0.1", - port = 6030, - database = "", - user = "root", - password = "taosdata", - max_packet_size = 1024 * 1024 -} - -local conn -local res = driver.connect(config) -if res.code ~=0 then - print("connect--- failed: "..res.error) - return -else - conn = res.conn - print("connect--- pass.") -end - -local res = driver.query(conn,"drop database if exists demo") - -res = driver.query(conn,"create database demo") -if res.code ~=0 then - print("create db--- failed: "..res.error) - return -else - print("create db--- pass.") -end - -res = driver.query(conn,"use demo") -if res.code ~=0 then - print("select db--- failed: "..res.error) - return -else - print("select db--- pass.") -end - -res = driver.query(conn,"create table m1 (ts timestamp, speed int, owner binary(20), mark nchar(30))") -if res.code ~=0 then - print("create table---failed: "..res.error) - return -else - print("create table--- pass.") -end - -res = driver.query(conn,"insert into m1 values ('2019-09-01 00:00:00.001', 0, 'robotspace', '世界人民大团结万岁'), ('2019-09-01 00:00:00.002', 1, 'Hilink', '⾾⾿⿀⿁⿂⿃⿄⿅⿆⿇⿈⿉⿊⿋⿌⿍⿎⿏⿐⿑⿒⿓⿔⿕'),('2019-09-01 00:00:00.003', 2, 'Harmony', '₠₡₢₣₤₥₦₧₨₩₪₫€₭₮₯₰₱₲₳₴₵')") -if res.code ~=0 then - print("insert records failed: "..res.error) - return -else - if(res.affected == 3) then - print("insert records--- pass") - else - print("insert records---failed: expect 3 affected records, actually affected "..res.affected) - end -end - -res = driver.query(conn,"select * from m1") - -if res.code ~=0 then - print("select failed: "..res.error) - return -else - if (#(res.item) == 3) then - print("select--- pass") - print(res.item[1].mark) - print(res.item[2].mark) - print(res.item[3].mark) - - else - print("select--- failed: expect 3 affected records, actually received "..#(res.item)) - end - -end - -res = driver.query(conn,"CREATE TABLE thermometer (ts timestamp, degree double) TAGS(location binary(20), type int)") -if res.code ~=0 then - print(res.error) - return -else - print("create super table--- pass") -end -res = driver.query(conn,"CREATE TABLE therm1 USING thermometer TAGS ('beijing', 1)") -if res.code ~=0 then - print(res.error) - return -else - print("create table--- pass") -end - -res = driver.query(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.001', 20),('2019-09-01 00:00:00.002', 21)") - -if res.code ~=0 then - print(res.error) - return -else - if(res.affected == 2) then - print("insert records--- pass") - else - print("insert records---failed: expect 2 affected records, actually affected "..res.affected) - end -end - -res = driver.query(conn,"SELECT COUNT(*) count, AVG(degree) AS av, MAX(degree), MIN(degree) FROM thermometer WHERE location='beijing' or location='tianjin' GROUP BY location, type") -if res.code ~=0 then - print("select from super table--- failed:"..res.error) - return -else - print("select from super table--- pass") - for i = 1, #(res.item) do - print("res:"..res.item[i].count) - end -end - -function async_query_callback(res) - if res.code ~=0 then - print("async_query_callback--- failed:"..res.error) - return - else - - if(res.affected == 3) then - print("async_query_callback, insert records--- pass") - else - print("async_query_callback, insert records---failed: expect 3 affected records, actually affected "..res.affected) - end - - end -end - -driver.query_a(conn,"INSERT INTO therm1 VALUES ('2019-09-01 00:00:00.005', 100),('2019-09-01 00:00:00.006', 101),('2019-09-01 00:00:00.007', 102)", async_query_callback) - - -function stream_callback(t) - print("------------------------") - print("continuous query result:") - for key, value in pairs(t) do - print("key:"..key..", value:"..value) - end -end - -local stream -res = driver.open_stream(conn,"SELECT COUNT(*) as count, AVG(degree) as avg, MAX(degree) as max, MIN(degree) as min FROM thermometer interval(2s) sliding(2s);)",0, stream_callback) -if res.code ~=0 then - print("open stream--- failed:"..res.error) - return -else - print("open stream--- pass") - stream = res.stream -end - -print("From now on we start continous insert in an definite (infinite if you want) loop.") -local loop_index = 0 -while loop_index < 30 do - local t = os.time()*1000 - local v = loop_index - res = driver.query(conn,string.format("INSERT INTO therm1 VALUES (%d, %d)",t,v)) - - if res.code ~=0 then - print("continous insertion--- failed:" .. res.error) - return - else - --print("insert successfully, affected:"..res.affected) - end - os.execute("sleep " .. 1) - loop_index = loop_index + 1 -end - -driver.close_stream(stream) - -driver.close(conn) diff --git a/tests/examples/matlab/TDengineDemo.m b/tests/examples/matlab/TDengineDemo.m deleted file mode 100644 index b44777512bb20d6231d92dd19645d39b77ac80ca..0000000000000000000000000000000000000000 --- a/tests/examples/matlab/TDengineDemo.m +++ /dev/null @@ -1,128 +0,0 @@ -%% Connect to TDengine -clear; -fprintf("Connecting to TDengine..."); -dbName = 'tsdb'; -user = 'root'; -password = 'taosdata'; -jdbcDriverName = 'com.taosdata.jdbc.TSDBDriver'; -jdbcUrl = 'jdbc:TSDB://192.168.1.113:0/'; -conn = database(dbName, user, password, jdbcDriverName, jdbcUrl) -if isempty(conn.Message) - fprintf("Connection is successfully established!\n"); -else - fprintf("Failed to connect to server: %s\n", conn.Message); -end - -%% Query a table in TDengine, and store the results in a MATLAB table object 'tb1' -% Please note that the select() function retrieves all rows in a table/supertale into MATLAB -sql = "select ts, distance1 from device1 limit 5"; -fprintf("Execute query: %s\n", sql); -tic -tb1 = select(conn, sql); -timeused = toc; -fprintf("\tQuery completed!\n\tNumber of rows retrieved: %d\n\tNumber of columns in each row: %d\n\tTime used: %g\n", height(tb1), width(tb1), timeused); - -% To go a bit further, we can convert the MATLAB table object to a MATLAB matrix object -data = table2array(tb1) - -%% Query table names in a TDengine supertable, and store the results in a MATLAB table object 'stbmeta' -sql = "select tbname from devices limit 10"; -fprintf("Execute query: %s\n", sql); -tic; -stbmeta = select(conn, sql); -timeused = toc; -fprintf("\tTables in supertable 'devices': %t", stbmeta); -fprintf("\tQuery completed!\n\tNumber of rows retrieved: %d\n\tNumber of columns in each row: %d\n\tTime used: %g\n", height(stbmeta), width(stbmeta), timeused); - -%% Query a TDengine supertable, and stores the results in a MATLAB table object 'stb' -sql = "select ts, distance1 from devices"; -fprintf("Execute query: %s\n", sql); -tic; -stb = select(conn, sql); -timeused = toc; -fprintf("\tQuery completed!\n\tNumber of rows retrieved: %d\n\tNumber of columns in each row: %d\n\tTime used: %g\n", height(stb), width(stb), timeused); - -%% Query TDengine using cursors and specify the number of rows to fetch -sql = 'select * from device1'; -rowLimit = 5; -fprintf("Execute query: %s with row limit set to %d\n", sql, rowLimit); -tic; -% Get cursor -cur = exec(conn, sql); -% Fetch data -cur = fetch(cur, rowLimit); -data = cur.Data -timeused = toc; -fprintf("\tQuery completed!\n\tNumber of rows retrieved: %d\n\tNumber of columns in each row: %d\n\tTime used: %g\n", size(data, 1), size(data, 2), timeused); - -%% Query specific columns in a TDenigine table 'device1', and stores the results directly in a MATLAB cell array 'data' -sql = 'SELECT * FROM device1 order by ts asc'; -fprintf("Execute query: %s\n", sql); -tic; -data = fetch(conn, sql); -timeused = toc; -fprintf("\tQuery completed!\n\tNumber of rows retrieved: %d\n\tNumber of columns in each row: %d\n\tTime used: %g\n", size(data, 1), size(data, 2), timeused); -% Let's now convert the cell array 'data' into some matrices, and make a plot of column 'c1' again the timestamp 'ts' -ts = cell2mat(data(:,1)); -c1 = cell2mat(data(:,2)); - -%% Query aggregation results from a table -% TDengine is so powerful at aggregated computations. Let's calculate the max, mean, standard deviation and min values for every 10 minutes in the -% tb1's timeline, and then plot them together with all the data points in tb1 -sql = sprintf('SELECT max(measure1), avg(measure1), stddev(measure1), min(measure1) FROM device1 WHERE ts >= %d and ts <= %d interval(10m)', ts(1), ts(end)); -fprintf("Execute query: %s\n", sql); -tic; -c1_stats = fetch(conn, sql); -timeused = toc; -fprintf("\tQuery completed!\n\tNumber of rows retrieved: %d\n\tNumber of columns in each row: %d\n\tTime used: %g\n", size(c1_stats, 1), size(c1_stats, 2), timeused); -% Prepare data for plotting. -tsAsDate = datestr(ts/86400000 + datenum(1970,1,1), 'mm-dd HH:MM'); -c1_stats = cell2mat(c1_stats); -c1_stats_ts = c1_stats(:, 1); -c1_stats_max = c1_stats(:, 2); -c1_stats_mean = c1_stats(:, 3); -c1_stats_stddev = c1_stats(:, 4); -c1_stats_min = c1_stats(:, 5); -c1_stats_tsAsDate = datestr(c1_stats(:,1)/86400000 + datenum(1970,1,1), 'mm-dd HH:MM'); - -%% Now let's plot the data and associated statistical aggregation calculation in a figure. -fh = figure(1); -set(fh,'position',[50 50 1300 700]); -h1 = scatter(ts, c1, 5, 'c'); -hold on; -h2 = plot(c1_stats_ts + 300000, c1_stats_max, '-or', 'linewidth', 1); -hold on; -h3 = plot(c1_stats_ts + 300000, c1_stats_mean, '-xg', 'linewidth', 1); -hold on; -h4 = plot(c1_stats_ts + 300000, c1_stats_stddev, '-*y', 'linewidth', 1); -hold on; -h5 = plot(c1_stats_ts + 300000, c1_stats_min, '-+k', 'linewidth', 1); -xlabel('time'); -ylabel('measurement1'); -set(gca, 'xtick',[ts(1),ts(end/4),ts(2*end/4),ts(3*end/4),ts(end)]); -set(gca, 'xticklabel',{tsAsDate(1,:), tsAsDate(end/4,:),tsAsDate(2*end/4,:),tsAsDate(3*end/4,:),tsAsDate(end,:)}); -xlim([ts(1), ts(end)]); -legend([h1, h2, h3, h4, h5], 'data points', 'max per 10 mins', 'mean per 10 mins', 'stddev per 10 mins', 'min per 10 mins'); -title('Device Measurement Monitoring Demo'); -grid on; - -%% Insert data into TDengine using exec() -sql = 'insert into device1 (ts, distance1) values (now, -1)'; -fprintf("Execute query: %s\n", sql); -cur = exec(conn, sql) -sql = 'select * from device1 limit 1'; -fprintf("Execute query: %s\n", sql); -data = select(conn, sql) -conn.close; - -%% Insert data into TDengine using datainsert() -% this is currently not supported - -% colnames = {'ts','c1','c2','c3'}; -% dat = {'now' 99 99 99}; -% tbname = 'plane1'; -% datainsert(conn, tbname, colnames, dat); -% cur = exec(conn, 'select * from ' + tbname); -% cur = fetch(cur, 5); -% data = cur.Data - diff --git a/tests/examples/nodejs/README-win.md b/tests/examples/nodejs/README-win.md deleted file mode 100644 index 75fec69413af2bb49498118ec7235c9947e2f89e..0000000000000000000000000000000000000000 --- a/tests/examples/nodejs/README-win.md +++ /dev/null @@ -1,200 +0,0 @@ -# 如何在windows上使用nodejs进行TDengine应用开发 - -## 环境准备 - -(1)安装nodejs-10.22.0 - -下载链接:https://nodejs.org/dist/v10.22.0/node-v10.22.0-win-x64.zip -解压安装,把node配置到环境变量里 - -cmd启动命令行,查看node的版本 - -```shell -> node.exe --version -v10.22.0 - -> npm --version -6.14.6 -``` - - - -(2)安装python2.7 - -下载链接:https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi - -查看python版本 - -```shell ->python --version -Python 2.7.18 -``` - - -(3)安装TDengine-client - -下载地址:https://www.taosdata.com/cn/all-downloads/,选择一个合适的windows-client下载(client应该尽量与server端的版本保持一致) - -使用client的taos shell连接server - -```shell ->taos -h node5 - -Welcome to the TDengine shell from Linux, Client Version:2.0.6.0 -Copyright (c) 2017 by TAOS Data, Inc. All rights reserved. - -taos> show dnodes; - id | end_point | vnodes | cores | status | role | create_time | offline reason | -============================================================================================================================================ - 1 | node5:6030 | 7 | 1 | ready | any | 2020-10-26 09:45:26.308 | | -Query OK, 1 row(s) in set (0.036000s) -``` - -注意: -* 检查能否在client的机器上ping通server的fqdn -* 如果你的dns server并没有提供到server的域名解析,可以将server的hostname配置到client的hosts文件中 - - -## 应用开发 - -(1)建立nodejs项目 - -``` -npm init -``` - -(2)安装windows-build-tools -``` -npm install --global --production windows-build-tools -``` - -(3)安装td2.0-connector驱动 - -``` tdshell -npm install td2.0-connector -``` - -(4)nodejs访问tdengine的示例程序 - -```javascript -const taos = require('td2.0-connector'); - -var host = null; -var port = 6030; -for (var i = 2; i < global.process.argv.length; i++) { - var key = global.process.argv[i].split("=")[0]; - var value = global.process.argv[i].split("=")[1]; - - if ("host" == key) { - host = value; - } - if ("port" == key) { - port = value; - } -} - -if (host == null) { - console.log("Usage: node nodejsChecker.js host= port="); - process.exit(0); -} - -// establish connection -var conn = taos.connect({host: host, user: "root", password: "taosdata", port: port}); -var cursor = conn.cursor(); -// create database -executeSql("create database if not exists testnodejs", 0); -// use db -executeSql("use testnodejs", 0); -// drop table -executeSql("drop table if exists testnodejs.weather", 0); -// create table -executeSql("create table if not exists testnodejs.weather(ts timestamp, temperature float, humidity int)", 0); -// insert -executeSql("insert into testnodejs.weather (ts, temperature, humidity) values(now, 20.5, 34)", 1); -// select -executeQuery("select * from testnodejs.weather"); -// close connection -conn.close(); - -function executeQuery(sql) { - var start = new Date().getTime(); - var promise = cursor.query(sql, true); - var end = new Date().getTime(); - promise.then(function (result) { - printSql(sql, result != null, (end - start)); - result.pretty(); - }); -} - -function executeSql(sql, affectRows) { - var start = new Date().getTime(); - var promise = cursor.execute(sql); - var end = new Date().getTime(); - printSql(sql, promise == affectRows, (end - start)); -} - -function printSql(sql, succeed, cost) { - console.log("[ " + (succeed ? "OK" : "ERROR!") + " ] time cost: " + cost + " ms, execute statement ====> " + sql); -} -``` - -(5)测试nodejs程序 - -```shell ->node nodejsChecker.js -Usage: node nodejsChecker.js host= port= -# 提示指定host - ->node nodejsChecker.js host=node5 -Successfully connected to TDengine -Query OK, 0 row(s) affected (0.00997610s) -[ OK ] time cost: 14 ms, execute statement ====> create database if not exists testnodejs -Query OK, 0 row(s) affected (0.00235920s) -[ OK ] time cost: 4 ms, execute statement ====> use testnodejs -Query OK, 0 row(s) affected (0.06604280s) -[ OK ] time cost: 67 ms, execute statement ====> drop table if exists testnodejs.weather -Query OK, 0 row(s) affected (0.59403290s) -[ OK ] time cost: 595 ms, execute statement ====> create table if not exists testnodejs.weather(ts timestamp, temperature float, humidity int) -Query OK, 1 row(s) affected (0.01058950s) -[ OK ] time cost: 12 ms, execute statement ====> insert into testnodejs.weather (ts, temperature, humidity) values(now, 20.5, 34) -Query OK, 1 row(s) in set (0.00401490s) -[ OK ] time cost: 10 ms, execute statement ====> select * from testnodejs.weather -Connection is closed - - ts | temperature | humidity | -===================================================================== -2020-10-27 18:49:15.547 | 20.5 | 34 | -``` - -## 指南 - -### 如何设置主机名和hosts - -在server上查看hostname和fqdn -```shell -查看hostname -# hostname -taos-server - -查看fqdn -# hostname -f -taos-server -``` - -windows下hosts文件位于: -C:\\Windows\System32\drivers\etc\hosts -修改hosts文件,添加server的ip和hostname - -``` -192.168.56.101 node5 -``` - -> 什么是FQDN? -> -> FQDN(Full qualified domain name)全限定域名,fqdn由2部分组成:hostname+domainname。 -> -> 例如,一个邮件服务器的fqdn可能是:mymail.somecollege.edu,其中mymail是hostname(主机名),somcollege.edu是domainname(域名)。本例中,.edu是顶级域名,.somecollege是二级域名。 -> -> 当连接服务器时,必须指定fqdn,然后,dns服务器通过查看dns表,将hostname解析为相应的ip地址。如果只指定hostname(不指定domainname),应用程序可能服务解析主机名。因为如果你试图访问不在本地的远程服务器时,本地的dns服务器和可能没有远程服务器的hostname列表。 -> -> 参考:https://kb.iu.edu/d/aiuv diff --git a/tests/examples/nodejs/node-example-raw.js b/tests/examples/nodejs/node-example-raw.js deleted file mode 100644 index 80d5cd1bdea23370f1ac03756541eaa96937a6d6..0000000000000000000000000000000000000000 --- a/tests/examples/nodejs/node-example-raw.js +++ /dev/null @@ -1,123 +0,0 @@ -/* This example is to show how to use the td-connector through the cursor only and is a bit more raw. - * No promises, object wrappers around data, functions that prettify the data, or anything. - * The cursor will generally use callback functions over promises, and return and store the raw data from the C Interface. - * It is advised to use the td-connector through the cursor and the TaosQuery class amongst other higher level APIs. -*/ - -// Get the td-connector package -const taos = require('td2.0-connector'); - -/* We will connect to TDengine by passing an object comprised of connection options to taos.connect and store the - * connection to the variable conn - */ -/* - * Connection Options - * host: the host to connect to - * user: the use to login as - * password: the password for the above user to login - * config: the location of the taos.cfg file, by default it is in /etc/taos - * port: the port we connect through - */ -var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0}); - -// Initialize our TDengineCursor, which we use to interact with TDengine -var c1 = conn.cursor(); - -//execute the sql -function execute(sql){ - try { - c1.execute(sql); - } - catch(err) { - conn.close(); - throw err; - } -} - -// c1.execute(query) will execute the query -// Let's create a database named db -execute('create database if not exists db;') - -// Now we will use database db -execute('use db;') - - -// Let's create a table called weather -// which stores some weather data like humidity, AQI (air quality index), temperature, and some notes as text -execute('create table if not exists weather (ts timestamp, humidity smallint, aqi int, temperature float, notes binary(30));'); - -// Let's get the description of the table weather -execute('describe db.weather'); - -// To get results, we run the function c1.fetchall() -// It only returns the query results as an array of result rows, but also stores the latest results in c1.data -try { - var tableDesc = c1.fetchall(); // The description variable here is equal to c1.data; - console.log(tableDesc); -} -catch (err) { - conn.close(); - throw err; -} - -// Let's try to insert some random generated data to test with - -let stime = new Date(); -let interval = 1000; - -// Timestamps must be in the form of "YYYY-MM-DD HH:MM:SS.MMM" if they are in milliseconds -// "YYYY-MM-DD HH:MM:SS.MMMMMM" if they are in microseconds -// Thus, we create the following function to convert a javascript Date object to the correct formatting -function convertDateToTS(date) { - let tsArr = date.toISOString().split("T") - return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length-1) + "\""; -} - -try { - for (let i = 0; i < 10000; i++) { - stime.setMilliseconds(stime.getMilliseconds() + interval); - let insertData = [convertDateToTS(stime), - parseInt(Math.random()*100), - parseInt(Math.random()*300), - parseFloat(Math.random()*10 + 30), - "\"random note!\""]; - c1.execute('insert into db.weather values(' + insertData.join(',') + ' );'); - } -} -catch (err) { - conn.close(); - throw err; -} - -// Now let's look at our newly inserted data -var retrievedData; -try { - c1.execute('select * from db.weather;') - retrievedData = c1.fetchall(); - - // c1.fields stores the names of each column retrieved - console.log(c1.fields); - console.log(retrievedData); - // timestamps retrieved are always JS Date Objects - // Numbers are numbers, big ints are big ints, and strings are strings -} -catch (err) { - conn.close(); - throw err; -} - -// Let's try running some basic functions -try { - c1.execute('select count(*), avg(temperature), max(temperature), min(temperature), stddev(temperature) from db.weather;') - c1.fetchall(); - console.log(c1.fields); - console.log(c1.data); -} -catch(err) { - conn.close(); - throw err; -} - -conn.close(); - -// Feel free to fork this repository or copy this code and start developing your own apps and backends with NodeJS and TDengine! diff --git a/tests/examples/nodejs/node-example.js b/tests/examples/nodejs/node-example.js deleted file mode 100644 index bfdd9e49a08fc1d6c20f3bdafbb84a500986b9fd..0000000000000000000000000000000000000000 --- a/tests/examples/nodejs/node-example.js +++ /dev/null @@ -1,153 +0,0 @@ -/* This example is to show the preferred way to use the td-connector */ -/* To run, enter node path/to/node-example.js */ -// Get the td-connector package -const taos = require('td2.0-connector'); - -/* We will connect to TDengine by passing an object comprised of connection options to taos.connect and store the - * connection to the variable conn - */ -/* - * Connection Options - * host: the host to connect to - * user: the use to login as - * password: the password for the above user to login - * config: the location of the taos.cfg file, by default it is in /etc/taos - * port: the port we connect through - */ -var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0}); - -// Initialize our TDengineCursor, which we use to interact with TDengine -var c1 = conn.cursor(); - -// c1.query(query) will return a TaosQuery object, of which then we can execute. The execute function then returns a promise -// Let's create a database named db -try { - c1.execute('create database if not exists db;'); - //var query = c1.query('create database if not exists db;'); - //query.execute(); -} -catch(err) { - conn.close(); - throw err; -} - -// Now we will use database db. As this query won't return any results, -// we can simplify the code and directly use the c1.execute() function. No need for a TaosQuery object to wrap around the query -try { - c1.execute('use db;'); -} -catch (err) { - conn.close(); - throw err; -} - -// Let's create a table called weather -// which stores some weather data like humidity, AQI (air quality index), temperature, and some notes as text -// We can also immedietely execute a TaosQuery object by passing true as the secodn argument -// This will then return a promise that we can then attach a callback function to -try { - var promise = c1.query('create table if not exists weather (ts timestamp, humidity smallint, aqi int, temperature float, notes binary(30));', true); - promise.then(function(){ - console.log("Table created!"); - }).catch(function() { - console.log("Table couldn't be created.") - }); -} -catch (err) { - conn.close(); - throw err; -} - -// Let's get the description of the table weather -// When using a TaosQuery object and then executing it, upon success it returns a TaosResult object, which is a wrapper around the -// retrieved data and allows us to easily access data and manipulate or display it. -try { - c1.query('describe db.weather;').execute().then(function(result){ - // Result is an instance of TaosResult and has the function pretty() which instantly logs a prettified version to the console - result.pretty(); - }); -} -catch (err) { - conn.close(); - throw err; -} - - -Date.prototype.Format = function(fmt){ - var o = { - 'M+': this.getMonth() + 1, - 'd+': this.getDate(), - 'H+': this.getHours(), - 'm+': this.getMinutes(), - 's+': this.getSeconds(), - 'S+': this.getMilliseconds() - }; - if (/(y+)/.test(fmt)) { - fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)); - } - for (var k in o) { - if (new RegExp('(' + k + ')').test(fmt)) { - fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(String(o[k]).length))); - } - } - return fmt; -} - - -// Let's try to insert some random generated data to test with -// We will use the bind function of the TaosQuery object to easily bind values to question marks in the query -// For Timestamps, a normal Datetime object or TaosTimestamp or milliseconds can be passed in through the bind function -let stime = new Date(); -let interval = 1000; -try { - for (let i = 0; i < 1000; i++) { - stime.setMilliseconds(stime.getMilliseconds() + interval); - - //console.log(stime.Format('yyyy-MM-dd HH:mm:ss.SSS')); - - let insertData = [stime, - parseInt(Math.random()*100), - parseInt(Math.random()*300), - parseFloat(Math.random()*10 + 30), - "Note"]; - //c1.execute('insert into db.weather values(' + insertData.join(',') + ' );'); - - //var query = c1.query('insert into db.weather values(?, ?, ?, ?, ?);').bind(insertData); - //query.execute(); - c1.execute('insert into db.weather values(\"'+stime.Format('yyyy-MM-dd HH:mm:ss.SSS')+'\",'+parseInt(Math.random() * 100)+','+parseInt(Math.random() * 300)+','+parseFloat(Math.random()*10 + 30)+',"Note");'); - } -}catch (err) { - conn.close(); - throw err; -} - -// Now let's look at our newly inserted data -var retrievedData; -try { - c1.query('select * from db.weather limit 5 offset 100;', true).then(function(result){ - //result.pretty(); - console.log('=========>'+JSON.stringify(result)); - // Neat! - }); - -} -catch (err) { - conn.close(); - throw err; -} - -// Let's try running some basic functions -try { - c1.query('select count(*), avg(temperature), max(temperature), min(temperature), stddev(temperature) from db.weather;', true) - .then(function(result) { - result.pretty(); - }) -} -catch(err) { - conn.close(); - throw err; -} - -conn.close(); - -// Feel free to fork this repository or copy this code and start developing your own apps and backends with NodeJS and TDengine! diff --git a/tests/examples/nodejs/nodejsChecker.js b/tests/examples/nodejs/nodejsChecker.js deleted file mode 100644 index 1b391e55a07b1e86a9c7dc92f6bfba23b147c822..0000000000000000000000000000000000000000 --- a/tests/examples/nodejs/nodejsChecker.js +++ /dev/null @@ -1,61 +0,0 @@ -//const taos = require('td2.0-connector'); -const taos = require('../../../src/connector/nodejs/'); - - -var host = null; -var port = 6030; -for(var i = 2; i < global.process.argv.length; i++){ - var key = global.process.argv[i].split("=")[0]; - var value = global.process.argv[i].split("=")[1]; - - if("host" == key){ - host = value; - } - if("port" == key){ - port = value; - } -} - -if(host == null){ - console.log("Usage: node nodejsChecker.js host= port="); - process.exit(0); -} - -// establish connection -var conn = taos.connect({host:host, user:"root", password:"taosdata",port:port}); -var cursor = conn.cursor(); -// create database -executeSql("create database if not exists test", 0); -// use db -executeSql("use test", 0); -// drop table -executeSql("drop table if exists test.weather", 0); -// create table -executeSql("create table if not exists test.weather(ts timestamp, temperature float, humidity int)", 0); -// insert -executeSql("insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)", 1); -// select -executeQuery("select * from test.weather"); -// close connection -conn.close(); - -function executeQuery(sql){ - var start = new Date().getTime(); - var promise = cursor.query(sql, true); - var end = new Date().getTime(); - promise.then(function(result){ - printSql(sql, result != null,(end - start)); - result.pretty(); - }); -} - -function executeSql(sql, affectRows){ - var start = new Date().getTime(); - var promise = cursor.execute(sql); - var end = new Date().getTime(); - printSql(sql, promise == affectRows, (end - start)); -} - -function printSql(sql, succeed, cost){ - console.log("[ "+(succeed ? "OK" : "ERROR!")+" ] time cost: " + cost + " ms, execute statement ====> " + sql); -} diff --git a/tests/examples/nodejs/test1970.js b/tests/examples/nodejs/test1970.js deleted file mode 100644 index 5177a7371e9a07fa7b548936ff038c1f2a29bc1f..0000000000000000000000000000000000000000 --- a/tests/examples/nodejs/test1970.js +++ /dev/null @@ -1,125 +0,0 @@ -const taos = require('td2.0-connector'); -var conn = taos.connect({host:"127.0.0.1", user:"root", password:"taosdata", config:"/etc/taos",port:0}) -var c1 = conn.cursor(); // Initializing a new cursor - -let stime = new Date(); -let interval = 1000; - -function convertDateToTS(date) { - let tsArr = date.toISOString().split("T") - return "\"" + tsArr[0] + " " + tsArr[1].substring(0, tsArr[1].length - 1) + "\""; -} - -function R(l, r) { - return Math.random() * (r - l) - r; -} - -function randomBool() { - if (Math.random() < 0.5) { - return true; - } - return false; -} - -// Initialize -const dbname = "nodejs_1970_db"; -const tbname = "t1"; - -let dropDB = "drop database if exists " + dbname -console.log(dropDB);//asdasdasd -c1.execute(dropDB);///asdasd - -let createDB = "create database " + dbname + " keep 36500" -console.log(createDB); -c1.execute(createDB); - -let useTbl = "use " + dbname -console.log(useTbl) -c1.execute(useTbl); - -let createTbl = "create table if not exists " + tbname + "(ts timestamp,id int)" -console.log(createTbl); -c1.execute(createTbl); - -//1969-12-31 23:59:59.999 -//1970-01-01 00:00:00.000 -//1970-01-01 07:59:59.999 -//1970-01-01 08:00:00.000a -//1628928479484 2021-08-14 08:07:59.484 -let sql1 = "insert into " + dbname + "." + tbname + " values('1969-12-31 23:59:59.999',1)" -console.log(sql1); -c1.execute(sql1); - -let sql2 = "insert into " + dbname + "." + tbname + " values('1970-01-01 00:00:00.000',2)" -console.log(sql2); -c1.execute(sql2); - -let sql3 = "insert into " + dbname + "." + tbname + " values('1970-01-01 07:59:59.999',3)" -console.log(sql3); -c1.execute(sql3); - -let sql4 = "insert into " + dbname + "." + tbname + " values('1970-01-01 08:00:00.000',4)" -console.log(sql4); -c1.execute(sql4); - -let sql5 = "insert into " + dbname + "." + tbname + " values('2021-08-14 08:07:59.484',5)" -console.log(sql5); -c1.execute(sql5); - -// Select -let query1 = "select * from " + dbname + "." + tbname -console.log(query1); -c1.execute(query1); - -var d = c1.fetchall(); -console.log(c1.fields); -for (let i = 0; i < d.length; i++) - console.log(d[i][0].valueOf()); - -//initialize -let initSql1 = "drop table if exists " + tbname -console.log(initSql1); -c1.execute(initSql1); - -console.log(createTbl); -c1.execute(createTbl); -c1.execute(useTbl) - -//-28800001 1969-12-31 23:59:59.999 -//-28800000 1970-01-01 00:00:00.000 -//-1 1970-01-01 07:59:59.999 -//0 1970-01-01 08:00:00.00 -//1628928479484 2021-08-14 08:07:59.484 -let sql11 = "insert into " + dbname + "." + tbname + " values(-28800001,11)"; -console.log(sql11); -c1.execute(sql11); - -let sql12 = "insert into " + dbname + "." + tbname + " values(-28800000,12)" -console.log(sql12); -c1.execute(sql12); - -let sql13 = "insert into " + dbname + "." + tbname + " values(-1,13)" -console.log(sql13); -c1.execute(sql13); - -let sql14 = "insert into " + dbname + "." + tbname + " values(0,14)" -console.log(sql14); -c1.execute(sql14); - -let sql15 = "insert into " + dbname + "." + tbname + " values(1628928479484,15)" -console.log(sql15); -c1.execute(sql15); - -// Select -console.log(query1); -c1.execute(query1); - -var d = c1.fetchall(); -console.log(c1.fields); -for (let i = 0; i < d.length; i++) - console.log(d[i][0].valueOf()); - -setTimeout(function () { - conn.close(); -}, 2000); - diff --git a/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py b/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py deleted file mode 100644 index d74f021ffcf3aa33c551cc265243b5139c23b757..0000000000000000000000000000000000000000 --- a/tests/examples/python/PYTHONConnectorChecker/PythonChecker.py +++ /dev/null @@ -1,114 +0,0 @@ -import taos -import time -import sys -import getopt -class ConnectorChecker: - def init(self): - self.host = "127.0.0.1" - self.dbName = "test" - self.tbName = "weather" - self.user = "root" - self.password = "taosdata" - - - def sethdt(self,FQDN,dbname,tbname): - if(FQDN): - self.host=FQDN - if(dbname): - self.dbname=dbname - if(tbname): - self.tbName - def printSql(self,sql,elapsed): - print("[ "+"OK"+" ]"+" time cost: %s ms, execute statement ====> %s" - %(elapsed,sql)) - def executeQuery(self,sql): - try: - start=time.time() - execute = self.cl.execute(sql) - elapsed = (time.time()-start)*1000 - self.printSql(sql,elapsed) - data = self.cl.fetchall() - numOfRows = self.cl.rowcount - numOfCols = len(self.cl.description) - for irow in range(numOfRows): - print("Row%d: ts=%s, temperature=%d, humidity=%f" %(irow, data[irow][0], data[irow][1],data[irow][2])) - except Exception as e: - print("Failure sql: %s,exception: %s" %sql,str(e)) - def execute(self,sql): - try: - start=time.time() - execute = self.cl.execute(sql) - elapsed = (time.time()-start)*1000 - self.printSql(sql,elapsed) - - except Exception as e: - print("Failure sql: %s,exception: %s" % - sql,str(e)) - def close(self): - print("connetion closed.") - self.cl.close() - self.conn.close() - def createDatabase(self): - sql="create database if not exists %s" % self.dbName - self.execute(sql) - def useDatabase(self): - sql="use %s" % self.dbName - self.execute(sql) - def createTable(self): - sql="create table if not exists %s.%s (ts timestamp, temperature float, humidity int)"%(self.dbName,self.tbName) - self.execute(sql) - def checkDropTable(self): - sql="drop table if exists " + self.dbName + "." + self.tbName + "" - self.execute(sql) - def checkInsert(self): - sql="insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)" - self.execute(sql) - def checkSelect(self): - sql = "select * from test.weather" - self.executeQuery(sql) - def srun(self): - try: - self.conn = taos.connect(host=self.host,user=self.user,password=self.password) - #self.conn = taos.connect(self.host,self.user,self.password) - except Exception as e: - print("connection failed: %s"%self.host) - exit(1) - print("[ OK ] Connection established.") - self.cl = self.conn.cursor() - -def main(argv): - FQDN='' - dbname='' - tbname='' - try: - opts, args = getopt.getopt(argv,"h:d:t:",["FQDN=","ifile=","ofile="]) - except getopt.GetoptError: - print ('PYTHONConnectorChecker.py -h ') - sys.exit(2) - for opt, arg in opts: - if opt in ("-h", "--FQDN"): - FQDN=arg - elif opt in ("-d", "--dbname"): - dbname = arg - elif opt in ("-t", "--tbname"): - tbname = arg - - checker = ConnectorChecker() - checker.init() - checker.sethdt(FQDN,dbname,tbname) - checker.srun() - checker.createDatabase() - checker.useDatabase() - checker.checkDropTable() - checker.createTable() - checker.checkInsert() - checker.checkSelect() - checker.checkDropTable() - checker.close() - - - -if __name__ == "__main__": - main(sys.argv[1:]) - - diff --git a/tests/examples/python/read_example.py b/tests/examples/python/read_example.py deleted file mode 100644 index 73052ab2df54fcee8fb01573e23eb7b29ed11712..0000000000000000000000000000000000000000 --- a/tests/examples/python/read_example.py +++ /dev/null @@ -1,93 +0,0 @@ -""" -This is the sample code for TDengine python2 client. -""" -import taos -import sys -import datetime -import random - -def exitProgram(conn): - conn.close() - sys.exit() - -if __name__ == '__main__': - start_time = datetime.datetime(2019, 7, 1) - time_interval = datetime.timedelta(seconds=60) - - # Connect to TDengine server. - # - # parameters: - # @host : TDengine server IP address - # @user : Username used to connect to TDengine server - # @password : Password - # @database : Database to use when connecting to TDengine server - # @config : Configuration directory - if len(sys.argv)>1: - hostname=sys.argv[1] - conn = taos.connect(host=hostname, user="root", password="taosdata", config="/etc/taos") - else: - conn = taos.connect(host="127.0.0.1", user="root", password="taosdata", config="/etc/taos") - - # Generate a cursor object to run SQL commands - c1 = conn.cursor() - # Create a database named db - try: - c1.execute('create database if not exists db ') - except Exception as err: - conn.close() - raise(err) - - # use database - try: - c1.execute('use db') - except Exception as err: - conn.close() - raise(err) - - - # create table - try: - c1.execute('create table if not exists t (ts timestamp, a int, b float, c binary(20))') - except Exception as err: - conn.close() - raise(err) - - # insert data - for i in range(10): - try: - value = c1.execute("insert into t values ('%s', %d, %f, '%s')" % (start_time, random.randint(1,10), random.randint(1,10)/10.0, 'hello')) - #if insert, value is the affected rows - print(value) - except Exception as err: - conn.close() - raise(err) - start_time += time_interval - - # query data and return data in the form of list - try: - c1.execute('select * from db.t') - except Exception as err: - conn.close() - raise(err) - - # Column names are in c1.description list - cols = c1.description - # Use fetchall to fetch data in a list - data = c1.fetchall() - - for col in data: - print(col) - - print('Another query method ') - - try: - c1.execute('select * from db.t') - except Exception as err: - conn.close() - raise(err) - - # Use iterator to go through the retreived data - for col in c1: - print(col) - - conn.close() diff --git a/tests/examples/python/taosdemo/README.md b/tests/examples/python/taosdemo/README.md deleted file mode 100644 index d48fffe8ff44fb68a1a147a2c97ca057fb360092..0000000000000000000000000000000000000000 --- a/tests/examples/python/taosdemo/README.md +++ /dev/null @@ -1,38 +0,0 @@ -install build environment -=== -/usr/bin/python3 -m pip install -r requirements.txt - -run python version taosdemo -=== -Usage: ./taosdemo.py [OPTION...] - -Author: Shuduo Sang - - -H, --help Show usage. - - -N, --native flag, Use native interface if set. Default is using RESTful interface. - -h, --host host, The host to connect to TDengine. Default is localhost. - -p, --port port, The TCP/IP port number to use for the connection. Default is 0. - -u, --user user, The user name to use when connecting to the server. Default is 'root'. - -P, --password password, The password to use when connecting to the server. Default is 'taosdata'. - -l, --colsPerRec num_of_columns_per_record, The number of columns per record. Default is 3. - -d, --dbname database, Destination database. Default is 'test'. - -a, --replica replica, Set the replica parameters of the database, Default 1, min: 1, max: 5. - -m, --tbname
table_prefix, Table prefix name. Default is 't'. - -M, --stable flag, Use super table. Default is no - -s, --stbname stable_prefix, STable prefix name. Default is 'st' - -Q, --query query, Execute query command. set 'DEFAULT' means select * from each table - -T, --threads num_of_threads, The number of threads. Default is 1. - -C, --processes num_of_processes, The number of threads. Default is 1. - -r, --batch num_of_records_per_req, The number of records per request. Default is 1000. - -t, --numOfTb num_of_tables, The number of tables. Default is 1. - -n, --numOfRec num_of_records_per_table, The number of records per table. Default is 1. - -c, --config config_directory, Configuration directory. Default is '/etc/taos/'. - -x, --inserOnly flag, Insert only flag. - -O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order. - -R, --rateOOOO rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50. - -D, --deleteMethod Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database. - -v, --verbose Print verbose output - -g, --debug Print debug output - -y, --skipPrompt Skip read key for continous test, default is not skip - diff --git a/tests/examples/python/taosdemo/requirements.txt b/tests/examples/python/taosdemo/requirements.txt deleted file mode 100644 index 977e8e3726a446e85635764fe9243a3c5416ea0f..0000000000000000000000000000000000000000 --- a/tests/examples/python/taosdemo/requirements.txt +++ /dev/null @@ -1,28 +0,0 @@ -## -######## example-requirements.txt ####### -## -####### Requirements without Version Specifiers ###### -requests -multipledispatch -#beautifulsoup4 -## -####### Requirements with Version Specifiers ###### -## See https://www.python.org/dev/peps/pep-0440/#version-specifiers -#docopt == 0.6.1 # Version Matching. Must be version 0.6.1 -#keyring >= 4.1.1 # Minimum version 4.1.1 -#coverage != 3.5 # Version Exclusion. Anything except version 3.5 -#Mopidy-Dirble ~= 1.1 # Compatible release. Same as >= 1.1, == 1.* -## -####### Refer to other requirements files ###### -#-r other-requirements.txt -## -## -####### A particular file ###### -#./downloads/numpy-1.9.2-cp34-none-win32.whl -#http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl -## -####### Additional Requirements without Version Specifiers ###### -## Same as 1st section, just here to show that you can put things in any order. -#rejected -#green -## diff --git a/tests/examples/python/taosdemo/taosdemo.py b/tests/examples/python/taosdemo/taosdemo.py deleted file mode 100755 index 4aaf00157c5fe5bbeec27b001f663a94c1d89439..0000000000000000000000000000000000000000 --- a/tests/examples/python/taosdemo/taosdemo.py +++ /dev/null @@ -1,817 +0,0 @@ -#!/usr/bin/python3 -# * Copyright (c) 2019 TAOS Data, Inc. -# * -# * This program is free software: you can use, redistribute, and/or modify -# * it under the terms of the GNU Affero General Public License, version 3 -# * or later ("AGPL"), as published by the Free Software Foundation. -# * -# * This program is distributed in the hope that it will be useful, but WITHOUT -# * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# * FITNESS FOR A PARTICULAR PURPOSE. -# * -# * You should have received a copy of the GNU Affero General Public License -# * along with this program. If not, see . - -# -*- coding: utf-8 -*- - -import sys -import getopt -import requests -import json -import random -import time -import datetime -import multiprocessing -from multiprocessing import Manager, Pool, Lock -from multipledispatch import dispatch -from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED - - -@dispatch(str, str) -def v_print(msg, arg): - # type: (str, str) -> None - if verbose: - print(msg % arg) - - -@dispatch(str, str, str) -def v_print(msg, arg1, arg2): - # type: (str, str, str) -> None - if verbose: - print(msg % (arg1, arg2)) - - -@dispatch(str, str, str, str) -def v_print(msg, arg1, arg2, arg3): - # type: (str, str, str, str) -> None - if verbose: - print(msg % (arg1, arg2, arg3)) - - -@dispatch(str, str, str, str, str) -def v_print(msg, arg1, arg2, arg3, arg4): - # type: (str, str, str, str, str) -> None - if verbose: - print(msg % (arg1, arg2, arg3, arg4)) - - -@dispatch(str, int) -def v_print(msg, arg): - # type: (str, int) -> None - if verbose: - print(msg % int(arg)) - - -@dispatch(str, int, str) -def v_print(msg, arg1, arg2): - # type: (str, int, str) -> None - if verbose: - print(msg % (int(arg1), str(arg2))) - - -@dispatch(str, str, int) -def v_print(msg, arg1, arg2): - # type: (str, str, int) -> None - if verbose: - print(msg % (arg1, int(arg2))) - - -@dispatch(str, int, int) -def v_print(msg, arg1, arg2): - # type: (str, int, int) -> None - if verbose: - print(msg % (int(arg1), int(arg2))) - - -@dispatch(str, int, int, str) -def v_print(msg, arg1, arg2, arg3): - # type: (str, int, int, str) -> None - if verbose: - print(msg % (int(arg1), int(arg2), str(arg3))) - - -@dispatch(str, int, int, int) -def v_print(msg, arg1, arg2, arg3): - # type: (str, int, int, int) -> None - if verbose: - print(msg % (int(arg1), int(arg2), int(arg3))) - - -@dispatch(str, int, int, int, int) -def v_print(msg, arg1, arg2, arg3, arg4): - # type: (str, int, int, int, int) -> None - if verbose: - print(msg % (int(arg1), int(arg2), int(arg3), int(arg4))) - - -def restful_execute(host, port, user, password, cmd): - # type: (str, int, str, str, str) -> None - url = "http://%s:%d/rest/sql" % (host, restPort) - - v_print("restful_execute - cmd: %s", cmd) - - resp = requests.post(url, cmd, auth=(user, password)) - - v_print("resp status: %d", resp.status_code) - - if debug: - v_print( - "resp text: %s", - json.dumps( - resp.json(), - sort_keys=True, - indent=2)) - else: - print("resp: %s" % json.dumps(resp.json())) - - -def query_func(process, thread, cmd): - # type: (int, int, str) -> None - v_print("%d process %d thread cmd: %s", process, thread, cmd) - - if oneMoreHost != "NotSupported" and random.randint( - 0, 1) == 1: - v_print("%s", "Send to second host") - if native: - cursor2.execute(cmd) - else: - restful_execute( - oneMoreHost, port, user, password, cmd) - else: - v_print("%s%s%s", "Send ", cmd, " to the host") - if native: - pass -# cursor.execute(cmd) - else: - restful_execute( - host, port, user, password, cmd) - - -def query_data_process(cmd): - # type: (str) -> None - # establish connection if native - if native: - v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir) - try: - conn = taos.connect( - host=host, - user=user, - password=password, - config=configDir) - v_print("conn: %s", str(conn.__class__)) - except Exception as e: - print("Error: %s" % e.args[0]) - sys.exit(1) - - try: - cursor = conn.cursor() - v_print("cursor:%d %s", id(cursor), str(cursor.__class__)) - except Exception as e: - print("Error: %s" % e.args[0]) - conn.close() - sys.exit(1) - - if native: - try: - cursor.execute(cmd) - cols = cursor.description - data = cursor.fetchall() - - for col in data: - print(col) - except Exception as e: - conn.close() - print("Error: %s" % e.args[0]) - sys.exit(1) - - else: - restful_execute( - host, - port, - user, - password, - cmd) - - if native: - cursor.close() - conn.close() - - -def create_stb(): - for i in range(0, numOfStb): - if native: - cursor.execute( - "CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" % - (stbName, i)) - else: - restful_execute( - host, - port, - user, - password, - "CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" % - (stbName, i) - ) - - -def use_database(): - - if native: - cursor.execute("USE %s" % current_db) - else: - restful_execute(host, port, user, password, "USE %s" % current_db) - - -def create_databases(): - for i in range(0, numOfDb): - v_print("will create database db%d", int(i)) - - if native: - cursor.execute( - "CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i)) - else: - restful_execute( - host, - port, - user, - password, - "CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i)) - - -def drop_tables(): - # TODO - v_print("TODO: drop tables total %d", numOfTb) - pass - - -def drop_stable(): - # TODO - v_print("TODO: drop stables total %d", numOfStb) - pass - - -def drop_databases(): - v_print("drop databases total %d", numOfDb) - - # drop exist databases first - for i in range(0, numOfDb): - v_print("will drop database db%d", int(i)) - - if native: - cursor.execute( - "DROP DATABASE IF EXISTS %s%d" % - (dbName, i)) - else: - restful_execute( - host, - port, - user, - password, - "DROP DATABASE IF EXISTS %s%d" % - (dbName, i)) - - -def insert_func(process, thread): - # type: (int, int) -> None - v_print("%d process %d thread, insert_func ", process, thread) - - # generate uuid - uuid_int = random.randint(0, numOfTb + 1) - uuid = "%s" % uuid_int - v_print("uuid is: %s", uuid) - - # establish connection if native - if native: - v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir) - try: - conn = taos.connect( - host=host, - user=user, - password=password, - config=configDir) - v_print("conn: %s", str(conn.__class__)) - except Exception as e: - print("Error: %s" % e.args[0]) - sys.exit(1) - - try: - cursor = conn.cursor() - v_print("cursor:%d %s", id(cursor), str(cursor.__class__)) - except Exception as e: - print("Error: %s" % e.args[0]) - conn.close() - sys.exit(1) - - v_print("numOfRec %d:", numOfRec) - - row = 0 - while row < numOfRec: - v_print("row: %d", row) - sqlCmd = ['INSERT INTO '] - try: - sqlCmd.append( - "%s.%s%d " % (current_db, tbName, thread)) - - if (numOfStb > 0 and autosubtable): - sqlCmd.append("USING %s.%s%d TAGS('%s') " % - (current_db, stbName, numOfStb - 1, uuid)) - - start_time = datetime.datetime( - 2021, 1, 25) + datetime.timedelta(seconds=row) - - sqlCmd.append("VALUES ") - for batchIter in range(0, batch): - sqlCmd.append("('%s', %f) " % - ( - start_time + - datetime.timedelta( - milliseconds=batchIter), - random.random())) - row = row + 1 - if row >= numOfRec: - v_print("BREAK, row: %d numOfRec:%d", row, numOfRec) - break - - except Exception as e: - print("Error: %s" % e.args[0]) - - cmd = ' '.join(sqlCmd) - - if measure: - exec_start_time = datetime.datetime.now() - - if native: - affectedRows = cursor.execute(cmd) - else: - restful_execute( - host, port, user, password, cmd) - - if measure: - exec_end_time = datetime.datetime.now() - exec_delta = exec_end_time - exec_start_time - v_print( - "consume %d microseconds", - exec_delta.microseconds) - - v_print("cmd: %s, length:%d", cmd, len(cmd)) - - if native: - cursor.close() - conn.close() - - -def create_tb_using_stb(): - # TODO: - pass - - -def create_tb(): - v_print("create_tb() numOfTb: %d", numOfTb) - for i in range(0, numOfDb): - if native: - cursor.execute("USE %s%d" % (dbName, i)) - else: - restful_execute( - host, port, user, password, "USE %s%d" % - (dbName, i)) - - for j in range(0, numOfTb): - if native: - cursor.execute( - "CREATE TABLE %s%d (ts timestamp, value float)" % - (tbName, j)) - else: - restful_execute( - host, - port, - user, - password, - "CREATE TABLE %s%d (ts timestamp, value float)" % - (tbName, j)) - - -def insert_data_process(lock, i, begin, end): - # type: (multiprocessing._LockType, int, int, int) -> None - lock.acquire() - tasks = end - begin - v_print("insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks) - - if (threads < (end - begin)): - for j in range(begin, end, threads): - with ThreadPoolExecutor(max_workers=threads) as executor: - k = end if ((j + threads) > end) else (j + threads) - workers = [ - executor.submit( - insert_func, - i, - n) for n in range( - j, - k)] - wait(workers, return_when=ALL_COMPLETED) - else: - with ThreadPoolExecutor(max_workers=threads) as executor: - workers = [ - executor.submit( - insert_func, - i, - j) for j in range( - begin, - end)] - wait(workers, return_when=ALL_COMPLETED) - - lock.release() - - -def query_db(i): - if native: - cursor.execute("USE %s%d" % (dbName, i)) - else: - restful_execute( - host, port, user, password, "USE %s%d" % - (dbName, i)) - - for j in range(0, numOfTb): - if native: - cursor.execute( - "SELECT COUNT(*) FROM %s%d" % (tbName, j)) - else: - restful_execute( - host, port, user, password, "SELECT COUNT(*) FROM %s%d" % - (tbName, j)) - - -def printConfig(): - - print("###################################################################") - print("# Use native interface: %s" % native) - print("# Server IP: %s" % host) - if native: - print("# Server port: %s" % port) - else: - print("# Server port: %s" % restPort) - - print("# Configuration Dir: %s" % configDir) - print("# User: %s" % user) - print("# Password: %s" % password) - print("# Number of Columns per record: %s" % colsPerRecord) - print("# Number of Threads: %s" % threads) - print("# Number of Processes: %s" % processes) - print("# Number of Tables: %s" % numOfTb) - print("# Number of records per Table: %s" % numOfRec) - print("# Records/Request: %s" % batch) - print("# Database name: %s" % dbName) - print("# Replica: %s" % replica) - print("# Use STable: %s" % useStable) - print("# Table prefix: %s" % tbName) - if useStable: - print("# STable prefix: %s" % stbName) - - print("# Data order: %s" % outOfOrder) - print("# Data out of order rate: %s" % rateOOOO) - print("# Delete method: %s" % deleteMethod) - print("# Query command: %s" % queryCmd) - print("# Insert Only: %s" % insertOnly) - print("# Verbose output %s" % verbose) - print("# Test time: %s" % - datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")) - print("###################################################################") - - -if __name__ == "__main__": - - native = False - verbose = False - debug = False - measure = True - dropDbOnly = False - colsPerRecord = 3 - numOfDb = 1 - dbName = "test" - replica = 1 - batch = 1 - numOfTb = 1 - tbName = "tb" - useStable = False - numOfStb = 0 - stbName = "stb" - numOfRec = 10 - ieration = 1 - host = "127.0.0.1" - configDir = "/etc/taos" - oneMoreHost = "NotSupported" - port = 6030 - restPort = 6041 - user = "root" - defaultPass = "taosdata" - processes = 1 - threads = 1 - insertOnly = False - autosubtable = False - queryCmd = "NO" - outOfOrder = 0 - rateOOOO = 0 - deleteMethod = 0 - skipPrompt = False - - try: - opts, args = getopt.gnu_getopt(sys.argv[1:], - 'Nh:p:u:P:d:a:m:Ms:Q:T:C:r:l:t:n:c:xOR:D:vgyH', - [ - 'native', 'host', 'port', 'user', 'password', 'dbname', 'replica', 'tbname', - 'stable', 'stbname', 'query', 'threads', 'processes', - 'recPerReq', 'colsPerRecord', 'numOfTb', 'numOfRec', 'config', - 'insertOnly', 'outOfOrder', 'rateOOOO', 'deleteMethod', - 'verbose', 'debug', 'skipPrompt', 'help' - ]) - except getopt.GetoptError as err: - print('ERROR:', err) - print('Try `taosdemo.py --help` for more options.') - sys.exit(1) - - if bool(opts) is False: - print('Try `taosdemo.py --help` for more options.') - sys.exit(1) - - for key, value in opts: - if key in ['-H', '--help']: - print('') - print( - 'taosdemo.py for TDengine') - print('') - print('Author: Shuduo Sang ') - print('') - - print('\t-H, --help Show usage.') - print('') - - print('\t-N, --native flag, Use native interface if set. Default is using RESTful interface.') - print('\t-h, --host host, The host to connect to TDengine. Default is localhost.') - print('\t-p, --port port, The TCP/IP port number to use for the connection. Default is 0.') - print('\t-u, --user user, The user name to use when connecting to the server. Default is \'root\'.') - print('\t-P, --password password, The password to use when connecting to the server. Default is \'taosdata\'.') - print('\t-l, --colsPerRec num_of_columns_per_record, The number of columns per record. Default is 3.') - print( - '\t-d, --dbname database, Destination database. Default is \'test\'.') - print('\t-a, --replica replica, Set the replica parameters of the database, Default 1, min: 1, max: 5.') - print( - '\t-m, --tbname
table_prefix, Table prefix name. Default is \'t\'.') - print( - '\t-M, --stable flag, Use super table. Default is no') - print( - '\t-s, --stbname stable_prefix, STable prefix name. Default is \'st\'') - print('\t-Q, --query [NO|EACHTB|command] query, Execute query command. set \'EACHTB\' means select * from each table') - print( - '\t-T, --threads num_of_threads, The number of threads. Default is 1.') - print( - '\t-C, --processes num_of_processes, The number of threads. Default is 1.') - print('\t-r, --batch num_of_records_per_req, The number of records per request. Default is 1000.') - print( - '\t-t, --numOfTb num_of_tables, The number of tables. Default is 1.') - print('\t-n, --numOfRec num_of_records_per_table, The number of records per table. Default is 1.') - print('\t-c, --config config_directory, Configuration directory. Default is \'/etc/taos/\'.') - print('\t-x, --inserOnly flag, Insert only flag.') - print('\t-O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order.') - print('\t-R, --rateOOOO rate, Out of order data\'s rate--if order=1 Default 10, min: 0, max: 50.') - print('\t-D, --deleteMethod Delete data methods 0: don\'t delete, 1: delete by table, 2: delete by stable, 3: delete by database.') - print('\t-v, --verbose Print verbose output') - print('\t-g, --debug Print debug output') - print( - '\t-y, --skipPrompt Skip read key for continous test, default is not skip') - print('') - sys.exit(0) - - if key in ['-N', '--native']: - try: - import taos - except Exception as e: - print("Error: %s" % e.args[0]) - sys.exit(1) - native = True - - if key in ['-h', '--host']: - host = value - - if key in ['-p', '--port']: - port = int(value) - - if key in ['-u', '--user']: - user = value - - if key in ['-P', '--password']: - password = value - else: - password = defaultPass - - if key in ['-d', '--dbname']: - dbName = value - - if key in ['-a', '--replica']: - replica = int(value) - if replica < 1: - print("FATAL: number of replica need > 0") - sys.exit(1) - - if key in ['-m', '--tbname']: - tbName = value - - if key in ['-M', '--stable']: - useStable = True - numOfStb = 1 - - if key in ['-s', '--stbname']: - stbName = value - - if key in ['-Q', '--query']: - queryCmd = str(value) - - if key in ['-T', '--threads']: - threads = int(value) - if threads < 1: - print("FATAL: number of threads must be larger than 0") - sys.exit(1) - - if key in ['-C', '--processes']: - processes = int(value) - if processes < 1: - print("FATAL: number of processes must be larger than 0") - sys.exit(1) - - if key in ['-r', '--batch']: - batch = int(value) - - if key in ['-l', '--colsPerRec']: - colsPerRec = int(value) - - if key in ['-t', '--numOfTb']: - numOfTb = int(value) - v_print("numOfTb is %d", numOfTb) - - if key in ['-n', '--numOfRec']: - numOfRec = int(value) - v_print("numOfRec is %d", numOfRec) - if numOfRec < 1: - print("FATAL: number of records must be larger than 0") - sys.exit(1) - - - if key in ['-c', '--config']: - configDir = value - v_print("config dir: %s", configDir) - - if key in ['-x', '--insertOnly']: - insertOnly = True - v_print("insert only: %d", insertOnly) - - if key in ['-O', '--outOfOrder']: - outOfOrder = int(value) - v_print("out of order is %d", outOfOrder) - - if key in ['-R', '--rateOOOO']: - rateOOOO = int(value) - v_print("the rate of out of order is %d", rateOOOO) - - if key in ['-D', '--deleteMethod']: - deleteMethod = int(value) - if (deleteMethod < 0) or (deleteMethod > 3): - print( - "inputed delete method is %d, valid value is 0~3, set to default 0" % - deleteMethod) - deleteMethod = 0 - v_print("the delete method is %d", deleteMethod) - - if key in ['-v', '--verbose']: - verbose = True - - if key in ['-g', '--debug']: - debug = True - - if key in ['-y', '--skipPrompt']: - skipPrompt = True - - if verbose: - printConfig() - - if not skipPrompt: - try: - input("Press any key to continue..") - except SyntaxError: - pass - - # establish connection first if native - if native: - v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir) - try: - conn = taos.connect( - host=host, - user=user, - password=password, - config=configDir) - v_print("conn: %s", str(conn.__class__)) - except Exception as e: - print("Error: %s" % e.args[0]) - sys.exit(1) - - try: - cursor = conn.cursor() - v_print("cursor:%d %s", id(cursor), str(cursor.__class__)) - except Exception as e: - print("Error: %s" % e.args[0]) - conn.close() - sys.exit(1) - - # drop data only if delete method be set - if deleteMethod > 0: - if deleteMethod == 1: - drop_tables() - print("Drop tables done.") - elif deleteMethod == 2: - drop_stables() - print("Drop super tables done.") - elif deleteMethod == 3: - drop_databases() - print("Drop Database done.") - sys.exit(0) - - # create databases - drop_databases() - create_databases() - - # use last database - current_db = "%s%d" % (dbName, (numOfDb - 1)) - use_database() - - if measure: - start_time_begin = time.time() - - if numOfStb > 0: - create_stb() - if (autosubtable == False): - create_tb_using_stb() - else: - create_tb() - - if measure: - end_time = time.time() - print( - "Total time consumed {} seconds for create table.".format( - (end_time - start_time_begin))) - - if native: - cursor.close() - conn.close() - - # start insert data - if measure: - start_time = time.time() - - manager = Manager() - lock = manager.Lock() - pool = Pool(processes) - - begin = 0 - end = 0 - - quotient = numOfTb // processes - if quotient < 1: - processes = numOfTb - quotient = 1 - - remainder = numOfTb % processes - v_print( - "num of tables: %d, quotient: %d, remainder: %d", - numOfTb, - quotient, - remainder) - - for i in range(processes): - begin = end - - if i < remainder: - end = begin + quotient + 1 - else: - end = begin + quotient - pool.apply_async(insert_data_process, args=(lock, i, begin, end,)) - - pool.close() - pool.join() - time.sleep(1) - - if measure: - end_time = time.time() - print( - "Total time consumed {} seconds for insert data.".format( - (end_time - start_time))) - - - # query data - if queryCmd != "NO": - print("queryCmd: %s" % queryCmd) - query_data_process(queryCmd) - - if measure: - end_time = time.time() - print( - "Total time consumed {} seconds.".format( - (end_time - start_time_begin))) - - print("done") diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 0085d0fc601adcfcceffb12c31f9225918bc12f9..f1abeeab32a3a908805c125e04cfa61e8b5f9175 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -36,8 +36,6 @@ 83,,script,./test.sh -f general/parser/limit1_tblocks100.sim 82,,script,./test.sh -f general/parser/limit1.sim 82,,pytest,python3 test.py -f query/last_row_cache.py -81,,develop-test,timeout 180 bash 3-connectors/c#/test.sh -80,,develop-test,timeout 180 bash 3-connectors/nodejs/test.sh 79,,script,./test.sh -f general/db/alter_tables_v4.sim 79,,pytest,python3 test.py -f insert/verifyMemToDiskCrash.py 78,2,script,./test.sh -f unique/dnode/balance3.sim @@ -151,6 +149,7 @@ 48,,script,./test.sh -f general/parser/nestquery.sim 48,,script,./test.sh -f general/parser/col_arithmetic_operation.sim 48,,pytest,python3 test.py -f query/queryStateWindow.py +41,,docs-examples-test,eval sh -c \"if [ `uname -m` != aarch64 ]; then ./test_csharp.sh; fi\" 47,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonSml-illegalData.py 47,,script,./test.sh -f unique/stable/balance_replica1.sim 47,,script,./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim @@ -172,6 +171,7 @@ 42,,script,./test.sh -f unique/dnode/monitor_bug.sim 42,,script,./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim 42,,script,./test.sh -f general/wal/kill.sim +41,,docs-examples-test,./test_c.sh 41,,script,./test.sh -f unique/dnode/lossdata.sim 41,,script,./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim 41,,script,./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim @@ -196,6 +196,7 @@ 37,,script,./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim 37,,script,./test.sh -f general/table/delete_reuse1.sim 37,,script,./test.sh -f general/db/delete_reuse2.sim +36,,docs-examples-test,eval sh -c \"if [ `uname -m` != aarch64 ]; then ./test_rust.sh; fi\" 36,,script,./test.sh -f unique/stable/replica3_vnode3.sim 36,,script,./test.sh -f unique/stable/dnode2_stop.sim 36,,script,./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim @@ -234,6 +235,7 @@ 30,,script,./test.sh -f unique/account/account_delete.sim 30,,script,./test.sh -f general/import/commit.sim 30,,script,./test.sh -f general/compute/diff2.sim +30,,develop-test,bash 3-connectors/R/test.sh 29,,system-test,python3 ./test.py -f 0-others/create_col_tag.py 29,,script,./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim 29,,script,./test.sh -f general/wal/maxtables.sim @@ -314,6 +316,7 @@ 20,,pytest,python3 test.py -f import_merge/importLastTO.py 20,,pytest,python3 test.py -f import_merge/importDataSub.py 20,,pytest,python3 test.py -f import_merge/importDataLastSub.py +20,,pytest,python3 test.py -f table/create.py 19,,script,./test.sh -f unique/stable/dnode2.sim 19,,script,./test.sh -f general/db/vnodes.sim 19,,pytest,python3 test.py -f tools/taosdumpTest3.py @@ -323,6 +326,7 @@ 19,,pytest,python3 test.py -f import_merge/importDataHPO.py 19,,pytest,python3 test.py -f import_merge/importCSV.py 19,,pytest,python3 test.py -f functions/function_operations.py -r 1 +18,,docs-examples-test,./test_java.sh 18,,script,./test.sh -f unique/stable/replica3_dnode6.sim 18,,script,./test.sh -f general/vector/table_field.sim 18,,script,./test.sh -f general/vector/single.sim @@ -551,6 +555,7 @@ 11,,pytest,python3 test.py -f import_merge/importLastHPO.py 11,,pytest,python3 test.py -f import_merge/importDataTO.py 11,,pytest,python3 test.py -f import_merge/importBlock1Sub.py +10,,docs-examples-test,./test_python.sh 10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonStmt-otherPara.py 10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonStmt.py 10,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJson-autoCreate.py @@ -561,6 +566,7 @@ 10,,pytest,python3 testCompress.py 10,,pytest,python3 test.py -f client/client.py 10,,script,./test.sh -f general/compute/scalar_pow.sim +9,,docs-examples-test,./test_go.sh 9,,script,./test.sh -f general/parser/alter1.sim 9,,script,./test.sh -f general/db/delete.sim 9,,pytest,python3 test.py -f tools/taosdemoTestLimitOffset.py @@ -583,6 +589,8 @@ 8,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestTypeTinyInt.py 8,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestTypeInt.py 8,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestTypeDouble.py +8,,pytest,python3 test.py -f update/update2.py +7,,docs-examples-test,./test_node.sh 7,,system-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestInsertWithJsonSml-otherPara.py 7,,pytest,python3 test.py -f tools/taosdumpTest2.py 7,,pytest,python3 test.py -f tools/taosdemoTestdatatype.py @@ -716,6 +724,7 @@ 5,,develop-test,python3 ./test.py -f 2-query/query_window_keywords.py 5,,develop-test,python3 ./test.py -f 2-query/scalar_triangle.py 5,,develop-test,python3 ./test.py -f 2-query/scalar_expression.py +5,,develop-test,python3 ./test.py -f 2-query/scalar_powlog.py 4,,system-test,python3 test.py -f 4-taosAdapter/TD-12163.py 4,,system-test,python3 ./test.py -f 3-connectors/restful/restful_binddbname.py 4,,system-test,python3 ./test.py -f 2-query/TD-12614.py @@ -788,10 +797,12 @@ 4,,pytest,python3 test.py -f alter/alterTabAddTagWithNULL.py 4,,pytest,python3 test.py -f alter/alter_debugFlag.py 4,,pytest,python3 test.py -f alter/alter_create_exception.py +4,,pytest,python3 test.py -f insert/line_insert.py 3,,pytest,python3 test.py -f tag_lite/binary.py 3,,pytest,python3 test.py -f query/filterAllIntTypes.py 3,,develop-test,python3 ./test.py -f 2-query/ts_hidden_column.py 3,,develop-test,python3 ./test.py -f 2-query/ts_shortcut.py +3,,develop-test,python3 ./test.py -f 2-query/nchar_funcs.py 3,,develop-test,python3 ./test.py -f 2-query/TD-5902.py 1,,develop-test,python3 ./test.py -f 2-query/TD-14196.py 3,,script,./test.sh -f general/compute/scalar_str_concat_len.sim @@ -799,8 +810,7 @@ 3,,develop-test,python3 ./test.py -f 2-query/function_tail.py 2,,develop-test,python3 ./test.py -f 2-query/function_unique.py 2,,develop-test,python3 ./test.py -f 2-query/function_hll.py +1,,docs-examples-test, ./test_R.sh 1,,develop-test,python3 ./test.py -f 2-query/function_state.py 1,,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py -8,,pytest,python3 test.py -f update/update2.py -4,,pytest,python3 test.py -f insert/line_insert.py -80,,develop-test,bash 3-connectors/R/test.sh +3,,develop-test,python3 ./test.py -f 5-taos-tools/taosdump/taosdumpTestInspect.py diff --git a/tests/parallel_test/run_container.sh b/tests/parallel_test/run_container.sh index 5c6751148a2a168934c9d155695bbf51ec01f77b..6ba16ee6467671dffda3b83f766f8fdb7247aeba 100755 --- a/tests/parallel_test/run_container.sh +++ b/tests/parallel_test/run_container.sh @@ -95,6 +95,7 @@ docker run \ -v $REPDIR/packaging/cfg/taos.cfg:/etc/taos/taos.cfg:ro \ -v $REPDIR/packaging:$CONTAINER_TESTDIR/packaging:ro \ -v $REPDIR/README.md:$CONTAINER_TESTDIR/README.md:ro \ + -v $REPDIR/docs-examples:$CONTAINER_TESTDIR/docs-examples \ -v $REPDIR/src/connector/python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \ -e LD_LIBRARY_PATH=/home/debug/build/lib:/home/debug/build/lib64 \ --rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" $timeout_param diff --git a/tests/perftest-scripts/coverity_scan.sh b/tests/perftest-scripts/coverity_scan.sh new file mode 100755 index 0000000000000000000000000000000000000000..4e9126948cae7380c1a7999d91a2bfca276e97ef --- /dev/null +++ b/tests/perftest-scripts/coverity_scan.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# follow link: https://scan.coverity.com/download + +workdir=/root +token="replace_with_coverity_scan_token" + + +cd $workdir/TDengine + +git reset --hard HEAD +git checkout -- . +git checkout develop +git pull +git submodule update --init --recursive + +mkdir -p debug +cd debug +rm -rf * +cmake .. -DBUILD_TOOLS=true +cov-build --dir cov-int make -j 4 +tar czvf TDengine.tgz cov-int +curl --form token=$token \ + --form email="support@taosdata.com" \ + --form file=@TDengine.tgz \ + --form version="2.4.0.0" \ + --form description="TDengine Test" \ + https://scan.coverity.com/builds?project=tdengine diff --git a/tests/perftest-scripts/perftest-query.sh b/tests/perftest-scripts/perftest-query.sh index 05b2d45ce434d0990d7c143863b9ca268a7d6a26..6582952de915fb6d2401dbfa7d008459e34cac5f 100755 --- a/tests/perftest-scripts/perftest-query.sh +++ b/tests/perftest-scripts/perftest-query.sh @@ -57,35 +57,21 @@ function stopTaosd { function buildTDengine { echoInfo "Build TDinternal" cd $WORK_DIR/TDinternal + + git reset --hard HEAD~3 + git fetch + git checkout $branch + git pull - git remote update > /dev/null + cd community git reset --hard HEAD git fetch git checkout $branch - REMOTE_COMMIT=`git rev-parse --short remotes/origin/$branch` + git pull > /dev/null LOCAL_COMMIT=`git rev-parse --short @` - - echo " LOCAL: $LOCAL_COMMIT" - echo "REMOTE: $REMOTE_COMMIT" - if [ "$LOCAL_COMMIT" == "$REMOTE_COMMIT" ]; then - echo "repo up-to-date" - fi - - cd community - git reset --hard HEAD - cd .. echo "git submodule update --init --recursive" git submodule update --init --recursive - git pull > /dev/null 2>&1 - - cd community - git remote update > /dev/null - git reset --hard HEAD - git fetch - git checkout $branch - REMOTE_COMMIT=`git rev-parse --short remotes/origin/$branch` - LOCAL_COMMIT=`git rev-parse --short @` cd ../debug rm -rf * if [ $type = "jemalloc" ];then @@ -94,36 +80,34 @@ function buildTDengine { else cmake .. > /dev/null fi - #cp $WORK_DIR/taosdemoPerformance.py $WORK_DIR/TDinternal/community/tests/pytest/tools/ - #cp $WORK_DIR/insertFromCSVPerformance.py $WORK_DIR/TDinternal/community/tests/pytest/insert/ - #cp $WORK_DIR/queryPerformance.py $WORK_DIR/TDinternal/community/tests/pytest/query/ - rm -rf $WORK_DIR/TDinternal/community/tests/pytest/query/operator.py + make > /dev/null 2>&1 make install > /dev/null 2>&1 + echo "Build TDengine on remote server" ssh perftest "./buildTDengine.sh $branch > /dev/null" } function runQueryPerfTest { [ -f $PERFORMANCE_TEST_REPORT ] && rm $PERFORMANCE_TEST_REPORT - nohup $WORK_DIR/TDinternal/debug/build/bin/taosd -c /etc/perf/ > /dev/null 2>&1 & + nohup $WORK_DIR/TDinternal/debug/build/bin/taosd -c /etc/$branch > /dev/null 2>&1 & echoInfo "Wait TDengine to start" sleep 60 echoInfo "Run Performance Test" - cd $WORK_DIR/TDinternal/community/tests/pytest + cd $WORK_DIR/TDinternal/community/tests/pytest - python3 query/queryPerformance.py -c $LOCAL_COMMIT -b $branch -T $type -d perf2 | tee -a $PERFORMANCE_TEST_REPORT + python3 perfbenchmark/queryPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT - python3 insert/insertFromCSVPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT + python3 perfbenchmark/insertFromCSVPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT echo "=========== taosdemo performance: 4 int columns, 10000 tables, 100000 recoreds per table ===========" | tee -a $PERFORMANCE_TEST_REPORT - python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT + python3 perfbenchmark/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type | tee -a $PERFORMANCE_TEST_REPORT echo "=========== taosdemo performance: 400 int columns, 400 double columns, 200 binary(128) columns, 10000 tables, 10 recoreds per table ===========" | tee -a $PERFORMANCE_TEST_REPORT - python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type -i 400 -D 400 -B 200 -t 10000 -r 10 | tee -a $PERFORMANCE_TEST_REPORT + python3 perfbenchmark/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type -i 400 -D 400 -B 200 -t 10000 -r 10 | tee -a $PERFORMANCE_TEST_REPORT echo "=========== taosdemo performance: 1900 int columns, 1900 double columns, 200 binary(128) columns, 10000 tables, 10 recoreds per table ===========" | tee -a $PERFORMANCE_TEST_REPORT - python3 tools/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type -i 1900 -D 1900 -B 200 -t 10000 -r 10 | tee -a $PERFORMANCE_TEST_REPORT + python3 perfbenchmark/taosdemoPerformance.py -c $LOCAL_COMMIT -b $branch -T $type -i 1900 -D 1900 -B 200 -t 10000 -r 10 | tee -a $PERFORMANCE_TEST_REPORT } diff --git a/tests/pytest/connector/lua.py b/tests/pytest/connector/lua.py index 23f0602e12fe378b97ebf493dcbdb0e9a0a9a8fd..653a61d36f00cb0d06f5315460f9c4a2af36efa4 100644 --- a/tests/pytest/connector/lua.py +++ b/tests/pytest/connector/lua.py @@ -39,8 +39,8 @@ class TDTestCase: return buildPath def isLuaInstalled(self): - if not which('lua'): - tdLog.exit("Lua not found!") + if not which('lua5.3'): + tdLog.log("Lua 5.3 not found!") return False else: return True @@ -57,12 +57,13 @@ class TDTestCase: else: tdLog.info("taosd found in %s" % buildPath) - targetPath = buildPath + "/../tests/examples/lua" + targetPath = buildPath + "/../examples/lua" tdLog.info(targetPath) currentPath = os.getcwd() os.chdir(targetPath) os.system('./build.sh') - os.system('lua test.lua') + os.system('lua5.3 test.lua') + os.chdir(currentPath) def stop(self): tdSql.close() diff --git a/tests/pytest/insert/bigint.py b/tests/pytest/insert/bigint.py index 7c7d2d0f9507e8688dd73bcefe88632361c80c70..5431cf8106fdbcd74bdd310de45039badb3bce7f 100644 --- a/tests/pytest/insert/bigint.py +++ b/tests/pytest/insert/bigint.py @@ -54,10 +54,6 @@ class TDTestCase: tdSql.checkData(0, 1, 9223372036854770000) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/binary.py b/tests/pytest/insert/binary.py index e91a20e65cd04dd64a88af88259e8e25eebf595c..da7ffbbbe0bf062c08bd52f5935ff03fde09b615 100644 --- a/tests/pytest/insert/binary.py +++ b/tests/pytest/insert/binary.py @@ -14,6 +14,23 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) + def getPath(self, tool="taos"): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + paths = [] + for root, dirs, files in os.walk(projPath): + if ((tool) in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) + break + return paths[0] + def run(self): tdSql.prepare() @@ -54,17 +71,27 @@ class TDTestCase: tdLog.info("tdSql.checkData(0, 0, '34567')") tdSql.checkData(0, 0, '34567') tdLog.info("insert into tb values (now+4a, \"'';\")") + if platform.system() == "Linux": - config_dir = subprocess.check_output(str("ps -ef |grep dnode1|grep -v grep |awk '{print $NF}'"), stderr=subprocess.STDOUT, shell=True).decode('utf-8').replace('\n', '') - result = ''.join(os.popen(r"""taos -s "insert into db.tb values (now+4a, \"'';\")" -c %s"""%(config_dir)).readlines()) - if "Query OK" not in result: tdLog.exit("err:insert '';") - tdLog.info('drop database db') - tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) -# convert end + config_dir = subprocess.check_output( + str("ps -ef |grep dnode1|grep -v grep |awk '{print $NF}'"), + stderr=subprocess.STDOUT, + shell=True).decode('utf-8').replace( + '\n', + '') + + binPath = self.getPath("taos") + if (binPath == ""): + tdLog.exit("taos not found!") + else: + tdLog.info("taos found: %s" % binPath) + + result = ''.join( + os.popen( + r"""%s -s "insert into db.tb values (now+4a, \"'';\")" -c %s""" % + (binPath, (config_dir))).readlines()) + if "Query OK" not in result: + tdLog.exit("err:insert '';") def stop(self): tdSql.close() diff --git a/tests/pytest/insert/date.py b/tests/pytest/insert/date.py index 6e22e5b72ee465bfd32b9fd839c8ab0deba9267c..60ef9030301a5316a3255b6d1420f92f4a31ec85 100644 --- a/tests/pytest/insert/date.py +++ b/tests/pytest/insert/date.py @@ -174,14 +174,6 @@ class TDTestCase: # TSIM: sql drop database $db tdLog.info('drop database db') tdSql.execute('drop database db') - # TSIM: sql show databases - tdLog.info('show databases') - tdSql.query('show databases') - # TSIM: if $rows != 0 then - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) - # TSIM: return -1 - # TSIM: endi # convert end def stop(self): diff --git a/tests/pytest/insert/smallint.py b/tests/pytest/insert/smallint.py index 16322e9aeb801ae92b75b920922991206a4b2e35..1a1eab6a98912639aa845e7aae552fdd49278a5b 100644 --- a/tests/pytest/insert/smallint.py +++ b/tests/pytest/insert/smallint.py @@ -91,10 +91,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/timestamp.py b/tests/pytest/insert/timestamp.py index 4c9cf36f40e31a792b550a557937d25d968f4fe2..d5ddffcfafbade7b59fb32269a58b5ae0c9c0fdc 100644 --- a/tests/pytest/insert/timestamp.py +++ b/tests/pytest/insert/timestamp.py @@ -38,28 +38,38 @@ class TDTestCase: tdSql.checkRows(1) # Case 2 - tdSql.execute("insert into t1(c1, ts) values(2, %d)(3, %d)" % (self.ts + 1000, self.ts + 2000)) + tdSql.execute( + "insert into t1(c1, ts) values(2, %d)(3, %d)" % + (self.ts + 1000, self.ts + 2000)) tdSql.query("select * from t1") tdSql.checkRows(3) # Case 3 tdSql.execute("create table t2(ts timestamp, c1 timestamp)") - tdSql.execute(" insert into t2(c1, ts) values(%d, %d)" % (self.ts, self.ts + 5000)) + tdSql.execute( + " insert into t2(c1, ts) values(%d, %d)" % + (self.ts, self.ts + 5000)) tdSql.query("select * from t2") tdSql.checkRows(1) - tdSql.execute(" insert into t2(c1, ts) values(%d, %d)(%d, %d)" % (self.ts, self.ts + 6000, self.ts + 3000, self.ts + 8000)) + tdSql.execute( + " insert into t2(c1, ts) values(%d, %d)(%d, %d)" % + (self.ts, self.ts + 6000, self.ts + 3000, self.ts + 8000)) tdSql.query("select * from t2") tdSql.checkRows(3) # Case 4 - tdSql.execute("create table stb(ts timestamp, c1 int, c2 binary(20)) tags(tstag timestamp, t1 int)") - tdSql.execute("insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', %d, 1)" % self.ts) + tdSql.execute( + "create table stb(ts timestamp, c1 int, c2 binary(20)) tags(tstag timestamp, t1 int)") + tdSql.execute( + "insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', %d, 1)" % + self.ts) tdSql.query("select * from stb") tdSql.checkRows(1) # Case 5 - tdSql.execute("insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now, 1) tb2(c1, ts) using stb tags(now + 2m, 1000) values(1, now - 1h)") + tdSql.execute( + "insert into tb1(c2, ts, c1) using stb(t1, tstag) tags(1, now) values('test', now, 1) tb2(c1, ts) using stb tags(now + 2m, 1000) values(1, now - 1h)") tdSql.query("select * from stb") tdSql.checkRows(3) @@ -68,14 +78,16 @@ class TDTestCase: tdSql.checkRows(6) # Case 6 - tdSql.execute("create table stb2 (ts timestamp, c1 timestamp, c2 timestamp) tags(t1 timestamp, t2 timestamp)") + tdSql.execute( + "create table stb2 (ts timestamp, c1 timestamp, c2 timestamp) tags(t1 timestamp, t2 timestamp)") tdSql.execute(" insert into tb4(c1, c2, ts) using stb2(t2, t1) tags(now, now + 1h) values(now + 1s, now + 2s, now + 3s)(now -1s, now - 2s, now - 3s) tb5(c2, ts, c1) using stb2(t2) tags(now + 1h) values(now, now, now)") tdSql.query("select * from stb2") tdSql.checkRows(3) - + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) + tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/insert/tinyint.py b/tests/pytest/insert/tinyint.py index a10c999e8c2f0fe070347651f9246e3734104eca..a27b60aa724a93c7ccd40d521f0ee09c066c53d3 100644 --- a/tests/pytest/insert/tinyint.py +++ b/tests/pytest/insert/tinyint.py @@ -91,10 +91,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/unsignedBigint.py b/tests/pytest/insert/unsignedBigint.py index b222f2cd0195e14fddf1f10662447cef97f0e841..0d121a7d088bea28a5450fd7d47015edda2c0c27 100644 --- a/tests/pytest/insert/unsignedBigint.py +++ b/tests/pytest/insert/unsignedBigint.py @@ -46,7 +46,8 @@ class TDTestCase: tdLog.info('tdSql.checkData(0, 1, 18446744073709551614)') tdSql.checkData(0, 1, 18446744073709551614) tdLog.info('=============== step4') - tdLog.info("insert into tb values (now+3m, 18446744073709551615) -x step4") + tdLog.info( + "insert into tb values (now+3m, 18446744073709551615) -x step4") tdSql.error("insert into tb values (now+3m, 18446744073709551615)") tdLog.info("insert into tb values (now+3m, NULL)") tdSql.execute("insert into tb values (now+3m, NULL)") @@ -93,10 +94,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/unsignedInt.py b/tests/pytest/insert/unsignedInt.py index ed18999bc415022da34788a79e9045a5f67cf8ee..f38964677f99b945a136fe9e9ae58073edaba102 100644 --- a/tests/pytest/insert/unsignedInt.py +++ b/tests/pytest/insert/unsignedInt.py @@ -93,10 +93,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/unsignedSmallint.py b/tests/pytest/insert/unsignedSmallint.py index 9893c470ce1a53a05138dd9d5c18e2b0a9f21374..ef577b6f804a2d27a8f8b79188e6ec7ac75a00ec 100644 --- a/tests/pytest/insert/unsignedSmallint.py +++ b/tests/pytest/insert/unsignedSmallint.py @@ -16,7 +16,8 @@ class TDTestCase: tdLog.info('=============== step1') tdLog.info('create table tb (ts timestamp, speed smallint unsigned)') - tdSql.execute('create table tb (ts timestamp, speed smallint unsigned)') + tdSql.execute( + 'create table tb (ts timestamp, speed smallint unsigned)') tdLog.info("insert into tb values (now, NULL)") tdSql.execute("insert into tb values (now, NULL)") tdLog.info('select * from tb order by ts desc') @@ -93,10 +94,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) # convert end def stop(self): diff --git a/tests/pytest/insert/unsignedTinyint.py b/tests/pytest/insert/unsignedTinyint.py index 5bdfe7580b198ccaffcab7005e88aa72e1c437af..53ea93a737112b8d8fe54f3509f3327de1371ebe 100644 --- a/tests/pytest/insert/unsignedTinyint.py +++ b/tests/pytest/insert/unsignedTinyint.py @@ -91,11 +91,6 @@ class TDTestCase: tdSql.checkData(0, 1, 2) tdLog.info('drop database db') tdSql.execute('drop database db') - tdLog.info('show databases') - tdSql.query('show databases') - tdLog.info('tdSql.checkRow(0)') - tdSql.checkRows(0) - def stop(self): tdSql.close() diff --git a/tests/pytest/insert/insertFromCSVPerformance.py b/tests/pytest/perfbenchmark/insertFromCSVPerformance.py similarity index 96% rename from tests/pytest/insert/insertFromCSVPerformance.py rename to tests/pytest/perfbenchmark/insertFromCSVPerformance.py index 487497631a368778c857ce71234a4574837390c1..27de19f67f5d348181544961ef3329f95e740909 100644 --- a/tests/pytest/insert/insertFromCSVPerformance.py +++ b/tests/pytest/perfbenchmark/insertFromCSVPerformance.py @@ -32,7 +32,7 @@ class insertFromCSVPerformace: self.host = "127.0.0.1" self.user = "root" self.password = "taosdata" - self.config = "/etc/perf" + self.config = "/etc/%s" % self.branchName self.conn = taos.connect( self.host, self.user, @@ -95,6 +95,7 @@ class insertFromCSVPerformace: in_order_time = (float) (totalTime / 10) print("In order - Insert time: %f" % in_order_time) + cursor.execute("drop database if exists %s" % self.dbName) cursor.close() @@ -133,9 +134,9 @@ if __name__ == '__main__': '-b', '--branch-name', action='store', - default='develop', + default='2.4', type=str, - help='branch name (default: develop)') + help='branch name (default: 2.4)') parser.add_argument( '-T', '--build-type', diff --git a/tests/pytest/query/queryPerformance.py b/tests/pytest/perfbenchmark/queryPerformance.py similarity index 89% rename from tests/pytest/query/queryPerformance.py rename to tests/pytest/perfbenchmark/queryPerformance.py index 29e5cb19b75b0943c24382d268e81daebed01cdf..cd64f8e2a264c69dfb9e84b11779d886a676834d 100644 --- a/tests/pytest/query/queryPerformance.py +++ b/tests/pytest/perfbenchmark/queryPerformance.py @@ -32,7 +32,7 @@ class taosdemoQueryPerformace: self.host = "127.0.0.1" self.user = "root" self.password = "taosdata" - self.config = "/etc/perf" + self.config = "/etc/%s" % self.branch self.conn = taos.connect( self.host, self.user, @@ -55,35 +55,35 @@ class taosdemoQueryPerformace: tableid = 1 cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - sql = "select avg(f1), max(f2), min(f3) from test.meters" + sql = "select avg(current), max(voltage), min(phase) from test.meters" tableid = 2 cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - sql = "select count(*) from test.meters where loc='beijing'" + sql = "select count(*) from test.meters where location='beijing'" tableid = 3 cursor2.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - sql = "select avg(f1), max(f2), min(f3) from test.meters where areaid=10" + sql = "select avg(current), max(voltage), min(phase) from test.meters where groupid=10" tableid = 4 cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - sql = "select avg(f1), max(f2), min(f3) from test.t10 interval(10s)" + sql = "select avg(current), max(voltage), min(phase) from test.d10 interval(10s)" tableid = 5 cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - sql = "select last_row(*) from meters" + sql = "select last_row(*) from test.meters" tableid = 6 cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - sql = "select * from meters limit 10000" + sql = "select * from test.meters limit 10000" tableid = 7 cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - sql = "select avg(f1), max(f2), min(f3) from meters where ts <= '2017-07-15 10:40:01.000' and ts <= '2017-07-15 14:00:40.000'" + sql = "select avg(current), max(voltage), min(phase) from meters where ts <= '2017-07-15 10:40:01.000' and ts <= '2017-07-15 14:00:40.000'" tableid = 8 cursor2.execute("create table if not exists %s%d using %s tags(%d, \"%s\")" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) - sql = "select last(*) from meters" + sql = "select last(*) from test.meters" tableid = 9 cursor2.execute("create table if not exists %s%d using %s tags(%d, '%s')" % (self.tbPerfix, tableid, self.stbName, tableid, sql)) @@ -106,7 +106,7 @@ class taosdemoQueryPerformace: query_data = { "filetype": "query", - "cfgdir": "/etc/perf", + "cfgdir": "/etc/%s" % self.branch, "host": "127.0.0.1", "port": 6030, "user": "root", @@ -126,6 +126,7 @@ class taosdemoQueryPerformace: return query_json_file def getBuildPath(self): + buildPath="" selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -134,7 +135,7 @@ class taosdemoQueryPerformace: projPath = selfPath[:selfPath.find("tests")] for root, dirs, files in os.walk(projPath): - if ("taosdemo" in files): + if ("perfMonitor" in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): buildPath = root[:len(root) - len("/build/bin")] @@ -150,7 +151,7 @@ class taosdemoQueryPerformace: def query(self): buildPath = self.getBuildPath() if (buildPath == ""): - print("taosdemo not found!") + print("perfMonitor not found!") sys.exit(1) binPath = buildPath + "/build/bin/" @@ -220,9 +221,9 @@ if __name__ == '__main__': '-b', '--git-branch', action='store', - default='master', + default='2.4', type=str, - help='git branch (default: master)') + help='git branch (default: 2.4)') parser.add_argument( '-T', '--build-type', diff --git a/tests/pytest/tools/taosdemoPerformance.py b/tests/pytest/perfbenchmark/taosdemoPerformance.py similarity index 97% rename from tests/pytest/tools/taosdemoPerformance.py rename to tests/pytest/perfbenchmark/taosdemoPerformance.py index 82c57a656dfea12f80fe4eb2b530742c5bfb0916..1d91d056abf870830d3a2117bc6df81c57140590 100644 --- a/tests/pytest/tools/taosdemoPerformance.py +++ b/tests/pytest/perfbenchmark/taosdemoPerformance.py @@ -32,7 +32,7 @@ class taosdemoPerformace: self.host = "127.0.0.1" self.user = "root" self.password = "taosdata" - self.config = "/etc/perf" + self.config = "/etc/%s" % self.branch self.conn = taos.connect( self.host, self.user, @@ -88,7 +88,7 @@ class taosdemoPerformace: insert_data = { "filetype": "insert", - "cfgdir": "/etc/perf", + "cfgdir": "/etc/%s" % self.branch, "host": "127.0.0.1", "port": 6030, "user": "root", @@ -112,6 +112,7 @@ class taosdemoPerformace: return output def getBuildPath(self): + buildPath = "" selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -130,7 +131,7 @@ class taosdemoPerformace: def insertData(self): buildPath = self.getBuildPath() if (buildPath == ""): - print("taosdemo not found!") + print("perfMonitor not found!") sys.exit(1) binPath = buildPath + "/build/bin/" @@ -198,9 +199,9 @@ if __name__ == '__main__': '-b', '--git-branch', action='store', - default='master', + default='2.4', type=str, - help='git branch (default: master)') + help='git branch (default: 2.4)') parser.add_argument( '-T', '--build-type', diff --git a/tests/pytest/query/nestedQuery/nestedQuery_datacheck.py b/tests/pytest/query/nestedQuery/nestedQuery_datacheck.py index 311133b8c8911c1d9d8fe90fd5e556571f8e9548..20452cd886932169836964f6e816e66cdb9daf0c 100755 --- a/tests/pytest/query/nestedQuery/nestedQuery_datacheck.py +++ b/tests/pytest/query/nestedQuery/nestedQuery_datacheck.py @@ -619,8 +619,11 @@ class TDTestCase: sql += "%s )" % random.choice(t_join_where) datacheck = self.stable_join_checkall_0(sql) tdSql.checkRows(100) - datacheck = self.stable_join_checkall_100(sql) - + datacheck = self.stable_join_checkall_100(sql) + + # for TD-14342 + sql = "select * from ( select * from stable_1 ) where t_nchar like 'nchar%' or t_nchar = '0'" + datacheck = self.stable1_checkall_0(sql) endTime = time.time() print("total time %ds" % (endTime - startTime)) diff --git a/tests/pytest/query/queryGroupbySort.py b/tests/pytest/query/queryGroupbySort.py index 063db936087c125e45051da0094b57a9fd184b9b..6439fc6560d7f74b6d27ba3847f2459918fd94dc 100644 --- a/tests/pytest/query/queryGroupbySort.py +++ b/tests/pytest/query/queryGroupbySort.py @@ -16,6 +16,7 @@ import taos from util.log import tdLog from util.cases import tdCases from util.sql import tdSql +import random class TDTestCase: @@ -56,6 +57,37 @@ class TDTestCase: tdSql.checkData(0, 0, 11.6) tdSql.query("select avg(current) from meters group by t4;") tdSql.query("select avg(current) from meters group by t3,t4;") + + # TS-899 + tdSql.execute("create table stb(ts timestamp, c0 int, c1 double, c2 binary(20), c3 int) tags(t1 int, t2 nchar(20))") + tags = ["beijing", "shanghai"] + cols = ["chaoyang", "haidian", "shunyi"] + for i in range(10): + tdSql.execute("create table t%d using stb tags(%d, '%s')" % (i, i, tags[i % 2])) + sql = "insert into t%d values" % i + for j in range(100): + sql += "(%d, %d, %f, '%s', %d)" % (self.ts + j, j % 10 + 1, random.uniform(1, 10), cols[j % 3], j % 5 + 1) + tdSql.execute(sql) + + tdSql.error("select count(*) from stb group by c1") + tdSql.query("select count(*), c0, c2, c3 from stb group by c0, c2, c3") + tdSql.checkRows(30) + + tdSql.query("select count(*), c0, c2, c3 from stb group by c0, c2, c3, t1, t2") + tdSql.checkRows(300) + + tdSql.query("select count(*), c0 from t0 group by c0") + tdSql.checkRows(10) + tdSql.checkData(0, 0, 10) + + # corner cases + tdSql.execute("create table tb(ts timestamp, c0 int, c1 bool, c2 float, c3 double)") + tdSql.error("select count(*) from tb group by c2") + tdSql.error("select count(*) from tb group by c3") + tdSql.error("select count(*) from tb group by c2, c3") + tdSql.query("select count(*) from tb group by c1") + tdSql.checkRows(0) + def stop(self): tdSql.close() diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index cbe80882fbb6dfb6cfa9695f66d0b22d09068ae5..32f5f00c513f0148506c27b6772ccd19b1197cc6 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -4,10 +4,32 @@ ulimit -c unlimited # insert python3 ./test.py $1 -f insert/basic.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/bool.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/tinyint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/smallint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/int.py +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/bigint.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/float.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/double.py +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/nchar.py python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/timestamp.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/unsignedTinyint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/unsignedSmallint.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/unsignedInt.py +python3 ./test.py $1 -s && sleep 1 +python3 ./test.py $1 -f insert/unsignedBigint.py +python3 ./test.py $1 -s && sleep 1 python3 ./test.py $1 -f insert/multi.py python3 ./test.py $1 -s && sleep 1 @@ -36,4 +58,4 @@ python3 ./test.py $1 -f client/client.py python3 ./test.py $1 -s && sleep 1 # connector -python3 ./test.py $1 -f connector/lua.py +# python3 ./test.py $1 -f connector/lua.py diff --git a/tests/pytest/table/create.py b/tests/pytest/table/create.py index a1eee6be63980504742b35d22b0035d56ad077fb..4bd630f4c00d70df857d81bfe97d6aab85398ec3 100644 --- a/tests/pytest/table/create.py +++ b/tests/pytest/table/create.py @@ -106,9 +106,9 @@ class TDTestCase: tdSql.query("select _block_dist() from db.`%s` ; " %self.stb1) tdSql.checkRows(0) - tdSql.query("show create stable db.`%s` ; " %self.stb1) + tdSql.query("show create table db.`%s` ; " %self.stb1) tdSql.checkData(0, 0, self.stb1) - tdSql.checkData(0, 1, "create table `%s` (ts TIMESTAMP,i INT) TAGS (j INT)" %self.stb1) + tdSql.checkData(0, 1, "CREATE TABLE `%s` (`ts` TIMESTAMP,`i` INT) TAGS (`j` INT)" %self.stb1) tdSql.execute("create table db.`table!1` using db.`%s` tags(1)" %self.stb1) tdSql.query("describe db.`table!1` ; ") @@ -221,7 +221,7 @@ class TDTestCase: tdSql.query("show create stable `%s` ; " %self.stb2) tdSql.checkData(0, 0, self.stb2) - tdSql.checkData(0, 1, "create table `%s` (ts TIMESTAMP,i INT) TAGS (j INT)" %self.stb2) + tdSql.checkData(0, 1, "CREATE TABLE `%s` (`ts` TIMESTAMP,`i` INT) TAGS (`j` INT)" %self.stb2) tdSql.execute("create table `table!2` using `%s` tags(1)" %self.stb2) tdSql.query("describe `table!2` ; ") @@ -310,7 +310,7 @@ class TDTestCase: tdSql.query("show create table `%s` ; " %self.regular_table) tdSql.checkData(0, 0, self.regular_table) - tdSql.checkData(0, 1, "CREATE TABLE `%s` (ts TIMESTAMP,i INT)" %self.regular_table) + tdSql.checkData(0, 1, "CREATE TABLE `%s` (`ts` TIMESTAMP,`i` INT)" %self.regular_table) tdSql.execute("insert into `%s` values(now, 1)" %self.regular_table) tdSql.query("select * from `%s` ; " %self.regular_table) @@ -341,7 +341,12 @@ class TDTestCase: tdSql.error("select * from `%s`" %self.regular_table) - + # TS-1366 + tdSql.execute("create table meters(ts timestamp, c1 int) tags(t1 int, t2 tinyint unsigned, t3 smallint unsigned, t4 int unsigned, t5 bigint unsigned, t6 int)") + tdSql.execute("create table meter1 using meters tags(1, 2, 3, 4, 5, 6)") + + tdSql.query("show create table meter1") + tdSql.checkData(0, 1, "CREATE TABLE `meter1` USING `meters` TAGS (1,2,3,4,5,6)") def stop(self): diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py index 36221e4b7ff21b82ccf72451cfea8472952b622d..61ed052c6b33e1e4400136374c92d9f6a5109c00 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestInsertTime_step.py @@ -24,7 +24,7 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -32,26 +32,29 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath() + if (binPath == "taosBenchmark"): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) + + # insert: create one or mutiple tables per sql and insert multiple + # rows per sql - # insert: create one or mutiple tables per sql and insert multiple rows per sql - # check the params of taosdemo about time_step is nano - os.system("%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json -y " % binPath) + os.system( + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertNanoDB.json -y " % + binPath) tdSql.execute("use testdb1") tdSql.query("show stables") tdSql.checkData(0, 4, 100) @@ -63,12 +66,14 @@ class TDTestCase: tdSql.checkData(0, 0, 10000) tdSql.query("describe stb0") tdSql.getData(9, 1) - tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.checkDataType(9, 1, "TIMESTAMP") tdSql.query("select last(ts) from stb0") - tdSql.checkData(0, 0,"2021-07-01 00:00:00.000099000") + tdSql.checkData(0, 0, "2021-07-01 00:00:00.000099000") # check the params of taosdemo about time_step is us - os.system("%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json -y " % binPath) + os.system( + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertUSDB.json -y " % + binPath) tdSql.execute("use testdb2") tdSql.query("show stables") tdSql.checkData(0, 4, 100) @@ -80,12 +85,14 @@ class TDTestCase: tdSql.checkData(0, 0, 10000) tdSql.query("describe stb0") tdSql.getData(9, 1) - tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.checkDataType(9, 1, "TIMESTAMP") tdSql.query("select last(ts) from stb0") - tdSql.checkData(0, 0,"2021-07-01 00:00:00.099000") + tdSql.checkData(0, 0, "2021-07-01 00:00:00.099000") # check the params of taosdemo about time_step is ms - os.system("%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json -y " % binPath) + os.system( + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoInsertMSDB.json -y " % + binPath) tdSql.execute("use testdb3") tdSql.query("show stables") tdSql.checkData(0, 4, 100) @@ -96,15 +103,12 @@ class TDTestCase: tdSql.query("select count(*) from stb0") tdSql.checkData(0, 0, 10000) tdSql.query("describe stb0") - tdSql.checkDataType(9, 1,"TIMESTAMP") + tdSql.checkDataType(9, 1, "TIMESTAMP") tdSql.query("select last(ts) from stb0") - tdSql.checkData(0, 0,"2021-07-01 00:01:39.000") + tdSql.checkData(0, 0, "2021-07-01 00:01:39.000") - os.system("rm -rf ./res.txt") os.system("rm -rf ./*.py.sql") - - def stop(self): tdSql.close() diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py index f6928dffefde2420969492c2160456297d99e8bf..8329b82076b598a6d35d6d65edce60fd38a4d72b 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoInsert.py @@ -12,7 +12,8 @@ # -*- coding: utf-8 -*- import sys -import os, time +import os +import time from util.log import * from util.cases import * from util.sql import * @@ -24,7 +25,7 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -32,28 +33,28 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) # insert: create one or mutiple tables per sql and insert multiple rows per sql # insert data from a special timestamp # check stable stb0 os.system( - "%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json -y " % + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json -y " % binPath) tdSql.execute("use nsdb") tdSql.query("show stables") @@ -88,7 +89,7 @@ class TDTestCase: # check stable stb0 os.system( - "%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json -y " % + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseNow.json -y " % binPath) tdSql.execute("use nsdb2") @@ -107,9 +108,8 @@ class TDTestCase: # insert by csv files and timetamp is long int , strings in ts and # cols - os.system( - "%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " % + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " % binPath) tdSql.execute("use nsdbcsv") tdSql.query("show stables") @@ -133,7 +133,7 @@ class TDTestCase: # taosdemo test insert with command and parameter , detals show # taosdemo --help os.system( - "%staosBenchmark -u root -ptaosdata -P 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " % + "%s -u root -ptaosdata -P 6030 -a 1 -m pre -n 10 -T 20 -t 60 -o res.txt -y " % binPath) tdSql.query("select count(*) from test.meters") tdSql.checkData(0, 0, 600) diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py index 137cbe724310260254591c874e7bc0362f1e7f2f..19e8e9263f654ffe9006052a7e28fb137db94e34 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.py @@ -1,4 +1,4 @@ -''################################################################### +'' # Copyright (c) 2016 by TAOS Technologies, Inc. # All rights reserved. # @@ -24,7 +24,7 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -32,70 +32,77 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) - # query: query test for nanoSecond with where and max min groupby order - os.system("%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json -y " % binPath) + # query: query test for nanoSecond with where and max min groupby order + os.system( + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabase.json -y " % + binPath) tdSql.execute("use nsdb") - # use where to filter - - tdSql.query("select count(*) from stb0 where ts>\"2021-07-01 00:00:00.590000000 \" ") + # use where to filter + + tdSql.query( + "select count(*) from stb0 where ts>\"2021-07-01 00:00:00.590000000 \" ") tdSql.checkData(0, 0, 4000) - tdSql.query("select count(*) from stb0 where ts>\"2021-07-01 00:00:00.000000000\" and ts <=\"2021-07-01 00:00:00.590000000\" ") + tdSql.query( + "select count(*) from stb0 where ts>\"2021-07-01 00:00:00.000000000\" and ts <=\"2021-07-01 00:00:00.590000000\" ") tdSql.checkData(0, 0, 5900) - tdSql.query("select count(*) from tb0_0 where ts>\"2021-07-01 00:00:00.590000000 \" ;") + tdSql.query( + "select count(*) from tb0_0 where ts>\"2021-07-01 00:00:00.590000000 \" ;") tdSql.checkData(0, 0, 40) - tdSql.query("select count(*) from tb0_0 where ts>\"2021-07-01 00:00:00.000000000\" and ts <=\"2021-07-01 00:00:00.590000000\" ") + tdSql.query( + "select count(*) from tb0_0 where ts>\"2021-07-01 00:00:00.000000000\" and ts <=\"2021-07-01 00:00:00.590000000\" ") tdSql.checkData(0, 0, 59) - # select max min avg from special col tdSql.query("select max(c10) from stb0;") - print("select max(c10) from stb0 : " , tdSql.getData(0, 0)) + print("select max(c10) from stb0 : ", tdSql.getData(0, 0)) tdSql.query("select max(c10) from tb0_0;") - print("select max(c10) from tb0_0 : " , tdSql.getData(0, 0)) - + print("select max(c10) from tb0_0 : ", tdSql.getData(0, 0)) tdSql.query("select min(c1) from stb0;") - print( "select min(c1) from stb0 : " , tdSql.getData(0, 0)) + print("select min(c1) from stb0 : ", tdSql.getData(0, 0)) tdSql.query("select min(c1) from tb0_0;") - print( "select min(c1) from tb0_0 : " , tdSql.getData(0, 0)) + print("select min(c1) from tb0_0 : ", tdSql.getData(0, 0)) tdSql.query("select avg(c1) from stb0;") - print( "select avg(c1) from stb0 : " , tdSql.getData(0, 0)) + print("select avg(c1) from stb0 : ", tdSql.getData(0, 0)) tdSql.query("select avg(c1) from tb0_0;") - print( "select avg(c1) from tb0_0 : " , tdSql.getData(0, 0)) + print("select avg(c1) from tb0_0 : ", tdSql.getData(0, 0)) tdSql.query("select count(*) from stb0 group by tbname;") tdSql.checkData(0, 0, 100) tdSql.checkData(10, 0, 100) - # query : query above sqls by taosdemo and continuously - - os.system("%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.json -y " % binPath) + # query : query above sqls by taosdemo and continuously + os.system( + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuery.json -y " % + binPath) - os.system("%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " % binPath) + os.system( + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabasecsv.json -y " % + binPath) tdSql.execute("use nsdbcsv") tdSql.query("show stables") tdSql.checkData(0, 4, 100) @@ -103,24 +110,37 @@ class TDTestCase: tdSql.checkData(0, 0, 10000) tdSql.query("describe stb0") tdSql.checkDataType(3, 1, "TIMESTAMP") - tdSql.query("select count(*) from stb0 where ts >\"2021-07-01 00:00:00.490000000\"") + tdSql.query( + "select count(*) from stb0 where ts >\"2021-07-01 00:00:00.490000000\"") tdSql.checkData(0, 0, 5000) tdSql.query("select count(*) from stb0 where ts 162687012800000000') - tdSql.execute('select count(*) from stb0 where c2 < 162687012800000000') - tdSql.execute('select count(*) from stb0 where c2 = 162687012800000000') - tdSql.execute('select count(*) from stb0 where c2 != 162687012800000000') - tdSql.execute('select count(*) from stb0 where c2 <> 162687012800000000') - tdSql.execute('select count(*) from stb0 where c2 > "2021-07-21 20:22:08.248246976"') - tdSql.execute('select count(*) from stb0 where c2 < "2021-07-21 20:22:08.248246976"') - tdSql.execute('select count(*) from stb0 where c2 = "2021-07-21 20:22:08.248246976"') - tdSql.execute('select count(*) from stb0 where c2 != "2021-07-21 20:22:08.248246976"') - tdSql.execute('select count(*) from stb0 where c2 <> "2021-07-21 20:22:08.248246976"') - tdSql.execute('select count(*) from stb0 where ts between "2021-07-01 00:00:00.000000000" and "2021-07-01 00:00:00.990000000"') - tdSql.execute('select count(*) from stb0 where ts between 1625068800000000000 and 1625068801000000000') + tdSql.execute( + 'select count(*) from stb0 where c2 > 162687012800000000') + tdSql.execute( + 'select count(*) from stb0 where c2 < 162687012800000000') + tdSql.execute( + 'select count(*) from stb0 where c2 = 162687012800000000') + tdSql.execute( + 'select count(*) from stb0 where c2 != 162687012800000000') + tdSql.execute( + 'select count(*) from stb0 where c2 <> 162687012800000000') + tdSql.execute( + 'select count(*) from stb0 where c2 > "2021-07-21 20:22:08.248246976"') + tdSql.execute( + 'select count(*) from stb0 where c2 < "2021-07-21 20:22:08.248246976"') + tdSql.execute( + 'select count(*) from stb0 where c2 = "2021-07-21 20:22:08.248246976"') + tdSql.execute( + 'select count(*) from stb0 where c2 != "2021-07-21 20:22:08.248246976"') + tdSql.execute( + 'select count(*) from stb0 where c2 <> "2021-07-21 20:22:08.248246976"') + tdSql.execute( + 'select count(*) from stb0 where ts between "2021-07-01 00:00:00.000000000" and "2021-07-01 00:00:00.990000000"') + tdSql.execute( + 'select count(*) from stb0 where ts between 1625068800000000000 and 1625068801000000000') tdSql.query('select avg(c0) from stb0 interval(5000000000b)') tdSql.checkRows(1) @@ -136,17 +156,17 @@ class TDTestCase: tdSql.query('select avg(c0) from stb0 interval(1u)') tdSql.checkRows(100) - tdSql.query('select avg(c0) from stb0 interval(100000000b) sliding (100000000b)') + tdSql.query( + 'select avg(c0) from stb0 interval(100000000b) sliding (100000000b)') tdSql.checkRows(10) # query : query above sqls by taosdemo and continuously - os.system("%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuerycsv.json -y " % binPath) + os.system( + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoQuerycsv.json -y " % + binPath) os.system("rm -rf ./query_res*.txt*") os.system("rm -rf tools/taosdemoAllTest/NanoTestCase/*.py.sql") - - - def stop(self): tdSql.close() diff --git a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py index f3cd4fb8333b37c55d5f1cf7a74adcabdfcde686..aa1f98edc104b4c829b9682420aba6ca7e7d095e 100644 --- a/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py +++ b/tests/pytest/tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanosubscribe.py @@ -26,8 +26,8 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): + + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -35,96 +35,104 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] # get the number of subscriptions - def subTimes(self,filename): + def subTimes(self, filename): self.filename = filename - command = 'cat %s |wc -l'% filename - times = int(subprocess.getstatusoutput(command)[1]) + command = 'cat %s |wc -l' % filename + times = int(subprocess.getstatusoutput(command)[1]) return times - + # assert results - def assertCheck(self,filename,subResult,expectResult): + def assertCheck(self, filename, subResult, expectResult): self.filename = filename self.subResult = subResult self.expectResult = expectResult args0 = (filename, subResult, expectResult) print("Queryfile:%s ,result is %s != expect: %s" % args0) - assert subResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0 + assert subResult == expectResult, "Queryfile:%s ,result is %s != expect: %s" % args0 def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) # clear envs - os.system("ps -aux |grep 'taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") - os.system("ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") - os.system("rm -rf ./subscribe_res*") - os.system("rm -rf ./all_subscribe_res*") + os.system( + "ps -aux |grep 'taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + os.system( + "ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./all_subscribe_res*") # insert data - os.system("%staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json" % binPath) + os.system( + "%s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json" % + binPath) tdSql.query("select count(*) from subnsdb.stb0") - tdSql.checkData(0,0,100) - - os.system(" nohup %staosBenchmark -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json & >/dev/null 2>&1" % binPath) + tdSql.checkData(0, 0, 100) + + os.system( + " nohup %s -f tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json & >/dev/null 2>&1" % + binPath) sleep(3) print('taosBenchmark query done!') - + # merge result files - + os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") sleep(5) - + # check subscribeTimes testcase subTimes0 = self.subTimes("all_subscribe_res0.txt") - self.assertCheck("all_subscribe_res0.txt",subTimes0 ,200) + self.assertCheck("all_subscribe_res0.txt", subTimes0, 200) subTimes1 = self.subTimes("all_subscribe_res1.txt") - self.assertCheck("all_subscribe_res1.txt",subTimes1 ,200) + self.assertCheck("all_subscribe_res1.txt", subTimes1, 200) subTimes2 = self.subTimes("all_subscribe_res2.txt") - self.assertCheck("all_subscribe_res2.txt",subTimes2 ,200) - + self.assertCheck("all_subscribe_res2.txt", subTimes2, 200) - # insert extral data + # insert extral data tdSql.execute("use subnsdb") - tdSql.execute("insert into tb0_0 values(now,100.1000,'subtest1',now-1s)") - sleep(5) + tdSql.execute( + "insert into tb0_0 values(now,100.1000,'subtest1',now-1s)") + sleep(5) os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") subTimes0 = self.subTimes("all_subscribe_res0.txt") - self.assertCheck("all_subscribe_res0.txt",subTimes0 ,202) + self.assertCheck("all_subscribe_res0.txt", subTimes0, 202) sleep(3) - os.system("rm -rf ./subscribe_res*") + os.system("rm -rf ./subscribe_res*") os.system("rm -rf ./all_subscribe*") os.system("rm -rf ./*.py.sql") os.system("rm -rf ./nohup*") - os.system("ps -aux |grep 'taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") - os.system("ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") - os.system("ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") - + os.system( + "ps -aux |grep 'taosdemoAllTest/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + os.system( + "ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestSupportNanoSubscribe.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") + os.system( + "ps -aux |grep 'tools/taosdemoAllTest/NanoTestCase/taosdemoTestNanoDatabaseInsertForSub.json' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) + tdCases.addWindows(__file__, TDTestCase()) tdCases.addLinux(__file__, TDTestCase()) - diff --git a/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo.py b/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo.py deleted file mode 100644 index 8f28f214090dd4ac528e3408ae133da3ed67c545..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo.py +++ /dev/null @@ -1,185 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import taos -import time -import os -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - os.system("rm -rf tools/taosdemoAllTest/TD-10539/create_taosdemo.py.sql") - tdSql.prepare() - - #print("==============taosdemo,#create stable,table; insert table; show table; select table; drop table") - self.tsdemo = "tsdemo~!.@#$%^*[]-_=+{,?.}" - #this escape character is not support in shell . include & () <> | / - os.system("%staosBenchmark -d test -E -m %s -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo)) - tdSql.execute("use test ;" ) - tdSql.query("select count(*) from meters") - tdSql.checkData(0, 0, 1000) - tdSql.query("show test.tables like 'tsdemo%'" ) - tdSql.checkRows(10) - tdSql.query("show test.tables like '%s_'" %self.tsdemo) - tdSql.checkRows(10) - tdSql.query("select _block_dist() from `%s1`" %self.tsdemo) - tdSql.checkRows(1) - tdSql.query("describe test.`%s1` ; " %self.tsdemo) - tdSql.checkRows(13) - tdSql.query("show create table test.`%s1` ; " %self.tsdemo) - tdSql.checkData(0, 0, self.tsdemo+str(1)) - tdSql.checkData(0, 1, "CREATE TABLE `%s1` USING `meters` TAGS (1,\"beijing\")" %self.tsdemo) - - print("==============drop table\stable") - try: - tdSql.execute("drop table test.`%s1` ; " %self.tsdemo) - except Exception as e: - tdLog.exit(e) - - tdSql.error("select * from test.`%s1` ; " %self.tsdemo) - tdSql.query("show test.tables like '%s_'" %self.tsdemo) - tdSql.checkRows(9) - - try: - tdSql.execute("drop table test.meters ") - except Exception as e: - tdLog.exit(e) - - tdSql.error("select * from test.meters ") - tdSql.error("select * from test.`%s2` ; " %self.tsdemo) - - # Exception - os.system("%staosBenchmark -d test -m %s -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo)) - tdSql.query("show test.tables ") - tdSql.checkRows(0) - - #print("==============taosdemo,#create regular table; insert table; show table; select table; drop table") - self.tsdemo = "tsdemo~!.@#$%^*[]-_=+{,?.}" - #this escape character is not support in shell . include & () <> | / - os.system("%staosBenchmark -N -E -m %s -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo)) - tdSql.execute("use test ;" ) - tdSql.query("select count(*) from `%s1`" %self.tsdemo) - tdSql.checkData(0, 0, 100) - tdSql.query("show test.tables like 'tsdemo%'" ) - tdSql.checkRows(10) - tdSql.query("show test.tables like '%s_'" %self.tsdemo) - tdSql.checkRows(10) - tdSql.query("select _block_dist() from `%s1`" %self.tsdemo) - tdSql.checkRows(1) - tdSql.query("describe test.`%s1` ; " %self.tsdemo) - tdSql.checkRows(11) - tdSql.query("show create table test.`%s1` ; " %self.tsdemo) - tdSql.checkData(0, 0, self.tsdemo+str(1)) - tdSql.checkData(0, 1, "CREATE TABLE `%s1` (ts TIMESTAMP,c0 FLOAT,c1 INT,c2 FLOAT,c3 INT,c4 INT,c5 INT,c6 INT,c7 INT,c8 INT,c9 INT)" %self.tsdemo) - - print("==============drop table\stable") - try: - tdSql.execute("drop table test.`%s1` ; " %self.tsdemo) - except Exception as e: - tdLog.exit(e) - - tdSql.error("select * from test.`%s1` ; " %self.tsdemo) - tdSql.query("show test.tables like '%s_'" %self.tsdemo) - tdSql.checkRows(9) - - # Exception - os.system("%staosBenchmark -N -m %s -t 10 -n 100 -l 10 -y " % (binPath,self.tsdemo)) - tdSql.query("show test.tables ") - tdSql.checkRows(0) - - - #print("==============taosdemo——json_yes,#create stable,table; insert table; show table; select table; drop table") - os.system("%staosBenchmark -f tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json -y " % binPath) - tdSql.execute("use dbyes") - - self.tsdemo_stable = "tsdemo_stable~!.@#$%^*[]-_=+{,?.}" - self.tsdemo = "tsdemo~!.@#$%^*[]-_=+{,?.}" - - tdSql.query("select count(*) from dbyes.`%s`" %self.tsdemo_stable) - tdSql.checkData(0, 0, 1000) - tdSql.query("show dbyes.tables like 'tsdemo%'" ) - tdSql.checkRows(10) - tdSql.query("show dbyes.tables like '%s_'" %self.tsdemo) - tdSql.checkRows(10) - tdSql.query("select _block_dist() from `%s1`" %self.tsdemo) - tdSql.checkRows(1) - tdSql.query("describe dbyes.`%s1` ; " %self.tsdemo) - tdSql.checkRows(13) - tdSql.query("show create table dbyes.`%s1` ; " %self.tsdemo) - tdSql.checkData(0, 0, self.tsdemo+str(1)) - tdSql.checkData(0, 1, "CREATE TABLE `%s1` USING `%s` TAGS (1,1)" %(self.tsdemo,self.tsdemo_stable)) - - print("==============drop table\stable") - try: - tdSql.execute("drop table dbyes.`%s1` ; " %self.tsdemo) - except Exception as e: - tdLog.exit(e) - - tdSql.error("select * from dbyes.`%s1` ; " %self.tsdemo) - tdSql.query("show dbyes.tables like '%s_'" %self.tsdemo) - tdSql.checkRows(9) - - try: - tdSql.execute("drop table dbyes.`%s` ; " %self.tsdemo_stable) - except Exception as e: - tdLog.exit(e) - - tdSql.error("select * from dbyes.`%s` ; " %self.tsdemo_stable) - tdSql.error("select * from dbyes.`%s2` ; " %self.tsdemo) - - #print("==============taosdemo——json_no,#create stable,table; insert table; show table; select table; drop table") - - os.system("%staosBenchmark -f tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json -y " % binPath) - tdSql.query("show dbno.tables;") - tdSql.checkRows(0) - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json b/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json deleted file mode 100644 index 759a437b448c8c65bf252e859345dd9557cc51c5..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_no.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "filetype": "insert", - "cfgdir": "/etc/taos", - "host": "127.0.0.1", - "port": 6030, - "user": "root", - "password": "taosdata", - "thread_count": 10, - "thread_count_create_tbl": 10, - "result_file": "./insert_res.txt", - "confirm_parameter_prompt": "no", - "insert_interval": 0, - "interlace_rows": 10, - "num_of_records_per_req": 1, - "max_sql_len": 1024000, - "databases": [{ - "dbinfo": { - "name": "dbno", - "drop": "yes", - "replica": 1, - "days": 10, - "cache": 50, - "blocks": 8, - "precision": "ms", - "keep": 36500, - "minRows": 100, - "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 - }, - "super_tables": [{ - "name": "meters", - "child_table_exists":"no", - "childtable_count": 10, - "childtable_prefix": "tsdemo~!.@#$%^*[]-_=+{,?.}", - "escape_character": "no", - "auto_create_table": "no", - "batch_create_tbl_num": 1, - "data_source": "rand", - "insert_mode": "taosc", - "insert_rows": 100, - "childtable_limit": 0, - "childtable_offset":0, - "multi_thread_write_one_tbl": "no", - "interlace_rows": 0, - "insert_interval":0, - "max_sql_len": 1024000, - "disorder_ratio": 0, - "disorder_range": 1000, - "timestamp_step": 1, - "start_timestamp": "2020-10-01 00:00:00.000", - "sample_format": "csv", - "sample_file": "", - "tags_file": "", - "columns": [{"type": "INT","count":9}, {"type": "BINARY", "len": 16, "count":1}], - "tags": [{"type": "INT", "count":2}] - }] - }] -} diff --git a/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json b/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json deleted file mode 100644 index aafc79215fc0b94d037da3a9b229a2f967b51613..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/TD-10539/create_taosdemo_yes.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "filetype": "insert", - "cfgdir": "/etc/taos", - "host": "127.0.0.1", - "port": 6030, - "user": "root", - "password": "taosdata", - "thread_count": 5, - "thread_count_create_tbl": 10, - "result_file": "./insert_res.txt", - "confirm_parameter_prompt": "no", - "insert_interval": 0, - "interlace_rows": 10, - "num_of_records_per_req": 1, - "max_sql_len": 1024000, - "databases": [{ - "dbinfo": { - "name": "dbyes", - "drop": "yes", - "replica": 1, - "days": 10, - "cache": 50, - "blocks": 8, - "precision": "ms", - "keep": 36500, - "minRows": 100, - "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 - }, - "super_tables": [{ - "name": "tsdemo_stable~!.@#$%^*[]-_=+{,?.}", - "child_table_exists":"no", - "childtable_count": 10, - "childtable_prefix": "tsdemo~!.@#$%^*[]-_=+{,?.}", - "escape_character": "yes", - "auto_create_table": "no", - "batch_create_tbl_num": 1, - "data_source": "rand", - "insert_mode": "taosc", - "insert_rows": 100, - "childtable_limit": 0, - "childtable_offset":0, - "multi_thread_write_one_tbl": "no", - "interlace_rows": 0, - "insert_interval":0, - "max_sql_len": 1024000, - "disorder_ratio": 0, - "disorder_range": 1000, - "timestamp_step": 1, - "start_timestamp": "2020-10-01 00:00:00.000", - "sample_format": "csv", - "sample_file": "", - "tags_file": "", - "columns": [{"type": "INT","count":9}, {"type": "BINARY", "len": 16, "count":1}], - "tags": [{"type": "INT", "count":2}] - }] - }] -} diff --git a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json deleted file mode 100644 index c2e4920097cd1b3581c9893c9677c3cf1f14b7ed..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "filetype": "insert", - "cfgdir": "/etc/taos", - "host": "127.0.0.1", - "port": 6030, - "user": "root", - "password": "taosdata", - "thread_count": 4, - "thread_count_create_tbl": 4, - "result_file": "./insert_res.txt", - "confirm_parameter_prompt": "no", - "insert_interval": 0, - "interlace_rows": 100, - "num_of_records_per_req": 1000, - "max_sql_len": 1024000, - "databases": [{ - "dbinfo": { - "name": "db", - "drop": "yes", - "replica": 1, - "days": 10, - "cache": 50, - "blocks": 8, - "precision": "ms", - "keep": 36500, - "minRows": 100, - "maxRows": 4096, - "comp":2, - "walLevel":1, - "cachelast":0, - "quorum":1, - "fsync":3000, - "update": 0 - }, - "super_tables": [{ - "name": "stb0", - "child_table_exists":"no", - "childtable_count": 60, - "childtable_prefix": "stb00_", - "auto_create_table": "no", - "batch_create_tbl_num": 20, - "data_source": "rand", - "insert_mode": "taosc", - "insert_rows": 100000, - "childtable_limit": -1, - "childtable_offset":0, - "multi_thread_write_one_tbl": "no", - "interlace_rows": 1000, - "insert_interval":0, - "max_sql_len": 1024000, - "disorder_ratio": 0, - "disorder_range": 1000, - "timestamp_step": 1, - "start_timestamp": "2020-10-01 00:00:00.000", - "sample_format": "csv", - "sample_file": "./sample.csv", - "tags_file": "", - "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], - "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] - }] - }] -} diff --git a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.py b/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.py deleted file mode 100644 index e8e65b68b89c35f33e239b4121f4d99b84c796a0..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/TD-3453/query-interrupt.py +++ /dev/null @@ -1,89 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -import subprocess -import time -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - # # insert 1000w rows in stb0 - os.system("%staosBenchmark -f tools/taosdemoAllTest/TD-3453/query-interrupt.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0,60) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 6000000) - os.system('%staosBenchmark -f tools/taosdemoAllTest/TD-3453/queryall.json -y & ' % binPath) - time.sleep(2) - query_pid = int(subprocess.getstatusoutput('ps aux|grep "TD-3453/queryall.json" |grep -v "grep"|awk \'{print $2}\'')[1]) - taosd_cpu_load_1 = float(subprocess.getstatusoutput('top -n 1 -b -p $(ps aux|grep "bin/taosd -c"|grep -v "grep" |awk \'{print $2}\')|awk \'END{print}\' |awk \'{print $9}\'')[1]) - if taosd_cpu_load_1 > 10.0 : - os.system("kill -9 %d" % query_pid) - time.sleep(5) - taosd_cpu_load_2 = float(subprocess.getstatusoutput('top -n 1 -b -p $(ps aux|grep "bin/taosd -c"|grep -v "grep" |awk \'{print $2}\')|awk \'END{print}\' |awk \'{print $9}\'')[1]) - if taosd_cpu_load_2 < 10.0 : - suc_kill = 60 - else: - suc_kill = 10 - print("taosd_cpu_load is higher than 10%") - else: - suc_kill = 20 - print("taosd_cpu_load is still less than 10%") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, "%d" % suc_kill) - os.system("rm -rf querySystemInfo*") - os.system("rm -rf insert_res.txt") - os.system("rm -rf query_res.txt") - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/TD-3453/queryall.json b/tests/pytest/tools/taosdemoAllTest/TD-3453/queryall.json deleted file mode 100644 index 97697feb9dd4e123a86543f0dc9198dacca1bc19..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/TD-3453/queryall.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "filetype":"query", - "cfgdir": "/etc/taos", - "host": "127.0.0.1", - "port": 6030, - "user": "root", - "password": "taosdata", - "confirm_parameter_prompt": "no", - "databases": "db", - "specified_table_query":{ - "query_interval":1, - "threads":1, - "sqls":[ - { - "sql": "select * from stb0", - "result": "./query_res.txt" - } - ] - } -} \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py index 987dd1bfa4771b505023bdeab78994ba488d671a..0b45b42dca5c9e51b0c03fde9d092fdb338811d5 100644 --- a/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py +++ b/tests/pytest/tools/taosdemoAllTest/TD-4985/query-limit-offset.py @@ -28,7 +28,7 @@ class TDTestCase: now = time.time() self.ts = int(round(now * 1000)) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -36,153 +36,184 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) # insert: create one or mutiple tables per sql and insert multiple rows per sql # test case for https://jira.taosdata.com:18080/browse/TD-4985 os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql") - os.system("%staosBenchmark -f tools/taosdemoAllTest/TD-4985/query-limit-offset.json -y " % binPath) + os.system( + "%s -f tools/taosdemoAllTest/TD-4985/query-limit-offset.json -y " % + binPath) tdSql.execute("use db") tdSql.query("select count (tbname) from stb0") tdSql.checkData(0, 0, 10000) for i in range(1000): - tdSql.execute('''insert into stb00_9999 values(%d, %d, %d,'test99.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_8888 values(%d, %d, %d,'test98.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_7777 values(%d, %d, %d,'test97.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_6666 values(%d, %d, %d,'test96.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_5555 values(%d, %d, %d,'test95.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_4444 values(%d, %d, %d,'test94.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_3333 values(%d, %d, %d,'test93.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_2222 values(%d, %d, %d,'test92.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_1111 values(%d, %d, %d,'test91.%s')''' - % (self.ts + i, i, -10000+i, i)) - tdSql.execute('''insert into stb00_100 values(%d, %d, %d,'test90.%s')''' - % (self.ts + i, i, -10000+i, i)) + tdSql.execute( + '''insert into stb00_9999 values(%d, %d, %d,'test99.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_8888 values(%d, %d, %d,'test98.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_7777 values(%d, %d, %d,'test97.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_6666 values(%d, %d, %d,'test96.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_5555 values(%d, %d, %d,'test95.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_4444 values(%d, %d, %d,'test94.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_3333 values(%d, %d, %d,'test93.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_2222 values(%d, %d, %d,'test92.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_1111 values(%d, %d, %d,'test91.%s')''' % + (self.ts + i, i, -10000 + i, i)) + tdSql.execute( + '''insert into stb00_100 values(%d, %d, %d,'test90.%s')''' % + (self.ts + i, i, -10000 + i, i)) tdSql.query("select * from stb0 where c2 like 'test99%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_9999' limit 10") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_9999' limit 10 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test98%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_8888' limit 10" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_8888' limit 10") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_8888' limit 10 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_8888' limit 10 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test97%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_7777' limit 10" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_7777' limit 10") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_7777' limit 10 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_7777' limit 10 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test96%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_6666' limit 10" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_6666' limit 10") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_6666' limit 10 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_6666' limit 10 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test95%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_5555' limit 10" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_5555' limit 10") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_5555' limit 10 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_5555' limit 10 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test94%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_4444' limit 10" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_4444' limit 10") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_4444' limit 10 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_4444' limit 10 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test93%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_3333' limit 100" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_3333' limit 100") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_3333' limit 100 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_3333' limit 100 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test92%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_2222' limit 100" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_2222' limit 100") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_2222' limit 100 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_2222' limit 100 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test91%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_1111' limit 100" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_1111' limit 100") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_1111' limit 100 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_1111' limit 100 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) tdSql.query("select * from stb0 where c2 like 'test90%' ") tdSql.checkRows(1000) - tdSql.query("select * from stb0 where tbname like 'stb00_100' limit 100" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_100' limit 100") tdSql.checkData(0, 1, 0) tdSql.checkData(1, 1, 1) tdSql.checkData(2, 1, 2) - tdSql.query("select * from stb0 where tbname like 'stb00_100' limit 100 offset 5" ) + tdSql.query( + "select * from stb0 where tbname like 'stb00_100' limit 100 offset 5") tdSql.checkData(0, 1, 5) tdSql.checkData(1, 1, 6) tdSql.checkData(2, 1, 7) - def stop(self): tdSql.close() diff --git a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py index 56b51f5498aed0a540a86bf03625266ad3599b58..c047e4b0aadcc27e0014420c2d350f106125109c 100755 --- a/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py +++ b/tests/pytest/tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py @@ -24,8 +24,8 @@ class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): + + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -33,26 +33,26 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath - + return paths[0] + def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) #-N:regular table -d:database name -t:table num -n:rows num per table -l:col num -y:force - #regular old && new + # regular old && new startTime = time.time() - os.system("%staosBenchmark -N -d regular_old -t 1 -n 10 -l 1023 -y" % binPath) + os.system("%s -N -d regular_old -t 1 -n 10 -l 1023 -y" % binPath) tdSql.execute("use regular_old") tdSql.query("show tables;") tdSql.checkRows(1) @@ -61,7 +61,7 @@ class TDTestCase: tdSql.query("describe d0;") tdSql.checkRows(1024) - os.system("%staosBenchmark -N -d regular_new -t 1 -n 10 -l 4095 -y" % binPath) + os.system("%s -N -d regular_new -t 1 -n 10 -l 4095 -y" % binPath) tdSql.execute("use regular_new") tdSql.query("show tables;") tdSql.checkRows(1) @@ -70,8 +70,9 @@ class TDTestCase: tdSql.query("describe d0;") tdSql.checkRows(4096) - #super table -d:database name -t:table num -n:rows num per table -l:col num -y:force - os.system("%staosBenchmark -d super_old -t 1 -n 10 -l 1021 -y" % binPath) + # super table -d:database name -t:table num -n:rows num per table + # -l:col num -y:force + os.system("%s -d super_old -t 1 -n 10 -l 1021 -y" % binPath) tdSql.execute("use super_old") tdSql.query("show tables;") tdSql.checkRows(1) @@ -84,7 +85,7 @@ class TDTestCase: tdSql.query("describe d0;") tdSql.checkRows(1024) - os.system("%staosBenchmark -d super_new -t 1 -n 10 -l 4093 -y" % binPath) + os.system("%s -d super_new -t 1 -n 10 -l 4093 -y" % binPath) tdSql.execute("use super_new") tdSql.query("show tables;") tdSql.checkRows(1) @@ -102,9 +103,11 @@ class TDTestCase: tdSql.query("describe stb_new1_1;") tdSql.checkRows(4096) - # insert: create one or mutiple tables per sql and insert multiple rows per sql + # insert: create one or mutiple tables per sql and insert multiple rows per sql # test case for https://jira.taosdata.com:18080/browse/TD-5213 - os.system("%staosBenchmark -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json -y " % binPath) + os.system( + "%s -f tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.json -y " % + binPath) tdSql.execute("use json_test") tdSql.query("select count (tbname) from stb_old") tdSql.checkData(0, 0, 1) @@ -112,7 +115,7 @@ class TDTestCase: tdSql.query("select * from stb_old") tdSql.checkRows(10) tdSql.checkCols(1024) - + tdSql.query("select count (tbname) from stb_new") tdSql.checkData(0, 0, 1) @@ -160,13 +163,11 @@ class TDTestCase: tdSql.query("describe stb_excel_0;") tdSql.checkRows(4096) endTime = time.time() - print("total time %ds" % (endTime - startTime)) + print("total time %ds" % (endTime - startTime)) + os.system( + "rm -rf tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py.sql") - os.system("rm -rf tools/taosdemoAllTest/TD-5213/insertSigcolumnsNum4096.py.sql") - - - def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/tools/taosdemoAllTest/query-interrupt.py b/tests/pytest/tools/taosdemoAllTest/query-interrupt.py deleted file mode 100644 index df021cbe3be5da9a0a28b78bbafef548c24697fa..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/query-interrupt.py +++ /dev/null @@ -1,88 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -import subprocess -import time -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - # # insert 1000w rows in stb0 - os.system("%staosBenchmark -f tools/taosdemoAllTest/query-interrupt.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0,60) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 6000000) - os.system('%staosBenchmark -f tools/taosdemoAllTest/queryall.json -y & ' % binPath) - time.sleep(2) - query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/queryall.json" |grep -v "grep"|awk \'{print $2}\'')[1]) - taosd_cpu_load_1 = float(subprocess.getstatusoutput('top -n 1 -b -p $(ps aux|grep "bin/taosd -c"|grep -v "grep" |awk \'{print $2}\')|awk \'END{print}\' |awk \'{print $9}\'')[1]) - if taosd_cpu_load_1 > 10.0 : - os.system("kill -9 %d" % query_pid) - time.sleep(5) - taosd_cpu_load_2 = float(subprocess.getstatusoutput('top -n 1 -b -p $(ps aux|grep "bin/taosd -c"|grep -v "grep" |awk \'{print $2}\')|awk \'END{print}\' |awk \'{print $9}\'')[1]) - if taosd_cpu_load_2 < 10.0 : - suc_kill = 60 - else: - suc_kill = 10 - print("taosd_cpu_load is higher than 10%") - else: - suc_kill = 20 - print("taosd_cpu_load is still less than 10%") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, "%d" % suc_kill) - os.system("rm -rf querySystemInfo*") - os.system("rm -rf insert_res.txt") - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/subscribeNoResult.py b/tests/pytest/tools/taosdemoAllTest/subscribeNoResult.py deleted file mode 100644 index e1a9f647fa2b5d1f561e50a06b9755d78bebfa79..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/subscribeNoResult.py +++ /dev/null @@ -1,82 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -import time -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * -import _thread - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - self.ts = 1601481600000 - self.numberOfRecords = 1100000 - - def execCmdAndGetOutput(self, cmd): - r = os.popen(cmd) - text = r.read() - r.close() - return text - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - buildPath = self.getBuildPath() - tdSql.prepare() - tdSql.execute("create table st(ts timestamp, c1 timestamp, c2 int, c3 bigint, c4 float, c5 double, c6 binary(8), c7 smallint, c8 tinyint, c9 bool, c10 nchar(8)) tags(t1 int)") - tdSql.execute("create table t1 using st tags(0)") - currts = self.ts - finish = 0 - while(finish < self.numberOfRecords): - sql = "insert into t1 values" - for i in range(finish, self.numberOfRecords): - sql += "(%d, 1019774612, 29931, 1442173978, 165092.468750, 1128.643179, 'MOCq1pTu', 18405, 82, 0, 'g0A6S0Fu')" % (currts + i) - finish = i + 1 - if (1048576 - len(sql)) < 16384: - break - tdSql.execute(sql) - - binPath = buildPath+ "/build/bin/" - - os.system("%staosBenchmark -f tools/taosdemoAllTest/sub_no_result.json -g 2>&1 | tee sub_no_result.log" % binPath) - test_line = int(self.execCmdAndGetOutput("cat sub_no_result.log | wc -l")) - if(test_line < 1100024): - tdLog.exit("failed test subscribeNoResult: %d != expected(1100024)" % test_line) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertAllType.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertAllType.py index 3bc2495f626e28017d55fc6d01f487ef239cd8b5..914231878a61d48bbbca3883e21db18eaf8761ad 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertAllType.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertAllType.py @@ -24,7 +24,7 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -32,24 +32,26 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) - # taosc interface - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-allDataType.json -y " % binPath) + # taosc interface + os.system( + "%s -f tools/taosdemoAllTest/insert-allDataType.json -y " % + binPath) tdSql.execute("use db") tdSql.query("select count (tbname) from stb0") tdSql.checkData(0, 0, 1000) @@ -64,8 +66,10 @@ class TDTestCase: tdSql.query("select count(*) from stb1") tdSql.checkData(0, 0, 200000) - # stmt interface - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-allDataType-stmt.json -y " % binPath) + # stmt interface + os.system( + "%s -f tools/taosdemoAllTest/stmt/insert-allDataType-stmt.json -y " % + binPath) tdSql.execute("use db") tdSql.query("select count (tbname) from stb0") tdSql.checkData(0, 0, 1000) @@ -80,53 +84,60 @@ class TDTestCase: tdSql.query("select count(*) from stb1") tdSql.checkData(0, 0, 200000) - # insert-interface: sml - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-allDataType-sml.json -y " % binPath) + # insert-interface: sml + os.system( + "%s -f tools/taosdemoAllTest/sml/insert-allDataType-sml.json -y " % + binPath) tdSql.execute("use db") tdSql.query("select count (tbname) from stb0") tdSql.checkData(0, 0, 10) tdSql.query("select count (tbname) from stb1") tdSql.checkData(0, 0, 20) # tdSql.query("select last(ts) from db.stb00_0") - # tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") + # tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 1000) + tdSql.checkData(0, 0, 1000) # tdSql.query("select last(ts) from db.stb01_0") - # tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") + # tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 4000) - + tdSql.checkData(0, 0, 4000) - # insert-interface: sml-json - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-sml-json-alltype.json -y " % binPath) + # insert-interface: sml-json + os.system( + "%s -f tools/taosdemoAllTest/sml/insert-sml-json-alltype.json -y " % + binPath) tdSql.execute("use db") tdSql.query("show stables") for i in range(13): - for j in range(13): - if tdSql.queryResult[i][0] == 'stb%d'%j: + for j in range(13): + if tdSql.queryResult[i][0] == 'stb%d' % j: # print(i,"stb%d"%j) - tdSql.checkData(i, 4, j+1) - + tdSql.checkData(i, 4, j + 1) # insert-interface: sml-telnet - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-sml-telnet-alltype.json -y " % binPath) + os.system( + "%s -f tools/taosdemoAllTest/sml/insert-sml-telnet-alltype.json -y " % + binPath) tdSql.execute("use db") tdSql.query("show stables") for i in range(13): - for j in range(13): - if tdSql.queryResult[i][0] == 'stb%d'%j: + for j in range(13): + if tdSql.queryResult[i][0] == 'stb%d' % j: # print(i,"stb%d"%j) - tdSql.checkData(i, 4, j+1) + tdSql.checkData(i, 4, j + 1) for i in range(13): - tdSql.query("select count(*) from stb%d"%i) - tdSql.checkData(0, 0, (i+1)*10) + tdSql.query("select count(*) from stb%d" % i) + tdSql.checkData(0, 0, (i + 1) * 10) # insert-interface: sml-telnet - assert os.system("%staosdemo -f tools/taosdemoAllTest/sml/insert-sml-timestamp.json -y " % binPath) !=0 - + assert os.system( + "%s -f tools/taosdemoAllTest/sml/insert-sml-timestamp.json -y " % + binPath) != 0 # taosdemo command line - os.system("%staosBenchmark -t 1000 -n 100 -T 10 -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,NCHAR,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY -y " % binPath) + os.system( + "%s -t 1000 -n 100 -T 10 -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,NCHAR,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY -y " % + binPath) tdSql.execute("use test") tdSql.query("select count (tbname) from meters") tdSql.checkData(0, 0, 1000) @@ -137,10 +148,7 @@ class TDTestCase: testcaseFilename = os.path.split(__file__)[-1] os.system("rm -rf ./insert_res.txt") - os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) - - - + os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename) def stop(self): tdSql.close() diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertShell.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertShell.py index a872d8566fa83a95c1c47519fd391a69c34b78d5..7403ad60a4a5ee2b257d44bcbaf5a849cdff581d 100644 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertShell.py +++ b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertShell.py @@ -24,40 +24,41 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) global cfgPath if ("community" in selfPath): projPath = selfPath[:selfPath.find("community")] cfgPath = projPath + "/community/sim/dnode1/cfg" - else: projPath = selfPath[:selfPath.find("tests")] cfgPath = projPath + "/sim/dnode1/cfg" + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] # def checkGerData(): def run(self): - buildPath = self.getBuildPath() - print("%s" % cfgPath ) - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + print("%s" % cfgPath) + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) tdLog.info("create super table") - # create super table - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4096 \ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % (binPath,cfgPath)) + # create super table + os.system( + "%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4096 \ + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % + (binPath, cfgPath)) tdSql.execute("use db1") tdSql.query("describe meters;") tdSql.checkRows(13) @@ -68,12 +69,13 @@ class TDTestCase: tdSql.query("select count(*) from `test.0`") tdSql.checkData(0, 0, 100) - tdLog.info("create general table -N ") tdSql.execute("drop database db1;") - # create general table -N - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4096 \ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -N " % (binPath,cfgPath)) + # create general table -N + os.system( + "%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4096 \ + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -N " % + (binPath, cfgPath)) tdSql.execute("use db1") tdSql.query("describe `test.0`;") tdSql.checkRows(11) @@ -85,8 +87,10 @@ class TDTestCase: tdLog.info("use diffrent interface stmt") tdSql.execute("drop database db1;") # use diffrent interface-stmt - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,BINARY\(4000\) -w 40 \ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt " % (binPath,cfgPath)) + os.system( + "%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,BINARY\(4000\) -w 40 \ + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt " % + (binPath, cfgPath)) tdSql.execute("use db1") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, 1000) @@ -98,8 +102,10 @@ class TDTestCase: tdLog.info("use diffrent interface rest") tdSql.execute("drop database db1;") # use diffrent interface -rest - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4097 \ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I rest " % (binPath,cfgPath)) + os.system( + "%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4097 \ + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I rest " % + (binPath, cfgPath)) tdSql.execute("use db1") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, 1000) @@ -111,8 +117,10 @@ class TDTestCase: tdLog.info("use diffrent interface sml") tdSql.execute("drop database db1;") # use diffrent interface-sml - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 1024 \ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I sml " % (binPath,cfgPath)) + os.system( + "%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 1024 \ + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I sml " % + (binPath, cfgPath)) tdSql.execute("use db1") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, 1000) @@ -122,9 +130,9 @@ class TDTestCase: tdLog.info("all data type") tdSql.execute("drop database db1;") # all data type-taosc - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ + os.system("%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096 \ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % (binPath,cfgPath)) + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % (binPath, cfgPath)) tdSql.execute("use db1") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, 1000) @@ -135,9 +143,9 @@ class TDTestCase: tdLog.info("all data type") tdSql.execute("drop database db1;") # all data type-stmt - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ + os.system("%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096 \ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt " % (binPath,cfgPath)) + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt " % (binPath, cfgPath)) tdSql.execute("use db1") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, 1000) @@ -147,9 +155,9 @@ class TDTestCase: tdSql.checkData(0, 0, 100) # all data type-rest - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ + os.system("%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096 \ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I rest " % (binPath,cfgPath)) + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I rest " % (binPath, cfgPath)) tdSql.execute("use db1") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, 1000) @@ -159,7 +167,7 @@ class TDTestCase: tdSql.checkData(0, 0, 100) # # all data type-rest - # os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ + # os.system("%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 \ # -b INT,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096 \ # -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I sml " % (binPath,cfgPath)) # tdSql.execute("use db1") @@ -172,10 +180,10 @@ class TDTestCase: tdLog.info("all data type and interlace rows") tdSql.execute("drop database db1;") - # all data type - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db3 -a 1 -l 10\ + # all data type + os.system("%s -u root -c %s -h localhost -P 6030 -d db3 -a 1 -l 10\ -b INT,TIMESTAMP,BIGINT,FLOAT,DOUBLE,SMALLINT,TINYINT,BOOL,UINT,UBIGINT,UTINYINT,USMALLINT,BINARY\(15\),NCHAR\(15\) -w 4096\ - -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -B 1000 -M -x -y -O 10 -R 100 -E -m test. " % (binPath,cfgPath)) + -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -B 1000 -M -x -y -O 10 -R 100 -E -m test. " % (binPath, cfgPath)) tdSql.execute("use db3") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, 1000) @@ -185,14 +193,18 @@ class TDTestCase: tdSql.checkData(0, 0, 100) tdLog.info("all data type and too much para") - tdLog.info("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4096 \ + tdLog.info( + "%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4096 \ -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test.taosdemo -u root -c %s -h \ - localhost -P 6030 -d db1 -a 1 -l 100 -b float,int,NCHAR\(15\) -w 4096 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % (binPath,cfgPath,cfgPath)) + localhost -P 6030 -d db1 -a 1 -l 100 -b float,int,NCHAR\(15\) -w 4096 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % + (binPath, cfgPath, cfgPath)) tdSql.execute("drop database db3;") - # repeate parameters - os.system("%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4096 \ + # repeate parameters + os.system( + "%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(15\) -w 4096 \ -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test.taosdemo -u root -c %s -h \ - localhost -P 6030 -d db1 -a 1 -l 100 -b float,int,NCHAR\(15\) -w 4096 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % (binPath,cfgPath,cfgPath)) + localhost -P 6030 -d db1 -a 1 -l 100 -b float,int,NCHAR\(15\) -w 4096 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. " % + (binPath, cfgPath, cfgPath)) tdSql.execute("use db1") tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, 1000) @@ -203,21 +215,22 @@ class TDTestCase: # taosdemo error # too max length - sql = "%staosBenchmark -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(4096\) \ - -w 40 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I taosc" % (binPath,cfgPath) - tdLog.info("%s" % sql ) - assert os.system("%s" % sql ) != 0 - - # error password - sql = "%staosBenchmark -u root -c %s -h localhost -P 6030 -p123 -d db1 -a 1 -l 10 -b float,int,NCHAR\(40\) \ - -w 40 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt" % (binPath,cfgPath) - tdLog.info("%s" % sql ) - assert os.system("%s" % sql ) != 0 + sql = "%s -u root -c %s -h localhost -P 6030 -d db1 -a 1 -l 10 -b float,int,NCHAR\(4096\) \ + -w 40 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I taosc" % (binPath, + cfgPath) + tdLog.info("%s" % sql) + assert os.system("%s" % sql) != 0 + + # error password + sql = "%s -u root -c %s -h localhost -P 6030 -p123 -d db1 -a 1 -l 10 -b float,int,NCHAR\(40\) \ + -w 40 -T 8 -i 10 -S 1000 -r 1000000 -t 10 -n 100 -M -x -y -O 10 -R 100 -E -m test. -I stmt" % (binPath, + cfgPath) + tdLog.info("%s" % sql) + assert os.system("%s" % sql) != 0 testcaseFilename = os.path.split(__file__)[-1] os.system("rm -rf ./insert_res*.txt*") - os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) - + os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename) def stop(self): tdSql.close() diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py deleted file mode 100644 index 8b0f55b5bfbb2706a470d55f0be6c62c804611da..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJson.py +++ /dev/null @@ -1,390 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - testcaseFilename = os.path.split(__file__)[-1] - os.system("rm -rf ./insert*_res.txt*") - os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) - - # insert: create one or mutiple tables per sql and insert multiple rows per sql - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-1s1tnt1r.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 11) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 1100) - tdSql.query("select count(*) from stb01_1") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 2000) - - # restful connector insert data - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertRestful.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from stb01_1") - tdSql.checkData(0, 0, 20) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 200) - - # default values json files - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-default.json -y " % binPath) - tdSql.query("show databases;") - for i in range(tdSql.queryRows): - if tdSql.queryResult[i][0] == 'db': - tdSql.checkData(i, 2, 100) - tdSql.checkData(i, 4, 1) - tdSql.checkData(i, 6, 10) - tdSql.checkData(i, 16, 'ms') - - # insert: create mutiple tables per sql and insert one rows per sql . - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-1s1tntmr.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 1000) - tdSql.query("select count(*) from stb01_0") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 4000) - - # insert: using parament "insert_interval to controls spped of insert. - # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-interval-speed.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - tdSql.checkData(0, 4, 10) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 2000) - tdSql.query("show stables") - tdSql.checkData(1, 4, 20) - tdSql.query("select count(*) from stb01_0") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 4000) - - # spend 2min30s for 3 testcases. - # insert: drop and child_table_exists combination test - # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-nodbnodrop.json -y" % binPath) - tdSql.error("show dbno.stables") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-newdb.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 5) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 6) - tdSql.query("select count (tbname) from stb2") - tdSql.checkData(0, 0, 7) - tdSql.query("select count (tbname) from stb3") - tdSql.checkData(0, 0, 8) - tdSql.query("select count (tbname) from stb4") - tdSql.checkData(0, 0, 8) - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-offset.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 240) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 220) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 180) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-newtable.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 150) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 360) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 360) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 340) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 400) - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-renewdb.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 120) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 140) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 160) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) - - - # insert: let parament in json file is illegal, it'll expect error. - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsAndTagNumLarge4096.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertSigcolumnsNum4096.json -y " % binPath) - tdSql.error("select * from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsAndTagNum4096.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkData(0, 0, 10000) - - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertInterlaceRowsLarge1M.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkRows(0) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertColumnsNum0.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables like 'stb0%' ") - tdSql.checkData(0, 2, 11) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertTagsNumLarge128.json -y " % binPath) - tdSql.error("use db1") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkRows(1) - tdSql.query("select count(*) from db.stb1") - tdSql.checkRows(1) - tdSql.error("select * from db.stb4") - tdSql.error("select * from db.stb2") - tdSql.query("select count(*) from db.stb3") - tdSql.checkRows(1) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertBinaryLenLarge16374AllcolLar49151-error.json -y " % binPath) - tdSql.error("select * from db.stb4") - tdSql.error("select * from db.stb2") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertNumOfrecordPerReq0.json -y " % binPath) - tdSql.error("select count(*) from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertNumOfrecordPerReqless0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertChildTab0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertChildTabLess0.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists blf") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertTimestepMulRowsLargeint16.json -y " % binPath) - tdSql.execute("use blf") - tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") - tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") - tdSql.query("select first(ts) from blf.p_0_topics_2") - tdSql.checkData(0, 0, "2019-10-01 00:00:00") - tdSql.query("select last(ts) from blf.p_0_topics_6 ") - tdSql.checkData(0, 0, "2020-09-29 23:59:00") - os.system("%staosBenchmark -f tools/taosdemoAllTest/insertMaxNumPerReq.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 5000000) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 5000000) - - - - # insert: timestamp and step - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-timestep.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select last(ts) from db.stb00_0") - tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 200) - tdSql.query("select last(ts) from db.stb01_0") - tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 400) - - # # insert: disorder_ratio - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-disorder.json -g 2>&1 -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 1) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 1) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 10) - - # insert: sample json - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-sample-ts.json -y " % binPath) - tdSql.execute("use dbtest123") - tdSql.query("select c2 from stb0") - tdSql.checkData(0, 0, 2147483647) - tdSql.query("select c0 from stb0_0 order by ts") - tdSql.checkData(3, 0, 4) - tdSql.query("select count(*) from stb0 order by ts") - tdSql.checkData(0, 0, 40) - tdSql.query("select * from stb0_1 order by ts") - tdSql.checkData(0, 0, '2021-10-28 15:34:44.735') - tdSql.checkData(3, 0, '2021-10-31 15:34:44.735') - tdSql.query("select * from stb1 where t1=-127") - tdSql.checkRows(20) - tdSql.query("select * from stb1 where t2=127") - tdSql.checkRows(10) - tdSql.query("select * from stb1 where t2=126") - tdSql.checkRows(10) - - # insert: sample json - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-sample.json -y " % binPath) - tdSql.execute("use dbtest123") - tdSql.query("select c2 from stb0") - tdSql.checkData(0, 0, 2147483647) - tdSql.query("select * from stb1 where t1=-127") - tdSql.checkRows(20) - tdSql.query("select * from stb1 where t2=127") - tdSql.checkRows(10) - tdSql.query("select * from stb1 where t2=126") - tdSql.checkRows(10) - - - # insert: test interlace parament - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-interlace-row.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count (*) from stb0") - tdSql.checkData(0, 0, 15000) - - - # # insert: auto_create - - tdSql.execute('drop database if exists db') - tdSql.execute('create database db') - tdSql.execute('use db') - os.system("%staosBenchmark -y -f tools/taosdemoAllTest/insert-drop-exist-auto-N00.json " % binPath) # drop = no, child_table_exists, auto_create_table varies - tdSql.execute('use db') - tdSql.query('show tables like \'NN123%\'') #child_table_exists = no, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'NNN%\'') #child_table_exists = no, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'NNY%\'') #child_table_exists = no, auto_create_table varies = yes - tdSql.checkRows(20) - tdSql.query('show tables like \'NYN%\'') #child_table_exists = yes, auto_create_table varies = no - tdSql.checkRows(0) - tdSql.query('show tables like \'NY123%\'') #child_table_exists = yes, auto_create_table varies = 123 - tdSql.checkRows(0) - tdSql.query('show tables like \'NYY%\'') #child_table_exists = yes, auto_create_table varies = yes - tdSql.checkRows(0) - - tdSql.execute('drop database if exists db') - os.system("%staosBenchmark -y -f tools/taosdemoAllTest/insert-drop-exist-auto-Y00.json " % binPath) # drop = yes, child_table_exists, auto_create_table varies - tdSql.execute('use db') - tdSql.query('show tables like \'YN123%\'') #child_table_exists = no, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'YNN%\'') #child_table_exists = no, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'YNY%\'') #child_table_exists = no, auto_create_table varies = yes - tdSql.checkRows(20) - tdSql.query('show tables like \'YYN%\'') #child_table_exists = yes, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'YY123%\'') #child_table_exists = yes, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'YYY%\'') #child_table_exists = yes, auto_create_table varies = yes - tdSql.checkRows(20) - - - # insert: test chinese encoding - # TD-11399、TD-10819 - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-chinese.json -y " % binPath) - os.system("%staosBenchmark -f tools/taosdemoAllTest/insert-chinese-sml.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - for i in range(6): - for j in range(6): - if tdSql.queryResult[i][0] == 'stb%d'%j: - # print(i,"stb%d"%j) - tdSql.checkData(i, 4, (j+1)*10) - for i in range(6): - tdSql.query("select count(*) from stb%d"%i) - tdSql.checkData(0, 0, (i+1)*1000) - - # rm useless files - os.system("rm -rf ./insert*_res.txt*") - - - - - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py deleted file mode 100644 index ee86fefda4397bba4470a1dd9c32b78a0866b45c..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonSml.py +++ /dev/null @@ -1,266 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - # insert: create one or mutiple tables per sql and insert multiple rows per sql - # line_protocol——telnet and json - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-1s1tnt1r-sml.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 1000) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 4000) - - - # insert: create mutiple tables per sql and insert one rows per sql . - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-1s1tntmr-sml.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 15) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 1500) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 3000) - - # insert: using parament "insert_interval to controls spped of insert. - # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-interval-speed-sml.json -y" % binPath) - tdSql.execute("use db") - # tdSql.query("select count (tbname) from stb0") - tdSql.query("select tbname from db.stb0") - tdSql.checkRows(100 ) - # tdSql.query("select count(*) from stb00_0") - # tdSql.checkData(0, 0, 20) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 2000) - tdSql.query("show stables") - tdSql.checkData(1, 4, 20) - # tdSql.query("select count(*) from stb01_0") - # tdSql.checkData(0, 0, 35) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 700) - - # spend 2min30s for 3 testcases. - # insert: drop and child_table_exists combination test - # insert: sml can't support parament "childtable_offset and childtable_limit" \ drop=no or child_table_exists = yes - - # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-nodbnodrop-sml.json -y" % binPath) - # tdSql.error("show dbno.stables") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-newdb-sml.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 5) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 6) - tdSql.query("select count (tbname) from stb2") - tdSql.checkData(0, 0, 7) - tdSql.query("select count (tbname) from stb3") - tdSql.checkData(0, 0, 8) - tdSql.query("select count (tbname) from stb4") - tdSql.checkData(0, 0, 8) - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-renewdb-sml.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 120) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 140) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 160) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) - - - # insert: let parament in json file is illegal, it'll expect error. - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertColumnsAndTagNumLarge4096-sml.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertSigcolumnsNum4096-sml.json -y " % binPath) - tdSql.error("select * from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertColumnsAndTagNum4096-sml.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkData(0, 0, 10000) - - # there is no limit of 4096 columns,so cancels this case - # tdSql.execute("drop database if exists db") - # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertInterlaceRowsLarge1M-sml.json -y " % binPath) - # tdSql.query("select count(*) from db.stb0") - # tdSql.checkRows(0) - - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertColumnsNum0-sml.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables like 'stb0%' ") - tdSql.checkData(0, 2, 11) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertTagsNumLarge128-sml.json -y " % binPath) - tdSql.error("use db1") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertBinaryLenLarge16374AllcolLar49151-sml.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkRows(1) - tdSql.query("select count(*) from db.stb1") - tdSql.checkRows(1) - tdSql.query("select count(*) from db.stb3") - tdSql.checkRows(1) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertBinaryLenLarge16374AllcolLar49151-error-sml.json -y " % binPath) - tdSql.error("select * from db.stb4") - tdSql.error("select * from db.stb2") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertNumOfrecordPerReq0-sml.json -y " % binPath) - tdSql.error("select count(*) from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertNumOfrecordPerReqless0-sml.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertChildTab0-sml.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertChildTabLess0-sml.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists blf") - - # child table name is invalid reading,so - # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertTimestepMulRowsLargeint16-sml.json -y " % binPath) - # tdSql.execute("use blf") - # tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") - # tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") - # tdSql.query("select first(ts) from blf.p_0_topics_2") - # tdSql.checkData(0, 0, "2019-10-01 00:00:00") - # tdSql.query("select last(ts) from blf.p_0_topics_6 ") - # tdSql.checkData(0, 0, "2020-09-29 23:59:00") - - # it will be commented in ci because it spend too much time to insert data, but when you can excute it when you want to test this case. - # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertMaxNumPerReq-sml.json -y " % binPath) - # tdSql.execute("use db") - # tdSql.query("select count(*) from stb0") - # tdSql.checkData(0, 0, 5000000) - # tdSql.query("select count(*) from stb1") - # tdSql.checkData(0, 0, 5000000) - # os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insertMaxNumPerReq-sml-telnet.json -y " % binPath) - # tdSql.execute("use db") - # tdSql.query("select count(*) from stb0") - # tdSql.checkData(0, 0, 5000000) - # tdSql.query("select count(*) from stb1") - # tdSql.checkData(0, 0, 5000000) - - - - # insert: timestamp and step - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-timestep-sml.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - # tdSql.query("select last(ts) from db.stb00_0") - # tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 200) - # tdSql.query("select last(ts) from db.stb01_0") - # tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 400) - - # # insert: disorder_ratio - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-disorder-sml.json 2>&1 -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 1) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 1) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 10) - - # insert: doesn‘t currently supported sample json - assert os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-sample-sml.json -y " % binPath) != 0 - # tdSql.execute("use dbtest123") - # tdSql.query("select c2 from stb0") - # tdSql.checkData(0, 0, 2147483647) - # tdSql.query("select * from stb1 where t1=-127") - # tdSql.checkRows(20) - # tdSql.query("select * from stb1 where t2=127") - # tdSql.checkRows(10) - # tdSql.query("select * from stb1 where t2=126") - # tdSql.checkRows(10) - - # insert: test interlace parament - os.system("%staosBenchmark -f tools/taosdemoAllTest/sml/insert-interlace-row-sml.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count (*) from stb0") - tdSql.checkData(0, 0, 15000) - - - testcaseFilename = os.path.split(__file__)[-1] - os.system("rm -rf ./insert_res.txt") - os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) - - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py deleted file mode 100644 index 6a5a3f767f1c5787680d75ee8cb98ee284a44741..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmt.py +++ /dev/null @@ -1,339 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - # insert: create one or mutiple tables per sql and insert multiple rows per sql - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-1s1tnt1r-stmt.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 1000) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 1000) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 100000) - tdSql.query("select count(*) from stb01_1") - tdSql.checkData(0, 0, 200) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 200000) - - - # insert: create mutiple tables per sql and insert one rows per sql . - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-1s1tntmr-stmt.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 10000) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 100000) - tdSql.query("select count(*) from stb01_0") - tdSql.checkData(0, 0, 20000) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 400000) - - # insert: using parament "insert_interval to controls spped of insert. - # but We need to have accurate methods to control the speed, such as getting the speed value, checking the count and so on。 - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-interval-speed-stmt.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - tdSql.checkData(0, 4, 100) - tdSql.query("select count(*) from stb00_0") - tdSql.checkData(0, 0, 20000) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 2000000) - tdSql.query("show stables") - tdSql.checkData(1, 4, 100) - tdSql.query("select count(*) from stb01_0") - tdSql.checkData(0, 0, 20000) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 2000000) - - # spend 2min30s for 3 testcases. - # insert: drop and child_table_exists combination test - # insert: using parament "childtable_offset and childtable_limit" to control table'offset point and offset - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-nodbnodrop-stmt.json -y" % binPath) - tdSql.error("show dbno.stables") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-newdb-stmt.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 5) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 6) - tdSql.query("select count (tbname) from stb2") - tdSql.checkData(0, 0, 7) - tdSql.query("select count (tbname) from stb3") - tdSql.checkData(0, 0, 8) - tdSql.query("select count (tbname) from stb4") - tdSql.checkData(0, 0, 8) - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-offset-stmt.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 240) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 220) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 180) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-newtable-stmt.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 150) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 360) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 360) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 340) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 400) - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-renewdb-stmt.json -y" % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 50) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 120) - tdSql.query("select count(*) from stb2") - tdSql.checkData(0, 0, 140) - tdSql.query("select count(*) from stb3") - tdSql.checkData(0, 0, 160) - tdSql.query("select count(*) from stb4") - tdSql.checkData(0, 0, 160) - - - # insert: let parament in json file is illegal, it'll expect error. - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertColumnsAndTagNumLarge4096-stmt.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertSigcolumnsNum4096-stmt.json -y " % binPath) - tdSql.error("select * from db.stb0") - # tdSql.execute("drop database if exists db") - # os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertColumnsAndTagNum4096-stmt.json -y " % binPath) - # tdSql.query("select count(*) from db.stb0") - # tdSql.checkData(0, 0, 10000) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertInterlaceRowsLarge1M-stmt.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkRows(0) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertColumnsNum0-stmt.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables like 'stb0%' ") - tdSql.checkData(0, 2, 11) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertTagsNumLarge128-stmt.json -y " % binPath) - tdSql.error("use db1") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-stmt.json -y " % binPath) - tdSql.query("select count(*) from db.stb0") - tdSql.checkRows(1) - tdSql.query("select count(*) from db.stb1") - tdSql.checkRows(1) - tdSql.error("select * from db.stb4") - tdSql.error("select * from db.stb2") - tdSql.query("select count(*) from db.stb3") - tdSql.checkRows(1) - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertBinaryLenLarge16374AllcolLar49151-error-stmt.json -y " % binPath) - tdSql.error("select * from db.stb4") - tdSql.error("select * from db.stb2") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertNumOfrecordPerReq0-stmt.json -y " % binPath) - tdSql.error("select count(*) from db.stb0") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertNumOfrecordPerReqless0-stmt.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertChildTab0-stmt.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists db") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertChildTabLess0-stmt.json -y " % binPath) - tdSql.error("use db") - tdSql.execute("drop database if exists blf") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertTimestepMulRowsLargeint16-stmt.json -y " % binPath) - tdSql.execute("use blf") - tdSql.query("select ts from blf.p_0_topics_7 limit 262800,1") - tdSql.checkData(0, 0, "2020-03-31 12:00:00.000") - tdSql.query("select first(ts) from blf.p_0_topics_2") - tdSql.checkData(0, 0, "2019-10-01 00:00:00") - tdSql.query("select last(ts) from blf.p_0_topics_6 ") - tdSql.checkData(0, 0, "2020-09-29 23:59:00") - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insertMaxNumPerReq-stmt.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 5000000) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 5000000) - - - # insert: sample json - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-sample-ts-stmt.json -y " % binPath) - tdSql.execute("use dbtest123") - tdSql.query("select c2 from stb0") - tdSql.checkData(0, 0, 2147483647) - tdSql.query("select c0 from stb0_0 order by ts") - tdSql.checkData(3, 0, 4) - tdSql.query("select count(*) from stb0 order by ts") - tdSql.checkData(0, 0, 40) - tdSql.query("select * from stb0_1 order by ts") - tdSql.checkData(0, 0, '2021-10-28 15:34:44.735') - tdSql.checkData(3, 0, '2021-10-31 15:34:44.735') - tdSql.query("select * from stb1 where t1=-127") - tdSql.checkRows(20) - tdSql.query("select * from stb1 where t2=127") - tdSql.checkRows(10) - tdSql.query("select * from stb1 where t2=126") - tdSql.checkRows(10) - - # insert: timestamp and step - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-timestep-stmt.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("show stables") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 20) - tdSql.query("select last(ts) from db.stb00_0") - tdSql.checkData(0, 0, "2020-10-01 00:00:00.019000") - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 200) - tdSql.query("select last(ts) from db.stb01_0") - tdSql.checkData(0, 0, "2020-11-01 00:00:00.190000") - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 400) - - # # insert: disorder_ratio - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-disorder-stmt.json 2>&1 -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 1) - tdSql.query("select count (tbname) from stb1") - tdSql.checkData(0, 0, 1) - tdSql.query("select count(*) from stb0") - tdSql.checkData(0, 0, 10) - tdSql.query("select count(*) from stb1") - tdSql.checkData(0, 0, 10) - - # insert: sample json - #os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-sample-stmt.json -y " % binPath) - #tdSql.execute("use dbtest123") - #tdSql.query("select c2 from stb0") - #tdSql.checkData(0, 0, 2147483647) - #tdSql.query("select * from stb1 where t1=-127") - #tdSql.checkRows(20) - #tdSql.query("select * from stb1 where t2=127") - #tdSql.checkRows(10) - #tdSql.query("select * from stb1 where t2=126") - #tdSql.checkRows(10) - - # insert: test interlace parament - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/insert-interlace-row-stmt.json -y " % binPath) - tdSql.execute("use db") - tdSql.query("select count (tbname) from stb0") - tdSql.checkData(0, 0, 100) - tdSql.query("select count (*) from stb0") - tdSql.checkData(0, 0, 15000) - - - # insert: auto_create - - tdSql.execute('drop database if exists db') - tdSql.execute('create database db') - tdSql.execute('use db') - os.system("%staosBenchmark -y -f tools/taosdemoAllTest/stmt/insert-drop-exist-auto-N00-stmt.json " % binPath) # drop = no, child_table_exists, auto_create_table varies - tdSql.execute('use db') - tdSql.query('show tables like \'NN123%\'') #child_table_exists = no, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'NNN%\'') #child_table_exists = no, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'NNY%\'') #child_table_exists = no, auto_create_table varies = yes - tdSql.checkRows(20) - tdSql.query('show tables like \'NYN%\'') #child_table_exists = yes, auto_create_table varies = no - tdSql.checkRows(0) - tdSql.query('show tables like \'NY123%\'') #child_table_exists = yes, auto_create_table varies = 123 - tdSql.checkRows(0) - tdSql.query('show tables like \'NYY%\'') #child_table_exists = yes, auto_create_table varies = yes - tdSql.checkRows(0) - - tdSql.execute('drop database if exists db') - os.system("%staosBenchmark -y -f tools/taosdemoAllTest/stmt/insert-drop-exist-auto-Y00-stmt.json " % binPath) # drop = yes, child_table_exists, auto_create_table varies - tdSql.execute('use db') - tdSql.query('show tables like \'YN123%\'') #child_table_exists = no, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'YNN%\'') #child_table_exists = no, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'YNY%\'') #child_table_exists = no, auto_create_table varies = yes - tdSql.checkRows(20) - tdSql.query('show tables like \'YYN%\'') #child_table_exists = yes, auto_create_table varies = no - tdSql.checkRows(20) - tdSql.query('show tables like \'YY123%\'') #child_table_exists = yes, auto_create_table varies = 123 - tdSql.checkRows(20) - tdSql.query('show tables like \'YYY%\'') #child_table_exists = yes, auto_create_table varies = yes - tdSql.checkRows(20) - - testcaseFilename = os.path.split(__file__)[-1] - os.system("rm -rf ./insert_res.txt") - os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) - - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmtPerformance.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmtPerformance.py deleted file mode 100644 index ff22ffe5a56bf69559d77bc202f289d4349e1e38..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestInsertWithJsonStmtPerformance.py +++ /dev/null @@ -1,92 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - # tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - # insert: create one or mutiple tables per sql and insert multiple rows per sql - os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/1174-small-stmt-random.json -y " % binPath) - # sleep(60) - - # os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/1174-small-taosc.json -y " % binPath) - # sleep(60) - # os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/1174-small-stmt.json -y " % binPath) - # sleep(60) - # os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/1174-large-taosc.json -y " % binPath) - # sleep(60) - # os.system("%staosBenchmark -f tools/taosdemoAllTest/stmt/1174-large-stmt.json -y " % binPath) - - # tdSql.execute("use db") - # tdSql.query("select count (tbname) from stb0") - # tdSql.checkData(0, 0, 1000) - # tdSql.query("select count (tbname) from stb1") - # tdSql.checkData(0, 0, 1000) - # tdSql.query("select count(*) from stb00_0") - # tdSql.checkData(0, 0, 100) - # tdSql.query("select count(*) from stb0") - # tdSql.checkData(0, 0, 100000) - # tdSql.query("select count(*) from stb01_1") - # tdSql.checkData(0, 0, 200) - # tdSql.query("select count(*) from stb1") - # tdSql.checkData(0, 0, 200000) - - - - - testcaseFilename = os.path.split(__file__)[-1] - os.system("rm -rf ./insert_res.txt") - os.system("rm -rf tools/taosdemoAllTest/%s.sql" % testcaseFilename ) - - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py deleted file mode 100644 index 06dcda48064913d69b18cfa004a8218958e35413..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestQueryWithJson.py +++ /dev/null @@ -1,244 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * -import time -from datetime import datetime -import ast -import re -# from assertpy import assert_that -import subprocess - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] - break - return buildPath - - # 获取taosc接口查询的结果文件中的内容,返回每行数据,并断言数据的第一列内容。 - def assertfileDataTaosc(self, filename, expectResult): - self.filename = filename - self.expectResult = expectResult - with open("%s" % filename, 'r+') as f1: - for line in f1.readlines(): - queryResultTaosc = line.strip().split()[0] - self.assertCheck(filename, queryResultTaosc, expectResult) - - # 获取restful接口查询的结果文件中的关键内容,目前的关键内容找到第一个key就跳出循,所以就只有一个数据。后续再修改多个结果文件。 - def getfileDataRestful(self, filename): - self.filename = filename - with open("%s" % filename, 'r+') as f1: - for line in f1.readlines(): - contents = line.strip() - if contents.find("data") != -1: - pattern = re.compile("{.*}") - contents = pattern.search(contents).group() - contentsDict = ast.literal_eval(contents) # 字符串转换为字典 - queryResultRest = contentsDict['data'][0][0] - break - else : - queryResultRest = "" - return queryResultRest - - - # 获取taosc接口查询次数 - def queryTimesTaosc(self, filename): - self.filename = filename - command = 'cat %s |wc -l' % filename - times = int(subprocess.getstatusoutput(command)[1]) - return times - - # 获取restful接口查询次数 - def queryTimesRestful(self, filename): - self.filename = filename - command = 'cat %s |grep "200 OK" |wc -l' % filename - times = int(subprocess.getstatusoutput(command)[1]) - return times - - # 定义断言结果是否正确。不正确返回错误结果,正确即通过。 - def assertCheck(self, filename, queryResult, expectResult): - self.filename = filename - self.queryResult = queryResult - self.expectResult = expectResult - args0 = (filename, queryResult, expectResult) - assert queryResult == expectResult, "Queryfile:%s ,result is %s != expect: %s" % args0 - - def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath + "/build/bin/" - - # delete useless files - os.system("rm -rf ./query_res*") - os.system("rm -rf ./all_query*") - - # taosc query: query specified table and query super table - os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryInsertdata.json" % - binPath) - os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryTaosc.json" % - binPath) - os.system("cat query_res0.txt* > all_query_res0_taosc.txt") - os.system("cat query_res1.txt* > all_query_res1_taosc.txt") - os.system("cat query_res2.txt* > all_query_res2_taosc.txt") - - # correct Times testcases - queryTimes0Taosc = self.queryTimesTaosc("all_query_res0_taosc.txt") - self.assertCheck("all_query_res0_taosc.txt", queryTimes0Taosc, 6) - - queryTimes1Taosc = self.queryTimesTaosc("all_query_res1_taosc.txt") - self.assertCheck("all_query_res1_taosc.txt", queryTimes1Taosc, 6) - - queryTimes2Taosc = self.queryTimesTaosc("all_query_res2_taosc.txt") - self.assertCheck("all_query_res2_taosc.txt", queryTimes2Taosc, 20) - - # correct data testcase - self.assertfileDataTaosc("all_query_res0_taosc.txt", "1604160000099") - self.assertfileDataTaosc("all_query_res1_taosc.txt", "100") - self.assertfileDataTaosc("all_query_res2_taosc.txt", "1604160000199") - - # delete useless files - os.system("rm -rf ./query_res*") - os.system("rm -rf ./all_query*") - - # use restful api to query - os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryInsertrestdata.json" % - binPath) - os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryRestful.json" % - binPath) - os.system("cat query_res0.txt* > all_query_res0_rest.txt") - os.system("cat query_res1.txt* > all_query_res1_rest.txt") - os.system("cat query_res2.txt* > all_query_res2_rest.txt") - - # correct Times testcases - queryTimes0Restful = self.queryTimesRestful("all_query_res0_rest.txt") - self.assertCheck("all_query_res0_rest.txt", queryTimes0Restful, 6) - - queryTimes1Restful = self.queryTimesRestful("all_query_res1_rest.txt") - self.assertCheck("all_query_res1_rest.txt", queryTimes1Restful, 6) - - queryTimes2Restful = self.queryTimesRestful("all_query_res2_rest.txt") - self.assertCheck("all_query_res2_rest.txt", queryTimes2Restful, 4) - - # correct data testcase - data0 = self.getfileDataRestful("all_query_res0_rest.txt") - self.assertCheck( - 'all_query_res0_rest.txt', - data0, - "2020-11-01 00:00:00.009") - - data1 = self.getfileDataRestful("all_query_res1_rest.txt") - self.assertCheck('all_query_res1_rest.txt', data1, 10) - - data2 = self.getfileDataRestful("all_query_res2_rest.txt") - self.assertCheck( - 'all_query_res2_rest.txt', - data2, - "2020-11-01 00:00:00.004") - - # query times less than or equal to 100 - assert os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryInsertdata.json" % - binPath) == 0 - assert os.system( - "%staosBenchmark -f tools/taosdemoAllTest/querySpeciMutisql100.json" % - binPath) != 0 - assert os.system( - "%staosBenchmark -f tools/taosdemoAllTest/querySuperMutisql100.json" % - binPath) == 0 - - # query result print QPS - os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryInsertdata.json" % - binPath) - exceptcode = os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryQps.json" % - binPath) - assert exceptcode == 0 - - # use illegal or out of range parameters query json file - os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryInsertdata.json" % - binPath) - exceptcode = os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryTimes0.json" % - binPath) - assert exceptcode != 0 - - exceptcode0 = os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryTimesless0.json" % - binPath) - assert exceptcode0 != 0 - - exceptcode1 = os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryConcurrentless0.json" % - binPath) - assert exceptcode1 != 0 - - exceptcode2 = os.system( - "%staosBenchmark -f tools/taosdemoAllTest/queryConcurrent0.json" % - binPath) - assert exceptcode2 != 0 - - exceptcode3 = os.system( - "%staosBenchmark -f tools/taosdemoAllTest/querrThreadsless0.json" % - binPath) - assert exceptcode3 != 0 - - exceptcode4 = os.system( - "%staosBenchmark -f tools/taosdemoAllTest/querrThreads0.json" % - binPath) - assert exceptcode4 != 0 - - # delete useless files - os.system("rm -rf ./insert_res.txt") - os.system("rm -rf tools/taosdemoAllTest/*.py.sql") - os.system("rm -rf ./querySystemInfo*") - os.system("rm -rf ./query_res*") - os.system("rm -rf ./all_query*") - os.system("rm -rf ./test_query_res0.txt") - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py deleted file mode 100644 index 265f50237bf2b5dae80eccc94aad885a7b84f5f2..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJson.py +++ /dev/null @@ -1,204 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * -import time -from datetime import datetime -import subprocess - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - # get the number of subscriptions - def subTimes(self,filename): - self.filename = filename - command = 'cat %s |wc -l'% filename - times = int(subprocess.getstatusoutput(command)[1]) - return times - - # assert results - def assertCheck(self,filename,subResult,expectResult): - self.filename = filename - self.subResult = subResult - self.expectResult = expectResult - args0 = (filename, subResult, expectResult) - assert subResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0 - - def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - # clear env - os.system("ps -ef |grep 'taosdemoAllTest/subSync.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9") - os.system("ps -ef |grep 'taosdemoAllTest/subSyncKeepStart.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9") - sleep(1) - os.system("rm -rf ./subscribe_res*") - os.system("rm -rf ./all_subscribe_res*") - sleep(2) - # subscribe: sync - os.system("%staosBenchmark -f tools/taosdemoAllTest/subInsertdata.json" % binPath) - os.system("nohup %staosBenchmark -f tools/taosdemoAllTest/subSync.json &" % binPath) - query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/subSync.json" |grep -v "grep"|awk \'{print $2}\'')[1]) - - # insert extral data - tdSql.execute("use db") - tdSql.execute("insert into stb00_0 values(1614218412000,'R','bf3',8637,98.861045)") - tdSql.execute("insert into stb00_1 values(1614218412000,'R','bf3',8637,78.861045)(1614218422000,'R','bf3',8637,98.861045)") - sleep(5) - - # merge result files - os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") - os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") - os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") - os.system("cat subscribe_res3.txt* > all_subscribe_res3.txt") - - - # correct subscribeTimes testcase - subTimes0 = self.subTimes("all_subscribe_res0.txt") - self.assertCheck("all_subscribe_res0.txt",subTimes0 ,22) - - subTimes1 = self.subTimes("all_subscribe_res1.txt") - self.assertCheck("all_subscribe_res1.txt",subTimes1 ,24) - - subTimes2 = self.subTimes("all_subscribe_res2.txt") - self.assertCheck("all_subscribe_res2.txt",subTimes2 ,21) - - subTimes3 = self.subTimes("all_subscribe_res3.txt") - self.assertCheck("all_subscribe_res3.txt",subTimes3 ,13) - - - # correct data testcase - os.system("kill -9 %d" % query_pid) - sleep(3) - os.system("rm -rf ./subscribe_res*") - os.system("rm -rf ./all_subscribe*") - - # # sql number lager 100 - os.system("%staosBenchmark -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath) - assert os.system("%staosBenchmark -f tools/taosdemoAllTest/subSyncSpecMaxsql100.json" % binPath) != 0 - assert os.system("%staosBenchmark -f tools/taosdemoAllTest/subSyncSuperMaxsql100.json" % binPath) != 0 - - # # result files is null - # os.system("%staosBenchmark -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath) - # os.system("%staosBenchmark -f tools/taosdemoAllTest/subSyncResFileNull.json" % binPath) - # # assert os.system("%staosBenchmark -f tools/taosdemoAllTest/subSyncResFileNull.json" % binPath) != 0 - - - - - # resubAfterConsume= -1 endAfter=-1 ; - os.system('kill -9 `ps aux|grep "subSyncResubACMinus1.json" |grep -v "grep"|awk \'{print $2}\'` ') - os.system("nohup %staosBenchmark -f tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1.json & " % binPath) - sleep(2) - query_pid1 = int(subprocess.getstatusoutput('ps aux|grep "subSyncResubACMinus1.json" |grep -v "grep"|awk \'{print $2}\'')[1]) - print("get sub1 process'pid") - subres0Number1 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) - subres2Number1 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res2* |wc -l' )[1]) - assert 0==subres0Number1 , "subres0Number1 error" - assert 0==subres2Number1 , "subres2Number1 error" - tdSql.execute("insert into db.stb00_0 values(1614218412000,'R','bf3',8637,78.861045)(1614218413000,'R','bf3',8637,98.861045)") - sleep(4) - subres2Number2 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) - subres0Number2 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) - assert 0!=subres2Number2 , "subres2Number2 error" - assert 0!=subres0Number2 , "subres0Number2 error" - os.system("kill -9 %d" % query_pid1) - os.system("rm -rf ./subscribe_res*") - - # # resubAfterConsume= -1 endAfter=0 ; - # os.system("%staosBenchmark -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath) - # os.system('kill -9 `ps aux|grep "subSyncResubACMinus1endAfter0.json" |grep -v "grep"|awk \'{print $2}\'` ') - # os.system("nohup %staosBenchmark -f tools/taosdemoAllTest/Resubjson/subSyncResubACMinus1endAfter0.json & " % binPath) - # sleep(2) - # query_pid1 = int(subprocess.getstatusoutput('ps aux|grep "subSyncResubACMinus1endAfter0.json" |grep -v "grep"|awk \'{print $2}\'')[1]) - # print("get sub2 process'pid") - # subres0Number1 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) - # subres2Number1 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res2* |wc -l' )[1]) - # assert 0==subres0Number1 , "subres0Number1 error" - # assert 0==subres2Number1 , "subres2Number1 error" - # tdSql.execute("insert into db.stb00_0 values(1614218412000,'R','bf3',8637,78.861045)(1614218413000,'R','bf3',8637,98.861045)") - # sleep(4) - # subres2Number2 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) - # subres0Number2 =int(subprocess.getstatusoutput('grep "1614218412000" subscribe_res0* |wc -l' )[1]) - # assert 0!=subres2Number2 , "subres2Number2 error" - # assert 0!=subres0Number2 , "subres0Number2 error" - # os.system("kill -9 %d" % query_pid1) - # os.system("rm -rf ./subscribe_res*") - - - - - # # # merge result files - # os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") - # os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") - # os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") - # # os.system("cat subscribe_res3.txt* > all_subscribe_res3.txt") - - # sleep(3) - - # # correct subscribeTimes testcase - # subTimes0 = self.subTimes("all_subscribe_res0.txt") - # self.assertCheck("all_subscribe_res0.txt",subTimes0 ,3960) - - # subTimes1 = self.subTimes("all_subscribe_res1.txt") - # self.assertCheck("all_subscribe_res1.txt",subTimes1 ,40) - - # subTimes2 = self.subTimes("all_subscribe_res2.txt") - # self.assertCheck("all_subscribe_res2.txt",subTimes2 ,1900) - - - # os.system("%staosBenchmark -f tools/taosdemoAllTest/subSupermaxsql100.json" % binPath) - # os.system("%staosBenchmark -f tools/taosdemoAllTest/subSupermaxsql100.json" % binPath) - - - - # delete useless files - os.system("rm -rf ./insert_res.txt") - os.system("rm -rf tools/taosdemoAllTest/*.py.sql") - os.system("rm -rf ./subscribe_res*") - os.system("rm -rf ./all_subscribe*") - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJsonAsync.py b/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJsonAsync.py deleted file mode 100644 index b236b2b48b93f210f0e73ebb5be240413f82d878..0000000000000000000000000000000000000000 --- a/tests/pytest/tools/taosdemoAllTest/taosdemoTestSubWithJsonAsync.py +++ /dev/null @@ -1,124 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import os -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * -import time -from datetime import datetime -import subprocess - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def getBuildPath(self): - selfPath = os.path.dirname(os.path.realpath(__file__)) - - if ("community" in selfPath): - projPath = selfPath[:selfPath.find("community")] - else: - projPath = selfPath[:selfPath.find("tests")] - - for root, dirs, files in os.walk(projPath): - if ("taosd" in files): - rootRealPath = os.path.dirname(os.path.realpath(root)) - if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] - break - return buildPath - - # 获取订阅次数 - def subTimes(self,filename): - self.filename = filename - command = 'cat %s |wc -l'% filename - times = int(subprocess.getstatusoutput(command)[1]) - return times - - def assertCheck(self,filename,queryResult,expectResult): - self.filename = filename - self.queryResult = queryResult - self.expectResult = expectResult - args0 = (filename, queryResult, expectResult) - assert queryResult == expectResult , "Queryfile:%s ,result is %s != expect: %s" % args0 - - def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") - else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - - # clear env - os.system("ps -ef |grep 'taosdemoAllTest/subAsync.json' |grep -v 'grep' |awk '{print $2}'|xargs kill -9") - sleep(1) - os.system("rm -rf ./subscribe_res*") - os.system("rm -rf ./all_subscribe_res*") - - # subscribe: resultfile - os.system("%staosBenchmark -f tools/taosdemoAllTest/subInsertdata.json" % binPath) - os.system("nohup %staosBenchmark -f tools/taosdemoAllTest/subAsync.json &" % binPath) - query_pid = int(subprocess.getstatusoutput('ps aux|grep "taosdemoAllTest/subAsync.json" |grep -v "grep"|awk \'{print $2}\'')[1]) - - # insert extral data - tdSql.execute("use db") - tdSql.execute("insert into stb00_0 values(1614218412000,'R','bf3',8637,98.861045)") - tdSql.execute("insert into stb00_1 values(1614218412000,'R','bf3',8637,78.861045)(1614218422000,'R','bf3',8637,98.861045)") - sleep(5) - - # merge result files - os.system("cat subscribe_res0.txt* > all_subscribe_res0.txt") - os.system("cat subscribe_res1.txt* > all_subscribe_res1.txt") - os.system("cat subscribe_res2.txt* > all_subscribe_res2.txt") - os.system("cat subscribe_res3.txt* > all_subscribe_res3.txt") - - # correct subscribeTimes testcase - subTimes0 = self.subTimes("all_subscribe_res0.txt") - self.assertCheck("all_subscribe_res0.txt",subTimes0 ,22) - - subTimes1 = self.subTimes("all_subscribe_res1.txt") - self.assertCheck("all_subscribe_res1.txt",subTimes1 ,24) - - subTimes2 = self.subTimes("all_subscribe_res2.txt") - self.assertCheck("all_subscribe_res2.txt",subTimes2 ,21) - - subTimes3 = self.subTimes("all_subscribe_res3.txt") - self.assertCheck("all_subscribe_res3.txt",subTimes3 ,13) - - # correct data testcase - - os.system("kill -9 %d" % query_pid) - - # # query times less than or equal to 100 - os.system("%staosBenchmark -f tools/taosdemoAllTest/subInsertdataMaxsql100.json" % binPath) - assert os.system("%staosBenchmark -f tools/taosdemoAllTest/subSyncSpecMaxsql100.json" % binPath) != 0 - assert os.system("%staosBenchmark -f tools/taosdemoAllTest/subSyncSuperMaxsql100.json" % binPath) != 0 - - # delete useless files - os.system("rm -rf ./insert_res.txt") - os.system("rm -rf tools/taosdemoAllTest/*.py.sql") - os.system("rm -rf ./subscribe_res*") - os.system("rm -rf ./all_subscribe*") - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTest.py b/tests/pytest/tools/taosdemoTest.py index 54e0906672637c1187cb8b078f1e8496e461e150..801cfe680dcd662db4317f19b3325ca522e9cbc9 100644 --- a/tests/pytest/tools/taosdemoTest.py +++ b/tests/pytest/tools/taosdemoTest.py @@ -27,7 +27,7 @@ class TDTestCase: self.numberOfTables = 1000 self.numberOfRecords = 100 - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -35,23 +35,25 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosdemo not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosdemo found in %s" % buildPath) - binPath = buildPath + "/build/bin/" - os.system("%staosBenchmark -y -t %d -n %d -b INT,INT,INT,INT" % + tdLog.info("taosBenchmark found: %s" % binPath) + os.system("%s -y -t %d -n %d -b INT,INT,INT,INT" % (binPath, self.numberOfTables, self.numberOfRecords)) tdSql.execute("use test") diff --git a/tests/pytest/tools/taosdemoTestInterlace.py b/tests/pytest/tools/taosdemoTestInterlace.py index 72f70edcbaa582231189677b9e15d76e507d3dec..328ef73ae88e4d95a2fd511647399661e241f81c 100644 --- a/tests/pytest/tools/taosdemoTestInterlace.py +++ b/tests/pytest/tools/taosdemoTestInterlace.py @@ -25,7 +25,7 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -33,24 +33,25 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] - buildPath = "" + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath + "/build/bin/" - taosdemoCmd = "%staosBenchmark -f tools/insert-interlace.json -G 2>&1 | grep sleep | wc -l" % binPath + tdLog.info("taosBenchmark found in %s" % binPath) + taosdemoCmd = "%s -f tools/insert-interlace.json -G 2>&1 | grep sleep | wc -l" % binPath sleepTimes = subprocess.check_output( taosdemoCmd, shell=True).decode("utf-8") print("sleep times: %d" % int(sleepTimes)) diff --git a/tests/pytest/tools/taosdemoTestLimitOffset.py b/tests/pytest/tools/taosdemoTestLimitOffset.py index e69098b7f562f996b2bad58b10df63fdaf8a8398..150a5fed47786a5fe06a914d47fbb0a7223aa716 100644 --- a/tests/pytest/tools/taosdemoTestLimitOffset.py +++ b/tests/pytest/tools/taosdemoTestLimitOffset.py @@ -27,7 +27,7 @@ class TDTestCase: self.numberOfTables = 10000 self.numberOfRecords = 100 - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -35,24 +35,30 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath("taosBenchmark") + if (binPath == ""): tdLog.exit("taosd not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - os.system("%staosBenchmark -f tools/insert-tblimit-tboffset-createdb.json" % binPath) - os.system("%staosBenchmark -f tools/insert-tblimit-tboffset-insertrec.json" % binPath) + tdLog.info("taosd found in %s" % binPath) + os.system( + "%s -f tools/insert-tblimit-tboffset-createdb.json" % + binPath) + os.system( + "%s -f tools/insert-tblimit-tboffset-insertrec.json" % + binPath) tdSql.execute("use db") tdSql.query("select count(tbname) from db.stb") @@ -60,8 +66,10 @@ class TDTestCase: tdSql.query("select count(*) from db.stb") tdSql.checkData(0, 0, 33000) - os.system("%staosBenchmark -f tools/insert-tblimit-tboffset-createdb.json" % binPath) - os.system("%staosBenchmark -f tools/insert-tblimit-tboffset0.json" % binPath) + os.system( + "%s -f tools/insert-tblimit-tboffset-createdb.json" % + binPath) + os.system("%s -f tools/insert-tblimit-tboffset0.json" % binPath) tdSql.execute("reset query cache") tdSql.execute("use db") @@ -70,8 +78,10 @@ class TDTestCase: tdSql.query("select count(*) from db.stb") tdSql.checkData(0, 0, 20000) - os.system("%staosBenchmark -f tools/insert-tblimit-tboffset-createdb.json" % binPath) - os.system("%staosBenchmark -f tools/insert-tblimit1-tboffset.json" % binPath) + os.system( + "%s -f tools/insert-tblimit-tboffset-createdb.json" % + binPath) + os.system("%s -f tools/insert-tblimit1-tboffset.json" % binPath) tdSql.execute("reset query cache") tdSql.execute("use db") diff --git a/tests/pytest/tools/taosdemoTestQuery.py b/tests/pytest/tools/taosdemoTestQuery.py index c77688aefaf93898ae33044408dd4027d71b07e9..a97230d2226bfb120debb27b978e8000f39985a3 100644 --- a/tests/pytest/tools/taosdemoTestQuery.py +++ b/tests/pytest/tools/taosdemoTestQuery.py @@ -29,7 +29,7 @@ class TDTestCase: self.numberOfTables = 1000 self.numberOfRecords = 100 - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -37,28 +37,30 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath + "/build/bin/" - os.system("%staosBenchmark -y -t %d -n %d" % + tdLog.info("taosBenchmark found in %s" % binPath) + os.system("%s -y -t %d -n %d" % (binPath, self.numberOfTables, self.numberOfRecords)) print("Sleep 2 seconds..") time.sleep(2) - os.system('%staosBenchmark -f tools/query.json ' % binPath) -# taosdemoCmd = '%staosBenchmark -f tools/query.json ' % binPath + os.system('%s -f tools/query.json ' % binPath) +# taosdemoCmd = '%s tools/query.json ' % binPath # threads = subprocess.check_output( # taosdemoCmd, shell=True).decode("utf-8") # print("threads: %d" % int(threads)) diff --git a/tests/pytest/tools/taosdemoTestSampleData.py b/tests/pytest/tools/taosdemoTestSampleData.py index 09a2e6c43b68d8271cb0472b288279b54789fded..0800f3decfabe96ff9f85ea798e209af2c2e02f1 100644 --- a/tests/pytest/tools/taosdemoTestSampleData.py +++ b/tests/pytest/tools/taosdemoTestSampleData.py @@ -27,7 +27,7 @@ class TDTestCase: self.numberOfTables = 10000 self.numberOfRecords = 100 - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -35,23 +35,25 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath+ "/build/bin/" - os.system("%staosBenchmark -f tools/taosdemo-sampledata.json" % binPath) + tdLog.info("taosBenchmark found in %s" % binPath) + os.system("%s -f tools/taosdemo-sampledata.json" % binPath) tdSql.execute("use db") tdSql.query("select count(tbname) from db.stb") diff --git a/tests/pytest/tools/taosdemoTestTblAlt.py b/tests/pytest/tools/taosdemoTestTblAlt.py index 444aab519bf7089b792125ffa3caa6de5ad4eb8d..46a2de1f97d67d222d9b763d23ef672c531c6ec2 100644 --- a/tests/pytest/tools/taosdemoTestTblAlt.py +++ b/tests/pytest/tools/taosdemoTestTblAlt.py @@ -29,8 +29,7 @@ class TDTestCase: self.numberOfTables = 8 self.numberOfRecords = 1000000 - def getBuildPath(self): - buildPath="" + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -38,26 +37,28 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files and "taosBenchmark" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def insertDataAndAlterTable(self, threadID): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd or staosBenchmark not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) if(threadID == 0): - print("%staosBenchmark -y -t %d -n %d -b INT,INT,INT,INT" % - (binPath, self.numberOfTables, self.numberOfRecords)) - os.system("%staosBenchmark -y -t %d -n %d -b INT,INT,INT,INT" % + print("%s -y -t %d -n %d -b INT,INT,INT,INT" % + (binPath, self.numberOfTables, self.numberOfRecords)) + os.system("%s -y -t %d -n %d -b INT,INT,INT,INT" % (binPath, self.numberOfTables, self.numberOfRecords)) if(threadID == 1): time.sleep(2) diff --git a/tests/pytest/tools/taosdemoTestWithJson.py b/tests/pytest/tools/taosdemoTestWithJson.py index 0868d07fd99f7731424a3f11883ae52d12f1e878..87b99ef31c96958fa512f81d5d22f779a38f1e77 100644 --- a/tests/pytest/tools/taosdemoTestWithJson.py +++ b/tests/pytest/tools/taosdemoTestWithJson.py @@ -24,31 +24,33 @@ class TDTestCase: tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) - if "community" in selfPath: - projPath = selfPath[: selfPath.find("community")] + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] else: - projPath = selfPath[: selfPath.find("tests")] + projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if "taosd" in files: + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) - if "packaging" not in rootRealPath: - buildPath = root[: len(root) - len("/build/bin")] + if ("packaging" not in rootRealPath): + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): tdSql.prepare() - buildPath = self.getBuildPath() - if buildPath == "": - tdLog.exit("taosd not found!") + binPath = self.getPath("taosBenchmark") + if binPath == "": + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath + "/build/bin/" - os.system("%staosBenchmark -f tools/insert.json -y" % binPath) + tdLog.info("taosBenchmark found: %s" % binPath) + os.system("%s -f tools/insert.json -y" % binPath) tdSql.execute("use db01") tdSql.query("select count(*) from stb01") diff --git a/tests/pytest/tools/taosdemoTestWithoutMetric.py b/tests/pytest/tools/taosdemoTestWithoutMetric.py index a92a4519e2d716b85df0ec29c9cf49abb0812b47..0ab49ada6b6c0e5e35d7fd8742a0179376606dce 100644 --- a/tests/pytest/tools/taosdemoTestWithoutMetric.py +++ b/tests/pytest/tools/taosdemoTestWithoutMetric.py @@ -27,7 +27,7 @@ class TDTestCase: self.numberOfTables = 100 self.numberOfRecords = 1000 - def getBuildPath(self): + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -35,32 +35,34 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosd not found!") + binPath = self.getPath() + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosd found in %s" % buildPath) - binPath = buildPath + "/build/bin/" - os.system("%staosBenchmark -N -y -t %d -n %d" % + tdLog.info("taosBenchmark found in %s" % binPath) + os.system("%s -N -y -t %d -n %d" % (binPath, self.numberOfTables, self.numberOfRecords)) tdSql.query("show databases") for i in range(18): - print(tdSql.getData(0, i) ) + print(tdSql.getData(0, i)) tdSql.checkData(0, 2, self.numberOfTables) tdSql.execute("use test") tdSql.query( - "select count(*) from test.d%d" % (self.numberOfTables -1)) + "select count(*) from test.d%d" % (self.numberOfTables - 1)) tdSql.checkData(0, 0, self.numberOfRecords) def stop(self): diff --git a/tests/pytest/tools/taosdemoTestdatatype.py b/tests/pytest/tools/taosdemoTestdatatype.py index ba99b0c532af3497de2daf4d0757b9105405dc1d..c221206365e5429c3e552865dec79605855b1134 100644 --- a/tests/pytest/tools/taosdemoTestdatatype.py +++ b/tests/pytest/tools/taosdemoTestdatatype.py @@ -18,6 +18,7 @@ from util.cases import * from util.sql import * from util.dnodes import * + class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -25,8 +26,8 @@ class TDTestCase: self.numberOfTables = 10 self.numberOfRecords = 10 - - def getBuildPath(self): + + def getPath(self, tool="taosBenchmark"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -34,61 +35,65 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): - buildPath = self.getBuildPath() - if (buildPath == ""): - tdLog.exit("taosdemo not found!") + binPath = self.getPath("taosBenchmark") + if (binPath == ""): + tdLog.exit("taosBenchmark not found!") else: - tdLog.info("taosdemo found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosBenchmark found in %s" % binPath) + + os.system( + "%s -d test002 -y -t %d -n %d -b INT,nchar\\(8\\),binary\\(16\\),binary,nchar -w 8" % + (binPath, self.numberOfTables, self.numberOfRecords)) - os.system("%staosBenchmark -d test002 -y -t %d -n %d -b INT,nchar\\(8\\),binary\\(16\\),binary,nchar -w 8" % - (binPath, self.numberOfTables, self.numberOfRecords)) - tdSql.execute('use test002') tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, self.numberOfTables * self.numberOfRecords) tdSql.query("select * from meters") tdSql.checkRows(self.numberOfTables * self.numberOfRecords) - - tdLog.info('insert into d1 values(now,100,"abcd1234","abcdefgh12345678","abcdefgh","abcdefgh")') - tdSql.execute('insert into d1 values(now,100,"abcd1234","abcdefgh12345678","abcdefgh","abcdefgh")') + + tdLog.info( + 'insert into d1 values(now,100,"abcd1234","abcdefgh12345678","abcdefgh","abcdefgh")') + tdSql.execute( + 'insert into d1 values(now,100,"abcd1234","abcdefgh12345678","abcdefgh","abcdefgh")') tdSql.query("select * from meters") tdSql.checkRows(101) tdSql.error('insert into d1 values(now,100,"abcd","abcd"') tdSql.error('insert into d1 values(now,100,100,100)') - os.system("%staosBenchmark -d test002 -y -t %d -n %d --data-type INT,nchar\\(8\\),binary\\(16\\),binary,nchar -w 8" % - (binPath, self.numberOfTables, self.numberOfRecords)) + os.system( + "%s -d test002 -y -t %d -n %d --data-type INT,nchar\\(8\\),binary\\(16\\),binary,nchar -w 8" % + (binPath, self.numberOfTables, self.numberOfRecords)) tdSql.execute('use test002') tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, self.numberOfTables * self.numberOfRecords) - - os.system("%staosBenchmark -d test002 -y -t %d -n %d -bINT,nchar\\(8\\),binary\\(16\\),binary,nchar -w 8" % - (binPath, self.numberOfTables, self.numberOfRecords)) + os.system( + "%s -d test002 -y -t %d -n %d -bINT,nchar\\(8\\),binary\\(16\\),binary,nchar -w 8" % + (binPath, self.numberOfTables, self.numberOfRecords)) tdSql.execute('use test002') tdSql.query("select count(*) from meters") tdSql.checkData(0, 0, self.numberOfTables * self.numberOfRecords) - - def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdumpTest.py b/tests/pytest/tools/taosdumpTest.py index 628617e27b4af8695b96961441c6b135bdb15416..21555567765fcae218b254472b1330a11d83e77f 100644 --- a/tests/pytest/tools/taosdumpTest.py +++ b/tests/pytest/tools/taosdumpTest.py @@ -35,7 +35,7 @@ class TDTestCase: else: return True - def getBuildPath(self): + def getPath(self, tool="taosdump"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -43,13 +43,16 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosdump" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): if not os.path.exists("./taosdumptest/tmp1"): @@ -78,16 +81,15 @@ class TDTestCase: sql += "(%d, %d, 'nchar%d')" % (currts + i, i % 100, i % 100) tdSql.execute(sql) - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) - os.system("%staosdump --databases db -o ./taosdumptest/tmp1" % binPath) + os.system("%s -y --databases db -o ./taosdumptest/tmp1" % binPath) os.system( - "%staosdump --databases db1 -o ./taosdumptest/tmp2" % + "%s -y --databases db1 -o ./taosdumptest/tmp2" % binPath) tdSql.execute("drop database db") @@ -95,8 +97,8 @@ class TDTestCase: tdSql.query("show databases") tdSql.checkRows(0) - os.system("%staosdump -i ./taosdumptest/tmp1" % binPath) - os.system("%staosdump -i ./taosdumptest/tmp2" % binPath) + os.system("%s -i ./taosdumptest/tmp1" % binPath) + os.system("%s -i ./taosdumptest/tmp2" % binPath) tdSql.execute("use db") tdSql.query("show databases") @@ -168,9 +170,10 @@ class TDTestCase: tdSql.query("show stables") tdSql.checkRows(2) os.system( - "%staosdump --databases db12312313231231321312312312_323 -o ./taosdumptest/tmp1" % binPath) + "%s -y --databases db12312313231231321312312312_323 -o ./taosdumptest/tmp1" % + binPath) tdSql.execute("drop database db12312313231231321312312312_323") - os.system("%staosdump -i ./taosdumptest/tmp1" % binPath) + os.system("%s -i ./taosdumptest/tmp1" % binPath) tdSql.execute("use db12312313231231321312312312_323") tdSql.query("show stables") tdSql.checkRows(2) diff --git a/tests/pytest/tools/taosdumpTest2.py b/tests/pytest/tools/taosdumpTest2.py index c405d4c5c67611ff87bee69e87c79820237419cb..c0de2c957a59ff94ab22a8656f030719e60e5761 100644 --- a/tests/pytest/tools/taosdumpTest2.py +++ b/tests/pytest/tools/taosdumpTest2.py @@ -22,7 +22,7 @@ import string import random -class TDTestCase: +class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) @@ -30,9 +30,9 @@ class TDTestCase: self.ts = 1601481600000 self.numberOfTables = 1 - self.numberOfRecords = 15000 + self.numberOfRecords = 150 - def getBuildPath(self): + def getPath(self, tool="taosdump"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -40,13 +40,16 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def generateString(self, length): chars = string.ascii_uppercase + string.ascii_lowercase @@ -56,6 +59,11 @@ class TDTestCase: return v def run(self): + if not os.path.exists("./taosdumptest/tmp"): + os.makedirs("./taosdumptest/tmp") + else: + print("directory exists") + tdSql.prepare() tdSql.execute("create table st(ts timestamp, c1 timestamp, c2 int, c3 bigint, c4 float, c5 double, c6 binary(8), c7 smallint, c8 tinyint, c9 bool, c10 nchar(8)) tags(t1 int)") @@ -71,24 +79,23 @@ class TDTestCase: break tdSql.execute(sql) - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found in %s" % binPath) - os.system("rm /tmp/*.sql") - os.system("rm /tmp/*.avro*") + os.system("rm ./taosdumptest/tmp/*.sql") + os.system("rm ./taosdumptest/tmp/*.avro*") os.system( - "%staosdump --databases db -o /tmp " % + "%s --databases db -o ./taosdumptest/tmp " % binPath) tdSql.execute("drop database db") tdSql.query("show databases") tdSql.checkRows(0) - os.system("%staosdump -i /tmp -y" % binPath) + os.system("%s -i ./taosdumptest/tmp -y" % binPath) tdSql.query("show databases") tdSql.checkRows(1) @@ -100,23 +107,28 @@ class TDTestCase: tdSql.checkData(0, 0, 'st') tdSql.query("select count(*) from t1") - tdSql.checkData(0, 0, self.numberOfRecords) + tdSql.checkData(0, 0, self.numberOfRecords) # test case for TS-1225 tdSql.execute("create database test") tdSql.execute("use test") - tdSql.execute("create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))") - tdSql.execute("insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" % (self.generateString(16374), self.generateString(16374), self.generateString(16374))) - - os.system("rm /tmp/*.sql") - os.system("rm /tmp/*.avro*") - os.system("%staosdump -D test -o /tmp -y" % binPath) + tdSql.execute( + "create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))") + tdSql.execute( + "insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" % + (self.generateString(16374), + self.generateString(16374), + self.generateString(16374))) + + os.system("rm ./taosdumptest/tmp/*.sql") + os.system("rm ./taosdumptest/tmp/*.avro*") + os.system("%s -D test -o ./taosdumptest/tmp -y" % binPath) tdSql.execute("drop database test") tdSql.query("show databases") tdSql.checkRows(1) - os.system("%staosdump -i /tmp -y" % binPath) + os.system("%s -i ./taosdumptest/tmp -y" % binPath) tdSql.execute("use test") tdSql.error("show vnodes '' ") diff --git a/tests/pytest/tools/taosdumpTest3.py b/tests/pytest/tools/taosdumpTest3.py index e506d5b7e889adc326650a3b0016cda71b97c746..3994ad0323a3e1b5b968999178f1cae83c5e0753 100644 --- a/tests/pytest/tools/taosdumpTest3.py +++ b/tests/pytest/tools/taosdumpTest3.py @@ -35,7 +35,7 @@ class TDTestCase: else: return True - def getBuildPath(self): + def getPath(self, tool="taosdump"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -43,166 +43,203 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosdump" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def run(self): if not os.path.exists("./taosdumptest"): os.makedirs("./taosdumptest") - for i in range(1,9): - if not os.path.exists("./taosdumptest/tmp%d"%i): - os.makedirs("./taosdumptest/tmp%d"%i) + for i in range(1, 9): + if not os.path.exists("./taosdumptest/tmp%d" % i): + os.makedirs("./taosdumptest/tmp%d" % i) else: - os.system("rm -rf ./taosdumptest/tmp%d"%i) - os.makedirs("./taosdumptest/tmp%d"%i) + os.system("rm -rf ./taosdumptest/tmp%d" % i) + os.makedirs("./taosdumptest/tmp%d" % i) - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath("taosdump") + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found in %s" % binPath) # create db1 , one stables and one table ; create general tables tdSql.execute("drop database if exists dp1") tdSql.execute("drop database if exists dp2") tdSql.execute("create database if not exists dp1") tdSql.execute("use dp1") - tdSql.execute("create stable st0(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int)") - tdSql.execute("create table st0_0 using st0 tags(0) st0_1 using st0 tags (1) ") - tdSql.execute("insert into st0_0 values(1614218412000,8537,'R')(1614218422000,8538,'E')") - tdSql.execute("insert into st0_1 values(1614218413000,1537,'A')(1614218423000,1538,'D')") - tdSql.execute("create table if not exists gt0 (ts timestamp, c0 int, c1 float) ") - tdSql.execute("create table if not exists gt1 (ts timestamp, c0 int, c1 double) ") + tdSql.execute( + "create stable st0(ts timestamp, c1 int, c2 nchar(10)) tags(t1 int)") + tdSql.execute( + "create table st0_0 using st0 tags(0) st0_1 using st0 tags (1) ") + tdSql.execute( + "insert into st0_0 values(1614218412000,8537,'R')(1614218422000,8538,'E')") + tdSql.execute( + "insert into st0_1 values(1614218413000,1537,'A')(1614218423000,1538,'D')") + tdSql.execute( + "create table if not exists gt0 (ts timestamp, c0 int, c1 float) ") + tdSql.execute( + "create table if not exists gt1 (ts timestamp, c0 int, c1 double) ") tdSql.execute("insert into gt0 values(1614218412000,637,8.861)") tdSql.execute("insert into gt1 values(1614218413000,638,8.862)") - # create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1 - # \stb3,include ctables stb3_0 and stb3_1 + # create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1 + # \stb3,include ctables stb3_0 and stb3_1 # create general three tables gt0 gt1 gt2 tdSql.execute("create database if not exists dp2") tdSql.execute("use dp2") - tdSql.execute("create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)") - tdSql.execute("create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ") - tdSql.execute("insert into st0_0 values(1614218412000,8600,'R')(1614218422000,8600,'E')") - tdSql.execute("insert into st0_1 values(1614218413000,8601,'A')(1614218423000,8601,'D')") - tdSql.execute("create stable st1(ts timestamp, c11 float, c12 nchar(10)) tags(t1 int)") - tdSql.execute("create table st1_0 using st1 tags(0) st1_1 using st1 tags(1) ") - tdSql.execute("insert into st1_0 values(1614218412000,8610.1,'R')(1614218422000,8610.1,'E')") - tdSql.execute("insert into st1_1 values(1614218413000,8611.2,'A')(1614218423000,8611.1,'D')") - tdSql.execute("create stable st2(ts timestamp, c21 float, c22 nchar(10)) tags(t1 int)") - tdSql.execute("create table st2_0 using st2 tags(0) st2_1 using st2 tags(1) ") - tdSql.execute("insert into st2_0 values(1614218412000,8620.3,'R')(1614218422000,8620.3,'E')") - tdSql.execute("insert into st2_1 values(1614218413000,8621.4,'A')(1614218423000,8621.4,'D')") - tdSql.execute("create table if not exists gt0 (ts timestamp, c00 int, c01 float) ") - tdSql.execute("create table if not exists gt1 (ts timestamp, c10 int, c11 double) ") - tdSql.execute("create table if not exists gt2 (ts timestamp, c20 int, c21 float) ") + tdSql.execute( + "create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)") + tdSql.execute( + "create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ") + tdSql.execute( + "insert into st0_0 values(1614218412000,8600,'R')(1614218422000,8600,'E')") + tdSql.execute( + "insert into st0_1 values(1614218413000,8601,'A')(1614218423000,8601,'D')") + tdSql.execute( + "create stable st1(ts timestamp, c11 float, c12 nchar(10)) tags(t1 int)") + tdSql.execute( + "create table st1_0 using st1 tags(0) st1_1 using st1 tags(1) ") + tdSql.execute( + "insert into st1_0 values(1614218412000,8610.1,'R')(1614218422000,8610.1,'E')") + tdSql.execute( + "insert into st1_1 values(1614218413000,8611.2,'A')(1614218423000,8611.1,'D')") + tdSql.execute( + "create stable st2(ts timestamp, c21 float, c22 nchar(10)) tags(t1 int)") + tdSql.execute( + "create table st2_0 using st2 tags(0) st2_1 using st2 tags(1) ") + tdSql.execute( + "insert into st2_0 values(1614218412000,8620.3,'R')(1614218422000,8620.3,'E')") + tdSql.execute( + "insert into st2_1 values(1614218413000,8621.4,'A')(1614218423000,8621.4,'D')") + tdSql.execute( + "create table if not exists gt0 (ts timestamp, c00 int, c01 float) ") + tdSql.execute( + "create table if not exists gt1 (ts timestamp, c10 int, c11 double) ") + tdSql.execute( + "create table if not exists gt2 (ts timestamp, c20 int, c21 float) ") tdSql.execute("insert into gt0 values(1614218412700,8637,78.86155)") - tdSql.execute("insert into gt1 values(1614218413800,8638,78.862020199)") + tdSql.execute( + "insert into gt1 values(1614218413800,8638,78.862020199)") tdSql.execute("insert into gt2 values(1614218413900,8639,78.863)") - # create + # create tdSql.execute("create database if not exists dp3 precision 'ns'") tdSql.execute("use dp3") - tdSql.execute("create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)") - tdSql.execute("create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ") - tdSql.execute("insert into st0_0 values(1614218412000000001,8600,'R')(1614218422000000002,8600,'E')") - tdSql.execute("insert into st0_1 values(1614218413000000001,8601,'A')(1614218423000000002,8601,'D')") - + tdSql.execute( + "create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)") + tdSql.execute( + "create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ") + tdSql.execute( + "insert into st0_0 values(1614218412000000001,8600,'R')(1614218422000000002,8600,'E')") + tdSql.execute( + "insert into st0_1 values(1614218413000000001,8601,'A')(1614218423000000002,8601,'D')") # # taosdump stable and general table - os.system("%staosdump -o ./taosdumptest/tmp1 -D dp1,dp2 -T 8 " % binPath) - os.system("%staosdump -o ./taosdumptest/tmp2 dp1 st0 gt0 -T 8 " % binPath) - os.system("%staosdump -o ./taosdumptest/tmp3 dp2 st0 st1_0 gt0 -T 8 " % binPath) - os.system("%staosdump -o ./taosdumptest/tmp4 dp2 st0 st2 gt0 gt2 -T 8 " % binPath) - - # verify ns - os.system("%staosdump -o ./taosdumptest/tmp6 dp3 st0_0 -T 8 " % binPath) + os.system("%s -o ./taosdumptest/tmp1 -D dp1,dp2 -T 8 " % binPath) + os.system("%s -o ./taosdumptest/tmp2 dp1 st0 gt0 -T 8 " % binPath) + os.system( + "%s -o ./taosdumptest/tmp3 dp2 st0 st1_0 gt0 -T 8 " % + binPath) + os.system( + "%s -o ./taosdumptest/tmp4 dp2 st0 st2 gt0 gt2 -T 8 " % + binPath) + + # verify ns + os.system("%s -o ./taosdumptest/tmp6 dp3 st0_0 -T 8 " % binPath) # verify -D:--database - assert os.system("%staosdump -o ./taosdumptest/tmp5 --databases dp1,dp2 -T 8 " % binPath) == 0 + assert os.system( + "%s -o ./taosdumptest/tmp5 --databases dp1,dp2 -T 8 " % + binPath) == 0 # verify mixed -D:--database and dbname tbname - assert os.system("%staosdump --databases dp1 -o ./taosdumptest/tmp5 dp2 st0 st1_0 gt0 -T 8 " % binPath) != 0 + assert os.system( + "%s --databases dp1 -o ./taosdumptest/tmp5 dp2 st0 st1_0 gt0 -T 8 " % + binPath) != 0 # verify -N - os.system("%staosdump -o ./taosdumptest/tmp7 dp3 st0_0 -N -d null -T 8 " % binPath) + os.system( + "%s -o ./taosdumptest/tmp7 dp3 st0_0 -N -d null -T 8 " % + binPath) # verify -N -s - os.system("%staosdump -o ./taosdumptest/tmp8 dp3 st0_0 -N -s -T 8 " % binPath) + os.system( + "%s -o ./taosdumptest/tmp8 dp3 st0_0 -N -s -T 8 " % + binPath) - #check taosdumptest/tmp1 + # check taosdumptest/tmp1 tdSql.execute("drop database dp1") tdSql.execute("drop database dp2") - os.system("%staosdump -i ./taosdumptest/tmp1 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp1 -T 8 " % binPath) tdSql.execute("use dp1") tdSql.query("show stables") tdSql.checkRows(1) tdSql.query("show tables") tdSql.checkRows(4) tdSql.query("select c1 from st0_0 order by ts") - tdSql.checkData(0,0,8537) + tdSql.checkData(0, 0, 8537) tdSql.query("select c2 from st0_1 order by ts") - tdSql.checkData(1,0,"D") + tdSql.checkData(1, 0, "D") tdSql.query("select * from gt0") - tdSql.checkData(0,0,'2021-02-25 10:00:12.000') - tdSql.checkData(0,1,637) + tdSql.checkData(0, 0, '2021-02-25 10:00:12.000') + tdSql.checkData(0, 1, 637) tdSql.execute("use dp2") tdSql.query("show stables") tdSql.checkRows(3) tdSql.query("show tables") tdSql.checkRows(9) tdSql.query("select ts from gt0") - tdSql.checkData(0,0,'2021-02-25 10:00:12.700') + tdSql.checkData(0, 0, '2021-02-25 10:00:12.700') tdSql.query("select c10 from gt1") tdSql.checkData(0, 0, 8638) tdSql.query("select c20 from gt2") tdSql.checkData(0, 0, 8639) - - #check taosdumptest/tmp2 + # check taosdumptest/tmp2 tdSql.execute("drop database dp1") tdSql.execute("drop database dp2") - os.system("%staosdump -i ./taosdumptest/tmp2 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp2 -T 8 " % binPath) tdSql.execute("use dp1") tdSql.query("show stables") tdSql.checkRows(1) tdSql.query("show tables") tdSql.checkRows(3) tdSql.query("select c1 from st0_0 order by ts") - tdSql.checkData(0,0,8537) + tdSql.checkData(0, 0, 8537) tdSql.query("select c2 from st0_1 order by ts") - tdSql.checkData(1,0,"D") + tdSql.checkData(1, 0, "D") tdSql.query("select * from gt0") - tdSql.checkData(0,0,'2021-02-25 10:00:12.000') - tdSql.checkData(0,1,637) + tdSql.checkData(0, 0, '2021-02-25 10:00:12.000') + tdSql.checkData(0, 1, 637) tdSql.error("select count(*) from gt1") tdSql.error("use dp2") - - #check taosdumptest/tmp3 + # check taosdumptest/tmp3 tdSql.execute("drop database dp1") - os.system("%staosdump -i ./taosdumptest/tmp3 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp3 -T 8 " % binPath) tdSql.execute("use dp2") tdSql.query("show stables") tdSql.checkRows(2) tdSql.query("show tables") tdSql.checkRows(4) tdSql.query("select count(*) from st1_0") - tdSql.checkData(0,0,2) + tdSql.checkData(0, 0, 2) tdSql.query("select ts from gt0") - tdSql.checkData(0,0,'2021-02-25 10:00:12.700') + tdSql.checkData(0, 0, '2021-02-25 10:00:12.700') tdSql.error("use dp1") tdSql.error("select count(*) from st2_0") tdSql.error("select count(*) from gt2") - #check taosdumptest/tmp4 + # check taosdumptest/tmp4 tdSql.execute("drop database dp2") - os.system("%staosdump -i ./taosdumptest/tmp4 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp4 -T 8 " % binPath) tdSql.execute("use dp2") tdSql.query("show stables") tdSql.checkRows(2) @@ -223,10 +260,9 @@ class TDTestCase: tdSql.error("select count(*) from st1_1") tdSql.error("select count(*) from gt3") - - #check taosdumptest/tmp5 + # check taosdumptest/tmp5 tdSql.execute("drop database dp2") - os.system("%staosdump -i ./taosdumptest/tmp5 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp5 -T 8 " % binPath) tdSql.execute("use dp2") tdSql.query("show stables") tdSql.checkRows(3) @@ -252,39 +288,39 @@ class TDTestCase: tdSql.query("show tables") tdSql.checkRows(4) tdSql.query("select c1 from st0_0 order by ts") - tdSql.checkData(0,0,8537) + tdSql.checkData(0, 0, 8537) tdSql.query("select c2 from st0_1 order by ts") - tdSql.checkData(1,0,"D") + tdSql.checkData(1, 0, "D") tdSql.query("select * from gt0") - tdSql.checkData(0,0,'2021-02-25 10:00:12.000') - tdSql.checkData(0,1,637) + tdSql.checkData(0, 0, '2021-02-25 10:00:12.000') + tdSql.checkData(0, 1, 637) # check taosdumptest/tmp6 tdSql.execute("drop database dp1") tdSql.execute("drop database dp2") tdSql.execute("drop database dp3") - os.system("%staosdump -i ./taosdumptest/tmp6 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp6 -T 8 " % binPath) tdSql.execute("use dp3") tdSql.query("show databases") tdSql.checkRows(1) - tdSql.checkData(0,16,'ns') + tdSql.checkData(0, 16, 'ns') tdSql.query("show stables") tdSql.checkRows(1) tdSql.query("show tables") tdSql.checkRows(1) tdSql.query("select count(*) from st0_0") - tdSql.checkData(0, 0, 2) + tdSql.checkData(0, 0, 2) tdSql.query("select * from st0 order by ts") - tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') - tdSql.checkData(0,1,8600) + tdSql.checkData(0, 0, '2021-02-25 10:00:12.000000001') + tdSql.checkData(0, 1, 8600) # check taosdumptest/tmp7 tdSql.execute("drop database dp3") - os.system("%staosdump -i ./taosdumptest/tmp7 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp7 -T 8 " % binPath) tdSql.execute("use dp3") tdSql.query("show databases") tdSql.checkRows(1) - tdSql.checkData(0,16,'ms') + tdSql.checkData(0, 16, 'ms') tdSql.query("show stables") tdSql.checkRows(1) tdSql.query("show tables") @@ -297,20 +333,20 @@ class TDTestCase: # check taosdumptest/tmp8 tdSql.execute("drop database dp3") - os.system("%staosdump -i ./taosdumptest/tmp8 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp8 -T 8 " % binPath) tdSql.execute("use dp3") tdSql.query("show stables") tdSql.checkRows(1) tdSql.query("show tables") tdSql.checkRows(1) tdSql.query("select count(*) from st0_0") - tdSql.checkRows(0) + tdSql.checkRows(0) # tdSql.query("select * from st0 order by ts") # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') # tdSql.checkData(0,1,8600) - for i in range(1,9): - os.system("rm -rf ./taosdumptest/tmp%d"%i) + for i in range(1, 9): + os.system("rm -rf ./taosdumptest/tmp%d" % i) os.system("rm -rf ./dump_result.txt") os.system("rm -rf ./db.csv") diff --git a/tests/pytest/tools/taosdumpTestBenchmark.py b/tests/pytest/tools/taosdumpTestBenchmark.py index 97dcf3e54bc972bceec4b250df690436fa3bbbc3..d3ac7347b3ad237e29ca5c30a918d4b0f7d649c3 100644 --- a/tests/pytest/tools/taosdumpTestBenchmark.py +++ b/tests/pytest/tools/taosdumpTestBenchmark.py @@ -35,7 +35,7 @@ class TDTestCase: else: return True - def getBuildPath(self): + def getPath(self, tool="taosdump"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -43,13 +43,16 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosdump" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def insert_data(self, tbname, ts_start, count): pre_insert = "insert into %s values" % tbname @@ -81,12 +84,11 @@ class TDTestCase: os.system("rm -rf ./taosdumptest/tmp%d" % i) os.makedirs("./taosdumptest/tmp%d" % i) - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath("taosdump") + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) # create db1 , one stables and one table ; create general tables tdSql.execute("drop database if exists dp1") @@ -158,7 +160,7 @@ class TDTestCase: 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, self.ts)) intData.append(i + 1) floatData.append(i + 0.1) - # os.system("%staosBenchmark -f tools/taosdump-insert-dp1.json -y " % binPath) + # os.system("%staosBenchmark -f tools/taosdump-insert-dp1.json -y " % benchBinPath) # create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1 # \stb3,include ctables stb3_0 and stb3_1 @@ -200,22 +202,22 @@ class TDTestCase: "insert into gt1 values(1614218413800,8638,78.862020199)") tdSql.execute("insert into gt2 values(1614218413900,8639,78.863)") # self.insert_data("t", self.ts, 300*10000); - # os.system("%staosBenchmark -f tools/taosdump-insert-dp2.json -y " % binPath) + # os.system("%staosBenchmark -f tools/taosdump-insert-dp2.json -y " % benchBinPath) # # taosdump data - # os.system("%staosdump -o ./taosdumptest/tmp1 taosdump -h -ptaosdata -P 6030 -u root -o taosdumptest \ + # os.system("%s -o ./taosdumptest/tmp1 taosdump -h -ptaosdata -P 6030 -u root -o taosdumptest \ # -D dp1,dp3 -N -c /home/chr/TDinternal/community/sim/dnode1/cfg/taos.cfg -s -d deflate" % binPath) os.system( - "%staosdump -o ./taosdumptest/tmp0 -D dp2,dp1 -T 8" % + "%s -o ./taosdumptest/tmp0 -D dp2,dp1 -T 8" % binPath) os.system( - "%staosdump -o ./taosdumptest/tmp1 dp2 st0 st1_0 gt0 -T 8" % + "%s -o ./taosdumptest/tmp1 dp2 st0 st1_0 gt0 -T 8" % binPath) # check taosdumptest/tmp0 tdSql.execute("drop database dp1") tdSql.execute("drop database dp2") - os.system("%staosdump -i ./taosdumptest/tmp0 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp0 -T 8 " % binPath) tdSql.execute("reset query cache") tdSql.execute("use dp1") @@ -265,7 +267,7 @@ class TDTestCase: # check taosdumptest/tmp1 tdSql.execute("drop database dp1") tdSql.execute("drop database dp2") - os.system("%staosdump -i ./taosdumptest/tmp1 -T 8 " % binPath) + os.system("%s -i ./taosdumptest/tmp1 -T 8 " % binPath) tdSql.execute("reset query cache") tdSql.execute("use dp2") tdSql.query("show stables") @@ -283,7 +285,7 @@ class TDTestCase: # #check taosdumptest/tmp2 # tdSql.execute("drop database dp1") # tdSql.execute("drop database dp2") - # os.system("%staosdump -i ./taosdumptest/tmp2 -T 8 " % binPath) + # os.system("%s -i ./taosdumptest/tmp2 -T 8 " % binPath) # tdSql.execute("use dp1") # tdSql.query("show stables") # tdSql.checkRows(1) @@ -301,7 +303,7 @@ class TDTestCase: # #check taosdumptest/tmp3 # tdSql.execute("drop database dp1") - # os.system("%staosdump -i ./taosdumptest/tmp3 -T 8 " % binPath) + # os.system("%s -i ./taosdumptest/tmp3 -T 8 " % binPath) # tdSql.execute("use dp2") # tdSql.query("show stables") # tdSql.checkRows(2) @@ -317,7 +319,7 @@ class TDTestCase: # #check taosdumptest/tmp4 # tdSql.execute("drop database dp2") - # os.system("%staosdump -i ./taosdumptest/tmp4 -T 8 " % binPath) + # os.system("%s -i ./taosdumptest/tmp4 -T 8 " % binPath) # tdSql.execute("use dp2") # tdSql.query("show stables") # tdSql.checkRows(2) @@ -340,7 +342,7 @@ class TDTestCase: # #check taosdumptest/tmp5 # tdSql.execute("drop database dp2") - # os.system("%staosdump -i ./taosdumptest/tmp5 -T 8 " % binPath) + # os.system("%s -i ./taosdumptest/tmp5 -T 8 " % binPath) # tdSql.execute("use dp2") # tdSql.query("show stables") # tdSql.checkRows(3) @@ -377,7 +379,7 @@ class TDTestCase: # tdSql.execute("drop database dp1") # tdSql.execute("drop database dp2") # tdSql.execute("drop database dp3") - # os.system("%staosdump -i ./taosdumptest/tmp6 -T 8 " % binPath) + # os.system("%s -i ./taosdumptest/tmp6 -T 8 " % binPath) # tdSql.execute("use dp3") # tdSql.query("show databases") # tdSql.checkRows(1) @@ -394,7 +396,7 @@ class TDTestCase: # # check taosdumptest/tmp7 # tdSql.execute("drop database dp3") - # os.system("%staosdump -i ./taosdumptest/tmp7 -T 8 " % binPath) + # os.system("%s -i ./taosdumptest/tmp7 -T 8 " % binPath) # tdSql.execute("use dp3") # tdSql.query("show databases") # tdSql.checkRows(1) @@ -411,7 +413,7 @@ class TDTestCase: # # check taosdumptest/tmp8 # tdSql.execute("drop database dp3") - # os.system("%staosdump -i ./taosdumptest/tmp8 -T 8 " % binPath) + # os.system("%s -i ./taosdumptest/tmp8 -T 8 " % binPath) # tdSql.execute("use dp3") # tdSql.query("show stables") # tdSql.checkRows(1) diff --git a/tests/pytest/tools/taosdumpTestNanoSupport.py b/tests/pytest/tools/taosdumpTestNanoSupport.py index 81e315934662184aa7828c2bf5ac5ef0a8cb368a..146beb90e5b999664eb3ab119ada96ee26768a2e 100644 --- a/tests/pytest/tools/taosdumpTestNanoSupport.py +++ b/tests/pytest/tools/taosdumpTestNanoSupport.py @@ -35,7 +35,7 @@ class TDTestCase: else: return True - def getBuildPath(self): + def getPath(self, tool="taosdump"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -43,13 +43,16 @@ class TDTestCase: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root) - len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def createdb(self, precision="ns"): tb_nums = self.numberOfTables @@ -118,12 +121,11 @@ class TDTestCase: if not os.path.exists("./taosdumptest/dumptmp3"): os.makedirs("./taosdumptest/dumptmp3") - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath("taosdump") + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) # create nano second database @@ -132,40 +134,40 @@ class TDTestCase: # dump all data os.system( - "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) # dump part data with -S -E os.system( - '%staosdump --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -o ./taosdumptest/dumptmp2 ' % + '%s -y -g --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -o ./taosdumptest/dumptmp2 ' % binPath) os.system( - '%staosdump --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' % + '%s -y -g --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' % binPath) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 510) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp3" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 900) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 1000) # check data origin_res = tdSql.getResult("select * from timedb1.st") tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + # dump data and check for taosdump dump_res = tdSql.getResult("select * from timedb1.st") if origin_res == dump_res: tdLog.info("test nano second : dump check data pass for all data!") @@ -177,7 +179,6 @@ class TDTestCase: os.system("rm -rf ./taosdumptest/") tdSql.execute("drop database if exists timedb1") - if not os.path.exists("./taosdumptest/tmp1"): os.makedirs("./taosdumptest/dumptmp1") @@ -190,53 +191,52 @@ class TDTestCase: if not os.path.exists("./taosdumptest/dumptmp3"): os.makedirs("./taosdumptest/dumptmp3") - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) self.createdb(precision="us") os.system( - "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) os.system( - '%staosdump --databases timedb1 -S 1625068810000000 -E 1625068860000000 -o ./taosdumptest/dumptmp2 ' % + '%s -y -g --databases timedb1 -S 1625068810000000 -E 1625068860000000 -o ./taosdumptest/dumptmp2 ' % binPath) os.system( - '%staosdump --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' % + '%s -y -g --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + os.system("%s -i ./taosdumptest/dumptmp3" % binPath) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 510) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp3" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 900) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 1000) # check data origin_res = tdSql.getResult("select * from timedb1.st") tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + # dump data and check for taosdump dump_res = tdSql.getResult("select * from timedb1.st") if origin_res == dump_res: tdLog.info("test micro second : dump check data pass for all data!") @@ -260,56 +260,56 @@ class TDTestCase: if not os.path.exists("./taosdumptest/dumptmp3"): os.makedirs("./taosdumptest/dumptmp3") - buildPath = self.getBuildPath() - if (buildPath == ""): + binPath = self.getPath() + if (binPath == ""): tdLog.exit("taosdump not found!") else: - tdLog.info("taosdump found in %s" % buildPath) - binPath = buildPath + "/build/bin/" + tdLog.info("taosdump found: %s" % binPath) self.createdb(precision="ms") os.system( - "%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % + "%s -y -g --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath) os.system( - '%staosdump --databases timedb1 -S 1625068810000 -E 1625068860000 -o ./taosdumptest/dumptmp2 ' % + '%s -y -g --databases timedb1 -S 1625068810000 -E 1625068860000 -o ./taosdumptest/dumptmp2 ' % binPath) os.system( - '%staosdump --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' % + '%s -y -g --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + os.system("%s -i ./taosdumptest/dumptmp3" % binPath) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp2" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp2" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 510) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp3" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp3" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 900) tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + # dump data and check for taosdump tdSql.query("select count(*) from timedb1.st") tdSql.checkData(0, 0, 1000) # check data origin_res = tdSql.getResult("select * from timedb1.st") tdSql.execute("drop database timedb1") - os.system("%staosdump -i ./taosdumptest/dumptmp1" % binPath) - # dump data and check for taosdump + os.system("%s -i ./taosdumptest/dumptmp1" % binPath) + # dump data and check for taosdump dump_res = tdSql.getResult("select * from timedb1.st") if origin_res == dump_res: - tdLog.info("test million second : dump check data pass for all data!") + tdLog.info( + "test million second : dump check data pass for all data!") else: tdLog.info( "test million second : dump check data failed for all data!") diff --git a/tests/pytest/util/dnodes-default.py b/tests/pytest/util/dnodes-default.py index 7d8fc3f630d6712e8d984f17fbcb701a4a81172c..055d3085d30c959490ea01815394a4c5bfe4d2ec 100644 --- a/tests/pytest/util/dnodes-default.py +++ b/tests/pytest/util/dnodes-default.py @@ -40,7 +40,8 @@ class TDSimClient: "jnidebugFlag": "135", "qdebugFlag": "135", "telemetryReporting": "0", - } + } + def init(self, path): self.__init__() self.path = path @@ -72,14 +73,14 @@ class TDSimClient: cmd = "rm -rf " + self.logDir if os.system(cmd) != 0: tdLog.exit(cmd) - - os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" + + os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" cmd = "rm -rf " + self.cfgDir if os.system(cmd) != 0: tdLog.exit(cmd) - os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -145,11 +146,11 @@ class TDDnode: if os.system(cmd) != 0: tdLog.exit(cmd) - os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p" - os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" - os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -198,7 +199,7 @@ class TDDnode: "dnode:%d is deployed and configured by %s" % (self.index, self.cfgPath)) - def getBuildPath(self): + def getPath(self, tool="taosd"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -206,23 +207,22 @@ class TDDnode: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def start(self): - buildPath = self.getBuildPath() + binPath = self.getPath() - if (buildPath == ""): + if (binPath == ""): tdLog.exit("taosd not found!") else: - tdLog.info("taosd found in %s" % buildPath) - - binPath = buildPath + "/build/bin/taosd" + tdLog.info("taosd found: %s" % binPath) if self.deployed == 0: tdLog.exit("dnode:%d is not deployed" % (self.index)) diff --git a/tests/pytest/util/dnodes-no-random-fail.py b/tests/pytest/util/dnodes-no-random-fail.py index 86ef9e178e7776b1f2bf160e513d8392531ae5c2..467a19fa4d0e96b6a0201c889bd82ff5bd3e0881 100644 --- a/tests/pytest/util/dnodes-no-random-fail.py +++ b/tests/pytest/util/dnodes-no-random-fail.py @@ -37,7 +37,7 @@ class TDSimClient: "jnidebugFlag": "135", "qdebugFlag": "135", "telemetryReporting": "0", - } + } def init(self, path): self.__init__() @@ -70,14 +70,14 @@ class TDSimClient: cmd = "rm -rf " + self.logDir if os.system(cmd) != 0: tdLog.exit(cmd) - - os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" + + os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" cmd = "rm -rf " + self.cfgDir if os.system(cmd) != 0: tdLog.exit(cmd) - os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -143,11 +143,11 @@ class TDDnode: if os.system(cmd) != 0: tdLog.exit(cmd) - os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p" - os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" - os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -196,7 +196,7 @@ class TDDnode: "dnode:%d is deployed and configured by %s" % (self.index, self.cfgPath)) - def getBuildPath(self): + def getPath(self, tool="taosd"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -204,23 +204,22 @@ class TDDnode: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def start(self): - buildPath = self.getBuildPath() + binPath = self.getPath() - if (buildPath == ""): + if (binPath == ""): tdLog.exit("taosd not found!") else: - tdLog.info("taosd found in %s" % buildPath) - - binPath = buildPath + "/build/bin/taosd" + tdLog.info("taosd found: %s" % binPath) if self.deployed == 0: tdLog.exit("dnode:%d is not deployed" % (self.index)) diff --git a/tests/pytest/util/dnodes-random-fail.py b/tests/pytest/util/dnodes-random-fail.py index 6590f1e2048521893d9eee5cd901ff9abde36ad1..6edd5f1f6a129f1890c6eff6cb0d282acdf03e45 100644 --- a/tests/pytest/util/dnodes-random-fail.py +++ b/tests/pytest/util/dnodes-random-fail.py @@ -37,7 +37,7 @@ class TDSimClient: "jnidebugFlag": "135", "qdebugFlag": "135", "telemetryReporting": "0", - } + } def init(self, path): self.__init__() @@ -70,14 +70,14 @@ class TDSimClient: cmd = "rm -rf " + self.logDir if os.system(cmd) != 0: tdLog.exit(cmd) - - os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" + + os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" cmd = "rm -rf " + self.cfgDir if os.system(cmd) != 0: tdLog.exit(cmd) - os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -143,11 +143,11 @@ class TDDnode: if os.system(cmd) != 0: tdLog.exit(cmd) - os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p" - os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" - os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -196,7 +196,7 @@ class TDDnode: "dnode:%d is deployed and configured by %s" % (self.index, self.cfgPath)) - def getBuildPath(self): + def getPath(self, tool="taosd"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -204,23 +204,22 @@ class TDDnode: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): - if ("taosd" in files): + if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + return paths[0] def start(self): - buildPath = self.getBuildPath() + binPath = self.getPath() - if (buildPath == ""): + if (binPath == ""): tdLog.exit("taosd not found!") else: - tdLog.info("taosd found in %s" % buildPath) - - binPath = buildPath + "/build/bin/taosd" + tdLog.info("taosd found: %s" % binPath) if self.deployed == 0: tdLog.exit("dnode:%d is not deployed" % (self.index)) diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 427cfe349e6ea9a43c0eab93dbee12828c8c3db1..a2c837ebfcce5b355b92080e66d109e1543b407f 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -65,10 +65,12 @@ class TDSimClient: cmd = "echo %s %s >> %s" % (option, value, self.cfgPath) if os.system(cmd) != 0: tdLog.exit(cmd) - def os_string(self,path): - os_path = path.replace("/",os.sep) + + def os_string(self, path): + os_path = path.replace("/", os.sep) return os_path - def deploy(self): + + def deploy(self, *updatecfgDict): self.logDir = self.os_string("%s/sim/psim/log" % (self.path)) self.cfgDir = self.os_string("%s/sim/psim/cfg" % (self.path)) self.cfgPath = self.os_string("%s/sim/psim/cfg/taos.cfg" % (self.path)) @@ -76,11 +78,11 @@ class TDSimClient: # cmd = "rm -rf " + self.logDir # if os.system(cmd) != 0: # tdLog.exit(cmd) - if os.path.exists(self.logDir): + if os.path.exists(self.logDir): try: shutil.rmtree(self.logDir) - except: - tdLog.exit("del %s failed"%self.logDir) + except BaseException: + tdLog.exit("del %s failed" % self.logDir) # cmd = "mkdir -p " + self.logDir # if os.system(cmd) != 0: # tdLog.exit(cmd) @@ -88,11 +90,11 @@ class TDSimClient: # cmd = "rm -rf " + self.cfgDir # if os.system(cmd) != 0: # tdLog.exit(cmd) - if os.path.exists(self.cfgDir): + if os.path.exists(self.cfgDir): try: shutil.rmtree(self.cfgDir) - except: - tdLog.exit("del %s failed"%self.cfgDir) + except BaseException: + tdLog.exit("del %s failed" % self.cfgDir) # cmd = "mkdir -p " + self.cfgDir # if os.system(cmd) != 0: # tdLog.exit(cmd) @@ -102,8 +104,8 @@ class TDSimClient: # tdLog.exit(cmd) try: pathlib.Path(self.cfgPath).touch() - except: - tdLog.exit("create %s failed"%self.cfgPath) + except BaseException: + tdLog.exit("create %s failed" % self.cfgPath) if self.testCluster: self.cfg("masterIp", "192.168.0.1") self.cfg("secondIp", "192.168.0.2") @@ -111,6 +113,15 @@ class TDSimClient: for key, value in self.cfgDict.items(): self.cfg(key, value) + + try: + if updatecfgDict and updatecfgDict[0] and updatecfgDict[0][0]: + clientCfg = dict (updatecfgDict[0][0].get('clientCfg')) + if clientCfg is not None: + for key, value in clientCfg.items(): + self.cfg(key, value) + except Exception as e: + pass tdLog.debug("psim is deployed and configured by %s" % (self.cfgPath)) @@ -123,36 +134,36 @@ class TDDnode: self.testCluster = False self.valgrind = 0 self.cfgDict = { - "numOfLogLines":"100000000", - "mnodeEqualVnodeNum":"0", - "walLevel":"2", - "fsync":"1000", - "statusInterval":"1", - "numOfMnodes":"3", - "numOfThreadsPerCore":"2.0", - "monitor":"0", - "maxVnodeConnections":"30000", - "maxMgmtConnections":"30000", - "maxMeterConnections":"30000", - "maxShellConns":"30000", - "locale":"en_US.UTF-8", - "charset":"UTF-8", - "asyncLog":"0", - "anyIp":"0", - "telemetryReporting":"0", - "dDebugFlag":"135", - "tsdbDebugFlag":"135", - "mDebugFlag":"135", - "sdbDebugFlag":"135", - "rpcDebugFlag":"135", - "tmrDebugFlag":"131", - "cDebugFlag":"135", - "httpDebugFlag":"135", - "monitorDebugFlag":"135", - "udebugFlag":"135", - "jnidebugFlag":"135", - "qdebugFlag":"135", - "maxSQLLength":"1048576", + "numOfLogLines": "100000000", + "mnodeEqualVnodeNum": "0", + "walLevel": "2", + "fsync": "1000", + "statusInterval": "1", + "numOfMnodes": "3", + "numOfThreadsPerCore": "2.0", + "monitor": "0", + "maxVnodeConnections": "30000", + "maxMgmtConnections": "30000", + "maxMeterConnections": "30000", + "maxShellConns": "30000", + "locale": "en_US.UTF-8", + "charset": "UTF-8", + "asyncLog": "0", + "anyIp": "0", + "telemetryReporting": "0", + "dDebugFlag": "135", + "tsdbDebugFlag": "135", + "mDebugFlag": "135", + "sdbDebugFlag": "135", + "rpcDebugFlag": "135", + "tmrDebugFlag": "131", + "cDebugFlag": "135", + "httpDebugFlag": "135", + "monitorDebugFlag": "135", + "udebugFlag": "135", + "jnidebugFlag": "135", + "qdebugFlag": "135", + "maxSQLLength": "1048576", "enableCoreFile": "1", } @@ -200,11 +211,11 @@ class TDDnode: if os.system(cmd) != 0: tdLog.exit(cmd) - os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.dataDir, exist_ok=True) # like "mkdir -p" - os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.logDir, exist_ok=True) # like "mkdir -p" - os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" + os.makedirs(self.cfgDir, exist_ok=True) # like "mkdir -p" cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -227,16 +238,18 @@ class TDDnode: isFirstDir = 1 if bool(updatecfgDict) and updatecfgDict[0] and updatecfgDict[0][0]: print(updatecfgDict[0][0]) - for key,value in updatecfgDict[0][0].items(): - if value == 'dataDir' : + for key, value in updatecfgDict[0][0].items(): + if key == "clientCfg": + continue + if value == 'dataDir': if isFirstDir: self.cfgDict.pop('dataDir') - self.cfg(value,key) + self.cfg(value, key) isFirstDir = 0 else: - self.cfg(value,key) + self.cfg(value, key) else: - self.addExtraCfg(key,value) + self.addExtraCfg(key, value) for key, value in self.cfgDict.items(): self.cfg(key, value) @@ -245,8 +258,7 @@ class TDDnode: "dnode:%d is deployed and configured by %s" % (self.index, self.cfgPath)) - def getBuildPath(self, tool="taosd"): - buildPath = "" + def getPath(self, tool="taosd"): selfPath = os.path.dirname(os.path.realpath(__file__)) if ("community" in selfPath): @@ -254,24 +266,30 @@ class TDDnode: else: projPath = selfPath[:selfPath.find("tests")] + paths = [] for root, dirs, files in os.walk(projPath): if ((tool) in files): rootRealPath = os.path.dirname(os.path.realpath(root)) if ("packaging" not in rootRealPath): - buildPath = root[:len(root)-len("/build/bin")] + paths.append(os.path.join(root, tool)) break - return buildPath + if (len(paths) == 0): + return "" + return paths[0] def start(self): - buildPath = self.getBuildPath() + binPath = self.getPath() - if (buildPath == ""): + if (binPath == ""): tdLog.exit("taosd not found!") else: - tdLog.info("taosd found in %s" % buildPath) + tdLog.info("taosd found: %s" % binPath) - binPath = buildPath + "/build/bin/taosd" - taosadapterBinPath = buildPath + "/build/bin/taosadapter" + taosadapterBinPath = self.getPath("taosadapter") + if (taosadapterBinPath == ""): + tdLog.info("taosAdapter not found!") + else: + tdLog.info("taosAdapter found: %s" % taosadapterBinPath) if self.deployed == 0: tdLog.exit("dnode:%d is not deployed" % (self.index)) @@ -287,11 +305,12 @@ class TDDnode: print(cmd) - taosadapterCmd = "nohup %s --opentsdb_telnet.enable=true > /dev/null 2>&1 & " % ( + if (taosadapterBinPath != ""): + taosadapterCmd = "nohup %s --opentsdb_telnet.enable=true --monitor.writeToTD=false > /dev/null 2>&1 & " % ( taosadapterBinPath) - tdLog.info(taosadapterCmd) - if os.system(taosadapterCmd) != 0: - tdLog.exit(taosadapterCmd) + tdLog.info(taosadapterCmd) + if os.system(taosadapterCmd) != 0: + tdLog.exit(taosadapterCmd) if os.system(cmd) != 0: tdLog.exit(cmd) @@ -301,18 +320,22 @@ class TDDnode: if self.valgrind == 0: time.sleep(0.1) key = 'from offline to online' - bkey = bytes(key,encoding="utf8") + bkey = bytes(key, encoding="utf8") logFile = self.logDir + "/taosdlog.0" i = 0 while not os.path.exists(logFile): sleep(0.1) i += 1 - if i>50: + if i > 50: break - popen = subprocess.Popen('tail -f ' + logFile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + popen = subprocess.Popen( + 'tail -f ' + logFile, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=True) pid = popen.pid # print('Popen.pid:' + str(pid)) - timeout = time.time() + 60*2 + timeout = time.time() + 60 * 2 while True: line = popen.stdout.readline().strip() if bkey in line: @@ -322,32 +345,38 @@ class TDDnode: tdLog.exit('wait too long for taosd start') tdLog.debug("the dnode:%d has been started." % (self.index)) else: - tdLog.debug("wait 10 seconds for the dnode:%d to start." % (self.index)) + tdLog.debug( + "wait 10 seconds for the dnode:%d to start." % + (self.index)) time.sleep(10) - # time.sleep(5) + def startWin(self): - buildPath = self.getBuildPath("taosd.exe") + binPath = self.getPath("taosd.exe") - if (buildPath == ""): + if (binPath == ""): tdLog.exit("taosd.exe not found!") else: - tdLog.info("taosd.exe found in %s" % buildPath) + tdLog.info("taosd.exe found: %s" % binPath) - binPath = buildPath + "/build/bin/taosd.exe" - taosadapterBinPath = buildPath + "/build/bin/taosadapter.exe" + taosadapterBinPath = self.getPath("taosadapter.exe") + if (taosadapterBinPath == ""): + tdLog.info("taosAdapter.exe not found!") + else: + tdLog.info("taosAdapter.exe found in %s" % taosadapterBuildPath) if self.deployed == 0: tdLog.exit("dnode:%d is not deployed" % (self.index)) cmd = "mintty -h never -w hide %s -c %s" % ( - binPath, self.cfgDir) - - taosadapterCmd = "mintty -h never -w hide %s " % ( + binPath, self.cfgDir) + + if (taosadapterBinPath != ""): + taosadapterCmd = "mintty -h never -w hide %s --monitor.writeToTD=false " % ( taosadapterBinPath) - if os.system(taosadapterCmd) != 0: - tdLog.exit(taosadapterCmd) + if os.system(taosadapterCmd) != 0: + tdLog.exit(taosadapterCmd) if os.system(cmd) != 0: tdLog.exit(cmd) @@ -357,18 +386,22 @@ class TDDnode: if self.valgrind == 0: time.sleep(0.1) key = 'from offline to online' - bkey = bytes(key,encoding="utf8") + bkey = bytes(key, encoding="utf8") logFile = self.logDir + "/taosdlog.0" i = 0 while not os.path.exists(logFile): sleep(0.1) i += 1 - if i>50: + if i > 50: break - popen = subprocess.Popen('tail -n +0 -f ' + logFile, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) + popen = subprocess.Popen( + 'tail -n +0 -f ' + logFile, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=True) pid = popen.pid # print('Popen.pid:' + str(pid)) - timeout = time.time() + 60*2 + timeout = time.time() + 60 * 2 while True: line = popen.stdout.readline().strip() if bkey in line: @@ -378,19 +411,24 @@ class TDDnode: tdLog.exit('wait too long for taosd start') tdLog.debug("the dnode:%d has been started." % (self.index)) else: - tdLog.debug("wait 10 seconds for the dnode:%d to start." % (self.index)) + tdLog.debug( + "wait 10 seconds for the dnode:%d to start." % + (self.index)) time.sleep(10) - + def startWithoutSleep(self): - buildPath = self.getBuildPath() + binPath = self.getPath() - if (buildPath == ""): + if (binPath == ""): tdLog.exit("taosd not found!") else: - tdLog.info("taosd found in %s" % buildPath) + tdLog.info("taosd found: %s" % binPath) - binPath = buildPath + "/build/bin/taosd" - taosadapterBinPath = buildPath + "/build/bin/taosadapter" + taosadapterBinPath = self.getPath("taosadapter") + if (taosadapterBinPath == ""): + tdLog.exit("taosAdapter not found!") + else: + tdLog.info("taosAdapter found: %s" % taosadapterBinPath) if self.deployed == 0: tdLog.exit("dnode:%d is not deployed" % (self.index)) @@ -406,9 +444,10 @@ class TDDnode: print(cmd) - taosadapterCmd = "%s > /dev/null 2>&1 & " % (taosadapterBinPath) - if os.system(taosadapterCmd) != 0: - tdLog.exit(taosadapterCmd) + if (taosadapterBinPath != ""): + taosadapterCmd = "%s --monitor.writeToTD=false > /dev/null 2>&1 & " % (taosadapterBinPath) + if os.system(taosadapterCmd) != 0: + tdLog.exit(taosadapterCmd) if os.system(cmd) != 0: tdLog.exit(cmd) @@ -420,14 +459,14 @@ class TDDnode: taosadapterPsCmd = "ps -ef|grep -w %s| grep -v grep | awk '{print $2}'" % taosadapterToBeKilled taosadapterProcessID = subprocess.check_output( - taosadapterPsCmd, shell=True).decode("utf-8") + taosadapterPsCmd, shell=True).decode("utf-8") while(taosadapterProcessID): taosadapterKillCmd = "kill -INT %s > /dev/null 2>&1" % taosadapterProcessID os.system(taosadapterKillCmd) time.sleep(1) taosadapterProcessID = subprocess.check_output( - taosadapterPsCmd, shell=True).decode("utf-8") + taosadapterPsCmd, shell=True).decode("utf-8") if self.valgrind == 0: toBeKilled = "taosd" @@ -580,7 +619,7 @@ class TDDnodes: self.sim.setTestCluster(self.testCluster) if (self.simDeployed == False): - self.sim.deploy() + self.sim.deploy(updatecfgDict) self.simDeployed = True self.check(index) @@ -599,7 +638,7 @@ class TDDnodes: def startWin(self, index): self.check(index) self.dnodes[index - 1].startWin() - + def startWithoutSleep(self, index): self.check(index) self.dnodes[index - 1].startWithoutSleep() diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index a7cc0ccc7b8768407f87981a32ab479a74ebbf84..85abd92dfccb391cb09ba5cdea14fb891d2bfa0b 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -21,16 +21,18 @@ import shutil import pandas as pd from util.log import * + def _parse_datetime(timestr): try: - return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') + return datetime.datetime.strptime(timestr, "%Y-%m-%d %H:%M:%S.%f") except ValueError: pass try: - return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S') + return datetime.datetime.strptime(timestr, "%Y-%m-%d %H:%M:%S") except ValueError: pass + class TDSql: def __init__(self): self.queryRows = 0 @@ -40,7 +42,7 @@ class TDSql: def init(self, cursor, log=False): self.cursor = cursor - if (log): + if log: caller = inspect.getframeinfo(inspect.stack()[1][0]) self.cursor.log(caller.filename + ".sql") @@ -49,13 +51,13 @@ class TDSql: def prepare(self): tdLog.info("prepare database:db") - s = 'reset query cache' + s = "reset query cache" self.cursor.execute(s) - s = 'drop database if exists db' + s = "drop database if exists db" self.cursor.execute(s) - s = 'create database db' + s = "create database db" self.cursor.execute(s) - s = 'use db' + s = "use db" self.cursor.execute(s) def error(self, sql): @@ -66,7 +68,10 @@ class TDSql: expectErrNotOccured = False if expectErrNotOccured: caller = inspect.getframeinfo(inspect.stack()[1][0]) - tdLog.exit("%s(%d) failed: sql:%s, expect error not occured" % (caller.filename, caller.lineno, sql)) + tdLog.exit( + "%s(%d) failed: sql:%s, expect error not occured" + % (caller.filename, caller.lineno, sql) + ) else: self.queryRows = 0 self.queryCols = 0 @@ -90,11 +95,11 @@ class TDSql: return self.queryRows def getVariable(self, search_attr): - ''' - get variable of search_attr access "show variables" - ''' + """ + get variable of search_attr access "show variables" + """ try: - sql = 'show variables' + sql = "show variables" param_list = self.query(sql, row_tag=True) for param in param_list: if param[0] == search_attr: @@ -125,7 +130,10 @@ class TDSql: return col_name_list def waitedQuery(self, sql, expectRows, timeout): - tdLog.info("sql: %s, try to retrieve %d rows in %d seconds" % (sql, expectRows, timeout)) + tdLog.info( + "sql: %s, try to retrieve %d rows in %d seconds" + % (sql, expectRows, timeout) + ) self.sql = sql try: for i in range(timeout): @@ -133,7 +141,10 @@ class TDSql: self.queryResult = self.cursor.fetchall() self.queryRows = len(self.queryResult) self.queryCols = len(self.cursor.description) - tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) + tdLog.info( + "sql: %s, try to retrieve %d rows,get %d rows" + % (sql, expectRows, self.queryRows) + ) if self.queryRows >= expectRows: return (self.queryRows, i) time.sleep(1) @@ -146,18 +157,36 @@ class TDSql: def checkRows(self, expectRows): if self.queryRows == expectRows: - tdLog.info("sql:%s, queryRows:%d == expect:%d" % (self.sql, self.queryRows, expectRows)) + tdLog.info( + "sql:%s, queryRows:%d == expect:%d" + % (self.sql, self.queryRows, expectRows) + ) else: caller = inspect.getframeinfo(inspect.stack()[1][0]) - args = (caller.filename, caller.lineno, self.sql, self.queryRows, expectRows) + args = ( + caller.filename, + caller.lineno, + self.sql, + self.queryRows, + expectRows, + ) tdLog.exit("%s(%d) failed: sql:%s, queryRows:%d != expect:%d" % args) def checkCols(self, expectCols): if self.queryCols == expectCols: - tdLog.info("sql:%s, queryCols:%d == expect:%d" % (self.sql, self.queryCols, expectCols)) + tdLog.info( + "sql:%s, queryCols:%d == expect:%d" + % (self.sql, self.queryCols, expectCols) + ) else: caller = inspect.getframeinfo(inspect.stack()[1][0]) - args = (caller.filename, caller.lineno, self.sql, self.queryCols, expectCols) + args = ( + caller.filename, + caller.lineno, + self.sql, + self.queryCols, + expectCols, + ) tdLog.exit("%s(%d) failed: sql:%s, queryCols:%d != expect:%d" % args) def checkRowCol(self, row, col): @@ -170,10 +199,14 @@ class TDSql: tdLog.exit("%s(%d) failed: sql:%s, col:%d is smaller than zero" % args) if row > self.queryRows: args = (caller.filename, caller.lineno, self.sql, row, self.queryRows) - tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + tdLog.exit( + "%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args + ) if col > self.queryCols: args = (caller.filename, caller.lineno, self.sql, col, self.queryCols) - tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + tdLog.exit( + "%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args + ) def checkDataType(self, row, col, dataType): self.checkRowCol(row, col) @@ -185,47 +218,90 @@ class TDSql: if self.cursor.istype(col, "TIMESTAMP"): # suppose user want to check nanosecond timestamp if a longer data passed if isinstance(data, int) or isinstance(data, float): - if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): - tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) - elif (len(data) >= 28): - if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): - tdLog.info("sql:%s, row:%d col:%d data:%d == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime( + data + ): + tdLog.info( + "sql:%s, row:%d col:%d data:%d == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) + elif not isinstance(data, datetime.datetime) and len(data) >= 28: + if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime( + data + ): + tdLog.info( + "sql:%s, row:%d col:%d data:%d == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) + elif isinstance(data, datetime.datetime): + if self.queryResult[row][col] == data: + tdLog.info( + "sql:%s, row:%d col:%d data:%s == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) else: if self.queryResult[row][col] == _parse_datetime(data): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info( + "sql:%s, row:%d col:%d data:%s == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) return if str(self.queryResult[row][col]) == str(data): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info( + "sql:%s, row:%d col:%d data:%s == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) return - elif isinstance(data, float) and abs(self.queryResult[row][col] - data) <= 0.000001: - tdLog.info("sql:%s, row:%d col:%d data:%f == expect:%f" % - (self.sql, row, col, self.queryResult[row][col], data)) + elif ( + isinstance(data, float) + and abs(self.queryResult[row][col] - data) <= 0.000001 + ): + tdLog.info( + "sql:%s, row:%d col:%d data:%f == expect:%f" + % (self.sql, row, col, self.queryResult[row][col], data) + ) return else: caller = inspect.getframeinfo(inspect.stack()[1][0]) - args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) - tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + args = ( + caller.filename, + caller.lineno, + self.sql, + row, + col, + self.queryResult[row][col], + data, + ) + tdLog.exit( + "%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args + ) if data is None: - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info( + "sql:%s, row:%d col:%d data:%s == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) elif isinstance(data, str): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info( + "sql:%s, row:%d col:%d data:%s == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) elif isinstance(data, datetime.date): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info( + "sql:%s, row:%d col:%d data:%s == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) elif isinstance(data, float): - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%s" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info( + "sql:%s, row:%d col:%d data:%s == expect:%s" + % (self.sql, row, col, self.queryResult[row][col], data) + ) else: - tdLog.info("sql:%s, row:%d col:%d data:%s == expect:%d" % - (self.sql, row, col, self.queryResult[row][col], data)) + tdLog.info( + "sql:%s, row:%d col:%d data:%s == expect:%d" + % (self.sql, row, col, self.queryResult[row][col], data) + ) def checkDeviaRation(self, row, col, data, deviation=0.001): self.checkRowCol(row, col) @@ -233,35 +309,59 @@ class TDSql: self.checkData(row, col, None) return caller = inspect.getframeinfo(inspect.stack()[1][0]) - if data is not None and len(self.queryResult)==0: - tdLog.exit(f"{caller.filename}({caller.lineno}) failed: sql:{self.sql}, data:{data}, " - f"expect result is not None but it is") + if data is not None and len(self.queryResult) == 0: + tdLog.exit( + f"{caller.filename}({caller.lineno}) failed: sql:{self.sql}, data:{data}, " + f"expect result is not None but it is" + ) args = ( - caller.filename, caller.lineno, self.sql, data, type(data), - deviation, type(deviation), self.queryResult[row][col], type(self.queryResult[row][col]) + caller.filename, + caller.lineno, + self.sql, + data, + type(data), + deviation, + type(deviation), + self.queryResult[row][col], + type(self.queryResult[row][col]), ) - if not(isinstance(data,int) or isinstance(data, float)): - tdLog.exit(f"{args[0]}({args[1]}) failed: sql:{args[2]}, data:{args[3]}, " - f"expect type: int or float, actual type: {args[4]}") - if not(isinstance(deviation,int) or isinstance(deviation, float)) or type(data)==type(True): - tdLog.exit(f"{args[0]}({args[1]}) failed: sql:{args[2]}, deviation:{args[5]}, " - f"expect type: int or float, actual type: {args[6]}") - if not(isinstance(self.queryResult[row][col], int) or isinstance(self.queryResult[row][col], float)): - tdLog.exit(f"{args[0]}({args[1]}) failed: sql:{args[2]}, result:{args[7]}, " - f"expect type: int or float, actual type: {args[8]}") + if not (isinstance(data, int) or isinstance(data, float)): + tdLog.exit( + f"{args[0]}({args[1]}) failed: sql:{args[2]}, data:{args[3]}, " + f"expect type: int or float, actual type: {args[4]}" + ) + if not (isinstance(deviation, int) or isinstance(deviation, float)) or type( + data + ) == type(True): + tdLog.exit( + f"{args[0]}({args[1]}) failed: sql:{args[2]}, deviation:{args[5]}, " + f"expect type: int or float, actual type: {args[6]}" + ) + if not ( + isinstance(self.queryResult[row][col], int) + or isinstance(self.queryResult[row][col], float) + ): + tdLog.exit( + f"{args[0]}({args[1]}) failed: sql:{args[2]}, result:{args[7]}, " + f"expect type: int or float, actual type: {args[8]}" + ) if data == 0: devia = abs(self.queryResult[row][col]) else: - devia = abs((data - self.queryResult[row][col])/data) + devia = abs((data - self.queryResult[row][col]) / data) if devia <= deviation: - tdLog.info(f"sql:{args[2]}, row:{row}, col:{col}, result data:{args[7]}, expect data:{args[3]}, " - f"actual deviation:{devia} <= expect deviation:{args[5]}") + tdLog.info( + f"sql:{args[2]}, row:{row}, col:{col}, result data:{args[7]}, expect data:{args[3]}, " + f"actual deviation:{devia} <= expect deviation:{args[5]}" + ) else: - tdLog.exit(f"{args[0]}({args[1]}) failed: sql:{args[2]}, row:{row}, col:{col}, " - f"result data:{args[7]}, expect data:{args[3]}," - f"actual deviation:{devia} > expect deviation:{args[5]}") + tdLog.exit( + f"{args[0]}({args[1]}) failed: sql:{args[2]}, row:{row}, col:{col}, " + f"result data:{args[7]}, expect data:{args[3]}," + f"actual deviation:{devia} > expect deviation:{args[5]}" + ) pass def getData(self, row, col): @@ -280,7 +380,6 @@ class TDSql: raise Exception(repr(e)) return self.queryResult - def executeTimes(self, sql, times): for i in range(times): try: @@ -303,18 +402,39 @@ class TDSql: def checkAffectedRows(self, expectAffectedRows): if self.affectedRows != expectAffectedRows: caller = inspect.getframeinfo(inspect.stack()[1][0]) - args = (caller.filename, caller.lineno, self.sql, self.affectedRows, expectAffectedRows) + args = ( + caller.filename, + caller.lineno, + self.sql, + self.affectedRows, + expectAffectedRows, + ) tdLog.exit("%s(%d) failed: sql:%s, affectedRows:%d != expect:%d" % args) - tdLog.info("sql:%s, affectedRows:%d == expect:%d" % (self.sql, self.affectedRows, expectAffectedRows)) + tdLog.info( + "sql:%s, affectedRows:%d == expect:%d" + % (self.sql, self.affectedRows, expectAffectedRows) + ) def checkColNameList(self, col_name_list, expect_col_name_list): if col_name_list == expect_col_name_list: - tdLog.info("sql:%s, col_name_list:%s == expect_col_name_list:%s" % (self.sql, col_name_list, expect_col_name_list)) + tdLog.info( + "sql:%s, col_name_list:%s == expect_col_name_list:%s" + % (self.sql, col_name_list, expect_col_name_list) + ) else: caller = inspect.getframeinfo(inspect.stack()[1][0]) - args = (caller.filename, caller.lineno, self.sql, col_name_list, expect_col_name_list) - tdLog.exit("%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s" % args) + args = ( + caller.filename, + caller.lineno, + self.sql, + col_name_list, + expect_col_name_list, + ) + tdLog.exit( + "%s(%d) failed: sql:%s, col_name_list:%s != expect_col_name_list:%s" + % args + ) def checkEqual(self, elm, expect_elm): if elm == expect_elm: @@ -348,46 +468,49 @@ class TDSql: pl = psutil.pids() for pid in pl: try: - if psutil.Process(pid).name() == 'taosd': - print('have already started') + if psutil.Process(pid).name() == "taosd": + print("have already started") pstate = 1 break except psutil.NoSuchProcess: pass - if pstate == state :break + if pstate == state: + break if state or pstate: tdLog.sleep(1) continue pstate = 0 break - args=(pstate,state) + args = (pstate, state) if pstate == state: - tdLog.info("taosd state is %d == expect:%d" %args) + tdLog.info("taosd state is %d == expect:%d" % args) else: - tdLog.exit("taosd state is %d != expect:%d" %args) + tdLog.exit("taosd state is %d != expect:%d" % args) pass def haveFile(self, dir, state): if os.path.exists(dir) and os.path.isdir(dir): if not os.listdir(dir): - if state : - tdLog.exit("dir: %s is empty, expect: not empty" %dir) + if state: + tdLog.exit("dir: %s is empty, expect: not empty" % dir) else: - tdLog.info("dir: %s is empty, expect: empty" %dir) + tdLog.info("dir: %s is empty, expect: empty" % dir) else: - if state : - tdLog.info("dir: %s is not empty, expect: not empty" %dir) + if state: + tdLog.info("dir: %s is not empty, expect: not empty" % dir) else: - tdLog.exit("dir: %s is not empty, expect: empty" %dir) + tdLog.exit("dir: %s is not empty, expect: empty" % dir) else: - tdLog.exit("dir: %s doesn't exist" %dir) + tdLog.exit("dir: %s doesn't exist" % dir) + def createDir(self, dir): if os.path.exists(dir): shutil.rmtree(dir) - tdLog.info("dir: %s is removed" %dir) - os.makedirs( dir, 755 ) - tdLog.info("dir: %s is created" %dir) + tdLog.info("dir: %s is removed" % dir) + os.makedirs(dir, 755) + tdLog.info("dir: %s is created" % dir) pass -tdSql = TDSql() \ No newline at end of file + +tdSql = TDSql() diff --git a/tests/script/general/alter/dnode.sim b/tests/script/general/alter/dnode.sim index 7b31218fc231cfdbb79ca97573cfc6f6f149037d..871aa6a6f8edd67380e6142bd3808ca55eb87199 100644 --- a/tests/script/general/alter/dnode.sim +++ b/tests/script/general/alter/dnode.sim @@ -36,7 +36,6 @@ sql alter dnode 1 tsdbDebugFlag 135 sql alter dnode 1 sDebugflag 135 sql alter dnode 1 rpcDebugFlag 135 sql alter dnode 1 dDebugFlag 135 -sql alter dnode 1 mqttDebugFlag 135 sql alter dnode 1 wDebugFlag 135 sql alter dnode 1 tmrDebugFlag 135 sql_error alter dnode 2 wDebugFlag 135 @@ -68,4 +67,4 @@ sql alter dnode 1 balance "vnode:2-dnode:1" -x step4 step4: print ======= over -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/general/compute/str_char_length.sim b/tests/script/general/compute/str_char_length.sim index 5ef295db8893dfbcf9fd38f07c6849764251dcce..97365867d91831487d8605e341f1e23395ee216d 100644 --- a/tests/script/general/compute/str_char_length.sim +++ b/tests/script/general/compute/str_char_length.sim @@ -1024,7 +1024,7 @@ if $data60 != @10@ then endi print execute sql select char_length(c15) from (select * from stb1); sql select char_length(c15) from (select * from stb1); -if $data00 != @0@ then +if $data00 != @1@ then return -1 endi if $data10 != @NULL@ then @@ -1033,25 +1033,25 @@ endi if $data20 != @NULL@ then return -1 endi -if $data30 != @0@ then +if $data30 != @1@ then return -1 endi -if $data40 != @0@ then +if $data40 != @1@ then return -1 endi -if $data50 != @0@ then +if $data50 != @3@ then return -1 endi if $data60 != @0@ then return -1 endi -if $data70 != @0@ then +if $data70 != @1@ then return -1 endi -if $data80 != @0@ then +if $data80 != @1@ then return -1 endi -if $data90 != @0@ then +if $data90 != @1@ then return -1 endi print execute sql select char_length(cast(a as binary(10))) from (select avg(c2) as a from stb1 where ts >= '2021-11-11 09:00:00.000' and ts <= '2021-11-11 09:00:09.000' interval(1s) fill(null)); diff --git a/tests/script/general/parser/groupby.sim b/tests/script/general/parser/groupby.sim index 9baf028bc8233c0fd6c3ada9392bca717270b3be..cbebfaae8eafaaff32f8840031ae2e01bf764782 100644 --- a/tests/script/general/parser/groupby.sim +++ b/tests/script/general/parser/groupby.sim @@ -783,13 +783,13 @@ if $data11 != 2 then return -1 endi -sql_error select count(*) from m1 group by tbname,k,f1; -sql_error select count(*) from m1 group by tbname,k,a; -sql_error select count(*) from m1 group by k, tbname; -sql_error select count(*) from m1 group by k,f1; +#sql_error select count(*) from m1 group by tbname,k,f1; +#sql_error select count(*) from m1 group by tbname,k,a; +#sql_error select count(*) from m1 group by k, tbname; +#sql_error select count(*) from m1 group by k,f1; sql_error select count(*) from tm0 group by tbname; sql_error select count(*) from tm0 group by a; -sql_error select count(*) from tm0 group by k,f1; +#sql_error select count(*) from tm0 group by k,f1; sql_error select count(*),f1 from m1 group by tbname,k; diff --git a/tests/system-test/5-taos-tools/basic.py b/tests/system-test/5-taos-tools/basic.py index a05cf39001e600085b654d20e0180351cc94f195..f2f273b9a78745d027d59c4a9a10246516f4d342 100644 --- a/tests/system-test/5-taos-tools/basic.py +++ b/tests/system-test/5-taos-tools/basic.py @@ -23,33 +23,34 @@ import subprocess class TDTestCase: def caseDescription(self): ''' - case1: [TD-11977] start taosdump without taosd + case1: [TD-11977] start taosdump without taosd case1: [TD-11977] start taosBenchmark without taosd case1: [TD-11977] start taosAdaptor without taosd - ''' + ''' return - + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) def run(self): - tdSql.prepare() - - tools = ["taosdump", "taosBenchmark", "taosAdaptor"] + tdSql.prepare() + + tools = ["taosdump", "taosBenchmark", "taosadapter"] tdDnodes.stop(1) - for tool in tools: - path = tdDnodes.dnodes[1].getBuildPath(tool) + for tool in tools: + path = tdDnodes.dnodes[1].getPath(tool) try: - path += "/build/bin/" print(f"{path}{tool}") if tool == "taosBenchmark": - os.system(f"{path}{tool} -y") + os.system(f"{path}{tool} -y") + elif tool == "taosadapter": + os.system(f"pkill -9 {tool}") else: os.system(f"{path}{tool}") - except: + except BaseException: pass def stop(self): diff --git a/tests/system-test/abnormal/Always_alter_schema.py b/tests/system-test/abnormal/Always_alter_schema.py deleted file mode 100644 index 175204a791b0504fa7db3f47c15ade77a113e9ae..0000000000000000000000000000000000000000 --- a/tests/system-test/abnormal/Always_alter_schema.py +++ /dev/null @@ -1,162 +0,0 @@ -################################################################### -# Copyright (c) 2020 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -from http import client -import taos -import time - -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * -import random - -class TDTestCase: - def __init__(self): - self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record - self.num = 10 - self.Loop = 10 - self.loop_alter = 100 - - def caseDescription(self): - - ''' - case1 : this is an abnormal case for always change schema - ''' - return - - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - - def run(self): - - # Loop - tdSql.execute("drop database if exists testdb") - tdSql.execute("create database testdb") - tdSql.execute("use testdb") - tdSql.execute("create stable testdb.st (ts timestamp , value int) tags (ind int)") - tdSql.query("describe testdb.st") - - # insert data - for cur in range(self.num): - tdSql.execute("insert into tb_%d using st tags(%d) values(%d, %d)"%(cur,cur, self.ts+1000*cur,cur)) - tdSql.execute("insert into tb_set using st tags(%d) values(%d, %d)"%(cur,self.ts+1000*cur,cur)) - - client_0 = taos.connect().cursor() # global conn - - client_1 = taos.connect().cursor() - client_2 = taos.connect().cursor() - - add_tag_list = [] - for i in range(self.loop_alter): - sql= "alter stable testdb.st add tag new_tag%d int"%i - add_tag_list.append(sql) - - change_tag_list = [] - for i in range(self.loop_alter+1): - sql = " alter stable testdb.st change tag new_tag%d new_tag_%d"%(i,i) - change_tag_list.append(sql) - - set_tag_list = [] - for i in range(self.loop_alter): - sql = "alter table testdb.tb_set set tag new_tag_%d=%d"%(i,i*10) - set_tag_list.append(sql) - - drop_tag_list = [] - for i in range(self.loop_alter): - sql = "alter stable testdb.st drop tag new_tag_%d"%(i) - drop_tag_list.append(sql) - - for i in range(self.loop_alter): - add_sql = add_tag_list[i] - change_sql = change_tag_list[i] - set_sql = set_tag_list[i] - drop_sql = drop_tag_list[i] - - execute_list= [add_sql,change_sql,set_sql,drop_sql] - - for ind,sql in enumerate(execute_list): - if sql ==drop_sql: - if i%5 !=0: - continue - else: - pass - - if ind%3==0: - # client_0.execute("reset query cache") - client_0.execute(sql) - print(" client_0 runing sqls : %s" %sql ) - elif ind%3==1: - # client_1.execute("reset query cache") - client_1.execute(sql) - print(" client_1 runing sqls : %s" %sql ) - elif ind%3==2: - # client_2.execute("reset query cache") - client_2.execute(sql) - print(" client_2 runing sqls : %s" %sql ) - else: - client_0.execute(sql) - print(" client_0 runing sqls : %s" %sql ) - - query_sqls = ["select count(*) from testdb.st group by ind", - "describe testdb.st", - "select count(*) from testdb.st group by tbname"] - reset_sql = "reset query cache" - - if i%10 ==0: - tdSql.execute(reset_sql) - client_0.execute(reset_sql) - client_1.execute(reset_sql) - client_2.execute(reset_sql) - - for sql in query_sqls: - if sql =="describe testdb.st": - print("==========================\n") - print("==========describe=======\n") - print("==========================\n") - client_0.execute(sql) - res = client_0.fetchall() - print("client 0 res :", res) if res else print("empty") - - client_1.execute(sql) - res = client_0.fetchall() - print("client 1 res :", res) if res else print("empty") - - client_2.execute(sql) - res = client_2.fetchall() - print("client 2 res :", res) if res else print("empty") - else: - client_0.execute(sql) - client_1.execute(sql) - client_2.execute(sql) - - tdLog.notice("===== this is the %d_th loop alter tags is going now ===="%i ) - - - - - - client_1.close() - client_2.close() - - client_0.close() - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/abnormal/Loop_restart_and_kill.py b/tests/system-test/abnormal/Loop_restart_and_kill.py deleted file mode 100644 index 8ac1f7c8f1f7e7b8bb15ffb7549370ec61438165..0000000000000000000000000000000000000000 --- a/tests/system-test/abnormal/Loop_restart_and_kill.py +++ /dev/null @@ -1,89 +0,0 @@ -################################################################### -# Copyright (c) 2020 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- -import taos -import time - -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def __init__(self): - self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record - self.num = 10 - self.Loop = 100 - - def caseDescription(self): - - ''' - case1 : this is an abnormal case for loop restart taosd - and basic this query ,it will run 4 client to change schema ,run always ; - ''' - return - - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def basic_insert(self): - tdSql.execute("create database if not exists testdb") - tdSql.execute("use testdb") - tdSql.execute("create stable st (ts timestamp , value int) tags (ind int)") - for i in range(self.num): - tdSql.execute("insert into sub_%s using st tags(%d) values (%d , %d );"%(str(i),i,self.ts+10000*i,i)) - - def basic_query(self): - for i in range(self.num): - tdSql.query("select count(*) from testdb.sub_%s"%str(i)) - tdSql.checkData(0,0,1) - tdSql.query("select count(*) from testdb.st") - tdSql.checkRows(1) - - - def run(self): - - # Loop - - for loop_step in range(self.Loop): - - # run basic query and insert - # kill all - os.system("ps -aux |grep 'taosd' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") - tdDnodes.start(1) - if loop_step ==0: - self.basic_insert() - else: - tdSql.execute("insert into sub_10 using st tags(10) values(now ,10)") - - # another client - os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"') - os.system('taos -s "select count(*) from testdb.sub_100;"') - - self.basic_query() - sleep(2) - tdDnodes.stopAll() - - - tdLog.info(" this is the %s_th loop restart taosd going " % loop_step) - - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/abnormal/Loop_restart_database_alter.py b/tests/system-test/abnormal/Loop_restart_database_alter.py deleted file mode 100644 index d2721fa15d3f309bc91d764356e3f1fb3b1d354a..0000000000000000000000000000000000000000 --- a/tests/system-test/abnormal/Loop_restart_database_alter.py +++ /dev/null @@ -1,160 +0,0 @@ -################################################################### -# Copyright (c) 2020 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -from http import client -import taos -import time - -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * -import random - -class TDTestCase: - def __init__(self): - self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record - self.num = 10 - self.Loop = 100 - global client - - def caseDescription(self): - - ''' - case1 : this is an abnormal case for loop restart taosd - between restart taosd ,there is an query and is insert is going on - ''' - return - - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - - def run(self): - - # Loop - tdSql.execute("drop database if exists testdb") - client = taos.connect().cursor() # global conn - - # tdSql.execute("create database testdb") - # tdSql.execute("create stable testdb.st (ts timestamp , value int) tags (ind int)") - # tdSql.query("describe testdb.st") - # result = tdSql.getResult("describe testdb.st") - # print(result) - # tdSql.execute("alter stable testdb.st add tag new_tags int") - # result = tdSql.getResult("describe testdb.st") - # print(result) - # tdSql.execute("alter stable testdb.st change tag new_tags alter_tag") - # result = tdSql.getResult("describe testdb.st") - # print(result) - - - for loop_step in range(self.Loop): - - # run basic query and insert - # kill all - os.system("ps -aux |grep 'taosd' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") - tdDnodes.start(1) - - tdSql.execute("create database if not exists testdb") - tdSql.execute("use testdb") - - if loop_step <1: - tdSql.execute("create stable st (ts timestamp , value int) tags (ind int)") - - tdSql.execute("create stable st%d (ts timestamp , value int) tags (ind int)"%loop_step) - for cur in range(self.num): - tdSql.execute("insert into tb_%d using st%d tags(%d) values(now, %d)"%(loop_step,loop_step,loop_step, cur)) - - os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"') - os.system('taos -s "select count(*) from testdb.sub_100;"') - os.system('taos -s "describe testdb.sub_100;"') - os.system('show databases\G') - # another client - client_1 = taos.connect().cursor() - client_2 = taos.connect().cursor() - - alter_dict = {"days" : int(random.randint(1,5)) , - "keep":int(random.randint(10,20)) , - "precision":"ns", - "blocks" : int(random.randint(1,6)*2), - "quorum": int(random.randint(0,3)), - "comp":int(random.randint(0,3)), - "minrows":int(random.randint(1,3)*100), - "replica":int(random.randint(1,3)) - } - alter_list = ['days', 'keep', 'precision', 'blocks', 'quorum', 'comp', 'minrows', 'replica'] - random_key = random.sample(alter_list, 1)[0] - - sql = "alter database {} {} {}".format("testdb", random_key, alter_dict[random_key]) - - for alter_db in range(100): - alter_list = ['days', 'keep', 'precision', 'blocks', 'quorum', 'comp', 'minrows', 'replica'] - random_key = random.sample(alter_list, 1)[0] - sql = "alter database {} {} {}".format("testdb", random_key, alter_dict[random_key]) - - if alter_db%3==0: - # client_0.execute("reset query cache") - try: - client.execute(sql) - client.fetchall() - os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"') - except : - pass - print(" client runing sqls : %s" %sql ) - elif alter_db%3==1: - # client_1.execute("reset query cache") - try: - client_1.execute(sql) - client_1.fetchall() - os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"') - except : - pass - print(" client_1 runing sqls : %s" %sql ) - elif alter_db%3==2: - try: - # client_2.execute("reset query cache") - client_2.execute(sql) - client_2.fetchall() - os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"') - except: - pass - print(" client_2 runing sqls : %s" %sql ) - else: - try: - client.execute(sql) - client.fetchall() - os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"') - except: - pass - print(" client runing sqls : %s" %sql ) - os.system("taos -s 'show databases;'") - - sleep(2) - tdDnodes.stopAll() - - tdLog.notice(" this is the %s_th loop restart taosd going " % loop_step) - - client_1.close() - client_2.close() - - client.close() - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/abnormal/Loop_restart_schema_alter.py b/tests/system-test/abnormal/Loop_restart_schema_alter.py deleted file mode 100644 index 63b4b645af4b73ab7056a07b4566ccdc682f986f..0000000000000000000000000000000000000000 --- a/tests/system-test/abnormal/Loop_restart_schema_alter.py +++ /dev/null @@ -1,139 +0,0 @@ -################################################################### -# Copyright (c) 2020 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -from http import client -import taos -import time - -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * -import random - -class TDTestCase: - def __init__(self): - self.ts = 1420041600000 # 2015-01-01 00:00:00 this is begin time for first record - self.num = 10 - self.Loop = 100 - global client - - def caseDescription(self): - - ''' - case1 : this is an abnormal case for loop restart taosd - between restart taosd ,there is an query and is insert is going on - ''' - return - - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - - def run(self): - - # Loop - tdSql.execute("drop database if exists testdb") - client = taos.connect().cursor() # global conn - - # tdSql.execute("create database testdb") - # tdSql.execute("create stable testdb.st (ts timestamp , value int) tags (ind int)") - # tdSql.query("describe testdb.st") - # result = tdSql.getResult("describe testdb.st") - # print(result) - # tdSql.execute("alter stable testdb.st add tag new_tags int") - # result = tdSql.getResult("describe testdb.st") - # print(result) - # tdSql.execute("alter stable testdb.st change tag new_tags alter_tag") - # result = tdSql.getResult("describe testdb.st") - # print(result) - - - for loop_step in range(self.Loop): - - # run basic query and insert - # kill all - os.system("ps -aux |grep 'taosd' |awk '{print $2}'|xargs kill -9 >/dev/null 2>&1") - tdDnodes.start(1) - - tdSql.execute("create database if not exists testdb") - tdSql.execute("use testdb") - - if loop_step <1: - tdSql.execute("create stable st (ts timestamp , value int) tags (ind int)") - - tdSql.execute("create stable st%d (ts timestamp , value int) tags (ind int)"%loop_step) - for cur in range(self.num): - tdSql.execute("insert into tb_%d using st%d tags(%d) values(%d, %d)"%(loop_step,loop_step,loop_step, self.ts+1000*cur,cur)) - - os.system('taos -s "insert into testdb.sub_100 using testdb.st tags(100) values(now ,100);"') - os.system('taos -s "select count(*) from testdb.sub_100;"') - os.system('taos -s "describe testdb.sub_100;"') - # another client - client_1 = taos.connect().cursor() - client_2 = taos.connect().cursor() - - alter_tag = [ - " alter stable testdb.st%d add tag new_tags int "%loop_step, - " alter stable testdb.st%d change tag new_tags alter_tag"%loop_step, - " alter stable testdb.st%d drop tag alter_tag"%loop_step, - "ALTER TABLE testdb.sub_100 SET TAG ind=%d"%(loop_step*10) - ] - print(alter_tag[0]) - client_1.execute(alter_tag[0]) - os.system('taos -s "%s; describe testdb.sub_100;select ind from testdb.sub_100;"'% alter_tag[3] ) - - # clinet1 - os.system('taos -s "%s; describe testdb.sub_100;select ind from testdb.sub_100;"'% alter_tag[3] ) - # client_1.execute("reset query cache;") - client_1.execute(" describe testdb.st%d"%loop_step) - res = client_1.fetchall() - - # clinet2 - os.system('taos -s "%s; describe testdb.sub_100;select ind from testdb.sub_100;"'% alter_tag[3] ) - - print(alter_tag[1]) - client_2.execute(alter_tag[1]) - # client_2.execute("reset query cache") - client_2.execute("describe testdb.st%d"%loop_step) - res = client_2.fetchall() - - client_2.execute("select * from testdb.st%d"%loop_step) - res = client_2.fetchall() - - client.execute("show databases;") - # client.execute("reset query cache") - client.execute("describe testdb.st%d"%loop_step) - print(alter_tag[2]) - client.execute(alter_tag[2]) - res = client.fetchall_row() - - - sleep(2) - tdDnodes.stopAll() - - tdLog.notice(" this is the %s_th loop restart taosd going " % loop_step) - - client_1.close() - client_2.close() - - client.close() - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase())