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-2067 adding support for deploy-time defined global temporary tables'
  • Loading branch information
Paul Richardson committed Mar 27, 2014
1 parent 85d951c commit b0bda66
Showing 1 changed file with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ Command createTempTable(ParseInfo info) #Create :
List<ElementSymbol> pk = null;
}
{
<CREATE> <LOCAL> <TEMPORARY> <TABLE>
<CREATE> [<LOCAL>] <TEMPORARY> <TABLE>
table = id(null)
<LPAREN>
{
Expand Down Expand Up @@ -5158,17 +5158,26 @@ example={code:sql}CREATE VIEW vw AS SELECT 1{code}
void createTable(MetadataFactory factory) :
{
boolean view = false;
boolean globalTemp = false;
String tableName = null;
Table table = null;
Token comment = null;
Command query = null;
}
{
<CREATE> (<FOREIGN> <TABLE> | [<VIRTUAL>] <VIEW> {view = true;})
<CREATE> (
(<FOREIGN> <TABLE>) |
([<VIRTUAL>] <VIEW> {view = true;}) |
(<GLOBAL> <TEMPORARY> <TABLE> { requires(versionAtLeast(Version.TEIID_8_5)); globalTemp = true; view = true;})
)

tableName = id(null)
{
table = factory.addTable(tableName);
table.setVirtual(view);
if (globalTemp) {
table.setTableType(Table.Type.TemporaryTable);
}
}
(createTableBody(table, factory) | [optionsClause(table, factory)
{
Expand All @@ -5177,7 +5186,7 @@ void createTable(MetadataFactory factory) :
])
[<AS> { comment = getToken(1).specialToken; } query = queryExpression(ParseInfo.DEFAULT_INSTANCE)
{
if (!view) {
if (!view || globalTemp) {
throw new ParseException(Messages.getString(Messages.TeiidParser.view_def, table.getName()));
}
table.setSelectTransformation((comment != null?comment.image+" ":"") + query.toString());
Expand All @@ -5198,7 +5207,7 @@ Create createForeignTempTable(ParseInfo info) :
MetadataFactory factory = getTempMetadataFactory();
}
{
<CREATE> <FOREIGN> <TEMPORARY> <TABLE>
<CREATE> [<LOCAL>] <FOREIGN> <TEMPORARY> <TABLE>
tableName = id(null)
{
table = new Table();
Expand Down Expand Up @@ -5382,7 +5391,7 @@ void createColumn(MetadataFactory factory, Table table) :
String element = null;
ParsedDataType type = null;
boolean autoIncrement = false;
Boolean notNull = false;
boolean notNull = false;
String defalt = null;
Column column = null;
List<String> columnName = new ArrayList<String>();
Expand All @@ -5394,16 +5403,27 @@ void createColumn(MetadataFactory factory, Table table) :
{
element = id(Boolean.TRUE)
(
type = parseDataType()
{
column = factory.addColumn(element, type.getType(), table);
column.setUpdatable(true);
setTypeInfo(type, column);
columnName.add(element);
}
<SERIAL>
{
requires(versionAtLeast(Version.TEIID_8_5));
type = new ParsedDataType("INTEGER");
autoIncrement = true;
notNull = true;
}
|
(
type = parseDataType()
[<NOT> <NULL> { notNull = true; }]
[<AUTO_INCREMENT> { autoIncrement = true; }]
)
{
column = factory.addColumn(element, type.getType(), table);
column.setUpdatable(true);
setTypeInfo(type, column);
columnName.add(element);
}
)
[<NOT> <NULL> { column.setNullType(Column.NullType.No_Nulls); }]
[<AUTO_INCREMENT> { autoIncrement = true; }]

((<PRIMARY> <KEY> { pk = true; }) | ([<UNIQUE> { unique = true; }] [<INDEX> { index = true; }]))
[<DEFAULT_KEYWORD> defalt = stringVal() {column.setDefaultValue(defalt);}]
[optionsClause(column, factory)
Expand All @@ -5422,7 +5442,10 @@ void createColumn(MetadataFactory factory, Table table) :
}
factory.addPrimaryKey("PK", columnName, table);
}


if (notNull) {
column.setNullType(Column.NullType.No_Nulls);
}
column.setAutoIncremented(autoIncrement);
}
}
Expand Down

0 comments on commit b0bda66

Please sign in to comment.