presto-main/src/main/java/io/prestosql/sql/planner/sanity/ValidateDependenciesChecker.java/ValidateDependenciesChecker/checkLeftOutputSymbolsBeforeRight
class ValidateDependenciesChecker:        private void checkLeftOutputSymbolsBeforeRight(List<Symbol> leftSymbols, List<Symbol> outputSymbols)
        {
            int leftMaxPosition = -1;
            Optional<Integer> rightMinPosition = Optional.empty();
            Set<Symbol> leftSymbolsSet = new HashSet<>(leftSymbols);
            for (int i = 0; i < outputSymbols.size(); i++) {
                Symbol symbol = outputSymbols.get(i);
                if (leftSymbolsSet.contains(symbol)) {
                    leftMaxPosition = i;
                }
                else if (!rightMinPosition.isPresent()) {
                    rightMinPosition = Optional.of(i);
                }
            }
            checkState(!rightMinPosition.isPresent() || rightMinPosition.get() > leftMaxPosition, "Not all left output symbols are before right output symbols");
        }