morrySnow commented on code in PR #67885:
URL: https://github.com/apache/doris/pull/67885#discussion_r4014037356


##########
fe/fe-core/src/main/java/org/apache/doris/qe/ShortCircuitQueryContext.java:
##########
@@ -152,4 +263,247 @@ public void sanitize() {
         Preconditions.checkNotNull(tbl);
         Preconditions.checkNotNull(tableName);
     }
+
+    /** Build state owned by one execution without modifying the cached plan 
or scan conjuncts. */
+    public PointQueryExecutionContext 
createPointQueryExecutionContext(StatementContext statementContext) {
+        return pointQueryKeyTemplate.bind(statementContext);
+    }
+
+    private static class PointQueryKeyTemplate {
+        private final List<Column> keyColumns;
+        private final List<PlaceholderKeyBinding> placeholderBindings;
+        private final List<List<Literal>> fixedConstraints;
+        private final boolean complete;
+
+        private PointQueryKeyTemplate(List<Column> keyColumns,
+                List<PlaceholderKeyBinding> placeholderBindings,
+                List<List<Literal>> fixedConstraints, boolean complete) {
+            this.keyColumns = Collections.unmodifiableList(new 
ArrayList<>(keyColumns));
+            this.placeholderBindings = Collections.unmodifiableList(new 
ArrayList<>(placeholderBindings));
+            List<List<Literal>> immutableConstraints = new 
ArrayList<>(fixedConstraints.size());
+            for (List<Literal> constraints : fixedConstraints) {
+                immutableConstraints.add(Collections.unmodifiableList(new 
ArrayList<>(constraints)));
+            }
+            this.fixedConstraints = 
Collections.unmodifiableList(immutableConstraints);
+            this.complete = complete;
+        }
+
+        private static PointQueryKeyTemplate unsupported() {
+            return new PointQueryKeyTemplate(Collections.emptyList(), 
Collections.emptyList(),
+                    Collections.emptyList(), false);
+        }
+
+        private static PointQueryKeyTemplate create(OlapScanNode scanNode, 
StatementContext statementContext) {
+            if (statementContext == null) {
+                return unsupported();
+            }
+            List<Column> keyColumns = 
scanNode.getOlapTable().getBaseSchemaKeyColumns();
+            if (keyColumns.isEmpty()) {
+                return new PointQueryKeyTemplate(keyColumns, 
Collections.emptyList(),
+                        Collections.emptyList(), true);
+            }
+            if (!statementContext.arePointQueryFixedKeyConstraintsComplete()) {
+                return unsupported();
+            }
+
+            Map<String, Integer> keyOrdinals = new 
TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+            List<List<Literal>> fixedConstraints = new 
ArrayList<>(keyColumns.size());
+            for (int ordinal = 0; ordinal < keyColumns.size(); ordinal++) {
+                keyOrdinals.put(keyColumns.get(ordinal).getName(), ordinal);
+                fixedConstraints.add(new ArrayList<>());
+            }
+
+            List<PlaceholderKeyBinding> placeholderBindings = new 
ArrayList<>();
+            for (Map.Entry<PlaceholderId, SlotReference> entry

Review Comment:
   Follow-up in 4ccff1315ce: the `ExecuteCommand` plan-wide scan has been 
removed. The existing short-circuit placeholder-to-slot registry is now 
populated only while analyzing `LogicalFilter`, and the point-query rewrite 
requires every prepared placeholder to be present in that filter-only registry. 
Placeholders in projections or other nodes therefore stay on the normal path 
without involving generic INSERT/DML execute handling. Injective casts are 
mapped to their underlying key slot, with a two-execution server-prepared 
regression.



-- 
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