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

Optimize DECIMAL128 sum aggregations [databricks] #4688

Merged
merged 7 commits into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2021, NVIDIA CORPORATION.
* Copyright (c) 2019-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.
Expand Down Expand Up @@ -152,7 +152,11 @@ public static synchronized void debug(String name, HostColumnVectorCore hostCol)
|| DType.TIMESTAMP_SECONDS.equals(type)
|| DType.TIMESTAMP_MICROSECONDS.equals(type)
|| DType.TIMESTAMP_MILLISECONDS.equals(type)
|| DType.TIMESTAMP_NANOSECONDS.equals(type)) {
|| DType.TIMESTAMP_NANOSECONDS.equals(type)
|| DType.UINT8.equals(type)
|| DType.UINT16.equals(type)
|| DType.UINT32.equals(type)
|| DType.UINT64.equals(type)) {
debugInteger(hostCol, type);
} else if (DType.BOOL8.equals(type)) {
for (int i = 0; i < hostCol.getRowCount(); i++) {
Expand Down Expand Up @@ -486,6 +490,10 @@ private static DType toRapidsOrNull(DataType type) {
// So, we don't have to handle decimal-supportable problem at here.
DecimalType dt = (DecimalType) type;
return DecimalUtil.createCudfDecimal(dt.precision(), dt.scale());
} else if (type instanceof GpuUnsignedIntegerType) {
return DType.UINT32;
} else if (type instanceof GpuUnsignedLongType) {
return DType.UINT64;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 com.nvidia.spark.rapids

import org.apache.spark.sql.types.DataType

/**
* An unsigned, 32-bit integer type that maps to DType.UINT32 in cudf.
* @note This type should NOT be used in Catalyst plan nodes that could be exposed to
* CPU expressions.
*/
class GpuUnsignedIntegerType private() extends DataType {
// The companion object and this class are separated so the companion object also subclasses
// this type. Otherwise the companion object would be of type "UnsignedIntegerType$" in
// byte code.
// Defined with a private constructor so the companion object is the only possible instantiation.
override def defaultSize: Int = 4

override def simpleString: String = "uint"

override def asNullable: DataType = this
}

case object GpuUnsignedIntegerType extends GpuUnsignedIntegerType


/**
* An unsigned, 64-bit integer type that maps to DType.UINT64 in cudf.
* @note This type should NOT be used in Catalyst plan nodes that could be exposed to
* CPU expressions.
*/
class GpuUnsignedLongType private() extends DataType {
// The companion object and this class are separated so the companion object also subclasses
// this type. Otherwise the companion object would be of type "UnsignedIntegerType$" in
// byte code.
// Defined with a private constructor so the companion object is the only possible instantiation.
override def defaultSize: Int = 8

override def simpleString: String = "ulong"

override def asNullable: DataType = this
}

case object GpuUnsignedLongType extends GpuUnsignedLongType
Loading