Github user yjshen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8049#discussion_r36936526
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala
 ---
    @@ -343,31 +343,57 @@ private[sql] object DataSourceStrategy extends 
Strategy with Logging {
        * and convert them.
        */
       protected[sql] def selectFilters(filters: Seq[Expression]) = {
    +    import CatalystTypeConverters._
    +
         def translate(predicate: Expression): Option[Filter] = predicate match 
{
           case expressions.EqualTo(a: Attribute, Literal(v, _)) =>
             Some(sources.EqualTo(a.name, v))
           case expressions.EqualTo(Literal(v, _), a: Attribute) =>
             Some(sources.EqualTo(a.name, v))
    +      case expressions.EqualTo(Cast(a: Attribute, _), l: Literal) =>
    +        Some(sources.EqualTo(a.name, convertToScala(Cast(l, 
a.dataType).eval(), a.dataType)))
    +      case expressions.EqualTo(l: Literal, Cast(a: Attribute, _)) =>
    +        Some(sources.EqualTo(a.name, convertToScala(Cast(l, 
a.dataType).eval(), a.dataType)))
    --- End diff --
    
    Hi, @marmbrus , I've think this twice and may be I could do this?
    
    For HadoopFsRelations, they all assume pushed down column and value are of 
same type, I think the only safe way is not pushed down these casted filters at 
all.
    For JDBCRelation, since the value itself is converted into a constructed 
string `where clause` and pushed to the underlying database, I think it's safe 
to just pushed to uncasted value down?


---
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