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

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


      if (desc != null)
      {
        return desc;
      }

      ASTNode expr = (ASTNode) nd;
      String str = null;

      switch (expr.getToken().getType())
      {
      case Windowing2Parser.StringLiteral:
        //str = BaseSemanticAnalyzer.unescapeSQLString(expr.getText());
        // unescape not needed already done, by tree walking in WShell.parse
        str = expr.getText();
        break;
      case Windowing2Parser.STRINGLITERALSEQUENCE:
        StringBuilder sb = new StringBuilder();
        for (Node n : expr.getChildren())
        {
          //sb.append(BaseSemanticAnalyzer
          //    .unescapeSQLString(((ASTNode) n).getText()));
          // unesacpe not needed already done, by tree walking in WShell.parse
          sb.append(((ASTNode) n).getText());
        }
        str = sb.toString();
        break;
      case Windowing2Parser.CHARSETLITERAL:
        str = BaseSemanticAnalyzer.charSetString(expr.getChild(0)
            .getText(), expr.getChild(1).getText());
        break;
      default:
        // HiveParser.identifier | HiveParse.KW_IF | HiveParse.KW_LEFT |
        // HiveParse.KW_RIGHT
        str = BaseSemanticAnalyzer.unescapeIdentifier(expr.getText());
        break;
      }
      return new ExprNodeConstantDesc(TypeInfoFactory.stringTypeInfo, str);
    }
View Full Code Here


  public static void translate(QueryDef qDef) throws WindowingException
  {
    QueryTranslationInfo tInfo = qDef.getTranslationInfo();
    QuerySpec spec = qDef.getSpec();
   
    ASTNode wExpr = spec.getWhereExpr();
   
    if ( wExpr == null ) return;
   
    WhereDef whDef = new WhereDef();
    whDef.setExpression(wExpr);
View Full Code Here

  }
 
  public static ColumnDef translateWindowFnAlias(QueryDef qDef, InputInfo iInfo, int colIdx, String alias)
    throws WindowingException
  {
    ASTNode expr = TranslateUtils.buildASTNode(alias);
    return translateSelectExpr(qDef, iInfo, colIdx, alias, expr);
  }
View Full Code Here

    @SuppressWarnings("rawtypes")
    @Override
    public void visit(Object t, Object parent, int childIndex, Map labels)
    {
      ASTNode expr = (ASTNode) t;
      String text = expr.getText();
      text = BaseSemanticAnalyzer.unescapeSQLString(text);
      expr.getToken().setText(text);
    }
View Full Code Here

    @SuppressWarnings("rawtypes")
    @Override
    public void visit(Object t, Object parent, int childIndex, Map labels)
    {
      ASTNode expr = (ASTNode) t;
      ASTNode nameNode = (ASTNode) expr.getChild(0);
      if (nameNode.getText().equals(FunctionRegistry.LEAD_FUNC_NAME)
          || nameNode.getText()
              .equals(FunctionRegistry.LAG_FUNC_NAME))
      {
        throwError = true;
        errorNode = expr;
      }
View Full Code Here

    if colTabName != null && !colTabName.equals(iInfo.getAlias()))
    {
      throw new WindowingException(sprintf("Unknown Table Reference in column", cSpec));
    }
   
    ASTNode expr = TranslateUtils.buildASTNode(cSpec.getColumnName());
    ExprNodeDesc exprNode = TranslateUtils.buildExprNode(expr, iInfo.getTypeCheckCtx());
    ExprNodeEvaluator exprEval = WindowingExprNodeEvaluatorFactory.get(qDef.getTranslationInfo(), exprNode);
    ObjectInspector oi = TranslateUtils.initExprNodeEvaluator(qDef, exprNode, exprEval, iInfo);
   
    cDef.setExpression(expr);
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

    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

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.