Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
use backtick in script transform outputs
  • Loading branch information
gatorsmile committed Feb 28, 2016
commit d18603525e6806a4de907a13a88c5759225065e8
Original file line number Diff line number Diff line change
Expand Up @@ -583,11 +583,11 @@ private[hive] class HiveQl(conf: ParserConf) extends SparkQl(conf) with Logging

val (output, schemaLess) = outputClause match {
case Token("TOK_ALIASLIST", aliases) :: Nil =>
(aliases.map { case Token(name, Nil) => AttributeReference(name, StringType)() },
false)
(aliases.map { case Token(name, Nil) =>
AttributeReference(cleanIdentifier(name), StringType)() }, false)
case Token("TOK_TABCOLLIST", attributes) :: Nil =>
(attributes.map { case Token("TOK_TABCOL", Token(name, Nil) :: dataType :: Nil) =>
AttributeReference(name, nodeToDataType(dataType))() }, false)
AttributeReference(cleanIdentifier(name), nodeToDataType(dataType))() }, false)
case Nil =>
(List(AttributeReference("key", StringType)(),
AttributeReference("value", StringType)()), true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,12 @@ class HiveQlSuite extends SparkFunSuite with BeforeAndAfterAll {

assert(plan.children.head.asInstanceOf[Generate].generator.isInstanceOf[JsonTuple])
}

test("use backticks in output of Script Transform") {
val plan = parser.parsePlan(
"""SELECT `t`.`thing1`
|FROM (SELECT TRANSFORM (`parquet_t1`.`key`, `parquet_t1`.`value`)
|USING 'cat' AS (`thing1` int, `thing2` string) FROM `default`.`parquet_t1`) AS t
""".stripMargin)
}
}