You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/src/sql/arrow_sql_gen/statement.rs
+27Lines changed: 27 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,7 @@ pub struct CreateTableBuilder {
37
37
schema:SchemaRef,
38
38
table_name:String,
39
39
primary_keys:Vec<String>,
40
+
temporary:bool,
40
41
}
41
42
42
43
implCreateTableBuilder{
@@ -46,6 +47,7 @@ impl CreateTableBuilder {
46
47
schema,
47
48
table_name: table_name.to_string(),
48
49
primary_keys:Vec::new(),
50
+
temporary:false,
49
51
}
50
52
}
51
53
@@ -58,6 +60,13 @@ impl CreateTableBuilder {
58
60
self
59
61
}
60
62
63
+
#[must_use]
64
+
/// Set whether the table is temporary or not.
65
+
pubfntemporary(mutself,temporary:bool) -> Self{
66
+
self.temporary = temporary;
67
+
self
68
+
}
69
+
61
70
#[must_use]
62
71
#[cfg(feature = "postgres")]
63
72
pubfnbuild_postgres(self) -> Vec<String>{
@@ -145,6 +154,10 @@ impl CreateTableBuilder {
145
154
create_stmt.primary_key(&mut index);
146
155
}
147
156
157
+
ifself.temporary{
158
+
create_stmt.temporary();
159
+
}
160
+
148
161
create_stmt.to_string(query_builder)
149
162
}
150
163
}
@@ -1550,6 +1563,20 @@ mod tests {
1550
1563
assert_eq!(sql,"CREATE TABLE IF NOT EXISTS \"users\" ( \"id\" integer NOT NULL, \"id2\" integer NOT NULL, \"name\" text NOT NULL, \"age\" integer, PRIMARY KEY (\"id\", \"id2\") )");
1551
1564
}
1552
1565
1566
+
#[test]
1567
+
fntest_temporary_table_creation(){
1568
+
let schema = Schema::new(vec![
1569
+
Field::new("id",DataType::Int32,false),
1570
+
Field::new("name",DataType::Utf8,false),
1571
+
]);
1572
+
let sql = CreateTableBuilder::new(SchemaRef::new(schema),"users")
1573
+
.primary_keys(vec!["id"])
1574
+
.temporary(true)
1575
+
.build_sqlite();
1576
+
1577
+
assert_eq!(sql,"CREATE TEMPORARY TABLE IF NOT EXISTS \"users\" ( \"id\" integer NOT NULL, \"name\" text NOT NULL, PRIMARY KEY (\"id\") )");
0 commit comments