Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonSerde - ClassCastException #25

Closed
randallwhitman opened this issue Jun 6, 2013 · 2 comments
Closed

JsonSerde - ClassCastException #25

randallwhitman opened this issue Jun 6, 2013 · 2 comments

Comments

@randallwhitman
Copy link
Contributor

Got ClassCastException with LazyString in JsonSerde with queries like the following:

create external table trips_by_origin_cell(leftlon double, botlat double, rightlon double, toplat double, totnum int, samedest int, pct double, destlhs double, destbot double, destrhs double, desttop double)
row format delimited fields terminated by '\t'
location '/user/rwhitman/out-trips-by-origin-cell';
create external table trip_origin_json  (totnum int, samedest int, pct double, destlhs double, destbot double, destrhs double, desttop double, shape binary)
row format serde 'com.esri.hadoop.hive.serde.JsonSerde'
stored as inputformat 'com.esri.json.hadoop.UnenclosedJsonInputFormat'
outputformat 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
location '/user/rwhitman/trip-origin-json';
insert overwrite table trip_origin_json select totnum, samedest, pct, destlhs, destbot, destrhs, desttop,
  ST_Polygon(leftlon,botlat, rightlon,botlat, rightlon,toplat, leftlon,toplat) from trips_by_origin_cell;

More detail of the exception:

Caused by: java.lang.ClassCastException: org.apache.hadoop.hive.serde2.lazy.LazyString cannot be cast to org.apache.hadoop.io.Writable
        at com.esri.hadoop.hive.serde.JsonSerde.serialize(Unknown Source)

Candidate patch:

                Writable writable;
                //   = (Writable)fieldWritables.get(i);  // usually Text; exception on LazyString
                Object tmpObj = fieldWritables.get(i);  // usually Text; exception on LazyString
                if (tmpObj instanceof LazyPrimitive) {
                    writable = ((LazyPrimitive)(tmpObj)).getWritableObject();
                } else {
                    writable = (Writable)tmpObj;
                }
                //Float dummy = (Float)tmpObj;  // temporary test

                jsonGen.writeObjectField(columnNames.get(i), writable.toString());
@randallwhitman
Copy link
Contributor Author

Patch has been checked in to branch jsonserde.

@randallwhitman
Copy link
Contributor Author

Branch jsonserde has been merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant