public class NestedFieldVirtualColumn extends Object implements VirtualColumn
NestedDataComplexColumn or any associated
nested fields (NestedFieldDictionaryEncodedColumn) including using
their indexes.
This virtual column is used for the SQL operators JSON_VALUE (if processFromRaw is set to false) or
JSON_QUERY (if it is true), and accepts 'JSONPath' or 'jq' syntax string representations of paths, or a parsed
list of NestedPathPart in order to determine what should be selected from the column.
Type information for nested fields is completely absent in the SQL planner, so it guesses the best it can to set
expectedType from the context of how something is being used, e.g. an aggregators default type or an
explicit cast, or, if using the 'RETURNING' syntax which explicitly specifies type. This might not be the same as
if it had actual type information, but, we try to stick with whatever we chose there to do the best we can for now.
Since capabilities(ColumnInspector, String) is determined by the expectedType, the results will
be best effor cast to the expected type if the column is not natively the expected type so that this column can
fulfill the contract of the type of selector that is likely to be created to read this column.
| Modifier and Type | Class and Description |
|---|---|
static class |
NestedFieldVirtualColumn.FieldDimensionSelector |
static class |
NestedFieldVirtualColumn.RawFieldColumnSelector
Process the "raw" data to extract values with
NestedPathFinder.find(Object, List), wrapping the result in
StructuredData |
static class |
NestedFieldVirtualColumn.RawFieldLiteralColumnValueSelector
Process the "raw" data to extract non-complex values.
|
static class |
NestedFieldVirtualColumn.RawFieldVectorObjectSelector
Process the "raw" data to extract vectors of values with
NestedPathFinder.find(Object, List), wrapping the
result in StructuredData |
| Constructor and Description |
|---|
NestedFieldVirtualColumn(String columnName,
String outputName,
ColumnType expectedType,
List<NestedPathPart> parts,
Boolean processFromRaw,
String path,
Boolean useJqSyntax) |
NestedFieldVirtualColumn(String columnName,
String path,
String outputName) |
NestedFieldVirtualColumn(String columnName,
String path,
String outputName,
ColumnType expectedType) |
| 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 |
getColumnName() |
ColumnType |
getExpectedType() |
ColumnIndexSupplier |
getIndexSupplier(String columnName,
ColumnSelector selector)
Get the
ColumnIndexSupplier for the specified virtual column, with the assistance of a
ColumnSelector to allow reading things from segments. |
String |
getOutputName()
Output name of this column.
|
List<NestedPathPart> |
getPathParts() |
int |
hashCode() |
boolean |
isProcessFromRaw() |
ColumnValueSelector<?> |
makeColumnValueSelector(String columnName,
ColumnSelectorFactory factory)
Build a
ColumnValueSelector corresponding to this virtual column. |
ColumnValueSelector<?> |
makeColumnValueSelector(String columnName,
ColumnSelector columnSelector,
ReadableOffset offset)
Returns similar
ColumnValueSelector object as returned by
VirtualColumn.makeColumnValueSelector(String, ColumnSelectorFactory) except this method has full access to the
underlying column and can potentially provide a more efficient implementation. |
DimensionSelector |
makeDimensionSelector(DimensionSpec dimensionSpec,
ColumnSelectorFactory factory)
Build a selector corresponding to this virtual column.
|
DimensionSelector |
makeDimensionSelector(DimensionSpec dimensionSpec,
ColumnSelector columnSelector,
ReadableOffset offset)
Returns similar
DimensionSelector object as returned by
VirtualColumn.makeDimensionSelector(DimensionSpec, ColumnSelectorFactory) except this method has full access to the
underlying column and can potentially provide a more efficient implementation. |
SingleValueDimensionVectorSelector |
makeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec,
ColumnSelector columnSelector,
ReadableVectorOffset offset)
Returns similar
SingleValueDimensionVectorSelector object as returned by
VirtualColumn.makeSingleValueVectorDimensionSelector(DimensionSpec, ColumnSelector, ReadableVectorOffset) except this
method has full access to the underlying column and can potentially provide a more efficient implementation. |
VectorObjectSelector |
makeVectorObjectSelector(String columnName,
ColumnSelector columnSelector,
ReadableVectorOffset offset)
Returns similar
VectorObjectSelector object as returned by
VirtualColumn.makeVectorObjectSelector(String, VectorColumnSelectorFactory) except this method has full access to the
underlying column and can potentially provide a more efficient implementation. |
VectorValueSelector |
makeVectorValueSelector(String columnName,
ColumnSelector columnSelector,
ReadableVectorOffset offset)
Returns similar
VectorValueSelector object as returned by
VirtualColumn.makeVectorValueSelector(String, VectorColumnSelectorFactory) except this method has full access to the
underlying column and can potentially provide a more efficient implementation. |
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, waitmakeMultiValueVectorDimensionSelector, makeMultiValueVectorDimensionSelector, makeSingleValueVectorDimensionSelector, makeVectorObjectSelector, makeVectorValueSelectorpublic NestedFieldVirtualColumn(String columnName, String outputName, @Nullable ColumnType expectedType, @Nullable List<NestedPathPart> parts, @Nullable Boolean processFromRaw, @Nullable String path, @Nullable Boolean useJqSyntax)
public NestedFieldVirtualColumn(String columnName, String path, String outputName)
public NestedFieldVirtualColumn(String columnName, String path, String outputName, @Nullable ColumnType expectedType)
public byte[] getCacheKey()
CacheablegetCacheKey in interface Cacheablepublic String getOutputName()
VirtualColumngetOutputName in interface VirtualColumnpublic String getColumnName()
public List<NestedPathPart> getPathParts()
public ColumnType getExpectedType()
public boolean isProcessFromRaw()
public DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelectorFactory factory)
VirtualColumnDimensionSpec.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 VirtualColumnpublic ColumnValueSelector<?> makeColumnValueSelector(String columnName, ColumnSelectorFactory factory)
VirtualColumnColumnValueSelector 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@Nullable public DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec, ColumnSelector columnSelector, ReadableOffset offset)
VirtualColumnDimensionSelector object as returned by
VirtualColumn.makeDimensionSelector(DimensionSpec, ColumnSelectorFactory) except this method has full access to the
underlying column and can potentially provide a more efficient implementation.
Users of this interface must ensure to first call this method whenever possible. Typically this can not be called
in query paths on top of IncrementalIndex which doesn't have columns as in persisted segments.makeDimensionSelector in interface VirtualColumn@Nullable public ColumnValueSelector<?> makeColumnValueSelector(String columnName, ColumnSelector columnSelector, ReadableOffset offset)
VirtualColumnColumnValueSelector object as returned by
VirtualColumn.makeColumnValueSelector(String, ColumnSelectorFactory) except this method has full access to the
underlying column and can potentially provide a more efficient implementation.
Users of this interface must ensure to first call this method whenever possible. Typically this can not be called
in query paths on top of IncrementalIndex which doesn't have columns as in persisted segments.makeColumnValueSelector in interface VirtualColumnpublic boolean canVectorize(ColumnInspector inspector)
canVectorize in interface VirtualColumn@Nullable public SingleValueDimensionVectorSelector makeSingleValueVectorDimensionSelector(DimensionSpec dimensionSpec, ColumnSelector columnSelector, ReadableVectorOffset offset)
VirtualColumnSingleValueDimensionVectorSelector object as returned by
VirtualColumn.makeSingleValueVectorDimensionSelector(DimensionSpec, ColumnSelector, ReadableVectorOffset) except this
method has full access to the underlying column and can potentially provide a more efficient implementation.
Users of this interface must ensure to first call this method whenever possible.makeSingleValueVectorDimensionSelector in interface VirtualColumn@Nullable public VectorObjectSelector makeVectorObjectSelector(String columnName, ColumnSelector columnSelector, ReadableVectorOffset offset)
VirtualColumnVectorObjectSelector object as returned by
VirtualColumn.makeVectorObjectSelector(String, VectorColumnSelectorFactory) except this method has full access to the
underlying column and can potentially provide a more efficient implementation.
Users of this interface must ensure to first call this method whenever possible.makeVectorObjectSelector in interface VirtualColumn@Nullable public VectorValueSelector makeVectorValueSelector(String columnName, ColumnSelector columnSelector, ReadableVectorOffset offset)
VirtualColumnVectorValueSelector object as returned by
VirtualColumn.makeVectorValueSelector(String, VectorColumnSelectorFactory) except this method has full access to the
underlying column and can potentially provide a more efficient implementation.
Users of this interface must ensure to first call this method whenever possible.makeVectorValueSelector in interface VirtualColumn@Nullable public ColumnIndexSupplier getIndexSupplier(String columnName, ColumnSelector selector)
VirtualColumnColumnIndexSupplier for the specified virtual column, with the assistance of a
ColumnSelector to allow reading things from segments. If the virtual column has no indexes, this method
will return null, or may also return a non-null supplier whose methods may return null values - having a supplier
is no guarantee that the column has indexes.getIndexSupplier in interface VirtualColumnpublic ColumnCapabilities capabilities(String columnName)
VirtualColumnVirtualColumn.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 VirtualColumncolumnName - the name this virtual column was referenced with@Nullable public ColumnCapabilities capabilities(ColumnInspector inspector, String columnName)
VirtualColumnColumnCapabilities 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 VirtualColumninspector - column inspector to provide additional information of other available columnscolumnName - the name this virtual column was referenced withpublic List<String> requiredColumns()
VirtualColumnrequiredColumns in interface VirtualColumnpublic boolean usesDotNotation()
VirtualColumnusesDotNotation in interface VirtualColumnCopyright © 2011–2023 The Apache Software Foundation. All rights reserved.