diff --git a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryResultPageSource.java b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryResultPageSource.java index 681a891d36e0..df894a10c228 100644 --- a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryResultPageSource.java +++ b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryResultPageSource.java @@ -27,6 +27,7 @@ import io.trino.spi.type.ArrayType; import io.trino.spi.type.DecimalType; import io.trino.spi.type.Decimals; +import io.trino.spi.type.Int128; import io.trino.spi.type.LongTimestampWithTimeZone; import io.trino.spi.type.RowType; import io.trino.spi.type.Type; @@ -190,6 +191,9 @@ else if (type.equals(TIME_MICROS)) { else if (javaType == double.class) { type.writeDouble(output, ((Number) value).doubleValue()); } + else if (type.getJavaType() == Int128.class) { + writeObject(output, type, value); + } else if (javaType == Slice.class) { writeSlice(output, type, value); } @@ -217,12 +221,6 @@ private static void writeSlice(BlockBuilder output, Type type, Object value) if (type instanceof VarcharType) { type.writeSlice(output, utf8Slice(((Utf8) value).toString())); } - else if (type instanceof DecimalType) { - verify(isLongDecimal(type), "The type should be long decimal"); - DecimalType decimalType = (DecimalType) type; - BigDecimal decimal = DECIMAL_CONVERTER.convert(decimalType.getPrecision(), decimalType.getScale(), value); - type.writeObject(output, Decimals.encodeScaledValue(decimal, decimalType.getScale())); - } else if (type instanceof VarbinaryType) { if (value instanceof ByteBuffer) { type.writeSlice(output, Slices.wrappedBuffer((ByteBuffer) value)); @@ -236,6 +234,19 @@ else if (type instanceof VarbinaryType) { } } + private static void writeObject(BlockBuilder output, Type type, Object value) + { + if (type instanceof DecimalType) { + verify(isLongDecimal(type), "The type should be long decimal"); + DecimalType decimalType = (DecimalType) type; + BigDecimal decimal = DECIMAL_CONVERTER.convert(decimalType.getPrecision(), decimalType.getScale(), value); + type.writeObject(output, Decimals.encodeScaledValue(decimal, decimalType.getScale())); + } + else { + throw new TrinoException(GENERIC_INTERNAL_ERROR, "Unhandled type for Object: " + type.getTypeSignature()); + } + } + private void writeBlock(BlockBuilder output, Type type, Object value) { if (type instanceof ArrayType && value instanceof List) {