You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2022/12/01 12:41:00 UTC
[jira] [Commented] (DRILL-8358) Storage plugin for querying other Apache Drill clusters
[ https://issues.apache.org/jira/browse/DRILL-8358?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17641891#comment-17641891 ]
ASF GitHub Bot commented on DRILL-8358:
---------------------------------------
jnturton commented on code in PR #2709:
URL: https://github.com/apache/drill/pull/2709#discussion_r1037061461
##########
contrib/storage-drill/src/main/java/org/apache/drill/exec/store/drill/plugin/DrillStoragePluginConfig.java:
##########
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.store.drill.plugin;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.calcite.avatica.ConnectStringParser;
+import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.common.config.DrillProperties;
+import org.apache.drill.common.logical.StoragePluginConfig;
+import org.apache.drill.common.logical.security.CredentialsProvider;
+import org.apache.drill.common.logical.security.PlainCredentialsProvider;
+import org.apache.drill.exec.client.DrillClient;
+import org.apache.drill.exec.memory.BufferAllocator;
+import org.apache.drill.exec.rpc.RpcException;
+
+import java.sql.SQLException;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Properties;
+
+@JsonTypeName(DrillStoragePluginConfig.NAME)
+public class DrillStoragePluginConfig extends StoragePluginConfig {
+ public static final String NAME = "drill";
+ public static final String CONNECTION_STRING_PREFIX = "jdbc:drill:";
+
+ private static final String DEFAULT_QUOTING_IDENTIFIER = "`";
+
+ private final String connection;
+ private final Properties properties;
+
+ @JsonCreator
+ public DrillStoragePluginConfig(
+ @JsonProperty("connection") String connection,
+ @JsonProperty("properties") Properties properties,
+ @JsonProperty("credentialsProvider") CredentialsProvider credentialsProvider) {
+ super(getCredentialsProvider(credentialsProvider), credentialsProvider == null);
+ this.connection = connection;
+ this.properties = Optional.ofNullable(properties).orElse(new Properties());
+ }
+
+ private DrillStoragePluginConfig(DrillStoragePluginConfig that,
+ CredentialsProvider credentialsProvider) {
+ super(getCredentialsProvider(credentialsProvider),
+ credentialsProvider == null, that.authMode);
+ this.connection = that.connection;
+ this.properties = that.properties;
+ }
+
+ @JsonProperty("connection")
+ public String getConnection() {
+ return connection;
+ }
+
+ @JsonProperty("properties")
+ public Properties getProperties() {
+ return properties;
+ }
+
+ private static CredentialsProvider getCredentialsProvider(CredentialsProvider credentialsProvider) {
+ return credentialsProvider != null ? credentialsProvider : PlainCredentialsProvider.EMPTY_CREDENTIALS_PROVIDER;
+ }
+
+ @JsonIgnore
+ public String getIdentifierQuoteString() {
+ return properties.getProperty(DrillProperties.QUOTING_IDENTIFIERS, DEFAULT_QUOTING_IDENTIFIER);
+ }
+
+ @Override
+ public DrillStoragePluginConfig updateCredentialProvider(CredentialsProvider credentialsProvider) {
+ return new DrillStoragePluginConfig(this, credentialsProvider);
+ }
+
+ @JsonIgnore
+ public DrillClient getDrillClient(String userName, BufferAllocator allocator) {
+ try {
+ String urlSuffix = connection.substring(CONNECTION_STRING_PREFIX.length());
+ Properties props = ConnectStringParser.parse(urlSuffix, properties);
+ props.putAll(credentialsProvider.getUserCredentials(userName));
Review Comment:
This getUserCredentials(String username) method is meant to fetch per-query-user credentials for plugins that are in user translation auth mode while the nullary method getUserCredentials() is meant for shared credentials. Only the plan and Vault providers currently support per-user credentials. You can see some logic for deciding which to call (via UsernamePasswordCredentials objects) in JdbcStorageConfig on line 142.
Those APIs wound up being a little ugly :/
##########
contrib/storage-drill/src/main/java/org/apache/drill/exec/store/drill/plugin/package-info.java:
##########
@@ -15,24 +15,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.drill.jdbc;
-
-import java.sql.SQLTimeoutException;
-
/**
- * Indicates that an operation timed out. This is not an error; you can
- * retry the operation.
+ * Drill storage plugin.
+ * <p>
+ * Enables querying Drill as a data store.
*/
-public class SqlTimeoutException extends SQLTimeoutException {
- private static final long serialVersionUID = 2017_04_03L;
-
- SqlTimeoutException() {
- // SQLException(reason, SQLState, vendorCode)
- // REVIEW mb 19-Jul-05 Is there a standard SQLState?
- super("timeout", null, 0);
- }
-
- public SqlTimeoutException(long timeoutValueInSeconds) {
- super("Query timed out in "+ timeoutValueInSeconds + " seconds");
- }
-}
+package org.apache.drill.exec.store.drill.plugin;
Review Comment:
So Git decided that this was the renaming of a file 😏
> Storage plugin for querying other Apache Drill clusters
> -------------------------------------------------------
>
> Key: DRILL-8358
> URL: https://issues.apache.org/jira/browse/DRILL-8358
> Project: Apache Drill
> Issue Type: New Feature
> Reporter: Vova Vysotskyi
> Assignee: Vova Vysotskyi
> Priority: Major
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)