-
Notifications
You must be signed in to change notification settings - Fork 549
fix: remove clippy warnings #3940
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Corwin Joy <[email protected]>
…ed_imports Signed-off-by: Corwin Joy <[email protected]>
…ippy::needless_borrow) Signed-off-by: Corwin Joy <[email protected]>
…mark default variants (clippy::derivable_impls) Signed-off-by: Corwin Joy <[email protected]>
Signed-off-by: Corwin Joy <[email protected]>
… on IntoIterator (clippy::unnecessary_to_owned, clippy::cloned_ref_to_slice_refs) Signed-off-by: Corwin Joy <[email protected]>
…oid field reassignment (clippy::field_reassign_with_default) Signed-off-by: Corwin Joy <[email protected]>
…borrow) Signed-off-by: Corwin Joy <[email protected]>
…ess_return) Signed-off-by: Corwin Joy <[email protected]>
…(declare_interior_mutable_const) Signed-off-by: Corwin Joy <[email protected]>
… multiple_bound_locations (clippy) Signed-off-by: Corwin Joy <[email protected]>
…orrow) Signed-off-by: Corwin Joy <[email protected]>
Signed-off-by: Corwin Joy <[email protected]>
Remove module_inception warning for schema. Signed-off-by: Corwin Joy <[email protected]>
Signed-off-by: Corwin Joy <[email protected]>
|
ACTION NEEDED delta-rs follows the Conventional Commits specification for release automation. The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
|
|
||
| pub mod cast; | ||
| pub mod partitions; | ||
| #[allow(clippy::module_inception)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy does not like the repeated name per https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#module_inception
But, changing this could break API usage so I just disabled the warning.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3940 +/- ##
==========================================
- Coverage 26.24% 26.23% -0.02%
==========================================
Files 124 124
Lines 19824 19819 -5
Branches 19824 19819 -5
==========================================
- Hits 5203 5199 -4
+ Misses 14251 14250 -1
Partials 370 370 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I'm not generally a fan of this. I think we should fix the deprecations rather than just silence the warnings. That's the entire reason they exist in the first place. Additionally, why are there changes in this PR entirely unrelated to the clippy warnings? |
|
@hntd187 Here is my reasoning on the deprecation flag.
I think these came about with the new kernel, but I'm not sure this update has been finished yet, so a new method may not exist.
In terms of your other question, as far as I can tell every one of these changes should be associated with a clippy warning message. I am running a double check to confirm. But, maybe I missed something? If so, could you please point out the incorrect change? |
| async fn run_merge_case(case: &MergeTestCase, parquet_dir: &Path) -> anyhow::Result<()> { | ||
| let tmp_dir = tempfile::tempdir()?; | ||
| let (source, table) = prepare_source_and_table(&case.params, &tmp_dir, &parquet_dir).await?; | ||
| let (source, table) = prepare_source_and_table(&case.params, &tmp_dir, parquet_dir).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/benchmarks File: crates/benchmarks/src/main.rs (run_merge_case) Clippy warning fixed: "this expression creates a reference which is immediately dereferenced by the compiler --> crates/benchmarks/src/main.rs:200:76 help: change this to: parquet_dir" Change: removed the needless borrow and passed parquet_dir directly to prepare_source_and_table.
| use crate::operations::write::metrics::WriteMetricExtensionPlanner; | ||
|
|
||
| const DELTA_EXTENSION_PLANNERS: LazyLock<Vec<Arc<dyn ExtensionPlanner + Send + Sync>>> = | ||
| static DELTA_EXTENSION_PLANNERS: LazyLock<Vec<Arc<dyn ExtensionPlanner + Send + Sync>>> = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/delta_datafusion/planner.rs Clippy warnings fixed: "named constant with interior mutability --> crates/core/src/delta_datafusion/planner.rs:42:7 = help: did you mean to make this a static item" and "named constant with interior mutability --> crates/core/src/delta_datafusion/planner.rs:52:7" Change: converted the LazyLock const items to static (e.g., static DELTA_EXTENSION_PLANNERS and static DELTA_PLANNER) so interior mutability is handled correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this modified such that interior mutability is relevant here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the full warning message. I tried just assigning to a local variable but the fix is a bit trickier than that I guess.
warning: borrow of a named constant with interior mutability
--> crates/core/src/delta_datafusion/planner.rs:98:28
|
98 | for ext_planner in DELTA_EXTENSION_PLANNERS.iter() {
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: there is a compiler inserted call to `Deref::deref` here
= help: this lint can be silenced by assigning the value to a local variable before borrowing
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#borrow_interior_mutable_const
= note: `#[warn(clippy::borrow_interior_mutable_const)]` on by default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hntd187 I could use some help on a better way to fix this error since simple assignment to a temporary doesn't quite do it. Here are the docs on this
https://rust-lang.github.io/rust-clippy/rust-1.91.0/index.html#borrow_interior_mutable_const
So, potentially, we could mark this to be ignored but that doesn't seem too great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My point was I don't believe this lint is correct. We don't modify this value here, or anywhere I'm aware of. Perhaps just
let planners = DELTA_EXTENSION_PLANNERS.clone();
for planner in planners.iter() {
...
}might work but I'd have to look into it myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. That also doesn't work. But, I think this should actually be a static here because of the use of LazyLock.
const here means a compile-time constant. (See: https://stackoverflow.com/questions/37405835/populating-a-static-const-with-an-environment-variable-at-runtime-in-rust). But LazyLock is something different; it is actually initialized on first usage.
https://doc.rust-lang.org/std/sync/struct.LazyLock.html
| Ok(ScanMetadataArrow { | ||
| scan_files, | ||
| scan_file_transforms, | ||
| _scan_file_transforms: scan_file_transforms, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/kernel/arrow/engine_ext.rs (ScanMetadataArrow) Clippy warning fixed: "field scan_file_transforms is never read --> crates/core/src/kernel/arrow/engine_ext.rs:44:5" Change: renamed the field to _scan_file_transforms and updated construction to _scan_file_transforms: scan_file_transforms to mark it intentionally unused.
| fn default() -> Self { | ||
| Self::Serializable | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/kernel/models/actions.rs Clippy warnings fixed: "associated function new is never used --> crates/core/src/kernel/models/actions.rs:271:19" and "this impl can be derived --> crates/core/src/kernel/models/actions.rs:706:1" Change: added #[allow(dead_code)] to the unused ProtocolInner::new method; replaced manual impl Default with #[derive(Default)] and marked default variants with #[default] for StorageType and IsolationLevel per clippy suggestions.
| if let Some(mut accumulator) = accumulator { | ||
| return accumulator | ||
| .update_batch(&[array.clone()]) | ||
| .update_batch(std::slice::from_ref(array)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/kernel/snapshot/log_data.rs Clippy warnings fixed: "unnecessary use of to_vec --> crates/core/src/kernel/snapshot/log_data.rs:102:18 help: use: self.data.iter().cloned()" and "this call to clone can be replaced with std::slice::from_ref --> crates/core/src/kernel/snapshot/log_data.rs:214:39 help: try: std::slice::from_ref(array)" Change: updated IntoIterator signature to carry the lifetime (impl<'a> IntoIterator for LogDataHandler<'a> and type IntoIter = Box<dyn Iterator<Item = Self::Item> + 'a>), replaced .to_vec().into_iter() with self.data.iter().cloned(), and replaced .update_batch(&[array.clone()]) with .update_batch(std::slice::from_ref(array)).
| let config = DeltaTableConfig { | ||
| require_files, | ||
| ..Default::default() | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/kernel/snapshot/mod.rs (resolve_snapshot) Clippy warning fixed: "field assignment outside of initializer for an instance created with Default::default() --> crates/core/src/kernel/snapshot/mod.rs:483:9 note: consider initializing the variable with DeltaTableConfig { require_files: require_files, ..Default::default() }" Change: constructed config with struct update syntax: let config = DeltaTableConfig { require_files, ..Default::default() }; instead of creating default and reassigning a field.
|
|
||
| /// Spawn task that will be aborted if this builder (or the stream | ||
| /// built from it) are dropped | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/kernel/snapshot/stream.rs (ReceiverStreamBuilder) Clippy warning fixed: "method spawn is never used --> crates/core/src/kernel/snapshot/stream.rs:92:12" Change: added #[allow(dead_code)] to the unused spawn method to silence the dead-code lint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not changed since I don't want to potentially break the API.
| K: AsRef<str> + Into<String>, | ||
| V: AsRef<str> + Into<String>, | ||
| T: TryUpdateKey, | ||
| T: TryUpdateKey + std::fmt::Debug, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/logstore/config.rs (try_parse_impl signature) Clippy warning fixed: "bound is defined in more than one place --> crates/core/src/logstore/config.rs:239:30 = help: for further information visit https://rust-lang.github.io/rust-clippy/...#multiple_bound_locations" Change: consolidated type bounds by moving std::fmt::Debug into the where-clause so T bounds are defined in one place: pub(super) fn try_parse_impl<T, K, V, I>(...) -> ... where ... T: TryUpdateKey + std::fmt::Debug, ....
| .iter() | ||
| .map(|(_, sql)| Constraint::new("*", sql)) | ||
| .values() | ||
| .map(|sql| Constraint::new("*", sql)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/operations/constraints.rs Clippy warnings fixed: "iterating on a map's keys --> crates/core/src/operations/constraints.rs:131:17 help: try: this.check_constraints.keys().map(|name| ...)" and "iterating on a map's values --> crates/core/src/operations/constraints.rs:179:56 help: try: constraints_sql_mapper.values().map(|sql| ...)" Change: iterated over keys/values directly: replaced .iter().map(|(name, )| ...) with .keys().cloned().map(|name| ...), and .iter().map(|(, sql)| ...) with .values().map(|sql| ...).
|
|
||
| let expired_tombstones = | ||
| get_stale_files(&snapshot, retention_period, now_millis, &self.log_store).await?; | ||
| get_stale_files(snapshot, retention_period, now_millis, &self.log_store).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/operations/vacuum.rs Clippy warning fixed: "this expression creates a reference which is immediately dereferenced by the compiler --> crates/core/src/operations/vacuum.rs:282:29 help: change this to: snapshot" Change: removed the needless borrow and passed snapshot directly to get_stale_files(snapshot, ...).
| }; | ||
|
|
||
| return Ok((actions, metrics)); | ||
| Ok((actions, metrics)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/operations/write/execution.rs Clippy warnings fixed: "unneeded return statement --> crates/core/src/operations/write/execution.rs:372:9" and "unneeded return statement --> crates/core/src/operations/write/execution.rs:564:9" Change: removed redundant return keywords and returned the expressions directly (Ok((actions, metrics))).
|
|
||
| #[error("Failed to execute write task: {source}")] | ||
| WriteTask { source: tokio::task::JoinError }, | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/operations/write/mod.rs Clippy warnings fixed: "unused import: crate::delta_datafusion::planner::DeltaPlanner --> crates/core/src/operations/write/mod.rs:59:5" and "variant WriteTask is never constructed --> crates/core/src/operations/write/mod.rs:86:5" Change: removed the unused DeltaPlanner import and deleted the unused WriteTask { source: tokio::task::JoinError } enum variant.
|
|
||
| impl ProtocolInner { | ||
| /// Create a new protocol action | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crate: crates/core File: crates/core/src/kernel/models/actions.rs Clippy warnings fixed: "associated function new is never used --> crates/core/src/kernel/models/actions.rs:271:19"
Not removed because this could break the API.
|
OK. With the help of copilot I have added comments listing the warning message and what was done for each of these. |
Description
Related Issue(s)
Closes #3907