Kunal Kapoor created CARBONDATA-2453:
----------------------------------------
Summary: Data write fails if complex data type contains a field with same name as any other field(not of same complex data type)
Key: CARBONDATA-2453
URL:
https://issues.apache.org/jira/browse/CARBONDATA-2453 Project: CarbonData
Issue Type: Bug
Reporter: Kunal Kapoor
val myaSchema=
"""{
| "type": "record",
| "name": "Order",
| "namespace": "com.apache.schema",
| "fields": [
| {
| "name": "id",
| "type": "long"
| },
| {
| "name": "date",
| "type": "long"
| },
| {
| "name": "entries",
| "type": {
| "type": "array",
| "items": {
| "type": "record",
| "name": "Entry",
| "fields": [
| {
| "name": "id",
| "type": "long"
| },
| {
| "name": "description",
| "type": "string"
| },
| {
| "name": "quantity",
| "type": "int"
| }
| ]
| }
|
| }
| }
| ]
|}""".stripMargin
var json = """{"id": 1525693807954, "date": 1419058662391170, "entries": [{"id":
1525693807954, "description": "Appliances", "quantity": 125}, {"id": 1525693807954,
"description": "Electronics", "quantity": 250}]}
""".stripMargin
val nn = new org.apache.avro.Schema.Parser().parse(myaSchema)
val converter = new JsonAvroConverter
var record = converter
.convertToGenericDataRecord(json.getBytes(CharEncoding.UTF_8), nn)
val fields = new Array[Field](3)
fields(0)=new Field("id", DataTypes.LONG)
fields(1)=new Field("date",DataTypes.DATE)
val fld_a = new java.util.ArrayList[StructField]
fld_a.add(new StructField("id", DataTypes.LONG))
fld_a.add(new StructField("desc", DataTypes.STRING))
fld_a.add(new StructField("QTY", DataTypes.INT))
fields(2)=new Field("entries", DataTypes.createStructType(fld_a))
try {
val writer = CarbonWriter.builder.withSchema(new Schema(fields))
.outputPath("D:/Hadoop/carbon_1_3/sdk/carbon_bln_4").isTransactionalTable(false).buildWriterForAvroInput
writer.write(record)
writer.close()
}
catch {
case e: Exception => {
e.printStackTrace()
}
}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)