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>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classScanQuery.ResultFormat
-
Field Summary
Fields Modifier and Type Field Description static StringCTX_KEY_OUTERMOSTThis context flag corresponds to whether the query is running on the "outermost" process (i.e.static intDEFAULT_BATCH_SIZE-
Fields inherited from class org.apache.druid.query.BaseQuery
QUERY_ID, SQL_QUERY_ID, SUB_QUERY_ID
-
Fields inherited from interface org.apache.druid.query.Query
DATASOURCE_METADATA, GROUP_BY, SCAN, SEARCH, SEGMENT_METADATA, SELECT, TIME_BOUNDARY, TIMESERIES, TOPN, UNION_QUERY, WINDOW_OPERATOR
-
-
Constructor Summary
Constructors Constructor Description ScanQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, VirtualColumns virtualColumns, ScanQuery.ResultFormat resultFormat, int batchSize, long scanRowsOffset, long scanRowsLimit, Order orderFromUser, List<OrderBy> orderBysFromUser, DimFilter dimFilter, List<String> columns, Map<String,Object> context, List<ColumnType> columnTypes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object o)intgetBatchSize()List<String>getColumns()List<ColumnType>getColumnTypes()DimFiltergetFilter()IntegergetMaxRowsQueuedForOrdering()IntegergetMaxSegmentPartitionsOrderedInMemory()OffsetLimitgetOffsetLimit()List<OrderBy>getOrderBys()Set<String>getRequiredColumns()Returns the set of columns that this query will need to access out of its datasource.ScanQuery.ResultFormatgetResultFormat()com.google.common.collect.Ordering<ScanResultValue>getResultOrdering()Default implementation ofQuery.getResultOrdering()that usesOrdering.natural().RowSignaturegetResultRowSignature(RowSignature.Finalization finalization)RowSignaturegetRowSignature()Returns the RowSignature.longgetScanRowsLimit()Limit for this query; behaves like SQL "LIMIT".longgetScanRowsOffset()Offset for this query; behaves like SQL "OFFSET".OrdergetTimeOrder()If this query is purely-time-ordered, returns a value of the enumOrder.StringgetType()VirtualColumnsgetVirtualColumns()booleanhasFilters()inthashCode()BooleanisLegacy()Deprecated.booleanisLimited()Returns whether this query is limited or not.StringtoString()static voidverifyOrderByForNativeExecution(ScanQuery query)Verifies that the ordering of a query is solely determined bygetTimeOrder().ScanQuerywithDataSource(DataSource dataSource)ScanQuerywithLimit(long newLimit)ScanQuerywithOffset(long newOffset)ScanQuerywithOverriddenContext(Map<String,Object> contextOverrides)ScanQuerywithQuerySegmentSpec(QuerySegmentSpec querySegmentSpec)Returns a new query, identical to this one, but with a different associatedQuerySegmentSpec.-
Methods inherited from class org.apache.druid.query.BaseQuery
checkInterrupted, computeOverriddenContext, computeOverridenContext, context, getContext, getDataSource, getDuration, getGranularity, getId, getIntervals, getQuerySegmentSpec, getQuerySegmentSpecForLookUp, getRunner, getSubQueryId, getTimezone, withId, withSqlQueryId, withSubQueryId
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.druid.query.Query
getContextBoolean, getContextHumanReadableBytes, getContextValue, getDataSourceAnalysis, getMostSpecificId, getResultRowSignature, getSingleInterval, getSqlQueryId, optimizeForSegment, withDefaultSubQueryId, withLane, withPriority
-
-
-
-
Field Detail
-
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:
- Constant Field Values
-
DEFAULT_BATCH_SIZE
public static final int DEFAULT_BATCH_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ScanQuery
public ScanQuery(DataSource dataSource, QuerySegmentSpec querySegmentSpec, VirtualColumns virtualColumns, ScanQuery.ResultFormat resultFormat, int batchSize, long scanRowsOffset, long scanRowsLimit, Order orderFromUser, List<OrderBy> orderBysFromUser, DimFilter dimFilter, List<String> columns, Map<String,Object> context, List<ColumnType> columnTypes)
-
-
Method Detail
-
verifyOrderByForNativeExecution
public static void verifyOrderByForNativeExecution(ScanQuery query)
Verifies that the ordering of a query is solely determined bygetTimeOrder(). Required to actually execute queries, becausegetOrderBys()is not yet understood by the query engines.- Throws:
IllegalStateException- if the ordering is not solely determined bygetTimeOrder()
-
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_VALUEis 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. BecauseLong.MAX_VALUEis used to signify unlimitedness, this is equivalent togetScanRowsLimit() != Long.Max_VALUE.- See Also:
getScanRowsLimit()
-
getTimeOrder
public Order getTimeOrder()
If this query is purely-time-ordered, returns a value of the enumOrder. Otherwise, returnsOrder.NONE. If the returned value isOrder.NONEit may not agree withgetOrderBys().
-
getMaxSegmentPartitionsOrderedInMemory
@Nullable public Integer getMaxSegmentPartitionsOrderedInMemory()
-
hasFilters
public boolean hasFilters()
-
getType
public String getType()
-
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:BaseQueryDefault implementation ofQuery.getResultOrdering()that usesOrdering.natural(). If your query result type T is not Comparable, you must override this method.- Specified by:
getResultOrderingin interfaceQuery<ScanResultValue>- Overrides:
getResultOrderingin classBaseQuery<ScanResultValue>
-
getRequiredColumns
@Nullable public Set<String> getRequiredColumns()
Description copied from interface:QueryReturns 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 aJoinDataSource, 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:QueryReturns a new query, identical to this one, but with a different associatedQuerySegmentSpec.This often changes the behavior of
Query.getRunner(QuerySegmentWalker), since most queries inherit that method fromBaseQuery, which implements it by callingQuerySegmentSpec.lookup(org.apache.druid.query.Query<T>, org.apache.druid.query.QuerySegmentWalker).
-
withDataSource
public ScanQuery withDataSource(DataSource dataSource)
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classBaseQuery<ScanResultValue>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classBaseQuery<ScanResultValue>
-
getResultRowSignature
public RowSignature getResultRowSignature(RowSignature.Finalization finalization)
-
getRowSignature
@Nullable public RowSignature getRowSignature()
Returns the RowSignature. IfcolumnTypesis not available it will do its best to fill in the types.
-
-