diff --git a/src/query/service/src/servers/http/clickhouse_handler.rs b/src/query/service/src/servers/http/clickhouse_handler.rs index e8b86c3c69d1..eea72f135d08 100644 --- a/src/query/service/src/servers/http/clickhouse_handler.rs +++ b/src/query/service/src/servers/http/clickhouse_handler.rs @@ -36,6 +36,7 @@ use common_sql::plans::Plan; use common_sql::Planner; use futures::StreamExt; use http::HeaderMap; +use http::StatusCode; use log::debug; use log::info; use log::warn; @@ -231,7 +232,6 @@ pub async fn clickhouse_handler_get( headers: &HeaderMap, ) -> PoemResult> { let root = Span::root(full_name!(), SpanContext::random()); - async { let session = ctx.upgrade_session(SessionType::ClickHouseHttpHandler)?; if let Some(db) = ¶ms.database { @@ -247,6 +247,16 @@ pub async fn clickhouse_handler_get( .set_batch_settings(¶ms.settings) .map_err(BadRequest)?; + if !settings + .get_enable_clickhouse_handler() + .map_err(InternalServerError)? + { + return Err(poem::Error::from_string( + "default settings: enable_clickhouse_handler is 0".to_string(), + StatusCode::METHOD_NOT_ALLOWED, + )); + } + let default_format = get_default_format(¶ms, headers).map_err(BadRequest)?; let sql = params.query(); let mut planner = Planner::new(context.clone()); @@ -301,6 +311,16 @@ pub async fn clickhouse_handler_post( .set_batch_settings(¶ms.settings) .map_err(BadRequest)?; + if !settings + .get_enable_clickhouse_handler() + .map_err(InternalServerError)? + { + return Err(poem::Error::from_string( + "default settings: enable_clickhouse_handler is 0".to_string(), + StatusCode::METHOD_NOT_ALLOWED, + )); + } + let default_format = get_default_format(¶ms, headers).map_err(BadRequest)?; let mut sql = params.query(); if !sql.is_empty() { diff --git a/src/query/service/tests/it/servers/http/clickhouse_handler.rs b/src/query/service/tests/it/servers/http/clickhouse_handler.rs index e0aa1f4d8d97..032576269de7 100644 --- a/src/query/service/tests/it/servers/http/clickhouse_handler.rs +++ b/src/query/service/tests/it/servers/http/clickhouse_handler.rs @@ -393,7 +393,7 @@ impl QueryBuilder { } let uri = uri.finish(); - let uri = "/?".to_string() + &uri; + let uri = "/?enable_clickhouse_handler=1&".to_string() + &uri; let uri = uri.parse::().unwrap(); let (method, body) = match self.body { None => (Method::GET, Body::empty()), diff --git a/src/query/service/tests/it/storages/testdata/settings_table.txt b/src/query/service/tests/it/storages/testdata/settings_table.txt index 29715e65d5d9..b68f7c7bc168 100644 --- a/src/query/service/tests/it/storages/testdata/settings_table.txt +++ b/src/query/service/tests/it/storages/testdata/settings_table.txt @@ -15,6 +15,7 @@ DB.Table: 'system'.'settings', Table: settings-table_id:1, ver:0, Engine: System | 'enable_aggregating_index_scan' | '1' | '1' | 'SESSION' | 'Enable scanning aggregating index data while querying.' | 'UInt64' | | 'enable_bushy_join' | '0' | '0' | 'SESSION' | 'Enables generating a bushy join plan with the optimizer.' | 'UInt64' | | 'enable_cbo' | '1' | '1' | 'SESSION' | 'Enables cost-based optimization.' | 'UInt64' | +| 'enable_clickhouse_handler' | '0' | '0' | 'SESSION' | 'Enables clickhouse handler.' | 'UInt64' | | 'enable_distributed_compact' | '0' | '0' | 'SESSION' | 'Enable distributed execution of table compaction.' | 'UInt64' | | 'enable_distributed_copy_into' | '1' | '1' | 'SESSION' | 'Enable distributed execution of copy into.' | 'UInt64' | | 'enable_distributed_merge_into' | '0' | '0' | 'SESSION' | 'Enable distributed merge into.' | 'UInt64' | diff --git a/src/query/settings/src/settings_default.rs b/src/query/settings/src/settings_default.rs index a85bf395f43c..1cb10fd721e7 100644 --- a/src/query/settings/src/settings_default.rs +++ b/src/query/settings/src/settings_default.rs @@ -61,6 +61,13 @@ impl DefaultSettings { let global_conf = GlobalConfig::try_get_instance(); let default_settings = HashMap::from([ + ("enable_clickhouse_handler", DefaultSettingValue { + value: UserSettingValue::UInt64(0), + desc: "Enables clickhouse handler.", + possible_values: None, + mode: SettingMode::Both, + range: None, + }), ("max_block_size", DefaultSettingValue { value: UserSettingValue::UInt64(65536), desc: "Sets the maximum byte size of a single data block that can be read.", diff --git a/src/query/settings/src/settings_getter_setter.rs b/src/query/settings/src/settings_getter_setter.rs index 53b45cbeeb67..b22c2cb8386f 100644 --- a/src/query/settings/src/settings_getter_setter.rs +++ b/src/query/settings/src/settings_getter_setter.rs @@ -119,6 +119,9 @@ impl Settings { ))) } + pub fn get_enable_clickhouse_handler(&self) -> Result { + Ok(self.try_get_u64("enable_clickhouse_handler")? != 0) + } // Get max_block_size. pub fn get_max_block_size(&self) -> Result { self.try_get_u64("max_block_size") diff --git a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0001_clickhouse_http.sh b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0001_clickhouse_http.sh index 9e4a7e693a80..f1a83f51587e 100755 --- a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0001_clickhouse_http.sh +++ b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0001_clickhouse_http.sh @@ -3,30 +3,30 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../../../shell_env.sh -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d 'select 1' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}?enable_clickhouse_handler=1" -d 'select 1' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d 'select 1' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select 1' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}//" -d 'select 1' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}//?enable_clickhouse_handler=1" -d 'select 1' curl -s -u root: "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/ping" curl -s -u root: "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/replicas_status" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d 'select version()' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select version()' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d 'drop database if exists db2' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d 'create database db2' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "show databases like 'db%' format TabSeparatedWithNamesAndTypes" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2" -d 'create table t2(a int not null)' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2" -d "show TABLES LIKE 't%' format TabSeparatedWithNamesAndTypes" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2" -d 'show create table t2 format TabSeparatedWithNamesAndTypes' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2" -d 'desc t2 format TabSeparatedWithNamesAndTypes' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2" -d 'insert into table t2 values(1)' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?" -d 'select * from db2.t2' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d 'drop database if exists db2' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'drop database if exists db2' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'create database db2' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "show databases like 'db%' format TabSeparatedWithNamesAndTypes" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2&enable_clickhouse_handler=1" -d 'create table t2(a int not null)' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2&enable_clickhouse_handler=1" -d "show TABLES LIKE 't%' format TabSeparatedWithNamesAndTypes" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2&enable_clickhouse_handler=1" -d 'show create table t2 format TabSeparatedWithNamesAndTypes' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2&enable_clickhouse_handler=1" -d 'desc t2 format TabSeparatedWithNamesAndTypes' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?database=db2&enable_clickhouse_handler=1" -d 'insert into table t2 values(1)' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select * from db2.t2' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'drop database if exists db2' echo "--- default_format" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?default_format=TabSeparatedWithNamesAndTypes" -d 'select number as a from numbers(1)' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?default_format=TabSeparatedWithNamesAndTypes&enable_clickhouse_handler=1" -d 'select number as a from numbers(1)' -curl -s -u root: -H "X-CLICKHOUSE-FORMAT: TabSeparatedWithNamesAndTypes" -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d 'select number as a from numbers(1)' +curl -s -u root: -H "X-CLICKHOUSE-FORMAT: TabSeparatedWithNamesAndTypes" -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select number as a from numbers(1)' diff --git a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0002_select_formats.sh b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0002_select_formats.sh index 11681b32dc6a..8554f99ae77b 100755 --- a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0002_select_formats.sh +++ b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0002_select_formats.sh @@ -5,40 +5,40 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) echo "----csv" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d 'select number, number::varchar, number + 1 from numbers(3) FORMAT CSV' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select number, number::varchar, number + 1 from numbers(3) FORMAT CSV' echo "----tsv" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d 'select number, number::varchar, number + 1 from numbers(3) FORMAT TSV' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select number, number::varchar, number + 1 from numbers(3) FORMAT TSV' echo "----tsv header escape" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select regexp_like('fo\nfo', '^fo$') FORMAT TabSeparatedWithNamesAndTypes" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select regexp_like('fo\nfo', '^fo$') FORMAT TabSeparatedWithNamesAndTypes" echo "----NDJSON" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d 'select number, number::varchar from numbers(2) FORMAT NDJSON' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select number, number::varchar from numbers(2) FORMAT NDJSON' echo "----JSONEachRow" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSONEachRow" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSONEachRow" echo "----JSONStringsEachRow" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSONStringsEachRow" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSONStringsEachRow" echo "----JSONCompactEachRow" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactEachRow" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactEachRow" echo "----JSONCompactEachRowWithNames" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactEachRowWithNames" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactEachRowWithNames" echo "----JSONCompactEachRowWithNamesAndTypes" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactEachRowWithNamesAndTypes" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactEachRowWithNamesAndTypes" echo "----JSONCompactStringsEachRow" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactStringsEachRow" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactStringsEachRow" echo "----JSONCompactStringsEachRowWithNames" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactStringsEachRowWithNames" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactStringsEachRowWithNames" echo "----JSONCompactStringsEachRowWithNamesAndTypes" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactStringsEachRowWithNamesAndTypes" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSONCompactStringsEachRowWithNamesAndTypes" echo "----JSON" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "select number, number::varchar from numbers(2) FORMAT JSON" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select number, number::varchar from numbers(2) FORMAT JSON" diff --git a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0003_http_auth.sh b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0003_http_auth.sh index 62d41b3f8db7..974eeb526144 100755 --- a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0003_http_auth.sh +++ b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0003_http_auth.sh @@ -3,14 +3,14 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../../../shell_env.sh -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d 'drop user if exists user1' +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'drop user if exists user1' -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "create user user1 identified by 'abc123'" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "create user user1 identified by 'abc123'" -curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "grant select on *.* to 'user1'" +curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "grant select on *.* to 'user1'" -curl -s -u user1:abc123 -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d 'select 1 FORMAT CSV' +curl -s -u user1:abc123 -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select 1 FORMAT CSV' -curl -s -H 'X-ClickHouse-User: user1' -H 'X-ClickHouse-Key: abc123' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d 'select 1 FORMAT CSV' +curl -s -H 'X-ClickHouse-User: user1' -H 'X-ClickHouse-Key: abc123' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d 'select 1 FORMAT CSV' -curl -s -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}?user=user1&password=abc123" -d 'select 1 FORMAT CSV' +curl -s -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?user=user1&password=abc123&enable_clickhouse_handler=1" -d 'select 1 FORMAT CSV' diff --git a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0004_http_clickhouse_input_format.sh b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0004_http_clickhouse_input_format.sh index 860c57f4821a..e8150540663c 100755 --- a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0004_http_clickhouse_input_format.sh +++ b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0004_http_clickhouse_input_format.sh @@ -62,21 +62,21 @@ for i in `seq 1 10000`;do echo '{"a": 0, "b": "3", "c": 0}' >> /tmp/databend_test_ndjson.txt done -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "drop table if exists a" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "create table a ( a int not null, b varchar not null, c double not null)" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table if exists a" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "create table a ( a int not null, b varchar not null, c double not null)" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" --data-binary @/tmp/databend_test_csv.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" --data-binary @/tmp/databend_test_csv_names.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" --data-binary @/tmp/databend_test_csv_names_and_types.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" --data-binary @/tmp/databend_test_tsv_names_and_types.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_csv.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_csv_names.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_csv_names_and_types.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_tsv_names_and_types.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" --data-binary @/tmp/databend_test_values.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" --data-binary @/tmp/databend_test_ndjson.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_values.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_ndjson.txt # Flaky test: wait for https://github.com/datafuselabs/databend/issues/7657 -#curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "SELECT count(), sum(a), min(b), sum(c) from a" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "SELECT count(), sum(a), min(b) from a" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "drop table a" +#curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "SELECT count(), sum(a), min(b), sum(c) from a" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "SELECT count(), sum(a), min(b) from a" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table a" rm /tmp/databend_test*.txt diff --git a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0006_input_format_nullable.sh b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0006_input_format_nullable.sh index ea25dccc634c..c26c5fbe9901 100755 --- a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0006_input_format_nullable.sh +++ b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0006_input_format_nullable.sh @@ -13,15 +13,15 @@ N1 EOF -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "drop table if exists t1" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "create table t1 (a varchar null)" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table if exists t1" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "create table t1 (a varchar null)" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" --data-binary @/tmp/databend_test_csv.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_csv.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "SELECT * from t1" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "SELECT * from t1" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" -d "drop table t1" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table t1" rm /tmp/databend_test*.txt diff --git a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0007_http_clickhouse_input_format_diagnostic.sh b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0007_http_clickhouse_input_format_diagnostic.sh index 17841feeb405..97a9e6dd1e37 100755 --- a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0007_http_clickhouse_input_format_diagnostic.sh +++ b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0007_http_clickhouse_input_format_diagnostic.sh @@ -3,12 +3,12 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) . "$CURDIR"/../../../shell_env.sh -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "drop table if exists a" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "create table a ( a int not null, b string not null, c int )" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table if exists a" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "create table a ( a int not null, b string not null, c int )" cat << EOF > /tmp/databend_test_csv_error.txt insert into a(a,b) format CSV 1,"Hello",1 EOF -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" --data-binary @/tmp/databend_test_csv_error.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "drop table if exists a" \ No newline at end of file +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_csv_error.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table if exists a" \ No newline at end of file diff --git a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0008_tsv_input_format.sh b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0008_tsv_input_format.sh index a3dcf3fe33ce..bdb49494ca66 100755 --- a/tests/suites/0_stateless/14_clickhouse_http_handler/14_0008_tsv_input_format.sh +++ b/tests/suites/0_stateless/14_clickhouse_http_handler/14_0008_tsv_input_format.sh @@ -15,16 +15,16 @@ EOF echo "---bigint" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "drop table if exists t1" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "create table t1 (a bigint not null)" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?default_format=TSV" --data-binary @/tmp/databend_test_tsv_bigint.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "select * from t1" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "drop table t1" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table if exists t1" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "create table t1 (a bigint not null)" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?default_format=TSV&enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_tsv_bigint.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select * from t1" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table t1" echo "---escape" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "drop table if exists t2" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "create table t2 (a string not null, b string not null)" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?default_format=TSV" --data-binary @/tmp/databend_test_tsv_escape.txt -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "select * from t2" -curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/" -d "drop table t2" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table if exists t2" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "create table t2 (a string not null, b string not null)" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?default_format=TSV&enable_clickhouse_handler=1" --data-binary @/tmp/databend_test_tsv_escape.txt +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "select * from t2" +curl -s -u 'root:' -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" -d "drop table t2" rm /tmp/databend_test*.txt diff --git a/tests/suites/1_stateful/05_formats/05_00_01_load_unload_all.sh b/tests/suites/1_stateful/05_formats/05_00_01_load_unload_all.sh index 626024aedf2f..3c271a3b6064 100755 --- a/tests/suites/1_stateful/05_formats/05_00_01_load_unload_all.sh +++ b/tests/suites/1_stateful/05_formats/05_00_01_load_unload_all.sh @@ -31,7 +31,7 @@ test_format() { insert_data rm -f /tmp/test_load_unload2.txt /tmp/test_load_unload.txt - curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" \ + curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" \ -d "select * from test_load_unload FORMAT ${1}" > /tmp/test_load_unload.txt cat /tmp/test_load_unload.txt @@ -42,7 +42,7 @@ test_format() { -F "upload=@/tmp/test_load_unload.txt" \ -u root: -XPUT "http://localhost:${QUERY_HTTP_HANDLER_PORT}/v1/streaming_load" | jq -r '.state, .error' - curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" \ + curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" \ -d "select * from test_load_unload FORMAT ${1}" > /tmp/test_load_unload2.txt diff /tmp/test_load_unload2.txt /tmp/test_load_unload.txt diff --git a/tests/suites/1_stateful/05_formats/05_05_parquet/05_05_01_parquet_load_unload.sh b/tests/suites/1_stateful/05_formats/05_05_parquet/05_05_01_parquet_load_unload.sh index aeb9bc93f7ec..f6d65de79811 100755 --- a/tests/suites/1_stateful/05_formats/05_05_parquet/05_05_01_parquet_load_unload.sh +++ b/tests/suites/1_stateful/05_formats/05_05_parquet/05_05_01_parquet_load_unload.sh @@ -28,7 +28,7 @@ test_format() { insert_data # unload clickhouse - curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" \ + curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" \ -d "select * from test_load_unload FORMAT ${1}" > /tmp/test_load_unload.parquet echo "truncate table test_load_unload" | $BENDSQL_CLIENT_CONNECT @@ -39,7 +39,7 @@ test_format() { -u root: -XPUT "http://localhost:${QUERY_HTTP_HANDLER_PORT}/v1/streaming_load" | grep -c "SUCCESS" # unload clickhouse again - curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" \ + curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" \ -d "select * from test_load_unload FORMAT ${1}" > /tmp/test_load_unload2.parquet echo "truncate table test_load_unload" | $BENDSQL_CLIENT_CONNECT @@ -48,7 +48,7 @@ test_format() { echo "copy into test_load_unload from 'fs:///tmp/test_load_unload.parquet' file_format = (type = ${1});" | $BENDSQL_CLIENT_CONNECT # unload clickhouse again - curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" \ + curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" \ -d "select * from test_load_unload FORMAT ${1}" > /tmp/test_load_unload3.parquet # copy into stage @@ -58,7 +58,7 @@ test_format() { echo "copy into @data_fs from test_load_unload file_format = (type = ${1});" | $BENDSQL_CLIENT_CONNECT # unload clickhouse again from stage - curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}" \ + curl -s -u root: -XPOST "http://localhost:${QUERY_CLICKHOUSE_HTTP_HANDLER_PORT}/?enable_clickhouse_handler=1" \ -d "select * from @data_fs FORMAT ${1}" > /tmp/test_load_unload4.parquet diff /tmp/test_load_unload2.parquet /tmp/test_load_unload.parquet