Skip to content

Conversation

@vinodkc
Copy link
Contributor

@vinodkc vinodkc commented Jun 26, 2015

No description provided.

@animeshbaranawal
Copy link

Just changing the loop structure is not sufficient because changing the loop structure causes the case when tests in ConditionalExpressionSuite to fail.

@vinodkc
Copy link
Contributor Author

vinodkc commented Jun 26, 2015

Ok, I'll update that test suite.

@smola , In predicates.scala, eval method of case class EqualNullSafe has similar if (l == null && r == null) check , shall I modify that condition too?

@animeshbaranawal
Copy link

Sorry for opening another PR @vinodkc
Even changing the testsuite alone would not work. Some changes to the gencode function are also required.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is far enough from Java/Scala semantics that it warrants a scaladoc and a pointer to NULL semantics in SQL, IMO

@marmbrus
Copy link
Contributor

marmbrus commented Jul 8, 2015

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.

We should at least consider renaming this function. Null safe equals in sql typically returns true for null <=> null

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_equal-to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marmbrus
Shall I rename the function private def equalNullSafe(l: Any, r: Any)
to private def equal(l: Any, r: Any) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

or threeValueEquals ?

@SparkQA
Copy link

SparkQA commented Jul 9, 2015

Test build #36862 has finished for PR 7040 at commit aac9f67.

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

@cloud-fan
Copy link
Contributor

According to the JIRA, if key is null, we can just return the else part(or null if there is no else), right?
I think we can simplify the evaluation logic like

if (key == null) {
  return else part or null
} else {
  for(iterate when parts) {
    // as key is not null here, we can just use ==, and remove that nullSafeEqual
    if (key == when) {
      return then part
    }
  }
}

@SparkQA
Copy link

SparkQA commented Jul 13, 2015

Test build #37120 has finished for PR 7040 at commit be5e641.

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

@marmbrus
Copy link
Contributor

I'm going to merge this to fix the bug. Thanks!

Feel free to do a follow-up to further simplify / optimize.

vinodkc pushed a commit that referenced this pull request Jul 13, 2015
Author: Vinod K C <[email protected]>

Closes #7040 from vinodkc/fix_CaseKeyWhen_equalNullSafe and squashes the following commits:

be5e641 [Vinod K C] Renamed equalNullSafe to threeValueEquals
aac9f67 [Vinod K C] Updated test suite and genCode method
f2d0b53 [Vinod K C]  Fix equalNullSafe comparison
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@marmbrus
Copy link
Contributor

Can you close this please, now that it has been merged?

@vinodkc vinodkc closed this Jul 14, 2015
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.

7 participants