Merge sorted files in IcebergDataSource only when something above the scan uses their order
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- rust
Línea de trabajo
Read the DataFusion PushdownSort behavior and the discussion linked from PR #55, then inspect IcebergDataSource and TableProvider::scan in the repository. Compare the proposed options against the described SELECT, filtered ORDER BY, aggregation, and sort-merge join plans; completion means agreeing on an approach and validating its behavior against those cases. The issue says the author already implemented option 2(a) and plans to submit it as a stacked PR.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Follow-up to https://github.com/apache/datafusion-iceberg/pull/55#discussion_r4235376704.
With iceberg.execution.preserve_data_ordering on, TableProvider::scan lists the data files, and if at most iceberg.execution.max_merge_files_per_partition share a sort order, IcebergDataSource reports it and open() k-way merges one reader per file, with every file open, on one thread. It merges even when nothing above the scan uses the order:
- a
SELECT *, aGROUP BYon another column, or a hash join; ORDER BY id DESC, which keeps itsSortExecabove the merge;ORDER BY idon a nullable key, because Iceberg sorts ascending fields NULLS FIRST by default while DataFusion'sORDER BYmeans NULLS LAST, so the sort stays and we pay for both.
TableProvider::scan can't tell whether anything above will use the order.
What DataFusion 55 offers. The PushdownSort rule (on by default through datafusion.optimizer.enable_sort_pushdown) offers each SortExec's order to its input through try_pushdown_sort. Exact removes the sort, Inexact keeps it over a rebuilt input, and Unsupported changes nothing. DataSourceExec passes the request to the source, and CooperativeExec, ProjectionExec and order-keeping RepartitionExec pass it down, but FilterExec doesn't, so a WHERE clause blocks it. The call is synchronous, so answering it means keeping the file listing in TableProvider::scan.
Sort-merge joins. As @mbutrovich pointed out, a design that merges only after an Exact answer can lose the join case that test_sorted_scan_removes_sort_from_sort_merge_join checks, because RepartitionExec::try_pushdown_sort returns Unsupported when the repartition doesn't keep its input's order. Measured at target_partitions = 4 with #55: an unfiltered sort-merge join keeps both scans' order and needs no SortExec, because the hash repartition over a single-partition scan keeps its input's order. With a WHERE on a join side, DataFusion adds a FilterExec and a round-robin repartition under the hash repartition, which loses the order. That side gets a SortExec while its scan still merges. The results are correct, but the merge is wasted, and pushdown can't remove it. Sorted aggregation never gets a SortExec, so pushdown can't help it either.
Options
- Report no order, implement
try_pushdown_sort, and merge only after anExactanswer. This fixes every case above, but loses filteredORDER BY, sorted aggregation, and filtered or multi-partition join inputs. - Keep reporting the order, and add cheap paths:
(a) when the sort above shares no leading column with the files' order, answerInexactwith a source that reads the files without merging. This is safe because the sort stays, and it fixesDESCand nullableORDER BY id.
(b) read files back to back instead of merging when their key ranges don't overlap (#71).
Neither helps aSELECT *with no sort. - Ship a
PhysicalOptimizerRulethat turns merging off on scans whose order nothing relies on. It must run beforeOutputRequirementsremoval, so users would have to rebuild the rule list, which is new public API. - Change DataFusion:
try_pushdown_sortonFilterExec, or a general "order is consumed" signal.
Proposal. Do 2(a) now, 2(b) once iceberg-rust has per-file bounds, and choose between 1 and 3 from measured plans. Feedback on that choice is very welcome.
I'm working on this. I have 2(a) implemented and will open it as a PR stacked on #55, and I'll drive the discussion for the rest.
- Lenguaje dominante
- Rust
- Estrellas
- 30
- Forks
- 30
- Merge medio
- 3 d 19 h
- PR fusionados (30 d)
- 15
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de apache/datafusion-iceberg
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
apache/datafusion-iceberg#100 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
apache/datafusion-iceberg#85 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
apache/datafusion-iceberg#84 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
apache/datafusion-iceberg#75 ·
Los mantenedores suelen responder en 1 día
-
Slow CI runnersAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 18/100
apache/datafusion-iceberg#74 ·
Los mantenedores suelen responder en 1 día
Todos los issues de apache/datafusion-iceberg
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
rubys/roundhouse#1917 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
[cosmic-applet-battery] Division by zero displays NaN% when UPower reports max_brightness = 0Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
pop-os/cosmic-applets#1619 ·
Los mantenedores suelen responder en 3 días
-
binding:python bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día