Skip to content

Commit

Permalink
Remove fetch from user-guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Vehmaanperä committed Aug 5, 2024
1 parent 23049a8 commit e5dfb83
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 35 deletions.
8 changes: 0 additions & 8 deletions docs/src/python/user-guide/lazy/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,4 @@
.collect(streaming=True)
)
# --8<-- [end:stream]
# --8<-- [start:partial]
q9 = (
pl.scan_csv(f"docs/data/reddit.csv")
.with_columns(pl.col("name").str.to_uppercase())
.filter(pl.col("comment_karma") > 0)
.fetch(n_rows=int(100))
)
# --8<-- [end:partial]
"""
27 changes: 0 additions & 27 deletions docs/user-guide/lazy/execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,4 @@ If your data requires more memory than you have available Polars may be able to

We look at [streaming in more detail here](streaming.md).

### Execution on a partial dataset

While you're writing, optimizing or checking your query on a large dataset, querying all available data may lead to a slow development process.

You can instead execute the query with the `.fetch` method. The `.fetch` method takes a parameter `n_rows` and tries to 'fetch' that number of rows at the data source. The number of rows cannot be guaranteed, however, as the lazy API does not count how many rows there are at each stage of the query.

Here we "fetch" 100 rows from the source file and apply the predicates.

{{code_block('user-guide/lazy/execution','partial',['scan_csv','collect','fetch'])}}

```text
shape: (27, 6)
┌───────┬───────────────────────────┬─────────────┬────────────┬───────────────┬────────────┐
│ id ┆ name ┆ created_utc ┆ updated_on ┆ comment_karma ┆ link_karma │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ i64 ┆ i64 ┆ i64 ┆ i64 │
╞═══════╪═══════════════════════════╪═════════════╪════════════╪═══════════════╪════════════╡
│ 6 ┆ TAOJIANLONG_JASONBROKEN ┆ 1397113510 ┆ 1536527864 ┆ 4 ┆ 0 │
│ 17 ┆ SSAIG_JASONBROKEN ┆ 1397113544 ┆ 1536527864 ┆ 1 ┆ 0 │
│ 19 ┆ FDBVFDSSDGFDS_JASONBROKEN ┆ 1397113552 ┆ 1536527864 ┆ 3 ┆ 0 │
│ 37 ┆ IHATEWHOWEARE_JASONBROKEN ┆ 1397113636 ┆ 1536527864 ┆ 61 ┆ 0 │
│ … ┆ … ┆ … ┆ … ┆ … ┆ … │
│ 77763 ┆ LUNCHY ┆ 1137599510 ┆ 1536528275 ┆ 65 ┆ 0 │
│ 77765 ┆ COMPOSTELLAS ┆ 1137474000 ┆ 1536528276 ┆ 6 ┆ 0 │
│ 77766 ┆ GENERICBOB ┆ 1137474000 ┆ 1536528276 ┆ 291 ┆ 14 │
│ 77768 ┆ TINHEADNED ┆ 1139665457 ┆ 1536497404 ┆ 4434 ┆ 103 │
└───────┴───────────────────────────┴─────────────┴────────────┴───────────────┴────────────┘
```

0 comments on commit e5dfb83

Please sign in to comment.