typelevel / typelevel/frameless
Use Avro as schema in TypedDataSet
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 895
- Forks
- 135
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 3
Description
Would it make sense to be able to introduce support for avro schema for TypedDataSet?
The current code defines schema based on the SparkSQL "language": https://github.com/typelevel/frameless/blob/576eb675dbd121453679a57ae7117e4fb53d9212/dataset/src/main/scala/frameless/TypedDatasetForwarded.scala#L43-L44
On the other hand frameless use a Scala types based "schema" to define data sets.
Using something like avro4s the avro schema can be derived from types.
It is quite useful to be able to use avro as schema in parquet files for example: https://dzone.com/articles/understanding-how-parquet
$ export HADOOP_CLASSPATH=parquet-avro-1.4.3.jar:parquet-column-1.4.3.jar:parquet-common-1.4.3.jar:parquet-encoding-1.4.3.jar:parquet-format-2.0.0.jar:parquet-generator-1.4.3.jar:parquet-hadoop-1.4.3.jar:parquet-hive-bundle-1.4.3.jar:parquet-jackson-1.4.3.jar:parquet-tools-1.4.3.jar
$ hadoop parquet.tools.Main meta stocks.parquet
creator: parquet-mr (build 3f25ad97f209e7653e9f816508252f850abd635f)
extra: avro.schema = {"type":"record","name":"Stock","namespace" [more]...
file schema: hip.ch5.avro.gen.Stock
--------------------------------------------------------------------------------
symbol: REQUIRED BINARY O:UTF8 R:0 D:0
date: REQUIRED BINARY O:UTF8 R:0 D:0
open: REQUIRED DOUBLE R:0 D:0
high: REQUIRED DOUBLE R:0 D:0
low: REQUIRED DOUBLE R:0 D:0
close: REQUIRED DOUBLE R:0 D:0
volume: REQUIRED INT32 R:0 D:0
adjClose: REQUIRED DOUBLE R:0 D:0
See also "Write Avro records to a Parquet file.":
https://github.com/apache/parquet-mr/blob/master/parquet-avro/src/main/java/org/apache/parquet/avro/AvroParquetWriter.java#L34
In spark-bigquery there is already a schema converter that could be use to map to and from SparkSql based schema.
See "convert between sparkSQL schemas to avro data schema"
https://github.com/spotify/spark-bigquery/blob/master/src/main/scala/com/databricks/spark/avro/SchemaConverters.scala#L114-L131
Somewhat related to https://github.com/typelevel/frameless/issues/280.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with dataset/src/main/scala/frameless/TypedDatasetForwarded.scala, especially the schema definition referenced in the issue, and review the related discussion in issue 280. Then compare the proposed Avro integration with spark-bigquery's SchemaConverters. Done should mean TypedDataSet can use Avro-derived schemas while preserving the existing SparkSQL-based behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- data-engineering
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100