juliuszsompolski commented on a change in pull request #28671:
URL: https://github.com/apache/spark/pull/28671#discussion_r432671994



##########
File path: 
sql/hive-thriftserver/v2.3/src/main/java/org/apache/hive/service/cli/operation/Operation.java
##########
@@ -298,7 +298,10 @@ public void cancel() throws HiveSQLException {
     throw new UnsupportedOperationException("SQLOperation.cancel()");
   }
 
-  public abstract void close() throws HiveSQLException;
+  public void close() throws HiveSQLException {
+    setState(OperationState.CLOSED);
+    cleanupOperationLog();
+  }

Review comment:
       I needed to add this concrete base implementation here, otherwise the 
abstract override of close() in the trait didn't work in 
SparkExecuteStatementOperation, because it didn't have a concrete 
implementation in any of the subclasses.
   On the other hand, if I wanted to implement it concretely in the trait, it 
was complaining about not being able to call protected methods from Java class 
in the trait.
   
   This base implementation here is doing what it was doing in all the 
operations we have.
   It might have been another tiny bug that SparkExecuteStatementOperation did 
not call cleanupOperationLog. The other operations did via their super call.

##########
File path: 
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkOperation.scala
##########
@@ -0,0 +1,97 @@
+/*
+ * 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.spark.sql.hive.thriftserver
+
+import org.apache.hive.service.cli.OperationState
+import org.apache.hive.service.cli.operation.Operation
+
+import org.apache.spark.SparkContext
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.{SparkSession, SQLContext}
+import org.apache.spark.sql.catalyst.catalog.CatalogTableType
+import org.apache.spark.sql.catalyst.catalog.CatalogTableType.{EXTERNAL, 
MANAGED, VIEW}
+import org.apache.spark.sql.internal.SQLConf
+import org.apache.spark.util.Utils
+
+/**
+ * Utils for Spark operations.
+ */
+private[hive] trait SparkOperation extends Operation with Logging {
+
+  protected def sqlContext: SQLContext
+
+  protected var statementId = 
getHandle().getHandleIdentifier().getPublicId().toString()

Review comment:
       Instead of creating a new UUID, I use the one that is already created 
for the operation.
   I found it confusing when debugging, that there were two UUIDs used for 
operations: SparkUI and some of the logs from Spark classes used the ones we 
created, while log lines from Hive imported code used this one, and the two 
couldn't be linked together... Now they are going to be the same id, which 
should make debugging easier.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to