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

Add operators to ignore list and update WindowExpr parser #890

Merged
merged 5 commits into from
Apr 1, 2024

Conversation

nartal1
Copy link
Collaborator

@nartal1 nartal1 commented Mar 31, 2024

This PR fixes #833 and fixes #834.

For 833, we added operators mentioned in the issue to IgnorePerf list. Also updated the shouldIgnore function to handle classNames correctly.

For 834, fixed the bug in parser for WindowExec for the case where windowExprs is empty. This happens in case where the string for WIndowExec is truncated.

@nartal1 nartal1 added the core_tools Scope the core module (scala) label Mar 31, 2024
@nartal1 nartal1 self-assigned this Mar 31, 2024
Copy link
Collaborator

@amahussein amahussein left a comment

Choose a reason for hiding this comment

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

Thanks @nartal1

val windowFunc = windowFunctionPattern.findAllIn(expr).toList
// Check to ensure windowFunc is not empty before accessing last element
if (windowFunc.nonEmpty) {
val expr = windowFunc.last
Copy link
Collaborator

Choose a reason for hiding this comment

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

This variable name shadows a variable name in the outer scope "expr"

Signed-off-by: Niranjan Artal <[email protected]>
case _ => // NO OP
if (windowExprs.nonEmpty) {
for ( i <- 0 to windowExprs.size - 1 ) {
val windowFunc = windowFunctionPattern.findAllIn(windowExprs(i)).toList
Copy link
Collaborator

@parthosa parthosa Apr 1, 2024

Choose a reason for hiding this comment

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

Can we use windowExprs.forEach for more idiomatic pattern?

Using last() can throw exceptions if windowFunc is empty. Can we use lastOption?

amahussein
amahussein previously approved these changes Apr 1, 2024
Copy link
Collaborator

@amahussein amahussein left a comment

Choose a reason for hiding this comment

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

Thanks @nartal1 !
I am ok with the changes. I don't remember why we would skip the last entry though.
If you have an insight, you can put a code comment so that we understand that in the future.

@@ -484,7 +488,7 @@ object SQLPlanParser extends Logging {
case c if c.contains("CreateDataSourceTableAsSelectCommand") =>
// create data source table doesn't show the format so we can't determine
// if we support it
ExecInfo(node, sqlID, node.name, expr = "", 1, duration = None, node.id,
ExecInfo(node, sqlID, normalizedNodeName, expr = "", 1, duration = None, node.id,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: It is not introduced by this PR, but I do not see we need this case anymore.
It should be handled by the default case, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right. This would be handled by default case. Removed this case statement.

Copy link
Collaborator

@cindyyuanjiang cindyyuanjiang left a comment

Choose a reason for hiding this comment

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

Thanks @nartal1!

Copy link
Collaborator

@parthosa parthosa left a comment

Choose a reason for hiding this comment

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

Thanks @nartal1. LGTM.

@nartal1 nartal1 merged commit b15659c into NVIDIA:dev Apr 1, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core_tools Scope the core module (scala)
Projects
None yet
4 participants