The Spark
version is 1.3.0.
The source code from the SQLContext.scala
(https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala):
@transient
protected[sql] val ddlParser = new DDLParser(sqlParser.apply(_))
@transient
protected[sql] val sqlParser = {
val fallback = new catalyst.SqlParser
new SparkSQLParser(fallback(_))
}
protected[sql] def parseSql(sql: String): LogicalPlan = {
ddlParser(sql, false).getOrElse(sqlParser(sql))
}
I cannot really understand the code above.
- how does the
sqlParser.apply(_)
work ?
what is (_) on earth? DDLParser's constructor needs a parameter parseQuery: String => LogicalPlan
, but the return type of sqlParser.apply
is LogicalPlan
.
- similarly,
fallback(_)
is also aapply
call, how does (_) work?