schema

package
v1.1.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MySQLToAvroType = map[string]types.AvroPrimitiveType{
	"INT":       types.AvroINT,
	"INTEGER":   types.AvroINT,
	"TINYINT":   types.AvroINT,
	"SMALLINT":  types.AvroINT,
	"MEDIUMINT": types.AvroINT,
	"BOOLEAN":   types.AvroBOOLEAN,
	"BIGINT":    types.AvroLONG,

	"FLOAT":   types.AvroFLOAT,
	"DOUBLE":  types.AvroDOUBLE,
	"DECIMAL": types.AvroDOUBLE,
	"BIT":     types.AvroBYTES,

	"CHAR":    types.AvroSTRING,
	"VARCHAR": types.AvroSTRING,

	"BINARY":    types.AvroBYTES,
	"VARBINARY": types.AvroBYTES,

	"TEXT":       types.AvroSTRING,
	"TINYTEXT":   types.AvroSTRING,
	"MEDIUMTEXT": types.AvroSTRING,
	"LONGTEXT":   types.AvroSTRING,
	"JSON":       types.AvroSTRING,

	"BLOB":       types.AvroBYTES,
	"TINYBLOB":   types.AvroBYTES,
	"MEDIUMBLOB": types.AvroBYTES,
	"LONGBLOB":   types.AvroBYTES,

	"DATE":      types.AvroSTRING,
	"DATETIME":  types.AvroLONG,
	"TIMESTAMP": types.AvroLONG,
	"TIME":      types.AvroSTRING,
	"YEAR":      types.AvroINT,
	"ENUM":      types.AvroSTRING,
	"SET":       types.AvroSTRING,
}

MySQLToAvroType is the static conversion map from MySQL types to Avro types

Functions

func ConvertToAvro

func ConvertToAvro(dbl *db.Loc, tableName string, inputType string, formatType string) ([]byte, error)

ConvertToAvro converts a MySQL schema to an Avro schema

func ConvertToAvroFromSchema

func ConvertToAvroFromSchema(tblSchema *types.TableSchema, formatType string) ([]byte, error)

ConvertToAvroFromSchema converts a MySQL schema to an Avro schema

func Get

func Get(dbl *db.Loc, table string, inputType string) (*types.TableSchema, error)

Get loads structured schema for "table", from master DB, identified by dbl

func GetColumns

func GetColumns(conn *sql.DB, dbName string, tableName string) (*types.TableSchema, error)

GetColumns reads structured schema from information_schema for table from given connection

func GetRaw

func GetRaw(dbl *db.Loc, fullTable string, inputType string) (string, error)

GetRaw returns output of SHOW CREATE TABLE after the "CREATE TABLE xyz (" So called "raw" schema

func HasPrimaryKey

func HasPrimaryKey(s *types.TableSchema) bool

HasPrimaryKey checks if given table has primary key

func MutateTable

func MutateTable(sdb *sql.DB, svc string, dbName string, tableName string, alter string, ts *types.TableSchema, rawSchema *string) bool

MutateTable perform alter schema for the given table, using temporary table and return structured and raw schema

func ParseColumnInfo

func ParseColumnInfo(rows *sql.Rows, dbName, table string) (*types.TableSchema, error)

ParseColumnInfo reads parses column information into table schema

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL