Package dev.frostlake.types
Class SqlTypeNames
java.lang.Object
dev.frostlake.types.SqlTypeNames
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
FieldsModifier and TypeFieldDescriptionstatic final longThe widest length a COLUMN's metadata prints for a string. -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic StringcolumnMetadata(DataType type) The canonical name a COLUMN's metadata prints, which stops a string at the width a column can declare.static StringinternalName(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.static StringrefusalSpelling(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).static StringroutineType(DataType type) A ROUTINE's type as the account spells it - in a signature, in a RETURNS clause and in a DESCRIBE row alike.static booleansameFamily(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).
-
Field Details
-
DESCRIBED_STRING_MAXIMUM
public static final long DESCRIBED_STRING_MAXIMUMThe widest length a COLUMN's metadata prints for a string.- See Also:
-
-
Method Details
-
columnMetadata
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 reportst || tover two 16MB columns as VARCHAR(33554432) andCAST(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
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
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 ascanonical(dev.frostlake.types.DataType)spells it, so a bare INT readsNUMBER(38,0)(live-verified).- Parameters:
type- the declared type- Returns:
- the spelling a routine surface prints
-
canonical
-
internalName
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
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).
-