[MINOR] Fix typo and others (#2164)
* remove HoodieSerializationException that will never be throw * remove unused method, make HoodieException more readable * fix typo
This commit is contained in:
@@ -23,7 +23,7 @@ import org.apache.hudi.common.util.StringUtils;
|
|||||||
import org.apache.hudi.common.util.collection.Pair;
|
import org.apache.hudi.common.util.collection.Pair;
|
||||||
import org.apache.hudi.exception.HoodieException;
|
import org.apache.hudi.exception.HoodieException;
|
||||||
import org.apache.hudi.exception.HoodieIOException;
|
import org.apache.hudi.exception.HoodieIOException;
|
||||||
import org.apache.hudi.exception.SchemaCompatabilityException;
|
import org.apache.hudi.exception.SchemaCompatibilityException;
|
||||||
|
|
||||||
import org.apache.avro.Conversions.DecimalConversion;
|
import org.apache.avro.Conversions.DecimalConversion;
|
||||||
import org.apache.avro.JsonProperties;
|
import org.apache.avro.JsonProperties;
|
||||||
@@ -321,7 +321,7 @@ public class HoodieAvroUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!GenericData.get().validate(newSchema, newRecord)) {
|
if (!GenericData.get().validate(newSchema, newRecord)) {
|
||||||
throw new SchemaCompatabilityException(
|
throw new SchemaCompatibilityException(
|
||||||
"Unable to validate the rewritten record " + record + " against schema " + newSchema);
|
"Unable to validate the rewritten record " + record + " against schema " + newSchema);
|
||||||
}
|
}
|
||||||
return newRecord;
|
return newRecord;
|
||||||
|
|||||||
@@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
package org.apache.hudi.common.util;
|
package org.apache.hudi.common.util;
|
||||||
|
|
||||||
import org.apache.hudi.exception.HoodieSerializationException;
|
|
||||||
|
|
||||||
import com.esotericsoftware.kryo.Kryo;
|
import com.esotericsoftware.kryo.Kryo;
|
||||||
import com.esotericsoftware.kryo.io.Input;
|
import com.esotericsoftware.kryo.io.Input;
|
||||||
import com.esotericsoftware.kryo.io.Output;
|
import com.esotericsoftware.kryo.io.Output;
|
||||||
@@ -72,7 +70,6 @@ public class SerializationUtils {
|
|||||||
* @param objectData the serialized object, must not be null
|
* @param objectData the serialized object, must not be null
|
||||||
* @return the deserialized object
|
* @return the deserialized object
|
||||||
* @throws IllegalArgumentException if {@code objectData} is {@code null}
|
* @throws IllegalArgumentException if {@code objectData} is {@code null}
|
||||||
* @throws HoodieSerializationException (runtime) if the serialization fails
|
|
||||||
*/
|
*/
|
||||||
public static <T> T deserialize(final byte[] objectData) {
|
public static <T> T deserialize(final byte[] objectData) {
|
||||||
if (objectData == null) {
|
if (objectData == null) {
|
||||||
|
|||||||
@@ -47,12 +47,4 @@ public class HoodieException extends RuntimeException implements Serializable {
|
|||||||
super(t);
|
super(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String format(String message, Object... args) {
|
|
||||||
String[] argStrings = new String[args.length];
|
|
||||||
for (int i = 0; i < args.length; i += 1) {
|
|
||||||
argStrings[i] = String.valueOf(args[i]);
|
|
||||||
}
|
|
||||||
return String.format(String.valueOf(message), (Object[]) argStrings);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,17 +21,17 @@ package org.apache.hudi.exception;
|
|||||||
/**
|
/**
|
||||||
* An exception thrown when schema has compatibility problems.
|
* An exception thrown when schema has compatibility problems.
|
||||||
*/
|
*/
|
||||||
public class SchemaCompatabilityException extends HoodieException {
|
public class SchemaCompatibilityException extends HoodieException {
|
||||||
|
|
||||||
public SchemaCompatabilityException(String message) {
|
public SchemaCompatibilityException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SchemaCompatabilityException(String message, Throwable t) {
|
public SchemaCompatibilityException(String message, Throwable t) {
|
||||||
super(message, t);
|
super(message, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SchemaCompatabilityException(Throwable t) {
|
public SchemaCompatibilityException(Throwable t) {
|
||||||
super(t);
|
super(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ package org.apache.hudi.avro;
|
|||||||
|
|
||||||
import org.apache.avro.JsonProperties;
|
import org.apache.avro.JsonProperties;
|
||||||
import org.apache.hudi.common.model.HoodieRecord;
|
import org.apache.hudi.common.model.HoodieRecord;
|
||||||
import org.apache.hudi.exception.SchemaCompatabilityException;
|
import org.apache.hudi.exception.SchemaCompatibilityException;
|
||||||
|
|
||||||
import org.apache.avro.Schema;
|
import org.apache.avro.Schema;
|
||||||
import org.apache.avro.generic.GenericData;
|
import org.apache.avro.generic.GenericData;
|
||||||
@@ -147,7 +147,7 @@ public class TestHoodieAvroUtils {
|
|||||||
rec.put("non_pii_col", "val1");
|
rec.put("non_pii_col", "val1");
|
||||||
rec.put("pii_col", "val2");
|
rec.put("pii_col", "val2");
|
||||||
rec.put("timestamp", 3.5);
|
rec.put("timestamp", 3.5);
|
||||||
assertThrows(SchemaCompatabilityException.class, () -> HoodieAvroUtils.rewriteRecord(rec, new Schema.Parser().parse(SCHEMA_WITH_NON_NULLABLE_FIELD)));
|
assertThrows(SchemaCompatibilityException.class, () -> HoodieAvroUtils.rewriteRecord(rec, new Schema.Parser().parse(SCHEMA_WITH_NON_NULLABLE_FIELD)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user