feat: add QuestDB support
Thanks @ptma!
This commit is contained in:
1 parent
0ae720d950
commit
1afc271c18
51 files changed
+633
-46
No files matched your search
@@ -193,6 +193,7 @@ pub fn build_drop_table_child_object_sql(options: DropTableChildObjectSqlOptions
|
||||
| DatabaseType::Gaussdb
|
||||
| DatabaseType::Kwdb
|
||||
| DatabaseType::OpenGauss
|
||||
| DatabaseType::Questdb
|
||||
| DatabaseType::Highgo
|
||||
| DatabaseType::Vastbase
|
||||
| DatabaseType::Kingbase
|
||||
@@ -223,6 +224,7 @@ pub fn build_drop_table_child_object_sql(options: DropTableChildObjectSqlOptions
|
||||
| DatabaseType::Gaussdb
|
||||
| DatabaseType::Kwdb
|
||||
| DatabaseType::OpenGauss
|
||||
| DatabaseType::Questdb
|
||||
| DatabaseType::Highgo
|
||||
| DatabaseType::Vastbase
|
||||
| DatabaseType::Kingbase
|
||||
@@ -249,7 +251,9 @@ pub fn build_empty_table_sql(options: TableAdminSqlOptions) -> String {
|
||||
match options.database_type {
|
||||
Some(DatabaseType::ClickHouse) => format!("ALTER TABLE {table} DELETE WHERE 1 = 1;"),
|
||||
Some(DatabaseType::Bigquery) => format!("DELETE FROM {table} WHERE TRUE;"),
|
||||
Some(DatabaseType::Cassandra | DatabaseType::Hive | DatabaseType::Kylin) => format!("TRUNCATE TABLE {table};"),
|
||||
Some(DatabaseType::Cassandra | DatabaseType::Hive | DatabaseType::Kylin | DatabaseType::Questdb) => {
|
||||
format!("TRUNCATE TABLE {table};")
|
||||
}
|
||||
Some(DatabaseType::Iotdb) => format!("DELETE FROM {};", iotdb_timeseries_pattern(&table)),
|
||||
_ => format!("DELETE FROM {table};"),
|
||||
}
|
||||
@@ -289,6 +293,9 @@ pub fn build_duplicate_table_structure_sql(options: DuplicateTableStructureSqlOp
|
||||
if options.database_type == Some(DatabaseType::Mysql) {
|
||||
return format!("CREATE TABLE {target} LIKE {source};");
|
||||
}
|
||||
if options.database_type == Some(DatabaseType::Questdb) {
|
||||
return format!("CREATE TABLE {target} (LIKE {source});");
|
||||
}
|
||||
if options.database_type.is_some_and(is_postgres_like_structure_copy) {
|
||||
return format!("CREATE TABLE {target} (LIKE {source} INCLUDING ALL);");
|
||||
}
|
||||
@@ -400,6 +407,7 @@ fn is_postgres_like_structure_copy(database_type: DatabaseType) -> bool {
|
||||
| DatabaseType::Gaussdb
|
||||
| DatabaseType::Kwdb
|
||||
| DatabaseType::OpenGauss
|
||||
| DatabaseType::Questdb
|
||||
)
|
||||
}
|
||||
|
||||
@@ -607,6 +615,23 @@ mod tests {
|
||||
}),
|
||||
"DELETE FROM root.test.DCU_101.*;"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
build_empty_table_sql(TableAdminSqlOptions {
|
||||
database_type: Some(DatabaseType::Questdb),
|
||||
schema: None,
|
||||
table_name: "table_sample".to_string(),
|
||||
}),
|
||||
"TRUNCATE TABLE `table_sample`;"
|
||||
);
|
||||
assert_eq!(
|
||||
build_truncate_table_sql(TableAdminSqlOptions {
|
||||
database_type: Some(DatabaseType::Questdb),
|
||||
schema: None,
|
||||
table_name: "table_sample".to_string(),
|
||||
}),
|
||||
"TRUNCATE TABLE `table_sample`;"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -711,6 +736,18 @@ mod tests {
|
||||
.unwrap(),
|
||||
"DROP TRIGGER \"orders_audit\" ON \"public\".\"orders\";"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
build_drop_table_child_object_sql(DropTableChildObjectSqlOptions {
|
||||
database_type: Some(DatabaseType::Questdb),
|
||||
object_type: TableChildObjectType::Column,
|
||||
schema: Some("public".to_string()),
|
||||
table_name: "orders".to_string(),
|
||||
name: "status".to_string(),
|
||||
})
|
||||
.unwrap(),
|
||||
"ALTER TABLE `orders` DROP COLUMN `status`;"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -751,6 +788,15 @@ mod tests {
|
||||
}),
|
||||
"CREATE TABLE \"HR\".\"USERS_COPY\" AS SELECT * FROM \"HR\".\"USERS\" WHERE 1=0"
|
||||
);
|
||||
assert_eq!(
|
||||
build_duplicate_table_structure_sql(DuplicateTableStructureSqlOptions {
|
||||
database_type: Some(DatabaseType::Questdb),
|
||||
schema: None,
|
||||
source_name: "users".to_string(),
|
||||
target_name: "users_copy".to_string(),
|
||||
}),
|
||||
"CREATE TABLE `users_copy` (LIKE `users`);"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user