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

Apply right-padding correctly for correlated subqueries

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 3.1.0, 3.1.1, 3.2.0
    • 3.1.2, 3.2.0
    • SQL

    Description

      This ticket aim at fixing the bug that does not apply right-padding for char types inside correlated subquries.
      For example, a query below returns nothing in master, but a correct result is `c`.

      scala> sql(s"CREATE TABLE t1(v VARCHAR(3), c CHAR(5)) USING parquet")
      scala> sql(s"CREATE TABLE t2(v VARCHAR(5), c CHAR(7)) USING parquet")
      scala> sql("INSERT INTO t1 VALUES ('c', 'b')")
      scala> sql("INSERT INTO t2 VALUES ('a', 'b')")
      scala> val df = sql("""
        |SELECT v FROM t1
        |WHERE 'a' IN (SELECT v FROM t2 WHERE t2.c = t1.c )""".stripMargin)
      
      scala> df.show()
      +---+
      |  v|
      +---+
      +---+
      
      

      This is because `ApplyCharTypePadding` does not handle the case above to apply right-padding into `'abc'`.

      Attachments

        Activity

          People

            maropu Takeshi Yamamuro
            maropu Takeshi Yamamuro
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: