fix: Only convert LogicalTypeId to ConcreteDataType in tests (#241)

LogicalTypeId to ConcreteDataType is only allowed in tests, since some
additional info is not stored in LogicalTypeId now. It is just an id, or
kind, not contains full type info.
This commit is contained in:
evenyag
2022-09-09 17:48:59 +08:00
committed by GitHub
parent 0290cdb5d6
commit d52d1eb122
6 changed files with 12 additions and 4 deletions

View File

@@ -168,7 +168,7 @@ impl AggregateFunctionCreator for DiffAccumulatorCreator {
with_match_primitive_type_id!(
input_types[0].logical_type_id(),
|$S| {
Ok(ConcreteDataType::list_datatype(PrimitiveType::<<$S as Primitive>::LargestType>::default().logical_type_id().data_type()))
Ok(ConcreteDataType::list_datatype(PrimitiveType::<<$S as Primitive>::LargestType>::default().into()))
},
{
unreachable!()
@@ -182,7 +182,7 @@ impl AggregateFunctionCreator for DiffAccumulatorCreator {
with_match_primitive_type_id!(
input_types[0].logical_type_id(),
|$S| {
Ok(vec![ConcreteDataType::list_datatype(PrimitiveType::<$S>::default().logical_type_id().data_type())])
Ok(vec![ConcreteDataType::list_datatype(PrimitiveType::<$S>::default().into())])
},
{
unreachable!()

View File

@@ -237,7 +237,7 @@ impl AggregateFunctionCreator for PolyvalAccumulatorCreator {
with_match_primitive_type_id!(
input_type,
|$S| {
Ok(PrimitiveType::<<$S as Primitive>::LargestType>::default().logical_type_id().data_type())
Ok(PrimitiveType::<<$S as Primitive>::LargestType>::default().into())
},
{
unreachable!()

View File

@@ -3,6 +3,10 @@ name = "datatypes"
version = "0.1.0"
edition = "2021"
[features]
default = []
test = []
[dependencies.arrow]
package = "arrow2"
version = "0.10"

View File

@@ -36,8 +36,12 @@ pub enum LogicalTypeId {
}
impl LogicalTypeId {
/// Create ConcreteDataType based on this id. This method is for test only as it
/// would lost some info.
///
/// # Panics
/// Panics if data type is not supported.
#[cfg(any(test, feature = "test"))]
pub fn data_type(&self) -> ConcreteDataType {
match self {
LogicalTypeId::Null => ConcreteDataType::null_datatype(),

View File

@@ -37,6 +37,7 @@ uuid = { version = "1.1" , features=["v4"]}
[dev-dependencies]
atomic_float="0.1"
criterion = "0.3"
datatypes = { path = "../datatypes", features = ["test"] }
rand = "0.8"
tempdir = "0.3"

View File

@@ -32,6 +32,5 @@ tempdir = { version = "0.3", optional = true }
tokio = { version = "1.0", features = ["full"] }
[dev-dependencies]
datatypes = { path = "../datatypes" }
tempdir = { version = "0.3" }
tokio = { version = "1.18", features = ["full"] }