Skip to content

Commit

Permalink
fixed issue using float, issue #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Congiu committed Oct 4, 2012
1 parent 89101b7 commit df0d1f4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.openx.data</groupId>
<artifactId>json-serde</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<packaging>jar</packaging>

<name>openx-json-serde</name>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/openx/data/jsonserde/JsonSerDe.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.apache.hadoop.hive.serde2.objectinspector.primitive.StringObjectInspector;
import org.apache.hadoop.hive.serde2.typeinfo.StructTypeInfo;
import org.apache.hadoop.io.Text;
import org.json.JSONArray;
import org.openx.data.jsonserde.json.JSONArray;
import org.openx.data.jsonserde.json.JSONException;
import org.openx.data.jsonserde.json.JSONObject;
import org.openx.data.jsonserde.objectinspector.JsonObjectInspectorFactory;
Expand Down Expand Up @@ -342,7 +342,7 @@ private JSONArray serializeList(Object obj, ListObjectInspector loi) {
Object element = loi.getListElement(obj, i);
try {
ar.put(i, serializeField(element, loi.getListElementObjectInspector() ) );
} catch (org.json.JSONException ex) {
} catch (JSONException ex) {
LOG.warn("Problem serializing array", ex);
throw new RuntimeException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ public static ObjectInspector getJsonObjectInspectorFromTypeInfo(
if (result == null) {
switch (typeInfo.getCategory()) {
case PRIMITIVE: {
PrimitiveTypeInfo pti = (PrimitiveTypeInfo) typeInfo;

result =
getPrimitiveJavaObjectInspector(((PrimitiveTypeInfo) typeInfo).getPrimitiveCategory());
getPrimitiveJavaObjectInspector( pti.getPrimitiveCategory().equals(PrimitiveCategory.FLOAT) ?
PrimitiveCategory.DOUBLE : pti.getPrimitiveCategory() );
break;
}
case LIST: {
Expand Down
2 changes: 1 addition & 1 deletion src/test/scripts/nested_test.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
add jar ../../../target/json-serde-1.0-SNAPSHOT-jar-with-dependencies.jar;
add jar ../../../target/json-serde-1.1.3-jar-with-dependencies.jar;

DROP TABLE json_nested_test;
CREATE TABLE json_nested_test (
Expand Down

0 comments on commit df0d1f4

Please sign in to comment.