mingmwang commented on code in PR #6657: URL: https://github.com/apache/arrow-datafusion/pull/6657#discussion_r1241217452
########## 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 had tried to move all the row accumulator supported types and the dispatching logic to this new added macros. I know this macro `dispatch_all_supported_data_types_pairs` is not well implemented, I will try to use another macro to generate the body. -- 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]
