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-7321][SQL] Add Column expression for conditional statements #5932

Closed
wants to merge 4 commits into from

Conversation

kaka1992
Copy link
Contributor

@kaka1992 kaka1992 commented May 6, 2015

Add case when else support in scala/java/python.
https://issues.apache.org/jira/browse/SPARK-7321
@rxin

@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@rxin
Copy link
Contributor

rxin commented May 6, 2015

@kaka1992 I think it's supposed to be

when(df.age == 1, "one").when(df.age == 2, "two").otherwise("unknown")

@kaka1992
Copy link
Contributor Author

kaka1992 commented May 6, 2015

@rxin This would be weird in scala as $"age".when($"age" == 1, "one").when($"age" == 2, "two").otherwise....

@rxin
Copy link
Contributor

rxin commented May 6, 2015

Scala also supports df("age"). I think we can add a separate function later on that does what you are proposing here, but that's not the "when" function.

@rxin
Copy link
Contributor

rxin commented May 11, 2015

@kaka1992 would you have time to update this?

rxin added a commit to rxin/spark that referenced this pull request May 12, 2015
[SPARK-7321][SQL] Add Column expression for conditional statements
@rxin
Copy link
Contributor

rxin commented May 12, 2015

Thanks, @kaka1992. I submitted a new pull request based on your work: #6072

The commit will go in under your name.

@asfgit asfgit closed this in 97dee31 May 13, 2015
asfgit pushed a commit that referenced this pull request May 13, 2015
…hen/otherwise)

This builds on #5932 and should close #5932 as well.

As an example:
```python
df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect()
```

Author: Reynold Xin <rxin@databricks.com>
Author: kaka1992 <kaka_1992@163.com>

Closes #6072 from rxin/when-expr and squashes the following commits:

8f49201 [Reynold Xin] Throw exception if otherwise is applied twice.
0455eda [Reynold Xin] Reset run-tests.
bfb9d9f [Reynold Xin] Updated documentation and test cases.
762f6a5 [Reynold Xin] Merge pull request #5932 from kaka1992/IFCASE
95724c6 [kaka1992] Update
8218d0a [kaka1992] Update
801009e [kaka1992] Update
76d6346 [kaka1992] [SPARK-7321][SQL] Add Column expression for conditional statements (if, case)

(cherry picked from commit 97dee31)
Signed-off-by: Reynold Xin <rxin@databricks.com>
jeanlyn pushed a commit to jeanlyn/spark that referenced this pull request May 28, 2015
…hen/otherwise)

This builds on apache#5932 and should close apache#5932 as well.

As an example:
```python
df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect()
```

Author: Reynold Xin <rxin@databricks.com>
Author: kaka1992 <kaka_1992@163.com>

Closes apache#6072 from rxin/when-expr and squashes the following commits:

8f49201 [Reynold Xin] Throw exception if otherwise is applied twice.
0455eda [Reynold Xin] Reset run-tests.
bfb9d9f [Reynold Xin] Updated documentation and test cases.
762f6a5 [Reynold Xin] Merge pull request apache#5932 from kaka1992/IFCASE
95724c6 [kaka1992] Update
8218d0a [kaka1992] Update
801009e [kaka1992] Update
76d6346 [kaka1992] [SPARK-7321][SQL] Add Column expression for conditional statements (if, case)
jeanlyn pushed a commit to jeanlyn/spark that referenced this pull request Jun 12, 2015
…hen/otherwise)

This builds on apache#5932 and should close apache#5932 as well.

As an example:
```python
df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect()
```

Author: Reynold Xin <rxin@databricks.com>
Author: kaka1992 <kaka_1992@163.com>

Closes apache#6072 from rxin/when-expr and squashes the following commits:

8f49201 [Reynold Xin] Throw exception if otherwise is applied twice.
0455eda [Reynold Xin] Reset run-tests.
bfb9d9f [Reynold Xin] Updated documentation and test cases.
762f6a5 [Reynold Xin] Merge pull request apache#5932 from kaka1992/IFCASE
95724c6 [kaka1992] Update
8218d0a [kaka1992] Update
801009e [kaka1992] Update
76d6346 [kaka1992] [SPARK-7321][SQL] Add Column expression for conditional statements (if, case)
nemccarthy pushed a commit to nemccarthy/spark that referenced this pull request Jun 19, 2015
…hen/otherwise)

This builds on apache#5932 and should close apache#5932 as well.

As an example:
```python
df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect()
```

Author: Reynold Xin <rxin@databricks.com>
Author: kaka1992 <kaka_1992@163.com>

Closes apache#6072 from rxin/when-expr and squashes the following commits:

8f49201 [Reynold Xin] Throw exception if otherwise is applied twice.
0455eda [Reynold Xin] Reset run-tests.
bfb9d9f [Reynold Xin] Updated documentation and test cases.
762f6a5 [Reynold Xin] Merge pull request apache#5932 from kaka1992/IFCASE
95724c6 [kaka1992] Update
8218d0a [kaka1992] Update
801009e [kaka1992] Update
76d6346 [kaka1992] [SPARK-7321][SQL] Add Column expression for conditional statements (if, case)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants