private static boolean isReadOnlyTxn(ASTNode tree) {
    final ASTSearcher astSearcher = new ASTSearcher();
    return READ_TXN_TOKENS.contains(tree.getToken().getType())
      || (tree.getToken().getType() == HiveParser.TOK_QUERY && Stream.of(
          new int[]{HiveParser.TOK_INSERT_INTO},
          new int[]{HiveParser.TOK_INSERT, HiveParser.TOK_TAB})
      .noneMatch(pattern -> astSearcher.simpleBreadthFirstSearch(tree, pattern) != null));
  }
Determines transaction type based on query AST.
@param tree AST
ql/src/java/org/apache/hadoop/hive/ql/io/AcidUtils.java