parthchandra commented on code in PR #45488:
URL: https://github.com/apache/spark/pull/45488#discussion_r1550642869
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala:
##########
@@ -369,6 +372,26 @@ class QueryExecution(
Utils.redact(sparkSession.sessionState.conf.stringRedactionPattern,
message)
}
+ def extendedExplainInfo(append: String => Unit, plan: SparkPlan): Unit = {
+ try {
+ val generator =
sparkSession.sparkContext.conf.get(EXTENDED_EXPLAIN_PROVIDER.key)
+ try {
+ val extensionClass = Utils.classForName(generator)
+ val extension = extensionClass.getConstructor().newInstance()
+ .asInstanceOf[ExtendedExplainGenerator]
Review Comment:
Good suggestion. I was not aware of this method. It is much cleaner to use.
Ironically, we do not use this method to load session extensions!
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala:
##########
@@ -369,6 +372,26 @@ class QueryExecution(
Utils.redact(sparkSession.sessionState.conf.stringRedactionPattern,
message)
}
+ def extendedExplainInfo(append: String => Unit, plan: SparkPlan): Unit = {
+ try {
+ val generator =
sparkSession.sparkContext.conf.get(EXTENDED_EXPLAIN_PROVIDER.key)
Review Comment:
It was originally a session config, then after a previous review comment,
made it static. Thinking about it again, it seems it might be better to allow
it as a session conf. The extended info can then be turned on/off for specific
sessions among other cases.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/ExtendedExplainGenerator.scala:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.execution
+
+/**
+ * A trait for a session extension to implement that provides addition explain
plan
+ * information.
+ */
+trait ExtendedExplainGenerator {
Review Comment:
Good point. Thanks!
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/QueryExecution.scala:
##########
@@ -369,6 +372,26 @@ class QueryExecution(
Utils.redact(sparkSession.sessionState.conf.stringRedactionPattern,
message)
}
+ def extendedExplainInfo(append: String => Unit, plan: SparkPlan): Unit = {
+ try {
+ val generator =
sparkSession.sparkContext.conf.get(EXTENDED_EXPLAIN_PROVIDER.key)
+ try {
+ val extensionClass = Utils.classForName(generator)
+ val extension = extensionClass.getConstructor().newInstance()
+ .asInstanceOf[ExtendedExplainGenerator]
+ append("\n== Extended Information ==\n")
+ append(extension.generateExtendedInfo(plan))
+ } catch {
+ case e@(_: ClassCastException |
+ _: ClassNotFoundException |
+ _: NoClassDefFoundError) =>
Review Comment:
Done
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/ExtendedExplainGenerator.scala:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.execution
Review Comment:
Done
--
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]