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

[SPARK-29648][SQL][TESTS] Port limit.sql #26311

Closed
wants to merge 2 commits into from

Conversation

maropu
Copy link
Member

@maropu maropu commented Oct 30, 2019

What changes were proposed in this pull request?

This PR ports limit.sql from PostgreSQL regression tests https://github.com/postgres/postgres/blob/REL_12_STABLE/src/test/regress/sql/limit.sql

The expected results can be found in the link: https://github.com/postgres/postgres/blob/REL_12_STABLE/src/test/regress/expected/limit.out

Why are the changes needed?

To check behaviour differences between Spark and PostgreSQL

Does this PR introduce any user-facing change?

No

How was this patch tested?

Pass the Jenkins. And, Comparison with PgSQL results

-- Test null limit and offset. The planner would discard a simple null
-- constant, so to ensure executor is exercised, do this:
-- [SPARK-29650] Discard a NULL constant in LIMIT
select * from int8_tbl limit (case when random() < 0.5 then bigint(null) end);
Copy link
Member Author

Choose a reason for hiding this comment

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

@SparkQA
Copy link

SparkQA commented Oct 30, 2019

Test build #112892 has finished for PR 26311 at commit 5032350.

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

@maropu
Copy link
Member Author

maropu commented Oct 30, 2019

retest this please

@SparkQA
Copy link

SparkQA commented Oct 30, 2019

Test build #112898 has finished for PR 26311 at commit 3abbe57.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 30, 2019

Test build #112894 has finished for PR 26311 at commit 3abbe57.

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

-- select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2
-- from tenk1 group by thousand order by thousand limit 3;

select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2
Copy link
Member

Choose a reason for hiding this comment

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

Although I believe Apache Spark behavior random()*0 == 0.0 is more natural, do we have a JIRA issue for this difference from PostgreSQL where random()*0 == 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, but I missed your point and the result seems to be the same;

select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2
  from tenk1 group by thousand order by thousand limit 3;
  s1   |  s2   
-------+-------
 45000 | 45000
 45010 | 45010
 45020 | 45020
(3 rows)

https://github.com/postgres/postgres/blob/REL_12_STABLE/src/test/regress/expected/limit.out#L497-L504

Also, I tried below;

postgres=# select * from (values (1)) t(v) where random() * 0.0 = 0.0;
 v 
---
 1
(1 row)

scala> sql("""select * from (values (1)) t(v) where random() * 0.0 = 0.0""").show()
+---+
|  v|
+---+
|  1|
+---+

What's the difference here?

Copy link
Member

Choose a reason for hiding this comment

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

The generated result is not the same in this PR.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

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

+1, LGTM (except one minor request to add a JIRA ID comment for the difference).

@dongjoon-hyun
Copy link
Member

Then, merged to master! Thank you, @maropu !

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