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

Support casting between day-time interval and string #5155

Merged
merged 8 commits into from
Apr 18, 2022

Conversation

res-life
Copy link
Collaborator

@res-life res-life commented Apr 7, 2022

Contributes #4811

  1. Support casting day-time interval to string
  2. Support casting string to day-time interval

Signed-off-by: Chong Gao res_life@163.com

Signed-off-by: Chong Gao <res_life@163.com>
@jlowe jlowe added this to the Apr 4 - Apr 15 milestone Apr 7, 2022
val numRows = micros.getRowCount
val from = DT.fieldToString(startField).toUpperCase
val to = DT.fieldToString(endField).toUpperCase
val prefixStr = "INTERVAL '"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can has this prefixStr as a const member of GpuIntervalUtils, instead of creating one each time this method is called.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

// prefix part: INTERVAL '
parts += getConstStringVector(prefixStr, numRows)

// sign part: - or empty
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may merge the sign vector and the prefix vector into one vector, to reduce the vectors to be concatenated.

            withResource(getConstStringVector("INTERVAL '-", numRows)) { neg =>
              withResource(getConstStringVector("INTERVAL '", numRows)) { empty =>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

/**
* return (micros / div).toString
*/
private def devResult(micros: ColumnVector, div: Long): ColumnVector = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

devResult -> divResult ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

/**
* return (micros / div).toString with padding zero
*/
private def devResultWithPadding(micros: ColumnVector, div: Long): ColumnVector = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

devResultWithPadding -> divResultWithPadding

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Chong Gao added 3 commits April 8, 2022 14:13
Fix
Signed-off-by: Chong Gao <res_life@163.com>
@res-life res-life changed the title Support cast day-time interval to string Support casting between day-time interval and string Apr 8, 2022
@res-life
Copy link
Collaborator Author

res-life commented Apr 8, 2022

Depending on #5020 to merge.

Comment on lines 558 to 561
// `restHolder` only hold one rest Cv;
// use `resetRest` to close the old one and set a new one
// make a copy of micros

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// `restHolder` only hold one rest Cv;
// use `resetRest` to close the old one and set a new one
// make a copy of micros

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment on lines 566 to 570
withResource(getConstStringVector(prefixStr + "-", numRows)) { neg =>
withResource(getConstStringVector(prefixStr, numRows)) { empty =>
less.ifElse(neg, empty)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

ifElse supports operating on scalar values directly which is more efficient, as we don't need to manifest a column of identical scalars.

Suggested change
withResource(getConstStringVector(prefixStr + "-", numRows)) { neg =>
withResource(getConstStringVector(prefixStr, numRows)) { empty =>
less.ifElse(neg, empty)
}
}
withResource(Scalar.fromString(prefixStr + "-")) { negPrefix =>
withResource(Scalar.fromString(prefixStr)) { prefix =>
less.ifElse(negPrefix, prefix)
}
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@sameerz sameerz added the audit_3.3.0 Audit related tasks for 3.3.0 label Apr 11, 2022
@res-life res-life marked this pull request as ready for review April 14, 2022 11:28
@res-life
Copy link
Collaborator Author

build

@@ -120,4 +124,5 @@ object GpuTypeShims {
*/
def additionalCommonOperatorSupportedTypes: TypeSig = TypeSig.none

def isDayTimeType(t: DataType): Boolean = false
Copy link
Member

Choose a reason for hiding this comment

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

The name here is problematic on Spark 3.2.x which does support DayTimeIntervalType and could return false when called with a DayTimeIntervalType instance. Maybe this should be named something like isSupportedDayTimeType?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done, already have isSupportedDayTimeType.

@res-life
Copy link
Collaborator Author

build

@res-life res-life merged commit 5251bac into NVIDIA:branch-22.06 Apr 18, 2022
@res-life res-life deleted the cast-dt-to-string branch April 18, 2022 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
audit_3.3.0 Audit related tasks for 3.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants