Registry / data / sparkorm

sparkorm

JSON →
library1.2.29pypypiunverified

SparkORM is a Python library for schema management and basic Object Relational Mapping for PySpark SQL and DataFrames. Current version: 1.2.29 (stable, monthly releases).

pip install sparkorm
INSTALL
IMPORT
SIG · SPARKORM
S
sparkorm
datapythonv1.2.29
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SparkSessionSingleton
from sparkorm import SparkSessionSingleton
from sparkorm import SparkSessionSingleton

Define a schema model, create a SparkDataFrame, and display it.

from sparkorm import SparkSessionSingleton, SparkDataFrame, Structure from pyspark.sql.types import StructType, StructField, StringType, IntegerType # Define schema model class Employee(Structure): name: str age: int # Get or create SparkSession spark = SparkSessionSingleton().get_or_create() # Create sample data rows = [("Alice", 30), ("Bob", 25)] schema = StructType([ StructField("name", StringType(), True), StructField("age", IntegerType(), True) ]) df = spark.createDataFrame(rows, schema) # Wrap with SparkDataFrame sdf = SparkDataFrame(df, Employee) sdf.show()
Debug
Known issues
gotchaSparkSessionSingleton caches the session globally; calling get_or_create after stopping the session will create a new one. Ensure you do not accidentally reuse a stopped session.
fix
Use SparkSessionSingleton().stop() carefully and recreate if needed.
affects: all
gotchaSparkORM requires an existing PySpark installation. Installing sparkorm alone will not bring in PySpark; you must install it separately or via an extra dependency if available.
fix
pip install pyspark
affects: all
deprecatedSome older tutorials use `from sparkorm import SparkSession` directly; this alias may be removed. Use `SparkSessionSingleton` instead.
fix
from sparkorm import SparkSessionSingleton
affects: >=1.0.0
Upgrade
Version history
1.2.29latest on PyPI · released Jun 24, 2024
Audit
Dependencies
pysparkrequiredRequired for Spark interaction; must be installed separately.
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
sparkorm — pip install sparkorm · libregistry