use of com.datastax.oss.sink.pulsar.PulsarRecordImpl in project pulsar-sink by datastax.
the class RawDataEndToEndCCMIT method null_to_unset_false.
@Test
void null_to_unset_false() {
// Make a row with some value for textcol to start with.
session.execute("INSERT INTO types (bigintcol, textcol) VALUES (1234567, 'got here')");
taskConfigs.add(makeConnectorProperties("bigintcol=key, textcol=value.text", ImmutableMap.of(String.format("topic.mytopic.%s.types.nullToUnset", keyspaceName), "false")));
PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", "1234567", new GenericRecordImpl().put("text", null), recordType);
runTaskWithRecords(record);
// Verify that the record was inserted properly in the database; textcol should be unchanged.
List<Row> results = session.execute("SELECT bigintcol, textcol FROM types").all();
assertThat(results.size()).isEqualTo(1);
Row row = results.get(0);
assertThat(row.getLong("bigintcol")).isEqualTo(1234567L);
assertThat(row.getString("textcol")).isNull();
}
use of com.datastax.oss.sink.pulsar.PulsarRecordImpl in project pulsar-sink by datastax.
the class RawDataEndToEndCCMIT method should_insert_from_topic_with_complex_name.
@Test
void should_insert_from_topic_with_complex_name() {
taskConfigs.add(makeConnectorProperties("bigintcol=value.bigint", "types", null, "this.is.complex_topic-name"));
PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/this.is.complex_topic-name", null, new GenericRecordImpl().put("bigint", 5725368L), recordType);
runTaskWithRecords(record);
// Verify that the record was inserted properly in the database.
List<Row> results = session.execute("SELECT bigintcol FROM types").all();
assertThat(results.size()).isEqualTo(1);
Row row = results.get(0);
assertThat(row.getLong("bigintcol")).isEqualTo(5725368L);
}
use of com.datastax.oss.sink.pulsar.PulsarRecordImpl in project pulsar-sink by datastax.
the class RawDataEndToEndCCMIT method null_to_unset_true.
@Test
void null_to_unset_true() {
// Make a row with some value for textcol to start with.
session.execute("INSERT INTO types (bigintcol, textcol) VALUES (1234567, 'got here')");
taskConfigs.add(makeConnectorProperties("bigintcol=key, textcol=value.text"));
PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", "1234567", new GenericRecordImpl().put("text", null), recordType);
runTaskWithRecords(record);
// Verify that the record was inserted properly in the database; textcol should be unchanged.
List<Row> results = session.execute("SELECT bigintcol, textcol FROM types").all();
assertThat(results.size()).isEqualTo(1);
Row row = results.get(0);
assertThat(row.getLong("bigintcol")).isEqualTo(1234567L);
assertThat(row.getString("textcol")).isEqualTo("got here");
}
use of com.datastax.oss.sink.pulsar.PulsarRecordImpl in project pulsar-sink by datastax.
the class RawDataEndToEndCCMIT method raw_bigint_value.
@Test
void raw_bigint_value() {
taskConfigs.add(makeConnectorProperties("bigintcol=value.bigint"));
PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", null, new GenericRecordImpl().put("bigint", 5725368L), recordType);
runTaskWithRecords(record);
// Verify that the record was inserted properly in the database.
List<Row> results = session.execute("SELECT bigintcol FROM types").all();
assertThat(results.size()).isEqualTo(1);
Row row = results.get(0);
assertThat(row.getLong("bigintcol")).isEqualTo(5725368L);
}
use of com.datastax.oss.sink.pulsar.PulsarRecordImpl in project pulsar-sink by datastax.
the class StructEndToEndCCMIT method raw_udt_value_and_cherry_pick_from_struct.
@Test
void raw_udt_value_and_cherry_pick_from_struct() {
taskConfigs.add(makeConnectorProperties("bigintcol=key, udtcol=value, intcol=value.udtmem1"));
RecordSchemaBuilder builder = org.apache.pulsar.client.api.schema.SchemaBuilder.record("MyBean");
builder.field("udtmem1").type(SchemaType.INT32);
builder.field("udtmem2").type(SchemaType.STRING);
Schema recordTypeUtd = org.apache.pulsar.client.api.Schema.generic(builder.build(SchemaType.AVRO));
GenericRecordImpl value = new GenericRecordImpl().put("udtmem1", 42).put("udtmem2", "the answer");
PulsarRecordImpl record = new PulsarRecordImpl("persistent://tenant/namespace/mytopic", "98761234", value, recordTypeUtd);
runTaskWithRecords(record);
// Verify that the record was inserted properly in the database.
List<Row> results = session.execute("SELECT bigintcol, udtcol, intcol FROM types").all();
assertThat(results.size()).isEqualTo(1);
Row row = results.get(0);
assertThat(row.getLong("bigintcol")).isEqualTo(98761234L);
UserDefinedType udt = new UserDefinedTypeBuilder(keyspaceName, "myudt").withField("udtmem1", DataTypes.INT).withField("udtmem2", DataTypes.TEXT).build();
udt.attach(session.getContext());
assertThat(row.getUdtValue("udtcol")).isEqualTo(udt.newValue(42, "the answer"));
assertThat(row.getInt("intcol")).isEqualTo(42);
}
Aggregations