Skip to content
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

[enhance](orc) Optimize ORC Predicate Pushdown for OR-connected Predicate #43255

Merged
merged 29 commits into from
Nov 22, 2024

Conversation

suxiaogang223
Copy link
Contributor

@suxiaogang223 suxiaogang223 commented Nov 5, 2024

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:
This issue addresses a limitation in Apache Doris where only predicates joined by AND are pushed down to the ORC reader, leaving OR-connected predicates unoptimized. By extending pushdown functionality to handle these OR conditions, the aim is to better leverage ORC’s predicate pushdown capabilities, reducing data reads and improving query performance.

Check List (For Committer)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No colde files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.
  • Release note

    None

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.h Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
@suxiaogang223
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 37.88% (9849/26001)
Line Coverage: 29.03% (81909/282154)
Region Coverage: 28.24% (42185/149374)
Branch Coverage: 24.83% (21408/86206)
Coverage Report: http://coverage.selectdb-in.cc/coverage/5ebe1d5c1da127bdc70c7a871ced06d390ccce62_5ebe1d5c1da127bdc70c7a871ced06d390ccce62/report/index.html

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/test/vec/exec/orc_reader_test.cpp Show resolved Hide resolved
@suxiaogang223
Copy link
Contributor Author

run buildall

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/test/testutil/desc_tbl_builder.cpp Show resolved Hide resolved
be/test/testutil/desc_tbl_builder.h Show resolved Hide resolved
@suxiaogang223
Copy link
Contributor Author

run buildall

@suxiaogang223 suxiaogang223 force-pushed the fix_orc_pushdown2 branch 2 times, most recently from 921f87f to 5056b99 Compare November 7, 2024 14:32
@suxiaogang223
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 38.11% (9910/26007)
Line Coverage: 29.23% (82500/282281)
Region Coverage: 28.45% (42525/149455)
Branch Coverage: 25.07% (21622/86260)
Coverage Report: http://coverage.selectdb-in.cc/coverage/5056b99e1268c1ab03ba3f30355c2f082a8ae5f1_5056b99e1268c1ab03ba3f30355c2f082a8ae5f1/report/index.html

@suxiaogang223
Copy link
Contributor Author

run external

1 similar comment
@suxiaogang223
Copy link
Contributor Author

run external

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
@suxiaogang223
Copy link
Contributor Author

run external

@suxiaogang223
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 38.15% (9931/26030)
Line Coverage: 29.30% (82887/282911)
Region Coverage: 28.45% (42696/150068)
Branch Coverage: 25.03% (21667/86562)
Coverage Report: http://coverage.selectdb-in.cc/coverage/22388b7bbe19673f8616d7cb9be19701415fc9b8_22388b7bbe19673f8616d7cb9be19701415fc9b8/report/index.html

be/src/vec/exec/format/orc/vorc_reader.cpp Outdated Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Outdated Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Outdated Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Outdated Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Outdated Show resolved Hide resolved
bool OrcReader::_init_search_argument(
std::unordered_map<std::string, ColumnValueRangeType>* colname_to_value_range) {
if ((!_enable_filter_by_min_max) || colname_to_value_range->empty()) {
bool OrcReader::_init_search_argument(const VExprContextSPtrs& conjuncts) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a certain query, the conjuncts is identical in all orc readers.
So I think we can just init search argument once and use the result for every orc reader?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is possible to cache searchArgument into member variables of OrcReader

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
@suxiaogang223
Copy link
Contributor Author

run external

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
be/src/vec/exec/format/orc/vorc_reader.cpp Show resolved Hide resolved
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Nov 20, 2024
Copy link
Contributor

PR approved by at least one committer and no changes requested.

Copy link
Contributor

PR approved by anyone and no changes requested.

Copy link
Contributor

@kaka11chen kaka11chen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@morningman morningman merged commit 14711d7 into apache:master Nov 22, 2024
26 of 29 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 22, 2024
…cate (#43255)

### What problem does this PR solve?

Problem Summary:
This issue addresses a limitation in Apache Doris where only predicates
joined by AND are pushed down to the ORC reader, leaving OR-connected
predicates unoptimized. By extending pushdown functionality to handle
these OR conditions, the aim is to better leverage ORC’s predicate
pushdown capabilities, reducing data reads and improving query
performance.
github-actions bot pushed a commit that referenced this pull request Nov 22, 2024
…cate (#43255)

### What problem does this PR solve?

Problem Summary:
This issue addresses a limitation in Apache Doris where only predicates
joined by AND are pushed down to the ORC reader, leaving OR-connected
predicates unoptimized. By extending pushdown functionality to handle
these OR conditions, the aim is to better leverage ORC’s predicate
pushdown capabilities, reducing data reads and improving query
performance.
yiguolei pushed a commit that referenced this pull request Nov 22, 2024
morningman pushed a commit that referenced this pull request Nov 28, 2024
@suxiaogang223 suxiaogang223 deleted the fix_orc_pushdown2 branch November 29, 2024 03:46
morningman pushed a commit that referenced this pull request Nov 29, 2024
### What problem does this PR solve?
In the old logic, the `check_expr_can_push_down` function does not check
whether the `orc::Literal` are constructed successfully, but only checks
during `build_search_argument`. However, if it is found that the
`orc::Literal` fails to be constructed after `builder->startNot`, it
will fail because the builder cannot end `startNot`.
Therefore, we advance the behavior of constructing `orc::Literal` to the
`check_expr_can_push_down` function and save the result to the map, so
that it will never fail in the `build_search_argument` phase.

Related PR: #43255
morningman pushed a commit to morningman/doris that referenced this pull request Nov 29, 2024
…4615)

In the old logic, the `check_expr_can_push_down` function does not check
whether the `orc::Literal` are constructed successfully, but only checks
during `build_search_argument`. However, if it is found that the
`orc::Literal` fails to be constructed after `builder->startNot`, it
will fail because the builder cannot end `startNot`.
Therefore, we advance the behavior of constructing `orc::Literal` to the
`check_expr_can_push_down` function and save the result to the map, so
that it will never fail in the `build_search_argument` phase.

Related PR: apache#43255
morningman added a commit to morningman/doris that referenced this pull request Dec 6, 2024
yiguolei pushed a commit that referenced this pull request Dec 6, 2024
Revert "branch-2.1: [enhance](orc) Optimize ORC Predicate Pushdown for
OR-connected Predicate #43255 (#44438)"
Revert "[fix](orc) check all the cases before build_search_argument
(#44615) (#44801)"
morningman pushed a commit that referenced this pull request Dec 18, 2024
…ins (#45104)

### What problem does this PR solve?

Related PR: #43255 

Problem Summary:
Should ignore null values when the literals of in_predicate contains
null value, like `in (1, null)`
For example, init table in hive:
```sql
CREATE TABLE sample_orc_table (
    id INT,
    name STRING,
    age INT
)
STORED AS ORC;
INSERT INTO TABLE sample_orc_table VALUES
    (1, 'Alice', 25),
    (2, NULL, NULL); 
```
select result in Doris should be:
```sql
mysql> select * from sample_orc_table where age in (null,25);
+------+-------+------+
| id   | name  | age  |
+------+-------+------+
|    1 | Alice |   25 |
+------+-------+------+
1 row in set (0.30 sec)

mysql> select * from sample_orc_table where age in (25);
+------+-------+------+
| id   | name  | age  |
+------+-------+------+
|    1 | Alice |   25 |
+------+-------+------+
1 row in set (0.27 sec)

mysql> select * from sample_orc_table where age in (null);
Empty set (0.01 sec)

mysql> select * from sample_orc_table where age is null;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    2 | NULL | NULL |
+------+------+------+
1 row in set (0.11 sec)
```
github-actions bot pushed a commit that referenced this pull request Dec 18, 2024
…ins (#45104)

### What problem does this PR solve?

Related PR: #43255 

Problem Summary:
Should ignore null values when the literals of in_predicate contains
null value, like `in (1, null)`
For example, init table in hive:
```sql
CREATE TABLE sample_orc_table (
    id INT,
    name STRING,
    age INT
)
STORED AS ORC;
INSERT INTO TABLE sample_orc_table VALUES
    (1, 'Alice', 25),
    (2, NULL, NULL); 
```
select result in Doris should be:
```sql
mysql> select * from sample_orc_table where age in (null,25);
+------+-------+------+
| id   | name  | age  |
+------+-------+------+
|    1 | Alice |   25 |
+------+-------+------+
1 row in set (0.30 sec)

mysql> select * from sample_orc_table where age in (25);
+------+-------+------+
| id   | name  | age  |
+------+-------+------+
|    1 | Alice |   25 |
+------+-------+------+
1 row in set (0.27 sec)

mysql> select * from sample_orc_table where age in (null);
Empty set (0.01 sec)

mysql> select * from sample_orc_table where age is null;
+------+------+------+
| id   | name | age  |
+------+------+------+
|    2 | NULL | NULL |
+------+------+------+
1 row in set (0.11 sec)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. dev/2.1.x-experimental dev/3.0.4-merged reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants