[ https://issues.apache.org/jira/browse/SPARK-37643?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
YuanGuanhu updated SPARK-37643: ------------------------------- Description: This ticket aim at fixing the bug that does not apply right-padding for char types partition column when charVarcharAsString is true and partition data length is lower than defined length. For example, a query below returns nothing in master, but a correct result is `abc`. {code:java} 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| +---+ +---+{code} This is because `ApplyCharTypePadding` rpad the expr to charLength. We should handle this consider conf spark.sql.legacy.charVarcharAsString value. was: This ticket aim at fixing the bug that does not apply right-padding for char types partition column when charVarcharAsString is true and partition data length is lower than defined length. For example, a query below returns nothing in master, but a correct result is `abc`. {code:java} 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 * from tb01 where c = 'abc'").show +---+ | c| +---+ +---+{code} This is because `ApplyCharTypePadding` rpad the expr to charLength. We should handle this consider conf spark.sql.legacy.charVarcharAsString value. > when charVarcharAsString is true, char datatype partition table query > incorrect > ------------------------------------------------------------------------------- > > Key: SPARK-37643 > URL: https://issues.apache.org/jira/browse/SPARK-37643 > Project: Spark > Issue Type: Bug > Components: SQL > Affects Versions: 3.1.2, 3.2.0 > Environment: spark 3.2.0 > Reporter: YuanGuanhu > Priority: Major > > This ticket aim at fixing the bug that does not apply right-padding for char > types partition column when charVarcharAsString is true and partition data > length is lower than defined length. > For example, a query below returns nothing in master, but a correct result is > `abc`. > {code:java} > 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| > +---+ > +---+{code} > This is because `ApplyCharTypePadding` rpad the expr to charLength. We should > handle this consider conf spark.sql.legacy.charVarcharAsString value. -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org