use of com.hazelcast.jet.sql.impl.inject.UpsertInjector.FAILING_TOP_LEVEL_INJECTOR in project hazelcast by hazelcast.
the class CompactUpsertTarget method createInjector.
@Override
@SuppressWarnings("checkstyle:ReturnCount")
public UpsertInjector createInjector(@Nullable String path, QueryDataType queryDataType) {
if (path == null) {
return FAILING_TOP_LEVEL_INJECTOR;
}
boolean hasField = schema.hasField(path);
if (!hasField) {
return value -> {
throw QueryException.error("Unable to inject a non-null value to \"" + path + "\"");
};
}
FieldKind kind = schema.getField(path).getKind();
switch(kind) {
case STRING:
return value -> builder.setString(path, (String) value);
case NULLABLE_BOOLEAN:
return value -> builder.setNullableBoolean(path, (Boolean) value);
case NULLABLE_INT8:
return value -> builder.setNullableInt8(path, (Byte) value);
case NULLABLE_INT16:
return value -> builder.setNullableInt16(path, (Short) value);
case NULLABLE_INT32:
return value -> builder.setNullableInt32(path, (Integer) value);
case NULLABLE_INT64:
return value -> builder.setNullableInt64(path, (Long) value);
case DECIMAL:
return value -> builder.setDecimal(path, (BigDecimal) value);
case NULLABLE_FLOAT32:
return value -> builder.setNullableFloat32(path, (Float) value);
case NULLABLE_FLOAT64:
return value -> builder.setNullableFloat64(path, (Double) value);
case TIME:
return value -> builder.setTime(path, (LocalTime) value);
case DATE:
return value -> builder.setDate(path, (LocalDate) value);
case TIMESTAMP:
return value -> builder.setTimestamp(path, (LocalDateTime) value);
case TIMESTAMP_WITH_TIMEZONE:
return value -> builder.setTimestampWithTimezone(path, (OffsetDateTime) value);
default:
throw QueryException.error(kind + " kind is not supported in SQL with Compact format!");
}
}
Aggregations