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 3aed2cd6ec8 Remove unreach codes on AgentTransformer (#37706)
3aed2cd6ec8 is described below

commit 3aed2cd6ec8bfdde445a0b59a638cba8fc740c87
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Jan 10 22:59:13 2026 +0800

    Remove unreach codes on AgentTransformer (#37706)
    
    * Remove unreach codes on AgentTransformer
    
    * Remove unreach codes on AgentTransformer
---
 .../agent/core/builder/AgentTransformer.java       |   3 -
 .../plugin/PluginLifecycleServiceManagerTest.java  |   7 +-
 .../src/main/resources/case/dml/insert-hive.xml    |  30 +++
 .../src/main/resources/case/dml/select-hive.xml    | 249 +++++++++++++++++++++
 .../resources/sql/supported/dml/insert-hive.xml    |   1 +
 .../resources/sql/supported/dml/select-hive.xml    |  14 ++
 6 files changed, 297 insertions(+), 7 deletions(-)

diff --git 
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/AgentTransformer.java
 
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/AgentTransformer.java
index dc2a36d314c..1b1fec8d9cd 100644
--- 
a/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/AgentTransformer.java
+++ 
b/agent/core/src/main/java/org/apache/shardingsphere/agent/core/builder/AgentTransformer.java
@@ -63,9 +63,6 @@ public final class AgentTransformer implements Transformer {
     @SuppressWarnings("NullableProblems")
     @Override
     public Builder<?> transform(final Builder<?> builder, final 
TypeDescription typeDescription, final ClassLoader classLoader, final 
JavaModule module, final ProtectionDomain protectionDomain) {
-        if (!advisorConfigs.containsKey(typeDescription.getTypeName())) {
-            return builder;
-        }
         ClassLoaderContext classLoaderContext = new 
ClassLoaderContext(classLoader, pluginJars);
         PluginLifecycleServiceManager.init(pluginConfigs, pluginJars, 
classLoaderContext.getPluginClassLoader(), isEnhancedForProxy);
         return AgentBuilderInterceptChainEngine.intercept(builder, new 
TargetAdviceObjectBuilderInterceptor(),
diff --git 
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/PluginLifecycleServiceManagerTest.java
 
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/PluginLifecycleServiceManagerTest.java
index 6e6ad76afd9..e02d115ba7d 100644
--- 
a/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/PluginLifecycleServiceManagerTest.java
+++ 
b/agent/core/src/test/java/org/apache/shardingsphere/agent/core/plugin/PluginLifecycleServiceManagerTest.java
@@ -51,10 +51,9 @@ class PluginLifecycleServiceManagerTest {
     @Test
     void assertInitPluginLifecycleServiceWithMockHandler() throws 
MalformedURLException {
         URLStreamHandlerFactory urlStreamHandlerFactory = 
mock(URLStreamHandlerFactory.class);
-        PluginLifecycleServiceManager.init(Collections.emptyMap(), 
Collections.emptyList(),
-                new URLClassLoader(new 
URL[]{Paths.get(System.getProperty("java.io.tmpdir"), 
"test.txt").toUri().toURL()},
-                        new 
MultipleParentClassLoader(Collections.emptyList()), urlStreamHandlerFactory),
-                true);
+        URLClassLoader urlClassLoader = new URLClassLoader(new 
URL[]{Paths.get(System.getProperty("java.io.tmpdir"), 
"test.txt").toUri().toURL()},
+                new MultipleParentClassLoader(Collections.emptyList()), 
urlStreamHandlerFactory);
+        PluginLifecycleServiceManager.init(Collections.emptyMap(), 
Collections.emptyList(), urlClassLoader, true);
         verify(urlStreamHandlerFactory).createURLStreamHandler(anyString());
     }
 }
diff --git a/test/it/parser/src/main/resources/case/dml/insert-hive.xml 
b/test/it/parser/src/main/resources/case/dml/insert-hive.xml
index cb00228cdab..34394ce6a3b 100644
--- a/test/it/parser/src/main/resources/case/dml/insert-hive.xml
+++ b/test/it/parser/src/main/resources/case/dml/insert-hive.xml
@@ -121,4 +121,34 @@
         </select>
     </insert>
 
+    <insert sql-case-id="hive_from_multi_insert">
+        <multi-table-insert-type value="ALL" />
+        <multi-table-insert-into start-index="9" stop-index="77" 
literal-start-index="9" literal-stop-index="77">
+            <insert-statement>
+                <table name="dst1" start-index="27" stop-index="30" />
+                <columns start-index="9" stop-index="9" />
+                <select>
+                    <projections start-index="39" stop-index="42">
+                        <column-projection name="col1" start-index="39" 
stop-index="42" />
+                    </projections>
+                    <from>
+                        <simple-table name="src" start-index="5" 
stop-index="7" />
+                    </from>
+                </select>
+            </insert-statement>
+            <insert-statement>
+                <table name="dst2" start-index="62" stop-index="65" />
+                <columns start-index="44" stop-index="44" />
+                <select>
+                    <projections start-index="74" stop-index="77">
+                        <column-projection name="col2" start-index="74" 
stop-index="77" />
+                    </projections>
+                    <from>
+                        <simple-table name="src" start-index="5" 
stop-index="7" />
+                    </from>
+                </select>
+            </insert-statement>
+        </multi-table-insert-into>
+    </insert>
+
 </sql-parser-test-cases>
diff --git a/test/it/parser/src/main/resources/case/dml/select-hive.xml 
b/test/it/parser/src/main/resources/case/dml/select-hive.xml
index b080d6c6b4a..237c9dcaf67 100644
--- a/test/it/parser/src/main/resources/case/dml/select-hive.xml
+++ b/test/it/parser/src/main/resources/case/dml/select-hive.xml
@@ -859,4 +859,253 @@
         </limit>
     </select>
 
+    <select sql-case-id="hive_select_not">
+        <projections start-index="7" stop-index="7">
+            <shorthand-projection start-index="7" stop-index="7" />
+        </projections>
+        <from>
+            <simple-table name="t_pred" start-index="14" stop-index="19" />
+        </from>
+        <where start-index="21" stop-index="36">
+            <expr>
+                <not-expression start-index="27" stop-index="36">
+                    <expr>
+                        <column name="status" start-index="31" stop-index="36" 
/>
+                    </expr>
+                </not-expression>
+            </expr>
+        </where>
+    </select>
+
+    <select sql-case-id="hive_select_is_null">
+        <projections start-index="7" stop-index="7">
+            <shorthand-projection start-index="7" stop-index="7" />
+        </projections>
+        <from>
+            <simple-table name="t_pred" start-index="14" stop-index="19" />
+        </from>
+        <where start-index="21" stop-index="40">
+            <expr>
+                <binary-operation-expression start-index="27" stop-index="40">
+                    <left>
+                        <column name="status" start-index="27" stop-index="32" 
/>
+                    </left>
+                    <operator>IS</operator>
+                    <right>
+                        <literal-expression value="NULL" start-index="37" 
stop-index="40" />
+                    </right>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
+
+    <select sql-case-id="hive_select_between">
+        <projections start-index="7" stop-index="7">
+            <shorthand-projection start-index="7" stop-index="7" />
+        </projections>
+        <from>
+            <simple-table name="t_pred" start-index="14" stop-index="19" />
+        </from>
+        <where start-index="21" stop-index="47">
+            <expr>
+                <between-expression start-index="27" stop-index="47">
+                    <left>
+                        <column name="age" start-index="27" stop-index="29" />
+                    </left>
+                    <between-expr>
+                        <literal-expression value="10" start-index="39" 
stop-index="40" />
+                    </between-expr>
+                    <and-expr>
+                        <literal-expression value="20" start-index="46" 
stop-index="47" />
+                    </and-expr>
+                </between-expression>
+            </expr>
+        </where>
+    </select>
+
+    <select sql-case-id="hive_select_regexp">
+        <projections start-index="7" stop-index="7">
+            <shorthand-projection start-index="7" stop-index="7" />
+        </projections>
+        <from>
+            <simple-table name="t_pred" start-index="14" stop-index="19" />
+        </from>
+        <where start-index="21" stop-index="41">
+            <expr>
+                <binary-operation-expression start-index="27" stop-index="41">
+                    <left>
+                        <column name="name" start-index="27" stop-index="30" />
+                    </left>
+                    <operator>REGEXP</operator>
+                    <right>
+                        <literal-expression value="a" start-index="39" 
stop-index="41" />
+                    </right>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
+
+    <select sql-case-id="hive_select_rlike">
+        <projections start-index="7" stop-index="7">
+            <shorthand-projection start-index="7" stop-index="7" />
+        </projections>
+        <from>
+            <simple-table name="t_pred" start-index="14" stop-index="19" />
+        </from>
+        <where start-index="21" stop-index="40">
+            <expr>
+                <binary-operation-expression start-index="27" stop-index="40">
+                    <left>
+                        <column name="name" start-index="27" stop-index="30" />
+                    </left>
+                    <operator>RLIKE</operator>
+                    <right>
+                        <literal-expression value="a" start-index="38" 
stop-index="40" />
+                    </right>
+                </binary-operation-expression>
+            </expr>
+        </where>
+    </select>
+
+    <select sql-case-id="hive_select_or_expr">
+        <projections start-index="7" stop-index="12">
+            <expression-projection text="1 OR 0" start-index="7" 
stop-index="12">
+                <expr>
+                    <binary-operation-expression start-index="7" 
stop-index="12">
+                        <left>
+                            <literal-expression value="1" start-index="7" 
stop-index="7" />
+                        </left>
+                        <operator>OR</operator>
+                        <right>
+                            <literal-expression value="0" start-index="12" 
stop-index="12" />
+                        </right>
+                    </binary-operation-expression>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="hive_select_count_distinct">
+        <projections start-index="7" stop-index="29">
+            <aggregation-distinct-projection type="COUNT" 
expression="(DISTINCT user_id)" distinct-inner-expression="user_id" 
start-index="7" stop-index="29" />
+        </projections>
+        <from>
+            <simple-table name="t_order" start-index="36" stop-index="42" />
+        </from>
+    </select>
+
+    <select sql-case-id="hive_select_window_frame">
+        <projections start-index="7" stop-index="98">
+            <aggregation-projection type="SUM" expression="(amount) OVER 
(PARTITION BY user_id ORDER BY id ROWS BETWEEN 1 PRECEDING AND CURRENT ROW)" 
start-index="7" stop-index="98">
+                <parameter>
+                    <column name="amount" start-index="11" stop-index="16" />
+                </parameter>
+            </aggregation-projection>
+        </projections>
+        <from>
+            <simple-table name="t_order" start-index="105" stop-index="111" />
+        </from>
+    </select>
+
+    <select sql-case-id="hive_select_position_function">
+        <projections start-index="7" stop-index="28">
+            <expression-projection text="POSITION('b' IN 'abc')" 
start-index="7" stop-index="28">
+                <expr>
+                    <function function-name="POSITION" start-index="7" 
stop-index="28" text="POSITION('b' IN 'abc')">
+                        <parameter>
+                            <literal-expression value="b" start-index="16" 
stop-index="18" />
+                        </parameter>
+                        <parameter>
+                            <literal-expression value="abc" start-index="23" 
stop-index="27" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="hive_select_char_function">
+        <projections start-index="7" stop-index="14">
+            <expression-projection text="CHAR(97)" start-index="7" 
stop-index="14">
+                <expr>
+                    <function function-name="CHAR" start-index="7" 
stop-index="14" text="CHAR(97)">
+                        <parameter>
+                            <literal-expression value="97" start-index="12" 
stop-index="13" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="hive_select_weight_string">
+        <projections start-index="7" stop-index="24">
+            <expression-projection text="WEIGHT_STRING('a')" start-index="7" 
stop-index="24">
+                <expr>
+                    <function function-name="WEIGHT_STRING" start-index="7" 
stop-index="24" text="WEIGHT_STRING('a')">
+                        <parameter>
+                            <literal-expression value="a" start-index="21" 
stop-index="23" />
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="hive_select_current_user">
+        <projections start-index="7" stop-index="18">
+            <expression-projection text="CURRENT_USER" start-index="7" 
stop-index="18">
+                <expr>
+                    <function function-name="CURRENT_USER" start-index="7" 
stop-index="18" text="CURRENT_USER" />
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="hive_select_cast_datetime_precision">
+        <projections start-index="7" stop-index="39">
+            <expression-projection text="CAST('2024-01-01' AS DATETIME(3))" 
start-index="7" stop-index="39">
+                <expr>
+                    <function function-name="CAST" text="CAST('2024-01-01' AS 
DATETIME(3))" start-index="7" stop-index="39">
+                        <parameter>
+                            <literal-expression value="2024-01-01" 
start-index="12" stop-index="23" />
+                        </parameter>
+                        <parameter>
+                            <data-type value="DATETIME" start-index="28" 
stop-index="38">
+                                <data-type-length precision="3" 
start-index="37" stop-index="37" />
+                            </data-type>
+                        </parameter>
+                    </function>
+                </expr>
+            </expression-projection>
+        </projections>
+    </select>
+
+    <select sql-case-id="hive_select_except">
+        <projections start-index="7" stop-index="7">
+            <shorthand-projection start-index="7" stop-index="7" />
+        </projections>
+        <from>
+            <simple-table name="t1" start-index="14" stop-index="15" />
+        </from>
+        <combine combine-type="EXCEPT" start-index="17" stop-index="39">
+            <left>
+                <projections start-index="7" stop-index="7">
+                    <shorthand-projection start-index="7" stop-index="7" />
+                </projections>
+                <from>
+                    <simple-table name="t1" start-index="14" stop-index="15" />
+                </from>
+            </left>
+            <right>
+                <projections start-index="31" stop-index="31">
+                    <shorthand-projection start-index="31" stop-index="31" />
+                </projections>
+                <from>
+                    <simple-table name="t2" start-index="38" stop-index="39" />
+                </from>
+            </right>
+        </combine>
+    </select>
+
 </sql-parser-test-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/dml/insert-hive.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/insert-hive.xml
index be01464cb39..63cad7aa228 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/insert-hive.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/insert-hive.xml
@@ -24,4 +24,5 @@
     <sql-case id="hive_from_insert" value="FROM t_source INSERT OVERWRITE 
TABLE t_target SELECT *" db-types="Hive" />
     <sql-case id="hive_insert_select_columns" value="INSERT INTO t_target (id, 
name) SELECT id, name FROM t_source" db-types="Hive" />
     <sql-case id="hive_insert_dynamic_partition_select" value="INSERT INTO 
TABLE t_order PARTITION (ds) SELECT * FROM t_source" db-types="Hive" />
+    <sql-case id="hive_from_multi_insert" value="FROM src INSERT INTO TABLE 
dst1 SELECT col1 INSERT INTO TABLE dst2 SELECT col2" db-types="Hive" />
 </sql-cases>
diff --git 
a/test/it/parser/src/main/resources/sql/supported/dml/select-hive.xml 
b/test/it/parser/src/main/resources/sql/supported/dml/select-hive.xml
index cff26fe3947..86bedeef66e 100644
--- a/test/it/parser/src/main/resources/sql/supported/dml/select-hive.xml
+++ b/test/it/parser/src/main/resources/sql/supported/dml/select-hive.xml
@@ -61,4 +61,18 @@
     <sql-case id="hive_json_array_simple" value="SELECT JSON_ARRAY(1, 'abc', 
NULL, TRUE, CURTIME())" db-types="Hive" />
     <sql-case id="hive_convert_date" value="SELECT CONVERT('2020-10-01', 
DATE)" db-types="Hive" />
     <sql-case id="hive_limit_param" value="SELECT * FROM t_order LIMIT ? 
OFFSET ?" db-types="Hive" />
+    <sql-case id="hive_select_not" value="SELECT * FROM t_pred WHERE NOT 
status" db-types="Hive" />
+    <sql-case id="hive_select_is_null" value="SELECT * FROM t_pred WHERE 
status IS NULL" db-types="Hive" />
+    <sql-case id="hive_select_between" value="SELECT * FROM t_pred WHERE age 
BETWEEN 10 AND 20" db-types="Hive" />
+    <sql-case id="hive_select_regexp" value="SELECT * FROM t_pred WHERE name 
REGEXP 'a'" db-types="Hive" />
+    <sql-case id="hive_select_rlike" value="SELECT * FROM t_pred WHERE name 
RLIKE 'a'" db-types="Hive" />
+    <sql-case id="hive_select_or_expr" value="SELECT 1 OR 0" db-types="Hive" />
+    <sql-case id="hive_select_count_distinct" value="SELECT COUNT(DISTINCT 
user_id) FROM t_order" db-types="Hive" />
+    <sql-case id="hive_select_window_frame" value="SELECT SUM(amount) OVER 
(PARTITION BY user_id ORDER BY id ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) 
FROM t_order" db-types="Hive" />
+    <sql-case id="hive_select_position_function" value="SELECT POSITION('b' IN 
'abc')" db-types="Hive" />
+    <sql-case id="hive_select_char_function" value="SELECT CHAR(97)" 
db-types="Hive" />
+    <sql-case id="hive_select_weight_string" value="SELECT WEIGHT_STRING('a')" 
db-types="Hive" />
+    <sql-case id="hive_select_current_user" value="SELECT CURRENT_USER" 
db-types="Hive" />
+    <sql-case id="hive_select_cast_datetime_precision" value="SELECT 
CAST('2024-01-01' AS DATETIME(3))" db-types="Hive" />
+    <sql-case id="hive_select_except" value="SELECT * FROM t1 EXCEPT SELECT * 
FROM t2" db-types="Hive" />
 </sql-cases>

Reply via email to