{"id":17175686,"url":"https://github.com/saurfang/sparksql-protobuf","last_synced_at":"2025-06-23T18:39:09.672Z","repository":{"id":30501557,"uuid":"34055891","full_name":"saurfang/sparksql-protobuf","owner":"saurfang","description":"Read SparkSQL parquet file as RDD[Protobuf]","archived":false,"fork":false,"pushed_at":"2018-10-12T01:34:51.000Z","size":63,"stargazers_count":93,"open_issues_count":5,"forks_count":37,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-13T16:49:50.263Z","etag":null,"topics":["parquet","protobuf","sparksql"],"latest_commit_sha":null,"homepage":"http://spark-packages.org/package/saurfang/sparksql-protobuf","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saurfang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-16T12:59:05.000Z","updated_at":"2024-09-23T11:25:07.000Z","dependencies_parsed_at":"2022-08-17T18:05:17.699Z","dependency_job_id":null,"html_url":"https://github.com/saurfang/sparksql-protobuf","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/saurfang/sparksql-protobuf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurfang%2Fsparksql-protobuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurfang%2Fsparksql-protobuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurfang%2Fsparksql-protobuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurfang%2Fsparksql-protobuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saurfang","download_url":"https://codeload.github.com/saurfang/sparksql-protobuf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saurfang%2Fsparksql-protobuf/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261535055,"owners_count":23173517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["parquet","protobuf","sparksql"],"created_at":"2024-10-14T23:57:22.152Z","updated_at":"2025-06-23T18:39:09.648Z","avatar_url":"https://github.com/saurfang.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sparksql-protobuf\n\nThis library provides utilities to work with Protobuf objects in SparkSQL.\nIt provides a way to read parquet file written by SparkSQL back as an RDD of compatible protobuf object.\nIt can also converts RDD of protobuf objects into DataFrame.\n\n[![Build Status](https://travis-ci.org/saurfang/sparksql-protobuf.svg?branch=master)](https://travis-ci.org/saurfang/sparksql-protobuf)\n[![codecov.io](https://codecov.io/github/saurfang/sparksql-protobuf/coverage.svg?branch=master)](https://codecov.io/github/saurfang/sparksql-protobuf?branch=master)\n\nFor sbt 0.13.6+\n\n```scala\nresolvers += Resolver.jcenterRepo\n\nlibraryDependencies ++= Seq(\n    \"com.github.saurfang\" %% \"sparksql-protobuf\" % \"0.1.3\",\n    \"org.apache.parquet\" % \"parquet-protobuf\" % \"1.8.3\"\n)\n```\n\n## Motivation\n\nSparkSQL is very powerful and easy to use. However it has a few limitations and schema is only detected during runtime\nmakes developers a lot less confident that they will get things right at first time. _Static_ typing helps a lot! This is where protobuf comes in:\n\n1. Protobuf defines nested data structure easily\n2. It doesn't constraint you to the 22 fields limit in case class (no longer true once we upgrade to 2.11+)\n3. It is language agnostic and generates code that gives you native objects\n   hence you get all the benefit of type checking and code completion unlike operating `Row` in Spark/SparkSQL\n\n## Features\n\n### Read Parquet file as `RDD[Protobuf]`\n\n```scala\nval personsPB = new ProtoParquetRDD(sc, \"persons.parquet\", classOf[Person])\n```\n\nwhere we need `SparkContext`, parquet path and protobuf class.\n\nThis converts the existing workflow:\n\n1. Ingest raw data as DataFrame with nested data structure\n2. Create awkward runtime type checking udfs\n3. Transform raw DataFrame using above udfs into a tabular DataFrame for data analytics\n\nto\n\n1. Ingest raw data as DataFrame with nested data structure and persist as Parquet file\n2. Read Parquet file back as `RDD[Protobuf]`\n3. Perform any data transformation and extraction by working with compile typesafe Protobuf getters\n4. Create a DataFrame out of the above transformation and perform additional downstream data analytics on the tabular DataFrame\n\n### Infer SparkSQL Schema from Protobuf Definition\n\n```scala\nval personSchema = ProtoReflection.schemaFor[Person].dataType.asInstanceOf[StructType]\n```\n\n### Convert `RDD[Protobuf]` to `DataFrame`\n\n```scala\nimport com.github.saurfang.parquet.proto.spark.sql._\nval personsDF = sqlContext.createDataFrame(protoPersons)\n```\n\n_For more information, please see test cases._\n\n## Under the hood\n\n1. `ProtoMessageConverter` has been improved to read from [LIST specification](https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#lists)\n   according to latest parquet documentation. This implementation should be backwards compatible and is able to read repeated\n   fields generated by writers like SparkSQL.\n2. `ProtoMessageParquetInputFormat` helps the above process by correctly returning the built protobuf object as value.\n3. `ProtoParquetRDD` abstract the Hadoop input format and returns an RDD of your protobuf objects from parquet files directly.\n4. `ProtoReflection` infers SparkSQL schema from any Protobuf message class.\n5. `ProtoRDDConversions` converts Protobuf objects into SparkSQL rows.\n\n## Related Work\n\n[Elephant Bird](https://github.com/twitter/elephant-bird)\n\n[Spark-9999](https://issues.apache.org/jira/browse/SPARK-9999)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaurfang%2Fsparksql-protobuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaurfang%2Fsparksql-protobuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaurfang%2Fsparksql-protobuf/lists"}