Class FileFunctionHelper

java.lang.Object
dev.frostlake.functions.scalar.file.FileFunctionHelper

public final class FileFunctionHelper extends Object
Shared argument handling for the fourteen FL_* accessors, mirroring the family-local helper pattern of VectorFunctionHelper.

Live, an accessor VALIDATES a caller-supplied metadata object exactly as TO_FILE does — FL_GET_SIZE(OBJECT_CONSTRUCT('RELATIVE_PATH','hello.txt','SIZE',24)) fails "Invalid file metadata. Missing required fields: LAST_MODIFIED, CONTENT_TYPE, ETAG." and FL_GET_SIZE(42) fails "Unsupported cast to FILE." A VARCHAR argument never reaches here: it is rejected at COMPILE time as "Invalid argument types for function 'FL_GET_RELATIVE_PATH': (VARCHAR(14))", which the expression layer raises from its strict-argument map.

The NULL rules split the family in two, and are the least guessable thing about it. The eight plain getters propagate NULL. FL_GET_FILE_TYPE and all five FL_IS_* DO NOT: live, FL_GET_FILE_TYPE(NULL) is the string 'unknown' and FL_IS_IMAGE(NULL) is FALSE, never NULL — measured both for a literal NULL and for a NULL FILE column.

  • Method Details

    • descriptorOf

      public static tools.jackson.databind.JsonNode descriptorOf(Object value)
      The validated descriptor behind an accessor's argument.
      Parameters:
      value - the argument value
      Returns:
      the descriptor node, or null when the argument is SQL NULL
    • textField

      public static String textField(Object value, String field)
      A descriptor field as a string, NULL-propagating.
      Parameters:
      value - the accessor's argument
      field - the descriptor field name
      Returns:
      the field's text, or null when the argument or the field is absent
    • numberField

      public static BigDecimal numberField(Object value, String field)
      A descriptor's SIZE as a number, NULL-propagating.
      Parameters:
      value - the accessor's argument
      Returns:
      the size, or null
    • contentTypeOf

      public static String contentTypeOf(Object value)
      The CONTENT_TYPE the classifiers key off, WITHOUT propagating NULL — a NULL file simply has no content type, which FileContentTypes maps to unknown / FALSE.
      Parameters:
      value - the accessor's argument
      Returns:
      the content type, or null