Skip to content

Commit efb063c

Browse files
committed
convert builder error into iceberg errors
1 parent c5a4c94 commit efb063c

9 files changed

Lines changed: 14 additions & 54 deletions

File tree

datafusion_iceberg/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub enum Error {
5656
ParseInt(#[from] std::num::ParseIntError),
5757
/// parse int error
5858
#[error(transparent)]
59-
ConfigBuilder(#[from] crate::table::DataFusionTableConfigBuilderError),
59+
DeriveBuilder(#[from] derive_builder::UninitializedFieldError),
6060
}
6161

6262
impl From<Error> for DataFusionError {

datafusion_iceberg/src/table.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ impl From<MaterializedView> for DataFusionTable {
107107
}
108108

109109
#[derive(Clone, Debug, Builder)]
110+
#[builder(build_fn(error = "Error"))]
110111
pub struct DataFusionTableConfig {
111112
/// With this option, an additional "__data_file_path" column is added to the output of the
112113
/// TableProvider that contains the path of the data-file the row originates from.

iceberg-rust-spec/src/error.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,9 @@ pub enum Error {
5555
/// parse int error
5656
#[error(transparent)]
5757
ParseInt(#[from] std::num::ParseIntError),
58-
/// table metadata builder
58+
/// derive builder
5959
#[error(transparent)]
60-
TableMetadataBuilder(#[from] crate::spec::table_metadata::TableMetadataBuilderError),
61-
/// view metadata builder
62-
#[error(transparent)]
63-
ViewMetadataBuilder(#[from] crate::spec::view_metadata::GeneralViewMetadataBuilderError),
64-
/// version builder
65-
#[error(transparent)]
66-
VersionBuilder(#[from] crate::spec::view_metadata::VersionBuilderError),
67-
/// manifest builder
68-
#[error(transparent)]
69-
ManifestEntryBuilder(#[from] crate::spec::manifest::ManifestEntryBuilderError),
70-
/// datafile builder
71-
#[error(transparent)]
72-
DatafileBuilder(#[from] crate::spec::manifest::DataFileBuilderError),
73-
/// snapshot builder
74-
#[error(transparent)]
75-
SnapshotBuilder(#[from] crate::spec::snapshot::SnapshotBuilderError),
76-
/// structype builder
77-
#[error(transparent)]
78-
StructTypeBuilder(#[from] crate::spec::types::StructTypeBuilderError),
79-
/// partition spec builder
80-
#[error(transparent)]
81-
PartitionSpec(#[from] crate::spec::partition::PartitionSpecBuilderError),
60+
DeriveBuilder(#[from] derive_builder::UninitializedFieldError),
8261
}
8362

8463
impl From<apache_avro::Error> for Error {

iceberg-rust-spec/src/spec/manifest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use super::{
3434
/// Entry in manifest with the iceberg spec version 2.
3535
#[derive(Debug, Serialize, PartialEq, Clone, Getters, Builder)]
3636
#[serde(into = "ManifestEntryEnum")]
37-
#[builder(setter(prefix = "with"))]
37+
#[builder(build_fn(error = "Error"), setter(prefix = "with"))]
3838
pub struct ManifestEntry {
3939
/// Table format version
4040
format_version: FormatVersion,
@@ -516,7 +516,7 @@ impl From<HashMap<i32, Value>> for AvroMap<ByteBuf> {
516516
}
517517

518518
#[derive(Debug, PartialEq, Clone, Getters, Builder)]
519-
#[builder(setter(prefix = "with"))]
519+
#[builder(build_fn(error = "Error"), setter(prefix = "with"))]
520520
/// DataFile found in Manifest.
521521
pub struct DataFile {
522522
///Type of content in data file.

iceberg-rust-spec/src/spec/partition.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl PartitionField {
169169

170170
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone, Default, Builder, Getters)]
171171
#[serde(rename_all = "kebab-case")]
172-
#[builder(setter(prefix = "with"))]
172+
#[builder(build_fn(error = "Error"), setter(prefix = "with"))]
173173
/// Partition spec that defines how to produce a tuple of partition values from a record.
174174
pub struct PartitionSpec {
175175
/// Identifier for PartitionSpec

iceberg-rust-spec/src/spec/snapshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use _serde::SnapshotEnum;
2929

3030
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Builder, Getters)]
3131
#[serde(from = "SnapshotEnum", into = "SnapshotEnum")]
32-
#[builder(setter(prefix = "with"))]
32+
#[builder(build_fn(error = "Error"), setter(prefix = "with"))]
3333
/// A snapshot represents the state of a table at some time and is used to access the complete set of data files in the table.
3434
pub struct Snapshot {
3535
/// A unique long ID

iceberg-rust-spec/src/spec/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ impl fmt::Display for PrimitiveType {
196196
/// DataType for a specific struct
197197
#[derive(Debug, Serialize, PartialEq, Eq, Clone, Builder)]
198198
#[serde(rename = "struct", tag = "type")]
199+
#[builder(build_fn(error = "Error"))]
199200
pub struct StructType {
200201
/// Struct fields
201202
#[builder(setter(each(name = "with_struct_field")))]

iceberg-rust/src/catalog/create.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use super::{identifier::Identifier, Catalog};
5353
/// can be serialized/deserialized using serde.
5454
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Builder)]
5555
#[serde(rename_all = "kebab-case")]
56-
#[builder(build_fn(name = "create"), setter(prefix = "with"))]
56+
#[builder(build_fn(name = "create", error = "Error"), setter(prefix = "with"))]
5757
pub struct CreateTable {
5858
#[builder(setter(into))]
5959
/// Name of the table
@@ -175,7 +175,7 @@ impl TryInto<TableMetadata> for CreateTable {
175175
/// can be serialized/deserialized using serde.
176176
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Builder)]
177177
#[serde(rename_all = "kebab-case")]
178-
#[builder(build_fn(name = "create"), setter(prefix = "with"))]
178+
#[builder(build_fn(name = "create", error = "Error"), setter(prefix = "with"))]
179179
pub struct CreateView<T: Materialization> {
180180
/// Name of the view
181181
#[builder(setter(into))]
@@ -285,7 +285,7 @@ impl TryInto<MaterializedViewMetadata> for CreateView<FullIdentifier> {
285285
/// can be serialized/deserialized using serde.
286286
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Builder)]
287287
#[serde(rename_all = "kebab-case")]
288-
#[builder(build_fn(name = "create"), setter(prefix = "with"))]
288+
#[builder(build_fn(name = "create", error = "Error"), setter(prefix = "with"))]
289289
pub struct CreateMaterializedView {
290290
/// Name of the view
291291
#[builder(setter(into))]

iceberg-rust/src/error.rs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,30 +89,9 @@ pub enum Error {
8989
/// parse int error
9090
#[error(transparent)]
9191
ParseInt(#[from] std::num::ParseIntError),
92-
/// table metadata builder
92+
/// derive builder
9393
#[error(transparent)]
94-
TableMetadataBuilder(
95-
#[from] iceberg_rust_spec::spec::table_metadata::TableMetadataBuilderError,
96-
),
97-
/// view metadata builder
98-
#[error(transparent)]
99-
ViewMetadataBuilder(
100-
#[from] iceberg_rust_spec::spec::view_metadata::GeneralViewMetadataBuilderError,
101-
),
102-
/// version builder
103-
#[error(transparent)]
104-
VersionBuilder(#[from] iceberg_rust_spec::spec::view_metadata::VersionBuilderError),
105-
/// create table builder
106-
#[error(transparent)]
107-
CreateTableBuilder(#[from] crate::catalog::create::CreateTableBuilderError),
108-
/// create view builder
109-
#[error(transparent)]
110-
CreateViewBuilder(#[from] crate::catalog::create::CreateViewBuilderError),
111-
/// create view builder
112-
#[error(transparent)]
113-
CreateMaterializedViewBuilder(
114-
#[from] crate::catalog::create::CreateMaterializedViewBuilderError,
115-
),
94+
DeriveBuilder(#[from] derive_builder::UninitializedFieldError),
11695
}
11796

11897
impl From<apache_avro::Error> for Error {

0 commit comments

Comments
 (0)