public class TTeradataPeriodForClause extends TParseTreeNode
Syntax:
PERIOD FOR period_name (start_column, end_column) [AS VALIDTIME | AS TRANSACTIONTIME]
The PERIOD FOR clause creates a derived column that represents a time period spanning from start_column to end_column. This derived column can be used with temporal constraints like SEQUENCED VALIDTIME PRIMARY KEY.
Example:
PERIOD FOR effective_period (eff_begin_dt, eff_end_dt) AS VALIDTIME
| Modifier and Type | Class and Description |
|---|---|
static class |
TTeradataPeriodForClause.ETemporalType
Temporal type for the PERIOD FOR clause.
|
dbvendor, doubleLinkedTokenListToString, nodeActionAppend, nodeActionInsert, nodeActionRemove, nodeActionUnknown, nodeActionUpdate, nodeActionUpdateText, nodeChangeEndToken, nodeChangeStartToken| Constructor and Description |
|---|
TTeradataPeriodForClause() |
| 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
|
TObjectName |
getEndColumnName()
Gets the end column name for the period.
|
TObjectName |
getPeriodName()
Gets the name of the derived period column.
|
TObjectName |
getStartColumnName()
Gets the start column name for the period.
|
TTeradataPeriodForClause.ETemporalType |
getTemporalType()
Gets the temporal type (VALIDTIME, TRANSACTIONTIME, or none).
|
void |
init(Object periodName,
Object startColumnName,
Object endColumnName)
Initialize with period name and column references.
|
void |
setEndColumnName(TObjectName endColumnName)
Sets the end column name for the period.
|
void |
setPeriodName(TObjectName periodName)
Sets the name of the derived period column.
|
void |
setStartColumnName(TObjectName startColumnName)
Sets the start column name for the period.
|
void |
setTemporalType(TTeradataPeriodForClause.ETemporalType temporalType)
Sets the temporal type.
|
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, 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 TTeradataPeriodForClause()
public void init(Object periodName, Object startColumnName, Object endColumnName)
init in class TParseTreeNodeperiodName - the name of the derived period columnstartColumnName - the start column of the periodendColumnName - the end column of the periodpublic TObjectName getPeriodName()
public void setPeriodName(TObjectName periodName)
periodName - the period column namepublic TObjectName getStartColumnName()
public void setStartColumnName(TObjectName startColumnName)
startColumnName - the start column referencepublic TObjectName getEndColumnName()
public void setEndColumnName(TObjectName endColumnName)
endColumnName - the end column referencepublic TTeradataPeriodForClause.ETemporalType getTemporalType()
public void setTemporalType(TTeradataPeriodForClause.ETemporalType temporalType)
temporalType - the temporal typepublic 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 TParseTreeVisitorpublic 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 TParseTreeNode