Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] fix after compactioned the array elements are duplicated #2364

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@
import org.junit.jupiter.params.provider.ValueSource;

import java.io.IOException;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;

/** SQL ITCase for continuous file store. */
public class FullCompactionFileStoreITCase extends CatalogITCaseBase {
private final String table = "T";
private final String options =
" WITH('changelog-producer'='full-compaction', 'changelog-producer.compaction-interval' = '1s')";

@Override
@BeforeEach
public void before() throws IOException {
super.before();
String options =
" WITH('changelog-producer'='full-compaction', 'changelog-producer.compaction-interval' = '1s')";
tEnv.executeSql(
"CREATE TABLE IF NOT EXISTS T (a STRING, b STRING, c STRING, PRIMARY KEY (a) NOT ENFORCED)"
+ options);
Expand All @@ -59,6 +60,28 @@ public void testStreamingRead() throws Exception {
assertThat(iterator.collect(1)).containsExactlyInAnyOrder(Row.of("7", "8", "9"));
}

/** Test streaming read with array and row nested data type. */
@Test
public void testStreamingReadOfArray() throws Exception {
String table = "T_ARRAY";
tEnv.executeSql(
"CREATE TABLE IF NOT EXISTS "
+ table
+ "("
+ "ID INT PRIMARY KEY NOT ENFORCED,\n"
+ "NAMES ARRAY<ROW<NAME STRING, MARK STRING>>\n"
+ ")"
+ options);
BlockingIterator<Row, Row> iterator =
BlockingIterator.of(streamSqlIter("SELECT * FROM %s", table));

sql(
"INSERT INTO %s VALUES (1, ARRAY[('c','mark1'), ('d','mark2'), ('e','mark3')]);",
table);
assertThat(iterator.collect(1).stream().map(Row::toString).collect(Collectors.toList()))
.containsExactlyInAnyOrder("+I[1, [+I[c, mark1], +I[d, mark2], +I[e, mark3]]]");
}

@Test
public void testCompactedScanMode() throws Exception {
BlockingIterator<Row, Row> iterator =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class OrcRowColumnVector extends AbstractOrcColumnVector
implements org.apache.paimon.data.columnar.RowColumnVector {

private final ColumnarRow columnarRow;
private final VectorizedColumnBatch batch;

public OrcRowColumnVector(StructColumnVector hiveVector, RowType type) {
super(hiveVector);
Expand All @@ -38,12 +38,11 @@ public OrcRowColumnVector(StructColumnVector hiveVector, RowType type) {
for (int i = 0; i < len; i++) {
paimonVectors[i] = createPaimonVector(hiveVector.fields[i], type.getTypeAt(i));
}
this.columnarRow = new ColumnarRow(new VectorizedColumnBatch(paimonVectors));
this.batch = new VectorizedColumnBatch(paimonVectors);
}

@Override
public ColumnarRow getRow(int i) {
this.columnarRow.setRowId(i);
return this.columnarRow;
return new ColumnarRow(batch, i);
}
}