Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
9 changes: 8 additions & 1 deletion fe/fe-core/src/main/java/org/apache/doris/analysis/Expr.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,14 @@ protected Function getBuiltinFunction(
throws AnalysisException {
FunctionName fnName = new FunctionName(name);
Function searchDesc = new Function(fnName, argTypes, Type.INVALID, false);
return Catalog.getCurrentCatalog().getFunction(searchDesc, mode);
Function f = Catalog.getCurrentCatalog().getFunction(searchDesc, mode);
if (f != null && fnName.getFunction().equalsIgnoreCase("rand")) {
if (this.children.size() == 1
&& !(this.children.get(0) instanceof LiteralExpr)) {
throw new AnalysisException("The param of rand function must be literal");
}
}
return f;
}

/**
Expand Down
15 changes: 15 additions & 0 deletions fe/fe-core/src/test/java/org/apache/doris/analysis/SelectStmtTest.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,21 @@ public void testDataGripSupport() throws Exception {
dorisAssert.query(sql).explainQuery();
}

@Test
public void testRandFunction() throws Exception {
String sql = "select rand(db1.tbl1.k1) from db1.tbl1;";
try {
dorisAssert.query(sql).explainQuery();
Assert.fail("The param of rand function must be literal");
} catch (AnalysisException e) {
System.out.println(e.getMessage());
}
sql = "select rand(1234) from db1.tbl1;";
dorisAssert.query(sql).explainQuery();
sql = "select rand() from db1.tbl1;";
dorisAssert.query(sql).explainQuery();
}

@Test
public void testVarcharToLongSupport() throws Exception {
String sql = "select count(*)\n" +
Expand Down