Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/src/main/java/org/apache/iceberg/types/Conversions.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.UUID;
import org.apache.iceberg.exceptions.RuntimeIOException;
Expand Down Expand Up @@ -68,6 +69,8 @@ public static Object fromPartitionString(Type type, String asString) {
return new BigDecimal(asString);
case DATE:
return Literal.of(asString).to(Types.DateType.get()).value();
case TIMESTAMP:
return (long) Timestamp.valueOf(asString).getNanos() / 1000;
default:
throw new UnsupportedOperationException(
"Unsupported type for fromPartitionString: " + type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,23 @@ public void testPartitionAppend() throws IOException {
Schema dateSchema =
new Schema(
required(1, "id", Types.LongType.get()),
optional(2, "timestamp", Types.TimestampType.withoutZone()));
optional(2, "timestamp", Types.TimestampType.withoutZone()),
optional(3, "timestamptz", Types.TimestampType.withZone()));

PartitionSpec partitionSpec =
PartitionSpec.builderFor(dateSchema).day("timestamp", "date").build();
PartitionSpec.builderFor(dateSchema)
.day("timestamp", "date")
.identity("timestamp")
.identity("timestamptz")
.build();

DataFile dataFile =
DataFiles.builder(partitionSpec)
.withPath("/path/to/data-1.parquet")
.withFileSizeInBytes(0)
.withRecordCount(0)
.withPartitionPath("date=2018-06-08")
.withPartitionPath(
"date=2018-06-08/timestamp=2023-02-11 18:30:00/timestamptz=2023-02-11 18:30:00")
.build();

File tableDir = temp.newFolder();
Expand Down