Skip to content

Commit 421d8ae

Browse files
authored
fix(ci): fix tpcds spill tests that no longer work (#18869)
* update * update
1 parent ef4b42f commit 421d8ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+452
-260
lines changed

.github/actions/test_sqllogic_cluster_linux/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ runs:
2626
env:
2727
TEST_HANDLERS: ${{ inputs.handlers }}
2828
TEST_PARALLEL: ${{ inputs.parallel }}
29-
TEST_EXT_ARGS: '--skip_file tpcds_spill_1.test,tpcds_spill_2.test,tpcds_spill_3.test'
3029
run: bash ./scripts/ci/ci-run-sqllogic-tests-cluster.sh ${{ inputs.dirs }}

.github/actions/test_sqllogic_standalone_linux/action.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,12 @@ runs:
2929
with:
3030
artifacts: sqllogictests,meta,query
3131

32-
- uses: actions/github-script@v7
33-
id: ext-args
34-
env:
35-
DIRS: ${{ inputs.dirs }}
36-
with:
37-
script: require('.github/actions/test_sqllogic_standalone_linux/script.js')(core)
38-
3932
- name: Run sqllogic Tests with Standalone mode
4033
if: inputs.storage-format == 'all' || inputs.storage-format == 'parquet'
4134
shell: bash
4235
env:
4336
TEST_HANDLERS: ${{ inputs.handlers }}
4437
TEST_PARALLEL: ${{ inputs.parallel }}
45-
TEST_EXT_ARGS: ${{ steps.ext-args.outputs.parquet }}
4638
CACHE_ENABLE_TABLE_META_CACHE: ${{ inputs.enable_table_meta_cache}}
4739
run: bash ./scripts/ci/ci-run-sqllogic-tests.sh ${{ inputs.dirs }}
4840

.github/actions/test_sqllogic_standalone_linux/script.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/workflows/reuse.sqllogic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- { dirs: "crdb", runner: "2c8g" }
6161
- { dirs: "base", runner: "2c8g" }
6262
- { dirs: "ydb", runner: "2c8g" }
63-
- { dirs: "tpcds", runner: "4c16g", parallel: "1" }
63+
- { dirs: "tpcds", runner: "2c8g" }
6464
- { dirs: "tpch", runner: "2c8g" }
6565
- { dirs: "standalone", runner: "2c8g" }
6666
handler:

tests/sqllogictests/src/client/http_client.rs

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::sync::Arc;
1717
use std::time::Duration;
1818
use std::time::Instant;
1919

20+
use regex::Regex;
2021
use reqwest::header::HeaderMap;
2122
use reqwest::header::HeaderValue;
2223
use reqwest::Client;
@@ -41,12 +42,43 @@ pub struct HttpClient {
4142
#[derive(serde::Deserialize, Debug)]
4243
struct QueryResponse {
4344
session: Option<HttpSessionConf>,
45+
schema: Vec<SchemaItem>,
4446
data: Option<serde_json::Value>,
4547
next_uri: Option<String>,
4648

4749
error: Option<serde_json::Value>,
4850
}
4951

52+
#[derive(serde::Deserialize, Debug)]
53+
struct SchemaItem {
54+
#[allow(dead_code)]
55+
pub name: String,
56+
pub r#type: String,
57+
}
58+
59+
impl SchemaItem {
60+
fn parse_type(&self) -> Result<DefaultColumnType> {
61+
let nullable = Regex::new(r"^Nullable\((.+)\)$").unwrap();
62+
let value = match nullable.captures(&self.r#type) {
63+
Some(captures) => {
64+
let (_, [value]) = captures.extract();
65+
value
66+
}
67+
None => &self.r#type,
68+
};
69+
let typ = match value {
70+
"String" => DefaultColumnType::Text,
71+
"Int8" | "Int16" | "Int32" | "Int64" | "UInt8" | "UInt16" | "UInt32" | "UInt64" => {
72+
DefaultColumnType::Integer
73+
}
74+
"Float32" | "Float64" => DefaultColumnType::FloatingPoint,
75+
decimal if decimal.starts_with("Decimal") => DefaultColumnType::FloatingPoint,
76+
_ => DefaultColumnType::Any,
77+
};
78+
Ok(typ)
79+
}
80+
}
81+
5082
// make error message the same with ErrorCode::display
5183
fn format_error(value: serde_json::Value) -> String {
5284
let value = value.as_object().unwrap();
@@ -125,14 +157,20 @@ impl HttpClient {
125157

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

129-
let url = format!("http://127.0.0.1:{}/v1/query", self.port);
165+
let mut schema = std::mem::take(&mut response.schema);
130166
let mut parsed_rows = vec![];
131-
let mut response = self.post_query(sql, &url).await?;
132167
self.handle_response(&response, &mut parsed_rows)?;
133168
while let Some(next_uri) = &response.next_uri {
134-
let url = format!("http://127.0.0.1:{}{next_uri}", self.port);
135-
let new_response = self.poll_query_result(&url).await?;
169+
let url = format!("http://127.0.0.1:{port}{next_uri}");
170+
let mut new_response = self.poll_query_result(&url).await?;
171+
if schema.is_empty() && !new_response.schema.is_empty() {
172+
schema = std::mem::take(&mut new_response.schema);
173+
}
136174
if new_response.next_uri.is_some() {
137175
self.handle_response(&new_response, &mut parsed_rows)?;
138176
response = new_response;
@@ -143,11 +181,6 @@ impl HttpClient {
143181
if let Some(error) = response.error {
144182
return Err(format_error(error).into());
145183
}
146-
// Todo: add types to compare
147-
let mut types = vec![];
148-
if !parsed_rows.is_empty() {
149-
types = vec![DefaultColumnType::Any; parsed_rows[0].len()];
150-
}
151184

152185
if self.debug {
153186
println!(
@@ -156,6 +189,11 @@ impl HttpClient {
156189
);
157190
}
158191

192+
let types = schema
193+
.iter()
194+
.map(|item| item.parse_type().unwrap_or(DefaultColumnType::Any))
195+
.collect();
196+
159197
Ok(DBOutput::Rows {
160198
types,
161199
rows: parsed_rows,

tests/sqllogictests/src/main.rs

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ use sqllogictest::default_validator;
2727
use sqllogictest::parse_file;
2828
use sqllogictest::DBOutput;
2929
use sqllogictest::DefaultColumnType;
30+
use sqllogictest::Location;
31+
use sqllogictest::QueryExpect;
3032
use sqllogictest::Record;
3133
use sqllogictest::Runner;
3234
use sqllogictest::TestError;
@@ -319,7 +321,6 @@ async fn run_suits(args: SqlLogicTestArgs, client_type: ClientType) -> Result<()
319321

320322
let col_separator = " ";
321323
let validator = default_validator;
322-
let column_validator = default_column_validator;
323324
let mut runner =
324325
Runner::new(|| async { create_databend(&client_type, &file_name).await });
325326
runner
@@ -328,7 +329,7 @@ async fn run_suits(args: SqlLogicTestArgs, client_type: ClientType) -> Result<()
328329
col_separator,
329330
validator,
330331
sqllogictest::default_normalizer,
331-
column_validator,
332+
default_column_validator,
332333
)
333334
.await
334335
.unwrap();
@@ -354,6 +355,33 @@ async fn run_suits(args: SqlLogicTestArgs, client_type: ClientType) -> Result<()
354355
Ok(())
355356
}
356357

358+
fn column_validator(
359+
loc: Location,
360+
actual: Vec<DefaultColumnType>,
361+
expected: Vec<DefaultColumnType>,
362+
) {
363+
let equals = if actual.len() != expected.len() {
364+
false
365+
} else {
366+
actual.iter().zip(expected.iter()).all(|x| {
367+
use DefaultColumnType::*;
368+
matches!(
369+
x,
370+
(Text, Text)
371+
| (Integer, Integer)
372+
| (FloatingPoint, FloatingPoint)
373+
| (Any, _)
374+
| (_, Any)
375+
)
376+
})
377+
};
378+
if !equals {
379+
println!(
380+
"warn: column type not match, actual: {actual:?}, expected: {expected:?}, loc: {loc}"
381+
);
382+
}
383+
}
384+
357385
async fn run_parallel_async(
358386
tasks: Vec<impl Future<Output = std::result::Result<Vec<TestError>, TestError>>>,
359387
num_of_tests: usize,
@@ -399,22 +427,40 @@ async fn run_file_async(
399427
break;
400428
}
401429
// Capture error record and continue to run next records
402-
if let Err(e) = runner.run_async(record).await {
403-
// Skip query result error in bench
404-
if bench
405-
&& matches!(
406-
e.kind(),
407-
sqllogictest::TestErrorKind::QueryResultMismatch { .. }
408-
)
409-
{
410-
continue;
411-
}
430+
let expected_types = if let Record::Query {
431+
loc,
432+
expected: QueryExpect::Results { types, .. },
433+
..
434+
} = &record
435+
{
436+
Some((loc.clone(), types.clone()))
437+
} else {
438+
None
439+
};
440+
441+
match (runner.run_async(record).await, expected_types) {
442+
(
443+
Ok(sqllogictest::RecordOutput::Query { types: actual, .. }),
444+
Some((loc, expected)),
445+
) => column_validator(loc, actual, expected),
446+
(Err(e), _) => {
447+
// Skip query result error in bench
448+
if bench
449+
&& matches!(
450+
e.kind(),
451+
sqllogictest::TestErrorKind::QueryResultMismatch { .. }
452+
)
453+
{
454+
continue;
455+
}
412456

413-
if no_fail_fast {
414-
error_records.push(e);
415-
} else {
416-
return Err(e);
457+
if no_fail_fast {
458+
error_records.push(e);
459+
} else {
460+
return Err(e);
461+
}
417462
}
463+
_ => {}
418464
}
419465
}
420466
let run_file_status = match error_records.is_empty() {

tests/sqllogictests/suites/tpcds/Q1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Q1
2-
query I
2+
query T
33
WITH customer_total_return AS
44
(SELECT sr_customer_sk AS ctr_customer_sk,
55
sr_store_sk AS ctr_store_sk,

tests/sqllogictests/suites/tpcds/Q10

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Q10
2-
query I
2+
query TTTIIITIIIIIII
33
SELECT cd_gender,
44
cd_marital_status,
55
cd_education_status,

tests/sqllogictests/suites/tpcds/Q11

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Q11
2-
query I
2+
query TTTT
33
WITH year_total AS
44
(SELECT c_customer_id customer_id,
55
c_first_name customer_first_name,

tests/sqllogictests/suites/tpcds/Q12

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Q12
2-
query I
2+
query TTTTRRR
33
SELECT i_item_id,
44
i_item_desc,
55
i_category,

0 commit comments

Comments
 (0)