-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-20680][SQL] Adding HiveVoidType in Spark to be compatible with Hive #28935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
17b1853
ba2ef06
17aace2
a3a1cef
9b9d021
fa853b1
3fa76cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * 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.types | ||
|
|
||
| /** | ||
| * A hive null type for compatibility. These datatypes should only used for parsing, | ||
| * and should NOT be used anywhere else. Any instance of these data types should be | ||
| * replaced by a [[NullType]] before analysis. | ||
| */ | ||
| class HiveNullType private() extends DataType { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know the context, but can we name this
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the description is interpreted like "
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You are right. |
||
|
|
||
| override def defaultSize: Int = 1 | ||
|
|
||
| override private[spark] def asNullable: HiveNullType = this | ||
|
|
||
| override def simpleString: String = "void" | ||
| } | ||
|
|
||
| case object HiveNullType extends HiveNullType { | ||
| def replaceNullType(dt: DataType): DataType = dt match { | ||
|
LantaoJin marked this conversation as resolved.
Outdated
|
||
| case ArrayType(et, nullable) => | ||
| ArrayType(replaceNullType(et), nullable) | ||
| case MapType(kt, vt, nullable) => | ||
| MapType(replaceNullType(kt), replaceNullType(vt), nullable) | ||
| case StructType(fields) => | ||
| StructType(fields.map { field => | ||
| field.copy(dataType = replaceNullType(field.dataType)) | ||
| }) | ||
|
LantaoJin marked this conversation as resolved.
Outdated
|
||
| case _: HiveNullType => NullType | ||
| case _ => dt | ||
| } | ||
|
|
||
|
|
||
| def containsNullType(dt: DataType): Boolean = dt match { | ||
|
LantaoJin marked this conversation as resolved.
Outdated
|
||
| case ArrayType(et, _) => containsNullType(et) | ||
| case MapType(kt, vt, _) => containsNullType(kt) || containsNullType(vt) | ||
| case StructType(fields) => fields.exists(f => containsNullType(f.dataType)) | ||
| case _ => dt.isInstanceOf[HiveNullType] | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.