瀏覽代碼

feat(runtime): add configuration ignoreCase

If set to false, performance will be beneficial

Signed-off-by: Jiyong Huang <huangjy@emqx.io>
Jiyong Huang 3 年之前
父節點
當前提交
2f9bba1d4c

+ 2 - 0
deploy/chart/kuiper/values.yaml

@@ -106,6 +106,8 @@ kuiperConfig:
       # There could be several hosts (host can be separated with comma), if same package could be found in the several hosts,
       # then the package in the 1st host will have the highest priority.
       pluginHosts: https://packages.emqx.net
+      # Whether to ignore case in SQL processing. Note that, the name of customized function by plugins are case-sensitive.
+      ignoreCase: true
 
     # The default options for all rules. Each rule can override this setting by defining its own option
     rule:

+ 4 - 0
docs/en_US/operation/configuration_file.md

@@ -18,9 +18,13 @@ basic:
   rotateTime: 24
   # Maximum file storage hours
   maxAge: 72
+  # Whether to ignore case in SQL processing. Note that, the name of customized function by plugins are case-sensitive.
+  ignoreCase: true
 ```
 for debug option in basic following env is valid `KUIPER_BASIC_DEBUG=true` and if used debug value will be set to true.
 
+Configuration **ignoreCase** is used to ignore case in SQL processing. By default, it's set to true to comply with standard SQL. In this case, data ingested can be case-insensitive. If the column names in the SQL, stream definition and the ingested data can be unified as a case-sensitive name, it is recommended to set to true to gain a better performance.
+
 ## Log level
 
 ```yaml

+ 5 - 0
docs/zh_CN/operation/configuration_file.md

@@ -15,7 +15,12 @@ basic:
   rotateTime: 24
   # Maximum file storage hours
   maxAge: 168
+  # Whether to ignore case in SQL processing. Note that, the name of customized function by plugins are case-sensitive.
+  ignoreCase: true
 ```
+
+配置项 **ignoreCase** 用于指定 SQL 处理中是否大小写无关。默认情况下,为了与标准 SQL 兼容,其值为 true 。从而使得输入数据的列名大小写可以与 SQL 中的定义不同。如果 SQL 语句中,流定义以及输入数据中可以保证列名大小写完全一致,则建议设置该值为 false 以获得更优的性能。
+
 ## 系统日志
 用户将名为 KuiperSyslogKey 的环境变量的值设置为 true 时,日志将打印到系统日志中。
 ## Cli 地址

+ 2 - 0
etc/kuiper.yaml

@@ -29,6 +29,8 @@ basic:
   # There could be several hosts (host can be separated with comma), if same package could be found in the several hosts,
   # then the package in the 1st host will have the highest priority.
   pluginHosts: https://packages.emqx.net
+  # Whether to ignore case in SQL processing. Note that, the name of customized function by plugins are case-sensitive.
+  ignoreCase: true
 
 # The default options for all rules. Each rule can override this setting by defining its own option
 rule:

+ 1 - 0
internal/conf/conf.go

@@ -53,6 +53,7 @@ type KuiperConf struct {
 		PrometheusPort int      `yaml:"prometheusPort"`
 		PluginHosts    string   `yaml:"pluginHosts"`
 		Authentication bool     `yaml:"authentication"`
+		IgnoreCase     bool     `yaml:"ignoreCase"`
 	}
 	Rule api.RuleOption
 	Sink struct {

+ 3 - 1
internal/xsql/collections.go

@@ -51,10 +51,12 @@ func ToMessage(input interface{}) (Message, bool) {
 func (m Message) Value(key, _ string) (interface{}, bool) {
 	if v, ok := m[key]; ok {
 		return v, ok
-	} else {
+	} else if conf.Config == nil || conf.Config.Basic.IgnoreCase {
 		//Only when with 'SELECT * FROM ...'  and 'schemaless', the key in map is not convert to lower case.
 		//So all of keys in map should be convert to lowercase and then compare them.
 		return m.getIgnoreCase(key)
+	} else {
+		return nil, false
 	}
 }
 

+ 1 - 0
internal/xsql/valuer.go

@@ -449,6 +449,7 @@ func (v *ValuerEval) Eval(expr ast.Expr) interface{} {
 		}
 		if expr.IsAlias() {
 			r := v.Eval(expr.Expression)
+			// TODO possible performance elevation to eliminate this cal
 			v.Valuer.AppendAlias(expr.Name, r)
 			return r
 		}