Skip to content

[Bug] The Paimon official website's lacking execution condition statement in stream-read demo code  #2932

@zhengyuan-cn

Description

@zhengyuan-cn

Search before asking

  • I searched in the issues and found nothing similar.

Paimon version

0.8-SNAPSHOT

Compute Engine

JavaAPI

Minimal reproduce step

https://paimon.apache.org/docs/master/program-api/java-api/#stream-read
`public class StreamReadTable {

public static void main(String[] args) throws Exception {
    // 1. Create a ReadBuilder and push filter (`withFilter`)
    // and projection (`withProjection`) if necessary
    Table table = GetTable.getTable();

    PredicateBuilder builder =
        new PredicateBuilder(RowType.of(DataTypes.STRING(), DataTypes.INT()));
    Predicate notNull = builder.isNotNull(0);
    Predicate greaterOrEqual = builder.greaterOrEqual(1, 12);

    int[] projection = new int[] {0, 1};

    ReadBuilder readBuilder =
        table.newReadBuilder()
            .withProjection(projection)
            .withFilter(Lists.newArrayList(notNull, greaterOrEqual));

    // 2. Plan splits in 'Coordinator' (or named 'Driver')
    StreamTableScan scan = readBuilder.newStreamScan();
    while (true) {
        List<Split> splits = scan.plan().splits();
        // Distribute these splits to different tasks

        Long state = scan.checkpoint();
        // can be restored in scan.restore(state) after fail over

        // 3. Read a split in task
        TableRead read = readBuilder.newRead();
        // should call .executeFilter()  or else the conditions will not take effect
        TableRead read = readBuilder.newRead().executeFilter();
        RecordReader<InternalRow> reader = read.createReader(splits);
        reader.forEachRemaining(System.out::println);

        Thread.sleep(1000);
    }
}

}`

What doesn't meet your expectations?

TableRead read = readBuilder.newRead();
change to
TableRead read = readBuilder.newRead().executeFilter();

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions