Skip to content

Commit

Permalink
test: add test case upgraded arrow&datafusion (#272)
Browse files Browse the repository at this point in the history
* test: add test case for issue #253

* chore: ignore `.out` file in gitignore

* chore: fix typo

Co-authored-by: WEI Xikai <ShiKaiWi@users.noreply.github.com>
  • Loading branch information
chunshao90 and ShiKaiWi committed Oct 8, 2022
1 parent 3dc1e62 commit ff99ab3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target
.DS_Store
.idea/
.vscode
*.out
48 changes: 27 additions & 21 deletions tests/cases/local/02_function/aggregate.result
Original file line number Diff line number Diff line change
@@ -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

39 changes: 21 additions & 18 deletions tests/cases/local/02_function/aggregate.sql
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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`;

0 comments on commit ff99ab3

Please sign in to comment.