db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From venu <VENUM...@GMAIL.COM>
Subject Using ASTParser and TreeWalker for parsing SQL query
Date Fri, 14 Jun 2013 03:34:27 GMT
Hi All,
I am new to derby and I am using derby-10.10.1.1 for parsing sql query.
I am using TreeWalker for parse SQL query as Rick mentioned in this post
(DERBY-3946)
When I use simple SQL query everything is fine. But, when I use query with
'order by' or 'group by' then TreeWalker  visit method is traversing upto
select nodes only.
ex:
SELECT FIRSTNME,TOTAL_PAY FROM EMPLOYEE ORDER BY TOTAL_PAY

Using TreeWalker :
Parsing:
select firstnme,total_pay from employee order by total_pay
    org.apache.derby.impl.sql.compile.CursorNode
        org.apache.derby.impl.sql.compile.SelectNode
            org.apache.derby.impl.sql.compile.ResultColumnList
                org.apache.derby.impl.sql.compile.ResultColumn
                    org.apache.derby.impl.sql.compile.ColumnReference
                org.apache.derby.impl.sql.compile.ResultColumn
                    org.apache.derby.impl.sql.compile.ColumnReference
            org.apache.derby.impl.sql.compile.FromList
                org.apache.derby.impl.sql.compile.FromBaseTable

When I use ASTParser  for printing the tree then I can see the node for
order by also.

Using ASTParser  :---
orderByList: 0	
	org.apache.derby.impl.sql.compile.OrderByList@f6d64c5
	allAscending: true
	alwaysSort:true
	sortNeeded: true
	columnOrdering: 
	
	[0]:	
	org.apache.derby.impl.sql.compile.OrderByColumn@56f2c96c
	nullsOrderedLow: false
	ascending; true
	addedColumnOffset: -1
	columnPosition: -1
	expression: 		
		org.apache.derby.impl.sql.compile.ColumnReference@5d85fe0c
		columnName: TOTAL_PAY
		tableNumber: -1
		columnNumber: 0
		replacesAggregate: false
		replacesWindowFunctionCall: false
		tableName: null
		nestingLevel: -1
		sourceLevel: -1
		dataTypeServices: null
	[1]:	
	org.apache.derby.impl.sql.compile.OrderByColumn@7e9f5cc
	nullsOrderedLow: false
	ascending; true
	addedColumnOffset: -1
	columnPosition: -1
	expression: 		
		org.apache.derby.impl.sql.compile.ColumnReference@11082823
		columnName: FIRSTNME
		tableNumber: -1
		columnNumber: 0
		replacesAggregate: false
		replacesWindowFunctionCall: false
		tableName: null
		nestingLevel: -1
		sourceLevel: -1
		dataTypeServices: null
---
Does anybody have any hint where I went wrong?

Thanks in advance.
Venu



--
View this message in context: http://apache-database.10148.n7.nabble.com/Using-ASTParser-and-TreeWalker-for-parsing-SQL-query-tp131219.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

Mime
View raw message