3

I am trying to convert a file into Parquet using Cascading. But I am getting the below error.

Error

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)

Code

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();
Vulcronos
  • 3,428
  • 3
  • 16
  • 24
user2732748
  • 97
  • 4
  • 12

2 Answers2

1

Ran into the same problem. Looking at the source code, you must pass a Parquet schema into ParquetTupleScheme's constructor so that it can serialize the data to HDFS. The class has a method isSink(), which checks to ensure it's there. Otherwise, it's not a sink and the code throws the error you identified.

Matt
  • 76
  • 4
0

A bit late. But i also ran in the same issue some time back. There is another variation for declaration of ParquetTupleScheme as below:

new ParquetTupleScheme(Fields SourceFields, Fields SinkFields, String ParquetSchema)

Change the declaration of the sink Scheme to as given below:

Scheme sinkScheme = new ParquetTupleScheme(new Fields("A", "B"), new Fields("A", "B"), "message FileName { required Binary A , required Binary B }" );
Kunal L
  • 51
  • 1
  • 6