Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In operator #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ The following query components are supported:

// greater than or equal
EqualityExpression gte(String propertyName, Object value);

// is one of these values
SetExpression in(String propertyName, Object[] values);

// between from and to (inclusive)
RangeExpression between(String propertyName, Object from, Object to);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public enum PhoenixHBaseOperator implements Symbolic {
AND("AND"),

LIKE("LIKE"),
LIKE_CASE_INSENSITIVE("ILIKE");
LIKE_CASE_INSENSITIVE("ILIKE"),
IN("IN");

private final String symbol;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,16 @@ public String between(String fieldName, Object from, Object to) {
}

@Override
public String in(String fieldName, Object[] values) {
throw new UnsupportedOperationException("IN operator is not supported in phoenix hbase library...");
public String in(String fieldName, Object[] values) {

String valueSet = Joiner.on(",").join(values);
StringBuffer sb = new StringBuffer();
return sb.append(resolveMappingName(fieldName))
.append(" ")
.append(PhoenixHBaseOperator.IN)
.append(" (")
.append(valueSet)
.append(")").toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ public void testBooleanEq() throws ParseException, ClassNotFoundException {
System.out.println(result);
Assert.assertEquals("isu = true", result);
}

@Test
public void testIn() throws ParseException, ClassNotFoundException {
PhoenixHBaseQueryTranslator translator = new PhoenixHBaseQueryTranslator(entityPropertiesResolver);
Object[] inVals = new Object[]{0,10,11};
String result = translator.in("cstat", inVals);
Assert.assertNotNull(result);
System.out.println(result);
Assert.assertEquals("cstat IN (0,10,11)", result);
}

@Test
public void testLongEq() throws ParseException, ClassNotFoundException {
Expand Down