yjhjstz commented on code in PR #1398:
URL: https://github.com/apache/cloudberry/pull/1398#discussion_r2452193740


##########
src/backend/gporca/libgpopt/src/xforms/CXformGet2ParallelTableScan.cpp:
##########
@@ -0,0 +1,265 @@
+/*-------------------------------------------------------------------------
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ * CXformGet2ParallelTableScan.cpp
+ *
+ * IDENTIFICATION
+ *       src/backend/gporca/libgpopt/src/xforms/CXformGet2ParallelTableScan.cpp
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "gpopt/xforms/CXformGet2ParallelTableScan.h"
+
+#include "gpos/base.h"
+
+#include "gpopt/base/COptCtxt.h"
+#include "gpopt/hints/CHintUtils.h"
+#include "gpopt/metadata/CTableDescriptor.h"
+#include "gpopt/operators/CExpressionHandle.h"
+#include "gpopt/operators/CLogicalGet.h"
+#include "gpopt/operators/CPhysicalParallelTableScan.h"
+#include "gpopt/optimizer/COptimizerConfig.h"
+#include "naucrates/md/IMDRelation.h"
+#include "gpopt/search/CGroupProxy.h"
+#include "gpopt/search/CMemo.h"
+
+
+// Use gpdbwrappers for parallel checks
+extern int max_parallel_workers_per_gather;
+
+// Forward declarations for gpdbwrappers functions
+namespace gpdb {
+       bool IsParallelModeOK(void);
+}
+
+using namespace gpopt;
+
+//---------------------------------------------------------------------------
+//     @function:
+//             CXformGet2ParallelTableScan::FHasParallelIncompatibleOps
+//
+//     @doc:
+//             Check if memo contains logical operators that are incompatible
+//             with parallel execution (CTE, Dynamic scans, Foreign scans, 
etc.)
+//
+//---------------------------------------------------------------------------
+BOOL
+CXformGet2ParallelTableScan::FHasParallelIncompatibleOps(CExpressionHandle 
&exprhdl)
+{
+       CGroupExpression *pgexprHandle = exprhdl.Pgexpr();
+       if (nullptr == pgexprHandle)
+       {
+               return false;
+       }
+
+       CGroup *pgroup = pgexprHandle->Pgroup();
+       if (nullptr == pgroup)
+       {
+               return false;
+       }
+
+       CMemo *pmemo = pgroup->Pmemo();
+       if (nullptr == pmemo)
+       {
+               return false;
+       }
+
+       // Iterate through all groups in memo to check for 
parallel-incompatible operations
+       const ULONG_PTR ulGroups = pmemo->UlpGroups();
+       for (ULONG_PTR ul = 0; ul < ulGroups; ul++)
+       {
+               CGroup *pgroupCurrent = pmemo->Pgroup(ul);
+               if (nullptr == pgroupCurrent)
+               {
+                       continue;
+               }
+
+               // Check all group expressions in this group using CGroupProxy
+               CGroupProxy gp(pgroupCurrent);
+               CGroupExpression *pgexpr = gp.PgexprFirst();
+               while (nullptr != pgexpr)
+               {
+                       COperator::EOperatorId eopid = pgexpr->Pop()->Eopid();
+
+                       // Check for CTE-related operators (incompatible with 
parallel execution)
+                       if (COperator::EopLogicalCTEProducer == eopid ||

Review Comment:
   have not found the way.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to