@@ -133,6 +133,15 @@ public void testMemoryLimitExceeded()
133
133
.hasMessageMatching ("Memory limit.*" );
134
134
}
135
135
136
+ @ Test
137
+ public void testTruncate ()
138
+ {
139
+ createTable (0L , 0L );
140
+ insertToTable (0L , createOneMegaBytePage (), 0L );
141
+ truncateTable (0L , 0L );
142
+ insertToTable (0L , createOneMegaBytePage (), 0L );
143
+ }
144
+
136
145
private void insertToTable (long tableId , Long ... activeTableIds )
137
146
{
138
147
insertToTable (tableId , createPage (), activeTableIds );
@@ -159,6 +168,16 @@ private void createTable(long tableId, Long... activeTableIds)
159
168
pageSink .finish ();
160
169
}
161
170
171
+ private void truncateTable (long tableId , Long ... activeTableIds )
172
+ {
173
+ ConnectorPageSink pageSink = pageSinkProvider .createPageSink (
174
+ MemoryTransactionHandle .INSTANCE ,
175
+ SESSION ,
176
+ createOverwriteMemoryInsertTableHandle (tableId , activeTableIds ),
177
+ TESTING_PAGE_SINK_ID );
178
+ pageSink .finish ();
179
+ }
180
+
162
181
private static ConnectorOutputTableHandle createMemoryOutputTableHandle (long tableId , Long ... activeTableIds )
163
182
{
164
183
return new MemoryOutputTableHandle (tableId , ImmutableSet .copyOf (activeTableIds ));
@@ -169,6 +188,11 @@ private static ConnectorInsertTableHandle createMemoryInsertTableHandle(long tab
169
188
return new MemoryInsertTableHandle (tableId , InsertMode .APPEND , ImmutableSet .copyOf (activeTableIds ));
170
189
}
171
190
191
+ private static ConnectorInsertTableHandle createOverwriteMemoryInsertTableHandle (long tableId , Long [] activeTableIds )
192
+ {
193
+ return new MemoryInsertTableHandle (tableId , InsertMode .OVERWRITE , ImmutableSet .copyOf (activeTableIds ));
194
+ }
195
+
172
196
private static Page createPage ()
173
197
{
174
198
BlockBuilder blockBuilder = BIGINT .createFixedSizeBlockBuilder (POSITIONS_PER_PAGE );
0 commit comments