Skip to content

Commit

Permalink
Several minor updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
yhuai committed Jul 23, 2014
1 parent 1d9c13a commit 9c99bc0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ abstract class QueryPlan[PlanType <: TreeNode[PlanType]] extends TreeNode[PlanTy
def schema: StructType = StructType.fromAttributes(output)

/** Returns the output schema in the tree format. */
def schemaString: String = schema.structString
def schemaString: String = schema.treeString

/** Prints out the schema in the tree format */
def printSchema(): Unit = println(schemaString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ case class StructType(fields: Seq[StructField]) extends DataType {
protected[sql] def toAttributes =
fields.map(f => AttributeReference(f.name, f.dataType, f.nullable)())

def structString: String = {
def treeString: String = {
val builder = new StringBuilder
builder.append("root\n")
val prefix = " |"
Expand All @@ -323,7 +323,7 @@ case class StructType(fields: Seq[StructField]) extends DataType {
builder.toString()
}

def printStruct(): Unit = println(structString)
def printTreeString(): Unit = println(treeString)

private[sql] def buildFormattedString(prefix: String, builder: StringBuilder): Unit = {
fields.foreach(field => field.buildFormattedString(prefix, builder))
Expand All @@ -335,6 +335,7 @@ case class StructType(fields: Seq[StructField]) extends DataType {
case class MapType(keyType: DataType, valueType: DataType) extends DataType {
private[sql] def buildFormattedString(prefix: String, builder: StringBuilder): Unit = {
builder.append(s"${prefix}-- key: ${keyType.simpleString}\n")
builder.append(s"${prefix}-- value: ${valueType.simpleString}\n")
DataType.buildFormattedString(keyType, s"$prefix |", builder)
DataType.buildFormattedString(valueType, s"$prefix |", builder)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ class SchemaRDD(
case (obj, (attrName, dataType)) =>
dataType match {
case struct: StructType => map.put(attrName, rowToMap(obj.asInstanceOf[Row], struct))
case array @ ArrayType(struct: StructType) =>
case array @ ArrayType(struct: StructType, _) =>
val arrayValues = obj match {
case seq: Seq[Any] =>
seq.map(element => rowToMap(element.asInstanceOf[Row], struct)).asJava
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private[sql] trait SchemaRDDLike {
*
* @group schema
*/
def schemaString: String = schema.structString
def schemaString: String = schema.treeString

/** Prints out the schema.
*
Expand Down
6 changes: 4 additions & 2 deletions sql/core/src/main/scala/org/apache/spark/sql/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import org.apache.spark.annotation.DeveloperApi
*
* @groupname dataType Data types
* @groupdesc Spark SQL data types.
* @groupprio dataType -2
* @groupprio dataType -3
* @groupname field Field
* @groupprio field -2
* @groupname row Row
* @groupprio row -1
*/
Expand Down Expand Up @@ -377,7 +379,7 @@ package object sql {
* `dataType` specifies the data type of a `StructField`.
* The field of `nullable` specifies if values of a `StructField` can contain `null` values.
*
* @group dataType
* @group field
*/
@DeveloperApi
type StructField = catalyst.types.StructField
Expand Down

0 comments on commit 9c99bc0

Please sign in to comment.