1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
Regression test for issue #1385: errors.missing_column parity.
PySpark scenario (from the issue):
def scenario_errors_missing_column(session):
if _backend_is_pyspark(session):
from pyspark.sql import functions as F # type: ignore
else:
from sparkless.sql import functions as F # type: ignore
df = session.createDataFrame([(1,)], ["x"])
return df.select(F.col("nope").alias("y"))
Both backends should error when selecting a non-existent column; this test
locks in Sparkless' error type and message shape.
"""
import pytest
from sparkless.sql import functions as F
from sparkless.errors import SparklessError
@pytest.mark.sparkless_only
def test_issue_1385_errors_missing_column_message(spark) -> None:
"""errors.missing_column: selecting a non-existent column should raise SparklessError (issue #1385)."""
df = spark.createDataFrame([(1,)], ["x"])
with pytest.raises(SparklessError) as excinfo:
_ = df.select(F.col("nope").alias("y")).collect()
msg = str(excinfo.value)
# Lock in the existing unresolved-column message shape so future changes
# remain intentional and visible in tests.
assert "unresolved_column: cannot be resolved: not found" in msg
assert "cannot resolve: column 'nope' not found" in msg
assert "Available columns: [x]" in msg