Skip to content

Commit

Permalink
fix: Transform::Day maps to Date rather than Int for consistency with…
Browse files Browse the repository at this point in the history
… reference implementation (#479)

Issue: #478
  • Loading branch information
sdd authored Jul 25, 2024
1 parent 4b275a2 commit e4d8001
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/iceberg/src/spec/partition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ mod tests {
NestedField::optional(
partition_spec.fields[0].field_id,
&partition_spec.fields[0].name,
Type::Primitive(crate::spec::PrimitiveType::Int)
Type::Primitive(crate::spec::PrimitiveType::Date)
)
);
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/iceberg/src/spec/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Transform {
match p {
PrimitiveType::Timestamp
| PrimitiveType::Timestamptz
| PrimitiveType::Date => Ok(Type::Primitive(PrimitiveType::Int)),
| PrimitiveType::Date => Ok(Type::Primitive(PrimitiveType::Date)),
_ => Err(Error::new(
ErrorKind::DataInvalid,
format!("{input_type} is not a valid input type of {self} transform",),
Expand Down
18 changes: 9 additions & 9 deletions crates/iceberg/src/transform/temporal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ mod test {
],
trans_types: vec![
(Primitive(Binary), None),
(Primitive(Date), Some(Primitive(Int))),
(Primitive(Date), Some(Primitive(Date))),
(
Primitive(Decimal {
precision: 8,
Expand All @@ -342,8 +342,8 @@ mod test {
(Primitive(StringType), None),
(Primitive(Uuid), None),
(Primitive(Time), None),
(Primitive(Timestamp), Some(Primitive(Int))),
(Primitive(Timestamptz), Some(Primitive(Int))),
(Primitive(Timestamp), Some(Primitive(Date))),
(Primitive(Timestamptz), Some(Primitive(Date))),
(
Struct(StructType::new(vec![NestedField::optional(
1,
Expand Down Expand Up @@ -378,7 +378,7 @@ mod test {
],
trans_types: vec![
(Primitive(Binary), None),
(Primitive(Date), Some(Primitive(Int))),
(Primitive(Date), Some(Primitive(Date))),
(
Primitive(Decimal {
precision: 8,
Expand All @@ -392,8 +392,8 @@ mod test {
(Primitive(StringType), None),
(Primitive(Uuid), None),
(Primitive(Time), None),
(Primitive(Timestamp), Some(Primitive(Int))),
(Primitive(Timestamptz), Some(Primitive(Int))),
(Primitive(Timestamp), Some(Primitive(Date))),
(Primitive(Timestamptz), Some(Primitive(Date))),
(
Struct(StructType::new(vec![NestedField::optional(
1,
Expand Down Expand Up @@ -428,7 +428,7 @@ mod test {
],
trans_types: vec![
(Primitive(Binary), None),
(Primitive(Date), Some(Primitive(Int))),
(Primitive(Date), Some(Primitive(Date))),
(
Primitive(Decimal {
precision: 8,
Expand All @@ -442,8 +442,8 @@ mod test {
(Primitive(StringType), None),
(Primitive(Uuid), None),
(Primitive(Time), None),
(Primitive(Timestamp), Some(Primitive(Int))),
(Primitive(Timestamptz), Some(Primitive(Int))),
(Primitive(Timestamp), Some(Primitive(Date))),
(Primitive(Timestamptz), Some(Primitive(Date))),
(
Struct(StructType::new(vec![NestedField::optional(
1,
Expand Down

0 comments on commit e4d8001

Please sign in to comment.