This is an automated email from the ASF dual-hosted git repository.

zhangliang 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 d46a3fddc43 Add authority-simple and authority-database profiles 
(#36312)
d46a3fddc43 is described below

commit d46a3fddc43ad279a51718238b642225063cc0ab
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Fri Aug 15 18:20:34 2025 +0800

    Add authority-simple and authority-database profiles (#36312)
---
 distribution/jdbc/pom.xml                          | 58 +++++++++++++++++-----
 distribution/proxy-native/pom.xml                  | 58 +++++++++++++++++-----
 distribution/proxy/pom.xml                         | 58 +++++++++++++++++-----
 .../sqltranslator/rule/SQLTranslatorRuleTest.java  | 22 ++++----
 4 files changed, 148 insertions(+), 48 deletions(-)

diff --git a/distribution/jdbc/pom.xml b/distribution/jdbc/pom.xml
index 369ea732b13..ae95e31b402 100644
--- a/distribution/jdbc/pom.xml
+++ b/distribution/jdbc/pom.xml
@@ -52,18 +52,6 @@
             <version>${project.version}</version>
             <scope>runtime</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-authority-simple</artifactId>
-            <version>${project.version}</version>
-            <scope>runtime</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-authority-database</artifactId>
-            <version>${project.version}</version>
-            <scope>runtime</scope>
-        </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             
<artifactId>shardingsphere-sql-translator-native-provider</artifactId>
@@ -160,6 +148,18 @@
                     <version>${project.version}</version>
                     <scope>runtime</scope>
                 </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
                 <dependency>
                     <groupId>org.apache.shardingsphere</groupId>
                     
<artifactId>shardingsphere-transaction-xa-atomikos</artifactId>
@@ -306,6 +306,18 @@
                     <version>${project.version}</version>
                     <scope>runtime</scope>
                 </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
                 <dependency>
                     <groupId>org.apache.shardingsphere</groupId>
                     
<artifactId>shardingsphere-transaction-xa-atomikos</artifactId>
@@ -531,6 +543,28 @@
             </dependencies>
         </profile>
         
+        <profile>
+            <id>authority-simple</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>authority-database</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+            </dependencies>
+        </profile>
         <profile>
             <id>transaction-atomikos</id>
             <dependencies>
diff --git a/distribution/proxy-native/pom.xml 
b/distribution/proxy-native/pom.xml
index b1be8cc77fb..395cade3d78 100644
--- a/distribution/proxy-native/pom.xml
+++ b/distribution/proxy-native/pom.xml
@@ -48,18 +48,6 @@
             <version>${project.version}</version>
             <scope>runtime</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-authority-simple</artifactId>
-            <version>${project.version}</version>
-            <scope>runtime</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-authority-database</artifactId>
-            <version>${project.version}</version>
-            <scope>runtime</scope>
-        </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             
<artifactId>shardingsphere-sql-translator-native-provider</artifactId>
@@ -257,6 +245,18 @@
                     <version>${project.version}</version>
                     <scope>runtime</scope>
                 </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
                 <dependency>
                     <groupId>org.apache.shardingsphere</groupId>
                     
<artifactId>shardingsphere-transaction-xa-atomikos</artifactId>
@@ -425,6 +425,18 @@
                     <version>${project.version}</version>
                     <scope>runtime</scope>
                 </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
                 <dependency>
                     <groupId>org.apache.shardingsphere</groupId>
                     
<artifactId>shardingsphere-transaction-xa-atomikos</artifactId>
@@ -734,6 +746,28 @@
             </dependencies>
         </profile>
         
+        <profile>
+            <id>authority-simple</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>authority-database</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+            </dependencies>
+        </profile>
         <profile>
             <id>transaction-atomikos</id>
             <dependencies>
diff --git a/distribution/proxy/pom.xml b/distribution/proxy/pom.xml
index dca88330189..e5957239c25 100644
--- a/distribution/proxy/pom.xml
+++ b/distribution/proxy/pom.xml
@@ -40,18 +40,6 @@
             <version>${project.version}</version>
             <scope>runtime</scope>
         </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-authority-simple</artifactId>
-            <version>${project.version}</version>
-            <scope>runtime</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.shardingsphere</groupId>
-            <artifactId>shardingsphere-authority-database</artifactId>
-            <version>${project.version}</version>
-            <scope>runtime</scope>
-        </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             
<artifactId>shardingsphere-sql-translator-native-provider</artifactId>
@@ -292,6 +280,18 @@
                     <version>${project.version}</version>
                     <scope>runtime</scope>
                 </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
                 <dependency>
                     <groupId>org.apache.shardingsphere</groupId>
                     
<artifactId>shardingsphere-transaction-xa-atomikos</artifactId>
@@ -460,6 +460,18 @@
                     <version>${project.version}</version>
                     <scope>runtime</scope>
                 </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
                 <dependency>
                     <groupId>org.apache.shardingsphere</groupId>
                     
<artifactId>shardingsphere-transaction-xa-atomikos</artifactId>
@@ -769,6 +781,28 @@
             </dependencies>
         </profile>
         
+        <profile>
+            <id>authority-simple</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-simple</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>authority-database</id>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.shardingsphere</groupId>
+                    <artifactId>shardingsphere-authority-database</artifactId>
+                    <version>${project.version}</version>
+                    <scope>runtime</scope>
+                </dependency>
+            </dependencies>
+        </profile>
         <profile>
             <id>transaction-atomikos</id>
             <dependencies>
diff --git 
a/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/rule/SQLTranslatorRuleTest.java
 
b/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/rule/SQLTranslatorRuleTest.java
index df95b42b472..41fb18da7d2 100644
--- 
a/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/rule/SQLTranslatorRuleTest.java
+++ 
b/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/rule/SQLTranslatorRuleTest.java
@@ -18,8 +18,6 @@
 package org.apache.shardingsphere.sqltranslator.rule;
 
 import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
-import 
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
-import org.apache.shardingsphere.infra.metadata.database.rule.RuleMetaData;
 import org.apache.shardingsphere.infra.session.query.QueryContext;
 import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
 import 
org.apache.shardingsphere.sqltranslator.config.SQLTranslatorRuleConfiguration;
@@ -49,8 +47,7 @@ class SQLTranslatorRuleTest {
         DatabaseType databaseType = 
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");
         QueryContext queryContext = mock(QueryContext.class, 
RETURNS_DEEP_STUBS);
         
when(queryContext.getSqlStatementContext().getSqlStatement().getDatabaseType()).thenReturn(databaseType);
-        Optional<SQLTranslatorContext> actual = new SQLTranslatorRule(new 
SQLTranslatorRuleConfiguration("FIXTURE", new Properties(), 
false)).translate(expected, Collections.emptyList(),
-                queryContext, databaseType, 
mock(ShardingSphereDatabase.class), mock(RuleMetaData.class));
+        Optional<SQLTranslatorContext> actual = 
createSQLTranslatorRule(false).translate(expected, Collections.emptyList(), 
queryContext, databaseType, mock(), mock());
         assertFalse(actual.isPresent());
     }
     
@@ -60,8 +57,7 @@ class SQLTranslatorRuleTest {
         DatabaseType sqlParserType = 
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");
         QueryContext queryContext = mock(QueryContext.class, 
RETURNS_DEEP_STUBS);
         
when(queryContext.getSqlStatementContext().getSqlStatement().getDatabaseType()).thenReturn(sqlParserType);
-        Optional<SQLTranslatorContext> actual = new SQLTranslatorRule(new 
SQLTranslatorRuleConfiguration("CORE:FIXTURE", new Properties(), 
false)).translate(expected, Collections.emptyList(),
-                queryContext, null, mock(ShardingSphereDatabase.class), 
mock(RuleMetaData.class));
+        Optional<SQLTranslatorContext> actual = 
createSQLTranslatorRule(false).translate(expected, Collections.emptyList(), 
queryContext, null, mock(), mock());
         assertFalse(actual.isPresent());
     }
     
@@ -72,8 +68,7 @@ class SQLTranslatorRuleTest {
         QueryContext queryContext = mock(QueryContext.class, 
RETURNS_DEEP_STUBS);
         
when(queryContext.getSqlStatementContext().getSqlStatement().getDatabaseType()).thenReturn(sqlParserType);
         DatabaseType storageType = 
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");
-        Optional<SQLTranslatorContext> actual = new SQLTranslatorRule(new 
SQLTranslatorRuleConfiguration("CORE:FIXTURE", new Properties(), 
false)).translate(input, Collections.emptyList(),
-                queryContext, storageType, mock(ShardingSphereDatabase.class), 
mock(RuleMetaData.class));
+        Optional<SQLTranslatorContext> actual = 
createSQLTranslatorRule(false).translate(input, Collections.emptyList(), 
queryContext, storageType, mock(), mock());
         assertTrue(actual.isPresent());
         assertThat(actual.get().getSql(), is(input.toUpperCase(Locale.ROOT)));
     }
@@ -85,8 +80,7 @@ class SQLTranslatorRuleTest {
         QueryContext queryContext = mock(QueryContext.class, 
RETURNS_DEEP_STUBS);
         
when(queryContext.getSqlStatementContext().getSqlStatement().getDatabaseType()).thenReturn(sqlParserType);
         DatabaseType storageType = 
TypedSPILoader.getService(DatabaseType.class, "MySQL");
-        Optional<SQLTranslatorContext> actual = new SQLTranslatorRule(new 
SQLTranslatorRuleConfiguration("CORE:FIXTURE", new Properties(), 
true)).translate(
-                expected, Collections.emptyList(), queryContext, storageType, 
mock(ShardingSphereDatabase.class), mock(RuleMetaData.class));
+        Optional<SQLTranslatorContext> actual = 
createSQLTranslatorRule(true).translate(expected, Collections.emptyList(), 
queryContext, storageType, mock(), mock());
         assertFalse(actual.isPresent());
     }
     
@@ -96,8 +90,8 @@ class SQLTranslatorRuleTest {
         DatabaseType sqlParserType = 
TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");
         
when(queryContext.getSqlStatementContext().getSqlStatement().getDatabaseType()).thenReturn(sqlParserType);
         DatabaseType storageType = 
TypedSPILoader.getService(DatabaseType.class, "MySQL");
-        assertThrows(UnsupportedTranslatedDatabaseException.class, () -> new 
SQLTranslatorRule(new SQLTranslatorRuleConfiguration("CORE:FIXTURE", new 
Properties(), false)).translate(
-                "ERROR: select 1", Collections.emptyList(), queryContext, 
storageType, mock(ShardingSphereDatabase.class), mock(RuleMetaData.class)));
+        assertThrows(UnsupportedTranslatedDatabaseException.class,
+                () -> createSQLTranslatorRule(false).translate("ERROR: select 
1", Collections.emptyList(), queryContext, storageType, mock(), mock()));
     }
     
     @Test
@@ -105,4 +99,8 @@ class SQLTranslatorRuleTest {
         SQLTranslatorRuleConfiguration expected = new 
SQLTranslatorRuleConfiguration("CORE:FIXTURE", new Properties(), false);
         assertThat(new SQLTranslatorRule(expected).getConfiguration(), 
is(expected));
     }
+    
+    private SQLTranslatorRule createSQLTranslatorRule(final boolean 
useOriginalSQLWhenTranslatingFailed) {
+        return new SQLTranslatorRule(new 
SQLTranslatorRuleConfiguration("CORE:FIXTURE", new Properties(), 
useOriginalSQLWhenTranslatingFailed));
+    }
 }

Reply via email to