airbytehq / airbytehq/PyAirbyte
Proposal: Add native `len()` support for the return of `get_records()` (`LazyDataset`)
- 主要语言
- Python
- 星标
- 344
- 派生
- 77
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 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 还没有评估数据。