Skip to content

Commit ed7f31a

Browse files
committed
feat(cubesql): Allow to upgrade Rust to stable
1 parent 6483f66 commit ed7f31a

File tree

8 files changed

+200
-450
lines changed

8 files changed

+200
-450
lines changed

packages/cubejs-backend-native/Cargo.lock

Lines changed: 47 additions & 142 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubesql/Cargo.lock

Lines changed: 53 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubesql/cubesql/Cargo.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ homepage = "https://cube.dev"
1111
[dependencies]
1212
arc-swap = "1"
1313
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "dcf3e4aa26fd112043ef26fa4a78db5dbd443c86", default-features = false, features = ["regex_expressions", "unicode_expressions"] }
14-
anyhow = "1.0"
15-
thiserror = "1.0.50"
14+
thiserror = "2"
1615
cubeclient = { path = "../cubeclient" }
1716
pg-srv = { path = "../pg-srv" }
1817
sqlparser = { git = 'https://github.com/cube-js/sqlparser-rs.git', rev = "6a54d27d3b75a04b9f9cbe309a83078aa54b32fd" }
@@ -25,8 +24,6 @@ bytes = "1.2"
2524
futures = "0.3.23"
2625
rand = "0.8.3"
2726
hashbrown = "0.14.3"
28-
smallvec = "1.7.0"
29-
byteorder = "1.3.4"
3027
log = "0.4.21"
3128
rust_decimal = { version = "1.25", features = ["c-repr", "db-postgres"]}
3229
postgres-types = "0.2.3"
@@ -41,13 +38,11 @@ uuid = { version = "1", features = ["serde", "v4"] }
4138
bincode = "1.3.1"
4239
chrono = "0.4.31"
4340
chrono-tz = "0.6"
44-
mockall = "0.8.1"
4541
tokio-util = { version = "0.7", features=["compat"] }
4642
comfy-table = "7.1.0"
4743
bitflags = "1.3.2"
4844
egg = { rev = "952f8c2a1033e5da097d23c523b0d8e392eb532b", git = "https://github.com/cube-js/egg.git", features = ["serde-1"] }
4945
paste = "1.0.6"
50-
csv = "1.1.6"
5146
tracing = { version = "0.1.40", features = ["async-await"] }
5247
async-stream = "0.3.3"
5348
futures-core = "0.3.23"

rust/cubesql/cubesql/src/compile/error.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1-
use std::{backtrace::Backtrace, collections::HashMap};
1+
use std::{backtrace::Backtrace, collections::HashMap, fmt::Formatter};
22

3-
#[derive(thiserror::Error, Debug)]
3+
/// TODO: Migrate back to thiserror crate, when Rust will stabilize feature(error_generic_member_access)
4+
#[derive(Debug)]
45
pub enum CompilationError {
5-
#[error("SQLCompilationError: Internal: {0}")]
66
Internal(String, Backtrace, Option<HashMap<String, String>>),
7-
#[error("SQLCompilationError: User: {0}")]
87
User(String, Option<HashMap<String, String>>),
9-
#[error("SQLCompilationError: Unsupported: {0}")]
108
Unsupported(String, Option<HashMap<String, String>>),
11-
#[error("SQLCompilationError: Fatal: {0}")]
129
Fatal(String, Option<HashMap<String, String>>),
1310
}
1411

12+
impl std::fmt::Display for CompilationError {
13+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
14+
match self {
15+
CompilationError::Internal(message, _, _) => {
16+
f.write_fmt(format_args!("SQLCompilationError: Internal: {}", message))
17+
}
18+
CompilationError::User(message, _) => {
19+
f.write_fmt(format_args!("SQLCompilationError: User: {}", message))
20+
}
21+
CompilationError::Unsupported(message, _) => f.write_fmt(format_args!(
22+
"SQLCompilationError: Unsupported: {}",
23+
message
24+
)),
25+
CompilationError::Fatal(message, _) => {
26+
f.write_fmt(format_args!("SQLCompilationError: Fatal: {}", message))
27+
}
28+
}
29+
}
30+
}
31+
1532
impl PartialEq for CompilationError {
1633
fn eq(&self, other: &Self) -> bool {
1734
match &self {

rust/cubesql/cubesql/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@
22
// Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422
33
clippy::nonstandard_macro_braces,
44
)]
5-
#![feature(test)]
6-
// #![feature(backtrace)]
7-
#![feature(async_closure)]
8-
#![feature(box_patterns)]
9-
// #![feature(slice_internals)]
10-
#![feature(vec_into_raw_parts)]
11-
#![feature(hash_set_entry)]
125
// #![feature(trace_macros)]
136
#![recursion_limit = "2048"]
14-
#![feature(error_generic_member_access)]
157

168
// trace_macros!(false);
179

rust/cubesql/pg-srv/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async-trait = "0.1.36"
1818
log = "0.4"
1919
bytes = "1.2"
2020
byteorder = "1.4"
21-
thiserror = "1.0.50"
21+
thiserror = "2"
2222
chrono = { version = "0.4", package = "chrono", default-features = false, features = [
2323
"clock",
2424
], optional = true }

rust/cubesql/pg-srv/src/lib.rs

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
//! You can find overview of the protocol at
33
//! <https://www.postgresql.org/docs/10/protocol.html>
44
5-
// #![feature(backtrace)]
6-
// #![feature(type_ascription)]
7-
#![feature(error_generic_member_access)]
8-
95
mod decoding;
106
mod encoding;
117

@@ -20,25 +16,51 @@ pub use encoding::*;
2016
pub use extended::*;
2117
pub use pg_type::*;
2218

23-
use std::backtrace::Backtrace;
19+
use std::{backtrace::Backtrace, fmt::Formatter};
2420

2521
/// Protocol error abstract of handled/unhandled errors, it should not handle any kind of business logic errors
26-
#[derive(thiserror::Error, Debug)]
22+
/// TODO: Migrate back to thiserror crate, when Rust will stabilize feature(error_generic_member_access)
23+
#[derive(Debug)]
2724
pub enum ProtocolError {
28-
#[error("IO Error: {}", .source)]
2925
IO {
30-
#[from]
3126
source: std::io::Error,
3227
backtrace: Backtrace,
3328
},
34-
#[error("Error: {}", .source.message)]
3529
ErrorResponse {
36-
#[from]
3730
source: protocol::ErrorResponse,
3831
backtrace: Backtrace,
3932
},
4033
}
4134

35+
impl std::fmt::Display for ProtocolError {
36+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
37+
match self {
38+
ProtocolError::IO { source, .. } => f.write_fmt(format_args!("IO error: {}", source)),
39+
ProtocolError::ErrorResponse { source, .. } => {
40+
f.write_fmt(format_args!("IO error: {}", source))
41+
}
42+
}
43+
}
44+
}
45+
46+
impl From<std::io::Error> for ProtocolError {
47+
fn from(source: std::io::Error) -> Self {
48+
ProtocolError::IO {
49+
source,
50+
backtrace: Backtrace::capture(),
51+
}
52+
}
53+
}
54+
55+
impl From<protocol::ErrorResponse> for ProtocolError {
56+
fn from(source: protocol::ErrorResponse) -> Self {
57+
ProtocolError::ErrorResponse {
58+
source,
59+
backtrace: Backtrace::capture(),
60+
}
61+
}
62+
}
63+
4264
impl ProtocolError {
4365
/// Return Backtrace from any variant of Enum
4466
pub fn backtrace(&self) -> Option<&Backtrace> {

0 commit comments

Comments
 (0)