Cannot write DataSet<Row> as csv file

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot write DataSet<Row> as csv file

Soheil Pourbafrani
Hi, 

Using the JDBCInputFormat I loaded a DataSet<Row> type. When I tried to save it as CSV file it errors:
java.lang.ClassCastException: org.apache.flink.types.Row cannot be cast to org.apache.flink.api.java.tuple.Tuple

That's while I can save it as a text file. Here is the code.

DataSet<Row> dataset = env.createInput(InputFormat);

dataset.writeAsCsv("table_data");
Is it a bug?

Reply | Threaded
Open this post in threaded view
|

Re: Cannot write DataSet<Row> as csv file

Konstantin Knauf-2
Hi Soheil,

I don't think it is a bug the Row class is pretty tightly linked to the TableAPI. DataSet#writeAsCsv has always only worked with Tuple classes. You can use DataSet#writeAsText to write arbitrary DataSets to file (will use toString() methods).

Cheers,

Konstantin

On Sat, Jul 6, 2019 at 3:49 PM Soheil Pourbafrani <[hidden email]> wrote:
Hi, 

Using the JDBCInputFormat I loaded a DataSet<Row> type. When I tried to save it as CSV file it errors:
java.lang.ClassCastException: org.apache.flink.types.Row cannot be cast to org.apache.flink.api.java.tuple.Tuple

That's while I can save it as a text file. Here is the code.

DataSet<Row> dataset = env.createInput(InputFormat);

dataset.writeAsCsv("table_data");
Is it a bug?



--

Konstantin Knauf | Solutions Architect

+49 160 91394525


Planned Absences: 10.08.2019 - 31.08.2019, 05.09. - 06.09.2010


--

Ververica GmbH | Invalidenstrasse 115, 10115 Berlin, Germany

--

Ververica GmbH
Registered at Amtsgericht Charlottenburg: HRB 158244 B
Managing Directors: Dr. Kostas Tzoumas, Dr. Stephan Ewen