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

feat: Add manual test to calculate spark builtin functions coverage #263

Merged
merged 12 commits into from
Apr 20, 2024

Conversation

comphead
Copy link
Contributor

Which issue does this PR close?

Closes #.
Related to #240

Rationale for this change

Comet needs a tool to evaluate which spark builtin functions are currently supported by Comet with native execution

What changes are included in this PR?

The PR includes the manual test CometExpressionCoverageSuite which will create 2 files
doc/spark_coverage.txt, doc/spark_coverage_agg.txt containing current coverage situation

How are these changes tested?

@comphead
Copy link
Contributor Author

files need to be excluded from RAT

@comphead comphead requested review from viirya and sunchao April 13, 2024 04:54
Copy link
Member

@sunchao sunchao left a comment

Choose a reason for hiding this comment

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

Nice, this is pretty neat!

doc/spark_coverage.txt Outdated Show resolved Hide resolved
Copy link
Contributor

@advancedxy advancedxy left a comment

Choose a reason for hiding this comment

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

This is great work. Left two comments.

doc/spark_coverage.txt Outdated Show resolved Hide resolved
"select result, d._2 as reason, count(1) cnt from (select name, t.details.result, explode_outer(t.details.details) as d from t) group by 1, 2"),
500,
0)
Files.write(Paths.get("doc/spark_coverage_agg.txt"), str_agg.getBytes(StandardCharsets.UTF_8))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Files.write(Paths.get("doc/spark_coverage_agg.txt"), str_agg.getBytes(StandardCharsets.UTF_8))
Files.write(Paths.get("doc/spark_agg_expr_coverage.txt"), str_agg.getBytes(StandardCharsets.UTF_8))

Copy link
Member

Choose a reason for hiding this comment

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

Oh, the file is not for aggregation expression. nvm.

Copy link
Member

Choose a reason for hiding this comment

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

But I think it may be better to have the aggregation of expression coverage in the same file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filed #282

@@ -0,0 +1,421 @@
+---------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|name |details |
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we can produce a markdown document instead of plain text. So it can be displayed in format. We can do it in follow up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Filed #282

|FAILED |Failed on native side |4 |
|PASSED |OK |254|
|SKIPPED|null |12 |
|FAILED |Failed on something else. Check query manually|10 |
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'm not sure I understand what this document represents?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SKIPPED means the indicator, there is no examples in the spark catalog, I'll add more meaningful message

@comphead
Copy link
Contributor Author

Something is wrong with TPC-DS Correctness it runs for 5 hours and stuck on downloadin Maven deps

Copy link
Contributor

@advancedxy advancedxy left a comment

Choose a reason for hiding this comment

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

LGTM, except some minor comments which could be addressed in followup PRs.


import testImplicits._

private val rawCoverageFilePath = "doc/spark_builtin_expr_coverage.txt"
Copy link
Contributor

Choose a reason for hiding this comment

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

After a second thought, I think maybe we should add spark version in this file name. More functions will be added in new spark version. It might be helpful to indicate how many functions are supported in each Spark version.

This can be done in a follow up though

Files.write(Paths.get(aggCoverageFilePath), str_agg.getBytes(StandardCharsets.UTF_8))

val str = showString(spark.sql("select * from t order by 1"), 1000, 0)
Files.write(Paths.get(rawCoverageFilePath), str.getBytes(StandardCharsets.UTF_8))
Copy link
Contributor

Choose a reason for hiding this comment

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

I second @viirya's point, #263 (comment). It would be better to put the aggregated result in the same file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see you filed a new issue. It could be addressed in a followup PR then.

@comphead comphead requested a review from viirya April 18, 2024 15:32
|FAILED |Failed on native side |16 |
|FAILED |Failed on something else. Check query manually |4 |
|PASSED |OK |101|
|SKIPPED|No examples found in spark.sessionState.functionRegistry|12 |
Copy link
Member

Choose a reason for hiding this comment

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

I'm thinking to have this aggregated summary in the expr coverage file too. It will be more readable. We can do it in making the coverage file as markdown format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I combined all of that in #282

Comment on lines 744 to 748
// disable constant folding. This optimization rule precompute and select value as literal
// which subsequently leads to false positives
//
// ConstantFolding is a operator optimization rule in Catalyst that replaces expressions
// that can be statically evaluated with their equivalent literal values.
Copy link
Member

Choose a reason for hiding this comment

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

This function doesn't always exclude ConstantFolding but passed in ones. This comment should be moved to where you pass ConstantFolding when you call testSingleLineQuery in CometExpressionCoverageSuite.

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

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

A few minor comments.

@sunchao sunchao merged commit b06794f into apache:main Apr 20, 2024
28 checks passed
himadripal pushed a commit to himadripal/datafusion-comet that referenced this pull request Sep 7, 2024
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