use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldPropagateNullValueWhenPartitioningByKeyExpression.
@Test
public void shouldPropagateNullValueWhenPartitioningByKeyExpression() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new ArithmeticBinaryExpression(Operator.ADD, new UnqualifiedColumnReferenceExp(COL0), new StringLiteral("-foo")))).getMapper();
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, null);
// Then:
assertThat(result.key, is(genericKey((OLD_KEY + "-foo"))));
assertThat(result.value, is(nullValue()));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldPropagateNullValueWhenPartitioningByKey.
@Test
public void shouldPropagateNullValueWhenPartitioningByKey() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new UnqualifiedColumnReferenceExp(COL0))).getMapper();
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, null);
// Then:
assertThat(result.key, is(genericKey((OLD_KEY))));
assertThat(result.value, is(nullValue()));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldNotChangeValueIfPartitioningByKeyColumnReference.
@Test
public void shouldNotChangeValueIfPartitioningByKeyColumnReference() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new UnqualifiedColumnReferenceExp(COL0))).getMapper();
final ImmutableList<Object> originals = ImmutableList.copyOf(value.values());
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, value);
// Then:
assertThat(result.value, is(GenericRow.fromList(originals)));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldPartitionByNullAnyRowsWhereFailedToExtractKey.
@Test
public void shouldPartitionByNullAnyRowsWhereFailedToExtractKey() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(FAILING_UDF, new UnqualifiedColumnReferenceExp(COL1))).getMapper();
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, value);
// Then:
assertThat(result.key, is(genericKey(null, COL1_VALUE)));
}
use of io.confluent.ksql.GenericKey in project ksql by confluentinc.
the class PartitionByParamsFactoryTest method shouldAppendNewKeyColumnToValueIfNotPartitioningByColumnReference.
@Test
public void shouldAppendNewKeyColumnToValueIfNotPartitioningByColumnReference() {
// Given:
final Mapper<GenericKey> mapper = partitionBy(ImmutableList.of(new FunctionCall(CONSTANT_UDF_NAME, ImmutableList.of(new UnqualifiedColumnReferenceExp(COL1))))).getMapper();
final ImmutableList<Object> originals = ImmutableList.copyOf(value.values());
// When:
final KeyValue<GenericKey, GenericRow> result = mapper.apply(key, value);
// Then:
assertThat(result.value, is(GenericRow.fromList(originals).append(ConstantUdf.VALUE)));
}
Aggregations