You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zh...@apache.org on 2022/07/13 00:39:31 UTC
[incubator-devlake] branch main updated: fix: load data from postgres data type (#2474)
This is an automated email from the ASF dual-hosted git repository.
zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new f6f0c393 fix: load data from postgres data type (#2474)
f6f0c393 is described below
commit f6f0c393cc96ad00e740516e20496cdb33121c47
Author: long2ice <lo...@gmail.com>
AuthorDate: Wed Jul 13 08:39:27 2022 +0800
fix: load data from postgres data type (#2474)
---
plugins/starrocks/utils.go | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/plugins/starrocks/utils.go b/plugins/starrocks/utils.go
index 0f2f9a00..c98d3276 100644
--- a/plugins/starrocks/utils.go
+++ b/plugins/starrocks/utils.go
@@ -67,18 +67,38 @@ func getTablesByDomainLayer(domainLayer string) []string {
}
return nil
}
+func hasPrefixes(s string, prefixes ...string) bool {
+ for _, prefix := range prefixes {
+ if strings.HasPrefix(s, prefix) {
+ return true
+ }
+ }
+ return false
+}
+func stringIn(s string, l ...string) bool {
+ for _, item := range l {
+ if s == item {
+ return true
+ }
+ }
+ return false
+}
func getDataType(dataType string) string {
starrocksDatatype := dataType
- if strings.HasPrefix(dataType, "varchar") {
+ if hasPrefixes(dataType, "varchar", "varying", "character", "bytea") {
starrocksDatatype = "string"
- } else if strings.HasPrefix(dataType, "datetime") {
+ } else if hasPrefixes(dataType, "datetime", "timestamp") {
starrocksDatatype = "datetime"
} else if strings.HasPrefix(dataType, "bigint") {
starrocksDatatype = "bigint"
- } else if dataType == "longtext" || dataType == "text" || dataType == "longblob" {
+ } else if stringIn(dataType, "longtext", "text", "longblob") {
starrocksDatatype = "string"
} else if dataType == "tinyint(1)" {
starrocksDatatype = "boolean"
+ } else if dataType == "numeric" {
+ starrocksDatatype = "double"
+ } else if stringIn(dataType, "json", "jsonb") {
+ starrocksDatatype = "json"
}
return starrocksDatatype
}