public final HiveParser.tableBuckets_return tableBuckets() throws RecognitionException {
		HiveParser.tableBuckets_return retval = new HiveParser.tableBuckets_return();
		retval.start = input.LT(1);

		CommonTree root_0 = null;

		Token num=null;
		Token KW_CLUSTERED543=null;
		Token KW_BY544=null;
		Token LPAREN545=null;
		Token RPAREN546=null;
		Token KW_SORTED547=null;
		Token KW_BY548=null;
		Token LPAREN549=null;
		Token RPAREN550=null;
		Token KW_INTO551=null;
		Token KW_BUCKETS552=null;
		ParserRuleReturnScope bucketCols =null;
		ParserRuleReturnScope sortCols =null;

		CommonTree num_tree=null;
		CommonTree KW_CLUSTERED543_tree=null;
		CommonTree KW_BY544_tree=null;
		CommonTree LPAREN545_tree=null;
		CommonTree RPAREN546_tree=null;
		CommonTree KW_SORTED547_tree=null;
		CommonTree KW_BY548_tree=null;
		CommonTree LPAREN549_tree=null;
		CommonTree RPAREN550_tree=null;
		CommonTree KW_INTO551_tree=null;
		CommonTree KW_BUCKETS552_tree=null;
		RewriteRuleTokenStream stream_RPAREN=new RewriteRuleTokenStream(adaptor,"token RPAREN");
		RewriteRuleTokenStream stream_KW_INTO=new RewriteRuleTokenStream(adaptor,"token KW_INTO");
		RewriteRuleTokenStream stream_Number=new RewriteRuleTokenStream(adaptor,"token Number");
		RewriteRuleTokenStream stream_KW_BUCKETS=new RewriteRuleTokenStream(adaptor,"token KW_BUCKETS");
		RewriteRuleTokenStream stream_KW_CLUSTERED=new RewriteRuleTokenStream(adaptor,"token KW_CLUSTERED");
		RewriteRuleTokenStream stream_LPAREN=new RewriteRuleTokenStream(adaptor,"token LPAREN");
		RewriteRuleTokenStream stream_KW_BY=new RewriteRuleTokenStream(adaptor,"token KW_BY");
		RewriteRuleTokenStream stream_KW_SORTED=new RewriteRuleTokenStream(adaptor,"token KW_SORTED");
		RewriteRuleSubtreeStream stream_columnNameList=new RewriteRuleSubtreeStream(adaptor,"rule columnNameList");
		RewriteRuleSubtreeStream stream_columnNameOrderList=new RewriteRuleSubtreeStream(adaptor,"rule columnNameOrderList");

		 msgs.push("table buckets specification"); 
		try {
			// HiveParser.g:1481:5: ( KW_CLUSTERED KW_BY LPAREN bucketCols= columnNameList RPAREN ( KW_SORTED KW_BY LPAREN sortCols= columnNameOrderList RPAREN )? KW_INTO num= Number KW_BUCKETS -> ^( TOK_TABLEBUCKETS $bucketCols ( $sortCols)? $num) )
			// HiveParser.g:1482:7: KW_CLUSTERED KW_BY LPAREN bucketCols= columnNameList RPAREN ( KW_SORTED KW_BY LPAREN sortCols= columnNameOrderList RPAREN )? KW_INTO num= Number KW_BUCKETS
			{
			KW_CLUSTERED543=(Token)match(input,KW_CLUSTERED,FOLLOW_KW_CLUSTERED_in_tableBuckets8479);  
			stream_KW_CLUSTERED.add(KW_CLUSTERED543);

			KW_BY544=(Token)match(input,KW_BY,FOLLOW_KW_BY_in_tableBuckets8481);  
			stream_KW_BY.add(KW_BY544);

			LPAREN545=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_tableBuckets8483);  
			stream_LPAREN.add(LPAREN545);

			pushFollow(FOLLOW_columnNameList_in_tableBuckets8487);
			bucketCols=columnNameList();
			state._fsp--;

			stream_columnNameList.add(bucketCols.getTree());
			RPAREN546=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_tableBuckets8489);  
			stream_RPAREN.add(RPAREN546);

			// HiveParser.g:1482:66: ( KW_SORTED KW_BY LPAREN sortCols= columnNameOrderList RPAREN )?
			int alt152=2;
			int LA152_0 = input.LA(1);
			if ( (LA152_0==KW_SORTED) ) {
				alt152=1;
			}
			switch (alt152) {
				case 1 :
					// HiveParser.g:1482:67: KW_SORTED KW_BY LPAREN sortCols= columnNameOrderList RPAREN
					{
					KW_SORTED547=(Token)match(input,KW_SORTED,FOLLOW_KW_SORTED_in_tableBuckets8492);  
					stream_KW_SORTED.add(KW_SORTED547);

					KW_BY548=(Token)match(input,KW_BY,FOLLOW_KW_BY_in_tableBuckets8494);  
					stream_KW_BY.add(KW_BY548);

					LPAREN549=(Token)match(input,LPAREN,FOLLOW_LPAREN_in_tableBuckets8496);  
					stream_LPAREN.add(LPAREN549);

					pushFollow(FOLLOW_columnNameOrderList_in_tableBuckets8500);
					sortCols=columnNameOrderList();
					state._fsp--;

					stream_columnNameOrderList.add(sortCols.getTree());
					RPAREN550=(Token)match(input,RPAREN,FOLLOW_RPAREN_in_tableBuckets8502);  
					stream_RPAREN.add(RPAREN550);

					}
					break;

			}

			KW_INTO551=(Token)match(input,KW_INTO,FOLLOW_KW_INTO_in_tableBuckets8506);  
			stream_KW_INTO.add(KW_INTO551);

			num=(Token)match(input,Number,FOLLOW_Number_in_tableBuckets8510);  
			stream_Number.add(num);

			KW_BUCKETS552=(Token)match(input,KW_BUCKETS,FOLLOW_KW_BUCKETS_in_tableBuckets8512);  
			stream_KW_BUCKETS.add(KW_BUCKETS552);

			// AST REWRITE
			// elements: sortCols, bucketCols, num
			// token labels: num
			// rule labels: sortCols, retval, bucketCols
			// token list labels: 
			// rule list labels: 
			// wildcard labels: 
			retval.tree = root_0;
			RewriteRuleTokenStream stream_num=new RewriteRuleTokenStream(adaptor,"token num",num);
			RewriteRuleSubtreeStream stream_sortCols=new RewriteRuleSubtreeStream(adaptor,"rule sortCols",sortCols!=null?sortCols.getTree():null);
			RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.getTree():null);
			RewriteRuleSubtreeStream stream_bucketCols=new RewriteRuleSubtreeStream(adaptor,"rule bucketCols",bucketCols!=null?bucketCols.getTree():null);

			root_0 = (CommonTree)adaptor.nil();
			// 1483:5: -> ^( TOK_TABLEBUCKETS $bucketCols ( $sortCols)? $num)
			{
				// HiveParser.g:1483:8: ^( TOK_TABLEBUCKETS $bucketCols ( $sortCols)? $num)
				{
				CommonTree root_1 = (CommonTree)adaptor.nil();
				root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(TOK_TABLEBUCKETS, "TOK_TABLEBUCKETS"), root_1);
				adaptor.addChild(root_1, stream_bucketCols.nextTree());
				// HiveParser.g:1483:40: ( $sortCols)?
				if ( stream_sortCols.hasNext() ) {
					adaptor.addChild(root_1, stream_sortCols.nextTree());
				}
				stream_sortCols.reset();

				adaptor.addChild(root_1, stream_num.nextNode());
				adaptor.addChild(root_0, root_1);
				}

			}


			retval.tree = root_0;

			}

			retval.stop = input.LT(-1);

			retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
			adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

			 msgs.pop(); 
		}

		catch (RecognitionException e) {
		 reportError(e);
		  throw e;
		}

		finally {
			// do for sure before leaving
		}
		return retval;
	}