Skip to content

Commit

Permalink
fix json protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
cloud-fan committed Sep 14, 2017
1 parent ddd7f5e commit 414457c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.spark.sql.execution

import com.fasterxml.jackson.annotation.JsonIgnoreProperties

import org.apache.spark.annotation.DeveloperApi
import org.apache.spark.sql.execution.exchange.ReusedExchangeExec
import org.apache.spark.sql.execution.metric.SQLMetricInfo
Expand All @@ -26,6 +28,7 @@ import org.apache.spark.sql.execution.metric.SQLMetricInfo
* Stores information about a SQL SparkPlan.
*/
@DeveloperApi
@JsonIgnoreProperties(Array("metadata")) // The metadata filed was removed in Spark 2.3.
class SparkPlanInfo(
val nodeName: String,
val simpleString: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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

import org.json4s.jackson.JsonMethods.parse

import org.apache.spark.SparkFunSuite
import org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionStart
import org.apache.spark.util.JsonProtocol

class SQLJsonProtocolSuite extends SparkFunSuite {

test("SparkPlanGraph backward compatibility: metadata") {
val reconstructedEvent = JsonProtocol.sparkEventFromJson(parse(SQLExecutionStartJsonString))
val expectedEvent = SparkListenerSQLExecutionStart(0, "test desc", "test detail", "test plan",
new SparkPlanInfo("TestNode", "test string", Nil, Nil), 0)
assert(reconstructedEvent == expectedEvent)
}

private val SQLExecutionStartJsonString =
"""
|{
| "Event":"org.apache.spark.sql.execution.ui.SparkListenerSQLExecutionStart",
| "executionId":0,
| "description":"test desc",
| "details":"test detail",
| "physicalPlanDescription":"test plan",
| "sparkPlanInfo": {
| "nodeName":"TestNode",
| "simpleString":"test string",
| "children":[],
| "metadata":{},
| "metrics":[]
| },
| "time":0
|}
""".stripMargin
}

0 comments on commit 414457c

Please sign in to comment.