Skip to content

Commit

Permalink
explain
Browse files Browse the repository at this point in the history
  • Loading branch information
nik9000 committed Jul 11, 2024
1 parent 0eb2958 commit 32a03b2
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.elasticsearch.xpack.esql.enrich.EnrichLookupService;
import org.elasticsearch.xpack.esql.evaluator.EvalMapper;
import org.elasticsearch.xpack.esql.evaluator.command.GrokEvaluatorExtracter;
import org.elasticsearch.xpack.esql.plan.logical.local.LocalRelation;
import org.elasticsearch.xpack.esql.plan.physical.AggregateExec;
import org.elasticsearch.xpack.esql.plan.physical.DissectExec;
import org.elasticsearch.xpack.esql.plan.physical.EnrichExec;
Expand Down Expand Up @@ -553,10 +554,18 @@ private PhysicalOperation planHashJoin(HashJoinExec join, LocalExecutionPlannerC
return source.with(new ProjectOperatorFactory(projection), layout);
}

/**
* Convert a {@link HashJoinExec} into an {@link EvalOperatorFactory eval}.
* This is mostly useful when we're merging a table without any lookup fields
* and only works for single-row {@link LocalRelation}s.
*/
private PhysicalOperation planHashJoinAsEval(PhysicalOperation source, HashJoinExec join, LocalExecutionPlannerContext context) {
Block[] blocks = join.joinData().supplier().get();
try {
for (int b = 0; b < join.joinData().output().size(); b++) {
if (blocks[b].getPositionCount() != 1) {
throw new IllegalArgumentException("EVAL-based HashJoins only work for single-row tables");
}
Attribute target = join.joinData().output().get(b);
Literal lit = new Literal(target.source(), BlockUtils.toJavaObject(blocks[b], 0), target.dataType());
ExpressionEvaluator.Factory evaluatorSupplier = EvalMapper.toEvaluator(lit, source.layout);
Expand Down

0 comments on commit 32a03b2

Please sign in to comment.