mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-31 12:20:38 +00:00
@@ -51,7 +51,7 @@ pub trait ScriptEngine {
|
||||
) -> std::result::Result<Self::Script, Self::Error>;
|
||||
}
|
||||
|
||||
/// Evalute script context
|
||||
/// Evaluate script context
|
||||
#[derive(Debug, Default)]
|
||||
pub struct EvalContext {}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ macro_rules! bind_call_unary_math_function {
|
||||
|
||||
/// The macro for binding function in `datafusion_physical_expr::expressions`(most of them are aggregate function)
|
||||
///
|
||||
/// - first arguements is the name of datafusion expression function like `Avg`
|
||||
/// - first arguments is the name of datafusion expression function like `Avg`
|
||||
/// - second is the python virtual machine ident `vm`
|
||||
/// - following is the actual args passing in(as a slice).i.e.`&[values.to_arrow_array()]`
|
||||
/// - the data type of passing in args, i.e: `Datatype::Float64`
|
||||
@@ -259,7 +259,7 @@ fn from_df_err(err: DataFusionError, vm: &VirtualMachine) -> PyBaseExceptionRef
|
||||
vm.new_runtime_error(format!("Data Fusion Error: {err:#?}"))
|
||||
}
|
||||
|
||||
/// evalute Aggregate Expr using its backing accumulator
|
||||
/// evaluate Aggregate Expr using its backing accumulator
|
||||
fn eval_aggr_fn<T: AggregateExpr>(
|
||||
aggr: T,
|
||||
values: &[ArrayRef],
|
||||
@@ -1120,7 +1120,7 @@ pub(crate) mod greptime_builtin {
|
||||
State::Num(v) => {
|
||||
if cur_idx + 1 > parsed.len() {
|
||||
return Err(vm.new_runtime_error(
|
||||
"Expect a spearator after number, found nothing!".to_string(),
|
||||
"Expect a separator after number, found nothing!".to_string(),
|
||||
));
|
||||
}
|
||||
let nxt = &parsed[cur_idx + 1];
|
||||
@@ -1128,7 +1128,7 @@ pub(crate) mod greptime_builtin {
|
||||
tot_time += v * factor(sep, vm)?;
|
||||
} else {
|
||||
return Err(vm.new_runtime_error(format!(
|
||||
"Expect a spearator after number, found `{nxt:#?}`"
|
||||
"Expect a separator after number, found `{nxt:#?}`"
|
||||
)));
|
||||
}
|
||||
cur_idx += 2;
|
||||
|
||||
@@ -118,7 +118,7 @@ struct Var {
|
||||
ty: DataType,
|
||||
}
|
||||
|
||||
/// for floating number comparsion
|
||||
/// for floating number comparison
|
||||
const EPS: f64 = 2.0 * f64::EPSILON;
|
||||
|
||||
/// Null element just not supported for now for simplicity with writing test cases
|
||||
|
||||
@@ -49,7 +49,7 @@ use crate::python::PyVector;
|
||||
#[cfg_attr(test, derive(Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct AnnotationInfo {
|
||||
/// if None, use types infered by PyVector
|
||||
/// if None, use types inferred by PyVector
|
||||
pub datatype: Option<DataType>,
|
||||
pub is_nullable: bool,
|
||||
}
|
||||
@@ -115,7 +115,7 @@ impl Coprocessor {
|
||||
datatype: ty,
|
||||
is_nullable,
|
||||
} = anno[idx].to_owned().unwrap_or_else(||
|
||||
// default to be not nullable and use DataType infered by PyVector itself
|
||||
// default to be not nullable and use DataType inferred by PyVector itself
|
||||
AnnotationInfo{
|
||||
datatype: Some(real_ty.to_owned()),
|
||||
is_nullable: false
|
||||
@@ -208,7 +208,7 @@ fn try_into_py_vector(fetch_args: Vec<ArrayRef>) -> Result<Vec<PyVector>> {
|
||||
}
|
||||
_ => {
|
||||
return ret_other_error_with(format!(
|
||||
"Unsupport data type at column {idx}: {:?} for coprocessor",
|
||||
"Unsupported data type at column {idx}: {:?} for coprocessor",
|
||||
arg.data_type()
|
||||
))
|
||||
.fail()
|
||||
@@ -348,7 +348,7 @@ fn set_items_in_scope(
|
||||
/// ```
|
||||
///
|
||||
/// # Type Annotation
|
||||
/// you can use type annotations in args and returns to designate types, so coprocessor will check for corrsponding types.
|
||||
/// you can use type annotations in args and returns to designate types, so coprocessor will check for corresponding types.
|
||||
///
|
||||
/// Currently support types are `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64` and `f16`, `f32`, `f64`
|
||||
///
|
||||
|
||||
@@ -67,7 +67,7 @@ fn gen_call(name: &str, deco_args: &DecoratorArgs, loc: &Location) -> ast::Stmt<
|
||||
|
||||
/// stripe the decorator(`@xxxx`) and type annotation(for type checker is done in rust function), add one line in the ast for call function with given parameter, and compiler into `CodeObject`
|
||||
///
|
||||
/// The rationale is that rustpython's vm is not very efficient according to [offical benchmark](https://rustpython.github.io/benchmarks),
|
||||
/// The rationale is that rustpython's vm is not very efficient according to [official benchmark](https://rustpython.github.io/benchmarks),
|
||||
/// So we should avoid running too much Python Bytecode, hence in this function we delete `@` decorator(instead of actually write a decorator in python)
|
||||
/// And add a function call in the end and also
|
||||
/// strip type annotation
|
||||
@@ -108,8 +108,8 @@ pub fn compile_script(name: &str, deco_args: &DecoratorArgs, script: &str) -> Re
|
||||
}
|
||||
loc = Some(stmt.location);
|
||||
|
||||
// This manually construct ast has no corrsponding code
|
||||
// in the script, so just give it a location that don't exist in orginal script
|
||||
// This manually construct ast has no corresponding code
|
||||
// in the script, so just give it a location that don't exist in original script
|
||||
// (which doesn't matter because Location usually only used in pretty print errors)
|
||||
}
|
||||
// Append statement which calling coprocessor function.
|
||||
|
||||
@@ -286,7 +286,7 @@ fn parse_keywords(keywords: &Vec<ast::Keyword<()>>) -> Result<DecoratorArgs> {
|
||||
let s = s.as_str();
|
||||
if visited_key.contains(s) {
|
||||
return fail_parse_error!(
|
||||
format!("`{s}` occur multiple times in decorator's arguements' list."),
|
||||
format!("`{s}` occur multiple times in decorator's arguments' list."),
|
||||
Some(kw.location),
|
||||
);
|
||||
}
|
||||
@@ -308,7 +308,7 @@ fn parse_keywords(keywords: &Vec<ast::Keyword<()>>) -> Result<DecoratorArgs> {
|
||||
None => {
|
||||
return fail_parse_error!(
|
||||
format!(
|
||||
"Expect explictly set both `args` and `returns`, found \n{:#?}",
|
||||
"Expect explicitly set both `args` and `returns`, found \n{:#?}",
|
||||
&kw.node
|
||||
),
|
||||
Some(kw.location),
|
||||
@@ -365,14 +365,14 @@ fn parse_decorator(decorator: &ast::Expr<()>) -> Result<DecoratorArgs> {
|
||||
}
|
||||
}
|
||||
|
||||
// get type annotaion in arguments
|
||||
// get type annotation in arguments
|
||||
fn get_arg_annotations(args: &Arguments) -> Result<Vec<Option<AnnotationInfo>>> {
|
||||
// get arg types from type annotation>
|
||||
args.args
|
||||
.iter()
|
||||
.map(|arg| {
|
||||
if let Some(anno) = &arg.node.annotation {
|
||||
// for there is erro handling for parse_annotation
|
||||
// for there is error handling for parse_annotation
|
||||
parse_annotation(anno).map(Some)
|
||||
} else {
|
||||
Ok(None)
|
||||
@@ -472,7 +472,7 @@ pub fn parse_and_compile_copr(script: &str) -> Result<Coprocessor> {
|
||||
.collect()
|
||||
};
|
||||
|
||||
// make sure both arguments&returns in fucntion
|
||||
// make sure both arguments&returns in function
|
||||
// and in decorator have same length
|
||||
ensure!(
|
||||
deco_args.arg_names.len() == arg_types.len(),
|
||||
|
||||
@@ -140,7 +140,7 @@ impl ErrorExt for Error {
|
||||
self
|
||||
}
|
||||
}
|
||||
// impl from for those error so one can use question mark and implictly cast into `CoprError`
|
||||
// impl from for those error so one can use question mark and implicitly cast into `CoprError`
|
||||
impl From<DataTypeError> for Error {
|
||||
fn from(e: DataTypeError) -> Self {
|
||||
Self::TypeCast { source: e }
|
||||
|
||||
@@ -450,7 +450,7 @@ impl PyVector {
|
||||
#[pymethod(magic)]
|
||||
fn rfloordiv(&self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyVector> {
|
||||
if is_pyobj_scalar(&other, vm) {
|
||||
// FIXME: DataType convert problem, target_type should be infered?
|
||||
// FIXME: DataType convert problem, target_type should be inferred?
|
||||
self.scalar_arith_op(other, Some(DataType::Int64), arrow2_rfloordiv_scalar, vm)
|
||||
} else {
|
||||
self.arith_op(
|
||||
@@ -482,7 +482,7 @@ impl PyVector {
|
||||
// The Comparable Trait only support normal cmp
|
||||
// (yes there is a slot_richcompare function, but it is not used in anywhere)
|
||||
// so use our own function
|
||||
// TODO(discord9): test those funciton
|
||||
// TODO(discord9): test those function
|
||||
|
||||
#[pymethod(name = "eq")]
|
||||
#[pymethod(magic)]
|
||||
@@ -676,7 +676,7 @@ impl PyVector {
|
||||
}
|
||||
}
|
||||
|
||||
/// Unsupport
|
||||
/// Unsupported
|
||||
/// TODO(discord9): make it work
|
||||
#[allow(unused)]
|
||||
fn setitem_by_index(
|
||||
@@ -689,7 +689,7 @@ impl PyVector {
|
||||
}
|
||||
}
|
||||
|
||||
/// get corrsponding arrow op function according to given PyComaprsionOp
|
||||
/// get corresponding arrow op function according to given PyComaprsionOp
|
||||
///
|
||||
/// TODO(discord9): impl scalar version function
|
||||
fn get_arrow_op(op: PyComparisonOp) -> impl Fn(&dyn Array, &dyn Array) -> Box<dyn Array> {
|
||||
@@ -708,7 +708,7 @@ fn get_arrow_op(op: PyComparisonOp) -> impl Fn(&dyn Array, &dyn Array) -> Box<dy
|
||||
}
|
||||
}
|
||||
|
||||
/// get corrsponding arrow scalar op function according to given PyComaprsionOp
|
||||
/// get corresponding arrow scalar op function according to given PyComaprsionOp
|
||||
///
|
||||
/// TODO(discord9): impl scalar version function
|
||||
fn get_arrow_scalar_op(
|
||||
|
||||
Reference in New Issue
Block a user