Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/actions/test_sqllogic_cluster_linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ runs:
env:
TEST_HANDLERS: ${{ inputs.handlers }}
TEST_PARALLEL: ${{ inputs.parallel }}
TEST_EXT_ARGS: '--skip_file tpcds_spill_1.test,tpcds_spill_2.test,tpcds_spill_3.test'
run: bash ./scripts/ci/ci-run-sqllogic-tests-cluster.sh ${{ inputs.dirs }}
8 changes: 0 additions & 8 deletions .github/actions/test_sqllogic_standalone_linux/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,12 @@ runs:
with:
artifacts: sqllogictests,meta,query

- uses: actions/github-script@v7
id: ext-args
env:
DIRS: ${{ inputs.dirs }}
with:
script: require('.github/actions/test_sqllogic_standalone_linux/script.js')(core)

- name: Run sqllogic Tests with Standalone mode
if: inputs.storage-format == 'all' || inputs.storage-format == 'parquet'
shell: bash
env:
TEST_HANDLERS: ${{ inputs.handlers }}
TEST_PARALLEL: ${{ inputs.parallel }}
TEST_EXT_ARGS: ${{ steps.ext-args.outputs.parquet }}
CACHE_ENABLE_TABLE_META_CACHE: ${{ inputs.enable_table_meta_cache}}
run: bash ./scripts/ci/ci-run-sqllogic-tests.sh ${{ inputs.dirs }}

Expand Down
12 changes: 0 additions & 12 deletions .github/actions/test_sqllogic_standalone_linux/script.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/reuse.sqllogic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- { dirs: "crdb", runner: "2c8g" }
- { dirs: "base", runner: "2c8g" }
- { dirs: "ydb", runner: "2c8g" }
- { dirs: "tpcds", runner: "4c16g", parallel: "1" }
- { dirs: "tpcds", runner: "2c8g" }
- { dirs: "tpch", runner: "2c8g" }
- { dirs: "standalone", runner: "2c8g" }
handler:
Expand Down
56 changes: 47 additions & 9 deletions tests/sqllogictests/src/client/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::sync::Arc;
use std::time::Duration;
use std::time::Instant;

use regex::Regex;
use reqwest::header::HeaderMap;
use reqwest::header::HeaderValue;
use reqwest::Client;
Expand All @@ -41,12 +42,43 @@ pub struct HttpClient {
#[derive(serde::Deserialize, Debug)]
struct QueryResponse {
session: Option<HttpSessionConf>,
schema: Vec<SchemaItem>,
data: Option<serde_json::Value>,
next_uri: Option<String>,

error: Option<serde_json::Value>,
}

#[derive(serde::Deserialize, Debug)]
struct SchemaItem {
#[allow(dead_code)]
pub name: String,
pub r#type: String,
}

impl SchemaItem {
fn parse_type(&self) -> Result<DefaultColumnType> {
let nullable = Regex::new(r"^Nullable\((.+)\)$").unwrap();
let value = match nullable.captures(&self.r#type) {
Some(captures) => {
let (_, [value]) = captures.extract();
value
}
None => &self.r#type,
};
let typ = match value {
"String" => DefaultColumnType::Text,
"Int8" | "Int16" | "Int32" | "Int64" | "UInt8" | "UInt16" | "UInt32" | "UInt64" => {
DefaultColumnType::Integer
}
"Float32" | "Float64" => DefaultColumnType::FloatingPoint,
decimal if decimal.starts_with("Decimal") => DefaultColumnType::FloatingPoint,
_ => DefaultColumnType::Any,
};
Ok(typ)
}
}

// make error message the same with ErrorCode::display
fn format_error(value: serde_json::Value) -> String {
let value = value.as_object().unwrap();
Expand Down Expand Up @@ -125,14 +157,20 @@ impl HttpClient {

pub async fn query(&mut self, sql: &str) -> Result<DBOutput<DefaultColumnType>> {
let start = Instant::now();
let port = self.port;
let mut response = self
.post_query(sql, &format!("http://127.0.0.1:{port}/v1/query"))
.await?;

let url = format!("http://127.0.0.1:{}/v1/query", self.port);
let mut schema = std::mem::take(&mut response.schema);
let mut parsed_rows = vec![];
let mut response = self.post_query(sql, &url).await?;
self.handle_response(&response, &mut parsed_rows)?;
while let Some(next_uri) = &response.next_uri {
let url = format!("http://127.0.0.1:{}{next_uri}", self.port);
let new_response = self.poll_query_result(&url).await?;
let url = format!("http://127.0.0.1:{port}{next_uri}");
let mut new_response = self.poll_query_result(&url).await?;
if schema.is_empty() && !new_response.schema.is_empty() {
schema = std::mem::take(&mut new_response.schema);
}
if new_response.next_uri.is_some() {
self.handle_response(&new_response, &mut parsed_rows)?;
response = new_response;
Expand All @@ -143,11 +181,6 @@ impl HttpClient {
if let Some(error) = response.error {
return Err(format_error(error).into());
}
// Todo: add types to compare
let mut types = vec![];
if !parsed_rows.is_empty() {
types = vec![DefaultColumnType::Any; parsed_rows[0].len()];
}

if self.debug {
println!(
Expand All @@ -156,6 +189,11 @@ impl HttpClient {
);
}

let types = schema
.iter()
.map(|item| item.parse_type().unwrap_or(DefaultColumnType::Any))
.collect();

Ok(DBOutput::Rows {
types,
rows: parsed_rows,
Expand Down
78 changes: 62 additions & 16 deletions tests/sqllogictests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use sqllogictest::default_validator;
use sqllogictest::parse_file;
use sqllogictest::DBOutput;
use sqllogictest::DefaultColumnType;
use sqllogictest::Location;
use sqllogictest::QueryExpect;
use sqllogictest::Record;
use sqllogictest::Runner;
use sqllogictest::TestError;
Expand Down Expand Up @@ -319,7 +321,6 @@ async fn run_suits(args: SqlLogicTestArgs, client_type: ClientType) -> Result<()

let col_separator = " ";
let validator = default_validator;
let column_validator = default_column_validator;
let mut runner =
Runner::new(|| async { create_databend(&client_type, &file_name).await });
runner
Expand All @@ -328,7 +329,7 @@ async fn run_suits(args: SqlLogicTestArgs, client_type: ClientType) -> Result<()
col_separator,
validator,
sqllogictest::default_normalizer,
column_validator,
default_column_validator,
)
.await
.unwrap();
Expand All @@ -354,6 +355,33 @@ async fn run_suits(args: SqlLogicTestArgs, client_type: ClientType) -> Result<()
Ok(())
}

fn column_validator(
loc: Location,
actual: Vec<DefaultColumnType>,
expected: Vec<DefaultColumnType>,
) {
let equals = if actual.len() != expected.len() {
false
} else {
actual.iter().zip(expected.iter()).all(|x| {
use DefaultColumnType::*;
matches!(
x,
(Text, Text)
| (Integer, Integer)
| (FloatingPoint, FloatingPoint)
| (Any, _)
| (_, Any)
)
})
};
if !equals {
println!(
"warn: column type not match, actual: {actual:?}, expected: {expected:?}, loc: {loc}"
);
}
}

async fn run_parallel_async(
tasks: Vec<impl Future<Output = std::result::Result<Vec<TestError>, TestError>>>,
num_of_tests: usize,
Expand Down Expand Up @@ -399,22 +427,40 @@ async fn run_file_async(
break;
}
// Capture error record and continue to run next records
if let Err(e) = runner.run_async(record).await {
// Skip query result error in bench
if bench
&& matches!(
e.kind(),
sqllogictest::TestErrorKind::QueryResultMismatch { .. }
)
{
continue;
}
let expected_types = if let Record::Query {
loc,
expected: QueryExpect::Results { types, .. },
..
} = &record
{
Some((loc.clone(), types.clone()))
} else {
None
};

match (runner.run_async(record).await, expected_types) {
(
Ok(sqllogictest::RecordOutput::Query { types: actual, .. }),
Some((loc, expected)),
) => column_validator(loc, actual, expected),
(Err(e), _) => {
// Skip query result error in bench
if bench
&& matches!(
e.kind(),
sqllogictest::TestErrorKind::QueryResultMismatch { .. }
)
{
continue;
}

if no_fail_fast {
error_records.push(e);
} else {
return Err(e);
if no_fail_fast {
error_records.push(e);
} else {
return Err(e);
}
}
_ => {}
}
}
let run_file_status = match error_records.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q1
query I
query T
WITH customer_total_return AS
(SELECT sr_customer_sk AS ctr_customer_sk,
sr_store_sk AS ctr_store_sk,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q10
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q10
query I
query TTTIIITIIIIIII
SELECT cd_gender,
cd_marital_status,
cd_education_status,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q11
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q11
query I
query TTTT
WITH year_total AS
(SELECT c_customer_id customer_id,
c_first_name customer_first_name,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q12
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q12
query I
query TTTTRRR
SELECT i_item_id,
i_item_desc,
i_category,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q13
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q13
query I
query RRRR

SELECT avg(ss_quantity) avg1,
avg(ss_ext_sales_price) avg2,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q14
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q14
query I
query TIIIRI
WITH cross_items AS
(SELECT i_item_sk ss_item_sk
FROM item,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q15
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q15
query I
query TR
SELECT ca_zip,
sum(cs_sales_price)
FROM catalog_sales,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q16
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q16
query I
query IRR
SELECT count(DISTINCT cs_order_number) AS "order count",
sum(cs_ext_ship_cost) AS "total shipping cost",
sum(cs_net_profit) AS "total net profit"
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q17
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q17
query I
query TTTIRRRIRRRIRRR
SELECT i_item_id,
i_item_desc,
s_state,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q18
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q18
query I
query TTTTRRRRRRR
SELECT i_item_id,
ca_country,
ca_state,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q19
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q19
query I
query ITITR
SELECT i_brand_id brand_id,
i_brand brand,
i_manufact_id,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q2
query I
query IRRRRRRR
WITH wscs AS
(SELECT sold_date_sk,
sales_price
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q20
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q20
query I
query TTTTRRR

SELECT i_item_id ,
i_item_desc,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q21
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q21
query I
query TTII
SELECT *
FROM
(SELECT w_warehouse_name,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q22
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q22
query I
query TTTTR
SELECT i_product_name ,
i_brand ,
i_class ,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q23
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q23
query I
query TTR
WITH frequent_ss_items AS
(SELECT itemdesc,
i_item_sk item_sk,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q24
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q24
query I
query TTTR
WITH ssales AS
(SELECT c_last_name,
c_first_name,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q25
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q25
query I
query TTTTRRR

SELECT i_item_id ,
i_item_desc ,
Expand Down
2 changes: 1 addition & 1 deletion tests/sqllogictests/suites/tpcds/Q26
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Q26
query I
query TRRRR
SELECT i_item_id,
avg(cs_quantity) agg1,
avg(cs_list_price) agg2,
Expand Down
Loading