Skip to content

Commit 7bd4e73

Browse files
committed
ARROW-7503: [Rust] [Parquet] Fix build failures
This replaces the deprecated `Error::description()` with a simpler ToString. I'm not familiar with the `quick-error` crate, but did my best from what I could see on the tailhook/quick-error@b26770f commit that addressed the deprecation warning/error. Closes #6143 from nevi-me/ARROW-7503 and squashes the following commits: 56d7507 <Neville Dipale> address review feedback 86a53a6 <Neville Dipale> ARROW-7503: Fix build failures Authored-by: Neville Dipale <[email protected]> Signed-off-by: Neville Dipale <[email protected]>
1 parent 38ba4ae commit 7bd4e73

File tree

6 files changed

+79
-53
lines changed

6 files changed

+79
-53
lines changed

rust/parquet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ edition = "2018"
3030

3131
[dependencies]
3232
parquet-format = "~2.6"
33-
quick-error = "1.2.2"
33+
quick-error = "1.2"
3434
byteorder = "1"
3535
thrift = "0.12"
3636
snap = "0.2"

rust/parquet/src/column/writer.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,6 @@ impl EncodingWriteSupport for ColumnWriterImpl<FixedLenByteArrayType> {
865865
mod tests {
866866
use super::*;
867867

868-
use std::error::Error;
869-
870868
use rand::distributions::range::SampleRange;
871869

872870
use crate::column::{
@@ -892,8 +890,8 @@ mod tests {
892890
assert!(res.is_err());
893891
if let Err(err) = res {
894892
assert_eq!(
895-
err.description(),
896-
"Inconsistent length of definition and repetition levels: 3 != 2"
893+
format!("{}", err),
894+
"Parquet error: Inconsistent length of definition and repetition levels: 3 != 2"
897895
);
898896
}
899897
}
@@ -907,8 +905,8 @@ mod tests {
907905
assert!(res.is_err());
908906
if let Err(err) = res {
909907
assert_eq!(
910-
err.description(),
911-
"Definition levels are required, because max definition level = 1"
908+
format!("{}", err),
909+
"Parquet error: Definition levels are required, because max definition level = 1"
912910
);
913911
}
914912
}
@@ -922,8 +920,8 @@ mod tests {
922920
assert!(res.is_err());
923921
if let Err(err) = res {
924922
assert_eq!(
925-
err.description(),
926-
"Repetition levels are required, because max repetition level = 1"
923+
format!("{}", err),
924+
"Parquet error: Repetition levels are required, because max repetition level = 1"
927925
);
928926
}
929927
}
@@ -937,8 +935,8 @@ mod tests {
937935
assert!(res.is_err());
938936
if let Err(err) = res {
939937
assert_eq!(
940-
err.description(),
941-
"Expected to write 4 values, but have only 2"
938+
format!("{}", err),
939+
"Parquet error: Expected to write 4 values, but have only 2"
942940
);
943941
}
944942
}
@@ -969,7 +967,10 @@ mod tests {
969967
let res = writer.write_dictionary_page();
970968
assert!(res.is_err());
971969
if let Err(err) = res {
972-
assert_eq!(err.description(), "Dictionary encoder is not set");
970+
assert_eq!(
971+
format!("{}", err),
972+
"Parquet error: Dictionary encoder is not set"
973+
);
973974
}
974975
}
975976

rust/parquet/src/errors.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use std::{cell, convert, io, result, str};
2222
use arrow::error::ArrowError;
2323
use quick_error::quick_error;
2424
use snap;
25-
use std::error::Error;
2625
use thrift;
2726

2827
quick_error! {
@@ -33,7 +32,6 @@ quick_error! {
3332
/// Returned when code violates normal workflow of working with Parquet files.
3433
General(message: String) {
3534
display("Parquet error: {}", message)
36-
description(message)
3735
from(e: io::Error) -> (format!("underlying IO error: {}", e))
3836
from(e: snap::Error) -> (format!("underlying snap error: {}", e))
3937
from(e: thrift::Error) -> (format!("underlying Thrift error: {}", e))
@@ -44,25 +42,21 @@ quick_error! {
4442
/// Returned when functionality is not yet available.
4543
NYI(message: String) {
4644
display("NYI: {}", message)
47-
description(message)
4845
}
4946
/// "End of file" Parquet error.
5047
/// Returned when IO related failures occur, e.g. when there are not enough bytes to
5148
/// decode.
5249
EOF(message: String) {
5350
display("EOF: {}", message)
54-
description(message)
5551
}
5652
/// Arrow error.
5753
/// Returned when reading into arrow or writing from arrow.
5854
ArrowError(message: String) {
5955
display("Arrow: {}", message)
60-
description(message)
6156
from(e: ArrowError) -> (format!("underlying Arrow error: {:?}", e))
6257
}
6358
IndexOutOfBound(index: usize, bound: usize) {
6459
display("Index {} out of bound: {}", index, bound)
65-
description("Index out of bound error")
6660
}
6761
}
6862
}
@@ -105,6 +99,6 @@ macro_rules! eof_err {
10599

106100
impl Into<ArrowError> for ParquetError {
107101
fn into(self) -> ArrowError {
108-
ArrowError::ParquetError(self.description().to_string())
102+
ArrowError::ParquetError(format!("{}", self))
109103
}
110104
}

rust/parquet/src/file/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ mod tests {
669669
assert!(row_group_meta.is_err());
670670
if let Err(e) = row_group_meta {
671671
assert_eq!(
672-
e.to_string(),
672+
format!("{}", e),
673673
"Parquet error: Column length mismatch: 2 != 0"
674674
);
675675
}

rust/parquet/src/file/writer.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl<T: Write + Position> PageWriter for SerializedPageWriter<T> {
524524
mod tests {
525525
use super::*;
526526

527-
use std::{error::Error, fs::File, io::Cursor};
527+
use std::{fs::File, io::Cursor};
528528

529529
use crate::basic::{Compression, Encoding, Repetition, Type};
530530
use crate::column::page::PageReader;
@@ -548,14 +548,14 @@ mod tests {
548548
let res = writer.next_row_group();
549549
assert!(res.is_err());
550550
if let Err(err) = res {
551-
assert_eq!(err.description(), "File writer is closed");
551+
assert_eq!(format!("{}", err), "Parquet error: File writer is closed");
552552
}
553553
}
554554
{
555555
let res = writer.close();
556556
assert!(res.is_err());
557557
if let Err(err) = res {
558-
assert_eq!(err.description(), "File writer is closed");
558+
assert_eq!(format!("{}", err), "Parquet error: File writer is closed");
559559
}
560560
}
561561
}
@@ -572,7 +572,10 @@ mod tests {
572572
let res = row_group_writer.next_column();
573573
assert!(res.is_err());
574574
if let Err(err) = res {
575-
assert_eq!(err.description(), "Row group writer is closed");
575+
assert_eq!(
576+
format!("{}", err),
577+
"Parquet error: Row group writer is closed"
578+
);
576579
}
577580
}
578581

@@ -596,7 +599,10 @@ mod tests {
596599
let res = row_group_writer.close();
597600
assert!(res.is_err());
598601
if let Err(err) = res {
599-
assert_eq!(err.description(), "Column length mismatch: 1 != 0");
602+
assert_eq!(
603+
format!("{}", err),
604+
"Parquet error: Column length mismatch: 1 != 0"
605+
);
600606
}
601607
}
602608

@@ -641,8 +647,8 @@ mod tests {
641647
assert!(res.is_err());
642648
if let Err(err) = res {
643649
assert_eq!(
644-
err.description(),
645-
"Incorrect number of rows, expected 3 != 2 rows"
650+
format!("{}", err),
651+
"Parquet error: Incorrect number of rows, expected 3 != 2 rows"
646652
);
647653
}
648654
}

rust/parquet/src/schema/types.rs

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,6 @@ fn to_thrift_helper(schema: &Type, elements: &mut Vec<SchemaElement>) {
10631063
mod tests {
10641064
use super::*;
10651065

1066-
use std::error::Error;
1067-
10681066
use crate::schema::parser::parse_message_type;
10691067

10701068
#[test]
@@ -1097,7 +1095,10 @@ mod tests {
10971095
.build();
10981096
assert!(result.is_err());
10991097
if let Err(e) = result {
1100-
assert_eq!(e.description(), "BSON can only annotate BYTE_ARRAY fields");
1098+
assert_eq!(
1099+
format!("{}", e),
1100+
"Parquet error: BSON can only annotate BYTE_ARRAY fields"
1101+
);
11011102
}
11021103

11031104
result = Type::primitive_type_builder("foo", PhysicalType::INT96)
@@ -1109,8 +1110,8 @@ mod tests {
11091110
assert!(result.is_err());
11101111
if let Err(e) = result {
11111112
assert_eq!(
1112-
e.description(),
1113-
"DECIMAL can only annotate INT32, INT64, BYTE_ARRAY and FIXED"
1113+
format!("{}", e),
1114+
"Parquet error: DECIMAL can only annotate INT32, INT64, BYTE_ARRAY and FIXED"
11141115
);
11151116
}
11161117

@@ -1122,7 +1123,10 @@ mod tests {
11221123
.build();
11231124
assert!(result.is_err());
11241125
if let Err(e) = result {
1125-
assert_eq!(e.description(), "Invalid DECIMAL precision: -1");
1126+
assert_eq!(
1127+
format!("{}", e),
1128+
"Parquet error: Invalid DECIMAL precision: -1"
1129+
);
11261130
}
11271131

11281132
result = Type::primitive_type_builder("foo", PhysicalType::BYTE_ARRAY)
@@ -1133,7 +1137,10 @@ mod tests {
11331137
.build();
11341138
assert!(result.is_err());
11351139
if let Err(e) = result {
1136-
assert_eq!(e.description(), "Invalid DECIMAL precision: 0");
1140+
assert_eq!(
1141+
format!("{}", e),
1142+
"Parquet error: Invalid DECIMAL precision: 0"
1143+
);
11371144
}
11381145

11391146
result = Type::primitive_type_builder("foo", PhysicalType::BYTE_ARRAY)
@@ -1144,7 +1151,7 @@ mod tests {
11441151
.build();
11451152
assert!(result.is_err());
11461153
if let Err(e) = result {
1147-
assert_eq!(e.description(), "Invalid DECIMAL scale: -1");
1154+
assert_eq!(format!("{}", e), "Parquet error: Invalid DECIMAL scale: -1");
11481155
}
11491156

11501157
result = Type::primitive_type_builder("foo", PhysicalType::BYTE_ARRAY)
@@ -1156,8 +1163,8 @@ mod tests {
11561163
assert!(result.is_err());
11571164
if let Err(e) = result {
11581165
assert_eq!(
1159-
e.description(),
1160-
"Invalid DECIMAL: scale (2) cannot be greater than or equal to precision (1)"
1166+
format!("{}", e),
1167+
"Parquet error: Invalid DECIMAL: scale (2) cannot be greater than or equal to precision (1)"
11611168
);
11621169
}
11631170

@@ -1170,8 +1177,8 @@ mod tests {
11701177
assert!(result.is_err());
11711178
if let Err(e) = result {
11721179
assert_eq!(
1173-
e.description(),
1174-
"Cannot represent INT32 as DECIMAL with precision 18"
1180+
format!("{}", e),
1181+
"Parquet error: Cannot represent INT32 as DECIMAL with precision 18"
11751182
);
11761183
}
11771184

@@ -1184,8 +1191,8 @@ mod tests {
11841191
assert!(result.is_err());
11851192
if let Err(e) = result {
11861193
assert_eq!(
1187-
e.description(),
1188-
"Cannot represent INT64 as DECIMAL with precision 32"
1194+
format!("{}", e),
1195+
"Parquet error: Cannot represent INT64 as DECIMAL with precision 32"
11891196
);
11901197
}
11911198

@@ -1199,8 +1206,8 @@ mod tests {
11991206
assert!(result.is_err());
12001207
if let Err(e) = result {
12011208
assert_eq!(
1202-
e.description(),
1203-
"Cannot represent FIXED_LEN_BYTE_ARRAY as DECIMAL with length 5 and precision 12"
1209+
format!("{}", e),
1210+
"Parquet error: Cannot represent FIXED_LEN_BYTE_ARRAY as DECIMAL with length 5 and precision 12"
12041211
);
12051212
}
12061213

@@ -1210,7 +1217,10 @@ mod tests {
12101217
.build();
12111218
assert!(result.is_err());
12121219
if let Err(e) = result {
1213-
assert_eq!(e.description(), "UINT_8 can only annotate INT32");
1220+
assert_eq!(
1221+
format!("{}", e),
1222+
"Parquet error: UINT_8 can only annotate INT32"
1223+
);
12141224
}
12151225

12161226
result = Type::primitive_type_builder("foo", PhysicalType::INT32)
@@ -1219,7 +1229,10 @@ mod tests {
12191229
.build();
12201230
assert!(result.is_err());
12211231
if let Err(e) = result {
1222-
assert_eq!(e.description(), "TIME_MICROS can only annotate INT64");
1232+
assert_eq!(
1233+
format!("{}", e),
1234+
"Parquet error: TIME_MICROS can only annotate INT64"
1235+
);
12231236
}
12241237

12251238
result = Type::primitive_type_builder("foo", PhysicalType::BYTE_ARRAY)
@@ -1229,8 +1242,8 @@ mod tests {
12291242
assert!(result.is_err());
12301243
if let Err(e) = result {
12311244
assert_eq!(
1232-
e.description(),
1233-
"INTERVAL can only annotate FIXED_LEN_BYTE_ARRAY(12)"
1245+
format!("{}", e),
1246+
"Parquet error: INTERVAL can only annotate FIXED_LEN_BYTE_ARRAY(12)"
12341247
);
12351248
}
12361249

@@ -1242,8 +1255,8 @@ mod tests {
12421255
assert!(result.is_err());
12431256
if let Err(e) = result {
12441257
assert_eq!(
1245-
e.description(),
1246-
"INTERVAL can only annotate FIXED_LEN_BYTE_ARRAY(12)"
1258+
format!("{}", e),
1259+
"Parquet error: INTERVAL can only annotate FIXED_LEN_BYTE_ARRAY(12)"
12471260
);
12481261
}
12491262

@@ -1253,7 +1266,10 @@ mod tests {
12531266
.build();
12541267
assert!(result.is_err());
12551268
if let Err(e) = result {
1256-
assert_eq!(e.description(), "ENUM can only annotate BYTE_ARRAY fields");
1269+
assert_eq!(
1270+
format!("{}", e),
1271+
"Parquet error: ENUM can only annotate BYTE_ARRAY fields"
1272+
);
12571273
}
12581274

12591275
result = Type::primitive_type_builder("foo", PhysicalType::INT32)
@@ -1262,7 +1278,10 @@ mod tests {
12621278
.build();
12631279
assert!(result.is_err());
12641280
if let Err(e) = result {
1265-
assert_eq!(e.description(), "MAP cannot be applied to a primitive type");
1281+
assert_eq!(
1282+
format!("{}", e),
1283+
"Parquet error: MAP cannot be applied to a primitive type"
1284+
);
12661285
}
12671286

12681287
result = Type::primitive_type_builder("foo", PhysicalType::FIXED_LEN_BYTE_ARRAY)
@@ -1272,7 +1291,10 @@ mod tests {
12721291
.build();
12731292
assert!(result.is_err());
12741293
if let Err(e) = result {
1275-
assert_eq!(e.description(), "Invalid FIXED_LEN_BYTE_ARRAY length: -1");
1294+
assert_eq!(
1295+
format!("{}", e),
1296+
"Parquet error: Invalid FIXED_LEN_BYTE_ARRAY length: -1"
1297+
);
12761298
}
12771299
}
12781300

@@ -1757,7 +1779,10 @@ mod tests {
17571779
let thrift_schema = to_thrift(&schema);
17581780
assert!(thrift_schema.is_err());
17591781
if let Err(e) = thrift_schema {
1760-
assert_eq!(e.description(), "Root schema must be Group type");
1782+
assert_eq!(
1783+
format!("{}", e),
1784+
"Parquet error: Root schema must be Group type"
1785+
);
17611786
}
17621787
}
17631788

0 commit comments

Comments
 (0)