Skip to content

Commit fa8e399

Browse files
wjxiz1992claude
andcommitted
style: fix unnecessary line wrapping in datetimeExpressions
Merge lines that were split despite being well under 100 chars: - if condition with || (91 chars) - RegexProgram constructor (80 chars) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 08289e8 commit fa8e399

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

sql-plugin/src/main/scala/org/apache/spark/sql/rapids/datetimeExpressions.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,12 @@ object GpuToTimestamp {
711711
// date-time separator doesn't match the format: cuDF treats 'T' and space
712712
// as interchangeable, but Spark's DateTimeFormatter requires an exact match.
713713
// We also use cuDF isTimestamp to reject truly unparseable strings.
714-
if (strfFormat.startsWith("%Y-%m-%d %H") ||
715-
strfFormat.startsWith("%Y/%m/%d %H")) {
716-
val tProg = new RegexProgram(
717-
raw"\A.{10}T", CaptureGroups.NON_CAPTURE)
714+
if (strfFormat.startsWith("%Y-%m-%d %H") || strfFormat.startsWith("%Y/%m/%d %H")) {
715+
// The 4 element-wise GPU kernels below (matchesRe, not, isTimestamp, and) add
716+
// negligible overhead compared to the downstream parseStringAsTimestamp which
717+
// performs full cuDF timestamp parsing. The regex is trivial (single fixed-position
718+
// character check) and withResource is just RAII for prompt GPU memory release.
719+
val tProg = new RegexProgram(raw"\A.{10}T", CaptureGroups.NON_CAPTURE)
718720
withResource(col.matchesRe(tProg)) { hasT =>
719721
withResource(hasT.not()) { noT =>
720722
withResource(col.isTimestamp(strfFormat)) { cudfValid =>

0 commit comments

Comments
 (0)