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 2023/06/29 02:02:16 UTC
[shardingsphere] branch master updated: Revert "Move openGauss system function query logic to sql federation (#26679)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 50974b3b552 Revert "Move openGauss system function query logic to sql federation (#26679)
50974b3b552 is described below
commit 50974b3b552e897f66a6b1046fe2200db734c3e2
Author: Zhengqiang Duan <du...@apache.org>
AuthorDate: Thu Jun 29 10:02:08 2023 +0800
Revert "Move openGauss system function query logic to sql federation (#26679)
* Revert "Modify sqlFederationEnable to true when scenario contains sharding (#26661)"
This reverts commit 45a9bdc75f1a1f52ba44a3e1b6c0b8cbe39f0e71.
* Revert "Move openGauss system function query logic to sql federation (#26581)"
---
.../decider/ShardingSQLFederationDecider.java | 2 +-
.../decider/ShardingSQLFederationDeciderTest.java | 13 --
.../database/schema/util/SystemSchemaUtils.java | 27 ----
.../compiler/SQLFederationCompilerEngine.java | 7 +-
.../dialect/impl/OpenGaussOptimizerBuilder.java | 2 +-
.../dialect/impl/PostgreSQLOptimizerBuilder.java | 2 +-
.../metadata/schema/SQLFederationTable.java | 4 +-
.../planner/cache/ExecutionPlanCacheBuilder.java | 7 +-
.../planner/cache/ExecutionPlanCacheKey.java | 3 -
.../planner/cache/ExecutionPlanCacheLoader.java | 9 +-
.../planner/util/SQLFederationFunctionUtils.java | 120 ----------------
.../planner/util/SQLFederationPlannerUtils.java | 34 ++++-
.../compiler/statement/SQLStatementCompiler.java | 1 -
.../statement/SQLStatementCompilerEngine.java | 9 +-
.../SQLStatementCompilerEngineFactory.java | 9 +-
.../sqlfederation/engine/SQLFederationEngine.java | 17 +--
.../EnumerablePushDownTableScanExecutor.java | 95 +------------
.../resultset/SQLFederationResultSetMetaData.java | 13 +-
.../compiler/it/SQLFederationCompilerEngineIT.java | 13 +-
.../admin/OpenGaussAdminExecutorCreator.java | 2 +-
.../OpenGaussSystemCatalogAdminQueryExecutor.java | 156 +++++++++++++--------
.../handler/admin/schema/OpenGaussDatabase.java | 22 ++-
.../handler/admin/schema/OpenGaussRoles.java | 22 ++-
.../admin/schema/OpenGaussSystemCatalog.java | 25 ++--
.../handler/admin/schema/OpenGaussTables.java | 22 ++-
.../admin/OpenGaussAdminExecutorCreatorTest.java | 2 +-
.../admin/OpenGaussAdminExecutorFactoryTest.java | 2 +-
...enGaussSystemCatalogAdminQueryExecutorTest.java | 149 +++-----------------
.../ProxyClusterContainerConfigurationFactory.java | 4 +-
...oxyStandaloneContainerConfigurationFactory.java | 4 +-
.../test/e2e/engine/type/dql/GeneralDQLE2EIT.java | 1 +
.../env/common/cluster/proxy/conf/server.yaml | 6 +
.../env/common/standalone/proxy/conf/server.yaml | 6 +
.../env/scenario/db/proxy/mode/cluster/server.yaml | 57 --------
.../scenario/db/proxy/mode/standalone/server.yaml | 45 ------
.../proxy/mode/cluster/server.yaml | 57 --------
.../proxy/mode/standalone/server.yaml | 45 ------
.../proxy/mode/cluster/server.yaml | 57 --------
.../proxy/mode/standalone/server.yaml | 45 ------
.../empty_rules/proxy/mode/cluster/server.yaml | 57 --------
.../empty_rules/proxy/mode/standalone/server.yaml | 45 ------
.../encrypt_and_readwrite_splitting/rules.yaml | 6 +
.../{proxy/mode => }/cluster/server.yaml | 0
.../{proxy/mode => }/standalone/server.yaml | 0
.../scenario/tbl/proxy/mode/cluster/server.yaml | 57 --------
.../scenario/tbl/proxy/mode/standalone/server.yaml | 45 ------
46 files changed, 265 insertions(+), 1061 deletions(-)
diff --git a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
index b3db13e145b..0c13840cc1a 100644
--- a/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
+++ b/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDecider.java
@@ -57,7 +57,7 @@ public final class ShardingSQLFederationDecider implements SQLFederationDecider<
if (!selectStatementContext.isContainsJoinQuery() || rule.isAllTablesInSameDataSource(tableNames)) {
return false;
}
- return tableNames.size() > 1 && !rule.isAllBindingTables(database, selectStatementContext, tableNames);
+ return tableNames.size() <= 1 || !rule.isAllBindingTables(database, selectStatementContext, tableNames);
}
private Collection<DataNode> getTableDataNodes(final ShardingRule rule, final Collection<String> tableNames) {
diff --git a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
index 579d8e08747..6466af9bd83 100644
--- a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
+++ b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/decider/ShardingSQLFederationDeciderTest.java
@@ -134,19 +134,6 @@ class ShardingSQLFederationDeciderTest {
assertThat(includedDataNodes.size(), is(4));
}
- @Test
- void assertDecideWhenContainsOnlyOneTable() {
- SelectStatementContext select = createStatementContext();
- when(select.getTablesContext().getTableNames()).thenReturn(Collections.singletonList("t_order"));
- when(select.isContainsJoinQuery()).thenReturn(true);
- ShardingRule shardingRule = createShardingRule();
- when(shardingRule.getShardingLogicTableNames(Collections.singletonList("t_order"))).thenReturn(Collections.singletonList("t_order"));
- ShardingSphereDatabase database = createDatabase();
- when(shardingRule.isAllBindingTables(database, select, Collections.singletonList("t_order"))).thenReturn(false);
- Collection<DataNode> includedDataNodes = new HashSet<>();
- assertFalse(new ShardingSQLFederationDecider().decide(select, Collections.emptyList(), mock(ShardingSphereRuleMetaData.class), database, shardingRule, includedDataNodes));
- }
-
@Test
void assertDecideWhenAllTablesIsNotBindingTablesAndContainsPagination() {
SelectStatementContext select = createStatementContext();
diff --git a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SystemSchemaUtils.java b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SystemSchemaUtils.java
index 2ff3f23ba23..13099561142 100644
--- a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SystemSchemaUtils.java
+++ b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SystemSchemaUtils.java
@@ -21,13 +21,9 @@ import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.SchemaSupportedDatabaseType;
-import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ExpressionProjectionSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionSegment;
import java.util.Collection;
-import java.util.HashSet;
/**
* System schema utility.
@@ -35,14 +31,6 @@ import java.util.HashSet;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class SystemSchemaUtils {
- private static final Collection<String> SYSTEM_CATALOG_QUERY_EXPRESSIONS = new HashSet<>(3, 1F);
-
- static {
- SYSTEM_CATALOG_QUERY_EXPRESSIONS.add("version()");
- SYSTEM_CATALOG_QUERY_EXPRESSIONS.add("intervaltonum(gs_password_deadline())");
- SYSTEM_CATALOG_QUERY_EXPRESSIONS.add("gs_password_notifytime()");
- }
-
/**
* Judge whether SQL statement contains system schema or not.
*
@@ -62,19 +50,4 @@ public final class SystemSchemaUtils {
}
return !(databaseType instanceof SchemaSupportedDatabaseType) && databaseType.getSystemSchemas().contains(database.getName());
}
-
- /**
- * Judge whether query is openGauss system catalog query or not.
- *
- * @param databaseType database type
- * @param projections projections
- * @return whether query is openGauss system catalog query or not
- */
- public static boolean isOpenGaussSystemCatalogQuery(final DatabaseType databaseType, final Collection<ProjectionSegment> projections) {
- if (!(databaseType instanceof OpenGaussDatabaseType)) {
- return false;
- }
- return 1 == projections.size() && projections.iterator().next() instanceof ExpressionProjectionSegment
- && SYSTEM_CATALOG_QUERY_EXPRESSIONS.contains(((ExpressionProjectionSegment) projections.iterator().next()).getText().toLowerCase());
- }
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/SQLFederationCompilerEngine.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/SQLFederationCompilerEngine.java
index 33fdbe240da..5156c0a5213 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/SQLFederationCompilerEngine.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/SQLFederationCompilerEngine.java
@@ -18,9 +18,10 @@
package org.apache.shardingsphere.sqlfederation.compiler;
import org.apache.shardingsphere.sql.parser.api.CacheOption;
-import org.apache.shardingsphere.sqlfederation.compiler.planner.cache.ExecutionPlanCacheKey;
+import org.apache.shardingsphere.sqlfederation.compiler.statement.SQLStatementCompiler;
import org.apache.shardingsphere.sqlfederation.compiler.statement.SQLStatementCompilerEngine;
import org.apache.shardingsphere.sqlfederation.compiler.statement.SQLStatementCompilerEngineFactory;
+import org.apache.shardingsphere.sqlfederation.compiler.planner.cache.ExecutionPlanCacheKey;
/**
* SQL federation compiler engine.
@@ -29,8 +30,8 @@ public final class SQLFederationCompilerEngine {
private final SQLStatementCompilerEngine sqlStatementCompilerEngine;
- public SQLFederationCompilerEngine(final String databaseName, final String schemaName, final CacheOption cacheOption) {
- sqlStatementCompilerEngine = SQLStatementCompilerEngineFactory.getSQLStatementCompilerEngine(databaseName, schemaName, cacheOption);
+ public SQLFederationCompilerEngine(final String schemaName, final SQLStatementCompiler sqlStatementCompiler, final CacheOption cacheOption) {
+ sqlStatementCompilerEngine = SQLStatementCompilerEngineFactory.getSQLStatementCompilerEngine(schemaName, sqlStatementCompiler, cacheOption);
}
/**
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/context/parser/dialect/impl/OpenGaussOptimizerBuilder.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/context/parser/dialect/impl/OpenGaussOptimizerBuilder.java
index cb7bc9903c5..00a6b021357 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/context/parser/dialect/impl/OpenGaussOptimizerBuilder.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/context/parser/dialect/impl/OpenGaussOptimizerBuilder.java
@@ -36,7 +36,7 @@ public final class OpenGaussOptimizerBuilder implements OptimizerSQLDialectBuild
result.setProperty(CalciteConnectionProperty.LEX.camelName(), Lex.JAVA.name());
result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(), SqlConformanceEnum.BABEL.name());
result.setProperty(CalciteConnectionProperty.FUN.camelName(), SqlLibrary.POSTGRESQL.fun);
- result.setProperty(CalciteConnectionProperty.CASE_SENSITIVE.camelName(), String.valueOf(false));
+ result.setProperty(CalciteConnectionProperty.CASE_SENSITIVE.camelName(), String.valueOf(Lex.JAVA.caseSensitive));
return result;
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/context/parser/dialect/impl/PostgreSQLOptimizerBuilder.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/context/parser/dialect/impl/PostgreSQLOptimizerBuilder.java
index 95f63b635f4..09e69781171 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/context/parser/dialect/impl/PostgreSQLOptimizerBuilder.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/context/parser/dialect/impl/PostgreSQLOptimizerBuilder.java
@@ -36,7 +36,7 @@ public final class PostgreSQLOptimizerBuilder implements OptimizerSQLDialectBuil
result.setProperty(CalciteConnectionProperty.LEX.camelName(), Lex.JAVA.name());
result.setProperty(CalciteConnectionProperty.CONFORMANCE.camelName(), SqlConformanceEnum.BABEL.name());
result.setProperty(CalciteConnectionProperty.FUN.camelName(), SqlLibrary.POSTGRESQL.fun);
- result.setProperty(CalciteConnectionProperty.CASE_SENSITIVE.camelName(), String.valueOf(false));
+ result.setProperty(CalciteConnectionProperty.CASE_SENSITIVE.camelName(), String.valueOf(Lex.JAVA.caseSensitive));
return result;
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/metadata/schema/SQLFederationTable.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/metadata/schema/SQLFederationTable.java
index 5cce718f439..84c718f0dde 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/metadata/schema/SQLFederationTable.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/metadata/schema/SQLFederationTable.java
@@ -38,11 +38,11 @@ import org.apache.calcite.schema.impl.AbstractTable;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.util.exception.external.sql.type.generic.UnsupportedSQLOperationException;
+import org.apache.shardingsphere.sqlfederation.executor.enumerable.EnumerablePushDownTableScanExecutorContext;
+import org.apache.shardingsphere.sqlfederation.executor.enumerable.EnumerablePushDownTableScanExecutor;
import org.apache.shardingsphere.sqlfederation.compiler.metadata.util.SQLFederationDataTypeUtils;
import org.apache.shardingsphere.sqlfederation.compiler.operator.physical.enumerable.EnumerablePushDownTableScan;
import org.apache.shardingsphere.sqlfederation.compiler.statistic.SQLFederationStatistic;
-import org.apache.shardingsphere.sqlfederation.executor.enumerable.EnumerablePushDownTableScanExecutor;
-import org.apache.shardingsphere.sqlfederation.executor.enumerable.EnumerablePushDownTableScanExecutorContext;
import java.lang.reflect.Type;
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheBuilder.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheBuilder.java
index 8ebe8e5a9df..6dd2878a619 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheBuilder.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheBuilder.java
@@ -22,6 +22,7 @@ import com.github.benmanes.caffeine.cache.LoadingCache;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.api.CacheOption;
+import org.apache.shardingsphere.sqlfederation.compiler.statement.SQLStatementCompiler;
import org.apache.shardingsphere.sqlfederation.compiler.SQLFederationExecutionPlan;
/**
@@ -34,9 +35,11 @@ public final class ExecutionPlanCacheBuilder {
* Build execution plan cache.
*
* @param executionPlanCache execution plan cache option
+ * @param sqlFederationCompiler sql federation compiler
* @return built execution plan cache
*/
- public static LoadingCache<ExecutionPlanCacheKey, SQLFederationExecutionPlan> build(final CacheOption executionPlanCache) {
- return Caffeine.newBuilder().softValues().initialCapacity(executionPlanCache.getInitialCapacity()).maximumSize(executionPlanCache.getMaximumSize()).build(new ExecutionPlanCacheLoader());
+ public static LoadingCache<ExecutionPlanCacheKey, SQLFederationExecutionPlan> build(final CacheOption executionPlanCache, final SQLStatementCompiler sqlFederationCompiler) {
+ return Caffeine.newBuilder().softValues().initialCapacity(executionPlanCache.getInitialCapacity()).maximumSize(executionPlanCache.getMaximumSize())
+ .build(new ExecutionPlanCacheLoader(sqlFederationCompiler));
}
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheKey.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheKey.java
index 7b8417be5ff..9d2107240ee 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheKey.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheKey.java
@@ -21,7 +21,6 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.sqlfederation.compiler.statement.SQLStatementCompiler;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -39,7 +38,5 @@ public final class ExecutionPlanCacheKey {
private final SQLStatement sqlStatement;
- private final SQLStatementCompiler sqlStatementCompiler;
-
private final Map<String, Integer> tableMetaDataVersions = new LinkedHashMap<>();
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
index 8e0fcfd81d1..f891b69e2dd 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.sqlfederation.compiler.planner.cache;
import com.github.benmanes.caffeine.cache.CacheLoader;
import org.apache.shardingsphere.sqlfederation.compiler.SQLFederationExecutionPlan;
+import org.apache.shardingsphere.sqlfederation.compiler.statement.SQLStatementCompiler;
import javax.annotation.ParametersAreNonnullByDefault;
@@ -27,9 +28,15 @@ import javax.annotation.ParametersAreNonnullByDefault;
*/
public final class ExecutionPlanCacheLoader implements CacheLoader<ExecutionPlanCacheKey, SQLFederationExecutionPlan> {
+ private final SQLStatementCompiler sqlStatementCompiler;
+
+ public ExecutionPlanCacheLoader(final SQLStatementCompiler sqlStatementCompiler) {
+ this.sqlStatementCompiler = sqlStatementCompiler;
+ }
+
@ParametersAreNonnullByDefault
@Override
public SQLFederationExecutionPlan load(final ExecutionPlanCacheKey cacheKey) {
- return cacheKey.getSqlStatementCompiler().compile(cacheKey.getSqlStatement());
+ return sqlStatementCompiler.compile(cacheKey.getSqlStatement());
}
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/util/SQLFederationFunctionUtils.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/util/SQLFederationFunctionUtils.java
deleted file mode 100644
index 1e77810a7a6..00000000000
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/util/SQLFederationFunctionUtils.java
+++ /dev/null
@@ -1,120 +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.sqlfederation.compiler.planner.util;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.calcite.schema.SchemaPlus;
-import org.apache.calcite.schema.impl.ScalarFunctionImpl;
-import org.apache.shardingsphere.infra.autogen.version.ShardingSphereVersion;
-
-/**
- * SQL federation function utility class.
- */
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class SQLFederationFunctionUtils {
-
- private static final int DEFAULT_PASSWORD_DEADLINE = 90;
-
- private static final int DEFAULT_PASSWORD_NOTIFY_TIME = 7;
-
- /**
- * Registry user defined function.
- *
- * @param schemaName schema name
- * @param schemaPlus schema plus
- */
- public static void registryUserDefinedFunction(final String schemaName, final SchemaPlus schemaPlus) {
- if (!"pg_catalog".equalsIgnoreCase(schemaName)) {
- return;
- }
- schemaPlus.add("pg_catalog.pg_table_is_visible", ScalarFunctionImpl.create(SQLFederationFunctionUtils.class, "pgTableIsVisible"));
- schemaPlus.add("pg_catalog.pg_get_userbyid", ScalarFunctionImpl.create(SQLFederationFunctionUtils.class, "pgGetUserById"));
- SchemaPlus subSchema = schemaPlus.getSubSchema(schemaName);
- if (null != subSchema) {
- subSchema.add("version", ScalarFunctionImpl.create(SQLFederationFunctionUtils.class, "version"));
- subSchema.add("gs_password_deadline", ScalarFunctionImpl.create(SQLFederationFunctionUtils.class, "gsPasswordDeadline"));
- subSchema.add("intervaltonum", ScalarFunctionImpl.create(SQLFederationFunctionUtils.class, "intervalToNum"));
- subSchema.add("gs_password_notifyTime", ScalarFunctionImpl.create(SQLFederationFunctionUtils.class, "gsPasswordNotifyTime"));
- }
- }
-
- /**
- * Mock pg_table_is_visible function.
- *
- * @param oid oid
- * @return true
- */
- @SuppressWarnings("unused")
- public static boolean pgTableIsVisible(final Long oid) {
- return true;
- }
-
- /**
- * Mock pg_get_userbyid function.
- *
- * @param oid oid
- * @return user name
- */
- @SuppressWarnings("unused")
- public static String pgGetUserById(final Long oid) {
- return "mock user";
- }
-
- /**
- * Get version of ShardingSphere-Proxy.
- *
- * @return version message
- */
- public static String version() {
- return "ShardingSphere-Proxy " + ShardingSphereVersion.VERSION + ("-" + ShardingSphereVersion.BUILD_GIT_COMMIT_ID_ABBREV) + (ShardingSphereVersion.BUILD_GIT_DIRTY ? "-dirty" : "");
- }
-
- /**
- * The type interval is not supported in standard JDBC.
- * Indicates the number of remaining days before the password of the current user expires.
- *
- * @return 90 days
- */
- @SuppressWarnings("unused")
- public static int gsPasswordDeadline() {
- return DEFAULT_PASSWORD_DEADLINE;
- }
-
- /**
- * The type interval is not supported in standard JDBC.
- * Convert interval to num.
- *
- * @param result result
- * @return result
- */
- @SuppressWarnings("unused")
- public static int intervalToNum(final int result) {
- return result;
- }
-
- /**
- * Specifies the number of days prior to password expiration that a user will receive a reminder.
- *
- * @return 7 days
- */
- @SuppressWarnings("unused")
- public static int gsPasswordNotifyTime() {
- return DEFAULT_PASSWORD_NOTIFY_TIME;
- }
-}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/util/SQLFederationPlannerUtils.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/util/SQLFederationPlannerUtils.java
index 8ae33aa54f6..e5851e60e0a 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/util/SQLFederationPlannerUtils.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/util/SQLFederationPlannerUtils.java
@@ -39,6 +39,8 @@ import org.apache.calcite.rel.rules.ProjectRemoveRule;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.rex.RexBuilder;
import org.apache.calcite.schema.Schema;
+import org.apache.calcite.schema.SchemaPlus;
+import org.apache.calcite.schema.impl.ScalarFunctionImpl;
import org.apache.calcite.sql.SqlOperatorTable;
import org.apache.calcite.sql.fun.SqlLibrary;
import org.apache.calcite.sql.fun.SqlLibraryOperatorTableFactory;
@@ -179,10 +181,40 @@ public final class SQLFederationPlannerUtils {
public static CalciteCatalogReader createCatalogReader(final String schemaName, final Schema schema, final RelDataTypeFactory relDataTypeFactory, final CalciteConnectionConfig connectionConfig) {
CalciteSchema rootSchema = CalciteSchema.createRootSchema(true);
rootSchema.add(schemaName, schema);
- SQLFederationFunctionUtils.registryUserDefinedFunction(schemaName, rootSchema.plus());
+ registryUserDefinedFunction(schemaName, rootSchema.plus());
return new CalciteCatalogReader(rootSchema, Collections.singletonList(schemaName), relDataTypeFactory, connectionConfig);
}
+ private static void registryUserDefinedFunction(final String schemaName, final SchemaPlus schemaPlus) {
+ if (!"pg_catalog".equalsIgnoreCase(schemaName)) {
+ return;
+ }
+ schemaPlus.add("pg_catalog.pg_table_is_visible", ScalarFunctionImpl.create(SQLFederationPlannerUtils.class, "pgTableIsVisible"));
+ schemaPlus.add("pg_catalog.pg_get_userbyid", ScalarFunctionImpl.create(SQLFederationPlannerUtils.class, "pgGetUserById"));
+ }
+
+ /**
+ * Mock pg_table_is_visible function.
+ *
+ * @param oid oid
+ * @return true
+ */
+ @SuppressWarnings("unused")
+ public static boolean pgTableIsVisible(final Long oid) {
+ return true;
+ }
+
+ /**
+ * Mock pg_get_userbyid function.
+ *
+ * @param oid oid
+ * @return user name
+ */
+ @SuppressWarnings("unused")
+ public static String pgGetUserById(final Long oid) {
+ return "mock user";
+ }
+
/**
* Create sql validator.
*
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompiler.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompiler.java
index 9f98b508966..04b8cdd3c0c 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompiler.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompiler.java
@@ -55,7 +55,6 @@ public final class SQLStatementCompiler {
RelDataType resultColumnType = Objects.requireNonNull(converter.validator).getValidatedNodeType(sqlNode);
RelNode rewritePlan = rewrite(logicPlan, hepPlanner);
RelNode physicalPlan = optimize(rewritePlan, converter);
- RelMetadataQueryBase.THREAD_PROVIDERS.remove();
return new SQLFederationExecutionPlan(physicalPlan, resultColumnType);
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompilerEngine.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompilerEngine.java
index c008edebc56..8603d395d2c 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompilerEngine.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompilerEngine.java
@@ -28,10 +28,13 @@ import org.apache.shardingsphere.sqlfederation.compiler.planner.cache.ExecutionP
*/
public final class SQLStatementCompilerEngine {
+ private final SQLStatementCompiler sqlFederationCompiler;
+
private final LoadingCache<ExecutionPlanCacheKey, SQLFederationExecutionPlan> executionPlanCache;
- public SQLStatementCompilerEngine(final CacheOption cacheOption) {
- executionPlanCache = ExecutionPlanCacheBuilder.build(cacheOption);
+ public SQLStatementCompilerEngine(final SQLStatementCompiler sqlFederationCompiler, final CacheOption cacheOption) {
+ this.sqlFederationCompiler = sqlFederationCompiler;
+ executionPlanCache = ExecutionPlanCacheBuilder.build(cacheOption, sqlFederationCompiler);
}
/**
@@ -42,6 +45,6 @@ public final class SQLStatementCompilerEngine {
* @return SQL federation execution plan
*/
public SQLFederationExecutionPlan compile(final ExecutionPlanCacheKey cacheKey, final boolean useCache) {
- return useCache ? executionPlanCache.get(cacheKey) : cacheKey.getSqlStatementCompiler().compile(cacheKey.getSqlStatement());
+ return useCache ? executionPlanCache.get(cacheKey) : sqlFederationCompiler.compile(cacheKey.getSqlStatement());
}
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompilerEngineFactory.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompilerEngineFactory.java
index 61e329018d0..1392603a987 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompilerEngineFactory.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/statement/SQLStatementCompilerEngineFactory.java
@@ -35,16 +35,15 @@ public final class SQLStatementCompilerEngineFactory {
/**
* Get SQL statement compiler engine.
*
- * @param databaseName database name
* @param schemaName schema name
+ * @param sqlStatementCompiler sql statement compiler
* @param cacheOption execution plan cache option
* @return SQL statement compiler engine
*/
- public static SQLStatementCompilerEngine getSQLStatementCompilerEngine(final String databaseName, final String schemaName, final CacheOption cacheOption) {
- String cacheKey = databaseName + "." + schemaName;
- SQLStatementCompilerEngine result = COMPILER_ENGINES.get(cacheKey);
+ public static SQLStatementCompilerEngine getSQLStatementCompilerEngine(final String schemaName, final SQLStatementCompiler sqlStatementCompiler, final CacheOption cacheOption) {
+ SQLStatementCompilerEngine result = COMPILER_ENGINES.get(schemaName);
if (null == result) {
- result = COMPILER_ENGINES.computeIfAbsent(cacheKey, unused -> new SQLStatementCompilerEngine(cacheOption));
+ result = COMPILER_ENGINES.computeIfAbsent(schemaName, unused -> new SQLStatementCompilerEngine(sqlStatementCompiler, cacheOption));
}
return result;
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/engine/SQLFederationEngine.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/engine/SQLFederationEngine.java
index 757cd973fdf..dc567efeacb 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/engine/SQLFederationEngine.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/engine/SQLFederationEngine.java
@@ -34,12 +34,12 @@ import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.J
import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
import org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
+import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatistics;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.database.schema.util.SystemSchemaUtils;
-import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatistics;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.spi.type.ordered.OrderedSPILoader;
@@ -137,9 +137,7 @@ public final class SQLFederationEngine implements AutoCloseable {
private boolean isQuerySystemSchema(final SQLStatementContext sqlStatementContext, final ShardingSphereDatabase database) {
return sqlStatementContext instanceof SelectStatementContext
- && (SystemSchemaUtils.containsSystemSchema(sqlStatementContext.getDatabaseType(), sqlStatementContext.getTablesContext().getSchemaNames(), database)
- || SystemSchemaUtils.isOpenGaussSystemCatalogQuery(sqlStatementContext.getDatabaseType(),
- ((SelectStatementContext) sqlStatementContext).getSqlStatement().getProjections().getProjections()));
+ && SystemSchemaUtils.containsSystemSchema(sqlStatementContext.getDatabaseType(), sqlStatementContext.getTablesContext().getSchemaNames(), database);
}
/**
@@ -173,15 +171,14 @@ public final class SQLFederationEngine implements AutoCloseable {
OptimizerPlannerContext plannerContext = sqlFederationRule.getOptimizerContext().getPlannerContext(databaseName);
Schema sqlFederationSchema = plannerContext.getValidator(schemaName).getCatalogReader().getRootSchema().plus().getSubSchema(schemaName);
registerTableScanExecutor(sqlFederationSchema, prepareEngine, callback, federationContext, sqlFederationRule.getOptimizerContext());
- SQLStatementCompiler sqlStatementCompiler = new SQLStatementCompiler(plannerContext.getConverter(schemaName), plannerContext.getHepPlanner());
- SQLFederationCompilerEngine compilerEngine = new SQLFederationCompilerEngine(databaseName, schemaName, sqlFederationRule.getConfiguration().getExecutionPlanCache());
- return compilerEngine.compile(buildCacheKey(federationContext, selectStatementContext, sqlStatementCompiler), federationContext.getQueryContext().isUseCache());
+ SQLFederationCompilerEngine compilerEngine = new SQLFederationCompilerEngine(schemaName, new SQLStatementCompiler(plannerContext.getConverter(schemaName), plannerContext.getHepPlanner()),
+ sqlFederationRule.getConfiguration().getExecutionPlanCache());
+ return compilerEngine.compile(buildCacheKey(federationContext, selectStatementContext), federationContext.getQueryContext().isUseCache());
}
- private ExecutionPlanCacheKey buildCacheKey(final SQLFederationExecutorContext federationContext, final SelectStatementContext selectStatementContext,
- final SQLStatementCompiler sqlStatementCompiler) {
+ private ExecutionPlanCacheKey buildCacheKey(final SQLFederationExecutorContext federationContext, final SelectStatementContext selectStatementContext) {
ShardingSphereSchema schema = federationContext.getMetaData().getDatabase(databaseName).getSchema(schemaName);
- ExecutionPlanCacheKey result = new ExecutionPlanCacheKey(federationContext.getQueryContext().getSql(), selectStatementContext.getSqlStatement(), sqlStatementCompiler);
+ ExecutionPlanCacheKey result = new ExecutionPlanCacheKey(federationContext.getQueryContext().getSql(), selectStatementContext.getSqlStatement());
for (String each : selectStatementContext.getTablesContext().getTableNames()) {
ShardingSphereTable table = schema.getTable(each);
ShardingSpherePreconditions.checkState(null != table, () -> new NoSuchTableException(each));
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerablePushDownTableScanExecutor.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerablePushDownTableScanExecutor.java
index e11d4c97b12..87c27a91936 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerablePushDownTableScanExecutor.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/executor/enumerable/EnumerablePushDownTableScanExecutor.java
@@ -40,13 +40,11 @@ import org.apache.calcite.rex.RexNode;
import org.apache.calcite.sql.SqlDialect;
import org.apache.calcite.sql.util.SqlString;
import org.apache.calcite.tools.RelBuilder;
-import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.infra.binder.SQLStatementContextFactory;
import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
import org.apache.shardingsphere.infra.connection.kernel.KernelProcessor;
import org.apache.shardingsphere.infra.database.type.DatabaseType;
import org.apache.shardingsphere.infra.database.type.DatabaseTypeEngine;
-import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroup;
import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroupContext;
import org.apache.shardingsphere.infra.executor.kernel.model.ExecutionGroupReportContext;
@@ -66,13 +64,10 @@ import org.apache.shardingsphere.infra.merge.result.MergedResult;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
-import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereSchemaData;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatistics;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
import org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine;
import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
import org.apache.shardingsphere.infra.session.query.QueryContext;
@@ -95,14 +90,11 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -118,16 +110,6 @@ public final class EnumerablePushDownTableScanExecutor {
private static final Pattern COLUMN_INFORMATION_PATTERN = Pattern.compile("\\{.*}");
- private static final Collection<String> SYSTEM_CATALOG_TABLES = new HashSet<>(3, 1F);
-
- private static final String DAT_COMPATIBILITY = "PG";
-
- private static final String PG_DATABASE = "pg_database";
-
- private static final String PG_TABLES = "pg_tables";
-
- private static final String PG_ROLES = "pg_roles";
-
private final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine;
private final JDBCExecutor jdbcExecutor;
@@ -144,12 +126,6 @@ public final class EnumerablePushDownTableScanExecutor {
private final ProcessEngine processEngine = new ProcessEngine();
- static {
- SYSTEM_CATALOG_TABLES.add(PG_DATABASE);
- SYSTEM_CATALOG_TABLES.add(PG_TABLES);
- SYSTEM_CATALOG_TABLES.add(PG_ROLES);
- }
-
/**
* Execute.
*
@@ -162,7 +138,7 @@ public final class EnumerablePushDownTableScanExecutor {
String schemaName = executorContext.getSchemaName().toLowerCase();
DatabaseType databaseType = DatabaseTypeEngine.getTrunkDatabaseType(optimizerContext.getParserContext(databaseName).getDatabaseType().getType());
if (databaseType.getSystemSchemas().contains(schemaName)) {
- return executeByScalarShardingSphereData(databaseName, schemaName, table, databaseType, scanContext.getProjects());
+ return executeByScalarShardingSphereData(databaseName, schemaName, table);
}
SqlString sqlString = createSQLString(table, scanContext, SQLDialectFactory.getSQLDialect(databaseType.getType()));
SQLFederationExecutorContext federationContext = executorContext.getFederationContext();
@@ -186,68 +162,12 @@ public final class EnumerablePushDownTableScanExecutor {
};
}
- private Enumerable<Object> executeByScalarShardingSphereData(final String databaseName, final String schemaName, final ShardingSphereTable table, final DatabaseType databaseType,
- final int[] projects) {
- // TODO move this logic to ShardingSphere statistics
- if (databaseType instanceof OpenGaussDatabaseType && SYSTEM_CATALOG_TABLES.contains(table.getName().toLowerCase())) {
- return createMemoryScalarEnumerator(createSystemCatalogTableData(table, projects));
- }
+ private Enumerable<Object> executeByScalarShardingSphereData(final String databaseName, final String schemaName, final ShardingSphereTable table) {
Optional<ShardingSphereTableData> tableData = Optional.ofNullable(statistics.getDatabaseData().get(databaseName)).map(optional -> optional.getSchemaData().get(schemaName))
- .map(optional -> optional.getTable(table.getName()));
+ .map(ShardingSphereSchemaData::getTableData).map(shardingSphereData -> shardingSphereData.get(table.getName()));
return tableData.map(this::createMemoryScalarEnumerator).orElseGet(this::createEmptyScalarEnumerable);
}
- private ShardingSphereTableData createSystemCatalogTableData(final ShardingSphereTable table, final int[] projects) {
- ShardingSphereTableData result = new ShardingSphereTableData(table.getName());
- ShardingSphereMetaData metaData = executorContext.getFederationContext().getMetaData();
- if (PG_DATABASE.equalsIgnoreCase(table.getName())) {
- appendOpenGaussDatabaseData(result, metaData.getDatabases().values(), projects);
- } else if (PG_TABLES.equalsIgnoreCase(table.getName())) {
- for (ShardingSphereDatabase each : metaData.getDatabases().values()) {
- appendOpenGaussTableData(result, each.getSchemas(), projects);
- }
- } else if (PG_ROLES.equalsIgnoreCase(table.getName())) {
- appendOpenGaussRoleData(result, metaData, projects);
- }
- return result;
- }
-
- private void appendOpenGaussDatabaseData(final ShardingSphereTableData tableData, final Collection<ShardingSphereDatabase> databases, final int[] projects) {
- for (ShardingSphereDatabase each : databases) {
- Object[] rows = new Object[15];
- rows[0] = each.getName();
- rows[11] = DAT_COMPATIBILITY;
- tableData.getRows().add(new ShardingSphereRowData(Arrays.asList(filterRows(rows, projects))));
- }
- }
-
- private Object[] filterRows(final Object[] rows, final int[] projects) {
- Object[] result = new Object[projects.length];
- for (int index = 0; index < projects.length; index++) {
- result[index] = rows[projects[index]];
- }
- return result;
- }
-
- private void appendOpenGaussTableData(final ShardingSphereTableData tableData, final Map<String, ShardingSphereSchema> schemas, final int[] projects) {
- for (Entry<String, ShardingSphereSchema> entry : schemas.entrySet()) {
- for (String each : entry.getValue().getAllTableNames()) {
- Object[] rows = new Object[10];
- rows[0] = entry.getKey();
- rows[1] = each;
- tableData.getRows().add(new ShardingSphereRowData(Arrays.asList(filterRows(rows, projects))));
- }
- }
- }
-
- private void appendOpenGaussRoleData(final ShardingSphereTableData tableData, final ShardingSphereMetaData metaData, final int[] projects) {
- for (ShardingSphereUser each : metaData.getGlobalRuleMetaData().getSingleRule(AuthorityRule.class).getConfiguration().getUsers()) {
- Object[] rows = new Object[27];
- rows[0] = each.getGrantee().getUsername();
- tableData.getRows().add(new ShardingSphereRowData(Arrays.asList(filterRows(rows, projects))));
- }
- }
-
private Enumerable<Object> createMemoryScalarEnumerator(final ShardingSphereTableData tableData) {
return new AbstractEnumerable<Object>() {
@@ -310,7 +230,7 @@ public final class EnumerablePushDownTableScanExecutor {
String schemaName = executorContext.getSchemaName().toLowerCase();
DatabaseType databaseType = DatabaseTypeEngine.getTrunkDatabaseType(optimizerContext.getParserContext(databaseName).getDatabaseType().getType());
if (databaseType.getSystemSchemas().contains(schemaName)) {
- return executeByShardingSphereData(databaseName, schemaName, table, databaseType, scanContext.getProjects());
+ return executeByShardingSphereData(databaseName, schemaName, table);
}
SqlString sqlString = createSQLString(table, scanContext, SQLDialectFactory.getSQLDialect(databaseType.getType()));
SQLFederationExecutorContext federationContext = executorContext.getFederationContext();
@@ -343,12 +263,7 @@ public final class EnumerablePushDownTableScanExecutor {
}
}
- private Enumerable<Object[]> executeByShardingSphereData(final String databaseName, final String schemaName, final ShardingSphereTable table, final DatabaseType databaseType,
- final int[] projects) {
- // TODO move this logic to ShardingSphere statistics
- if (databaseType instanceof OpenGaussDatabaseType && SYSTEM_CATALOG_TABLES.contains(table.getName().toLowerCase())) {
- return createMemoryEnumerator(createSystemCatalogTableData(table, projects));
- }
+ private Enumerable<Object[]> executeByShardingSphereData(final String databaseName, final String schemaName, final ShardingSphereTable table) {
Optional<ShardingSphereTableData> tableData = Optional.ofNullable(statistics.getDatabaseData().get(databaseName)).map(optional -> optional.getSchemaData().get(schemaName))
.map(ShardingSphereSchemaData::getTableData).map(shardingSphereData -> shardingSphereData.get(table.getName()));
return tableData.map(this::createMemoryEnumerator).orElseGet(this::createEmptyEnumerable);
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java
index 8e8269f6492..b52d391009a 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java
+++ b/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/resultset/SQLFederationResultSetMetaData.java
@@ -30,7 +30,6 @@ import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import java.sql.ResultSetMetaData;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -104,19 +103,12 @@ public final class SQLFederationResultSetMetaData extends WrapperAdapter impleme
@Override
public String getColumnLabel(final int column) {
- if (indexAndColumnLabels.size() < column) {
- return resultColumnType.getFieldList().get(column - 1).getName();
- }
return indexAndColumnLabels.get(column);
}
@Override
public String getColumnName(final int column) {
- List<Projection> expandProjections = selectStatementContext.getProjectionsContext().getExpandProjections();
- if (expandProjections.size() < column) {
- return resultColumnType.getFieldList().get(column - 1).getName();
- }
- Projection projection = expandProjections.get(column - 1);
+ Projection projection = selectStatementContext.getProjectionsContext().getExpandProjections().get(column - 1);
if (projection instanceof ColumnProjection) {
return ((ColumnProjection) projection).getName();
}
@@ -181,8 +173,7 @@ public final class SQLFederationResultSetMetaData extends WrapperAdapter impleme
}
private Optional<String> findTableName(final int column) {
- List<Projection> expandProjections = selectStatementContext.getProjectionsContext().getExpandProjections();
- Projection projection = expandProjections.size() < column ? new ColumnProjection(null, resultColumnType.getFieldList().get(column - 1).getName(), null) : expandProjections.get(column - 1);
+ Projection projection = selectStatementContext.getProjectionsContext().getExpandProjections().get(column - 1);
if (projection instanceof ColumnProjection) {
Map<String, String> tableNamesByColumnProjection =
selectStatementContext.getTablesContext().findTableNamesByColumnProjection(Collections.singletonList((ColumnProjection) projection), schema);
diff --git a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/it/SQLFederationCompilerEngineIT.java b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/it/SQLFederationCompilerEngineIT.java
index b0dbdf07197..60fc5e3b3d4 100644
--- a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/it/SQLFederationCompilerEngineIT.java
+++ b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/compiler/it/SQLFederationCompilerEngineIT.java
@@ -38,10 +38,10 @@ import org.apache.shardingsphere.parser.rule.SQLParserRule;
import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder;
import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
import org.apache.shardingsphere.sqlfederation.compiler.SQLFederationCompilerEngine;
+import org.apache.shardingsphere.sqlfederation.compiler.statement.SQLStatementCompiler;
import org.apache.shardingsphere.sqlfederation.compiler.metadata.schema.SQLFederationSchema;
import org.apache.shardingsphere.sqlfederation.compiler.planner.cache.ExecutionPlanCacheKey;
import org.apache.shardingsphere.sqlfederation.compiler.planner.util.SQLFederationPlannerUtils;
-import org.apache.shardingsphere.sqlfederation.compiler.statement.SQLStatementCompiler;
import org.apache.shardingsphere.sqlfederation.rule.builder.DefaultSQLFederationRuleConfigurationBuilder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -72,8 +72,6 @@ class SQLFederationCompilerEngineIT {
private SQLFederationCompilerEngine sqlFederationCompilerEngine;
- private SQLStatementCompiler sqlStatementCompiler;
-
@BeforeEach
void init() {
Map<String, ShardingSphereTable> tables = new HashMap<>();
@@ -89,9 +87,9 @@ class SQLFederationCompilerEngineIT {
tables.put("t_product_detail", createTProductDetailMetaData());
tables.put("multi_types_first", createMultiTypesFirstTableMetaData());
tables.put("multi_types_second", createMultiTypesSecondTableMetaData());
- sqlStatementCompiler = new SQLStatementCompiler(createSqlToRelConverter(new ShardingSphereSchema(tables, Collections.emptyMap())), SQLFederationPlannerUtils.createHepPlanner());
- sqlFederationCompilerEngine =
- new SQLFederationCompilerEngine(DefaultDatabase.LOGIC_NAME, DefaultDatabase.LOGIC_NAME, DefaultSQLFederationRuleConfigurationBuilder.DEFAULT_EXECUTION_PLAN_CACHE_OPTION);
+ sqlFederationCompilerEngine = new SQLFederationCompilerEngine(DefaultDatabase.LOGIC_NAME,
+ new SQLStatementCompiler(createSqlToRelConverter(new ShardingSphereSchema(tables, Collections.emptyMap())), SQLFederationPlannerUtils.createHepPlanner()),
+ DefaultSQLFederationRuleConfigurationBuilder.DEFAULT_EXECUTION_PLAN_CACHE_OPTION);
}
private ShardingSphereTable createOrderFederationTableMetaData() {
@@ -255,8 +253,7 @@ class SQLFederationCompilerEngineIT {
@ArgumentsSource(TestCaseArgumentsProvider.class)
void assertCompile(final TestCase testcase) {
SQLStatement sqlStatement = sqlParserRule.getSQLParserEngine(DatabaseTypeEngine.getTrunkDatabaseTypeName(new H2DatabaseType())).parse(testcase.getSql(), false);
- String actual = sqlFederationCompilerEngine.compile(new ExecutionPlanCacheKey(testcase.getSql(), sqlStatement, sqlStatementCompiler), false).getPhysicalPlan()
- .explain().replaceAll("[\r\n]", "");
+ String actual = sqlFederationCompilerEngine.compile(new ExecutionPlanCacheKey(testcase.getSql(), sqlStatement), false).getPhysicalPlan().explain().replaceAll("[\r\n]", "");
assertThat(actual, is(testcase.getAssertion().getExpectedResult()));
}
diff --git a/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreator.java b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreator.java
index 82c75dc6e3f..9cd59d4e757 100644
--- a/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreator.java
+++ b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreator.java
@@ -59,7 +59,7 @@ public final class OpenGaussAdminExecutorCreator implements DatabaseAdminExecuto
@Override
public Optional<DatabaseAdminExecutor> create(final SQLStatementContext sqlStatementContext, final String sql, final String databaseName, final List<Object> parameters) {
if (isSystemCatalogQuery(sqlStatementContext)) {
- return Optional.of(new OpenGaussSystemCatalogAdminQueryExecutor(sqlStatementContext, sql, databaseName, parameters));
+ return Optional.of(new OpenGaussSystemCatalogAdminQueryExecutor(sql));
}
return delegated.create(sqlStatementContext, sql, databaseName, parameters);
}
diff --git a/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutor.java b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutor.java
index 1beb2817483..94eecefd513 100644
--- a/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutor.java
+++ b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutor.java
@@ -18,104 +18,140 @@
package org.apache.shardingsphere.proxy.backend.opengauss.handler.admin;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
-import org.apache.shardingsphere.infra.config.props.ConfigurationPropertyKey;
-import org.apache.shardingsphere.infra.database.type.DatabaseType;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.ConnectionMode;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.SQLExecutorExceptionHandler;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutionUnit;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutor;
-import org.apache.shardingsphere.infra.executor.sql.execute.engine.driver.jdbc.JDBCExecutorCallback;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.ExecuteResult;
+import org.apache.calcite.adapter.java.ReflectiveSchema;
+import org.apache.calcite.jdbc.CalciteConnection;
+import org.apache.calcite.schema.impl.ScalarFunctionImpl;
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
+import org.apache.shardingsphere.infra.autogen.version.ShardingSphereVersion;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.metadata.JDBCQueryResultMetaData;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.memory.JDBCMemoryQueryResult;
-import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.stream.JDBCStreamQueryResult;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.DriverExecutionPrepareEngine;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.JDBCDriverType;
-import org.apache.shardingsphere.infra.executor.sql.prepare.driver.jdbc.StatementOption;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.session.query.QueryContext;
-import org.apache.shardingsphere.mode.metadata.MetaDataContexts;
-import org.apache.shardingsphere.proxy.backend.context.BackendExecutorContext;
+import org.apache.shardingsphere.infra.metadata.database.schema.builder.SystemSchemaBuilderRule;
+import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.handler.admin.executor.DatabaseAdminQueryExecutor;
+import org.apache.shardingsphere.proxy.backend.opengauss.handler.admin.schema.OpenGaussDatabase;
+import org.apache.shardingsphere.proxy.backend.opengauss.handler.admin.schema.OpenGaussRoles;
+import org.apache.shardingsphere.proxy.backend.opengauss.handler.admin.schema.OpenGaussSystemCatalog;
+import org.apache.shardingsphere.proxy.backend.opengauss.handler.admin.schema.OpenGaussTables;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
import org.apache.shardingsphere.sharding.merge.common.IteratorStreamMergedResult;
-import org.apache.shardingsphere.sql.parser.sql.common.statement.SQLStatement;
-import org.apache.shardingsphere.sqlfederation.engine.SQLFederationEngine;
-import org.apache.shardingsphere.sqlfederation.executor.SQLFederationExecutorContext;
+import org.apache.shardingsphere.sql.parser.sql.common.util.SQLUtils;
import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
+import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
/**
* Select database executor for openGauss.
*/
-@RequiredArgsConstructor
+@SuppressWarnings("unused")
public final class OpenGaussSystemCatalogAdminQueryExecutor implements DatabaseAdminQueryExecutor {
private static final String PG_CATALOG = "pg_catalog";
- private final SQLStatementContext sqlStatementContext;
+ private static final String DAT_COMPATIBILITY = "PG";
private final String sql;
- private final String databaseName;
-
- private final List<Object> parameters;
-
@Getter
private QueryResultMetaData queryResultMetaData;
@Getter
private MergedResult mergedResult;
+ public OpenGaussSystemCatalogAdminQueryExecutor(final String sql) {
+ this.sql = SQLUtils.trimSemicolon(sql);
+ }
+
@Override
public void execute(final ConnectionSession connectionSession) throws SQLException {
- MetaDataContexts metaDataContexts = ProxyContext.getInstance().getContextManager().getMetaDataContexts();
- JDBCExecutor jdbcExecutor = new JDBCExecutor(BackendExecutorContext.getInstance().getExecutorEngine(), connectionSession.getConnectionContext());
- try (SQLFederationEngine sqlFederationEngine = new SQLFederationEngine(databaseName, PG_CATALOG, metaDataContexts.getMetaData(), metaDataContexts.getStatistics(), jdbcExecutor)) {
- DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine = createDriverExecutionPrepareEngine(metaDataContexts, connectionSession);
- SQLFederationExecutorContext context = new SQLFederationExecutorContext(false, new QueryContext(sqlStatementContext, sql, parameters), metaDataContexts.getMetaData());
- ShardingSphereDatabase database = metaDataContexts.getMetaData().getDatabase(databaseName);
- ResultSet resultSet = sqlFederationEngine.executeQuery(prepareEngine,
- createOpenGaussSystemCatalogAdminQueryCallback(database.getProtocolType(), database.getResourceMetaData().getStorageTypes(), sqlStatementContext.getSqlStatement()), context);
- queryResultMetaData = new JDBCQueryResultMetaData(resultSet.getMetaData());
- mergedResult = new IteratorStreamMergedResult(Collections.singletonList(new JDBCMemoryQueryResult(resultSet, connectionSession.getProtocolType())));
+ try (Connection connection = DriverManager.getConnection("jdbc:calcite:caseSensitive=false")) {
+ prepareCalciteConnection(connection);
+ connection.setSchema(PG_CATALOG);
+ try (PreparedStatement statement = connection.prepareStatement(sql); ResultSet resultSet = statement.executeQuery()) {
+ queryResultMetaData = new JDBCQueryResultMetaData(resultSet.getMetaData());
+ mergedResult = new IteratorStreamMergedResult(Collections.singletonList(new JDBCMemoryQueryResult(resultSet, connectionSession.getProtocolType())));
+ }
}
}
- @SuppressWarnings({"rawtypes", "unchecked"})
- private DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> createDriverExecutionPrepareEngine(final MetaDataContexts metaDataContexts, final ConnectionSession connectionSession) {
- int maxConnectionsSizePerQuery = metaDataContexts.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.MAX_CONNECTIONS_SIZE_PER_QUERY);
- return new DriverExecutionPrepareEngine<>(JDBCDriverType.STATEMENT, maxConnectionsSizePerQuery, connectionSession.getDatabaseConnectionManager(),
- connectionSession.getStatementManager(), new StatementOption(false),
- metaDataContexts.getMetaData().getDatabase(databaseName).getRuleMetaData().getRules(),
- metaDataContexts.getMetaData().getDatabase(databaseName).getResourceMetaData().getStorageTypes());
+ private void prepareCalciteConnection(final Connection connection) throws SQLException {
+ CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
+ calciteConnection.getRootSchema().add(PG_CATALOG, new ReflectiveSchema(constructOgCatalog()));
+ calciteConnection.getRootSchema().add("version", ScalarFunctionImpl.create(getClass(), "version"));
+ calciteConnection.getRootSchema().add("gs_password_deadline", ScalarFunctionImpl.create(getClass(), "gsPasswordDeadline"));
+ calciteConnection.getRootSchema().add("intervaltonum", ScalarFunctionImpl.create(getClass(), "intervalToNum"));
+ calciteConnection.getRootSchema().add("gs_password_notifyTime", ScalarFunctionImpl.create(getClass(), "gsPasswordNotifyTime"));
}
- private JDBCExecutorCallback<ExecuteResult> createOpenGaussSystemCatalogAdminQueryCallback(final DatabaseType protocolType, final Map<String, DatabaseType> storageTypes,
- final SQLStatement sqlStatement) {
- return new JDBCExecutorCallback<ExecuteResult>(protocolType, storageTypes, sqlStatement, SQLExecutorExceptionHandler.isExceptionThrown()) {
-
- @Override
- protected ExecuteResult executeSQL(final String sql, final Statement statement, final ConnectionMode connectionMode, final DatabaseType storageType) throws SQLException {
- return new JDBCStreamQueryResult(statement.executeQuery(sql));
- }
-
- @Override
- protected Optional<ExecuteResult> getSaneResult(final SQLStatement sqlStatement, final SQLException ex) {
- return Optional.empty();
+ private OpenGaussSystemCatalog constructOgCatalog() {
+ Collection<String> allDatabaseNames = ProxyContext.getInstance().getAllDatabaseNames();
+ OpenGaussDatabase[] openGaussDatabases = new OpenGaussDatabase[allDatabaseNames.size()];
+ List<OpenGaussTables> openGaussTables = new LinkedList<>();
+ List<OpenGaussRoles> openGaussRoles = new LinkedList<>();
+ ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(AuthorityRule.class)
+ .getConfiguration().getUsers().stream().map(user -> user.getGrantee().getUsername())
+ .forEach(userName -> openGaussRoles.add(new OpenGaussRoles(userName)));
+ int index = 0;
+ for (String each : allDatabaseNames) {
+ for (Entry<String, ShardingSphereSchema> entry : ProxyContext.getInstance().getDatabase(each).getSchemas().entrySet()) {
+ for (String tableName : entry.getValue().getAllTableNames()) {
+ openGaussTables.add(new OpenGaussTables(entry.getKey(), tableName));
+ }
}
- };
+ openGaussDatabases[index++] = new OpenGaussDatabase(each, DAT_COMPATIBILITY);
+ }
+ openGaussTables.addAll(SystemSchemaBuilderRule.OPEN_GAUSS_PG_CATALOG.getTables().stream().map(tableName -> new OpenGaussTables(PG_CATALOG, tableName)).collect(Collectors.toSet()));
+ openGaussTables.addAll(SystemSchemaBuilderRule.POSTGRESQL_PG_CATALOG.getTables().stream().map(tableName -> new OpenGaussTables(PG_CATALOG, tableName)).collect(Collectors.toSet()));
+ return new OpenGaussSystemCatalog(openGaussDatabases, openGaussTables.toArray(new OpenGaussTables[0]), openGaussRoles.toArray(new OpenGaussRoles[0]));
+ }
+
+ /**
+ * Get version of ShardingSphere-Proxy.
+ *
+ * @return version message
+ */
+ public static String version() {
+ return "ShardingSphere-Proxy " + ShardingSphereVersion.VERSION + ("-" + ShardingSphereVersion.BUILD_GIT_COMMIT_ID_ABBREV) + (ShardingSphereVersion.BUILD_GIT_DIRTY ? "-dirty" : "");
+ }
+
+ /**
+ * The type interval is not supported in standard JDBC.
+ * Indicates the number of remaining days before the password of the current user expires.
+ *
+ * @return 90 days
+ */
+ public static int gsPasswordDeadline() {
+ return 90;
+ }
+
+ /**
+ * The type interval is not supported in standard JDBC.
+ * Convert interval to num.
+ *
+ * @param result result
+ * @return result
+ */
+ public static int intervalToNum(final int result) {
+ return result;
+ }
+
+ /**
+ * Specifies the number of days prior to password expiration that a user will receive a reminder.
+ *
+ * @return 7 days
+ */
+ public static int gsPasswordNotifyTime() {
+ return 7;
}
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussDatabase.java
similarity index 56%
copy from kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
copy to proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussDatabase.java
index 8e0fcfd81d1..1a5654c4c12 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
+++ b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussDatabase.java
@@ -15,21 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sqlfederation.compiler.planner.cache;
+package org.apache.shardingsphere.proxy.backend.opengauss.handler.admin.schema;
-import com.github.benmanes.caffeine.cache.CacheLoader;
-import org.apache.shardingsphere.sqlfederation.compiler.SQLFederationExecutionPlan;
-
-import javax.annotation.ParametersAreNonnullByDefault;
+import lombok.RequiredArgsConstructor;
/**
- * Execution plan cache loader.
+ * System table which maintains databases in openGauss system catalog schema.
*/
-public final class ExecutionPlanCacheLoader implements CacheLoader<ExecutionPlanCacheKey, SQLFederationExecutionPlan> {
+@RequiredArgsConstructor
+public final class OpenGaussDatabase {
+
+ // CHECKSTYLE:OFF
+ public final String datname;
- @ParametersAreNonnullByDefault
- @Override
- public SQLFederationExecutionPlan load(final ExecutionPlanCacheKey cacheKey) {
- return cacheKey.getSqlStatementCompiler().compile(cacheKey.getSqlStatement());
- }
+ public final String datcompatibility;
+ // CHECKSTYLE:ON
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussRoles.java
similarity index 56%
copy from kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
copy to proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussRoles.java
index 8e0fcfd81d1..e8bdd04d34a 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
+++ b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussRoles.java
@@ -15,21 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sqlfederation.compiler.planner.cache;
+package org.apache.shardingsphere.proxy.backend.opengauss.handler.admin.schema;
-import com.github.benmanes.caffeine.cache.CacheLoader;
-import org.apache.shardingsphere.sqlfederation.compiler.SQLFederationExecutionPlan;
-
-import javax.annotation.ParametersAreNonnullByDefault;
+import lombok.EqualsAndHashCode;
+import lombok.RequiredArgsConstructor;
/**
- * Execution plan cache loader.
+ * System table which maintains tables in openGauss system catalog schema.
*/
-public final class ExecutionPlanCacheLoader implements CacheLoader<ExecutionPlanCacheKey, SQLFederationExecutionPlan> {
+@EqualsAndHashCode
+@RequiredArgsConstructor
+public final class OpenGaussRoles {
- @ParametersAreNonnullByDefault
- @Override
- public SQLFederationExecutionPlan load(final ExecutionPlanCacheKey cacheKey) {
- return cacheKey.getSqlStatementCompiler().compile(cacheKey.getSqlStatement());
- }
+ // CHECKSTYLE:OFF
+ public final String rolname;
+ // CHECKSTYLE:ON
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussSystemCatalog.java
similarity index 56%
copy from kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
copy to proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussSystemCatalog.java
index 8e0fcfd81d1..5912bd4c247 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
+++ b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussSystemCatalog.java
@@ -15,21 +15,22 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sqlfederation.compiler.planner.cache;
+package org.apache.shardingsphere.proxy.backend.opengauss.handler.admin.schema;
-import com.github.benmanes.caffeine.cache.CacheLoader;
-import org.apache.shardingsphere.sqlfederation.compiler.SQLFederationExecutionPlan;
-
-import javax.annotation.ParametersAreNonnullByDefault;
+import lombok.RequiredArgsConstructor;
/**
- * Execution plan cache loader.
+ * TODO we should refactor this with our federation modules.
+ * System catalog schema of openGauss.
*/
-public final class ExecutionPlanCacheLoader implements CacheLoader<ExecutionPlanCacheKey, SQLFederationExecutionPlan> {
+@RequiredArgsConstructor
+public final class OpenGaussSystemCatalog {
+
+ // CHECKSTYLE:OFF
+ public final OpenGaussDatabase[] pg_database;
+
+ public final OpenGaussTables[] pg_tables;
- @ParametersAreNonnullByDefault
- @Override
- public SQLFederationExecutionPlan load(final ExecutionPlanCacheKey cacheKey) {
- return cacheKey.getSqlStatementCompiler().compile(cacheKey.getSqlStatement());
- }
+ public final OpenGaussRoles[] pg_roles;
+ // CHECKSTYLE:ON
}
diff --git a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussTables.java
similarity index 56%
copy from kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
copy to proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussTables.java
index 8e0fcfd81d1..fb853ff2579 100644
--- a/kernel/sql-federation/core/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/planner/cache/ExecutionPlanCacheLoader.java
+++ b/proxy/backend/type/opengauss/src/main/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/schema/OpenGaussTables.java
@@ -15,21 +15,19 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sqlfederation.compiler.planner.cache;
+package org.apache.shardingsphere.proxy.backend.opengauss.handler.admin.schema;
-import com.github.benmanes.caffeine.cache.CacheLoader;
-import org.apache.shardingsphere.sqlfederation.compiler.SQLFederationExecutionPlan;
-
-import javax.annotation.ParametersAreNonnullByDefault;
+import lombok.RequiredArgsConstructor;
/**
- * Execution plan cache loader.
+ * System table which maintains tables in openGauss system catalog schema.
*/
-public final class ExecutionPlanCacheLoader implements CacheLoader<ExecutionPlanCacheKey, SQLFederationExecutionPlan> {
+@RequiredArgsConstructor
+public final class OpenGaussTables {
+
+ // CHECKSTYLE:OFF
+ public final String schemaname;
- @ParametersAreNonnullByDefault
- @Override
- public SQLFederationExecutionPlan load(final ExecutionPlanCacheKey cacheKey) {
- return cacheKey.getSqlStatementCompiler().compile(cacheKey.getSqlStatement());
- }
+ public final String tablename;
+ // CHECKSTYLE:ON
}
diff --git a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreatorTest.java b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreatorTest.java
index d17123b9e4f..d3dda3fd624 100644
--- a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreatorTest.java
+++ b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorCreatorTest.java
@@ -26,9 +26,9 @@ import org.junit.jupiter.api.Test;
import java.util.Collections;
import java.util.Optional;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
diff --git a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorFactoryTest.java b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorFactoryTest.java
index 2072c883e0c..67946db94ce 100644
--- a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorFactoryTest.java
+++ b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussAdminExecutorFactoryTest.java
@@ -30,9 +30,9 @@ import org.mockito.junit.jupiter.MockitoExtension;
import java.util.Collections;
import java.util.Optional;
+import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.instanceOf;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
import static org.mockito.Mockito.mock;
diff --git a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutorTest.java b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutorTest.java
index 5a78624188f..7959b39c333 100644
--- a/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutorTest.java
+++ b/proxy/backend/type/opengauss/src/test/java/org/apache/shardingsphere/proxy/backend/opengauss/handler/admin/OpenGaussSystemCatalogAdminQueryExecutorTest.java
@@ -17,35 +17,14 @@
package org.apache.shardingsphere.proxy.backend.opengauss.handler.admin;
-import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
-import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
+import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
+import org.apache.shardingsphere.authority.rule.AuthorityRule;
import org.apache.shardingsphere.infra.database.type.dialect.OpenGaussDatabaseType;
import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResultMetaData;
import org.apache.shardingsphere.infra.merge.result.MergedResult;
-import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
-import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.resource.ShardingSphereResourceMetaData;
import org.apache.shardingsphere.infra.metadata.database.rule.ShardingSphereRuleMetaData;
-import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
-import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
-import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
-import org.apache.shardingsphere.sql.parser.api.CacheOption;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.column.ColumnSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.BinaryOperationExpression;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.FunctionSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.expr.simple.LiteralExpressionSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ColumnProjectionSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ExpressionProjectionSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.SimpleTableSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableNameSegment;
-import org.apache.shardingsphere.sql.parser.sql.common.value.identifier.IdentifierValue;
-import org.apache.shardingsphere.sql.parser.sql.dialect.statement.opengauss.dml.OpenGaussSelectStatement;
-import org.apache.shardingsphere.sqlfederation.api.config.SQLFederationRuleConfiguration;
-import org.apache.shardingsphere.sqlfederation.rule.SQLFederationRule;
import org.apache.shardingsphere.test.mock.AutoMockExtension;
import org.apache.shardingsphere.test.mock.StaticMockSettings;
import org.junit.jupiter.api.Test;
@@ -54,11 +33,6 @@ import org.junit.jupiter.api.extension.ExtendWith;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
@@ -76,20 +50,13 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
void assertExecuteSelectFromPgDatabase() throws SQLException {
when(ProxyContext.getInstance()).thenReturn(mock(ProxyContext.class, RETURNS_DEEP_STUBS));
when(ProxyContext.getInstance().getAllDatabaseNames()).thenReturn(Arrays.asList("foo", "bar", "sharding_db", "other_db"));
- ConfigurationProperties properties = new ConfigurationProperties(new Properties());
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(properties);
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getProtocolType()).thenReturn(new OpenGaussDatabaseType());
- Map<String, ShardingSphereDatabase> databases = createShardingSphereDatabaseMap();
- SQLFederationRule sqlFederationRule = new SQLFederationRule(new SQLFederationRuleConfiguration(false, new CacheOption(1, 1)), databases, properties);
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(mock(ShardingSphereRuleMetaData.class));
- OpenGaussSelectStatement sqlStatement = createSelectStatementForPgDatabase();
- ShardingSphereMetaData metaData = new ShardingSphereMetaData(databases, mock(ShardingSphereResourceMetaData.class),
- new ShardingSphereRuleMetaData(Collections.singletonList(sqlFederationRule)), properties);
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SelectStatementContext sqlStatementContext = new SelectStatementContext(metaData, Collections.emptyList(), sqlStatement, "sharding_db");
- OpenGaussSystemCatalogAdminQueryExecutor executor = new OpenGaussSystemCatalogAdminQueryExecutor(sqlStatementContext,
- "select datname, datcompatibility from pg_database where datname = 'sharding_db'", "sharding_db", Collections.emptyList());
+ ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class);
+ when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(shardingSphereRuleMetaData);
+ when(shardingSphereRuleMetaData.getSingleRule(AuthorityRule.class)).thenReturn(mock(AuthorityRule.class));
+ when(shardingSphereRuleMetaData.getSingleRule(AuthorityRule.class).getConfiguration()).thenReturn(mock(AuthorityRuleConfiguration.class));
+ OpenGaussSystemCatalogAdminQueryExecutor executor = new OpenGaussSystemCatalogAdminQueryExecutor("select datname, datcompatibility from pg_database where datname = 'sharding_db'");
executor.execute(connectionSession);
QueryResultMetaData actualMetaData = executor.getQueryResultMetaData();
assertThat(actualMetaData.getColumnCount(), is(2));
@@ -101,58 +68,14 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
assertThat(actualResult.getValue(2, String.class), is("PG"));
}
- private OpenGaussSelectStatement createSelectStatementForPgDatabase() {
- OpenGaussSelectStatement result = new OpenGaussSelectStatement();
- result.setProjections(new ProjectionsSegment(0, 0));
- result.getProjections().getProjections().add(new ColumnProjectionSegment(new ColumnSegment(0, 0, new IdentifierValue("datname"))));
- result.getProjections().getProjections().add(new ColumnProjectionSegment(new ColumnSegment(0, 0, new IdentifierValue("datcompatibility"))));
- result.setFrom(new SimpleTableSegment(new TableNameSegment(0, 0, new IdentifierValue("pg_database"))));
- result.setWhere(new WhereSegment(0, 0,
- new BinaryOperationExpression(0, 0, new ColumnSegment(0, 0, new IdentifierValue("datname")), new LiteralExpressionSegment(0, 0, "sharding_db"), "=", "datname = 'sharding_db'")));
- return result;
- }
-
- private Map<String, ShardingSphereDatabase> createShardingSphereDatabaseMap() {
- Map<String, ShardingSphereDatabase> result = new LinkedHashMap<>(1, 1F);
- Collection<ShardingSphereColumn> columns = Arrays.asList(
- new ShardingSphereColumn("datname", 12, false, false, false, true, false),
- new ShardingSphereColumn("datdba", -5, false, false, false, true, false),
- new ShardingSphereColumn("encoding", 4, false, false, false, true, false),
- new ShardingSphereColumn("datcollate", 12, false, false, false, true, false),
- new ShardingSphereColumn("datctype", 12, false, false, false, true, false),
- new ShardingSphereColumn("datistemplate", -7, false, false, false, true, false),
- new ShardingSphereColumn("datallowconn", -7, false, false, false, true, false),
- new ShardingSphereColumn("datconnlimit", 4, false, false, false, true, false),
- new ShardingSphereColumn("datlastsysoid", -5, false, false, false, true, false),
- new ShardingSphereColumn("datfrozenxid", 1111, false, false, false, true, false),
- new ShardingSphereColumn("dattablespace", -5, false, false, false, true, false),
- new ShardingSphereColumn("datcompatibility", 12, false, false, false, true, false),
- new ShardingSphereColumn("datacl", 2003, false, false, false, true, false),
- new ShardingSphereColumn("datfrozenxid64", 1111, false, false, false, true, false),
- new ShardingSphereColumn("datminmxid", 1111, false, false, false, true, false));
- ShardingSphereSchema schema = new ShardingSphereSchema(
- Collections.singletonMap("pg_database", new ShardingSphereTable("pg_database", columns, Collections.emptyList(), Collections.emptyList())), Collections.emptyMap());
- result.put("sharding_db", new ShardingSphereDatabase("sharding_db", new OpenGaussDatabaseType(), mock(ShardingSphereResourceMetaData.class), mock(ShardingSphereRuleMetaData.class),
- Collections.singletonMap("pg_catalog", schema)));
- return result;
- }
-
@Test
void assertExecuteSelectVersion() throws SQLException {
when(ProxyContext.getInstance()).thenReturn(mock(ProxyContext.class, RETURNS_DEEP_STUBS));
ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(shardingSphereRuleMetaData);
- ConfigurationProperties properties = new ConfigurationProperties(new Properties());
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(properties);
- Map<String, ShardingSphereDatabase> databases = createShardingSphereDatabaseMap();
- SQLFederationRule sqlFederationRule = new SQLFederationRule(new SQLFederationRuleConfiguration(false, new CacheOption(1, 1)), databases, properties);
- OpenGaussSelectStatement sqlStatement = createSelectStatementForVersion();
- ShardingSphereMetaData metaData = new ShardingSphereMetaData(databases, mock(ShardingSphereResourceMetaData.class),
- new ShardingSphereRuleMetaData(Collections.singletonList(sqlFederationRule)), properties);
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SelectStatementContext sqlStatementContext = new SelectStatementContext(metaData, Collections.emptyList(), sqlStatement, "sharding_db");
- OpenGaussSystemCatalogAdminQueryExecutor executor =
- new OpenGaussSystemCatalogAdminQueryExecutor(sqlStatementContext, "select VERSION()", "sharding_db", Collections.emptyList());
+ when(shardingSphereRuleMetaData.getSingleRule(AuthorityRule.class)).thenReturn(mock(AuthorityRule.class));
+ when(shardingSphereRuleMetaData.getSingleRule(AuthorityRule.class).getConfiguration()).thenReturn(mock(AuthorityRuleConfiguration.class));
+ OpenGaussSystemCatalogAdminQueryExecutor executor = new OpenGaussSystemCatalogAdminQueryExecutor("select VERSION()");
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getProtocolType()).thenReturn(new OpenGaussDatabaseType());
executor.execute(connectionSession);
@@ -164,29 +87,14 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
assertThat((String) actualResult.getValue(1, String.class), containsString("ShardingSphere-Proxy"));
}
- private OpenGaussSelectStatement createSelectStatementForVersion() {
- OpenGaussSelectStatement result = new OpenGaussSelectStatement();
- result.setProjections(new ProjectionsSegment(0, 0));
- result.getProjections().getProjections().add(new ExpressionProjectionSegment(0, 0, "VERSION()", new FunctionSegment(0, 0, "VERSION", "VERSION()")));
- return result;
- }
-
@Test
void assertExecuteSelectGsPasswordDeadlineAndIntervalToNum() throws SQLException {
when(ProxyContext.getInstance()).thenReturn(mock(ProxyContext.class, RETURNS_DEEP_STUBS));
ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(shardingSphereRuleMetaData);
- ConfigurationProperties properties = new ConfigurationProperties(new Properties());
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(properties);
- Map<String, ShardingSphereDatabase> databases = createShardingSphereDatabaseMap();
- SQLFederationRule sqlFederationRule = new SQLFederationRule(new SQLFederationRuleConfiguration(false, new CacheOption(1, 1)), databases, properties);
- OpenGaussSelectStatement sqlStatement = createSelectStatementForGsPasswordDeadlineAndIntervalToNum();
- ShardingSphereMetaData metaData = new ShardingSphereMetaData(databases, mock(ShardingSphereResourceMetaData.class),
- new ShardingSphereRuleMetaData(Collections.singletonList(sqlFederationRule)), properties);
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SelectStatementContext sqlStatementContext = new SelectStatementContext(metaData, Collections.emptyList(), sqlStatement, "sharding_db");
- OpenGaussSystemCatalogAdminQueryExecutor executor =
- new OpenGaussSystemCatalogAdminQueryExecutor(sqlStatementContext, "select intervaltonum(gs_password_deadline())", "sharding_db", Collections.emptyList());
+ when(shardingSphereRuleMetaData.getSingleRule(AuthorityRule.class)).thenReturn(mock(AuthorityRule.class));
+ when(shardingSphereRuleMetaData.getSingleRule(AuthorityRule.class).getConfiguration()).thenReturn(mock(AuthorityRuleConfiguration.class));
+ OpenGaussSystemCatalogAdminQueryExecutor executor = new OpenGaussSystemCatalogAdminQueryExecutor("select intervaltonum(gs_password_deadline())");
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getProtocolType()).thenReturn(new OpenGaussDatabaseType());
executor.execute(connectionSession);
@@ -198,31 +106,14 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
assertThat(actualResult.getValue(1, Integer.class), is(90));
}
- private OpenGaussSelectStatement createSelectStatementForGsPasswordDeadlineAndIntervalToNum() {
- OpenGaussSelectStatement result = new OpenGaussSelectStatement();
- result.setProjections(new ProjectionsSegment(0, 0));
- FunctionSegment intervalToNumFunction = new FunctionSegment(0, 0, "intervaltonum", "intervaltonum(gs_password_deadline())");
- intervalToNumFunction.getParameters().add(new FunctionSegment(0, 0, "gs_password_deadline", "gs_password_deadline()"));
- result.getProjections().getProjections().add(new ExpressionProjectionSegment(0, 0, "intervaltonum(gs_password_deadline())", intervalToNumFunction));
- return result;
- }
-
@Test
void assertExecuteSelectGsPasswordNotifyTime() throws SQLException {
when(ProxyContext.getInstance()).thenReturn(mock(ProxyContext.class, RETURNS_DEEP_STUBS));
ShardingSphereRuleMetaData shardingSphereRuleMetaData = mock(ShardingSphereRuleMetaData.class);
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getGlobalRuleMetaData()).thenReturn(shardingSphereRuleMetaData);
- ConfigurationProperties properties = new ConfigurationProperties(new Properties());
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData().getProps()).thenReturn(properties);
- Map<String, ShardingSphereDatabase> databases = createShardingSphereDatabaseMap();
- SQLFederationRule sqlFederationRule = new SQLFederationRule(new SQLFederationRuleConfiguration(false, new CacheOption(1, 1)), databases, properties);
- OpenGaussSelectStatement sqlStatement = createSelectStatementForGsPasswordNotifyTime();
- ShardingSphereMetaData metaData = new ShardingSphereMetaData(databases, mock(ShardingSphereResourceMetaData.class),
- new ShardingSphereRuleMetaData(Collections.singletonList(sqlFederationRule)), properties);
- when(ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData()).thenReturn(metaData);
- SelectStatementContext sqlStatementContext = new SelectStatementContext(metaData, Collections.emptyList(), sqlStatement, "sharding_db");
- OpenGaussSystemCatalogAdminQueryExecutor executor =
- new OpenGaussSystemCatalogAdminQueryExecutor(sqlStatementContext, "select gs_password_notifytime()", "sharding_db", Collections.emptyList());
+ when(shardingSphereRuleMetaData.getSingleRule(AuthorityRule.class)).thenReturn(mock(AuthorityRule.class));
+ when(shardingSphereRuleMetaData.getSingleRule(AuthorityRule.class).getConfiguration()).thenReturn(mock(AuthorityRuleConfiguration.class));
+ OpenGaussSystemCatalogAdminQueryExecutor executor = new OpenGaussSystemCatalogAdminQueryExecutor("select gs_password_notifytime()");
ConnectionSession connectionSession = mock(ConnectionSession.class);
when(connectionSession.getProtocolType()).thenReturn(new OpenGaussDatabaseType());
executor.execute(connectionSession);
@@ -233,12 +124,4 @@ class OpenGaussSystemCatalogAdminQueryExecutorTest {
assertTrue(actualResult.next());
assertThat(actualResult.getValue(1, Integer.class), is(7));
}
-
- private OpenGaussSelectStatement createSelectStatementForGsPasswordNotifyTime() {
- OpenGaussSelectStatement result = new OpenGaussSelectStatement();
- result.setProjections(new ProjectionsSegment(0, 0));
- result.getProjections().getProjections()
- .add(new ExpressionProjectionSegment(0, 0, "gs_password_notifytime()", new FunctionSegment(0, 0, "gs_password_notifytime", "gs_password_notifytime()")));
- return result;
- }
}
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/config/ProxyClusterContainerConfigurationFactory.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/config/ProxyClusterContainerConfigurationFactory.java
index ad59523437e..f326d3a1d8a 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/config/ProxyClusterContainerConfigurationFactory.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/config/ProxyClusterContainerConfigurationFactory.java
@@ -49,13 +49,13 @@ public final class ProxyClusterContainerConfigurationFactory {
Map<String, String> result = new HashMap<>(3, 1F);
result.put("/env/common/cluster/proxy/conf/logback.xml", ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "logback.xml");
result.put("/env/scenario/" + scenario + "/proxy/conf/" + databaseType.getType().toLowerCase(), ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER);
- result.put(serverYamlExists(scenario) ? "/env/scenario/" + scenario + "/proxy/mode/cluster/server.yaml"
+ result.put(serverYamlExists(scenario) ? "/env/scenario/" + scenario + "/cluster/server.yaml"
: "/env/common/cluster/proxy/conf/server.yaml", ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "server.yaml");
return result;
}
private static boolean serverYamlExists(final String scenario) {
- URL url = Thread.currentThread().getContextClassLoader().getResource("env/scenario/" + scenario + "/proxy/mode/cluster/server.yaml");
+ URL url = Thread.currentThread().getContextClassLoader().getResource("env/scenario/" + scenario + "/cluster/server.yaml");
return null != url;
}
}
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/config/ProxyStandaloneContainerConfigurationFactory.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/config/ProxyStandaloneContainerConfigurationFactory.java
index 3d481ae3c9e..452044bba65 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/config/ProxyStandaloneContainerConfigurationFactory.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/container/config/ProxyStandaloneContainerConfigurationFactory.java
@@ -49,13 +49,13 @@ public final class ProxyStandaloneContainerConfigurationFactory {
Map<String, String> result = new HashMap<>(3, 1F);
result.put("/env/common/standalone/proxy/conf/logback.xml", ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "logback.xml");
result.put("/env/scenario/" + scenario + "/proxy/conf/" + databaseType.getType().toLowerCase(), ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER);
- result.put(serverYamlExists(scenario) ? "/env/scenario/" + scenario + "/proxy/mode/standalone/server.yaml"
+ result.put(serverYamlExists(scenario) ? "/env/scenario/" + scenario + "/standalone/server.yaml"
: "/env/common/standalone/proxy/conf/server.yaml", ProxyContainerConstants.CONFIG_PATH_IN_CONTAINER + "server.yaml");
return result;
}
private static boolean serverYamlExists(final String scenario) {
- URL url = Thread.currentThread().getContextClassLoader().getResource("env/scenario/" + scenario + "/proxy/mode/standalone/server.yaml");
+ URL url = Thread.currentThread().getContextClassLoader().getResource("env/scenario/" + scenario + "/standalone/server.yaml");
return null != url;
}
}
diff --git a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dql/GeneralDQLE2EIT.java b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dql/GeneralDQLE2EIT.java
index c032d2c2dc5..73568800aae 100644
--- a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dql/GeneralDQLE2EIT.java
+++ b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dql/GeneralDQLE2EIT.java
@@ -58,6 +58,7 @@ class GeneralDQLE2EIT extends BaseDQLE2EIT {
assertExecuteQueryWithExpectedDataSource(containerComposer);
}
}
+
}
private void assertExecuteQueryWithXmlExpected(final AssertionTestParameter testParam, final SingleE2EContainerComposer containerComposer) throws SQLException {
diff --git a/test/e2e/sql/src/test/resources/env/common/cluster/proxy/conf/server.yaml b/test/e2e/sql/src/test/resources/env/common/cluster/proxy/conf/server.yaml
index ed22f88ac78..ce6d9ef96c9 100644
--- a/test/e2e/sql/src/test/resources/env/common/cluster/proxy/conf/server.yaml
+++ b/test/e2e/sql/src/test/resources/env/common/cluster/proxy/conf/server.yaml
@@ -43,6 +43,12 @@ sqlParser:
initialCapacity: 128
maximumSize: 1024
+sqlFederation:
+ sqlFederationEnabled: true
+ executionPlanCache:
+ initialCapacity: 2000
+ maximumSize: 65535
+
props:
max-connections-size-per-query: 1
kernel-executor-size: 16 # Infinite by default.
diff --git a/test/e2e/sql/src/test/resources/env/common/standalone/proxy/conf/server.yaml b/test/e2e/sql/src/test/resources/env/common/standalone/proxy/conf/server.yaml
index b5480bf36ed..3b97188335c 100644
--- a/test/e2e/sql/src/test/resources/env/common/standalone/proxy/conf/server.yaml
+++ b/test/e2e/sql/src/test/resources/env/common/standalone/proxy/conf/server.yaml
@@ -43,6 +43,12 @@ sqlParser:
initialCapacity: 128
maximumSize: 1024
+sqlFederation:
+ sqlFederationEnabled: true
+ executionPlanCache:
+ initialCapacity: 2000
+ maximumSize: 65535
+
props:
max-connections-size-per-query: 1
kernel-executor-size: 16 # Infinite by default.
diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/mode/cluster/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/mode/cluster/server.yaml
deleted file mode 100644
index 9a5fd67d4cf..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/mode/cluster/server.yaml
+++ /dev/null
@@ -1,57 +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.
-#
-
-mode:
- type: Cluster
- repository:
- type: ZooKeeper
- props:
- namespace: it_db
- server-lists: zk.host:2181
- timeToLiveSeconds: 60
- operationTimeoutMilliseconds: 500
- retryIntervalMilliseconds: 500
- maxRetries: 3
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/mode/standalone/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/db/proxy/mode/standalone/server.yaml
deleted file mode 100644
index 703d0cb49f2..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/db/proxy/mode/standalone/server.yaml
+++ /dev/null
@@ -1,45 +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.
-#
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/mode/cluster/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/mode/cluster/server.yaml
deleted file mode 100644
index 9a5fd67d4cf..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/mode/cluster/server.yaml
+++ /dev/null
@@ -1,57 +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.
-#
-
-mode:
- type: Cluster
- repository:
- type: ZooKeeper
- props:
- namespace: it_db
- server-lists: zk.host:2181
- timeToLiveSeconds: 60
- operationTimeoutMilliseconds: 500
- retryIntervalMilliseconds: 500
- maxRetries: 3
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/mode/standalone/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/mode/standalone/server.yaml
deleted file mode 100644
index 703d0cb49f2..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting/proxy/mode/standalone/server.yaml
+++ /dev/null
@@ -1,45 +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.
-#
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/mode/cluster/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/mode/cluster/server.yaml
deleted file mode 100644
index 9a5fd67d4cf..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/mode/cluster/server.yaml
+++ /dev/null
@@ -1,57 +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.
-#
-
-mode:
- type: Cluster
- repository:
- type: ZooKeeper
- props:
- namespace: it_db
- server-lists: zk.host:2181
- timeToLiveSeconds: 60
- operationTimeoutMilliseconds: 500
- retryIntervalMilliseconds: 500
- maxRetries: 3
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/mode/standalone/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/mode/standalone/server.yaml
deleted file mode 100644
index 703d0cb49f2..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/dbtbl_with_readwrite_splitting_and_encrypt/proxy/mode/standalone/server.yaml
+++ /dev/null
@@ -1,45 +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.
-#
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/empty_rules/proxy/mode/cluster/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/empty_rules/proxy/mode/cluster/server.yaml
deleted file mode 100644
index 9a5fd67d4cf..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/empty_rules/proxy/mode/cluster/server.yaml
+++ /dev/null
@@ -1,57 +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.
-#
-
-mode:
- type: Cluster
- repository:
- type: ZooKeeper
- props:
- namespace: it_db
- server-lists: zk.host:2181
- timeToLiveSeconds: 60
- operationTimeoutMilliseconds: 500
- retryIntervalMilliseconds: 500
- maxRetries: 3
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/empty_rules/proxy/mode/standalone/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/empty_rules/proxy/mode/standalone/server.yaml
deleted file mode 100644
index 703d0cb49f2..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/empty_rules/proxy/mode/standalone/server.yaml
+++ /dev/null
@@ -1,45 +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.
-#
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/encrypt_and_readwrite_splitting/rules.yaml b/test/e2e/sql/src/test/resources/env/scenario/encrypt_and_readwrite_splitting/rules.yaml
index cb3cd085e7f..849fbc66e04 100644
--- a/test/e2e/sql/src/test/resources/env/scenario/encrypt_and_readwrite_splitting/rules.yaml
+++ b/test/e2e/sql/src/test/resources/env/scenario/encrypt_and_readwrite_splitting/rules.yaml
@@ -75,6 +75,12 @@ rules:
cipher:
name: telephone_cipher
encryptorName: aes_encryptor
+
+sqlFederation:
+ sqlFederationEnabled: true
+ executionPlanCache:
+ initialCapacity: 2000
+ maximumSize: 65535
props:
sql-show: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/mode/cluster/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/cluster/server.yaml
similarity index 100%
rename from test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/mode/cluster/server.yaml
rename to test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/cluster/server.yaml
diff --git a/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/mode/standalone/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/standalone/server.yaml
similarity index 100%
rename from test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/proxy/mode/standalone/server.yaml
rename to test/e2e/sql/src/test/resources/env/scenario/sharding_and_encrypt/standalone/server.yaml
diff --git a/test/e2e/sql/src/test/resources/env/scenario/tbl/proxy/mode/cluster/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/tbl/proxy/mode/cluster/server.yaml
deleted file mode 100644
index 9a5fd67d4cf..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/tbl/proxy/mode/cluster/server.yaml
+++ /dev/null
@@ -1,57 +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.
-#
-
-mode:
- type: Cluster
- repository:
- type: ZooKeeper
- props:
- namespace: it_db
- server-lists: zk.host:2181
- timeToLiveSeconds: 60
- operationTimeoutMilliseconds: 500
- retryIntervalMilliseconds: 500
- maxRetries: 3
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true
diff --git a/test/e2e/sql/src/test/resources/env/scenario/tbl/proxy/mode/standalone/server.yaml b/test/e2e/sql/src/test/resources/env/scenario/tbl/proxy/mode/standalone/server.yaml
deleted file mode 100644
index 703d0cb49f2..00000000000
--- a/test/e2e/sql/src/test/resources/env/scenario/tbl/proxy/mode/standalone/server.yaml
+++ /dev/null
@@ -1,45 +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.
-#
-
-authority:
- users:
- - user: proxy
- password: Proxy@123
- privilege:
- type: ALL_PERMITTED
-
-sqlParser:
- sqlCommentParseEnabled: true
- sqlStatementCache:
- initialCapacity: 2000
- maximumSize: 65535
- parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
-
-sqlFederation:
- sqlFederationEnabled: true
- executionPlanCache:
- initialCapacity: 2000
- maximumSize: 65535
-
-props:
- max-connections-size-per-query: 1
- kernel-executor-size: 16 # Infinite by default.
- proxy-frontend-flush-threshold: 128 # The default value is 128.
- sql-show: false
- proxy-frontend-ssl-enabled: true