github-actions[bot] commented on code in PR #62183: URL: https://github.com/apache/doris/pull/62183#discussion_r3082088978
########## fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnector.java: ########## @@ -0,0 +1,112 @@ +// 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.doris.connector.hive; + +import org.apache.doris.connector.api.Connector; +import org.apache.doris.connector.api.ConnectorMetadata; +import org.apache.doris.connector.api.ConnectorSession; +import org.apache.doris.connector.api.DorisConnectorException; +import org.apache.doris.connector.api.scan.ConnectorScanPlanProvider; +import org.apache.doris.connector.hms.HmsClient; +import org.apache.doris.connector.hms.HmsClientConfig; +import org.apache.doris.connector.hms.ThriftHmsClient; +import org.apache.doris.connector.spi.ConnectorContext; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.util.Collections; +import java.util.Map; + +/** + * Hive connector implementation. Manages the lifecycle of + * an {@link HmsClient} for HMS operations and provides scan planning. + */ +public class HiveConnector implements Connector { + + private static final Logger LOG = LogManager.getLogger(HiveConnector.class); + + private final Map<String, String> properties; + private final ConnectorContext context; + private volatile HmsClient hmsClient; + + public HiveConnector(Map<String, String> properties, ConnectorContext context) { + this.properties = Collections.unmodifiableMap(properties); + this.context = context; + } + + @Override + public ConnectorMetadata getMetadata(ConnectorSession session) { + return new HiveConnectorMetadata(getOrCreateClient(), properties); + } + + @Override + public ConnectorScanPlanProvider getScanPlanProvider() { + return new HiveScanPlanProvider(getOrCreateClient(), properties); + } + + private HmsClient getOrCreateClient() { + if (hmsClient == null) { + synchronized (this) { + if (hmsClient == null) { + hmsClient = createClient(); + } + } + } + return hmsClient; + } + + private HmsClient createClient() { + String metastoreUri = properties.get(HiveConnectorProperties.HIVE_METASTORE_URIS); + if (metastoreUri == null || metastoreUri.isEmpty()) { + // Also check the "uri" short form + metastoreUri = properties.get("uri"); + } + if (metastoreUri == null || metastoreUri.isEmpty()) { + throw new DorisConnectorException( + "HMS URI ('" + HiveConnectorProperties.HIVE_METASTORE_URIS + "') is required"); + } + + int poolSize = HiveConnectorProperties.getInt( + properties, HiveConnectorProperties.HMS_CLIENT_POOL_SIZE, + HiveConnectorProperties.DEFAULT_HMS_CLIENT_POOL_SIZE); + + HmsClientConfig config = new HmsClientConfig(properties, poolSize); + LOG.info("Creating Hive connector client for catalog='{}', uri={}, type={}, poolSize={}", + context.getCatalogName(), config.getMetastoreUri(), + config.getMetastoreType(), poolSize); + + ThriftHmsClient.AuthAction simpleAuth = new ThriftHmsClient.AuthAction() { + @Override + public <T> T execute(java.util.concurrent.Callable<T> callable) throws Exception { + return callable.call(); + } + }; + return new ThriftHmsClient(config, simpleAuth); + } Review Comment: `HiveConnectorMetadata` computes `enable_mapping_binary_as_string` / `enable_mapping_timestamp_tz`, but this creation path still uses `new ThriftHmsClient(config, simpleAuth)`, which hard-wires `HmsTypeMapping.Options.DEFAULT`. In other words, catalogs that enable those mapping flags will still get the default HMS type conversion. Please pass the configured `HmsTypeMapping.Options` into the `ThriftHmsClient` overload here so the SPI path matches the existing catalog behavior. ########## fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnector.java: ########## @@ -0,0 +1,112 @@ +// 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.doris.connector.hive; + +import org.apache.doris.connector.api.Connector; +import org.apache.doris.connector.api.ConnectorMetadata; +import org.apache.doris.connector.api.ConnectorSession; +import org.apache.doris.connector.api.DorisConnectorException; +import org.apache.doris.connector.api.scan.ConnectorScanPlanProvider; +import org.apache.doris.connector.hms.HmsClient; +import org.apache.doris.connector.hms.HmsClientConfig; +import org.apache.doris.connector.hms.ThriftHmsClient; +import org.apache.doris.connector.spi.ConnectorContext; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.io.IOException; +import java.util.Collections; +import java.util.Map; + +/** + * Hive connector implementation. Manages the lifecycle of + * an {@link HmsClient} for HMS operations and provides scan planning. + */ +public class HiveConnector implements Connector { + + private static final Logger LOG = LogManager.getLogger(HiveConnector.class); + + private final Map<String, String> properties; + private final ConnectorContext context; + private volatile HmsClient hmsClient; + + public HiveConnector(Map<String, String> properties, ConnectorContext context) { + this.properties = Collections.unmodifiableMap(properties); + this.context = context; + } + + @Override + public ConnectorMetadata getMetadata(ConnectorSession session) { + return new HiveConnectorMetadata(getOrCreateClient(), properties); + } + + @Override + public ConnectorScanPlanProvider getScanPlanProvider() { + return new HiveScanPlanProvider(getOrCreateClient(), properties); + } + + private HmsClient getOrCreateClient() { + if (hmsClient == null) { + synchronized (this) { + if (hmsClient == null) { + hmsClient = createClient(); + } + } + } + return hmsClient; + } + + private HmsClient createClient() { + String metastoreUri = properties.get(HiveConnectorProperties.HIVE_METASTORE_URIS); + if (metastoreUri == null || metastoreUri.isEmpty()) { + // Also check the "uri" short form + metastoreUri = properties.get("uri"); + } + if (metastoreUri == null || metastoreUri.isEmpty()) { + throw new DorisConnectorException( + "HMS URI ('" + HiveConnectorProperties.HIVE_METASTORE_URIS + "') is required"); + } + + int poolSize = HiveConnectorProperties.getInt( + properties, HiveConnectorProperties.HMS_CLIENT_POOL_SIZE, + HiveConnectorProperties.DEFAULT_HMS_CLIENT_POOL_SIZE); + + HmsClientConfig config = new HmsClientConfig(properties, poolSize); + LOG.info("Creating Hive connector client for catalog='{}', uri={}, type={}, poolSize={}", + context.getCatalogName(), config.getMetastoreUri(), + config.getMetastoreType(), poolSize); + + ThriftHmsClient.AuthAction simpleAuth = new ThriftHmsClient.AuthAction() { + @Override Review Comment: The old HMS path wraps metastore access in a Kerberos-aware authenticator (`HMSBaseProperties` -> `HadoopExecutionAuthenticator` -> `ThriftHMSCachedClient.ugiDoAs`). Here `simpleAuth` always calls straight through, so a catalog configured with `hive.metastore.authentication.type=kerberos` and client principal/keytab will create the Thrift client and issue HMS RPCs without the required `doAs` context. That is a functional regression for secured Hive metastores. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
