You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ma...@apache.org on 2025/02/21 09:45:39 UTC

(cloudberry) 24/30: [ORCA] Update all join operators to derive set of table descriptors

This is an automated email from the ASF dual-hosted git repository.

maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit b05263bde4ab3167920abc81236cf4983e2e3ea1
Author: David Kimura <dk...@vmware.com>
AuthorDate: Thu Feb 8 13:55:01 2024 -0800

    [ORCA] Update all join operators to derive set of table descriptors
    
    Commit a76fa13ce25 updated API DeriveTableDescriptor() to return a table
    descriptor set, intead of a single table descriptor (or NULL). That
    commit updated CLogicalNAryJoin, but other join types still returned
    NULL.
    
    This follow up commit updates the other join types as well via class
    inheritance. That list includes:
    
      - CLogicalFullOuterJoin
      - CLogicalInnerJoin
      - CLogicalLeftAntiSemiJoin
      - CLogicalLeftOuterJoin
      - CLogicalLeftSemiJoin
      - CLogicalNAryJoin
      - CLogicalRightOuterJoin
---
 .../include/gpopt/operators/CLogicalJoin.h         |  4 ++++
 .../include/gpopt/operators/CLogicalNAryJoin.h     |  4 ----
 .../gporca/libgpopt/src/operators/CLogicalJoin.cpp | 27 ++++++++++++++++++++++
 .../libgpopt/src/operators/CLogicalNAryJoin.cpp    | 27 ----------------------
 4 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalJoin.h b/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalJoin.h
index fc12ac3711..8c1e366a11 100644
--- a/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalJoin.h
+++ b/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalJoin.h
@@ -109,6 +109,10 @@ public:
 		return PfpDeriveFromScalar(mp, exprhdl);
 	}
 
+	// derive table descriptor
+	CTableDescriptorHashSet *DeriveTableDescriptor(
+		CMemoryPool *mp, CExpressionHandle &exprhdl) const override;
+
 	//-------------------------------------------------------------------------------------
 	// Derived Stats
 	//-------------------------------------------------------------------------------------
diff --git a/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalNAryJoin.h b/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalNAryJoin.h
index 6f5dafa192..7e2f6e07d7 100644
--- a/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalNAryJoin.h
+++ b/src/backend/gporca/libgpopt/include/gpopt/operators/CLogicalNAryJoin.h
@@ -86,10 +86,6 @@ public:
 	CPropConstraint *DerivePropertyConstraint(
 		CMemoryPool *mp, CExpressionHandle &exprhdl) const override;
 
-	// derive table descriptor
-	CTableDescriptorHashSet *DeriveTableDescriptor(
-		CMemoryPool *mp, CExpressionHandle &exprhdl) const override;
-
 	//-------------------------------------------------------------------------------------
 	// Derived Stats
 	//-------------------------------------------------------------------------------------
diff --git a/src/backend/gporca/libgpopt/src/operators/CLogicalJoin.cpp b/src/backend/gporca/libgpopt/src/operators/CLogicalJoin.cpp
index c1b9f73b51..aada2d9374 100644
--- a/src/backend/gporca/libgpopt/src/operators/CLogicalJoin.cpp
+++ b/src/backend/gporca/libgpopt/src/operators/CLogicalJoin.cpp
@@ -52,6 +52,33 @@ CLogicalJoin::Matches(COperator *pop) const
 	return (pop->Eopid() == Eopid());
 }
 
+CTableDescriptorHashSet *
+CLogicalJoin::DeriveTableDescriptor(CMemoryPool *mp,
+									CExpressionHandle &exprhdl) const
+{
+	CTableDescriptorHashSet *table_descriptor_set =
+		GPOS_NEW(mp) CTableDescriptorHashSet(mp);
+
+	for (ULONG ul = 0; ul < exprhdl.Arity(); ul++)
+	{
+		if (exprhdl.Pop(ul)->FLogical())
+		{
+			CTableDescriptorHashSetIter hsiter(
+				exprhdl.DeriveTableDescriptor(ul));
+			while (hsiter.Advance())
+			{
+				CTableDescriptor *ptabdesc =
+					const_cast<CTableDescriptor *>(hsiter.Get());
+				if (table_descriptor_set->Insert(ptabdesc))
+				{
+					ptabdesc->AddRef();
+				}
+			}
+		}
+	}
+	return table_descriptor_set;
+}
+
 //---------------------------------------------------------------------------
 //	@function:
 //		CLogicalJoin::PstatsDerive
diff --git a/src/backend/gporca/libgpopt/src/operators/CLogicalNAryJoin.cpp b/src/backend/gporca/libgpopt/src/operators/CLogicalNAryJoin.cpp
index e469f88031..620958b06f 100644
--- a/src/backend/gporca/libgpopt/src/operators/CLogicalNAryJoin.cpp
+++ b/src/backend/gporca/libgpopt/src/operators/CLogicalNAryJoin.cpp
@@ -194,33 +194,6 @@ CLogicalNAryJoin::DerivePropertyConstraint(CMemoryPool *mp,
 	return GPOS_NEW(mp) CPropConstraint(mp, equivalenceClasses, pcnstrNew);
 }
 
-CTableDescriptorHashSet *
-CLogicalNAryJoin::DeriveTableDescriptor(CMemoryPool *mp,
-										CExpressionHandle &exprhdl) const
-{
-	CTableDescriptorHashSet *table_descriptor_set =
-		GPOS_NEW(mp) CTableDescriptorHashSet(mp);
-
-	for (ULONG ul = 0; ul < exprhdl.Arity(); ul++)
-	{
-		if (exprhdl.Pop(ul)->FLogical())
-		{
-			CTableDescriptorHashSetIter hsiter(
-				exprhdl.DeriveTableDescriptor(ul));
-			while (hsiter.Advance())
-			{
-				CTableDescriptor *ptabdesc =
-					const_cast<CTableDescriptor *>(hsiter.Get());
-				if (table_descriptor_set->Insert(ptabdesc))
-				{
-					ptabdesc->AddRef();
-				}
-			}
-		}
-	}
-	return table_descriptor_set;
-}
-
 //---------------------------------------------------------------------------
 //	@function:
 //		CLogicalNAryJoin::PxfsCandidates


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org