Throw PrestoException instead IllegalArgumentException from JsonRowDecoderFactory
@@ -17,6 +17,7 @@ import com.facebook.presto.decoder.DecoderColumnHandle;
import com.facebook.presto.decoder.FieldDecoder;
import com.facebook.presto.decoder.RowDecoder;
import com.facebook.presto.decoder.RowDecoderFactory;
+import com.facebook.presto.spi.PrestoException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.airlift.slice.Slice;
@@ -27,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import static com.facebook.presto.decoder.FieldDecoder.DEFAULT_FIELD_DECODER_NAME;
+import static com.facebook.presto.spi.StandardErrorCode.GENERIC_USER_ERROR;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static java.lang.String.format;
@@ -59,6 +61,7 @@ public class JsonRowDecoderFactory
private FieldDecoder<JsonNode> chooseFieldDecoder(DecoderColumnHandle column)
{
+ try {
checkArgument(!column.isInternal(), "unexpected internal column '%s'", column.getName());
if (column.getDataFormat() == null || column.getDataFormat().equals(DEFAULT_FIELD_DECODER_NAME)) {
return new JsonFieldDecoder();
@@ -80,4 +83,8 @@ public class JsonRowDecoderFactory
}
throw new IllegalArgumentException(format("unknown data format '%s' for column '%s'", column.getDataFormat(), column.getName()));
}
+ catch (IllegalArgumentException e) {
+ throw new PrestoException(GENERIC_USER_ERROR, e);
+ }
+ }
}
