15 package com.cloudera.impala.analysis;
17 import java.util.List;
19 import com.google.common.collect.Lists;
42 this.nullsFirstParam_ = nullsFirstParam;
52 StringBuilder strBuilder =
new StringBuilder();
53 strBuilder.append(expr_.toSql());
54 strBuilder.append(
isAsc_ ?
" ASC" :
" DESC");
62 strBuilder.append(
" NULLS FIRST");
65 strBuilder.append(
" NULLS LAST");
68 return strBuilder.toString();
73 if (obj == null)
return false;
74 if (obj.getClass() != this.getClass())
return false;
76 boolean nullsFirstEqual =
79 nullsFirstEqual = nullsFirstParam_.equals(o.nullsFirstParam_);
81 return expr_.equals(o.expr_) &&
isAsc_ == o.
isAsc_ && nullsFirstEqual;
103 return nullsFirstParam == null ? !isAsc : nullsFirstParam;
110 public static List<OrderByElement>
substitute(List<OrderByElement> src,
112 List<OrderByElement> result = Lists.newArrayListWithCapacity(src.size());
114 result.add(
new OrderByElement(element.getExpr().substitute(smap, analyzer,
false),
115 element.isAsc_, element.nullsFirstParam_));
124 List<Expr> result = Lists.newArrayListWithCapacity(src.size());
126 result.add(element.getExpr());
135 public static List<OrderByElement>
reverse(List<OrderByElement> src) {
136 List<OrderByElement> result = Lists.newArrayListWithCapacity(src.size());
137 for (
int i = 0; i < src.size(); ++i) {
142 result.add(reverseElement);
boolean equals(Object obj)
static List< Expr > getOrderByExprs(List< OrderByElement > src)
final Boolean nullsFirstParam_
static List< OrderByElement > substitute(List< OrderByElement > src, ExprSubstitutionMap smap, Analyzer analyzer)
Boolean getNullsFirstParam()
OrderByElement(Expr expr, boolean isAsc, Boolean nullsFirstParam)
static boolean nullsFirst(Boolean nullsFirstParam, boolean isAsc)
static List< OrderByElement > reverse(List< OrderByElement > src)