From 8da88aebe921beee2e12420e0fcead80911f33a2 Mon Sep 17 00:00:00 2001 From: "pavel.voropaev" Date: Thu, 27 Apr 2023 21:34:17 +0100 Subject: [PATCH] Add numeric types support (close #349) --- .../storage/bigquery/common/Adapter.scala | 21 ++++++++++--------- project/Dependencies.scala | 6 +++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/modules/common/src/main/scala/com/snowplowanalytics/snowplow/storage/bigquery/common/Adapter.scala b/modules/common/src/main/scala/com/snowplowanalytics/snowplow/storage/bigquery/common/Adapter.scala index 0435e860..2b9a759e 100644 --- a/modules/common/src/main/scala/com/snowplowanalytics/snowplow/storage/bigquery/common/Adapter.scala +++ b/modules/common/src/main/scala/com/snowplowanalytics/snowplow/storage/bigquery/common/Adapter.scala @@ -22,7 +22,7 @@ import scala.jdk.CollectionConverters._ /** Transform dependency-free schema-ddl AST into Google Cloud Java definitions */ object Adapter { def adaptRow(row: Row): AnyRef = row match { - case Row.Null => null + case Row.Null => null case Row.Primitive(value) => value.asInstanceOf[AnyRef] case Row.Repeated(rows) => rows.map(adaptRow).asJava @@ -34,8 +34,8 @@ object Adapter { def adaptField(bigQueryField: DdlField): Field = bigQueryField match { - case DdlField(name, record @ Type.Record(fields), mode) => - val subFields = fields.map(adaptField) + case DdlField(name, record@Type.Record(fields), mode) => + val subFields = fields.map(adaptField) val fieldsList = FieldList.of(subFields.asJava) Field.newBuilder(name, adaptType(record), fieldsList).setMode(adaptMode(mode)).build() case DdlField(name, fieldType, mode) => @@ -52,13 +52,14 @@ object Adapter { def adaptType(fieldType: Type): LegacySQLTypeName = fieldType match { case Type.Timestamp => LegacySQLTypeName.TIMESTAMP - case Type.Integer => LegacySQLTypeName.INTEGER - case Type.Boolean => LegacySQLTypeName.BOOLEAN - case Type.String => LegacySQLTypeName.STRING - case Type.Float => LegacySQLTypeName.FLOAT - case Type.Numeric => LegacySQLTypeName.NUMERIC - case Type.Date => LegacySQLTypeName.DATE - case Type.DateTime => LegacySQLTypeName.DATETIME + case Type.Integer => LegacySQLTypeName.INTEGER + case Type.Boolean => LegacySQLTypeName.BOOLEAN + case Type.String => LegacySQLTypeName.STRING + case Type.Float => LegacySQLTypeName.FLOAT + case Type.Numeric(precision, scale) if (precision <= 38) & (scale <= 9) => LegacySQLTypeName.NUMERIC + case _: Type.Numeric => LegacySQLTypeName.BIGNUMERIC + case Type.Date => LegacySQLTypeName.DATE + case Type.DateTime => LegacySQLTypeName.DATETIME case Type.Record(_) => LegacySQLTypeName.RECORD } } diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 5a741478..27238c1b 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -32,20 +32,20 @@ object Dependencies { val cats = "2.6.1" val catsEffect = "3.3.12" val catsRetry = "3.1.0" - val circe = "0.14.1" + val circe = "0.14.3" val decline = "1.4.0" val fs2 = "3.2.8" val httpClient = "0.23.18" val logging = "2.3.1" val pubsubFs2 = "0.20.0" - val circeConfig = "0.8.0" + val circeConfig = "0.10.0" // Scala Snowplow val analyticsSdk = "2.1.0" val badrows = "2.2.0" val igluClient = "2.2.0" val igluCore = "1.0.1" - val schemaDdl = "0.14.4" + val schemaDdl = "0.19.0-M1" // Scala (test only) val specs2 = "4.13.2"