wjones127 commented on code in PR #478:
URL: https://github.com/apache/arrow-adbc/pull/478#discussion_r1141482237


##########
rust/src/info.rs:
##########
@@ -0,0 +1,287 @@
+// 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.
+
+//! Utilities for driver info
+//!
+//! For use with [crate::AdbcConnection::get_info].
+
+use arrow_array::builder::{
+    ArrayBuilder, BooleanBuilder, Int32Builder, Int64Builder, ListBuilder, 
MapBuilder,
+    StringBuilder, UInt32BufferBuilder, UInt32Builder, UInt8BufferBuilder,
+};
+use arrow_array::cast::{as_primitive_array, as_string_array, as_union_array};
+use arrow_array::types::UInt32Type;
+use arrow_array::{Array, ArrayRef, UnionArray};
+use arrow_array::{RecordBatch, RecordBatchIterator, RecordBatchReader};
+use arrow_schema::{ArrowError, DataType, Field, Schema, UnionMode};
+use std::{borrow::Cow, collections::HashMap, sync::Arc};
+
+/// Contains known info codes defined by ADBC.
+pub mod codes {
+    /// The database vendor/product version (type: utf8).
+    pub const VENDOR_NAME: u32 = 0;
+    /// The database vendor/product version (type: utf8).
+    pub const VENDOR_VERSION: u32 = 1;
+    /// The database vendor/product Arrow library version (type: utf8).
+    pub const VENDOR_ARROW_VERSION: u32 = 2;
+    /// The driver name (type: utf8).
+    pub const DRIVER_NAME: u32 = 100;
+    /// The driver version (type: utf8).
+    pub const DRIVER_VERSION: u32 = 101;
+    /// The driver Arrow library version (type: utf8).
+    pub const DRIVER_ARROW_VERSION: u32 = 102;
+}
+
+pub fn info_schema() -> Schema {
+    Schema::new(vec![
+        Field::new("info_name", DataType::UInt32, false),
+        Field::new(
+            "info_value",
+            DataType::Union(
+                vec![
+                    Field::new("string_value", DataType::Utf8, true),
+                    Field::new("bool_value", DataType::Boolean, true),
+                    Field::new("int64_value", DataType::Int64, true),
+                    Field::new("int32_bitmask", DataType::Int32, true),
+                    Field::new(
+                        "string_list",
+                        DataType::List(Box::new(Field::new("item", 
DataType::Utf8, true))),
+                        true,
+                    ),
+                    Field::new(
+                        "int32_to_int32_list_map",
+                        DataType::Map(
+                            Box::new(Field::new(
+                                "entries",
+                                DataType::Struct(vec![
+                                    Field::new("keys", DataType::Int32, false),
+                                    Field::new(
+                                        "values",
+                                        DataType::List(Box::new(Field::new(
+                                            "item",
+                                            DataType::Int32,
+                                            true,
+                                        ))),
+                                        true,
+                                    ),
+                                ]),
+                                false,
+                            )),
+                            false,
+                        ),
+                        true,
+                    ),
+                ],
+                vec![0, 1, 2, 3, 4, 5],
+                UnionMode::Dense,
+            ),
+            true,
+        ),
+    ])
+}

Review Comment:
   Done.



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