Revert "connection supplies properties approach"

This reverts commit 2700557a55.
This commit is contained in:
Zoltan Haindrich 2024-08-06 15:28:58 +00:00
parent 2700557a55
commit 69a39a42da
6 changed files with 7 additions and 62 deletions

View File

@ -160,14 +160,4 @@ public class MSQDruidMeta extends DruidMeta
}
@Override
public Map<String, String> getEngineProperties()
{
return ImmutableMap.<String, String>builder()
.putAll(super.getEngineProperties())
.put("isMSQ", "true")
.put("isNative", "false")
.build();
}
}

View File

@ -1,3 +1,5 @@
!set isNative false
!set isMSQ true
!set plannerStrategy DECOUPLED
!if (isMSQ) {
!use druidtest://?componentSupplier=DrillWindowQueryMSQComponentSupplier

View File

@ -933,9 +933,4 @@ public class DruidMeta extends MetaImpl
{
return Calcites.escapeStringLiteral(toEscape) + " ESCAPE '\\'";
}
public Map<String, String> getEngineProperties()
{
return ImmutableMap.of("isNative", "true");
}
}

View File

@ -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

View File

@ -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<String, String> getEngineProperties();
class DruidConnectionExtrasImpl implements DruidConnectionExtras
{
private final ObjectMapper objectMapper;
private final DruidHookDispatcher druidHookDispatcher;
private final Map<String, String> engineProperties;
public DruidConnectionExtrasImpl(ObjectMapper objectMapper,
DruidHookDispatcher druidHookDispatcher,
Map<String, String> 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<String, String> 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!");
}
}

View File

@ -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<String, String> 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<String, String> 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);
}
}