use of com.datastax.oss.dsbulk.tests.ccm.CCMCluster.Type in project dsbulk by datastax.
the class CSVConnectorEndToEndCCMIT method unload_load_preserving_ttl_and_timestamp.
@SuppressWarnings("unused")
Stream<Arguments> unload_load_preserving_ttl_and_timestamp() throws UnknownHostException {
session.execute("CREATE TYPE IF NOT EXISTS preserve_ttl_timestamp_udt (f1 int, f2 text)");
TupleType tupleType = DataTypes.tupleOf(DataTypes.INT, DataTypes.TEXT);
UserDefinedType udt = session.getKeyspace().flatMap(ks -> session.getMetadata().getKeyspace(ks)).flatMap(ks -> ks.getUserDefinedType("preserve_ttl_timestamp_udt")).orElseThrow(IllegalStateException::new);
return Stream.of(Arguments.of(DataTypes.ASCII, "abc", "def", "abc", "def"), Arguments.of(DataTypes.BIGINT, 123L, 456L, "123", "456"), Arguments.of(DataTypes.BLOB, ByteBuffer.wrap(new byte[] { 1, 2 }), ByteBuffer.wrap(new byte[] { 3, 4 }), "AQI=", "AwQ="), Arguments.of(DataTypes.BOOLEAN, true, false, "1", "0"), // Arguments.of(DataTypes.COUNTER, v1, v2, csv1, csv2),
Arguments.of(DataTypes.DECIMAL, new BigDecimal("12.34"), new BigDecimal("56.78"), "12.34", "56.78"), Arguments.of(DataTypes.DOUBLE, 12.34, 56.78, "12.34", "56.78"), Arguments.of(DataTypes.FLOAT, 12.34f, 56.78f, "12.34", "56.78"), Arguments.of(DataTypes.INT, 12, 34, "12", "34"), Arguments.of(DataTypes.TIMESTAMP, Instant.parse("2021-01-11T11:01:01Z"), Instant.parse("2022-02-22T22:02:02Z"), "2021-01-11T11:01:01Z", "2022-02-22T22:02:02Z"), Arguments.of(DataTypes.UUID, Uuids.startOf(123456789), Uuids.endOf(123456789), Uuids.startOf(123456789).toString(), Uuids.endOf(123456789).toString()), Arguments.of(DataTypes.VARINT, new BigInteger("1234"), new BigInteger("5678"), "1234", "5678"), Arguments.of(DataTypes.TIMEUUID, Uuids.startOf(123456789), Uuids.endOf(123456789), Uuids.startOf(123456789).toString(), Uuids.endOf(123456789).toString()), Arguments.of(DataTypes.INET, InetAddress.getByAddress(new byte[] { 1, 2, 3, 4 }), InetAddress.getByAddress(new byte[] { 5, 6, 7, 8 }), "1.2.3.4", "5.6.7.8"), Arguments.of(DataTypes.DATE, LocalDate.of(2021, 1, 11), LocalDate.of(2022, 2, 22), "2021-01-11", "2022-02-22"), Arguments.of(DataTypes.TEXT, "abc", "def", "abc", "def"), Arguments.of(DataTypes.TIME, LocalTime.of(1, 2, 3), LocalTime.of(4, 5, 6), "01:02:03", "04:05:06"), Arguments.of(DataTypes.SMALLINT, (short) 12, (short) 34, "12", "34"), Arguments.of(DataTypes.TINYINT, (byte) 12, (byte) 34, "12", "34"), Arguments.of(DataTypes.DURATION, CqlDuration.newInstance(1, 2, 34), CqlDuration.newInstance(5, 6, 78), "1mo2d34ns", "5mo6d78ns"), Arguments.of(tupleType, tupleType.newValue(12, "ab"), tupleType.newValue(34, "cd"), "[12,\\\"ab\\\"]", "[34,\\\"cd\\\"]"), Arguments.of(// only frozen UDTs work
udt.copy(true), udt.newValue(12, "ab"), udt.newValue(34, "cd"), "{\\\"f1\\\":12,\\\"f2\\\":\\\"ab\\\"}", "{\\\"f1\\\":34,\\\"f2\\\":\\\"cd\\\"}"));
}
use of com.datastax.oss.dsbulk.tests.ccm.CCMCluster.Type in project dsbulk by datastax.
the class CSVConnectorEndToEndCCMIT method unload_load_preserving_ttl_and_timestamp_unsupported_types.
@SuppressWarnings("unused")
Stream<Arguments> unload_load_preserving_ttl_and_timestamp_unsupported_types() {
session.execute("CREATE TYPE IF NOT EXISTS preserve_ttl_timestamp_udt (f1 int, f2 text)");
UserDefinedType udt = session.getKeyspace().flatMap(ks -> session.getMetadata().getKeyspace(ks)).flatMap(ks -> ks.getUserDefinedType("preserve_ttl_timestamp_udt")).orElseThrow(IllegalStateException::new);
return Stream.of(Arguments.of(DataTypes.listOf(DataTypes.INT), ImmutableList.of(12, 34)), Arguments.of(DataTypes.setOf(DataTypes.INT), ImmutableSet.of(12, 34)), Arguments.of(DataTypes.mapOf(DataTypes.INT, DataTypes.TEXT), ImmutableMap.of(12, "ab", 34, "cd")), Arguments.of(DataTypes.frozenListOf(DataTypes.INT), ImmutableList.of(12, 34)), Arguments.of(DataTypes.frozenSetOf(DataTypes.INT), ImmutableSet.of(12, 34)), Arguments.of(DataTypes.frozenMapOf(DataTypes.INT, DataTypes.TEXT), ImmutableMap.of(12, "ab", 34, "cd")), // non-frozen UDT
Arguments.of(udt, udt.newValue(12, "ab")));
}
Aggregations