Skip to content

[SPARK-20876][SQL]If the input parameter is float type for ceil or floor,the result is not we expected - #18103

Closed
10110346 wants to merge 1 commit into
apache:masterfrom
10110346:wip-lx-0525-1
Closed

[SPARK-20876][SQL]If the input parameter is float type for ceil or floor,the result is not we expected#18103
10110346 wants to merge 1 commit into
apache:masterfrom
10110346:wip-lx-0525-1

Conversation

@10110346

@1011034610110346 commented May 25, 2017

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

spark-sql>SELECT ceil(cast(12345.1233 as float));
spark-sql>12345
For this case, the result we expected is 12346
spark-sql>SELECT floor(cast(-12345.1233 as float));
spark-sql>-12345
For this case, the result we expected is -12346

Because in Ceil or Floor, inputTypes has no FloatType, so it is converted to LongType.

How was this patch tested?

After the modification:
spark-sql>SELECT ceil(cast(12345.1233 as float));
spark-sql>12346
spark-sql>SELECT floor(cast(-12345.1233 as float));
spark-sql>-12346

@10110346
10110346force-pushed the wip-lx-0525-1 branch 4 times, most recently from 953d207 to c9331e3CompareMay 25, 2017 03:38
@1011034610110346 changed the title [SPARK-20876][SQL]if the input parameter is float type for ceil ,the result is not we expected[SPARK-20876][SQL]if the input parameter is float type for ceil or floor,the result is not we expectedMay 25, 2017
@sameeragarwal

Copy link
Copy Markdown
Member

ok to test

1 similar comment
@gatorsmile

Copy link
Copy Markdown
Member

ok to test

@1011034610110346 changed the title [SPARK-20876][SQL]if the input parameter is float type for ceil or floor,the result is not we expected[SPARK-20876][SQL]If the input parameter is float type for ceil or floor,the result is not we expectedMay 25, 2017
@SparkQA

Copy link
Copy Markdown

Test build #77345 has finished for PR 18103 at commit 37f0ff3.

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

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.

You also need to fix this code path.

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.

Moving the related test cases from operators.sql here. You can hit the bug I mentioned above.

@1011034610110346May 27, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

yes, actually, i have done it as #18082

@1011034610110346May 27, 2017

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@gatorsmile I closed the PR #18082 temporarily

@gatorsmilegatorsmileMay 27, 2017

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.

No need to add FloatType, I think. Type coersion will promote it to DoubleType.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

yes, it will promote it to DoubleType, but must move LongType to end

@SparkQA

Copy link
Copy Markdown

Test build #77444 has finished for PR 18103 at commit 4cdb44e.

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

@gatorsmile

Copy link
Copy Markdown
Member

Could you remove the sql statements from opterators.sql after you moving them to mathExpressionSuite?

@gatorsmile

Copy link
Copy Markdown
Member

LGTM except one comment.

@SparkQA

Copy link
Copy Markdown

Test build #77450 has started for PR 18103 at commit 660c038.

@SparkQA

Copy link
Copy Markdown

Test build #77458 has finished for PR 18103 at commit 93baa57.

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

@gatorsmile

Copy link
Copy Markdown
Member

Thanks! Merging to master.

@gatorsmile

Copy link
Copy Markdown
Member

Could you open another PR to backport the fix to 2.2? Thanks!

asfgit pushed a commit that referenced this pull request May 31, 2017
… for ceil or floor,the result is not we expected
## What changes were proposed in this pull request?
This PR is to backport #18103 to Spark 2.2
## How was this patch tested?
unit test
Author: liuxian <liu.xian3@zte.com.cn>
Closes#18155 from 10110346/wip-lx-0531.
Sign up for freeto 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.

4 participants

@10110346@sameeragarwal@gatorsmile@SparkQA