[ https://issues.apache.org/jira/browse/HIVE-25102?focusedWorklogId=600329&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-600329 ]
ASF GitHub Bot logged work on HIVE-25102: ----------------------------------------- Author: ASF GitHub Bot Created on: 21/May/21 12:23 Start Date: 21/May/21 12:23 Worklog Time Spent: 10m Work Description: pvary commented on a change in pull request #2261: URL: https://github.com/apache/hive/pull/2261#discussion_r636875464 ########## File path: iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/IcebergTableUtil.java ########## @@ -0,0 +1,59 @@ +/* + * 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.iceberg.mr.hive; + +import java.util.Properties; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.ql.QueryState; +import org.apache.hadoop.hive.ql.session.SessionState; +import org.apache.iceberg.Table; +import org.apache.iceberg.mr.Catalogs; + +public class IcebergTableUtil { + + private IcebergTableUtil() { + + } + + /** + * Load the iceberg table either from the {@link QueryState} or through the configured catalog. + * @param configuration a Hadoop configuration + * @param properties controlling properties + * @return + */ + static Table getTable(Configuration configuration, Properties properties) { + // look for the table object stored in the query state. If it's null, it means the table was not loaded yet + // within the same query therefore we claim it through the Catalogs API and then store it in query state. + QueryState queryState = SessionState.get() + .getQueryState(configuration.get(HiveConf.ConfVars.HIVEQUERYID.varname)); + Table table = null; + if (queryState != null) { Review comment: Maybe Optional<QueryState> ? -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 600329) Time Spent: 6h 50m (was: 6h 40m) > Cache Iceberg table objects within same query > --------------------------------------------- > > Key: HIVE-25102 > URL: https://issues.apache.org/jira/browse/HIVE-25102 > Project: Hive > Issue Type: Improvement > Reporter: László Pintér > Assignee: László Pintér > Priority: Major > Labels: pull-request-available > Time Spent: 6h 50m > Remaining Estimate: 0h > > We run Catalogs.loadTable(configuration, props) plenty of times which is > costly. > We should: > - Cache it maybe even globally based on the queryId > - Make sure that the query uses one snapshot during the whole execution of a > single query -- This message was sent by Atlassian Jira (v8.3.4#803005)