Skip to content

Commit 654b926

Browse files
committed
Clean-up, add tests
1 parent 763af15 commit 654b926

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/debug/package.scala

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ package object debug {
134134
}
135135
}
136136

137+
/**
138+
* :: DeveloperApi ::
139+
* Helper functions for checking that runtime types match a given schema.
140+
*/
141+
@DeveloperApi
137142
object TypeCheck {
138143
def typeCheck(data: Any, schema: DataType): Unit = (data, schema) match {
139144
case (null, _) =>
@@ -159,13 +164,20 @@ package object debug {
159164
}
160165
}
161166

162-
case class TypeCheck(child: SparkPlan) extends SparkPlan {
167+
/**
168+
* :: DeveloperApi ::
169+
* Augments SchemaRDDs with debug methods.
170+
*/
171+
@DeveloperApi
172+
private[sql] case class TypeCheck(child: SparkPlan) extends SparkPlan {
163173
import TypeCheck._
164-
//def otherCopyArgs = null :: Nil
165174

166175
override def nodeName = ""
167176

168-
override def makeCopy(args: Array[Object]): this.type = TypeCheck(args(0).asInstanceOf[SparkPlan]).asInstanceOf[this.type]
177+
/* Only required when defining this class in a REPL.
178+
override def makeCopy(args: Array[Object]): this.type =
179+
TypeCheck(args(0).asInstanceOf[SparkPlan]).asInstanceOf[this.type]
180+
*/
169181

170182
def output = child.output
171183

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.sql.execution.debug
19+
20+
import org.scalatest.FunSuite
21+
22+
import org.apache.spark.sql.TestData._
23+
import org.apache.spark.sql.test.TestSQLContext._
24+
25+
class DebuggingSuite extends FunSuite {
26+
test("SchemaRDD.debug()") {
27+
testData.debug()
28+
}
29+
30+
test("SchemaRDD.typeCheck()") {
31+
testData.typeCheck()
32+
}
33+
}

0 commit comments

Comments
 (0)