Skip to content

Commit

Permalink
fix engine migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k authored and chenzl25 committed Nov 21, 2024
1 parent 5c83b2f commit 11734b3
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/common/src/catalog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ impl ConflictBehavior {

#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Engine {
/// TODO(nimtable): use iceberg engine as default.
#[default]
Hummock,
Iceberg,
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/handler/create_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ pub async fn extract_iceberg_columns(
);
ColumnCatalog {
column_desc,
// hide the _row_id column for nimtable
// hide the _row_id column for iceberg engine table
// This column is auto generated when users define a table without primary key
is_hidden: field.name() == ROWID_PREFIX,
}
Expand Down
3 changes: 3 additions & 0 deletions src/meta/model/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ mod m20241016_065621_hummock_gc_history;
mod m20241025_062548_singleton_vnode_count;
mod m20241115_085007_remove_function_type;
mod m20241120_182555_hummock_add_time_travel_sst_index;

mod m20241121_101830_table_engine;
mod utils;

pub struct Migrator;
Expand Down Expand Up @@ -90,6 +92,7 @@ impl MigratorTrait for Migrator {
Box::new(m20241025_062548_singleton_vnode_count::Migration),
Box::new(m20241115_085007_remove_function_type::Migration),
Box::new(m20241120_182555_hummock_add_time_travel_sst_index::Migration),
Box::new(m20241121_101830_table_engine::Migration),
]
}
}
38 changes: 38 additions & 0 deletions src/meta/model/migration/src/m20241121_101830_table_engine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use sea_orm_migration::prelude::{Table as MigrationTable, *};

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// Replace the sample below with your own migration scripts
manager
.alter_table(
MigrationTable::alter()
.table(Table::Table)
.add_column(ColumnDef::new(Table::Engine).string().not_null())
.to_owned(),
)
.await
}

async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
MigrationTable::alter()
.table(Table::Table)
.drop_column(Alias::new(Table::Engine.to_string()))
.to_owned(),
)
.await?;
Ok(())
}
}

#[derive(DeriveIden)]

enum Table {
Table,
Engine,
}
1 change: 0 additions & 1 deletion src/sqlparser/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,6 @@ impl fmt::Display for Statement {
write!(f, " FROM {}", info.source_name)?;
write!(f, " TABLE '{}'", info.external_table_name)?;
}
// TODO(nimtable): change the default engine to iceberg
match engine {
Engine::Hummock => {},
Engine::Iceberg => {
Expand Down
1 change: 0 additions & 1 deletion src/sqlparser/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2595,7 +2595,6 @@ impl Parser<'_> {
parser_err!("Unsupported engine: {}", engine_name);
}
} else {
// TODO(nimtable): default to hummock, later we can change it to iceberg
Engine::Hummock
};

Expand Down

0 comments on commit 11734b3

Please sign in to comment.