Package gudusoft.gsqlparser
Class TAttributeNode
Object
gudusoft.gsqlparser.compiler.TSymbol
gudusoft.gsqlparser.TAttributeNode
TAttributeNode 类似 column,但含义更广泛。用来表示 SQL 语句中 table 包含的字段(table 或许用 relation 更准确)。
这里的 table 可以是数据库的基本表,也可以是 from clause 中出现的子查询,或者是 CTE。
GSP 会把 SQL 语句中出现的每个 table 都生成对应的 TAttributeNode 列表,表示该 table 可以在 SQL 中被使用的字段。
例如:一般 table
select column1 from table1
GSP 会在 SQLEnv 中查找 table1 的定义,如果找到(column1,column2,column3), 则 table 会创建三个对应的 TAttributeNode。
用户可以通过
TTable.getAttributes() 来获取。
如果SQLEnv 中没有查找 table1 的定义,则创建一个 star column TAttributeNode, 形如 table1.*
例如:子查询
select column1 from (select c1,c2 from table1) t1
针对上例中的 t1 子查询, GSP 会创建两个 TAttributeNode,对应 t1.c1, t1.c2
针对其他类型的 table, 也做类似处理。为 SQL 中的每个 table 准备好 TAttributeNode 列表,
在接下来的分析中,SQL 语句中出现的 column 引用都应该能找到对应的来源表和 TAttributeNode
相关的属性
getName(), 字段名,不带前缀。
getTable_ref(), 该字段对应的 table,每个在 SQL 语句中出现的 table 都有对应的 TTable 对象。
getSqlColumn(), 如果在 SQLEnv 中找到该 table 的定义,这个方法返回数据库中定义的字段、
getSubLevelResultColumn(), 如果 table 类型为子查询,该方法返回子查询 select list 中的 TResultColumn 对象,为该字段的数据来源。
或者是 values() 中的 result column。-
Field Summary
Fields inherited from class gudusoft.gsqlparser.compiler.TSymbol
ctx, enclosingScope, qualifiedName -
Constructor Summary
ConstructorsConstructorDescriptionTAttributeNode(String n, TTable table) TAttributeNode(String n, TTable table, TColumnDefinition columnDef, TResultColumn resultColumn) TAttributeNode(String n, TTable table, TResultColumn attribute) TAttributeNode(String n, TTable table, TResultColumn attribute, int index) TAttributeNode(String n, TTable table, TSQLColumn columnDef) TAttributeNode(String n, TTable table, TSQLColumn columnDef, TResultColumn attribute) TAttributeNode(String n, TTable table, TSQLColumn columnDef, TResultColumn attribute, int index) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddAllNodesToList(ArrayList<TAttributeNode> nodes, ArrayList<TAttributeNode> list) voidaddAttributeRefToThisNode(TObjectName objectName) 把关联上的 column 加入到 attributeNode 中来。 另外,如果这个 attributeNode 的源来自 sub-query 中的 select list 的 star column, 那么把这个 column 加到 star column 中来,完成自顶向下的数据传递,static booleanaddNodeToList(TAttributeNode node, ArrayList<TAttributeNode> list) booleanintgetIndex()getName()inthashCode()toString()Methods inherited from class gudusoft.gsqlparser.compiler.TSymbol
getCtx, getEnclosingScope, getQualifiedName, setEnclosingScope
-
Constructor Details
-
TAttributeNode
public TAttributeNode(String n, TTable table, TColumnDefinition columnDef, TResultColumn resultColumn) -
TAttributeNode
-
TAttributeNode
-
TAttributeNode
-
TAttributeNode
-
TAttributeNode
-
TAttributeNode
public TAttributeNode(String n, TTable table, TSQLColumn columnDef, TResultColumn attribute, int index)
-
-
Method Details
-
addNodeToList
-
addAllNodesToList
public static boolean addAllNodesToList(ArrayList<TAttributeNode> nodes, ArrayList<TAttributeNode> list) -
getAccompaniedAttributeNodes
-
getStructResultColumn
-
getColumnDefinition
-
getSubLevelResultColumn
-
getSqlColumn
-
addAttributeRefToThisNode
把关联上的 column 加入到 attributeNode 中来。 另外,如果这个 attributeNode 的源来自 sub-query 中的 select list 的 star column, 那么把这个 column 加到 star column 中来,完成自顶向下的数据传递,- Parameters:
objectName-
-
getIndex
-
getName
- Overrides:
getNamein classgudusoft.gsqlparser.compiler.TSymbol
-
getLastPartOfName
-
getTable_ref
-
toString
-
equals
-
hashCode
-