mingmwang commented on code in PR #6657:
URL: https://github.com/apache/arrow-datafusion/pull/6657#discussion_r1241817848


##########
datafusion/physical-expr/src/aggregate/row_agg_macros.rs:
##########
@@ -0,0 +1,525 @@
+// 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.
+
+#[macro_export]
+macro_rules! matches_all_supported_data_types {
+    ($expression:expr) => {
+        matches!(
+            $expression,
+            DataType::Boolean
+                | DataType::UInt8
+                | DataType::UInt16
+                | DataType::UInt32
+                | DataType::UInt64
+                | DataType::Int8
+                | DataType::Int16
+                | DataType::Int32
+                | DataType::Int64
+                | DataType::Float32
+                | DataType::Float64
+                | DataType::Decimal128(_, _)
+        )
+    };
+}
+pub use matches_all_supported_data_types;
+
+#[macro_export]
+macro_rules! dispatch_all_supported_data_types {
+    ($macro:ident $(, $x:ident)*) => {
+        $macro! {
+                [$($x),*],
+                { Boolean, BooleanArray },
+                { Int8, Int8Array },
+                { Int16, Int16Array },
+                { Int32, Int32Array },
+                { Int64, Int64Array },
+                { UInt8, UInt8Array },
+                { UInt16, UInt16Array },
+                { UInt32, UInt32Array },
+                { UInt64, UInt64Array },
+                { Float32, Float32Array },
+                { Float64, Float64Array },
+                { Decimal128, Decimal128Array }
+        }
+    };
+}
+
+pub use dispatch_all_supported_data_types;
+
+// TODO generate the matching type pairs
+#[macro_export]

Review Comment:
   > I really worry about this table -- it seems like it will be very hard to 
maintain (aka trying to add some new type or accumulator type will be very hard)
   
   Done, I use nested macros to generate the body now. 
   



-- 
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]

Reply via email to