liangz1 commented on a change in pull request #27565: [WIP][SPARK-30791]
Dataframe add sameSemantics and sementicHash method
URL: https://github.com/apache/spark/pull/27565#discussion_r379349637
##
File path: python/pyspark/sql/dataframe.py
##
@@ -2153,6 +2153,45 @@ def transform(self, func):
"should have been DataFrame." %
type(result)
return result
+@since(3.1)
+def sameSemantics(self, other):
+"""
+Return true when the query plan of the given :class:`DataFrame` will
return the same
+results as this :class:`DataFrame`.
+
+>>> df1 = spark.createDataFrame([(1, 2),(4, 5)], ["col1", "col2"])
+>>> df2 = spark.createDataFrame([(1, 2),(4, 5)], ["col0", "col2"])
+>>> df3 = spark.createDataFrame([(0, 2),(4, 5)], ["col1", "col2"])
+>>> df4 = spark.createDataFrame([(1, 2),(4, 5)], ["col1", "col2"])
+>>> df1.sameSemantics(df2)
+False
+>>> df1.sameSemantics(df3)
+False
+>>> df1.sameSemantics(df4)
+True
+"""
+if not isinstance(other, DataFrame):
+raise ValueError("other parameter should be of DataFrame; however,
got %s" % type(other))
Review comment:
Thanks! I'll try it.
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.
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org
With regards,
Apache Git Services
-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org