@Override protected String visitLikePredicate(LikePredicate node, Void context) { StringBuilder builder = new StringBuilder(); builder.append('(') .append(process(node.getValue(), context)) .append(" LIKE ") .append(process(node.getPattern(), context)); node.getEscape().ifPresent(escape -> { builder.append(" ESCAPE ") .append(process(escape, context)); }); builder.append(')'); return builder.toString(); }
private boolean evaluateLikePredicate(LikePredicate node, Slice value, Regex regex) { if (type(node.getValue()) instanceof VarcharType) { return LikeFunctions.likeVarchar(value, regex); } Type type = type(node.getValue()); checkState(type instanceof CharType, "LIKE value is neither VARCHAR or CHAR"); return LikeFunctions.likeChar((long) ((CharType) type).getLength(), value, regex); }
@Override protected Boolean visitLikePredicate(LikePredicate node, Void context) { return process(node.getValue(), context) && process(node.getPattern(), context); }
@Override protected R visitLikePredicate(LikePredicate node, C context) { process(node.getValue(), context); process(node.getPattern(), context); node.getEscape().ifPresent(value -> process(value, context)); return null; }
@Override protected Type visitLikePredicate(LikePredicate node, StackableAstVisitorContext<Context> context) { Type valueType = process(node.getValue(), context); if (!(valueType instanceof CharType) && !(valueType instanceof VarcharType)) { coerceType(context, node.getValue(), VARCHAR, "Left side of LIKE expression"); } Type patternType = getVarcharType(node.getPattern(), context); coerceType(context, node.getPattern(), patternType, "Pattern for LIKE expression"); if (node.getEscape().isPresent()) { Expression escape = node.getEscape().get(); Type escapeType = getVarcharType(escape, context); coerceType(context, escape, escapeType, "Escape for LIKE expression"); } return setExpressionType(node, BOOLEAN); }
@Override protected RowExpression visitLikePredicate(LikePredicate node, Void context) { RowExpression value = process(node.getValue(), context); RowExpression pattern = process(node.getPattern(), context); if (node.getEscape().isPresent()) { RowExpression escape = process(node.getEscape().get(), context); return likeFunctionCall(value, call(likePatternSignature(), LIKE_PATTERN, pattern, escape)); } return likeFunctionCall(value, call(castSignature(LIKE_PATTERN, VARCHAR), LIKE_PATTERN, pattern)); }
@Override protected Object visitLikePredicate(LikePredicate node, Object context) Object value = process(node.getValue(), context); Type valueType = type(node.getValue()); Type patternType = createVarcharType(unescapedPattern.length()); TypeManager typeManager = metadata.getTypeManager(); toExpression(value, type(node.getValue())), toExpression(pattern, type(node.getPattern())), optimizedEscape);
@Override protected String visitLikePredicate(LikePredicate node, Void context) { StringBuilder builder = new StringBuilder(); builder.append('(') .append(process(node.getValue(), context)) .append(" LIKE ") .append(process(node.getPattern(), context)); if (node.getEscape() != null) { builder.append(" ESCAPE ") .append(process(node.getEscape(), context)); } builder.append(')'); return builder.toString(); }
String process = process(node.getValue(), context); builder.append('(') .append(process).append(" instanceof String && ((String) ").append(process).append(").");
@Override protected String visitLikePredicate(LikePredicate node, Boolean negate) { return "SELECT date, dimension, _user_set FROM " + process(node.getValue(), negate) + " WHERE dimension LIKE " + process(node.getPattern(), negate); }
process(node.getValue(), unmangleNames), visitStringLiteral(new StringLiteral(value), false)));
@Override protected String visitLikePredicate(LikePredicate node, Void context) { StringBuilder builder = new StringBuilder(); builder.append('(') .append(process(node.getValue(), context)) .append(" LIKE ") .append(process(node.getPattern(), context)); node.getEscape().ifPresent(escape -> { builder.append(" ESCAPE ") .append(process(escape, context)); }); builder.append(')'); return builder.toString(); }
@Override protected String visitLikePredicate(LikePredicate node, Boolean unmangleNames) { StringBuilder builder = new StringBuilder(); builder.append('(') .append(process(node.getValue(), unmangleNames)) .append(" LIKE ") .append(process(node.getPattern(), unmangleNames)); if (node.getEscape() != null) { builder.append(" ESCAPE ") .append(process(node.getEscape(), unmangleNames)); } builder.append(')'); return builder.toString(); }
@Override protected String visitLikePredicate(LikePredicate node, Boolean unmangleNames) { StringBuilder builder = new StringBuilder(); builder.append('(') .append(process(node.getValue(), unmangleNames)) .append(" LIKE ") .append(process(node.getPattern(), unmangleNames)); if (node.getEscape() != null) { builder.append(" ESCAPE ") .append(process(node.getEscape(), unmangleNames)); } builder.append(')'); return builder.toString(); }
@Override protected Boolean visitLikePredicate(LikePredicate node, Void context) { return process(node.getValue(), context) && process(node.getPattern(), context); }
@Override protected R visitLikePredicate(LikePredicate node, C context) { process(node.getValue(), context); process(node.getPattern(), context); node.getEscape().ifPresent(value -> process(value, context)); return null; }
@Override protected Type visitLikePredicate(LikePredicate node, StackableAstVisitorContext<AnalysisContext> context) { Type valueType = getVarcharType(node.getValue(), context); Type patternType = getVarcharType(node.getPattern(), context); coerceType(context, node.getValue(), valueType, "Left side of LIKE expression"); coerceType(context, node.getPattern(), patternType, "Pattern for LIKE expression"); if (node.getEscape() != null) { Type escapeType = getVarcharType(node.getEscape(), context); coerceType(context, node.getEscape(), escapeType, "Escape for LIKE expression"); } expressionTypes.put(node, BOOLEAN); return BOOLEAN; }
@Override protected R visitLikePredicate(LikePredicate node, C context) { process(node.getValue(), context); process(node.getPattern(), context); if (node.getEscape() != null) { process(node.getEscape(), context); } return null; }
@Override protected Object visitLikePredicate(LikePredicate node, Object context) Object value = process(node.getValue(), context); if (!stringPattern.contains("%") && !stringPattern.contains("_")) { return new ComparisonExpression(ComparisonExpression.Type.EQUAL, toExpression(value, expressionTypes.get(node.getValue())), toExpression(pattern, expressionTypes.get(node.getPattern()))); toExpression(value, expressionTypes.get(node.getValue())), toExpression(pattern, expressionTypes.get(node.getPattern())), optimizedEscape);
@Override protected RowExpression visitLikePredicate(LikePredicate node, Void context) { RowExpression value = process(node.getValue(), context); RowExpression pattern = process(node.getPattern(), context); if (node.getEscape() != null) { RowExpression escape = process(node.getEscape(), context); return call(likeSignature(), BOOLEAN, value, call(likePatternSignature(), LIKE_PATTERN, pattern, escape)); } return call(likeSignature(), BOOLEAN, value, call(castSignature(LIKE_PATTERN, VARCHAR), LIKE_PATTERN, pattern)); }