From 0f6e2efe1194f9c6e089ca58852821fbaea4d239 Mon Sep 17 00:00:00 2001 From: Liang Zhang Date: Tue, 5 Nov 2024 23:48:22 +0800 Subject: [PATCH] Refactor ShadowDMLStatementDataSourceMappingsRetriever (#33556) --- .../dml/ShadowDMLStatementDataSourceMappingsRetriever.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDMLStatementDataSourceMappingsRetriever.java b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDMLStatementDataSourceMappingsRetriever.java index 2971b1e35c164..b42cefe88151d 100644 --- a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDMLStatementDataSourceMappingsRetriever.java +++ b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/route/retriever/dml/ShadowDMLStatementDataSourceMappingsRetriever.java @@ -80,13 +80,13 @@ private ShadowColumnDataSourceMappingsRetriever createShadowDataSourceMappingsRe if (queryContext.getSqlStatementContext() instanceof SelectStatementContext) { return new ShadowSelectStatementDataSourceMappingsRetriever((SelectStatementContext) queryContext.getSqlStatementContext(), queryContext.getParameters(), tableAliasAndNameMappings); } - throw new UnsupportedOperationException(String.format("unsupported SQL statement context `%s`", queryContext.getSqlStatementContext().getClass().getName())); + return null; } @Override public Map retrieve(final ShadowRule rule) { Collection shadowTables = rule.filterShadowTables(tableAliasAndNameMappings.values()); Map result = tableHintDataSourceMappingsRetriever.retrieve(rule, shadowTables); - return result.isEmpty() ? shadowColumnDataSourceMappingsRetriever.retrieve(rule, shadowTables) : result; + return result.isEmpty() && null != shadowColumnDataSourceMappingsRetriever ? shadowColumnDataSourceMappingsRetriever.retrieve(rule, shadowTables) : result; } }