Skip to content

Commit

Permalink
chore: correct typos (GreptimeTeam#589) (GreptimeTeam#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
dongxuwang authored Nov 21, 2022
1 parent ca5734e commit b6fa316
Showing 35 changed files with 78 additions and 78 deletions.
4 changes: 2 additions & 2 deletions docs/how-to/how-to-write-aggregate-function.md
Original file line number Diff line number Diff line change
@@ -55,15 +55,15 @@ The DataFusion basically execute aggregate like this:
2. Call `update_batch` on each accumulator with partitioned data, to let you update your aggregate calculation.
3. Call `state` to get each accumulator's internal state, the medial calculation result.
4. Call `merge_batch` to merge all accumulator's internal state to one.
5. Execute `evalute` on the chosen one to get the final calculation result.
5. Execute `evaluate` on the chosen one to get the final calculation result.

Once you know the meaning of each method, you can easily write your accumulator. You can refer to `Median` accumulator or `SUM` accumulator defined in file `my_sum_udaf_example.rs` for more details.

# 3. Register your aggregate function to our query engine.

You can call `register_aggregate_function` method in query engine to register your aggregate function. To do that, you have to new an instance of struct `AggregateFunctionMeta`. The struct has three fields, first is the name of your aggregate function's name. The function name is case-sensitive due to DataFusion's restriction. We strongly recommend using lowercase for your name. If you have to use uppercase name, wrap your aggregate function with quotation marks. For example, if you define an aggregate function named "my_aggr", you can use "`SELECT MY_AGGR(x)`"; if you define "my_AGGR", you have to use "`SELECT "my_AGGR"(x)`".

The second field is arg_counts ,the count of the arguments. Like accumulator `percentile`, caculating the p_number of the column. We need to input the value of column and the value of p to cacalate, and so the count of the arguments is two.
The second field is arg_counts ,the count of the arguments. Like accumulator `percentile`, calculating the p_number of the column. We need to input the value of column and the value of p to cacalate, and so the count of the arguments is two.

The third field is a function about how to create your accumulator creator that you defined in step 1 above. Create creator, that's a bit intertwined, but it is how we make DataFusion use a newly created aggregate function each time it executes a SQL, preventing the stored input types from affecting each other. The key detail can be starting looking at our `DfContextProviderAdapter` struct's `get_aggregate_meta` method.

2 changes: 1 addition & 1 deletion src/api/greptime/v1/meta/heartbeat.proto
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ message NodeStat {
uint64 wcus = 2;
// Table number in this node
uint64 table_num = 3;
// Regon number in this node
// Region number in this node
uint64 region_num = 4;

double cpu_usage = 5;
2 changes: 1 addition & 1 deletion src/catalog/src/system.rs
Original file line number Diff line number Diff line change
@@ -383,7 +383,7 @@ mod tests {
use super::*;

#[test]
pub fn test_decode_catalog_enrty() {
pub fn test_decode_catalog_entry() {
let entry = decode_system_catalog(
Some(EntryType::Catalog as u8),
Some("some_catalog".as_bytes()),
6 changes: 3 additions & 3 deletions src/client/examples/insert.rs
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ async fn run() {

fn insert_batches() -> Vec<Vec<u8>> {
const SEMANTIC_TAG: i32 = 0;
const SEMANTIC_FEILD: i32 = 1;
const SEMANTIC_FIELD: i32 = 1;
const SEMANTIC_TS: i32 = 2;

let row_count = 4;
@@ -71,7 +71,7 @@ fn insert_batches() -> Vec<Vec<u8>> {
};
let cpu_column = Column {
column_name: "cpu".to_string(),
semantic_type: SEMANTIC_FEILD,
semantic_type: SEMANTIC_FIELD,
values: Some(cpu_vals),
null_mask: vec![2],
..Default::default()
@@ -83,7 +83,7 @@ fn insert_batches() -> Vec<Vec<u8>> {
};
let mem_column = Column {
column_name: "memory".to_string(),
semantic_type: SEMANTIC_FEILD,
semantic_type: SEMANTIC_FIELD,
values: Some(mem_vals),
null_mask: vec![4],
..Default::default()
2 changes: 1 addition & 1 deletion src/client/src/database.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ use api::v1::{
SelectExpr,
};
use common_error::status_code::StatusCode;
use common_grpc::{AsExcutionPlan, DefaultAsPlanImpl};
use common_grpc::{AsExecutionPlan, DefaultAsPlanImpl};
use common_insert::column_to_vector;
use common_query::Output;
use common_recordbatch::{RecordBatch, RecordBatches};
2 changes: 1 addition & 1 deletion src/common/grpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -20,4 +20,4 @@ pub mod writer;

pub use error::Error;
pub use physical::plan::{DefaultAsPlanImpl, MockExecution};
pub use physical::AsExcutionPlan;
pub use physical::AsExecutionPlan;
2 changes: 1 addition & 1 deletion src/common/grpc/src/physical.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ use datafusion::physical_plan::ExecutionPlan;

pub type ExecutionPlanRef = Arc<dyn ExecutionPlan>;

pub trait AsExcutionPlan {
pub trait AsExecutionPlan {
type Error: std::error::Error;

fn try_into_physical_plan(&self) -> Result<ExecutionPlanRef, Self::Error>;
14 changes: 7 additions & 7 deletions src/common/grpc/src/physical/plan.rs
Original file line number Diff line number Diff line change
@@ -35,13 +35,13 @@ use crate::error::{
DecodePhysicalPlanNodeSnafu, EmptyPhysicalPlanSnafu, Error, MissingFieldSnafu,
NewProjectionSnafu, UnsupportedDfPlanSnafu,
};
use crate::physical::{expr, AsExcutionPlan, ExecutionPlanRef};
use crate::physical::{expr, AsExecutionPlan, ExecutionPlanRef};

pub struct DefaultAsPlanImpl {
pub bytes: Vec<u8>,
}

impl AsExcutionPlan for DefaultAsPlanImpl {
impl AsExecutionPlan for DefaultAsPlanImpl {
type Error = Error;

// Vec<u8> -> PhysicalPlanNode -> ExecutionPlanRef
@@ -64,7 +64,7 @@ impl AsExcutionPlan for DefaultAsPlanImpl {
}
}

impl AsExcutionPlan for PhysicalPlanNode {
impl AsExecutionPlan for PhysicalPlanNode {
type Error = Error;

fn try_into_physical_plan(&self) -> Result<ExecutionPlanRef, Self::Error> {
@@ -227,7 +227,7 @@ mod tests {
use datafusion::physical_plan::projection::ProjectionExec;

use crate::physical::plan::{DefaultAsPlanImpl, MockExecution};
use crate::physical::{AsExcutionPlan, ExecutionPlanRef};
use crate::physical::{AsExecutionPlan, ExecutionPlanRef};

#[test]
fn test_convert_df_projection_with_bytes() {
@@ -236,7 +236,7 @@ mod tests {
let bytes = DefaultAsPlanImpl::try_from_physical_plan(projection_exec).unwrap();
let exec = bytes.try_into_physical_plan().unwrap();

verify_df_porjection(exec);
verify_df_projection(exec);
}

#[test]
@@ -246,7 +246,7 @@ mod tests {
let projection_node = PhysicalPlanNode::try_from_physical_plan(projection_exec).unwrap();
let exec = projection_node.try_into_physical_plan().unwrap();

verify_df_porjection(exec);
verify_df_projection(exec);
}

fn mock_df_projection() -> Arc<ProjectionExec> {
@@ -264,7 +264,7 @@ mod tests {
)
}

fn verify_df_porjection(exec: ExecutionPlanRef) {
fn verify_df_projection(exec: ExecutionPlanRef) {
let projection_exec = exec.as_any().downcast_ref::<ProjectionExec>().unwrap();
let mock_input = projection_exec
.input()
2 changes: 1 addition & 1 deletion src/common/query/src/logical_plan/udf.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
// limitations under the License.

//! Udf module contains foundational types that are used to represent UDFs.
//! It's modifed from datafusion.
//! It's modified from datafusion.
use std::fmt;
use std::fmt::{Debug, Formatter};
use std::sync::Arc;
8 changes: 4 additions & 4 deletions src/common/query/src/signature.rs
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ pub struct Signature {
}

#[inline]
fn concret_types_to_arrow_types(ts: Vec<ConcreteDataType>) -> Vec<ArrowDataType> {
fn concrete_types_to_arrow_types(ts: Vec<ConcreteDataType>) -> Vec<ArrowDataType> {
ts.iter().map(ConcreteDataType::as_arrow_type).collect()
}

@@ -118,14 +118,14 @@ impl From<TypeSignature> for DfTypeSignature {
fn from(type_signature: TypeSignature) -> DfTypeSignature {
match type_signature {
TypeSignature::Variadic(types) => {
DfTypeSignature::Variadic(concret_types_to_arrow_types(types))
DfTypeSignature::Variadic(concrete_types_to_arrow_types(types))
}
TypeSignature::VariadicEqual => DfTypeSignature::VariadicEqual,
TypeSignature::Uniform(n, types) => {
DfTypeSignature::Uniform(n, concret_types_to_arrow_types(types))
DfTypeSignature::Uniform(n, concrete_types_to_arrow_types(types))
}
TypeSignature::Exact(types) => {
DfTypeSignature::Exact(concret_types_to_arrow_types(types))
DfTypeSignature::Exact(concrete_types_to_arrow_types(types))
}
TypeSignature::Any(n) => DfTypeSignature::Any(n),
TypeSignature::OneOf(ts) => {
10 changes: 5 additions & 5 deletions src/common/substrait/src/df_logical.rs
Original file line number Diff line number Diff line change
@@ -178,14 +178,14 @@ impl DFLogicalSubstraitConvertor {
})?;
let adapter = Arc::new(DfTableProviderAdapter::new(table_ref));

// Get schema directly from the table, and compare it with the schema retrived from substrait proto.
// Get schema directly from the table, and compare it with the schema retrieved from substrait proto.
let stored_schema = adapter.schema();
let retrived_schema = to_schema(read_rel.base_schema.unwrap_or_default())?;
let retrived_arrow_schema = retrived_schema.arrow_schema();
let retrieved_schema = to_schema(read_rel.base_schema.unwrap_or_default())?;
let retrieved_arrow_schema = retrieved_schema.arrow_schema();
ensure!(
stored_schema.fields == retrived_arrow_schema.fields,
stored_schema.fields == retrieved_arrow_schema.fields,
SchemaNotMatchSnafu {
substrait_schema: retrived_arrow_schema.clone(),
substrait_schema: retrieved_arrow_schema.clone(),
storage_schema: stored_schema
}
);
2 changes: 1 addition & 1 deletion src/common/substrait/src/error.rs
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ pub enum Error {
source: BoxedError,
},

#[snafu(display("Table quering not found: {}", name))]
#[snafu(display("Table querying not found: {}", name))]
TableNotFound { name: String, backtrace: Backtrace },

#[snafu(display("Cannot convert plan doesn't belong to GreptimeDB"))]
4 changes: 2 additions & 2 deletions src/common/substrait/src/types.rs
Original file line number Diff line number Diff line change
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! Methods that perform convertion between Substrait's type ([Type](SType)) and GreptimeDB's type ([ConcreteDataType]).
//! Methods that perform conversion between Substrait's type ([Type](SType)) and GreptimeDB's type ([ConcreteDataType]).
//!
//! Substrait use [type variation](https://substrait.io/types/type_variations/) to express different "logical types".
//! Current we only have variations on integer types. Variation 0 (system prefered) are the same with base types, which
//! Current we only have variations on integer types. Variation 0 (system preferred) are the same with base types, which
//! are signed integer (i.e. I8 -> [i8]), and Variation 1 stands for unsigned integer (i.e. I8 -> [u8]).
use datatypes::prelude::ConcreteDataType;
2 changes: 1 addition & 1 deletion src/datanode/src/server/grpc/ddl.rs
Original file line number Diff line number Diff line change
@@ -339,7 +339,7 @@ mod tests {
assert_eq!(column_schema.data_type, ConcreteDataType::string_datatype());
assert!(column_schema.is_nullable());

let default_constraint = ColumnDefaultConstraint::Value(Value::from("defaut value"));
let default_constraint = ColumnDefaultConstraint::Value(Value::from("default value"));
let column_def = ColumnDef {
name: "a".to_string(),
datatype: 12, // string
2 changes: 1 addition & 1 deletion src/datanode/src/server/grpc/plan.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@

use std::sync::Arc;

use common_grpc::{AsExcutionPlan, DefaultAsPlanImpl};
use common_grpc::{AsExecutionPlan, DefaultAsPlanImpl};
use common_query::physical_plan::{PhysicalPlanAdapter, PhysicalPlanRef};
use common_query::Output;
use datatypes::schema::Schema;
2 changes: 1 addition & 1 deletion src/datatypes/src/schema.rs
Original file line number Diff line number Diff line change
@@ -156,7 +156,7 @@ impl Schema {
/// Create a schema from a vector of [ColumnSchema].
///
/// # Panics
/// Panics when ColumnSchema's `default_constrait` can't be serialized into json.
/// Panics when ColumnSchema's `default_constraint` can't be serialized into json.
pub fn new(column_schemas: Vec<ColumnSchema>) -> Schema {
// Builder won't fail in this case
SchemaBuilder::try_from(column_schemas)
2 changes: 1 addition & 1 deletion src/datatypes/src/vectors/operations/find_unique.rs
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ pub(crate) fn find_unique_scalar<'a, T: ScalarVector>(
}
}

// Marks first element as selcted if it is different from previous element, otherwise
// Marks first element as selected if it is different from previous element, otherwise
// keep selected bitmap unchanged.
let is_first_not_duplicate = prev_vector
.map(|pv| {
16 changes: 8 additions & 8 deletions src/frontend/src/spliter.rs
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ pub struct WriteSpliter {
}

impl WriteSpliter {
pub fn with_patition_rule(rule: PartitionRuleRef<Error>) -> Self {
pub fn with_partition_rule(rule: PartitionRuleRef<Error>) -> Self {
Self {
partition_rule: rule,
}
@@ -204,7 +204,7 @@ mod tests {
fn test_writer_spliter() {
let insert = mock_insert_request();
let rule = Arc::new(MockPartitionRule) as PartitionRuleRef<Error>;
let spliter = WriteSpliter::with_patition_rule(rule);
let spliter = WriteSpliter::with_partition_rule(rule);
let ret = spliter.split(insert).unwrap();

assert_eq!(2, ret.len());
@@ -354,16 +354,16 @@ mod tests {
let vectors = vec![v1, v2];

let row_0_vals = partition_values(&vectors, 0);
let expeted: Vec<Value> = vec![true.into(), "host1".into()];
assert_eq!(expeted, row_0_vals);
let expected: Vec<Value> = vec![true.into(), "host1".into()];
assert_eq!(expected, row_0_vals);

let row_1_vals = partition_values(&vectors, 1);
let expeted: Vec<Value> = vec![false.into(), Value::Null];
assert_eq!(expeted, row_1_vals);
let expected: Vec<Value> = vec![false.into(), Value::Null];
assert_eq!(expected, row_1_vals);

let row_2_vals = partition_values(&vectors, 2);
let expeted: Vec<Value> = vec![true.into(), "host3".into()];
assert_eq!(expeted, row_2_vals);
let expected: Vec<Value> = vec![true.into(), "host3".into()];
assert_eq!(expected, row_2_vals);
}

fn mock_insert_request() -> InsertRequest {
2 changes: 1 addition & 1 deletion src/frontend/src/table.rs
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ impl Table for DistTable {
async fn insert(&self, request: InsertRequest) -> table::Result<usize> {
let partition_rule = self.find_partition_rule().await.map_err(TableError::new)?;

let spliter = WriteSpliter::with_patition_rule(partition_rule);
let spliter = WriteSpliter::with_partition_rule(partition_rule);
let inserts = spliter.split(request).map_err(TableError::new)?;
let result = match self.dist_insert(inserts).await.map_err(TableError::new)? {
client::ObjectResult::Select(_) => unreachable!(),
2 changes: 1 addition & 1 deletion src/meta-client/src/rpc/router.rs
Original file line number Diff line number Diff line change
@@ -186,7 +186,7 @@ impl TryFrom<PbTable> for Table {
let table_name = t
.table_name
.context(error::RouteInfoCorruptedSnafu {
err_msg: "table name requied",
err_msg: "table name required",
})?
.into();
Ok(Self {
2 changes: 1 addition & 1 deletion src/meta-srv/src/service/heartbeat.rs
Original file line number Diff line number Diff line change
@@ -85,7 +85,7 @@ impl heartbeat_server::Heartbeat for MetaSrv {

match tx.send(Err(err)).await {
Ok(_) => (),
Err(_err) => break, // response was droped
Err(_err) => break, // response was dropped
}
}
}
2 changes: 1 addition & 1 deletion src/script/src/engine.rs
Original file line number Diff line number Diff line change
@@ -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 {}

8 changes: 4 additions & 4 deletions src/script/src/python/builtins/mod.rs
Original file line number Diff line number Diff line change
@@ -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,15 +1120,15 @@ 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];
if let State::Separator(sep) = nxt {
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;
2 changes: 1 addition & 1 deletion src/script/src/python/builtins/test.rs
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit b6fa316

Please sign in to comment.