Skip to content

Conversation

@maropu
Copy link
Member

@maropu maropu commented Apr 23, 2020

What changes were proposed in this pull request?

This PR intends to add a new test suite for ExpressionInfo. Major changes are as follows;

Why are the changes needed?

To improve test suites/coverage.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added tests.


// The groups below are almost the same with ones defined in `sql/functions.sql`.
// But, `collection_funcs` is split into fine-grained three groups: `array_funcs`, `map_funcs`,
// and `json_funcs`.
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a minor follow-up for #28224, @HyukjinKwon

Copy link
Member

Choose a reason for hiding this comment

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

Nice but what about we document this in ExpressionDescription, and here we say things like please refer ExpressionDescription?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, the idea looks nice. I'll update.

assert(errMsg.contains("'group' is malformed in the expression [testName]."))
}

test("error handling in ExpressionInfo") {
Copy link
Member Author

Choose a reason for hiding this comment

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

To improve test coverage, a new test added here.


class ExpressionInfoSuite extends SparkFunSuite with SharedSparkSession {

test("Replace _FUNC_ in ExpressionInfo") {
Copy link
Member Author

Choose a reason for hiding this comment

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

from UDFSuite

assert(info.getExtended.contains("> SELECT upper('SparkSql');"))
}

test("group info in ExpressionInfo") {
Copy link
Member Author

Choose a reason for hiding this comment

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

from UDFSuite

assert(errMsg3.contains("'deprecated' is malformed in the expression [testName]."))
}

test("using _FUNC_ instead of function names in examples") {
Copy link
Member Author

Choose a reason for hiding this comment

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

from SQLQuerySuite

}
}

test("check outputs of expression examples") {
Copy link
Member Author

Choose a reason for hiding this comment

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

from SQLQuerySuite

withClue(s"Function '${info.getName}', Expression class '$className'") {
val example = info.getExamples
checkExampleSyntax(example)
example.split(" > ").toList.foreach {
Copy link
Member Author

Choose a reason for hiding this comment

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

minor: I modified this line a bit as my IDE suggested.

private String since;
private String deprecated;

// The groups below are almost the same with ones defined in `sql/functions.sql`.
Copy link
Member

Choose a reason for hiding this comment

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

maybe you meant functions.sql -> functions.scala?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, yes...

Copy link
Member

@HyukjinKwon HyukjinKwon left a comment

Choose a reason for hiding this comment

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

LGTM otherwise.

/**
* Valid group names are almost the same with one defined as `groupname` in
* `sql/functions.scala`. But, `collection_funcs` is split into fine-grained three groups:
* `array_funcs`, `map_funcs`, and `json_funcs`. See `ExpressionInfo` for the
Copy link
Member

Choose a reason for hiding this comment

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

Why all the csv _funcs are left behind?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just a basic set for the 3.0 release. Yea, we can improve docs by adding more groups. Actually, we need to assign all the exprs to groups for removing the SQL Built-in Function doc:
#28224 (comment) @HyukjinKwon

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks

@SparkQA
Copy link

SparkQA commented Apr 23, 2020

Test build #121661 has finished for PR 28308 at commit c4800ba.

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

@SparkQA
Copy link

SparkQA commented Apr 23, 2020

Test build #121662 has finished for PR 28308 at commit 15df98f.

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

@HyukjinKwon
Copy link
Member

Merged to master and branch-3.0.

HyukjinKwon pushed a commit that referenced this pull request Apr 24, 2020
### What changes were proposed in this pull request?

This PR intends to add a new test suite for `ExpressionInfo`. Major changes are as follows;

 - Added a new test suite named `ExpressionInfoSuite`
 - To improve test coverage, added a test for error handling in `ExpressionInfoSuite`
 - Moved the `ExpressionInfo`-related tests from `UDFSuite` to `ExpressionInfoSuite`
 - Moved the related tests from `SQLQuerySuite` to `ExpressionInfoSuite`
 - Added a comment in `ExpressionInfoSuite` (followup of #28224)

### Why are the changes needed?

To improve test suites/coverage.

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

No.

### How was this patch tested?

Added tests.

Closes #28308 from maropu/SPARK-31526.

Authored-by: Takeshi Yamamuro <[email protected]>
Signed-off-by: HyukjinKwon <[email protected]>
(cherry picked from commit 42f496f)
Signed-off-by: HyukjinKwon <[email protected]>
}
}

test("check outputs of expression examples") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, @maropu this test case has a minor problem when running individually for machines in different timezones: expressions such as FromUnixTime are timezone aware.
In SQLQuerySuite, the timezone is set explicitly in org.apache.spark.sql.QueryTest, however ExpressionInfoSuite doesn't set timezone, thus fails this test case.

Copy link
Member

Choose a reason for hiding this comment

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

@advancedxy, that was fixed SPARK-31725.

Copy link
Member Author

Choose a reason for hiding this comment

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

Have you checked the thread in #28538?

Copy link
Contributor

Choose a reason for hiding this comment

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

@HyukjinKwon and @maropu thanks for the information, I was checking an older version of Spark 3.0

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