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/05/11 01:23:57 UTC
[GitHub] [spark] xinrong-databricks opened a new pull request, #36504: Access to JVM through passed-in JavaGateway during type conversion
xinrong-databricks opened a new pull request, #36504:
URL: https://github.com/apache/spark/pull/36504
### What changes were proposed in this pull request?
Access to JVM through passed-in JavaGateway during type conversion.
### Why are the changes needed?
In customized type converters, we may utilize `jvm` field of passed-in JavaGateway directly to access to JVM, rather than rely on the SparkContext.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Existing tests.
--
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
[GitHub] [spark] HyukjinKwon closed pull request #36504: [SPARK-39155][PYTHON] Access to JVM through passed-in GatewayClient during type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #36504: [SPARK-39155][PYTHON] Access to JVM through passed-in GatewayClient during type conversion
URL: https://github.com/apache/spark/pull/36504
--
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
[GitHub] [spark] HyukjinKwon commented on pull request #36504: [SPARK-39155][PYTHON] Access to JVM through passed-in GatewayClient during type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on PR #36504:
URL: https://github.com/apache/spark/pull/36504#issuecomment-1124490588
Merged to master and branch-3.3.
--
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
[GitHub] [spark] HyukjinKwon commented on a diff in pull request #36504: Access to JVM through passed-in JavaGateway during type conversion
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on code in PR #36504:
URL: https://github.com/apache/spark/pull/36504#discussion_r870852807
##########
python/pyspark/sql/types.py:
##########
@@ -1958,27 +1958,25 @@ def can_convert(self, obj: Any) -> bool:
and is_timestamp_ntz_preferred()
)
- def convert(self, obj: datetime.datetime, gateway_client: JavaGateway) -> JavaObject:
- from pyspark import SparkContext
-
+ def convert(self, obj: datetime.datetime, gateway_client: GatewayClient) -> JavaObject:
seconds = calendar.timegm(obj.utctimetuple())
- jvm = SparkContext._jvm
- assert jvm is not None
- return jvm.org.apache.spark.sql.catalyst.util.DateTimeUtils.microsToLocalDateTime(
- int(seconds) * 1000000 + obj.microsecond
+ DateTimeUtils = JavaClass(
+ "org.apache.spark.sql.catalyst.util.DateTimeUtils",
+ gateway_client,
)
+ return DateTimeUtils.microsToLocalDateTime(int(seconds) * 1000000 + obj.microsecond)
class DayTimeIntervalTypeConverter:
def can_convert(self, obj: Any) -> bool:
return isinstance(obj, datetime.timedelta)
- def convert(self, obj: datetime.timedelta, gateway_client: JavaGateway) -> JavaObject:
- from pyspark import SparkContext
-
- jvm = SparkContext._jvm
- assert jvm is not None
- return jvm.org.apache.spark.sql.catalyst.util.IntervalUtils.microsToDuration(
+ def convert(self, obj: datetime.timedelta, gateway_client: GatewayClient) -> JavaObject:
+ IntervalUtils = JavaClass(
Review Comment:
Nice
--
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