greenplumn CScalarSubqueryQuantified 源码

  • 2022-08-18
  • 浏览 (9)

greenplumn CScalarSubqueryQuantified 代码

文件路径:/src/backend/gporca/libgpopt/include/gpopt/operators/CScalarSubqueryQuantified.h

//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2011 EMC Corp.
//
//	@filename:
//		CScalarSubqueryQuantified.h
//
//	@doc:
//		Parent class for quantified subquery operators
//---------------------------------------------------------------------------
#ifndef GPOPT_CScalarSubqueryQuantified_H
#define GPOPT_CScalarSubqueryQuantified_H

#include "gpos/base.h"

#include "gpopt/operators/CScalar.h"
#include "gpopt/xforms/CSubqueryHandler.h"

namespace gpopt
{
using namespace gpos;

// fwd declarations
class CExpressionHandle;

//---------------------------------------------------------------------------
//	@class:
//		CScalarSubqueryQuantified
//
//	@doc:
//		Parent class for quantified subquery operators (ALL/ANY subqueries);
//		A quantified subquery expression has two children:
//		- Logical child: the inner logical expression
//		- Scalar child:	the scalar expression in the outer expression that
//		is used in quantified comparison;
//
//		Example: SELECT * from R where a+b = ANY (SELECT c from S);
//		- logical child: (SELECT c from S)
//		- scalar child : (a+b)
//
//---------------------------------------------------------------------------
class CScalarSubqueryQuantified : public CScalar
{
private:
	// id of comparison operator
	IMDId *m_scalar_op_mdid;

	// name of comparison operator
	const CWStringConst *m_pstrScalarOp;

	// column reference used in comparison
	const CColRef *m_pcr;

protected:
	// ctor
	CScalarSubqueryQuantified(CMemoryPool *mp, IMDId *scalar_op_mdid,
							  const CWStringConst *pstrScalarOp,
							  const CColRef *colref);

	// dtor
	~CScalarSubqueryQuantified() override;

public:
	CScalarSubqueryQuantified(const CScalarSubqueryQuantified &) = delete;

	// operator mdid accessor
	IMDId *MdIdOp() const;

	// operator name accessor
	const CWStringConst *PstrOp() const;

	// column reference accessor
	const CColRef *
	Pcr() const
	{
		return m_pcr;
	}

	// return the type of the scalar expression
	IMDId *MdidType() const override;

	// operator specific hash function
	ULONG HashValue() const override;

	// match function
	BOOL Matches(COperator *pop) const override;

	// sensitivity to order of inputs
	BOOL
	FInputOrderSensitive() const override
	{
		return true;
	}

	// return locally used columns
	CColRefSet *PcrsUsed(CMemoryPool *mp, CExpressionHandle &exprhdl) override;

	// derive partition consumer info
	CPartInfo *PpartinfoDerive(CMemoryPool *mp,
							   CExpressionHandle &exprhdl) const override;

	// conversion function
	static CScalarSubqueryQuantified *
	PopConvert(COperator *pop)
	{
		GPOS_ASSERT(nullptr != pop);
		GPOS_ASSERT(EopScalarSubqueryAny == pop->Eopid() ||
					EopScalarSubqueryAll == pop->Eopid());

		return dynamic_cast<CScalarSubqueryQuantified *>(pop);
	}

	// print
	IOstream &OsPrint(IOstream &os) const override;

};	// class CScalarSubqueryQuantified
}  // namespace gpopt

#endif	// !GPOPT_CScalarSubqueryQuantified_H

// EOF

相关信息

greenplumn 源码目录

相关文章

greenplumn CExpression 源码

greenplumn CExpressionFactorizer 源码

greenplumn CExpressionHandle 源码

greenplumn CExpressionPreprocessor 源码

greenplumn CExpressionUtils 源码

greenplumn CHashedDistributions 源码

greenplumn CLogical 源码

greenplumn CLogicalApply 源码

greenplumn CLogicalAssert 源码

greenplumn CLogicalBitmapTableGet 源码

0  赞