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

com.sap.cds.ql.cqn.CqnSelect Maven / Gradle / Ivy

/************************************************************************
 * © 2019-2023 SAP SE or an SAP affiliate company. All rights reserved. *
 ************************************************************************/
package com.sap.cds.ql.cqn;

import java.util.List;
import java.util.Optional;

import com.google.common.annotations.Beta;
import com.sap.cds.ql.cqn.transformation.CqnTransformation;

public interface CqnSelect extends CqnFilterableStatement, CqnEntitySelector, CqnSource {

	/**
	 * The from clause of this select statement.
	 * 
	 * @return a reference to this statement's {@link CqnSource}
	 */
	CqnSource from();

	/**
	 * @return whether statement is a SELECT DISTINCT
	 */
	boolean isDistinct();

	/**
	 * @deprecated instead use {@link CqnEntitySelector#items}
	 * @return the select list items
	 */
	@Deprecated
	default List columns() {
		return items();
	}

	List groupBy();

	List excluding();

	Optional having();

	Optional getLock();

	Optional search();

	/**
	 * Returns the pipeline of transformations, which is applied to the source ref
	 * of this select statement before the the regular clauses are applied.
	 * 
	 * The statement is processed in this order:
	 * 
	 * 
    *
  1. ref, source
  2. *
  3. transformations
  4. *
  5. where, search
  6. *
  7. groupBy
  8. *
  9. having
  10. *
  11. items, distinct
  12. *
  13. orderBy
  14. *
  15. skip
  16. *
  17. top
  18. *
* * @return the pipeline of transformations */ @Beta List transformations(); @Override default boolean isSelect() { return true; } @Override default CqnSelect asSelect() { return this; } /** * Traverses the clauses of this {@code CqnSelect} with a given {@code visitor}. * * If the source of this select is a structured type reference it is visited * first. * * The other clauses are traversed depth-first in the following order: * *
    *
  • items
  • *
  • where
  • *
  • search
  • *
  • group by
  • *
  • having
  • *
  • order by
  • *
* * Afterwards this {@code CqnSelect} is passed to the * {@link CqnVisitor#visit(CqnSelect)} method. * * @param visitor the {@link CqnVisitor} */ @Override default void accept(CqnVisitor visitor) { if (from().isRef()) { ref().accept(visitor); } dispatch(visitor); visitor.visit(this); } @Override default void dispatch(CqnVisitor visitor) { items().forEach(c -> c.accept(visitor)); where().ifPresent(w -> w.accept(visitor)); search().ifPresent(s -> s.accept(visitor)); groupBy().forEach(c -> c.accept(visitor)); having().ifPresent(h -> h.accept(visitor)); orderBy().forEach(o -> o.accept(visitor)); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy