Class ScanQuery

java.lang.Object
org.apache.druid.query.BaseQuery<ScanResultValue>
org.apache.druid.query.scan.ScanQuery
All Implemented Interfaces:
Query<ScanResultValue>

public class ScanQuery extends BaseQuery<ScanResultValue>
  • Field Details

    • CTX_KEY_OUTERMOST

      public static final String CTX_KEY_OUTERMOST
      This context flag corresponds to whether the query is running on the "outermost" process (i.e. the process the query is sent to).
      See Also:
    • DEFAULT_BATCH_SIZE

      public static final int DEFAULT_BATCH_SIZE
      See Also:
  • Constructor Details

  • Method Details

    • verifyOrderByForNativeExecution

      public static void verifyOrderByForNativeExecution(ScanQuery query)
      Verifies that the ordering of a query is solely determined by getTimeOrder(). Required to actually execute queries, because getOrderBys() is not yet understood by the query engines.
      Throws:
      IllegalStateException - if the ordering is not solely determined by getTimeOrder()
    • getVirtualColumns

      public VirtualColumns getVirtualColumns()
    • getResultFormat

      public ScanQuery.ResultFormat getResultFormat()
    • getBatchSize

      public int getBatchSize()
    • getScanRowsOffset

      public long getScanRowsOffset()
      Offset for this query; behaves like SQL "OFFSET". Zero means no offset. Negative values are invalid.
    • getScanRowsLimit

      public long getScanRowsLimit()
      Limit for this query; behaves like SQL "LIMIT". Will always be positive. Long.MAX_VALUE is used in situations where the user wants an effectively unlimited result set.
    • getOffsetLimit

      public OffsetLimit getOffsetLimit()
    • isLimited

      public boolean isLimited()
      Returns whether this query is limited or not. Because Long.MAX_VALUE is used to signify unlimitedness, this is equivalent to getScanRowsLimit() != Long.Max_VALUE.
      See Also:
    • getTimeOrder

      public Order getTimeOrder()
      If this query is purely-time-ordered, returns a value of the enum Order. Otherwise, returns Order.NONE. If the returned value is Order.NONE it may not agree with getOrderBys().
    • getOrderBys

      public List<OrderBy> getOrderBys()
    • getMaxRowsQueuedForOrdering

      @Nullable public Integer getMaxRowsQueuedForOrdering()
    • getMaxSegmentPartitionsOrderedInMemory

      @Nullable public Integer getMaxSegmentPartitionsOrderedInMemory()
    • hasFilters

      public boolean hasFilters()
    • getFilter

      @Nullable public DimFilter getFilter()
    • getType

      public String getType()
    • getColumns

      @Nullable public List<String> getColumns()
    • getColumnTypes

      @Nullable public List<ColumnType> getColumnTypes()
    • isLegacy

      @Deprecated public Boolean isLegacy()
      Deprecated.
      Prior to PR https://github.com/apache/druid/pull/16659 (Druid 31) data servers require the "legacy" parameter to be set to a non-null value. For compatibility with older data servers during rolling updates, we need to write out "false".
    • getResultOrdering

      public com.google.common.collect.Ordering<ScanResultValue> getResultOrdering()
      Description copied from class: BaseQuery
      Default implementation of Query.getResultOrdering() that uses Ordering.natural(). If your query result type T is not Comparable, you must override this method.
      Specified by:
      getResultOrdering in interface Query<ScanResultValue>
      Overrides:
      getResultOrdering in class BaseQuery<ScanResultValue>
    • getRequiredColumns

      @Nullable public Set<String> getRequiredColumns()
      Description copied from interface: Query
      Returns the set of columns that this query will need to access out of its datasource.

      This method does not "look into" what the datasource itself is doing. For example, if a query is built on a QueryDataSource, this method will not return the columns used by that subquery. As another example, if a query is built on a JoinDataSource, this method will not return the columns from the underlying datasources that are used by the join condition, unless those columns are also used by this query in other ways.

      Returns null if the set of required columns cannot be known ahead of time.

    • withOffset

      public ScanQuery withOffset(long newOffset)
    • withLimit

      public ScanQuery withLimit(long newLimit)
    • withQuerySegmentSpec

      public ScanQuery withQuerySegmentSpec(QuerySegmentSpec querySegmentSpec)
      Description copied from interface: Query
      Returns a new query, identical to this one, but with a different associated QuerySegmentSpec.

      This often changes the behavior of Query.getRunner(QuerySegmentWalker), since most queries inherit that method from BaseQuery, which implements it by calling QuerySegmentSpec.lookup(org.apache.druid.query.Query<T>, org.apache.druid.query.QuerySegmentWalker).

    • withDataSource

      public ScanQuery withDataSource(DataSource dataSource)
    • withOverriddenContext

      public ScanQuery withOverriddenContext(Map<String,Object> contextOverrides)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class BaseQuery<ScanResultValue>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BaseQuery<ScanResultValue>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getResultRowSignature

      public RowSignature getResultRowSignature(RowSignature.Finalization finalization)
    • getRowSignature

      @Nullable public RowSignature getRowSignature()
      Returns the RowSignature. If columnTypes is not available it will do its best to fill in the types.