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

[SPARK-8573] [SPARK-8568] [SQL] [PYSPARK] raise Exception if column is used in booelan expression #6961

Closed
wants to merge 4 commits into from

Conversation

davies
Copy link
Contributor

@davies davies commented Jun 23, 2015

It's a common mistake that user will put Column in a boolean expression (together with and , or), which does not work as expected, we should raise a exception in that case, and suggest user to use &, | instead.

@davies
Copy link
Contributor Author

davies commented Jun 23, 2015

cc @rxin

@@ -396,6 +396,11 @@ def over(self, window):
jc = self._jc.over(window._jspec)
return Column(jc)

def __nonzero__(self):
raise ValueError("Can't convert column into bool: please use '&' for 'and', '|' for 'or', "
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 mention not as well?

And "Can't" -> "Cannot"

@rxin
Copy link
Contributor

rxin commented Jun 23, 2015

lgtm otherwise

@davies
Copy link
Contributor Author

davies commented Jun 23, 2015

@rxin updated.

@@ -396,6 +396,11 @@ def over(self, window):
jc = self._jc.over(window._jspec)
return Column(jc)

def __nonzero__(self):
raise ValueError("Cannot convert column into bool: please use '&' for 'and', '|' for 'or', "
"'~'for 'not', when using Column in a boolean expression.")
Copy link
Contributor

Choose a reason for hiding this comment

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

missed a space after ~

actually let's do this

Cannot convert column into bool: please use '&' for 'and', '|' for 'or', and '~' for 'not' when building DataFrame boolean expressions.

@davies davies changed the title [SQL] [PYSPARK] raise Exception if column is used in booelan expression [SPARK-8573] [SPARK-8568] [SQL] [PYSPARK] raise Exception if column is used in booelan expression Jun 23, 2015
@SparkQA
Copy link

SparkQA commented Jun 23, 2015

Test build #35590 has finished for PR 6961 at commit f70c08e.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • class LinearDataGenerator(object):

@SparkQA
Copy link

SparkQA commented Jun 23, 2015

Test build #954 has finished for PR 6961 at commit f70c08e.

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

@SparkQA
Copy link

SparkQA commented Jun 23, 2015

Test build #35592 has finished for PR 6961 at commit 07dff84.

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

@SparkQA
Copy link

SparkQA commented Jun 23, 2015

Test build #35597 has finished for PR 6961 at commit af74bd6.

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

asfgit pushed a commit that referenced this pull request Jun 23, 2015
…s used in booelan expression

It's a common mistake that user will put Column in a boolean expression (together with `and` , `or`), which does not work as expected, we should raise a exception in that case, and suggest user to use `&`, `|` instead.

Author: Davies Liu <davies@databricks.com>

Closes #6961 from davies/column_bool and squashes the following commits:

9f19beb [Davies Liu] update message
af74bd6 [Davies Liu] fix tests
07dff84 [Davies Liu] address comments, fix tests
f70c08e [Davies Liu] raise Exception if column is used in booelan expression

(cherry picked from commit 7fb5ae5)
Signed-off-by: Davies Liu <davies@databricks.com>
@asfgit asfgit closed this in 7fb5ae5 Jun 23, 2015
@SparkQA
Copy link

SparkQA commented Jun 23, 2015

Test build #35604 has finished for PR 6961 at commit 9f19beb.

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

@AmplabJenkins
Copy link

Merged build finished. Test FAILed.

nemccarthy pushed a commit to nemccarthy/spark that referenced this pull request Jun 25, 2015
…s used in booelan expression

It's a common mistake that user will put Column in a boolean expression (together with `and` , `or`), which does not work as expected, we should raise a exception in that case, and suggest user to use `&`, `|` instead.

Author: Davies Liu <davies@databricks.com>

Closes apache#6961 from davies/column_bool and squashes the following commits:

9f19beb [Davies Liu] update message
af74bd6 [Davies Liu] fix tests
07dff84 [Davies Liu] address comments, fix tests
f70c08e [Davies Liu] raise Exception if column is used in booelan expression

(cherry picked from commit 7fb5ae5)
Signed-off-by: Davies Liu <davies@databricks.com>
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