Skip to content

Commit 5cfe002

Browse files
authored
Merge pull request JanKaul#237 from JanKaul/fix-builder-errors
Fix builder errors
2 parents c5a4c94 + e64e1f2 commit 5cfe002

19 files changed

Lines changed: 32 additions & 81 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/materialized_view_metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub type MaterializedViewMetadata = GeneralViewMetadata<FullIdentifier>;
2929
pub type MaterializedViewMetadataBuilder = GeneralViewMetadataBuilder<FullIdentifier>;
3030

3131
impl MaterializedViewMetadata {
32-
pub fn as_ref(&self) -> TabularMetadataRef {
32+
pub fn as_ref(&self) -> TabularMetadataRef<'_> {
3333
TabularMetadataRef::MaterializedView(self)
3434
}
3535
}

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/table_metadata.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl TableMetadata {
204204
pub fn current_partition_fields(
205205
&self,
206206
branch: Option<&str>,
207-
) -> Result<Vec<BoundPartitionField>, Error> {
207+
) -> Result<Vec<BoundPartitionField<'_>>, Error> {
208208
let schema = self.current_schema(branch)?;
209209
let partition_spec = self.default_partition_spec()?;
210210
partition_fields(partition_spec, schema)
@@ -218,7 +218,10 @@ impl TableMetadata {
218218
/// # Returns
219219
/// * `Result<Vec<BoundPartitionField>, Error>` - Vector of partition fields bound to their source schema fields,
220220
/// or an error if the schema or partition spec cannot be found
221-
pub fn partition_fields(&self, snapshot_id: i64) -> Result<Vec<BoundPartitionField>, Error> {
221+
pub fn partition_fields(
222+
&self,
223+
snapshot_id: i64,
224+
) -> Result<Vec<BoundPartitionField<'_>>, Error> {
222225
let schema = self.schema(snapshot_id)?;
223226
self.default_partition_spec()?
224227
.fields()
@@ -325,7 +328,7 @@ impl TableMetadata {
325328
.map(|x| *x.sequence_number())
326329
}
327330

328-
pub fn as_ref(&self) -> TabularMetadataRef {
331+
pub fn as_ref(&self) -> TabularMetadataRef<'_> {
329332
TabularMetadataRef::Table(self)
330333
}
331334
}

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-spec/src/spec/view_metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<T: Materialization> GeneralViewMetadata<T> {
143143
}
144144

145145
impl ViewMetadata {
146-
pub fn as_ref(&self) -> TabularMetadataRef {
146+
pub fn as_ref(&self) -> TabularMetadataRef<'_> {
147147
TabularMetadataRef::View(self)
148148
}
149149
}

0 commit comments

Comments
 (0)