Skip to content

Conversation

05st
Copy link
Contributor

@05st 05st commented Jul 16, 2025

In Value::createDefaultValue we were initializing a union value with a single null value as the default child. This resulted in the child lacking required information when copying from certain types. For example, childrenSize of the child would be 0, and so if the selected field turned out to be a struct (with more than one field), none of its fields would be copied, resulting in an empty output. E.g.

return union_value(a := struct_pack(b := 2))
{}

when the correct output should be {b: 2}

The solution implemented here was to just set up default union values with no children, and create the default child value during copying once we know the selected field.

@05st 05st requested a review from acquamarin July 16, 2025 17:40
Copy link

codecov bot commented Jul 17, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Project coverage is 85.94%. Comparing base (34b1eb7) to head (5da8b0d).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/common/types/value/value.cpp 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5772      +/-   ##
==========================================
- Coverage   85.94%   85.94%   -0.01%     
==========================================
  Files        1620     1620              
  Lines       73512    73510       -2     
  Branches     8788     8783       -5     
==========================================
- Hits        63181    63179       -2     
  Misses      10107    10107              
  Partials      224      224              
Flag Coverage Δ
extension 63.36% <87.50%> (+<0.01%) ⬆️
in-mem 81.67% <87.50%> (-0.01%) ⬇️
on-disk 86.53% <87.50%> (-0.01%) ⬇️
recovery 86.53% <87.50%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Benchmark Result

Master commit hash: 309be4327d91ca8213873c907d8d3a78e9848a6c
Branch commit hash: f4b1919427bf1cc2add57500284f3f4facdb6f77

Query Group Query Name Mean Time - Commit (ms) Mean Time - Master (ms) Diff
ldbc_snb_is q32 3.15 5.45 -2.29 (-42.11%)
ldbc_snb_is q33 13.33 18.64 -5.31 (-28.47%)
recursive_join recursive-join-sparse 6.56 10.84 -4.28 (-39.47%)
Other queries
Query Group Query Name Mean Time - Commit (ms) Mean Time - Master (ms) Diff
aggregation q24 709.02 698.81 10.21 (1.46%)
aggregation q28 7605.20 7941.83 -336.63 (-4.24%)
filter q14 59.86 58.77 1.09 (1.86%)
filter q15 60.63 58.20 2.43 (4.17%)
filter q16 276.63 274.04 2.59 (0.95%)
filter q17 380.85 381.02 -0.17 (-0.04%)
filter q18 1831.54 1823.42 8.13 (0.45%)
filter zonemap-node 22.86 22.04 0.82 (3.73%)
filter zonemap-node-lhs-cast 23.13 22.46 0.67 (2.98%)
filter zonemap-node-null 22.85 22.03 0.82 (3.72%)
filter zonemap-rel 5604.02 5488.02 116.01 (2.11%)
fixed_size_expr_evaluator q07 620.65 625.97 -5.32 (-0.85%)
fixed_size_expr_evaluator q08 903.31 912.32 -9.01 (-0.99%)
fixed_size_expr_evaluator q09 902.71 910.55 -7.84 (-0.86%)
fixed_size_expr_evaluator q10 190.71 198.23 -7.52 (-3.79%)
fixed_size_expr_evaluator q11 189.76 198.80 -9.04 (-4.55%)
fixed_size_expr_evaluator q12 168.42 175.48 -7.06 (-4.03%)
fixed_size_expr_evaluator q13 1503.97 1505.00 -1.03 (-0.07%)
fixed_size_seq_scan q23 45.23 56.25 -11.02 (-19.59%)
join q29 746.49 851.43 -104.93 (-12.32%)
join q30 1751.80 1842.69 -90.88 (-4.93%)
join q31 7.88 7.52 0.36 (4.75%)
join SelectiveTwoHopJoin 65.31 59.03 6.28 (10.63%)
ldbc_snb_ic q35 10.44 10.02 0.42 (4.20%)
ldbc_snb_ic q36 93.95 97.88 -3.93 (-4.02%)
ldbc_snb_is q34 1.22 1.17 0.06 (4.74%)
limit push-down-limit-into-distinct 1919.11 2033.71 -114.60 (-5.63%)
multi-rel multi-rel-large-scan 1446.23 1494.41 -48.19 (-3.22%)
multi-rel multi-rel-lookup 9.29 9.26 0.03 (0.27%)
multi-rel multi-rel-small-scan 200.44 172.19 28.25 (16.40%)
order_by q25 62.07 62.61 -0.54 (-0.86%)
order_by q26 392.08 380.26 11.82 (3.11%)
order_by q27 1308.84 1311.51 -2.67 (-0.20%)
recursive_join recursive-join-bidirection 386.24 372.98 13.26 (3.56%)
recursive_join recursive-join-dense 7059.80 7140.45 -80.65 (-1.13%)
recursive_join recursive-join-path 23646.21 23856.18 -209.96 (-0.88%)
recursive_join recursive-join-trail 7014.65 7108.18 -93.53 (-1.32%)
scan_after_filter q01 103.60 104.28 -0.68 (-0.65%)
scan_after_filter q02 89.85 89.86 -0.02 (-0.02%)
shortest_path_ldbc100 q37 84.59 78.04 6.54 (8.38%)
shortest_path_ldbc100 q38 297.64 308.47 -10.83 (-3.51%)
shortest_path_ldbc100 q39 89.08 92.43 -3.35 (-3.62%)
shortest_path_ldbc100 q40 529.34 485.60 43.74 (9.01%)
var_size_expr_evaluator q03 2140.01 2139.12 0.89 (0.04%)
var_size_expr_evaluator q04 2142.85 2166.50 -23.65 (-1.09%)
var_size_expr_evaluator q05 2604.43 2559.38 45.04 (1.76%)
var_size_expr_evaluator q06 1270.17 1265.16 5.02 (0.40%)
var_size_seq_scan q19 1363.04 1380.99 -17.94 (-1.30%)
var_size_seq_scan q20 2648.26 2629.88 18.39 (0.70%)
var_size_seq_scan q21 2185.00 2220.53 -35.53 (-1.60%)
var_size_seq_scan q22 109.62 108.58 1.04 (0.96%)

} else {
childValue->setNull(false);
childValue->copyFromRowLayout(unionValues);
children[0] = std::make_unique<Value>(std::move(childValue));
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit confused there?
When will the children by empty? Since you always push a value to the createDefaultValue function:

ase LogicalTypeID::UNION: {
        // We can't create a default value for the union since the
        // selected variant is runtime information. Default value
        // is initialized when copying (see Value::copyFromUnion).
        return Value(dataType.copy(), std::vector<std::unique_ptr<Value>>{});

@05st 05st merged commit eb52db9 into master Jul 17, 2025
28 checks passed
@05st 05st deleted the union-copy-fix branch July 17, 2025 13:10
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