Package org.apache.druid.segment.virtual
Class ExpressionVirtualColumn
java.lang.Object
org.apache.druid.segment.virtual.ExpressionVirtualColumn
- All Implemented Interfaces:
Cacheable,VirtualColumn
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.druid.segment.VirtualColumn
VirtualColumn.EquivalenceKey -
Constructor Summary
ConstructorsConstructorDescriptionExpressionVirtualColumn(String name, String expression, Expr parsedExpression, ColumnType outputType) Constructor for creating an ExpressionVirtualColumn from a pre-parsed-and-analyzed expression, where the original expression string is known.ExpressionVirtualColumn(String name, String expression, ColumnType outputType, ExprMacroTable macroTable) Constructor for deserialization.ExpressionVirtualColumn(String name, Expr parsedExpression, ColumnType outputType) Constructor for creating an ExpressionVirtualColumn from a pre-parsed expression, where the original expression string is not known. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanVectorize(ColumnInspector inspector) capabilities(String columnName) This method is deprecated in favor ofVirtualColumn.capabilities(ColumnInspector, String), which should be used whenever possible and can support virtual column implementations that need to inspect other columns as inputs.capabilities(ColumnInspector inspector, String columnName) Return theColumnCapabilitieswhich best describe the optimal selector to read from this virtual column.booleanbyte[]Get a byte array used as a cache key.Returns a key used for "equivalence" comparisons, for checking if some virtual column is equivalent to some other virtual column, regardless of the output name.getIndexSupplier(String columnName, ColumnIndexSelector columnIndexSelector) Get theColumnIndexSupplierof the specified virtual column, with the assistance of aColumnSelectorto allow reading things from segments.Output name of this column.com.google.common.base.Supplier<Expr>inthashCode()makeColumnValueSelector(String columnName, ColumnSelectorFactory factory) makeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelectorFactory columnSelectorFactory) makeGroupByVectorColumnSelector(String columnName, VectorColumnSelectorFactory factory, DeferExpressionDimensions deferExpressionDimensions) Returns a group-by selector.makeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec, VectorColumnSelectorFactory factory) makeVectorObjectSelector(String columnName, VectorColumnSelectorFactory factory) makeVectorValueSelector(String columnName, VectorColumnSelectorFactory factory) Returns a list of columns that this virtual column will access.rewriteRequiredColumns(Map<String, String> columnRewrites) Return a copy of this virtual column that is identical to this virtual column except that it operates on different columns, based on a renaming map where the key is the column to be renamed and the value is the new column.booleanReturns true if the virtual column supportsVirtualColumn.rewriteRequiredColumns(Map)toString()booleanIndicates that this virtual column can be referenced with dot notation.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.druid.segment.VirtualColumn
makeColumnValueSelector, makeColumnValueSelector, makeDimensionSelector, makeDimensionSelector, makeMultiValueVectorDimensionSelector, makeMultiValueVectorDimensionSelector, makeMultiValueVectorDimensionSelector, makeSingleValueVectorDimensionSelector, makeSingleValueVectorDimensionSelector, makeVectorObjectSelector, makeVectorObjectSelector, makeVectorValueSelector, makeVectorValueSelector, toSelectableColumn
-
Constructor Details
-
ExpressionVirtualColumn
public ExpressionVirtualColumn(String name, String expression, @Nullable ColumnType outputType, ExprMacroTable macroTable) Constructor for deserialization. -
ExpressionVirtualColumn
public ExpressionVirtualColumn(String name, String expression, Expr parsedExpression, @Nullable ColumnType outputType) Constructor for creating an ExpressionVirtualColumn from a pre-parsed-and-analyzed expression, where the original expression string is known. -
ExpressionVirtualColumn
Constructor for creating an ExpressionVirtualColumn from a pre-parsed expression, where the original expression string is not known. Instead, it is generated byExpr.stringify().
-
-
Method Details
-
getOutputName
Description copied from interface:VirtualColumnOutput name of this column.- Specified by:
getOutputNamein interfaceVirtualColumn- Returns:
- name
-
getExpression
-
getOutputType
-
getParsedExpression
-
makeDimensionSelector
public DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelectorFactory columnSelectorFactory) - Specified by:
makeDimensionSelectorin interfaceVirtualColumn
-
makeColumnValueSelector
public ColumnValueSelector<?> makeColumnValueSelector(String columnName, ColumnSelectorFactory factory) - Specified by:
makeColumnValueSelectorin interfaceVirtualColumn
-
canVectorize
- Specified by:
canVectorizein interfaceVirtualColumn
-
makeSingleValueVectorDimensionSelector
public SingleValueDimensionVectorSelector makeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec, VectorColumnSelectorFactory factory) - Specified by:
makeSingleValueVectorDimensionSelectorin interfaceVirtualColumn
-
makeVectorValueSelector
public VectorValueSelector makeVectorValueSelector(String columnName, VectorColumnSelectorFactory factory) - Specified by:
makeVectorValueSelectorin interfaceVirtualColumn
-
makeVectorObjectSelector
public VectorObjectSelector makeVectorObjectSelector(String columnName, VectorColumnSelectorFactory factory) - Specified by:
makeVectorObjectSelectorin interfaceVirtualColumn
-
makeGroupByVectorColumnSelector
@Nullable public GroupByVectorColumnSelector makeGroupByVectorColumnSelector(String columnName, VectorColumnSelectorFactory factory, DeferExpressionDimensions deferExpressionDimensions) Description copied from interface:VirtualColumnReturns a group-by selector. Allows virtual columns to control their own grouping behavior.- Specified by:
makeGroupByVectorColumnSelectorin interfaceVirtualColumn- Parameters:
columnName- column namefactory- column selector factorydeferExpressionDimensions- active value ofGroupByQueryConfig.CTX_KEY_DEFER_EXPRESSION_DIMENSIONS- Returns:
- selector, or null if this virtual column does not have a specialized one
-
getIndexSupplier
@Nullable public ColumnIndexSupplier getIndexSupplier(String columnName, ColumnIndexSelector columnIndexSelector) Description copied from interface:VirtualColumnGet theColumnIndexSupplierof the specified virtual column, with the assistance of aColumnSelectorto allow reading things from segments. Returns null if the virtual column wants to act like a missing column. ReturnsNoIndexesColumnIndexSupplier.getInstance()if the virtual column does not support indexes and wants cursor-based filtering.- Specified by:
getIndexSupplierin interfaceVirtualColumn
-
capabilities
Description copied from interface:VirtualColumnThis method is deprecated in favor ofVirtualColumn.capabilities(ColumnInspector, String), which should be used whenever possible and can support virtual column implementations that need to inspect other columns as inputs. This is a fallback implementation to return the capabilities of this virtual column, which includes a type that corresponds to the best performing base selector supertype (e. g.BaseLongColumnValueSelector) of the object, returned fromVirtualColumn.makeColumnValueSelector(String, ColumnSelectorFactory). May vary based on columnName if this column uses dot notation.- Specified by:
capabilitiesin interfaceVirtualColumn- Parameters:
columnName- the name this virtual column was referenced with- Returns:
- capabilities, must not be null
-
capabilities
Description copied from interface:VirtualColumnReturn theColumnCapabilitieswhich best describe the optimal selector to read from this virtual column.The
ColumnInspector(most likely corresponding to an underlyingColumnSelectorFactoryof a query) allows the virtual column to consider this information if necessary to compute its output type details.Examples of this include the
ExpressionVirtualColumn, which takes input from other columns and uses theColumnInspectorto infer the output type of expressions based on the types of the inputs.- Specified by:
capabilitiesin interfaceVirtualColumn- Parameters:
inspector- column inspector to provide additional information of other available columnscolumnName- the name this virtual column was referenced with- Returns:
- capabilities, or null if the column should be treated as if it doesn't exist.
-
requiredColumns
Description copied from interface:VirtualColumnReturns a list of columns that this virtual column will access. This may include the names of other virtual columns. May be empty if a virtual column doesn't access any underlying columns. Does not pass columnName because there is an assumption that the list of columns needed by a dot-notation supporting virtual column will not vary based on the columnName.- Specified by:
requiredColumnsin interfaceVirtualColumn- Returns:
- column names
-
supportsRequiredRewrite
public boolean supportsRequiredRewrite()Description copied from interface:VirtualColumnReturns true if the virtual column supportsVirtualColumn.rewriteRequiredColumns(Map)- Specified by:
supportsRequiredRewritein interfaceVirtualColumn
-
rewriteRequiredColumns
Description copied from interface:VirtualColumnReturn a copy of this virtual column that is identical to this virtual column except that it operates on different columns, based on a renaming map where the key is the column to be renamed and the value is the new column. Callers should checkVirtualColumn.supportsRequiredRewrite()first to ensure that this method is supported.- Specified by:
rewriteRequiredColumnsin interfaceVirtualColumn- Parameters:
columnRewrites- Column rewrite map- Returns:
- Copy of this virtual column that operates on new columns based on the rewrite map
-
usesDotNotation
public boolean usesDotNotation()Description copied from interface:VirtualColumnIndicates that this virtual column can be referenced with dot notation. For example, a virtual column named "foo" could be referred to as "foo.bar" with the Cursor it is registered with. In that case, init will be called with columnName "foo.bar" rather than "foo".- Specified by:
usesDotNotationin interfaceVirtualColumn- Returns:
- whether to use dot notation
-
getCacheKey
public byte[] getCacheKey()Description copied from interface:CacheableGet a byte array used as a cache key.- Specified by:
getCacheKeyin interfaceCacheable- Returns:
- bytes to be used as cache key - or null if this object should not be cached.
-
getEquivalanceKey
Description copied from interface:VirtualColumnReturns a key used for "equivalence" comparisons, for checking if some virtual column is equivalent to some other virtual column, regardless of the output name. If this method returns null, it does not participate in equivalence comparisons.- Specified by:
getEquivalanceKeyin interfaceVirtualColumn- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-