-
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
310faf8
commit 56e82c2
Showing
3 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,6 @@ options: | |
|
||
- title: (Experimental) ETL | ||
url: docs/experimental | ||
|
||
- title: (Experimental) Protobuf | ||
url: docs/protobuf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
layout: docs | ||
title: Read and write Parquet from and to Protobuf | ||
permalink: docs/protobuf/ | ||
--- | ||
|
||
# Read and write Parquet from and to Protobuf | ||
|
||
Using the original Java Parquet library, you can read and write parquet to and from Protbuf. Parquet4s has `custom` functions in its API, which could be leveraged for that. However, Protobuf Parquet can only be used with Java models, not to mention other issues that make it hard to use, especially in Scala. You would prefer to use [ScalaPB](https://scalapb.github.io/) in Scala projects, right? Thanks to Parquet4S, you can! Import ScalaPB extension to any Parquet4S project, either it is Akka, FS2 or plain Scala: | ||
|
||
```scala | ||
"com.github.mjakubowski84" %% "parquet4s-scalapb" % "@VERSION@" | ||
``` | ||
|
||
Follow the ScalaPB [documentation](https://scalapb.github.io/docs/installation) to generate your Scala model from `.proto` files. | ||
|
||
Then, import Parquet4S type classes tailored for Protobuf. The rest of the code stays the same as in regular Parquet4S - no matter if that is Akka, FS2 or core! | ||
|
||
```scala mdoc:compile-only | ||
import com.github.mjakubowski84.parquet4s.ScalaPBImplicits.* | ||
import com.github.mjakubowski84.parquet4s.protobuf.Data | ||
import com.github.mjakubowski84.parquet4s.{ParquetReader, ParquetWriter, Path} | ||
|
||
import scala.util.Using | ||
|
||
val data: Iterable[Data] = ??? // your data | ||
val path: Path = ??? // path to write to / to read from | ||
|
||
// write | ||
ParquetWriter.of[Data].writeAndClose(path.append("data.parquet"), data) | ||
|
||
// read | ||
Using(ParquetReader.as[Data].read(path))(_.foreach(println)) | ||
``` | ||
|
||
Please follow the [examples](https://github.com/mjakubowski84/parquet4s/tree/master/examples/src/main/scala/com/github/mjakubowski84/parquet4s/scalapb) to learn more. |