Skip to content
Snippets Groups Projects
Commit 5d638256 authored by LY Lai's avatar LY Lai Committed by Reynold Xin
Browse files

[SQL] SPARK-1922

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 #873 from lyuanlai/master and squashes the following commits:

2253263 [LY Lai] Allow underscore in struct field column name

(cherry picked from commit 06825674)
Signed-off-by: default avatarReynold Xin <rxin@apache.org>
parent 50e234ba
No related branches found
No related tags found
No related merge requests found
......@@ -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)
}
......
/*
* 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% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment