Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
beam.io.WriteToText writes 0 bytes to the destination file?

I have a simple apache beam pipeline which reads bigquery >> creates a parquet file in GCS >> From the GCS path, I read the metadata information and yield a JSON object with a custom ParDo function >> I write as text back to the GCS.

There is no runtime error but, when I check the file created in the destination GCS path, it has 0 bytes. I checked the whether the Pcollection is empty by using the beam.ParDo(print) function. When I do this it prints the JSON object. I already tried convert the object as str, list and dict. Everything works well with the beam.ParDo(print) statement but fails to write any data to GCS. Please let me know, what is my mistake? Thanks in advance :)

class CreateMetadata(beam.DoFn):
    def process(self, element, *args, **kwargs):
        # element here gets a GCS path as gs://.....
        ### Some internal process ###
        # This function is called only once at the end of the internal 
        # process have a JSON object as entity data
        yield entity_data

with beam.Pipeline(options=pipeline_options) as pipeline:
    table = (
        pipeline | 'ReadTableFromBigQuery' >> beam.io.Read(beam.io.BigQuerySource(query=bigquery.read_sql(query_string=query),
                                                                                  use_standard_sql=True))
        | 'writeAsParquetToGCS' >> pq.WriteToParquet(OUTPUT, schema=bigquery.get_parquet_schema_from_bq(),
                                                     num_shards=1)
        | 'CreateMetadata' >> beam.ParDo(CreateMetadata())
        # | beam.ParDo(print)

        | 'WriteToGCS' >> beam.io.WriteToText(file_path_prefix=OUTPUT.replace('Some GCS path'), file_name_suffix='.json',num_shards=1)
        # Now after the pipeline runs when I check the GCS path there is a file created with 
        # 0 bytes???

    )```
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda