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: forbid wildcard imports + additional rustfmt #2466

Merged
merged 22 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ opt-level = 3
codegen-units = 1
strip = true

[workspace.lints.clippy]
wildcard_imports = "deny"

[workspace.dependencies]
clap = { version = "4.4.18", features = ["derive"] }
datafusion = { version = "32.0", features = ["avro"] }
Expand Down
3 changes: 3 additions & 0 deletions bindings/nodejs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ version = "0.0.0"
[lib]
crate-type = ["cdylib"]

[lints]
workspace = true

[dependencies]
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
ioutil = { path = "../../crates/ioutil" }
Expand Down
5 changes: 4 additions & 1 deletion bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ name = "py-glaredb"
version.workspace = true
edition = "2021"

[lints]
workspace = true

# [workspace]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
name = "glaredb"
crate-type = ["cdylib"]
Expand Down
3 changes: 2 additions & 1 deletion crates/arrow_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "arrow_util"
version.workspace = true
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
datafusion = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/bench_runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "bench_runner"
version = { workspace = true }
edition = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
logutil = {path = "../logutil"}
Expand Down
3 changes: 2 additions & 1 deletion crates/bytesutil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "bytesutil"
version = {workspace = true}
edition = {workspace = true}

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
bytes = "1.4.0"
3 changes: 2 additions & 1 deletion crates/catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "catalog"
version.workspace = true
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
datafusion = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/datafusion_ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ description = "Shared datafusion extensions"
version = { workspace = true }
edition = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[features]
default = ["unicode_expressions"]
Expand Down
3 changes: 1 addition & 2 deletions crates/datafusion_ext/src/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,8 +1822,7 @@ mod tests {
DataType::List(Arc::new(Field::new("item", DataType::Int32, true))),
);

let array =
scalar_iter_to_array(vec![l1, l2, l3].iter().map(|v| Ok(v.to_owned()))).unwrap();
let array = scalar_iter_to_array([l1, l2, l3].iter().map(|v| Ok(v.to_owned()))).unwrap();
let array = as_list_array(&array).unwrap();

// Construct expected array with array builders
Expand Down
2 changes: 1 addition & 1 deletion crates/datafusion_ext/src/planner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mod values;
use std::collections::HashMap;
use std::sync::Arc;

use crate::functions::*;
use crate::functions::FuncParamValue;
use async_trait::async_trait;
use datafusion::arrow::datatypes::DataType;
use datafusion::arrow::datatypes::Field;
Expand Down
6 changes: 3 additions & 3 deletions crates/datafusion_ext/src/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ mod error;
mod inner;
mod utils;
mod value;
use constants::*;
use constants::IMPLICIT_SCHEMAS;
use datafusion::arrow::datatypes::{DataType, Field};
use datafusion::config::{ConfigExtension, ExtensionOptions};
use datafusion::scalar::ScalarValue;
use pgrepr::notice::NoticeSeverity;
use utils::*;
use utils::split_comma_delimited;

use datafusion::variable::{VarProvider, VarType};
use inner::*;
use inner::ServerVar;
use uuid::Uuid;

pub use inner::Dialect;
Expand Down
2 changes: 1 addition & 1 deletion crates/datafusion_ext/src/vars/constants.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::*;
use super::{Dialect, Lazy, ServerVar, ToOwned, Uuid};

use pgrepr::compatible::server_version;
use pgrepr::notice::NoticeSeverity;
Expand Down
9 changes: 8 additions & 1 deletion crates/datafusion_ext/src/vars/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ use datafusion::variable::VarType;
use pgrepr::notice::NoticeSeverity;
use std::borrow::Borrow;

use super::constants::*;
use super::constants::{
APPLICATION_NAME, CLIENT_ENCODING, CLIENT_MIN_MESSAGES, CONNECTION_ID, DATABASE_ID,
DATABASE_NAME, DATESTYLE, DIALECT, ENABLE_DEBUG_DATASOURCES, ENABLE_EXPERIMENTAL_SCHEDULER,
EXTRA_FLOAT_DIGITS, FORCE_CATALOG_REFRESH, GLAREDB_VERSION, IS_CLOUD_INSTANCE,
MAX_CREDENTIALS_COUNT, MAX_DATASOURCE_COUNT, MAX_TUNNEL_COUNT, MEMORY_LIMIT_BYTES,
REMOTE_SESSION_ID, SEARCH_PATH, SERVER_VERSION, STANDARD_CONFORMING_STRINGS, STATEMENT_TIMEOUT,
TIMEZONE, TRANSACTION_ISOLATION, USER_ID, USER_NAME,
};
use super::error::VarError;
use super::value::Value;
use std::sync::Arc;
Expand Down
5 changes: 4 additions & 1 deletion crates/datafusion_ext/src/vars/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use regex::Regex;

use super::*;
use super::Lazy;

/// Regex for matching strings delineated by commas. Will match full quoted
/// strings as well.
Expand All @@ -24,6 +24,9 @@ mod tests {

use super::*;

use crate::vars::inner::SessionVar;
use crate::vars::ServerVar;

#[test]
fn split_on_commas() {
struct Test {
Expand Down
2 changes: 1 addition & 1 deletion crates/datafusion_ext/src/vars/value.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pgrepr::notice::NoticeSeverity;

use super::*;
use super::{split_comma_delimited, Dialect, Display, FromStr, ToOwned, Uuid};

pub trait Value: ToOwned + std::fmt::Debug {
fn try_parse(s: &str) -> Option<Self::Owned>;
Expand Down
3 changes: 2 additions & 1 deletion crates/datasources/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "datasources"
version = { workspace = true }
edition = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
ioutil = { path = "../ioutil" }
Expand Down
12 changes: 11 additions & 1 deletion crates/datasources/src/bson/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,17 @@ pub mod stream;
pub mod table;

use datafusion::arrow::array::cast::as_string_array;
use datafusion::arrow::array::{types::*, Array, ArrayRef, AsArray, StructArray};
use datafusion::arrow::array::{
types::{
Date32Type, Date64Type, Decimal128Type, DurationMicrosecondType, DurationMillisecondType,
DurationNanosecondType, DurationSecondType, Float16Type, Float32Type, Float64Type,
GenericBinaryType, Int16Type, Int32Type, Int64Type, Int8Type, IntervalDayTimeType,
IntervalYearMonthType, Time32MillisecondType, Time32SecondType, Time64MicrosecondType,
Time64NanosecondType, TimestampMicrosecondType, TimestampMillisecondType,
TimestampSecondType, UInt16Type, UInt32Type, UInt64Type, UInt8Type,
},
Array, ArrayRef, AsArray, StructArray,
};
use datafusion::arrow::datatypes::{DataType, Fields, IntervalUnit, TimeUnit};
use datafusion::arrow::error::ArrowError;

Expand Down
5 changes: 4 additions & 1 deletion crates/datasources/src/cassandra/builder.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use super::*;
use super::{
Any, Arc, ArrayRef, CqlValue, DataType, Float32Builder, Float64Builder, Int16Builder,
Int32Builder, Int8Builder, StringBuilder, TimeUnit, TimestampMillisecondBuilder,
};
use chrono::{DateTime, NaiveTime, Utc};
use datafusion::arrow::array::{
ArrayBuilder, Date64Builder, DurationNanosecondBuilder, Int64Builder, ListBuilder,
Expand Down
8 changes: 7 additions & 1 deletion crates/datasources/src/cassandra/exec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
use super::{builder::CqlValueArrayBuilder, *};
use super::{
builder::CqlValueArrayBuilder, fmt, stream, Any, Arc, ArrowSchemaRef, Context, DataFusionError,
DataSourceMetricsStreamAdapter, DatafusionResult, DisplayAs, DisplayFormatType, ExecutionPlan,
ExecutionPlanMetricsSet, MetricsSet, Partitioning, PhysicalSortExpr, Pin, Poll, RecordBatch,
RecordBatchStream, Result, Row, SendableRecordBatchStream, Session, Statistics, Stream,
StreamExt, TaskContext,
};
use datafusion::arrow::array::ArrayBuilder;

pub(super) struct CassandraExec {
Expand Down
5 changes: 4 additions & 1 deletion crates/datasources/src/common/ssh/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ impl SshTunnelAccess {
/// what's exposed in Cloud.
#[cfg(any(target_os = "linux", target_os = "macos"))]
mod unix_impl {
use super::*;
use super::{
debug, fs, io, trace, Duration, File, NamedTempFile, Permissions, SocketAddr, SshKey,
SshTunnelError, TcpListener, ToSocketAddrs,
};
use openssh::{ForwardType, KnownHosts, Session, SessionBuilder};
use std::{
net::{IpAddr, Ipv4Addr},
Expand Down
5 changes: 4 additions & 1 deletion crates/datasources/src/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ use datafusion::{
};
use decimal::Decimal128;
use once_cell::sync::Lazy;
use repr::str::encode::*;
use repr::str::encode::{
encode_binary, encode_binary_mysql, encode_binary_snowflake, encode_date, encode_decimal,
encode_float, encode_int, encode_string, encode_time, encode_utc_timestamp,
};

use super::errors::{DatasourceCommonError, Result};

Expand Down
3 changes: 3 additions & 0 deletions crates/decimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name = "decimal"
version = {workspace = true}
edition = {workspace = true}

[lints]
workspace = true

[dependencies]
thiserror.workspace = true
num-traits = "0.2.17"
Expand Down
3 changes: 3 additions & 0 deletions crates/glaredb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ edition = { workspace = true }
name = "glaredb"
path = "src/bin/main.rs"

[lints]
workspace = true

[dependencies]
anyhow = { workspace = true }
clap = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/glaredb/src/args/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use clap::Args;

use super::*;
use super::{PathBuf, StorageConfigArgs};

#[derive(Args)]
pub struct ServerArgs {
Expand Down
4 changes: 2 additions & 2 deletions crates/glaredb/tests/iss_2309.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn test_special_characters() {

let assert = cmd
.timeout(DEFAULT_TIMEOUT)
.args(&["-q", r#"select ';'"#])
.args(["-q", r#"select ';'"#])
.assert();
assert.success().stdout(predicates::str::contains(
r#"
Expand All @@ -31,7 +31,7 @@ fn test_special_characters_2() {

let assert = cmd
.timeout(DEFAULT_TIMEOUT)
.args(&["-q", r#"select ";""#])
.args(["-q", r#"select ";""#])
.assert();
assert.failure().stderr(predicates::str::contains(
"Schema error: No field named \";\".",
Expand Down
10 changes: 5 additions & 5 deletions crates/glaredb/tests/local_args_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn test_query_or_file() {

let assert = cmd
.timeout(DEFAULT_TIMEOUT)
.args(&["-q", "SELECT * FROM foo", "foo.sql"])
.args(["-q", "SELECT * FROM foo", "foo.sql"])
.assert();
assert.failure().stderr(predicates::str::contains(
"the argument '--query <QUERY>' cannot be used with '[FILE]'",
Expand All @@ -28,7 +28,7 @@ fn test_storage_config_require_location() {

let assert = cmd
.timeout(DEFAULT_TIMEOUT)
.args(&["-o", "foo=bar"])
.args(["-o", "foo=bar"])
.assert();
assert.failure().stderr(
predicates::str::contains("error: the following required arguments were not provided:")
Expand All @@ -44,7 +44,7 @@ fn test_parse_storage_options_not_ok() {

let assert = cmd
.timeout(DEFAULT_TIMEOUT)
.args(&["-l", "foo", "-o", "foobar"])
.args(["-l", "foo", "-o", "foobar"])
.assert();
assert.failure().stderr(predicates::str::contains(
"Expected key-value pair delimited by an equals sign, got",
Expand All @@ -61,7 +61,7 @@ fn test_parse_storage_options_ok() {

let assert = cmd
.timeout(DEFAULT_TIMEOUT)
.args(&["-l", temp_dir, "-o", "foo=bar", "-q", "select 1"])
.args(["-l", temp_dir, "-o", "foo=bar", "-q", "select 1"])
.assert();
assert.success();
}
Expand All @@ -77,7 +77,7 @@ fn test_data_dir() {

let assert = cmd
.timeout(DEFAULT_TIMEOUT)
.args(&["-f", path, "-q", "create table test as select 1"])
.args(["-f", path, "-q", "create table test as select 1"])
.assert();
assert.success();

Expand Down
2 changes: 1 addition & 1 deletion crates/glaredb/tests/server_args_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn test_user_requires_password() {
.arg("server")
.arg("--bind")
.arg("0.0.0.0:0")
.args(&["-u", "test"])
.args(["-u", "test"])
.assert();

assert.failure(/* We expect a timeout here */).stderr(contains(
Expand Down
3 changes: 2 additions & 1 deletion crates/ioutil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "ioutil"
version = {workspace = true}
edition = {workspace = true}

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
bytes = "1.4.0"
Expand Down
3 changes: 2 additions & 1 deletion crates/logutil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "logutil"
version = {workspace = true}
edition = {workspace = true}

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
tracing = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion crates/metastore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "metastore"
version = {workspace = true}
edition = {workspace = true}

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
ioutil = {path = "../ioutil"}
Expand Down
3 changes: 2 additions & 1 deletion crates/object_store_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "object_store_util"
version = { workspace = true }
edition = { workspace = true }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
logutil = { path = "../logutil" }
Expand Down
3 changes: 2 additions & 1 deletion crates/pgprototest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name = "pgprototest"
version = {workspace = true}
edition = {workspace = true}

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lints]
workspace = true

[dependencies]
serde = { workspace = true }
Expand Down
Loading