roeap commented on code in PR #4359: URL: https://github.com/apache/arrow-rs/pull/4359#discussion_r1218591968
########## arrow-flight/src/sql/metadata/xdbc_info.rs: ########## @@ -0,0 +1,441 @@ +// 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. + +//! Helpers for [`CommandGetXdbcTypeInfo`] metadata requests. +//! +//! - [`XdbcTypeInfo`] - a typed struct that holds the xdbc info corresponding to expected schema. +//! - [`XdbcTypeInfoListBuilder`] - a builder for collecting type infos +//! and building a conformant `RecordBatch`. +//! - [`XdbcTypeInfoList`] - a helper type wrapping a `RecordBatch` +//! used for handling [`CommandGetXdbcTypeInfo`] requests. +//! +use std::sync::Arc; + +use arrow_array::builder::{BooleanBuilder, Int32Builder, ListBuilder, StringBuilder}; +use arrow_array::cast::downcast_array; +use arrow_array::{ArrayRef, Int32Array, ListArray, RecordBatch}; +use arrow_ord::comparison::eq_scalar; +use arrow_schema::{DataType, Field, Schema, SchemaRef}; +use arrow_select::filter::filter_record_batch; +use arrow_select::take::take; +use once_cell::sync::Lazy; + +use super::lexsort_to_indices; +use crate::error::*; +use crate::sql::{ + CommandGetXdbcTypeInfo, Nullable, Searchable, XdbcDataType, XdbcDatetimeSubcode, +}; + +/// Data structure representing type information for xdbc types. +#[derive(Debug, Clone, Default)] +pub struct XdbcTypeInfo { + pub type_name: String, + pub data_type: XdbcDataType, + pub column_size: Option<i32>, + pub literal_prefix: Option<String>, + pub literal_suffix: Option<String>, + pub create_params: Option<Vec<String>>, + pub nullable: Nullable, + pub case_sensitive: bool, + pub searchable: Searchable, + pub unsigned_attribute: Option<bool>, + pub fixed_prec_scale: bool, + pub auto_increment: Option<bool>, + pub local_type_name: Option<String>, + pub minimum_scale: Option<i32>, + pub maximum_scale: Option<i32>, + pub sql_data_type: XdbcDataType, + pub datetime_subcode: Option<XdbcDatetimeSubcode>, + pub num_prec_radix: Option<i32>, + pub interval_precision: Option<i32>, +} + +impl From<CommandGetXdbcTypeInfo> for Option<i32> { Review Comment: we do not :) -- 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]
