Skip to content

Commit

Permalink
fix: several clippy error/warnings after upgrading toolchain (#2156)
Browse files Browse the repository at this point in the history
* fix pyscripts mod

Signed-off-by: Ruihang Xia <[email protected]>

* fix clippy::needless-pass-by-ref-mut

Signed-off-by: Ruihang Xia <[email protected]>

* add pyo3 feature gate in Makefile

Signed-off-by: Ruihang Xia <[email protected]>

---------

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Aug 11, 2023
1 parent 6877d08 commit 4fd1057
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ check: ## Cargo check all the targets.

.PHONY: clippy
clippy: ## Check clippy rules.
cargo clippy --workspace --all-targets -- -D warnings
cargo clippy --workspace --all-targets -F pyo3_backend -- -D warnings

.PHONY: fmt-check
fmt-check: ## Check code format.
Expand Down
11 changes: 4 additions & 7 deletions src/meta-srv/src/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,12 @@ impl MetaSrvInstance {
pub async fn start(&mut self) -> Result<()> {
self.meta_srv.try_start().await?;

let (tx, mut rx) = mpsc::channel::<()>(1);
let (tx, rx) = mpsc::channel::<()>(1);

self.signal_sender = Some(tx);

let meta_srv = bootstrap_meta_srv_with_router(
&self.opts.bind_addr,
router(self.meta_srv.clone()),
&mut rx,
);
let meta_srv =
bootstrap_meta_srv_with_router(&self.opts.bind_addr, router(self.meta_srv.clone()), rx);
let addr = self
.opts
.http_opts
Expand Down Expand Up @@ -124,7 +121,7 @@ impl MetaSrvInstance {
pub async fn bootstrap_meta_srv_with_router(
bind_addr: &str,
router: Router,
signal: &mut Receiver<()>,
mut signal: Receiver<()>,
) -> Result<()> {
let listener = TcpListener::bind(bind_addr)
.await
Expand Down
4 changes: 2 additions & 2 deletions src/script/src/python/pyo3/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ bind_aggr_expr!(median, Median,[v0], v0, expr0=>0);
#[pyfunction]
fn approx_percentile_cont(py: Python<'_>, values: &PyVector, percent: f64) -> PyResult<PyObject> {
let percent = expressions::Literal::new(datafusion_common::ScalarValue::Float64(Some(percent)));
return eval_df_aggr_expr(
eval_df_aggr_expr(
py,
expressions::ApproxPercentileCont::new(
vec![
Expand All @@ -363,7 +363,7 @@ fn approx_percentile_cont(py: Python<'_>, values: &PyVector, percent: f64) -> Py
)
.map_err(|e| PyValueError::new_err(format!("{e:?}")))?,
&[values.to_arrow_array()],
);
)
}

bind_aggr_expr!(array_agg, ArrayAgg,[v0], v0, expr0=>0);
Expand Down
4 changes: 2 additions & 2 deletions src/script/src/python/pyo3/copr_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub(crate) fn pyo3_exec_parsed(
) -> Result<RecordBatch> {
let _t = timer!(metric::METRIC_PYO3_EXEC_TOTAL_ELAPSED);
// i.e params or use `vector(..)` to construct a PyVector
let arg_names = &copr.deco_args.arg_names.clone().unwrap_or(vec![]);
let arg_names = &copr.deco_args.arg_names.clone().unwrap_or_default();
let args: Vec<PyVector> = if let Some(rb) = rb {
let args = select_from_rb(rb, arg_names)?;
check_args_anno_real_type(arg_names, &args, copr, rb)?;
Expand Down Expand Up @@ -270,7 +270,7 @@ fn py_list_to_vec(list: &PyList) -> PyResult<VectorRef> {
})?;
v.push(scalar);
}
let array = ScalarValue::iter_to_array(v.into_iter()).map_err(|err| {
let array = ScalarValue::iter_to_array(v).map_err(|err| {
PyRuntimeError::new_err(format!("Can't convert scalar value list to array: {}", err))
})?;
let ret = Helper::try_into_vector(array).map_err(|err| {
Expand Down
1 change: 1 addition & 0 deletions src/servers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#![feature(assert_matches)]
#![feature(try_blocks)]
#![feature(exclusive_wrapper)]

use datatypes::schema::Schema;
use query::plan::LogicalPlan;
Expand Down
7 changes: 4 additions & 3 deletions src/servers/src/postgres/auth_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

use std::fmt::Debug;
use std::sync::Exclusive;

use async_trait::async_trait;
use common_catalog::parse_catalog_and_schema_from_db_string;
Expand Down Expand Up @@ -153,7 +154,7 @@ impl StartupHandler for PostgresServerHandler {
auth::save_startup_parameters_to_metadata(client, startup);

// check if db is valid
match resolve_db_info(client, self.query_handler.clone()).await? {
match resolve_db_info(Exclusive::new(client), self.query_handler.clone()).await? {
DbResolution::Resolved(catalog, schema) => {
let metadata = client.metadata_mut();
let _ = metadata.insert(super::METADATA_CATALOG.to_owned(), catalog);
Expand Down Expand Up @@ -226,13 +227,13 @@ enum DbResolution {

/// A function extracted to resolve lifetime and readability issues:
async fn resolve_db_info<C>(
client: &mut C,
client: Exclusive<&mut C>,
query_handler: ServerSqlQueryHandlerRef,
) -> PgWireResult<DbResolution>
where
C: ClientInfo + Unpin + Send,
{
let db_ref = client.metadata().get(super::METADATA_DATABASE);
let db_ref = client.into_inner().metadata().get(super::METADATA_DATABASE);
if let Some(db) = db_ref {
let (catalog, schema) = parse_catalog_and_schema_from_db_string(db);
if query_handler
Expand Down

0 comments on commit 4fd1057

Please sign in to comment.