Skip to content

infinity value sanitized , input pattern validation and ISO fallback #70

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

MatloaItumeleng
Copy link

Closes #69 , Adds:

  • Support for ISO pattern as fallback
  • Casts infinity values directly to date & timestamp derived from SimpleDateFormat

protected def field: TypedStructField


private def sanitizeInput(s: String): String = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why you need this function? Why you need to sanitze the strings?

infPlusValue.map { plusValue =>
when(columnWithNegativeInf === lit(plusSymbol).cast(origType), lit(plusValue).cast(origType))
.otherwise(columnWithNegativeInf)
val validatedMinus = if (origType == DateType || origType == TimestampType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You testing same condition twice after each other.



def replaceInfinitySymbols(column: Column)(implicit spark:SparkSession, defaults: TypeDefaults): Column = {
var resultCol = column.cast(StringType)
Copy link
Contributor

Choose a reason for hiding this comment

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

var is to be avoided in Scala

to_date(resultCol, "yyyy-MM-dd")
).cast(origType)
case _ =>
resultCol.cast(origType)
Copy link
Contributor

Choose a reason for hiding this comment

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

Indenation

origType match {
case TimestampType =>
val pattern = getPattern(origType).getOrElse(
defaults.defaultTimestampTimeZone.map(_ => "yyyy-MM-dd'T'HH:mm:ss.SSSSSS").getOrElse("yyyy-MM-dd HH:mm:ss")
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point and goal of this expression?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow infinity values with different pattern than input values
2 participants