15 package com.cloudera.impala.analysis;
17 import java.util.ArrayList;
18 import java.util.Arrays;
19 import java.util.Collections;
20 import java.util.HashSet;
21 import java.util.IdentityHashMap;
22 import java.util.Iterator;
23 import java.util.LinkedHashMap;
24 import java.util.LinkedList;
25 import java.util.List;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
55 import com.cloudera.impala.common.Id;
56 import com.cloudera.impala.common.IdGenerator;
59 import com.cloudera.impala.common.Pair;
63 import com.cloudera.impala.thrift.TAccessEvent;
64 import com.cloudera.impala.thrift.TCatalogObjectType;
65 import com.cloudera.impala.thrift.TNetworkAddress;
66 import com.cloudera.impala.thrift.TQueryCtx;
67 import com.cloudera.impala.util.DisjointSet;
69 import com.cloudera.impala.util.ListMap;
71 import com.google.common.base.Joiner;
72 import com.google.common.base.Preconditions;
73 import com.google.common.base.Predicates;
74 import com.google.common.base.Strings;
75 import com.google.common.collect.ImmutableList;
76 import com.google.common.collect.Lists;
77 import com.google.common.collect.Maps;
78 import com.google.common.collect.Sets;
114 "Data source does not exist: ";
116 "Data source already exists: ";
118 private final static Logger
LOG = LoggerFactory.getLogger(Analyzer.class);
150 globalState_.containsSubquery =
true;
184 public final Map<ExprId, Expr>
conjuncts = Maps.newHashMap();
199 Collections.newSetFromMap(
new IdentityHashMap<ExprId, Boolean>());
231 public final Map<SlotId, Analyzer>
blockBySlot = Maps.newHashMap();
240 Lists.newArrayList();
250 public final LinkedHashMap<String, Integer>
warnings =
251 new LinkedHashMap<String, Integer>();
254 EquivalenceClassId.createGenerator();
271 Lists.newArrayList();
275 private final ListMap<TNetworkAddress>
hostIndex =
new ListMap<TNetworkAddress>();
308 private final Map<String, TupleDescriptor>
aliasMap_ = Maps.newHashMap();
317 private final Map<String, SlotDescriptor>
slotRefMap_ = Maps.newHashMap();
343 this(parentAnalyzer, parentAnalyzer.globalState_);
350 ancestors_ = Lists.newArrayList(parentAnalyzer);
351 ancestors_.addAll(parentAnalyzer.ancestors_);
354 user_ = parentAnalyzer.getUser();
365 parentAnalyzer.
getQueryCtx(), parentAnalyzer.getAuthzConfig());
366 return new Analyzer(parentAnalyzer, globalState);
374 Preconditions.checkState(tid == null
375 || globalState_.semiJoinedTupleIds.containsKey(tid));
391 List<String> result =
new ArrayList<String>();
393 String error = e.getKey();
394 int count = e.getValue();
395 Preconditions.checkState(count > 0);
399 result.add(error +
" (" + count +
" warnings like this)");
410 Preconditions.checkState(view.isLocalView());
411 if (
localViews_.put(view.getName().toLowerCase(), view) != null) {
413 String.format(
"Duplicate table alias: '%s'", view.getName()));
428 String uniqueAlias = ref.getUniqueAlias();
429 if (
aliasMap_.containsKey(uniqueAlias)) {
436 String unqualifiedAlias = null;
437 String[] aliases = ref.getAliases();
438 if (aliases.length > 1) {
439 unqualifiedAlias = aliases[1];
441 if (tupleDesc != null) {
444 "Duplicate table alias: '" + unqualifiedAlias +
"'");
446 ambiguousAliases_.add(unqualifiedAlias);
453 result.setAliases(aliases, ref.hasExplicitAlias());
455 for (String alias: aliases) {
456 aliasMap_.put(alias, result);
458 tableRefMap_.put(result.getId(), ref);
470 if (tableRef.isResolved())
return tableRef;
472 if (tableRef.getPath().size() == 1) {
475 String viewAlias = tableRef.getPath().
get(0).toLowerCase();
478 View localView = analyzer.localViews_.get(viewAlias);
479 if (localView != null)
return new InlineViewRef(localView, tableRef);
480 analyzer = (analyzer.ancestors_.isEmpty() ? null : analyzer.ancestors_.get(0));
481 }
while (analyzer != null);
486 tableRef.analyze(
this);
487 Path resolvedPath = tableRef.getResolvedPath();
488 if (resolvedPath.destTable() != null) {
489 Table table = resolvedPath.destTable();
490 Preconditions.checkNotNull(table);
493 Preconditions.checkState(table instanceof
HdfsTable ||
495 return new BaseTableRef(tableRef, tableRef.getResolvedPath());
509 Preconditions.checkState(
510 !globalState_.fullOuterJoinedConjuncts.containsKey(e.getId()));
511 List<TupleId> tids = Lists.newArrayList();
512 e.getIds(tids, null);
515 TableRef currentOuterJoin = globalState_.fullOuterJoinedTupleIds.get(tid);
516 globalState_.fullOuterJoinedConjuncts.put(e.getId(), currentOuterJoin);
519 LOG.trace(
"registerFullOuterJoinedConjunct: " +
520 globalState_.fullOuterJoinedConjuncts.toString());
529 globalState_.fullOuterJoinedTupleIds.put(tid, rhsRef);
531 LOG.trace(
"registerFullOuterJoinedTids: " +
532 globalState_.fullOuterJoinedTupleIds.toString());
540 globalState_.outerJoinedTupleIds.put(tid, rhsRef);
542 LOG.trace(
"registerOuterJoinedTids: " + globalState_.outerJoinedTupleIds.toString());
549 globalState_.semiJoinedTupleIds.put(tid, rhsRef);
558 String lookupAlias = tableAlias.toLowerCase();
561 "Unqualified table alias is ambiguous: '%s'", tableAlias));
563 return aliasMap_.get(lookupAlias);
567 return globalState_.descTbl.getTupleDesc(id);
576 return slotRefMap_.get(qualifiedColumnName);
627 ArrayList<String> lcRawPath = Lists.newArrayListWithCapacity(rawPath.size());
628 for (String s: rawPath) lcRawPath.add(s.toLowerCase());
629 return resolvePath(lcRawPath, pathType, resolveInAncestors);
636 ArrayList<Path> candidates = Lists.newArrayList();
640 if (rootDesc != null) {
641 candidates.add(
new Path(rootDesc, rawPath.subList(1, rawPath.size())));
645 if (rawPath.size() > 1) {
646 rootDesc =
getDescriptor(rawPath.get(0) +
"." + rawPath.get(1));
647 if (rootDesc != null) {
648 candidates.add(
new Path(rootDesc, rawPath.subList(2, rawPath.size())));
652 LinkedList<String> errors = Lists.newLinkedList();
656 candidates.add(
new Path(tblRef.getDesc(), rawPath));
662 if (result != null)
return result;
666 int end = Math.min(2, rawPath.size());
667 for (
int tblNameIdx = 0; tblNameIdx < end; ++tblNameIdx) {
668 String dbName = (tblNameIdx == 0) ?
getDefaultDb() : rawPath.get(0);
669 String tblName = rawPath.get(tblNameIdx);
678 candidates.add(
new Path(tbl, rawPath.subList(tblNameIdx + 1, rawPath.size())));
684 if (result == null && resolveInAncestors &&
hasAncestors()) {
687 if (result == null) {
688 Preconditions.checkState(!errors.isEmpty());
701 LinkedList<String> errors) {
703 String pathTypeStr = null;
704 String pathStr = Joiner.on(
".").join(rawPath);
706 pathTypeStr =
"Column/field reference";
708 pathTypeStr =
"Table reference";
710 pathTypeStr =
"Star expression";
714 List<Path> legalPaths = Lists.newArrayList();
715 for (
Path p: paths) {
716 if (!p.resolve())
continue;
719 if (p.getRootDesc() != null && !
isVisible(p.getRootDesc().getId())) {
720 errors.addLast(String.format(
721 "Illegal %s '%s' of semi-/anti-joined table '%s'",
722 pathTypeStr.toLowerCase(), pathStr, p.getRootDesc().getAlias()));
729 if (!p.destType().isCollectionType()) {
730 errors.addFirst(String.format(
731 "Illegal table reference to non-collection type: '%s'\n" +
732 "Path resolved to type: %s", pathStr, p.destType().toSql()));
741 if (p.hasNonDestCollection()) {
742 errors.addFirst(String.format(
743 "Illegal column/field reference '%s' with intermediate " +
744 "collection '%s' of type '%s'",
745 pathStr, p.getFirstCollectionName(),
746 p.getFirstCollectionType().toSql()));
750 if (p.getMatchedTypes().isEmpty())
continue;
757 if (p.hasNonDestCollection()) {
758 errors.addFirst(String.format(
759 "Illegal star expression '%s' with intermediate " +
760 "collection '%s' of type '%s'",
761 pathStr, p.getFirstCollectionName(),
762 p.getFirstCollectionType().toSql()));
765 if (!p.destType().isStructType()) {
766 errors.addFirst(String.format(
767 "Cannot expand star in '%s' because path '%s' resolved to type '%s'." +
768 "\nStar expansion is only valid for paths to a struct type.",
769 pathStr, Joiner.on(
".").join(rawPath), p.destType().toSql()));
778 if (legalPaths.size() > 1) {
779 errors.addFirst(String.format(
"%s is ambiguous: '%s'",
780 pathTypeStr, pathStr));
783 if (legalPaths.isEmpty()) {
784 if (errors.isEmpty()) {
785 errors.addFirst(String.format(
"Could not resolve %s: '%s'",
786 pathTypeStr.toLowerCase(), pathStr));
790 return legalPaths.get(0);
801 String key = slotPath.toString();
803 if (result != null)
return result;
805 result.setPath(slotPath);
806 slotRefMap_.put(slotPath.toString(), result);
814 SlotDescriptor result = globalState_.descTbl.addSlotDescriptor(tupleDesc);
815 globalState_.blockBySlot.put(result.getId(),
this);
825 SlotDescriptor result = globalState_.descTbl.addSlotDescriptor(tupleDesc);
826 globalState_.blockBySlot.put(result.getId(),
this);
827 result.setSourceExprs(srcSlotDesc.getSourceExprs());
828 result.setLabel(srcSlotDesc.getLabel());
829 result.setStats(srcSlotDesc.getStats());
830 result.setType(srcSlotDesc.getType());
850 Preconditions.checkNotNull(rhsRef);
851 Preconditions.checkNotNull(e);
852 List<ExprId> ojConjuncts = null;
854 ojConjuncts = globalState_.conjunctsByOjClause.get(rhsRef);
855 if (ojConjuncts == null) {
856 ojConjuncts = Lists.newArrayList();
857 globalState_.conjunctsByOjClause.put(rhsRef, ojConjuncts);
863 globalState_.ojClauseByConjunct.put(conjunct.getId(), rhsRef);
864 ojConjuncts.add(conjunct.getId());
867 globalState_.sjClauseByConjunct.put(conjunct.getId(), rhsRef);
880 if (!fromHavingClause) conjunct.setIsWhereClauseConjunct();
899 if (fromHavingClause) {
907 throw new IllegalStateException(ex);
919 e.setId(globalState_.conjunctIdGenerator.getNextId());
920 globalState_.conjuncts.put(e.getId(), e);
922 ArrayList<TupleId> tupleIds = Lists.newArrayList();
923 ArrayList<SlotId> slotIds = Lists.newArrayList();
924 e.getIds(tupleIds, slotIds);
930 LOG.trace(
"register tuple/slotConjunct: " + Integer.toString(e.getId().asInt())
931 +
" " + e.
toSql() +
" " + e.debugString());
934 BinaryPredicate binaryPred = (BinaryPredicate) e;
939 if (binaryPred.
getOp() != BinaryPredicate.Operator.EQ &&
940 binaryPred.getOp() != BinaryPredicate.
Operator.NULL_MATCHING_EQ) {
944 if (tupleIds.size() < 2)
return;
947 for (
int i = 0; i < 2; ++i) {
948 tupleIds = Lists.newArrayList();
949 binaryPred.getChild(i).getIds(tupleIds, null);
950 if (tupleIds.size() == 1) {
952 List<ExprId> conjunctIds = Lists.newArrayList();
953 conjunctIds.add(e.getId());
954 globalState_.eqJoinConjuncts.put(tupleIds.get(0), conjunctIds);
956 globalState_.eqJoinConjuncts.get(tupleIds.get(0)).add(e.getId());
958 binaryPred.setIsEqJoinConjunct(
true);
959 LOG.trace(
"register eqJoinConjunct: " + Integer.toString(e.getId().asInt()));
973 LOG.trace(
"register equiv predicate: " + p.toSql() +
" " + p.
debugString());
985 pred.analyzeNoThrow(
this);
995 List<TupleId> tupleIds,
boolean inclOjConjuncts) {
996 LOG.trace(
"getUnassignedConjuncts for " + Id.printIds(tupleIds));
997 List<Expr> result = Lists.newArrayList();
999 if (e.isBoundByTupleIds(tupleIds)
1002 && ((inclOjConjuncts && !e.isConstant())
1005 LOG.trace(
"getUnassignedConjunct: " + e.toSql());
1012 return globalState_.ojClauseByConjunct.containsKey(e.getId());
1016 return globalState_.fullOuterJoinedConjuncts.get(e.getId());
1020 return globalState_.fullOuterJoinedConjuncts.containsKey(e.getId());
1029 List<TupleId> tupleIds = node.getTblRefIds();
1030 LOG.trace(
"getUnassignedConjuncts for node with " + Id.printIds(tupleIds));
1031 List<Expr> result = Lists.newArrayList();
1035 LOG.trace(
"getUnassignedConjunct: " + e.toSql());
1046 List<TupleId> tids = Lists.newArrayList();
1047 e.getIds(tids, null);
1048 if (tids.isEmpty())
return false;
1062 Preconditions.checkState(ref.getJoinOp().isOuterJoin());
1063 List<Expr> result = Lists.newArrayList();
1064 List<ExprId> candidates = globalState_.conjunctsByOjClause.get(ref);
1065 if (candidates == null)
return result;
1066 for (
ExprId conjunctId: candidates) {
1068 Expr e = globalState_.conjuncts.get(conjunctId);
1069 Preconditions.checkNotNull(e);
1071 LOG.trace(
"getUnassignedOjConjunct: " + e.toSql());
1081 return globalState_.outerJoinedTupleIds.get(id);
1090 if (slotDesc.getColumn() == col)
return slotDesc;
1096 return globalState_.descTbl;
1101 throw new AnalysisException(
"This Impala daemon is not ready to accept user " +
1102 "requests. Status: Waiting for catalog update from the StateStore.");
1104 return globalState_.catalog;
1108 return aliasMap_.keySet();
1120 Preconditions.checkNotNull(joinedTblRef);
1121 TupleId id = joinedTblRef.getId();
1122 List<TupleId> nodeTupleIds = Lists.newArrayList(tids);
1123 nodeTupleIds.add(id);
1124 List<ExprId> conjunctIds = globalState_.eqJoinConjuncts.get(id);
1125 if (conjunctIds == null)
return null;
1126 List<Expr> result = Lists.newArrayList();
1127 List<ExprId> ojClauseConjuncts = null;
1128 if (joinedTblRef.
getJoinOp().isOuterJoin()) {
1129 Preconditions.checkState(joinedTblRef.getOnClause() != null);
1130 ojClauseConjuncts = globalState_.conjunctsByOjClause.get(joinedTblRef);
1132 for (
ExprId conjunctId: conjunctIds) {
1133 Expr e = globalState_.conjuncts.get(conjunctId);
1134 Preconditions.checkState(e != null);
1135 if (ojClauseConjuncts != null) {
1136 if (ojClauseConjuncts.contains(conjunctId)
1155 if (fullOuterJoin == null)
return true;
1156 return tids.containsAll(fullOuterJoin.getAllTupleIds());
1170 LOG.trace(
"canEval: " + e.toSql() +
" " + e.
debugString() +
" "
1171 + Id.printIds(tupleIds));
1173 ArrayList<TupleId> tids = Lists.newArrayList();
1174 e.getIds(tids, null);
1175 if (tids.isEmpty())
return true;
1178 if (tids.size() > 1) {
1203 TableRef tblRef = globalState_.ojClauseByConjunct.get(e.getId());
1204 if (tblRef.
getJoinOp().isFullOuterJoin())
return false;
1224 LOG.trace(
"canEval: checking tid " + tid.toString());
1227 if (rhsRef == null)
continue;
1229 boolean contains = tupleIds.containsAll(rhsRef.getAllTupleIds());
1230 LOG.trace(
"canEval: contains=" + (contains ?
"true " :
"false ")
1231 + Id.printIds(tupleIds) +
" " + Id.printIds(rhsRef.getAllTupleIds()));
1232 if (!tupleIds.containsAll(rhsRef.
getAllTupleIds()))
return false;
1247 if (antiJoinRef == null)
return true;
1248 List<TupleId> tids = Lists.newArrayList();
1249 e.getIds(tids, null);
1250 if (tids.size() > 1) {
1251 return nodeTupleIds.containsAll(antiJoinRef.getAllTupleIds())
1252 && antiJoinRef.getAllTupleIds().containsAll(nodeTupleIds);
1256 return globalState_.semiJoinedTupleIds.containsKey(tids.get(0));
1275 boolean markAssigned) {
1276 ArrayList<Expr> result = Lists.newArrayList();
1278 Expr srcConjunct = globalState_.conjuncts.get(srcConjunctId);
1279 if (srcConjunct instanceof
SlotRef)
continue;
1280 Preconditions.checkNotNull(srcConjunct);
1281 List<TupleId> srcTids = Lists.newArrayList();
1282 List<SlotId> srcSids = Lists.newArrayList();
1283 srcConjunct.getIds(srcTids, srcSids);
1284 Preconditions.checkState(srcTids.size() == 1);
1287 TupleId srcTid = srcTids.get(0);
1288 List<List<SlotId>> allDestSids =
1290 if (allDestSids.isEmpty())
continue;
1295 for (
SlotId srcSid: srcSids) {
1297 hasOuterJoinedTuple =
true;
1326 TableRef tblRef = globalState_.ojClauseByConjunct.get(srcConjunct.getId());
1327 if (tblRef.
getJoinOp().isFullOuterJoin())
continue;
1335 for (List<SlotId> destSids: allDestSids) {
1336 Preconditions.checkState(destSids.size() == srcSids.size());
1338 if (srcSids.containsAll(destSids)) {
1342 for (
int i = 0; i < srcSids.size(); ++i) {
1348 p = srcConjunct.trySubstitute(smap,
this,
false);
1353 LOG.trace(
"new pred: " + p.toSql() +
" " + p.debugString());
1364 boolean reverseValueTransfer =
true;
1365 for (
int i = 0; i < srcSids.size(); ++i) {
1367 reverseValueTransfer =
false;
1373 (globalState_.ojClauseByConjunct.get(srcConjunct.getId())
1374 != globalState_.outerJoinedTupleIds.get(srcTid));
1381 if (!result.contains(p)) result.add(p);
1401 Preconditions.checkState(oldRhsTbl.getJoinOp().isOuterJoin());
1403 List<ExprId> conjunctIds = globalState_.conjunctsByOjClause.remove(oldRhsTbl);
1404 Preconditions.checkNotNull(conjunctIds);
1405 globalState_.conjunctsByOjClause.put(newRhsTbl, conjunctIds);
1406 for (
ExprId eid: conjunctIds) {
1407 globalState_.ojClauseByConjunct.put(eid, newRhsTbl);
1410 if (e.getValue() == oldRhsTbl) e.setValue(newRhsTbl);
1431 List<T> conjuncts) {
1432 Preconditions.checkState(!lhsTids.contains(rhsTid));
1435 Map<EquivalenceClassId, List<SlotId>> planEquivClasses =
1439 Map<EquivalenceClassId, List<SlotId>> tidEquivClasses =
1445 DisjointSet<SlotId> partialEquivSlots =
new DisjointSet<SlotId>();
1450 for (List<SlotId> partialEquivClass: planEquivClasses.values()) {
1451 partialEquivSlots.bulkUnion(partialEquivClass);
1453 for (List<SlotId> partialEquivClass: tidEquivClasses.values()) {
1454 partialEquivSlots.bulkUnion(partialEquivClass);
1458 Set<SlotId> outerJoinedSlots = Sets.newHashSet();
1462 Iterator<T> conjunctIter = conjuncts.iterator();
1463 while (conjunctIter.hasNext()) {
1464 Expr conjunct = conjunctIter.next();
1465 Pair<SlotId, SlotId> eqSlots = BinaryPredicate.getEqSlots(conjunct);
1466 if (eqSlots == null)
continue;
1470 if (!firstEqClassId.equals(secondEqClassId))
continue;
1479 boolean filtersOuterJoinNulls =
false;
1481 && lhsTids.contains(
getTupleId(eqSlots.first))
1482 && !outerJoinedSlots.contains(eqSlots.first)) {
1483 outerJoinedSlots.add(eqSlots.first);
1484 filtersOuterJoinNulls =
true;
1487 && lhsTids.contains(
getTupleId(eqSlots.second))
1488 && !outerJoinedSlots.contains(eqSlots.second)) {
1489 outerJoinedSlots.add(eqSlots.second);
1490 filtersOuterJoinNulls =
true;
1494 if (!partialEquivSlots.union(eqSlots.first, eqSlots.second)
1495 && !filtersOuterJoinNulls) {
1496 conjunctIter.remove();
1503 tidEquivClasses.entrySet()) {
1504 List<SlotId> lhsSlots = planEquivClasses.get(tidEquivClass.getKey());
1505 if (lhsSlots == null)
continue;
1506 List<SlotId> rhsSlots = tidEquivClass.getValue();
1507 Preconditions.checkState(!lhsSlots.isEmpty() && !rhsSlots.isEmpty());
1509 if (!partialEquivSlots.union(lhsSlots.get(0), rhsSlots.get(0)))
continue;
1517 newEqPred.analyzeNoThrow(
this);
1519 conjuncts.add(newEqPred);
1536 Set<SlotId> ignoreSlots) {
1539 DisjointSet<SlotId> partialEquivSlots =
new DisjointSet<SlotId>();
1543 partialEquivSlots.bulkUnion(ignoreSlots);
1544 partialEquivSlots.checkConsistency();
1548 Iterator<T> conjunctIter = conjuncts.iterator();
1549 while (conjunctIter.hasNext()) {
1550 Expr conjunct = conjunctIter.next();
1551 Pair<SlotId, SlotId> eqSlots = BinaryPredicate.getEqSlots(conjunct);
1552 if (eqSlots == null)
continue;
1556 if (!firstEqClassId.equals(secondEqClassId))
continue;
1558 if (!partialEquivSlots.union(eqSlots.first, eqSlots.second)) conjunctIter.remove();
1576 Map<EquivalenceClassId, List<SlotId>> targetEquivClasses =
1579 targetEquivClasses.entrySet()) {
1582 List<SlotId> slotIds = targetEquivClass.getValue();
1583 boolean done =
false;
1584 for (
int i = 1; i < slotIds.size(); ++i) {
1585 SlotId rhs = slotIds.get(i);
1586 for (
int j = 0; j < i; ++j) {
1587 SlotId lhs = slotIds.get(j);
1588 if (!partialEquivSlots.union(lhs, rhs))
continue;
1590 newEqPred.analyzeNoThrow(
this);
1592 conjuncts.add(newEqPred);
1594 if (partialEquivSlots.get(lhs).size() == slotIds.size()) {
1613 Map<EquivalenceClassId, List<SlotId>> result = Maps.newHashMap();
1619 List<SlotId> slotIds = result.get(eqClassId);
1620 if (slotIds == null) {
1621 slotIds = Lists.newArrayList();
1622 result.put(eqClassId, slotIds);
1624 slotIds.add(slotDesc.getId());
1638 TupleId destTid, Set<SlotId> ignoreSlots) {
1639 List<List<SlotId>> allDestSids = Lists.newArrayList();
1641 if (srcSids.size() == 1) {
1647 SlotId srcSid = srcSids.get(0);
1649 if (ignoreSlots.contains(destSlot.getId()))
continue;
1651 allDestSids.add(Lists.newArrayList(destSlot.getId()));
1654 }
else if (srcTid.equals(destTid)) {
1660 allDestSids.add(srcSids);
1668 List<SlotId> destSids = Lists.newArrayList();
1669 for (
SlotId srcSid: srcSids) {
1671 if (ignoreSlots.contains(destSlot.getId()))
continue;
1673 && !destSids.contains(destSlot.getId())) {
1674 destSids.add(destSlot.getId());
1679 if (destSids.size() == srcSids.size()) allDestSids.add(destSids);
1689 ArrayList<SlotId> eqClass = globalState_.equivClassMembers.get(eqClassId);
1690 for (
SlotId s: eqClass) {
1703 List<SlotRef> slotRefs = Lists.newArrayList();
1704 p.collect(Predicates.instanceOf(SlotRef.class), slotRefs);
1706 Expr nullTuplePred = null;
1710 nullLiteral.analyzeNoThrow(
this);
1711 for (
SlotRef slotRef: slotRefs) {
1712 nullSmap.put(slotRef.clone(), nullLiteral.
clone());
1714 nullTuplePred = p.substitute(nullSmap,
this,
false);
1716 return FeSupport.EvalPredicate(nullTuplePred,
getQueryCtx());
1718 Preconditions.checkState(
false,
"Failed to evaluate generated predicate: "
1719 + nullTuplePred.toSql() +
"." + e.getMessage());
1725 return globalState_.descTbl.getSlotDesc(slotId).getParent().getId();
1729 globalState_.registeredValueTransfers.add(
new Pair(id1, id2));
1733 return globalState_.outerJoinedTupleIds.containsKey(tid);
1741 return globalState_.semiJoinedTupleIds.containsKey(tid);
1749 TableRef tblRef = globalState_.sjClauseByConjunct.get(e.getId());
1750 if (tblRef == null)
return null;
1751 return (tblRef.
getJoinOp().isAntiJoin()) ? tblRef : null;
1755 return globalState_.fullOuterJoinedTupleIds.containsKey(tid);
1779 globalState_.valueTransferGraph.computeValueTransfers();
1782 int numSlots = globalState_.descTbl.getMaxSlotId().asInt() + 1;
1783 for (
int i = 0; i < numSlots; ++i) {
1785 globalState_.equivClassMembers.put(id, Lists.newArrayList(
new SlotId(i)));
1797 if (e1.getKey() == e2.getKey())
continue;
1798 List<SlotId> class1Members = e1.getValue();
1799 if (class1Members.isEmpty())
continue;
1800 List<SlotId> class2Members = e2.getValue();
1801 if (class2Members.isEmpty())
continue;
1804 boolean canMerge =
true;
1805 for (
SlotId class1Slot: class1Members) {
1806 for (
SlotId class2Slot: class2Members) {
1813 if (!canMerge)
break;
1815 if (!canMerge)
continue;
1818 class1Members.addAll(class2Members);
1819 class2Members.clear();
1827 List<SlotId> members = globalState_.equivClassMembers.get(id);
1828 if (members.isEmpty())
continue;
1830 globalState_.descTbl.getSlotDesc(members.get(0));
1832 SlotDescriptor slotDesc = globalState_.descTbl.getSlotDesc(slotId);
1833 globalState_.equivClassSmap.put(
1841 globalState_.equivClassBySlotId.put(slotId, id);
1851 List<SlotId> equivSlotIds) {
1852 equivSlotIds.clear();
1853 LOG.trace(
"getequivslots: slotid=" + Integer.toString(slotId.asInt()));
1856 if (tupleIds.contains(
1858 equivSlotIds.add(memberId);
1864 return globalState_.equivClassBySlotId.get(slotId);
1875 List<Expr> substL1 =
1876 Expr.substituteList(l1, globalState_.equivClassSmap,
this,
false);
1877 Expr.removeDuplicates(substL1);
1878 List<Expr> substL2 =
1879 Expr.substituteList(l2, globalState_.equivClassSmap,
this,
false);
1880 Expr.removeDuplicates(substL2);
1881 return Expr.equalSets(substL1, substL2);
1888 Expr substE1 = e1.substitute(globalState_.equivClassSmap,
this,
false);
1889 Expr substE2 = e2.substitute(globalState_.equivClassSmap,
this,
false);
1890 return substE1.equals(substE2);
1900 List<Expr> result = Lists.newArrayList();
1901 List<Expr> normalizedExprs =
1902 Expr.substituteList(exprs, globalState_.equivClassSmap,
this,
false);
1903 Preconditions.checkState(exprs.size() == normalizedExprs.size());
1904 List<Expr> uniqueExprs = Lists.newArrayList();
1905 for (
int i = 0; i < normalizedExprs.size(); ++i) {
1906 if (!uniqueExprs.contains(normalizedExprs.get(i))) {
1907 uniqueExprs.add(normalizedExprs.get(i));
1908 result.add(exprs.get(i).clone());
1918 if (conjuncts == null)
return;
1919 for (
Expr p: conjuncts) {
1920 globalState_.assignedConjuncts.add(p.getId());
1921 LOG.trace(
"markAssigned " + p.toSql() +
" " + p.debugString());
1929 LOG.trace(
"markAssigned " + conjunct.toSql() +
" " + conjunct.
debugString());
1930 globalState_.assignedConjuncts.add(conjunct.getId());
1934 return globalState_.assignedConjuncts.contains(conjunct.getId());
1938 return Sets.newHashSet(globalState_.assignedConjuncts);
1942 globalState_.assignedConjuncts = Sets.newHashSet(assigned);
1951 Expr e = globalState_.conjuncts.get(id);
1953 LOG.trace(
"unassigned: " + e.toSql() +
" " + e.
debugString());
1963 List<SlotId> slotIds = Lists.newArrayList();
1964 for (
Expr e: exprs) {
1965 Preconditions.checkState(e.isAnalyzed_);
1966 e.getIds(null, slotIds);
1968 globalState_.descTbl.markSlotsMaterialized(slotIds);
1972 List<SlotId> slotIds = Lists.newArrayList();
1973 Preconditions.checkState(e.isAnalyzed_);
1974 e.getIds(null, slotIds);
1975 globalState_.descTbl.markSlotsMaterialized(slotIds);
1990 Expr lastCompatibleExpr,
Expr expr)
1992 Type newCompatibleType;
1993 if (lastCompatibleType == null) {
1994 newCompatibleType = expr.getType();
1996 newCompatibleType = Type.getAssignmentCompatibleType(
1997 lastCompatibleType, expr.getType());
1999 if (!newCompatibleType.
isValid()) {
2001 "Incompatible return types '%s' and '%s' of exprs '%s' and '%s'.",
2002 lastCompatibleType.toSql(), expr.getType().toSql(),
2003 lastCompatibleExpr.toSql(), expr.toSql()));
2005 return newCompatibleType;
2016 Expr lastCompatibleExpr = exprs.get(0);
2017 Type compatibleType = null;
2018 for (
int i = 0; i < exprs.size(); ++i) {
2019 exprs.get(i).analyze(
this);
2024 for (
int i = 0; i < exprs.size(); ++i) {
2025 if (!exprs.get(i).getType().equals(compatibleType)) {
2026 Expr castExpr = exprs.get(i).castTo(compatibleType);
2027 exprs.set(i, castExpr);
2030 return compatibleType;
2040 if (exprLists == null || exprLists.size() < 2)
return;
2043 List<Expr> firstList = exprLists.get(0);
2044 for (
int i = 0; i < firstList.size(); ++i) {
2047 Type compatibleType = firstList.get(i).getType();
2049 Expr lastCompatibleExpr = firstList.get(i);
2050 for (
int j = 1; j < exprLists.size(); ++j) {
2051 Preconditions.checkState(exprLists.get(j).size() == firstList.size());
2053 lastCompatibleExpr, exprLists.get(j).get(i));
2054 lastCompatibleExpr = exprLists.get(j).
get(i);
2057 for (
int j = 0; j < exprLists.size(); ++j) {
2058 if (!exprLists.get(j).get(i).getType().equals(compatibleType)) {
2059 Expr castExpr = exprLists.get(j).
get(i).castTo(compatibleType);
2060 exprLists.get(j).set(i, castExpr);
2066 public String
getDefaultDb() {
return globalState_.queryCtx.session.database; }
2070 public ListMap<TNetworkAddress>
getHostIndex() {
return globalState_.hostIndex; }
2073 Preconditions.checkNotNull(globalState_.lineageGraph);
2074 return globalState_.lineageGraph.toJson();
2078 return ImmutableList.copyOf(globalState_.privilegeReqs);
2088 globalState_.accessEvents.add(event);
2102 table =
getCatalog().getTable(dbName, tableName);
2106 String errMsg = String.format(
"Failed to load metadata for table: %s", tableName);
2109 LOG.error(String.format(
"%s\n%s", errMsg, e.getMessage()));
2111 throw new TableLoadingException(errMsg, e);
2113 if (table == null) {
2120 "Table/view is missing metadata: " + table.
getFullName());
2136 Preconditions.checkNotNull(tableName);
2137 Preconditions.checkNotNull(privilege);
2142 .onTable(tableName.getDb(), tableName.getTbl()).allOf(privilege).toRequest());
2147 table =
getTable(tableName.getDb(), tableName.getTbl());
2151 Preconditions.checkNotNull(table);
2154 TCatalogObjectType objectType = TCatalogObjectType.TABLE;
2155 if (table instanceof
View) objectType = TCatalogObjectType.VIEW;
2156 globalState_.accessEvents.add(
new TAccessEvent(
2157 tableName.toString(), objectType, privilege.toString()));
2172 return getTable(tableName, privilege,
true);
2186 return getDb(dbName, privilege,
true);
2199 if (db == null && throwIfDoesNotExist) {
2202 globalState_.accessEvents.add(
new TAccessEvent(
2203 dbName, TCatalogObjectType.DATABASE, privilege.toString()));
2218 .onTable(dbName, tableName).toRequest());
2224 return db.containsTable(tableName);
2256 public boolean isExplain() {
return globalState_.isExplain; }
2263 this.hasLimitOffsetClause_ = hasLimitOffset;
2267 return new ArrayList<Expr>(globalState_.conjuncts.values());
2270 return globalState_.conjuncts.get(exprId);
2282 return globalState_.valueTransferGraph.hasValueTransfer(a, b);
2291 int numSlots = globalState_.descTbl.getMaxSlotId().asInt() + 1;
2292 for (
int i = 0; i < numSlots; ++i) {
2296 globalState_.equivClassMembers.put(classId, Lists.newArrayList(slotId));
2297 globalState_.equivClassBySlotId.put(slotId, classId);
2308 if (msg == null)
return;
2309 Integer
count = globalState_.warnings.get(msg);
2310 if (count == null) count = 0;
2311 globalState_.warnings.put(msg, count + 1);
2356 long start = System.currentTimeMillis();
2359 List<Pair<SlotId, SlotId>> origValueTransfers = Lists.newArrayList();
2363 int origNumSlots = globalState_.descTbl.getMaxSlotId().asInt() + 1;
2368 for (
SlotId slotId: equivClass) {
2369 coalescedSlots_[slotId.asInt()] = representative;
2376 List<Pair<Integer, Integer>> coalescedValueTransfers = Lists.newArrayList();
2379 DisjointSet<Integer> graphPartitions =
new DisjointSet<Integer>();
2380 mapSlots(origValueTransfers, coalescedValueTransfers, graphPartitions);
2387 Map<Set<Integer>, List<Pair<Integer, Integer>>> partitionedValueTransfers =
2389 for (Pair<Integer, Integer> vt: coalescedValueTransfers) {
2390 Set<Integer> partition = graphPartitions.get(vt.first.intValue());
2391 List<Pair<Integer, Integer>> l = partitionedValueTransfers.get(partition);
2393 l = Lists.newArrayList();
2394 partitionedValueTransfers.put(partition, l);
2401 valueTransfer_ =
new boolean[numCoalescedSlots][numCoalescedSlots];
2402 for (
int i = 0; i < numCoalescedSlots; ++i) {
2407 for (Map.Entry<Set<Integer>, List<Pair<Integer, Integer>>> graphPartition:
2408 partitionedValueTransfers.entrySet()) {
2410 for (Pair<Integer, Integer> vt: graphPartition.getValue()) {
2413 Set<Integer> partitionSlotIds = graphPartition.getKey();
2415 if (partitionSlotIds.size() <= 2)
continue;
2419 int[] p =
new int[partitionSlotIds.size()];
2420 int numPartitionSlots = 0;
2421 for (Integer slotId: partitionSlotIds) {
2422 p[numPartitionSlots++] = slotId;
2428 boolean changed =
false;
2431 for (
int i = 0; i < numPartitionSlots; ++i) {
2432 for (
int j = 0; j < numPartitionSlots; ++j) {
2433 for (
int k = 0; k < numPartitionSlots; ++k) {
2445 long end = System.currentTimeMillis();
2446 LOG.trace(
"Time taken in computeValueTransfers(): " + (end - start) +
"ms");
2456 public void bulkUpdate(List<Pair<SlotId, SlotId>> mutualValueTransfers) {
2459 int oldNumSlots = coalescedSlots_.length;
2460 int maxNumSlots = globalState_.descTbl.getMaxSlotId().asInt() + 1;
2465 for (Pair<SlotId, SlotId> valTrans: mutualValueTransfers) {
2466 SlotId existingSid = valTrans.first;
2467 SlotId newSid = valTrans.second;
2469 Preconditions.checkState(completeSubGraphs_.get(newSid) == null);
2470 Preconditions.checkState(coalescedSlots_[newSid.asInt()] == -1);
2471 completeSubGraphs_.union(existingSid, newSid);
2472 coalescedSlots_[newSid.asInt()] = coalescedSlots_[existingSid.asInt()];
2481 if (slotA.equals(slotB))
return true;
2484 if (mappedSrcId == -1 || mappedDestId == -1)
return false;
2486 Set<SlotId> eqSlots = completeSubGraphs_.get(slotA);
2487 if (eqSlots == null)
return false;
2488 return eqSlots.contains(slotB);
2498 private void mapSlots(List<Pair<SlotId, SlotId>> origValueTransfers,
2499 List<Pair<Integer, Integer>> coalescedValueTransfers,
2500 DisjointSet<Integer> graphPartitions) {
2501 for (Pair<SlotId, SlotId> vt: origValueTransfers) {
2514 coalescedValueTransfers.add(
2515 new Pair<Integer, Integer>(Integer.valueOf(src), Integer.valueOf(dest)));
2516 graphPartitions.union(Integer.valueOf(src), Integer.valueOf(dest));
2530 List<Pair<SlotId, SlotId>> valueTransfers) {
2533 Expr e = globalState_.conjuncts.get(id);
2534 Pair<SlotId, SlotId> slotIds = BinaryPredicate.getEqSlots(e);
2535 if (slotIds == null)
continue;
2537 boolean isAntiJoin =
false;
2538 TableRef sjTblRef = globalState_.sjClauseByConjunct.get(id);
2539 Preconditions.checkState(sjTblRef == null || sjTblRef.getJoinOp().isSemiJoin());
2540 isAntiJoin = sjTblRef != null && sjTblRef.getJoinOp().isAntiJoin();
2542 TableRef ojTblRef = globalState_.ojClauseByConjunct.get(id);
2543 Preconditions.checkState(ojTblRef == null || ojTblRef.getJoinOp().isOuterJoin());
2544 if (ojTblRef == null && !isAntiJoin) {
2549 Analyzer firstBlock = globalState_.blockBySlot.get(slotIds.first);
2550 Analyzer secondBlock = globalState_.blockBySlot.get(slotIds.second);
2551 LOG.trace(
"value transfer: from " + slotIds.first.toString());
2552 Pair<SlotId, SlotId> firstToSecond = null;
2553 Pair<SlotId, SlotId> secondToFirst = null;
2554 if (!(secondBlock.hasLimitOffsetClause_ &&
2555 secondBlock.ancestors_.contains(firstBlock))) {
2556 firstToSecond =
new Pair<SlotId, SlotId>(slotIds.first, slotIds.second);
2559 firstBlock.
ancestors_.contains(secondBlock))) {
2560 secondToFirst =
new Pair<SlotId, SlotId>(slotIds.second, slotIds.first);
2564 if (firstToSecond != null && secondToFirst != null
2565 && completeSubGraphs != null) {
2566 completeSubGraphs.union(slotIds.first, slotIds.second);
2568 if (firstToSecond != null) valueTransfers.add(firstToSecond);
2569 if (secondToFirst != null) valueTransfers.add(secondToFirst);
2574 TableRef tblRef = (ojTblRef != null) ? ojTblRef : sjTblRef;
2575 Preconditions.checkNotNull(tblRef);
2583 SlotId outerSlot, innerSlot;
2585 innerSlot = slotIds.first;
2586 outerSlot = slotIds.second;
2588 innerSlot = slotIds.second;
2589 outerSlot = slotIds.first;
2603 if (tblRef.
getJoinOp() == JoinOperator.LEFT_OUTER_JOIN
2606 valueTransfers.add(
new Pair<SlotId, SlotId>(outerSlot, innerSlot));
2607 }
else if (tblRef.
getJoinOp() == JoinOperator.RIGHT_OUTER_JOIN
2609 valueTransfers.add(
new Pair<SlotId, SlotId>(innerSlot, outerSlot));
2622 public boolean validate(StringBuilder expected, StringBuilder actual) {
2623 Preconditions.checkState(expected.length() == 0 && actual.length() == 0);
2624 int numSlots = globalState_.descTbl.getMaxSlotId().asInt() + 1;
2625 boolean[][] expectedValueTransfer =
new boolean[numSlots][numSlots];
2626 for (
int i = 0; i < numSlots; ++i) {
2627 expectedValueTransfer[i][i] =
true;
2631 List<Pair<SlotId, SlotId>> valueTransfers = Lists.newArrayList();
2633 for (Pair<SlotId, SlotId> vt: valueTransfers) {
2634 expectedValueTransfer[vt.first.asInt()][vt.second.asInt()] =
true;
2638 expectedValueTransfer[vt.first.asInt()][vt.second.asInt()] =
true;
2642 boolean changed =
false;
2645 for (
int i = 0; i < numSlots; ++i) {
2646 for (
int j = 0; j < numSlots; ++j) {
2647 for (
int k = 0; k < numSlots; ++k) {
2648 if (expectedValueTransfer[i][j] && expectedValueTransfer[j][k]
2649 && !expectedValueTransfer[i][k]) {
2650 expectedValueTransfer[i][k] =
true;
2659 boolean[][] actualValueTransfer =
new boolean[numSlots][numSlots];
2660 for (
int i = 0; i < numSlots; ++i) {
2661 for (
int j = 0; j < numSlots; ++j) {
2667 PrintUtils.printMatrix(expectedValueTransfer, 3, expected);
2668 PrintUtils.printMatrix(actualValueTransfer, 3, actual);
2669 String expectedStr = expected.toString();
2670 String actualStr = actual.toString();
2671 return expectedStr.equals(actualStr);
2689 globalState_.privilegeReqs.add(privReq);
2691 globalState_.maskedPrivilegeReqs.add(Pair.create(privReq,
authErrorMsg_));
2704 String dbName = null;
2706 dbName = privReq.getName();
2709 dbName = tbl.getDbName();
2716 authzChecker.checkAccess(
getUser(), privReq);
2721 if (!authzChecker.hasAccess(
getUser(), maskedReq.first)) {
2734 Db db = globalState_.catalog.getDb(dbName);
2736 switch (privilege) {
void markConstantConjunct(Expr conjunct, boolean fromHavingClause)
void computeEquivClasses()
final DescriptorTable descTbl
boolean hasMutualValueTransfer(SlotId slotA, SlotId slotB)
String getTargetDbName(FunctionName fnName)
Type castAllToCompatibleType(List< Expr > exprs)
Set< ExprId > getAssignedConjuncts()
SlotDescriptor registerSlotRef(Path slotPath)
String getSerializedLineageGraph()
void invertOuterJoinState(TableRef oldRhsTbl, TableRef newRhsTbl)
DescriptorTable getDescTbl()
boolean isFullOuterJoined(SlotId sid)
boolean isWhereClauseConjunct()
public< T extends Expr > void createEquivConjuncts(TupleId tid, List< T > conjuncts, Set< SlotId > ignoreSlots)
TableRef getTableRef(TupleId tid)
Path resolvePath(List< String > rawPath, PathType pathType)
final Map< TupleId, List< ExprId > > eqJoinConjuncts
void createAuxEquivPredicate(Expr lhs, Expr rhs)
TupleId visibleSemiJoinedTupleId_
boolean hasValueTransfer(SlotId a, SlotId b)
void markConjunctAssigned(Expr conjunct)
void addWarning(String msg)
Analyzer(Analyzer parentAnalyzer)
Set< ExprId > assignedConjuncts
final Map< TupleId, TableRef > semiJoinedTupleIds
boolean isOuterJoined(SlotId sid)
final Map< EquivalenceClassId, ArrayList< SlotId > > equivClassMembers
List< Expr > getEqJoinConjuncts(List< TupleId > tids, TableRef joinedTblRef)
void registerConjuncts(Expr e, boolean fromHavingClause)
boolean isFullOuterJoined(TupleId tid)
void setAuthErrMsg(String errMsg)
TupleDescriptor getDescriptor(String tableAlias)
static Analyzer createWithNewGlobalState(Analyzer parentAnalyzer)
ArrayList< Expr > getBoundPredicates(TupleId destTid)
SlotDescriptor addSlotDescriptor(TupleDescriptor tupleDesc)
Set< TAccessEvent > accessEvents
boolean isAntiJoinedConjunct(Expr e)
List< TupleId > getAllTupleIds()
final Map< String, TupleDescriptor > aliasMap_
PrivilegeRequestBuilder any()
boolean hasEmptySpjResultSet_
Set< TAccessEvent > getAccessEvents()
ValueTransferGraph valueTransferGraph
final ExprSubstitutionMap equivClassSmap
TableRef resolveTableRef(TableRef tableRef)
boolean canEvalPredicate(List< TupleId > tupleIds, Expr e)
SlotDescriptor getSlotDesc(SlotId id)
ArrayList< TupleId > getTblRefIds()
void registerConjuncts(List< Expr > l)
void castToUnionCompatibleTypes(List< List< Expr >> exprLists)
Set< TableName > getMissingTbls()
TupleId getTupleId(SlotId slotId)
final Map< ExprId, TableRef > fullOuterJoinedConjuncts
BinaryPredicate createEqPredicate(SlotId lhsSlotId, SlotId rhsSlotId)
final List< Pair< SlotId, SlotId > > registeredValueTransfers
final Set< String > ambiguousAliases_
final Map< ExprId, TableRef > sjClauseByConjunct
final Map< ExprId, Expr > conjuncts
void setHasLimitOffsetClause(boolean hasLimitOffset)
void registerOuterJoinedTids(List< TupleId > tids, TableRef rhsRef)
void setAssignedConjuncts(Set< ExprId > assigned)
boolean hasEmptyResultSet_
void setHasEmptyResultSet()
final Map< String, View > localViews_
boolean setHasPlanHints()
TableRef getLastOjClause(TupleId id)
boolean evalByJoin(Expr e)
Set< TableName > missingTbls_
void registerFullOuterJoinedConjunct(Expr e)
Operator(String description, String name, TComparisonOp thriftOp)
Path resolvePath(List< String > rawPath, PathType pathType, boolean resolveInAncestors)
boolean containsSubquery()
final ImpaladCatalog catalog
Analyzer(Analyzer parentAnalyzer, GlobalState globalState)
boolean hasEmptySpjResultSet()
void markConjunctsAssigned(List< Expr > conjuncts)
Type getCompatibleType(Type lastCompatibleType, Expr lastCompatibleExpr, Expr expr)
void registerValueTransfer(SlotId id1, SlotId id2)
boolean canEvalAntiJoinedConjunct(Expr e, List< TupleId > nodeTupleIds)
final Map< TupleId, TableRef > fullOuterJoinedTupleIds
void registerOnClauseConjuncts(Expr e, TableRef rhsRef)
void bulkUpdate(List< Pair< SlotId, SlotId >> mutualValueTransfers)
Db getDb(String dbName, Privilege privilege, boolean throwIfDoesNotExist)
boolean hasEmptyResultSet()
List< Expr > getUnassignedOjConjuncts(TableRef ref)
Path resolvePaths(List< String > rawPath, List< Path > paths, PathType pathType, LinkedList< String > errors)
public< T extends Expr > void createEquivConjuncts(List< TupleId > lhsTids, TupleId rhsTid, List< T > conjuncts)
void computeValueTransfers()
boolean isVisible(TupleId tid)
final List< PrivilegeRequest > privilegeReqs
List< List< SlotId > > getEquivDestSlotIds(TupleId srcTid, List< SlotId > srcSids, TupleId destTid, Set< SlotId > ignoreSlots)
final Map< TupleId, TableRef > outerJoinedTupleIds
void authorize(AuthorizationChecker authzChecker)
SlotDescriptor copySlotDescriptor(SlotDescriptor srcSlotDesc, TupleDescriptor tupleDesc)
void setEnablePrivChecks(boolean value)
boolean hasLimitOffsetClause_
final Map< ExprId, TableRef > ojClauseByConjunct
final List< Pair< PrivilegeRequest, String > > maskedPrivilegeReqs
void registerPrivReq(PrivilegeRequest privReq)
final Map< SlotId, EquivalenceClassId > equivClassBySlotId
void registerSemiJoinedTid(TupleId tid, TableRef rhsRef)
void createIdentityEquivClasses()
Analyzer(ImpaladCatalog catalog, TQueryCtx queryCtx, AuthorizationConfig authzConfig)
Db getDb(String dbName, Privilege privilege)
boolean isSemiJoined(TupleId tid)
List< Expr > removeRedundantExprs(List< Expr > exprs)
SlotDescriptor getSlotDescriptor(String qualifiedColumnName)
ArrayList< SlotDescriptor > getSlots()
GlobalState(ImpaladCatalog catalog, TQueryCtx queryCtx, AuthorizationConfig authzConfig)
static boolean EvalPredicate(Expr pred, TQueryCtx queryCtx)
static final String TBL_ALREADY_EXISTS_ERROR_MSG
AuthorizationConfig getAuthzConfig()
TupleDescriptor getTupleDesc(TupleId id)
boolean equivExprs(Expr e1, Expr e2)
Map< String, View > getLocalViews()
final Map< TableRef, List< ExprId > > conjunctsByOjClause
TupleDescriptor registerTableRef(TableRef ref)
TableName getFqTableName(TableName tableName)
final Map< TupleId, TableRef > tableRefMap_
boolean hasExplicitAlias()
void addAccessEvent(TAccessEvent event)
final GlobalState globalState_
boolean isOjConjunct(Expr e)
final Map< SlotId, Analyzer > blockBySlot
boolean isOuterJoined(TupleId tid)
void materializeSlots(Expr e)
boolean isConjunctAssigned(Expr conjunct)
ArrayList< Expr > getBoundPredicates(TupleId destTid, Set< SlotId > ignoreSlots, boolean markAssigned)
Set< String > getAliases()
void materializeSlots(List< Expr > exprs)
void setUseHiveColLabels(boolean useHiveColLabels)
String getTargetDbName(TableName tableName)
void registerLocalView(View view)
final ColumnLineageGraph lineageGraph
SlotDescriptor getColumnSlot(TupleDescriptor tupleDesc, Column col)
EventSequence getTimeline()
ImmutableList< PrivilegeRequest > getPrivilegeReqs()
public< T extends Expr > void createEquivConjuncts(TupleId tid, List< T > conjuncts)
static final String DB_DOES_NOT_EXIST_ERROR_MSG
void mapSlots(List< Pair< SlotId, SlotId >> origValueTransfers, List< Pair< Integer, Integer >> coalescedValueTransfers, DisjointSet< Integer > graphPartitions)
List< Expr > getUnassignedConjuncts(PlanNode node)
List< Expr > getUnassignedConjuncts(List< TupleId > tupleIds, boolean inclOjConjuncts)
TableRef getAntiJoinRef(Expr e)
final IdGenerator< ExprId > conjunctIdGenerator
final EventSequence timeline
final AuthorizationConfig authzConfig
boolean isWhereClauseConjunct_
List< Expr > getConjuncts()
Analyzer getParentAnalyzer()
ColumnLineageGraph getColumnLineageGraph()
List< String > getWarnings()
PrivilegeRequestBuilder allOf(Privilege privilege)
NULL_AWARE_LEFT_ANTI_JOIN
ExprSubstitutionMap getEquivClassSmap()
boolean containsOuterJoinedTid(List< TupleId > tids)
Table getTable(String dbName, String tableName)
boolean[][] valueTransfer_
static final String DATA_SRC_ALREADY_EXISTS_ERROR_MSG
TableRef getFullOuterJoinRef(Expr e)
static final String DB_ALREADY_EXISTS_ERROR_MSG
Map< EquivalenceClassId, List< SlotId > > getEquivClasses(List< TupleId > tids)
boolean equivSets(List< Expr > l1, List< Expr > l2)
final ListMap< TNetworkAddress > hostIndex
boolean useHiveColLabels()
void partitionValueTransfers(DisjointSet< SlotId > completeSubGraphs, List< Pair< SlotId, SlotId >> valueTransfers)
static final String FN_DOES_NOT_EXIST_ERROR_MSG
static final String DATA_SRC_DOES_NOT_EXIST_ERROR_MSG
boolean canEvalFullOuterJoinedConjunct(Expr e, List< TupleId > tids)
boolean hasUnassignedConjuncts()
boolean enablePrivChecks_
final DisjointSet< SlotId > completeSubGraphs_
boolean isFullOuterJoined(Expr e)
final IdGenerator< EquivalenceClassId > equivClassIdGenerator
final Map< String, SlotDescriptor > slotRefMap_
boolean hasValueTransfer(SlotId slotA, SlotId slotB)
EquivalenceClassId getEquivClassId(SlotId slotId)
ImpaladCatalog getCatalog()
boolean checkSystemDbAccess(String dbName, Privilege privilege)
final LinkedHashMap< String, Integer > warnings
Authorizeable getAuthorizeable()
boolean isFullyQualified()
boolean isBoundByTupleIds(List< TupleId > tids)
List< Expr > getConjuncts()
boolean isTrueWithNullSlots(Expr p)
void getEquivSlots(SlotId slotId, List< TupleId > tupleIds, List< SlotId > equivSlotIds)
static final String TBL_DOES_NOT_EXIST_ERROR_MSG
Table getTable(TableName tableName, Privilege privilege)
final ArrayList< Analyzer > ancestors_
boolean canEvalPredicate(PlanNode node, Expr e)
void registerFullOuterJoinedTids(List< TupleId > tids, TableRef rhsRef)
Table getTable(TableName tableName, Privilege privilege, boolean addAccessEvent)
void registerConjunct(Expr e)
Expr getConjunct(ExprId exprId)
ListMap< TNetworkAddress > getHostIndex()
final ArrayList< ExprId > singleTidConjuncts
void setVisibleSemiJoinedTuple(TupleId tid)
static String getEffectiveUser(TSessionState session)
static final String FN_ALREADY_EXISTS_ERROR_MSG
boolean hasOuterJoinedTuple(EquivalenceClassId eqClassId)
boolean dbContainsTable(String dbName, String tableName, Privilege privilege)
boolean validate(StringBuilder expected, StringBuilder actual)