Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-29860

[SQL] Fix data type mismatch issue for inSubQuery

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.4.4
    • 3.0.0
    • SQL
    • None

    Description

      The follow statement would throw an exception.

            sql("create table ta(id Decimal(18,0)) using parquet")
            sql("create table tb(id Decimal(19,0)) using parquet")
            sql("select * from ta where id in (select id from tb)").shown()
      
      // Exception information
      cannot resolve '(default.ta.`id` IN (listquery()))' due to data type mismatch: 
      The data type of one or more elements in the left hand side of an IN subquery
      is not compatible with the data type of the output of the subquery
      Mismatched columns:
      [(default.ta.`id`:decimal(18,0), default.tb.`id`:decimal(19,0))]
      Left side:
      [decimal(18,0)].
      Right side:
      [decimal(19,0)].;;
      'Project [*]
      +- 'Filter id#219 IN (list#218 [])
         :  +- Project [id#220]
         :     +- SubqueryAlias `default`.`tb`
         :        +- Relation[id#220] parquet
         +- SubqueryAlias `default`.`ta`
            +- Relation[id#219] parquet
      

      Attachments

        Issue Links

          Activity

            People

              hzfeiwang feiwang
              hzfeiwang feiwang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: