pyspark

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

PySpark

Translates JSON Schema to PySpark StructType definitions (.py).

Example

Input (JSON Schema):

{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "age": { "type": "integer", "minimum": 0, "maximum": 150 },
    "status": { "type": "integer", "minimum": -128, "maximum": 127 },
    "price": { "type": "number", "multipleOf": 0.01, "minimum": 0, "maximum": 99999.99 }
  }
}

Output (PySpark):

import pyspark.sql.types as T

orders_schema = T.StructType([
    T.StructField("name", T.StringType(), nullable=True),
    T.StructField("age", T.ShortType(), nullable=True),
    T.StructField("status", T.ByteType(), nullable=True),
    T.StructField("price", T.DecimalType(7, 2), nullable=True),
])

When minimum and maximum are specified, integers are narrowed to the smallest fitting type (ByteType, ShortType, IntegerType, or LongType). When multipleOf is a decimal fraction (e.g. 0.01), numbers become DecimalType with precision derived from the bounds and scale from multipleOf.

Supported JSON Schema Features

Type Keywords
  • type
  • enum
  • const
Type Values
  • string
  • integer
  • number
  • boolean
  • array
  • object
  • null
Schema Composition
  • allOf
  • anyOf
  • oneOf
  • not
Object Keywords
  • properties
  • required
  • additionalProperties
  • patternProperties
  • propertyNames
  • minProperties / maxProperties
  • unevaluatedProperties
  • dependentRequired
Array Keywords
  • items
  • prefixItems
  • contains
  • minItems / maxItems
  • uniqueItems
  • unevaluatedItems
  • maxContains / minContains
Numeric Validation
  • minimum / maximum
  • exclusiveMinimum / exclusiveMaximum
  • multipleOf
String Validation
  • minLength / maxLength
  • pattern
References & Definitions
  • $ref
  • $defs
  • $id
  • $anchor
  • $dynamicRef / $dynamicAnchor
String Formats
  • date
  • date-time
  • time
  • duration
  • uuid
  • uri / uri-reference / uri-template
  • iri / iri-reference
  • email / idn-email
  • hostname / idn-hostname
  • ipv4 / ipv6
  • json-pointer / relative-json-pointer
  • regex
Annotations
  • description
  • title
  • default
  • deprecated
  • readOnly / writeOnly
  • examples
Conditional
  • if / then / else
  • dependentSchemas
Content
  • contentEncoding
  • contentMediaType
  • contentSchema

Documentation

Overview

Package pyspark provides PySpark schema translation utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Translator

type Translator struct{}

Translator translates JSON schemas to PySpark StructType definitions.

func (*Translator) FileExtension

func (t *Translator) FileExtension() string

FileExtension returns the file extension for PySpark schemas.

func (*Translator) Translate

func (t *Translator) Translate(portName string, schema *jsonschema.Schema, _ string) ([]byte, error)

Translate converts a JSON schema to PySpark Python code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL