apache / apache/beam

[Bug]: ReadFromCSV does not handle EmptyDataframe well internally

Open
#38,742 6 comments 0 reactions 0 assignees View on GitHub
awaiting triage bug dataflow io P2 python
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

### What happened?

Hello,

I am trying to read 50 csv files with 3 columns from a Cloud Dataflow / Apache Beam v2.67.0 job. Previously, I was using ReadFromText, then I wrote a lambda function to split each text line into 3 fields. I tried switching to beam.io.textio.ReadFromCsv (to handle quoted fields for example), but the job randomly fails with the following error :

Image

What I understand is :
ReadFromCsv is reading the data using the Pandas API, which results in 1 or multiple pandas Dataframes. Then it tries to convert each Dataframe into a Beam PCollection. In my case, it seems like an empty Dataframe can be generated sometimes, but the conversion process does not handle it well.

This code here : https://github.com/apache/beam/blob/master/sdks/python/apache_beam/runners/worker/opcounters.py#L221

```
mean_element_size = self.producer_batch_converter.estimate_byte_size(
windowed_batch.values) / batch_length
```
Seems to be the issue, as the batch_length is 0,

The files are not empty of course, they all have around a million lines each

### Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

### Issue Components

- [x] Component: Python SDK
- [ ] Component: Java SDK
- [ ] Component: Go SDK
- [ ] Component: Typescript SDK
- [x] Component: IO connector
- [ ] Component: Beam YAML
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Infrastructure
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Prism Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [x] Component: Google Cloud Dataflow Runner

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.