public ASTNode toAST(Context ctx) throws LensException { String hql = toHQL(); ParseDriver pd = new ParseDriver(); ASTNode tree; try { log.info("HQL:{}", hql); tree = pd.parse(hql, ctx); } catch (ParseException e) { throw new LensException(e); } return ParseUtils.findRootNonNullToken(tree); }
public ASTNode parseQuery(String tname) throws Exception { return pd.parse(qMap.get(tname)); }
private ASTNode parse(String command) throws Exception { return ParseUtils.findRootNonNullToken(parseDriver.parse(command)); }
public OpetatorTreeDemo() { super(new GridLayout(1, 0)); DefaultMutableTreeNode top = null; try { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); System.out.println(classLoader.getResource("hive-default.xml")); System.out.println(classLoader.getResource("hive-site.xml")); HiveConf hiveConf = new HiveConf(SessionState.class); SessionState.start(new SessionState(hiveConf)); Context ctx = new Context(hiveConf); ctx.setTryCount(10); ctx.setCmd(CommondDemo.command3); ctx.setHDFSCleanup(true); ParseDriver pd = new ParseDriver(); ASTNode astTree = pd.parse(CommondDemo.command3, ctx); astTree = ParseUtils.findRootNonNullToken(astTree); SemanticAnalyzer sem = (SemanticAnalyzer) SemanticAnalyzerFactory.get(hiveConf, astTree); sem.analyze(astTree, ctx); sem.validate(); List<Operator<? extends OperatorDesc>> topOpList = new ArrayList<Operator<? extends OperatorDesc>>(sem.topOps.values()); if (topOpList.size() == 1) { top = createNodes(topOpList.get(0)); } else { top = new DefaultMutableTreeNode("root"); for (Operator<? extends OperatorDesc> op : topOpList) { top.add(createNodes(op)); } } } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Listen for when the selection changes. tree.addTreeSelectionListener(this); if (playWithLineStyle) { System.out.println("line style = " + lineStyle); tree.putClientProperty("JTree.lineStyle", lineStyle); } // Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); // Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); // Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); splitPane.setPreferredSize(new Dimension(500, 300)); // Add the split pane to this panel. add(splitPane); }