Skip to content

Commit

Permalink
Traits -> Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
c-thiel committed Oct 28, 2024
1 parent 002a0c3 commit 9562d22
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 253 deletions.
4 changes: 2 additions & 2 deletions crates/catalog/memory/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ mod tests {
use std::iter::FromIterator;

use iceberg::io::FileIOBuilder;
use iceberg::spec::{NestedField, PartitionSpec, PrimitiveType, Schema, SortOrder, Type};
use iceberg::spec::{BoundPartitionSpec, NestedField, PrimitiveType, Schema, SortOrder, Type};
use regex::Regex;
use tempfile::TempDir;

Expand Down Expand Up @@ -355,7 +355,7 @@ mod tests {

assert_eq!(metadata.current_schema().as_ref(), expected_schema);

let expected_partition_spec = PartitionSpec::builder((*expected_schema).clone())
let expected_partition_spec = BoundPartitionSpec::builder((*expected_schema).clone())
.with_spec_id(0)
.build()
.unwrap();
Expand Down
7 changes: 4 additions & 3 deletions crates/catalog/sql/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ mod tests {
use std::hash::Hash;

use iceberg::io::FileIOBuilder;
use iceberg::spec::{NestedField, PartitionSpec, PrimitiveType, Schema, SortOrder, Type};
use iceberg::spec::{BoundPartitionSpec, NestedField, PrimitiveType, Schema, SortOrder, Type};
use iceberg::table::Table;
use iceberg::{Catalog, Namespace, NamespaceIdent, TableCreation, TableIdent};
use itertools::Itertools;
Expand Down Expand Up @@ -874,10 +874,11 @@ mod tests {

assert_eq!(metadata.current_schema().as_ref(), expected_schema);

let expected_partition_spec = PartitionSpec::builder(expected_schema)
let expected_partition_spec = BoundPartitionSpec::builder(expected_schema.clone())
.with_spec_id(0)
.build()
.unwrap();
.unwrap()
.into_schemaless();

assert_eq!(
metadata
Expand Down
13 changes: 7 additions & 6 deletions crates/iceberg/src/expr/visitors/expression_evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,13 @@ mod tests {
UnaryExpression,
};
use crate::spec::{
DataContentType, DataFile, DataFileFormat, Datum, Literal, NestedField, PartitionSpec,
PartitionSpecRef, PrimitiveType, Schema, Struct, Transform, Type, UnboundPartitionField,
BoundPartitionSpec, BoundPartitionSpecRef, DataContentType, DataFile, DataFileFormat,
Datum, Literal, NestedField, PrimitiveType, Schema, Struct, Transform, Type,
UnboundPartitionField,
};
use crate::Result;

fn create_partition_spec(r#type: PrimitiveType) -> Result<PartitionSpecRef> {
fn create_partition_spec(r#type: PrimitiveType) -> Result<BoundPartitionSpecRef> {
let schema = Schema::builder()
.with_fields(vec![Arc::new(NestedField::optional(
1,
Expand All @@ -272,7 +273,7 @@ mod tests {
))])
.build()?;

let spec = PartitionSpec::builder(schema.clone())
let spec = BoundPartitionSpec::builder(schema.clone())
.with_spec_id(1)
.add_unbound_fields(vec![UnboundPartitionField::builder()
.source_id(1)
Expand All @@ -288,7 +289,7 @@ mod tests {
}

fn create_partition_filter(
partition_spec: PartitionSpecRef,
partition_spec: BoundPartitionSpecRef,
predicate: &BoundPredicate,
case_sensitive: bool,
) -> Result<BoundPredicate> {
Expand All @@ -312,7 +313,7 @@ mod tests {
}

fn create_expression_evaluator(
partition_spec: PartitionSpecRef,
partition_spec: BoundPartitionSpecRef,
predicate: &BoundPredicate,
case_sensitive: bool,
) -> Result<ExpressionEvaluator> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ mod test {
UnaryExpression,
};
use crate::spec::{
DataContentType, DataFile, DataFileFormat, Datum, NestedField, PartitionSpec,
BoundPartitionSpec, DataContentType, DataFile, DataFileFormat, Datum, NestedField,
PrimitiveType, Schema, Struct, Transform, Type, UnboundPartitionField,
};

Expand Down Expand Up @@ -1645,7 +1645,7 @@ mod test {
assert!(result, "Should read: NotIn on no nulls column");
}

fn create_test_partition_spec() -> Arc<PartitionSpec> {
fn create_test_partition_spec() -> Arc<BoundPartitionSpec> {
let table_schema = Schema::builder()
.with_fields(vec![Arc::new(NestedField::optional(
1,
Expand All @@ -1656,7 +1656,7 @@ mod test {
.unwrap();
let table_schema_ref = Arc::new(table_schema);

let partition_spec = PartitionSpec::builder(table_schema_ref.clone())
let partition_spec = BoundPartitionSpec::builder(table_schema_ref.clone())
.with_spec_id(1)
.add_unbound_fields(vec![UnboundPartitionField::builder()
.source_id(1)
Expand Down
16 changes: 8 additions & 8 deletions crates/iceberg/src/expr/visitors/inclusive_projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ mod tests {
use crate::expr::visitors::inclusive_projection::InclusiveProjection;
use crate::expr::{Bind, Predicate, Reference};
use crate::spec::{
Datum, NestedField, PartitionSpec, PrimitiveType, Schema, Transform, Type,
BoundPartitionSpec, Datum, NestedField, PrimitiveType, Schema, Transform, Type,
UnboundPartitionField,
};

Expand Down Expand Up @@ -267,7 +267,7 @@ mod tests {
let schema = build_test_schema();
let arc_schema = Arc::new(schema);

let partition_spec = PartitionSpec::builder(arc_schema.clone())
let partition_spec = BoundPartitionSpec::builder(arc_schema.clone())
.with_spec_id(1)
.build()
.unwrap()
Expand Down Expand Up @@ -298,7 +298,7 @@ mod tests {
let schema = build_test_schema();
let arc_schema = Arc::new(schema);

let partition_spec = PartitionSpec::builder(arc_schema.clone())
let partition_spec = BoundPartitionSpec::builder(arc_schema.clone())
.with_spec_id(1)
.add_unbound_field(
UnboundPartitionField::builder()
Expand Down Expand Up @@ -336,7 +336,7 @@ mod tests {
let schema = build_test_schema();
let arc_schema = Arc::new(schema);

let partition_spec = PartitionSpec::builder(arc_schema.clone())
let partition_spec = BoundPartitionSpec::builder(arc_schema.clone())
.with_spec_id(1)
.add_unbound_fields(vec![UnboundPartitionField {
source_id: 2,
Expand Down Expand Up @@ -372,7 +372,7 @@ mod tests {
let schema = build_test_schema();
let arc_schema = Arc::new(schema);

let partition_spec = PartitionSpec::builder(arc_schema.clone())
let partition_spec = BoundPartitionSpec::builder(arc_schema.clone())
.with_spec_id(1)
.add_unbound_fields(vec![UnboundPartitionField {
source_id: 2,
Expand Down Expand Up @@ -408,7 +408,7 @@ mod tests {
let schema = build_test_schema();
let arc_schema = Arc::new(schema);

let partition_spec = PartitionSpec::builder(arc_schema.clone())
let partition_spec = BoundPartitionSpec::builder(arc_schema.clone())
.with_spec_id(1)
.add_unbound_fields(vec![UnboundPartitionField {
source_id: 2,
Expand Down Expand Up @@ -444,7 +444,7 @@ mod tests {
let schema = build_test_schema();
let arc_schema = Arc::new(schema);

let partition_spec = PartitionSpec::builder(arc_schema.clone())
let partition_spec = BoundPartitionSpec::builder(arc_schema.clone())
.with_spec_id(1)
.add_unbound_field(
UnboundPartitionField::builder()
Expand Down Expand Up @@ -485,7 +485,7 @@ mod tests {
let schema = build_test_schema();
let arc_schema = Arc::new(schema);

let partition_spec = PartitionSpec::builder(arc_schema.clone())
let partition_spec = BoundPartitionSpec::builder(arc_schema.clone())
.with_spec_id(1)
.add_unbound_field(
UnboundPartitionField::builder()
Expand Down
20 changes: 10 additions & 10 deletions crates/iceberg/src/spec/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ use typed_builder::TypedBuilder;

use self::_const_schema::{manifest_schema_v1, manifest_schema_v2};
use super::{
Datum, FieldSummary, FormatVersion, ManifestContentType, ManifestFile, PartitionSpec, Schema,
SchemaId, SchemaRef, Struct, INITIAL_SEQUENCE_NUMBER, UNASSIGNED_SEQUENCE_NUMBER,
BoundPartitionSpec, Datum, FieldSummary, FormatVersion, ManifestContentType, ManifestFile,
Schema, SchemaId, SchemaRef, Struct, INITIAL_SEQUENCE_NUMBER, UNASSIGNED_SEQUENCE_NUMBER,
};
use crate::error::Result;
use crate::io::OutputFile;
Expand Down Expand Up @@ -706,7 +706,7 @@ pub struct ManifestMetadata {
/// ID of the schema used to write the manifest as a string
schema_id: SchemaId,
/// The partition spec used to write the manifest
partition_spec: PartitionSpec,
partition_spec: BoundPartitionSpec,
/// Table format version number of the manifest as a string
format_version: FormatVersion,
/// Type of content files tracked by the manifest: “data” or “deletes”
Expand Down Expand Up @@ -773,7 +773,7 @@ impl ManifestMetadata {
})
.transpose()?
.unwrap_or(0);
PartitionSpec::builder(schema.clone())
BoundPartitionSpec::builder(schema.clone())
.with_spec_id(spec_id)
.add_unbound_fields(fields.into_iter().map(|f| f.into_unbound()))?
.build()?
Expand Down Expand Up @@ -1594,7 +1594,7 @@ mod tests {
metadata: ManifestMetadata {
schema_id: 0,
schema: schema.clone(),
partition_spec: PartitionSpec::builder(schema).with_spec_id(0).build().unwrap(),
partition_spec: BoundPartitionSpec::builder(schema).with_spec_id(0).build().unwrap(),
content: ManifestContentType::Data,
format_version: FormatVersion::V2,
},
Expand Down Expand Up @@ -1707,7 +1707,7 @@ mod tests {
metadata: ManifestMetadata {
schema_id: 0,
schema: schema.clone(),
partition_spec: PartitionSpec::builder(schema)
partition_spec: BoundPartitionSpec::builder(schema)
.with_spec_id(0).add_partition_field("v_int", "v_int", Transform::Identity).unwrap()
.add_partition_field("v_long", "v_long", Transform::Identity).unwrap().build().unwrap(),
content: ManifestContentType::Data,
Expand Down Expand Up @@ -1818,7 +1818,7 @@ mod tests {
metadata: ManifestMetadata {
schema_id: 1,
schema: schema.clone(),
partition_spec: PartitionSpec::builder(schema).with_spec_id(0).build().unwrap(),
partition_spec: BoundPartitionSpec::builder(schema).with_spec_id(0).build().unwrap(),
content: ManifestContentType::Data,
format_version: FormatVersion::V1,
},
Expand Down Expand Up @@ -1882,7 +1882,7 @@ mod tests {
metadata: ManifestMetadata {
schema_id: 0,
schema: schema.clone(),
partition_spec: PartitionSpec::builder(schema).add_partition_field("category", "category", Transform::Identity).unwrap().build().unwrap(),
partition_spec: BoundPartitionSpec::builder(schema).add_partition_field("category", "category", Transform::Identity).unwrap().build().unwrap(),
content: ManifestContentType::Data,
format_version: FormatVersion::V1,
},
Expand Down Expand Up @@ -1961,7 +1961,7 @@ mod tests {
metadata: ManifestMetadata {
schema_id: 0,
schema: schema.clone(),
partition_spec: PartitionSpec::builder(schema).with_spec_id(0).build().unwrap(),
partition_spec: BoundPartitionSpec::builder(schema).with_spec_id(0).build().unwrap(),
content: ManifestContentType::Data,
format_version: FormatVersion::V2,
},
Expand Down Expand Up @@ -2033,7 +2033,7 @@ mod tests {
metadata: ManifestMetadata {
schema_id: 0,
schema: schema.clone(),
partition_spec: PartitionSpec::builder(schema).with_spec_id(0).build().unwrap(),
partition_spec: BoundPartitionSpec::builder(schema).with_spec_id(0).build().unwrap(),
content: ManifestContentType::Data,
format_version: FormatVersion::V2,
},
Expand Down
Loading

0 comments on commit 9562d22

Please # to comment.