-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-41432][UI][SQL] Protobuf serializer for SparkPlanGraphWrapper #39164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
743cd10
4e6f9b2
25b63fa
558ad23
0f9f767
f9b0c13
72e658a
c721cca
98e0ebb
ab51bef
a34dd22
49ef0ed
ce8621d
4a8e9d3
f8ffa42
7c0d6be
29c4ef4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -208,6 +208,12 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <artifactId>htmlunit-driver</artifactId> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <scope>test</scope> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </dependency> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <dependency> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <groupId>com.google.protobuf</groupId> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <artifactId>protobuf-java</artifactId> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <version>${protobuf.version}</version> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <scope>compile</scope> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </dependency> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </dependencies> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <build> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <outputDirectory>target/scala-${scala.binary.version}/classes</outputDirectory> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -272,6 +278,27 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </execution> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </executions> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </plugin> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <plugin> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <groupId>org.apache.maven.plugins</groupId> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <artifactId>maven-shade-plugin</artifactId> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <configuration> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <shadedArtifactAttached>false</shadedArtifactAttached> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <shadeTestJar>true</shadeTestJar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <relocations> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <relocation> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <pattern>com.google.common</pattern> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <shadedPattern>${spark.shade.packageName}.guava</shadedPattern> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </relocation> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <relocation> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <pattern>com.google.protobuf</pattern> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <shadedPattern>${spark.shade.packageName}.spark-core.protobuf</shadedPattern> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <includes> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <include>com.google.protobuf.**</include> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </includes> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </relocation> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </relocations> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </configuration> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </plugin> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </plugins> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </build> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -291,5 +318,68 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </dependency> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </dependencies> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </profile> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <profile> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <relocation> | |
| <pattern>com.google.protobuf</pattern> | |
| <shadedPattern>${spark.shade.packageName}.spark-core.protobuf</shadedPattern> | |
| <includes> | |
| <include>com.google.protobuf.**</include> | |
| </includes> | |
| </relocation> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding to this pr? This is some necessary initial work for sql module @techaddict
both pom.xml and SparkBuild.scala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for SBT we can refer to
spark/project/SparkBuild.scala
Lines 618 to 631 in 73593d8
| lazy val settings = Seq( | |
| // Setting version for the protobuf compiler. This has to be propagated to every sub-project | |
| // even if the project is not using it. | |
| PB.protocVersion := BuildCommons.protoVersion, | |
| // For some reason the resolution from the imported Maven build does not work for some | |
| // of these dependendencies that we need to shade later on. | |
| libraryDependencies ++= { | |
| Seq( | |
| "com.google.protobuf" % "protobuf-java" % protoVersion % "protobuf" | |
| ) | |
| }, | |
| (Compile / PB.targets) := Seq( | |
| PB.gens.java -> (Compile / sourceManaged).value | |
| ), |
spark/project/SparkBuild.scala
Lines 645 to 654 in 73593d8
| ) ++ { | |
| val sparkProtocExecPath = sys.props.get("spark.protoc.executable.path") | |
| if (sparkProtocExecPath.isDefined) { | |
| Seq( | |
| PB.protocExecutable := file(sparkProtocExecPath.get) | |
| ) | |
| } else { | |
| Seq.empty | |
| } | |
| } |
Otherwise, GA task may can't compile proto file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old protobuf deps in root pom causes so many troubles...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 821 to 831 in e56f31d
| <!-- In theory we need not directly depend on protobuf since Spark does not directly | |
| use it. However, when building with Hadoop/YARN 2.2 Maven doesn't correctly bump | |
| the protobuf version up from the one Mesos gives. For now we include this variable | |
| to explicitly bump the version when building with YARN. It would be nice to figure | |
| out why Maven can't resolve this correctly (like SBT does). --> | |
| <dependency> | |
| <groupId>com.google.protobuf</groupId> | |
| <artifactId>protobuf-java</artifactId> | |
| <version>${protobuf.hadoopDependency.version}</version> | |
| <scope>${hadoop.deps.scope}</scope> | |
| </dependency> |
From the comments, maybe we can try to remove the old protobuf dependency. mesos uses the shaded-protobuf one now. Let me do some tests with different hadoop profiles first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into it!
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| syntax = "proto3"; | ||
| package org.apache.spark.status.protobuf.sql; | ||
techaddict marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| message SQLPlanMetric { | ||
| string name = 1; | ||
| int64 accumulator_id = 2; | ||
| string metric_type = 3; | ||
| } | ||
|
|
||
| message SparkPlanGraphNode { | ||
| int64 id = 1; | ||
| string name = 2; | ||
| string desc = 3; | ||
| repeated SQLPlanMetric metrics = 4; | ||
| } | ||
|
|
||
| message SparkPlanGraphClusterWrapper { | ||
| int64 id = 1; | ||
| string name = 2; | ||
| string desc = 3; | ||
| repeated SparkPlanGraphNodeWrapper nodes = 4; | ||
| repeated SQLPlanMetric metrics = 5; | ||
| } | ||
|
|
||
| message SparkPlanGraphNodeWrapper { | ||
| SparkPlanGraphNode node = 1; | ||
| SparkPlanGraphClusterWrapper cluster = 2; | ||
| } | ||
|
|
||
| message SparkPlanGraphEdge { | ||
| int64 from_id = 1; | ||
| int64 to_id = 2; | ||
| } | ||
|
|
||
| message SparkPlanGraphWrapper { | ||
| int64 execution_id = 1; | ||
| repeated SparkPlanGraphNodeWrapper nodes = 2; | ||
| repeated SparkPlanGraphEdge edges = 3; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # | ||
| # 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. | ||
| # | ||
|
|
||
| org.apache.spark.status.protobuf.sql.SparkPlanGraphWrapperSerializer |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| /* | ||
| * 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.status.protobuf.sql | ||
|
|
||
| import collection.JavaConverters._ | ||
|
|
||
| import org.apache.spark.sql.execution.ui.{SparkPlanGraphClusterWrapper, SparkPlanGraphEdge, SparkPlanGraphNode, SparkPlanGraphNodeWrapper, SparkPlanGraphWrapper, SQLPlanMetric} | ||
| import org.apache.spark.status.protobuf.ProtobufSerDe | ||
|
|
||
| class SparkPlanGraphWrapperSerializer extends ProtobufSerDe { | ||
|
|
||
| override val supportClass: Class[_] = classOf[SparkPlanGraphWrapper] | ||
|
|
||
| override def serialize(input: Any): Array[Byte] = | ||
techaddict marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| serialize(input.asInstanceOf[SparkPlanGraphWrapper]) | ||
|
|
||
| private def serialize(plan: SparkPlanGraphWrapper): Array[Byte] = { | ||
| val builder = StoreTypes.SparkPlanGraphWrapper.newBuilder() | ||
| builder.setExecutionId(plan.executionId) | ||
| plan.nodes.foreach { node => | ||
| builder.addNodes(serializeSparkPlanGraphNodeWrapper(node)) | ||
| } | ||
| plan.edges.foreach {edge => | ||
| builder.addEdges(serializeSparkPlanGraphEdge(edge)) | ||
| } | ||
| builder.build().toByteArray | ||
| } | ||
|
|
||
| def deserialize(bytes: Array[Byte]): SparkPlanGraphWrapper = { | ||
| val wrapper = StoreTypes.SparkPlanGraphWrapper.parseFrom(bytes) | ||
| new SparkPlanGraphWrapper( | ||
| executionId = wrapper.getExecutionId, | ||
| nodes = wrapper.getNodesList.asScala.map(deserializeSparkPlanGraphNodeWrapper).toSeq, | ||
| edges = wrapper.getEdgesList.asScala.map(deserializeSparkPlanGraphEdge).toSeq | ||
| ) | ||
| } | ||
|
|
||
| private def serializeSparkPlanGraphNodeWrapper(input: SparkPlanGraphNodeWrapper): | ||
| StoreTypes.SparkPlanGraphNodeWrapper = { | ||
|
|
||
| val builder = StoreTypes.SparkPlanGraphNodeWrapper.newBuilder() | ||
| builder.setNode(serializeSparkPlanGraphNode(input.node)) | ||
| builder.setCluster(serializeSparkPlanGraphClusterWrapper(input.cluster)) | ||
| builder.build() | ||
| } | ||
|
|
||
| private def deserializeSparkPlanGraphNodeWrapper(input: StoreTypes.SparkPlanGraphNodeWrapper): | ||
| SparkPlanGraphNodeWrapper = { | ||
|
|
||
| new SparkPlanGraphNodeWrapper( | ||
| node = deserializeSparkPlanGraphNode(input.getNode), | ||
| cluster = deserializeSparkPlanGraphClusterWrapper(input.getCluster) | ||
| ) | ||
| } | ||
|
|
||
| private def serializeSparkPlanGraphEdge(edge: SparkPlanGraphEdge): | ||
| StoreTypes.SparkPlanGraphEdge = { | ||
| val builder = StoreTypes.SparkPlanGraphEdge.newBuilder() | ||
| builder.setFromId(edge.fromId) | ||
| builder.setToId(edge.toId) | ||
| builder.build() | ||
| } | ||
|
|
||
| private def deserializeSparkPlanGraphEdge(edge: StoreTypes.SparkPlanGraphEdge): | ||
| SparkPlanGraphEdge = { | ||
| SparkPlanGraphEdge( | ||
| fromId = edge.getFromId, | ||
| toId = edge.getToId) | ||
| } | ||
|
|
||
| private def serializeSparkPlanGraphNode(node: SparkPlanGraphNode): | ||
| StoreTypes.SparkPlanGraphNode = { | ||
| val builder = StoreTypes.SparkPlanGraphNode.newBuilder() | ||
| builder.setId(node.id) | ||
| builder.setName(node.name) | ||
| builder.setName(node.desc) | ||
| node.metrics.foreach { metric => | ||
| builder.addMetrics(serializeSQLPlanMetric(metric)) | ||
| } | ||
| builder.build() | ||
| } | ||
|
|
||
| private def deserializeSparkPlanGraphNode(node: StoreTypes.SparkPlanGraphNode): | ||
| SparkPlanGraphNode = { | ||
|
|
||
| new SparkPlanGraphNode( | ||
| id = node.getId, | ||
| name = node.getName, | ||
| desc = node.getDesc, | ||
| metrics = node.getMetricsList.asScala.map(deserializeSQLPlanMetric).toSeq | ||
| ) | ||
| } | ||
|
|
||
| private def serializeSparkPlanGraphClusterWrapper(cluster: SparkPlanGraphClusterWrapper): | ||
| StoreTypes.SparkPlanGraphClusterWrapper = { | ||
| val builder = StoreTypes.SparkPlanGraphClusterWrapper.newBuilder() | ||
| builder.setId(cluster.id) | ||
| builder.setName(cluster.name) | ||
| builder.setDesc(cluster.desc) | ||
| cluster.nodes.foreach { node => | ||
| builder.addNodes(serializeSparkPlanGraphNodeWrapper(node)) | ||
| } | ||
| cluster.metrics.foreach { metric => | ||
| builder.addMetrics(serializeSQLPlanMetric(metric)) | ||
| } | ||
| builder.build() | ||
| } | ||
|
|
||
| private def deserializeSparkPlanGraphClusterWrapper( | ||
| cluster: StoreTypes.SparkPlanGraphClusterWrapper): SparkPlanGraphClusterWrapper = { | ||
|
|
||
| new SparkPlanGraphClusterWrapper( | ||
| id = cluster.getId, | ||
| name = cluster.getName, | ||
| desc = cluster.getDesc, | ||
| nodes = cluster.getNodesList.asScala.map(deserializeSparkPlanGraphNodeWrapper).toSeq, | ||
| metrics = cluster.getMetricsList.asScala.map(deserializeSQLPlanMetric).toSeq | ||
| ) | ||
| } | ||
|
|
||
| private def serializeSQLPlanMetric(metric: SQLPlanMetric): StoreTypes.SQLPlanMetric = { | ||
techaddict marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| val builder = StoreTypes.SQLPlanMetric.newBuilder() | ||
| builder.setName(metric.name) | ||
| builder.setAccumulatorId(metric.accumulatorId) | ||
| builder.setMetricType(metric.metricType) | ||
| builder.build() | ||
| } | ||
|
|
||
| private def deserializeSQLPlanMetric(metric: StoreTypes.SQLPlanMetric): SQLPlanMetric = { | ||
| SQLPlanMetric( | ||
| name = metric.getName, | ||
| accumulatorId = metric.getAccumulatorId, | ||
| metricType = metric.getMetricType | ||
| ) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.