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

Trunc #17

Draft
wants to merge 21 commits into
base: if-modified-files
Choose a base branch
from
Draft
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
Next Next commit
Implement GpuOverride
Signed-off-by: Nghia Truong <nghiat@nvidia.com>
ttnghia committed Dec 4, 2024
commit 630c5934720d5e1b1f4a9d7b8923455bfc2fafa1
Original file line number Diff line number Diff line change
@@ -1821,6 +1821,53 @@ object GpuOverrides extends Logging {
ParamCheck("round", TypeSig.lit(TypeEnum.BOOLEAN), TypeSig.BOOLEAN))),
(a, conf, p, r) => new MonthsBetweenExprMeta(a, conf, p, r)
),
expr[TruncDate](
"Truncate the date to the unit specified by the given string format",
ExprChecks.binaryProject(TypeSig.DATE, TypeSig.DATE,
("date", TypeSig.DATE, TypeSig.DATE),
("format", TypeSig.lit(TypeEnum.STRING)
.withPsNote(TypeEnum.STRING, "\"QUARTER\" and \"WEEK\" are not supported"),
TypeSig.STRING)),
(a, conf, p, r) => new BinaryExprMeta[TruncDate](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
def isSupported(format: String): Boolean = {
format.toUpperCase match {
case "YEAR" | "YYYY" | "YY" | "MONTH" | "MM" | "MON" => true
case _ => false
}
}
extractStringLit(a.format) match {
case Some(format) if isSupported(format) =>
case _ =>
willNotWorkOnGpu("Truncation format is not supported")
}
}
override def convertToGpu(child: Expression): GpuExpression = GpuTruncDate(child)
}),
expr[TruncTimestamp](
"Truncate the timestamp to the unit specified by the given string format",
ExprChecks.binaryProject(TypeSig.TIMESTAMP, TypeSig.TIMESTAMP,
("date", TypeSig.TIMESTAMP, TypeSig.TIMESTAMP),
("format", TypeSig.lit(TypeEnum.STRING)
.withPsNote(TypeEnum.STRING, "\"QUARTER\" and \"WEEK\" are not supported"),
TypeSig.STRING)),
(a, conf, p, r) => new BinaryExprMeta[TruncDate](a, conf, p, r) {
override def tagExprForGpu(): Unit = {
def isSupported(format: String): Boolean = {
format.toUpperCase match {
case "YEAR" | "YYYY" | "YY" | "MONTH" | "MM" | "MON" | "DAY" | "DD" |
"HOUR" | "MINUTE" | "SECOND" | "MILLISECOND" | "MICROSECOND" => true
case _ => false
}
}
extractStringLit(a.format) match {
case Some(format) if isSupported(format) =>
case _ =>
willNotWorkOnGpu("Truncation format is not supported")
}
}
override def convertToGpu(child: Expression): GpuExpression = GpuTruncTimestamp(child)
}),
expr[Pmod](
"Pmod",
// Decimal support disabled https://github.com/NVIDIA/spark-rapids/issues/7553