docs: protected boolean orderByColumnsCoverUniqueKeys() {
          // In theory, if EVERY table in the query has a uniqueness constraint
          // (primary key or other unique index) on columns that are all listed in the ORDER BY values,
          // the result is deterministic.
          // This holds regardless of whether the associated index is actually used in the selected plan,
          // so this check is plan-independent.
          //
          // baseTableAliases associates table aliases with the order by
          // expressions which reference them.  Presumably by using
          // table aliases we will map table scans to expressions rather
          // than tables to expressions, and not confuse ourselves with
          // different instances of the same table in self joins.
          HashMap<String, List<AbstractExpression> > baseTableAliases =
                  new HashMap<>();
          for (ParsedColInfo col : orderByColumns()) {
              AbstractExpression expr = col.m_expression;
              //
              // Compute the set of tables mentioned in the expression.
              //   1. Search out all the TVEs.
              //   2. Throw the aliases of the tables of each of these into a HashSet.
              //      The table must have an alias.  It might not have a name.
              //   3. If the HashSet has size > 1 we can't use this expression.
              //
              List<TupleValueExpression> baseTVEExpressions =
                      expr.findAllTupleValueSubexpressions();
              Set<String> baseTableNames = new HashSet<>();
              for (TupleValueExpression tve : baseTVEExpressions) {
                  String tableAlias = tve.getTableAlias();
                  assert(tableAlias != null);
                  baseTableNames.add(tableAlias);
              }
              if (baseTableNames.size() != 1) {
                  // Table-spanning ORDER BYs -- like ORDER BY A.X + B.Y are not helpful.
                  // Neither are (nonsense) constant (table-less) expressions.
                  continue;
              }
              // Everything in the baseTVEExpressions table is a column
              // in the same table and has the same alias. So just grab the first one.
              // All we really want is the alias.
              AbstractExpression baseTVE = baseTVEExpressions.get(0);
              String nextTableAlias = ((TupleValueExpression)baseTVE).getTableAlias();
              // This was tested above.  But the assert above may prove to be over cautious
              // and disappear.
              assert(nextTableAlias != null);
              List<AbstractExpression> perTable = baseTableAliases.get(nextTableAlias);
              if (perTable == null) {
                  perTable = new ArrayList<>();
                  baseTableAliases.put(nextTableAlias, perTable);
              }
              perTable.add(expr);
          }
  
          if (m_tableAliasMap.size() > baseTableAliases.size()) {
              // FIXME: There are more table aliases in the select list than tables
              //        named in the order by clause.  So, some tables named in the
              //        select list are not explicitly listed in the order by
              //        clause.
              //
              //        This would be one of the tricky cases where the goal would be to prove that the
              //        row with no ORDER BY component came from the right side of a 1-to-1 or many-to-1 join.
              //        like Unique Index nested loop join, etc.
              return false;
          }
          boolean allScansAreDeterministic = true;
          for (Entry<String, List<AbstractExpression>> orderedAlias : baseTableAliases.entrySet()) {
              List<AbstractExpression> orderedAliasExprs = orderedAlias.getValue();
              StmtTableScan tableScan = getStmtTableScanByAlias(orderedAlias.getKey());
              if (tableScan == null) {
                  assert(false);
                  return false;
              }
  
              if (tableScan instanceof StmtSubqueryScan) {
                  return false; // don't yet handle FROM clause subquery, here.
              }
  
              Table table = ((StmtTargetTableScan)tableScan).getTargetTable();
  
              // This table's scans need to be proven deterministic.
              allScansAreDeterministic = false;
              // Search indexes for one that makes the order by deterministic
              for (Index index : table.getIndexes()) {
                  // skip non-unique indexes
                  if ( ! index.getUnique()) {
                      continue;
                  }
  
                  // get the list of expressions for the index
                  List<AbstractExpression> indexExpressions = new ArrayList<>();
  
                  String jsonExpr = index.getExpressionsjson();
                  // if this is a pure-column index...
                  if (jsonExpr.isEmpty()) {
                      for (ColumnRef cref : index.getColumns()) {
                          Column col = cref.getColumn();
                          TupleValueExpression tve = new TupleValueExpression(table.getTypeName(),
                                                                              orderedAlias.getKey(),
                                                                              col.getName(),
                                                                              col.getName(),
                                                                              col.getIndex());
                          indexExpressions.add(tve);
                      }
                  }
                  // if this is a fancy expression-based index...
                  else {
                      try {
                          indexExpressions = AbstractExpression.fromJSONArrayString(jsonExpr, tableScan);
                      }
                      catch (JSONException e) {
                          e.printStackTrace();
                          assert(false);
                          continue;
                      }
                  }
  
                  // If the sort covers the index, then it's a unique sort.
                  // TODO: The statement's equivalence sets would be handy here to recognize cases like
                  //    WHERE B.unique_id = A.b_id
                  //    ORDER BY A.unique_id, A.b_id
                  if (orderedAliasExprs.containsAll(indexExpressions)) {
                      allScansAreDeterministic = true;
                      break;
                  }
              }
              // ALL tables' scans need to have proved deterministic
              if ( ! allScansAreDeterministic) {
                  return false;
              }
          }
          return true;
      }