public boolean fillStorageFormat(ASTNode child) throws SemanticException {
    switch (child.getToken().getType()) {
    case HiveParser.TOK_TABLEFILEFORMAT:
      if (child.getChildCount() < 2) {
        throw new SemanticException(
          "Incomplete specification of File Format. " +
            "You must provide InputFormat, OutputFormat.");
      }
      inputFormat = ensureClassExists(BaseSemanticAnalyzer.unescapeSQLString(child.getChild(0).getText()));
      outputFormat = ensureClassExists(BaseSemanticAnalyzer.unescapeSQLString(child.getChild(1).getText()));
      if (child.getChildCount() == 3) {
        serde = ensureClassExists(BaseSemanticAnalyzer.unescapeSQLString(child.getChild(2).getText()));
      }
      break;
    case HiveParser.TOK_STORAGEHANDLER:
      for (int i = 0; i < child.getChildCount(); i++) {
        ASTNode grandChild = (ASTNode) child.getChild(i);
        switch (grandChild.getToken().getType()) {
          case HiveParser.TOK_FILEFORMAT_GENERIC:
            HiveStorageHandler handler;
            try {
              handler = HiveUtils.getStorageHandler(conf, storageHandler);
            } catch (HiveException e) {
              throw new SemanticException("Failed to load storage handler:  " + e.getMessage());
            }

            String fileFormatPropertyKey = handler.getFileFormatPropertyKey();
            if (fileFormatPropertyKey != null) {
              String fileFormat = grandChild.getChild(0).getText();
              if (serdeProps.containsKey(fileFormatPropertyKey)) {
                throw new SemanticException("Provide only one of the following: STORED BY " + fileFormat +
                    " or WITH SERDEPROPERTIES('" + fileFormatPropertyKey + "'='" + fileFormat + "')");
              }

              serdeProps.put(fileFormatPropertyKey, fileFormat);
            } else {
              throw new SemanticException("STORED AS is not supported for storage handler " +
                  handler.getClass().getName());
            }
            break;
          case HiveParser.TOK_TABLEPROPERTIES:
            BaseSemanticAnalyzer.readProps((ASTNode) grandChild.getChild(0), serdeProps);
            break;
          default:
            storageHandler = processStorageHandler(grandChild);
        }
      }
      break;
    case HiveParser.TOK_FILEFORMAT_GENERIC:
      if (storageHandler != null) {
        // Under normal circumstances, we should not get here (since STORED BY and STORED AS are incompatible within the
        // same command). Only scenario we can end up here is if a default storage handler class is set in the config.
        // In this case, we opt to ignore the STORED AS clause.
        LOG.info("'STORED AS' clause will be ignored, since a default storage handler class is already set: '{}'",
            storageHandler);
        break;
      }
      ASTNode grandChild = (ASTNode)child.getChild(0);
      String name = (grandChild == null ? "" : grandChild.getText()).trim().toUpperCase();
      processStorageFormat(name);
      break;
    default:
      // token was not a storage format token
      return false;
    }
    return true;
  }
Returns true if the passed token was a storage format token
and thus was processed accordingly.
ql/src/java/org/apache/hadoop/hive/ql/parse/StorageFormat.java