|
21 | 21 | import io.trino.spi.Page;
|
22 | 22 | import io.trino.spi.TrinoException;
|
23 | 23 | import io.trino.spi.block.BlockBuilder;
|
| 24 | +import io.trino.spi.block.ByteArrayBlock; |
| 25 | +import io.trino.spi.block.IntArrayBlock; |
| 26 | +import io.trino.spi.block.RunLengthEncodedBlock; |
24 | 27 | import io.trino.spi.connector.ConnectorInsertTableHandle;
|
25 | 28 | import io.trino.spi.connector.ConnectorOutputTableHandle;
|
26 | 29 | import io.trino.spi.connector.ConnectorPageSink;
|
|
33 | 36 | import java.util.OptionalDouble;
|
34 | 37 | import java.util.OptionalLong;
|
35 | 38 |
|
| 39 | +import static io.trino.block.BlockAssertions.createLongSequenceBlock; |
36 | 40 | import static io.trino.spi.type.BigintType.BIGINT;
|
| 41 | +import static io.trino.spi.type.BooleanType.BOOLEAN; |
37 | 42 | import static io.trino.spi.type.IntegerType.INTEGER;
|
38 | 43 | import static io.trino.testing.TestingConnectorSession.SESSION;
|
39 | 44 | import static io.trino.testing.TestingPageSinkId.TESTING_PAGE_SINK_ID;
|
@@ -99,6 +104,29 @@ public void testTryToReadFromEmptyTable()
|
99 | 104 | .hasMessageMatching("Expected to find.*");
|
100 | 105 | }
|
101 | 106 |
|
| 107 | + @Test |
| 108 | + public void testReadBackExtraColumns() |
| 109 | + { |
| 110 | + createTable(0L, 0L); |
| 111 | + int positions = 1024; |
| 112 | + // insert single BIGINT column page |
| 113 | + insertToTable(0L, new Page(createLongSequenceBlock(0, positions)), 0L); |
| 114 | + // Read back as BIGINT, INTEGER, BOOLEAN expecting the INTEGER and BOOLEAN columns to be RLE encoded |
| 115 | + List<Page> readBack = pagesStore.getPages(0L, 0, 1, new int[] {0, 1, 2}, List.of(BIGINT, INTEGER, BOOLEAN), positions, OptionalLong.empty(), OptionalDouble.empty()); |
| 116 | + assertThat(readBack).hasSize(1); |
| 117 | + Page readPage = readBack.getFirst(); |
| 118 | + assertThat(readPage.getChannelCount()).isEqualTo(3); |
| 119 | + assertThat(readPage.getPositionCount()).isEqualTo(positions); |
| 120 | + assertThat(readPage.getBlock(1)) |
| 121 | + .isInstanceOf(RunLengthEncodedBlock.class); |
| 122 | + assertThat(readPage.getBlock(1).getUnderlyingValueBlock()) |
| 123 | + .isInstanceOf(IntArrayBlock.class); |
| 124 | + assertThat(readPage.getBlock(2)) |
| 125 | + .isInstanceOf(RunLengthEncodedBlock.class); |
| 126 | + assertThat(readPage.getBlock(2).getUnderlyingValueBlock()) |
| 127 | + .isInstanceOf(ByteArrayBlock.class); |
| 128 | + } |
| 129 | + |
102 | 130 | @Test
|
103 | 131 | public void testCleanUp()
|
104 | 132 | {
|
|
0 commit comments