Skip to content

Commit

Permalink
[SPARK-3483][SQL] Special chars in column names
Browse files Browse the repository at this point in the history
Supporting special chars in column names by using back ticks. Closed #2804 and created this PR as it has merge conflicts

Author: ravipesala <ravindra.pesala@huawei.com>

Closes #2927 from ravipesala/SPARK-3483-NEW and squashes the following commits:

f6329f3 [ravipesala] Rebased with master
  • Loading branch information
ravipesala authored and marmbrus committed Oct 26, 2014
1 parent 0481aaa commit 974d7b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Expand Up @@ -75,6 +75,8 @@ class SqlLexical(val keywords: Seq[String]) extends StdLexical {
{ case chars => StringLit(chars mkString "") }
| '"' ~> chrExcept('"', '\n', EofCh).* <~ '"' ^^
{ case chars => StringLit(chars mkString "") }
| '`' ~> chrExcept('`', '\n', EofCh).* <~ '`' ^^
{ case chars => Identifier(chars mkString "") }
| EofCh ^^^ EOF
| '\'' ~> failure("unclosed string literal")
| '"' ~> failure("unclosed string literal")
Expand Down
Expand Up @@ -748,4 +748,10 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
""".stripMargin),
(1 to 100).map(i => Seq(i, i, i)))
}

test("SPARK-3483 Special chars in column names") {
val data = sparkContext.parallelize(Seq("""{"key?number1": "value1", "key.number2": "value2"}"""))
jsonRDD(data).registerTempTable("records")
sql("SELECT `key?number1` FROM records")
}
}

0 comments on commit 974d7b2

Please sign in to comment.