mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-19 06:20:38 +00:00
refactor: use rwlock for modifiable session data (#4232)
* chore: update sqlness results * refactor: use rwlock for modifiable data in session and querycontext * chore: format toml * refactor: use mutable_inner structure for mutable fields * refactor: remove arc wrapper
This commit is contained in:
490
Cargo.lock
generated
490
Cargo.lock
generated
@@ -1335,7 +1335,7 @@ dependencies = [
|
||||
"common-time",
|
||||
"common-version",
|
||||
"dashmap",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion",
|
||||
"datatypes",
|
||||
"futures",
|
||||
"futures-util",
|
||||
@@ -1862,7 +1862,7 @@ dependencies = [
|
||||
"common-runtime",
|
||||
"common-telemetry",
|
||||
"common-test-util",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion",
|
||||
"datatypes",
|
||||
"derive_builder 0.12.0",
|
||||
"dotenv",
|
||||
@@ -1937,7 +1937,7 @@ dependencies = [
|
||||
"common-telemetry",
|
||||
"common-time",
|
||||
"common-version",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion",
|
||||
"datatypes",
|
||||
"num",
|
||||
"num-traits",
|
||||
@@ -2063,8 +2063,8 @@ dependencies = [
|
||||
"common-telemetry",
|
||||
"common-time",
|
||||
"common-wal",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datatypes",
|
||||
"derive_builder 0.12.0",
|
||||
"etcd-client",
|
||||
@@ -2144,9 +2144,9 @@ dependencies = [
|
||||
"common-macro",
|
||||
"common-recordbatch",
|
||||
"common-time",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datatypes",
|
||||
"serde",
|
||||
"snafu 0.8.3",
|
||||
@@ -2165,8 +2165,8 @@ dependencies = [
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-telemetry",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datatypes",
|
||||
"futures",
|
||||
"pin-project",
|
||||
@@ -2729,57 +2729,6 @@ version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2"
|
||||
|
||||
[[package]]
|
||||
name = "datafusion"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85069782056753459dc47e386219aa1fdac5b731f26c28abb8c0ffd4b7c5ab11"
|
||||
dependencies = [
|
||||
"ahash 0.8.11",
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"arrow-ipc",
|
||||
"arrow-schema",
|
||||
"async-compression 0.4.11",
|
||||
"async-trait",
|
||||
"bytes",
|
||||
"bzip2",
|
||||
"chrono",
|
||||
"dashmap",
|
||||
"datafusion-common 37.1.0",
|
||||
"datafusion-common-runtime 37.1.0",
|
||||
"datafusion-execution 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"datafusion-functions 37.1.0",
|
||||
"datafusion-functions-array 37.1.0",
|
||||
"datafusion-optimizer 37.1.0",
|
||||
"datafusion-physical-expr 37.1.0",
|
||||
"datafusion-physical-plan 37.1.0",
|
||||
"datafusion-sql 37.1.0",
|
||||
"flate2",
|
||||
"futures",
|
||||
"glob",
|
||||
"half 2.4.1",
|
||||
"hashbrown 0.14.5",
|
||||
"indexmap 2.2.6",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"num_cpus",
|
||||
"object_store",
|
||||
"parking_lot 0.12.3",
|
||||
"parquet",
|
||||
"pin-project-lite",
|
||||
"rand",
|
||||
"sqlparser 0.44.0",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"url",
|
||||
"uuid",
|
||||
"xz2",
|
||||
"zstd 0.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion"
|
||||
version = "38.0.0"
|
||||
@@ -2796,18 +2745,18 @@ dependencies = [
|
||||
"bzip2",
|
||||
"chrono",
|
||||
"dashmap",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-common-runtime 38.0.0",
|
||||
"datafusion-execution 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-functions 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-common-runtime",
|
||||
"datafusion-execution",
|
||||
"datafusion-expr",
|
||||
"datafusion-functions",
|
||||
"datafusion-functions-aggregate",
|
||||
"datafusion-functions-array 38.0.0",
|
||||
"datafusion-optimizer 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion-functions-array",
|
||||
"datafusion-optimizer",
|
||||
"datafusion-physical-expr",
|
||||
"datafusion-physical-expr-common",
|
||||
"datafusion-physical-plan 38.0.0",
|
||||
"datafusion-sql 38.0.0",
|
||||
"datafusion-physical-plan",
|
||||
"datafusion-sql",
|
||||
"flate2",
|
||||
"futures",
|
||||
"glob",
|
||||
@@ -2832,27 +2781,6 @@ dependencies = [
|
||||
"zstd 0.13.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-common"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "309d9040751f6dc9e33c85dce6abb55a46ef7ea3644577dd014611c379447ef3"
|
||||
dependencies = [
|
||||
"ahash 0.8.11",
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
"arrow-schema",
|
||||
"chrono",
|
||||
"half 2.4.1",
|
||||
"instant",
|
||||
"libc",
|
||||
"num_cpus",
|
||||
"object_store",
|
||||
"parquet",
|
||||
"sqlparser 0.44.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-common"
|
||||
version = "38.0.0"
|
||||
@@ -2874,15 +2802,6 @@ dependencies = [
|
||||
"sqlparser 0.45.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-common-runtime"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e4a44d8ef1b1e85d32234e6012364c411c3787859bb3bba893b0332cb03dfd"
|
||||
dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-common-runtime"
|
||||
version = "38.0.0"
|
||||
@@ -2891,27 +2810,6 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-execution"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06a3a29ae36bcde07d179cc33b45656a8e7e4d023623e320e48dcf1200eeee95"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"chrono",
|
||||
"dashmap",
|
||||
"datafusion-common 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"futures",
|
||||
"hashbrown 0.14.5",
|
||||
"log",
|
||||
"object_store",
|
||||
"parking_lot 0.12.3",
|
||||
"rand",
|
||||
"tempfile",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-execution"
|
||||
version = "38.0.0"
|
||||
@@ -2920,8 +2818,8 @@ dependencies = [
|
||||
"arrow",
|
||||
"chrono",
|
||||
"dashmap",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"futures",
|
||||
"hashbrown 0.14.5",
|
||||
"log",
|
||||
@@ -2932,23 +2830,6 @@ dependencies = [
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-expr"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a3542aa322029c2121a671ce08000d4b274171070df13f697b14169ccf4f628"
|
||||
dependencies = [
|
||||
"ahash 0.8.11",
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"chrono",
|
||||
"datafusion-common 37.1.0",
|
||||
"paste",
|
||||
"sqlparser 0.44.0",
|
||||
"strum 0.26.2",
|
||||
"strum_macros 0.26.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-expr"
|
||||
version = "38.0.0"
|
||||
@@ -2958,7 +2839,7 @@ dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"chrono",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-common",
|
||||
"paste",
|
||||
"serde_json",
|
||||
"sqlparser 0.45.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -2966,31 +2847,6 @@ dependencies = [
|
||||
"strum_macros 0.26.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-functions"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd221792c666eac174ecc09e606312844772acc12cbec61a420c2fca1ee70959"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"base64 0.22.1",
|
||||
"blake2",
|
||||
"blake3",
|
||||
"chrono",
|
||||
"datafusion-common 37.1.0",
|
||||
"datafusion-execution 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"datafusion-physical-expr 37.1.0",
|
||||
"hex",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"md-5",
|
||||
"regex",
|
||||
"sha2",
|
||||
"unicode-segmentation",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-functions"
|
||||
version = "38.0.0"
|
||||
@@ -3001,10 +2857,10 @@ dependencies = [
|
||||
"blake2",
|
||||
"blake3",
|
||||
"chrono",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-execution 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-execution",
|
||||
"datafusion-expr",
|
||||
"datafusion-physical-expr",
|
||||
"hashbrown 0.14.5",
|
||||
"hex",
|
||||
"itertools 0.12.1",
|
||||
@@ -3025,35 +2881,15 @@ dependencies = [
|
||||
"ahash 0.8.11",
|
||||
"arrow",
|
||||
"arrow-schema",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-execution 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-execution",
|
||||
"datafusion-expr",
|
||||
"datafusion-physical-expr-common",
|
||||
"log",
|
||||
"paste",
|
||||
"sqlparser 0.45.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-functions-array"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e501801e84d9c6ef54caaebcda1b18a6196a24176c12fb70e969bc0572e03c55"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
"arrow-ord",
|
||||
"arrow-schema",
|
||||
"datafusion-common 37.1.0",
|
||||
"datafusion-execution 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"datafusion-functions 37.1.0",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-functions-array"
|
||||
version = "38.0.0"
|
||||
@@ -3064,33 +2900,15 @@ dependencies = [
|
||||
"arrow-buffer",
|
||||
"arrow-ord",
|
||||
"arrow-schema",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-execution 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-functions 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-execution",
|
||||
"datafusion-expr",
|
||||
"datafusion-functions",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-optimizer"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76bd7f5087817deb961764e8c973d243b54f8572db414a8f0a8f33a48f991e0a"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"datafusion-common 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"datafusion-physical-expr 37.1.0",
|
||||
"hashbrown 0.14.5",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"regex-syntax 0.8.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-optimizer"
|
||||
version = "38.0.0"
|
||||
@@ -3099,9 +2917,9 @@ dependencies = [
|
||||
"arrow",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datafusion-physical-expr",
|
||||
"hashbrown 0.14.5",
|
||||
"indexmap 2.2.6",
|
||||
"itertools 0.12.1",
|
||||
@@ -3109,41 +2927,6 @@ dependencies = [
|
||||
"regex-syntax 0.8.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-physical-expr"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cabc0d9aaa0f5eb1b472112f16223c9ffd2fb04e58cbf65c0a331ee6e993f96"
|
||||
dependencies = [
|
||||
"ahash 0.8.11",
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
"arrow-ord",
|
||||
"arrow-schema",
|
||||
"arrow-string",
|
||||
"base64 0.22.1",
|
||||
"blake2",
|
||||
"blake3",
|
||||
"chrono",
|
||||
"datafusion-common 37.1.0",
|
||||
"datafusion-execution 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"half 2.4.1",
|
||||
"hashbrown 0.14.5",
|
||||
"hex",
|
||||
"indexmap 2.2.6",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"md-5",
|
||||
"paste",
|
||||
"petgraph",
|
||||
"rand",
|
||||
"regex",
|
||||
"sha2",
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-physical-expr"
|
||||
version = "38.0.0"
|
||||
@@ -3158,9 +2941,9 @@ dependencies = [
|
||||
"arrow-string",
|
||||
"base64 0.22.1",
|
||||
"chrono",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-execution 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-execution",
|
||||
"datafusion-expr",
|
||||
"datafusion-functions-aggregate",
|
||||
"datafusion-physical-expr-common",
|
||||
"half 2.4.1",
|
||||
@@ -3180,42 +2963,11 @@ version = "38.0.0"
|
||||
source = "git+https://github.com/apache/datafusion.git?rev=729b356ef543ffcda6813c7b5373507a04ae0109#729b356ef543ffcda6813c7b5373507a04ae0109"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-physical-plan"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17c0523e9c8880f2492a88bbd857dde02bed1ed23f3e9211a89d3d7ec3b44af9"
|
||||
dependencies = [
|
||||
"ahash 0.8.11",
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"arrow-buffer",
|
||||
"arrow-schema",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"datafusion-common 37.1.0",
|
||||
"datafusion-common-runtime 37.1.0",
|
||||
"datafusion-execution 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"datafusion-physical-expr 37.1.0",
|
||||
"futures",
|
||||
"half 2.4.1",
|
||||
"hashbrown 0.14.5",
|
||||
"indexmap 2.2.6",
|
||||
"itertools 0.12.1",
|
||||
"log",
|
||||
"once_cell",
|
||||
"parking_lot 0.12.3",
|
||||
"pin-project-lite",
|
||||
"rand",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-physical-plan"
|
||||
version = "38.0.0"
|
||||
@@ -3229,12 +2981,12 @@ dependencies = [
|
||||
"arrow-schema",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-common-runtime 38.0.0",
|
||||
"datafusion-execution 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-common-runtime",
|
||||
"datafusion-execution",
|
||||
"datafusion-expr",
|
||||
"datafusion-functions-aggregate",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion-physical-expr",
|
||||
"datafusion-physical-expr-common",
|
||||
"futures",
|
||||
"half 2.4.1",
|
||||
@@ -3249,22 +3001,6 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-sql"
|
||||
version = "37.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49eb54b42227136f6287573f2434b1de249fe1b8e6cd6cc73a634e4a3ec29356"
|
||||
dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
"datafusion-common 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"log",
|
||||
"sqlparser 0.44.0",
|
||||
"strum 0.26.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "datafusion-sql"
|
||||
version = "38.0.0"
|
||||
@@ -3273,8 +3009,8 @@ dependencies = [
|
||||
"arrow",
|
||||
"arrow-array",
|
||||
"arrow-schema",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"log",
|
||||
"regex",
|
||||
"sqlparser 0.45.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -3288,7 +3024,7 @@ source = "git+https://github.com/apache/datafusion.git?rev=729b356ef543ffcda6813
|
||||
dependencies = [
|
||||
"async-recursion",
|
||||
"chrono",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion",
|
||||
"itertools 0.12.1",
|
||||
"object_store",
|
||||
"pbjson-types",
|
||||
@@ -3324,9 +3060,9 @@ dependencies = [
|
||||
"common-version",
|
||||
"common-wal",
|
||||
"dashmap",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datatypes",
|
||||
"file-engine",
|
||||
"futures",
|
||||
@@ -3367,7 +3103,7 @@ dependencies = [
|
||||
"common-macro",
|
||||
"common-telemetry",
|
||||
"common-time",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-common",
|
||||
"enum_dispatch",
|
||||
"num",
|
||||
"num-traits",
|
||||
@@ -3931,8 +3667,8 @@ dependencies = [
|
||||
"common-telemetry",
|
||||
"common-test-util",
|
||||
"common-time",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-expr",
|
||||
"datatypes",
|
||||
"futures",
|
||||
"object-store",
|
||||
@@ -4036,10 +3772,10 @@ dependencies = [
|
||||
"common-telemetry",
|
||||
"common-time",
|
||||
"common-version",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datafusion-physical-expr",
|
||||
"datatypes",
|
||||
"enum-as-inner",
|
||||
"enum_dispatch",
|
||||
@@ -6404,7 +6140,7 @@ dependencies = [
|
||||
"common-telemetry",
|
||||
"common-test-util",
|
||||
"common-time",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion",
|
||||
"datatypes",
|
||||
"itertools 0.10.5",
|
||||
"lazy_static",
|
||||
@@ -6507,9 +6243,9 @@ dependencies = [
|
||||
"crc32fast",
|
||||
"criterion 0.4.0",
|
||||
"crossbeam-utils",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datatypes",
|
||||
"dotenv",
|
||||
"futures",
|
||||
@@ -7401,9 +7137,9 @@ dependencies = [
|
||||
"common-telemetry",
|
||||
"common-test-util",
|
||||
"common-time",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datatypes",
|
||||
"file-engine",
|
||||
"futures",
|
||||
@@ -7448,9 +7184,6 @@ dependencies = [
|
||||
"bytes",
|
||||
"chrono",
|
||||
"chrono-tz 0.8.6",
|
||||
"datafusion 37.1.0",
|
||||
"datafusion-expr 37.1.0",
|
||||
"datafusion-physical-expr 37.1.0",
|
||||
"fallible-streaming-iterator",
|
||||
"flate2",
|
||||
"futures",
|
||||
@@ -7458,7 +7191,6 @@ dependencies = [
|
||||
"lz4_flex 0.11.3",
|
||||
"lzokay-native",
|
||||
"num",
|
||||
"object_store",
|
||||
"prost 0.11.9",
|
||||
"snafu 0.7.5",
|
||||
"snap",
|
||||
@@ -7687,8 +7419,8 @@ dependencies = [
|
||||
"common-macro",
|
||||
"common-meta",
|
||||
"common-query",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datatypes",
|
||||
"itertools 0.10.5",
|
||||
"serde",
|
||||
@@ -7988,11 +7720,11 @@ dependencies = [
|
||||
"common-time",
|
||||
"crossbeam-utils",
|
||||
"csv",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-functions 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datafusion-functions",
|
||||
"datafusion-physical-expr",
|
||||
"datatypes",
|
||||
"futures",
|
||||
"greptime-proto",
|
||||
@@ -8413,8 +8145,8 @@ dependencies = [
|
||||
"common-macro",
|
||||
"common-recordbatch",
|
||||
"common-telemetry",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-expr",
|
||||
"datatypes",
|
||||
"futures",
|
||||
"greptime-proto",
|
||||
@@ -8759,13 +8491,13 @@ dependencies = [
|
||||
"common-runtime",
|
||||
"common-telemetry",
|
||||
"common-time",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-functions 38.0.0",
|
||||
"datafusion-optimizer 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion-sql 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datafusion-functions",
|
||||
"datafusion-optimizer",
|
||||
"datafusion-physical-expr",
|
||||
"datafusion-sql",
|
||||
"datatypes",
|
||||
"format_num",
|
||||
"futures",
|
||||
@@ -10159,11 +9891,11 @@ dependencies = [
|
||||
"console",
|
||||
"criterion 0.4.0",
|
||||
"crossbeam-utils",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-functions 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datafusion-functions",
|
||||
"datafusion-physical-expr",
|
||||
"datatypes",
|
||||
"futures",
|
||||
"lazy_static",
|
||||
@@ -10467,8 +10199,8 @@ dependencies = [
|
||||
"common-version",
|
||||
"criterion 0.5.1",
|
||||
"dashmap",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datatypes",
|
||||
"derive_builder 0.12.0",
|
||||
"futures",
|
||||
@@ -10837,11 +10569,11 @@ dependencies = [
|
||||
"common-macro",
|
||||
"common-query",
|
||||
"common-time",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion-sql 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datafusion-physical-expr",
|
||||
"datafusion-sql",
|
||||
"datatypes",
|
||||
"hex",
|
||||
"itertools 0.10.5",
|
||||
@@ -10900,16 +10632,6 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlparser"
|
||||
version = "0.44.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aaf9c7ff146298ffda83a200f8d5084f08dcee1edfc135fcc1d646a45d50ffd6"
|
||||
dependencies = [
|
||||
"log",
|
||||
"sqlparser_derive 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlparser"
|
||||
version = "0.45.0"
|
||||
@@ -11122,8 +10844,8 @@ dependencies = [
|
||||
"common-recordbatch",
|
||||
"common-time",
|
||||
"common-wal",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-physical-plan 38.0.0",
|
||||
"datafusion-expr",
|
||||
"datafusion-physical-plan",
|
||||
"datatypes",
|
||||
"derive_builder 0.12.0",
|
||||
"futures",
|
||||
@@ -11285,9 +11007,9 @@ dependencies = [
|
||||
"common-error",
|
||||
"common-macro",
|
||||
"common-telemetry",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datafusion-substrait",
|
||||
"datatypes",
|
||||
"promql",
|
||||
@@ -11495,10 +11217,10 @@ dependencies = [
|
||||
"common-telemetry",
|
||||
"common-test-util",
|
||||
"common-time",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-common 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion-physical-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-common",
|
||||
"datafusion-expr",
|
||||
"datafusion-physical-expr",
|
||||
"datatypes",
|
||||
"derive_builder 0.12.0",
|
||||
"futures",
|
||||
@@ -11812,8 +11534,8 @@ dependencies = [
|
||||
"common-telemetry",
|
||||
"common-test-util",
|
||||
"common-wal",
|
||||
"datafusion 38.0.0",
|
||||
"datafusion-expr 38.0.0",
|
||||
"datafusion",
|
||||
"datafusion-expr",
|
||||
"datanode",
|
||||
"datatypes",
|
||||
"dotenv",
|
||||
|
||||
@@ -42,7 +42,7 @@ pub enum PermissionResp {
|
||||
pub trait PermissionChecker: Send + Sync {
|
||||
fn check_permission(
|
||||
&self,
|
||||
user_info: Option<UserInfoRef>,
|
||||
user_info: UserInfoRef,
|
||||
req: PermissionReq,
|
||||
) -> Result<PermissionResp>;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ pub trait PermissionChecker: Send + Sync {
|
||||
impl PermissionChecker for Option<&PermissionCheckerRef> {
|
||||
fn check_permission(
|
||||
&self,
|
||||
user_info: Option<UserInfoRef>,
|
||||
user_info: UserInfoRef,
|
||||
req: PermissionReq,
|
||||
) -> Result<PermissionResp> {
|
||||
match self {
|
||||
|
||||
@@ -27,7 +27,7 @@ struct DummyPermissionChecker;
|
||||
impl PermissionChecker for DummyPermissionChecker {
|
||||
fn check_permission(
|
||||
&self,
|
||||
_user_info: Option<UserInfoRef>,
|
||||
_user_info: UserInfoRef,
|
||||
req: PermissionReq,
|
||||
) -> auth::error::Result<PermissionResp> {
|
||||
match req {
|
||||
@@ -45,13 +45,13 @@ fn test_permission_checker() {
|
||||
let checker: PermissionCheckerRef = Arc::new(DummyPermissionChecker);
|
||||
|
||||
let grpc_result = checker.check_permission(
|
||||
None,
|
||||
auth::userinfo_by_name(None),
|
||||
PermissionReq::GrpcRequest(&Request::Query(Default::default())),
|
||||
);
|
||||
assert_matches!(grpc_result, Ok(PermissionResp::Allow));
|
||||
|
||||
let sql_result = checker.check_permission(
|
||||
None,
|
||||
auth::userinfo_by_name(None),
|
||||
PermissionReq::SqlStatement(&Statement::ShowDatabases(ShowDatabases::new(
|
||||
ShowKind::All,
|
||||
false,
|
||||
@@ -59,6 +59,7 @@ fn test_permission_checker() {
|
||||
);
|
||||
assert_matches!(sql_result, Ok(PermissionResp::Reject));
|
||||
|
||||
let err_result = checker.check_permission(None, PermissionReq::Opentsdb);
|
||||
let err_result =
|
||||
checker.check_permission(auth::userinfo_by_name(None), PermissionReq::Opentsdb);
|
||||
assert_matches!(err_result, Err(InternalState { msg }) if msg == "testing");
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ derive_builder.workspace = true
|
||||
futures.workspace = true
|
||||
lazy_static.workspace = true
|
||||
object-store.workspace = true
|
||||
orc-rust = { git = "https://github.com/datafusion-contrib/datafusion-orc.git", rev = "502217315726314c4008808fe169764529640599" }
|
||||
orc-rust = { git = "https://github.com/datafusion-contrib/datafusion-orc.git", rev = "502217315726314c4008808fe169764529640599", default-features = false, features = [
|
||||
"async",
|
||||
] }
|
||||
parquet.workspace = true
|
||||
paste = "1.0"
|
||||
rand.workspace = true
|
||||
|
||||
@@ -680,7 +680,7 @@ mod tests {
|
||||
|
||||
// query context with timezone `+08:00`
|
||||
let ctx = QueryContextBuilder::default()
|
||||
.timezone(Timezone::from_tz_string("+08:00").unwrap().into())
|
||||
.timezone(Timezone::from_tz_string("+08:00").unwrap())
|
||||
.build()
|
||||
.into();
|
||||
let expr = create_to_expr(&create_table, &ctx).unwrap();
|
||||
@@ -735,7 +735,7 @@ mod tests {
|
||||
//
|
||||
// query context with timezone `+08:00`
|
||||
let ctx = QueryContextBuilder::default()
|
||||
.timezone(Timezone::from_tz_string("+08:00").unwrap().into())
|
||||
.timezone(Timezone::from_tz_string("+08:00").unwrap())
|
||||
.build()
|
||||
.into();
|
||||
let expr = to_alter_expr(alter_table, &ctx).unwrap();
|
||||
|
||||
@@ -494,7 +494,6 @@ fn idents_to_full_database_name(
|
||||
mod tests {
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use common_time::range::TimestampRange;
|
||||
use common_time::{Timestamp, Timezone};
|
||||
@@ -509,7 +508,7 @@ mod tests {
|
||||
|
||||
fn check_timestamp_range((start, end): (&str, &str)) -> error::Result<Option<TimestampRange>> {
|
||||
let query_ctx = QueryContextBuilder::default()
|
||||
.timezone(Arc::new(Timezone::from_tz_string("Asia/Shanghai").unwrap()))
|
||||
.timezone(Timezone::from_tz_string("Asia/Shanghai").unwrap())
|
||||
.build()
|
||||
.into();
|
||||
let map = OptionMap::from(
|
||||
|
||||
@@ -145,7 +145,7 @@ impl TypeConverter {
|
||||
) -> Result<ScalarValue> {
|
||||
match (target_type, value) {
|
||||
(DataType::Timestamp(_, _), ScalarValue::Utf8(Some(v))) => {
|
||||
string_to_timestamp_ms(v, Some(self.query_ctx.timezone().as_ref()))
|
||||
string_to_timestamp_ms(v, Some(&self.query_ctx.timezone()))
|
||||
}
|
||||
(DataType::Boolean, ScalarValue::Utf8(Some(v))) => match v.to_lowercase().as_str() {
|
||||
"true" => Ok(ScalarValue::Boolean(Some(true))),
|
||||
|
||||
@@ -257,11 +257,8 @@ impl<'a> TreeNodeRewriter for RangeExprRewriter<'a> {
|
||||
.map_err(|e| DataFusionError::Plan(e.to_string()))?;
|
||||
let by = parse_expr_list(&func.args, 4, byc)?;
|
||||
let align = parse_duration_expr(&func.args, byc + 4)?;
|
||||
let align_to = parse_align_to(
|
||||
&func.args,
|
||||
byc + 5,
|
||||
Some(self.query_ctx.timezone().as_ref()),
|
||||
)?;
|
||||
let align_to =
|
||||
parse_align_to(&func.args, byc + 5, Some(&self.query_ctx.timezone()))?;
|
||||
let mut data_type = range_expr.get_type(self.input_plan.schema())?;
|
||||
let mut need_cast = false;
|
||||
let fill = Fill::try_from_str(parse_str_expr(&func.args, 2)?, &data_type)?;
|
||||
|
||||
@@ -1021,7 +1021,7 @@ mod test {
|
||||
};
|
||||
let ctx = Arc::new(
|
||||
QueryContextBuilder::default()
|
||||
.timezone(Arc::new(Timezone::from_tz_string(tz).unwrap()))
|
||||
.timezone(Timezone::from_tz_string(tz).unwrap())
|
||||
.build(),
|
||||
);
|
||||
match show_variable(stmt, ctx) {
|
||||
|
||||
@@ -108,7 +108,7 @@ async fn do_auth<T>(
|
||||
let query_ctx = Arc::new(QueryContext::with(&catalog, &schema));
|
||||
|
||||
let Some(user_provider) = user_provider else {
|
||||
query_ctx.set_current_user(Some(auth::userinfo_by_name(None)));
|
||||
query_ctx.set_current_user(auth::userinfo_by_name(None));
|
||||
let _ = req.extensions_mut().insert(query_ctx);
|
||||
return Ok(());
|
||||
};
|
||||
@@ -124,7 +124,7 @@ async fn do_auth<T>(
|
||||
.await
|
||||
.map_err(|e| tonic::Status::unauthenticated(e.to_string()))?;
|
||||
|
||||
query_ctx.set_current_user(Some(user_info));
|
||||
query_ctx.set_current_user(user_info);
|
||||
let _ = req.extensions_mut().insert(query_ctx);
|
||||
|
||||
Ok(())
|
||||
@@ -201,7 +201,7 @@ mod tests {
|
||||
assert_eq!(expected_catalog, ctx.current_catalog());
|
||||
assert_eq!(expected_schema, ctx.current_schema());
|
||||
|
||||
let user_info = ctx.current_user().unwrap();
|
||||
let user_info = ctx.current_user();
|
||||
assert_eq!(expected_user_name, user_info.username());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +128,9 @@ pub(crate) async fn auth(
|
||||
user_provider: Option<UserProviderRef>,
|
||||
header: Option<&RequestHeader>,
|
||||
query_ctx: &QueryContextRef,
|
||||
) -> Result<Option<UserInfoRef>> {
|
||||
) -> Result<UserInfoRef> {
|
||||
let Some(user_provider) = user_provider else {
|
||||
return Ok(None);
|
||||
return Ok(auth::userinfo_by_name(None));
|
||||
};
|
||||
|
||||
let auth_scheme = header
|
||||
@@ -156,7 +156,6 @@ pub(crate) async fn auth(
|
||||
name: "Token AuthScheme".to_string(),
|
||||
}),
|
||||
}
|
||||
.map(Some)
|
||||
.map_err(|e| {
|
||||
METRIC_AUTH_FAILURE
|
||||
.with_label_values(&[e.status_code().as_ref()])
|
||||
@@ -197,7 +196,7 @@ pub(crate) fn create_query_context(header: Option<&RequestHeader>) -> QueryConte
|
||||
QueryContextBuilder::default()
|
||||
.current_catalog(catalog)
|
||||
.current_schema(schema)
|
||||
.timezone(Arc::new(timezone))
|
||||
.timezone(timezone)
|
||||
.build()
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ pub async fn inner_auth<B>(
|
||||
// 1. prepare
|
||||
let (catalog, schema) = extract_catalog_and_schema(&req);
|
||||
// TODO(ruihang): move this out of auth module
|
||||
let timezone = Arc::new(extract_timezone(&req));
|
||||
let timezone = extract_timezone(&req);
|
||||
let query_ctx_builder = QueryContextBuilder::default()
|
||||
.current_catalog(catalog.clone())
|
||||
.current_schema(schema.clone())
|
||||
@@ -75,7 +75,7 @@ pub async fn inner_auth<B>(
|
||||
let user_provider = if let Some(user_provider) = user_provider.filter(|_| need_auth) {
|
||||
user_provider
|
||||
} else {
|
||||
query_ctx.set_current_user(Some(auth::userinfo_by_name(None)));
|
||||
query_ctx.set_current_user(auth::userinfo_by_name(None));
|
||||
let _ = req.extensions_mut().insert(query_ctx);
|
||||
return Ok(req);
|
||||
};
|
||||
@@ -103,7 +103,7 @@ pub async fn inner_auth<B>(
|
||||
.await
|
||||
{
|
||||
Ok(userinfo) => {
|
||||
query_ctx.set_current_user(Some(userinfo));
|
||||
query_ctx.set_current_user(userinfo);
|
||||
let _ = req.extensions_mut().insert(query_ctx);
|
||||
Ok(req)
|
||||
}
|
||||
|
||||
@@ -103,9 +103,7 @@ impl MysqlInstanceShim {
|
||||
{
|
||||
vec![Ok(output)]
|
||||
} else {
|
||||
let output = self.query_handler.do_query(query, query_ctx.clone()).await;
|
||||
query_ctx.update_session(&self.session);
|
||||
output
|
||||
self.query_handler.do_query(query, query_ctx.clone()).await
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ impl SimpleQueryHandler for PostgresServerHandler {
|
||||
.with_label_values(&[crate::metrics::METRIC_POSTGRES_SIMPLE_QUERY, db.as_str()])
|
||||
.start_timer();
|
||||
let outputs = self.query_handler.do_query(query, query_ctx.clone()).await;
|
||||
query_ctx.update_session(&self.session);
|
||||
|
||||
let mut results = Vec::with_capacity(outputs.len());
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ async fn test_http_auth() {
|
||||
let req = mock_http_request(Some("Basic dXNlcm5hbWU6cGFzc3dvcmQ="), None).unwrap();
|
||||
let req = inner_auth(None, req).await.unwrap();
|
||||
let ctx: &QueryContextRef = req.extensions().get().unwrap();
|
||||
let user_info = ctx.current_user().unwrap();
|
||||
let user_info = ctx.current_user();
|
||||
let default = auth::userinfo_by_name(None);
|
||||
assert_eq!(default.username(), user_info.username());
|
||||
|
||||
@@ -39,7 +39,7 @@ async fn test_http_auth() {
|
||||
let req = mock_http_request(Some("Basic Z3JlcHRpbWU6Z3JlcHRpbWU="), None).unwrap();
|
||||
let req = inner_auth(mock_user_provider.clone(), req).await.unwrap();
|
||||
let ctx: &QueryContextRef = req.extensions().get().unwrap();
|
||||
let user_info = ctx.current_user().unwrap();
|
||||
let user_info = ctx.current_user();
|
||||
let default = auth::userinfo_by_name(None);
|
||||
assert_eq!(default.username(), user_info.username());
|
||||
|
||||
@@ -80,7 +80,7 @@ async fn test_schema_validating() {
|
||||
.unwrap();
|
||||
let req = inner_auth(mock_user_provider.clone(), req).await.unwrap();
|
||||
let ctx: &QueryContextRef = req.extensions().get().unwrap();
|
||||
let user_info = ctx.current_user().unwrap();
|
||||
let user_info = ctx.current_user();
|
||||
let default = auth::userinfo_by_name(None);
|
||||
assert_eq!(default.username(), user_info.username());
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ use crate::{
|
||||
async fn test_sql_not_provided() {
|
||||
let sql_handler = create_testing_sql_query_handler(MemTable::default_numbers_table());
|
||||
let ctx = QueryContext::arc();
|
||||
ctx.set_current_user(Some(auth::userinfo_by_name(None)));
|
||||
ctx.set_current_user(auth::userinfo_by_name(None));
|
||||
let api_state = ApiState {
|
||||
sql_handler,
|
||||
script_handler: None,
|
||||
@@ -75,7 +75,7 @@ async fn test_sql_output_rows() {
|
||||
let sql_handler = create_testing_sql_query_handler(MemTable::default_numbers_table());
|
||||
|
||||
let ctx = QueryContext::arc();
|
||||
ctx.set_current_user(Some(auth::userinfo_by_name(None)));
|
||||
ctx.set_current_user(auth::userinfo_by_name(None));
|
||||
let api_state = ApiState {
|
||||
sql_handler,
|
||||
script_handler: None,
|
||||
@@ -181,7 +181,7 @@ async fn test_sql_output_rows() {
|
||||
async fn test_dashboard_sql_limit() {
|
||||
let sql_handler = create_testing_sql_query_handler(MemTable::specified_numbers_table(2000));
|
||||
let ctx = QueryContext::arc();
|
||||
ctx.set_current_user(Some(auth::userinfo_by_name(None)));
|
||||
ctx.set_current_user(auth::userinfo_by_name(None));
|
||||
let api_state = ApiState {
|
||||
sql_handler,
|
||||
script_handler: None,
|
||||
@@ -227,7 +227,7 @@ async fn test_sql_form() {
|
||||
let sql_handler = create_testing_sql_query_handler(MemTable::default_numbers_table());
|
||||
|
||||
let ctx = QueryContext::arc();
|
||||
ctx.set_current_user(Some(auth::userinfo_by_name(None)));
|
||||
ctx.set_current_user(auth::userinfo_by_name(None));
|
||||
let api_state = ApiState {
|
||||
sql_handler,
|
||||
script_handler: None,
|
||||
|
||||
@@ -15,34 +15,32 @@
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use api::v1::region::RegionRequestHeader;
|
||||
use arc_swap::ArcSwap;
|
||||
use auth::UserInfoRef;
|
||||
use common_catalog::consts::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME};
|
||||
use common_catalog::{build_db_string, parse_catalog_and_schema_from_db_string};
|
||||
use common_time::timezone::{get_timezone, parse_timezone};
|
||||
use common_time::timezone::parse_timezone;
|
||||
use common_time::Timezone;
|
||||
use derive_builder::Builder;
|
||||
use sql::dialect::{Dialect, GreptimeDbDialect, MySqlDialect, PostgreSqlDialect};
|
||||
|
||||
use crate::session_config::{PGByteaOutputValue, PGDateOrder, PGDateTimeStyle};
|
||||
use crate::SessionRef;
|
||||
use crate::MutableInner;
|
||||
|
||||
pub type QueryContextRef = Arc<QueryContext>;
|
||||
pub type ConnInfoRef = Arc<ConnInfo>;
|
||||
|
||||
#[derive(Debug, Builder)]
|
||||
#[derive(Debug, Builder, Clone)]
|
||||
#[builder(pattern = "owned")]
|
||||
#[builder(build_fn(skip))]
|
||||
pub struct QueryContext {
|
||||
current_catalog: String,
|
||||
#[builder(setter(custom))]
|
||||
current_schema: ArcSwap<String>,
|
||||
current_user: ArcSwap<Option<UserInfoRef>>,
|
||||
#[builder(setter(custom))]
|
||||
timezone: ArcSwap<Timezone>,
|
||||
// we use Arc<RwLock>> for modifiable fields
|
||||
#[builder(default)]
|
||||
mutable_inner: Arc<RwLock<MutableInner>>,
|
||||
sql_dialect: Arc<dyn Dialect + Send + Sync>,
|
||||
#[builder(default)]
|
||||
extensions: HashMap<String, String>,
|
||||
@@ -51,18 +49,6 @@ pub struct QueryContext {
|
||||
configuration_parameter: Arc<ConfigurationVariables>,
|
||||
}
|
||||
|
||||
impl QueryContextBuilder {
|
||||
pub fn timezone(mut self, tz: Arc<Timezone>) -> Self {
|
||||
self.timezone = Some(ArcSwap::new(tz));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn current_schema(mut self, schema: String) -> Self {
|
||||
self.current_schema = Some(ArcSwap::new(Arc::new(schema)));
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for QueryContext {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
@@ -74,17 +60,29 @@ impl Display for QueryContext {
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for QueryContext {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
current_catalog: self.current_catalog.clone(),
|
||||
current_schema: ArcSwap::new(self.current_schema.load().clone()),
|
||||
current_user: self.current_user.load().clone().into(),
|
||||
timezone: self.timezone.load().clone().into(),
|
||||
sql_dialect: self.sql_dialect.clone(),
|
||||
extensions: self.extensions.clone(),
|
||||
configuration_parameter: self.configuration_parameter.clone(),
|
||||
impl QueryContextBuilder {
|
||||
pub fn current_schema(mut self, schema: String) -> Self {
|
||||
if self.mutable_inner.is_none() {
|
||||
self.mutable_inner = Some(Arc::new(RwLock::new(MutableInner::default())));
|
||||
}
|
||||
|
||||
// safe for unwrap because previous none check
|
||||
self.mutable_inner.as_mut().unwrap().write().unwrap().schema = schema;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn timezone(mut self, timezone: Timezone) -> Self {
|
||||
if self.mutable_inner.is_none() {
|
||||
self.mutable_inner = Some(Arc::new(RwLock::new(MutableInner::default())));
|
||||
}
|
||||
|
||||
self.mutable_inner
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.write()
|
||||
.unwrap()
|
||||
.timezone = timezone;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +93,7 @@ impl From<&RegionRequestHeader> for QueryContext {
|
||||
builder = builder
|
||||
.current_catalog(ctx.current_catalog.clone())
|
||||
.current_schema(ctx.current_schema.clone())
|
||||
.timezone(Arc::new(parse_timezone(Some(&ctx.timezone))))
|
||||
.timezone(parse_timezone(Some(&ctx.timezone)))
|
||||
.extensions(ctx.extensions.clone());
|
||||
}
|
||||
builder.build()
|
||||
@@ -107,7 +105,7 @@ impl From<api::v1::QueryContext> for QueryContext {
|
||||
QueryContextBuilder::default()
|
||||
.current_catalog(ctx.current_catalog)
|
||||
.current_schema(ctx.current_schema)
|
||||
.timezone(Arc::new(parse_timezone(Some(&ctx.timezone))))
|
||||
.timezone(parse_timezone(Some(&ctx.timezone)))
|
||||
.extensions(ctx.extensions)
|
||||
.build()
|
||||
}
|
||||
@@ -117,16 +115,16 @@ impl From<QueryContext> for api::v1::QueryContext {
|
||||
fn from(
|
||||
QueryContext {
|
||||
current_catalog,
|
||||
current_schema,
|
||||
timezone,
|
||||
mutable_inner,
|
||||
extensions,
|
||||
..
|
||||
}: QueryContext,
|
||||
) -> Self {
|
||||
let mutable_inner = mutable_inner.read().unwrap();
|
||||
api::v1::QueryContext {
|
||||
current_catalog,
|
||||
current_schema: current_schema.load().to_string(),
|
||||
timezone: timezone.to_string(),
|
||||
current_schema: mutable_inner.schema.clone(),
|
||||
timezone: mutable_inner.timezone.to_string(),
|
||||
extensions,
|
||||
}
|
||||
}
|
||||
@@ -163,11 +161,11 @@ impl QueryContext {
|
||||
}
|
||||
|
||||
pub fn current_schema(&self) -> String {
|
||||
self.current_schema.load().as_ref().clone()
|
||||
self.mutable_inner.read().unwrap().schema.clone()
|
||||
}
|
||||
|
||||
pub fn set_current_schema(&self, new_schema: &str) {
|
||||
let _ = self.current_schema.swap(Arc::new(new_schema.to_string()));
|
||||
self.mutable_inner.write().unwrap().schema = new_schema.to_string();
|
||||
}
|
||||
|
||||
pub fn current_catalog(&self) -> &str {
|
||||
@@ -184,20 +182,20 @@ impl QueryContext {
|
||||
build_db_string(catalog, &schema)
|
||||
}
|
||||
|
||||
pub fn timezone(&self) -> Arc<Timezone> {
|
||||
self.timezone.load().clone()
|
||||
}
|
||||
|
||||
pub fn current_user(&self) -> Option<UserInfoRef> {
|
||||
self.current_user.load().as_ref().clone()
|
||||
}
|
||||
|
||||
pub fn set_current_user(&self, user: Option<UserInfoRef>) {
|
||||
let _ = self.current_user.swap(Arc::new(user));
|
||||
pub fn timezone(&self) -> Timezone {
|
||||
self.mutable_inner.read().unwrap().timezone.clone()
|
||||
}
|
||||
|
||||
pub fn set_timezone(&self, timezone: Timezone) {
|
||||
let _ = self.timezone.swap(Arc::new(timezone));
|
||||
self.mutable_inner.write().unwrap().timezone = timezone;
|
||||
}
|
||||
|
||||
pub fn current_user(&self) -> UserInfoRef {
|
||||
self.mutable_inner.read().unwrap().user_info.clone()
|
||||
}
|
||||
|
||||
pub fn set_current_user(&self, user: UserInfoRef) {
|
||||
self.mutable_inner.write().unwrap().user_info = user;
|
||||
}
|
||||
|
||||
pub fn set_extension<S1: Into<String>, S2: Into<String>>(&mut self, key: S1, value: S2) {
|
||||
@@ -212,23 +210,6 @@ impl QueryContext {
|
||||
self.extensions.clone()
|
||||
}
|
||||
|
||||
/// SQL like `set variable`, `use <database>` may change timezone or other
|
||||
/// info in `QueryContext`.
|
||||
/// We need persist these change in `Session`.
|
||||
pub fn update_session(&self, session: &SessionRef) {
|
||||
// update timezone for session
|
||||
let tz = self.timezone();
|
||||
if *session.timezone() != *tz {
|
||||
session.set_timezone(tz.as_ref().clone())
|
||||
}
|
||||
|
||||
// update current schema for session
|
||||
let schema = self.current_schema();
|
||||
if *session.schema() != *schema {
|
||||
session.set_schema(schema)
|
||||
}
|
||||
}
|
||||
|
||||
/// Default to double quote and fallback to back quote
|
||||
pub fn quote_style(&self) -> char {
|
||||
if self.sql_dialect().is_delimited_identifier_start('"') {
|
||||
@@ -251,15 +232,7 @@ impl QueryContextBuilder {
|
||||
current_catalog: self
|
||||
.current_catalog
|
||||
.unwrap_or_else(|| DEFAULT_CATALOG_NAME.to_string()),
|
||||
current_schema: self
|
||||
.current_schema
|
||||
.unwrap_or_else(|| ArcSwap::new(Arc::new(DEFAULT_SCHEMA_NAME.to_string()))),
|
||||
current_user: self
|
||||
.current_user
|
||||
.unwrap_or_else(|| ArcSwap::new(Arc::new(None))),
|
||||
timezone: self
|
||||
.timezone
|
||||
.unwrap_or(ArcSwap::new(Arc::new(get_timezone(None).clone()))),
|
||||
mutable_inner: self.mutable_inner.unwrap_or_default(),
|
||||
sql_dialect: self
|
||||
.sql_dialect
|
||||
.unwrap_or_else(|| Arc::new(GreptimeDbDialect {})),
|
||||
@@ -278,9 +251,8 @@ impl QueryContextBuilder {
|
||||
pub fn from_existing(context: &QueryContext) -> QueryContextBuilder {
|
||||
QueryContextBuilder {
|
||||
current_catalog: Some(context.current_catalog.clone()),
|
||||
current_schema: Some(context.current_schema.load().clone().into()),
|
||||
current_user: Some(context.current_user.load().clone().into()),
|
||||
timezone: Some(context.timezone.load().clone().into()),
|
||||
// note that this is a shallow copy
|
||||
mutable_inner: Some(context.mutable_inner.clone()),
|
||||
sql_dialect: Some(context.sql_dialect.clone()),
|
||||
extensions: Some(context.extensions.clone()),
|
||||
configuration_parameter: Some(context.configuration_parameter.clone()),
|
||||
|
||||
@@ -17,9 +17,8 @@ pub mod session_config;
|
||||
pub mod table_name;
|
||||
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use arc_swap::ArcSwap;
|
||||
use auth::UserInfoRef;
|
||||
use common_catalog::build_db_string;
|
||||
use common_catalog::consts::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME};
|
||||
@@ -32,16 +31,32 @@ use crate::context::{Channel, ConnInfo, QueryContextRef};
|
||||
/// Session for persistent connection such as MySQL, PostgreSQL etc.
|
||||
#[derive(Debug)]
|
||||
pub struct Session {
|
||||
catalog: ArcSwap<String>,
|
||||
schema: ArcSwap<String>,
|
||||
user_info: ArcSwap<UserInfoRef>,
|
||||
catalog: RwLock<String>,
|
||||
mutable_inner: Arc<RwLock<MutableInner>>,
|
||||
conn_info: ConnInfo,
|
||||
timezone: ArcSwap<Timezone>,
|
||||
configuration_variables: Arc<ConfigurationVariables>,
|
||||
}
|
||||
|
||||
pub type SessionRef = Arc<Session>;
|
||||
|
||||
/// A container for mutable items in query context
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct MutableInner {
|
||||
schema: String,
|
||||
user_info: UserInfoRef,
|
||||
timezone: Timezone,
|
||||
}
|
||||
|
||||
impl Default for MutableInner {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
schema: DEFAULT_SCHEMA_NAME.into(),
|
||||
user_info: auth::userinfo_by_name(None),
|
||||
timezone: get_timezone(None).clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Session {
|
||||
pub fn new(
|
||||
addr: Option<SocketAddr>,
|
||||
@@ -49,80 +64,67 @@ impl Session {
|
||||
configuration_variables: ConfigurationVariables,
|
||||
) -> Self {
|
||||
Session {
|
||||
catalog: ArcSwap::new(Arc::new(DEFAULT_CATALOG_NAME.into())),
|
||||
schema: ArcSwap::new(Arc::new(DEFAULT_SCHEMA_NAME.into())),
|
||||
user_info: ArcSwap::new(Arc::new(auth::userinfo_by_name(None))),
|
||||
catalog: RwLock::new(DEFAULT_CATALOG_NAME.into()),
|
||||
conn_info: ConnInfo::new(addr, channel),
|
||||
timezone: ArcSwap::new(Arc::new(get_timezone(None).clone())),
|
||||
configuration_variables: Arc::new(configuration_variables),
|
||||
mutable_inner: Arc::new(RwLock::new(MutableInner::default())),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn new_query_context(&self) -> QueryContextRef {
|
||||
QueryContextBuilder::default()
|
||||
.current_user(ArcSwap::new(Arc::new(Some(
|
||||
self.user_info.load().as_ref().clone(),
|
||||
))))
|
||||
.current_catalog(self.catalog.load().to_string())
|
||||
.current_schema(self.schema.load().to_string())
|
||||
// catalog is not allowed for update in query context so we use
|
||||
// string here
|
||||
.current_catalog(self.catalog.read().unwrap().clone())
|
||||
.mutable_inner(self.mutable_inner.clone())
|
||||
.sql_dialect(self.conn_info.channel.dialect())
|
||||
.configuration_parameter(self.configuration_variables.clone())
|
||||
.timezone(self.timezone())
|
||||
.build()
|
||||
.into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn conn_info(&self) -> &ConnInfo {
|
||||
&self.conn_info
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn mut_conn_info(&mut self) -> &mut ConnInfo {
|
||||
&mut self.conn_info
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn timezone(&self) -> Arc<Timezone> {
|
||||
self.timezone.load().clone()
|
||||
pub fn timezone(&self) -> Timezone {
|
||||
self.mutable_inner.read().unwrap().timezone.clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_timezone(&self, tz: Timezone) {
|
||||
let _ = self.timezone.swap(Arc::new(tz));
|
||||
let mut inner = self.mutable_inner.write().unwrap();
|
||||
inner.timezone = tz;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn user_info(&self) -> UserInfoRef {
|
||||
self.user_info.load().clone().as_ref().clone()
|
||||
self.mutable_inner.read().unwrap().user_info.clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_user_info(&self, user_info: UserInfoRef) {
|
||||
self.user_info.store(Arc::new(user_info));
|
||||
self.mutable_inner.write().unwrap().user_info = user_info;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_catalog(&self, catalog: String) {
|
||||
self.catalog.store(Arc::new(catalog));
|
||||
*self.catalog.write().unwrap() = catalog;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn catalog(&self) -> String {
|
||||
self.catalog.load().as_ref().clone()
|
||||
self.catalog.read().unwrap().clone()
|
||||
}
|
||||
|
||||
pub fn schema(&self) -> String {
|
||||
self.schema.load().as_ref().clone()
|
||||
self.mutable_inner.read().unwrap().schema.clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_schema(&self, schema: String) {
|
||||
self.schema.store(Arc::new(schema));
|
||||
self.mutable_inner.write().unwrap().schema = schema;
|
||||
}
|
||||
|
||||
pub fn get_db_string(&self) -> String {
|
||||
build_db_string(self.catalog.load().as_ref(), self.schema.load().as_ref())
|
||||
build_db_string(&self.catalog(), &self.schema())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user