#pragma once #include "yql_statistics.h" #include #include #include #include /** * The cost function for cost based optimizer currently consists of methods for computing * both the cost and cardinalities of individual plan operators */ namespace NYql { struct IProviderContext; enum class EJoinAlgoType { Undefined, LookupJoin, LookupJoinReverse, MapJoin, GraceJoin, StreamLookupJoin, //Right part can be updated during an operation. Used mainly for joining streams with lookup tables. Currently impplemented in Dq by LookupInputTransform MergeJoin // To be used in YT }; //StreamLookupJoin is not a subject for CBO and not not included here static constexpr auto AllJoinAlgos = { EJoinAlgoType::LookupJoin, EJoinAlgoType::LookupJoinReverse, EJoinAlgoType::MapJoin, EJoinAlgoType::GraceJoin, EJoinAlgoType::MergeJoin }; namespace NDq { /** * Join column is a struct that records the relation label and * attribute name, used in join conditions */ struct TJoinColumn { TString RelName{}; TString AttributeName{}; TString AttributeNameWithAliases{}; std::optional EquivalenceClass{}; bool IsConstant = false; TJoinColumn(TString relName, TString attributeName) : RelName(relName), AttributeName(attributeName), AttributeNameWithAliases(attributeName) {} bool operator == (const TJoinColumn& other) const { return RelName == other.RelName && AttributeName == other.AttributeName; } struct THashFunction { size_t operator()(const TJoinColumn& c) const { return THash{}(c.RelName) ^ THash{}(c.AttributeName); } }; }; bool operator < (const TJoinColumn& c1, const TJoinColumn& c2); } // namespace NDq } // namespace NYql