use of io.confluent.ksql.execution.expression.tree.FunctionCall in project ksql by confluentinc.
the class AggregateAnalyzerTest method shouldThrowOnNestedSelectAggFunctions.
@Test
public void shouldThrowOnNestedSelectAggFunctions() {
// Given:
final FunctionCall nestedCall = new FunctionCall(FunctionName.of("MIN"), ImmutableList.of(AGG_FUNCTION_CALL, COL2));
givenSelectExpression(nestedCall);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> analyzer.analyze(analysis, selects));
// Then:
assertThat(e.getMessage(), containsString("Aggregate functions can not be nested: MIN(MAX())"));
}
use of io.confluent.ksql.execution.expression.tree.FunctionCall in project ksql by confluentinc.
the class AggregateAnalyzerTest method shouldNotThrowOnNonAggregateFunctionArgumentsWhenNestedInsideAggFunction.
@Test
public void shouldNotThrowOnNonAggregateFunctionArgumentsWhenNestedInsideAggFunction() {
// Given:
final FunctionCall nonAggFunc = new FunctionCall(FunctionName.of("ROUND"), ImmutableList.of(COL3));
final FunctionCall aggFuncWithNestedNonAgg = new FunctionCall(FunctionName.of("MAX"), ImmutableList.of(COL2, nonAggFunc));
givenSelectExpression(aggFuncWithNestedNonAgg);
// When:
analyzer.analyze(analysis, selects);
// Then: did not throw.
}
use of io.confluent.ksql.execution.expression.tree.FunctionCall in project ksql by confluentinc.
the class AggregateAnalyzerTest method shouldCaptureDefaultFunctionArguments.
@Test
public void shouldCaptureDefaultFunctionArguments() {
// Given:
final FunctionCall emptyFunc = new FunctionCall(FunctionName.of("COUNT"), new ArrayList<>());
givenSelectExpression(emptyFunc);
// When:
final AggregateAnalysisResult result = analyzer.analyze(analysis, selects);
// Then:
assertThat(result.getRequiredColumns(), hasItem(DEFAULT_ARGUMENT));
assertThat(result.getAggregateFunctionArguments(), hasItem(DEFAULT_ARGUMENT));
}
use of io.confluent.ksql.execution.expression.tree.FunctionCall in project ksql by confluentinc.
the class AggregateAnalyzerTest method shouldThrowOnNestedHavingAggFunctions.
@Test
public void shouldThrowOnNestedHavingAggFunctions() {
// Given:
final FunctionCall nestedCall = new FunctionCall(FunctionName.of("MIN"), ImmutableList.of(AGG_FUNCTION_CALL, COL2));
givenHavingExpression(nestedCall);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> analyzer.analyze(analysis, selects));
// Then:
assertThat(e.getMessage(), containsString("Aggregate functions can not be nested: MIN(MAX())"));
}
use of io.confluent.ksql.execution.expression.tree.FunctionCall in project ksql by confluentinc.
the class AggregateAnalyzerTest method shouldThrowOnNonAggFunctionCallWithColumnParamNotInGroupBy.
@Test
public void shouldThrowOnNonAggFunctionCallWithColumnParamNotInGroupBy() {
// Given:
givenSelectExpression(new FunctionCall(FunctionName.of("UCASE"), ImmutableList.of(COL2)));
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> analyzer.analyze(analysis, selects));
// Then:
assertThat(e.getMessage(), containsString("Non-aggregate SELECT expression(s) not part of GROUP BY: UCASE(COL2)"));
}
Aggregations