{{ message }}
Repository navigation
Improve estimate when first Parquet file is almost empty, and get exact cardinality count when we are using union by name - #21345
Merged
Mytherin merged 1 commit intoMar 13, 2026
Conversation
…ct cardinality count when we are using union by name
github-actions Bot
pushed a commit
to duckdb/duckdb-r
that referenced
this pull request
Mar 18, 2026
Date: 2026-03-13 10:09:43 +0100 Improve estimate when first Parquet file is almost empty, and get exact cardinality count when we are using union by name (duckdb/duckdb#21345) CLI: Make bail on error the default in more situations (duckdb/duckdb#21344) Fixup 401bcf041f36f3abc39ecc6d50ba3dd336fc79d7: "When stress testing … (duckdb/duckdb#21329) CLI: Explicitly clean up shell state instead of letting static destructor order determine when it gets destroyed (duckdb/duckdb#21315)
github-actions Bot
added a commit
to duckdb/duckdb-r
that referenced
this pull request
Mar 18, 2026
Date: 2026-03-13 10:09:43 +0100 Improve estimate when first Parquet file is almost empty, and get exact cardinality count when we are using union by name (duckdb/duckdb#21345) CLI: Make bail on error the default in more situations (duckdb/duckdb#21344) Fixup 401bcf041f36f3abc39ecc6d50ba3dd336fc79d7: "When stress testing … (duckdb/duckdb#21329) CLI: Explicitly clean up shell state instead of letting static destructor order determine when it gets destroyed (duckdb/duckdb#21315) Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr
added a commit
to duckdb/duckdb-r
that referenced
this pull request
Mar 22, 2026
Date: 2026-03-13 10:09:43 +0100 Improve estimate when first Parquet file is almost empty, and get exact cardinality count when we are using union by name (duckdb/duckdb#21345) CLI: Make bail on error the default in more situations (duckdb/duckdb#21344) Fixup 401bcf041f36f3abc39ecc6d50ba3dd336fc79d7: "When stress testing … (duckdb/duckdb#21329) CLI: Explicitly clean up shell state instead of letting static destructor order determine when it gets destroyed (duckdb/duckdb#21315) Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr
added a commit
to krlmlr/duckdb-r-old
that referenced
this pull request
Mar 22, 2026
Date: 2026-03-13 10:09:43 +0100 Improve estimate when first Parquet file is almost empty, and get exact cardinality count when we are using union by name (duckdb/duckdb#21345) CLI: Make bail on error the default in more situations (duckdb/duckdb#21344) Fixup 401bcf041f36f3abc39ecc6d50ba3dd336fc79d7: "When stress testing … (duckdb/duckdb#21329) CLI: Explicitly clean up shell state instead of letting static destructor order determine when it gets destroyed (duckdb/duckdb#21315) Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
krlmlr
added a commit
to krlmlr/duckdb-r-old
that referenced
this pull request
Mar 22, 2026
Date: 2026-03-13 10:09:43 +0100 Improve estimate when first Parquet file is almost empty, and get exact cardinality count when we are using union by name (duckdb/duckdb#21345) CLI: Make bail on error the default in more situations (duckdb/duckdb#21344) Fixup 401bcf041f36f3abc39ecc6d50ba3dd336fc79d7: "When stress testing … (duckdb/duckdb#21329) CLI: Explicitly clean up shell state instead of letting static destructor order determine when it gets destroyed (duckdb/duckdb#21315) Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
kaka11chen
pushed a commit
to AstroVela/vane
that referenced
this pull request
Aug 14, 2026
…ct cardinality count when we are using union by name (duckdb/duckdb#21345) Currently when reading Parquet files we depend heavily on the cardinality of the first Parquet file for our cardinality estimate (`initial_file_cardinality`). When that estimate is very low, we can be off by a lot. For example, if the first Parquet file has a single row, and we are reading 2000 files, we would currently estimate the table cardinality to be 2000 rows. This PR makes this a bit more robust by setting the estimate to at least 1000 rows per file if the first file is almost empty. In addition, when running with `union_by_name = true`, we have already read the metadata of all of the Parquet files and can therefore just use that cardinality instead of relying only on the first file. This gives us an exact cardinality for Parquet files read using `union_by_name = true`. Upstream-Commit: duckdb/duckdb@66a910f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Currently when reading Parquet files we depend heavily on the cardinality of the first Parquet file for our cardinality estimate (
initial_file_cardinality).When that estimate is very low, we can be off by a lot. For example, if the first Parquet file has a single row, and we are reading 2000 files, we would currently estimate the table cardinality to be 2000 rows. This PR makes this a bit more robust by setting the estimate to at least 1000 rows per file if the first file is almost empty.
In addition, when running with
union_by_name = true, we have already read the metadata of all of the Parquet files and can therefore just use that cardinality instead of relying only on the first file. This gives us an exact cardinality for Parquet files read usingunion_by_name = true.