Github user HyukjinKwon commented on a diff in the pull request:
https://github.com/apache/spark/pull/22037#discussion_r209130685
--- Diff:
external/avro/src/test/scala/org/apache/spark/sql/avro/AvroSuite.scala ---
@@ -475,6 +498,41 @@ class AvroSuite extends QueryTest with
SharedSQLContext with SQLTestUtils {
checkAnswer(df, expected)
}
+ test("Logical type: Decimal") {
+ val expected = Seq((1.23, 45.67), (65.37, 81.39))
+ .map { d =>
+ Row(new java.math.BigDecimal(d._1.toString), new
java.math.BigDecimal(d._2.toString))
+ }
+ val df = spark.read.format("avro").load(decimalAvro)
+
+ checkAnswer(df, expected)
+
+ val avroSchema = s"""
+ {
+ "namespace": "logical",
+ "type": "record",
+ "name": "test",
+ "fields": [
+ {"name": "bytes", "type":
+ {"type": "bytes", "logicalType": "decimal", "precision": 4,
"scale": 2}
+ },
+ {"name": "fixed", "type":
+ {"type": "fixed", "size": 5, "logicalType": "decimal",
+ "precision": 4, "scale": 2, "name": "foo"}
--- End diff --
One option might be to use json4s and convert it to JSON string.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]