You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2021/09/04 00:30:20 UTC

[calcite] branch master updated (51c0d92 -> 48d4cfa)

This is an automated email from the ASF dual-hosted git repository.

jhyde pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.


    from 51c0d92  [CALCITE-4584] Using function in partition by list of over window cause converting exception (Wang Yanlin)
     add 8c46299  [CALCITE-4726] Support aggregate calls with a FILTER clause in AggregateExpandWithinDistinctRule (Will Noble)
     new 48d4cfa  [CALCITE-4760] RelBuilder creation fails with error 'No suitable driver found for jdbc:calcite:' in shaded Calcite

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/calcite/jdbc/SimpleCalciteSchema.java   |   2 +-
 .../rules/AggregateExpandWithinDistinctRule.java   | 210 +++++++++++++++++----
 .../java/org/apache/calcite/rex/RexSimplify.java   |   2 +-
 .../java/org/apache/calcite/tools/Frameworks.java  |  13 +-
 .../java/org/apache/calcite/tools/RelBuilder.java  |  16 +-
 .../org/apache/calcite/test/RelBuilderTest.java    |  16 ++
 .../org/apache/calcite/test/RelOptRulesTest.java   | 111 ++++++++++-
 .../org/apache/calcite/test/RelOptRulesTest.xml    | 178 ++++++++++++++++-
 core/src/test/resources/sql/within-distinct.iq     |  47 +++++
 9 files changed, 534 insertions(+), 61 deletions(-)

[calcite] 01/01: [CALCITE-4760] RelBuilder creation fails with error 'No suitable driver found for jdbc:calcite:' in shaded Calcite

Posted by jh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jhyde pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git

commit 48d4cfadd4f521716a7e9a03175e52cd3972e737
Author: Julian Hyde <jh...@apache.org>
AuthorDate: Wed Sep 1 15:48:40 2021 -0700

    [CALCITE-4760] RelBuilder creation fails with error 'No suitable driver found for jdbc:calcite:' in shaded Calcite
    
    This commit does not add tests; it's not easy to reproduce
    issues caused by jar-packaging/shading.
---
 core/src/main/java/org/apache/calcite/tools/Frameworks.java | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/calcite/tools/Frameworks.java b/core/src/main/java/org/apache/calcite/tools/Frameworks.java
index 977cbd4..8ffba39 100644
--- a/core/src/main/java/org/apache/calcite/tools/Frameworks.java
+++ b/core/src/main/java/org/apache/calcite/tools/Frameworks.java
@@ -18,6 +18,7 @@ package org.apache.calcite.tools;
 
 import org.apache.calcite.config.CalciteConnectionProperty;
 import org.apache.calcite.jdbc.CalciteSchema;
+import org.apache.calcite.jdbc.Driver;
 import org.apache.calcite.materialize.SqlStatisticProvider;
 import org.apache.calcite.plan.Context;
 import org.apache.calcite.plan.Contexts;
@@ -42,21 +43,27 @@ import org.apache.calcite.sql2rel.StandardConvertletTable;
 import org.apache.calcite.statistic.QuerySqlStatisticProvider;
 import org.apache.calcite.util.Util;
 
+import com.google.common.base.Suppliers;
 import com.google.common.collect.ImmutableList;
 
 import org.checkerframework.checker.nullness.qual.Nullable;
 
 import java.sql.Connection;
-import java.sql.DriverManager;
 import java.util.List;
 import java.util.Objects;
 import java.util.Properties;
+import java.util.function.Supplier;
 
 /**
  * Tools for invoking Calcite functionality without initializing a container /
  * server first.
  */
 public class Frameworks {
+
+  /** Caches an instance of the JDBC driver. */
+  private static final Supplier<Driver> DRIVER_SUPPLIER =
+      Suppliers.memoize(Driver::new);
+
   private Frameworks() {
   }
 
@@ -174,8 +181,10 @@ public class Frameworks {
         info.setProperty(CalciteConnectionProperty.TYPE_SYSTEM.camelName(),
             config.getTypeSystem().getClass().getName());
       }
+      // Connect via a Driver instance. Don't use DriverManager because driver
+      // auto-loading can get broken by shading and jar-repacking.
       Connection connection =
-          DriverManager.getConnection("jdbc:calcite:", info);
+          DRIVER_SUPPLIER.get().connect("jdbc:calcite:", info);
       final CalciteServerStatement statement =
           connection.createStatement()
               .unwrap(CalciteServerStatement.class);