vustef commented on code in PR #8715:
URL: https://github.com/apache/arrow-rs/pull/8715#discussion_r2501006664


##########
parquet/src/arrow/schema/virtual_type.rs:
##########
@@ -0,0 +1,163 @@
+// 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.
+
+//! RowNumber
+//!
+
+use arrow_schema::{ArrowError, DataType, Field, extension::ExtensionType};
+
+/// Prefix for virtual column extension type names.
+const VIRTUAL_PREFIX: &str = "arrow.virtual.";
+
+/// Macro to concatenate VIRTUAL_PREFIX with a suffix.
+macro_rules! virtual_name {
+    ($suffix:literal) => {
+        concat!("arrow.virtual.", $suffix)
+    };
+}
+
+/// Constants for virtual column type identifiers.
+mod virtual_column_type {
+    /// Row number virtual column.
+    pub(super) const ROW_NUMBER: u8 = 0;
+}
+
+/// Generic virtual column extension type.
+///
+/// This struct provides a common implementation for all virtual column types.
+///
+/// The storage type of the extension is `Int64`.
+#[derive(Debug, Default, Clone, Copy, PartialEq)]
+pub struct VirtualColumn<const TYPE: u8>;
+
+impl<const TYPE: u8> ExtensionType for VirtualColumn<TYPE> {
+    const NAME: &'static str = match TYPE {
+        virtual_column_type::ROW_NUMBER => virtual_name!("row_number"),

Review Comment:
   Unfortunately because NAME is const I couldn't pass in any rust type to the 
generic VirtualColumn. Would you rather not have generics, or keep it as is? Or 
something else?



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