All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ma.vi.esql.parser.query.CompositeSelects Maven / Gradle / Ivy

/*
 * Copyright (c) 2020 Vikash Madhow
 */

package ma.vi.esql.parser.query;

import ma.vi.base.tuple.T2;
import ma.vi.esql.parser.*;
import ma.vi.esql.parser.define.Attribute;
import ma.vi.esql.parser.define.Metadata;
import ma.vi.esql.parser.expression.Expression;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Selects combined with set operators: union (all), intersect and except.
 *
 * @author Vikash Madhow ([email protected])
 */
public class CompositeSelects extends Select {
  public CompositeSelects(Context context, String operator, List selects() {
    return childValue("selects");
  }

  public String operator() {
    return value;
  }

  @Override
  public T2 restrict(Restriction restriction,
                                      String targetAlias,
                                      boolean ignoreHiddenFields,
                                      boolean followSubSelect) {
    boolean joined = false;
    String alias = null;
    for (Select sel: selects()) {
      T2 res = sel.restrict(restriction, targetAlias, ignoreHiddenFields, followSubSelect);
      joined |= res.a;
      alias = alias == null ? res.b : alias;
    }
    return T2.of(joined, alias);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy