AngersZhuuuu commented on a change in pull request #30869: URL: https://github.com/apache/spark/pull/30869#discussion_r547610805
########## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/avro/AvroFileFormat.scala ########## @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.execution.datasources.avro + +import org.apache.avro.SchemaParseException + +object AvroFileFormat { Review comment: Add test in AvroV2Suite ``` test("SPARK-33865: Hive DDL with avro should check col name -- data source") { withTempDir { dir => val df = sql("SELECT 1, IF(1=1,1,0), ABS(1)") df.write.format("avro").save(dir.getAbsolutePath + "/test") } } ``` Same error ``` [info] AvroV2Suite: [info] - SPARK-33865: Hive DDL with avro should check col name -- data source *** FAILED *** (4 seconds, 643 milliseconds) [info] org.apache.avro.SchemaParseException: Illegal initial character: 1 [info] at org.apache.avro.Schema.validateName(Schema.java:1147) [info] at org.apache.avro.Schema.access$200(Schema.java:81) [info] at org.apache.avro.Schema$Field.<init>(Schema.java:403) [info] at org.apache.avro.SchemaBuilder$FieldBuilder.completeField(SchemaBuilder.java:2124) [info] at org.apache.avro.SchemaBuilder$FieldBuilder.completeField(SchemaBuilder.java:2120) [info] at org.apache.avro.SchemaBuilder$FieldBuilder.access$5200(SchemaBuilder.java:2034) [info] at org.apache.avro.SchemaBuilder$GenericDefault.noDefault(SchemaBuilder.java:2417) [info] at org.apache.spark.sql.avro.SchemaConverters$.$anonfun$toAvroType$1(SchemaConverters.scala:194) [info] at scala.collection.Iterator.foreach(Iterator.scala:941) [info] at scala.collection.Iterator.foreach$(Iterator.scala:941) [info] at scala.collection.AbstractIterator.foreach(Iterator.scala:1429) [info] at scala.collection.IterableLike.foreach(IterableLike.scala:74) [info] at scala.collection.IterableLike.foreach$(IterableLike.scala:73) [info] at org.apache.spark.sql.types.StructType.foreach(StructType.scala:102) [info] at org.apache.spark.sql.avro.SchemaConverters$.toAvroType(SchemaConverters.scala:191) [info] at org.apache.spark.sql.avro.AvroUtils$.$anonfun$prepareWrite$2(AvroUtils.scala:97) [info] at scala.Option.getOrElse(Option.scala:189) [info] at org.apache.spark.sql.avro.AvroUtils$.prepareWrite(AvroUtils.scala:96) [info] at org.apache.spark.sql.avro.AvroFileFormat.prepareWrite(AvroFileFormat.scala:75) [info] at org.apache.spark.sql.execution.datasources.FileFormatWriter$.write(FileFormatWriter.scala:133) [info] at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand.run(InsertIntoHadoopFsRelationCommand.scala:188) [info] at org.apache.spark.sql.execution.command.DataWritingCommandExec.sideEffectResult$lzycompute(commands.scala:108) [info] at org.apache.spark.sql.execution.command.DataWritingCommandExec.sideEffectResult(commands.scala:106) [info] at org.apache.spark.sql.execution.command.DataWritingCommandExec.doExecute(commands.scala:131) [info] at org.apache.spark.sql.execution.SparkPlan.$anonfun$execute$1(SparkPlan.scala:180) [info] at org.apache.spark.sql.execution.SparkPlan.$anonfun$executeQuery$1(SparkPlan.scala:218) [info] at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151) [info] at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:215) [info] at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:176) [info] at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:127) [info] at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:126) [info] at org.apache.spark.sql.DataFrameWriter.$anonfun$runCommand$1(DataFrameWriter.scala:989) [info] at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$5(SQLExecution.scala:103) [info] at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:163) [info] at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:90) [info] at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:772) [info] at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:64) [info] at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:989) [info] at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:438) [info] at org.apache.spark.sql.DataFrameWriter.saveInternal(DataFrameWriter.scala:415) [info] at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:293) [info] at org.apache.spark.sql.avro.AvroV2Suite.$anonfun$new$268(AvroSuite.scala:2090) [info] at org.apache.spark.sql.avro.AvroV2Suite.$anonfun$new$268$adapted(AvroSuite.scala:2088) [info] at org.apache.spark.sql.test.SQLTestUtils.$anonfun$withTempDir$1(SQLTestUtils.scala:78) [info] at org.apache.spark.sql.test.SQLTestUtils.$anonfun$withTempDir$1$adapted(SQLTestUtils.scala:77) [info] at org.apache.spark.SparkFunSuite.withTempDir(SparkFunSuite.scala:188) [info] at org.apache.spark.sql.avro.AvroSuite.org$apache$spark$sql$test$SQLTestUtils$$super$withTempDir(AvroSuite.scala:57) [info] at org. ``` ---------------------------------------------------------------- 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: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
