Search in sources :

Example 1 with UpdateIndexNode

use of io.prestosql.sql.planner.plan.UpdateIndexNode in project hetu-core by openlookeng.

the class QueryPlanner method updateIndex.

private PlanBuilder updateIndex(PlanBuilder subPlan, Statement originalStatement) {
    if (!(originalStatement instanceof UpdateIndex)) {
        return subPlan;
    }
    // rewrite sub queries
    UpdateIndex updateIndex = (UpdateIndex) originalStatement;
    Map<String, Type> columnTypes = new HashMap<>();
    for (Field field : analysis.getRootScope().getRelationType().getAllFields()) {
        columnTypes.put(field.getOriginColumnName().get(), field.getType());
    }
    Properties indexProperties = new Properties();
    for (Property property : updateIndex.getProperties()) {
        String key = extractPropertyValue(property.getName());
        String val = extractPropertyValue(property.getValue()).toUpperCase(Locale.ENGLISH);
        indexProperties.setProperty(key, val);
    }
    return subPlan.withNewRoot(new UpdateIndexNode(idAllocator.getNextId(), ExchangeNode.gatheringExchange(idAllocator.getNextId(), ExchangeNode.Scope.REMOTE, subPlan.getRoot()), new UpdateIndexMetadata(updateIndex.getIndexName().toString(), indexProperties, session.getUser(), columnTypes)));
}
Also used : Field(io.prestosql.sql.analyzer.Field) FrameBoundType(io.prestosql.spi.sql.expression.Types.FrameBoundType) Type(io.prestosql.spi.type.Type) WindowFrameType(io.prestosql.spi.sql.expression.Types.WindowFrameType) RelationType(io.prestosql.sql.analyzer.RelationType) UpdateIndexNode(io.prestosql.sql.planner.plan.UpdateIndexNode) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) UpdateIndexMetadata(io.prestosql.spi.connector.UpdateIndexMetadata) UpdateIndex(io.prestosql.sql.tree.UpdateIndex) Properties(java.util.Properties) Property(io.prestosql.sql.tree.Property)

Aggregations

UpdateIndexMetadata (io.prestosql.spi.connector.UpdateIndexMetadata)1 FrameBoundType (io.prestosql.spi.sql.expression.Types.FrameBoundType)1 WindowFrameType (io.prestosql.spi.sql.expression.Types.WindowFrameType)1 Type (io.prestosql.spi.type.Type)1 Field (io.prestosql.sql.analyzer.Field)1 RelationType (io.prestosql.sql.analyzer.RelationType)1 UpdateIndexNode (io.prestosql.sql.planner.plan.UpdateIndexNode)1 Property (io.prestosql.sql.tree.Property)1 UpdateIndex (io.prestosql.sql.tree.UpdateIndex)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Properties (java.util.Properties)1