Skip to content

Commit 5851a25

Browse files
authored
ci: ttc test with arrow body format. (#18985)
* ci: ttc test with arrow body format. * fix dynamic_schema
1 parent 6b4cf08 commit 5851a25

File tree

4 files changed

+64
-19
lines changed

4 files changed

+64
-19
lines changed

src/query/service/src/interpreters/util.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ impl Client for ScriptClient {
137137
let interpreter = InterpreterFactory::get(ctx.clone(), &plan).await?;
138138
let stream = interpreter.execute(ctx.clone()).await?;
139139
let blocks = stream.try_collect::<Vec<_>>().await?;
140-
let schema = plan.schema();
140+
let mut schema = plan.schema();
141+
if let Some(real_schema) = interpreter.get_dynamic_schema().await {
142+
schema = real_schema;
143+
}
141144

142145
let block = match blocks.len() {
143146
0 => DataBlock::empty_with_schema(schema.clone()),

tests/sqllogictests/src/client/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,22 @@ pub use ttc_client::TTCClient;
3131
use crate::error::Result;
3232
use crate::util::ColumnType;
3333

34+
#[derive(Debug, Clone, Copy)]
35+
pub enum BodyFormat {
36+
Json,
37+
Arrow,
38+
}
39+
3440
#[derive(Debug, Clone)]
3541
pub enum ClientType {
3642
MySQL,
3743
Http,
3844
// Tcp Testing Container
39-
Ttc(String, u16),
45+
Ttc {
46+
image: String,
47+
port: u16,
48+
body_format: BodyFormat,
49+
},
4050
Hybird,
4151
}
4252

tests/sqllogictests/src/main.rs

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use testcontainers::GenericImage;
3636
use testcontainers::Image;
3737

3838
use crate::arg::SqlLogicTestArgs;
39+
use crate::client::BodyFormat;
3940
use crate::client::Client;
4041
use crate::client::ClientType;
4142
use crate::client::HttpClient;
@@ -65,17 +66,27 @@ static HYBRID_CONFIGS: LazyLock<Vec<(Box<ClientType>, usize)>> = LazyLock::new(|
6566
vec![
6667
(Box::new(ClientType::MySQL), 3),
6768
(
68-
Box::new(ClientType::Ttc(
69-
"ghcr.io/databendlabs/ttc-rust:latest".to_string(),
70-
TTC_PORT_START,
71-
)),
69+
Box::new(ClientType::Ttc {
70+
image: "ghcr.io/databendlabs/ttc-rust:latest".to_string(),
71+
port: TTC_PORT_START,
72+
body_format: BodyFormat::Arrow,
73+
}),
7274
5,
7375
),
7476
(
75-
Box::new(ClientType::Ttc(
76-
"ghcr.io/databendlabs/ttc-go:latest".to_string(),
77-
TTC_PORT_START + 1,
78-
)),
77+
Box::new(ClientType::Ttc {
78+
image: "ghcr.io/databendlabs/ttc-rust:latest".to_string(),
79+
port: TTC_PORT_START + 1,
80+
body_format: BodyFormat::Json,
81+
}),
82+
5,
83+
),
84+
(
85+
Box::new(ClientType::Ttc {
86+
image: "ghcr.io/databendlabs/ttc-go:latest".to_string(),
87+
port: TTC_PORT_START + 2,
88+
body_format: BodyFormat::Json,
89+
}),
7990
5,
8091
),
8192
]
@@ -138,12 +149,20 @@ pub async fn main() -> Result<()> {
138149
handler if handler.starts_with("ttc") => {
139150
if handler != "ttc_dev" {
140151
let image = format!("ghcr.io/databendlabs/{handler}:latest");
141-
run_ttc_container(&image, TTC_PORT_START, args.port, &mut containers).await?;
152+
run_ttc_container(
153+
&image,
154+
TTC_PORT_START,
155+
args.port,
156+
&mut containers,
157+
BodyFormat::Json,
158+
)
159+
.await?;
142160
}
143-
run_ttc_client(
144-
args.clone(),
145-
ClientType::Ttc(handler.to_string(), TTC_PORT_START),
146-
)
161+
run_ttc_client(args.clone(), ClientType::Ttc {
162+
image: handler.to_string(),
163+
port: TTC_PORT_START,
164+
body_format: BodyFormat::Json,
165+
})
147166
.await?;
148167
}
149168
_ => {
@@ -181,8 +200,12 @@ async fn run_hybrid_client(
181200
for (c, _) in HYBRID_CONFIGS.iter() {
182201
match c.as_ref() {
183202
ClientType::MySQL | ClientType::Http => {}
184-
ClientType::Ttc(image, port) => {
185-
run_ttc_container(image, *port, args.port, cs).await?;
203+
ClientType::Ttc {
204+
image,
205+
port,
206+
body_format,
207+
} => {
208+
run_ttc_container(image, *port, args.port, cs, *body_format).await?;
186209
}
187210
ClientType::Hybird => panic!("Can't run hybrid client in hybrid client"),
188211
}
@@ -221,7 +244,11 @@ async fn create_databend(client_type: &ClientType, filename: &str) -> Result<Dat
221244
client = Client::Http(HttpClient::create(args.port).await?);
222245
}
223246

224-
ClientType::Ttc(image, port) => {
247+
ClientType::Ttc {
248+
image,
249+
port,
250+
body_format: _,
251+
} => {
225252
let conn = format!("127.0.0.1:{port}");
226253
client = Client::Ttc(TTCClient::create(image, &conn).await?);
227254
}

tests/sqllogictests/src/util.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use walkdir::DirEntry;
4242
use walkdir::WalkDir;
4343

4444
use crate::arg::SqlLogicTestArgs;
45+
use crate::client::BodyFormat;
4546
use crate::error::DSqlLogicTestError;
4647
use crate::error::Result;
4748

@@ -254,6 +255,7 @@ pub async fn run_ttc_container(
254255
port: u16,
255256
http_server_port: u16,
256257
cs: &mut Vec<ContainerAsync<GenericImage>>,
258+
body_format: BodyFormat,
257259
) -> Result<()> {
258260
let docker = &docker_client_instance().await?;
259261
let mut images = image.split(":");
@@ -271,10 +273,13 @@ pub async fn run_ttc_container(
271273
let container_name = format!("databend-ttc-{}-{}", port, x);
272274
let start = Instant::now();
273275
println!("Starting container {container_name}");
274-
let dsn = format!(
276+
let mut dsn = format!(
275277
"databend://root:@127.0.0.1:{}?sslmode=disable",
276278
http_server_port
277279
);
280+
if matches!(body_format, BodyFormat::Arrow) {
281+
dsn = format!("{dsn}&body_format=arrow");
282+
}
278283

279284
let mut i = 1;
280285
loop {

0 commit comments

Comments
 (0)