Search in sources :

Example 1 with StringBasedRegexpSubstrFunction

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

the class SortOrderExpressionTest method regexpSubstr.

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

Example 2 with StringBasedRegexpSubstrFunction

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

the class RegexpSubstrParseNode 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 ByteBasedRegexpSubstrFunction(children);
    } else {
        return new StringBasedRegexpSubstrFunction(children);
    }
}
Also used : ByteBasedRegexpSubstrFunction(org.apache.phoenix.expression.function.ByteBasedRegexpSubstrFunction) QueryServices(org.apache.phoenix.query.QueryServices) StringBasedRegexpSubstrFunction(org.apache.phoenix.expression.function.StringBasedRegexpSubstrFunction)

Aggregations

ByteBasedRegexpSubstrFunction (org.apache.phoenix.expression.function.ByteBasedRegexpSubstrFunction)2 StringBasedRegexpSubstrFunction (org.apache.phoenix.expression.function.StringBasedRegexpSubstrFunction)2 RoundDateExpression (org.apache.phoenix.expression.function.RoundDateExpression)1 QueryServices (org.apache.phoenix.query.QueryServices)1 Test (org.junit.Test)1