|
12 | 12 | // See the License for the specific language governing permissions and
|
13 | 13 | // limitations under the License.
|
14 | 14 |
|
15 |
| -use std::ops::Add; |
16 | 15 | use std::ops::Sub;
|
17 | 16 | use std::time::Duration;
|
18 | 17 |
|
19 | 18 | use common_base::base::tokio;
|
20 |
| -use common_catalog::table::AppendMode; |
21 | 19 | use common_datablocks::DataBlock;
|
22 | 20 | use common_exception::ErrorCode;
|
23 | 21 | use common_exception::Result;
|
24 | 22 | use common_storages_fuse::io::SnapshotHistoryReader;
|
25 |
| -use databend_query::pipelines::Pipeline; |
26 | 23 | use databend_query::storages::fuse::io::MetaReaders;
|
27 | 24 | use databend_query::storages::fuse::io::TableMetaLocationGenerator;
|
28 | 25 | use databend_query::storages::fuse::FuseTable;
|
29 |
| -use databend_query::storages::Table; |
30 | 26 | use futures::TryStreamExt;
|
31 | 27 |
|
32 | 28 | use crate::storages::fuse::table_test_fixture::execute_query;
|
@@ -121,73 +117,3 @@ async fn test_fuse_navigate() -> Result<()> {
|
121 | 117 | };
|
122 | 118 | Ok(())
|
123 | 119 | }
|
124 |
| - |
125 |
| -#[tokio::test] |
126 |
| -async fn test_fuse_historical_table_is_read_only() -> Result<()> { |
127 |
| - // 1. Setup |
128 |
| - let fixture = TestFixture::new().await; |
129 |
| - let db = fixture.default_db_name(); |
130 |
| - let tbl = fixture.default_table_name(); |
131 |
| - let ctx = fixture.ctx(); |
132 |
| - fixture.create_default_table().await?; |
133 |
| - |
134 |
| - let qry = format!("insert into {}.{} values (1, (2, 3))", db, tbl); |
135 |
| - execute_query(ctx.clone(), qry.as_str()) |
136 |
| - .await? |
137 |
| - .try_collect::<Vec<DataBlock>>() |
138 |
| - .await?; |
139 |
| - |
140 |
| - // 2. grab the history |
141 |
| - let table = fixture.latest_default_table().await?; |
142 |
| - let fuse_table = FuseTable::try_from_table(table.as_ref())?; |
143 |
| - let loc = fuse_table.snapshot_loc().await?.unwrap(); |
144 |
| - let reader = MetaReaders::table_snapshot_reader(fuse_table.get_operator()); |
145 |
| - let version = TableMetaLocationGenerator::snapshot_version(loc.as_str()); |
146 |
| - let snapshots: Vec<_> = reader |
147 |
| - .snapshot_history(loc, version, fuse_table.meta_location_generator().clone()) |
148 |
| - .try_collect() |
149 |
| - .await?; |
150 |
| - |
151 |
| - let snapshot = &snapshots[0]; |
152 |
| - let instant = snapshot |
153 |
| - .timestamp |
154 |
| - .unwrap() |
155 |
| - .add(chrono::Duration::milliseconds(1)); |
156 |
| - let tbl = fuse_table.navigate_to_time_point(instant).await?; |
157 |
| - |
158 |
| - // check append2 |
159 |
| - let res = tbl.append_data( |
160 |
| - ctx.clone(), |
161 |
| - &mut Pipeline::create(), |
162 |
| - AppendMode::Normal, |
163 |
| - false, |
164 |
| - ); |
165 |
| - assert_not_writable(res, "append2"); |
166 |
| - |
167 |
| - // check append_data |
168 |
| - let res = fixture |
169 |
| - .append_commit_blocks(tbl.clone(), vec![], false, true) |
170 |
| - .await; |
171 |
| - assert_not_writable(res, "append2"); |
172 |
| - |
173 |
| - // check truncate |
174 |
| - let res = tbl.truncate(ctx.clone(), false).await; |
175 |
| - assert_not_writable(res, "truncate"); |
176 |
| - |
177 |
| - Ok(()) |
178 |
| -} |
179 |
| - |
180 |
| -fn assert_not_writable<T>(res: Result<T>, case_name: &str) { |
181 |
| - match res { |
182 |
| - Ok(_) => panic!( |
183 |
| - "historical table should NOT be writable, case {}", |
184 |
| - case_name |
185 |
| - ), |
186 |
| - Err(e) => assert_eq!( |
187 |
| - e.code(), |
188 |
| - ErrorCode::TABLE_NOT_WRITABLE, |
189 |
| - " case {}", |
190 |
| - case_name |
191 |
| - ), |
192 |
| - } |
193 |
| -} |
0 commit comments