Skip to content

Commit

Permalink
Add Support for modulus operation in substrait (#13108)
Browse files Browse the repository at this point in the history
* Add modulus operation

* change the producer to output `modulus` instead of `mod` for `modulo` operation

* Add a roundtrip test case for modulus
  • Loading branch information
LatrecheYasser authored Oct 29, 2024
1 parent 67b0f25 commit d00a089
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions datafusion/substrait/src/logical_plan/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ pub fn name_to_op(name: &str) -> Option<Operator> {
"multiply" => Some(Operator::Multiply),
"divide" => Some(Operator::Divide),
"mod" => Some(Operator::Modulo),
"modulus" => Some(Operator::Modulo),
"and" => Some(Operator::And),
"or" => Some(Operator::Or),
"is_distinct_from" => Some(Operator::IsDistinctFrom),
Expand Down
2 changes: 1 addition & 1 deletion datafusion/substrait/src/logical_plan/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ pub fn operator_to_name(op: Operator) -> &'static str {
Operator::Minus => "subtract",
Operator::Multiply => "multiply",
Operator::Divide => "divide",
Operator::Modulo => "mod",
Operator::Modulo => "modulus",
Operator::And => "and",
Operator::Or => "or",
Operator::IsDistinctFrom => "is_distinct_from",
Expand Down
5 changes: 5 additions & 0 deletions datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,11 @@ async fn roundtrip_ilike() -> Result<()> {
roundtrip("SELECT f FROM data WHERE f ILIKE 'a%b'").await
}

#[tokio::test]
async fn roundtrip_modulus() -> Result<()> {
roundtrip("SELECT a%3 from data").await
}

#[tokio::test]
async fn roundtrip_not() -> Result<()> {
roundtrip("SELECT * FROM data WHERE NOT d").await
Expand Down

0 comments on commit d00a089

Please sign in to comment.