Skip to content

Commit

Permalink
Merge pull request #7012 from sundy-li/deprecate-clickhouse-tcp
Browse files Browse the repository at this point in the history
feat(query): deprecate clickhouse's tcp protocol support
  • Loading branch information
mergify[bot] authored Aug 5, 2022
2 parents f6dda7b + 512d596 commit e077f83
Show file tree
Hide file tree
Showing 57 changed files with 52 additions and 2,105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ sleep 3
nohup bin/databend-query --config-file=configs/databend-query.toml 2>&1 >query.log &
sleep 3
echo "Usage: mysql -h127.0.0.1 -P3307 -uroot"
echo "or: clickhouse-client --port 9001"
echo "or: curl -u root: --request POST '127.0.0.1:8001/v1/query/' --data-raw '{\"sql\": \"<your-query>\"}' -H 'Content-Type: application/json'"
92 changes: 9 additions & 83 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions common/config/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ pub struct QueryConfig {
pub mysql_handler_host: String,
pub mysql_handler_port: u16,
pub max_active_sessions: u64,
pub clickhouse_handler_host: String,
pub clickhouse_handler_port: u16,
pub clickhouse_http_handler_host: String,
pub clickhouse_http_handler_port: u16,
pub http_handler_host: String,
Expand Down Expand Up @@ -162,8 +160,6 @@ impl Default for QueryConfig {
mysql_handler_host: "127.0.0.1".to_string(),
mysql_handler_port: 3307,
max_active_sessions: 256,
clickhouse_handler_host: "127.0.0.1".to_string(),
clickhouse_handler_port: 9000,
clickhouse_http_handler_host: "127.0.0.1".to_string(),
clickhouse_http_handler_port: 8124,
http_handler_host: "127.0.0.1".to_string(),
Expand Down
12 changes: 8 additions & 4 deletions common/config/src/outer_v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,11 @@ pub struct QueryConfig {
#[clap(long, default_value = "256")]
pub max_active_sessions: u64,

#[deprecated(note = "clickhouse tcp support is deprecated")]
#[clap(long, default_value = "127.0.0.1")]
pub clickhouse_handler_host: String,

#[deprecated(note = "clickhouse tcp support is deprecated")]
#[clap(long, default_value = "9000")]
pub clickhouse_handler_port: u16,

Expand Down Expand Up @@ -665,8 +667,6 @@ impl TryInto<InnerQueryConfig> for QueryConfig {
mysql_handler_host: self.mysql_handler_host,
mysql_handler_port: self.mysql_handler_port,
max_active_sessions: self.max_active_sessions,
clickhouse_handler_host: self.clickhouse_handler_host,
clickhouse_handler_port: self.clickhouse_handler_port,
clickhouse_http_handler_host: self.clickhouse_http_handler_host,
clickhouse_http_handler_port: self.clickhouse_http_handler_port,
http_handler_host: self.http_handler_host,
Expand Down Expand Up @@ -705,6 +705,7 @@ impl TryInto<InnerQueryConfig> for QueryConfig {
}
}

#[allow(deprecated)]
impl From<InnerQueryConfig> for QueryConfig {
fn from(inner: InnerQueryConfig) -> Self {
Self {
Expand All @@ -714,8 +715,11 @@ impl From<InnerQueryConfig> for QueryConfig {
mysql_handler_host: inner.mysql_handler_host,
mysql_handler_port: inner.mysql_handler_port,
max_active_sessions: inner.max_active_sessions,
clickhouse_handler_host: inner.clickhouse_handler_host,
clickhouse_handler_port: inner.clickhouse_handler_port,

// clickhouse tcp is deprecated
clickhouse_handler_host: "127.0.0.1".to_string(),
clickhouse_handler_port: 9000,

clickhouse_http_handler_host: inner.clickhouse_http_handler_host,
clickhouse_http_handler_port: inner.clickhouse_http_handler_port,
http_handler_host: inner.http_handler_host,
Expand Down
1 change: 0 additions & 1 deletion common/datavalues/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ lexical-core = "0.8.5"
micromarshal = "0.1.0"
num = "0.4.0"
once_cell = "1.12.0"
opensrv-clickhouse = "0.1.0"
ordered-float = "3.0.0"
paste = "1.0.7"
rand = { version = "0.8.5", features = ["small_rng"] }
Expand Down
37 changes: 0 additions & 37 deletions common/datavalues/src/types/serializations/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::sync::Arc;

use common_exception::Result;
use common_io::prelude::FormatSettings;
use opensrv_clickhouse::types::column::ArrayColumnData;
use serde_json::Value;

use crate::prelude::*;
Expand Down Expand Up @@ -53,40 +50,6 @@ impl<'a> TypeSerializer<'a> for ArraySerializer<'a> {
buf.push(b']');
}

fn serialize_clickhouse_const(
&self,
format: &FormatSettings,
size: usize,
) -> Result<opensrv_clickhouse::types::column::ArcColumnData> {
let len = self.offsets.len() - 1;
let mut offsets = opensrv_clickhouse::types::column::List::with_capacity(size * len);
let total = self.offsets[len];
let mut base = 0;
for _ in 0..size {
for offset in self.offsets.iter().skip(1) {
offsets.push(((*offset) + base) as u64);
}
base += total;
}

let inner_data = self.inner.serialize_clickhouse_const(format, size)?;
Ok(Arc::new(ArrayColumnData::create(inner_data, offsets)))
}

fn serialize_clickhouse_column(
&self,
format: &FormatSettings,
) -> Result<opensrv_clickhouse::types::column::ArcColumnData> {
let mut offsets =
opensrv_clickhouse::types::column::List::with_capacity(self.offsets.len() - 1);
for offset in self.offsets.iter().skip(1) {
offsets.push(*offset as u64);
}

let inner_data = self.inner.serialize_clickhouse_column(format)?;
Ok(Arc::new(ArrayColumnData::create(inner_data, offsets)))
}

fn serialize_json_values(&self, format: &FormatSettings) -> Result<Vec<Value>> {
let size = self.offsets.len() - 1;
let mut result = Vec::with_capacity(size);
Expand Down
24 changes: 0 additions & 24 deletions common/datavalues/src/types/serializations/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
use common_arrow::arrow::bitmap::Bitmap;
use common_exception::Result;
use common_io::prelude::FormatSettings;
use opensrv_clickhouse::types::column::ArcColumnWrapper;
use opensrv_clickhouse::types::column::ColumnFrom;
use serde_json::Value;

use crate::prelude::*;
Expand Down Expand Up @@ -57,28 +55,6 @@ impl<'a> TypeSerializer<'a> for BooleanSerializer {
Ok(result)
}

fn serialize_clickhouse_const(
&self,
_format: &FormatSettings,
size: usize,
) -> Result<opensrv_clickhouse::types::column::ArcColumnData> {
let mut values: Vec<u8> = Vec::with_capacity(self.values.len() * size);
for _ in 0..size {
for v in self.values.iter() {
values.push(v as u8)
}
}
Ok(Vec::column_from::<ArcColumnWrapper>(values))
}

fn serialize_clickhouse_column(
&self,
_format: &FormatSettings,
) -> Result<opensrv_clickhouse::types::column::ArcColumnData> {
let values: Vec<u8> = self.values.iter().map(|c| c as u8).collect();
Ok(Vec::column_from::<ArcColumnWrapper>(values))
}

fn serialize_json_object(
&self,
_valids: Option<&Bitmap>,
Expand Down
7 changes: 0 additions & 7 deletions common/datavalues/src/types/serializations/const_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ impl<'a> TypeSerializer<'a> for ConstSerializer<'a> {
Ok(self.repeat(self.inner.serialize_json_values(format)?))
}

fn serialize_clickhouse_column(
&self,
format: &FormatSettings,
) -> Result<opensrv_clickhouse::types::column::ArcColumnData> {
self.inner.serialize_clickhouse_const(format, self.size)
}

fn serialize_json_object(
&self,
valids: Option<&Bitmap>,
Expand Down
Loading

1 comment on commit e077f83

@vercel
Copy link

@vercel vercel bot commented on e077f83 Aug 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

databend – ./

databend.vercel.app
databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.rs

Please sign in to comment.