Skip to content

Commit 204dacc

Browse files
authored
forbid todo!/unimplemented! in vortex-duckdb (#8762)
We should never crash the host if we don't have support for something Signed-off-by: Mikhail Kot <[email protected]>
1 parent b084b3d commit 204dacc

5 files changed

Lines changed: 28 additions & 22 deletions

File tree

‎vortex-duckdb/src/convert/dtype.rs‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,19 @@ impl FromLogicalType for DType {
179179
)
180180
}
181181
DUCKDB_TYPE::DUCKDB_TYPE_VARIANT => DType::Variant(nullability),
182-
DUCKDB_TYPE::DUCKDB_TYPE_TIME_TZ => todo!(),
183-
DUCKDB_TYPE::DUCKDB_TYPE_INTERVAL => todo!(),
184-
DUCKDB_TYPE::DUCKDB_TYPE_ENUM => todo!(),
185-
DUCKDB_TYPE::DUCKDB_TYPE_MAP => todo!(),
186-
DUCKDB_TYPE::DUCKDB_TYPE_UUID => todo!(),
187-
DUCKDB_TYPE::DUCKDB_TYPE_UNION => todo!(),
188-
DUCKDB_TYPE::DUCKDB_TYPE_BIT => todo!(),
189-
DUCKDB_TYPE::DUCKDB_TYPE_ANY => todo!(),
190-
DUCKDB_TYPE::DUCKDB_TYPE_BIGNUM => todo!(),
191-
DUCKDB_TYPE::DUCKDB_TYPE_STRING_LITERAL => todo!(),
192-
DUCKDB_TYPE::DUCKDB_TYPE_INTEGER_LITERAL => todo!(),
182+
other @ (DUCKDB_TYPE::DUCKDB_TYPE_TIME_TZ
183+
| DUCKDB_TYPE::DUCKDB_TYPE_INTERVAL
184+
| DUCKDB_TYPE::DUCKDB_TYPE_ENUM
185+
| DUCKDB_TYPE::DUCKDB_TYPE_MAP
186+
| DUCKDB_TYPE::DUCKDB_TYPE_UUID
187+
| DUCKDB_TYPE::DUCKDB_TYPE_UNION
188+
| DUCKDB_TYPE::DUCKDB_TYPE_BIT
189+
| DUCKDB_TYPE::DUCKDB_TYPE_ANY
190+
| DUCKDB_TYPE::DUCKDB_TYPE_BIGNUM
191+
| DUCKDB_TYPE::DUCKDB_TYPE_STRING_LITERAL
192+
| DUCKDB_TYPE::DUCKDB_TYPE_INTEGER_LITERAL) => {
193+
vortex_bail!("{other:?} -> DType conversion is not supported")
194+
}
193195
})
194196
}
195197
}
@@ -241,10 +243,9 @@ impl TryFrom<&DType> for LogicalType {
241243
DType::Struct(struct_type, _) => {
242244
return LogicalType::try_from(struct_type);
243245
}
244-
DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"),
245-
DType::Variant(_) => {
246-
vortex_bail!("Vortex Variant array aren't supported in DuckDB")
247-
}
246+
// TODO(connor): Union
247+
DType::Union(..) => vortex_bail!("Vortex Union isn't supported"),
248+
DType::Variant(_) => vortex_bail!("Vortex Variant array aren't supported"),
248249
DType::Extension(ext_dtype) => {
249250
// Handle first-party extension types that have DuckDB equivalents.
250251
if let Some(temporal) = ext_dtype.metadata_opt::<AnyTemporal>() {

‎vortex-duckdb/src/convert/expr.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,14 +732,14 @@ impl TryFrom<DUCKDB_VX_EXPR_TYPE> for Operator {
732732

733733
fn try_from(value: DUCKDB_VX_EXPR_TYPE) -> VortexResult<Self> {
734734
Ok(match value {
735-
DUCKDB_VX_EXPR_TYPE::DUCKDB_VX_EXPR_TYPE_INVALID => vortex_bail!("invalid expr"),
735+
DUCKDB_VX_EXPR_TYPE::DUCKDB_VX_EXPR_TYPE_INVALID => vortex_bail!("invalid expression"),
736736
DUCKDB_VX_EXPR_TYPE::DUCKDB_VX_EXPR_TYPE_COMPARE_EQUAL => Operator::Eq,
737737
DUCKDB_VX_EXPR_TYPE::DUCKDB_VX_EXPR_TYPE_COMPARE_NOTEQUAL => Operator::NotEq,
738738
DUCKDB_VX_EXPR_TYPE::DUCKDB_VX_EXPR_TYPE_COMPARE_LESSTHAN => Operator::Lt,
739739
DUCKDB_VX_EXPR_TYPE::DUCKDB_VX_EXPR_TYPE_COMPARE_GREATERTHAN => Operator::Gt,
740740
DUCKDB_VX_EXPR_TYPE::DUCKDB_VX_EXPR_TYPE_COMPARE_LESSTHANOREQUALTO => Operator::Lte,
741741
DUCKDB_VX_EXPR_TYPE::DUCKDB_VX_EXPR_TYPE_COMPARE_GREATERTHANOREQUALTO => Operator::Gte,
742-
_ => todo!("cannot convert {:?}", value),
742+
_ => vortex_bail!("cannot convert {:?}", value),
743743
})
744744
}
745745
}

‎vortex-duckdb/src/convert/scalar.rs‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,14 @@ impl ToDuckDBScalar for Scalar {
7878
DType::Decimal(..) => self.as_decimal().try_to_duckdb_scalar(),
7979
DType::Utf8(_) => self.as_utf8().try_to_duckdb_scalar(),
8080
DType::Binary(_) => self.as_binary().try_to_duckdb_scalar(),
81-
DType::List(..) | DType::FixedSizeList(..) | DType::Struct(..) => todo!(),
82-
DType::Union(..) => todo!("TODO(connor)[Union]: unimplemented"),
83-
DType::Variant(_) => {
84-
vortex_bail!("Vortex Variant scalars aren't supported in DuckDB")
81+
DType::List(..) => vortex_bail!("Vortex List scalars aren't supported"),
82+
DType::FixedSizeList(..) => {
83+
vortex_bail!("Vortex FixedSizeList scalars aren't supported")
8584
}
85+
DType::Variant(_) => vortex_bail!("Vortex Variant scalars aren't supported"),
86+
DType::Struct(..) => vortex_bail!("Vortex Struct scalars aren't supported"),
87+
// TODO(connor): Union
88+
DType::Union(..) => vortex_bail!("Vortex Union scalars aren't supported"),
8689
DType::Extension(..) => self.as_extension().try_to_duckdb_scalar(),
8790
}
8891
}

‎vortex-duckdb/src/convert/vector.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ pub fn flat_vector_to_vortex(vector: &VectorRef, len: usize) -> VortexResult<Arr
361361
StructArray::try_new(names, children, len, vector.validity_ref(len).to_validity())
362362
.map(|a| a.into_array())
363363
}
364-
type_id => unimplemented!("missing impl for {type_id:?}"),
364+
type_id => vortex_bail!("{type_id:?} flat Vector to Vortex array not supported"),
365365
}
366366
}
367367

‎vortex-duckdb/src/lib.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
#![expect(clippy::missing_safety_doc)]
5+
#![forbid(clippy::todo)]
6+
#![forbid(clippy::unimplemented)]
57

68
use std::ffi::c_char;
79
use std::ffi::c_void;

0 commit comments

Comments
 (0)