[WIP][POC][GRAPHFRAMES] Add GraphFrames as an in-tree Spark module - #58302
[WIP][POC][GRAPHFRAMES] Add GraphFrames as an in-tree Spark module#58302zhengruifeng wants to merge 5 commits into
Conversation
|
Test coverage and GraphX-fork audit I compared this PR with the current GraphFrames checkout ( Test coverage
This is broad algorithm coverage, but it is not a complete copy of the upstream test tree:
GraphFrames GraphX fork versus Spark GraphX The GraphFrames fork is a renamed snapshot of GraphX, not a separate graph execution design: it duplicates 42 production files under
This PR deliberately uses canonical At the time of this check, the GraphFrames Scala and Python jobs were green. The overall workflow was still running, with separate documentation and lint failures in GraphFrames code; no fixes or reruns were made as part of this audit. |
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/__ / .__/\_,_/_/ /_/\_\ version 5.0.0.dev0
/_/
Using Python version 3.13.12 (main, Feb 24 2026 16:13:31)
Client connected to the Spark Connect server at localhost
SparkSession available as 'spark'.
In [1]: from pyspark.graphframes import GraphFrame
In [2]: v = spark.createDataFrame([
...: ("a", "Alice", 34), ("b", "Bob", 36), ("c", "Charlie", 30), ("d", "David", 29),
...: ("e", "Esther", 32), ("f", "Fanny", 36), ("g", "Gabby", 60)
...: ], ["id", "name", "age"])
...: e = spark.createDataFrame([
...: ("a", "b", "friend"), ("b", "c", "follow"), ("c", "b", "follow"), ("f", "c", "follow"),
...: ("e", "f", "follow"), ("e", "d", "friend"), ("d", "a", "friend"), ("a", "e", "friend")
...: ], ["src", "dst", "relationship"])
...: g = GraphFrame(v, e)
In [3]: results = g.pageRank(resetProbability=0.15, tol=0.01)
26/08/26 17:32:50 WARN PageRank: Returned DataFrame is persistent and materialized!
In [4]: results.vertices.show()
[*********************************************************-----------------------] 72.40% Complete (0 Tasks running, 0s, Scanned 8.4[*********************************************************-----------------------] 72.40% Complete (0 Tasks running, 0s, Scanned 8.4[*********************************************************-----------------------] 72.40% Complete (0 Tasks running, 0s, Scanned 8.4[*********************************************************-----------------------] 72.40% Complete (0 Tasks running, 0s, Scanned 8.4 +---+-------+---+-------------------+
| id| name|age| pagerank|
+---+-------+---+-------------------+
| f| Fanny| 36| 0.3283606792049851|
| g| Gabby| 60| 0.1799821386239711|
| a| Alice| 34|0.44910633706538744|
| e| Esther| 32|0.37085233187676075|
| d| David| 29| 0.3283606792049851|
| b| Bob| 36| 2.655507832863289|
| c|Charlie| 30| 2.6878300011606218|
+---+-------+---+-------------------+
In [5]: results.edges.show()
[************************************************************--------------------] 75.00% Complete (0 Tasks running, 0s, Scanned 0.0[************************************************************--------------------] 75.00% Complete (0 Tasks running, 0s, Scanned 0.0[************************************************************--------------------] 75.00% Complete (0 Tasks running, 0s, Scanned 0.0 +---+---+------------+------+
|src|dst|relationship|weight|
+---+---+------------+------+
| a| b| friend| 0.5|
| b| c| follow| 1.0|
| c| b| follow| 1.0|
| f| c| follow| 1.0|
| e| f| follow| 0.5|
| e| d| friend| 0.5|
| d| a| friend| 1.0|
| a| e| friend| 0.5|
+---+---+------------+------+
In [6]: spark
Out[6]: <pyspark.sql.connect.session.SparkSession at 0x7e982c56cc20> |
What changes were proposed in this pull request?
This draft upstreams GraphFrames into Apache Spark as an in-tree module. It uses Spark-owned public namespaces:
org.apache.spark.graphframespyspark.graphframesThe patch:
spark-graphframesmodule and includes its JAR in Spark distributions;spark-graphxmodule rather than the private GraphFrames GraphX fork;Relation.graph_framesprotocol field and directSparkConnectPlannerhandling.Spark Connect does not use
Any, a relation extension, orRelationPlugin. The server invokes the same JVM GraphFrames implementations used by classic Spark.Algorithm coverage includes:
The relational APIs also include graph construction and validation, degree DataFrames, typed degrees, filtering, isolated-vertex removal, reversal, and undirected conversion.
This remains an experimental draft and is not proposed for merge until the community agrees on the SPIP, package and artifact compatibility, maintainership, API stability, documentation, benchmarks, and any required IP-clearance process. The working upstreaming plan is here:
https://docs.google.com/document/d/1emar4QUbrf30jC1Iffv41AVBr-UmRoz2H32VRG3zmAs/edit
Why are the changes needed?
GraphFrames provides a widely used DataFrame graph abstraction, but its external release model requires a separate Spark/Scala compatibility matrix and separately packaged Spark Connect extensions. An in-tree module can provide release-aligned JVM, Python, and built-in Connect APIs while sharing Spark SQL, GraphX, and MLlib internals.
Does this PR introduce any user-facing change?
Yes. It proposes experimental APIs under new Spark-owned namespaces:
No released Spark version contains these APIs. Existing
org.graphframesandgraphframespackages are not changed by this patch.How was this patch tested?
build/sbt graphframes/compile connect/compilebuild/sbt graphframes/test(324/325 in the combined run; the sole broadcast-memory failure passed when its suite was rerun in isolation)build/sbt 'graphframes/testOnly org.apache.spark.graphframes.lib.MaximalIndependentSetSuite'build/sbt assembly/packagepython/run-tests --testnames pyspark.graphframes.tests.test_graphframepython/run-tests --testnames pyspark.graphframes.tests.connect.test_parity_graphframepython/run-tests --testnames pyspark.graphframes.tests.connect.test_all_algorithmsruff check python/pyspark/graphframesWas this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex (GPT-5)