From 45ede44c8f6b2492e0a4755a3d8c065fdac5ce38 Mon Sep 17 00:00:00 2001 From: Max Thonagel <12283268+thoniTUB@users.noreply.github.com> Date: Thu, 2 Sep 2021 10:21:11 +0200 Subject: [PATCH] fix open date range for arrow result --- .../io/result/arrow/ArrowRenderer.java | 1 + .../arrow/ArrowResultGenerationTest.java | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/bakdata/conquery/io/result/arrow/ArrowRenderer.java b/backend/src/main/java/com/bakdata/conquery/io/result/arrow/ArrowRenderer.java index e8149eafac..c5ee5a9009 100644 --- a/backend/src/main/java/com/bakdata/conquery/io/result/arrow/ArrowRenderer.java +++ b/backend/src/main/java/com/bakdata/conquery/io/result/arrow/ArrowRenderer.java @@ -183,6 +183,7 @@ private static RowConsumer dateDayVectorFiller(DateDayVector vector, Function dr = (List) obj; - return "{\"min\":" + dr.get(0) + ",\"max\":" + dr.get(1) + "}"; + StringBuilder sb = new StringBuilder(); + sb.append("{"); + final int min = (int) dr.get(0); + final int max = (int) dr.get(1); + // Handle cases where one of the limits is infinity + if (!CDate.isNegativeInfinity(min)) { + sb.append("\"min\":").append(min); + } + if (!CDate.isNegativeInfinity(min) && !CDate.isPositiveInfinity(max)) { + sb.append(","); + } + if (!CDate.isPositiveInfinity(max)) { + sb.append("\"max\":").append(max); + } + sb.append("}"); + return sb.toString(); } if (type.equals(ResultType.ResolutionT.INSTANCE)) { return type.printNullable(settings, obj);