Skip to content
Open
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
76 changes: 76 additions & 0 deletions paimon-core/src/test/java/org/apache/paimon/JavaPyE2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.paimon.data.GenericRow;
import org.apache.paimon.data.InternalArray;
import org.apache.paimon.data.InternalRow;
import org.apache.paimon.data.serializer.InternalRowSerializer;
import org.apache.paimon.data.variant.GenericVariant;
import org.apache.paimon.deletionvectors.BitmapDeletionVector;
import org.apache.paimon.deletionvectors.DeletionVector;
Expand All @@ -42,6 +43,7 @@
import org.apache.paimon.fs.Path;
import org.apache.paimon.fs.local.LocalFileIO;
import org.apache.paimon.globalindex.sorted.SortedGlobalIndexBuilder;
import org.apache.paimon.index.HashBucketAssigner;
import org.apache.paimon.index.IndexFileMeta;
import org.apache.paimon.io.CompactIncrement;
import org.apache.paimon.io.DataFileMeta;
Expand Down Expand Up @@ -335,6 +337,35 @@ public void testJavaWriteReadPkTable() throws Exception {
}
}

@Test
@EnabledIfSystemProperty(named = "run.e2e.tests", matches = "true")
public void testJavaWriteDynamicBucketHashIndex() throws Exception {
Identifier identifier = identifier("dynamic_hash_java_to_python");
Schema schema =
Schema.newBuilder()
.column("key1", DataTypes.STRING())
.column("key2", DataTypes.BIGINT())
.column("value", DataTypes.STRING())
.primaryKey("key1", "key2")
.option("bucket", "-1")
.option("dynamic-bucket.target-row-num", "1")
.option("file.format", "parquet")
.build();
catalog.createTable(identifier, schema, true);
FileStoreTable table = (FileStoreTable) catalog.getTable(identifier);

try (StreamTableWrite write = table.newWrite(commitUser);
InnerTableCommit commit = table.newCommit(commitUser)) {
GenericRow row =
GenericRow.of(
BinaryString.fromString("hello-java"),
42L,
BinaryString.fromString("java-old"));
write.write(row, assignDynamicBucket(table, row));
commit.commit(0, write.prepareCommit(true, 0));
}
}

@Test
@EnabledIfSystemProperty(named = "run.e2e.tests", matches = "true")
public void testPKDeletionVectorWrite() throws Exception {
Expand Down Expand Up @@ -525,6 +556,51 @@ public void testReadPkTable() throws Exception {
}
}

@Test
@EnabledIfSystemProperty(named = "run.e2e.tests", matches = "true")
public void testReadPythonDynamicBucketHashIndex() throws Exception {
Identifier identifier = identifier("dynamic_hash_python_to_java");
FileStoreTable table = (FileStoreTable) catalog.getTable(identifier);

try (StreamTableWrite write = table.newWrite(commitUser);
InnerTableCommit commit = table.newCommit(commitUser)) {
GenericRow row =
GenericRow.of(
BinaryString.fromString("hello-java"),
42L,
BinaryString.fromString("java-new"));
write.write(row, assignDynamicBucket(table, row));
commit.commit(1, write.prepareCommit(true, 1));
}

List<String> result =
getResult(
table.newRead(),
table.newScan().plan().splits(),
row -> DataFormatTestUtil.toStringNoRowKind(row, table.rowType()));
assertThat(result)
.containsExactlyInAnyOrder(
"hello-java, 42, java-new", "python-only, 7, python-only");
}

private int assignDynamicBucket(FileStoreTable table, InternalRow row) {
InternalRowSerializer serializer =
new InternalRowSerializer(DataTypes.STRING(), DataTypes.BIGINT());
int keyHash =
serializer.toBinaryRow(GenericRow.of(row.getString(0), row.getLong(1))).hashCode();
HashBucketAssigner assigner =
new HashBucketAssigner(
table.snapshotManager(),
commitUser,
table.store().newIndexFileHandler(),
1,
1,
0,
1,
-1);
return assigner.assign(BinaryRow.EMPTY_ROW, keyHash);
}

@Test
@EnabledIfSystemProperty(named = "run.e2e.tests", matches = "true")
public void testBtreeIndexWrite() throws Exception {
Expand Down
9 changes: 5 additions & 4 deletions paimon-python/dev/run_mixed_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ run_batched_java_write_tests() {
local result=0

local core_tests="org.apache.paimon.JavaPyE2ETest#testJavaWriteReadPkTable"
core_tests="${core_tests}+testJavaWriteDynamicBucketHashIndex"
core_tests="${core_tests}+testPKDeletionVectorWrite"
core_tests="${core_tests}+testBtreeIndexWrite"
core_tests="${core_tests}+testBtreeRawFallbackWrite"
Expand Down Expand Up @@ -184,7 +185,7 @@ run_java_write_test() {
echo "Running Maven test for JavaPyE2ETest.testJavaWriteReadPkTable (Parquet/Orc/Avro)..."
echo "Note: Maven may download dependencies on first run, this may take a while..."
local parquet_result=0
if mvn test -Dtest=org.apache.paimon.JavaPyE2ETest#testJavaWriteReadPkTable -pl paimon-core -Drun.e2e.tests=true; then
if mvn test -Dtest=org.apache.paimon.JavaPyE2ETest#testJavaWriteReadPkTable+testJavaWriteDynamicBucketHashIndex -pl paimon-core -Drun.e2e.tests=true; then
echo -e "${GREEN}✓ Java write Parquet/Orc/Avro test completed successfully${NC}"
else
echo -e "${RED}✗ Java write Parquet/Orc/Avro test failed${NC}"
Expand Down Expand Up @@ -222,7 +223,7 @@ run_python_read_test() {

# Run the parameterized Python test method (runs for both Parquet/Orc/Avro and Lance)
echo "Running Python test for JavaPyReadWriteTest.test_read_pk_table..."
if python -m pytest java_py_read_write_test.py::JavaPyReadWriteTest -k "test_read_pk_table" -v; then
if python -m pytest java_py_read_write_test.py::JavaPyReadWriteTest -k "test_read_pk_table or test_read_java_dynamic_bucket_hash_index" -v; then
echo -e "${GREEN}✓ Python test completed successfully${NC}"
# source deactivate
return 0
Expand All @@ -241,7 +242,7 @@ run_python_write_test() {

# Run the parameterized Python test method for writing data (pk table, includes bucket num assertion)
echo "Running Python test for JavaPyReadWriteTest (test_py_write_read_pk_table)..."
if python -m pytest java_py_read_write_test.py::JavaPyReadWriteTest -k "test_py_write_read_pk_table" -v; then
if python -m pytest java_py_read_write_test.py::JavaPyReadWriteTest -k "test_py_write_read_pk_table or test_py_write_dynamic_bucket_hash_index" -v; then
echo -e "${GREEN}✓ Python write test completed successfully${NC}"
return 0
else
Expand All @@ -260,7 +261,7 @@ run_java_read_test() {
echo "Running Maven test for JavaPyE2ETest.testReadPkTable (Java Read Parquet/Orc/Avro)..."
echo "Note: Maven may download dependencies on first run, this may take a while..."
local parquet_result=0
if mvn test -Dtest=org.apache.paimon.JavaPyE2ETest#testReadPkTable -pl paimon-core -Drun.e2e.tests=true -Dpython.version="$PYTHON_VERSION"; then
if mvn test -Dtest=org.apache.paimon.JavaPyE2ETest#testReadPkTable+testReadPythonDynamicBucketHashIndex -pl paimon-core -Drun.e2e.tests=true -Dpython.version="$PYTHON_VERSION"; then
echo -e "${GREEN}✓ Java read Parquet/Orc/Avro test completed successfully${NC}"
else
echo -e "${RED}✗ Java read Parquet/Orc/Avro test failed${NC}"
Expand Down
Loading
Loading