[ https://issues.apache.org/jira/browse/SPARK-44354?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kai-Michael Roesner updated SPARK-44354: ---------------------------------------- Description: When trying to create a dataframe with a CharType or VarcharType column like so: {code} from datetime import date from decimal import Decimal from pyspark.sql import SparkSession from pyspark.sql.types import * data = [ (1, 'abc', Decimal(3.142), date(2023, 1, 1)), (2, 'bcd', Decimal(1.414), date(2023, 1, 2)), (3, 'cde', Decimal(2.718), date(2023, 1, 3))] schema = StructType([ StructField('INT', IntegerType()), StructField('STR', CharType(3)), StructField('DEC', DecimalType(4, 3)), StructField('DAT', DateType())]) spark = SparkSession.builder.appName('data-types').getOrCreate() df = spark.createDataFrame(data, schema) df.show() {code} a {{java.lang.IllegalStateException}} is thrown [here|https://github.com/apache/spark/blob/85e252e8503534009f4fb5ea005d44c9eda31447/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala#L168]. I'm expecting this to work... was: When trying to create a dataframe with a CharType or VarcharType column like so: {code} from datetime import date from decimal import Decimal from pyspark.sql import SparkSession from pyspark.sql.types import * data = [ (1, 'abc', Decimal(3.142), date(2023, 1, 1)), (2, 'bcd', Decimal(1.414), date(2023, 1, 2)), (3, 'cde', Decimal(2.718), date(2023, 1, 3))] schema = StructType([ StructField('INT', IntegerType()), StructField('STR', CharType(3)), StructField('DEC', DecimalType(4, 3)), StructField('DAT', DateType())]) spark = SparkSession.builder.appName('data-types').getOrCreate() df = spark.createDataFrame(data, schema) df.show() {code} a {{java.lang.IllegalStateException}} is thrown [here|https://github.com/apache/spark/blame/85e252e8503534009f4fb5ea005d44c9eda31447/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala#L168] I'm expecting this to work... > Cannot create dataframe with CharType/VarcharType column > -------------------------------------------------------- > > Key: SPARK-44354 > URL: https://issues.apache.org/jira/browse/SPARK-44354 > Project: Spark > Issue Type: Bug > Components: PySpark > Affects Versions: 3.4.0 > Reporter: Kai-Michael Roesner > Priority: Major > > When trying to create a dataframe with a CharType or VarcharType column like > so: > {code} > from datetime import date > from decimal import Decimal > from pyspark.sql import SparkSession > from pyspark.sql.types import * > data = [ > (1, 'abc', Decimal(3.142), date(2023, 1, 1)), > (2, 'bcd', Decimal(1.414), date(2023, 1, 2)), > (3, 'cde', Decimal(2.718), date(2023, 1, 3))] > schema = StructType([ > StructField('INT', IntegerType()), > StructField('STR', CharType(3)), > StructField('DEC', DecimalType(4, 3)), > StructField('DAT', DateType())]) > spark = SparkSession.builder.appName('data-types').getOrCreate() > df = spark.createDataFrame(data, schema) > df.show() > {code} > a {{java.lang.IllegalStateException}} is thrown > [here|https://github.com/apache/spark/blob/85e252e8503534009f4fb5ea005d44c9eda31447/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala#L168]. > I'm expecting this to work... -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org For additional commands, e-mail: issues-h...@spark.apache.org