airbytehq / airbytehq/PyAirbyte

Proposal: Add native `len()` support for the return of `get_records()` (`LazyDataset`)

オープン
#26 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
344
フォーク
77
平均マージ
1日 11時間
マージ済み PR(30日)
35

説明

We because to implement this but then reverted because the `len()` implementation was exhausting the iterator and then the records were not iteratable after running `len()` on the result.

A workaround is to wrap in `len(list())`, and in this case the result will be converted to a list and then counted.

Design challenge:

There's an argument that we _should not_ directly implement len() over get_records() because it will carry the full cost of streaming all records, while discarding all records. If the user then wants to actually view the records, they will pay the cost of extracting records twice - and the results (including counts) could change between calls.

Logging this issue so that we can discuss and iterate on path forward. If we don't support directly, perhaps we can provide better guidance to users in a better error message.

Note:

The `len()` call _is_ directly supported on CachedDataset objects, and there's no similar issue with performance. We have already optimized that codepath to use `count()` in SQL to provide optimized `len()` results.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。