MXS-2106: Update schema generation scripts
Updated the schemas generated by the scripts. Also added a requirements.txt for installing all of the python dependencies.
This commit is contained in:
@ -46,7 +46,7 @@ The "user" and "password" flags are required.
|
|||||||
// Avro field
|
// Avro field
|
||||||
type Field struct {
|
type Field struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Type string `json:"type"`
|
Type []string `json:"type"`
|
||||||
RealType string `json:"real_type"`
|
RealType string `json:"real_type"`
|
||||||
Length int `json:"length"`
|
Length int `json:"length"`
|
||||||
}
|
}
|
||||||
@ -81,25 +81,23 @@ func (f *Field) ToAvroType() {
|
|||||||
switch f.Type {
|
switch f.Type {
|
||||||
case "date", "datetime", "time", "timestamp", "year", "tinytext", "text",
|
case "date", "datetime", "time", "timestamp", "year", "tinytext", "text",
|
||||||
"mediumtext", "longtext", "char", "varchar":
|
"mediumtext", "longtext", "char", "varchar":
|
||||||
f.Type = "string"
|
f.Type = ["null", "string"]
|
||||||
f.Length, _ = strconv.Atoi(length_re.ReplaceAllString(orig, "$1"))
|
f.Length, _ = strconv.Atoi(length_re.ReplaceAllString(orig, "$1"))
|
||||||
case "enum", "set":
|
case "enum", "set":
|
||||||
f.Type = "string"
|
f.Type = ["null", "string"]
|
||||||
case "tinyblob", "blob", "mediumblob", "longblob", "binary", "varbinary":
|
case "tinyblob", "blob", "mediumblob", "longblob", "binary", "varbinary":
|
||||||
f.Type = "bytes"
|
f.Type = ["null", "bytes"]
|
||||||
case "int", "smallint", "mediumint", "integer", "tinyint", "short", "bit":
|
case "int", "smallint", "mediumint", "integer", "tinyint", "short", "bit":
|
||||||
f.Type = "int"
|
f.Type = ["null", "int"]
|
||||||
case "float":
|
case "float":
|
||||||
f.Type = "float"
|
f.Type = ["null", "float"]
|
||||||
case "double", "decimal":
|
case "double", "decimal":
|
||||||
f.Type = "double"
|
f.Type = ["null", "double"]
|
||||||
case "null":
|
|
||||||
f.Type = "null"
|
|
||||||
case "long", "bigint":
|
case "long", "bigint":
|
||||||
f.Type = "long"
|
f.Type = ["null", "long"]
|
||||||
default:
|
default:
|
||||||
LogObject(f)
|
LogObject(f)
|
||||||
f.Type = "string"
|
f.Type = ["null", "string"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,24 +43,23 @@ def parse_field(row):
|
|||||||
else:
|
else:
|
||||||
res["length"] = -1
|
res["length"] = -1
|
||||||
|
|
||||||
|
type = "string"
|
||||||
|
|
||||||
if name in ("date", "datetime", "time", "timestamp", "year", "tinytext", "text",
|
if name in ("date", "datetime", "time", "timestamp", "year", "tinytext", "text",
|
||||||
"mediumtext", "longtext", "char", "varchar", "enum", "set"):
|
"mediumtext", "longtext", "char", "varchar", "enum", "set"):
|
||||||
res["type"] = "string"
|
type = "string"
|
||||||
elif name in ("tinyblob", "blob", "mediumblob", "longblob", "binary", "varbinary"):
|
elif name in ("tinyblob", "blob", "mediumblob", "longblob", "binary", "varbinary"):
|
||||||
res["type"] = "bytes"
|
type = "bytes"
|
||||||
elif name in ("int", "smallint", "mediumint", "integer", "tinyint", "short", "bit"):
|
elif name in ("int", "smallint", "mediumint", "integer", "tinyint", "short", "bit"):
|
||||||
res["type"] = "int"
|
type = "int"
|
||||||
elif name in ("float"):
|
elif name in ("float"):
|
||||||
res["type"] = "float"
|
type = "float"
|
||||||
elif name in ("double", "decimal"):
|
elif name in ("double", "decimal"):
|
||||||
res["type"] = "double"
|
type = "double"
|
||||||
elif name in ("null"):
|
|
||||||
res["type"] = "null"
|
|
||||||
elif name in ("long", "bigint"):
|
elif name in ("long", "bigint"):
|
||||||
res["type"] = "long"
|
type = "long"
|
||||||
else:
|
|
||||||
res["type"] = "string"
|
|
||||||
|
|
||||||
|
res["type"] = ["null", type]
|
||||||
|
|
||||||
res["name"] = row[0].lower()
|
res["name"] = row[0].lower()
|
||||||
|
|
||||||
|
|||||||
2
server/modules/protocol/examples/requirements.txt
Normal file
2
server/modules/protocol/examples/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
mysql-connector-python
|
||||||
|
kafka-python
|
||||||
Reference in New Issue
Block a user