@@ -81,7 +81,7 @@ public boolean isAnalyticsIndex(String query, QueryType queryType) {
8181 return false ;
8282 }
8383 try (UnifiedQueryContext context = buildParsingContext (queryType )) {
84- String indexName = extractIndexName (query , context );
84+ String indexName = extractIndexName (query , queryType , context );
8585 if (indexName == null ) {
8686 return false ;
8787 }
@@ -182,15 +182,14 @@ private UnifiedQueryContext buildContext(QueryType queryType, boolean profiling)
182182 * Extract the source index name by parsing the query and visiting the AST to find the Relation
183183 * node. Uses the context's parser which supports both PPL and SQL.
184184 */
185- private static String extractIndexName (String query , UnifiedQueryContext context ) {
186- Object parseResult = context .getParser ().parse (query );
187- if (parseResult instanceof UnresolvedPlan unresolvedPlan ) {
185+ private static String extractIndexName (
186+ String query , QueryType queryType , UnifiedQueryContext context ) {
187+ if (queryType == QueryType .PPL ) {
188+ UnresolvedPlan unresolvedPlan = (UnresolvedPlan ) context .getParser ().parse (query );
188189 return unresolvedPlan .accept (new IndexNameExtractor (), null );
189190 }
190- if (parseResult instanceof SqlNode sqlNode ) {
191- return extractTableNameFromSqlNode (sqlNode );
192- }
193- return null ;
191+ SqlNode sqlNode = (SqlNode ) context .getParser ().parse (query );
192+ return extractTableNameFromSqlNode (sqlNode );
194193 }
195194
196195 /**
0 commit comments