private static SortSpec[] annotateSortSpecs(QueryBlock block, String [] referNames, Sort.SortSpec[] rawSortSpecs) { int sortKeyNum = rawSortSpecs.length; Column column; List<SortSpec> annotatedSortSpecs = Lists.newArrayList(); for (int i = 0; i < sortKeyNum; i++) { String refName = referNames[i]; if (block.isConstReference(refName)) { continue; } else if (block.namedExprsMgr.isEvaluated(refName)) { column = block.namedExprsMgr.getTarget(refName).getNamedColumn(); } else { throw new IllegalStateException("Unexpected State: " + StringUtils.join(rawSortSpecs)); } annotatedSortSpecs.add(new SortSpec(column, rawSortSpecs[i].isAscending(), rawSortSpecs[i].isNullsFirst())); } return annotatedSortSpecs.toArray(new SortSpec[annotatedSortSpecs.size()]); }
private static SortSpec[] annotateSortSpecs(QueryBlock block, String [] referNames, Sort.SortSpec[] rawSortSpecs) { int sortKeyNum = rawSortSpecs.length; Column column; List<SortSpec> annotatedSortSpecs = Lists.newArrayList(); for (int i = 0; i < sortKeyNum; i++) { String refName = referNames[i]; if (block.isConstReference(refName)) { continue; } else if (block.namedExprsMgr.isEvaluated(refName)) { column = block.namedExprsMgr.getTarget(refName).getNamedColumn(); } else { throw new IllegalStateException("Unexpected State: " + StringUtils.join(rawSortSpecs)); } annotatedSortSpecs.add(new SortSpec(column, rawSortSpecs[i].isAscending(), rawSortSpecs[i].isNullsFirst())); } return annotatedSortSpecs.toArray(new SortSpec[annotatedSortSpecs.size()]); }
throw new IllegalStateException("Unexpected State: " + StringUtils.join(sortSpecs)); annotatedSortSpecs[i] = new SortSpec(column, sortSpecs[i].isAscending(), sortSpecs[i].isNullsFirst());
throw new IllegalStateException("Unexpected State: " + StringUtils.join(sortSpecs)); annotatedSortSpecs[i] = new SortSpec(column, sortSpecs[i].isAscending(), sortSpecs[i].isNullsFirst());
@Override public String toString() { return key + " " + (asc ? "asc" : "desc") + " " + (isNullsFirst() ? "nulls first" : "nulls last"); }
@Override public String toString() { return key + " " + (asc ? "asc" : "desc") + " " + (isNullsFirst() ? "nulls first" : "nulls last"); }