public static QueryQueueOptions createFromEnvAndQuery(DefaultCoordinator coord) {
        if (!coord.getJobSpec().isEnableQueue() || !coord.getJobSpec().isNeedQueued()) {
            return new QueryQueueOptions(false, V2.DEFAULT);
        }

        return createFromEnv();
    }
@Test
    public void testCreateFromEnvAndQuery() throws Exception {
        Config.enable_query_queue_v2 = true;

        {
            GlobalVariable.setEnableQueryQueueSelect(false);
            DefaultCoordinator coordinator = getScheduler("SELECT /*+SET_VAR(enable_query_queue=true)*/ * FROM lineitem");
            QueryQueueOptions opts = QueryQueueOptions.createFromEnvAndQuery(coordinator);
            assertThat(opts.isEnableQueryQueueV2()).isFalse();
        }

        {
            GlobalVariable.setEnableQueryQueueSelect(true);
            DefaultCoordinator coordinator = getScheduler("SELECT /*+SET_VAR(enable_query_queue=true)*/ * FROM lineitem");
            QueryQueueOptions opts = QueryQueueOptions.createFromEnvAndQuery(coordinator);
            assertThat(opts.isEnableQueryQueueV2()).isTrue();
        }

        {
            GlobalVariable.setEnableQueryQueueSelect(true);
            DefaultCoordinator coordinator = getScheduler("SELECT /*+SET_VAR(enable_query_queue=false)*/ * FROM lineitem");
            QueryQueueOptions opts = QueryQueueOptions.createFromEnvAndQuery(coordinator);
            assertThat(opts.isEnableQueryQueueV2()).isFalse();
        }

        {
            GlobalVariable.setEnableQueryQueueSelect(true);
            DefaultCoordinator coordinator = getScheduler(
                    "SELECT /*+SET_VAR(enable_query_queue=true)*/ * FROM information_schema.columns");
            QueryQueueOptions opts = QueryQueueOptions.createFromEnvAndQuery(coordinator);
            assertThat(opts.isEnableQueryQueueV2()).isFalse();
        }
    }