Skip to content

Commit

Permalink
ci: add sqlness job (#835)
Browse files Browse the repository at this point in the history
* ci: add sqlness job

Signed-off-by: Ruihang Xia <[email protected]>

* update sqlness to official release

Signed-off-by: Ruihang Xia <[email protected]>

* filter out backtrace

Signed-off-by: Ruihang Xia <[email protected]>

* fix error display

Signed-off-by: Ruihang Xia <[email protected]>

* close once_cell feature gate

Signed-off-by: Ruihang Xia <[email protected]>

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Jan 10, 2023
1 parent ea753b9 commit 1305924
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 50 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@ jobs:
# GT_S3_ACCESS_KEY: ${{ secrets.S3_ACCESS_KEY }}
# UNITTEST_LOG_DIR: "__unittest_logs"

sqlness:
name: Sqlness Test
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest-8-cores
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Run sqlness
run: cargo run --bin sqlness-runner

fmt:
name: Rustfmt
if: github.event.pull_request.draft == false
Expand Down
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/sql/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ pub enum Error {
backtrace: Backtrace,
},

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

#[snafu(display(
"Column {} expect type: {:?}, actual: {:?}",
column_name,
expect,
actual
actual,
))]
ColumnTypeMismatch {
column_name: String,
Expand Down
53 changes: 30 additions & 23 deletions tests/cases/standalone/basic.result
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,52 @@ CREATE TABLE system_metrics (
TIME INDEX(ts)
);

Affected Rows: 0

INSERT INTO system_metrics
VALUES
("host1", "idc_a", 11.8, 10.3, 10.3, 1667446797450),
("host2", "idc_a", 80.1, 70.3, 90.0, 1667446797450),
("host1", "idc_b", 50.0, 66.7, 40.6, 1667446797450);

Affected Rows: 3

SELECT * FROM system_metrics;

+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+
| host, #Field, #String | idc, #Field, #String | cpu_util, #Field, #Float64 | memory_util, #Field, #Float64 | disk_util, #Field, #Float64 | ts, #Timestamp, #Timestamp |
+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+
| host1 | idc_a | 11.8 | 10.3 | 10.3 | 1667446797450 |
| host1 | idc_b | 50 | 66.7 | 40.6 | 1667446797450 |
| host2 | idc_a | 80.1 | 70.3 | 90 | 1667446797450 |
+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+
+-------+-------+----------+-------------+-----------+-------------------------+
| host | idc | cpu_util | memory_util | disk_util | ts |
+-------+-------+----------+-------------+-----------+-------------------------+
| host1 | idc_a | 11.8 | 10.3 | 10.3 | 2022-11-03T03:39:57.450 |
| host1 | idc_b | 50 | 66.7 | 40.6 | 2022-11-03T03:39:57.450 |
| host2 | idc_a | 80.1 | 70.3 | 90 | 2022-11-03T03:39:57.450 |
+-------+-------+----------+-------------+-----------+-------------------------+

SELECT count(*) FROM system_metrics;

+----------------------------------+
| COUNT(UInt8(1)), #Field, #Uint64 |
+----------------------------------+
| 3 |
+----------------------------------+
+-----------------+
| COUNT(UInt8(1)) |
+-----------------+
| 3 |
+-----------------+

SELECT avg(cpu_util) FROM system_metrics;

+------------------------------------------------+
| AVG(system_metrics.cpu_util), #Field, #Float64 |
+------------------------------------------------+
| 47.29999999999999 |
+------------------------------------------------+
+------------------------------+
| AVG(system_metrics.cpu_util) |
+------------------------------+
| 47.29999999999999 |
+------------------------------+

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

+----------------------+---------------------------------------------------+
| idc, #Field, #String | AVG(system_metrics.memory_util), #Field, #Float64 |
+----------------------+---------------------------------------------------+
| idc_a | 40.3 |
| idc_b | 66.7 |
+----------------------+---------------------------------------------------+
+-------+---------------------------------+
| idc | AVG(system_metrics.memory_util) |
+-------+---------------------------------+
| idc_a | 40.3 |
| idc_b | 66.7 |
+-------+---------------------------------+

DROP TABLE system_metrics;

Affected Rows: 1

36 changes: 18 additions & 18 deletions tests/cases/standalone/select/dummy.result
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
select 1;

+--------------------------+
| Int64(1), #Field, #Int64 |
+--------------------------+
| 1 |
+--------------------------+
+----------+
| Int64(1) |
+----------+
| 1 |
+----------+

select 2 + 3;

+----------------------------------------+
| Int64(2) Plus Int64(3), #Field, #Int64 |
+----------------------------------------+
| 5 |
+----------------------------------------+
+---------------------+
| Int64(2) + Int64(3) |
+---------------------+
| 5 |
+---------------------+

select 4 + 0.5;

+----------------------------------------------+
| Int64(4) Plus Float64(0.5), #Field, #Float64 |
+----------------------------------------------+
| 4.5 |
+----------------------------------------------+
+-------------------------+
| Int64(4) + Float64(0.5) |
+-------------------------+
| 4.5 |
+-------------------------+

select "a";

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:{}" }
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 .

select "A";

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:{}" }
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 .

select * where "a" = "A";

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:{}" }
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 .

2 changes: 1 addition & 1 deletion tests/runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ client = { path = "../../src/client" }
common-base = { path = "../../src/common/base" }
common-grpc = { path = "../../src/common/grpc" }
common-query = { path = "../../src/common/query" }
sqlness = { git = "https://github.com/ceresdb/sqlness.git" }
sqlness = "0.1"
tokio.workspace = true
9 changes: 5 additions & 4 deletions tests/runner/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

use std::fmt::Display;
use std::fs::OpenOptions;
use std::path::Path;
use std::process::Stdio;
use std::time::Duration;

use async_trait::async_trait;
use client::{Client, Database as DB, Error as ClientError};
use common_query::Output;
use sqlness::{Database, Environment};
use sqlness::{Database, EnvController};
use tokio::process::{Child, Command};

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

#[async_trait]
impl Environment for Env {
impl EnvController for Env {
type DB = GreptimeDB;

async fn start(&self, mode: &str, _config: Option<String>) -> Self::DB {
async fn start(&self, mode: &str, _config: Option<&Path>) -> Self::DB {
match mode {
"standalone" => Self::start_standalone().await,
"distributed" => Self::start_distributed().await,
Expand Down Expand Up @@ -139,7 +140,7 @@ impl Display for ResultDisplayer {
}
Output::Stream(_) => unreachable!(),
},
Err(e) => write!(f, "Failed to execute, error: {e:?}"),
Err(e) => write!(f, "{e}"),
}
}
}

0 comments on commit 1305924

Please sign in to comment.