QueryContext context) {
TableName fullName = convertName(defaultSchemaName, createView.getObjectName());
String schemaName = fullName.getSchemaName();
String viewName = fullName.getTableName();
View curView = ddlFunctions.getAIS(session).getView(schemaName, viewName);
if((curView != null) &&
skipOrThrow(context, createView.getExistenceCheck(), curView, new DuplicateViewException(schemaName, viewName))) {
return;
}
TypesTranslator typesTranslator = ddlFunctions.getTypesTranslator();
AISViewDefinition viewdef = binderContext.getViewDefinition(createView);
Map<TableName,Collection<String>> tableColumnReferences = viewdef.getTableColumnReferences();
AISBuilder builder = new AISBuilder();
builder.view(schemaName, viewName, viewdef.getQueryExpression(),
binderContext.getParserProperties(schemaName), tableColumnReferences);
int colpos = 0;
for (ResultColumn rc : viewdef.getResultColumns()) {
DataTypeDescriptor type = rc.getType();
if (type == null) {
if (rc.getExpression().getNodeType() != NodeTypes.UNTYPED_NULL_CONSTANT_NODE)
throw new AkibanInternalException(rc.getName() + " has unknown type");
type = new DataTypeDescriptor(TypeId.CHAR_ID, true, 0);
}
TableDDL.addColumn(builder, typesTranslator,
schemaName, viewName, rc.getName(), colpos++,
type, null, null);
}
View view = builder.akibanInformationSchema().getView(schemaName, viewName);
ddlFunctions.createView(session, view);
}