Skip to content

Commit

Permalink
[SQL] SPARK-1922
Browse files Browse the repository at this point in the history
Allow underscore in column name of a struct field https://issues.apache.org/jira/browse/SPARK-1922 .

Author: LY Lai <ly.lai@vpon.com>

Closes apache#873 from lyuanlai/master and squashes the following commits:

2253263 [LY Lai] Allow underscore in struct field column name
  • Loading branch information
LY Lai authored and conviva-zz committed Sep 4, 2014
1 parent e5776f3 commit 6dd26a5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ object HiveMetastoreTypes extends RegexParsers {
}

protected lazy val structField: Parser[StructField] =
"[a-zA-Z0-9]*".r ~ ":" ~ dataType ^^ {
"[a-zA-Z0-9_]*".r ~ ":" ~ dataType ^^ {
case name ~ _ ~ tpe => StructField(name, tpe, nullable = true)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.sql.hive

import org.scalatest.FunSuite

import org.apache.spark.sql.catalyst.types.{DataType, StructType}

class HiveMetastoreCatalogSuite extends FunSuite {

test("struct field should accept underscore in sub-column name") {
val metastr = "struct<a: int, b_1: string, c: string>"

val datatype = HiveMetastoreTypes.toDataType(metastr)
assert(datatype.isInstanceOf[StructType])
}
}

0 comments on commit 6dd26a5

Please sign in to comment.