Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object PhysicalOperation extends PredicateHelper {
}

def collectAliases(fields: Seq[Expression]): Map[Attribute, Expression] = fields.collect {
case a @ Alias(child, _) => a.toAttribute.asInstanceOf[Attribute] -> child
case a @ Alias(child, _) => a.toAttribute -> child
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this asInstanceOf is not necessary, also delete it here

}.toMap

def substitute(aliases: Map[Attribute, Expression])(expr: Expression): Expression = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private[sql] object DataTypeParser {
override val lexical = new SqlLexical
}

def apply(dataTypeString: String): DataType = dataTypeParser.toDataType(dataTypeString)
def parse(dataTypeString: String): DataType = dataTypeParser.toDataType(dataTypeString)
}

/** The exception thrown from the [[DataTypeParser]]. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class DataTypeParserSuite extends FunSuite {

def checkDataType(dataTypeString: String, expectedDataType: DataType): Unit = {
test(s"parse ${dataTypeString.replace("\n", "")}") {
assert(DataTypeParser(dataTypeString) === expectedDataType)
assert(DataTypeParser.parse(dataTypeString) === expectedDataType)
}
}

def unsupported(dataTypeString: String): Unit = {
test(s"$dataTypeString is not supported") {
intercept[DataTypeException](DataTypeParser(dataTypeString))
intercept[DataTypeException](DataTypeParser.parse(dataTypeString))
}
}

Expand Down
2 changes: 1 addition & 1 deletion sql/core/src/main/scala/org/apache/spark/sql/Column.scala
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ class Column(protected[sql] val expr: Expression) extends Logging {
*
* @group expr_ops
*/
def cast(to: String): Column = cast(DataTypeParser(to))
def cast(to: String): Column = cast(DataTypeParser.parse(to))

/**
* Returns an ordering used in sorting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ private[hive] case class MetastoreRelation


private[hive] object HiveMetastoreTypes {
def toDataType(metastoreType: String): DataType = DataTypeParser(metastoreType)
def toDataType(metastoreType: String): DataType = DataTypeParser.parse(metastoreType)

def toMetastoreType(dt: DataType): String = dt match {
case ArrayType(elementType, _) => s"array<${toMetastoreType(elementType)}>"
Expand Down