From 5fa7412c7a4950eb1ef58c71524c82ab3737ee51 Mon Sep 17 00:00:00 2001 From: frank chen Date: Fri, 18 Jun 2021 11:31:12 +0800 Subject: [PATCH] Add jsonPath function length() to Parquet --- .../example/flattening/flat_1_flatten.json | 5 +++++ .../data/input/parquet/simple/ParquetGroupJsonProvider.java | 2 +- .../data/input/parquet/FlattenSpecParquetInputTest.java | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions-core/parquet-extensions/example/flattening/flat_1_flatten.json b/extensions-core/parquet-extensions/example/flattening/flat_1_flatten.json index 75caf256f2a..760dea7757b 100644 --- a/extensions-core/parquet-extensions/example/flattening/flat_1_flatten.json +++ b/extensions-core/parquet-extensions/example/flattening/flat_1_flatten.json @@ -46,6 +46,11 @@ "type": "path", "name": "list", "expr": "$.listDim" + }, + { + "type": "path", + "name": "listLength", + "expr": "$.listDim.length()" } ] }, diff --git a/extensions-core/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/simple/ParquetGroupJsonProvider.java b/extensions-core/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/simple/ParquetGroupJsonProvider.java index 3ba15e41a98..3190c7e28ad 100644 --- a/extensions-core/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/simple/ParquetGroupJsonProvider.java +++ b/extensions-core/parquet-extensions/src/main/java/org/apache/druid/data/input/parquet/simple/ParquetGroupJsonProvider.java @@ -191,7 +191,7 @@ public class ParquetGroupJsonProvider implements JsonProvider @Override public Object unwrap(final Object o) { - throw new UnsupportedOperationException("Unused"); + return o; } } diff --git a/extensions-core/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/FlattenSpecParquetInputTest.java b/extensions-core/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/FlattenSpecParquetInputTest.java index 6532ab222df..38a916c93e0 100644 --- a/extensions-core/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/FlattenSpecParquetInputTest.java +++ b/extensions-core/parquet-extensions/src/test/java/org/apache/druid/data/input/parquet/FlattenSpecParquetInputTest.java @@ -116,6 +116,7 @@ public class FlattenSpecParquetInputTest extends BaseParquetInputTest Assert.assertEquals("1", rows.get(0).getDimension("dim3").get(0)); Assert.assertEquals("listDim1v1", rows.get(0).getDimension("list").get(0)); Assert.assertEquals("listDim1v2", rows.get(0).getDimension("list").get(1)); + Assert.assertEquals("2", rows.get(0).getDimension("listLength").get(0)); Assert.assertEquals(1, rows.get(0).getMetric("metric1").longValue()); }