notfilippo commented on code in PR #11160: URL: https://github.com/apache/datafusion/pull/11160#discussion_r1662576117
########## datafusion/common/src/logical_type/extension.rs: ########## @@ -0,0 +1,289 @@ +// 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. + +use std::sync::Arc; + +use arrow_schema::{DataType, FieldRef, IntervalUnit, TimeUnit}; + +use crate::logical_type::type_signature::TypeSignature; +use crate::logical_type::LogicalType; + +pub type ExtensionTypeRef = Arc<dyn ExtensionType + Send + Sync>; + +pub trait ExtensionType: std::fmt::Debug { + fn display_name(&self) -> &str; + fn type_signature(&self) -> TypeSignature; + fn physical_type(&self) -> DataType; Review Comment: I've refactored the code a bit to keep a reference to the physical type. ########## datafusion/common/src/scalar/mod.rs: ########## @@ -3270,6 +3271,118 @@ impl TryFrom<&DataType> for ScalarValue { } } + +impl TryFrom<LogicalType> for ScalarValue { + type Error = DataFusionError; + + /// Create a Null instance of ScalarValue for this datatype + fn try_from(datatype: LogicalType) -> Result<Self> { + (&datatype).try_into() + } +} + +impl TryFrom<&LogicalType> for ScalarValue { + type Error = DataFusionError; + + /// Create a Null instance of ScalarValue for this datatype + fn try_from(data_type: &LogicalType) -> Result<Self> { Review Comment: It makes sense. I'll add a node to refactor ScalarValues at some point ########## datafusion/common/src/logical_type/mod.rs: ########## @@ -0,0 +1,156 @@ +// 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. + +use std::{fmt::Display, sync::Arc}; + +use arrow_schema::{DataType, IntervalUnit, TimeUnit}; + +use crate::logical_type::extension::{ExtensionType, ExtensionTypeRef}; +use crate::logical_type::field::{LogicalField, LogicalFieldRef}; +use crate::logical_type::fields::LogicalFields; + +pub mod type_signature; +pub mod extension; +pub mod registry; +pub mod schema; +pub mod field; +pub mod fields; + +#[derive(Clone, Debug)] +pub enum LogicalType { Review Comment: I've added support for treating large types as their _non-large_ logical type. I agree that types that can store different ranges of values should be different logical types -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
