mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-22 22:20:02 +00:00
fix: several clippy error/warnings after upgrading toolchain (#2156)
* fix pyscripts mod Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix clippy::needless-pass-by-ref-mut Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * add pyo3 feature gate in Makefile Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
2
Makefile
2
Makefile
@@ -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.
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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![
|
||||
@@ -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);
|
||||
|
||||
@@ -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)?;
|
||||
@@ -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| {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#![feature(assert_matches)]
|
||||
#![feature(try_blocks)]
|
||||
#![feature(exclusive_wrapper)]
|
||||
|
||||
use datatypes::schema::Schema;
|
||||
use query::plan::LogicalPlan;
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user