-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[refactoring](multi-catalog)data_lake_reader_refactoring. #62306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kaka11chen
wants to merge
20
commits into
master
Choose a base branch
from
data_lake_reader_refactoring
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fcad2a1
[refactoring](multi-catalog)data_lake_reader_refactoring.
kaka11chen 5420e85
1. Refactor count agg push down.
kaka11chen 9f8c8eb
fix.
kaka11chen 0c6293f
unify reader init.
kaka11chen c7272c2
[refactor](be) Unify all standalone readers to use NVI init_reader
kaka11chen e1b3a02
[refactor](be) Apply NVI template to get_next_block
kaka11chen bc381e5
[refactor](be) Introduce TableFormatReader with auto column filling
kaka11chen 09c4b71
[refactor](be) Move column-filling logic from GenericReader to TableF…
kaka11chen 08bccb3
[refactor](be) Move fill-column computation to on_before_init_reader
kaka11chen 00ff751
[fix](be) Fix standalone reader init for Parquet and ORC
kaka11chen 9737aed
update.
kaka11chen e4b7793
[refactor](be) Migrate parquet test files to new NVI init_reader API
kaka11chen 79fa1d8
fix
kaka11chen 7afb6dc
remove _fill_columns_from_path.
kaka11chen e0e1f6b
update
kaka11chen 4e4c5cf
update.
kaka11chen 55d1881
update push down agg.
kaka11chen 5b2f94c
fix v3 (#62305)
hubgeter 3e44d1e
fix build && type (#62352)
hubgeter 29774b4
remove compile check
kaka11chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "exprs/vexpr_fwd.h" | ||
|
|
||
| namespace doris { | ||
| class SlotDescriptor; | ||
|
|
||
| /// Column categories for table format reading. | ||
| /// | ||
| /// Each column requested by the query is classified into one of these categories. | ||
| /// The category determines how the column's value is obtained: | ||
| /// - REGULAR: Read directly from the data file (Parquet/ORC). | ||
| /// If the column is absent from a file (schema evolution), | ||
| /// its default_expr is used to produce a default value. | ||
| /// - PARTITION_KEY: Filled from partition metadata (e.g. Hive path partitions). | ||
| /// - SYNTHESIZED: Never in the data file; fully computed at runtime | ||
| /// (e.g. Doris V2 __DORIS_ICEBERG_ROWID_COL__). | ||
| /// - GENERATED: May or may not exist in the data file. If present but null, | ||
| /// the value is backfilled at runtime (e.g. Iceberg V3 _row_id). | ||
| enum class ColumnCategory { | ||
| REGULAR, | ||
| PARTITION_KEY, | ||
| SYNTHESIZED, | ||
| GENERATED, | ||
| }; | ||
|
|
||
| /// Describes a column requested by the query, along with its category. | ||
| struct ColumnDescriptor { | ||
| std::string name; | ||
| const SlotDescriptor* slot_desc = nullptr; | ||
| ColumnCategory category = ColumnCategory::REGULAR; | ||
| /// Default value expression when this column is missing from the data file. | ||
| /// nullptr means fill with NULL. Built once per table scan in FileScanner. | ||
| VExprContextSPtr default_expr; | ||
| }; | ||
|
|
||
| } // namespace doris |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <memory> | ||
|
|
||
| #include "common/status.h" | ||
| #include "core/block/block.h" | ||
| #include "format/generic_reader.h" | ||
|
|
||
| namespace doris { | ||
|
|
||
| /// A lightweight reader that emits row counts without reading any actual data. | ||
| /// Used as a decorator to replace the real reader when COUNT(*) push down is active. | ||
| /// | ||
| /// Instead of duplicating the COUNT short-circuit logic in every format reader | ||
| /// (ORC, Parquet, etc.), FileScanner creates a CountReader after the real reader | ||
| /// is initialized and the total row count is known. The CountReader then serves | ||
| /// all subsequent get_next_block calls by simply resizing columns. | ||
| /// | ||
| /// This cleanly separates the "how many rows" concern from the actual data reading, | ||
| /// eliminating duplicated COUNT blocks across format readers. | ||
| class CountReader : public GenericReader { | ||
| public: | ||
| /// @param total_rows Total number of rows to emit (post-filter). | ||
| /// @param batch_size Maximum rows per batch. | ||
| /// @param inner_reader The original reader, kept alive for profile collection | ||
| /// and lifecycle management. Ownership is transferred. | ||
| CountReader(int64_t total_rows, size_t batch_size, | ||
| std::unique_ptr<GenericReader> inner_reader = nullptr) | ||
| : _remaining_rows(total_rows), | ||
| _batch_size(batch_size), | ||
| _inner_reader(std::move(inner_reader)) { | ||
| set_push_down_agg_type(TPushAggOp::type::COUNT); | ||
| } | ||
|
|
||
| ~CountReader() override = default; | ||
|
|
||
| Status _do_get_next_block(Block* block, size_t* read_rows, bool* eof) override { | ||
| auto rows = std::min(_remaining_rows, static_cast<int64_t>(_batch_size)); | ||
| _remaining_rows -= rows; | ||
|
|
||
| auto mutate_columns = block->mutate_columns(); | ||
| for (auto& col : mutate_columns) { | ||
| col->resize(rows); | ||
| } | ||
| block->set_columns(std::move(mutate_columns)); | ||
|
|
||
| *read_rows = rows; | ||
| *eof = (_remaining_rows == 0); | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| /// CountReader counts rows by definition. | ||
| bool count_read_rows() override { return true; } | ||
|
|
||
| /// Delegate to inner reader if available, otherwise return our total. | ||
| int64_t get_total_rows() const override { | ||
| return _inner_reader ? _inner_reader->get_total_rows() : _initial_total_rows(); | ||
| } | ||
|
|
||
| Status close() override { | ||
| if (_inner_reader) { | ||
| return _inner_reader->close(); | ||
| } | ||
| return Status::OK(); | ||
| } | ||
|
|
||
| /// Access the inner reader for profile collection or other lifecycle needs. | ||
| GenericReader* inner_reader() const { return _inner_reader.get(); } | ||
|
|
||
| protected: | ||
| void _collect_profile_before_close() override { | ||
| if (_inner_reader) { | ||
| _inner_reader->collect_profile_before_close(); | ||
| } | ||
| } | ||
|
|
||
| private: | ||
| int64_t _initial_total_rows() const { return _remaining_rows; } | ||
|
|
||
| int64_t _remaining_rows; | ||
| size_t _batch_size; | ||
| std::unique_ptr<GenericReader> _inner_reader; | ||
| }; | ||
|
|
||
| } // namespace doris | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CountReader::get_total_rows() falls back to _initial_total_rows(), but _initial_total_rows() returns _remaining_rows, which decreases as batches are emitted. This makes get_total_rows() time-dependent and can underreport after reading starts. Store the initial total rows in a separate member (e.g., _total_rows) and return that when there is no inner reader.