Skip to content

Commit d288392

Browse files
committed
add antlr version
Signed-off-by: Eric Wei <mengwei.eric@gmail.com>
1 parent 9274b56 commit d288392

4 files changed

Lines changed: 6 additions & 0 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private void serializeBundle(XContentBuilder builder, GrammarBundle bundle) thro
9191

9292
// Identity & versioning
9393
builder.field("bundleVersion", bundle.getBundleVersion());
94+
builder.field("antlrVersion", bundle.getAntlrVersion());
9495
builder.field("grammarHash", bundle.getGrammarHash());
9596
builder.field("startRuleIndex", bundle.getStartRuleIndex());
9697

plugin/src/test/java/org/opensearch/sql/plugin/rest/RestPPLGrammarActionTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public void testGetGrammar_ReturnsBundle() throws Exception {
6868

6969
String content = response.content().utf8ToString();
7070
assertTrue(content.contains("\"bundleVersion\":\"1.0\""));
71+
assertTrue(content.contains("\"antlrVersion\":"));
7172
assertTrue(content.contains("\"grammarHash\":\"sha256:"));
7273
assertTrue(content.contains("\"startRuleIndex\":0"));
7374
assertTrue(content.contains("\"lexerSerializedATN\":"));

ppl/src/main/java/org/opensearch/sql/ppl/autocomplete/GrammarBundle.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public class GrammarBundle {
1717
/** Bundle format version. */
1818
@NonNull private String bundleVersion;
1919

20+
/** ANTLR runtime version used to generate the grammar. */
21+
@NonNull private String antlrVersion;
22+
2023
/** SHA-256 hash of the serialized ATN data. Clients may use this to detect grammar changes. */
2124
@NonNull private String grammarHash;
2225

ppl/src/main/java/org/opensearch/sql/ppl/autocomplete/PPLGrammarBundleBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public GrammarBundle build() {
4545

4646
return GrammarBundle.builder()
4747
.bundleVersion(BUNDLE_VERSION)
48+
.antlrVersion(ANTLR_VERSION)
4849
.grammarHash(computeGrammarHash(lexerATN, parserATN))
4950
.lexerSerializedATN(lexerATN)
5051
.parserSerializedATN(parserATN)

0 commit comments

Comments
 (0)