Skip to content

Commit

Permalink
fix: code: 4000, message: invalid data (tag for enum is not valid, fo…
Browse files Browse the repository at this point in the history
…und 7): compaction error (#11480)

* add fuse compat test for release 1.1.30

* Revert "feat(query): Support Computed columns (#11391)"

This reverts commit f530b1e.

* resolve conflicts

* fix stateless test

* fix create table default value

* fix

* refine meta change log, mark ver 36 as reverted

---------

Co-authored-by: baishen <baishen2009@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored May 17, 2023
1 parent a170b8e commit e649085
Show file tree
Hide file tree
Showing 76 changed files with 437 additions and 1,553 deletions.
1 change: 1 addition & 0 deletions .github/actions/fuse_compat/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ runs:
bash ./tests/fuse-compat/test-fuse-compat.sh 0.7.151 base
bash ./tests/fuse-compat/test-fuse-compat.sh 1.0.56 base
bash ./tests/fuse-compat/test-fuse-compat.sh 1.0.56 01_meta_compression 01_flashback
bash ./tests/fuse-compat/test-fuse-compat.sh 1.1.30 base
- name: Upload failure
if: failure() || cancelled()
Expand Down
15 changes: 12 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion src/common/io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ ordered-float = { workspace = true }
serde = { workspace = true }

[dev-dependencies]
aho-corasick = { version = "1.0.1" }
aho-corasick = { version = "0.7.20" }
rand = "0.8.5"
4 changes: 2 additions & 2 deletions src/common/io/tests/it/cursor_ext/fast_read_text_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn test_positions() -> Result<()> {
];

let patterns = &["'", "\\"];
let ac = AhoCorasick::new(patterns).unwrap();
let ac = AhoCorasick::new(patterns);
for (data, expect) in cases {
let mut positions = VecDeque::new();
for mat in ac.find_iter(&data) {
Expand All @@ -47,7 +47,7 @@ fn test_positions() -> Result<()> {
fn test_fast_read_text() -> Result<()> {
let data = r#"'abc','d\'ef','g\\\'hi'"#.to_string();
let patterns = &["'", "\\"];
let ac = AhoCorasick::new(patterns).unwrap();
let ac = AhoCorasick::new(patterns);
let mut positions = VecDeque::new();
for mat in ac.find_iter(&data) {
let pos = mat.start();
Expand Down
56 changes: 1 addition & 55 deletions src/meta/proto-conv/src/schema_from_to_protobuf_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,84 +71,30 @@ impl FromToProto for ex::TableField {
fn from_pb(p: pb::DataField) -> Result<Self, Incompatible> {
reader_check_msg(p.ver, p.min_reader_ver)?;

let computed_expr = match p.computed_expr {
Some(computed_expr) => Some(ex::ComputedExpr::from_pb(computed_expr)?),
None => None,
};

let v = ex::TableField::new_from_column_id(
&p.name,
ex::TableDataType::from_pb(p.data_type.ok_or_else(|| Incompatible {
reason: "DataField.data_type can not be None".to_string(),
})?)?,
p.column_id,
)
.with_default_expr(p.default_expr)
.with_computed_expr(computed_expr);
.with_default_expr(p.default_expr);
Ok(v)
}

fn to_pb(&self) -> Result<pb::DataField, Incompatible> {
let computed_expr = match self.computed_expr() {
Some(computed_expr) => Some(computed_expr.to_pb()?),
None => None,
};
let p = pb::DataField {
ver: VER,
min_reader_ver: MIN_READER_VER,
name: self.name().clone(),
default_expr: self.default_expr().cloned(),
data_type: Some(self.data_type().to_pb()?),
column_id: self.column_id(),
computed_expr,
};
Ok(p)
}
}

impl FromToProto for ex::ComputedExpr {
type PB = pb::ComputedExpr;

fn get_pb_ver(p: &Self::PB) -> u64 {
p.ver
}

fn from_pb(p: pb::ComputedExpr) -> Result<Self, Incompatible> {
reader_check_msg(p.ver, p.min_reader_ver)?;

let computed_expr = match p.computed_expr {
None => {
return Err(Incompatible {
reason: "Invalid ComputedExpr: .computed_expr can not be None".to_string(),
});
}
Some(x) => x,
};

let x = match computed_expr {
pb::computed_expr::ComputedExpr::Virtual(expr) => Self::Virtual(expr),
pb::computed_expr::ComputedExpr::Stored(expr) => Self::Stored(expr),
};
Ok(x)
}

fn to_pb(&self) -> Result<pb::ComputedExpr, Incompatible> {
let x = match self {
ex::ComputedExpr::Virtual(expr) => {
pb::computed_expr::ComputedExpr::Virtual(expr.clone())
}
ex::ComputedExpr::Stored(expr) => pb::computed_expr::ComputedExpr::Stored(expr.clone()),
};

Ok(pb::ComputedExpr {
ver: VER,
min_reader_ver: MIN_READER_VER,

computed_expr: Some(x),
})
}
}

impl FromToProto for ex::TableDataType {
type PB = pb::DataType;
fn get_pb_ver(p: &Self::PB) -> u64 {
Expand Down
2 changes: 1 addition & 1 deletion src/meta/proto-conv/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const META_CHANGE_LOG: &[(u64, &str)] = &[
(33, "2023-04-13: Update: add `shared_by` field into TableMeta", ),
(34, "2023-04-23: Add: metadata.proto/DataType Bitmap type", ),
(35, "2023-05-08: Add: CopyOptions::disable_variant_check", ),
(36, "2023-05-12: Add: metadata.proto/ComputedExpr", ),
(36, "2023-05-12: Add: metadata.proto/ComputedExpr (reverted)", ),
(37, "2023-05-05: Add: index.proto", ),
// Dear developer:
// If you're gonna add a new metadata version, you'll have to add a test for it.
Expand Down
1 change: 0 additions & 1 deletion src/meta/proto-conv/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,4 @@ mod v032_file_format_params;
mod v033_table_meta;
mod v034_schema;
mod v035_user_stage;
mod v036_table_meta;
mod v037_index_meta;
109 changes: 0 additions & 109 deletions src/meta/proto-conv/tests/it/v036_table_meta.rs

This file was deleted.

12 changes: 0 additions & 12 deletions src/meta/protos/proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,6 @@ message DataSchema {
uint32 next_column_id = 3;
}

message ComputedExpr {
uint64 ver = 100;
uint64 min_reader_ver = 101;

oneof computed_expr {
string virtual = 1;
string stored = 2;
}
}

// One field, AKA column
message DataField {
uint64 ver = 100;
Expand All @@ -58,6 +48,4 @@ message DataField {
DataType data_type = 3;

uint32 column_id = 4;

optional ComputedExpr computed_expr = 5;
}
30 changes: 3 additions & 27 deletions src/query/ast/src/ast/statements/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,35 +578,11 @@ impl Display for OptimizeTableAction {
}
}

#[derive(Debug, Clone, PartialEq)]
pub enum ColumnExpr {
Default(Box<Expr>),
Virtual(Box<Expr>),
Stored(Box<Expr>),
}

impl Display for ColumnExpr {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
match self {
ColumnExpr::Default(expr) => {
write!(f, " DEFAULT {expr}")?;
}
ColumnExpr::Virtual(expr) => {
write!(f, " AS ({expr}) VIRTUAL")?;
}
ColumnExpr::Stored(expr) => {
write!(f, " AS ({expr}) STORED")?;
}
}
Ok(())
}
}

#[derive(Debug, Clone, PartialEq)]
pub struct ColumnDefinition {
pub name: Identifier,
pub data_type: TypeName,
pub expr: Option<ColumnExpr>,
pub default_expr: Option<Box<Expr>>,
pub comment: Option<String>,
}

Expand All @@ -618,8 +594,8 @@ impl Display for ColumnDefinition {
write!(f, " NOT NULL")?;
}

if let Some(expr) = &self.expr {
write!(f, "{expr}")?;
if let Some(default_expr) = &self.default_expr {
write!(f, " DEFAULT {default_expr}")?;
}
if let Some(comment) = &self.comment {
write!(f, " COMMENT '{comment}'")?;
Expand Down
Loading

1 comment on commit e649085

@vercel
Copy link

@vercel vercel bot commented on e649085 May 17, 2023

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.