private FileSinkOperator.RecordWriter getHiveWriter() throws IOException {
      if (this.hiveWriter == null){
        Properties properties = new Properties();
        for (AvroSerdeUtils.AvroTableProperties tableProperty : AvroSerdeUtils.AvroTableProperties.values()){
          String propVal;
          if((propVal = jobConf.get(tableProperty.getPropName())) != null){
            properties.put(tableProperty.getPropName(),propVal);
          }
        }

        Boolean isCompressed = jobConf.getBoolean("mapreduce.output.fileoutputformat.compress", false);
        Path path = new Path(this.fileName);
        if(path.getFileSystem(jobConf).isDirectory(path)){
          // This path is only potentially encountered during setup
          // Otherwise, a specific part_xxxx file name is generated and passed in.
          path = new Path(path,"_dummy");
        }

        this.hiveWriter = getHiveRecordWriter(jobConf,path,null,isCompressed, properties, progressable);
      }
      return this.hiveWriter;
    }
Write to an Avro file from a Hive process.
ql/src/java/org/apache/hadoop/hive/ql/io/avro/AvroContainerOutputFormat.java