scala.googleapis.bigquery.TimePartitioning.scala Maven / Gradle / Ivy
package googleapis.bigquery
import JsonInstances._
import io.circe._
import io.circe.syntax._
import scala.concurrent.duration.FiniteDuration
final case class TimePartitioning(
/** Optional. Number of milliseconds for which to keep the storage for a partition. A wrapper is used here because 0 is an invalid value.
*/
expirationMs: Option[FiniteDuration] = None,
/** Optional. If not set, the table is partitioned by pseudo column '_PARTITIONTIME'; if set, the table is partitioned by this field. The field must be a top-level TIMESTAMP or DATE field. Its mode must be NULLABLE or REQUIRED. A wrapper is used here because an empty string is an invalid value.
*/
field: Option[String] = None,
/** If set to true, queries over this table require a partition filter that can be used for partition elimination to be specified. This field is deprecated; please set the field with the same name on the table itself instead. This field needs a wrapper because we want to output the default value, false, if the user explicitly set it.
*/
requirePartitionFilter: Option[Boolean] = None,
/** Required. The supported types are DAY, HOUR, MONTH, and YEAR, which will generate one partition per day, hour, month, and year, respectively.
*/
`type`: Option[String] = None,
)
object TimePartitioning {
implicit val encoder: Encoder[TimePartitioning] = Encoder.instance { x =>
Json.obj(
"expirationMs" := x.expirationMs,
"field" := x.field,
"requirePartitionFilter" := x.requirePartitionFilter,
"type" := x.`type`,
)
}
implicit val decoder: Decoder[TimePartitioning] = Decoder.instance { c =>
for {
v0 <- c.get[Option[FiniteDuration]]("expirationMs")
v1 <- c.get[Option[String]]("field")
v2 <- c.get[Option[Boolean]]("requirePartitionFilter")
v3 <- c.get[Option[String]]("type")
} yield TimePartitioning(v0, v1, v2, v3)
}
}