From 55455870f2cb0c402ce049251e284d7f6ec295c7 Mon Sep 17 00:00:00 2001 From: "chunshao.rcs" Date: Sat, 8 Oct 2022 15:20:07 +0800 Subject: [PATCH] test: add test case upgraded arrow&datafusion (#272) * test: add test case for issue https://github.com/CeresDB/ceresdb/issues/253 * chore: ignore `.out` file in gitignore * chore: fix typo Co-authored-by: WEI Xikai --- .gitignore | 1 + .../cases/local/02_function/aggregate.result | 48 +++++++++++-------- tests/cases/local/02_function/aggregate.sql | 39 ++++++++------- 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index 7f220c5e8a..76fc8a70a1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target .DS_Store .idea/ .vscode +*.out \ No newline at end of file diff --git a/tests/cases/local/02_function/aggregate.result b/tests/cases/local/02_function/aggregate.result index 4b50befb23..7f93222f0b 100644 --- a/tests/cases/local/02_function/aggregate.result +++ b/tests/cases/local/02_function/aggregate.result @@ -1,69 +1,75 @@ -DROP TABLE IF EXISTS `02_function_aggretate_table1`; +DROP TABLE IF EXISTS `02_function_aggregate_table1`; affected_rows: 0 -CREATE TABLE `02_function_aggretate_table1` ( `timestamp` timestamp NOT NULL, `arch` string TAG, `datacenter` string TAG, `value` int, timestamp KEY (timestamp)) ENGINE=AnalyticWITH( enable_ttl='false'); +CREATE TABLE `02_function_aggregate_table1` ( `timestamp` timestamp NOT NULL, `arch` string TAG, `datacenter` string TAG, `value` int, `uvalue` uint64, timestamp KEY (timestamp)) ENGINE=AnalyticWITH( enable_ttl='false'); affected_rows: 0 -INSERT INTO `02_function_aggretate_table1` (`timestamp`, `arch`, `datacenter`, `value`)VALUES (1658304762, 'x86-64', 'china', 100), (1658304763, 'x86-64', 'china', 200), (1658304762, 'arm64', 'china', 110), (1658304763, 'arm64', 'china', 210); +INSERT INTO `02_function_aggregate_table1` (`timestamp`, `arch`, `datacenter`, `value`, `uvalue`)VALUES (1658304762, 'x86-64', 'china', 100, 10), (1658304763, 'x86-64', 'china', 200, 10), (1658304762, 'arm64', 'china', 110, 0), (1658304763, 'arm64', 'china', 210, 0); affected_rows: 4 -SELECT sum(`value`) FROM `02_function_aggretate_table1`; +SELECT sum(`value`) FROM `02_function_aggregate_table1`; -SUM(02_function_aggretate_table1.value), +SUM(02_function_aggregate_table1.value), Int64(620), -SELECT `arch`, sum(`value`)FROM `02_function_aggretate_table1`WHERE `timestamp` BETWEEN 1658304763 AND 1658304763GROUP BY `arch`ORDER BY `arch` DESC; +SELECT `arch`, sum(`value`)FROM `02_function_aggregate_table1`WHERE `timestamp` BETWEEN 1658304763 AND 1658304763GROUP BY `arch`ORDER BY `arch` DESC; -arch,SUM(02_function_aggretate_table1.value), +arch,SUM(02_function_aggregate_table1.value), String(StringBytes(b"x86-64")),Int64(200), String(StringBytes(b"arm64")),Int64(210), -SELECT count(`value`) FROM `02_function_aggretate_table1`; +SELECT count(`value`) FROM `02_function_aggregate_table1`; -COUNT(02_function_aggretate_table1.value), +COUNT(02_function_aggregate_table1.value), Int64(4), -SELECT avg(`value`) FROM `02_function_aggretate_table1`; +SELECT avg(`value`) FROM `02_function_aggregate_table1`; -AVG(02_function_aggretate_table1.value), +AVG(02_function_aggregate_table1.value), Double(155.0), -SELECT max(`value`) FROM `02_function_aggretate_table1`; +SELECT max(`value`) FROM `02_function_aggregate_table1`; -MAX(02_function_aggretate_table1.value), +MAX(02_function_aggregate_table1.value), Int32(210), -SELECT min(`value`) FROM `02_function_aggretate_table1`; +SELECT min(`value`) FROM `02_function_aggregate_table1`; -MIN(02_function_aggretate_table1.value), +MIN(02_function_aggregate_table1.value), Int32(100), -INSERT INTO `02_function_aggretate_table1` (`timestamp`, `arch`, `datacenter`, `value`)VALUES (1658304762, 'x86-64', 'china', 100); +SELECT min(`uvalue`) - max(`uvalue`) FROM `02_function_aggregate_table1`; + +MIN(02_function_aggregate_table1.uvalue) - MAX(02_function_aggregate_table1.uvalue), +Int64(-10), + + +INSERT INTO `02_function_aggregate_table1` (`timestamp`, `arch`, `datacenter`, `value`)VALUES (1658304762, 'x86-64', 'china', 100); affected_rows: 1 -SELECT count(`arch`) FROM `02_function_aggretate_table1`; +SELECT count(`arch`) FROM `02_function_aggregate_table1`; -COUNT(02_function_aggretate_table1.arch), +COUNT(02_function_aggregate_table1.arch), Int64(4), -SELECT count(distinct(`arch`)) FROM `02_function_aggretate_table1`; +SELECT count(distinct(`arch`)) FROM `02_function_aggregate_table1`; -COUNT(DISTINCT 02_function_aggretate_table1.arch), +COUNT(DISTINCT 02_function_aggregate_table1.arch), Int64(2), -DROP TABLE `02_function_aggretate_table1`; +DROP TABLE `02_function_aggregate_table1`; affected_rows: 0 diff --git a/tests/cases/local/02_function/aggregate.sql b/tests/cases/local/02_function/aggregate.sql index dedd2b90db..d913910cbb 100644 --- a/tests/cases/local/02_function/aggregate.sql +++ b/tests/cases/local/02_function/aggregate.sql @@ -1,31 +1,32 @@ -DROP TABLE IF EXISTS `02_function_aggretate_table1`; +DROP TABLE IF EXISTS `02_function_aggregate_table1`; -CREATE TABLE `02_function_aggretate_table1` ( +CREATE TABLE `02_function_aggregate_table1` ( `timestamp` timestamp NOT NULL, `arch` string TAG, `datacenter` string TAG, `value` int, + `uvalue` uint64, timestamp KEY (timestamp)) ENGINE=Analytic WITH( enable_ttl='false' ); -INSERT INTO `02_function_aggretate_table1` - (`timestamp`, `arch`, `datacenter`, `value`) +INSERT INTO `02_function_aggregate_table1` + (`timestamp`, `arch`, `datacenter`, `value`, `uvalue`) VALUES - (1658304762, 'x86-64', 'china', 100), - (1658304763, 'x86-64', 'china', 200), - (1658304762, 'arm64', 'china', 110), - (1658304763, 'arm64', 'china', 210); + (1658304762, 'x86-64', 'china', 100, 10), + (1658304763, 'x86-64', 'china', 200, 10), + (1658304762, 'arm64', 'china', 110, 0), + (1658304763, 'arm64', 'china', 210, 0); -SELECT sum(`value`) FROM `02_function_aggretate_table1`; +SELECT sum(`value`) FROM `02_function_aggregate_table1`; SELECT `arch`, sum(`value`) FROM - `02_function_aggretate_table1` + `02_function_aggregate_table1` WHERE `timestamp` BETWEEN 1658304763 AND 1658304763 GROUP BY @@ -34,22 +35,24 @@ ORDER BY `arch` DESC; -SELECT count(`value`) FROM `02_function_aggretate_table1`; +SELECT count(`value`) FROM `02_function_aggregate_table1`; + +SELECT avg(`value`) FROM `02_function_aggregate_table1`; -SELECT avg(`value`) FROM `02_function_aggretate_table1`; +SELECT max(`value`) FROM `02_function_aggregate_table1`; -SELECT max(`value`) FROM `02_function_aggretate_table1`; +SELECT min(`value`) FROM `02_function_aggregate_table1`; -SELECT min(`value`) FROM `02_function_aggretate_table1`; +SELECT min(`uvalue`) - max(`uvalue`) FROM `02_function_aggregate_table1`; -- duplicate with last insert -INSERT INTO `02_function_aggretate_table1` +INSERT INTO `02_function_aggregate_table1` (`timestamp`, `arch`, `datacenter`, `value`) VALUES (1658304762, 'x86-64', 'china', 100); -SELECT count(`arch`) FROM `02_function_aggretate_table1`; +SELECT count(`arch`) FROM `02_function_aggregate_table1`; -SELECT count(distinct(`arch`)) FROM `02_function_aggretate_table1`; +SELECT count(distinct(`arch`)) FROM `02_function_aggregate_table1`; -DROP TABLE `02_function_aggretate_table1`; +DROP TABLE `02_function_aggregate_table1`;