github-advanced-security[bot] commented on code in PR #15543:
URL: https://github.com/apache/druid/pull/15543#discussion_r1423591542
##########
processing/src/main/java/org/apache/druid/math/expr/BinaryEvalOpExprBase.java:
##########
@@ -207,7 +207,7 @@
break;
}
if (!ExpressionProcessing.useStrictBooleans() && !type.is(ExprType.STRING)
&& !type.isArray()) {
- return ExprEval.ofBoolean(result, type.getType());
+ return ExprEval.ofBoolean(result, type);
Review Comment:
## Deprecated method or constructor invocation
Invoking [ExprEval.ofBoolean](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6332)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2313,38 +2320,39 @@
@Test
public void testAbnormalRightWithNegativeNumber()
{
- expectException(
- ExpressionValidationException.class,
- "Function[right] needs a positive integer as the second argument"
- );
-
- testHelper.testExpressionString(
- new RightOperatorConversion().calciteOperator(),
- ImmutableList.of(
- testHelper.makeInputRef("s"),
- testHelper.makeLiteral(-1)
- ),
- makeExpression("right(\"s\",-1)"),
- null
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new RightOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeLiteral(-1)
+ ),
+ makeExpression("right(\"s\",-1)"),
+ null
+ )
);
+ Assert.assertEquals("Function[right] needs a positive integer as the
second argument", t.getMessage());
}
@Test
public void testAbnormalRightWithWrongType()
{
- expectException(
- ExpressionValidationException.class,
- "Function[right] needs a STRING as first argument and a LONG as second
argument"
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new RightOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeInputRef("s")
+ ),
+ makeExpression("right(\"s\",\"s\")"),
+ null
+ )
Review Comment:
## Deprecated method or constructor invocation
Invoking [ExpressionTestHelper.testExpressionString](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6337)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2313,38 +2320,39 @@
@Test
public void testAbnormalRightWithNegativeNumber()
{
- expectException(
- ExpressionValidationException.class,
- "Function[right] needs a positive integer as the second argument"
- );
-
- testHelper.testExpressionString(
- new RightOperatorConversion().calciteOperator(),
- ImmutableList.of(
- testHelper.makeInputRef("s"),
- testHelper.makeLiteral(-1)
- ),
- makeExpression("right(\"s\",-1)"),
- null
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new RightOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeLiteral(-1)
+ ),
+ makeExpression("right(\"s\",-1)"),
Review Comment:
## Deprecated method or constructor invocation
Invoking [CalciteTestBase.makeExpression](1) should be avoided because it
has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6336)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -1255,50 +1260,53 @@
final SqlFunction roundFunction = new
RoundOperatorConversion().calciteOperator();
if (!NullHandling.sqlCompatible()) {
- expectException(
- ExpressionValidationException.class,
- "Function[round] first argument should be a LONG or DOUBLE but got
STRING instead"
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpression(
+ roundFunction,
+ testHelper.makeInputRef("s"),
+ DruidExpression.ofExpression(
+ ColumnType.STRING,
+ DruidExpression.functionCall("round"),
+ ImmutableList.of(
+ DruidExpression.ofColumn(ColumnType.STRING, "s")
+ )
+ ),
+ NullHandling.sqlCompatible() ? null : "IAE Exception"
+ )
+ );
+ Assert.assertEquals(
+ "Function[round] first argument should be a LONG or DOUBLE but got
STRING instead",
+ t.getMessage()
);
}
- testHelper.testExpression(
- roundFunction,
- testHelper.makeInputRef("s"),
- DruidExpression.ofExpression(
- ColumnType.STRING,
- DruidExpression.functionCall("round"),
- ImmutableList.of(
- DruidExpression.ofColumn(ColumnType.STRING, "s")
- )
- ),
- NullHandling.sqlCompatible() ? null : "IAE Exception"
- );
}
@Test
public void testRoundWithInvalidSecondArgument()
{
final SqlFunction roundFunction = new
RoundOperatorConversion().calciteOperator();
- expectException(
- ExpressionValidationException.class,
- "Function[round] second argument should be a LONG but got STRING
instead"
- );
- testHelper.testExpressionString(
- roundFunction,
- ImmutableList.of(
- testHelper.makeInputRef("x"),
- testHelper.makeLiteral("foo")
- ),
- DruidExpression.ofExpression(
- ColumnType.FLOAT,
- DruidExpression.functionCall("round"),
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ roundFunction,
ImmutableList.of(
- DruidExpression.ofColumn(ColumnType.FLOAT, "x"),
- DruidExpression.ofStringLiteral("foo")
- )
- ),
- "IAE Exception"
+ testHelper.makeInputRef("x"),
+ testHelper.makeLiteral("foo")
+ ),
+ DruidExpression.ofExpression(
+ ColumnType.FLOAT,
+ DruidExpression.functionCall("round"),
+ ImmutableList.of(
+ DruidExpression.ofColumn(ColumnType.FLOAT, "x"),
+ DruidExpression.ofStringLiteral("foo")
+ )
+ ),
+ "IAE Exception"
+ )
Review Comment:
## Deprecated method or constructor invocation
Invoking [ExpressionTestHelper.testExpressionString](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6334)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2477,19 +2486,21 @@
@Test
public void testAbnormalRepeatWithWrongType()
{
- expectException(
- ExpressionValidationException.class,
- "Function[repeat] needs a STRING as first argument and a LONG as
second argument"
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new RepeatOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeInputRef("s")
+ ),
+ makeExpression("repeat(\"s\",\"s\")"),
Review Comment:
## Deprecated method or constructor invocation
Invoking [CalciteTestBase.makeExpression](1) should be avoided because it
has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6345)
##########
processing/src/main/java/org/apache/druid/math/expr/UnaryOperatorExpr.java:
##########
@@ -184,7 +184,7 @@
if (!ExpressionProcessing.useStrictBooleans()) {
// conforming to other boolean-returning binary operators
ExpressionType retType = ret.type().is(ExprType.DOUBLE) ?
ExpressionType.DOUBLE : ExpressionType.LONG;
- return ExprEval.ofBoolean(!ret.asBoolean(), retType.getType());
+ return ExprEval.ofBoolean(!ret.asBoolean(), retType);
Review Comment:
## Deprecated method or constructor invocation
Invoking [ExprEval.ofBoolean](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6333)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2313,38 +2320,39 @@
@Test
public void testAbnormalRightWithNegativeNumber()
{
- expectException(
- ExpressionValidationException.class,
- "Function[right] needs a positive integer as the second argument"
- );
-
- testHelper.testExpressionString(
- new RightOperatorConversion().calciteOperator(),
- ImmutableList.of(
- testHelper.makeInputRef("s"),
- testHelper.makeLiteral(-1)
- ),
- makeExpression("right(\"s\",-1)"),
- null
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new RightOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeLiteral(-1)
+ ),
+ makeExpression("right(\"s\",-1)"),
+ null
+ )
Review Comment:
## Deprecated method or constructor invocation
Invoking [ExpressionTestHelper.testExpressionString](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6335)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2405,38 +2413,39 @@
@Test
public void testAbnormalLeftWithNegativeNumber()
{
- expectException(
- ExpressionValidationException.class,
- "Function[left] needs a postive integer as second argument"
- );
-
- testHelper.testExpressionString(
- new LeftOperatorConversion().calciteOperator(),
- ImmutableList.of(
- testHelper.makeInputRef("s"),
- testHelper.makeLiteral(-1)
- ),
- makeExpression("left(\"s\",-1)"),
- null
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new LeftOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeLiteral(-1)
+ ),
+ makeExpression("left(\"s\",-1)"),
+ null
+ )
Review Comment:
## Deprecated method or constructor invocation
Invoking [ExpressionTestHelper.testExpressionString](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6339)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2313,38 +2320,39 @@
@Test
public void testAbnormalRightWithNegativeNumber()
{
- expectException(
- ExpressionValidationException.class,
- "Function[right] needs a positive integer as the second argument"
- );
-
- testHelper.testExpressionString(
- new RightOperatorConversion().calciteOperator(),
- ImmutableList.of(
- testHelper.makeInputRef("s"),
- testHelper.makeLiteral(-1)
- ),
- makeExpression("right(\"s\",-1)"),
- null
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new RightOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeLiteral(-1)
+ ),
+ makeExpression("right(\"s\",-1)"),
+ null
+ )
);
+ Assert.assertEquals("Function[right] needs a positive integer as the
second argument", t.getMessage());
}
@Test
public void testAbnormalRightWithWrongType()
{
- expectException(
- ExpressionValidationException.class,
- "Function[right] needs a STRING as first argument and a LONG as second
argument"
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new RightOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeInputRef("s")
+ ),
+ makeExpression("right(\"s\",\"s\")"),
Review Comment:
## Deprecated method or constructor invocation
Invoking [CalciteTestBase.makeExpression](1) should be avoided because it
has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6338)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2405,38 +2413,39 @@
@Test
public void testAbnormalLeftWithNegativeNumber()
{
- expectException(
- ExpressionValidationException.class,
- "Function[left] needs a postive integer as second argument"
- );
-
- testHelper.testExpressionString(
- new LeftOperatorConversion().calciteOperator(),
- ImmutableList.of(
- testHelper.makeInputRef("s"),
- testHelper.makeLiteral(-1)
- ),
- makeExpression("left(\"s\",-1)"),
- null
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new LeftOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeLiteral(-1)
+ ),
+ makeExpression("left(\"s\",-1)"),
+ null
+ )
);
+ Assert.assertEquals("Function[left] needs a postive integer as second
argument", t.getMessage());
}
@Test
public void testAbnormalLeftWithWrongType()
{
- expectException(
- ExpressionValidationException.class,
- "Function[left] needs a STRING as first argument and a LONG as second
argument"
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new LeftOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeInputRef("s")
+ ),
+ makeExpression("left(\"s\",\"s\")"),
Review Comment:
## Deprecated method or constructor invocation
Invoking [CalciteTestBase.makeExpression](1) should be avoided because it
has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6342)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2405,38 +2413,39 @@
@Test
public void testAbnormalLeftWithNegativeNumber()
{
- expectException(
- ExpressionValidationException.class,
- "Function[left] needs a postive integer as second argument"
- );
-
- testHelper.testExpressionString(
- new LeftOperatorConversion().calciteOperator(),
- ImmutableList.of(
- testHelper.makeInputRef("s"),
- testHelper.makeLiteral(-1)
- ),
- makeExpression("left(\"s\",-1)"),
- null
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new LeftOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeLiteral(-1)
+ ),
+ makeExpression("left(\"s\",-1)"),
Review Comment:
## Deprecated method or constructor invocation
Invoking [CalciteTestBase.makeExpression](1) should be avoided because it
has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6340)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2405,38 +2413,39 @@
@Test
public void testAbnormalLeftWithNegativeNumber()
{
- expectException(
- ExpressionValidationException.class,
- "Function[left] needs a postive integer as second argument"
- );
-
- testHelper.testExpressionString(
- new LeftOperatorConversion().calciteOperator(),
- ImmutableList.of(
- testHelper.makeInputRef("s"),
- testHelper.makeLiteral(-1)
- ),
- makeExpression("left(\"s\",-1)"),
- null
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new LeftOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeLiteral(-1)
+ ),
+ makeExpression("left(\"s\",-1)"),
+ null
+ )
);
+ Assert.assertEquals("Function[left] needs a postive integer as second
argument", t.getMessage());
}
@Test
public void testAbnormalLeftWithWrongType()
{
- expectException(
- ExpressionValidationException.class,
- "Function[left] needs a STRING as first argument and a LONG as second
argument"
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new LeftOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeInputRef("s")
+ ),
+ makeExpression("left(\"s\",\"s\")"),
+ null
+ )
Review Comment:
## Deprecated method or constructor invocation
Invoking [ExpressionTestHelper.testExpressionString](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6341)
##########
sql/src/test/java/org/apache/druid/sql/calcite/expression/ExpressionsTest.java:
##########
@@ -2477,19 +2486,21 @@
@Test
public void testAbnormalRepeatWithWrongType()
{
- expectException(
- ExpressionValidationException.class,
- "Function[repeat] needs a STRING as first argument and a LONG as
second argument"
+ Throwable t = Assert.assertThrows(
+ DruidException.class,
+ () -> testHelper.testExpressionString(
+ new RepeatOperatorConversion().calciteOperator(),
+ ImmutableList.of(
+ testHelper.makeInputRef("s"),
+ testHelper.makeInputRef("s")
+ ),
+ makeExpression("repeat(\"s\",\"s\")"),
+ null
+ )
Review Comment:
## Deprecated method or constructor invocation
Invoking [ExpressionTestHelper.testExpressionString](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/6344)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]