use of org.h2.schema.Schema in project ignite by apache.
the class GridSqlQueryParser method parseCreateIndex.
/**
* Parse {@code CREATE INDEX} statement.
*
* @param createIdx {@code CREATE INDEX} statement.
* @see <a href="http://h2database.com/html/grammar.html#create_index">H2 {@code CREATE INDEX} spec.</a>
*/
private GridSqlCreateIndex parseCreateIndex(CreateIndex createIdx) {
if (CREATE_INDEX_HASH.get(createIdx) || CREATE_INDEX_PRIMARY_KEY.get(createIdx) || CREATE_INDEX_UNIQUE.get(createIdx))
throw new IgniteSQLException("Only SPATIAL modifier is supported for CREATE INDEX", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
GridSqlCreateIndex res = new GridSqlCreateIndex();
Schema schema = SCHEMA_COMMAND_SCHEMA.get(createIdx);
String tblName = CREATE_INDEX_TABLE_NAME.get(createIdx);
res.schemaName(schema.getName());
res.tableName(tblName);
res.ifNotExists(CREATE_INDEX_IF_NOT_EXISTS.get(createIdx));
QueryIndex idx = new QueryIndex();
idx.setName(CREATE_INDEX_NAME.get(createIdx));
idx.setIndexType(CREATE_INDEX_SPATIAL.get(createIdx) ? QueryIndexType.GEOSPATIAL : QueryIndexType.SORTED);
IndexColumn[] cols = CREATE_INDEX_COLUMNS.get(createIdx);
LinkedHashMap<String, Boolean> flds = new LinkedHashMap<>(cols.length);
for (IndexColumn col : CREATE_INDEX_COLUMNS.get(createIdx)) {
int sortType = INDEX_COLUMN_SORT_TYPE.get(col);
if ((sortType & SortOrder.NULLS_FIRST) != 0 || (sortType & SortOrder.NULLS_LAST) != 0)
throw new IgniteSQLException("NULLS FIRST and NULLS LAST modifiers are not supported for index columns", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
flds.put(INDEX_COLUMN_NAME.get(col), (sortType & SortOrder.DESCENDING) == 0);
}
idx.setFields(flds);
res.index(idx);
return res;
}
Aggregations