@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 Regex getConstantPattern(LikePredicate node) { Regex result = likePatternCache.get(node); if (result == null) { StringLiteral pattern = (StringLiteral) node.getPattern(); if (node.getEscape().isPresent()) { Slice escape = ((StringLiteral) node.getEscape().get()).getSlice(); result = LikeFunctions.likePattern(pattern.getSlice(), escape); } else { result = LikeFunctions.likePattern(pattern.getSlice()); } likePatternCache.put(node, result); } return result; }
@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 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 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 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(); }
if (node.getEscape() != null) { throw new UnsupportedOperationException();
if (node.getEscape() != null) { throw new RakamException("ESCAPE is not supported LIKE statement", BAD_REQUEST);
@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 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 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; }
private Regex getConstantPattern(LikePredicate node) { Regex result = likePatternCache.get(node); if (result == null) { StringLiteral pattern = (StringLiteral) node.getPattern(); StringLiteral escape = (StringLiteral) node.getEscape(); if (escape == null) { result = LikeFunctions.likePattern(pattern.getSlice()); } else { result = LikeFunctions.likePattern(pattern.getSlice(), escape.getSlice()); } likePatternCache.put(node, result); } return result; }
@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)); }