This is an automated email from the ASF dual-hosted git repository.
progers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/druid.git
The following commit(s) were added to refs/heads/master by this push:
new 9e9976001c Add ANSI_QUOTES propety to DBI init in lookups. (#13826)
9e9976001c is described below
commit 9e9976001c5692732be4b7e28d79886e0d6859a9
Author: Abhishek Radhakrishnan <[email protected]>
AuthorDate: Tue Feb 21 15:13:22 2023 -0800
Add ANSI_QUOTES propety to DBI init in lookups. (#13826)
---
.../server/lookup/namespace/JdbcCacheGenerator.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git
a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/JdbcCacheGenerator.java
b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/JdbcCacheGenerator.java
index b9d1a4cda6..8c0fc5f7db 100644
---
a/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/JdbcCacheGenerator.java
+++
b/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/JdbcCacheGenerator.java
@@ -40,6 +40,7 @@ import org.skife.jdbi.v2.util.TimestampMapper;
import javax.annotation.Nullable;
import java.sql.Timestamp;
+import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -191,10 +192,21 @@ public final class JdbcCacheGenerator implements
CacheGenerator<JdbcExtractionNa
dbi = dbiCache.get(key);
}
if (dbi == null) {
+ Properties props = new Properties();
+ if (namespace.getConnectorConfig().getUser() != null) {
+ props.setProperty("user", namespace.getConnectorConfig().getUser());
+ }
+ if (namespace.getConnectorConfig().getPassword() != null) {
+ props.setProperty("password",
namespace.getConnectorConfig().getPassword());
+ }
+
+ // We use double quotes to quote identifiers. This enables us to write
SQL
+ // that works with most databases that are SQL compliant.
+ props.setProperty("sessionVariables", "sql_mode='ANSI_QUOTES'");
+
final DBI newDbi = new DBI(
namespace.getConnectorConfig().getConnectURI(),
- namespace.getConnectorConfig().getUser(),
- namespace.getConnectorConfig().getPassword()
+ props
);
dbiCache.putIfAbsent(key, newDbi);
dbi = dbiCache.get(key);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]