From 9962796a04365275e5a77329053be7530a56ed1a Mon Sep 17 00:00:00 2001 From: Guoyu Su Date: Sun, 27 Sep 2026 10:24:36 +0800 Subject: [PATCH] fix(iotdb): recognize JDBC rpc_compress option --- agents/drivers/iotdb/README.md | 4 ++- agents/drivers/iotdb/driver.go | 2 +- agents/drivers/iotdb/main_test.go | 50 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/agents/drivers/iotdb/README.md b/agents/drivers/iotdb/README.md index 840babbd20..ed21056db1 100644 --- a/agents/drivers/iotdb/README.md +++ b/agents/drivers/iotdb/README.md @@ -35,7 +35,9 @@ The following URL parameters are supported: - `time_zone` - `connect_retry_max` - `connect_timeout_ms` -- `enable_compression=true` +- `enable_compression=true` (also accepts `rpc_compression` and the IoTDB JDBC + alias `rpc_compress`; when conflicting aliases are present, they take + precedence in that order) - `node_urls=host1:6667,host2:6667` for cluster sessions - `ssl=true` and `insecure_skip_verify=true` diff --git a/agents/drivers/iotdb/driver.go b/agents/drivers/iotdb/driver.go index 1997b37b0e..ae09da4a22 100644 --- a/agents/drivers/iotdb/driver.go +++ b/agents/drivers/iotdb/driver.go @@ -187,7 +187,7 @@ func parseConnectionConfig(params connectParams) (connectionConfig, error) { } config.ConnectTimeoutMS = parsed } - config.EnableCompression = queryBool(query, "enable_compression", "rpc_compression") + config.EnableCompression = queryBool(query, "enable_compression", "rpc_compression", "rpc_compress") config.NodeURLs = parseNodeURLs(firstQueryValue(query, "node_urls", "nodes")) if len(config.NodeURLs) == 0 { config.NodeURLs = []string{net.JoinHostPort(config.Host, strconv.Itoa(config.Port))} diff --git a/agents/drivers/iotdb/main_test.go b/agents/drivers/iotdb/main_test.go index 544e37c896..4586b52fa0 100644 --- a/agents/drivers/iotdb/main_test.go +++ b/agents/drivers/iotdb/main_test.go @@ -70,6 +70,56 @@ func TestParseConnectionConfig(t *testing.T) { } } +func TestParseConnectionConfigCompressionAliases(t *testing.T) { + tests := []struct { + name string + connectionString string + urlParams string + want bool + }{ + {name: "default disabled"}, + {name: "documented enabled", urlParams: "enable_compression=true", want: true}, + {name: "documented disabled", urlParams: "enable_compression=false"}, + {name: "existing alias enabled", urlParams: "rpc_compression=true", want: true}, + {name: "existing alias disabled", urlParams: "rpc_compression=false"}, + {name: "JDBC alias enabled in URL parameters", urlParams: "rpc_compress=true", want: true}, + {name: "JDBC alias false", urlParams: "rpc_compress=false"}, + { + name: "JDBC alias enabled in connection string", + connectionString: "jdbc:iotdb://localhost:6667/?rpc_compress=true", + want: true, + }, + { + name: "URL parameters override same connection string key", + connectionString: "jdbc:iotdb://localhost:6667/?rpc_compress=true", + urlParams: "rpc_compress=false", + }, + { + name: "documented option takes precedence", + urlParams: "enable_compression=false&rpc_compression=true&rpc_compress=true", + }, + { + name: "existing alias takes precedence over JDBC alias", + urlParams: "rpc_compression=false&rpc_compress=true", + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + config, err := parseConnectionConfig(connectParams{ + ConnectionString: test.connectionString, + URLParams: test.urlParams, + }) + if err != nil { + t.Fatal(err) + } + if config.EnableCompression != test.want { + t.Fatalf("EnableCompression = %t, want %t", config.EnableCompression, test.want) + } + }) + } +} + func TestBundledTimeZoneDatabase(t *testing.T) { dataSet, err := client.NewIoTDBRpcDataSet( "", nil, nil, nil, true, false, 0, 0, nil, 0, nil, 0, nil,