title: pyspark: dataframe select row by id in another dataframe's column
body: <p>I want to </p>
  
  <ol>
  <li>filter df1 by <code>time_create==last_timestamp</code>, </li>
  <li>filter df2  by selected <code>store_product_id</code> from df1 </li>
  </ol>
  
  <hr>
  
  <p>Here I only use df1 for example,</p>
  
  <p>Select by time_create is nice : </p>
  
  <pre><code>df1[df1.time_create==last_timestamp].show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/UKNKg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UKNKg.png" alt="enter image description here"></a></p>
  
  <p>However, use the selected <code>store_product_id</code>, filter original dataframe <code>df1</code> gave me a lot of rows. </p>
  
  <pre><code>df1[df1.store_product_id.isin(df1[df1.time_create==last_timestamp].store_product_id)].show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/f71vF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f71vF.png" alt="enter image description here"></a></p>
  
  <p>I also tried collect <code>store_product_id</code> list which match <code>time_create==last_timestamp</code> .</p>
  
  <pre><code>ids = df1[df1.time_create==last_timestamp].select('store_product_id').collect()
  df1[df1.store_product_id.isin(ids)].show()
  </code></pre>
  
  <p>But got error :</p>
  
  <pre><code>Py4JJavaError: An error occurred while calling z:org.apache.spark.sql.functions.lit.
  : java.lang.RuntimeException: Unsupported literal type class java.util.ArrayList [01e8f3c0-3ad5-4b69-b46d-f5feb3cadd5f]
      at org.apache.spark.sql.catalyst.expressions.Literal$.apply(literals.scala:78)
      at org.apache.spark.sql.catalyst.expressions.Literal$$anonfun$create$2.apply(literals.scala:164)
      at org.apache.spark.sql.catalyst.expressions.Literal$$anonfun$create$2.apply(literals.scala:164)
      at scala.util.Try.getOrElse(Try.scala:79)
      at org.apache.spark.sql.catalyst.expressions.Literal$.create(literals.scala:163)
      at org.apache.spark.sql.functions$.typedLit(functions.scala:127)
      at org.apache.spark.sql.functions$.lit(functions.scala:110)
      at org.apache.spark.sql.functions.lit(functions.scala)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
      at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
      at py4j.Gateway.invoke(Gateway.java:282)
      at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
      at py4j.commands.CallCommand.execute(CallCommand.java:79)
      at py4j.GatewayConnection.run(GatewayConnection.java:238)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>
  
  <p>What is the correct way ?</p>