将级联文本文件转换为Parquet格式

3

我正在尝试使用Cascading将一个文件转换为Parquet。但是我遇到了以下错误。

错误

Exception in thread "main" cascading.flow.planner.PlannerException: tap named: 'Copy', cannot be used as a sink: Hfs["ParquetTupleScheme[['A', 'B']->[ALL]]"]["/user/cloudera/htcountp"]
at cascading.flow.planner.FlowPlanner.verifyTaps(FlowPlanner.java:240)
at cascading.flow.planner.FlowPlanner.verifyAllTaps(FlowPlanner.java:174)
at cascading.flow.hadoop.planner.HadoopPlanner.buildFlow(HadoopPlanner.java:242)
at cascading.flow.hadoop.planner.HadoopPlanner.buildFlow(HadoopPlanner.java:80)
at cascading.flow.FlowConnector.connect(FlowConnector.java:459)
at first.Copy.main(Copy.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:212)

代码

Scheme sourceScheme = new TextDelimited(new Fields("A","B"), ", ");
Scheme sinkScheme = new ParquetTupleScheme(new Fields("A", "B"));

// create the source tap
Tap inTap = new Hfs(sourceScheme, inPath );

// create the sink tap
Tap outTap = new Hfs( sinkScheme, outPath );

// specify a pipe to connect the taps
Pipe copyPipe = new Pipe("Copy"); 

// connect the taps, pipes, etc., into a flow
FlowDef flowDef = FlowDef.flowDef()
 .addSource( copyPipe, inTap )
 .addTailSink( copyPipe, outTap );

// run the flow
flowConnector.connect( flowDef ).complete();

你有找到解决方案吗? - Capacytron
你找到解决方案了吗? - Prabodh Mhalgi
2个回答

1
遇到了同样的问题。查看源代码,您必须将Parquet模式传递到ParquetTupleScheme的构造函数中,以便它可以将数据序列化到HDFS。该类有一个isSink()方法,用于检查是否存在。否则,它不是一个接收器,代码会抛出您识别的错误。

你能帮我定义Parquet模式吗?我是Parquet的初学者。谢谢! - Prabodh Mhalgi

0
有点晚了。但是我之前也遇到了同样的问题。以下是另一种声明 ParquetTupleScheme 的变体:
new ParquetTupleScheme(Fields SourceFields, Fields SinkFields, String ParquetSchema)

将接收器 Scheme 的声明更改为以下内容:
Scheme sinkScheme = new ParquetTupleScheme(new Fields("A", "B"), new Fields("A", "B"), "message FileName { required Binary A , required Binary B }" );

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接