martin-g commented on code in PR #18753:
URL: https://github.com/apache/datafusion/pull/18753#discussion_r2534283736


##########
datafusion/substrait/src/logical_plan/bounds_type.rs:
##########
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use datafusion::{
+    common::{plan_datafusion_err, Result},
+    logical_expr::WindowFrameUnits,
+};
+use substrait::proto::expression::window_function::BoundsType;
+
+/// Wrapper for the Substrait `BoundsType` to add the `GROUPS` (value 3)
+/// variant which `substrait::proto::expression::window_function::BoundsType`
+/// currently does not support. This type centralizes conversions to/from the
+/// Substrait `i32` representation and to DataFusion's `WindowFrameUnits`.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub(crate) enum BoundsTypeExt {
+    Rows,
+    Range,
+    Groups,
+    Unspecified,
+}
+
+impl BoundsTypeExt {
+    /// Convert from an i32 value (from Substrait protobuf) to BoundsTypeExt
+    pub(crate) fn from_i32(value: i32) -> Result<Self> {
+        match value {
+            v if v == BoundsType::Rows as i32 => Ok(BoundsTypeExt::Rows),
+            v if v == BoundsType::Range as i32 => Ok(BoundsTypeExt::Range),
+            3 => Ok(BoundsTypeExt::Groups), // Groups variant from Substrait 
spec

Review Comment:
   Consider extracting a constant (e.g. `SUBSTRAIT_GROUPS_VALUE`) instead of 
using a `magic number`



##########
datafusion/substrait/src/logical_plan/bounds_type.rs:
##########
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use datafusion::{
+    common::{plan_datafusion_err, Result},
+    logical_expr::WindowFrameUnits,
+};
+use substrait::proto::expression::window_function::BoundsType;
+
+/// Wrapper for the Substrait `BoundsType` to add the `GROUPS` (value 3)
+/// variant which `substrait::proto::expression::window_function::BoundsType`
+/// currently does not support. This type centralizes conversions to/from the
+/// Substrait `i32` representation and to DataFusion's `WindowFrameUnits`.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub(crate) enum BoundsTypeExt {
+    Rows,
+    Range,
+    Groups,
+    Unspecified,
+}
+
+impl BoundsTypeExt {

Review Comment:
   Please add some unit tests



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to