public static void addResourceOrThrow(Configuration conf, String key, Object resource) {
    getQueryState(conf)
            .orElseThrow(() -> new IllegalStateException("Query state is missing; failed to add resource for " + key))
            .addResource(key, resource);
  }
@param conf Configuration object used for getting the query state, should contain the query id
@param key The resource identifier
@param resource The resource to save into the QueryState
@return whether operation succeeded
ql/src/java/org/apache/hadoop/hive/ql/session/SessionStateUtil.java