Skip to content

Conversation

@ulysses-you
Copy link
Contributor

What changes were proposed in this pull request?

Add distinct info at UnresolvedFunction.toString.

Why are the changes needed?

Make UnresolvedFunction info complete.

create table test (c1 int, c2 int);
explain extended select sum(distinct c1) from test;

-- before this pr
== Parsed Logical Plan ==
'Project [unresolvedalias('sum('c1), None)]
+- 'UnresolvedRelation [test]

-- after this pr
== Parsed Logical Plan ==
'Project [unresolvedalias('sum(distinct 'c1), None)]
+- 'UnresolvedRelation [test]

Does this PR introduce any user-facing change?

Yes, get distinct info during sql parse.

How was this patch tested?

manual test.

@ulysses-you
Copy link
Contributor Author

@maropu sorry for the late pr.

override def toString: String = s"'$name(${children.mkString(", ")})"
override def toString: String = {
val distinct = if (isDistinct) "distinct " else ""
s"'$name($distinct${children.mkString(", ")})"
Copy link
Member

Choose a reason for hiding this comment

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

We need to handle filter, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filter as a child already exists.

Copy link
Member

@maropu maropu Aug 31, 2020

Choose a reason for hiding this comment

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

Ah, I see. But, its better to reformat the output, 'Project [unresolvedalias('sum('c1), None)] into 'Project [unresolvedalias('sum('c1))] because None looks ambigous for users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The none is introduced by unresolvedalias, shall we reformat it in this pr ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems we can check none in Expression.flatArguments to avoid these case.

  protected def flatArguments: Iterator[Any] = stringArgs.flatMap {
    case t: Iterable[_] => t
    case single => single :: Nil
    case None => Nil
  }

Copy link
Member

@maropu maropu Aug 31, 2020

Choose a reason for hiding this comment

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

Oh, ok. Yea, can you? NVM, on second thought, the current one looks okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this like ok ? please tell me if need to do anything else.

Copy link
Member

Choose a reason for hiding this comment

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

Could you add tests somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about add test in explain.sql ? like this

-- distinct func
EXPLAIN EXTENDED
  SELECT sum(distinct val)
  FROM explain_temp1

Copy link
Member

Choose a reason for hiding this comment

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

sgtm

@SparkQA
Copy link

SparkQA commented Aug 31, 2020

Test build #128056 has finished for PR 29586 at commit d4e578c.

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

@SparkQA
Copy link

SparkQA commented Sep 8, 2020

Test build #128373 has finished for PR 29586 at commit 745de51.

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

@SparkQA
Copy link

SparkQA commented Sep 8, 2020

Test build #128379 has finished for PR 29586 at commit 7f112c9.

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

@SparkQA
Copy link

SparkQA commented Sep 8, 2020

Test build #128392 has finished for PR 29586 at commit a784a9b.

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

@SparkQA
Copy link

SparkQA commented Sep 8, 2020

Test build #128402 has finished for PR 29586 at commit 0eeafdc.

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

@SparkQA
Copy link

SparkQA commented Sep 8, 2020

Test build #128411 has finished for PR 29586 at commit b8c438a.

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

@SparkQA
Copy link

SparkQA commented Sep 16, 2020

Test build #128726 has finished for PR 29586 at commit 458d744.

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

@SparkQA
Copy link

SparkQA commented Sep 16, 2020

Test build #128733 has finished for PR 29586 at commit c340253.

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

@SparkQA
Copy link

SparkQA commented Sep 16, 2020

Test build #128741 has finished for PR 29586 at commit 95a3e02.

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

@maropu
Copy link
Member

maropu commented Sep 30, 2020

retest this please

@maropu
Copy link
Member

maropu commented Sep 30, 2020

cc: @HyukjinKwon @viirya

@SparkQA
Copy link

SparkQA commented Oct 1, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33908/

@SparkQA
Copy link

SparkQA commented Oct 1, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33908/

@maropu
Copy link
Member

maropu commented Oct 1, 2020

@ulysses-you could you fix the test failures?

@HyukjinKwon
Copy link
Member

retest this please

@SparkQA
Copy link

SparkQA commented Oct 2, 2020

Test build #129337 has finished for PR 29586 at commit 95a3e02.

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

@SparkQA
Copy link

SparkQA commented Oct 2, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33950/

@SparkQA
Copy link

SparkQA commented Oct 2, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/33950/

@ulysses-you
Copy link
Contributor Author

thanks @maropu, can you trigger an another test ? I'm not sure if it is a related test failure.

@maropu
Copy link
Member

maropu commented Oct 6, 2020

thanks @maropu, can you trigger an another test ? I'm not sure if it is a related test failure.

You cannot do so?

@maropu
Copy link
Member

maropu commented Oct 6, 2020

retest this please

@SparkQA
Copy link

SparkQA commented Oct 6, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34060/

@SparkQA
Copy link

SparkQA commented Oct 6, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34060/

@SparkQA
Copy link

SparkQA commented Oct 6, 2020

Test build #129453 has finished for PR 29586 at commit 95a3e02.

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

@maropu
Copy link
Member

maropu commented Oct 6, 2020

The test failure looks valid.

@ulysses-you
Copy link
Contributor Author

thanks @maropu , this failure is introduced after #29756. Updated the test.

@SparkQA
Copy link

SparkQA commented Oct 8, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34161/

@SparkQA
Copy link

SparkQA commented Oct 8, 2020

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34161/

@SparkQA
Copy link

SparkQA commented Oct 8, 2020

Test build #129555 has finished for PR 29586 at commit 4e10394.

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

@SparkQA
Copy link

SparkQA commented Oct 8, 2020

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34162/

@SparkQA
Copy link

SparkQA commented Oct 8, 2020

Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/34162/

@SparkQA
Copy link

SparkQA commented Oct 8, 2020

Test build #129556 has finished for PR 29586 at commit 75d0b58.

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

@maropu maropu closed this in a907729 Oct 9, 2020
@maropu
Copy link
Member

maropu commented Oct 9, 2020

Thanks! Merged to master.

@ulysses-you
Copy link
Contributor Author

thanks for merging !

thbzh pushed a commit to thbzh/spark that referenced this pull request Nov 10, 2022
### What changes were proposed in this pull request?

Add distinct info at `UnresolvedFunction.toString`.

### Why are the changes needed?

Make `UnresolvedFunction` info complete.

```
create table test (c1 int, c2 int);
explain extended select sum(distinct c1) from test;

-- before this pr
== Parsed Logical Plan ==
'Project [unresolvedalias('sum('c1), None)]
+- 'UnresolvedRelation [test]

-- after this pr
== Parsed Logical Plan ==
'Project [unresolvedalias('sum(distinct 'c1), None)]
+- 'UnresolvedRelation [test]
```

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

Yes, get distinct info during sql parse.

### How was this patch tested?

manual test.

Closes apache#29586 from ulysses-you/SPARK-32743.

Authored-by: ulysses <[email protected]>
Signed-off-by: Takeshi Yamamuro <[email protected]>
(cherry picked from commit a907729)

# Conflicts:
#	sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
#	sql/core/src/test/resources/sql-tests/results/explain-aqe.sql.out
#	sql/core/src/test/resources/sql-tests/results/explain.sql.out
@ulysses-you ulysses-you deleted the SPARK-32743 branch October 18, 2023 09:13
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.

5 participants