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

add setJoinSubsetType to inject joinSubsetType to BeamSqlSeekableTable #28477

Merged
merged 5 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -20,6 +20,7 @@
import java.io.Serializable;
import java.util.List;
import org.apache.beam.sdk.options.PipelineOptions;
import org.apache.beam.sdk.schemas.Schema;
import org.apache.beam.sdk.transforms.DoFn;
import org.apache.beam.sdk.values.Row;

Expand All @@ -28,6 +29,7 @@
* FROM FACT_TABLE JOIN LOOKUP_TABLE ON ...}.
*/
public interface BeamSqlSeekableTable extends Serializable {
default void setJoinSubsetType(Schema joinSubsetType) {}
gabrywu marked this conversation as resolved.
Show resolved Hide resolved
/** prepare the instance. */
default void setUp() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public JoinAsLookup(
this.outputSchema = outputSchema;
this.factColOffset = factColOffset;
joinFieldsMapping(joinCondition, factColOffset, lkpColOffset);
this.seekableTable.setJoinSubsetType(joinSubsetType);
gabrywu marked this conversation as resolved.
Show resolved Hide resolved
}

private void joinFieldsMapping(RexNode joinCondition, int factColOffset, int lkpColOffset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.beam.sdk.values.POutput;
import org.apache.beam.sdk.values.Row;
import org.hamcrest.core.StringContains;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -48,10 +49,17 @@ public class BeamSideInputLookupJoinRelTest extends BaseRelTest {
/** Test table for JOIN-AS-LOOKUP. */
public static class SiteLookupTable extends SchemaBaseBeamTable implements BeamSqlSeekableTable {

private Schema joinSubsetType;

public SiteLookupTable(Schema schema) {
super(schema);
}

@Override
public void setJoinSubsetType(Schema joinSubsetType) {
this.joinSubsetType = joinSubsetType;
}

@Override
public PCollection.IsBounded isBounded() {
return PCollection.IsBounded.BOUNDED;
Expand All @@ -69,6 +77,7 @@ public POutput buildIOWriter(PCollection<Row> input) {

@Override
public List<Row> seekRow(Row lookupSubRow) {
Assert.assertNotNull(joinSubsetType);
if (lookupSubRow.getInt32("site_id") == 2) {
return Arrays.asList(Row.withSchema(getSchema()).addValues(2, "SITE1").build());
}
Expand Down
Loading