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/08/29 03:34:27 UTC
(shardingsphere) branch master updated: Fall back to the default execution plan cache when SQL federation YAML omits it (#39608)
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 c575167cc6b Fall back to the default execution plan cache when SQL federation YAML omits it (#39608)
c575167cc6b is described below
commit c575167cc6b59fb8142f881c98b5e4117cc24e7d
Author: ZIHAN DAI <99...@users.noreply.github.com>
AuthorDate: Sat Aug 29 13:34:19 2026 +1000
Fall back to the default execution plan cache when SQL federation YAML omits it (#39608)
executionPlanCache has no default on YamlSQLFederationRuleConfiguration, so a
SQL_FEDERATION rule written without that block leaves it null and swapToObject
dereferences it:
Cannot invoke YamlSQLFederationExecutionPlanCacheRuleConfiguration
.getInitialCapacity() because "yamlConfig" is null
Use DEFAULT_EXECUTION_PLAN_CACHE_OPTION, the same value the rule gets when no
SQL_FEDERATION block is present at all.
Co-authored-by: Zihan Dai <dz...@gmail.com>
---
.../YamlSQLFederationRuleConfigurationSwapper.java | 5 ++-
...lSQLFederationRuleConfigurationSwapperTest.java | 37 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/YamlSQLFederationRuleConfigurationSwapper.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/YamlSQLFederationRuleConfigurationSwapper.java
index d555d4c15c8..9d68925e6f6 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/YamlSQLFederationRuleConfigurationSwapper.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/YamlSQLFederationRuleConfigurationSwapper.java
@@ -21,6 +21,7 @@ import org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigur
import org.apache.shardingsphere.sqlfederation.config.SQLFederationCacheOption;
import org.apache.shardingsphere.sqlfederation.config.SQLFederationRuleConfiguration;
import org.apache.shardingsphere.sqlfederation.constant.SQLFederationOrder;
+import org.apache.shardingsphere.sqlfederation.rule.builder.DefaultSQLFederationRuleConfigurationBuilder;
import org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationRuleConfiguration;
/**
@@ -41,7 +42,9 @@ public final class YamlSQLFederationRuleConfigurationSwapper implements YamlRule
@Override
public SQLFederationRuleConfiguration swapToObject(final YamlSQLFederationRuleConfiguration yamlConfig) {
- SQLFederationCacheOption executionPlanCacheConfig = executionPlanCacheConfigSwapper.swapToObject(yamlConfig.getExecutionPlanCache());
+ SQLFederationCacheOption executionPlanCacheConfig = null == yamlConfig.getExecutionPlanCache()
+ ? DefaultSQLFederationRuleConfigurationBuilder.DEFAULT_EXECUTION_PLAN_CACHE_OPTION
+ : executionPlanCacheConfigSwapper.swapToObject(yamlConfig.getExecutionPlanCache());
return new SQLFederationRuleConfiguration(yamlConfig.isSqlFederationEnabled(), yamlConfig.isAllQueryUseSQLFederation(), executionPlanCacheConfig);
}
diff --git a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/YamlSQLFederationRuleConfigurationSwapperTest.java b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/YamlSQLFederationRuleConfigurationSwapperTest.java
new file mode 100644
index 00000000000..e7da556ff24
--- /dev/null
+++ b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/yaml/swapper/YamlSQLFederationRuleConfigurationSwapperTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.sqlfederation.yaml.swapper;
+
+import org.apache.shardingsphere.sqlfederation.config.SQLFederationRuleConfiguration;
+import org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationRuleConfiguration;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+class YamlSQLFederationRuleConfigurationSwapperTest {
+
+ @Test
+ void assertSwapToObjectWithoutExecutionPlanCache() {
+ YamlSQLFederationRuleConfiguration yamlConfig = new YamlSQLFederationRuleConfiguration();
+ yamlConfig.setSqlFederationEnabled(true);
+ SQLFederationRuleConfiguration actual = new YamlSQLFederationRuleConfigurationSwapper().swapToObject(yamlConfig);
+ assertThat(actual.getExecutionPlanCache().getInitialCapacity(), is(2000));
+ assertThat(actual.getExecutionPlanCache().getMaximumSize(), is(65535L));
+ }
+}