Skip to content

Commit

Permalink
Docs: Add row-level Java API example (apache#3083)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrigorievNick authored Sep 13, 2021
1 parent e0b20d4 commit 9641ec8
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions site/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Tables also provide `refresh` to update the table to the latest version, and exp

### Scanning

#### File level

Iceberg table scans start by creating a `TableScan` object with `newScan`.

```java
Expand Down Expand Up @@ -70,6 +72,28 @@ Iterable<CombinedScanTask> tasks = scan.planTasks();

Use `asOfTime` or `useSnapshot` to configure the table snapshot for time travel queries.

#### Row level

Iceberg table scans start by creating a `ScanBuilder` object with `IcebergGenerics.read`.

```java
ScanBuilder scanBuilder = IcebergGenerics.read(table)
```

To configure a scan, call `where` and `select` on the `ScanBuilder` to get a new `ScanBuilder` with those changes.

```java
scanBuilder.where(Expressions.equal("id", 5))
```

When a scan is configured, call method `build` to execute scan. `build` return `CloseableIterable<Record>`

```java
CloseableIterable<Record> result = IcebergGenerics.read(table)
.where(Expressions.lessThan("id", 5))
.build();
```
where `Record` is Iceberg record for iceberg-data module `org.apache.iceberg.data.Record`.

### Update operations

Expand Down

0 comments on commit 9641ec8

Please sign in to comment.