Skip to content

Commit 62578cd

Browse files
committed
Add commons-text to analytics-engine ZIP and fix isAnalyticsIndex NPE
commons-text is needed by Calcite (parent classloader) for fuzzy matching but was only in the SQL plugin (child classloader). Also use lightweight parsing context in isAnalyticsIndex to avoid requiring cluster state. Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent a1923ac commit 62578cd

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
216 KB
Binary file not shown.

plugin/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ bundlePlugin {
7777
exclude 'memory-0*.jar'
7878
exclude 'sketches-core-*.jar'
7979
exclude 'commons-lang3-*.jar'
80+
exclude 'commons-text-*.jar'
8081
exclude 'commons-math3-*.jar'
8182
exclude 'commons-dbcp2-*.jar'
8283
exclude 'commons-io-*.jar'

plugin/src/main/java/org/opensearch/sql/plugin/rest/RestUnifiedQueryAction.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public boolean isAnalyticsIndex(String query, QueryType queryType) {
7575
if (query == null || query.isEmpty()) {
7676
return false;
7777
}
78-
try (UnifiedQueryContext context = buildContext(queryType, false)) {
78+
try (UnifiedQueryContext context = buildParsingContext(queryType)) {
7979
String indexName = extractIndexName(query, context);
8080
if (indexName == null) {
8181
return false;
@@ -156,6 +156,14 @@ private void doExplain(
156156
}
157157
}
158158

159+
/**
160+
* Build a lightweight context for parsing only (index name extraction). Does not require cluster
161+
* state or catalog schema.
162+
*/
163+
private static UnifiedQueryContext buildParsingContext(QueryType queryType) {
164+
return UnifiedQueryContext.builder().language(queryType).build();
165+
}
166+
159167
private UnifiedQueryContext buildContext(QueryType queryType, boolean profiling) {
160168
return UnifiedQueryContext.builder()
161169
.language(queryType)

0 commit comments

Comments
 (0)