private static AlterTableExecuteDesc getExpireSnapshotDesc(TableName tableName, Map<String, String> partitionSpec,
      List<Node> children, HiveConf conf) throws SemanticException {
    AlterTableExecuteSpec<ExpireSnapshotsSpec> spec;
    if (children.size() == 1) {
      spec = new AlterTableExecuteSpec(EXPIRE_SNAPSHOT, null);
      return new AlterTableExecuteDesc(tableName, partitionSpec, spec);
    }
    ZoneId timeZone = SessionState.get() == null ?
        new HiveConf().getLocalTimeZone() :
        SessionState.get().getConf().getLocalTimeZone();
    ASTNode firstNode = (ASTNode) children.get(1);
    String firstNodeText = PlanUtils.stripQuotes(firstNode.getText().trim());
    if (firstNode.getType() == KW_RETAIN) {
      ASTNode numRetainLastNode = (ASTNode) children.get(2);
      String numToRetainText = PlanUtils.stripQuotes(numRetainLastNode.getText());
      int numToRetain = Integer.parseInt(numToRetainText);
      spec = new AlterTableExecuteSpec(EXPIRE_SNAPSHOT, new ExpireSnapshotsSpec(numToRetain));
    } else if (children.size() == 3) {
      ASTNode secondNode = (ASTNode) children.get(2);
      String secondNodeText = PlanUtils.stripQuotes(secondNode.getText().trim());
      TimestampTZ fromTime = TimestampTZUtil.parse(getTimeStampString(conf, firstNode, firstNodeText), timeZone);
      TimestampTZ toTime = TimestampTZUtil.parse(getTimeStampString(conf, secondNode, secondNodeText), timeZone);
      spec = new AlterTableExecuteSpec(EXPIRE_SNAPSHOT,
          new ExpireSnapshotsSpec(fromTime.toEpochMilli(), toTime.toEpochMilli()));
    } else if (EXPIRE_SNAPSHOT_BY_ID_REGEX.matcher(firstNodeText).matches()) {
      spec = new AlterTableExecuteSpec(EXPIRE_SNAPSHOT, new ExpireSnapshotsSpec(firstNodeText));
    } else {
      TimestampTZ time = TimestampTZUtil.parse(getTimeStampString(conf, firstNode, firstNodeText), timeZone);
      spec = new AlterTableExecuteSpec(EXPIRE_SNAPSHOT, new ExpireSnapshotsSpec(time.toEpochMilli()));
    }
    return new AlterTableExecuteDesc(tableName, partitionSpec, spec);
  }
Analyzer for ALTER TABLE ... EXECUTE commands.
ql/src/java/org/apache/hadoop/hive/ql/ddl/table/execute/AlterTableExecuteAnalyzer.java