From 68f71d41add98be1da97e22af9d92ac6a99a573d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Wa=C5=9B?= Date: Mon, 20 Jan 2025 15:51:43 +0100 Subject: [PATCH] fixup! Determine range constraints in Faker connector --- .../src/main/java/io/trino/plugin/faker/FakerMetadata.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java b/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java index aa0f3c9c7913..69b993577862 100644 --- a/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java +++ b/plugin/trino-faker/src/main/java/io/trino/plugin/faker/FakerMetadata.java @@ -455,7 +455,11 @@ private synchronized TableInfo createTableInfoFromStats(SchemaTableName tableNam List columns = info.columns(); Map types = columns.stream().collect(toImmutableMap(ColumnInfo::name, ColumnInfo::type)); Long rowCount = null; - for (ComputedStatistics statistic : computedStatistics) { + Optional optionalStatistic = computedStatistics.stream().reduce((_, _) -> { + throw new IllegalStateException("Found more than one computed statistic"); + }); + if (optionalStatistic.isPresent()) { + ComputedStatistics statistic = optionalStatistic.get(); if (!statistic.getTableStatistics().get(ROW_COUNT).isNull(0)) { rowCount = BIGINT.getLong(statistic.getTableStatistics().get(ROW_COUNT), 0); }