Skip to content

Commit

Permalink
Teiid 8 Parser updating to support 8.5-8.7
Browse files Browse the repository at this point in the history
* commit 'TEIID-2859 adding for ordinality to texttable'
  • Loading branch information
Paul Richardson committed Mar 27, 2014
1 parent 756fd1d commit 80a22bf
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2854,31 +2854,45 @@ TextColumn textColumn(ParseInfo info) #TextColumn :
}
{
name = id(Boolean.TRUE)
datatype = parseDataType()
[
<WIDTH>
width = intVal()
[ LOOKAHEAD(2)
<NO> <TRIM>
{ jjtThis.setName(name);
}
(
(
<FOR> <ORDINALITY>
{
requires(versionAtLeast(Version.TEIID_8_7));
jjtThis.setOrdinal(true);
return jjtThis;
}
)
|
(
datatype = parseDataType()
[
<WIDTH>
width = intVal()
[ LOOKAHEAD(2)
<NO> <TRIM>
{
noTrim = true;
noTrim = true;
}
]
]
[
<SELECTOR>
selector = stringVal()
position = intVal()
]
{
jjtThis.setName(name);
jjtThis.setType(datatype.getType());
jjtThis.setWidth(width);
jjtThis.setNoTrim(noTrim);
jjtThis.setSelector(selector);
jjtThis.setPosition(position);
return jjtThis;
}
]
]
[
<SELECTOR>
selector = stringVal()
position = intVal()
]
{
jjtThis.setType(datatype.getType());
jjtThis.setWidth(width);
jjtThis.setNoTrim(noTrim);
jjtThis.setSelector(selector);
jjtThis.setPosition(position);
return jjtThis;
}
)
)
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* JavaCCOptions:MULTI=true,NODE_USES_PARSER=true,VISITOR=true,TRACK_TOKENS=false,NODE_PREFIX=,NODE_EXTENDS=,NODE_FACTORY=TeiidNodeFactory,SUPPORT_CLASS_VISIBILITY_PUBLIC=true */
package org.teiid.query.sql.lang;

import org.teiid.designer.annotation.Since;
import org.teiid.designer.query.sql.lang.ITextColumn;
import org.teiid.query.parser.LanguageVisitor;
import org.teiid.query.parser.TeiidParser;
Expand All @@ -19,6 +20,8 @@ public class TextColumn extends ProjectedColumn implements ITextColumn<LanguageV

private Integer position;

private boolean ordinal;

/**
* @param p
* @param id
Expand Down Expand Up @@ -83,6 +86,22 @@ public void setPosition(Integer position) {
this.position = position;
}

/**
* @return ordinal
*/
@Since("8.7.0")
public boolean isOrdinal() {
return ordinal;
}

/**
* @param ordinal the ordinal to set
*/
@Since("8.7.0")
public void setOrdinal(boolean ordinal) {
this.ordinal = ordinal;
}

@Override
public int hashCode() {
final int prime = 31;
Expand All @@ -91,6 +110,7 @@ public int hashCode() {
result = prime * result + ((this.position == null) ? 0 : this.position.hashCode());
result = prime * result + ((this.selector == null) ? 0 : this.selector.hashCode());
result = prime * result + ((this.width == null) ? 0 : this.width.hashCode());
result = prime * result + (this.ordinal ? 1231 : 1237);
return result;
}

Expand All @@ -110,6 +130,8 @@ public boolean equals(Object obj) {
if (this.width == null) {
if (other.width != null) return false;
} else if (!this.width.equals(other.width)) return false;
if (this.ordinal != other.ordinal)
return false;
return true;
}

Expand All @@ -134,7 +156,8 @@ public TextColumn clone() {
clone.setName(getName());
if(getType() != null)
clone.setType(getType());

clone.setOrdinal(isOrdinal());

return clone;
}

Expand Down

0 comments on commit 80a22bf

Please sign in to comment.