You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Kai-Michael Roesner (Jira)" <ji...@apache.org> on 2023/07/10 14:36:00 UTC
[jira] [Created] (SPARK-44354) Cannot create dataframe with CharType/VarcharType column
Kai-Michael Roesner created SPARK-44354:
-------------------------------------------
Summary: 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
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...
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org