Skip to content

Commit 0191b37

Browse files
authored
refactor: enhance copy from avro. (#17709)
* refactor: enhance copy from avro. 1. support more types. 2. support default expr. 3. add unit test. * fix flaky test
1 parent af73fdf commit 0191b37

File tree

14 files changed

+716
-216
lines changed

14 files changed

+716
-216
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/query/expression/src/types/decimal.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ pub trait Decimal:
399399

400400
fn from_float(value: f64) -> Self;
401401
fn from_i128<U: Into<i128>>(value: U) -> Self;
402+
fn from_i256(value: i256) -> Self;
402403
fn from_bigint(value: BigInt) -> Option<Self>;
403404

404405
fn de_binary(bytes: &mut &[u8]) -> Self;
@@ -578,6 +579,10 @@ impl Decimal for i128 {
578579
value.into()
579580
}
580581

582+
fn from_i256(value: i256) -> Self {
583+
value.as_i128()
584+
}
585+
581586
fn from_bigint(value: BigInt) -> Option<Self> {
582587
value.to_i128()
583588
}
@@ -811,6 +816,10 @@ impl Decimal for i256 {
811816
i256::from(value.into())
812817
}
813818

819+
fn from_i256(value: i256) -> Self {
820+
value
821+
}
822+
814823
fn from_bigint(value: BigInt) -> Option<Self> {
815824
let mut ret: u256 = u256::ZERO;
816825
let mut bits = 0;

src/query/storages/stage/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ databend-common-storages-parquet = { workspace = true }
3535
databend-storages-common-stage = { workspace = true }
3636
databend-storages-common-table-meta = { workspace = true }
3737
enum-as-inner = { workspace = true }
38+
ethnum = { workspace = true }
3839
futures = { workspace = true }
3940
jsonb = { workspace = true }
4041
lexical-core = { workspace = true }
4142
log = { workspace = true }
4243
match-template = { workspace = true }
44+
num-bigint = { workspace = true }
4345
num-traits = { workspace = true }
4446
opendal = { workspace = true }
4547
parquet = { workspace = true }

src/query/storages/stage/src/read/avro/avro_to_jsonb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub(super) fn to_jsonb(value: &Value) -> Result<jsonb::Value, String> {
2626
Value::Double(v) => jsonb::Value::from(*v),
2727
Value::String(v) => jsonb::Value::from(v.as_str()),
2828
Value::Enum(_, v) => jsonb::Value::from(v.as_str()),
29+
Value::Uuid(v) => jsonb::Value::from(v.to_string()),
2930
Value::Union(_, v) => to_jsonb(v)?,
3031
Value::Array(v) => {
3132
let mut array = Vec::with_capacity(v.len());
@@ -62,7 +63,6 @@ pub(super) fn to_jsonb(value: &Value) -> Result<jsonb::Value, String> {
6263
// Value::LocalTimestampMicros(_) => {}
6364
// Value::LocalTimestampNanos(_) => {}
6465
// Value::Duration(_) => {}
65-
// Value::Uuid(_) => {}
6666
};
6767
Ok(jvalue)
6868
}

0 commit comments

Comments
 (0)