xy720 commented on code in PR #66981:
URL: https://github.com/apache/doris/pull/66981#discussion_r3820027810
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/CTEInline.java:
##########
@@ -135,4 +139,36 @@ private boolean
containsNondeterministicFunction(LogicalCTEProducer<?> producer)
producer.accept(NondeterministicFunctionCollector.INSTANCE,
nondeterministicFunctions);
return !nondeterministicFunctions.isEmpty();
}
+
+ /**
+ * Return true if the CTE producer's subtree is a LogicalOneRowRelation
and its
+ * final output slots are all compile-time constants.
+ */
+ private static boolean isConstantOneRowProducer(Plan producerRoot) {
+ if (!(producerRoot instanceof LogicalCTEProducer)) {
+ return false;
+ }
+ Plan node = ((LogicalCTEProducer<?>) producerRoot).child();
+ while (node instanceof LogicalSubQueryAlias) {
+ if (node.arity() != 1) {
+ return false;
+ }
+ node = node.child(0);
+ }
+ if (node instanceof LogicalProject) {
+ LogicalProject<?> project = (LogicalProject<?>) node;
+ if (project.arity() != 1) {
+ return false;
+ }
+ if (!ExpressionUtils.allMatch(project.getProjects(),
Expression::isConstant)) {
Review Comment:
Profile:
PhysicalCTEProducer[11232] ( stats=1, cteId=CTEId#1 )
+--PhysicalOneRowRelation[11227]@0 ( expressions=['2026-01-01' AS
day_start#15, ...] )
--
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]