public static Buffer getBufferFromDecimal(HiveDecimal dec, int scale) {
    if (dec == null) {
      return null;
    }

    // NOTE: Previously, we did OldHiveDecimal.setScale(scale), called OldHiveDecimal
    //       unscaledValue().toByteArray().
    return AvroSerdeUtils.getBufferFromBytes(dec.bigIntegerBytesScaled(scale));
  }
Determine if we're being executed from within an MR job or as part
of a select * statement.  The signals for this varies between Hive versions.
@param job that contains things that are or are not set in a job
@return Are we in a job or not?
serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerdeUtils.java