Skip to content

Commit

Permalink
[fix](Nereids) fix log bug and add more numeric arithmetic function c…
Browse files Browse the repository at this point in the history
…ases (#47228)
  • Loading branch information
LiBinfeng-01 authored Feb 11, 2025
1 parent cf2fcf9 commit 538ce55
Show file tree
Hide file tree
Showing 3 changed files with 369 additions and 343 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ public static Expression log(DoubleLiteral first, DoubleLiteral second) {
if (first.getValue().equals(1.0d)) {
throw new NotSupportedException("the first input of function log can not be 1.0");
}
return checkOutputBoundary(new DoubleLiteral(Math.log(first.getValue()) / Math.log(second.getValue())));
return checkOutputBoundary(new DoubleLiteral(Math.log(second.getValue()) / Math.log(first.getValue())));
}

/**
Expand Down Expand Up @@ -1084,15 +1084,15 @@ public static Expression dpow(DoubleLiteral first, DoubleLiteral second) {
*/
@ExecFunction(name = "fmod")
public static Expression fmod(DoubleLiteral first, DoubleLiteral second) {
return checkOutputBoundary(new DoubleLiteral(first.getValue() / second.getValue()));
return checkOutputBoundary(new DoubleLiteral(first.getValue() % second.getValue()));
}

/**
* fmod
*/
@ExecFunction(name = "fmod")
public static Expression fmod(FloatLiteral first, FloatLiteral second) {
return new FloatLiteral(first.getValue() / second.getValue());
return new FloatLiteral(first.getValue() % second.getValue());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1691,14 +1691,20 @@ class Suite implements GroovyInterceptable {
String openFoldConstant = "set debug_skip_fold_constant=false";
sql(openFoldConstant)
logger.info(foldSql)
List<List<Object>> resultByFoldConstant = sql(foldSql)
Tuple2<List<List<Object>>, ResultSetMetaData> tupleResult = null
tupleResult = JdbcUtils.executeToStringList(context.getConnection(), foldSql)
def (resultByFoldConstant, meta) = tupleResult
logger.info("result by fold constant: " + resultByFoldConstant.toString())
String closeFoldConstant = "set debug_skip_fold_constant=true";
sql(closeFoldConstant)
logger.info(foldSql)
List<List<Object>> resultExpected = sql(foldSql)
logger.info("result expected: " + resultExpected.toString())
Assert.assertEquals(resultExpected, resultByFoldConstant)

String errorMsg = OutputUtils.checkOutput(resultExpected.iterator(), resultByFoldConstant.iterator(),
{ row -> OutputUtils.toCsvString(row as List<Object>) },
{ row -> OutputUtils.toCsvString(row) },
"check output failed", meta)
}

String getJobName(String dbName, String mtmvName) {
Expand Down
Loading

0 comments on commit 538ce55

Please sign in to comment.