Skip to content

Commit 60c7681

Browse files
authored
add documentation for Abris 5 (#253)
* add documentation for Abris 5 - remove unused dependencies - remove prints in test
1 parent 8c65177 commit 60c7681

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

README.md

+27-16
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55
- Pain free Spark/Avro integration.
66

7+
- Seamlessly integrate with Confluent platform, including Schema Registry with all available [naming strategies](https://docs.confluent.io/current/schema-registry/serializer-formatter.html#how-the-naming-strategies-work) and schema evolution.
8+
79
- Seamlessly convert your Avro records from anywhere (e.g. Kafka, Parquet, HDFS, etc) into Spark Rows.
810

911
- Convert your Dataframes into Avro records without even specifying a schema.
1012

11-
- Seamlessly integrate with Confluent platform, including Schema Registry with all available [naming strategies](https://docs.confluent.io/current/schema-registry/serializer-formatter.html#how-the-naming-strategies-work) and schema evolution.
12-
1313
- Go back-and-forth Spark Avro (since Spark 2.4).
1414

1515

@@ -21,17 +21,33 @@
2121
| 2.12 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/za.co.absa/abris_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/za.co.absa/abris_2.12) |
2222

2323
## Supported Spark versions
24-
On spark 3.0.x and 2.4.x Abris should work without any further requirements.
24+
On spark 2.4.x, 3.0.x and 3.1.x Abris should work without any further requirements.
2525

26-
On Spark 2.3.x you must declare dependency on ```org.apache.avro:avro:1.8.0``` or higher. (Spark 2.3.x uses Avro 1.7.x so you must overwrite this because ABRiS needs Avro 1.8.0+.)
26+
On Spark 2.3.x you must declare dependency on ```org.apache.avro:avro:1.8.0``` or higher.
27+
(Spark 2.3.x uses Avro 1.7.x so you must overwrite this because ABRiS needs Avro 1.8.0+.)
2728

2829
## Older Versions
29-
This is documentation for Abris **version 4**. Documentation for **version 3** is located in
30+
This is documentation for Abris **version 5**. Documentation for older versions is located in corresponding branches:
31+
[branch-4](https://github.com/AbsaOSS/ABRiS/tree/branch-4),
3032
[branch-3.2](https://github.com/AbsaOSS/ABRiS/tree/branch-3.2).
3133

34+
## Spark Avro Version
35+
Abris by default uses Spark Avro version 2.4, but it is recommended to use the version matching the used Spark Core version.
36+
To do this override the dependency on `org.apache.spark:spark-avro`.
37+
38+
For example why is this beneficial: Spark Avro 3.0 accepts nullable columns even for non-nullable avro schema.
39+
This means the Spark schema doesn't need to be changed (to non-nullable columns) for avro conversion to succeed.
40+
41+
## Confluent Schema Registry Version
42+
Abris by default uses Confluent client version 5.3.4. Although Abris is able to work with newer versions as well
43+
the Avro 1.8 used by Spark is not compatible with them.
44+
45+
Spark 3.2 uses Avro 1.10 which should work well with newer Confluent. Abris for Spark 3.2 is in development.
46+
3247
## Usage
3348

34-
ABRiS API is in it's most basic form almost identical to Spark built-in support for Avro, but it provides additional functionality. Mainly it's support of schema registry and also seamless integration with confluent Avro data format.
49+
ABRiS API is in it's most basic form almost identical to Spark built-in support for Avro, but it provides additional functionality.
50+
Mainly it's support of schema registry and also seamless integration with confluent Avro data format.
3551

3652
The API consists of two Spark SQL expressions (`to_avro` and `from_avro`) and fluent configurator (`AbrisConfig`)
3753

@@ -64,7 +80,9 @@ Full runnable examples can be found in the ```za.co.absa.abris.examples``` packa
6480
`provided` scope, or change the scope directly.
6581

6682
### Confluent Avro format
67-
The format of Avro binary data is defined in [Avro specification](http://avro.apache.org/docs/current/spec.html). Confluent format extends it and prepends the schema id before the actual record. The Confluent expressions in this library expect this format and add the id after the Avro data are generated or remove it before they are parsed.
83+
The format of Avro binary data is defined in [Avro specification](http://avro.apache.org/docs/current/spec.html).
84+
Confluent format extends it and prepends the schema id before the actual record.
85+
The Confluent expressions in this library expect this format and add the id after the Avro data are generated or remove it before they are parsed.
6886

6987
You can find more about Confluent and Schema Registry in [Confluent documentation](https://docs.confluent.io/current/schema-registry/index.html).
7088

@@ -74,8 +92,8 @@ You can find more about Confluent and Schema Registry in [Confluent documentatio
7492
Only Schema registry client setting that is mandatory is the url,
7593
but if you need to provide more the configurer allows you to provide a whole map.
7694

77-
For example you may want to provide `basic.auth.user.info` and `basic.auth.credentials.source` required for user authentication.
78-
You can do this this way:
95+
For example, you may want to provide `basic.auth.user.info` and `basic.auth.credentials.source` required for user authentication.
96+
You can do it this way:
7997

8098
```scala
8199
val registryConfig = Map(
@@ -149,13 +167,6 @@ because all rows in dataframe must have the same schema.
149167
So if you have multiple incompatible types of avro data in a dataframe you must first sort them out to several dataframes.
150168
One for each schema. Then you can use Abris and convert the avro data.
151169

152-
## Avro Fixed type
153-
**Fixed** is an alternative way of encoding binary data in Avro.
154-
Unlike *bytes* type the fixed type doesn't store the length of the data in the payload, but in Avro schema itself.
155-
156-
The corresponding data type in Spark is **BinaryType**, but the inferred schema will always use bytes type for this kind of data.
157-
If you want to use the fixed type you must provide the appropriate Avro schema.
158-
159170
---
160171

161172
Copyright 2018 ABSA Group Limited

pom.xml

-10
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,6 @@
196196
<artifactId>kafka-schema-registry-client</artifactId>
197197
<version>${confluent.version}</version>
198198
</dependency>
199-
<dependency>
200-
<groupId>io.confluent</groupId>
201-
<artifactId>common-config</artifactId>
202-
<version>${confluent.version}</version>
203-
</dependency>
204-
<dependency>
205-
<groupId>io.confluent</groupId>
206-
<artifactId>common-utils</artifactId>
207-
<version>${confluent.version}</version>
208-
</dependency>
209199

210200
<!-- Other -->
211201
<dependency>

src/test/scala/za/co/absa/abris/avro/sql/CatalystAvroConversionSpec.scala

-3
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ class CatalystAvroConversionSpec extends FlatSpec with Matchers with BeforeAndAf
305305
val result = avroBytes
306306
.select(from_avro('avroBytes, fromAvroConfig) as 'bytes)
307307

308-
dataFrame.select('bytes).printSchema()
309-
result.printSchema()
310-
311308
shouldEqualByData(dataFrame.select('bytes), result)
312309
}
313310

0 commit comments

Comments
 (0)