Class ColumnTypeJson

java.lang.Object
dev.frostlake.types.ColumnTypeJson

public final class ColumnTypeJson extends Object
SHOW COLUMNS' data_type cell. Snowflake answers a JSON DESCRIPTOR there rather than a type name, and spells the type in its internal vocabulary — TEXT, FIXED, REAL — with a key set that differs per family. Every rule below is live-measured:
  • {"type":"FIXED","precision":10,"scale":2,"nullable":true} — the whole exact-numeric family, integers included, since they are all NUMBER(38,0).
  • {"type":"TEXT","length":9,"byteLength":36,"nullable":true,"fixed":false} — a string's byte budget is four bytes per character, and CHAR is a VARCHAR here, so fixed reads false for the whole family.
  • {"type":"BINARY","length":20,"byteLength":20,"nullable":true,"fixed":true} — one byte per byte. Both binary spellings report the type BINARY and are told apart by fixed alone, which reads the SPELLING rather than the family — see BinaryType.isFixed().
  • {"type":"TIME","precision":0,"scale":3,"nullable":true} — the declared precision is reported as the SCALE for every time-of-day and timestamp type; the precision key is always zero. DATE carries neither.
  • {"type":"REAL","nullable":true} for the approximate numerics, and the same bare pair for BOOLEAN, DATE, VARIANT and the unstructured OBJECT and ARRAY.
  • {"type":"GEOGRAPHY","outputType":"OBJECT","nullable":true} — GEOMETRY and FILE take the same shape.
  • The structured types nest a descriptor of their own: OBJECT gains fields (each a fieldName/fieldType pair whose name keeps its declared case), ARRAY gains elementType, MAP gains keyType and valueType, and VECTOR gains vectorElementType and dimension. A map key and a vector element are never nullable; an array element and a map value are.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    render(DataType type, boolean nullable)
    Renders one column's descriptor.
    static String
    render(DataType type, boolean nullable, String collation)
    The same for a column declared with a collation: live adds it after every other fact — {"type":"TEXT",...,"fixed":false,"collation":"en-ci"} — and a column without one, or with the empty specification, has no such key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • render

      public static String render(DataType type, boolean nullable)
      Renders one column's descriptor.
      Parameters:
      type - the column's declared type
      nullable - whether the column accepts NULL
      Returns:
      the JSON descriptor Snowflake reports for it
    • render

      public static String render(DataType type, boolean nullable, String collation)
      The same for a column declared with a collation: live adds it after every other fact — {"type":"TEXT",...,"fixed":false,"collation":"en-ci"} — and a column without one, or with the empty specification, has no such key.
      Parameters:
      type - the column's type
      nullable - whether it takes NULL
      collation - its collation specification, or null
      Returns:
      the descriptor