@Override public void initialize(Configuration configuration, Properties properties) throws SerDeException { tsTZTypeInfo = new TimestampLocalTZTypeInfo(configuration.get(HiveConf.ConfVars.HIVE_LOCAL_TIME_ZONE.varname)); // Druid query final String druidQuery = properties.getProperty(Constants.DRUID_QUERY_JSON, null); if (druidQuery != null && !druidQuery.isEmpty()) { initFromDruidQueryPlan(properties, druidQuery); } else { // No query. Either it is a CTAS, or we need to create a Druid meta data Query if (!org.apache.commons.lang3.StringUtils.isEmpty(properties.getProperty(serdeConstants.LIST_COLUMNS)) && !org.apache.commons.lang3.StringUtils.isEmpty(properties.getProperty(serdeConstants.LIST_COLUMN_TYPES))) { // CASE CTAS statement initFromProperties(properties); } else { // Segment Metadata query that retrieves all columns present in // the data source (dimensions and metrics). initFromMetaDataQuery(configuration, properties); } } if (LOG.isDebugEnabled()) { LOG.debug("DruidSerDe initialized with\n" + "\t columns: " + Arrays.toString(columns) + "\n\t types: " + Arrays.toString(types)); } }
@Override public String toString() { return getQualifiedName(timeZone); }
TimestampLocalTZTypeInfo timestampLocalTZTypeInfo = new TimestampLocalTZTypeInfo(); HiveConf conf; try { throw new SemanticException(e); timestampLocalTZTypeInfo.setTimeZone(conf.getLocalTimeZone()); if (genericUDF != null) { ((SettableUDF)genericUDF).setTypeInfo(timestampLocalTZTypeInfo);
@Override public String getDisplayString(String[] children) { assert (children.length == 1); StringBuilder sb = new StringBuilder(); sb.append("CAST( "); sb.append(children[0]); sb.append(" AS "); sb.append(typeInfo.getTypeName()); sb.append(")"); return sb.toString(); }
final TimestampLocalTZTypeInfo timestampLocalTZTypeInfo = (TimestampLocalTZTypeInfo) typeInfo; final String timeZone = timestampLocalTZTypeInfo.getTimeZone().toString(); return Field.nullable(name, new ArrowType.Timestamp(TimeUnit.MILLISECOND, timeZone)); case BINARY:
@Override public Object set(Object o, byte[] bytes, int offset) { ((TimestampLocalTZWritable) o).set(bytes, offset, ((TimestampLocalTZTypeInfo) typeInfo).timeZone()); return o; }
final TimestampLocalTZTypeInfo tsTZTypeInfo = new TimestampLocalTZTypeInfo( conf.get(ConfVars.HIVE_LOCAL_TIME_ZONE.varname)); for (int i = 0; i < columnTypes.size(); i++) {
@Override public String getQualifiedName() { return getQualifiedName(null); }
@Override public Object set(Object o, byte[] bytes, int offset) { TimestampLocalTZWritable.setTimestampTZ( (TimestampTZ) o, bytes, offset, ((TimestampLocalTZTypeInfo) typeInfo).timeZone()); return o; }
return null; return new TimestampLocalTZTypeInfo(parts.typeParams[0]); default: return null;
public static TimestampLocalTZTypeInfo getTimestampTZTypeInfo(ZoneId defaultTimeZone) { String fullName = TimestampLocalTZTypeInfo.getQualifiedName(defaultTimeZone); return (TimestampLocalTZTypeInfo) getPrimitiveTypeInfo(fullName); };
@Override public Object create(byte[] bytes, int offset) { return new TimestampLocalTZWritable(bytes, offset, ((TimestampLocalTZTypeInfo) typeInfo).timeZone()); }
final TimestampLocalTZTypeInfo tsTZTypeInfo = new TimestampLocalTZTypeInfo( conf.get(ConfVars.HIVE_LOCAL_TIME_ZONE.varname)); for (int i = 0; i < columnTypes.size(); i++) {
public static String getTypeName(ASTNode node) throws SemanticException { int token = node.getType(); String typeName; // datetime type isn't currently supported if (token == HiveParser.TOK_DATETIME) { throw new SemanticException(ErrorMsg.UNSUPPORTED_TYPE.getMsg()); } switch (token) { case HiveParser.TOK_CHAR: CharTypeInfo charTypeInfo = ParseUtils.getCharTypeInfo(node); typeName = charTypeInfo.getQualifiedName(); break; case HiveParser.TOK_VARCHAR: VarcharTypeInfo varcharTypeInfo = ParseUtils.getVarcharTypeInfo(node); typeName = varcharTypeInfo.getQualifiedName(); break; case HiveParser.TOK_TIMESTAMPLOCALTZ: TimestampLocalTZTypeInfo timestampLocalTZTypeInfo = TypeInfoFactory.getTimestampTZTypeInfo(null); typeName = timestampLocalTZTypeInfo.getQualifiedName(); break; case HiveParser.TOK_DECIMAL: DecimalTypeInfo decTypeInfo = ParseUtils.getDecimalTypeTypeInfo(node); typeName = decTypeInfo.getQualifiedName(); break; default: typeName = TokenToTypeName.get(token); } return typeName; }
public LazyTimestampLocalTZ(LazyTimestampLocalTZObjectInspector lazyTimestampTZObjectInspector) { super(lazyTimestampTZObjectInspector); TimestampLocalTZTypeInfo typeInfo = (TimestampLocalTZTypeInfo) oi.getTypeInfo(); if (typeInfo == null) { throw new RuntimeException("TimestampLocalTZ type used without type params"); } timeZone = typeInfo.timeZone(); data = new TimestampLocalTZWritable(); }
return null; return new TimestampLocalTZTypeInfo(parts.typeParams[0]); default: return null;
@Override public String toString() { return getQualifiedName(); }
public LazyBinaryTimestampLocalTZ(WritableTimestampLocalTZObjectInspector oi) { super(oi); TimestampLocalTZTypeInfo typeInfo = (TimestampLocalTZTypeInfo) oi.getTypeInfo(); this.timeZone = typeInfo.timeZone(); this.data = new TimestampLocalTZWritable(); }
@Override public String getQualifiedName() { return getQualifiedName(timeZone); }