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

Replace coalesce function with a special form #1430

Closed

Conversation

mbasmanova
Copy link
Contributor

@mbasmanova mbasmanova commented Apr 15, 2022

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate b / 0 and should not fail.

coalesce(a, b / 0)

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 15, 2022
@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@mbasmanova has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

mbasmanova added a commit to mbasmanova/velox-1 that referenced this pull request Apr 15, 2022
Summary:
Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

Pull Request resolved: facebookincubator#1430

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 1b430c3e863a8aaf14ed9cfd96a6118d6c11bb06
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D35674128

Copy link
Contributor

@amitkdutta amitkdutta left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Collaborator

@majetideepak majetideepak left a comment

Choose a reason for hiding this comment

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

@mbasmanova Changes look good to me.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D35674128

mbasmanova added a commit to mbasmanova/velox-1 that referenced this pull request Apr 25, 2022
Summary:
Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

Pull Request resolved: facebookincubator#1430

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 85fec3a9569d56a1917824897162f61028b8ea82
mbasmanova added a commit to mbasmanova/torcharrow that referenced this pull request Apr 25, 2022
Summary:
Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 07650ac8a519e566a96abdc27871c4f131478619
mbasmanova added a commit to mbasmanova/velox-1 that referenced this pull request Apr 25, 2022
Summary:
X-link: pytorch/torcharrow#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

Pull Request resolved: facebookincubator#1430

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 7cf3fac8650f6227beb4f6721935fa73de428397
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D35674128

mbasmanova added a commit to mbasmanova/torcharrow that referenced this pull request Apr 25, 2022
Summary:
Pull Request resolved: pytorch#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: d1fe74c00ac355661ea90bf0d7837b7418ebb7e1
Summary:
X-link: pytorch/torcharrow#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

Pull Request resolved: facebookincubator#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: bb9b73fb1c4160aee7111bf4dc08dcd3d68ebe57
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D35674128

mbasmanova added a commit to mbasmanova/torcharrow that referenced this pull request Apr 26, 2022
Summary:
Pull Request resolved: pytorch#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 6ec63b4f5ecf99247232fb0f006209461a2b7662
mbasmanova added a commit to mbasmanova/torcharrow that referenced this pull request Apr 26, 2022
Summary:
Pull Request resolved: pytorch#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 83b6c13e9ff8a89aee988bbd705dd5e1831c4799
mbasmanova added a commit to mbasmanova/torcharrow that referenced this pull request Apr 26, 2022
Summary:
Pull Request resolved: pytorch#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 4b8d6599e74238b4a20a58c41c72de567b8a4da5
mbasmanova added a commit to mbasmanova/torcharrow that referenced this pull request Apr 26, 2022
Summary:
Pull Request resolved: pytorch#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 6bba174f60a7b1334dbcf8b89a7f245393cf1342
mbasmanova added a commit to mbasmanova/torcharrow that referenced this pull request Apr 26, 2022
Summary:
Pull Request resolved: pytorch#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: e7583dcabfa419ba5afcb425e6c58c5d64c9284b
facebook-github-bot pushed a commit to pytorch/torcharrow that referenced this pull request Apr 27, 2022
Summary:
Pull Request resolved: #301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 2d16cb3404843322da67b699e7163d53757225bd
Copy link
Collaborator

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks for this change.

Another minor cleanup comment is that we could either move CoalesceExpr class to ControlExpr or promote SpecialForm to its own file since it now has implementations spread out from ControlExpr. Will do it some point.

@@ -202,7 +202,7 @@ class FlatVector final : public SimpleVector<T> {
T* mutableRawValues() {
if (!values_ || !values_->unique()) {
BufferPtr newValues =
AlignedBuffer::allocate<T>(BaseVector::length_, values_->pool());
AlignedBuffer::allocate<T>(BaseVector::length_, BaseVector::pool());
Copy link
Collaborator

Choose a reason for hiding this comment

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

QQ : Why is this needed for the current change ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is needed to avoid a crash when values_ is a nullptr.

Arty-Maly pushed a commit to Arty-Maly/velox that referenced this pull request May 13, 2022
Summary:
X-link: pytorch/torcharrow#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

Pull Request resolved: facebookincubator#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 2d16cb3404843322da67b699e7163d53757225bd
facebook-github-bot pushed a commit to pytorch/torcharrow that referenced this pull request Jun 29, 2022
Summary:
X-link: #301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

X-link: facebookincubator/velox#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 2d16cb3404843322da67b699e7163d53757225bd
shiyu-bytedance pushed a commit to shiyu-bytedance/velox-1 that referenced this pull request Aug 18, 2022
Summary:
X-link: pytorch/torcharrow#301

Coalesce needs to be a special form expression and cannot be a function because
it is not supposed to evaluate remaining inputs once there are no nulls. For
example, if column a has no nulls, the following expression should not try to
evaluate `b / 0` and should not fail.

```
coalesce(a, b / 0)
```

This change introduces CoalesceExpr special form and deletes coalesce function.

Also, fix a crash due to null pointer dereference in FlatVector::mutableRawValues.

Pull Request resolved: facebookincubator#1430

Reviewed By: laithsakka

Differential Revision: D35674128

Pulled By: mbasmanova

fbshipit-source-id: 2d16cb3404843322da67b699e7163d53757225bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants