From 6f32c58f8b6175226f2c75791214e92b9b41e71c Mon Sep 17 00:00:00 2001 From: xuzifu666 <1206332514@qq.com> Date: Mon, 8 Jul 2024 17:24:57 +0800 Subject: [PATCH] [core] Add type and classname in TypeHandle condition when throw IllegalArgumentException (#3698) --- .../apache/paimon/data/BinaryArrayWriter.java | 7 ++++++- .../org/apache/paimon/data/BinaryWriter.java | 6 +++++- .../org/apache/paimon/data/InternalArray.java | 7 ++++++- .../org/apache/paimon/data/InternalRow.java | 6 +++++- .../serializer/RowCompactedSerializer.java | 14 ++++++++++++-- .../compact/aggregate/FieldBoolAndAgg.java | 6 +++++- .../compact/aggregate/FieldBoolOrAgg.java | 6 +++++- .../compact/aggregate/FieldCountAgg.java | 12 ++++++++++-- .../compact/aggregate/FieldListaggAgg.java | 6 +++++- .../compact/aggregate/FieldProductAgg.java | 12 ++++++++++-- .../compact/aggregate/FieldSumAgg.java | 18 +++++++++++++++--- 11 files changed, 84 insertions(+), 16 deletions(-) diff --git a/paimon-common/src/main/java/org/apache/paimon/data/BinaryArrayWriter.java b/paimon-common/src/main/java/org/apache/paimon/data/BinaryArrayWriter.java index 56333abc285c..58f98dc18933 100644 --- a/paimon-common/src/main/java/org/apache/paimon/data/BinaryArrayWriter.java +++ b/paimon-common/src/main/java/org/apache/paimon/data/BinaryArrayWriter.java @@ -253,7 +253,12 @@ public static NullSetter createNullSetter(DataType elementType) { case DOUBLE: return BinaryArrayWriter::setNullDouble; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + elementType.getTypeRoot().toString(), + BinaryArrayWriter.class.getName()); + throw new IllegalArgumentException(msg); } } diff --git a/paimon-common/src/main/java/org/apache/paimon/data/BinaryWriter.java b/paimon-common/src/main/java/org/apache/paimon/data/BinaryWriter.java index d17d51e490cf..3fb27cc4ff1e 100644 --- a/paimon-common/src/main/java/org/apache/paimon/data/BinaryWriter.java +++ b/paimon-common/src/main/java/org/apache/paimon/data/BinaryWriter.java @@ -209,7 +209,11 @@ static ValueSetter createValueSetter(DataType elementType, Serializer seriali writer.writeRow( pos, (InternalRow) value, (InternalRowSerializer) rowSerializer); default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + elementType.getTypeRoot().toString(), BinaryArray.class.getName()); + throw new IllegalArgumentException(msg); } } diff --git a/paimon-common/src/main/java/org/apache/paimon/data/InternalArray.java b/paimon-common/src/main/java/org/apache/paimon/data/InternalArray.java index f8b3257a41b5..ce552fa04bc6 100644 --- a/paimon-common/src/main/java/org/apache/paimon/data/InternalArray.java +++ b/paimon-common/src/main/java/org/apache/paimon/data/InternalArray.java @@ -131,7 +131,12 @@ static ElementGetter createElementGetter(DataType elementType) { elementGetter = (array, pos) -> array.getRow(pos, rowFieldCount); break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + elementType.getTypeRoot().toString(), + InternalArray.class.getName()); + throw new IllegalArgumentException(msg); } if (!elementType.isNullable()) { return elementGetter; diff --git a/paimon-common/src/main/java/org/apache/paimon/data/InternalRow.java b/paimon-common/src/main/java/org/apache/paimon/data/InternalRow.java index ce4afc2a3303..4c4f3f978d56 100644 --- a/paimon-common/src/main/java/org/apache/paimon/data/InternalRow.java +++ b/paimon-common/src/main/java/org/apache/paimon/data/InternalRow.java @@ -222,7 +222,11 @@ static FieldGetter createFieldGetter(DataType fieldType, int fieldPos) { fieldGetter = row -> row.getRow(fieldPos, rowFieldCount); break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), InternalRow.class.getName()); + throw new IllegalArgumentException(msg); } if (!fieldType.isNullable()) { return fieldGetter; diff --git a/paimon-common/src/main/java/org/apache/paimon/data/serializer/RowCompactedSerializer.java b/paimon-common/src/main/java/org/apache/paimon/data/serializer/RowCompactedSerializer.java index 72678c364883..d39dc8c95a7c 100644 --- a/paimon-common/src/main/java/org/apache/paimon/data/serializer/RowCompactedSerializer.java +++ b/paimon-common/src/main/java/org/apache/paimon/data/serializer/RowCompactedSerializer.java @@ -230,7 +230,12 @@ private static FieldWriter createFieldWriter(DataType fieldType) { (writer, pos, value) -> writer.writeRow((InternalRow) value, rowSerializer); break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), + RowCompactedSerializer.class.getName()); + throw new IllegalArgumentException(msg); } if (!fieldType.isNullable()) { @@ -302,7 +307,12 @@ private static FieldReader createFieldReader(DataType fieldType) { fieldReader = (reader, pos) -> reader.readRow(serializer); break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), + RowCompactedSerializer.class.getName()); + throw new IllegalArgumentException(msg); } if (!fieldType.isNullable()) { return fieldReader; diff --git a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldBoolAndAgg.java b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldBoolAndAgg.java index b523654f7144..91bdd053be6b 100644 --- a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldBoolAndAgg.java +++ b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldBoolAndAgg.java @@ -46,7 +46,11 @@ public Object agg(Object accumulator, Object inputField) { boolAnd = (boolean) accumulator && (boolean) inputField; break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return boolAnd; diff --git a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldBoolOrAgg.java b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldBoolOrAgg.java index 1e2709d195ed..b3bee58a84f3 100644 --- a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldBoolOrAgg.java +++ b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldBoolOrAgg.java @@ -46,7 +46,11 @@ public Object agg(Object accumulator, Object inputField) { boolOr = (boolean) accumulator || (boolean) inputField; break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return boolOr; diff --git a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldCountAgg.java b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldCountAgg.java index 87d4bacf3df4..6a8d089067e9 100644 --- a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldCountAgg.java +++ b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldCountAgg.java @@ -55,7 +55,11 @@ public Object agg(Object accumulator, Object inputField) { count = (long) accumulator + 1L; break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return count; @@ -82,7 +86,11 @@ public Object retract(Object accumulator, Object inputField) { count = (long) accumulator - 1L; break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return count; diff --git a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldListaggAgg.java b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldListaggAgg.java index 951951ab610f..a4937a929307 100644 --- a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldListaggAgg.java +++ b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldListaggAgg.java @@ -57,7 +57,11 @@ public Object agg(Object accumulator, Object inputField) { mergeFieldSD, BinaryString.fromString(DELIMITER), inFieldSD); break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return concatenate; diff --git a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldProductAgg.java b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldProductAgg.java index 8427df476ac5..d1b9172bc01a 100644 --- a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldProductAgg.java +++ b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldProductAgg.java @@ -79,7 +79,11 @@ public Object agg(Object accumulator, Object inputField) { product = (double) accumulator * (double) inputField; break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return product; @@ -124,7 +128,11 @@ public Object retract(Object accumulator, Object inputField) { product = (double) accumulator / (double) inputField; break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return product; diff --git a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldSumAgg.java b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldSumAgg.java index 458542cf892a..ac8b1c4a2e96 100644 --- a/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldSumAgg.java +++ b/paimon-core/src/main/java/org/apache/paimon/mergetree/compact/aggregate/FieldSumAgg.java @@ -78,7 +78,11 @@ public Object agg(Object accumulator, Object inputField) { sum = (double) accumulator + (double) inputField; break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return sum; @@ -125,7 +129,11 @@ public Object retract(Object accumulator, Object inputField) { sum = (double) accumulator - (double) inputField; break; default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } return sum; @@ -153,7 +161,11 @@ private Object negative(Object value) { case DOUBLE: return -((double) value); default: - throw new IllegalArgumentException(); + String msg = + String.format( + "type %s not support in %s", + fieldType.getTypeRoot().toString(), this.getClass().getName()); + throw new IllegalArgumentException(msg); } } }