Skip to content

Conversation

@yaooqinn
Copy link
Member

What changes were proposed in this pull request?

-- !query 83
select -integer '7'
-- !query 83 schema
struct<7:int>
-- !query 83 output
7

-- !query 86
select -date '1999-01-01'
-- !query 86 schema
struct<DATE '1999-01-01':date>
-- !query 86 output
1999-01-01

-- !query 87
select -timestamp '1999-01-01'
-- !query 87 schema
struct<TIMESTAMP('1999-01-01 00:00:00'):timestamp>
-- !query 87 output
1999-01-01 00:00:00

the integer should be -7 and the date and timestamp results are confusing which should throw exceptions

Why are the changes needed?

bug fix

Does this PR introduce any user-facing change?

NO

How was this patch tested?

ADD UTs

@yaooqinn
Copy link
Member Author

cc @cloud-fan @maropu @HyukjinKwon @MaxGekk, thanks a lot

val value = string(ctx.STRING)
val valueType = ctx.identifier.getText.toUpperCase(Locale.ROOT)
val negativeSign = Option(ctx.negativeSign).map(_.getText).getOrElse("")
val isNegative = if (negativeSign == "-") true else false
Copy link
Contributor

Choose a reason for hiding this comment

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

is it simply val isNegative = ctx.negativeSign != null?

@cloud-fan
Copy link
Contributor

looks reasonable to me. Is it a common behavior in other DBs like pgsql?

val value = string(ctx.STRING)
val valueType = ctx.identifier.getText.toUpperCase(Locale.ROOT)
val negativeSign = Option(ctx.negativeSign).map(_.getText).getOrElse("")
val isNegative = if (negativeSign == "-") true else false
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
val isNegative = if (negativeSign == "-") true else false
val isNegative = ctx.negativeSign != null && ctx.negativeSign.getText == "-"

Copy link
Member

Choose a reason for hiding this comment

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

and remove val negativeSign

Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need to check ctx.negativeSign.getText? the parser rule is MINUS? ...

Copy link
Member Author

Choose a reason for hiding this comment

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

negativeSign is used in error message, but I think @cloud-fan 's point is right, we need not to check ctx.negativeSign.getText. I'd do some tests to verify this.

@SparkQA
Copy link

SparkQA commented Nov 12, 2019

Test build #113615 has finished for PR 26479 at commit 1d04cb3.

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

@yaooqinn
Copy link
Member Author

looks reasonable to me. Is it a common behavior in other DBs like pgsql?

yes it right the pg behavior

select '1' year to second;
select interval 1 year '2-1' year to month;
select 1 year '2-1' year to month;
SET spark.sql.ansi.enabled=false;
Copy link
Contributor

Choose a reason for hiding this comment

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

not related to this PR, but it's really annoying to duplicate the test cases with ansi mode on and off.

I'm wondering if we can introduce a -- import abc.sql directive so that we can easily import test cases in ansi/interval.sql, with several ansi specific test cases. cc @maropu

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. That's certainly annoying. I'll try to make a pr later for that approach.

@SparkQA
Copy link

SparkQA commented Nov 12, 2019

Test build #113617 has finished for PR 26479 at commit 8f524c3.

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

@HyukjinKwon
Copy link
Member

Merged to master.

cloud-fan pushed a commit that referenced this pull request Nov 14, 2019
…s from another test case in SQLQueryTestSuite

### What changes were proposed in this pull request?

This pr is to support `--import` directive to load queries from another test case in SQLQueryTestSuite.

This fix comes from the cloud-fan suggestion in #26479 (comment)

### Why are the changes needed?

This functionality might reduce duplicate test code in `SQLQueryTestSuite`.

### Does this PR introduce any user-facing change?

No.

### How was this patch tested?

Run `SQLQueryTestSuite`.

Closes #26497 from maropu/ImportTests.

Authored-by: Takeshi Yamamuro <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
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.

7 participants