[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] Support user provided avro schema for writing fields with different ordering

2019-05-20 Thread GitBox
dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] 
Support user provided avro schema for writing fields with different ordering
URL: https://github.com/apache/spark/pull/24635#discussion_r285805169
 
 

 ##
 File path: 
external/avro/src/test/scala/org/apache/spark/sql/avro/AvroSuite.scala
 ##
 @@ -692,7 +692,7 @@ class AvroSuite extends QueryTest with SharedSQLContext 
with SQLTestUtils {
   |  "type" : "record",
   |  "name" : "test_schema",
   |  "fields" : [{
-  |"name": "enum",
+  |"name": "Suit",
 
 Review comment:
   Ya. The newly updated test code looks more clear.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] Support user provided avro schema for writing fields with different ordering

2019-05-20 Thread GitBox
dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] 
Support user provided avro schema for writing fields with different ordering
URL: https://github.com/apache/spark/pull/24635#discussion_r285804966
 
 

 ##
 File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroSerializer.scala
 ##
 @@ -205,18 +205,28 @@ class AvroSerializer(rootCatalystType: DataType, 
rootAvroType: Schema, nullable:
   throw new IncompatibleSchemaException(s"Cannot convert Catalyst type 
$catalystStruct to " +
 s"Avro type $avroStruct.")
 }
-val fieldConverters = catalystStruct.zip(avroStruct.getFields.asScala).map 
{
-  case (f1, f2) => newConverter(f1.dataType, 
resolveNullableType(f2.schema(), f1.nullable))
-}
+
+val (avroIndices: Array[Int], fieldConverters: Array[Converter]) =
+  catalystStruct.map { catalystField =>
+val avroField = avroStruct.getField(catalystField.name)
+if (avroField == null) {
 
 Review comment:
   +1 for that.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] Support user provided avro schema for writing fields with different ordering

2019-05-17 Thread GitBox
dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] 
Support user provided avro schema for writing fields with different ordering
URL: https://github.com/apache/spark/pull/24635#discussion_r285326200
 
 

 ##
 File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroSerializer.scala
 ##
 @@ -205,18 +205,28 @@ class AvroSerializer(rootCatalystType: DataType, 
rootAvroType: Schema, nullable:
   throw new IncompatibleSchemaException(s"Cannot convert Catalyst type 
$catalystStruct to " +
 s"Avro type $avroStruct.")
 }
-val fieldConverters = catalystStruct.zip(avroStruct.getFields.asScala).map 
{
-  case (f1, f2) => newConverter(f1.dataType, 
resolveNullableType(f2.schema(), f1.nullable))
-}
+
+val (avroIndices: Array[Int], fieldConverters: Array[Converter]) =
+  catalystStruct.map { catalystField =>
+val avroField = avroStruct.getField(catalystField.name)
+if (avroField == null) {
 
 Review comment:
   To fix `enum` issue at 
https://github.com/apache/spark/pull/24635#discussion_r285326100, can we try to 
use the corresponding field at the same position when `avroField == null`?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] Support user provided avro schema for writing fields with different ordering

2019-05-17 Thread GitBox
dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] 
Support user provided avro schema for writing fields with different ordering
URL: https://github.com/apache/spark/pull/24635#discussion_r285326200
 
 

 ##
 File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroSerializer.scala
 ##
 @@ -205,18 +205,28 @@ class AvroSerializer(rootCatalystType: DataType, 
rootAvroType: Schema, nullable:
   throw new IncompatibleSchemaException(s"Cannot convert Catalyst type 
$catalystStruct to " +
 s"Avro type $avroStruct.")
 }
-val fieldConverters = catalystStruct.zip(avroStruct.getFields.asScala).map 
{
-  case (f1, f2) => newConverter(f1.dataType, 
resolveNullableType(f2.schema(), f1.nullable))
-}
+
+val (avroIndices: Array[Int], fieldConverters: Array[Converter]) =
+  catalystStruct.map { catalystField =>
+val avroField = avroStruct.getField(catalystField.name)
+if (avroField == null) {
 
 Review comment:
   To fix `enum` issue at 
https://github.com/apache/spark/pull/24635#discussion_r285326100, can we use 
the corresponding field at the same position when `avroField == null`?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] Support user provided avro schema for writing fields with different ordering

2019-05-17 Thread GitBox
dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] 
Support user provided avro schema for writing fields with different ordering
URL: https://github.com/apache/spark/pull/24635#discussion_r285326200
 
 

 ##
 File path: 
external/avro/src/main/scala/org/apache/spark/sql/avro/AvroSerializer.scala
 ##
 @@ -205,18 +205,28 @@ class AvroSerializer(rootCatalystType: DataType, 
rootAvroType: Schema, nullable:
   throw new IncompatibleSchemaException(s"Cannot convert Catalyst type 
$catalystStruct to " +
 s"Avro type $avroStruct.")
 }
-val fieldConverters = catalystStruct.zip(avroStruct.getFields.asScala).map 
{
-  case (f1, f2) => newConverter(f1.dataType, 
resolveNullableType(f2.schema(), f1.nullable))
-}
+
+val (avroIndices: Array[Int], fieldConverters: Array[Converter]) =
+  catalystStruct.map { catalystField =>
+val avroField = avroStruct.getField(catalystField.name)
+if (avroField == null) {
 
 Review comment:
   To fix `enum` issue, can we use the corresponding field at the same position 
when `avroField == null`?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] Support user provided avro schema for writing fields with different ordering

2019-05-17 Thread GitBox
dongjoon-hyun commented on a change in pull request #24635: [SPARK-27762][SQL] 
Support user provided avro schema for writing fields with different ordering
URL: https://github.com/apache/spark/pull/24635#discussion_r285326100
 
 

 ##
 File path: 
external/avro/src/test/scala/org/apache/spark/sql/avro/AvroSuite.scala
 ##
 @@ -692,7 +692,7 @@ class AvroSuite extends QueryTest with SharedSQLContext 
with SQLTestUtils {
   |  "type" : "record",
   |  "name" : "test_schema",
   |  "fields" : [{
-  |"name": "enum",
+  |"name": "Suit",
 
 Review comment:
   `enum` type name and the field name (of that `enum` type) can be different. 
We should not assume that this line is equal to the line 697.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org