This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new d00a089971 Add Support for `modulus` operation in substrait (#13108)
d00a089971 is described below
commit d00a089971b341d8f10cb5ecb446c27a4d824ac4
Author: Yasser Latreche <[email protected]>
AuthorDate: Tue Oct 29 07:24:12 2024 -0400
Add Support for `modulus` operation in substrait (#13108)
* Add modulus operation
* change the producer to output `modulus` instead of `mod` for `modulo`
operation
* Add a roundtrip test case for modulus
---
datafusion/substrait/src/logical_plan/consumer.rs | 1 +
datafusion/substrait/src/logical_plan/producer.rs | 2 +-
datafusion/substrait/tests/cases/roundtrip_logical_plan.rs | 5 +++++
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/datafusion/substrait/src/logical_plan/consumer.rs
b/datafusion/substrait/src/logical_plan/consumer.rs
index 3d5d7cce56..54b93cb7e3 100644
--- a/datafusion/substrait/src/logical_plan/consumer.rs
+++ b/datafusion/substrait/src/logical_plan/consumer.rs
@@ -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),
diff --git a/datafusion/substrait/src/logical_plan/producer.rs
b/datafusion/substrait/src/logical_plan/producer.rs
index 4855af683b..da8a4c994f 100644
--- a/datafusion/substrait/src/logical_plan/producer.rs
+++ b/datafusion/substrait/src/logical_plan/producer.rs
@@ -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",
diff --git a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
index 06a047b108..9739afa992 100644
--- a/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
+++ b/datafusion/substrait/tests/cases/roundtrip_logical_plan.rs
@@ -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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]