Return-Path: X-Original-To: apmail-crunch-user-archive@www.apache.org Delivered-To: apmail-crunch-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ADD7C18548 for ; Thu, 6 Aug 2015 15:51:45 +0000 (UTC) Received: (qmail 66210 invoked by uid 500); 6 Aug 2015 15:51:45 -0000 Delivered-To: apmail-crunch-user-archive@crunch.apache.org Received: (qmail 66170 invoked by uid 500); 6 Aug 2015 15:51:45 -0000 Mailing-List: contact user-help@crunch.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@crunch.apache.org Delivered-To: mailing list user@crunch.apache.org Received: (qmail 66157 invoked by uid 99); 6 Aug 2015 15:51:45 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2015 15:51:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1582CC027D for ; Thu, 6 Aug 2015 15:51:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.041 X-Spam-Level: ** X-Spam-Status: No, score=2.041 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H2=-1.108, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id H25n_GMyS7IF for ; Thu, 6 Aug 2015 15:51:43 +0000 (UTC) Received: from mail-io0-f169.google.com (mail-io0-f169.google.com [209.85.223.169]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 4C70420F17 for ; Thu, 6 Aug 2015 15:51:43 +0000 (UTC) Received: by iodd187 with SMTP id d187so85315140iod.2 for ; Thu, 06 Aug 2015 08:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=fTIzeBCVcZciBiK1ttZiutVbuoxAur5d0R0nUXnNadQ=; b=HBW3iASgpCnKUy00DSnlEwyQHYPwfKFlD1NYC5vjRozXhIQyXfnGoxpnX+M/bU2tqd d5PjKb2RCTcHkmpPjm5Tp6M4eyyU2PymYFHGpsf++oblkQAaBIC8l05PUVzqbJk5WBlX yjJhTbunIeSYKT+thfCmLugGkPn4HGKr43AJ33Vb98o47Ugib85SfwnX7z1QJkPq8I/R ebwZ9GRVH1V0zL0BQksaRXd7Z0n0po1QGJXwXV1SsIPt/6fAuq/fvYK0q0RinPpeHYZA y8LlmlJE/Y6DGMvqq/BCPlM+KiW6++nyvFtAKxzLDhEiJJGUTbxT5CqnoJIZKQWJ4wtl x+Mw== X-Received: by 10.107.132.19 with SMTP id g19mr3021985iod.3.1438876256971; Thu, 06 Aug 2015 08:50:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Ortiz Date: Thu, 06 Aug 2015 15:50:47 +0000 Message-ID: Subject: Re: ClassCastException: org.apache.avro.util.Utf8 cannot be cast to org.apache.avro.generic.IndexedRecord To: Crunch users Content-Type: multipart/alternative; boundary=001a113eca102c3046051ca67c4d --001a113eca102c3046051ca67c4d Content-Type: text/plain; charset=UTF-8 Believe the output type for a TextFileOutput has to be a String, not a Table containing a String key with an Avro Map. With the complex object I think you have to write it out as an AvroFile. On Thu, Aug 6, 2015 at 11:47 AM Hrishikesh P wrote: > I'm trying to write a PTable> to a > TextFileSourceTarget but I am running into a ClassCastException. > > {code} > PTable> table = ...; > > table.write(new > TextFileSourceTarget<>(Path.mergePaths(fs.getHomeDirectory(), path), > Avros.tableOf(Avros.strings(), Avros.maps(Avros.strings())))); > {code} > > The exception is: > > WARN [main] org.apache.hadoop.mapred.YarnChild: Exception running child : java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cast to org.apache.avro.generic.IndexedRecord > at org.apache.crunch.types.avro.AvroTableType$IndexedRecordToPair.map(AvroTableType.java:88) > at org.apache.crunch.MapFn.process(MapFn.java:34) > at org.apache.crunch.impl.mr.run.RTNode.process(RTNode.java:98) > at org.apache.crunch.impl.mr.run.RTNode.process(RTNode.java:109) > at org.apache.crunch.impl.mr.run.CrunchMapper.map(CrunchMapper.java:60) > at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145) > at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787) > at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341) > at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:163) > at java.security.AccessController.doPrivileged(Native Method) > at javax.security.auth.Subject.doAs(Subject.java:422) > at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1671) > at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) > > > Does someone have an idea why the exception might be occurring? The > version of avro is 1.7.6. I have checked for dependency conflicts but there > doesn't seem to be a problem with it although it looks like it. > > Thanks. > --001a113eca102c3046051ca67c4d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Believe the output type for a TextFileOutput has to be a S= tring, not a Table containing a String key with an Avro Map.=C2=A0 With the= complex object I think you have to write it out as an AvroFile.

<= div class=3D"gmail_quote">
On Thu, Aug 6, 2015 at 11:47 AM = Hrishikesh P <hrishi.engine= er@gmail.com> wrote:
I'm trying to write a PTable<String,= Map<String, String>> to a TextFileSourceTarget but I am running i= nto a ClassCastException.

{code}
PT= able<String, Map<String, String>> table =3D ...;

<= div class=3D"gmail_default" style=3D"font-family:comic sans ms,sans-serif;c= olor:rgb(11,83,148)">table.write(new TextFileSourceTarget<>(Path.merg= ePaths(fs.getHomeDirectory(), path), Avros.tableOf(Avros.strings(), Avros.m= aps(Avros.strings()))));
{code}

The exception is:

WARN [main] org.apache.hadoop.mapred.YarnChild: Exception running ch=
ild : java.lang.ClassCastException: org.apache.avro.util.Utf8 cannot be cas=
t to org.apache.avro.generic.IndexedRecord
	at org.apache.crunch.types.avro.AvroTableType$IndexedRecordToPair.map(Avro=
TableType.java:88)
	at org.apache.crunch.MapFn.process(MapFn.java:34)
	at org.apache.crunch.impl.mr.run.RTNode.process(RTNode.java:98)
	at org.apache.crunch.impl.mr.run.RTNode.process(RTNode.java:109)
	at org.apache.crunch.impl.mr.run.CrunchMapper.map(CrunchMapper.java:60)
	at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
	at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
	at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
	at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:163)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:422)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformati=
on.java:1671)
	at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

Do= es someone have an idea why the exception might be occurring? The version o= f avro is 1.7.6. I have checked for dependency conflicts but there doesn= 9;t seem to be a problem with it although it looks like it.

Thanks.
--001a113eca102c3046051ca67c4d--