Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
Collect() call used for a UDF function that returns pretty fat column (out of 2 columns in total) to avoid crossJoin

The problem is as follow:

'genre', 'top_tags' (250 rows)
----------------
Action, Array('bleeding', 'dying', 'guns', ...) - can hold up to 50k max. (avg is 4000)
Drama,  Array('crying', 'hard life', 'street') 

And another table with movies, a genre and its associated tags

'movie', 'genre', 'tags'. (DataFrame size, around 23M Rows)
------------------------
M1        Action,  'guns', 'dying', 'bleeding', 'outside', 'worldwide'.  approx ~10 records for each movie

I want to iterate every movie and try to extend its genre similarity by comparing tags. NO Fuzzy algorithm, just exact match.

I want to return a DataFrame (the same movie, genre, tags dataframe) with new column called potentially_related_genres and a list of genres.

As I see it, I have two options:

  1. crossJoin and compare two columns using UDF but this will be bad since it will lad me to iterate 5,750,000,000 rows. (crossJoin output)

  2. pickle the results (do a collect() on the first dataframe (250 rows) and use right after within a UDF with all the logic, this by calling the original dataframe and use withColumn

DF.withColumn('potentially_related_genres', my_udf('genre', 'tags'))

The issue with the approach is that passing to the driver is a pretty big collect ( remember the fat column top_tags ). and transfer this to all of the workers to be used. (the pickling and unpickling)

Any suggestion ?

Thanks in advance.

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda