Class ParseIp


public class ParseIp extends TextArgumentFunction
PARSE_IP(ip_address, type [, permissive]) — parses an IPv4/IPv6 address (optionally in CIDR addr/prefix form) into a VARIANT OBJECT, matching Snowflake. type is 'INET' or 'CIDR' (case-insensitive) and is echoed lowercased as ip_type.

For an IPv4 address the keys are, in order: family (4), host (the address without the prefix), ip_fields (a 4-element array — the 32-bit address then three zeros), ip_type, ipv4 (the address as a 32-bit integer), ipv4_range_end, ipv4_range_start (the CIDR range as 32-bit integers), netmask_prefix_length (defaulting to 32 when no prefix is given), and snowflake$type ("ip_address"). Example: PARSE_IP('192.168.242.188/24','INET') yields ipv4 3232297660 with range 3232297472..3232297727.

IPv6 support is minimal: an address containing ':' yields family 6 with host, ip_type, netmask_prefix_length (default 128), snowflake$type, and best-effort hex_ipv6 / hex_ipv6_range_start / hex_ipv6_range_end (a 32-char lowercase hex rendering of the 128-bit value / range — the exact Snowflake hex format is undocumented).

A malformed address (or bad type) raises; when permissive is 1 it instead returns an object with only an error key. NULL address yields NULL.

  • Constructor Details

    • ParseIp

      public ParseIp()
  • Method Details

    • evaluate

      public Object evaluate(List<Object> args)
      Description copied from class: BuiltInFunction
      Computes the function's result over its already-evaluated argument values. A SQL NULL argument arrives as Java null, and returning null makes the SQL result NULL.
      Specified by:
      evaluate in class BuiltInFunction
      Parameters:
      args - the argument values, in call order
      Returns:
      the function's value for these arguments, or null for SQL NULL
    • getMinArgCount

      public int getMinArgCount()
      Description copied from class: BuiltInFunction
      The fewest arguments a call to this function may pass; fewer is an argument-count error.
      Specified by:
      getMinArgCount in class BuiltInFunction
      Returns:
      the minimum accepted argument count
    • getMaxArgCount

      public int getMaxArgCount()
      Description copied from class: BuiltInFunction
      The most arguments a call to this function may pass; Integer.MAX_VALUE marks a variadic function (see BuiltInFunction.isVariadic()).
      Specified by:
      getMaxArgCount in class BuiltInFunction
      Returns:
      the maximum accepted argument count