Skip to content

[UT](be) improve if expr be UT coverage#64489

Open
jacktengg wants to merge 3 commits into
apache:masterfrom
jacktengg:wt-coverage-if
Open

[UT](be) improve if expr be UT coverage#64489
jacktengg wants to merge 3 commits into
apache:masterfrom
jacktengg:wt-coverage-if

Conversation

@jacktengg

@jacktengg jacktengg commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Before:

Filename Function Coverage Line Coverage Region Coverage Branch Coverage
be/src/exprs/function/if.cpp 66.67% (12/18) 35.49% (137/386) 36.63% (89/243) 27.21% (40/147)

After:

Filename Function Coverage Line Coverage Region Coverage Branch Coverage
be/src/exprs/function/if.cpp 100.00% (19/19) 93.37% (366/392) 88.93% (217/244) 88.44% (130/147)
-- -- -- --

Release note

None

Check List (For Author)

  • 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 code files have been changed.
      • Other reason
  • Behavior changed:

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

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

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

@hello-stephen

Copy link
Copy Markdown
Contributor

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

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@jacktengg

Copy link
Copy Markdown
Contributor Author

/review

@jacktengg

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review result: no blocking code issues found.

Critical checkpoint conclusions:

  • Goal and proof: This PR is focused on increasing BE unit-test coverage for FunctionIf; the new tests exercise scalar dispatch, generic/string execution, nullable then/else handling, NULL then/else branches, and nullable condition handling. The implementation change is limited to #ifdef BE_TEST wrappers used by those tests.
  • Scope: The change is small in behavioral surface: one test-only wrapper block in if.cpp plus one new BE unit test file. No production if() semantics are changed.
  • Concurrency and lifecycle: No new shared mutable runtime state, thread entry, locking, static initialization dependency, or special lifecycle management is introduced.
  • Config, compatibility, persistence, transactions: No new config items, wire/storage format changes, FE-BE protocol changes, persistence paths, or transaction/write paths are involved.
  • Parallel paths and conditions: I checked the FunctionIf call chain through SimpleFunctionFactory, nullif, and ifnull; the test-only direct wrappers are scoped to branches that are otherwise hard to reach through public factory execution.
  • Error handling and memory: New wrappers preserve Status returns. No new production allocation ownership or memory-tracking concern is introduced outside BE_TEST-only code.
  • Test coverage: be/test/CMakeLists.txt uses recursive globbing, so the new be/test/exprs/function/function_if_test.cpp is included in doris_be_test. The tests cover the relevant nullable/const/null and scalar/generic branches added for coverage.
  • Observability/docs: No new logs, metrics, or documentation are needed for this test-only coverage change.

Verification notes:

  • Existing inline review context was empty; no duplicate review thread issue applies.
  • User focus file had no additional focus points.
  • git diff --check passed for the touched files.
  • Local build-support/check-format.sh could not run because this runner does not have clang-format v16, but GitHub Clang Formatter is green for this PR.
  • I did not run BE UT locally because this checkout has no BE build/test tree. The completed GitHub BE UT (macOS) failure is environmental (JAVA version is 25, it must be JDK-17) and occurs before compiling this PR; Linux TeamCity BE compile/UT statuses were still queued during review.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28567 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 935bc646b69bc7b10cbd3474ece93442e011cf3f, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17715	3994	3978	3978
q2	q3	10790	1353	767	767
q4	4679	478	340	340
q5	7536	841	578	578
q6	176	166	132	132
q7	790	823	638	638
q8	9340	1564	1535	1535
q9	6254	4445	4390	4390
q10	6856	1803	1525	1525
q11	442	273	245	245
q12	628	425	283	283
q13	18129	3294	2767	2767
q14	276	257	241	241
q15	q16	821	777	706	706
q17	1128	966	977	966
q18	6810	5735	5571	5571
q19	1316	1258	994	994
q20	506	389	261	261
q21	5860	2629	2347	2347
q22	419	353	303	303
Total cold run time: 100471 ms
Total hot run time: 28567 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4309	4227	4296	4227
q2	q3	4506	4939	4310	4310
q4	2036	2137	1376	1376
q5	4383	4241	4221	4221
q6	224	175	125	125
q7	1719	1624	1420	1420
q8	2691	2190	2139	2139
q9	7848	7926	7829	7829
q10	4787	4771	4272	4272
q11	549	394	369	369
q12	743	754	534	534
q13	3283	3800	2933	2933
q14	283	298	270	270
q15	q16	715	726	719	719
q17	1354	1294	1317	1294
q18	7923	7325	7401	7325
q19	1112	1101	1085	1085
q20	2206	2213	1934	1934
q21	5149	4522	4376	4376
q22	514	449	397	397
Total cold run time: 56334 ms
Total hot run time: 51155 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 167775 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 935bc646b69bc7b10cbd3474ece93442e011cf3f, data reload: false

query5	4323	647	469	469
query6	451	186	168	168
query7	4835	556	287	287
query8	347	203	191	191
query9	8743	3955	3944	3944
query10	438	303	252	252
query11	5944	2335	2182	2182
query12	158	100	95	95
query13	1262	593	423	423
query14	6885	5327	5028	5028
query14_1	4323	4326	4304	4304
query15	203	194	173	173
query16	963	450	431	431
query17	1092	687	560	560
query18	2595	462	324	324
query19	197	176	136	136
query20	112	105	101	101
query21	215	134	115	115
query22	13614	13539	13357	13357
query23	17240	16554	16073	16073
query23_1	16139	16269	16262	16262
query24	7707	1758	1277	1277
query24_1	1288	1306	1267	1267
query25	598	458	397	397
query26	1314	315	169	169
query27	2632	559	341	341
query28	4536	2007	2021	2007
query29	1073	632	496	496
query30	303	245	196	196
query31	1162	1082	973	973
query32	117	61	58	58
query33	552	315	243	243
query34	1205	1134	659	659
query35	738	757	664	664
query36	1389	1413	1271	1271
query37	165	110	88	88
query38	3261	3197	3046	3046
query39	929	914	881	881
query39_1	902	882	858	858
query40	215	120	98	98
query41	62	60	62	60
query42	91	91	89	89
query43	310	317	275	275
query44	
query45	196	185	179	179
query46	1077	1130	738	738
query47	2374	2352	2248	2248
query48	383	408	290	290
query49	617	444	345	345
query50	1003	372	269	269
query51	4309	4268	4224	4224
query52	85	86	75	75
query53	250	261	191	191
query54	265	213	186	186
query55	75	73	68	68
query56	224	218	224	218
query57	1428	1399	1304	1304
query58	273	205	206	205
query59	1532	1634	1447	1447
query60	277	234	224	224
query61	156	156	157	156
query62	695	645	595	595
query63	226	184	184	184
query64	2508	758	634	634
query65	
query66	1803	459	336	336
query67	29728	29657	29413	29413
query68	
query69	452	307	262	262
query70	978	958	939	939
query71	292	221	208	208
query72	2942	2631	2385	2385
query73	890	781	421	421
query74	5195	4948	4756	4756
query75	2660	2555	2225	2225
query76	2333	1157	744	744
query77	344	386	287	287
query78	12364	12385	11888	11888
query79	1508	1000	776	776
query80	569	467	396	396
query81	452	290	246	246
query82	588	152	114	114
query83	373	277	252	252
query84	
query85	845	494	404	404
query86	359	316	280	280
query87	3356	3353	3184	3184
query88	3598	2730	2703	2703
query89	421	379	327	327
query90	1862	173	167	167
query91	176	158	133	133
query92	61	57	57	57
query93	1485	1406	898	898
query94	566	346	300	300
query95	674	370	349	349
query96	1107	795	331	331
query97	2677	2688	2561	2561
query98	213	208	204	204
query99	1133	1178	1028	1028
Total cold run time: 250997 ms
Total hot run time: 167775 ms

Issue Number: close #xxx

Related PR: #xxx

Problem Summary: Rewriting nullif to if must not be controlled by disable_nereids_expression_rules, otherwise users could disable the rewrite and still require BE FunctionIf support for nullif. This changes NullIfToIf from a pattern rule with an ExpressionRuleType bit into a direct visitor-based expression rewrite rule, and adds coverage that the rewrite still runs when all expression rule bits are disabled.

None

- Test: Static check / Not run
    - git diff --check -- fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionRuleType.java fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/NullIfToIf.java fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/rules/NullIfToIfTest.java
    - Build and tests not run per request.
- Behavior changed: No
- Does this need documentation: No

Issue Number: close #xxx

Related PR: #xxx

Problem Summary: FunctionIf in BE is only reached through nullif because SQL if is rewritten to VectorizedIfExpr. The nullif semantics can be represented as if(first = second, null, first), so this adds a Nereids expression normalization rule to rewrite remaining NullIf expressions to If after existing constant folding. The nullable-dependent conditional simplification also falls back to the same rewrite so NullIf does not survive that path.

None

- Test: Static check / Not run
    - git diff --cached --check
    - Build and tests not run per request.
- Behavior changed: No
- Does this need documentation: No
Issue Number: close #xxx

Related PR: #xxx

Problem Summary: NullIfToIf is a mandatory visitor-based expression rewrite rule so it is not controlled by disable_nereids_expression_rules. It was still placed inside the bottomUp pattern-rule varargs in ExpressionNormalization, which only accepts ExpressionPatternRuleFactory and causes FE compilation to fail. Split normalization into a pre-fold bottom-up pattern batch, the mandatory NullIfToIf rule, and the remaining bottom-up pattern batch.

None

- Test: Static check / Not run
    - git diff --check -- fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionNormalization.java
    - Build and tests not run per request.
- Behavior changed: No
- Does this need documentation: No
zclllyybb added a commit that referenced this pull request Jun 15, 2026
…mpt (#64536)

Problem Summary: Automated code review runs relied on the reviewer to
infer which module-specific AGENTS.md files apply to a pull request.
Recent Litefuse traces showed that reviews often skipped ancestor guides
such as the repository root AGENTS.md, fe/AGENTS.md, and
be/test/AGENTS.md even when the changed files made them applicable. This
change fetches the PR changed file list, derives every existing
AGENTS.md file from the changed file ancestor directories, records the
list in the review context, and injects the required guide paths
directly into the first Codex review prompt.

We tested 5 PRs that did not read the AGENTS.md file during previous
pipeline runs, and the new results are as follows:

| Origin PR | Test PR | Run | Litefuse Trace | Result |
|---|---:|---:|---|---|
| #64478 | zclllyybb#36 | `27536249602` |
`d76b77ac4e0d52d96f413b154c9f2571` | Read All |
| #64458 | zclllyybb#37 | `27536258049` |
`8db34388a8379acdcd9e48720f11225f` | Read All |
| #64392 | zclllyybb#38 | `27536266784` |
`a5e37fba03375a9517f7a67e33f70d39` | Read All |
| #64489 | zclllyybb#39 | `27536275680` |
`22ace18d70ece96b0ca7fa73123b62da` | Read All |
| #64419 | zclllyybb#41 | `27538239601` |
`1803c040e4140d61e840e4e1526190e7` | Read All |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants