public class ExpressionVirtualColumn extends Object implements VirtualColumn
Constructor and Description |
---|
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.
|
ExpressionVirtualColumn(String name,
String expression,
ColumnType outputType,
ExprMacroTable macroTable)
Constructor for deserialization.
|
ExpressionVirtualColumn(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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canVectorize(ColumnInspector inspector) |
ColumnCapabilities |
capabilities(ColumnInspector inspector,
String columnName)
Return the
ColumnCapabilities which best describe the optimal selector to read from this virtual column. |
ColumnCapabilities |
capabilities(String columnName)
This method is deprecated in favor of
VirtualColumn.capabilities(ColumnInspector, String) , which should be used whenever
possible and can support virtual column implementations that need to inspect other columns as inputs. |
boolean |
equals(Object o) |
byte[] |
getCacheKey()
Get a byte array used as a cache key.
|
String |
getExpression() |
String |
getOutputName()
Output name of this column.
|
ColumnType |
getOutputType() |
com.google.common.base.Supplier<Expr> |
getParsedExpression() |
int |
hashCode() |
ColumnValueSelector<?> |
makeColumnValueSelector(String columnName,
ColumnSelectorFactory factory)
Build a
ColumnValueSelector corresponding to this virtual column. |
DimensionSelector |
makeDimensionSelector(DimensionSpec dimensionSpec,
ColumnSelectorFactory columnSelectorFactory)
Build a selector corresponding to this virtual column.
|
SingleValueDimensionVectorSelector |
makeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec,
VectorColumnSelectorFactory factory)
Build a
SingleValueDimensionVectorSelector corresponding to this virtual column. |
VectorObjectSelector |
makeVectorObjectSelector(String columnName,
VectorColumnSelectorFactory factory)
Build a
VectorObjectSelector corresponding to this virtual column. |
VectorValueSelector |
makeVectorValueSelector(String columnName,
VectorColumnSelectorFactory factory)
Build a
VectorValueSelector corresponding to this virtual column. |
List<String> |
requiredColumns()
Returns a list of columns that this virtual column will access.
|
String |
toString() |
boolean |
usesDotNotation()
Indicates that this virtual column can be referenced with dot notation.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getIndexSupplier, makeColumnValueSelector, makeDimensionSelector, makeMultiValueVectorDimensionSelector, makeMultiValueVectorDimensionSelector, makeSingleValueVectorDimensionSelector, makeVectorObjectSelector, makeVectorValueSelector
public ExpressionVirtualColumn(String name, String expression, @Nullable ColumnType outputType, ExprMacroTable macroTable)
public ExpressionVirtualColumn(String name, String expression, Expr parsedExpression, @Nullable ColumnType outputType)
public ExpressionVirtualColumn(String name, Expr parsedExpression, @Nullable ColumnType outputType)
getExpression()
is the toString representation of the
parsed expression, which is not necessarily a valid expression. Do not try to reparse it as an expression, as
this will not work.
If you know the original expression, use
ExpressionVirtualColumn(String, String, Expr, ColumnType)
instead.public String getOutputName()
VirtualColumn
getOutputName
in interface VirtualColumn
public String getExpression()
@Nullable public ColumnType getOutputType()
public com.google.common.base.Supplier<Expr> getParsedExpression()
public DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelectorFactory columnSelectorFactory)
VirtualColumn
DimensionSpec.getDimension()
, which
is useful if this column uses dot notation. The virtual column is expected to apply any
necessary decoration from the dimensionSpec.makeDimensionSelector
in interface VirtualColumn
public ColumnValueSelector<?> makeColumnValueSelector(String columnName, ColumnSelectorFactory factory)
VirtualColumn
ColumnValueSelector
corresponding to this virtual column. Also provides the name that the
virtual column was referenced with, which is useful if this column uses dot notation.makeColumnValueSelector
in interface VirtualColumn
public boolean canVectorize(ColumnInspector inspector)
canVectorize
in interface VirtualColumn
public SingleValueDimensionVectorSelector makeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec, VectorColumnSelectorFactory factory)
VirtualColumn
SingleValueDimensionVectorSelector
corresponding to this virtual column. Also provides the name
that the virtual column was referenced with (through DimensionSpec.getDimension()
, which is useful if this
column uses dot notation. The virtual column is expected to apply any necessary decoration from the
DimensionSpec
.makeSingleValueVectorDimensionSelector
in interface VirtualColumn
public VectorValueSelector makeVectorValueSelector(String columnName, VectorColumnSelectorFactory factory)
VirtualColumn
VectorValueSelector
corresponding to this virtual column. Also provides the name that the
virtual column was referenced with, which is useful if this column uses dot notation.makeVectorValueSelector
in interface VirtualColumn
public VectorObjectSelector makeVectorObjectSelector(String columnName, VectorColumnSelectorFactory factory)
VirtualColumn
VectorObjectSelector
corresponding to this virtual column. Also provides the name that the
virtual column was referenced with, which is useful if this column uses dot notation.makeVectorObjectSelector
in interface VirtualColumn
public ColumnCapabilities capabilities(String columnName)
VirtualColumn
VirtualColumn.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 from VirtualColumn.makeColumnValueSelector(String, ColumnSelectorFactory)
. May vary based on columnName
if this column uses dot notation.capabilities
in interface VirtualColumn
columnName
- the name this virtual column was referenced with@Nullable public ColumnCapabilities capabilities(ColumnInspector inspector, String columnName)
VirtualColumn
ColumnCapabilities
which best describe the optimal selector to read from this virtual column.
The ColumnInspector
(most likely corresponding to an underlying ColumnSelectorFactory
of 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 the
ColumnInspector
to infer the output type of expressions based on the types of the inputs.
capabilities
in interface VirtualColumn
inspector
- column inspector to provide additional information of other available columnscolumnName
- the name this virtual column was referenced withpublic List<String> requiredColumns()
VirtualColumn
requiredColumns
in interface VirtualColumn
public boolean usesDotNotation()
VirtualColumn
usesDotNotation
in interface VirtualColumn
public byte[] getCacheKey()
Cacheable
getCacheKey
in interface Cacheable
Copyright © 2011–2023 The Apache Software Foundation. All rights reserved.