Skip to content

Commit 2c4d775

Browse files
Paul Rogersstiga-huang
Paul Rogers
authored andcommitted
IMPALA-8148: Misc. FE code cleanup
Roll-up of a bunch of minor code cleanup and refactoring. Pulled out of other patches to keep those patches focused on a single change. Tests: Reran all FE tests to verify no regressions. Change-Id: I4e2f2e79f36e804fd592b6fe77f0554c5ca803eb Reviewed-on: http://gerrit.cloudera.org:8080/12317 Reviewed-by: Impala Public Jenkins <[email protected]> Tested-by: Impala Public Jenkins <[email protected]>
1 parent 24eab71 commit 2c4d775

30 files changed

+316
-286
lines changed

fe/src/main/java/org/apache/impala/analysis/Analyzer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,7 @@ public void createEquivConjuncts(List<TupleId> lhsTids,
17551755
* among slots in ignoreSlots are assumed to have already been enforced.
17561756
* TODO: Consider optimizing for the cheapest minimum set of predicates.
17571757
*/
1758+
@SuppressWarnings("unchecked")
17581759
public <T extends Expr> void createEquivConjuncts(TupleId tid, List<T> conjuncts,
17591760
Set<SlotId> ignoreSlots) {
17601761
// Maps from a slot id to its set of equivalent slots. Used to track equivalences
@@ -1929,7 +1930,7 @@ public TupleId getTupleId(SlotId slotId) {
19291930
}
19301931

19311932
public void registerValueTransfer(SlotId id1, SlotId id2) {
1932-
globalState_.registeredValueTransfers.add(new Pair(id1, id2));
1933+
globalState_.registeredValueTransfers.add(new Pair<SlotId, SlotId>(id1, id2));
19331934
}
19341935

19351936
public boolean isOuterJoined(TupleId tid) {

fe/src/main/java/org/apache/impala/analysis/CastExpr.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.apache.impala.thrift.TExpr;
3030
import org.apache.impala.thrift.TExprNode;
3131
import org.apache.impala.thrift.TExprNodeType;
32+
3233
import com.google.common.base.Objects;
3334
import com.google.common.base.Preconditions;
3435
import com.google.common.collect.Lists;
@@ -309,6 +310,11 @@ public Expr ignoreImplicitCast() {
309310
}
310311
}
311312

313+
@Override
314+
public boolean isImplicitCast() {
315+
return isImplicit();
316+
}
317+
312318
@Override
313319
public boolean localEquals(Expr that) {
314320
if (!super.localEquals(that)) return false;

fe/src/main/java/org/apache/impala/analysis/ColumnDef.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ private void analyzeKuduOptions(Analyzer analyzer) throws AnalysisException {
257257
throw new AnalysisException(String.format("Only constant values are allowed " +
258258
"for default values: %s", defaultValue_.toSql()));
259259
}
260-
if (defaultValLiteral.getType().isNull() && ((isNullable_ != null && !isNullable_)
261-
|| isPrimaryKey_)) {
260+
if (Expr.IS_NULL_VALUE.apply(defaultValLiteral) &&
261+
((isNullable_ != null && !isNullable_) || isPrimaryKey_)) {
262262
throw new AnalysisException(String.format("Default value of NULL not allowed " +
263263
"on non-nullable column: '%s'", getColName()));
264264
}

fe/src/main/java/org/apache/impala/analysis/ComputeStatsStmt.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ public class ComputeStatsStmt extends StatementBase {
131131
private static final String STATS_FETCH_NUM_PARTITIONS_WITH_STATS =
132132
STATS_FETCH_PREFIX + ".NumPartitionsWithStats";
133133

134+
// The maximum number of partitions that may be explicitly selected by filter
135+
// predicates. Any query that selects more than this automatically drops back to a full
136+
// incremental stats recomputation.
137+
// TODO: We can probably do better than this, e.g. running several queries, each of
138+
// which selects up to MAX_INCREMENTAL_PARTITIONS partitions.
139+
private static final int MAX_INCREMENTAL_PARTITIONS = 1000;
140+
134141
protected final TableName tableName_;
135142
protected final TableSampleClause sampleParams_;
136143

@@ -151,14 +158,14 @@ public class ComputeStatsStmt extends StatementBase {
151158
protected String columnStatsQueryStr_;
152159

153160
// If true, stats will be gathered incrementally per-partition.
154-
private boolean isIncremental_ = false;
161+
private boolean isIncremental_;
155162

156163
// If true, expect the compute stats process to produce output for all partitions in the
157164
// target table. In that case, 'expectedPartitions_' will be empty. The point of this
158165
// flag is to optimize the case where all partitions are targeted.
159166
// False for unpartitioned HDFS tables, non-HDFS tables or when stats extrapolation
160167
// is enabled.
161-
private boolean expectAllPartitions_ = false;
168+
private boolean expectAllPartitions_;
162169

163170
// The list of valid partition statistics that can be used in an incremental computation
164171
// without themselves being recomputed. Populated in analyze().
@@ -173,23 +180,16 @@ public class ComputeStatsStmt extends StatementBase {
173180

174181
// If non-null, partitions that an incremental computation might apply to. Must be
175182
// null if this is a non-incremental computation.
176-
private PartitionSet partitionSet_ = null;
183+
private PartitionSet partitionSet_;
177184

178185
// If non-null, represents the user-specified list of columns for computing statistics.
179186
// Not supported for incremental statistics.
180-
private List<String> columnWhitelist_ = null;
187+
private List<String> columnWhitelist_;
181188

182189
// The set of columns to be analyzed. Each column is valid: it must exist in the table
183190
// schema, it must be of a type that can be analyzed, and cannot refer to a partitioning
184191
// column for HDFS tables. If the set is null, no columns are restricted.
185-
private Set<Column> validatedColumnWhitelist_ = null;
186-
187-
// The maximum number of partitions that may be explicitly selected by filter
188-
// predicates. Any query that selects more than this automatically drops back to a full
189-
// incremental stats recomputation.
190-
// TODO: We can probably do better than this, e.g. running several queries, each of
191-
// which selects up to MAX_INCREMENTAL_PARTITIONS partitions.
192-
private static final int MAX_INCREMENTAL_PARTITIONS = 1000;
192+
private Set<Column> validatedColumnWhitelist_;
193193

194194
/**
195195
* Should only be constructed via static creation functions.

0 commit comments

Comments
 (0)