From 4a06bc3ae6022d0d0cb4e23e9f955beefabe1902 Mon Sep 17 00:00:00 2001 From: ljfgem <82360990+ljfgem@users.noreply.github.com> Date: Fri, 18 Jun 2021 10:10:19 -0700 Subject: [PATCH] Allow empty array (#101) * Bump calcite version to 1.21.0.148 * Allow users to select empty array with calcite 1.21.0.149 --- coral-hive/build.gradle | 2 +- .../hive/hive2rel/HiveToRelConverterTest.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/coral-hive/build.gradle b/coral-hive/build.gradle index fa4dd6b27..b92c7d4c2 100644 --- a/coral-hive/build.gradle +++ b/coral-hive/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'antlr' dependencies { antlr deps.'antlr' - compile('com.linkedin.calcite:calcite-core:1.21.0.148') { + compile('com.linkedin.calcite:calcite-core:1.21.0.149') { artifact { name = 'calcite-core' extension = 'jar' diff --git a/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverterTest.java b/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverterTest.java index dca662052..35081cbc7 100644 --- a/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverterTest.java +++ b/coral-hive/src/test/java/com/linkedin/coral/hive/hive2rel/HiveToRelConverterTest.java @@ -191,6 +191,21 @@ public void testArrayType() { assertEquals(RelOptUtil.toString(converter.convertSql(sql)), expected); } + @Test + public void testSelectEmptyArray() { + final String sql = "SELECT array()"; + final String expected = "LogicalProject(EXPR$0=[ARRAY()])\n" + " LogicalValues(tuples=[[{ 0 }]])\n"; + assertEquals(RelOptUtil.toString(converter.convertSql(sql)), expected); + } + + @Test + public void testEmptyArrayInFilter() { + String sql = "SELECT 1 WHERE array_contains(array(), '1')"; + String expected = "LogicalProject(EXPR$0=[1])\n" + " LogicalFilter(condition=[array_contains(ARRAY(), '1')])\n" + + " LogicalValues(tuples=[[{ 0 }]])\n"; + assertEquals(RelOptUtil.toString(converter.convertSql(sql)), expected); + } + @Test public void testSelectArrayElement() { final String sql = "SELECT c[0] from complex";