{"id":30764738,"url":"https://github.com/airbnb/airbnb-spark-thrift","last_synced_at":"2025-09-04T17:13:24.735Z","repository":{"id":65976497,"uuid":"88910481","full_name":"airbnb/airbnb-spark-thrift","owner":"airbnb","description":"A library for loadling Thrift data into Spark SQL","archived":false,"fork":false,"pushed_at":"2023-03-04T01:16:31.000Z","size":52,"stargazers_count":43,"open_issues_count":3,"forks_count":16,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-08-29T06:33:19.600Z","etag":null,"topics":["spark","spark-sql","spark-streaming","thrift"],"latest_commit_sha":null,"homepage":"","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/airbnb.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,"governance":null}},"created_at":"2017-04-20T21:06:10.000Z","updated_at":"2024-11-27T20:14:35.000Z","dependencies_parsed_at":"2023-09-24T15:25:43.551Z","dependency_job_id":null,"html_url":"https://github.com/airbnb/airbnb-spark-thrift","commit_stats":{"total_commits":12,"total_committers":3,"mean_commits":4.0,"dds":0.25,"last_synced_commit":"3ccdf80c5c0390d5aa4dbc35b7323c625e6d5d32"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/airbnb/airbnb-spark-thrift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fairbnb-spark-thrift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fairbnb-spark-thrift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fairbnb-spark-thrift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fairbnb-spark-thrift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/airbnb","download_url":"https://codeload.github.com/airbnb/airbnb-spark-thrift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fairbnb-spark-thrift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273641904,"owners_count":25142252,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["spark","spark-sql","spark-streaming","thrift"],"created_at":"2025-09-04T17:13:19.289Z","updated_at":"2025-09-04T17:13:24.719Z","avatar_url":"https://github.com/airbnb.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Spark Thrift Loader\n[![Build Status](https://travis-ci.org/airbnb/airbnb-spark-thrift.svg)](https://travis-ci.org/airbnb/airbnb-spark-thrift)\n\n\nA library for loadling Thrift data into [Spark SQL](http://spark.apache.org/docs/latest/sql-programming-guide.html).\n\n## Features\n\nIt supports conversions from Thrift records to Spark SQL, making Thrift a first-class citizen in Spark.\nIt automatically derives Spark SQL schema from Thrift struct and convert Thrift object to Spark Row in runtime.\nAny nested-structs are all support except Map key field needs to be primitive.\n\nIt is especially useful when running spark streaming job to consume thrift events from different streaming sources.\n\n\n## Supported types for Thrift -\u003e Spark SQL conversion\n\nThis library supports reading following types. It uses the following mapping from convert Thrift types to Spark SQL types:\n\n| Thrift Type | Spark SQL type |\n| --- | --- |\n| bool | BooleanType |\n| i16 | ShortType |\n| i32 | IntegerType |\n| i64 | LongType |\n| double | DoubleType |\n| binary | StringType |\n| string | StringType |\n| enum | String |\n| list | ArrayType |\n| set | ArrayType |\n| map | MapType |\n| struct | StructType |\n\n\n## Examples\n\n\n### Convert Thrift Schema to StructType in Spark\n\n```scala\nimport com.airbnb.spark.thrift.ThriftSchemaConverter\n\n// this will return a StructType for the thrift class\nval thriftStructType = ThriftSchemaConverter.convert(ThriftExampleClass.getClass)\n\n\n```\n\n### Convert Thrift Object to Row in Spark\n\n```scala\nimport com.airbnb.spark.thrift.ThriftSchemaConverter\nimport com.airbnb.spark.thrift.ThriftParser\n\n// this will return a StructType for the thrift class\nval thriftStructType = ThriftSchemaConverter.convert(ThriftExampleClass.getClass)\nval row =  ThriftParser.convertObject(\n                thriftObject,\n                thriftStructType)\n```\n\n### Use cases: consume Kafka Streaming, where each event is a thrift object\n```scala\nimport com.airbnb.spark.thrift.ThriftSchemaConverter\nimport com.airbnb.spark.thrift.ThriftParser\n\n\n directKafkaStream.foreachRDD(rdd =\u003e {\n    val schema = ThriftSchemaConverter.convert(ThriftExampleClass.getClass)\n\n     val deserializedEvents = rdd\n       .map(_.message)\n       .filter(_ != null)\n       .flatMap(eventBytes =\u003e {\n           try Some(MessageSerializer.getInstance().fromBytes(eventBytes))\n             .asInstanceOf[Option[Message[_]]]\n           catch {\n               case e: Exception =\u003e {\n                   LOG.warn(s\"Failed to deserialize  thrift event ${e.toString}\")\n                   None\n               }\n           }\n       }).map(_.getEvent.asInstanceOf[TBaseType])\n\n       val rows: RDD[Row] = ThriftParser(\n           ThriftExampleClass.getClass,\n           deserializedEvents,\n           schema)\n\n       val df = sqlContext.createDataFrame(rows, schema)\n\n       // Process the dataframe on this micrao batch\n    })\n }\n```\n\n## How to get started\nClone the project and mvn package to get the artifact.\n\n\n## How to contribute\nPlease send the PR here and cc @liyintang or @jingweilu1974 for reviewing\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairbnb%2Fairbnb-spark-thrift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairbnb%2Fairbnb-spark-thrift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairbnb%2Fairbnb-spark-thrift/lists"}