Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/datafuselabs/databend into …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
andylokandy committed Feb 3, 2022
2 parents a857b8e + 76e831b commit dc37597
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 54 deletions.
5 changes: 5 additions & 0 deletions common/datavalues/src/series/series_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ use common_exception::Result;
use crate::prelude::*;

#[derive(Debug, Clone)]

/// Series is a wrapper type to store pointer to real data.
/// This kind definition of `Series` style will make `Arc<dyn SeriesTrait>` as anonymous field.
pub struct Series(pub Arc<dyn SeriesTrait>);

impl<'a> AsRef<(dyn SeriesTrait + 'a)> for Series {
Expand All @@ -41,6 +44,7 @@ impl Deref for Series {
}
}

/// Various trait implementation for Type is cocked by macro in the wrap module.
pub trait IntoSeries {
fn into_series(self) -> Series;
}
Expand Down Expand Up @@ -308,6 +312,7 @@ impl Series {
}
}

/// Any Array can be converted to a Series Type.
impl IntoSeries for ArrayRef {
fn into_series(self) -> Series {
let data_type = DataType::try_from(self.data_type()).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion common/functions/tests/it/scalars/scalar_function_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn test_scalar_functions_with_type(
let mut rows_size = 0;
let mut arguments_type = Vec::with_capacity(test.columns.len());

for (_index, arg_column) in test.columns.iter().enumerate() {
for (_, arg_column) in test.columns.iter().enumerate() {
match arg_column.column() {
DataColumn::Constant(v, n) => {
rows_size = *n;
Expand Down
38 changes: 22 additions & 16 deletions docs/dev/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,34 @@ This is Databend Roadmap 2022 :rocket:

# Main tasks

### 1. Query
### 1. Query


| Task | Status | Release Target | Comments |
| ----------------------------------------------- | --------- | -------------- | --------------- |
| [Query cluster track #747](https://github.com/datafuselabs/databend/issues/747) | PROGRESS | | |
| [Query Cluster Track #747](https://github.com/datafuselabs/databend/issues/747) | PROGRESS | | |
| [RBAC Privileges #2793](https://github.com/datafuselabs/databend/issues/2793) | PROGRESS | | |
| [ New planner framework #1217](https://github.com/datafuselabs/databend/issues/1218)| PROGRESS | | [RFC](https://databend.rs/dev/rfcs/query/new-sql-planner-framework)|
| [ Database sharing #3430](https://github.com/datafuselabs/databend/issues/3430)| PROGRESS | | |
| [ New Planner Framework #1217](https://github.com/datafuselabs/databend/issues/1218)| PROGRESS | | [RFC](https://databend.rs/dev/rfcs/query/new-sql-planner-framework)|
| [ Database Sharing #3430](https://github.com/datafuselabs/databend/issues/3430)| PROGRESS | | |
| [ Stage #2976](https://github.com/datafuselabs/databend/issues/2976)| PROGRESS | | |
| Push-Based + Pull-Based processor | PROGRESS | | |
| [Index design #3711](https://github.com/datafuselabs/databend/issues/3711) | PLANNING | | |
| Limited support for transactions | PLANNING | | |
| Window functions | PLANNING | | |
| Lambda functions | PLANNING | | |
| Array functions | PLANNING | | |
| Compile aggregate functions(JIT) | PLANNING | | |


### 2. Testing
| [Index Design #3711](https://github.com/datafuselabs/databend/issues/3711) | PROGRESS | | |
| [Push-Based + Pull-Based processor](https://github.com/datafuselabs/databend/issues/3379)| PROGRESS | | |
| [Semi-structured Data Types #3916](https://github.com/datafuselabs/databend/issues/3916) | PLANNING | | |
| [Support Fulltext Index #3915](https://github.com/datafuselabs/databend/issues/3915) | PLANNING | | |
| Tansactions | PLANNING | | |
| Window Functions | PLANNING | | |
| Lambda Functions | PLANNING | | |
| Array Functions | PLANNING | | |
| Compile Aggregate Functions(JIT) | PLANNING | | |
| Common Table Expressions | PLANNING | | [MySQL CTE](https://dev.mysql.com/doc/refman/8.0/en/with.html#common-table-expressions) |
| External Cache | PLANNING | | |
| External Table | PLANNING | | [Snowflake ET](https://docs.snowflake.com/en/sql-reference/sql/create-external-table.html)|
| Update&Delete | PLANNING | | |
| Streaming Ingestion | PLANNING | | |
| Streaming Analytics | PLANNING | | |


### 2. Testing

| Task | Status | Release Target | Comments |
| ----------------------------------------------- | --------- | -------------- | --------------- |
Expand All @@ -44,8 +52,6 @@ This is Databend Roadmap 2022 :rocket:
| [ databend cli #938](https://github.com/datafuselabs/databend/issues/938) | PROGRESS | | All-in-one tool for setting up, managing with Databend |
| online playground | PROGRESS | | User can try the demo on the databend.rs website |



# Releases
- [x] #2525
- [x] #2257
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
label: 'Context Functions'
link:
type: generated-index
title: 'Context Functions'

This file was deleted.

11 changes: 11 additions & 0 deletions query/src/sessions/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::configs::Config;

#[derive(Clone, Debug, MallocSizeOf)]
pub struct SettingValue {
default_value: DataValue,
#[ignore_malloc_size_of = "insignificant"]
user_setting: UserSetting,
desc: &'static str,
Expand All @@ -42,48 +43,56 @@ impl Settings {
let values = vec![
// max_block_size
SettingValue {
default_value:DataValue::UInt64(Some(10000)),
user_setting: UserSetting::create("max_block_size", DataValue::UInt64(Some(10000))),
desc: "Maximum block size for reading",
},

// max_threads
SettingValue {
default_value:DataValue::UInt64(Some(16)),
user_setting: UserSetting::create("max_threads", DataValue::UInt64(Some(16))),
desc: "The maximum number of threads to execute the request. By default, it is determined automatically.",
},

// flight_client_timeout
SettingValue {
default_value:DataValue::UInt64(Some(60)),
user_setting: UserSetting::create("flight_client_timeout", DataValue::UInt64(Some(60))),
desc:"Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds",
},

// parallel_read_threads
SettingValue {
default_value: DataValue::UInt64(Some(1)),
user_setting: UserSetting::create("parallel_read_threads", DataValue::UInt64(Some(1))),
desc:"The maximum number of parallelism for reading data. By default, it is 1.",
},

// storage_read_buffer_size
SettingValue {
default_value: DataValue::UInt64(Some(1024*1024)),
user_setting: UserSetting::create("storage_read_buffer_size", DataValue::UInt64(Some(1024*1024))),
desc:"The size of buffer in bytes for buffered reader of dal. By default, it is 1MB.",
},

// storage_backoff_init_delay_ms
SettingValue {
default_value: DataValue::UInt64(Some(5)),
user_setting: UserSetting::create("storage_occ_backoff_init_delay_ms", DataValue::UInt64(Some(5))),
desc:"The initial retry delay in millisecond. By default, it is 5 ms.",
},

// storage_occ_backoff_max_delay_ms
SettingValue {
default_value:DataValue::UInt64(Some(20*1000)),
user_setting: UserSetting::create("storage_occ_backoff_max_delay_ms", DataValue::UInt64(Some(20*1000))),
desc:"The maximum back off delay in millisecond, once the retry interval reaches this value, it stops increasing. By default, it is 20 seconds.",
},

// storage_occ_backoff_max_elapsed_ms
SettingValue {
default_value:DataValue::UInt64(Some(120*1000)),
user_setting: UserSetting::create("storage_occ_backoff_max_elapsed_ms", DataValue::UInt64(Some(120*1000))),
desc:"The maximum elapsed time after the occ starts, beyond which there will be no more retries. By default, it is 2 minutes.",
},
Expand Down Expand Up @@ -244,6 +253,8 @@ impl Settings {
DataValue::String(Some(k.as_bytes().to_vec())),
// Value.
v.user_setting.value.clone(),
// Default Value.
v.default_value.clone(),
// Desc.
DataValue::String(Some(v.desc.as_bytes().to_vec())),
]);
Expand Down
11 changes: 5 additions & 6 deletions query/src/sql/statements/analyzer_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl ExpressionAnalyzer {
pub async fn analyze(&self, expr: &Expr) -> Result<Expression> {
let mut stack = Vec::new();

// Build RPN for expr. because async function unsupported recursion
// Build RPN for expr. Because async function unsupported recursion
for rpn_item in &ExprRPNBuilder::build(self.context.clone(), expr).await? {
match rpn_item {
ExprRPNItem::Value(v) => Self::analyze_value(v, &mut stack)?,
Expand Down Expand Up @@ -97,7 +97,7 @@ impl ExpressionAnalyzer {

fn analyze_inlist(&self, info: &InListInfo, args: &mut Vec<Expression>) -> Result<()> {
let mut list = Vec::with_capacity(info.list_size);
for _index in 0..info.list_size {
for _ in 0..info.list_size {
match args.pop() {
None => {
return Err(ErrorCode::LogicalError("It's a bug."));
Expand Down Expand Up @@ -125,7 +125,7 @@ impl ExpressionAnalyzer {

fn analyze_function(&self, info: &FunctionExprInfo, args: &mut Vec<Expression>) -> Result<()> {
let mut arguments = Vec::with_capacity(info.args_count);
for _index in 0..info.args_count {
for _ in 0..info.args_count {
match args.pop() {
None => {
return Err(ErrorCode::LogicalError("It's a bug."));
Expand All @@ -151,9 +151,7 @@ impl ExpressionAnalyzer {

fn unary_function(info: &FunctionExprInfo, args: &[Expression]) -> Result<Expression> {
match args.is_empty() {
true => Err(ErrorCode::LogicalError(
"Unary operator must be two children.",
)),
true => Err(ErrorCode::LogicalError("Unary operator must be one child.")),
false => Ok(Expression::UnaryExpression {
op: info.name.clone(),
expr: Box::new(args[0].to_owned()),
Expand All @@ -175,6 +173,7 @@ impl ExpressionAnalyzer {
}
}

/// Function to process when args's size is more than 2.
fn other_function(&self, info: &FunctionExprInfo, args: &[Expression]) -> Result<Expression> {
let query_context = self.context.clone();
let context_args = ContextFunction::build_args_from_ctx(&info.name, query_context)?;
Expand Down
3 changes: 2 additions & 1 deletion query/src/sql/statements/statement_show_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ pub struct DfShowSettings;
impl AnalyzableStatement for DfShowSettings {
#[tracing::instrument(level = "debug", skip(self, ctx), fields(ctx.id = ctx.get_id().as_str()))]
async fn analyze(&self, ctx: Arc<QueryContext>) -> Result<AnalyzedResult> {
let rewritten_query = "SELECT name, value FROM system.settings ORDER BY name";
let rewritten_query =
"SELECT name, value, default, description, type FROM system.settings ORDER BY name";
let rewritten_query_plan = PlanParser::parse(rewritten_query, ctx);
Ok(AnalyzedResult::SimpleQuery(Box::new(
rewritten_query_plan.await?,
Expand Down
17 changes: 16 additions & 1 deletion query/src/storages/system/settings_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ impl SettingsTable {
let schema = DataSchemaRefExt::create(vec![
DataField::new("name", DataType::String, false),
DataField::new("value", DataType::String, false),
DataField::new("default", DataType::String, false),
DataField::new("description", DataType::String, false),
DataField::new("type", DataType::String, false),
]);

let table_info = TableInfo {
Expand Down Expand Up @@ -75,22 +77,35 @@ impl Table for SettingsTable {

let mut names: Vec<String> = vec![];
let mut values: Vec<String> = vec![];
let mut defaults: Vec<String> = vec![];
let mut descs: Vec<String> = vec![];
let mut types: Vec<String> = vec![];
for setting in settings {
if let DataValue::Struct(vals) = setting {
// Name.
names.push(format!("{:?}", vals[0]));
// Value.
values.push(format!("{:?}", vals[1]));
descs.push(format!("{:?}", vals[2]));
// Default Value.
defaults.push(format!("{:?}", vals[2]));
// Desc.
descs.push(format!("{:?}", vals[3]));
// Types.
types.push(format!("{:?}", vals[2].data_type()));
}
}

let names: Vec<&[u8]> = names.iter().map(|x| x.as_bytes()).collect();
let values: Vec<&[u8]> = values.iter().map(|x| x.as_bytes()).collect();
let defaults: Vec<&[u8]> = defaults.iter().map(|x| x.as_bytes()).collect();
let descs: Vec<&[u8]> = descs.iter().map(|x| x.as_bytes()).collect();
let types: Vec<&[u8]> = types.iter().map(|x| x.as_bytes()).collect();
let block = DataBlock::create_by_array(self.table_info.schema(), vec![
Series::new(names),
Series::new(values),
Series::new(defaults),
Series::new(descs),
Series::new(types),
]);
Ok(Box::pin(DataBlockStream::create(
self.table_info.schema(),
Expand Down
29 changes: 12 additions & 17 deletions query/tests/it/storages/system/settings_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use databend_query::storages::system::SettingsTable;
use databend_query::storages::Table;
use databend_query::storages::ToReadDataSourcePlan;
use futures::TryStreamExt;
use pretty_assertions::assert_eq;

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
async fn test_settings_table() -> Result<()> {
Expand All @@ -32,24 +31,20 @@ async fn test_settings_table() -> Result<()> {

let stream = table.read(ctx, &source_plan).await?;
let result = stream.try_collect::<Vec<_>>().await?;
let block = &result[0];
assert_eq!(block.num_columns(), 3);

let expected = vec![
"+------------------------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------+",
"| name | value | description |",
"+------------------------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------+",
"| flight_client_timeout | 60 | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds |",
"| max_block_size | 10000 | Maximum block size for reading |",
"| storage_occ_backoff_init_delay_ms | 5 | The initial retry delay in millisecond. By default, it is 5 ms. |",
"| max_threads | 2 | The maximum number of threads to execute the request. By default, it is determined automatically. |",
"| storage_read_buffer_size | 1048576 | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. |",
"| storage_occ_backoff_max_delay_ms | 20000 | The maximum back off delay in millisecond, once the retry interval reaches this value, it stops increasing. By default, it is 20 seconds. |",
"| storage_occ_backoff_max_elapsed_ms | 120000 | The maximum elapsed time after the occ starts, beyond which there will be no more retries. By default, it is 2 minutes. |",
"| parallel_read_threads | 1 | The maximum number of parallelism for reading data. By default, it is 1. |",
"+------------------------------------+---------+--------------------------------------------------------------------------------------------------------------------------------------------+",


"+------------------------------------+---------+---------+--------------------------------------------------------------------------------------------------------------------------------------------+--------+",
"| name | value | default | description | type |",
"+------------------------------------+---------+---------+--------------------------------------------------------------------------------------------------------------------------------------------+--------+",
"| flight_client_timeout | 60 | 60 | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds | UInt64 |",
"| max_block_size | 10000 | 10000 | Maximum block size for reading | UInt64 |",
"| max_threads | 2 | 16 | The maximum number of threads to execute the request. By default, it is determined automatically. | UInt64 |",
"| parallel_read_threads | 1 | 1 | The maximum number of parallelism for reading data. By default, it is 1. | UInt64 |",
"| storage_occ_backoff_init_delay_ms | 5 | 5 | The initial retry delay in millisecond. By default, it is 5 ms. | UInt64 |",
"| storage_occ_backoff_max_delay_ms | 20000 | 20000 | The maximum back off delay in millisecond, once the retry interval reaches this value, it stops increasing. By default, it is 20 seconds. | UInt64 |",
"| storage_occ_backoff_max_elapsed_ms | 120000 | 120000 | The maximum elapsed time after the occ starts, beyond which there will be no more retries. By default, it is 2 minutes. | UInt64 |",
"| storage_read_buffer_size | 1048576 | 1048576 | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. | UInt64 |",
"+------------------------------------+---------+---------+--------------------------------------------------------------------------------------------------------------------------------------------+--------+",
];
common_datablocks::assert_blocks_sorted_eq(expected, result.as_slice());

Expand Down

0 comments on commit dc37597

Please sign in to comment.