| 3107 | } |
| 3108 | |
| 3109 | HashJoinNodeOptions GenerateHashJoinNodeOptions(Random64Bit& rng, int num_left_cols, |
| 3110 | int num_right_cols) { |
| 3111 | HashJoinNodeOptions opts; |
| 3112 | opts.join_type = static_cast<JoinType>(rng.from_range(0, 7)); |
| 3113 | bool is_left_join = opts.join_type == JoinType::LEFT_SEMI || |
| 3114 | opts.join_type == JoinType::LEFT_ANTI || |
| 3115 | opts.join_type == JoinType::LEFT_OUTER; |
| 3116 | bool is_right_join = opts.join_type == JoinType::RIGHT_SEMI || |
| 3117 | opts.join_type == JoinType::RIGHT_ANTI || |
| 3118 | opts.join_type == JoinType::RIGHT_OUTER; |
| 3119 | |
| 3120 | int num_keys = rng.from_range(1, std::min(num_left_cols, num_right_cols)); |
| 3121 | for (int i = 0; i < num_left_cols; i++) { |
| 3122 | bool is_out = rng.from_range(0, 2) != 2; |
| 3123 | if (is_out && !is_right_join) opts.left_output.push_back(FieldRef(i)); |
| 3124 | } |
| 3125 | for (int i = 0; i < num_right_cols; i++) { |
| 3126 | bool is_out = rng.from_range(0, 2) == 2; |
| 3127 | if (is_out && !is_left_join) opts.right_output.push_back(FieldRef(i)); |
| 3128 | } |
| 3129 | // We need at least one output |
| 3130 | if (opts.right_output.empty() && opts.left_output.empty()) { |
| 3131 | if (is_left_join) { |
| 3132 | int col = rng.from_range(0, num_left_cols - 1); |
| 3133 | opts.left_output.push_back(FieldRef(col)); |
| 3134 | } else if (is_right_join) { |
| 3135 | int col = rng.from_range(0, num_right_cols - 1); |
| 3136 | opts.right_output.push_back(FieldRef(col)); |
| 3137 | } else { |
| 3138 | if (rng.from_range(0, 1) == 0) { |
| 3139 | int col = rng.from_range(0, num_left_cols - 1); |
| 3140 | opts.left_output.push_back(FieldRef(col)); |
| 3141 | } else { |
| 3142 | int col = rng.from_range(0, num_right_cols - 1); |
| 3143 | opts.right_output.push_back(FieldRef(col)); |
| 3144 | } |
| 3145 | } |
| 3146 | } |
| 3147 | |
| 3148 | for (int i = 0; i < num_keys; i++) { |
| 3149 | int left = rng.from_range(0, num_left_cols - 1); |
| 3150 | int right = rng.from_range(0, num_right_cols - 1); |
| 3151 | bool is_or_eq = rng.from_range(0, 1) == 0; |
| 3152 | opts.left_keys.push_back(FieldRef(left)); |
| 3153 | opts.right_keys.push_back(FieldRef(right)); |
| 3154 | opts.key_cmp.push_back(is_or_eq ? JoinKeyCmp::IS : JoinKeyCmp::EQ); |
| 3155 | } |
| 3156 | return opts; |
| 3157 | } |
| 3158 | |
| 3159 | void TestSingleChainOfHashJoins(Random64Bit& rng) { |
| 3160 | int num_joins = rng.from_range(2, 5); |
no test coverage detected