use of io.confluent.ksql.execution.expression.tree.LongLiteral 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)));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldCoerceToBigIntIfStringNumericTooWideForInt.
@Test
public void shouldCoerceToBigIntIfStringNumericTooWideForInt() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new IntegerLiteral(10), new StringLiteral("1234567890000"));
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.of(SqlTypes.BIGINT)));
assertThat(result.expressions(), is(ImmutableList.of(new LongLiteral(10), new LongLiteral(1234567890000L))));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldCoerceToDecimals.
@Test
public void shouldCoerceToDecimals() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new IntegerLiteral(10), new LongLiteral(1234567890), new StringLiteral("\t -100.010 \t"), BIGINT_EXPRESSION, DECIMAL_EXPRESSION, INT_EXPRESSION);
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
final SqlDecimal decimalType = SqlTypes.decimal(22, 3);
assertThat(result.commonType(), is(Optional.of(decimalType)));
assertThat(result.expressions(), is(ImmutableList.of(new DecimalLiteral(new BigDecimal("10.000")), new DecimalLiteral(new BigDecimal("1234567890.000")), new DecimalLiteral(new BigDecimal("-100.010")), cast(BIGINT_EXPRESSION, decimalType), cast(DECIMAL_EXPRESSION, decimalType), cast(INT_EXPRESSION, decimalType))));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class CoercionUtilTest method shouldHandleSomeNulls.
@Test
public void shouldHandleSomeNulls() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new NullLiteral(), new IntegerLiteral(10), new NullLiteral(), new LongLiteral(20L), new NullLiteral());
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.of(SqlTypes.BIGINT)));
assertThat(result.expressions(), is(ImmutableList.of(new NullLiteral(), new LongLiteral(10), new NullLiteral(), new LongLiteral(20L), new NullLiteral())));
}
use of io.confluent.ksql.execution.expression.tree.LongLiteral in project ksql by confluentinc.
the class SchemaKStreamTest method shouldRewriteTimeComparisonInFilter.
@Test
@SuppressWarnings("rawtypes")
public void shouldRewriteTimeComparisonInFilter() {
// Given:
final PlanNode logicalPlan = givenInitialKStreamOf("SELECT col0, col2, col3 FROM test1 " + "WHERE ROWTIME = '1984-01-01T00:00:00+00:00' EMIT CHANGES;");
final FilterNode filterNode = (FilterNode) logicalPlan.getSources().get(0).getSources().get(0);
// When:
final SchemaKStream<?> filteredSchemaKStream = initialSchemaKStream.filter(filterNode.getPredicate(), childContextStacker);
// Then:
final StreamFilter step = (StreamFilter) filteredSchemaKStream.getSourceStep();
assertThat(step.getFilterExpression(), equalTo(new ComparisonExpression(ComparisonExpression.Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("ROWTIME")), new LongLiteral(441763200000L))));
}
Aggregations