Skip to content

Commit

Permalink
Add Expr::Case when_then_else support to rex_call_operands function (#…
Browse files Browse the repository at this point in the history
…388)

* Add Expr::Case when_then_else support to rex_call_operands function

* Update gitignore and formatting

* Update gitignore and formatting
  • Loading branch information
jdye64 authored May 26, 2023
1 parent 82b4a95 commit d912db5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
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 @@ -384,14 +384,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

0 comments on commit d912db5

Please sign in to comment.