Class ScanQuery
- All Implemented Interfaces:
Query<ScanResultValue>
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThis context flag corresponds to whether the query is running on the "outermost" process (i.e.static final intFields inherited from class org.apache.druid.query.BaseQuery
QUERY_ID, SQL_QUERY_ID, SUB_QUERY_IDFields 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
ConstructorsConstructorDescriptionScanQuery(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
Modifier and TypeMethodDescriptionbooleanintReturns the set of columns that this query will need to access out of its datasource.com.google.common.collect.Ordering<ScanResultValue>Default implementation ofQuery.getResultOrdering()that usesOrdering.natural().getResultRowSignature(RowSignature.Finalization finalization) Returns the RowSignature.longLimit for this query; behaves like SQL "LIMIT".longOffset for this query; behaves like SQL "OFFSET".If this query is purely-time-ordered, returns a value of the enumOrder.getType()booleaninthashCode()isLegacy()Deprecated.booleanReturns whether this query is limited or not.toString()static voidVerifies that the ordering of a query is solely determined bygetTimeOrder().withDataSource(DataSource dataSource) withLimit(long newLimit) withOffset(long newOffset) withOverriddenContext(Map<String, Object> contextOverrides) withQuerySegmentSpec(QuerySegmentSpec querySegmentSpec) Returns a new query, identical to this one, but with a different associatedQuerySegmentSpec.Methods inherited from class org.apache.druid.query.BaseQuery
calculateDuration, checkInterrupted, computeOverriddenContext, computeOverridenContext, context, getContext, getDataSource, getDuration, getGranularity, getId, getIntervals, getQuerySegmentSpec, getRunner, getSubQueryId, getTimezone, withId, withSqlQueryId, withSubQueryIdMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.druid.query.Query
getContextBoolean, getContextHumanReadableBytes, getContextValue, getMostSpecificId, getResultRowSignature, getSingleInterval, getSqlQueryId, mayCollapseQueryDataSource, optimizeForSegment, withDefaultSubQueryId, withLane, withPriority
-
Field Details
-
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
-
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 Details
-
verifyOrderByForNativeExecution
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
-
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
-
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:
-
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(). -
getOrderBys
-
getMaxRowsQueuedForOrdering
-
getMaxSegmentPartitionsOrderedInMemory
-
hasFilters
public boolean hasFilters() -
getFilter
-
getType
-
getColumns
-
getColumnTypes
-
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
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
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
-
withLimit
-
withQuerySegmentSpec
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
-
withOverriddenContext
-
equals
- Overrides:
equalsin classBaseQuery<ScanResultValue>
-
hashCode
public int hashCode()- Overrides:
hashCodein classBaseQuery<ScanResultValue>
-
toString
-
getResultRowSignature
-
getRowSignature
Returns the RowSignature. IfcolumnTypesis not available it will do its best to fill in the types.
-