mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-05 21:02:58 +00:00
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>
This commit is contained in:
18
.github/workflows/develop.yml
vendored
18
.github/workflows/develop.yml
vendored
@@ -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
|
||||
|
||||
5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -6875,8 +6875,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sqlness"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/ceresdb/sqlness.git#94ad8235b52d8a8d8211844a0880e0a845f6dcc7"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ffa69a2ae10018ec72a3cb7574e3a33a3fc322ed03740f6e435fd7f0c1db4a7"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"derive_builder",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 .
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
@@ -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,
|
||||
@@ -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}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user