@Override
  public Object scalarCalucate(IRowSet kvPair, ExecutionContext ec) throws TddlRuntimeException {

    IQueryTree query = this.getQueryPlan();

    if (query.isCorrelatedSubquery()) {
      QueryTreeNode ast = OptimizerUtils.convertPlanToAst(query);
      // 获取correlated column
      List<ISelectable> columnsCorrelated = ast.getColumnsCorrelated();
      Map<Long, Object> correlatedValues = new HashMap();
      // 从rowset中找到对应的column进行替换
      for (ISelectable column : columnsCorrelated) {
        Object value = getValueByIColumnWithException(kvPair, column);
        correlatedValues.put(column.getCorrelateOnFilterId(), value);
      }
      // 替换correlated column
      OptimizerContext.getContext()
          .getOptimizer()
          .assignmentSubquery(ast, correlatedValues, ec.getExtraCmds());
      // 重新生成执行计划
      query =
          (IQueryTree)
              OptimizerContext.getContext()
                  .getOptimizer()
                  .optimizePlan(ast, ec.getParams(), ec.getExtraCmds());
    }

    return this.compute(new Object[] {query}, ec);
  }