[jira] [Created] (CARBONDATA-2461) DIS customer Schema is not supported,Even Mapped to String Column

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (CARBONDATA-2461) DIS customer Schema is not supported,Even Mapped to String Column

Akash R Nilugal (Jira)
Praveen M P created CARBONDATA-2461:
---------------------------------------

             Summary: DIS customer Schema is not supported,Even Mapped to String Column
                 Key: CARBONDATA-2461
                 URL: https://issues.apache.org/jira/browse/CARBONDATA-2461
             Project: CarbonData
          Issue Type: Bug
            Reporter: Praveen M P


val avroschema="""{
| "type": "record",
| "name": "RecordName",
| "fields": [
| {
| "name": "timeStamp",
| "type": "long",
| "doc": "Type inferred from '1500277699000'"
| },
| {
| "name": "vin",
| "type": "string",
| "doc": "Type inferred from '\"LFV0A24G5G3028152\"'"
| },
| {
| "name": "event",
| "type": "string",
| "doc": "Type inferred from '\"upload\"'"
| },
| {
| "name": "signals",
| "type": {
| "type": "array",
| "items": {
| "type": "record",
| "name": "signals",
| "fields": [
| {
| "name": "valueType",
| "type": "string",
| "doc": "Type inferred from '\"int\"'"
| },
| {
| "name": "status",
| "type": "string",
| "doc": "Type inferred from '\"VALID\"'"
| },
| {
| "name": "code",
| "type": "string",
| "doc": "Type inferred from '\"V048\"'"
| },
| {
| "name": "name_en",
| "type": "string",
| "doc": "Type inferred from '\"VehicleStatus\"'"
| },
| {
| "name": "name",
| "type": "string",
| "doc": "Type inferred from '\"车辆状态\"'"
| },
| {
| "name": "value",
| "type": "string",
| "doc": "Type inferred from '\"3\"'"
| }
| ]
| }
| }
| },
| {
| "name": "metaData",
| "type": "string",
| "doc": "Type inferred from '\"\{\\\"reissueFlag\\\":0}\"'"
| },
| {
| "name": "orginalReport",
| "type": null,
| "doc": "Type inferred from 'null'"
| },
| {
| "name": "uploadType",
| "type": "string",
| "doc": "Type inferred from '\"upload\"'"
| },
| {
| "name": "uploadTime",
| "type": "long",
| "doc": "Type inferred from '1500277699000'"
| }
| ]
|}""".stripMargin
val jvalue=SupportSDK_1.readFileAndConvertoStringObject("D:/Hadoop/carbon_1_3/sdk/JVData.json");

val fields = new Array[Field](8)
fields(0)=new Field("timeStamp", DataTypes.LONG)
fields(1)=new Field("vin", DataTypes.STRING)
fields(2)=new Field("event", DataTypes.STRING)

val fld_s = new java.util.ArrayList[StructField]
fld_s.add(new StructField("valueType", DataTypes.STRING))
fld_s.add(new StructField("status", DataTypes.STRING))
fld_s.add(new StructField("code", DataTypes.STRING))
fld_s.add(new StructField("name_en", DataTypes.STRING))
fld_s.add(new StructField("name", DataTypes.STRING))
fld_s.add(new StructField("value", DataTypes.STRING))

val fld_s_n = new java.util.ArrayList[StructField]
fld_s_n.add(new StructField("signals", DataTypes.createStructType(fld_s)))
fields(3)=new Field("signals", "array",fld_s_n)

fields(4)=new Field("metaData", DataTypes.STRING)
fields(5)=new Field("orginalReport", DataTypes.STRING)
fields(6)=new Field("uploadType", DataTypes.STRING)
fields(7)=new Field("uploadTime", DataTypes.LONG)

val converter = new JsonAvroConverter();
val parsedAschema=new org.apache.avro.Schema.Parser().parse(avroschema)

val record = converter.convertToGenericDataRecord(
jvalue.getBytes(CharEncoding.UTF_8),parsedAschema );

try {
val writer = CarbonWriter.builder.withSchema(new Schema(fields)).sortBy(Array("vin"))
.outputPath("D:/Hadoop/carbon_1_3/sdk/carbon_cust_1").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)