/** * Returns a {@link SchemaBuilder} for a {@link MicroTimestamp}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>microseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link NanoTime}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>nanoseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link Timestamp}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>milliseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link MicroTime}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>microseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link NanoTimestamp}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>nanoseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
.field("id", SchemaBuilder.int64().build()) .build();
case Types.BIGINT: return SchemaBuilder.int64();
return SchemaBuilder.int64(); case PgOid.JSONB_OID: case PgOid.JSON:
/** * Returns a SchemaBuilder for a Timestamp. By returning a SchemaBuilder you can override additional schema settings such * as required/optional, default value, and documentation. * @return a SchemaBuilder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(LOGICAL_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link MicroTimestamp}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>microseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link NanoTime}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>nanoseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link Timestamp}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>milliseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link MicroTime}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>microseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
/** * Returns a {@link SchemaBuilder} for a {@link NanoTimestamp}. The resulting schema will describe a field * with the {@value #SCHEMA_NAME} as the {@link Schema#name() name} and {@link SchemaBuilder#int64() INT64} for the literal * type storing the number of <em>nanoseconds</em> past midnight. * <p> * You can use the resulting SchemaBuilder to set or override additional schema settings such as required/optional, default * value, and documentation. * * @return the schema builder */ public static SchemaBuilder builder() { return SchemaBuilder.int64() .name(SCHEMA_NAME) .version(1); }
static Schema schema(Class<?> logClass, String logFieldName) { final SchemaBuilder builder; if (LocalDate.class.equals(logClass)) { builder = Date.builder(); } else if (LocalTime.class.equals(logClass)) { builder = Time.builder(); } else if (Integer.class.equals(logClass)) { builder = SchemaBuilder.int32(); } else if (Long.class.equals(logClass)) { builder = SchemaBuilder.int64(); } else if (String.class.equals(logClass)) { builder = SchemaBuilder.string(); } else { throw new UnsupportedOperationException( String.format("%s is not a supported type.", logClass.getName()) ); } builder.optional(); return builder.build(); }
public static Schema buildSchema(Schema valueSchema) { SchemaBuilder ret = SchemaBuilder.struct() .field(OpcRecordFields.TAG_NAME, SchemaBuilder.string()) .field(OpcRecordFields.TAG_ID, SchemaBuilder.string()) .field(OpcRecordFields.TIMESTAMP, SchemaBuilder.int64()) .field(OpcRecordFields.QUALITY, SchemaBuilder.string()) .field(OpcRecordFields.UPDATE_PERIOD, SchemaBuilder.int64().optional()) .field(OpcRecordFields.TAG_GROUP, SchemaBuilder.string().optional()) .field(OpcRecordFields.OPC_SERVER_DOMAIN, SchemaBuilder.string().optional()) .field(OpcRecordFields.OPC_SERVER_HOST, SchemaBuilder.string()) .field(OpcRecordFields.ERROR_CODE, SchemaBuilder.int64().optional()) .field(OpcRecordFields.ERROR_REASON, SchemaBuilder.string().optional()); if (valueSchema != null) { ret = ret.field(OpcRecordFields.VALUE, valueSchema); } return ret; }
private SchemaBuilder convertFieldType(Schema.Type type) { switch (type) { case INT8: return SchemaBuilder.int8(); case INT16: return SchemaBuilder.int16(); case INT32: return SchemaBuilder.int32(); case INT64: return SchemaBuilder.int64(); case FLOAT32: return SchemaBuilder.float32(); case FLOAT64: return SchemaBuilder.float64(); case BOOLEAN: return SchemaBuilder.bool(); case STRING: return SchemaBuilder.string(); default: throw new DataException("Unexpected type in Cast transformation: " + type); } }
@TestFactory @DisplayName("tests for int64 field conversions") public List<DynamicTest> testInt64FieldConverter() { SinkFieldConverter converter = new Int64FieldConverter(); List<DynamicTest> tests = new ArrayList<>(); new ArrayList<>(Arrays.asList(Long.MIN_VALUE,0L,Long.MAX_VALUE)).forEach( el -> tests.add(dynamicTest("conversion with " + converter.getClass().getSimpleName() + " for "+el, () -> assertEquals((long)el, ((BsonInt64)converter.toBson(el)).getValue()) )) ); tests.add(dynamicTest("optional type conversions", () -> { Schema valueOptionalDefault = SchemaBuilder.int64().optional().defaultValue(0L); assertAll("checks", () -> assertThrows(DataException.class, () -> converter.toBson(null, Schema.INT64_SCHEMA)), () -> assertEquals(new BsonNull(), converter.toBson(null, Schema.OPTIONAL_INT64_SCHEMA)), () -> assertEquals((long)valueOptionalDefault.defaultValue(), ((BsonInt64)converter.toBson(null, valueOptionalDefault)).getValue()) ); })); return tests; }
@Test(expected = ConversionConnectException.class) public void testBadDate() { final String fieldName = "Date"; Schema kafkaConnectTestSchema = SchemaBuilder .struct() .field(fieldName, SchemaBuilder.int64().name(Date.LOGICAL_NAME)) .build(); new BigQuerySchemaConverter(false).convertSchema(kafkaConnectTestSchema); }