You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/06/18 14:58:11 UTC
(shardingsphere) branch master updated: Remove useless DerivedColumnPlan and refactor LLMMCPConversationRunner (#38871)
This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 291f612fb10 Remove useless DerivedColumnPlan and refactor LLMMCPConversationRunner (#38871)
291f612fb10 is described below
commit 291f612fb1004d09f7326e1470095b2b6ff06531
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu Jun 18 22:58:03 2026 +0800
Remove useless DerivedColumnPlan and refactor LLMMCPConversationRunner (#38871)
---
.../support/workflow/model/DerivedColumnPlan.java | 95 ----------------------
.../workflow/model/DerivedColumnPlanTest.java | 50 ------------
.../llm/conversation/LLMMCPConversationRunner.java | 15 +---
3 files changed, 4 insertions(+), 156 deletions(-)
diff --git a/mcp/support/src/main/java/org/apache/shardingsphere/mcp/support/workflow/model/DerivedColumnPlan.java b/mcp/support/src/main/java/org/apache/shardingsphere/mcp/support/workflow/model/DerivedColumnPlan.java
deleted file mode 100644
index 7033985e9c1..00000000000
--- a/mcp/support/src/main/java/org/apache/shardingsphere/mcp/support/workflow/model/DerivedColumnPlan.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.shardingsphere.mcp.support.workflow.model;
-
-import lombok.Getter;
-import lombok.Setter;
-
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Derived column plan.
- */
-@Getter
-@Setter
-public final class DerivedColumnPlan {
-
- private String logicalColumn = "";
-
- private String cipherColumnName = "";
-
- private String assistedQueryColumnName = "";
-
- private String likeQueryColumnName = "";
-
- private boolean cipherColumnRequired;
-
- private boolean assistedQueryColumnRequired;
-
- private boolean likeQueryColumnRequired;
-
- private String dataTypeStrategy = "shardingsphere-default";
-
- private final List<Map<String, String>> nameCollisions = new LinkedList<>();
-
- public void setLogicalColumn(final String logicalColumn) {
- this.logicalColumn = normalize(logicalColumn);
- }
-
- public void setCipherColumnName(final String cipherColumnName) {
- this.cipherColumnName = normalize(cipherColumnName);
- }
-
- public void setAssistedQueryColumnName(final String assistedQueryColumnName) {
- this.assistedQueryColumnName = normalize(assistedQueryColumnName);
- }
-
- public void setLikeQueryColumnName(final String likeQueryColumnName) {
- this.likeQueryColumnName = normalize(likeQueryColumnName);
- }
-
- public void setDataTypeStrategy(final String dataTypeStrategy) {
- this.dataTypeStrategy = normalize(dataTypeStrategy);
- }
-
- /**
- * Convert to map.
- *
- * @return map representation
- */
- public Map<String, Object> toMap() {
- Map<String, Object> result = new LinkedHashMap<>(12, 1F);
- result.put("logical_column", logicalColumn);
- result.put(WorkflowFieldNames.CIPHER_COLUMN_NAME, cipherColumnName);
- result.put(WorkflowFieldNames.ASSISTED_QUERY_COLUMN_NAME, assistedQueryColumnName);
- result.put(WorkflowFieldNames.LIKE_QUERY_COLUMN_NAME, likeQueryColumnName);
- result.put("cipher_column_required", cipherColumnRequired);
- result.put("assisted_query_column_required", assistedQueryColumnRequired);
- result.put("like_query_column_required", likeQueryColumnRequired);
- result.put("data_type_strategy", dataTypeStrategy);
- result.put("name_collisions", nameCollisions);
- return result;
- }
-
- private static String normalize(final String value) {
- return null == value ? "" : value.trim();
- }
-}
diff --git a/mcp/support/src/test/java/org/apache/shardingsphere/mcp/support/workflow/model/DerivedColumnPlanTest.java b/mcp/support/src/test/java/org/apache/shardingsphere/mcp/support/workflow/model/DerivedColumnPlanTest.java
deleted file mode 100644
index ec8f287bc1a..00000000000
--- a/mcp/support/src/test/java/org/apache/shardingsphere/mcp/support/workflow/model/DerivedColumnPlanTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.shardingsphere.mcp.support.workflow.model;
-
-import org.junit.jupiter.api.Test;
-
-import java.util.Map;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-class DerivedColumnPlanTest {
-
- @Test
- void assertToMap() {
- DerivedColumnPlan plan = new DerivedColumnPlan();
- plan.setLogicalColumn(" phone ");
- plan.setCipherColumnName(" phone_cipher ");
- plan.setAssistedQueryColumnName(" phone_assisted ");
- plan.setLikeQueryColumnName(" phone_like ");
- plan.setCipherColumnRequired(true);
- plan.setAssistedQueryColumnRequired(true);
- plan.getNameCollisions().add(Map.of("original_name", "phone_cipher", "resolved_name", "phone_cipher_1"));
- Map<String, Object> actual = plan.toMap();
- assertThat(actual.get("logical_column"), is("phone"));
- assertThat(actual.get("cipher_column_name"), is("phone_cipher"));
- assertThat(actual.get("assisted_query_column_name"), is("phone_assisted"));
- assertThat(actual.get("like_query_column_name"), is("phone_like"));
- assertTrue((boolean) actual.get("cipher_column_required"));
- assertTrue((boolean) actual.get("assisted_query_column_required"));
- assertFalse((boolean) actual.get("like_query_column_required"));
- }
-}
diff --git a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/llm/conversation/LLMMCPConversationRunner.java b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/llm/conversation/LLMMCPConversationRunner.java
index 3cdea7aecc7..12e4c4f1dd5 100644
--- a/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/llm/conversation/LLMMCPConversationRunner.java
+++ b/test/e2e/mcp/src/test/java/org/apache/shardingsphere/test/e2e/mcp/llm/conversation/LLMMCPConversationRunner.java
@@ -37,6 +37,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
+import java.util.stream.Collectors;
/**
* LLM MCP conversation runner.
@@ -204,20 +205,12 @@ public final class LLMMCPConversationRunner {
}
}
List<String> missingToolNames = findMissingAllowedToolNames(scenario, interactionTrace);
- if (!missingToolNames.isEmpty()) {
- return List.of(missingToolNames.getFirst());
- }
- return scenario.getAllowedToolNames();
+ return missingToolNames.isEmpty() ? scenario.getAllowedToolNames() : List.of(missingToolNames.getFirst());
}
private List<String> findMissingAllowedToolNames(final LLME2EScenario scenario, final List<MCPInteractionTraceRecord> interactionTrace) {
- List<String> result = new LinkedList<>();
- for (String each : LLMMCPInteractionCoverage.findMissingRequiredInteractionNames(scenario.getRequiredToolNames(), interactionTrace)) {
- if (scenario.getAllowedToolNames().contains(each)) {
- result.add(each);
- }
- }
- return result;
+ return LLMMCPInteractionCoverage.findMissingRequiredInteractionNames(
+ scenario.getRequiredToolNames(), interactionTrace).stream().filter(each -> scenario.getAllowedToolNames().contains(each)).collect(Collectors.toList());
}
private List<String> findMissingReadOnlyToolNames(final LLME2EScenario scenario, final List<MCPInteractionTraceRecord> interactionTrace) {