Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-162

Implement substring function

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.1.0-m1
    • None
    • None

    Description

      Implement SUBSTRING with support for byte and character (UTF-8) sequences.

      SUBSTRING ( expression , start, length )
      
      Types:

      expression: VARCHAR or VARBINARY
      start: Literal BIGINT
      length: Literal BIGINT
      Returns: Same type as the expression argument

      Arguments:

      start: position within the expression value the return value will start from
      length: number of subsequent characters or bytes to return.

      Aliases:

      SUBSTR
      BYTE_SUBSTR

      Return Value:

      Returns the specified portion of the input string.

      Notes on behavior:
      • If the start position is negative, start from abs(start) characters from the end of the buffer.
      • If no length is specified, continue to the end of the string.
      • BYTE_SUBSTR always assumes a character is 8 bits, while SUBSTR accounts for UTF-8 character sequences.
      • If the substring expression's length exceeds the value's upward bound, the
        value's length will be used.
      • If the substring is invalid (e.g. negative length), return an empty string.

      Attachments

        1. substring_function.patch
          37 kB
          Ben Becker
        2. DRILL-162-substrings.patch
          25 kB
          Ben Becker

        Activity

          People

            benjamin.becker Ben Becker
            benjamin.becker Ben Becker
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: