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

feat: Support Spark explode outer #11954

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

WangGuangxin
Copy link
Contributor

Support the explode/posexplode with outer semantic. Unlike explode/posexplode, if the array/map is null or empty then null is produced.

Spark doc: https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.explode_outer.html

@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 Dec 24, 2024
Copy link

netlify bot commented Dec 24, 2024

Deploy Preview for meta-velox ready!

Name Link
🔨 Latest commit cca4e68
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/67a96ca50045b1000862c037
😎 Deploy Preview https://deploy-preview-11954--meta-velox.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@WangGuangxin
Copy link
Contributor Author

@pedroerp @rui-mo @jinchengchenghh @PHILO-HE Can you please help review this?

Copy link
Collaborator

@rui-mo rui-mo left a comment

Choose a reason for hiding this comment

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

Thanks.

velox/exec/Unnest.h Outdated Show resolved Hide resolved
// is_outer = false
auto op1 = PlanBuilder().values({vector}).unnest({"c0"}, {"c1"}, std::nullopt, false /* is_outer */).planNode();
auto params1 = makeCursorParameters(op1);
auto expected1 = makeRowVector({
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we have 'op', 'params', 'expected' and reuse them in the other test cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: can we have 'op', 'params', 'expected' and reuse them in the other test cases?

just follow the style of other test cases in UnnestTest. Maybe another PR to refactor it?

velox/core/PlanNode.h Outdated Show resolved Hide resolved

createDuckDbTable({vector});

// is_outer = false
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: isOuter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

velox/exec/tests/UnnestTest.cpp Outdated Show resolved Hide resolved
@WangGuangxin WangGuangxin requested a review from rui-mo January 16, 2025 02:49
Copy link
Contributor

@jinchengchenghh jinchengchenghh 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 your contribution. Overall looks good. % minors.

I don't think we need to use isOuter as template, isOuter is not a too expensive cost, It will make the change not precise. What do you think? @rui-mo

velox/core/PlanNode.h Outdated Show resolved Hide resolved
velox/exec/Unnest.h Outdated Show resolved Hide resolved
velox/exec/Unnest.h Outdated Show resolved Hide resolved
velox/exec/Unnest.cpp Outdated Show resolved Hide resolved
velox/exec/tests/UnnestTest.cpp Outdated Show resolved Hide resolved
velox/exec/tests/UnnestTest.cpp Outdated Show resolved Hide resolved
if (rawOrdinalityIsNull_[row]) {
ordinalityVector->setNull(index, true);
}
}
std::iota(rawOrdinality, rawOrdinality + size, start + 1);
rawOrdinality += size;
Copy link
Contributor

Choose a reason for hiding this comment

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

Then we don't need to move rawOrdinality, just use rawOrdinality + index in L263.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you mean change it to std::iota(rawOrdinality + index, rawOrdinality + index + size, start + 1); right?

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.

4 participants