You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/08/02 04:40:33 UTC
[GitHub] [spark] zhengruifeng commented on pull request #37369: [SPARK-39942][PYTHON][PS] Need to verify the input nums is integer in nsmallest func
zhengruifeng commented on PR #37369:
URL: https://github.com/apache/spark/pull/37369#issuecomment-1202009196
I think this is a more general problem:
```
def nsmallest(self, n: int = 5)
```
this method already hint the input type, but given a boolean it will fail with a `AnalysisException` (which should be a `TypeError`).
I guess it could accept a floating number like 5.5, and run successfully.
I did a quick investigation of [`typing`](https://docs.python.org/3/library/typing.html#module-typing), there is an annotation `@typing.runtime_checkable`, but only works for `class typing.Protocol`
is there some method to enforce the input type checking? @zero323
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org