Class EsqlDataTypeConverter

java.lang.Object
org.elasticsearch.xpack.esql.type.EsqlDataTypeConverter

public class EsqlDataTypeConverter extends Object
  • Field Details

  • Constructor Details

    • EsqlDataTypeConverter

      public EsqlDataTypeConverter()
  • Method Details

    • converterFor

      public static Converter converterFor(DataType from, DataType to)
    • foldToTemporalAmount

      public static TemporalAmount foldToTemporalAmount(FoldContext ctx, Expression field, String sourceText, DataType expectedType)
    • parseTemporalAmount

      public static TemporalAmount parseTemporalAmount(Object val, DataType expectedType)
    • maybeParseTemporalAmount

      public static TemporalAmount maybeParseTemporalAmount(String str)
    • convert

      public static Object convert(Object value, DataType dataType)
      Converts arbitrary object to the desired data type.

      Throws QlIllegalArgumentException if such conversion is not possible

    • commonType

      public static DataType commonType(DataType left, DataType right)
      Returns the type compatible with both left and right types

      If one of the types is null - returns another type If both types are numeric - returns type with the highest precision int < long < float < double

    • parseTemporalAmount

      public static TemporalAmount parseTemporalAmount(Number value, String temporalUnit, Source source) throws InvalidArgumentException, ArithmeticException, ParsingException
      Throws:
      InvalidArgumentException
      ArithmeticException
      ParsingException
    • chronoToLong

      public static long chronoToLong(long dateTime, org.apache.lucene.util.BytesRef chronoField, ZoneId zone)
    • chronoToLong

      public static long chronoToLong(long dateTime, ChronoField chronoField, ZoneId zone)
    • chronoToLongNanos

      public static long chronoToLongNanos(long dateNanos, org.apache.lucene.util.BytesRef chronoField, ZoneId zone)
      Extract the given ChronoField value from a date specified as a long number of nanoseconds since epoch
      Parameters:
      dateNanos - - long nanoseconds since epoch
      chronoField - - The field to extract
      zone - - Timezone for the given date
      Returns:
      - long representing the given ChronoField value
    • chronoToLongNanos

      public static long chronoToLongNanos(long dateNanos, ChronoField chronoField, ZoneId zone)
      Extract the given ChronoField value from a date specified as a long number of nanoseconds since epoch
      Parameters:
      dateNanos - - long nanoseconds since epoch
      chronoField - - The field to extract
      zone - - Timezone for the given date
      Returns:
      - long representing the given ChronoField value
    • stringToIP

      public static org.apache.lucene.util.BytesRef stringToIP(org.apache.lucene.util.BytesRef field)
      The following conversions are between String and other data types.
    • stringToIP

      public static org.apache.lucene.util.BytesRef stringToIP(String field)
    • ipToString

      public static String ipToString(org.apache.lucene.util.BytesRef field)
    • stringToVersion

      public static org.apache.lucene.util.BytesRef stringToVersion(org.apache.lucene.util.BytesRef field)
    • stringToVersion

      public static org.apache.lucene.util.BytesRef stringToVersion(String field)
    • versionToString

      public static String versionToString(org.apache.lucene.util.BytesRef field)
    • versionToString

      public static String versionToString(org.elasticsearch.xpack.versionfield.Version field)
    • spatialToString

      public static String spatialToString(org.apache.lucene.util.BytesRef field)
    • stringToGeo

      public static org.apache.lucene.util.BytesRef stringToGeo(String field)
    • stringToSpatial

      public static org.apache.lucene.util.BytesRef stringToSpatial(String field)
    • dateTimeToLong

      public static long dateTimeToLong(String dateTime)
    • dateTimeToLong

      public static long dateTimeToLong(String dateTime, DateFormatter formatter)
    • dateNanosToLong

      public static long dateNanosToLong(String dateNano)
    • dateNanosToLong

      public static long dateNanosToLong(String dateNano, DateFormatter formatter)
    • dateWithTypeToString

      public static String dateWithTypeToString(long dateTime, DataType type)
    • dateTimeToString

      public static String dateTimeToString(long dateTime)
    • nanoTimeToString

      public static String nanoTimeToString(long dateTime)
    • dateTimeToString

      public static String dateTimeToString(long dateTime, DateFormatter formatter)
    • nanoTimeToString

      public static String nanoTimeToString(long dateTime, DateFormatter formatter)
    • numericBooleanToString

      public static org.apache.lucene.util.BytesRef numericBooleanToString(Object field)
    • stringToBoolean

      public static boolean stringToBoolean(String field)
    • stringToInt

      public static int stringToInt(String field)
    • stringToLong

      public static long stringToLong(String field)
    • stringToDouble

      public static double stringToDouble(String field)
    • unsignedLongToString

      public static org.apache.lucene.util.BytesRef unsignedLongToString(long number)
    • stringToUnsignedLong

      public static long stringToUnsignedLong(String field)
    • stringToIntegral

      public static Number stringToIntegral(String field)
    • unsignedLongToDouble

      public static double unsignedLongToDouble(long number)
      The following conversion are between unsignedLong and other numeric data types.
    • doubleToUnsignedLong

      public static long doubleToUnsignedLong(double number)
    • unsignedLongToInt

      public static int unsignedLongToInt(long number)
    • intToUnsignedLong

      public static long intToUnsignedLong(int number)
    • unsignedLongToLong

      public static long unsignedLongToLong(long number)
    • longToUnsignedLong

      public static long longToUnsignedLong(long number, boolean allowNegative)
    • bigIntegerToUnsignedLong

      public static long bigIntegerToUnsignedLong(BigInteger field)
    • unsignedLongToBigInteger

      public static BigInteger unsignedLongToBigInteger(long number)
    • unsignedLongToBoolean

      public static boolean unsignedLongToBoolean(long number)
    • booleanToUnsignedLong

      public static long booleanToUnsignedLong(boolean number)
    • aggregateMetricDoubleBlockToString

      public static String aggregateMetricDoubleBlockToString(AggregateMetricDoubleBlock aggBlock, int index)
    • aggregateMetricDoubleLiteralToString

      public static String aggregateMetricDoubleLiteralToString(AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral aggMetric)
    • stringToAggregateMetricDoubleLiteral

      public static AggregateMetricDoubleBlockBuilder.AggregateMetricDoubleLiteral stringToAggregateMetricDoubleLiteral(String s)
    • converterFunctionFactory

      public static BiFunction<Source,Expression,AbstractConvertFunction> converterFunctionFactory(DataType toType)