diff --git a/docs/doc/14-sql-commands/40-show/show-settings.md b/docs/doc/14-sql-commands/40-show/show-settings.md index 68e6d11a63a1d..92cf84864d4ba 100644 --- a/docs/doc/14-sql-commands/40-show/show-settings.md +++ b/docs/doc/14-sql-commands/40-show/show-settings.md @@ -16,39 +16,40 @@ SHOW SETTINGS ```sql SHOW SETTINGS; -+---------------------------------+-------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ -| name | value | default | level | description | type | -+---------------------------------+-------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ -| collation | binary | binary | SESSION | Char collation, support "binary" "utf8" default value: binary | String | -| enable_async_insert | 0 | 0 | SESSION | Whether the client open async insert mode, default value: 0. | UInt64 | -| enable_cbo | 1 | 1 | SESSION | If enable cost based optimization, default value: 1. | UInt64 | -| enable_distributed_eval_index | 1 | 1 | SESSION | If enable distributed eval index, default value: 1 | UInt64 | -| enable_new_processor_framework | 1 | 1 | SESSION | Enable new processor framework if value != 0, default value: 1. | UInt64 | -| enable_planner_v2 | 1 | 1 | SESSION | Enable planner v2 by setting this variable to 1, default value: 1. | UInt64 | -| flight_client_timeout | 60 | 60 | SESSION | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds. | UInt64 | -| format_compression | None | None | SESSION | Format compression, default value: "None". | String | -| format_empty_as_default | 1 | 1 | SESSION | Format empty_as_default, default value: 1. | UInt64 | -| format_escape | | | SESSION | format escape char, default value: "", which means the format`s default setting. | String | -| format_field_delimiter | | | SESSION | Format field delimiter, default value is "": use default of the format. | String | -| format_quote | | | SESSION | The quote char for format. default value is "": use default of the format. | String | -| format_record_delimiter | | | SESSION | Format record_delimiter, default value is "": use default of the format. | String | -| format_skip_header | 0 | 0 | SESSION | Whether to skip the input header, default value: 0. | UInt64 | -| group_by_two_level_threshold | 10000 | 10000 | SESSION | The threshold of keys to open two-level aggregation, default value: 10000. | UInt64 | -| input_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for input with format. By default, it is 1MB. | UInt64 | -| load_file_metadata_expire_hours | 168 | 168 | SESSION | How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days | UInt64 | -| max_block_size | 65536 | 65536 | SESSION | Maximum block size for reading, default value: 65536. | UInt64 | -| max_execute_time | 0 | 0 | SESSION | The maximum query execution time. it means no limit if the value is zero. default value: 0. | UInt64 | -| max_memory_usage | 26771259392 | 26771259392 | SESSION | The maximum memory usage for processing single query, in bytes. By default the value is determined automatically. | UInt64 | -| max_storage_io_requests | 1000 | 1000 | SESSION | The maximum number of concurrent IO requests. By default, it is 1000. | UInt64 | -| max_threads | 24 | 24 | SESSION | The maximum number of threads to execute the request. By default the value is determined automatically. | UInt64 | -| prefer_broadcast_join | 0 | 0 | SESSION | If enable broadcast join, default value: 0 | UInt64 | -| quoted_ident_case_sensitive | 1 | 1 | SESSION | Case sensitivity of quoted identifiers, default value: 1 (aka case-sensitive). | UInt64 | -| row_tag | row | row | SESSION | In xml format, this field is represented as a row tag, e.g. .... | String | -| sql_dialect | PostgreSQL | PostgreSQL | SESSION | SQL dialect, support "PostgreSQL" "MySQL" and "Hive", default value: "PostgreSQL". | String | -| storage_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. | UInt64 | -| timezone | UTC | UTC | SESSION | Timezone, default value: "UTC". | String | -| unquoted_ident_case_sensitive | 0 | 0 | SESSION | Case sensitivity of unquoted identifiers, default value: 0 (aka case-insensitive). | UInt64 | -| wait_for_async_insert | 1 | 1 | SESSION | Whether the client wait for the reply of async insert, default value: 1. | UInt64 | -| wait_for_async_insert_timeout | 100 | 100 | SESSION | The timeout in seconds for waiting for processing of async insert, default value: 100. | UInt64 | -+---------------------------------+-------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ ++---------------------------------+-------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ +| name | value | default | level | description | type | ++---------------------------------+-------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ +| collation | binary | binary | SESSION | Char collation, support "binary" "utf8" default value: binary | String | +| enable_async_insert | 0 | 0 | SESSION | Whether the client open async insert mode, default value: 0. | UInt64 | +| enable_cbo | 1 | 1 | SESSION | If enable cost based optimization, default value: 1. | UInt64 | +| enable_distributed_eval_index | 1 | 1 | SESSION | If enable distributed eval index, default value: 1 | UInt64 | +| enable_new_processor_framework | 1 | 1 | SESSION | Enable new processor framework if value != 0, default value: 1. | UInt64 | +| enable_planner_v2 | 1 | 1 | SESSION | Enable planner v2 by setting this variable to 1, default value: 1. | UInt64 | +| flight_client_timeout | 60 | 60 | SESSION | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds. | UInt64 | +| format_compression | None | None | SESSION | Format compression, default value: "None". | String | +| format_empty_as_default | 1 | 1 | SESSION | Format empty_as_default, default value: 1. | UInt64 | +| format_escape | | | SESSION | format escape char, default value: "", which means the format`s default setting. | String | +| format_field_delimiter | | | SESSION | Format field delimiter, default value is "": use default of the format. | String | +| format_quote | | | SESSION | The quote char for format. default value is "": use default of the format. | String | +| format_record_delimiter | | | SESSION | Format record_delimiter, default value is "": use default of the format. | String | +| format_skip_header | 0 | 0 | SESSION | Whether to skip the input header, default value: 0. | UInt64 | +| group_by_two_level_threshold | 10000 | 10000 | SESSION | The threshold of keys to open two-level aggregation, default value: 10000. | UInt64 | +| input_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for input with format. By default, it is 1MB. | UInt64 | +| insert_values_enable_expression | 1 | 1 | GLOBAL | Whether to enable expression when inserting values, if your values do not have expressions please disable this setting to improve write performance, default value: 1. | UInt64 | +| load_file_metadata_expire_hours | 168 | 168 | SESSION | How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days | UInt64 | +| max_block_size | 65536 | 65536 | SESSION | Maximum block size for reading, default value: 65536. | UInt64 | +| max_execute_time | 0 | 0 | SESSION | The maximum query execution time. it means no limit if the value is zero. default value: 0. | UInt64 | +| max_memory_usage | 26771259392 | 26771259392 | SESSION | The maximum memory usage for processing single query, in bytes. By default the value is determined automatically. | UInt64 | +| max_storage_io_requests | 1000 | 1000 | SESSION | The maximum number of concurrent IO requests. By default, it is 1000. | UInt64 | +| max_threads | 24 | 24 | SESSION | The maximum number of threads to execute the request. By default the value is determined automatically. | UInt64 | +| prefer_broadcast_join | 0 | 0 | SESSION | If enable broadcast join, default value: 0 | UInt64 | +| quoted_ident_case_sensitive | 1 | 1 | SESSION | Case sensitivity of quoted identifiers, default value: 1 (aka case-sensitive). | UInt64 | +| row_tag | row | row | SESSION | In xml format, this field is represented as a row tag, e.g. .... | String | +| sql_dialect | PostgreSQL | PostgreSQL | SESSION | SQL dialect, support "PostgreSQL" "MySQL" and "Hive", default value: "PostgreSQL". | String | +| storage_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. | UInt64 | +| timezone | UTC | UTC | SESSION | Timezone, default value: "UTC". | String | +| unquoted_ident_case_sensitive | 0 | 0 | SESSION | Case sensitivity of unquoted identifiers, default value: 0 (aka case-insensitive). | UInt64 | +| wait_for_async_insert | 1 | 1 | SESSION | Whether the client wait for the reply of async insert, default value: 1. | UInt64 | +| wait_for_async_insert_timeout | 100 | 100 | SESSION | The timeout in seconds for waiting for processing of async insert, default value: 100. | UInt64 | ++---------------------------------+-------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ ``` diff --git a/docs/doc/14-sql-commands/80-setting-cmds/show-settings.md b/docs/doc/14-sql-commands/80-setting-cmds/show-settings.md index 006c7eead7787..be001dbb03a28 100644 --- a/docs/doc/14-sql-commands/80-setting-cmds/show-settings.md +++ b/docs/doc/14-sql-commands/80-setting-cmds/show-settings.md @@ -15,40 +15,41 @@ SHOW SETTINGS; ```sql SHOW SETTINGS; -+---------------------------------+-------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ -| name | value | default | level | description | type | -+---------------------------------+-------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ -| collation | binary | binary | SESSION | Char collation, support "binary" "utf8" default value: binary | String | -| enable_async_insert | 0 | 0 | SESSION | Whether the client open async insert mode, default value: 0. | UInt64 | -| enable_cbo | 1 | 1 | SESSION | If enable cost based optimization, default value: 1. | UInt64 | -| enable_distributed_eval_index | 1 | 1 | SESSION | If enable distributed eval index, default value: 1 | UInt64 | -| enable_new_processor_framework | 1 | 1 | SESSION | Enable new processor framework if value != 0, default value: 1. | UInt64 | -| enable_planner_v2 | 1 | 1 | SESSION | Enable planner v2 by setting this variable to 1, default value: 1. | UInt64 | -| flight_client_timeout | 60 | 60 | SESSION | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds. | UInt64 | -| format_compression | None | None | SESSION | Format compression, default value: "None". | String | -| format_empty_as_default | 1 | 1 | SESSION | Format empty_as_default, default value: 1. | UInt64 | -| format_escape | | | SESSION | format escape char, default value: "", which means the format`s default setting. | String | -| format_field_delimiter | | | SESSION | Format field delimiter, default value is "": use default of the format. | String | -| format_quote | | | SESSION | The quote char for format. default value is "": use default of the format. | String | -| format_record_delimiter | | | SESSION | Format record_delimiter, default value is "": use default of the format. | String | -| format_skip_header | 0 | 0 | SESSION | Whether to skip the input header, default value: 0. | UInt64 | -| group_by_two_level_threshold | 10000 | 10000 | SESSION | The threshold of keys to open two-level aggregation, default value: 10000. | UInt64 | -| input_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for input with format. By default, it is 1MB. | UInt64 | -| load_file_metadata_expire_hours | 168 | 168 | SESSION | How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days | UInt64 | -| max_block_size | 65536 | 65536 | SESSION | Maximum block size for reading, default value: 65536. | UInt64 | -| max_execute_time | 0 | 0 | SESSION | The maximum query execution time. it means no limit if the value is zero. default value: 0. | UInt64 | -| max_memory_usage | 26771259392 | 26771259392 | SESSION | The maximum memory usage for processing single query, in bytes. By default the value is determined automatically. | UInt64 | -| max_storage_io_requests | 1000 | 1000 | SESSION | The maximum number of concurrent IO requests. By default, it is 1000. | UInt64 | -| max_threads | 24 | 24 | SESSION | The maximum number of threads to execute the request. By default the value is determined automatically. | UInt64 | -| prefer_broadcast_join | 0 | 0 | SESSION | If enable broadcast join, default value: 0 | UInt64 | -| quoted_ident_case_sensitive | 1 | 1 | SESSION | Case sensitivity of quoted identifiers, default value: 1 (aka case-sensitive). | UInt64 | -| row_tag | row | row | SESSION | In xml format, this field is represented as a row tag, e.g. .... | String | -| sql_dialect | PostgreSQL | PostgreSQL | SESSION | SQL dialect, support "PostgreSQL" "MySQL" and "Hive", default value: "PostgreSQL". | String | -| storage_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. | UInt64 | -| timezone | UTC | UTC | SESSION | Timezone, default value: "UTC". | String | -| unquoted_ident_case_sensitive | 0 | 0 | SESSION | Case sensitivity of unquoted identifiers, default value: 0 (aka case-insensitive). | UInt64 | -| wait_for_async_insert | 1 | 1 | SESSION | Whether the client wait for the reply of async insert, default value: 1. | UInt64 | -| wait_for_async_insert_timeout | 100 | 100 | SESSION | The timeout in seconds for waiting for processing of async insert, default value: 100. | UInt64 | -+---------------------------------+-------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ ++---------------------------------+-------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ +| name | value | default | level | description | type | ++---------------------------------+-------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ +| collation | binary | binary | SESSION | Char collation, support "binary" "utf8" default value: binary | String | +| enable_async_insert | 0 | 0 | SESSION | Whether the client open async insert mode, default value: 0. | UInt64 | +| enable_cbo | 1 | 1 | SESSION | If enable cost based optimization, default value: 1. | UInt64 | +| enable_distributed_eval_index | 1 | 1 | SESSION | If enable distributed eval index, default value: 1 | UInt64 | +| enable_new_processor_framework | 1 | 1 | SESSION | Enable new processor framework if value != 0, default value: 1. | UInt64 | +| enable_planner_v2 | 1 | 1 | SESSION | Enable planner v2 by setting this variable to 1, default value: 1. | UInt64 | +| flight_client_timeout | 60 | 60 | SESSION | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds. | UInt64 | +| format_compression | None | None | SESSION | Format compression, default value: "None". | String | +| format_empty_as_default | 1 | 1 | SESSION | Format empty_as_default, default value: 1. | UInt64 | +| format_escape | | | SESSION | format escape char, default value: "", which means the format`s default setting. | String | +| format_field_delimiter | | | SESSION | Format field delimiter, default value is "": use default of the format. | String | +| format_quote | | | SESSION | The quote char for format. default value is "": use default of the format. | String | +| format_record_delimiter | | | SESSION | Format record_delimiter, default value is "": use default of the format. | String | +| format_skip_header | 0 | 0 | SESSION | Whether to skip the input header, default value: 0. | UInt64 | +| group_by_two_level_threshold | 10000 | 10000 | SESSION | The threshold of keys to open two-level aggregation, default value: 10000. | UInt64 | +| input_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for input with format. By default, it is 1MB. | UInt64 | +| insert_values_enable_expression | 1 | 1 | GLOBAL | Whether to enable expression when inserting values, if your values do not have expressions please disable this setting to improve write performance, default value: 1. | UInt64 | +| load_file_metadata_expire_hours | 168 | 168 | SESSION | How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days | UInt64 | +| max_block_size | 65536 | 65536 | SESSION | Maximum block size for reading, default value: 65536. | UInt64 | +| max_execute_time | 0 | 0 | SESSION | The maximum query execution time. it means no limit if the value is zero. default value: 0. | UInt64 | +| max_memory_usage | 26771259392 | 26771259392 | SESSION | The maximum memory usage for processing single query, in bytes. By default the value is determined automatically. | UInt64 | +| max_storage_io_requests | 1000 | 1000 | SESSION | The maximum number of concurrent IO requests. By default, it is 1000. | UInt64 | +| max_threads | 24 | 24 | SESSION | The maximum number of threads to execute the request. By default the value is determined automatically. | UInt64 | +| prefer_broadcast_join | 0 | 0 | SESSION | If enable broadcast join, default value: 0 | UInt64 | +| quoted_ident_case_sensitive | 1 | 1 | SESSION | Case sensitivity of quoted identifiers, default value: 1 (aka case-sensitive). | UInt64 | +| row_tag | row | row | SESSION | In xml format, this field is represented as a row tag, e.g. .... | String | +| sql_dialect | PostgreSQL | PostgreSQL | SESSION | SQL dialect, support "PostgreSQL" "MySQL" and "Hive", default value: "PostgreSQL". | String | +| storage_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. | UInt64 | +| timezone | UTC | UTC | SESSION | Timezone, default value: "UTC". | String | +| unquoted_ident_case_sensitive | 0 | 0 | SESSION | Case sensitivity of unquoted identifiers, default value: 0 (aka case-insensitive). | UInt64 | +| wait_for_async_insert | 1 | 1 | SESSION | Whether the client wait for the reply of async insert, default value: 1. | UInt64 | +| wait_for_async_insert_timeout | 100 | 100 | SESSION | The timeout in seconds for waiting for processing of async insert, default value: 100. | UInt64 | ++---------------------------------+-------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ ``` \ No newline at end of file diff --git a/src/query/service/src/interpreters/interpreter_insert_v2.rs b/src/query/service/src/interpreters/interpreter_insert_v2.rs index f7f663eda8ccb..d36000bdaeb7c 100644 --- a/src/query/service/src/interpreters/interpreter_insert_v2.rs +++ b/src/query/service/src/interpreters/interpreter_insert_v2.rs @@ -34,6 +34,8 @@ use common_io::cursor_ext::ReadBytesExt; use common_io::cursor_ext::ReadCheckPointExt; use common_pipeline_sources::processors::sources::AsyncSource; use common_pipeline_sources::processors::sources::AsyncSourcer; +use common_pipeline_sources::processors::sources::SyncSource; +use common_pipeline_sources::processors::sources::SyncSourcer; use common_pipeline_transforms::processors::transforms::Transform; use common_sql::evaluator::ChunkOperator; use common_sql::evaluator::CompoundChunkOperator; @@ -138,7 +140,13 @@ impl Interpreter for InsertInterpreterV2 { name_resolution_ctx, plan.schema(), ); - AsyncSourcer::create(self.ctx.clone(), output, inner) + let enable_expression = + settings.get_insert_values_enable_expression()?; + if enable_expression == 0 { + SyncSourcer::create(self.ctx.clone(), output, inner) + } else { + AsyncSourcer::create(self.ctx.clone(), output, inner) + } }, 1, )?; @@ -279,6 +287,20 @@ impl AsyncSource for ValueSource { } } +impl SyncSource for ValueSource { + const NAME: &'static str = "ValueSource"; + + fn generate(&mut self) -> Result> { + if self.is_finished { + return Ok(None); + } + let mut reader = Cursor::new(self.data.as_bytes()); + let block = self.sync_read(&mut reader)?; + self.is_finished = true; + Ok(Some(block)) + } +} + impl ValueSource { pub fn new( data: String, @@ -347,6 +369,45 @@ impl ValueSource { Ok(DataBlock::create(self.schema.clone(), columns)) } + pub fn sync_read>(&self, reader: &mut Cursor) -> Result { + let mut desers = self + .schema + .fields() + .iter() + .map(|f| f.data_type().create_deserializer(1024)) + .collect::>(); + + let col_size = desers.len(); + let mut rows = 0; + let timezone = parse_timezone(&self.ctx.get_settings())?; + let field_decoder = FieldDecoderValues::create_for_insert(timezone); + + loop { + let _ = reader.ignore_white_spaces(); + if reader.eof() { + break; + } + // Not the first row + if rows != 0 { + reader.must_ignore_byte(b',')?; + } + + self.parse_next_row_values(&field_decoder, reader, col_size, &mut desers)?; + rows += 1; + } + + if rows == 0 { + return Ok(DataBlock::empty_with_schema(self.schema.clone())); + } + + let columns = desers + .iter_mut() + .map(|deser| deser.finish_to_column()) + .collect::>(); + + Ok(DataBlock::create(self.schema.clone(), columns)) + } + /// Parse single row value, like ('111', 222, 1 + 1) async fn parse_next_row>( &self, @@ -373,7 +434,7 @@ impl ValueSource { let deser = desers .get_mut(col_idx) - .ok_or_else(|| ErrorCode::BadBytes("Deserializer is None"))?; + .ok_or_else(|| ErrorCode::Internal("Deserializer is None"))?; let (need_fallback, pop_count) = field_decoder .read_field(deser, reader, false) @@ -425,6 +486,39 @@ impl ValueSource { Ok(()) } + + /// Parse single row values. + /// If the value is an expression, an Error will occur. + fn parse_next_row_values>( + &self, + field_decoder: &FieldDecoderValues, + reader: &mut Cursor, + col_size: usize, + desers: &mut [TypeDeserializerImpl], + ) -> Result<()> { + let _ = reader.ignore_white_spaces(); + + // Start of the row --- '(' + if !reader.ignore_byte(b'(') { + return Err(ErrorCode::BadDataValueType( + "Must start with parentheses".to_string(), + )); + } + for col_idx in 0..col_size { + let _ = reader.ignore_white_spaces(); + let deser = desers + .get_mut(col_idx) + .ok_or_else(|| ErrorCode::Internal("Deserializer is None"))?; + + field_decoder.read_field(deser, reader, false)?; + + let _ = reader.ignore_white_spaces(); + let col_end = if col_idx + 1 == col_size { b')' } else { b',' }; + reader.must_ignore_byte(col_end)?; + } + + Ok(()) + } } // Values |(xxx), (yyy), (zzz) diff --git a/src/query/service/tests/it/storages/testdata/system-tables.txt b/src/query/service/tests/it/storages/testdata/system-tables.txt index dbce79969d5f8..b43a5fd7f5e13 100644 --- a/src/query/service/tests/it/storages/testdata/system-tables.txt +++ b/src/query/service/tests/it/storages/testdata/system-tables.txt @@ -324,40 +324,41 @@ DB.Table: 'system'.'roles', Table: roles-table_id:1, ver:0, Engine: SystemRoles ---------- TABLE INFO ------------ DB.Table: 'system'.'settings', Table: settings-table_id:1, ver:0, Engine: SystemSettings -------- TABLE CONTENTS ---------- -+---------------------------------+------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ -| name | value | default | level | description | type | -+---------------------------------+------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ -| collation | binary | binary | SESSION | Char collation, support "binary" "utf8" default value: binary | String | -| enable_async_insert | 0 | 0 | SESSION | Whether the client open async insert mode, default value: 0. | UInt64 | -| enable_cbo | 1 | 1 | SESSION | If enable cost based optimization, default value: 1. | UInt64 | -| enable_distributed_eval_index | 1 | 1 | SESSION | If enable distributed eval index, default value: 1 | UInt64 | -| enable_new_processor_framework | 1 | 1 | SESSION | Enable new processor framework if value != 0, default value: 1. | UInt64 | -| enable_planner_v2 | 1 | 1 | SESSION | Enable planner v2 by setting this variable to 1, default value: 1. | UInt64 | -| flight_client_timeout | 60 | 60 | SESSION | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds. | UInt64 | -| format_compression | None | None | SESSION | Format compression, default value: "None". | String | -| format_empty_as_default | 1 | 1 | SESSION | Format empty_as_default, default value: 1. | UInt64 | -| format_escape | | | SESSION | format escape char, default value: "", which means the format`s default setting. | String | -| format_field_delimiter | | | SESSION | Format field delimiter, default value is "": use default of the format. | String | -| format_nan_display | | | SESSION | must be literal `nan` or `null` (case-sensitive), default value is "". | String | -| format_quote | | | SESSION | The quote char for format. default value is "": use default of the format. | String | -| format_record_delimiter | | | SESSION | Format record_delimiter, default value is "": use default of the format. | String | -| format_skip_header | 0 | 0 | SESSION | Whether to skip the input header, default value: 0. | UInt64 | -| group_by_two_level_threshold | 10000 | 10000 | SESSION | The threshold of keys to open two-level aggregation, default value: 10000. | UInt64 | -| input_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for input with format. By default, it is 1MB. | UInt64 | -| load_file_metadata_expire_hours | 168 | 168 | SESSION | How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days | UInt64 | -| max_block_size | 65536 | 65536 | SESSION | Maximum block size for reading, default value: 65536. | UInt64 | -| max_execute_time | 0 | 0 | SESSION | The maximum query execution time. it means no limit if the value is zero. default value: 0. | UInt64 | -| max_storage_io_requests | 1000 | 1000 | SESSION | The maximum number of concurrent IO requests. By default, it is 1000. | UInt64 | -| prefer_broadcast_join | 0 | 0 | SESSION | If enable broadcast join, default value: 0 | UInt64 | -| quoted_ident_case_sensitive | 1 | 1 | SESSION | Case sensitivity of quoted identifiers, default value: 1 (aka case-sensitive). | UInt64 | -| row_tag | row | row | SESSION | In xml format, this field is represented as a row tag, e.g. .... | String | -| sql_dialect | PostgreSQL | PostgreSQL | SESSION | SQL dialect, support "PostgreSQL" "MySQL" and "Hive", default value: "PostgreSQL". | String | -| storage_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. | UInt64 | -| timezone | UTC | UTC | SESSION | Timezone, default value: "UTC". | String | -| unquoted_ident_case_sensitive | 0 | 0 | SESSION | Case sensitivity of unquoted identifiers, default value: 0 (aka case-insensitive). | UInt64 | -| wait_for_async_insert | 1 | 1 | SESSION | Whether the client wait for the reply of async insert, default value: 1. | UInt64 | -| wait_for_async_insert_timeout | 100 | 100 | SESSION | The timeout in seconds for waiting for processing of async insert, default value: 100. | UInt64 | -+---------------------------------+------------+-------------+---------+-------------------------------------------------------------------------------------------------------------------+--------+ ++---------------------------------+------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ +| name | value | default | level | description | type | ++---------------------------------+------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ +| collation | binary | binary | SESSION | Char collation, support "binary" "utf8" default value: binary | String | +| enable_async_insert | 0 | 0 | SESSION | Whether the client open async insert mode, default value: 0. | UInt64 | +| enable_cbo | 1 | 1 | SESSION | If enable cost based optimization, default value: 1. | UInt64 | +| enable_distributed_eval_index | 1 | 1 | SESSION | If enable distributed eval index, default value: 1 | UInt64 | +| enable_new_processor_framework | 1 | 1 | SESSION | Enable new processor framework if value != 0, default value: 1. | UInt64 | +| enable_planner_v2 | 1 | 1 | SESSION | Enable planner v2 by setting this variable to 1, default value: 1. | UInt64 | +| flight_client_timeout | 60 | 60 | SESSION | Max duration the flight client request is allowed to take in seconds. By default, it is 60 seconds. | UInt64 | +| format_compression | None | None | SESSION | Format compression, default value: "None". | String | +| format_empty_as_default | 1 | 1 | SESSION | Format empty_as_default, default value: 1. | UInt64 | +| format_escape | | | SESSION | format escape char, default value: "", which means the format`s default setting. | String | +| format_field_delimiter | | | SESSION | Format field delimiter, default value is "": use default of the format. | String | +| format_nan_display | | | SESSION | must be literal `nan` or `null` (case-sensitive), default value is "". | String | +| format_quote | | | SESSION | The quote char for format. default value is "": use default of the format. | String | +| format_record_delimiter | | | SESSION | Format record_delimiter, default value is "": use default of the format. | String | +| format_skip_header | 0 | 0 | SESSION | Whether to skip the input header, default value: 0. | UInt64 | +| group_by_two_level_threshold | 10000 | 10000 | SESSION | The threshold of keys to open two-level aggregation, default value: 10000. | UInt64 | +| input_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for input with format. By default, it is 1MB. | UInt64 | +| insert_values_enable_expression | 1 | 1 | SESSION | Whether to enable expression when inserting values, if your values do not have expressions please disable this setting to improve write performance, default value: 1. | UInt64 | +| load_file_metadata_expire_hours | 168 | 168 | SESSION | How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days | UInt64 | +| max_block_size | 65536 | 65536 | SESSION | Maximum block size for reading, default value: 65536. | UInt64 | +| max_execute_time | 0 | 0 | SESSION | The maximum query execution time. it means no limit if the value is zero. default value: 0. | UInt64 | +| max_storage_io_requests | 1000 | 1000 | SESSION | The maximum number of concurrent IO requests. By default, it is 1000. | UInt64 | +| prefer_broadcast_join | 0 | 0 | SESSION | If enable broadcast join, default value: 0 | UInt64 | +| quoted_ident_case_sensitive | 1 | 1 | SESSION | Case sensitivity of quoted identifiers, default value: 1 (aka case-sensitive). | UInt64 | +| row_tag | row | row | SESSION | In xml format, this field is represented as a row tag, e.g. .... | String | +| sql_dialect | PostgreSQL | PostgreSQL | SESSION | SQL dialect, support "PostgreSQL" "MySQL" and "Hive", default value: "PostgreSQL". | String | +| storage_read_buffer_size | 1048576 | 1048576 | SESSION | The size of buffer in bytes for buffered reader of dal. By default, it is 1MB. | UInt64 | +| timezone | UTC | UTC | SESSION | Timezone, default value: "UTC". | String | +| unquoted_ident_case_sensitive | 0 | 0 | SESSION | Case sensitivity of unquoted identifiers, default value: 0 (aka case-insensitive). | UInt64 | +| wait_for_async_insert | 1 | 1 | SESSION | Whether the client wait for the reply of async insert, default value: 1. | UInt64 | +| wait_for_async_insert_timeout | 100 | 100 | SESSION | The timeout in seconds for waiting for processing of async insert, default value: 100. | UInt64 | ++---------------------------------+------------+-------------+---------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------+ ---------- TABLE INFO ------------ diff --git a/src/query/settings/src/lib.rs b/src/query/settings/src/lib.rs index 490fe331f08a9..b7441d1f00f9e 100644 --- a/src/query/settings/src/lib.rs +++ b/src/query/settings/src/lib.rs @@ -481,6 +481,16 @@ impl Settings { desc: "How many hours will the COPY file metadata expired in the metasrv, default value: 24*7=7days", possible_values: None, }, + SettingValue { + default_value: UserSettingValue::UInt64(1), + user_setting: UserSetting::create( + "insert_values_enable_expression", + UserSettingValue::UInt64(1), + ), + level: ScopeLevel::Session, + desc: "Whether to enable expression when inserting values, if your values do not have expressions please disable this setting to improve write performance, default value: 1.", + possible_values: None, + }, ]; let settings: Arc> = Arc::new(DashMap::default()); @@ -775,6 +785,11 @@ impl Settings { self.try_get_u64(key) } + pub fn get_insert_values_enable_expression(&self) -> Result { + static KEY: &str = "insert_values_enable_expression"; + self.try_get_u64(KEY) + } + pub fn has_setting(&self, key: &str) -> bool { self.settings.get(key).is_some() } diff --git a/tests/logictest/suites/base/03_dml/03_0016_insert_into_values b/tests/logictest/suites/base/03_dml/03_0016_insert_into_values index e4bea32728b0e..275f73847ea3b 100644 --- a/tests/logictest/suites/base/03_dml/03_0016_insert_into_values +++ b/tests/logictest/suites/base/03_dml/03_0016_insert_into_values @@ -52,6 +52,32 @@ create table if not exists st1(a string); statement error 1303 insert into st1 values ('a', 'b'); +statement ok +set global insert_values_enable_expression = 0; + +statement error 4000 +insert into st1 values (upper('a')); + +statement ok +insert into st1 values ('a'),('b'), ('c'); + +statement query T +select * from st1; + +---- +a +b +c + +statement query I +select segment_count from fuse_snapshot('db1', 'st1'); + +---- +1 + +statement ok +set global insert_values_enable_expression = 1; + statement ok drop table st1;