use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldThrowOnMapOfMultipleTypes.
@Test
public void shouldThrowOnMapOfMultipleTypes() {
// Given:
Expression expression = new CreateMapExpression(ImmutableMap.of(new StringLiteral("foo"), new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("bar"), new StringLiteral("bar")));
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("invalid input syntax for type BIGINT: \"bar\""));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldThrowOnArrayMultipleTypes.
@Test
public void shouldThrowOnArrayMultipleTypes() {
// Given:
Expression expression = new CreateArrayExpression(ImmutableList.of(new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("foo")));
// When:
final Exception e = assertThrows(KsqlException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
// Then:
assertThat(e.getMessage(), containsString("invalid input syntax for type BIGINT: \"foo\"."));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldThrowOnSimpleCase.
@Test
public void shouldThrowOnSimpleCase() {
final Expression expression = new SimpleCaseExpression(TestExpressions.COL0, ImmutableList.of(new WhenClause(new IntegerLiteral(10), new StringLiteral("ten"))), Optional.empty());
// When:
assertThrows(UnsupportedOperationException.class, () -> expressionTypeManager.getExpressionSqlType(expression));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class FunctionArgumentsUtilTest method shouldResolveFunctionWithoutLambdas.
@Test
public void shouldResolveFunctionWithoutLambdas() {
// Given:
givenUdfWithNameAndReturnType("NoLambdas", SqlTypes.STRING);
when(function.parameters()).thenReturn(ImmutableList.of(ParamTypes.STRING));
final FunctionCall expression = new FunctionCall(FunctionName.of("NoLambdas"), ImmutableList.of(new StringLiteral("a")));
// When:
final FunctionTypeInfo argumentsAndContexts = FunctionArgumentsUtil.getFunctionTypeInfo(expressionTypeManager, expression, udfFactory, Collections.emptyMap());
// Then:
assertThat(argumentsAndContexts.getReturnType(), is(SqlTypes.STRING));
assertThat(argumentsAndContexts.getArgumentInfos().size(), is(1));
verify(udfFactory).getFunction(ImmutableList.of(SqlArgument.of(SqlTypes.STRING)));
verify(function).getReturnType(ImmutableList.of(SqlArgument.of(SqlTypes.STRING)));
}
use of io.confluent.ksql.execution.expression.tree.StringLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldCoerceToDoubles.
@Test
public void shouldCoerceToDoubles() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new IntegerLiteral(10), new LongLiteral(1234567890), new DoubleLiteral(123.456), new StringLiteral("\t -100.010 \t"), BIGINT_EXPRESSION, DECIMAL_EXPRESSION, INT_EXPRESSION, DOUBLE_EXPRESSION);
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.of(SqlTypes.DOUBLE)));
assertThat(result.expressions(), is(ImmutableList.of(new DoubleLiteral(10.0), new DoubleLiteral(1234567890.0), new DoubleLiteral(123.456), new DoubleLiteral(-100.01), cast(BIGINT_EXPRESSION, SqlTypes.DOUBLE), cast(DECIMAL_EXPRESSION, SqlTypes.DOUBLE), cast(INT_EXPRESSION, SqlTypes.DOUBLE), DOUBLE_EXPRESSION)));
}
Aggregations