Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Better error handling #783

Merged
merged 6 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/search/indexing/bm25.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ It ranks documents by considering how often a term appears and how unique that t
documents. BM25 is especially useful when you need to find exact keywords or phrases within documents.

The BM25 index enables full text search over a table and relevance scoring using the BM25 algorithm.
This index is strongly consistent, which means that new data is immediately searchable across all connections.

## Creating a BM25 Index

Expand Down
5 changes: 2 additions & 3 deletions docs/search/indexing/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ title: Indexing Explained

In Postgres, indexes are database objects that provide a fast way to look up rows in a table. If you
imagine a Postgres table as a book, then an index is like the table of contents. Instead of flipping
through every page to find a chapter, the table of contents stores additional information that enables
readers to locate a chapter much faster.
through every page to find a chapter, the table of contents stores additional information that can help
readers find chapters faster.

## ParadeDB Indexes

Expand All @@ -16,4 +16,3 @@ the HNSW index for dense vector search, and the sparse HNSW index for sparse vec

Once an index is created, it will automatically stay in sync with the underlying table data, and
does not need to be re-created unless the table schema changes (for instance, if a column is renamed or deleted).
The bm25 index is strongly consistent. This means that new data is immediately searchable across all connections.
4 changes: 3 additions & 1 deletion pg_analytics/src/api/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
#[pg_guard]
#[no_mangle]
pub extern "C" fn init() {
let _ = DatafusionContext::init().expect("Failed to initialize context");
let _ = DatafusionContext::init().unwrap_or_else(|err| {
panic!("{}", err);
});

Check warning on line 16 in pg_analytics/src/api/init.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/api/init.rs#L14-L16

Added lines #L14 - L16 were not covered by tests
}
6 changes: 3 additions & 3 deletions pg_analytics/src/datafusion/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use deltalake::datafusion::common::DataFusionError;
use parking_lot::RwLock;
use pgrx::*;
use std::{any::Any, collections::HashMap, ffi::CStr, sync::Arc};
use std::{any::type_name, any::Any, collections::HashMap, ffi::CStr, ffi::OsStr, sync::Arc};

use crate::datafusion::directory::ParadeDirectory;
use crate::datafusion::schema::ParadeSchemaProvider;
Expand Down Expand Up @@ -36,9 +36,9 @@
if path.is_dir() {
let schema_oid = path
.file_name()
.ok_or_else(|| ParadeError::NotFound)?
.ok_or(ParadeError::NoneError(type_name::<OsStr>().to_string()))?

Check warning on line 39 in pg_analytics/src/datafusion/catalog.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/catalog.rs#L39

Added line #L39 was not covered by tests
.to_str()
.ok_or_else(|| ParadeError::NotFound)?
.ok_or(ParadeError::NoneError(type_name::<str>().to_string()))?

Check warning on line 41 in pg_analytics/src/datafusion/catalog.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/catalog.rs#L41

Added line #L41 was not covered by tests
.parse::<u32>()?;

let pg_oid = pg_sys::Oid::from(schema_oid);
Expand Down
19 changes: 12 additions & 7 deletions pg_analytics/src/datafusion/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use deltalake::datafusion::sql::TableReference;
use lazy_static::lazy_static;
use parking_lot::{RwLock, RwLockWriteGuard};
use std::any::type_name;
use std::sync::Arc;

use crate::datafusion::catalog::{ParadeCatalog, ParadeCatalogList, PARADE_CATALOG};
Expand Down Expand Up @@ -56,14 +57,16 @@

let schema_provider = context
.catalog(PARADE_CATALOG)
.ok_or_else(|| ParadeError::NotFound)?
.ok_or(ParadeError::CatalogNotFound(PARADE_CATALOG.to_string()))?

Check warning on line 60 in pg_analytics/src/datafusion/context.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/context.rs#L60

Added line #L60 was not covered by tests
.schema(schema_name)
.ok_or_else(|| ParadeError::NotFound)?;
.ok_or(ParadeError::SchemaNotFound(schema_name.to_string()))?;

Check warning on line 62 in pg_analytics/src/datafusion/context.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/context.rs#L62

Added line #L62 was not covered by tests

let parade_provider = schema_provider
.as_any()
.downcast_ref::<ParadeSchemaProvider>()
.ok_or_else(|| ParadeError::NotFound)?;
.ok_or(ParadeError::NoneError(
type_name::<ParadeSchemaProvider>().to_string(),
))?;

Check warning on line 69 in pg_analytics/src/datafusion/context.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/context.rs#L67-L69

Added lines #L67 - L69 were not covered by tests

f(parade_provider)
}
Expand All @@ -83,12 +86,14 @@

let catalog_provider = context
.catalog(PARADE_CATALOG)
.ok_or_else(|| ParadeError::NotFound)?;
.ok_or(ParadeError::CatalogNotFound(PARADE_CATALOG.to_string()))?;

Check warning on line 89 in pg_analytics/src/datafusion/context.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/context.rs#L89

Added line #L89 was not covered by tests

let parade_catalog = catalog_provider
.as_any()
.downcast_ref::<ParadeCatalog>()
.ok_or_else(|| ParadeError::NotFound)?;
.ok_or(ParadeError::NoneError(
type_name::<ParadeCatalog>().to_string(),
))?;

Check warning on line 96 in pg_analytics/src/datafusion/context.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/context.rs#L94-L96

Added lines #L94 - L96 were not covered by tests

f(parade_catalog)
}
Expand Down Expand Up @@ -151,8 +156,8 @@
let schema_name = reference.schema().unwrap_or("public");

DatafusionContext::with_schema_provider(schema_name, |provider| {
let table =
task::block_on(provider.table(table_name)).ok_or_else(|| ParadeError::NotFound)?;
let table = task::block_on(provider.table(table_name))
.ok_or(ParadeError::TableNotFound(table_name.to_string()))?;

Check warning on line 160 in pg_analytics/src/datafusion/context.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/context.rs#L159-L160

Added lines #L159 - L160 were not covered by tests

Ok(provider_as_source(table))
})
Expand Down
135 changes: 80 additions & 55 deletions pg_analytics/src/datafusion/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
};
use pgrx::pg_sys::{Datum, VARHDRSZ};
use pgrx::*;
use std::any::type_name;
use std::sync::Arc;

use crate::errors::ParadeError;
Expand All @@ -39,19 +40,21 @@
ExactNumberInfo::PrecisionAndScale(*precision as u64, *scale as u64),
),
DataType::Time64(TimeUnit::Microsecond) => {
return Err(ParadeError::NotSupported("time not supported".into()))
return Err(ParadeError::NotSupported("time not supported".to_string()))

Check warning on line 43 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L43

Added line #L43 was not covered by tests
}
DataType::Timestamp(TimeUnit::Microsecond, timestamp) => SQLDataType::Timestamp(
None,
match timestamp {
None => TimezoneInfo::WithoutTimeZone,
Some(_) => {
return Err(ParadeError::NotSupported("timestamp with time zone".into()))
return Err(ParadeError::NotSupported(
"timestamp with time zone".to_string(),
))

Check warning on line 52 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L50-L52

Added lines #L50 - L52 were not covered by tests
}
},
),
DataType::Date32 => SQLDataType::Date,
_ => return Err(ParadeError::NotFound),
_ => return Err(ParadeError::DataTypeNotSupported(self.to_string())),

Check warning on line 57 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L57

Added line #L57 was not covered by tests
};

Ok(result)
Expand Down Expand Up @@ -90,15 +93,17 @@

DataType::Decimal128(casted_precision, casted_scale)
}
SQLDataType::Time(_, _) => return Err(ParadeError::NotSupported("time".into())),
SQLDataType::Time(_, _) => return Err(ParadeError::NotSupported("time".to_string())),

Check warning on line 96 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L96

Added line #L96 was not covered by tests
SQLDataType::Timestamp(_, TimezoneInfo::WithoutTimeZone) => {
DataType::Timestamp(TimeUnit::Microsecond, None)
}
SQLDataType::Timestamp(_, TimezoneInfo::WithTimeZone) => {
return Err(ParadeError::NotSupported("timestamp with time zone".into()))
return Err(ParadeError::NotSupported(
"timestamp with time zone".to_string(),
))

Check warning on line 103 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L101-L103

Added lines #L101 - L103 were not covered by tests
}
SQLDataType::Date => DataType::Date32,
_ => return Err(ParadeError::NotFound),
_ => return Err(ParadeError::DataTypeNotSupported(sql_data_type.to_string())),

Check warning on line 106 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L106

Added line #L106 was not covered by tests
};

Ok(result)
Expand Down Expand Up @@ -126,26 +131,38 @@
PgBuiltInOids::OIDOID | PgBuiltInOids::XIDOID => SQLDataType::UnsignedInt4(None),
PgBuiltInOids::FLOAT4OID => SQLDataType::Float4,
PgBuiltInOids::FLOAT8OID => SQLDataType::Float8,
PgBuiltInOids::TIMEOID => return Err(ParadeError::NotSupported("time".into())),
PgBuiltInOids::TIMEOID => {
return Err(ParadeError::NotSupported("time".to_string()))

Check warning on line 135 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L135

Added line #L135 was not covered by tests
}
PgBuiltInOids::TIMESTAMPOID => {
SQLDataType::Timestamp(None, TimezoneInfo::WithoutTimeZone)
}
PgBuiltInOids::DATEOID => SQLDataType::Date,
PgBuiltInOids::TIMETZOID => {
return Err(ParadeError::NotSupported("time with time zone".into()))
return Err(ParadeError::NotSupported("time with time zone".to_string()))

Check warning on line 142 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L142

Added line #L142 was not covered by tests
}
PgBuiltInOids::TIMESTAMPTZOID => {
return Err(ParadeError::NotSupported("timestamp with time zone".into()))
return Err(ParadeError::NotSupported(
"timestamp with time zone".to_string(),
))

Check warning on line 147 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L145-L147

Added lines #L145 - L147 were not covered by tests
}
PgBuiltInOids::JSONOID => {
return Err(ParadeError::NotSupported("json".to_string()))

Check warning on line 150 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L150

Added line #L150 was not covered by tests
}
PgBuiltInOids::JSONBOID => {
return Err(ParadeError::NotSupported("jsonb".to_string()))

Check warning on line 153 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L153

Added line #L153 was not covered by tests
}
PgBuiltInOids::BOXOID => return Err(ParadeError::NotSupported("box".to_string())),

Check warning on line 155 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L155

Added line #L155 was not covered by tests
PgBuiltInOids::POINTOID => {
return Err(ParadeError::NotSupported("point".to_string()))

Check warning on line 157 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L157

Added line #L157 was not covered by tests
}
PgBuiltInOids::JSONOID => return Err(ParadeError::NotSupported("json".into())),
PgBuiltInOids::JSONBOID => return Err(ParadeError::NotSupported("jsonb".into())),
PgBuiltInOids::BOXOID => return Err(ParadeError::NotSupported("box".into())),
PgBuiltInOids::POINTOID => return Err(ParadeError::NotSupported("point".into())),
PgBuiltInOids::TIDOID => return Err(ParadeError::NotSupported("tid".into())),
PgBuiltInOids::TIDOID => return Err(ParadeError::NotSupported("tid".to_string())),

Check warning on line 159 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L159

Added line #L159 was not covered by tests
PgBuiltInOids::CSTRINGOID => {
return Err(ParadeError::NotSupported("cstring".into()))
return Err(ParadeError::NotSupported("cstring".to_string()))

Check warning on line 161 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L161

Added line #L161 was not covered by tests
}
PgBuiltInOids::INETOID => {
return Err(ParadeError::NotSupported("inet".to_string()))

Check warning on line 164 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L164

Added line #L164 was not covered by tests
}
PgBuiltInOids::INETOID => return Err(ParadeError::NotSupported("inet".into())),
PgBuiltInOids::NUMERICOID => {
let scale: i32 = (((typmod - VARHDRSZ as i32) & 0x7ff) ^ 1024) - 1024;
let precision: i32 = ((typmod - VARHDRSZ as i32) >> 16) & 0xffff;
Expand All @@ -168,31 +185,36 @@
scale as u64,
))
}
PgBuiltInOids::VOIDOID => return Err(ParadeError::NotSupported("void".into())),
PgBuiltInOids::VOIDOID => {
return Err(ParadeError::NotSupported("void".to_string()))

Check warning on line 189 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L189

Added line #L189 was not covered by tests
}
PgBuiltInOids::INT4RANGEOID => {
return Err(ParadeError::NotSupported("int4 range".into()))
return Err(ParadeError::NotSupported("int4 range".to_string()))

Check warning on line 192 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L192

Added line #L192 was not covered by tests
}
PgBuiltInOids::INT8RANGEOID => {
return Err(ParadeError::NotSupported("int8 range".into()))
return Err(ParadeError::NotSupported("int8 range".to_string()))

Check warning on line 195 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L195

Added line #L195 was not covered by tests
}
PgBuiltInOids::NUMRANGEOID => {
return Err(ParadeError::NotSupported("numeric range".into()))
return Err(ParadeError::NotSupported("numeric range".to_string()))

Check warning on line 198 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L198

Added line #L198 was not covered by tests
}
PgBuiltInOids::DATERANGEOID => {
return Err(ParadeError::NotSupported("date range".into()))
return Err(ParadeError::NotSupported("date range".to_string()))

Check warning on line 201 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L201

Added line #L201 was not covered by tests
}
PgBuiltInOids::TSRANGEOID => {
return Err(ParadeError::NotSupported("timestamp range".into()))
return Err(ParadeError::NotSupported("timestamp range".to_string()))

Check warning on line 204 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L204

Added line #L204 was not covered by tests
}
PgBuiltInOids::TSTZRANGEOID => {
return Err(ParadeError::NotSupported(
"timestamp with time zone range".into(),
"timestamp with time zone range".to_string(),

Check warning on line 208 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L208

Added line #L208 was not covered by tests
))
}
PgBuiltInOids::UUIDOID => SQLDataType::Uuid,
_ => return Err(ParadeError::NotFound),
_ => return Err(ParadeError::DataTypeNotSupported("unknown".to_string())),

Check warning on line 212 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L212

Added line #L212 was not covered by tests
},
_ => return Err(ParadeError::NotFound),
PgOid::Invalid => return Err(ParadeError::DataTypeNotSupported("invalid".to_string())),

Check warning on line 214 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L214

Added line #L214 was not covered by tests
PgOid::Custom(_) => {
return Err(ParadeError::DataTypeNotSupported("custom".to_string()))

Check warning on line 216 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L216

Added line #L216 was not covered by tests
}
};

Ok(result)
Expand All @@ -212,13 +234,15 @@
SQLDataType::Numeric(ExactNumberInfo::PrecisionAndScale(_precision, _scale)) => {
PgBuiltInOids::NUMERICOID
}
SQLDataType::Time(_, _) => return Err(ParadeError::NotSupported("time".into())),
SQLDataType::Time(_, _) => return Err(ParadeError::NotSupported("time".to_string())),

Check warning on line 237 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L237

Added line #L237 was not covered by tests
SQLDataType::Timestamp(_, TimezoneInfo::WithoutTimeZone) => PgBuiltInOids::TIMESTAMPOID,
SQLDataType::Date => PgBuiltInOids::DATEOID,
SQLDataType::Timestamp(_, TimezoneInfo::WithTimeZone) => {
return Err(ParadeError::NotSupported("timestamp with time zone".into()))
return Err(ParadeError::NotSupported(
"timestamp with time zone".to_string(),
))

Check warning on line 243 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L241-L243

Added lines #L241 - L243 were not covered by tests
}
_ => return Err(ParadeError::NotFound),
_ => return Err(ParadeError::DataTypeNotSupported(sql_data_type.to_string())),

Check warning on line 245 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L245

Added line #L245 was not covered by tests
};

let typmod: i32 = match sql_data_type {
Expand Down Expand Up @@ -248,7 +272,7 @@
pg_sys::numeric,
&[anynumeric.into_datum(), original_typmod.into_datum()],
)
.ok_or_else(|| ParadeError::Generic("numeric direct function call failed".into()))?
.ok_or_else(|| ParadeError::Generic("numeric direct function call failed".to_string()))?

Check warning on line 275 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L275

Added line #L275 was not covered by tests
};

// Scale the anynumeric up or down
Expand All @@ -271,7 +295,7 @@
pg_sys::numeric,
&[scaled_anynumeric.into_datum(), target_typmod.into_datum()],
)
.ok_or_else(|| ParadeError::Generic("numeric direct function call failed".into()))
.ok_or_else(|| ParadeError::Generic("numeric direct function call failed".to_string()))

Check warning on line 298 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L298

Added line #L298 was not covered by tests
}
}

Expand Down Expand Up @@ -410,24 +434,13 @@
if is_null {
vec.push(None);
} else {
vec.push(unsafe {
match AnyNumeric::from_datum(*datum, false) {
Some(numeric) => {
let ret = scale_anynumeric(
numeric,
precision as i32,
scale as i32,
true,
)?;
let val = i128::try_from(ret);
match val {
Ok(val) => Some(val),
Err(e) => return Err(ParadeError::Generic(e.to_string())),
}
}
None => return Err(ParadeError::NotFound),
}
});
let numeric = unsafe {
AnyNumeric::from_datum(*datum, false)
.ok_or(ParadeError::DatumNotFound("numeric".to_string()))?

Check warning on line 439 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L437-L439

Added lines #L437 - L439 were not covered by tests
};
let numeric_with_scale =
scale_anynumeric(numeric, precision as i32, scale as i32, true)?;
vec.push(Some(i128::try_from(numeric_with_scale)?));

Check warning on line 443 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L441-L443

Added lines #L441 - L443 were not covered by tests
}
}
Ok(Arc::new(
Expand Down Expand Up @@ -480,7 +493,9 @@
}
Ok(Arc::new(Date32Array::from(vec)))
}
_ => Err(ParadeError::NotFound),
_ => Err(ParadeError::DataTypeNotSupported(
datafusion_type.to_string(),
)),

Check warning on line 498 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L496-L498

Added lines #L496 - L498 were not covered by tests
}
}

Expand All @@ -495,13 +510,17 @@
DataType::Boolean => array
.as_any()
.downcast_ref::<BooleanArray>()
.ok_or_else(|| ParadeError::NotFound)?
.ok_or(ParadeError::NoneError(
type_name::<BooleanArray>().to_string(),
))?

Check warning on line 515 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L513-L515

Added lines #L513 - L515 were not covered by tests
.value(index)
.into_datum(),
DataType::Utf8 => array
.as_any()
.downcast_ref::<StringArray>()
.ok_or_else(|| ParadeError::NotFound)?
.ok_or(ParadeError::NoneError(
type_name::<StringArray>().to_string(),
))?

Check warning on line 523 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L521-L523

Added lines #L521 - L523 were not covered by tests
.value(index)
.into_datum(),
DataType::Int16 => array.as_primitive::<Int16Type>().value(index).into_datum(),
Expand All @@ -523,18 +542,24 @@
ret.into_datum()
}
DataType::Time64(TimeUnit::Microsecond) => {
return Err(ParadeError::NotSupported("time".into()));
return Err(ParadeError::NotSupported("time".to_string()));

Check warning on line 545 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L545

Added line #L545 was not covered by tests
}
DataType::Timestamp(TimeUnit::Microsecond, None) => array
.as_primitive::<TimestampMicrosecondType>()
.value(index)
.into_datum(),
DataType::Timestamp(TimeUnit::Microsecond, Some(_)) => {
return Err(ParadeError::NotSupported("timestamp with time zone".into()));
return Err(ParadeError::NotSupported(
"timestamp with time zone".to_string(),
));

Check warning on line 554 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L552-L554

Added lines #L552 - L554 were not covered by tests
}
DataType::Date32 => array.as_primitive::<Date32Type>().value(index).into_datum(),
_ => return Err(ParadeError::NotFound),
_ => {
return Err(ParadeError::DataTypeNotSupported(
datafusion_type.to_string(),
))

Check warning on line 560 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L558-L560

Added lines #L558 - L560 were not covered by tests
}
}
.ok_or_else(|| ParadeError::NotFound)
.ok_or(ParadeError::DatumNotFound(datafusion_type.to_string()))

Check warning on line 563 in pg_analytics/src/datafusion/datatype.rs

View check run for this annotation

Codecov / codecov/patch

pg_analytics/src/datafusion/datatype.rs#L563

Added line #L563 was not covered by tests
}
}