From ec1f443a5ccd8db08f2003385b814d9947d2725e Mon Sep 17 00:00:00 2001 From: Clint Wylie Date: Wed, 24 Jun 2020 19:58:34 -0700 Subject: [PATCH] update avatica to handle additional character sets over jdbc (#10074) * update avatica to handle additional character sets over jdbc * update license yaml, fix test * oops --- licenses.yaml | 8 ++--- pom.xml | 2 +- .../sql/avatica/DruidAvaticaHandlerTest.java | 30 +++++++++++++++++++ .../druid/sql/calcite/CalciteQueryTest.java | 4 +-- .../druid/sql/calcite/util/CalciteTests.java | 2 +- .../druid/sql/http/SqlResourceTest.java | 17 +++++++++++ 6 files changed, 55 insertions(+), 8 deletions(-) diff --git a/licenses.yaml b/licenses.yaml index 24d93ee0d1c..709772cba34 100644 --- a/licenses.yaml +++ b/licenses.yaml @@ -1295,7 +1295,7 @@ name: Apache Calcite Avatica license_category: binary module: java-core license_name: Apache License version 2.0 -version: 1.15.0 +version: 1.17.0 libraries: - org.apache.calcite.avatica: avatica-core - org.apache.calcite.avatica: avatica-metrics @@ -1303,13 +1303,13 @@ libraries: notices: - avatica-core: | Apache Calcite Avatica - Copyright 2012-2018 The Apache Software Foundation + Copyright 2012-2020 The Apache Software Foundation - avatica-metrics: | Apache Calcite Avatica Metrics - Copyright 2012-2018 The Apache Software Foundation + Copyright 2012-2020 The Apache Software Foundation - avatica-server: | Apache Calcite Avatica Server - Copyright 2012-2018 The Apache Software Foundation + Copyright 2012-2020 The Apache Software Foundation --- name: Apache Curator diff --git a/pom.xml b/pom.xml index 8c024bd83cb..b774edbd8e1 100644 --- a/pom.xml +++ b/pom.xml @@ -81,7 +81,7 @@ 2.5.0 2.0.0 2.2.4 - 1.15.0 + 1.17.0 1.9.2 1.21.0 1.3.0-incubating diff --git a/sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java b/sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java index 3f43f76c175..99b8cd51fd3 100644 --- a/sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java +++ b/sql/src/test/java/org/apache/druid/sql/avatica/DruidAvaticaHandlerTest.java @@ -991,6 +991,36 @@ public class DruidAvaticaHandlerTest extends CalciteTestBase ); } + @Test + public void testExtendedCharacters() throws Exception + { + final ResultSet resultSet = client.createStatement().executeQuery( + "SELECT COUNT(*) AS cnt FROM druid.lotsocolumns WHERE dimMultivalEnumerated = 'ㅑ ㅓ ㅕ ㅗ ㅛ ㅜ ㅠ ㅡ ㅣ'" + ); + final List> rows = getRows(resultSet); + Assert.assertEquals( + ImmutableList.of( + ImmutableMap.of("cnt", 1L) + ), + rows + ); + + + PreparedStatement statement = client.prepareStatement( + "SELECT COUNT(*) AS cnt FROM druid.lotsocolumns WHERE dimMultivalEnumerated = ?" + ); + statement.setString(1, "ㅑ ㅓ ㅕ ㅗ ㅛ ㅜ ㅠ ㅡ ㅣ"); + final ResultSet resultSet2 = statement.executeQuery(); + final List> rows2 = getRows(resultSet2); + Assert.assertEquals( + ImmutableList.of( + ImmutableMap.of("cnt", 1L) + ), + rows + ); + Assert.assertEquals(rows, rows2); + } + @Test public void testEscapingForGetColumns() throws Exception { diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java index 622842fd32e..17c970fa138 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java @@ -1261,7 +1261,7 @@ public class CalciteQueryTest extends BaseCalciteQueryTest 1576306800000L, 1L, "8", - "[\"Baz\",\"World\",\"World\",\"World\"]", + "[\"Baz\",\"World\",\"ㅑ ㅓ ㅕ ㅗ ㅛ ㅜ ㅠ ㅡ ㅣ\"]", useDefault ? "[\"\",\"Corundum\",\"Xylophone\"]" : "[null,\"Corundum\",\"Xylophone\"]", useDefault ? "" : null, "8", @@ -1331,7 +1331,7 @@ public class CalciteQueryTest extends BaseCalciteQueryTest 1576306800000L, 1L, "8", - "[\"Baz\",\"World\",\"World\",\"World\"]", + "[\"Baz\",\"World\",\"ㅑ ㅓ ㅕ ㅗ ㅛ ㅜ ㅠ ㅡ ㅣ\"]", useDefault ? "[\"\",\"Corundum\",\"Xylophone\"]" : "[null,\"Corundum\",\"Xylophone\"]", useDefault ? "" : null, "8", diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/util/CalciteTests.java b/sql/src/test/java/org/apache/druid/sql/calcite/util/CalciteTests.java index dfee466bcef..6c6427e12ee 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/util/CalciteTests.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/util/CalciteTests.java @@ -608,7 +608,7 @@ public class CalciteTests .put("metFloatNormal", 4999.0) .put("dimZipf", "9") .put("dimUniform", "50515") - .put("dimMultivalEnumerated", Arrays.asList("Baz", "World", "World", "World")) + .put("dimMultivalEnumerated", Arrays.asList("Baz", "World", "ㅑ ㅓ ㅕ ㅗ ㅛ ㅜ ㅠ ㅡ ㅣ")) .put("metLongSequential", 8) .put("dimHyperUnique", "8") .put("dimSequential", "8") diff --git a/sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java b/sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java index c4e2de59c95..cc3bce3f6b2 100644 --- a/sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java +++ b/sql/src/test/java/org/apache/druid/sql/http/SqlResourceTest.java @@ -243,6 +243,23 @@ public class SqlResourceTest extends CalciteTestBase checkSqlRequestLog(true); } + + @Test + public void testCountStarExtendedCharacters() throws Exception + { + final List> rows = doPost( + new SqlQuery("SELECT COUNT(*) AS cnt FROM druid.lotsocolumns WHERE dimMultivalEnumerated = 'ㅑ ㅓ ㅕ ㅗ ㅛ ㅜ ㅠ ㅡ ㅣ'", null, false, null, null) + ).rhs; + + Assert.assertEquals( + ImmutableList.of( + ImmutableMap.of("cnt", 1) + ), + rows + ); + checkSqlRequestLog(true); + } + @Test public void testTimestampsInResponse() throws Exception {