Skip to content

Commit 092ee0c

Browse files
committed
refactor: use binary as grpc value of json
1 parent 5e9e417 commit 092ee0c

4 files changed

Lines changed: 11 additions & 15 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ etcd-client = { version = "0.13" }
120120
fst = "0.4.7"
121121
futures = "0.3"
122122
futures-util = "0.3"
123-
greptime-proto = { git = "https://github.com/CookiePieWw/greptime-proto.git", rev = "4346f484c14bb8a6711d10906ee6db54a896030a" }
123+
greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "c437b55725b7f5224fe9d46db21072b4a682ee4b" }
124124
humantime = "2.1"
125125
humantime-serde = "1.1"
126126
itertools = "0.10"

src/api/src/helper.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ impl From<ColumnDataTypeWrapper> for ConcreteDataType {
137137
ConcreteDataType::decimal128_default_datatype()
138138
}
139139
}
140-
ColumnDataType::Json => ConcreteDataType::json_datatype(),
141140
}
142141
}
143142
}
@@ -237,7 +236,7 @@ impl TryFrom<ConcreteDataType> for ColumnDataTypeWrapper {
237236
ConcreteDataType::UInt64(_) => ColumnDataType::Uint64,
238237
ConcreteDataType::Float32(_) => ColumnDataType::Float32,
239238
ConcreteDataType::Float64(_) => ColumnDataType::Float64,
240-
ConcreteDataType::Binary(_) => ColumnDataType::Binary,
239+
ConcreteDataType::Binary(_) | ConcreteDataType::Json(_) => ColumnDataType::Binary,
241240
ConcreteDataType::String(_) => ColumnDataType::String,
242241
ConcreteDataType::Date(_) => ColumnDataType::Date,
243242
ConcreteDataType::DateTime(_) => ColumnDataType::Datetime,
@@ -259,7 +258,6 @@ impl TryFrom<ConcreteDataType> for ColumnDataTypeWrapper {
259258
IntervalType::MonthDayNano(_) => ColumnDataType::IntervalMonthDayNano,
260259
},
261260
ConcreteDataType::Decimal128(_) => ColumnDataType::Decimal128,
262-
ConcreteDataType::Json(_) => ColumnDataType::Json,
263261
ConcreteDataType::Null(_)
264262
| ConcreteDataType::List(_)
265263
| ConcreteDataType::Dictionary(_)
@@ -397,10 +395,6 @@ pub fn values_with_capacity(datatype: ColumnDataType, capacity: usize) -> Values
397395
decimal128_values: Vec::with_capacity(capacity),
398396
..Default::default()
399397
},
400-
ColumnDataType::Json => Values {
401-
json_values: Vec::with_capacity(capacity),
402-
..Default::default()
403-
},
404398
}
405399
}
406400

@@ -575,7 +569,6 @@ pub fn pb_value_to_value_ref<'a>(
575569
))
576570
}
577571
}
578-
ValueData::JsonValue(v) => ValueRef::Json(v),
579572
}
580573
}
581574

@@ -840,7 +833,12 @@ pub fn is_column_type_value_eq(
840833
expect_type: &ConcreteDataType,
841834
) -> bool {
842835
ColumnDataTypeWrapper::try_new(type_value, type_extension)
843-
.map(|wrapper| ConcreteDataType::from(wrapper) == *expect_type)
836+
.map(|wrapper| {
837+
let datatype = ConcreteDataType::from(wrapper);
838+
(datatype == *expect_type)
839+
|| (datatype == ConcreteDataType::binary_datatype()
840+
&& *expect_type == ConcreteDataType::json_datatype())
841+
})
844842
.unwrap_or(false)
845843
}
846844

@@ -938,7 +936,7 @@ pub fn to_proto_value(value: Value) -> Option<v1::Value> {
938936
value_data: Some(ValueData::Decimal128Value(convert_to_pb_decimal128(v))),
939937
},
940938
Value::Json(v) => v1::Value {
941-
value_data: Some(ValueData::JsonValue(v.to_vec())),
939+
value_data: Some(ValueData::BinaryValue(v.to_vec())),
942940
},
943941
Value::List(_) | Value::Duration(_) => return None,
944942
};
@@ -978,7 +976,6 @@ pub fn proto_value_type(value: &v1::Value) -> Option<ColumnDataType> {
978976
ValueData::IntervalDayTimeValue(_) => ColumnDataType::IntervalDayTime,
979977
ValueData::IntervalMonthDayNanoValue(_) => ColumnDataType::IntervalMonthDayNano,
980978
ValueData::Decimal128Value(_) => ColumnDataType::Decimal128,
981-
ValueData::JsonValue(_) => ColumnDataType::Json,
982979
};
983980
Some(value_type)
984981
}
@@ -1036,7 +1033,7 @@ pub fn value_to_grpc_value(value: Value) -> GrpcValue {
10361033
}
10371034
}),
10381035
Value::Decimal128(v) => Some(ValueData::Decimal128Value(convert_to_pb_decimal128(v))),
1039-
Value::Json(v) => Some(ValueData::JsonValue(v.to_vec())),
1036+
Value::Json(v) => Some(ValueData::BinaryValue(v.to_vec())),
10401037
Value::List(_) | Value::Duration(_) => unreachable!(),
10411038
},
10421039
}

src/operator/src/req_convert/common.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ fn push_column_to_rows(column: Column, rows: &mut [Row]) -> Result<()> {
164164
interval_month_day_nano_values
165165
),
166166
(Decimal128, Decimal128Value, decimal128_values),
167-
(Json, JsonValue, json_values),
168167
);
169168

170169
Ok(())

0 commit comments

Comments
 (0)