Skip to content
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

Port whole parsePartitions method from Spark3.3 to Gpu side #6048

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ import scala.util.Try

import org.apache.spark.sql.catalyst.catalog.ExternalCatalogUtils.unescapePathName
import org.apache.spark.sql.catalyst.expressions.{Cast, Literal}
import org.apache.spark.sql.types.{AnsiIntervalType, AnyTimestampType, DataType, DateType}
import org.apache.spark.sql.types.{AnyTimestampType, DataType, DateType}

object PartitionValueCastShims {
def isSupportedType(dt: DataType): Boolean = dt match {
// Timestamp types
case dt if AnyTimestampType.acceptsType(dt) => true
case it: AnsiIntervalType => true
case _ => false
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2022, NVIDIA CORPORATION.
*
* Licensed 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.shims

import java.time.ZoneId

import org.apache.spark.sql.catalyst.catalog.ExternalCatalogUtils.unescapePathName
import org.apache.spark.sql.catalyst.expressions.{Cast, Literal}
import org.apache.spark.sql.types.{AnsiIntervalType, DataType}

object PartitionValueCastShims {
def isSupportedType(dt: DataType): Boolean = dt match {
// AnsiIntervalType
case it: AnsiIntervalType => true
Copy link
Collaborator

@tgravescs tgravescs Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why doesn't the 330 shim have the AnyTimestampType checks?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case _ => false
}

// Only for AnsiIntervalType
def castTo(desiredType: DataType, value: String, zoneId: ZoneId): Any = desiredType match {
// Copied from org/apache/spark/sql/execution/datasources/PartitionUtils.scala
case it: AnsiIntervalType =>
Cast(Literal(unescapePathName(value)), it).eval()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ import org.apache.spark.sql.types._
import org.apache.spark.sql.types.shims.PartitionValueCastShims
import org.apache.spark.unsafe.types.UTF8String




object GpuPartitioningUtils extends SQLConfHelper {

case class TypedPartValue(value: String, dataType: DataType)
Expand All @@ -64,9 +61,6 @@ object GpuPartitioningUtils extends SQLConfHelper {
*
* Mainly copied from PartitioningAwareFileIndex.inferPartitioning
*/
// Copied from Spark: org/apache/spark/sql/execution/datasources/PartitionUtils.scala
// for for https://github.com/NVIDIA/spark-rapids/issues/6026
// It can be removed when Spark3.3 is the least supported Spark version
def inferPartitioning(
sparkSession: SparkSession,
rootPaths: Seq[Path],
Expand Down