mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 22:32:55 +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:
@@ -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