Skip to content

Commit

Permalink
fix: Fix various complaints from the latest nightly clippy (#11958)
Browse files Browse the repository at this point in the history
* fix: Fix various complaints from the latest nightly clippy

* fix: run fmt for ci :/

* fix: Update cli lockfile since that's what ci wants
  • Loading branch information
itsjunetime committed Aug 13, 2024
1 parent 5d3cda5 commit 1d86724
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 135 deletions.
68 changes: 35 additions & 33 deletions datafusion-cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions datafusion/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ libc = "0.2.140"
num_cpus = { workspace = true }
object_store = { workspace = true, optional = true }
parquet = { workspace = true, optional = true, default-features = true }
paste = "1.0.15"
pyo3 = { version = "0.21.0", optional = true }
sqlparser = { workspace = true }

Expand Down
67 changes: 27 additions & 40 deletions datafusion/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,6 @@ macro_rules! unwrap_or_internal_err {
};
}

macro_rules! with_dollar_sign {
($($body:tt)*) => {
macro_rules! __with_dollar_sign { $($body)* }
__with_dollar_sign!($);
}
}

/// Add a macros for concise DataFusionError::* errors declaration
/// supports placeholders the same way as `format!`
/// Examples:
Expand All @@ -501,37 +494,37 @@ macro_rules! with_dollar_sign {
/// `NAME_DF_ERR` - macro name for wrapping DataFusionError::*. Needed to keep backtrace opportunity
/// in construction where DataFusionError::* used directly, like `map_err`, `ok_or_else`, etc
macro_rules! make_error {
($NAME_ERR:ident, $NAME_DF_ERR: ident, $ERR:ident) => {
with_dollar_sign! {
($d:tt) => {
/// Macro wraps `$ERR` to add backtrace feature
#[macro_export]
macro_rules! $NAME_DF_ERR {
($d($d args:expr),*) => {
$crate::DataFusionError::$ERR(
format!(
"{}{}",
format!($d($d args),*),
$crate::DataFusionError::get_back_trace(),
).into()
)
}
($NAME_ERR:ident, $NAME_DF_ERR: ident, $ERR:ident) => { make_error!(@inner ($), $NAME_ERR, $NAME_DF_ERR, $ERR); };
(@inner ($d:tt), $NAME_ERR:ident, $NAME_DF_ERR:ident, $ERR:ident) => {
::paste::paste!{
/// Macro wraps `$ERR` to add backtrace feature
#[macro_export]
macro_rules! $NAME_DF_ERR {
($d($d args:expr),*) => {
$crate::DataFusionError::$ERR(
::std::format!(
"{}{}",
::std::format!($d($d args),*),
$crate::DataFusionError::get_back_trace(),
).into()
)
}
}

/// Macro wraps Err(`$ERR`) to add backtrace feature
#[macro_export]
macro_rules! $NAME_ERR {
($d($d args:expr),*) => {
Err($crate::DataFusionError::$ERR(
format!(
"{}{}",
format!($d($d args),*),
$crate::DataFusionError::get_back_trace(),
).into()
))
}
/// Macro wraps Err(`$ERR`) to add backtrace feature
#[macro_export]
macro_rules! $NAME_ERR {
($d($d args:expr),*) => {
Err($crate::[<_ $NAME_DF_ERR>]!($d($d args),*))
}
}

#[doc(hidden)]
#[allow(unused)]
pub use $NAME_ERR as [<_ $NAME_ERR>];
#[doc(hidden)]
#[allow(unused)]
pub use $NAME_DF_ERR as [<_ $NAME_DF_ERR>];
}
};
}
Expand Down Expand Up @@ -613,12 +606,6 @@ macro_rules! schema_err {

// To avoid compiler error when using macro in the same crate:
// macros from the current crate cannot be referred to by absolute paths
pub use config_err as _config_err;
pub use internal_datafusion_err as _internal_datafusion_err;
pub use internal_err as _internal_err;
pub use not_impl_err as _not_impl_err;
pub use plan_datafusion_err as _plan_datafusion_err;
pub use plan_err as _plan_err;
pub use schema_err as _schema_err;

/// Create a "field not found" DataFusion::SchemaError
Expand Down
12 changes: 12 additions & 0 deletions datafusion/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ pub use table_reference::{ResolvedTableReference, TableReference};
pub use unnest::UnnestOptions;
pub use utils::project_schema;

// These are hidden from docs purely to avoid polluting the public view of what this crate exports.
// These are just re-exports of macros by the same name, which gets around the 'cannot refer to
// macro-expanded macro_export macros by their full path' error.
// The design to get around this comes from this comment:
// https://github.com/rust-lang/rust/pull/52234#issuecomment-976702997
#[doc(hidden)]
pub use error::{
_config_datafusion_err, _exec_datafusion_err, _internal_datafusion_err,
_not_impl_datafusion_err, _plan_datafusion_err, _resources_datafusion_err,
_substrait_datafusion_err,
};

/// Downcast an Arrow Array to a concrete type, return an `DataFusionError::Internal` if the cast is
/// not possible. In normal usage of DataFusion the downcast should always succeed.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,9 @@ pub fn build_row_filter(
let mut candidates: Vec<FilterCandidate> = predicates
.into_iter()
.flat_map(|expr| {
if let Ok(candidate) =
FilterCandidateBuilder::new(expr.clone(), file_schema, table_schema)
.build(metadata)
{
candidate
} else {
None
}
FilterCandidateBuilder::new(expr.clone(), file_schema, table_schema)
.build(metadata)
.unwrap_or_default()
})
.collect();

Expand Down
Loading

0 comments on commit 1d86724

Please sign in to comment.