Skip to content
Merged
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ val kantanCodecsVersion = "0.6.0"
val kantanCsvVersion = "0.8.0"
val kryoVersion = "4.0.3"
val magnoliaVersion = "1.1.10"
val magnolifyVersion = "0.9.7"
val magnolifyVersion = "0.9.8"
val metricsVersion = "4.2.39"
val munitVersion = "1.3.3"
val neo4jDriverVersion = "4.4.26"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import com.dimafeng.testcontainers.{ForAllTestContainer, GenericContainer}
import com.spotify.scio.parquet.BeamInputFile
import com.spotify.scio.testing.PipelineSpec
import magnolify.beam._
import magnolify.beam.logical.millis._
import magnolify.beam.logical.timestamp.micros._
import org.apache.iceberg.catalog.{Namespace, TableIdentifier}
import org.apache.iceberg.rest.RESTCatalog
import org.apache.iceberg.types.Types.{
Expand All @@ -42,15 +42,24 @@ import org.apache.iceberg.{
import org.apache.parquet.hadoop.ParquetFileReader
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy

import java.time.{Duration, Instant}
import java.time.{Duration, Instant, LocalDateTime, ZoneOffset}
import java.io.File
import java.nio.file.Files
import java.time.temporal.ChronoUnit
import scala.jdk.CollectionConverters._

case class Nested(d: Boolean)
case class IcebergIOITRecord(ts: Instant, a: Int, b: String, c: Nested)
case class IcebergIOITRecord(
ts: Instant,
tsWithoutZone: LocalDateTime,
a: Int,
b: String,
c: Nested
)
object IcebergIOITRecord {
implicit val instantRowField: RowField[Instant] = rfInstantMicros
implicit val localDateTimeRowField: RowField[LocalDateTime] =
magnolify.beam.logical.timestamp.millis.rfLocalDateTimeMillis
implicit val icebergIOITRecordRowType: RowType[IcebergIOITRecord] = RowType[IcebergIOITRecord]
}

Expand Down Expand Up @@ -79,12 +88,13 @@ class IcebergIOIT extends PipelineSpec with ForAllTestContainer {

lazy val tableSchema = new Schema(
NestedField.required(1, "ts", TimestampType.withZone()),
NestedField.required(2, "a", IntegerType.get()),
NestedField.required(3, "b", StringType.get()),
NestedField.required(2, "tsWithoutZone", TimestampType.withoutZone()),
NestedField.required(3, "a", IntegerType.get()),
NestedField.required(4, "b", StringType.get()),
NestedField.required(
4,
5,
"c",
StructType.of(NestedField.required(5, "d", BooleanType.get()))
StructType.of(NestedField.required(6, "d", BooleanType.get()))
)
)

Expand All @@ -110,8 +120,10 @@ class IcebergIOIT extends PipelineSpec with ForAllTestContainer {
CatalogUtil.ICEBERG_CATALOG_TYPE -> CatalogUtil.ICEBERG_CATALOG_TYPE_REST,
CatalogProperties.URI -> uri
)
val ts = Instant.now().truncatedTo(ChronoUnit.DAYS)
val elements = 1.to(10).map(i => IcebergIOITRecord(ts, i, s"$i", Nested(i % 2 == 0)))
val ts = Instant.now().truncatedTo(ChronoUnit.MICROS)
val tsWithoutZone = LocalDateTime.ofInstant(ts, ZoneOffset.UTC)
val elements =
1.to(10).map(i => IcebergIOITRecord(ts, tsWithoutZone, i, s"$i", Nested(i % 2 == 0)))

runWithRealContext() { sc =>
sc.parallelize(elements)
Expand All @@ -133,7 +145,16 @@ class IcebergIOIT extends PipelineSpec with ForAllTestContainer {
CatalogProperties.URI -> uri
)
val elements =
1.to(100).map(i => IcebergIOITRecord(Instant.now(), i, s"value_$i", Nested(i % 2 == 0)))
1.to(100).map { i =>
val ts = Instant.now()
IcebergIOITRecord(
ts,
LocalDateTime.ofInstant(ts, ZoneOffset.UTC),
i,
s"value_$i",
Nested(i % 2 == 0)
)
}

val customWriteDataPath = s"$tempDir/custom_path"

Expand Down
Loading