Skip to content

[SPARK-29502][SQL] typed interval expression should fail for invalid format#26151

Closed
cloud-fan wants to merge 3 commits into
apache:masterfrom
cloud-fan:bug
Closed

[SPARK-29502][SQL] typed interval expression should fail for invalid format#26151
cloud-fan wants to merge 3 commits into
apache:masterfrom
cloud-fan:bug

Conversation

@cloud-fan

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This is a followup of #25241 .

The typed interval expression should fail for invalid format.

Why are the changes needed?

Te be consistent with the typed timestamp/date expression

Does this PR introduce any user-facing change?

Yes. But this feature is not released yet.

How was this patch tested?

updated test

@cloud-fan

Copy link
Copy Markdown
Contributor Author

cc @wangyum @dongjoon-hyun

assertEqual("INTERVAL '3 month 1 hour'", intervalLiteral)
assertEqual("Interval 'interval 3 monthsss 1 hoursss'",
Literal(null, CalendarIntervalType))
intercept("Interval 'interval 3 monthsss 1 hoursss'")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We can refer to the timestamp/date tests just a few lines above.

@SparkQA

SparkQA commented Oct 17, 2019

Copy link
Copy Markdown

Test build #112226 has finished for PR 26151 at commit ee86886.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

val ex = new ParseException(e.getMessage, ctx)
ex.setStackTrace(e.getStackTrace)
throw ex
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The error message is still inconsistent. Invalid interval vs Cannot parse the DATE value:

scala> spark.sql("select Interval '10000 secondss'").show(false)
org.apache.spark.sql.catalyst.parser.ParseException:
Invalid interval: 10000 secondss(line 1, pos 7)
scala> spark.sql("select date '10000 secondss'").show(false)
org.apache.spark.sql.catalyst.parser.ParseException:
Cannot parse the DATE value: 10000 secondss(line 1, pos 7)

== SQL ==
select date '10000 secondss'
-------^^^

@SparkQA

SparkQA commented Oct 18, 2019

Copy link
Copy Markdown

Test build #112254 has finished for PR 26151 at commit 5a375eb.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@wangyum

wangyum commented Oct 18, 2019

Copy link
Copy Markdown
Member

retest this please

@SparkQA

SparkQA commented Oct 18, 2019

Copy link
Copy Markdown

Test build #112258 has finished for PR 26151 at commit 5a375eb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

assertEqual("INTERVAL '3 month 1 hour'", intervalLiteral)
assertEqual("Interval 'interval 3 monthsss 1 hoursss'",
Literal(null, CalendarIntervalType))
intercept("Interval 'interval 3 monthsss 1 hoursss'")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you check the error message?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test suite defines the intercept method and uses it in many places. I don't want to break the rule here. It's definitely better to update the intercept method and take a error message parameter. This should be done in a followup.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the method has messages arg

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

damn, the date and timestamp tests don't specify message, and I thought it doesn't have the message arg... Let me update it now.

@SparkQA

SparkQA commented Oct 18, 2019

Copy link
Copy Markdown

Test build #112283 has finished for PR 26151 at commit b27be9f.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@wangyum wangyum closed this in 2437878 Oct 18, 2019
@wangyum

wangyum commented Oct 18, 2019

Copy link
Copy Markdown
Member

Merged to master.

@dongjoon-hyun

Copy link
Copy Markdown
Member

Late LGTM. Thank you all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants