Package dev.frostlake.types
Class ColumnTypeJson
java.lang.Object
dev.frostlake.types.ColumnTypeJson
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, sofixedreads 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 byfixedalone, which reads the SPELLING rather than the family — seeBinaryType.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; theprecisionkey 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 afieldName/fieldTypepair whose name keeps its declared case), ARRAY gainselementType, MAP gainskeyTypeandvalueType, and VECTOR gainsvectorElementTypeanddimension. A map key and a vector element are never nullable; an array element and a map value are.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringRenders one column's descriptor.static StringThe 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.
-
Method Details
-
render
Renders one column's descriptor.- Parameters:
type- the column's declared typenullable- whether the column accepts NULL- Returns:
- the JSON descriptor Snowflake reports for it
-
render
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 typenullable- whether it takes NULLcollation- its collation specification, or null- Returns:
- the descriptor
-