Class SqlTypeNames

java.lang.Object
dev.frostlake.types.SqlTypeNames

public final class SqlTypeNames extends Object
How Snowflake SPELLS a type back: the canonical name with its parameters, never the alias a column was declared with. INT, INTEGER, BIGINT, SMALLINT and NUMBER all read NUMBER(38,0); STRING, TEXT and VARCHAR read VARCHAR(16777216); DOUBLE reads FLOAT; a bare TIME reads TIME(9) and a bare TIMESTAMP TIMESTAMP_NTZ(9). CHAR, NCHAR and NVARCHAR are all VARCHAR of their length, a bare BINARY is BINARY(8388608), and OBJECT, ARRAY, VARIANT, GEOGRAPHY, GEOMETRY, VECTOR and UUID read back as declared. Live-verified across the family.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final long
    The widest length a COLUMN's metadata prints for a string.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
     
    static String
    The canonical name a COLUMN's metadata prints, which stops a string at the width a column can declare.
    static String
    The INTERNAL name Snowflake uses for a type where it does not spell the SQL one: TEXT for the string family, FIXED for the exact numerics, REAL for the approximate ones, and the SQL name for everything else — never with parameters.
    static String
    A type as a refusal sentence spells it: the canonical name, except that a bare BINARY is always BINARY(67108864), whatever width the engine holds one at (live-verified in the CALL argument and declared-RETURNS sentences).
    static String
    A ROUTINE's type as the account spells it - in a signature, in a RETURNS clause and in a DESCRIBE row alike.
    static boolean
    Whether two types belong to the same FAMILY, which is what a policy attachment is judged on: the parameters are ignored — a VARCHAR(5) policy argument takes a VARCHAR(20) column — while the timestamp variants stay distinct from each other, and NUMBER never matches FLOAT (live-verified).

    Methods inherited from class java.lang.Object

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

    • DESCRIBED_STRING_MAXIMUM

      public static final long DESCRIBED_STRING_MAXIMUM
      The widest length a COLUMN's metadata prints for a string.
      See Also:
  • Method Details

    • columnMetadata

      public static String columnMetadata(DataType type)
      The canonical name a COLUMN's metadata prints, which stops a string at the width a column can declare. An EXPRESSION may be wider — live reports t || t over two 16MB columns as VARCHAR(33554432) and CAST(i AS VARCHAR) as VARCHAR(134217728) when selected, through a view, a derived table and a CTE alike — but DESCRIBE and SHOW COLUMNS over the same view stop at 16777216.
      Parameters:
      type - the column's declared type
      Returns:
      the canonical name, with a string's width capped
    • refusalSpelling

      public static String refusalSpelling(DataType type)
      A type as a refusal sentence spells it: the canonical name, except that a bare BINARY is always BINARY(67108864), whatever width the engine holds one at (live-verified in the CALL argument and declared-RETURNS sentences).
    • routineType

      public static String routineType(DataType type)
      A ROUTINE's type as the account spells it - in a signature, in a RETURNS clause and in a DESCRIBE row alike. It is the type AS DECLARED: a string of the column default width is spelled BARE, a sized one keeps its width, and everything else reads as canonical(dev.frostlake.types.DataType) spells it, so a bare INT reads NUMBER(38,0) (live-verified).
      Parameters:
      type - the declared type
      Returns:
      the spelling a routine surface prints
    • canonical

      public static String canonical(DataType type)
    • internalName

      public static String internalName(DataType type)
      The INTERNAL name Snowflake uses for a type where it does not spell the SQL one: TEXT for the string family, FIXED for the exact numerics, REAL for the approximate ones, and the SQL name for everything else — never with parameters. A masking policy's argument type is reported this way, and so is SHOW COLUMNS' data_type blob (live-verified).
    • sameFamily

      public static boolean sameFamily(DataType left, DataType right)
      Whether two types belong to the same FAMILY, which is what a policy attachment is judged on: the parameters are ignored — a VARCHAR(5) policy argument takes a VARCHAR(20) column — while the timestamp variants stay distinct from each other, and NUMBER never matches FLOAT (live-verified).