forked from StarRocks/starrocks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug show full column does not display default value
Signed-off-by: Astralidea <astralidea@163.com>
- Loading branch information
1 parent
b78bd1d
commit 151f038
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
fe/fe-core/src/test/java/com/starrocks/analysis/ShowColumnStmtTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.starrocks.analysis; | ||
|
||
import com.starrocks.common.Config; | ||
import com.starrocks.common.FeConstants; | ||
import com.starrocks.qe.ConnectContext; | ||
import com.starrocks.qe.ShowExecutor; | ||
import com.starrocks.qe.ShowResultSet; | ||
import com.starrocks.server.GlobalStateMgr; | ||
import com.starrocks.sql.ast.DropTableStmt; | ||
import com.starrocks.sql.ast.ShowColumnStmt; | ||
import com.starrocks.utframe.StarRocksAssert; | ||
import com.starrocks.utframe.UtFrameUtils; | ||
import org.junit.AfterClass; | ||
import org.junit.Assert; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
public class ShowColumnStmtTest { | ||
|
||
private static ConnectContext connectContext; | ||
private static StarRocksAssert starRocksAssert; | ||
|
||
@BeforeClass | ||
public static void beforeClass() throws Exception { | ||
FeConstants.runningUnitTest = true; | ||
Config.dynamic_partition_enable = true; | ||
Config.dynamic_partition_check_interval_seconds = 1; | ||
Config.enable_strict_storage_medium_check = false; | ||
UtFrameUtils.createMinStarRocksCluster(); | ||
UtFrameUtils.addMockBackend(10002); | ||
UtFrameUtils.addMockBackend(10003); | ||
// create connect context | ||
connectContext = UtFrameUtils.createDefaultCtx(); | ||
starRocksAssert = new StarRocksAssert(connectContext); | ||
|
||
starRocksAssert.withDatabase("test").useDatabase("test") | ||
.withTable("create table test_default\n" + | ||
"(id varchar(255) default (uuid()))\n" + | ||
"distributed by hash(id)\n" + | ||
"PROPERTIES ( \"replication_num\" = \"1\" )"); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() throws Exception { | ||
ConnectContext ctx = starRocksAssert.getCtx(); | ||
String dropSQL = "drop table test_default"; | ||
try { | ||
DropTableStmt dropTableStmt = (DropTableStmt) UtFrameUtils.parseStmtWithNewParser(dropSQL, ctx); | ||
GlobalStateMgr.getCurrentState().dropTable(dropTableStmt); | ||
} catch (Exception ex) { | ||
|
||
} | ||
} | ||
|
||
@Test | ||
public void testShowDefaultValue() throws Exception { | ||
ConnectContext ctx = starRocksAssert.getCtx(); | ||
String sql = "show full columns from test_default;"; | ||
ShowColumnStmt showColumnStmt = (ShowColumnStmt) UtFrameUtils.parseStmtWithNewParser(sql, ctx); | ||
ShowExecutor executor = new ShowExecutor(ctx, showColumnStmt); | ||
ShowResultSet resultSet = executor.execute(); | ||
Assert.assertEquals("uuid()", resultSet.getResultRows().get(0).get(5)); | ||
} | ||
|
||
} |