Skip to content

Commit 1305924

Browse files
authored
ci: add sqlness job (#835)
* ci: add sqlness job Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * update sqlness to official release Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * filter out backtrace Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix error display Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * close once_cell feature gate Signed-off-by: Ruihang Xia <waynestxia@gmail.com> Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
1 parent ea753b9 commit 1305924

File tree

7 files changed

+77
-50
lines changed

7 files changed

+77
-50
lines changed

.github/workflows/develop.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@ jobs:
110110
# GT_S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
111111
# UNITTEST_LOG_DIR: "__unittest_logs"
112112

113+
sqlness:
114+
name: Sqlness Test
115+
if: github.event.pull_request.draft == false
116+
runs-on: ubuntu-latest-8-cores
117+
timeout-minutes: 60
118+
steps:
119+
- uses: actions/checkout@v3
120+
- uses: arduino/setup-protoc@v1
121+
with:
122+
repo-token: ${{ secrets.GITHUB_TOKEN }}
123+
- uses: dtolnay/rust-toolchain@master
124+
with:
125+
toolchain: ${{ env.RUST_TOOLCHAIN }}
126+
- name: Rust Cache
127+
uses: Swatinem/rust-cache@v2
128+
- name: Run sqlness
129+
run: cargo run --bin sqlness-runner
130+
113131
fmt:
114132
name: Rustfmt
115133
if: github.event.pull_request.draft == false

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/sql/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ pub enum Error {
7979
backtrace: Backtrace,
8080
},
8181

82-
#[snafu(display("Failed to parse value: {}, {}", msg, backtrace))]
82+
#[snafu(display("Failed to parse value: {}", msg))]
8383
ParseSqlValue { msg: String, backtrace: Backtrace },
8484

8585
#[snafu(display(
8686
"Column {} expect type: {:?}, actual: {:?}",
8787
column_name,
8888
expect,
89-
actual
89+
actual,
9090
))]
9191
ColumnTypeMismatch {
9292
column_name: String,

tests/cases/standalone/basic.result

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,52 @@ CREATE TABLE system_metrics (
99
TIME INDEX(ts)
1010
);
1111

12+
Affected Rows: 0
13+
1214
INSERT INTO system_metrics
1315
VALUES
1416
("host1", "idc_a", 11.8, 10.3, 10.3, 1667446797450),
1517
("host2", "idc_a", 80.1, 70.3, 90.0, 1667446797450),
1618
("host1", "idc_b", 50.0, 66.7, 40.6, 1667446797450);
1719

20+
Affected Rows: 3
21+
1822
SELECT * FROM system_metrics;
1923

20-
+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+
21-
| host, #Field, #String | idc, #Field, #String | cpu_util, #Field, #Float64 | memory_util, #Field, #Float64 | disk_util, #Field, #Float64 | ts, #Timestamp, #Timestamp |
22-
+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+
23-
| host1 | idc_a | 11.8 | 10.3 | 10.3 | 1667446797450 |
24-
| host1 | idc_b | 50 | 66.7 | 40.6 | 1667446797450 |
25-
| host2 | idc_a | 80.1 | 70.3 | 90 | 1667446797450 |
26-
+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+
24+
+-------+-------+----------+-------------+-----------+-------------------------+
25+
| host | idc | cpu_util | memory_util | disk_util | ts |
26+
+-------+-------+----------+-------------+-----------+-------------------------+
27+
| host1 | idc_a | 11.8 | 10.3 | 10.3 | 2022-11-03T03:39:57.450 |
28+
| host1 | idc_b | 50 | 66.7 | 40.6 | 2022-11-03T03:39:57.450 |
29+
| host2 | idc_a | 80.1 | 70.3 | 90 | 2022-11-03T03:39:57.450 |
30+
+-------+-------+----------+-------------+-----------+-------------------------+
2731

2832
SELECT count(*) FROM system_metrics;
2933

30-
+----------------------------------+
31-
| COUNT(UInt8(1)), #Field, #Uint64 |
32-
+----------------------------------+
33-
| 3 |
34-
+----------------------------------+
34+
+-----------------+
35+
| COUNT(UInt8(1)) |
36+
+-----------------+
37+
| 3 |
38+
+-----------------+
3539

3640
SELECT avg(cpu_util) FROM system_metrics;
3741

38-
+------------------------------------------------+
39-
| AVG(system_metrics.cpu_util), #Field, #Float64 |
40-
+------------------------------------------------+
41-
| 47.29999999999999 |
42-
+------------------------------------------------+
42+
+------------------------------+
43+
| AVG(system_metrics.cpu_util) |
44+
+------------------------------+
45+
| 47.29999999999999 |
46+
+------------------------------+
4347

4448
SELECT idc, avg(memory_util) FROM system_metrics GROUP BY idc ORDER BY idc;
4549

46-
+----------------------+---------------------------------------------------+
47-
| idc, #Field, #String | AVG(system_metrics.memory_util), #Field, #Float64 |
48-
+----------------------+---------------------------------------------------+
49-
| idc_a | 40.3 |
50-
| idc_b | 66.7 |
51-
+----------------------+---------------------------------------------------+
50+
+-------+---------------------------------+
51+
| idc | AVG(system_metrics.memory_util) |
52+
+-------+---------------------------------+
53+
| idc_a | 40.3 |
54+
| idc_b | 66.7 |
55+
+-------+---------------------------------+
5256

5357
DROP TABLE system_metrics;
58+
59+
Affected Rows: 1
60+
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
select 1;
22

3-
+--------------------------+
4-
| Int64(1), #Field, #Int64 |
5-
+--------------------------+
6-
| 1 |
7-
+--------------------------+
3+
+----------+
4+
| Int64(1) |
5+
+----------+
6+
| 1 |
7+
+----------+
88

99
select 2 + 3;
1010

11-
+----------------------------------------+
12-
| Int64(2) Plus Int64(3), #Field, #Int64 |
13-
+----------------------------------------+
14-
| 5 |
15-
+----------------------------------------+
11+
+---------------------+
12+
| Int64(2) + Int64(3) |
13+
+---------------------+
14+
| 5 |
15+
+---------------------+
1616

1717
select 4 + 0.5;
1818

19-
+----------------------------------------------+
20-
| Int64(4) Plus Float64(0.5), #Field, #Float64 |
21-
+----------------------------------------------+
22-
| 4.5 |
23-
+----------------------------------------------+
19+
+-------------------------+
20+
| Int64(4) + Float64(0.5) |
21+
+-------------------------+
22+
| 4.5 |
23+
+-------------------------+
2424

2525
select "a";
2626

27-
Failed to execute, error: Datanode { code: 1003, msg: "Failed to execute query: select \"a\";, source: Failed to select from table, source: Error occurred on the data node, code: 3000, msg: Failed to execute sql, source: Cannot plan SQL: SELECT \"a\", source: Error during planning: Invalid identifier '#a' for schema fields:[], metadata:{}" }
27+
Failed to do Flight get, addr: 127.0.0.1:4001, code: 3000, err_msg: Failed to execute sql statement, source: Failed to execute sql, source: Failure during query planning, source: Cannot plan SQL: SELECT "a", source: Schema error: No field named 'a'. Valid fields are .
2828

2929
select "A";
3030

31-
Failed to execute, error: Datanode { code: 1003, msg: "Failed to execute query: select \"A\";, source: Failed to select from table, source: Error occurred on the data node, code: 3000, msg: Failed to execute sql, source: Cannot plan SQL: SELECT \"A\", source: Error during planning: Invalid identifier '#A' for schema fields:[], metadata:{}" }
31+
Failed to do Flight get, addr: 127.0.0.1:4001, code: 3000, err_msg: Failed to execute sql statement, source: Failed to execute sql, source: Failure during query planning, source: Cannot plan SQL: SELECT "A", source: Schema error: No field named 'A'. Valid fields are .
3232

3333
select * where "a" = "A";
3434

35-
Failed to execute, error: Datanode { code: 1003, msg: "Failed to execute query: select * where \"a\" = \"A\";, source: Failed to select from table, source: Error occurred on the data node, code: 3000, msg: Failed to execute sql, source: Cannot plan SQL: SELECT * WHERE \"a\" = \"A\", source: Error during planning: Invalid identifier '#a' for schema fields:[], metadata:{}" }
35+
Failed to do Flight get, addr: 127.0.0.1:4001, code: 3000, err_msg: Failed to execute sql statement, source: Failed to execute sql, source: Failure during query planning, source: Cannot plan SQL: SELECT * WHERE "a" = "A", source: Schema error: No field named 'a'. Valid fields are .
3636

tests/runner/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ client = { path = "../../src/client" }
1010
common-base = { path = "../../src/common/base" }
1111
common-grpc = { path = "../../src/common/grpc" }
1212
common-query = { path = "../../src/common/query" }
13-
sqlness = { git = "https://github.com/ceresdb/sqlness.git" }
13+
sqlness = "0.1"
1414
tokio.workspace = true

tests/runner/src/env.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414

1515
use std::fmt::Display;
1616
use std::fs::OpenOptions;
17+
use std::path::Path;
1718
use std::process::Stdio;
1819
use std::time::Duration;
1920

2021
use async_trait::async_trait;
2122
use client::{Client, Database as DB, Error as ClientError};
2223
use common_query::Output;
23-
use sqlness::{Database, Environment};
24+
use sqlness::{Database, EnvController};
2425
use tokio::process::{Child, Command};
2526

2627
use crate::util;
@@ -31,10 +32,10 @@ const SERVER_LOG_FILE: &str = "/tmp/greptime-sqlness.log";
3132
pub struct Env {}
3233

3334
#[async_trait]
34-
impl Environment for Env {
35+
impl EnvController for Env {
3536
type DB = GreptimeDB;
3637

37-
async fn start(&self, mode: &str, _config: Option<String>) -> Self::DB {
38+
async fn start(&self, mode: &str, _config: Option<&Path>) -> Self::DB {
3839
match mode {
3940
"standalone" => Self::start_standalone().await,
4041
"distributed" => Self::start_distributed().await,
@@ -139,7 +140,7 @@ impl Display for ResultDisplayer {
139140
}
140141
Output::Stream(_) => unreachable!(),
141142
},
142-
Err(e) => write!(f, "Failed to execute, error: {e:?}"),
143+
Err(e) => write!(f, "{e}"),
143144
}
144145
}
145146
}

0 commit comments

Comments
 (0)