Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions python/pyspark/sql/tests/connect/test_connect_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,29 +145,33 @@ def test_literal_integers(self):
cdf.select(CF.lit(JVM_LONG_MIN - 1)).show()

def test_cast(self):
# SPARK-41412: test basic Column.cast
df = self.connect.read.table(self.tbl_name)
df2 = self.spark.read.table(self.tbl_name)

self.assert_eq(
df.select(df.id.cast("string")).toPandas(), df2.select(df2.id.cast("string")).toPandas()
)

for x in [
StringType(),
BinaryType(),
ShortType(),
IntegerType(),
LongType(),
FloatType(),
DoubleType(),
ByteType(),
DecimalType(10, 2),
BooleanType(),
DayTimeIntervalType(),
]:
self.assert_eq(
df.select(df.id.cast(x)).toPandas(), df2.select(df2.id.cast(x)).toPandas()
)
# Test if the arguments can be passed properly.
# Do not need to check individual behaviour for the ANSI mode thoroughly.
with self.sql_conf({"spark.sql.ansi.enabled": False}):
for x in [
StringType(),
BinaryType(),
ShortType(),
IntegerType(),
LongType(),
FloatType(),
DoubleType(),
ByteType(),
DecimalType(10, 2),
BooleanType(),
DayTimeIntervalType(),
]:
self.assert_eq(
df.select(df.id.cast(x)).toPandas(), df2.select(df2.id.cast(x)).toPandas()
)

def test_unsupported_functions(self):
# SPARK-41225: Disable unsupported functions.
Expand Down