def schema_from_json(path):
""" Create a pyspark schema from the json representation.
The json representation must be from a StructType. This can be
generated from any StructType using the `.json()` method. The
schema for a dataframe can be obtained using the `.schema`
accessor. For example, to generate the json from the
`topline_summary`, run the following in the pyspark repl:
>>> path = 's3a://telemetry-parquet/topline_summary/v1/mode=weekly'
>>> json_data = spark.read.parquet(path).schema.json()
:path str: Path the the json data
"""
with pkg_resources.resource_stream(mozetl.topline.__name__, path) as f:
data = json.load(f)
return StructType.fromJson(data)
# Generate module level schemas
评论列表
文章目录