Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spark/src/main/antlr/SqlBaseLexer.g4
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ ELSE: 'ELSE';
END: 'END';
ESCAPE: 'ESCAPE';
ESCAPED: 'ESCAPED';
EVOLUTION: 'EVOLUTION';
EXCEPT: 'EXCEPT';
EXCHANGE: 'EXCHANGE';
EXCLUDE: 'EXCLUDE';
Expand Down
4 changes: 3 additions & 1 deletion spark/src/main/antlr/SqlBaseParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ dmlStatementNoWith
| fromClause multiInsertQueryBody+ #multiInsertQuery
| DELETE FROM identifierReference tableAlias whereClause? #deleteFromTable
| UPDATE identifierReference tableAlias setClause whereClause? #updateTable
| MERGE INTO target=identifierReference targetAlias=tableAlias
| MERGE (WITH SCHEMA EVOLUTION)? INTO target=identifierReference targetAlias=tableAlias
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is latest changes from Spark 3.3.1 grammar?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

USING (source=identifierReference |
LEFT_PAREN sourceQuery=query RIGHT_PAREN) sourceAlias=tableAlias
ON mergeCondition=booleanExpression
Expand Down Expand Up @@ -1399,6 +1399,7 @@ ansiNonReserved
| DOUBLE
| DROP
| ESCAPED
| EVOLUTION
| EXCHANGE
| EXCLUDE
| EXISTS
Expand Down Expand Up @@ -1715,6 +1716,7 @@ nonReserved
| END
| ESCAPE
| ESCAPED
| EVOLUTION
| EXCHANGE
| EXCLUDE
| EXECUTE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public static IndexQueryDetails extractIndexDetails(String sqlQuery) {
new CommonTokenStream(
new FlintSparkSqlExtensionsLexer(new CaseInsensitiveCharStream(sqlQuery))));
flintSparkSqlExtensionsParser.addErrorListener(new SyntaxAnalysisErrorListener());
FlintSparkSqlExtensionsParser.StatementContext statementContext =
flintSparkSqlExtensionsParser.statement();
FlintSparkSqlExtensionsParser.SingleStatementContext singleStatementContext =
flintSparkSqlExtensionsParser.singleStatement();
FlintSQLIndexDetailsVisitor flintSQLIndexDetailsVisitor = new FlintSQLIndexDetailsVisitor();
statementContext.accept(flintSQLIndexDetailsVisitor);
singleStatementContext.accept(flintSQLIndexDetailsVisitor);
return flintSQLIndexDetailsVisitor.getIndexQueryDetailsBuilder().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,39 @@ void testAutoRefresh() {
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertTrue(
SQLQueryUtils.extractIndexDetails(
skippingIndex().withProperty("auto_refresh", "true").withSemicolon().getQuery())
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertTrue(
SQLQueryUtils.extractIndexDetails(
skippingIndex().withProperty("\"auto_refresh\"", "true").getQuery())
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertTrue(
SQLQueryUtils.extractIndexDetails(
skippingIndex().withProperty("\"auto_refresh\"", "true").withSemicolon().getQuery())
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertTrue(
SQLQueryUtils.extractIndexDetails(
skippingIndex().withProperty("\"auto_refresh\"", "\"true\"").getQuery())
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertTrue(
SQLQueryUtils.extractIndexDetails(
skippingIndex()
.withProperty("\"auto_refresh\"", "\"true\"")
.withSemicolon()
.getQuery())
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertFalse(
SQLQueryUtils.extractIndexDetails(
skippingIndex().withProperty("auto_refresh", "1").getQuery())
Expand Down Expand Up @@ -317,10 +338,22 @@ void testAutoRefresh() {
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertTrue(
SQLQueryUtils.extractIndexDetails(
index().withProperty("auto_refresh", "true").withSemicolon().getQuery())
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertTrue(
SQLQueryUtils.extractIndexDetails(mv().withProperty("auto_refresh", "true").getQuery())
.getFlintIndexOptions()
.autoRefresh());

Assertions.assertTrue(
SQLQueryUtils.extractIndexDetails(
mv().withProperty("auto_refresh", "true").withSemicolon().getQuery())
.getFlintIndexOptions()
.autoRefresh());
}

@Getter
Expand Down Expand Up @@ -350,5 +383,10 @@ public IndexQuery withProperty(String key, String value) {
query = String.format("%s with (%s = %s)", query, key, value);
return this;
}

public IndexQuery withSemicolon() {
query += ";";
return this;
}
}
}