Documentation
¶
Index ¶
- Constants
- Variables
- func AreTheSame(a DataType, b DataType) bool
- func IsTextDataType(a DataType) bool
- type ArrayDataType
- type BinaryDataType
- type BooleanDataType
- type DataType
- type DateDataType
- type FloatDataType
- type GeographyDataType
- type GeometryDataType
- type NumberDataType
- type ObjectDataType
- type TableDataType
- type TableDataTypeColumn
- type TextDataType
- type TimeDataType
- type TimestampLtzDataType
- type TimestampNtzDataType
- type TimestampTzDataType
- type VariantDataType
- type VectorDataType
Constants ¶
const ( ArrayLegacyDataType = "ARRAY" BinaryLegacyDataType = "BINARY" BooleanLegacyDataType = "BOOLEAN" DateLegacyDataType = "DATE" FloatLegacyDataType = "FLOAT" GeographyLegacyDataType = "GEOGRAPHY" GeometryLegacyDataType = "GEOMETRY" NumberLegacyDataType = "NUMBER" ObjectLegacyDataType = "OBJECT" VarcharLegacyDataType = "VARCHAR" TimeLegacyDataType = "TIME" TimestampLtzLegacyDataType = "TIMESTAMP_LTZ" TimestampNtzLegacyDataType = "TIMESTAMP_NTZ" TimestampTzLegacyDataType = "TIMESTAMP_TZ" VariantLegacyDataType = "VARIANT" // TableLegacyDataType was not a value of legacy data type in the old implementation. Left for now for an easier implementation. TableLegacyDataType = "TABLE" )
const ( DefaultNumberPrecision = 38 DefaultNumberScale = 0 )
const ( DefaultVarcharLength = 16777216 DefaultCharLength = 1 )
const DefaultBinarySize = 8388608
const DefaultTimePrecision = 9
const DefaultTimestampPrecision = 9
Variables ¶
var ( NumberDataTypeSynonyms = []string{NumberLegacyDataType, "DECIMAL", "DEC", "NUMERIC"} NumberDataTypeSubTypes = []string{"INTEGER", "INT", "BIGINT", "SMALLINT", "TINYINT", "BYTEINT"} AllNumberDataTypes = append(NumberDataTypeSynonyms, NumberDataTypeSubTypes...) )
var ( TextDataTypeSynonyms = []string{VarcharLegacyDataType, "STRING", "TEXT", "NVARCHAR2", "NVARCHAR", "CHAR VARYING", "NCHAR VARYING"} TextDataTypeSubtypes = []string{"CHARACTER", "CHAR", "NCHAR"} AllTextDataTypes = append(TextDataTypeSynonyms, TextDataTypeSubtypes...) )
var ( VectorDataTypeSynonyms = []string{"VECTOR"} VectorAllowedInnerTypes = []string{"INT", "FLOAT"} )
var ArrayDataTypeSynonyms = []string{ArrayLegacyDataType}
var BinaryDataTypeSynonyms = []string{BinaryLegacyDataType, "VARBINARY"}
var BooleanDataTypeSynonyms = []string{BooleanLegacyDataType}
var DateDataTypeSynonyms = []string{DateLegacyDataType}
var FloatDataTypeSynonyms = []string{"FLOAT8", "FLOAT4", FloatLegacyDataType, "DOUBLE PRECISION", "DOUBLE", "REAL"}
var GeographyDataTypeSynonyms = []string{GeographyLegacyDataType}
var GeometryDataTypeSynonyms = []string{GeometryLegacyDataType}
var ObjectDataTypeSynonyms = []string{ObjectLegacyDataType}
var TableDataTypeSynonyms = []string{"TABLE"}
var TimeDataTypeSynonyms = []string{TimeLegacyDataType}
var TimestampLtzDataTypeSynonyms = []string{TimestampLtzLegacyDataType, "TIMESTAMPLTZ", "TIMESTAMP WITH LOCAL TIME ZONE"}
var TimestampNtzDataTypeSynonyms = []string{TimestampNtzLegacyDataType, "TIMESTAMPNTZ", "TIMESTAMP WITHOUT TIME ZONE", "DATETIME"}
var TimestampTzDataTypeSynonyms = []string{TimestampTzLegacyDataType, "TIMESTAMPTZ", "TIMESTAMP WITH TIME ZONE"}
var VariantDataTypeSynonyms = []string{VariantLegacyDataType}
Functions ¶
func AreTheSame ¶
AreTheSame compares any two data types. If both data types are nil it returns true. If only one data type is nil it returns false. It returns false for different underlying types. For the same type it performs type-specific comparison.
func IsTextDataType ¶
Types ¶
type ArrayDataType ¶
type ArrayDataType struct {
// contains filtered or unexported fields
}
ArrayDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-semistructured#array It does not have synonyms. It does not have any attributes.
func (*ArrayDataType) Canonical ¶
func (t *ArrayDataType) Canonical() string
func (*ArrayDataType) ToLegacyDataTypeSql ¶
func (t *ArrayDataType) ToLegacyDataTypeSql() string
func (*ArrayDataType) ToSql ¶
func (t *ArrayDataType) ToSql() string
type BinaryDataType ¶
type BinaryDataType struct {
// contains filtered or unexported fields
}
BinaryDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-text#data-types-for-binary-strings It does have synonyms that allow specifying size.
func (*BinaryDataType) Canonical ¶
func (t *BinaryDataType) Canonical() string
func (*BinaryDataType) ToLegacyDataTypeSql ¶
func (t *BinaryDataType) ToLegacyDataTypeSql() string
func (*BinaryDataType) ToSql ¶
func (t *BinaryDataType) ToSql() string
type BooleanDataType ¶
type BooleanDataType struct {
// contains filtered or unexported fields
}
BooleanDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-logical It does not have synonyms. It does not have any attributes.
func (*BooleanDataType) Canonical ¶
func (t *BooleanDataType) Canonical() string
func (*BooleanDataType) ToLegacyDataTypeSql ¶
func (t *BooleanDataType) ToLegacyDataTypeSql() string
func (*BooleanDataType) ToSql ¶
func (t *BooleanDataType) ToSql() string
type DataType ¶
type DataType interface { // ToSql formats data type explicitly specifying all arguments and using the given type (e.g. CHAR(29) for CHAR(29)). ToSql() string // ToLegacyDataTypeSql formats data type using its base type without any attributes (e.g. VARCHAR for CHAR(29)). ToLegacyDataTypeSql() string // Canonical formats the data type between ToSql and ToLegacyDataTypeSql: it uses base type but with arguments (e.g. VARCHAR(29) for CHAR(29)). Canonical() string }
DataType is the common interface that represents all Snowflake datatypes documented in https://docs.snowflake.com/en/sql-reference/intro-summary-data-types.
func ParseDataType ¶
ParseDataType is the entry point to get the implementation of the DataType from input raw string. TODO [SNOW-1843440]: order currently matters (e.g. HasPrefix(TIME) can match also TIMESTAMP*, make the checks more precise and order-independent)
type DateDataType ¶
type DateDataType struct {
// contains filtered or unexported fields
}
DateDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-datetime#date It does not have synonyms. It does not have any attributes.
func (*DateDataType) Canonical ¶
func (t *DateDataType) Canonical() string
func (*DateDataType) ToLegacyDataTypeSql ¶
func (t *DateDataType) ToLegacyDataTypeSql() string
func (*DateDataType) ToSql ¶
func (t *DateDataType) ToSql() string
type FloatDataType ¶
type FloatDataType struct {
// contains filtered or unexported fields
}
FloatDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-numeric#data-types-for-floating-point-numbers It does have synonyms. It does not have any attributes.
func (*FloatDataType) Canonical ¶
func (t *FloatDataType) Canonical() string
func (*FloatDataType) ToLegacyDataTypeSql ¶
func (t *FloatDataType) ToLegacyDataTypeSql() string
func (*FloatDataType) ToSql ¶
func (t *FloatDataType) ToSql() string
type GeographyDataType ¶
type GeographyDataType struct {
// contains filtered or unexported fields
}
GeographyDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-geospatial#geography-data-type It does not have synonyms. It does not have any attributes.
func (*GeographyDataType) Canonical ¶
func (t *GeographyDataType) Canonical() string
func (*GeographyDataType) ToLegacyDataTypeSql ¶
func (t *GeographyDataType) ToLegacyDataTypeSql() string
func (*GeographyDataType) ToSql ¶
func (t *GeographyDataType) ToSql() string
type GeometryDataType ¶
type GeometryDataType struct {
// contains filtered or unexported fields
}
GeometryDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-geospatial#geometry-data-type It does not have synonyms. It does not have any attributes.
func (*GeometryDataType) Canonical ¶
func (t *GeometryDataType) Canonical() string
func (*GeometryDataType) ToLegacyDataTypeSql ¶
func (t *GeometryDataType) ToLegacyDataTypeSql() string
func (*GeometryDataType) ToSql ¶
func (t *GeometryDataType) ToSql() string
type NumberDataType ¶
type NumberDataType struct {
// contains filtered or unexported fields
}
NumberDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-numeric#data-types-for-fixed-point-numbers It does have synonyms that allow specifying precision and scale; here called synonyms. It does have synonyms that does not allow specifying precision and scale; here called subtypes.
func (*NumberDataType) Canonical ¶
func (t *NumberDataType) Canonical() string
func (*NumberDataType) ToLegacyDataTypeSql ¶
func (t *NumberDataType) ToLegacyDataTypeSql() string
func (*NumberDataType) ToSql ¶
func (t *NumberDataType) ToSql() string
type ObjectDataType ¶
type ObjectDataType struct {
// contains filtered or unexported fields
}
ObjectDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-semistructured#object It does not have synonyms. It does not have any attributes.
func (*ObjectDataType) Canonical ¶
func (t *ObjectDataType) Canonical() string
func (*ObjectDataType) ToLegacyDataTypeSql ¶
func (t *ObjectDataType) ToLegacyDataTypeSql() string
func (*ObjectDataType) ToSql ¶
func (t *ObjectDataType) ToSql() string
type TableDataType ¶
type TableDataType struct {
// contains filtered or unexported fields
}
TableDataType is based on https://docs.snowflake.com/en/developer-guide/stored-procedure/stored-procedures-java#returning-tabular-data. It does not have synonyms. It consists of a list of column name + column type; may be empty.
func (*TableDataType) Canonical ¶
func (t *TableDataType) Canonical() string
func (*TableDataType) Columns ¶
func (t *TableDataType) Columns() []TableDataTypeColumn
func (*TableDataType) ToLegacyDataTypeSql ¶
func (t *TableDataType) ToLegacyDataTypeSql() string
func (*TableDataType) ToSql ¶
func (t *TableDataType) ToSql() string
type TableDataTypeColumn ¶
type TableDataTypeColumn struct {
// contains filtered or unexported fields
}
func (*TableDataTypeColumn) ColumnName ¶
func (c *TableDataTypeColumn) ColumnName() string
func (*TableDataTypeColumn) ColumnType ¶
func (c *TableDataTypeColumn) ColumnType() DataType
type TextDataType ¶
type TextDataType struct {
// contains filtered or unexported fields
}
TextDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-text#data-types-for-text-strings It does have synonyms that allow specifying length. It does have synonyms that allow specifying length but differ with the default length when length is omitted; here called subtypes.
func (*TextDataType) Canonical ¶
func (t *TextDataType) Canonical() string
func (*TextDataType) ToLegacyDataTypeSql ¶
func (t *TextDataType) ToLegacyDataTypeSql() string
func (*TextDataType) ToSql ¶
func (t *TextDataType) ToSql() string
type TimeDataType ¶
type TimeDataType struct {
// contains filtered or unexported fields
}
TimeDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-datetime#time It does not have synonyms. It does have optional precision attribute.
func (*TimeDataType) Canonical ¶
func (t *TimeDataType) Canonical() string
func (*TimeDataType) ToLegacyDataTypeSql ¶
func (t *TimeDataType) ToLegacyDataTypeSql() string
func (*TimeDataType) ToSql ¶
func (t *TimeDataType) ToSql() string
type TimestampLtzDataType ¶
type TimestampLtzDataType struct {
// contains filtered or unexported fields
}
TimestampLtzDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-datetime#timestamp-ltz-timestamp-ntz-timestamp-tz It does have synonyms. It does have optional precision attribute.
func (*TimestampLtzDataType) Canonical ¶
func (t *TimestampLtzDataType) Canonical() string
func (*TimestampLtzDataType) ToLegacyDataTypeSql ¶
func (t *TimestampLtzDataType) ToLegacyDataTypeSql() string
func (*TimestampLtzDataType) ToSql ¶
func (t *TimestampLtzDataType) ToSql() string
type TimestampNtzDataType ¶
type TimestampNtzDataType struct {
// contains filtered or unexported fields
}
TimestampNtzDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-datetime#timestamp-ltz-timestamp-ntz-timestamp-tz It does have synonyms. It does have optional precision attribute.
func (*TimestampNtzDataType) Canonical ¶
func (t *TimestampNtzDataType) Canonical() string
func (*TimestampNtzDataType) ToLegacyDataTypeSql ¶
func (t *TimestampNtzDataType) ToLegacyDataTypeSql() string
func (*TimestampNtzDataType) ToSql ¶
func (t *TimestampNtzDataType) ToSql() string
type TimestampTzDataType ¶
type TimestampTzDataType struct {
// contains filtered or unexported fields
}
TimestampTzDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-datetime#timestamp-ltz-timestamp-ntz-timestamp-tz It does have synonyms. It does have optional precision attribute.
func (*TimestampTzDataType) Canonical ¶
func (t *TimestampTzDataType) Canonical() string
func (*TimestampTzDataType) ToLegacyDataTypeSql ¶
func (t *TimestampTzDataType) ToLegacyDataTypeSql() string
func (*TimestampTzDataType) ToSql ¶
func (t *TimestampTzDataType) ToSql() string
type VariantDataType ¶
type VariantDataType struct {
// contains filtered or unexported fields
}
VariantDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-semistructured#variant It does not have synonyms. It does not have any attributes.
func (*VariantDataType) Canonical ¶
func (t *VariantDataType) Canonical() string
func (*VariantDataType) ToLegacyDataTypeSql ¶
func (t *VariantDataType) ToLegacyDataTypeSql() string
func (*VariantDataType) ToSql ¶
func (t *VariantDataType) ToSql() string
type VectorDataType ¶
type VectorDataType struct {
// contains filtered or unexported fields
}
VectorDataType is based on https://docs.snowflake.com/en/sql-reference/data-types-vector#vector It does not have synonyms. It does have type (int or float) and dimension required attributes.
func (*VectorDataType) Canonical ¶
func (t *VectorDataType) Canonical() string
func (*VectorDataType) ToLegacyDataTypeSql ¶
func (t *VectorDataType) ToLegacyDataTypeSql() string
ToLegacyDataTypeSql for vector is the only one correct because in the old implementation it was returned as DataType(dType), so a proper format.
func (*VectorDataType) ToSql ¶
func (t *VectorDataType) ToSql() string