From 69a39a42da94ae6b645696860b009457d62d2ae2 Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Tue, 6 Aug 2024 15:28:58 +0000 Subject: [PATCH] Revert "connection supplies properties approach" This reverts commit 2700557a55921145877b4dd51b301cc48815aa09. --- .../druid/sql/avatica/MSQDruidMeta.java | 10 -------- .../msq2.iq | 2 ++ .../apache/druid/sql/avatica/DruidMeta.java | 5 ---- .../druid/quidem/DruidAvaticaTestDriver.java | 12 +++------- .../druid/quidem/DruidConnectionExtras.java | 16 +------------ .../quidem/DruidQuidemConnectionFactory.java | 24 +------------------ 6 files changed, 7 insertions(+), 62 deletions(-) diff --git a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java index c6c17a67f5d..845d8adb2b3 100644 --- a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java +++ b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/sql/avatica/MSQDruidMeta.java @@ -160,14 +160,4 @@ public class MSQDruidMeta extends DruidMeta } - @Override - public Map getEngineProperties() - { - return ImmutableMap.builder() - .putAll(super.getEngineProperties()) - .put("isMSQ", "true") - .put("isNative", "false") - .build(); - } - } diff --git a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq2.iq b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq2.iq index f83a3747719..f36f8e04460 100644 --- a/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq2.iq +++ b/extensions-core/multi-stage-query/src/test/quidem/org.apache.druid.msq.exec.MSQQuidemTest/msq2.iq @@ -1,3 +1,5 @@ +!set isNative false +!set isMSQ true !set plannerStrategy DECOUPLED !if (isMSQ) { !use druidtest://?componentSupplier=DrillWindowQueryMSQComponentSupplier diff --git a/sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java b/sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java index 3143fba5d84..e271a6f60ab 100644 --- a/sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java +++ b/sql/src/main/java/org/apache/druid/sql/avatica/DruidMeta.java @@ -933,9 +933,4 @@ public class DruidMeta extends MetaImpl { return Calcites.escapeStringLiteral(toEscape) + " ESCAPE '\\'"; } - - public Map getEngineProperties() - { - return ImmutableMap.of("isNative", "true"); - } } diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java index c25f9275152..30eca2782e7 100644 --- a/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java +++ b/sql/src/test/java/org/apache/druid/quidem/DruidAvaticaTestDriver.java @@ -120,16 +120,9 @@ public class DruidAvaticaTestDriver implements Driver @Provides @LazySingleton - public DruidConnectionExtras getConnectionExtras( - ObjectMapper objectMapper, - DruidHookDispatcher druidHookDispatcher, - DruidMeta meta) + public DruidConnectionExtras getConnectionExtras(ObjectMapper objectMapper, DruidHookDispatcher druidHookDispatcher) { - return new DruidConnectionExtras.DruidConnectionExtrasImpl( - objectMapper, - druidHookDispatcher, - meta.getEngineProperties() - ); + return new DruidConnectionExtras.DruidConnectionExtrasImpl(objectMapper, druidHookDispatcher); } @Provides @@ -151,6 +144,7 @@ public class DruidAvaticaTestDriver implements Driver { closer.close(); } + } static class AvaticaJettyServer implements Closeable diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidConnectionExtras.java b/sql/src/test/java/org/apache/druid/quidem/DruidConnectionExtras.java index c7538775c06..176411a6bb7 100644 --- a/sql/src/test/java/org/apache/druid/quidem/DruidConnectionExtras.java +++ b/sql/src/test/java/org/apache/druid/quidem/DruidConnectionExtras.java @@ -23,7 +23,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.druid.sql.hook.DruidHookDispatcher; import java.sql.Connection; -import java.util.Map; public interface DruidConnectionExtras { @@ -31,21 +30,15 @@ public interface DruidConnectionExtras DruidHookDispatcher getDruidHookDispatcher(); - Map getEngineProperties(); - class DruidConnectionExtrasImpl implements DruidConnectionExtras { private final ObjectMapper objectMapper; private final DruidHookDispatcher druidHookDispatcher; - private final Map engineProperties; - public DruidConnectionExtrasImpl(ObjectMapper objectMapper, - DruidHookDispatcher druidHookDispatcher, - Map engineProperties) + public DruidConnectionExtrasImpl(ObjectMapper objectMapper, DruidHookDispatcher druidHookDispatcher) { this.objectMapper = objectMapper; this.druidHookDispatcher = druidHookDispatcher; - this.engineProperties = engineProperties; } @Override @@ -59,12 +52,6 @@ public interface DruidConnectionExtras { return druidHookDispatcher; } - - @Override - public Map getEngineProperties() - { - return engineProperties; - } } static DruidConnectionExtras unwrapOrThrow(Connection connection) @@ -74,5 +61,4 @@ public interface DruidConnectionExtras } throw new UnsupportedOperationException("Expected DruidConnectionExtras to be implemented by connection!"); } - } diff --git a/sql/src/test/java/org/apache/druid/quidem/DruidQuidemConnectionFactory.java b/sql/src/test/java/org/apache/druid/quidem/DruidQuidemConnectionFactory.java index 1c38702537c..b9a7963f4d8 100644 --- a/sql/src/test/java/org/apache/druid/quidem/DruidQuidemConnectionFactory.java +++ b/sql/src/test/java/org/apache/druid/quidem/DruidQuidemConnectionFactory.java @@ -21,16 +21,13 @@ package org.apache.druid.quidem; import net.hydromatic.quidem.Quidem.ConnectionFactory; import net.hydromatic.quidem.Quidem.PropertyHandler; - import java.sql.Connection; import java.sql.DriverManager; -import java.util.Map; import java.util.Properties; public class DruidQuidemConnectionFactory implements ConnectionFactory, PropertyHandler { private Properties props = new Properties(); - private Map engineProperties; public DruidQuidemConnectionFactory() { @@ -42,33 +39,14 @@ public class DruidQuidemConnectionFactory implements ConnectionFactory, Property public Connection connect(String name, boolean reference) throws Exception { if (name.startsWith("druidtest://")) { - Connection connection = DriverManager.getConnection(name, props); - engineProperties = unwrapEngineProperties(connection); - return connection; + return DriverManager.getConnection(name, props); } throw new RuntimeException("unknown connection '" + name + "'"); } - private Map unwrapEngineProperties(Connection connection) - { - if(connection instanceof DruidConnectionExtras) { - DruidConnectionExtras extras = ((DruidConnectionExtras) connection); - return extras.getEngineProperties(); - } - return null; - } - @Override public void onSet(String key, Object value) { props.setProperty(key, value.toString()); } - - public Object getEnv(String env) - { - if (engineProperties == null) { - return null; - } - return engineProperties.get(env); - } }