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 @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ class SQLQuerySuite extends QueryTest with SQLTestUtils with TestHiveSingleton {
data.toDF("key", "value").registerTempTable("test")
checkAnswer(
sql("""FROM
|(FROM test SELECT TRANSFORM(key, value) USING 'cat' AS (thing1 int, thing2 string)) t
|(FROM test SELECT TRANSFORM(key, value) USING 'cat' AS (`thing1` int, thing2 string)) t
|SELECT thing1 + 1
""".stripMargin), (2 to 6).map(i => Row(i)))
}
Expand Down