Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
w41ter committed Nov 21, 2024
1 parent 382c08b commit 663a7f5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public boolean needChangeMTMVState() {
@Override
public String toSql() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("DROP INDEX ").append(indexName);
stringBuilder.append("DROP INDEX ").append("`" + indexName + "`");
if (!alter) {
stringBuilder.append(" ON ").append(tableName.toSql());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,27 @@ public void testEnableFeature() throws UserException {
stmt.toSql());
Assert.assertEquals("testDb", stmt.getTbl().getDb());
}

@Test
public void testCreateIndex() throws UserException {
List<AlterClause> ops = Lists.newArrayList();
ops.add(new CreateIndexClause(
new TableName(InternalCatalog.INTERNAL_CATALOG_NAME, "db", "table"),
new IndexDef("index1", false, Lists.newArrayList("col1"), IndexDef.IndexType.INVERTED, null, "balabala"),
true));
AlterTableStmt stmt = new AlterTableStmt(new TableName(internalCtl, "testDb", "testTbl"), ops);
stmt.analyze(analyzer);
Assert.assertEquals("ALTER TABLE `testDb`.`testTbl` ADD INDEX `index1` (`col1`) USING INVERTED COMMENT 'balabala'",
stmt.toSql());
}

@Test
public void testDropIndex() throws UserException {
List<AlterClause> ops = Lists.newArrayList();
ops.add(new DropIndexClause("index1", false,
new TableName(InternalCatalog.INTERNAL_CATALOG_NAME, "db", "table"), true));
AlterTableStmt stmt = new AlterTableStmt(new TableName(internalCtl, "testDb", "testTbl"), ops);
stmt.analyze(analyzer);
Assert.assertEquals("ALTER TABLE `testDb`.`testTbl` DROP INDEX `index1`", stmt.toSql());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ public void testAlter() throws AnalysisException {
new IndexDef("index1", false, Lists.newArrayList("col1"), IndexDef.IndexType.INVERTED, null, "balabala"),
true);
clause.analyze(analyzer);
Assert.assertEquals("ALTER TABLE `db`.`table` ADD INDEX `index1` (`col1`) USING INVERTED COMMENT 'balabala'",
clause.toSql());
Assert.assertEquals("ADD INDEX `index1` (`col1`) USING INVERTED COMMENT 'balabala'", clause.toSql());
}

@Test(expected = AnalysisException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testAlter() throws UserException {
DropIndexClause clause = new DropIndexClause("index1", false,
new TableName(InternalCatalog.INTERNAL_CATALOG_NAME, "db", "table"), true);
clause.analyze(analyzer);
Assert.assertEquals("ALTER TABLE `db`.`table` DROP INDEX `index1`", clause.toSql());
Assert.assertEquals("DROP INDEX `index1`", clause.toSql());
}

@Test(expected = AnalysisException.class)
Expand Down

0 comments on commit 663a7f5

Please sign in to comment.