airbytehq / airbytehq/PyAirbyte

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

Aperta
#26 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
344
Fork
77
Merge medio
1g 11h
PR unite (30g)
35

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.