public static Object toAvro(Object item, Field field) { if (item == null && !nullOk(field.schema())) { try { // this will fail if there is no default value return ReflectData.get().getDefaultValue(field); } catch (AvroRuntimeException e) { return ERROR; } } Object result = toAvro(item, field.schema()); return result; }
public static Object toAvro(Object item, Field field) { if (item == null && !nullOk(field.schema())) { try { // this will fail if there is no default value return ReflectData.get().getDefaultValue(field); } catch (AvroRuntimeException e) { return ERROR; } } Object result = toAvro(item, field.schema()); return result; }
private static Object makeValue(String string, Schema.Field field) { Object value = makeValue(string, field.schema()); if (value != null || nullOk(field.schema())) { return value; } else { // this will fail if there is no default value return ReflectData.get().getDefaultValue(field); } }
private Object toAvro(Object item, Field field) { if (item == null && !nullOk(field.schema())) { try { // this will fail if there is no default value return ReflectData.get().getDefaultValue(field); } catch (AvroRuntimeException e) { return ERROR; } } Object result = toAvro(item, field.schema()); return result; }
private static Object makeValue(@Nullable String string, Schema.Field field) { try { Object value = makeValue(string, field.schema()); if (value != null || SchemaUtil.nullOk(field.schema())) { return value; } else { // this will fail if there is no default value return ReflectData.get().getDefaultValue(field); } } catch (DatasetRecordException e) { // add the field name to the error message throw new DatasetRecordException(String.format( "Cannot convert field %s", field.name()), e); } catch (NumberFormatException e) { throw new DatasetRecordException(String.format( "Field %s: value not a %s: '%s'", field.name(), field.schema(), string), e); } catch (AvroRuntimeException e) { throw new DatasetRecordException(String.format( "Field %s: cannot make %s value: '%s'", field.name(), field.schema(), string), e); } }
} else if (list.size() == 0) { try { // this will fail if there is no default value avroResult = ReflectData.get().getDefaultValue(field); } catch (AvroRuntimeException e) { avroResult = AvroConversions.ERROR;
} else if (list.size() == 0) { try { // this will fail if there is no default value avroResult = ReflectData.get().getDefaultValue(field); } catch (AvroRuntimeException e) { avroResult = AvroConversions.ERROR;
} else if (list.size() == 0) { try { // this will fail if there is no default value avroResult = ReflectData.get().getDefaultValue(field); } catch (AvroRuntimeException e) { avroResult = ERROR;