public class TRedshiftTableAttributes extends TParseTreeNode
| Modifier and Type | Class and Description |
|---|---|
static class |
TRedshiftTableAttributes.EAutoRefresh
Possible auto refresh options for Redshift materialized views
|
static class |
TRedshiftTableAttributes.EDistStyle
Possible distribution styles for Redshift materialized views
|
dbvendor, doubleLinkedTokenListToString, nodeActionAppend, nodeActionInsert, nodeActionRemove, nodeActionUnknown, nodeActionUpdate, nodeActionUpdateText, nodeChangeEndToken, nodeChangeStartToken| Constructor and Description |
|---|
TRedshiftTableAttributes()
Default constructor
|
TRedshiftTableAttributes(TRedshiftTableAttributes.EDistStyle distStyle)
Constructor with distribution style
|
TRedshiftTableAttributes(TRedshiftTableAttributes.EDistStyle distStyle,
TObjectName distKey)
Constructor with distribution style and key
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(TParseTreeVisitor v)
Accept a visitor
|
void |
acceptChildren(TParseTreeVisitor v)
Accept a visitor to iterate this class and sub-nodes of this class
|
ETableAttributeType |
getAttributeType()
Get the attribute type
|
TRedshiftTableAttributes.EAutoRefresh |
getAutoRefresh()
Get the auto refresh setting
|
TObjectName |
getDistKey()
Get the distribution key
|
TRedshiftTableAttributes.EDistStyle |
getDistStyle()
Get the distribution style
|
TObjectNameList |
getSortKeyColumns()
Get the sort key columns
|
void |
init(Object arg1)
Initialize a query tree node.
|
void |
init(Object arg1,
Object arg2) |
void |
setAttributeType(ETableAttributeType attributeType)
Set the attribute type
|
TRedshiftTableAttributes |
setAutoRefresh(TRedshiftTableAttributes.EAutoRefresh autoRefresh)
Set the auto refresh setting
|
TRedshiftTableAttributes |
setDistKey(TObjectName distKey)
Set the distribution key
|
TRedshiftTableAttributes |
setDistStyle(TRedshiftTableAttributes.EDistStyle distStyle)
Set the distribution style
|
String |
toSql()
Generate the SQL fragment for table_attributes
|
String |
toString()
将一个语法树节点(
TParseTreeNode)转换回它对应的原始SQL字符串。
它通过遍历一个由 startToken(起始词法单元)和 endToken(结束词法单元)界定的双向链表来实现这一功能。 |
addAllMyTokensToTokenList, addToTokenChain, appendNewNode, calculateTokenCount, doAppendNewNode, doParse, fastSetString, getAnchorNode, getColumnNo, getCommentAfterNode, getCommentBeforeNode, getCompactString, getDummyTag, getEndToken, getEvaluateDatatype, getEvalValue, getGsqlparser, getLineNo, getLocation, getMd5, getNodeStatus, getNodeType, getParentObjectName, getPlainText, getStartToken, getTokenCount, hasNext, init, init, init, init, init, init, init, init, insertAfterAToken, insertNewNodeBeforeMe, isChanged, isTokensInChain, next, refreshAllNodesTokenCount, remove, removeAllMyTokensFromTokenList, removeTokens, removeTokensBetweenNodes, removeTokensBetweenToken, replaceWithNewNode, resetIterator, setAnchorNode, setChanged, setDummyTag, setEndToken, setEndToken, setEndToken, setEndToken, setEndToken, setEndTokenDirectly, setEvaluateDatatype, setEvalValue, setGsqlparser, setIncludingComment, setLocation, setNewSubNode, setNodeStatus, setNodeType, setParent, setPlainText, setStartToken, setStartToken, setStartToken, setStartToken, setStartTokenDirectly, setString, setString2, subNodeInNode, toScript, toString2clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEachRemainingpublic TRedshiftTableAttributes()
public TRedshiftTableAttributes(TRedshiftTableAttributes.EDistStyle distStyle)
distStyle - The distribution style to usepublic TRedshiftTableAttributes(TRedshiftTableAttributes.EDistStyle distStyle, TObjectName distKey)
distStyle - The distribution style to usedistKey - The distribution key columnpublic void init(Object arg1)
TParseTreeNodeinit in class TParseTreeNodearg1 - first argumentpublic void init(Object arg1, Object arg2)
init in class TParseTreeNodepublic ETableAttributeType getAttributeType()
public void setAttributeType(ETableAttributeType attributeType)
attributeType - The type of table attributepublic TRedshiftTableAttributes.EDistStyle getDistStyle()
public TRedshiftTableAttributes setDistStyle(TRedshiftTableAttributes.EDistStyle distStyle)
distStyle - The distribution stylepublic TObjectName getDistKey()
public TRedshiftTableAttributes setDistKey(TObjectName distKey)
distKey - The column identifier to use as distribution keypublic TObjectNameList getSortKeyColumns()
public TRedshiftTableAttributes.EAutoRefresh getAutoRefresh()
public TRedshiftTableAttributes setAutoRefresh(TRedshiftTableAttributes.EAutoRefresh autoRefresh)
autoRefresh - The auto refresh setting (YES or NO)public String toSql()
public String toString()
TParseTreeNode
将一个语法树节点(TParseTreeNode)转换回它对应的原始SQL字符串。
它通过遍历一个由 startToken(起始词法单元)和 endToken(结束词法单元)界定的双向链表来实现这一功能。
这个方法的设计采用了“两遍扫描”(Two-Pass)的策略,也就是使用了两个 while 循环。
第一个循环是预处理阶段,用于清理格式;第二个循环则负责构建最终的字符串。
while 循环这个循环的主要目标是识别并“软删除”多余的换行符(newline tokens)。这种情况尤其在SQL被程序动态修改后容易出现。 这个循环本身不构建字符串,只负责分析和更新词法单元的状态。 其工作原理是:
startToken 开始,通过 getNextTokenInChain() 方法遍历到 endToken。posinlist(词法单元在原始完整列表中的位置索引)来判断链表是否“自然”。
如果不连续,意味着词法单元被插入或重排了,此时 isChainModified 标志位会被设为 true。while 循环这个循环负责从(经过第一步清理后的)词法单元流中实际地构建最终的输出字符串。 其工作原理是:
StringBuffer 之前,它会进行检查。StringBuffer 中。StringBuffer 就包含了该语法树节点的最终、重构后的SQL文本。
toString in class TParseTreeNodepublic void accept(TParseTreeVisitor v)
TParseTreeNodeaccept in interface Visitableaccept in class TParseTreeNodev - visitor is a descendant class of TParseTreeVisitorpublic void acceptChildren(TParseTreeVisitor v)
TParseTreeNodeacceptChildren in interface VisitableacceptChildren in class TParseTreeNodev - visitor is a descendant class of TParseTreeVisitor