Comments (4)
@zero323,
The following valid snippet currently results in an error:
df = df.withColumn("score", sum((F.col("sim"), F.col("weight"))))
(note that sum is the stdlib sum, not the one from pyspark functions)
The error is Argument 2 to "withColumn" of "DataFrame" has incompatible type "Union[Column, int]"; expected "Column"
We actually do have a proper annotation for radd
on Column, but it has a type: ignore
. It sounds like this is connected to the python/mypy#2129 you mention above, but that one has been fixed. Do you think the type: ignore
can be safely removed now?
from pyspark-stubs.
@harpaj Indeed, it looks like it should be safe to remove type: ignore
now.
However I don't think that's really the source of the problem here. With ingore
this for example is valid:
expr: Column = 1 + col("b")
It looks like the problem is more that we don't have dependent types here, and mypy cannot infer that sum(NonEmptyIterable[Column])
is Column
. Instead in consider both cases:
- iterable is empty and we default to
int
, - iterable is non empty and we get
Column
If you want sum
to type check you should rather start with literal
sum([F.col("sim"), F.col("weight")], lit(0))
from pyspark-stubs.
Partially addressed by #194
from pyspark-stubs.
This issue haven't seen any activity in a while.
from pyspark-stubs.
Related Issues (20)
- [SPARK-32517] Add StorageLevel.DISK_ONLY_3
- [SPARK-31000][PYTHON][SQL] Add ability to set table description via Catalog.createTable()
- [SPARK-32449] Add summary to MultilayerPerceptronClassificationModel
- [SPARK-29157] Add DataFrameWriterV2 to Python API
- [SPARK-31849] Make PySpark SQL exceptions more Pythonic HOT 1
- [SPARK-32010] Thread leaks in pinned thread mode
- Support string type in pyspark.sql.DataFrameReader.csv's schema parameter HOT 1
- [SPARK-31656] AFT blockify input vectors
- [SPARK-32719] Add Flake8 check for missing imports
- [SPARK-32319] Disallow the use of unused imports
- [SPARK-32798] Make unionByName optionally fill missing columns with nulls in PySpark
- RandomForestRegressor.{__init__, setParams} are missing leafCol
- Drop hasSummary from LinearRegressionTrainingSummary, GeneralizedLinearRegressionTrainingSummary and LogisticRegressionSummary
- [SPARK-32835] Add withField method to the pyspark Column class
- pyspark-stubs installed pyspark-2.4.4 and corrupt pre-installed pyspark-3.0.0 HOT 3
- `pyspark.rdd.RDD.histogram`'s `buckets` argument is incomplete
- How to handle java backend stubs HOT 2
- DataFrameLike does not have to_sql method HOT 2
- Wrong type in Dataframe.write.parquet
- Allow latest version of pyspark HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyspark-stubs.