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

when charVarcharAsString is true, char datatype partition table query incorrect

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.1.2, 3.2.0
    • 3.1.3, 3.3.0, 3.2.2
    • SQL
    • spark 3.2.0

    Description

      This ticket aim at fixing the bug that does not apply right-padding for char types column when charVarcharAsString is true and partition data length is less than defined length.
      For example, a query below returns nothing in master, but a correct result is `abc`.

      scala> sql("set spark.sql.legacy.charVarcharAsString=true")
      scala> sql("CREATE TABLE tb01(i string, c char(5)) USING parquet partitioned by (c)")
      scala> sql("INSERT INTO tb01 values(1, 'abc')")
      scala> sql("select c from tb01 where c = 'abc'").show
      +---+
      |  c|
      +---+
      +---+

      This is because `ApplyCharTypePadding` rpad the expr to charLength. We should handle this consider conf spark.sql.legacy.charVarcharAsString value.

      Attachments

        Activity

          People

            yghu YuanGuanhu
            yghu YuanGuanhu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: