Refine search
@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; } }
@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; } }
private void processQueryWindowClause(WindowingSpec spec, ASTNode node) throws SemanticException { ASTNode nameNode = (ASTNode) node.getChild(0); ASTNode wsNode = (ASTNode) node.getChild(1); if(spec.getWindowSpecs() != null && spec.getWindowSpecs().containsKey(nameNode.getText())){ throw new SemanticException(generateErrorMessage(nameNode, "Duplicate definition of window " + nameNode.getText() + " is not allowed")); } WindowSpec ws = processWindowSpec(wsNode); spec.addWindowSpec(nameNode.getText(), ws); }
/** * Given a ASTNode, return list of values. * * use case: * create table xyz list bucketed (col1) with skew (1,2,5) * AST Node is for (1,2,5) * @param ast * @return */ protected List<String> getSkewedValueFromASTNode(ASTNode ast) { List<String> colList = new ArrayList<String>(); int numCh = ast.getChildCount(); for (int i = 0; i < numCh; i++) { ASTNode child = (ASTNode) ast.getChild(i); colList.add(stripQuotes(child.getText()).toLowerCase()); } return colList; }
private void processQueryWindowClause(WindowingSpec spec, ASTNode node) throws SemanticException { ASTNode nameNode = (ASTNode) node.getChild(0); ASTNode wsNode = (ASTNode) node.getChild(1); if(spec.getWindowSpecs() != null && spec.getWindowSpecs().containsKey(nameNode.getText())){ throw new SemanticException(generateErrorMessage(nameNode, "Duplicate definition of window " + nameNode.getText() + " is not allowed")); } WindowSpec ws = processWindowSpec(wsNode); spec.addWindowSpec(nameNode.getText(), ws); }
/** * Given a ASTNode, return list of values. * * use case: * create table xyz list bucketed (col1) with skew (1,2,5) * AST Node is for (1,2,5) * * @param ast * @return */ private List<String> getColumnValues(ASTNode ast) { List<String> colList = new ArrayList<String>(); int numCh = ast.getChildCount(); for (int i = 0; i < numCh; i++) { ASTNode child = (ASTNode) ast.getChild(i); colList.add(stripQuotes(child.getText()).toLowerCase()); } return colList; }
/** * Given a ASTNode, return list of values. * * use case: * create table xyz list bucketed (col1) with skew (1,2,5) * AST Node is for (1,2,5) * @param ast * @return */ protected List<String> getSkewedValueFromASTNode(ASTNode ast) { List<String> colList = new ArrayList<String>(); int numCh = ast.getChildCount(); for (int i = 0; i < numCh; i++) { ASTNode child = (ASTNode) ast.getChild(i); colList.add(stripQuotes(child.getText()).toLowerCase()); } return colList; }
@Override protected PrivilegeObjectDesc parsePrivObject(ASTNode ast) throws SemanticException { ASTNode child = (ASTNode) ast.getChild(0); ASTNode gchild = (ASTNode)child.getChild(0); if (child.getType() == HiveParser.TOK_URI_TYPE) { uriPath = gchild.getText().replaceAll("'", "").replaceAll("\"", ""); } else if (child.getType() == HiveParser.TOK_SERVER_TYPE) { serverName = gchild.getText(); } return super.parsePrivObject(ast); }
/** * Given a ASTNode, return list of values. * * use case: * create table xyz list bucketed (col1) with skew (1,2,5) * AST Node is for (1,2,5) * * @param ast * @return */ private List<String> getColumnValues(ASTNode ast) { List<String> colList = new ArrayList<String>(); int numCh = ast.getChildCount(); for (int i = 0; i < numCh; i++) { ASTNode child = (ASTNode) ast.getChild(i); colList.add(stripQuotes(child.getText()).toLowerCase()); } return colList; }
private void analyzeAlterTableFileFormat(ASTNode ast, String tableName, HashMap<String, String> partSpec) throws SemanticException { StorageFormat format = new StorageFormat(conf); ASTNode child = (ASTNode) ast.getChild(0); if (!format.fillStorageFormat(child)) { throw new AssertionError("Unknown token " + child.getText()); } AlterTableDesc alterTblDesc = new AlterTableDesc(tableName, format.getInputFormat(), format.getOutputFormat(), format.getSerde(), format.getStorageHandler(), partSpec); addInputsOutputsAlterTable(tableName, partSpec, alterTblDesc); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), alterTblDesc))); }
public static String getFunctionText(ASTNode expr, boolean isFunction) { String funcText = null; if (!isFunction) { // For operator, the function name is the operator text, unless it's in // our special dictionary if (expr.getChildCount() == 1) { funcText = specialUnaryOperatorTextHashMap.get(expr.getType()); } if(funcText == null) { funcText = expr.getText(); } } else { // For TOK_FUNCTION, the function name is stored in the first child, // unless it's in our // special dictionary. assert (expr.getChildCount() >= 1); int funcType = ((ASTNode) expr.getChild(0)).getType(); if (funcText == null) { funcText = conversionFunctionTextHashMap.get(funcType); } if (funcText == null) { funcText = ((ASTNode) expr.getChild(0)).getText(); } } return BaseSemanticAnalyzer.unescapeIdentifier(funcText); }
private void analyzeAlterTableFileFormat(ASTNode ast, String tableName, HashMap<String, String> partSpec) throws SemanticException { StorageFormat format = new StorageFormat(conf); ASTNode child = (ASTNode) ast.getChild(0); if (!format.fillStorageFormat(child)) { throw new AssertionError("Unknown token " + child.getText()); } AlterTableDesc alterTblDesc = new AlterTableDesc(tableName, format.getInputFormat(), format.getOutputFormat(), format.getSerde(), format.getStorageHandler(), partSpec); addInputsOutputsAlterTable(tableName, partSpec, alterTblDesc); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), alterTblDesc), conf)); }
/** * Given an AST this method figures out if it is a value clause * e.g. VALUES(1,3..) */ private boolean isValueClause(ASTNode select) { if(select == null) { return false; } if(select.getChildCount() == 1) { ASTNode selectExpr = (ASTNode)select.getChild(0); if(selectExpr.getChildCount() == 1 ) { ASTNode selectChildExpr = (ASTNode)selectExpr.getChild(0); if(selectChildExpr.getType() == HiveParser.TOK_FUNCTION) { ASTNode inline = (ASTNode)selectChildExpr.getChild(0); ASTNode func = (ASTNode)selectChildExpr.getChild(1); if(inline.getText().equals(GenericUDTFInline.class.getAnnotation(Description.class).name()) && func.getType() == HiveParser.TOK_FUNCTION) { ASTNode arrayNode = (ASTNode)func.getChild(0); ASTNode funcNode= (ASTNode)func.getChild(1); if(arrayNode.getText().equals(GenericUDFArray.class.getAnnotation(Description.class).name() ) && funcNode.getType() == HiveParser.TOK_FUNCTION) { return true; } } } } } return false; }
/** * Get the fully qualified name in the ast. e.g. the ast of the form ^(DOT * ^(DOT a b) c) will generate a name of the form a.b.c * * @param ast * The AST from which the qualified name has to be extracted * @return String */ static public String getFullyQualifiedName(ASTNode ast) { if (ast.getChildCount() == 0) { return ast.getText(); } else if (ast.getChildCount() == 2) { return getFullyQualifiedName((ASTNode) ast.getChild(0)) + "." + getFullyQualifiedName((ASTNode) ast.getChild(1)); } else if (ast.getChildCount() == 3) { return getFullyQualifiedName((ASTNode) ast.getChild(0)) + "." + getFullyQualifiedName((ASTNode) ast.getChild(1)) + "." + getFullyQualifiedName((ASTNode) ast.getChild(2)); } else { return null; } }