Interface UdfUtilities

All Known Subinterfaces:
ExchangeFragmentContext, ExecutorFragmentContext, FragmentContext, OptimizerRulesContext, RootFragmentContext
All Known Implementing Classes:
BaseFragmentContext, FragmentContextImpl, QueryContext

public interface UdfUtilities
Defines the query state and shared resources available to UDFs through injectables. For use in a function, include a Inject annotation on a UDF class member with any of the types available through this interface.
  • Field Details

    • INJECTABLE_GETTER_METHODS

      static final org.apache.drill.shaded.guava.com.google.common.collect.ImmutableMap<Class<?>,String> INJECTABLE_GETTER_METHODS
  • Method Details

    • getContextInformation

      ContextInformation getContextInformation()
      Get the context information such as: - query start time - root fragment timezone - query userName - system userName - default schema name in current session at the time of query.
      Returns:
      - ContextInformation
    • getManagedBuffer

      DrillBuf getManagedBuffer()
      For UDFs to allocate general purpose intermediate buffers we provide the DrillBuf type as an injectable, which provides access to an off-heap buffer that can be tracked by Drill and re-allocated as needed.
      Returns:
      - a buffer managed by Drill, connected to the fragment allocator for memory management
    • getPartitionExplorer

      PartitionExplorer getPartitionExplorer()
      A partition explorer allows UDFs to view the sub-partitions below a particular partition. This allows for the implementation of UDFs to query against the partition information, without having to read the actual data contained in the partition. This interface is designed for UDFs that take only constant inputs, as this interface will only be useful if we can evaluate the constant UDF at planning time. Any function defined to use this interface that is not evaluated at planning time by the constant folding rule will be querying the storage plugin for meta-data for each record processed. Be sure to check the query plans to see that this expression has already been evaluated during planning if you write UDFs against this interface. See DirectoryExplorers for example usages of this interface.
      Returns:
      - an object for exploring partitions of all available schemas
    • getDrillbitContext

      DrillbitContext getDrillbitContext()
      The Drillbit context allows UDFs to view storage information and other pieces of information about the running system. See the http_get implementation for details.
      Returns:
      - an object for accessing drillbit information such as storage configs.
    • getResultSetLoader

      ResultSetLoader getResultSetLoader()
    • getConstantValueHolder

      ValueHolder getConstantValueHolder(String value, TypeProtos.MinorType type, org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf,ValueHolder> holderInitializer)
      Works with value holders cache which holds constant value and its wrapper by type. If value is absent uses holderInitializer to create holder and adds it to cache.
      Returns:
      - a wrapper object for an constant value.