private Object getScalarValue(ExprNodeConstantDesc constDesc) throws HiveException { if (constDesc.getTypeString().equalsIgnoreCase("String")) { try { byte[] bytes = ((String) constDesc.getValue()).getBytes("UTF-8"); return bytes; } catch (Exception ex) { throw new HiveException(ex); } } else if (constDesc.getTypeString().equalsIgnoreCase("boolean")) { if (constDesc.getValue().equals(Boolean.valueOf(true))) { return 1; } else { return 0; } } else if (decimalTypePattern.matcher(constDesc.getTypeString()).matches()) { return constDesc.getValue(); } else { return constDesc.getValue(); } }
private Object getScalarValue(ExprNodeConstantDesc constDesc) throws HiveException { String typeString = constDesc.getTypeString(); if (typeString.equalsIgnoreCase("String")) { return ((String) constDesc.getValue()).getBytes(StandardCharsets.UTF_8); } else if (charTypePattern.matcher(typeString).matches()) { return ((HiveChar) constDesc.getValue()).getStrippedValue().getBytes(StandardCharsets.UTF_8); } else if (varcharTypePattern.matcher(typeString).matches()) { return ((HiveVarchar) constDesc.getValue()).getValue().getBytes(StandardCharsets.UTF_8); } else if (typeString.equalsIgnoreCase("boolean")) { if (constDesc.getValue().equals(Boolean.TRUE)) { return 1; } else { return 0; } } else if (decimalTypePattern.matcher(typeString).matches()) { return constDesc.getValue(); } else { return constDesc.getValue(); } }
} catch (ClassCastException cce) { throw new IOException("Currently only primitve types are supported. Found: " + sc.getConstantDesc().getTypeString()); } catch (HiveException e) { throw new IOException(e);
private Timestamp getTimestampScalar(ExprNodeDesc expr) throws HiveException { if (expr instanceof ExprNodeGenericFuncDesc && ((ExprNodeGenericFuncDesc) expr).getGenericUDF() instanceof GenericUDFTimestamp) { return evaluateCastToTimestamp(expr); } if (!(expr instanceof ExprNodeConstantDesc)) { throw new HiveException("Constant timestamp value expected for expression argument. " + "Non-constant argument not supported for vectorization."); } ExprNodeConstantDesc constExpr = (ExprNodeConstantDesc) expr; String constTypeString = constExpr.getTypeString(); if (isStringFamily(constTypeString) || isDatetimeFamily(constTypeString)) { // create expression tree with type cast from string to timestamp ExprNodeGenericFuncDesc expr2 = new ExprNodeGenericFuncDesc(); GenericUDFTimestamp f = new GenericUDFTimestamp(); expr2.setGenericUDF(f); ArrayList<ExprNodeDesc> children = new ArrayList<>(); children.add(expr); expr2.setChildren(children); // initialize and evaluate return evaluateCastToTimestamp(expr2); } throw new HiveException("Udf: unhandled constant type for scalar argument. " + "Expecting string/date/timestamp."); }
private Timestamp getTimestampScalar(ExprNodeDesc expr) throws HiveException { if (expr instanceof ExprNodeGenericFuncDesc && ((ExprNodeGenericFuncDesc) expr).getGenericUDF() instanceof GenericUDFTimestamp) { return evaluateCastToTimestamp(expr); } if (!(expr instanceof ExprNodeConstantDesc)) { throw new HiveException("Constant timestamp value expected for expression argument. " + "Non-constant argument not supported for vectorization."); } ExprNodeConstantDesc constExpr = (ExprNodeConstantDesc) expr; String constTypeString = constExpr.getTypeString(); if (isStringFamily(constTypeString) || isDatetimeFamily(constTypeString)) { // create expression tree with type cast from string to timestamp ExprNodeGenericFuncDesc expr2 = new ExprNodeGenericFuncDesc(); GenericUDFTimestamp f = new GenericUDFTimestamp(); expr2.setGenericUDF(f); ArrayList<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>(); children.add(expr); expr2.setChildren(children); // initialize and evaluate return evaluateCastToTimestamp(expr2); } throw new HiveException("Udf: unhandled constant type for scalar argument. " + "Expecting string/date/timestamp."); }
if (!valExpr.getTypeString().equals(type)) { Converter converter = ObjectInspectorConverters.getConverter( TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(valExpr.getTypeInfo()),
if (!valExpr.getTypeString().equals(type)) { Converter converter = ObjectInspectorConverters.getConverter( TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(valExpr.getTypeInfo()),
colType = encd.getTypeString(); if (encd.getValue() == null) {
colType = encd.getTypeString(); if (encd.getValue() == null) {
private Object getScalarValue(ExprNodeConstantDesc constDesc) throws HiveException { if (constDesc.getTypeString().equalsIgnoreCase("String")) { try { byte[] bytes = ((String) constDesc.getValue()).getBytes("UTF-8"); return bytes; } catch (Exception ex) { throw new HiveException(ex); } } else if (constDesc.getTypeString().equalsIgnoreCase("boolean")) { if (constDesc.getValue().equals(Boolean.valueOf(true))) { return 1; } else { return 0; } } else if (decimalTypePattern.matcher(constDesc.getTypeString()).matches()) { return constDesc.getValue(); } else { return constDesc.getValue(); } }
} catch (ClassCastException cce) { throw new IOException("Currently only primitve types are supported. Found: " + sc.getConstantDesc().getTypeString()); } catch (HiveException e) { throw new IOException(e);
} catch (ClassCastException cce) { throw new IOException("Currently only primitve types are supported. Found: " + sc.getConstantDesc().getTypeString()); } catch (HiveException e) { throw new IOException(e);
public CompareOp getCompareOp(String udfType, IndexSearchCondition sc) throws NoSuchCompareOpException, SerDeException { Class<? extends CompareOp> clz = getCompareOpClass(udfType); try { return clz.newInstance(); } catch (ClassCastException e) { throw new SerDeException("Column type mismatch in WHERE clause " + sc.getComparisonExpr().getExprString() + " found type " + sc.getConstantDesc().getTypeString() + " instead of " + sc.getColumnDesc().getTypeString()); } catch (IllegalAccessException e) { throw new SerDeException("Could not instantiate class for WHERE clause", e); } catch (InstantiationException e) { throw new SerDeException("Could not instantiate class for WHERE clause", e); } }
private long getTimestampScalar(ExprNodeDesc expr) throws HiveException { if (expr instanceof ExprNodeGenericFuncDesc && ((ExprNodeGenericFuncDesc) expr).getGenericUDF() instanceof GenericUDFTimestamp) { return evaluateCastToTimestamp(expr); } if (!(expr instanceof ExprNodeConstantDesc)) { throw new HiveException("Constant timestamp value expected for expression argument. " + "Non-constant argument not supported for vectorization."); } ExprNodeConstantDesc constExpr = (ExprNodeConstantDesc) expr; if (isStringFamily(constExpr.getTypeString())) { // create expression tree with type cast from string to timestamp ExprNodeGenericFuncDesc expr2 = new ExprNodeGenericFuncDesc(); GenericUDFTimestamp f = new GenericUDFTimestamp(); expr2.setGenericUDF(f); ArrayList<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>(); children.add(expr); expr2.setChildren(children); // initialize and evaluate return evaluateCastToTimestamp(expr2); } throw new HiveException("Udf: unhandled constant type for scalar argument. " + "Expecting string."); }
public PrimitiveComparison getPrimitiveComparison(String type, IndexSearchCondition sc) throws NoSuchPrimitiveComparisonException, SerDeException { Class<? extends PrimitiveComparison> clz = getPrimitiveComparisonClass(type); try { return clz.newInstance(); } catch (ClassCastException e) { throw new SerDeException("Column type mismatch in WHERE clause " + sc.getComparisonExpr().getExprString() + " found type " + sc.getConstantDesc().getTypeString() + " instead of " + sc.getColumnDesc().getTypeString()); } catch (IllegalAccessException e) { throw new SerDeException("Could not instantiate class for WHERE clause", e); } catch (InstantiationException e) { throw new SerDeException("Could not instantiate class for WHERE clause", e); } }
public CompareOp getCompareOp(String udfType, IndexSearchCondition sc) throws NoSuchCompareOpException, SerDeException { Class<? extends CompareOp> clz = getCompareOpClass(udfType); try { return clz.newInstance(); } catch (ClassCastException e) { throw new SerDeException("Column type mismatch in WHERE clause " + sc.getIndexExpr().getExprString() + " found type " + sc.getConstantDesc().getTypeString() + " instead of " + sc.getColumnDesc().getTypeString()); } catch (IllegalAccessException e) { throw new SerDeException("Could not instantiate class for WHERE clause", e); } catch (InstantiationException e) { throw new SerDeException("Could not instantiate class for WHERE clause", e); } }
public PrimitiveComparison getPrimitiveComparison(String type, IndexSearchCondition sc) throws NoSuchPrimitiveComparisonException, SerDeException { Class<? extends PrimitiveComparison> clz = getPrimitiveComparisonClass(type); try { return clz.newInstance(); } catch (ClassCastException e) { throw new SerDeException("Column type mismatch in WHERE clause " + sc.getIndexExpr().getExprString() + " found type " + sc.getConstantDesc().getTypeString() + " instead of " + sc.getColumnDesc().getTypeString()); } catch (IllegalAccessException e) { throw new SerDeException("Could not instantiate class for WHERE clause", e); } catch (InstantiationException e) { throw new SerDeException("Could not instantiate class for WHERE clause", e); } }
public PushdownTuple(IndexSearchCondition sc, PrimitiveComparison pCompare, CompareOp cOpt) throws SerDeException { ExprNodeConstantEvaluator eval = new ExprNodeConstantEvaluator(sc.getConstantDesc()); try { this.pCompare = pCompare; this.cOpt = cOpt; Writable writable = (Writable) eval.evaluate(null); constVal = getConstantAsBytes(writable); } catch (ClassCastException cce) { log.info(StringUtils.stringifyException(cce)); throw new SerDeException(" Column type mismatch in where clause " + sc.getIndexExpr().getExprString() + " found type " + sc.getConstantDesc().getTypeString() + " instead of " + sc.getColumnDesc().getTypeString()); } catch (HiveException e) { throw new SerDeException(e); } }
if (!valExpr.getTypeString().equals(type)) { Converter converter = ObjectInspectorConverters.getConverter( TypeInfoUtils.getStandardJavaObjectInspectorFromTypeInfo(valExpr.getTypeInfo()),
public PushdownTuple(IndexSearchCondition sc, PrimitiveComparison pCompare, CompareOp cOpt) throws SerDeException { ExprNodeConstantEvaluator eval = new ExprNodeConstantEvaluator(sc.getConstantDesc()); try { this.pCompare = pCompare; this.cOpt = cOpt; Writable writable = (Writable) eval.evaluate(null); constVal = getConstantAsBytes(writable); } catch (ClassCastException cce) { log.info(StringUtils.stringifyException(cce)); throw new SerDeException(" Column type mismatch in where clause " + sc.getComparisonExpr().getExprString() + " found type " + sc.getConstantDesc().getTypeString() + " instead of " + sc.getColumnDesc().getTypeString()); } catch (HiveException e) { throw new SerDeException(e); } }