Source:
<code>public ExecutionPlan build(PlannerContext plannerContext, ProjectionBuilder projectionBuilder, int limitHint, int offsetHint, @Nullable OrderBy order, @Nullable Integer pageSizeHint, Row params, SubQueryResults subQueryResults) { var executionPlan = source.build( plannerContext, projectionBuilder, TopN.NO_LIMIT, TopN.NO_OFFSET, null, null, params, subQueryResults ); if (executionPlan.resultDescription().hasRemainingLimitOrOffset()) { executionPlan = Merge.ensureOnHandler(executionPlan, plannerContext); } if (!source.outputs().equals(outputs)) { EvalProjection evalProjection = new EvalProjection( InputColumns.create(outputs, new InputColumns.SourceSymbols(source.outputs())) ); executionPlan.addProjection(evalProjection); } int limit = DataTypes.INTEGER.value( evaluate( plannerContext.transactionContext(), plannerContext.functions(), this.limit, params, subQueryResults ) ); int offset = DataTypes.INTEGER.value( evaluate( plannerContext.transactionContext(), plannerContext.functions(), this.offset, params, subQueryResults ) ); var inputColOutputs = InputColumn.mapToInputColumns(outputs); executionPlan.addProjection( new TopNDistinctProjection( limit + offset, inputColOutputs, source.preferShardProjections() ? RowGranularity.SHARD : RowGranularity.CLUSTER ) ); boolean onHandler = ExecutionPhases.executesOnHandler( plannerContext.handlerNode(), executionPlan.resultDescription().nodeIds()); if (!onHandler || source.preferShardProjections()) { if (!onHandler) { executionPlan = Merge.ensureOnHandler(executionPlan, plannerContext); } TopNDistinctProjection topNDistinct = new TopNDistinctProjection( limit + offset, inputColOutputs, RowGranularity.CLUSTER ); executionPlan.addProjection(topNDistinct); if (offset > 0) { executionPlan.addProjection( <START> new TopNProjection(limit, offset, Symbols.typeView(topNDistinct.outputs())) <END> ); } } return executionPlan; }</code><technical_language>limit = limit + offset also</technical_language>

Target:
public ExecutionPlan build(PlannerContext plannerContext, ProjectionBuilder projectionBuilder, int limitHint, int offsetHint, @Nullable OrderBy order, @Nullable Integer pageSizeHint, Row params, SubQueryResults subQueryResults) { var executionPlan = source.build( plannerContext, projectionBuilder, TopN.NO_LIMIT, TopN.NO_OFFSET, null, null, params, subQueryResults ); if (executionPlan.resultDescription().hasRemainingLimitOrOffset()) { executionPlan = Merge.ensureOnHandler(executionPlan, plannerContext); } if (!source.outputs().equals(outputs)) { EvalProjection evalProjection = new EvalProjection( InputColumns.create(outputs, new InputColumns.SourceSymbols(source.outputs())) ); executionPlan.addProjection(evalProjection); } int limit = DataTypes.INTEGER.value( evaluate( plannerContext.transactionContext(), plannerContext.functions(), this.limit, params, subQueryResults ) ); int offset = DataTypes.INTEGER.value( evaluate( plannerContext.transactionContext(), plannerContext.functions(), this.offset, params, subQueryResults ) ); var inputColOutputs = InputColumn.mapToInputColumns(outputs); executionPlan.addProjection( new TopNDistinctProjection( limit + offset, inputColOutputs, source.preferShardProjections() ? RowGranularity.SHARD : RowGranularity.CLUSTER ) ); boolean onHandler = ExecutionPhases.executesOnHandler( plannerContext.handlerNode(), executionPlan.resultDescription().nodeIds()); if (!onHandler || source.preferShardProjections()) { if (!onHandler) { executionPlan = Merge.ensureOnHandler(executionPlan, plannerContext); } TopNDistinctProjection topNDistinct = new TopNDistinctProjection( limit + offset, inputColOutputs, RowGranularity.CLUSTER ); executionPlan.addProjection(topNDistinct); } if (offset > 0) { executionPlan.addProjection( new TopNProjection(limit, offset, Symbols.typeView(inputColOutputs)) ); } return executionPlan; }