Skip to content

Commit

Permalink
Allow underscore in struct field column name
Browse files Browse the repository at this point in the history
Correcting for PR comments: remove changes to q-file, add a separate unittest
  • Loading branch information
LY Lai committed May 27, 2014
1 parent 0659529 commit 2253263
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 2253263

Please sign in to comment.