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

Add Expr::Case when_then_else support to rex_call_operands function #388

Merged
merged 3 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ __pycache__/
*.py[cod]
*$py.class

# Python dist ignore
dist

# C extensions
*.so

Expand All @@ -24,4 +27,4 @@ apache-rat-*.jar
.env
CHANGELOG.md.bak

docs/mdbook/book
docs/mdbook/book
19 changes: 13 additions & 6 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,21 @@ impl PyExpr {
let mut operands: Vec<PyExpr> = Vec::new();

if let Some(e) = expr {
operands.push(PyExpr::from(*e.clone()));
for (when, then) in when_then_expr {
operands.push(PyExpr::from(Expr::BinaryExpr(BinaryExpr::new(
Box::new(*e.clone()),
Operator::Eq,
Box::new(*when.clone()),
))));
operands.push(PyExpr::from(*then.clone()));
}
} else {
for (when, then) in when_then_expr {
operands.push(PyExpr::from(*when.clone()));
operands.push(PyExpr::from(*then.clone()));
}
};

for (when, then) in when_then_expr {
operands.push(PyExpr::from(*when.clone()));
operands.push(PyExpr::from(*then.clone()));
}

if let Some(e) = else_expr {
operands.push(PyExpr::from(*e.clone()));
};
Expand Down