Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split ANTLR grammar rule
Browse files Browse the repository at this point in the history
Signed-off-by: Chen Dai <[email protected]>
dai-chen committed Jul 24, 2024
1 parent bdf2d45 commit a0da1a2
Showing 2 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -156,7 +156,10 @@ indexManagementStatement
;

showFlintIndexStatement
: SHOW FLINT (INDEX | INDEXES) EXTENDED? IN catalogDb=multipartIdentifier
: SHOW FLINT (INDEX | INDEXES)
IN catalogDb=multipartIdentifier #showFlintIndex
| SHOW FLINT (INDEX | INDEXES) EXTENDED
IN catalogDb=multipartIdentifier #showFlintIndexExtended
;

indexJobManagementStatement
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import org.opensearch.flint.spark.mv.FlintSparkMaterializedView
import org.opensearch.flint.spark.skipping.FlintSparkSkippingIndex
import org.opensearch.flint.spark.sql.{FlintSparkSqlCommand, FlintSparkSqlExtensionsVisitor, SparkSqlAstBuilder}
import org.opensearch.flint.spark.sql.FlintSparkSqlAstBuilder.IndexBelongsTo
import org.opensearch.flint.spark.sql.FlintSparkSqlExtensionsParser.{MultipartIdentifierContext, ShowFlintIndexStatementContext}
import org.opensearch.flint.spark.sql.FlintSparkSqlExtensionsParser.{MultipartIdentifierContext, ShowFlintIndexContext, ShowFlintIndexExtendedContext}

import org.apache.spark.sql.Row
import org.apache.spark.sql.catalyst.expressions.AttributeReference
@@ -55,20 +55,20 @@ trait FlintSparkIndexAstBuilder extends FlintSparkSqlExtensionsVisitor[AnyRef] {
private val extendedOutputSchema = Seq(
AttributeReference("error", StringType, nullable = true)())

override def visitShowFlintIndexStatement(ctx: ShowFlintIndexStatementContext): Command = {
if (ctx.EXTENDED() == null) {
new ShowFlintIndexCommandBuilder()
.withSchema(baseOutputSchema)
.forCatalog(ctx.catalogDb)
.constructRows(baseRowData)
.build()
} else {
new ShowFlintIndexCommandBuilder()
.withSchema(baseOutputSchema ++ extendedOutputSchema)
.forCatalog(ctx.catalogDb)
.constructRows(index => baseRowData(index) ++ extendedRowData(index))
.build()
}
override def visitShowFlintIndex(ctx: ShowFlintIndexContext): Command = {
new ShowFlintIndexCommandBuilder()
.withSchema(baseOutputSchema)
.forCatalog(ctx.catalogDb)
.constructRows(baseRowData)
.build()
}

override def visitShowFlintIndexExtended(ctx: ShowFlintIndexExtendedContext): Command = {
new ShowFlintIndexCommandBuilder()
.withSchema(baseOutputSchema ++ extendedOutputSchema)
.forCatalog(ctx.catalogDb)
.constructRows(index => baseRowData(index) ++ extendedRowData(index))
.build()
}

/**

0 comments on commit a0da1a2

Please sign in to comment.