Search in sources :

Example 1 with StringBasedRegexpReplaceFunction

use of org.apache.phoenix.expression.function.StringBasedRegexpReplaceFunction in project phoenix by apache.

the class RegexpReplaceParseNode method create.

@Override
public Expression create(List<Expression> children, StatementContext context) throws SQLException {
    QueryServices services = context.getConnection().getQueryServices();
    boolean useByteBasedRegex = services.getProps().getBoolean(QueryServices.USE_BYTE_BASED_REGEX_ATTRIB, QueryServicesOptions.DEFAULT_USE_BYTE_BASED_REGEX);
    if (useByteBasedRegex) {
        return new ByteBasedRegexpReplaceFunction(children);
    } else {
        return new StringBasedRegexpReplaceFunction(children);
    }
}
Also used : ByteBasedRegexpReplaceFunction(org.apache.phoenix.expression.function.ByteBasedRegexpReplaceFunction) StringBasedRegexpReplaceFunction(org.apache.phoenix.expression.function.StringBasedRegexpReplaceFunction) QueryServices(org.apache.phoenix.query.QueryServices)

Example 2 with StringBasedRegexpReplaceFunction

use of org.apache.phoenix.expression.function.StringBasedRegexpReplaceFunction in project phoenix by apache.

the class SortOrderExpressionTest method regexpReplace.

@Test
public void regexpReplace() throws Exception {
    List<Expression> args = Lists.newArrayList(getInvertedLiteral("blah", PChar.INSTANCE), getLiteral("l.h"), getLiteral("foo"));
    evaluateAndAssertResult(new ByteBasedRegexpReplaceFunction(args), "bfoo");
    evaluateAndAssertResult(new StringBasedRegexpReplaceFunction(args), "bfoo");
}
Also used : ByteBasedRegexpReplaceFunction(org.apache.phoenix.expression.function.ByteBasedRegexpReplaceFunction) RoundDateExpression(org.apache.phoenix.expression.function.RoundDateExpression) StringBasedRegexpReplaceFunction(org.apache.phoenix.expression.function.StringBasedRegexpReplaceFunction) Test(org.junit.Test)

Aggregations

ByteBasedRegexpReplaceFunction (org.apache.phoenix.expression.function.ByteBasedRegexpReplaceFunction)2 StringBasedRegexpReplaceFunction (org.apache.phoenix.expression.function.StringBasedRegexpReplaceFunction)2 RoundDateExpression (org.apache.phoenix.expression.function.RoundDateExpression)1 QueryServices (org.apache.phoenix.query.QueryServices)1 Test (org.junit.Test)1