All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.pinot.spi.config.table.QueryConfig Maven / Gradle / Ivy

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.pinot.spi.config.table;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Preconditions;
import java.util.Map;
import javax.annotation.Nullable;
import org.apache.pinot.spi.config.BaseJsonConfig;


/**
 * The {@code QueryConfig} class contains the table-level query execution related configurations.
 */
public class QueryConfig extends BaseJsonConfig {
  // The timeout for the entire query execution in milliseconds. This value will be gathered on the broker side, and
  // passed to the servers within the broker request.
  // If the broker times out, it will stop waiting for more server responses and return the reduced server responses
  // gathered so far, and numServersResponded should be smaller than numServersQueried.
  // If the server times out, it will directly interrupt the query execution. The server response does not matter much
  // because by the time the server times out, the broker should already timed out and returned the response.
  private final Long _timeoutMs;

  // Table config override for disable Groovy broker property
  private final Boolean _disableGroovy;

  // Table config override for use approximate function property
  private final Boolean _useApproximateFunction;

  // This map configures the expressions to override in the query. In certain scenarios, users cannot control the
  // queries sent to pinot (e.g. queries are auto-generated by some other tools), then they can use this map to override
  // the expressions within the query to the desired ones (e.g. override transform function to derived column).
  private final Map _expressionOverrideMap;

  @JsonCreator
  public QueryConfig(@JsonProperty("timeoutMs") @Nullable Long timeoutMs,
      @JsonProperty("disableGroovy") @Nullable Boolean disableGroovy,
      @JsonProperty("useApproximateFunction") @Nullable Boolean useApproximateFunction,
      @JsonProperty("expressionOverrideMap") @Nullable Map expressionOverrideMap) {
    Preconditions.checkArgument(timeoutMs == null || timeoutMs > 0, "Invalid 'timeoutMs': %s", timeoutMs);
    _timeoutMs = timeoutMs;
    _disableGroovy = disableGroovy;
    _useApproximateFunction = useApproximateFunction;
    _expressionOverrideMap = expressionOverrideMap;
  }

  @Nullable
  @JsonProperty("timeoutMs")
  public Long getTimeoutMs() {
    return _timeoutMs;
  }

  @Nullable
  @JsonProperty("disableGroovy")
  public Boolean getDisableGroovy() {
    return _disableGroovy;
  }

  @Nullable
  @JsonProperty("useApproximateFunction")
  public Boolean getUseApproximateFunction() {
    return _useApproximateFunction;
  }

  @Nullable
  @JsonProperty("expressionOverrideMap")
  public Map getExpressionOverrideMap() {
    return _expressionOverrideMap;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy