Package dev.frostlake.types
Class BinaryType
java.lang.Object
dev.frostlake.types.DataType
dev.frostlake.types.BinaryType
- All Implemented Interfaces:
Serializable
The BINARY family. Snowflake reports both spellings as the type
BINARY everywhere a type is
named — DESCRIBE, INFORMATION_SCHEMA, GET_DDL, a result column and even an argument-type refusal all
say BINARY(8) for a VARBINARY column — so the NAME here is always BINARY and the spelling
survives as isFixed(), which one metadata cell reads: SHOW COLUMNS' fixed flag.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BinaryTypeA binary sized at the 64MB maximum, held at the default width like every other.static BinaryTypestatic final intThe width a bare BINARY column declares, and the one a stored column settles a wider binary at.static final intThe 64MB maximum an unsized binary is named at in a refusal.static final BinaryTypeThe binary no width was given to: TO_BINARY's, a cast to a bare VARBINARY's, the crypto family's.static BinaryType -
Constructor Summary
ConstructorsConstructorDescriptionBinaryType(int maxLength, boolean fixed) A binary of that width with its fixedness stated outright, which is what a restored snapshot and a fold both need — neither has a spelling to read it off.BinaryType(int maxLength, boolean fixed, BinaryWidthSpelling widthSpelling) A binary held at that width whose width the plan spells aswidthSpellingsays.BinaryType(String name, int maxLength) A binary of that width, taking its fixedness from the SPELLING it was declared with. -
Method Summary
Modifier and TypeMethodDescriptionThis binary as a stored column holds it: a width pastDEFAULT_WIDTHsettles at that default, keeping its fixedness.static BinaryTypeconcatenation(long sizedWidths, boolean unsizedOperand) The binary a concatenation declares, from its operands' SIZED widths added up and whether any operand is unsized or at the maximum.formatValue(Object value) getCommonType(DataType other) intintgetSize()How this binary's width is spelled — seeBinaryWidthSpelling.booleanisCompatible(DataType other) booleanisFixed()Whether this binary is the FIXED spelling, which is the whole meaning of SHOW COLUMNS'fixedcell.parseValue(String value) piece()The binary a piece of this one declares — SUBSTR, LEFT, RIGHT: this one's own width, and the maximum where this one is unsized (live:SUBSTR(b5, 1, 1)is BINARY(5),SUBSTR(TO_BINARY(s), 1, 1)BINARY(67108864)).The type as an argument-type refusal names it: an unsized binary at the 64MB maximum.The type asSYSTEM$TYPEOFnames it: bare BINARY when unsized, else with its width.static BinaryTypeunsized(boolean fixed) The unsized binary of a cast to a bare BINARY (fixed) or VARBINARY.
-
Field Details
-
DEFAULT_WIDTH
public static final int DEFAULT_WIDTHThe width a bare BINARY column declares, and the one a stored column settles a wider binary at.- See Also:
-
NOMINAL_MAXIMUM
public static final int NOMINAL_MAXIMUMThe 64MB maximum an unsized binary is named at in a refusal.- See Also:
-
BINARY
-
VARBINARY
-
UNSIZED
The binary no width was given to: TO_BINARY's, a cast to a bare VARBINARY's, the crypto family's. -
AT_MAXIMUM
A binary sized at the 64MB maximum, held at the default width like every other.
-
-
Constructor Details
-
BinaryType
A binary of that width, taking its fixedness from the SPELLING it was declared with. Both spellings are kept as an input vocabulary — the parser, the cast targets and the derived widths all name one — while the type they build reports BINARY either way.- Parameters:
name- the spelling, BINARY or VARBINARYmaxLength- the declared width
-
BinaryType
public BinaryType(int maxLength, boolean fixed) A binary of that width with its fixedness stated outright, which is what a restored snapshot and a fold both need — neither has a spelling to read it off.- Parameters:
maxLength- the declared widthfixed- whether SHOW COLUMNS reports it fixed
-
BinaryType
A binary held at that width whose width the plan spells aswidthSpellingsays.- Parameters:
maxLength- the width the binary is held atfixed- whether SHOW COLUMNS reports it fixedwidthSpelling- how SYSTEM$TYPEOF and a refusal name its width
-
-
Method Details
-
getMaxLength
public int getMaxLength() -
getWidthSpelling
How this binary's width is spelled — seeBinaryWidthSpelling. -
typeofText
The type asSYSTEM$TYPEOFnames it: bare BINARY when unsized, else with its width. -
refusalText
The type as an argument-type refusal names it: an unsized binary at the 64MB maximum. -
piece
The binary a piece of this one declares — SUBSTR, LEFT, RIGHT: this one's own width, and the maximum where this one is unsized (live:SUBSTR(b5, 1, 1)is BINARY(5),SUBSTR(TO_BINARY(s), 1, 1)BINARY(67108864)). -
concatenation
The binary a concatenation declares, from its operands' SIZED widths added up and whether any operand is unsized or at the maximum. The widths add up to the 64MB maximum — live types two 8MB columns concatenated as BINARY(16777216) and an 8MB one beside a BINARY(5) as BINARY(8388613) — and a sum past it, or one over an unsized operand, is unsized itself: live, bothX'00' || TO_BINARY('00')andCAST(x AS BINARY(67108864)) || X'00'read bare BINARY. Only a stored column settles the width (seeatColumnWidth()). Never the fixed spelling: live reads a concatenation fixed false even over two BINARY columns.- Parameters:
sizedWidths- the sized operands' widths, added upunsizedOperand- whether any operand is unsized or at the maximum- Returns:
- the concatenation's type
-
atColumnWidth
This binary as a stored column holds it: a width pastDEFAULT_WIDTHsettles at that default, keeping its fixedness. Live stores a CTAS over a 16MB concatenation, or overCAST(x AS BINARY(67108864)), as BINARY(8388608), and declares a view's such column the same while a query over the view still reads the full width. A binary within the default is itself.- Returns:
- the binary a stored column takes
-
isFixed
public boolean isFixed()Whether this binary is the FIXED spelling, which is the whole meaning of SHOW COLUMNS'fixedcell. The flag is not "this is a BINARY" — every binary reports the type BINARY. It says the type was spelled BINARY rather than arrived at some other way (live-verified):BINARY / BINARY(4) column true VARBINARY(4) column false CAST(x AS BINARY(10)) true CAST(x AS VARBINARY(10)) false CAST(bin || bin AS BINARY) true bin || bin, CONCAT(bin, bin) false every binary-returning function an X'..' literalSo a CAST to BINARY RESETS it — being derived is not what makes it false — and no function ever produces it, TO_BINARY included, which is the pair worth remembering:
TO_BINARY(s)andCAST(s AS BINARY)convert identically and differ only in this cell.- Returns:
- true when the type was spelled BINARY
-
parseValue
- Specified by:
parseValuein classDataType
-
formatValue
- Specified by:
formatValuein classDataType
-
isCompatible
- Specified by:
isCompatiblein classDataType
-
getCommonType
- Specified by:
getCommonTypein classDataType
-
getSize
public int getSize() -
unsized
The unsized binary of a cast to a bare BINARY (fixed) or VARBINARY.
-