Package org.apache.hadoop.hive.ql.parse

Examples of org.apache.hadoop.hive.ql.parse.ASTNode


  private List<PrivilegeDesc> analyzePrivilegeListDef(ASTNode node)
      throws SemanticException {
    List<PrivilegeDesc> ret = new ArrayList<PrivilegeDesc>();
    for (int i = 0; i < node.getChildCount(); i++) {
      ASTNode privilegeDef = (ASTNode) node.getChild(i);
      ASTNode privilegeType = (ASTNode) privilegeDef.getChild(0);
      Privilege privObj = PrivilegeRegistry.getPrivilege(privilegeType.getType());
      if (privObj == null) {
        throw new SemanticException("undefined privilege " + privilegeType.getType());
      }
      if (!SentryHiveConstants.ALLOWED_PRIVS.contains(privObj.getPriv())) {
        String msg = SentryHiveConstants.PRIVILEGE_NOT_SUPPORTED + privObj.getPriv();
        throw new SemanticException(msg);
      }
View Full Code Here


      ctx.setTryCount(getTryCount());
      ctx.setCmd(command);
      ctx.setHDFSCleanup(true);

      ParseDriver pd = new ParseDriver();
      ASTNode tree = pd.parse(command, ctx);
      tree = ParseUtils.findRootNonNullToken(tree);

      BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(conf, tree);
      List<AbstractSemanticAnalyzerHook> saHooks =
          getHooks(HiveConf.ConfVars.SEMANTIC_ANALYZER_HOOK,
View Full Code Here

        int numCh = ast.getChildCount();

        databaseName = BaseSemanticAnalyzer.getUnescapedName((ASTNode) ast.getChild(0));

        for (int num = 1; num < numCh; num++) {
            ASTNode child = (ASTNode) ast.getChild(num);

            switch (child.getToken().getType()) {

            case HiveParser.TOK_IFNOTEXISTS:
                try {
                    List<String> dbs = db.getDatabasesByPattern(databaseName);
                    if (dbs != null && dbs.size() > 0) { // db exists
View Full Code Here

        tableName = BaseSemanticAnalyzer.getUnescapedName((ASTNode) ast
            .getChild(0));
        boolean likeTable = false;

        for (int num = 1; num < numCh; num++) {
            ASTNode child = (ASTNode) ast.getChild(num);

            switch (child.getToken().getType()) {

            case HiveParser.TOK_QUERY: // CTAS
                throw new SemanticException(
                    "Operation not supported. Create table as " +
                        "Select is not a valid operation.");

            case HiveParser.TOK_TABLEBUCKETS:
                break;

            case HiveParser.TOK_TBLSEQUENCEFILE:
                inputFormat = HCatConstants.SEQUENCEFILE_INPUT;
                outputFormat = HCatConstants.SEQUENCEFILE_OUTPUT;
                break;

            case HiveParser.TOK_TBLTEXTFILE:
                inputFormat = org.apache.hadoop.mapred.TextInputFormat.class.getName();
                outputFormat = org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat.class.getName();

                break;

            case HiveParser.TOK_LIKETABLE:
                likeTable = true;
                break;

            case HiveParser.TOK_IFNOTEXISTS:
                try {
                    List<String> tables = db.getTablesByPattern(tableName);
                    if (tables != null && tables.size() > 0) { // table
                        // exists
                        return ast;
                    }
                } catch (HiveException e) {
                    throw new SemanticException(e);
                }
                break;

            case HiveParser.TOK_TABLEPARTCOLS:
                List<FieldSchema> partCols = BaseSemanticAnalyzer
                    .getColumns((ASTNode) child.getChild(0), false);
                for (FieldSchema fs : partCols) {
                    if (!fs.getType().equalsIgnoreCase("string")) {
                        throw new SemanticException(
                            "Operation not supported. HCatalog only " +
                                "supports partition columns of type string. "
                                + "For column: "
                                + fs.getName()
                                + " Found type: " + fs.getType());
                    }
                }
                break;

            case HiveParser.TOK_STORAGEHANDLER:
                String storageHandler = BaseSemanticAnalyzer
                    .unescapeSQLString(child.getChild(0).getText());
                if (org.apache.commons.lang.StringUtils
                    .isNotEmpty(storageHandler)) {
                    return ast;
                }

                break;

            case HiveParser.TOK_TABLEFILEFORMAT:
                if (child.getChildCount() < 2) {
                    throw new SemanticException(
                        "Incomplete specification of File Format. " +
                            "You must provide InputFormat, OutputFormat.");
                }
                inputFormat = BaseSemanticAnalyzer.unescapeSQLString(child
                    .getChild(0).getText());
                outputFormat = BaseSemanticAnalyzer.unescapeSQLString(child
                    .getChild(1).getText());
                break;

            case HiveParser.TOK_TBLRCFILE:
                inputFormat = RCFileInputFormat.class.getName();
View Full Code Here

    try {
      ctx = new Context(conf);

      ParseDriver pd = new ParseDriver();
      ASTNode tree = pd.parse(command, ctx);
      tree = ParseUtils.findRootNonNullToken(tree);

      BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(conf, tree);
      // Do semantic analysis and plan generation
      sem.analyze(tree, ctx);
View Full Code Here

    try {
      ctx = new Context (conf);

      ParseDriver pd = new ParseDriver();
      ASTNode tree = pd.parse(command);

      while ((tree.getToken() == null) && (tree.getChildCount() > 0)) {
        tree = (ASTNode) tree.getChild(0);
      }

      BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(conf, tree);
      // Do semantic analysis and plan generation
      sem.analyze(tree, ctx);
View Full Code Here

    Context ctx;
    ParseContext subPCtx = null;
    try {
      ctx = new Context(conf);
      ParseDriver pd = new ParseDriver();
      ASTNode tree = pd.parse(command, ctx);
      tree = ParseUtils.findRootNonNullToken(tree);

      BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(conf, tree);
      assert(sem instanceof SemanticAnalyzer);
      doSemanticAnalysis((SemanticAnalyzer) sem, tree, ctx);
View Full Code Here

   * @throws SemanticException
   */
  private static void doSemanticAnalysis(SemanticAnalyzer sem,
      ASTNode ast, Context ctx) throws SemanticException {
    QB qb = new QB(null, null, false);
    ASTNode child = ast;
    ParseContext subPCtx = ((SemanticAnalyzer) sem).getParseContext();
    subPCtx.setContext(ctx);
    ((SemanticAnalyzer) sem).init(subPCtx);

    LOG.info("Starting Sub-query Semantic Analysis");
View Full Code Here

      ctx = new Context(conf);
      ctx.setTryCount(getTryCount());
      ctx.setCmd(command);

      ParseDriver pd = new ParseDriver();
      ASTNode tree = pd.parse(command, ctx);
      tree = ParseUtils.findRootNonNullToken(tree);

      BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(conf, tree);
      List<AbstractSemanticAnalyzerHook> saHooks = getSemanticAnalyzerHooks();
View Full Code Here

    Context ctx;
    ParseContext subPCtx = null;
    try {
      ctx = new Context(conf);
      ParseDriver pd = new ParseDriver();
      ASTNode tree = pd.parse(command, ctx);
      tree = ParseUtils.findRootNonNullToken(tree);

      BaseSemanticAnalyzer sem = SemanticAnalyzerFactory.get(conf, tree);
      assert(sem instanceof SemanticAnalyzer);
      doSemanticAnalysis((SemanticAnalyzer) sem, tree, ctx);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.parse.ASTNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.