Improve Parquet documentation for AvroCompat, @doc annotation#885
Merged
clairemcginty merged 4 commits intomainfrom Jan 12, 2024
Merged
Improve Parquet documentation for AvroCompat, @doc annotation#885clairemcginty merged 4 commits intomainfrom
clairemcginty merged 4 commits intomainfrom
Conversation
clairemcginty
commented
Jan 11, 2024
|
|
||
| However, the parquet-avro API encodes array types differently: as a nested array inside a required group. | ||
|
|
||
| ```scala mdoc |
Contributor
Author
There was a problem hiding this comment.
after running sbt site/mdoc this evaluates to:
import org.apache.avro.Schema
val avroSchema = new Schema.Parser().parse("{\"type\":\"record\",\"name\":\"MyRecord\",\"fields\":[{\"name\": \"listField\", \"type\": {\"type\": \"array\", \"items\": \"string\"}}]}")
// avroSchema: Schema = {"type":"record","name":"MyRecord","fields":[{"name":"listField","type":{"type":"array","items":"string"}}]}
import org.apache.parquet.avro.AvroSchemaConverter
new AvroSchemaConverter().convert(avroSchema)
// res4: org.apache.parquet.schema.MessageType = message MyRecord {
// required group listField (LIST) {
// repeated binary array (STRING);
// }
// }
//| writer.write(MyRecord(List(1,2,3))) | ||
| writer.close() | ||
|
|
||
| ParquetFileReader.open(HadoopInputFile.fromPath(path, new Configuration())).getFileMetaData |
Contributor
Author
There was a problem hiding this comment.
after running sbt site/mdoc this block evaluates to:
import magnolify.parquet._
import magnolify.parquet.ParquetArray.AvroCompat._
import magnolify.shared._
@doc("Top level annotation")
case class MyRecord(@doc("field annotation") listField: List[Int])
val writer = ParquetType[MyRecord]
.writeBuilder(HadoopOutputFile.fromPath(path, new Configuration()))
.build()
// writer: org.apache.parquet.hadoop.ParquetWriter[MyRecord] = org.apache.parquet.hadoop.ParquetWriter@432302e5
writer.write(MyRecord(List(1,2,3)))
writer.close()
ParquetFileReader.open(HadoopInputFile.fromPath(path, new Configuration())).getFileMetaData
// res12: org.apache.parquet.hadoop.metadata.FileMetaData = FileMetaData{schema: message repl.MdocSession.MdocApp9.MyRecord {
// required group listField (LIST) {
// repeated int32 array (INTEGER(32,true));
// }
// }
// , metadata: {writer.model.name=magnolify, parquet.avro.schema={"type":"record","name":"MyRecord","namespace":"repl.MdocSession.MdocApp9","doc":"Top level annotation","fields":[{"name":"listField","type":{"type":"array","items":"int"},"doc":"field annotation"}]}}}5fd732c to
170abc2
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #885 +/- ##
=======================================
Coverage 95.17% 95.17%
=======================================
Files 51 51
Lines 1825 1825
Branches 157 157
=======================================
Hits 1737 1737
Misses 88 88 ☔ View full report in Codecov by Sentry. |
RustedBones
approved these changes
Jan 12, 2024
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.