-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-8753][SQL] Create an IntervalType data type #7226
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 5 commits
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,24 @@ | ||
| /* | ||
| * 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 | ||
|
|
||
|
|
||
| /** | ||
| * The internal representation of interval type. | ||
| */ | ||
| case class Interval(months: Int, microseconds: Long) extends Serializable | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * 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 | ||
|
|
||
| import org.apache.spark.annotation.DeveloperApi | ||
|
|
||
|
|
||
| /** | ||
| * :: DeveloperApi :: | ||
| * The data type representing time intervals. | ||
| * | ||
| * Please use the singleton [[DataTypes.IntervalType]]. | ||
| */ | ||
| @DeveloperApi | ||
| class IntervalType private() extends DataType { | ||
|
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. I didn't make it extend |
||
|
|
||
| override def defaultSize: Int = 4096 | ||
|
|
||
| private[spark] override def asNullable: IntervalType = this | ||
| } | ||
|
|
||
| case object IntervalType extends IntervalType | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -304,6 +304,9 @@ private[sql] object ResolvedDataSource { | |
| mode: SaveMode, | ||
| options: Map[String, String], | ||
| data: DataFrame): ResolvedDataSource = { | ||
| if (data.schema.map(_.dataType).exists(_.isInstanceOf[IntervalType])) { | ||
| sys.error("Cannot save interval data type into external storage.") | ||
|
Contributor
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. when is this called? if it is called during analysis, it'd make more sense to throw AnalysisException, since that has better error reporting in Python. |
||
| } | ||
| val clazz: Class[_] = lookupDataSource(provider) | ||
| val relation = clazz.newInstance() match { | ||
| case dataSource: CreatableRelationProvider => | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually can you make this a java class and move it to unsafe/src/main/java/org/apache/spark/unsafe/types ?
Just leave the fields public so we can easily access them in codegen.