Skip to content

Commit 3e651e0

Browse files
authored
Upgrade arrow to 58 (#36)
* Upgrade arrow to 58 * Bump version
1 parent e1ed0be commit 3e651e0

3 files changed

Lines changed: 22 additions & 21 deletions

File tree

Cargo.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ repository = "https://github.com/sundy-li/arrow_cli"
77
edition = "2024"
88
license = "Apache-2.0"
99
name = "arrow_cli"
10-
version = "0.5.0"
10+
version = "0.6.0"
1111

1212

1313
[dependencies]
14-
arrow-array = "57"
15-
arrow-cast = { version = "57", features = ["prettyprint"] }
16-
arrow-csv = "57"
17-
arrow-flight = { version = "57", features = ["flight-sql-experimental"] }
18-
arrow-json = "57"
19-
arrow-schema = "57"
14+
arrow-array = { version = "58", features = ["chrono-tz"] }
15+
arrow-cast = { version = "58", features = ["prettyprint"] }
16+
arrow-csv = "58"
17+
arrow-flight = { version = "58", features = ["flight-sql-experimental"] }
18+
arrow-json = "58"
19+
arrow-schema = "58"
2020
atty = "0.2"
2121
clap = { version = "4.5", features = ["derive"] }
2222
futures = { version = "0.3", default-features = false, features = ["alloc"] }

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod session;
44

55
use std::time::Duration;
66

7+
use arrow_flight::error::FlightError;
78
use arrow_schema::ArrowError;
89
use atty::Stream;
910

@@ -59,7 +60,7 @@ struct Args {
5960
}
6061

6162
#[tokio::main]
62-
pub async fn main() -> Result<(), ArrowError> {
63+
pub async fn main() -> Result<(), FlightError> {
6364
let args = Args::parse();
6465

6566
let protocol = if args.tls { "https" } else { "http" };

src/session.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use arrow_array::RecordBatch;
22
use arrow_flight::{
3-
FlightInfo, flight_service_client::FlightServiceClient, sql::client::FlightSqlServiceClient,
3+
FlightInfo, error::FlightError, flight_service_client::FlightServiceClient,
4+
sql::client::FlightSqlServiceClient,
45
};
56
use arrow_schema::ArrowError;
67
use futures::TryStreamExt;
@@ -29,11 +30,11 @@ impl Session {
2930
endpoint: Endpoint,
3031
is_repl: bool,
3132
args: Args,
32-
) -> Result<Self, ArrowError> {
33+
) -> Result<Self, FlightError> {
3334
let channel = endpoint
3435
.connect()
3536
.await
36-
.map_err(|err| ArrowError::IpcError(err.to_string()))?;
37+
.map_err(|err| FlightError::ExternalError(Box::new(err)))?;
3738

3839
if is_repl {
3940
println!("Welcome to Arrow CLI v{}.", env!("CARGO_PKG_VERSION"));
@@ -106,7 +107,7 @@ impl Session {
106107
if let Err(e) = async {
107108
let result = self.execute_query(&query).await?;
108109
print_query_result(&result, &self.args)?;
109-
Ok::<_, ArrowError>(())
110+
Ok::<_, FlightError>(())
110111
}
111112
.await
112113
{
@@ -124,7 +125,7 @@ impl Session {
124125
if let Err(e) = async {
125126
let result = self.execute_query(command).await?;
126127
print_query_result(&result, &self.args)?;
127-
Ok::<_, ArrowError>(())
128+
Ok::<_, FlightError>(())
128129
}
129130
.await
130131
{
@@ -134,13 +135,12 @@ impl Session {
134135

135136
pub async fn handle_stdin(&mut self) {
136137
let mut lines = std::io::stdin().lock().lines();
137-
// TODO support multi line
138138
while let Some(Ok(line)) = lines.next() {
139139
let line = line.trim_end();
140140
if let Err(e) = async {
141141
let result = self.execute_query(line).await?;
142142
print_query_result(&result, &self.args)?;
143-
Ok::<_, ArrowError>(())
143+
Ok::<_, FlightError>(())
144144
}
145145
.await
146146
{
@@ -149,7 +149,7 @@ impl Session {
149149
}
150150
}
151151

152-
async fn execute_query(&mut self, query: &str) -> Result<QueryResult, ArrowError> {
152+
async fn execute_query(&mut self, query: &str) -> Result<QueryResult, FlightError> {
153153
let start = Instant::now();
154154
let flight_info = if self.args.prepared {
155155
let mut stmt = self.client.prepare(query.to_string(), None).await?;
@@ -167,15 +167,15 @@ impl Session {
167167
let ticket = endpoint
168168
.ticket
169169
.as_ref()
170-
.ok_or_else(|| ArrowError::IpcError("Ticket is emtpy".to_string()))?
170+
.ok_or_else(|| {
171+
FlightError::Arrow(ArrowError::IpcError("Ticket is emtpy".to_string()))
172+
})?
171173
.clone();
172174
let mut client = self.client.clone();
173175
handles.push(tokio::spawn(async move {
174176
let flight_data = client.do_get(ticket).await?;
175-
let result: Vec<RecordBatch> = flight_data.try_collect().await.map_err(|e| {
176-
ArrowError::IpcError(format!("Failed to collect record batches: {e}"))
177-
})?;
178-
Ok::<Vec<RecordBatch>, ArrowError>(result)
177+
let result: Vec<RecordBatch> = flight_data.try_collect().await?;
178+
Ok::<Vec<RecordBatch>, FlightError>(result)
179179
}));
180180
}
181181

0 commit comments

Comments
 (0)