private static void validateMigrateStmt(String sql, VoltXMLElement xmlSQL, Database db) {
        final Map<String, String> attributes = xmlSQL.attributes;
        assert attributes.size() == 1;
        final Table targetTable = db.getTables().get(attributes.get("table"));
        assert targetTable != null;
        final CatalogMap<TimeToLive> ttls = targetTable.getTimetolive();
        if (ttls.isEmpty()) {
            throw new PlanningErrorException(String.format(
                    "%s: Cannot migrate from table %s because it does not have a TTL column",
                    sql, targetTable.getTypeName()));
        } else {
            final Column ttl = ttls.iterator().next().getTtlcolumn();
            final TupleValueExpression columnExpression = new TupleValueExpression(
                    targetTable.getTypeName(), ttl.getName(), ttl.getIndex());
            if (! ExpressionUtil.collectTerminals(
                    ExpressionUtil.from(db,
                            VoltXMLElementHelper.getFirstChild(
                                    VoltXMLElementHelper.getFirstChild(xmlSQL, "condition"),
                                    "operation")))
                    .contains(columnExpression)) {
                throw new PlanningErrorException(String.format(
                        "%s: Cannot migrate from table %s because the WHERE caluse does not contain TTL column %s",
                        sql, targetTable.getTypeName(), ttl.getName()));
            }
        }
    }
private static void validateMigrateStmt ( String sql , VoltXMLElement xmlSQL , Database db ) { final Map < String , String > attributes = xmlSQL . attributes ; assert attributes . size ( ) == 1 ; final Table targetTable = db . getTables ( ) . get ( attributes . get ( "table" ) ) ; assert targetTable != null ; final CatalogMap < TimeToLive > ttls = targetTable . getTimetolive ( ) ; if ( ttls . isEmpty ( ) ) { throw new PlanningErrorException ( String . format ( "%s: Cannot migrate from table %s because it does not have a TTL column" , sql , targetTable . getTypeName ( ) ) ) ; } else { final Column ttl = ttls . iterator ( ) . next ( ) . getTtlcolumn ( ) ; final TupleValueExpression columnExpression = new TupleValueExpression ( targetTable . getTypeName ( ) , ttl . getName ( ) , ttl . getIndex ( ) ) ; if ( ! ExpressionUtil . collectTerminals ( ExpressionUtil . from ( db , VoltXMLElementHelper . getFirstChild ( VoltXMLElementHelper . getFirstChild ( xmlSQL , "condition" ) , "operation" ) ) ) . contains ( columnExpression ) ) { throw new PlanningErrorException ( String . format ( "%s: Cannot migrate from table %s because the WHERE caluse does not contain TTL column %s" , sql , targetTable . getTypeName ( ) , ttl . getName ( ) ) ) ; } } }
Check that "MIGRATE FROM tbl WHERE..." statement is valid.
@param sql SQL statement
@param xmlSQL HSQL parsed tree
@param db database catalog