SOLR-8153: Support upper case and mixed case column identifiers in the SQL interface

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1708259 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joel Bernstein 2015-10-12 21:51:45 +00:00
parent f525b1a6c9
commit 14854b4f08
7 changed files with 253 additions and 89 deletions

View File

@ -20,7 +20,7 @@ com.codahale.metrics.version = 3.0.1
/com.cybozu.labs/langdetect = 1.1-20120112
/com.drewnoakes/metadata-extractor = 2.6.2
/com.facebook.presto/presto-parser = 0.108
/com.facebook.presto/presto-parser = 0.122
com.fasterxml.jackson.core.version = 2.5.4
/com.fasterxml.jackson.core/jackson-annotations = ${com.fasterxml.jackson.core.version}

View File

@ -111,7 +111,10 @@ Other Changes
* SOLR-7554: Add checks in Streams for incoming stream order (Dennis Gove, Joel Bernstein)
* SOLR-7441: Improve overall robustness of the Streaming stack: Streaming API,
Streaming Expressions, Parallel SQL (Joel Bernstein)
Streaming Expressions, Parallel SQL (Joel Bernstein)
* SOLR-8153: Support upper case and mixed case column identifiers in the SQL interface
(Joel Bernstein)
* SOLR-8132: HDFSDirectoryFactory now defaults to using the global block cache. (Mark Miller)

View File

@ -94,7 +94,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
SolrParams params = req.getParams();
params = adjustParams(params);
req.setParams(params);
String sql = params.get("sql");
String sql = params.get("stmt");
int numWorkers = params.getInt("numWorkers", 1);
String workerCollection = params.get("workerCollection", defaultWorkerCollection);
String workerZkhost = params.get("workerZkhost",defaultZkhost);
@ -370,8 +370,9 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
Set<String> sortFields = new HashSet();
for(SortItem sortItem : sorts) {
sortFields.add(stripSingleQuotes(stripQuotes(sortItem.getSortKey().toString())));
adjustedSorts.add(new FieldComparator(stripSingleQuotes(stripQuotes(sortItem.getSortKey().toString())),
sortFields.add(getSortField(sortItem));
adjustedSorts.add(new FieldComparator(getSortField(sortItem),
ascDescComp(sortItem.getOrdering().toString())));
}
@ -380,7 +381,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
}
for(SortItem sortItem : sorts) {
String sortField = stripSingleQuotes(stripQuotes(sortItem.getSortKey().toString()));
String sortField = getSortField(sortItem);
if(!bucketFields.contains(sortField)) {
throw new IOException("All sort fields must be in the field list.");
}
@ -555,7 +556,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
if (comma) {
siBuf.append(",");
}
siBuf.append(stripSingleQuotes(stripQuotes(sortItem.getSortKey().toString())) + " " + ascDesc(sortItem.getOrdering().toString()));
siBuf.append(getSortField(sortItem) + " " + ascDesc(sortItem.getOrdering().toString()));
}
} else {
if(sqlVisitor.limit < 0) {
@ -599,7 +600,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
for(int i=0; i< buckets.length; i++) {
Bucket bucket = buckets[i];
SortItem sortItem = sortItems.get(i);
if(!bucket.toString().equals(stripSingleQuotes(stripQuotes(sortItem.getSortKey().toString())))) {
if(!bucket.toString().equals(getSortField(sortItem))) {
return false;
}
@ -661,7 +662,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
return buf.toString();
}
public static String getSortDirection(List<SortItem> sorts) {
private static String getSortDirection(List<SortItem> sorts) {
if(sorts != null && sorts.size() > 0) {
for(SortItem item : sorts) {
return ascDesc(stripSingleQuotes(stripQuotes(item.getOrdering().toString())));
@ -692,8 +693,8 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
SortItem sortItem = sortItems.get(i);
String ordering = sortItem.getOrdering().toString();
ComparatorOrder comparatorOrder = ascDescComp(ordering);
String sortKey = sortItem.getSortKey().toString();
comps[i] = new FieldComparator(stripSingleQuotes(stripQuotes(sortKey)), comparatorOrder);
String sortKey = getSortField(sortItem);
comps[i] = new FieldComparator(sortKey, comparatorOrder);
}
if(comps.length == 1) {
@ -709,8 +710,8 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
SortItem sortItem = sortItems.get(i);
String ordering = sortItem.getOrdering().toString();
ComparatorOrder comparatorOrder = ascDescComp(ordering);
String sortKey = sortItem.getSortKey().toString();
comps[i] = new FieldComparator(stripSingleQuotes(stripQuotes(sortKey)), comparatorOrder);
String sortKey = getSortField(sortItem);
comps[i] = new FieldComparator(sortKey, comparatorOrder);
}
return comps;
@ -855,7 +856,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
}
protected Void visitComparisonExpression(ComparisonExpression node, StringBuilder buf) {
String field = node.getLeft().toString();
String field = getPredicateField(node.getLeft());
String value = node.getRight().toString();
value = stripSingleQuotes(value);
@ -864,7 +865,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
value = '"'+value+'"';
}
buf.append('(').append(stripQuotes(stripSingleQuotes(field)) + ":" + value).append(')');
buf.append('(').append(field + ":" + value).append(')');
return null;
}
}
@ -943,7 +944,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
this.groupByQuery = true;
List<Expression> groups = node.getGroupBy();
for(Expression group : groups) {
groupBy.add(stripSingleQuotes(stripQuotes(group.toString())));
groupBy.add(getGroupField(group));
}
}
@ -992,7 +993,37 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
}
protected Void visitSingleColumn(SingleColumn node, Integer indent) {
fields.add(stripSingleQuotes(stripQuotes(ExpressionFormatter.formatExpression(node.getExpression()))));
Expression ex = node.getExpression();
String field = null;
if(ex instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference)ex;
List<String> parts = ref.getName().getOriginalParts();
field = parts.get(0);
} else if(ex instanceof FunctionCall) {
FunctionCall functionCall = (FunctionCall)ex;
List<String> parts = functionCall.getName().getOriginalParts();
List<Expression> args = functionCall.getArguments();
String col = null;
if(args.size() > 0 && args.get(0) instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference) args.get(0);
col = ref.getName().getOriginalParts().get(0);
field = parts.get(0)+"("+stripSingleQuotes(col)+")";
} else {
field = stripSingleQuotes(stripQuotes(functionCall.toString()));
}
} else if(ex instanceof StringLiteral) {
StringLiteral stringLiteral = (StringLiteral)ex;
field = stripSingleQuotes(stringLiteral.toString());
}
fields.add(field);
if(node.getAlias().isPresent()) {
}
@ -1000,6 +1031,9 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
return null;
}
protected Void visitAllColumns(AllColumns node, Integer context) {
return null;
}
@ -1041,6 +1075,98 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
}
}
private static String getSortField(SortItem sortItem)
{
String field;
Expression ex = sortItem.getSortKey();
if(ex instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference)ex;
List<String> parts = ref.getName().getOriginalParts();
field = parts.get(0);
} else if(ex instanceof FunctionCall) {
FunctionCall functionCall = (FunctionCall)ex;
List<String> parts = functionCall.getName().getOriginalParts();
List<Expression> args = functionCall.getArguments();
String col = null;
if(args.size() > 0 && args.get(0) instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference) args.get(0);
col = ref.getName().getOriginalParts().get(0);
field = parts.get(0)+"("+stripSingleQuotes(col)+")";
} else {
field = stripSingleQuotes(stripQuotes(functionCall.toString()));
}
} else {
StringLiteral stringLiteral = (StringLiteral)ex;
field = stripSingleQuotes(stringLiteral.toString());
}
return field;
}
private static String getHavingField(Expression ex)
{
String field;
if(ex instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference)ex;
List<String> parts = ref.getName().getOriginalParts();
field = parts.get(0);
} else if(ex instanceof FunctionCall) {
FunctionCall functionCall = (FunctionCall)ex;
List<String> parts = functionCall.getName().getOriginalParts();
List<Expression> args = functionCall.getArguments();
String col = null;
if(args.size() > 0 && args.get(0) instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference) args.get(0);
col = ref.getName().getOriginalParts().get(0);
field = parts.get(0)+"("+stripSingleQuotes(col)+")";
} else {
field = stripSingleQuotes(stripQuotes(functionCall.toString()));
}
} else {
StringLiteral stringLiteral = (StringLiteral)ex;
field = stripSingleQuotes(stringLiteral.toString());
}
return field;
}
private static String getPredicateField(Expression ex)
{
String field;
if(ex instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference)ex;
List<String> parts = ref.getName().getOriginalParts();
field = parts.get(0);
} else {
StringLiteral stringLiteral = (StringLiteral)ex;
field = stripSingleQuotes(stringLiteral.toString());
}
return field;
}
private static String getGroupField(Expression ex)
{
String field;
if(ex instanceof QualifiedNameReference) {
QualifiedNameReference ref = (QualifiedNameReference)ex;
List<String> parts = ref.getName().getOriginalParts();
field = parts.get(0);
} else {
StringLiteral stringLiteral = (StringLiteral)ex;
field = stripSingleQuotes(stringLiteral.toString());
}
return field;
}
private static class LimitStream extends TupleStream {
private TupleStream stream;
@ -1174,7 +1300,7 @@ public class SQLHandler extends RequestHandlerBase implements SolrCoreAware {
}
protected Boolean visitComparisonExpression(ComparisonExpression node, Tuple tuple) {
String field = stripQuotes(node.getLeft().toString());
String field = getHavingField(node.getLeft());
double d = Double.parseDouble(node.getRight().toString());
double td = tuple.getDouble(field);
ComparisonExpression.Type t = node.getType();

View File

@ -88,7 +88,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
waitForRecoveriesToFinish(false);
testPredicate();
testBasicSelect();
testStringLiteralFields();
testMixedCaseFields();
testBasicGrouping();
testBasicGroupingFacets();
testSelectDistinct();
@ -233,7 +233,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
commit();
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select 'id', field_i, str_s from collection1 where 'text'='XXXX' order by field_i desc");
params.put("stmt", "select 'id', field_i, str_s from collection1 where 'text'='XXXX' order by field_i desc");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -284,7 +284,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select id, field_i, str_s from collection1 where text='XXXX' order by field_i desc limit 1");
params.put("stmt", "select id, field_i, str_s from collection1 where text='XXXX' order by field_i desc limit 1");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -298,7 +298,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select id, field_i, str_s from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
params.put("stmt", "select id, field_i, str_s from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -326,7 +326,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
}
private void testStringLiteralFields() throws Exception {
private void testMixedCaseFields() throws Exception {
try {
CloudJettyRunner jetty = this.cloudJettys.get(0);
@ -335,18 +335,18 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
commit();
indexDoc(sdoc("id", "1", "Text_t", "XXXX XXXX", "str_s", "a", "Field_i", "7"));
indexDoc(sdoc("id", "2", "Text_t", "XXXX XXXX", "str_s", "b", "Field_i", "8"));
indexDoc(sdoc("id", "3", "Text_t", "XXXX XXXX", "str_s", "a", "Field_i", "20"));
indexDoc(sdoc("id", "4", "Text_t", "XXXX XXXX", "str_s", "b", "Field_i", "11"));
indexDoc(sdoc("id", "5", "Text_t", "XXXX XXXX", "str_s", "c", "Field_i", "30"));
indexDoc(sdoc("id", "6", "Text_t", "XXXX XXXX", "str_s", "c", "Field_i", "40"));
indexDoc(sdoc("id", "7", "Text_t", "XXXX XXXX", "str_s", "c", "Field_i", "50"));
indexDoc(sdoc("id", "8", "Text_t", "XXXX XXXX", "str_s", "c", "Field_i", "60"));
indexDoc(sdoc("id", "1", "Text_t", "XXXX XXXX", "Str_s", "a", "Field_i", "7"));
indexDoc(sdoc("id", "2", "Text_t", "XXXX XXXX", "Str_s", "b", "Field_i", "8"));
indexDoc(sdoc("id", "3", "Text_t", "XXXX XXXX", "Str_s", "a", "Field_i", "20"));
indexDoc(sdoc("id", "4", "Text_t", "XXXX XXXX", "Str_s", "b", "Field_i", "11"));
indexDoc(sdoc("id", "5", "Text_t", "XXXX XXXX", "Str_s", "c", "Field_i", "30"));
indexDoc(sdoc("id", "6", "Text_t", "XXXX XXXX", "Str_s", "c", "Field_i", "40"));
indexDoc(sdoc("id", "7", "Text_t", "XXXX XXXX", "Str_s", "c", "Field_i", "50"));
indexDoc(sdoc("id", "8", "Text_t", "XXXX XXXX", "Str_s", "c", "Field_i", "60"));
commit();
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select id, 'Field_i', str_s from Collection1 where 'Text_t'='XXXX' order by 'Field_i' desc");
params.put("stmt", "select id, Field_i, Str_s from Collection1 where Text_t='XXXX' order by Field_i desc");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -358,42 +358,77 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
tuple = tuples.get(0);
assert(tuple.getLong("id") == 8);
assert(tuple.getLong("Field_i") == 60);
assert(tuple.get("str_s").equals("c"));
assert(tuple.get("Str_s").equals("c"));
tuple = tuples.get(1);
assert(tuple.getLong("id") == 7);
assert(tuple.getLong("Field_i") == 50);
assert(tuple.get("str_s").equals("c"));
assert(tuple.get("Str_s").equals("c"));
tuple = tuples.get(2);
assert(tuple.getLong("id") == 6);
assert(tuple.getLong("Field_i") == 40);
assert(tuple.get("str_s").equals("c"));
assert(tuple.get("Str_s").equals("c"));
tuple = tuples.get(3);
assert(tuple.getLong("id") == 5);
assert(tuple.getLong("Field_i") == 30);
assert(tuple.get("str_s").equals("c"));
assert(tuple.get("Str_s").equals("c"));
tuple = tuples.get(4);
assert(tuple.getLong("id") == 3);
assert(tuple.getLong("Field_i") == 20);
assert(tuple.get("str_s").equals("a"));
assert(tuple.get("Str_s").equals("a"));
tuple = tuples.get(5);
assert(tuple.getLong("id") == 4);
assert(tuple.getLong("Field_i") == 11);
assert(tuple.get("str_s").equals("b"));
assert(tuple.get("Str_s").equals("b"));
tuple = tuples.get(6);
assert(tuple.getLong("id") == 2);
assert(tuple.getLong("Field_i") == 8);
assert(tuple.get("str_s").equals("b"));
assert(tuple.get("Str_s").equals("b"));
tuple = tuples.get(7);
assert(tuple.getLong("id") == 1);
assert(tuple.getLong("Field_i") == 7);
assert(tuple.get("str_s").equals("a"));
assert(tuple.get("Str_s").equals("a"));
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("stmt", "select Str_s, sum(Field_i) from Collection1 where 'id'='(1 8)' group by Str_s having (sum(Field_i) = 7 OR 'sum(Field_i)' = 60) order by 'sum(Field_i)' desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
assert(tuples.size() == 2);
tuple = tuples.get(0);
assert(tuple.get("Str_s").equals("c"));
assert(tuple.getDouble("sum(Field_i)") == 60);
tuple = tuples.get(1);
assert(tuple.get("Str_s").equals("a"));
assert(tuple.getDouble("sum(Field_i)") == 7);
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("stmt", "select Str_s, sum(Field_i) from Collection1 where 'id'='(1 8)' group by 'Str_s' having (sum(Field_i) = 7 OR 'sum(Field_i)' = 60) order by 'sum(Field_i)' desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
assert(tuples.size() == 2);
tuple = tuples.get(0);
assert(tuple.get("Str_s").equals("c"));
assert(tuple.getDouble("sum(Field_i)") == 60);
tuple = tuples.get(1);
assert(tuple.get("Str_s").equals("a"));
assert(tuple.getDouble("sum(Field_i)") == 7);
} finally {
delete();
@ -421,7 +456,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select id, field_i, str_s from collection1 where text='XXXX' order by field_iff desc");
params.put("stmt", "select id, field_i, str_s from collection1 where text='XXXX' order by field_iff desc");
SolrStream solrStream = new SolrStream(jetty.url, params);
Tuple tuple = getTuple(new ExceptionStream(solrStream));
@ -432,7 +467,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select id, field_iff, str_s from collection1 where text='XXXX' order by field_iff desc");
params.put("stmt", "select id, field_iff, str_s from collection1 where text='XXXX' order by field_iff desc");
solrStream = new SolrStream(jetty.url, params);
tuple = getTuple(new ExceptionStream(solrStream));
@ -443,7 +478,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select str_s, count(*), sum(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
params.put("stmt", "select str_s, count(*), sum(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
solrStream = new SolrStream(jetty.url, params);
tuple = getTuple(new ExceptionStream(solrStream));
@ -454,7 +489,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select str_s, count(*), blah(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
params.put("stmt", "select str_s, count(*), blah(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
solrStream = new SolrStream(jetty.url, params);
tuple = getTuple(new ExceptionStream(solrStream));
@ -465,7 +500,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select str_s from collection1 where text='XXXX' group by str_s");
params.put("stmt", "select str_s from collection1 where text='XXXX' group by str_s");
solrStream = new SolrStream(jetty.url, params);
tuple = getTuple(new ExceptionStream(solrStream));
@ -498,7 +533,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
commit();
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select str_s, 'count(*)', sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
params.put("stmt", "select str_s, 'count(*)', sum('field_i'), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -526,7 +561,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -563,7 +598,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -580,7 +615,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -598,7 +633,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -633,7 +668,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
params.put("stmt", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -671,7 +706,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -709,7 +744,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -730,7 +765,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select distinct str_s, field_i from collection1");
params.put("stmt", "select distinct str_s, field_i from collection1");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -767,7 +802,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select distinct str_s, field_i from collection1 where str_s = 'a'");
params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -809,7 +844,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
commit();
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
params.put("stmt", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -846,7 +881,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
//reverse the sort
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -883,7 +918,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
//test with limit
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -903,7 +938,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select distinct str_s, field_i from collection1");
params.put("stmt", "select distinct str_s, field_i from collection1");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -938,7 +973,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select distinct str_s, field_i from collection1 where str_s = 'a'");
params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -980,7 +1015,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select distinct str_s, field_i from collection1 order by str_s asc, field_i asc");
params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s asc, field_i asc");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -1018,7 +1053,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1056,7 +1091,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s desc, field_i desc limit 2");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1077,7 +1112,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select distinct str_s, field_i from collection1");
params.put("stmt", "select distinct str_s, field_i from collection1");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1113,7 +1148,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select distinct str_s, field_i from collection1 where str_s = 'a'");
params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1156,7 +1191,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select 'str_s', 'count(*)', sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
params.put("stmt", "select 'str_s', 'count(*)', sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -1185,7 +1220,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1223,7 +1258,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having 'sum(field_i)' = 19");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1241,7 +1276,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having (('sum(field_i)' = 19) AND (min(field_i) = 8))");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1260,7 +1295,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1298,7 +1333,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by sum(field_i) asc limit 2");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by sum(field_i) asc limit 2");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -1328,7 +1363,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by str_s desc");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by str_s desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1365,7 +1400,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1392,7 +1427,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1411,7 +1446,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", "2");
params.put("sql", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1447,7 +1482,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
SolrStream solrStream = new SolrStream(jetty.url, params);
@ -1485,7 +1520,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where id = 2");
params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where id = 2");
solrStream = new SolrStream(jetty.url, params);
@ -1520,7 +1555,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where a_s = 'blah'");
params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where a_s = 'blah'");
solrStream = new SolrStream(jetty.url, params);
@ -1578,7 +1613,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
commit();
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -1596,7 +1631,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
assert(tuple.getLong("year_i") == 2014);
assert(tuple.getDouble("sum(item_i)") == 7);
params.put("sql", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1623,7 +1658,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("sql", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1697,7 +1732,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -1719,7 +1754,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1746,7 +1781,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("aggregationMode", "facet");
params.put("sql", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1816,7 +1851,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
Map params = new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", 2);
params.put("sql", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
SolrStream solrStream = new SolrStream(jetty.url, params);
List<Tuple> tuples = getTuples(solrStream);
@ -1837,7 +1872,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", 2);
params.put("sql", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);
@ -1866,7 +1901,7 @@ public class TestSQLHandler extends AbstractFullDistribZkTestBase {
new HashMap();
params.put(CommonParams.QT, "/sql");
params.put("numWorkers", 2);
params.put("sql", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
solrStream = new SolrStream(jetty.url, params);
tuples = getTuples(solrStream);

View File

@ -1 +0,0 @@
f39d675687a3b29c1acbd6d05a0f583d13d93fbc

View File

@ -0,0 +1 @@
b4261cbabfd2f28b8d4d20d7e3a3d1be48bb890c

View File

@ -99,7 +99,7 @@ class StatementImpl implements Statement {
Collections.shuffle(shuffler, new Random());
params.put(CommonParams.QT, "/sql");
params.put("sql", sql);
params.put("stmt", sql);
params.putAll(properties);
Replica rep = shuffler.get(0);