Github user hvanhovell commented on the issue:

    https://github.com/apache/spark/pull/14411
  
    @nsyca I think we do need to prevent sampling from being used. I have the 
following example:
    ```scala
    range(0, 10).createOrReplaceTempView("tbl_a")
    range(0, 10).select($"id", $"id" % 10 as 
"grp_id").createOrReplaceTempView("tbl_b")
    range(0, 10).select($"id", $"id" % 10 as 
"grp_id").createOrReplaceTempView("tbl_c")
    
    val plan = sql("""
    select *
    from   tbl_a
    where  not exists(
            select 1
            from   tbl_b
                   join (select *
                         from   tbl_c
                         where  tbl_c.id = tbl_a.id) tablesample(0.01 percent) c
                    on c.grp_id = tbl_b.grp_id)
    """)
    ```
    This results in the following analyzed plan:
    ```
    Project [id#8L]
    +- Filter NOT predicate-subquery#34 [(id#24L = id#8L)]
       :  +- SubqueryAlias predicate-subquery#34 [(id#24L = id#8L)]
       :     +- Project [1 AS 1#42, id#24L]
       :        +- Join Inner, (grp_id#29L = grp_id#19L)
       :           :- SubqueryAlias tbl_b
       :           :  +- Project [id#14L, (id#14L % cast(10 as bigint)) AS 
grp_id#19L]
       :           :     +- Range (0, 10, splits=8)
       :           +- SubqueryAlias c
       :              +- Sample 0.0, 1.0E-4, false, 968
       :                 +- Project [id#24L, grp_id#29L]
       :                    +- SubqueryAlias tbl_c
       :                       +- Project [id#24L, (id#24L % cast(10 as 
bigint)) AS grp_id#29L]
       :                          +- Range (0, 10, splits=8)
       +- SubqueryAlias tbl_a
          +- Range (0, 10, splits=8)
    ```
    Clearly the predicate has been pulled out of a sampled relation. I don't 
think we want this.
    
    I am looking forward to discuss your `NOT IN` approach. Could you open a 
JIRA for that?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to