Skip to content

[SPARK-14335][SQL] Describe function command returns wrong output#12128

Closed
yongtang wants to merge 6 commits intoapache:masterfrom
yongtang:SPARK-14335
Closed

[SPARK-14335][SQL] Describe function command returns wrong output#12128
yongtang wants to merge 6 commits intoapache:masterfrom
yongtang:SPARK-14335

Conversation

@yongtang
Copy link
Contributor

@yongtang yongtang commented Apr 2, 2016

What changes were proposed in this pull request?

…because some of built-in functions are not in function registry.

This fix tries to fix issues in describe function command where some of the outputs
still shows Hive's function because some built-in functions are not in FunctionRegistry.

The following built-in functions have been added to FunctionRegistry:

-
!
*
/
&
%
^
+
<
<=
<=>
=
==
>
>=
|
~
and
in
like
not
or
rlike
when

The following listed functions are not added, but hard coded in commands.scala (@hvanhovell):

!=
<>
between
case

Below are the existing result of the above functions that have not been added:

spark-sql> describe function `!=`;
Function: <>
Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNotEqual
Usage: a <> b - Returns TRUE if a is not equal to b
spark-sql> describe function `<>`;
Function: <>
Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNotEqual
Usage: a <> b - Returns TRUE if a is not equal to b
spark-sql> describe function `between`;
Function: between
Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFBetween
Usage: between a [NOT] BETWEEN b AND c - evaluate if a is [not] in between b and c
spark-sql> describe function `case`;
Function: case
Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFCase
Usage: CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END - When a = b, returns c; when a = d, return e; else return f

How was this patch tested?

Existing tests passed. Additional test cases added.

@SparkQA
Copy link

SparkQA commented Apr 2, 2016

Test build #2735 has finished for PR 12128 at commit 7a84e9b.

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

@hvanhovell
Copy link
Contributor

@yhuai what do you want to do with the composed expressions, i.e.: !=, <> & between? case is more of a keyword.

@yhuai
Copy link
Contributor

yhuai commented Apr 3, 2016

For composed expressions, if there are only a few of them, maybe we can have special handling in the describe command? For case, we do not need to support describe function case if it is more of a keyword.

@yongtang
Copy link
Contributor Author

yongtang commented Apr 3, 2016

Hi @yhuai @hvanhovell , as a reference, below is the result of the describe function for current master. I haven't been able to identify the corresponding functions:

spark-sql> describe function `!=`;
Function: <>
Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNotEqual
Usage: a <> b - Returns TRUE if a is not equal to b
spark-sql> describe function `<>`;
Function: <>
Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNotEqual
Usage: a <> b - Returns TRUE if a is not equal to b
spark-sql> describe function `between`;
Function: between
Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFBetween
Usage: between a [NOT] BETWEEN b AND c - evaluate if a is [not] in between b and c
spark-sql> describe function `case`;
Function: case
Class: org.apache.hadoop.hive.ql.udf.generic.GenericUDFCase
Usage: CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END - When a = b, returns c; when a = d, return e; else return f

@hvanhovell
Copy link
Contributor

@yongtang can you see if you can hardcode the descriptions for the composed function into the DecribeFunction command? See: https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/execution/command/commands.scala#L421-L423

@yongtang
Copy link
Contributor Author

yongtang commented Apr 3, 2016

@hvanhovell Thanks. Let me take a look and update the pull request.

@yongtang
Copy link
Contributor Author

yongtang commented Apr 4, 2016

Hi @hvanhovell the pull request was updated. Let me know if there are any issues.

@yhuai
Copy link
Contributor

yhuai commented Apr 4, 2016

ok to test

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add the usage at here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yhuai Sure let me update the pull request shortly.

@yongtang
Copy link
Contributor Author

yongtang commented Apr 4, 2016

Hi @yhuai the pull request has been updated with the usages being added. Let me know if there are any other issues. And thanks for the review.

@SparkQA
Copy link

SparkQA commented Apr 4, 2016

Test build #54829 has finished for PR 12128 at commit baad78f.

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

@SparkQA
Copy link

SparkQA commented Apr 4, 2016

Test build #54834 has finished for PR 12128 at commit f318e8c.

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

@SparkQA
Copy link

SparkQA commented Apr 4, 2016

Test build #54855 has finished for PR 12128 at commit 6e1e879.

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

@SparkQA
Copy link

SparkQA commented Apr 4, 2016

Test build #2743 has finished for PR 12128 at commit 6e1e879.

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we also need to match upper case letters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @yhuai let me update the pull request.

@yongtang
Copy link
Contributor Author

yongtang commented Apr 5, 2016

Thanks @yhuai. The pull request has been updated. Please let me know if there are any other issues.

@SparkQA
Copy link

SparkQA commented Apr 5, 2016

Test build #54928 has finished for PR 12128 at commit 353a132.

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also add a test case for one of the hard coded functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hvanhovell Thanks. Additional test cases have been added.

@SparkQA
Copy link

SparkQA commented Apr 5, 2016

Test build #54986 has finished for PR 12128 at commit 927272c.

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

@yhuai
Copy link
Contributor

yhuai commented Apr 9, 2016

@yongtang This PR looks good to me. Can you rebase?

yongtang added 6 commits April 9, 2016 17:34
…ause some of built-in functions are not in function registry.

This fix tries to fix issues in `describe function` command where some of the outputs
still shows Hive's function because some built-in functions are not in FunctionRegistry.

The following built-in functions have been added to FunctionRegistry:
```
-
!
*
/
&
%
^
+
<
<=
<=>
=
==
>
>=
|
~
and
in
like
not
or
rlike
when
```

The following listed functions are not added:
```
!=
<>
between
case
```

All existing tests passed.
…ause some of built-in functions are not in function registry.

Hard code describe functions for `<>`, `!=`, `between`, and `case` for now,
based on the feedback from @hvanhovell.
…ause some of built-in functions are not in function registry.

Add usages for `<>`, `!=`, `between`, and `case`, based on the feedback from @yhuai.
…ause some of built-in functions are not in function registry.

Update SQLQuerySuite to reflect changes in `describe function`.
…ause some of built-in functions are not in function registry.

Take into consideration the upper and lower case of `describe function` `between` and `describe function` `case`.
Fix incorrect `between` usage.
…ause some of built-in functions are not in function registry.

Add tests to cover hard coded 'describe function's.
@SparkQA
Copy link

SparkQA commented Apr 9, 2016

Test build #55436 has finished for PR 12128 at commit 4c59c81.

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

@yongtang
Copy link
Contributor Author

yongtang commented Apr 9, 2016

Thanks @yhuai. The pull request has been rebased and passed the Jenkins. Please let me know if there are any other issues.

@asfgit asfgit closed this in cd2fed7 Apr 9, 2016
@yongtang yongtang deleted the SPARK-14335 branch April 9, 2016 23:12
Sign up for free to 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