Github user hyunsik commented on a diff in the pull request:
https://github.com/apache/tajo/pull/652#discussion_r38281202
--- Diff: tajo-common/src/main/java/org/apache/tajo/datum/DatumFactory.java
---
@@ -114,45 +114,42 @@ public static Datum createFromString(DataType
dataType, String value) {
public static Datum createFromBytes(DataType dataType, byte[] bytes) {
switch (dataType.getType()) {
- case BOOLEAN:
- return createBool(bytes[0]);
- case INT2:
- return createInt2(NumberUtil.toShort(bytes));
- case INT4:
- return createInt4(NumberUtil.toInt(bytes));
- case INT8:
- return createInt8(NumberUtil.toLong(bytes));
- case FLOAT4:
- return createFloat4(NumberUtil.toFloat(bytes));
- case FLOAT8:
- return createFloat8(NumberUtil.toDouble(bytes));
- case CHAR:
- return createChar(bytes);
- case TEXT:
- return createText(bytes);
- case DATE:
- return new DateDatum(NumberUtil.toInt(bytes));
- case TIME:
- return new TimeDatum(NumberUtil.toLong(bytes));
- case TIMESTAMP:
- return new TimestampDatum(NumberUtil.toLong(bytes));
- case BIT:
- return createBit(bytes[0]);
- case BLOB:
- return createBlob(bytes);
- case INET4:
- return createInet4(bytes);
- case PROTOBUF:
- ProtobufDatumFactory factory = ProtobufDatumFactory.get(dataType);
- Message.Builder builder = factory.newBuilder();
- try {
- builder.mergeFrom(bytes);
- return factory.createDatum(builder.build());
- } catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- default:
+ case BOOLEAN:
+ return createBool(bytes[0]);
+ case INT2:
+ return createInt2(NumberUtil.toShort(bytes));
+ case INT4:
+ return createInt4(NumberUtil.toInt(bytes));
+ case INT8:
+ return createInt8(NumberUtil.toLong(bytes));
+ case FLOAT4:
+ return createFloat4(NumberUtil.toFloat(bytes));
+ case FLOAT8:
+ return createFloat8(NumberUtil.toDouble(bytes));
+ case CHAR:
+ return createChar(bytes);
+ case TEXT:
+ return createText(bytes);
+ case DATE:
+ return new DateDatum(NumberUtil.toInt(bytes));
+ case TIME:
+ return new TimeDatum(NumberUtil.toLong(bytes));
+ case TIMESTAMP:
+ return new TimestampDatum(NumberUtil.toLong(bytes));
+ case BIT:
+ return createBit(bytes[0]);
+ case BLOB:
+ return createBlob(bytes);
+ case INET4:
+ return createInet4(bytes);
+ case PROTOBUF:
+ try {
+ return ProtobufDatumFactory.createDatum(dataType, bytes);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ default:
throw new UnsupportedOperationException(dataType.toString());
--- End diff --
It should be UndefinedOperatorException wrapped by TajoRuntimeException.
You need to take a look at ErrorMessage.java in order to know how it makes the
error message for UndefinedOperatorException.
I also think that UnsupportedException is also proper here.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---