From f5a9b738735784a9131a213521b2a8c854ca0dc0 Mon Sep 17 00:00:00 2001 From: Kelvin Wu Date: Fri, 3 May 2024 00:19:47 +0800 Subject: [PATCH] refactor: change the return type of build() in QueryContextBuilder --- Cargo.lock | 342 +++++++++--------- src/cmd/src/cli/repl.rs | 5 +- src/common/function/src/function.rs | 4 +- src/common/function/src/scalars/udf.rs | 2 +- src/common/function/src/system/database.rs | 3 +- src/common/function/src/system/timezone.rs | 2 +- src/datanode/src/region_server.rs | 2 +- src/operator/src/expr_factory.rs | 6 +- src/operator/src/statement.rs | 3 +- src/operator/src/statement/ddl.rs | 2 +- src/query/src/dist_plan/merge_scan.rs | 4 +- src/query/src/query_engine/options.rs | 4 +- src/query/src/sql.rs | 8 +- src/script/src/python/ffi_types/copr.rs | 2 +- src/script/src/table.rs | 1 + src/servers/src/export_metrics.rs | 3 +- src/servers/src/grpc/greptime_handler.rs | 1 + src/servers/src/http/authorize.rs | 2 +- src/servers/src/http/prometheus.rs | 11 +- src/servers/src/http/script.rs | 5 +- src/servers/src/postgres/types.rs | 3 +- src/servers/tests/py_script/mod.rs | 10 +- src/session/src/context.rs | 57 ++- src/session/src/lib.rs | 1 + tests-integration/src/otlp.rs | 2 +- tests-integration/src/prom_store.rs | 2 +- .../src/tests/instance_kafka_wal_test.rs | 20 +- tests-integration/src/tests/instance_test.rs | 10 +- tests-integration/src/tests/promql_test.rs | 6 +- 29 files changed, 272 insertions(+), 251 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 284dcaa4c10e..16f5e1a3398b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -334,7 +334,7 @@ dependencies = [ "chrono", "chrono-tz", "half 2.4.1", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "num", ] @@ -361,7 +361,7 @@ dependencies = [ "arrow-schema", "arrow-select", "atoi 2.0.0", - "base64 0.22.0", + "base64 0.22.1", "chrono", "comfy-table", "half 2.4.1", @@ -412,7 +412,7 @@ dependencies = [ "arrow-cast", "arrow-ipc", "arrow-schema", - "base64 0.22.0", + "base64 0.22.1", "bytes", "futures", "paste", @@ -484,7 +484,7 @@ dependencies = [ "arrow-data", "arrow-schema", "half 2.4.1", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -574,11 +574,11 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07dbbf24db18d609b1462965249abdf49129ccad073ec257da372adc83259c60" +checksum = "4e9eabd7a98fe442131a17c316bd9349c43695e49e730c3c8e12cfb5f4da2693" dependencies = [ - "brotli 4.0.0", + "brotli 5.0.0", "bzip2", "flate2", "futures-core", @@ -604,9 +604,9 @@ dependencies = [ [[package]] name = "async-recursion" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c5ef0ede93efbf733c1a727f3b6b5a1060bbedd5600183e66f6e4be4af0ec5" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", @@ -848,9 +848,9 @@ checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" @@ -1026,9 +1026,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0901fc8eb0aca4c83be0106d6f2db17d86a08dfc2c25f0e84464bf381158add6" +checksum = "dbe5b10e214954177fb1dc9fbd20a1a2608fe99e6c832033bdc7cea287a20d77" dependencies = [ "borsh-derive", "cfg_aliases", @@ -1036,9 +1036,9 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51670c3aa053938b0ee3bd67c3817e471e626151131b934038e83c5bf8de48f5" +checksum = "d7a8646f94ab393e43e8b35a2558b1624bed28b97ee09c5d15456e3c9463f46d" dependencies = [ "once_cell", "proc-macro-crate 3.1.0", @@ -1061,13 +1061,13 @@ dependencies = [ [[package]] name = "brotli" -version = "4.0.0" +version = "5.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125740193d7fee5cc63ab9e16c2fdc4e07c74ba755cc53b327d6ea029e9fc569" +checksum = "19483b140a7ac7174d34b5a581b406c64f84da5409d3e09cf4fff604f9270e67" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", - "brotli-decompressor 3.0.0", + "brotli-decompressor 4.0.0", ] [[package]] @@ -1082,9 +1082,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "3.0.0" +version = "4.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65622a320492e09b5e0ac436b14c54ff68199bac392d0e89a6832c4518eea525" +checksum = "e6221fe77a248b9117d431ad93761222e1cf8ff282d9d1d5d9f53d6299a1cf76" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1290,12 +1290,13 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.94" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f6e324229dc011159fcc089755d1e2e216a90d43a7dea6853ca740b84f35e7" +checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] @@ -1542,7 +1543,7 @@ dependencies = [ "futures-util", "lazy_static", "moka", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "prometheus", "prost 0.12.4", "rand", @@ -2064,7 +2065,7 @@ dependencies = [ "opentelemetry-otlp", "opentelemetry-semantic-conventions", "opentelemetry_sdk 0.21.2", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "prometheus", "serde", "serde_json", @@ -2134,9 +2135,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] @@ -2532,17 +2533,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" dependencies = [ "cfg-if 1.0.0", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core 0.9.9", + "parking_lot_core 0.9.10", ] [[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "datafusion" @@ -2554,7 +2555,7 @@ dependencies = [ "arrow-array", "arrow-ipc", "arrow-schema", - "async-compression 0.4.8", + "async-compression 0.4.9", "async-trait", "bytes", "bzip2", @@ -2575,13 +2576,13 @@ dependencies = [ "futures", "glob", "half 2.4.1", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "indexmap 2.2.6", "itertools 0.12.1", "log", "num_cpus", "object_store", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "parquet", "pin-project-lite", "rand", @@ -2634,10 +2635,10 @@ dependencies = [ "datafusion-common", "datafusion-expr", "futures", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "log", "object_store", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "rand", "tempfile", "url", @@ -2666,7 +2667,7 @@ version = "37.0.0" source = "git+https://github.com/apache/arrow-datafusion.git?rev=34eda15b73a9e278af8844b30ed2f1c21c10359c#34eda15b73a9e278af8844b30ed2f1c21c10359c" dependencies = [ "arrow", - "base64 0.22.0", + "base64 0.22.1", "blake2", "blake3", "chrono", @@ -2674,7 +2675,7 @@ dependencies = [ "datafusion-execution", "datafusion-expr", "datafusion-physical-expr", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "hex", "itertools 0.12.1", "log", @@ -2730,7 +2731,7 @@ dependencies = [ "datafusion-common", "datafusion-expr", "datafusion-physical-expr", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "itertools 0.12.1", "log", "regex-syntax 0.8.3", @@ -2748,7 +2749,7 @@ dependencies = [ "arrow-ord", "arrow-schema", "arrow-string", - "base64 0.22.0", + "base64 0.22.1", "chrono", "datafusion-common", "datafusion-execution", @@ -2756,7 +2757,7 @@ dependencies = [ "datafusion-functions-aggregate", "datafusion-physical-expr-common", "half 2.4.1", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "hex", "indexmap 2.2.6", "itertools 0.12.1", @@ -2798,12 +2799,12 @@ dependencies = [ "datafusion-physical-expr-common", "futures", "half 2.4.1", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "indexmap 2.2.6", "itertools 0.12.1", "log", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "pin-project-lite", "rand", "tokio", @@ -3240,9 +3241,9 @@ dependencies = [ [[package]] name = "enum-iterator-derive" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03cdc46ec28bd728e67540c528013c6a10eb69a02eb31078a1bda695438cbfb8" +checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", @@ -3380,9 +3381,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fastrand" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fd-lock" @@ -3391,7 +3392,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if 1.0.0", - "rustix 0.38.32", + "rustix 0.38.34", "windows-sys 0.48.0", ] @@ -3479,9 +3480,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", "libz-sys", @@ -3958,9 +3959,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" dependencies = [ "ahash 0.8.11", "allocator-api2", @@ -3972,7 +3973,7 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -4282,7 +4283,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tower-service", "tracing", @@ -4298,7 +4299,7 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls 0.21.10", + "rustls 0.21.12", "tokio", "tokio-rustls 0.24.1", ] @@ -4424,7 +4425,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" dependencies = [ "equivalent", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "serde", ] @@ -4837,9 +4838,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libfuzzer-sys" @@ -4943,9 +4944,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" dependencies = [ "autocfg", "scopeguard", @@ -5051,7 +5052,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -5302,7 +5303,7 @@ dependencies = [ "itertools 0.10.5", "lazy_static", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "prometheus", "prost 0.12.4", "rand", @@ -5332,7 +5333,7 @@ source = "git+https://github.com/GreptimeTeam/greptime-meter.git?rev=80b72716dcd dependencies = [ "anymap", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", ] [[package]] @@ -5507,9 +5508,9 @@ dependencies = [ [[package]] name = "moka" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87bfd249f570638bfb0b4f9d258e6b8cddd2a5a7d0ed47e8bb8b176bfc0e7a17" +checksum = "9e0d88686dc561d743b40de8269b26eaf0dc58781bde087b0984646602021d08" dependencies = [ "async-lock", "async-trait", @@ -5519,7 +5520,7 @@ dependencies = [ "event-listener 5.3.0", "futures-util", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "quanta", "rustc_version", "smallvec", @@ -5614,11 +5615,11 @@ dependencies = [ "percent-encoding", "pin-project", "rand", - "rustls 0.21.10", + "rustls 0.21.12", "rustls-pemfile 1.0.4", "serde", "serde_json", - "socket2 0.5.6", + "socket2 0.5.7", "thiserror", "tokio", "tokio-rustls 0.24.1", @@ -6067,7 +6068,7 @@ dependencies = [ "futures", "humantime", "itertools 0.12.1", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "percent-encoding", "snafu", "tokio", @@ -6402,7 +6403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" dependencies = [ "dlv-list 0.5.2", - "hashbrown 0.14.3", + "hashbrown 0.14.5", ] [[package]] @@ -6476,12 +6477,12 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" dependencies = [ "lock_api", - "parking_lot_core 0.9.9", + "parking_lot_core 0.9.10", ] [[package]] @@ -6500,18 +6501,18 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" dependencies = [ "backtrace", "cfg-if 1.0.0", "libc", "petgraph", - "redox_syscall 0.4.1", + "redox_syscall 0.5.1", "smallvec", "thread-id", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] @@ -6528,14 +6529,14 @@ dependencies = [ "arrow-ipc", "arrow-schema", "arrow-select", - "base64 0.22.0", + "base64 0.22.1", "brotli 3.5.0", "bytes", "chrono", "flate2", "futures", "half 2.4.1", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "lz4_flex 0.11.3", "num", "num-bigint", @@ -6615,7 +6616,7 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "serde", ] @@ -6651,9 +6652,9 @@ checksum = "df202b0b0f5b8e389955afd5f27b007b00fb948162953f1db9c70d2c7e3157d7" [[package]] name = "pest" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "311fb059dee1a7b802f036316d790138c613a4e8b180c822e3925a662e9f0c95" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" dependencies = [ "memchr", "thiserror", @@ -6662,9 +6663,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73541b156d32197eecda1a4014d7f868fd2bcb3c550d5386087cfba442bf69c" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" dependencies = [ "pest", "pest_generator", @@ -6672,9 +6673,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35eeed0a3fab112f75165fdc026b3913f4183133f19b49be773ac9ea966e8bd" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", @@ -6685,9 +6686,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.9" +version = "2.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2adbf29bb9776f28caece835398781ab24435585fe0d4dc1374a61db5accedca" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" dependencies = [ "once_cell", "pest", @@ -6711,7 +6712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c00492c52bb65e0421211b7f4c5d9de7586e53786a3b244efb00f74851206bf6" dependencies = [ "async-trait", - "base64 0.22.0", + "base64 0.22.1", "bytes", "chrono", "derive-new 0.6.0", @@ -6984,7 +6985,7 @@ dependencies = [ "log", "nix 0.26.4", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "prost 0.12.4", "prost-build 0.12.4", "prost-derive 0.12.4", @@ -7144,7 +7145,7 @@ dependencies = [ "lazy_static", "libc", "memchr", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "procfs", "protobuf", "thiserror", @@ -7418,7 +7419,7 @@ dependencies = [ "indoc", "libc", "memoffset 0.9.1", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -7597,16 +7598,16 @@ dependencies = [ [[package]] name = "raft-engine" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bc58d7f3a865d3224bad461e5fbe386b799b2b7eabea43e1da6f11ac725d83f" +checksum = "1213c3a24e3fee8afcc74b2be08c4081adde96f092e0fc1c607abb3e16ae722e" dependencies = [ "byteorder", "crc32fast", "crossbeam", "fail", "fs2", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "hex", "if_chain", "lazy_static", @@ -7616,7 +7617,7 @@ dependencies = [ "nix 0.26.4", "num-derive", "num-traits", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "prometheus", "prometheus-static-metric", "protobuf", @@ -7672,9 +7673,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.0.1" +version = "11.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" +checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd" dependencies = [ "bitflags 2.5.0", ] @@ -7729,6 +7730,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +dependencies = [ + "bitflags 2.5.0", +] + [[package]] name = "redox_users" version = "0.4.5" @@ -7820,7 +7830,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4f5f39ba4513916c1b2657b72af6ec671f091cd637992f58d0ede5cae4e5dea0" dependencies = [ - "hashbrown 0.14.3", + "hashbrown 0.14.5", "memchr", ] @@ -7888,7 +7898,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.10", + "rustls 0.21.12", "rustls-native-certs", "rustls-pemfile 1.0.4", "serde", @@ -8077,7 +8087,7 @@ dependencies = [ "futures", "integer-encoding 4.0.0", "lz4", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "pin-project-lite", "rand", "snap", @@ -8281,9 +8291,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.32" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.5.0", "errno", @@ -8306,9 +8316,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.10" +version = "0.21.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" dependencies = [ "log", "ring 0.17.8", @@ -8325,7 +8335,7 @@ dependencies = [ "log", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.2", + "rustls-webpki 0.102.3", "subtle", "zeroize", ] @@ -8357,15 +8367,15 @@ version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" dependencies = [ - "base64 0.22.0", + "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd36cc4259e3e4514335c4a138c6b43171a8d61d8f5c9348f9fc7529416f247" +checksum = "beb461507cee2c2ff151784c52762cf4d9ff6a61f3e80968600ed24fa837fa54" [[package]] name = "rustls-webpki" @@ -8379,9 +8389,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.102.2" +version = "0.102.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faaa0a62740bedb9b2ef5afa303da42764c012f743917351dc9a237ea1663610" +checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" dependencies = [ "ring 0.17.8", "rustls-pki-types", @@ -8570,7 +8580,7 @@ dependencies = [ "num_enum", "once_cell", "page_size", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "paste", "puruspe", "rand", @@ -8636,7 +8646,7 @@ dependencies = [ "num_enum", "once_cell", "optional", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "paste", "rand", "result-like", @@ -8826,9 +8836,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45a28f4c49489add4ce10783f7911893516f15afe45d015608d41faca6bc4d29" +checksum = "7f55c82c700538496bdc329bb4918a81f87cc8888811bd123cf325a0f2f8d309" dependencies = [ "dyn-clone", "indexmap 1.9.3", @@ -8839,14 +8849,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.16" +version = "0.8.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c767fd6fa65d9ccf9cf026122c1b555f2ef9a4f0cea69da4d7dbc3e258d30967" +checksum = "83263746fe5e32097f06356968a077f96089739c927a61450efa069905eec108" dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] @@ -8987,18 +8997,18 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.198" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9846a40c979031340571da2545a4e5b7c4163bdae79b301d5f86d03979451fcc" +checksum = "ddc6f9cc94d67c0e21aaf7eda3a010fd3af78ebf6e096aa6e2e13c79749cce4f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.198" +version = "1.0.200" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88edab869b01783ba905e7d0153f9fc1a6505a96e4ad3018011eedb838566d9" +checksum = "856f046b9400cee3c8c94ed572ecdb752444c24528c035cd35882aad6f492bcb" dependencies = [ "proc-macro2", "quote", @@ -9007,13 +9017,13 @@ dependencies = [ [[package]] name = "serde_derive_internals" -version = "0.26.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.60", ] [[package]] @@ -9084,11 +9094,11 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee80b0e361bbf88fd2f6e242ccd19cfda072cb0faa6ae694ecee08199938569a" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", @@ -9102,9 +9112,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.7.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6561dc161a9224638a31d876ccdfefbc1df91d3f3a8342eddb35f055d48c7655" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ "darling 0.20.8", "proc-macro2", @@ -9167,7 +9177,7 @@ dependencies = [ "datatypes", "derive_builder 0.12.0", "futures", - "hashbrown 0.14.3", + "hashbrown 0.14.5", "headers", "hostname", "http", @@ -9185,7 +9195,7 @@ dependencies = [ "openmetrics-parser", "opensrv-mysql", "opentelemetry-proto 0.5.0", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "permutation", "pgwire", "pin-project", @@ -9306,9 +9316,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.1" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] @@ -9434,9 +9444,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" dependencies = [ "libc", "windows-sys 0.52.0", @@ -9819,7 +9829,7 @@ checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "phf_shared 0.10.0", "precomputed-hash", ] @@ -10083,9 +10093,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sysinfo" -version = "0.30.10" +version = "0.30.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d7c217777061d5a2d652aea771fb9ba98b6dade657204b08c4b9604d11555b" +checksum = "87341a165d73787554941cd5ef55ad728011566fe714e987d1b976c15dbc3a83" dependencies = [ "cfg-if 1.0.0", "core-foundation-sys", @@ -10176,7 +10186,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96374855068f47402c3121c6eed88d29cb1de8f3ab27090e273e420bdabcf050" dependencies = [ - "parking_lot 0.12.1", + "parking_lot 0.12.2", ] [[package]] @@ -10187,7 +10197,7 @@ checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if 1.0.0", "fastrand", - "rustix 0.38.32", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -10352,18 +10362,18 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66" dependencies = [ "proc-macro2", "quote", @@ -10526,10 +10536,10 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.6", + "socket2 0.5.7", "tokio-macros", "tracing", "windows-sys 0.48.0", @@ -10575,7 +10585,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d767da47381602cc481653456823b3ebb600e83d5dd4e0293da9b5566c6c00f0" dependencies = [ "lazy_static", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "prometheus", "tokio", "tokio-metrics", @@ -10594,14 +10604,14 @@ dependencies = [ "futures-channel", "futures-util", "log", - "parking_lot 0.12.1", + "parking_lot 0.12.2", "percent-encoding", "phf", "pin-project-lite", "postgres-protocol", "postgres-types", "rand", - "socket2 0.5.6", + "socket2 0.5.7", "tokio", "tokio-util", "whoami", @@ -10639,7 +10649,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.10", + "rustls 0.21.12", "tokio", ] @@ -10712,7 +10722,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.9", + "toml_edit 0.22.12", ] [[package]] @@ -10748,15 +10758,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.9" +version = "0.22.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" +checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" dependencies = [ "indexmap 2.2.6", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.6", + "winnow 0.6.7", ] [[package]] @@ -10896,7 +10906,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "async-compression 0.4.8", + "async-compression 0.4.9", "base64 0.21.7", "bitflags 2.5.0", "bytes", @@ -11173,7 +11183,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "rand", "static_assertions", ] @@ -11477,9 +11487,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "unicode-xid" @@ -11823,7 +11833,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.32", + "rustix 0.38.34", ] [[package]] @@ -11839,9 +11849,9 @@ dependencies = [ [[package]] name = "wide" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a1851a719f11d1d2fea40e15c72f6c00de8c142d7ac47c1441cc7e4d0d5bc6" +checksum = "0f0e39d2c603fdc0504b12b458cf1f34e0b937ed2f4f2dc20796e3e86f34e11f" dependencies = [ "bytemuck", "safe_arch", @@ -11871,11 +11881,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "winapi", + "windows-sys 0.52.0", ] [[package]] @@ -12162,9 +12172,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352" +checksum = "14b9415ee827af173ebb3f15f9083df5a122eb93572ec28741fb153356ea2578" dependencies = [ "memchr", ] diff --git a/src/cmd/src/cli/repl.rs b/src/cmd/src/cli/repl.rs index b13bb776f856..6759a923fc43 100644 --- a/src/cmd/src/cli/repl.rs +++ b/src/cmd/src/cli/repl.rs @@ -161,7 +161,10 @@ impl Repl { let start = Instant::now(); let output = if let Some(query_engine) = &self.query_engine { - let query_ctx = QueryContext::with(self.database.catalog(), self.database.schema()); + let query_ctx = Arc::new(QueryContext::with( + self.database.catalog(), + self.database.schema(), + )); let stmt = QueryLanguageParser::parse_sql(&sql, &query_ctx) .with_context(|_| ParseSqlSnafu { sql: sql.clone() })?; diff --git a/src/common/function/src/function.rs b/src/common/function/src/function.rs index 8da7f344bbc3..433f54b6ce7d 100644 --- a/src/common/function/src/function.rs +++ b/src/common/function/src/function.rs @@ -35,7 +35,7 @@ impl FunctionContext { #[cfg(any(test, feature = "testing"))] pub fn mock() -> Self { Self { - query_ctx: QueryContextBuilder::default().build(), + query_ctx: QueryContextBuilder::default().build().into(), state: Arc::new(FunctionState::mock()), } } @@ -44,7 +44,7 @@ impl FunctionContext { impl Default for FunctionContext { fn default() -> Self { Self { - query_ctx: QueryContextBuilder::default().build(), + query_ctx: QueryContextBuilder::default().build().into(), state: Arc::new(FunctionState::default()), } } diff --git a/src/common/function/src/scalars/udf.rs b/src/common/function/src/scalars/udf.rs index 0f34fbcfaa59..593162e4abdc 100644 --- a/src/common/function/src/scalars/udf.rs +++ b/src/common/function/src/scalars/udf.rs @@ -89,7 +89,7 @@ mod tests { #[test] fn test_create_udf() { let f = Arc::new(TestAndFunction); - let query_ctx = QueryContextBuilder::default().build(); + let query_ctx = QueryContextBuilder::default().build().into(); let args: Vec = vec![ Arc::new(ConstantVector::new( diff --git a/src/common/function/src/system/database.rs b/src/common/function/src/system/database.rs index 2efe8bb8e94f..11dbb2da143b 100644 --- a/src/common/function/src/system/database.rs +++ b/src/common/function/src/system/database.rs @@ -79,7 +79,8 @@ mod tests { let query_ctx = QueryContextBuilder::default() .current_schema("test_db".to_string()) - .build(); + .build() + .into(); let func_ctx = FunctionContext { query_ctx, diff --git a/src/common/function/src/system/timezone.rs b/src/common/function/src/system/timezone.rs index 4a85e3956341..f9c824ab33a2 100644 --- a/src/common/function/src/system/timezone.rs +++ b/src/common/function/src/system/timezone.rs @@ -77,7 +77,7 @@ mod tests { } if valid_types == vec![] )); - let query_ctx = QueryContextBuilder::default().build(); + let query_ctx = QueryContextBuilder::default().build().into(); let func_ctx = FunctionContext { query_ctx, diff --git a/src/datanode/src/region_server.rs b/src/datanode/src/region_server.rs index 23d21200af30..440f0a3d036d 100644 --- a/src/datanode/src/region_server.rs +++ b/src/datanode/src/region_server.rs @@ -613,7 +613,7 @@ impl RegionServerInner { let ctx: QueryContextRef = header .as_ref() .map(|h| Arc::new(h.into())) - .unwrap_or_else(|| QueryContextBuilder::default().build()); + .unwrap_or_else(|| QueryContextBuilder::default().build().into()); // build dummy catalog list let region_status = self diff --git a/src/operator/src/expr_factory.rs b/src/operator/src/expr_factory.rs index 17782c3addac..91c374889e57 100644 --- a/src/operator/src/expr_factory.rs +++ b/src/operator/src/expr_factory.rs @@ -658,7 +658,8 @@ mod tests { // query context with timezone `+08:00` let ctx = QueryContextBuilder::default() .timezone(Timezone::from_tz_string("+08:00").unwrap().into()) - .build(); + .build() + .into(); let expr = create_to_expr(&create_table, ctx).unwrap(); let ts_column = &expr.column_defs[1]; let constraint = assert_ts_column(ts_column); @@ -712,7 +713,8 @@ mod tests { // query context with timezone `+08:00` let ctx = QueryContextBuilder::default() .timezone(Timezone::from_tz_string("+08:00").unwrap().into()) - .build(); + .build() + .into(); let expr = to_alter_expr(alter_table, ctx).unwrap(); let kind = expr.kind.unwrap(); diff --git a/src/operator/src/statement.rs b/src/operator/src/statement.rs index a7a1cd52926d..ad1e3de80201 100644 --- a/src/operator/src/statement.rs +++ b/src/operator/src/statement.rs @@ -422,7 +422,8 @@ mod tests { fn check_timestamp_range((start, end): (&str, &str)) -> error::Result> { let query_ctx = QueryContextBuilder::default() .timezone(Arc::new(Timezone::from_tz_string("Asia/Shanghai").unwrap())) - .build(); + .build() + .into(); let map = OptionMap::from( [ (COPY_DATABASE_TIME_START_KEY.to_string(), start.to_string()), diff --git a/src/operator/src/statement/ddl.rs b/src/operator/src/statement/ddl.rs index cf908611f52a..767b443eb465 100644 --- a/src/operator/src/statement/ddl.rs +++ b/src/operator/src/statement/ddl.rs @@ -1089,7 +1089,7 @@ ENGINE=mito", r#"[{"column_list":["b","a"],"value_list":["{\"Value\":{\"String\":\"hz\"}}","{\"Value\":{\"Int32\":10}}"]},{"column_list":["b","a"],"value_list":["{\"Value\":{\"String\":\"sh\"}}","{\"Value\":{\"Int32\":20}}"]},{"column_list":["b","a"],"value_list":["\"MaxValue\"","\"MaxValue\""]}]"#, ), ]; - let ctx = QueryContextBuilder::default().build(); + let ctx = QueryContextBuilder::default().build().into(); for (sql, expected) in cases { let result = ParserContext::create_with_dialect( sql, diff --git a/src/query/src/dist_plan/merge_scan.rs b/src/query/src/dist_plan/merge_scan.rs index cc17cb23f705..fbc88da3b435 100644 --- a/src/query/src/dist_plan/merge_scan.rs +++ b/src/query/src/dist_plan/merge_scan.rs @@ -182,7 +182,7 @@ impl MergeScanExec { let current_catalog = self.query_ctx.current_catalog().to_string(); let current_schema = self.query_ctx.current_schema().to_string(); let timezone = self.query_ctx.timezone().to_string(); - let extension = self.query_ctx.to_extension(); + let extensions = self.query_ctx.extensions(); let stream = Box::pin(stream!({ MERGE_SCAN_REGIONS.observe(regions.len() as f64); @@ -199,7 +199,7 @@ impl MergeScanExec { current_catalog: current_catalog.clone(), current_schema: current_schema.clone(), timezone: timezone.clone(), - extension: extension.clone(), + extensions: extensions.clone(), }), }), region_id: region_id.into(), diff --git a/src/query/src/query_engine/options.rs b/src/query/src/query_engine/options.rs index 867e8c15fef0..f9e36c835478 100644 --- a/src/query/src/query_engine/options.rs +++ b/src/query/src/query_engine/options.rs @@ -42,13 +42,15 @@ pub fn validate_catalog_and_schema( #[cfg(test)] mod tests { + use std::sync::Arc; + use session::context::QueryContext; use super::*; #[test] fn test_validate_catalog_and_schema() { - let context = QueryContext::with("greptime", "public"); + let context = Arc::new(QueryContext::with("greptime", "public")); validate_catalog_and_schema("greptime", "public", &context).unwrap(); let re = validate_catalog_and_schema("greptime", "private_schema", &context); diff --git a/src/query/src/sql.rs b/src/query/src/sql.rs index 5aee6cc4ae7a..2fe7aa9e5544 100644 --- a/src/query/src/sql.rs +++ b/src/query/src/sql.rs @@ -944,9 +944,11 @@ mod test { let stmt = ShowVariables { variable: ObjectName(vec![Ident::new(variable)]), }; - let ctx = QueryContextBuilder::default() - .timezone(Arc::new(Timezone::from_tz_string(tz).unwrap())) - .build(); + let ctx = Arc::new( + QueryContextBuilder::default() + .timezone(Arc::new(Timezone::from_tz_string(tz).unwrap())) + .build(), + ); match show_variable(stmt, ctx) { Ok(Output { data: OutputData::RecordBatches(record), diff --git a/src/script/src/python/ffi_types/copr.rs b/src/script/src/python/ffi_types/copr.rs index 704b0db77d44..b81fc9d57621 100644 --- a/src/script/src/python/ffi_types/copr.rs +++ b/src/script/src/python/ffi_types/copr.rs @@ -411,7 +411,7 @@ impl PyQueryEngine { let rt = tokio::runtime::Runtime::new().map_err(|e| e.to_string())?; let handle = rt.handle().clone(); let res = handle.block_on(async { - let ctx = QueryContextBuilder::default().build(); + let ctx = Arc::new(QueryContextBuilder::default().build()); let plan = engine .planner() .plan(stmt, ctx.clone()) diff --git a/src/script/src/table.rs b/src/script/src/table.rs index d9becf552164..8f998d64eb4e 100644 --- a/src/script/src/table.rs +++ b/src/script/src/table.rs @@ -339,6 +339,7 @@ fn query_ctx(table_info: &TableInfo) -> QueryContextRef { .current_catalog(table_info.catalog_name.to_string()) .current_schema(table_info.schema_name.to_string()) .build() + .into() } /// Builds scripts schema, returns (time index, primary keys, column defs) diff --git a/src/servers/src/export_metrics.rs b/src/servers/src/export_metrics.rs index 3ec089db411b..8932adf59d6e 100644 --- a/src/servers/src/export_metrics.rs +++ b/src/servers/src/export_metrics.rs @@ -13,6 +13,7 @@ // limitations under the License. use std::collections::HashMap; +use std::sync::Arc; use std::time::Duration; use axum::http::HeaderValue; @@ -247,7 +248,7 @@ pub async fn write_system_metric_by_handler( ); // Pass the first tick. Because the first tick completes immediately. interval.tick().await; - let ctx = QueryContextBuilder::default().current_schema(db).build(); + let ctx = Arc::new(QueryContextBuilder::default().current_schema(db).build()); loop { interval.tick().await; let metric_families = prometheus::gather(); diff --git a/src/servers/src/grpc/greptime_handler.rs b/src/servers/src/grpc/greptime_handler.rs index 9ee670795a13..081e180ebf61 100644 --- a/src/servers/src/grpc/greptime_handler.rs +++ b/src/servers/src/grpc/greptime_handler.rs @@ -190,6 +190,7 @@ pub(crate) fn create_query_context(header: Option<&RequestHeader>) -> QueryConte .current_schema(schema) .timezone(Arc::new(timezone)) .build() + .into() } /// Histogram timer for handling gRPC request. diff --git a/src/servers/src/http/authorize.rs b/src/servers/src/http/authorize.rs index bef5224aba86..971fdce57ef3 100644 --- a/src/servers/src/http/authorize.rs +++ b/src/servers/src/http/authorize.rs @@ -68,7 +68,7 @@ pub async fn inner_auth( .current_schema(schema.clone()) .timezone(timezone); - let query_ctx = query_ctx_builder.build(); + let query_ctx = Arc::new(query_ctx_builder.build()); let need_auth = need_auth(&req); // 2. check if auth is needed diff --git a/src/servers/src/http/prometheus.rs b/src/servers/src/http/prometheus.rs index 4f453a1ea43b..0aa3b8abd6e2 100644 --- a/src/servers/src/http/prometheus.rs +++ b/src/servers/src/http/prometheus.rs @@ -14,6 +14,7 @@ //! prom supply the prometheus HTTP API Server compliance use std::collections::{HashMap, HashSet}; +use std::sync::Arc; use axum::extract::{Path, Query, State}; use axum::{Extension, Form}; @@ -572,10 +573,12 @@ pub(crate) fn try_update_catalog_schema( schema: &str, ) -> QueryContextRef { if ctx.current_catalog() != catalog || ctx.current_schema() != schema { - QueryContextBuilder::from_existing(&ctx) - .current_catalog(catalog.to_string()) - .current_schema(schema.to_string()) - .build() + Arc::new( + QueryContextBuilder::from_existing(&ctx) + .current_catalog(catalog.to_string()) + .current_schema(schema.to_string()) + .build(), + ) } else { ctx } diff --git a/src/servers/src/http/script.rs b/src/servers/src/http/script.rs index 312d2766a7c2..cb8ca7fc2b93 100644 --- a/src/servers/src/http/script.rs +++ b/src/servers/src/http/script.rs @@ -13,6 +13,7 @@ // limitations under the License. use std::collections::HashMap; +use std::sync::Arc; use std::time::Instant; use axum::extract::{Query, RawBody, State}; @@ -76,7 +77,7 @@ pub async fn scripts( unwrap_or_json_err!(String::from_utf8(bytes.to_vec()).context(InvalidUtf8ValueSnafu)); // Safety: schema and name are already checked above. - let query_ctx = QueryContext::with(&catalog, schema.unwrap()); + let query_ctx = Arc::new(QueryContext::with(&catalog, schema.unwrap())); match script_handler .insert_script(query_ctx, name.unwrap(), &script) .await @@ -128,7 +129,7 @@ pub async fn run_script( } // Safety: schema and name are already checked above. - let query_ctx = QueryContext::with(&catalog, schema.unwrap()); + let query_ctx = Arc::new(QueryContext::with(&catalog, schema.unwrap())); let output = script_handler .execute_script(query_ctx, name.unwrap(), params.params) .await; diff --git a/src/servers/src/postgres/types.rs b/src/servers/src/postgres/types.rs index 186c290e15bc..e0d018f05bc2 100644 --- a/src/servers/src/postgres/types.rs +++ b/src/servers/src/postgres/types.rs @@ -807,7 +807,8 @@ mod test { ]; let query_context = QueryContextBuilder::default() .configuration_parameter(Default::default()) - .build(); + .build() + .into(); let mut builder = DataRowEncoder::new(Arc::new(schema)); for i in values.iter() { encode_value(&query_context, i, &mut builder).unwrap(); diff --git a/src/servers/tests/py_script/mod.rs b/src/servers/tests/py_script/mod.rs index 03232329b829..e5682220e5c5 100644 --- a/src/servers/tests/py_script/mod.rs +++ b/src/servers/tests/py_script/mod.rs @@ -56,10 +56,12 @@ def hello() -> vector[str]: let table = MemTable::table("scripts", recordbatch); - let query_ctx = QueryContextBuilder::default() - .current_catalog(catalog.to_string()) - .current_schema(schema.to_string()) - .build(); + let query_ctx = Arc::new( + QueryContextBuilder::default() + .current_catalog(catalog.to_string()) + .current_schema(schema.to_string()) + .build(), + ); let instance = create_testing_instance(table); instance diff --git a/src/session/src/context.rs b/src/session/src/context.rs index 410d264fd57f..37f7e39c5fb7 100644 --- a/src/session/src/context.rs +++ b/src/session/src/context.rs @@ -44,7 +44,7 @@ pub struct QueryContext { timezone: ArcSwap, sql_dialect: Arc, #[builder(default)] - extension: HashMap, + extensions: HashMap, // The configuration parameter are used to store the parameters that are set by the user #[builder(default)] configuration_parameter: Arc, @@ -76,7 +76,7 @@ impl Clone for QueryContext { current_user: self.current_user.load().clone().into(), timezone: self.timezone.load().clone().into(), sql_dialect: self.sql_dialect.clone(), - extension: self.extension.clone(), + extensions: self.extensions.clone(), configuration_parameter: self.configuration_parameter.clone(), } } @@ -84,42 +84,31 @@ impl Clone for QueryContext { impl From<&RegionRequestHeader> for QueryContext { fn from(value: &RegionRequestHeader) -> Self { - match &value.query_context { - Some(ctx) => QueryContext { - current_catalog: ctx.current_catalog.clone(), - current_schema: ctx.current_schema.clone(), - current_user: Default::default(), - timezone: ArcSwap::new(Arc::new(parse_timezone(Some(&ctx.timezone)))), - sql_dialect: Arc::new(GreptimeDbDialect {}), - extension: ctx.extension.clone(), - configuration_parameter: Default::default(), - }, - None => QueryContext { - current_catalog: DEFAULT_CATALOG_NAME.to_string(), - current_schema: DEFAULT_SCHEMA_NAME.to_string(), - current_user: ArcSwap::new(Arc::new(None)), - timezone: ArcSwap::new(Arc::new(get_timezone(None).clone())), - sql_dialect: Arc::new(GreptimeDbDialect {}), - extension: HashMap::new(), - configuration_parameter: Default::default(), - }, + let mut builder = QueryContextBuilder::default(); + if let Some(ctx) = &value.query_context { + builder = builder + .current_catalog(ctx.current_catalog.clone()) + .current_schema(ctx.current_schema.clone()) + .timezone(Arc::new(parse_timezone(Some(&ctx.timezone)))) + .extensions(ctx.extensions.clone()); } + builder.build() } } impl QueryContext { pub fn arc() -> QueryContextRef { - QueryContextBuilder::default().build() + Arc::new(QueryContextBuilder::default().build()) } - pub fn with(catalog: &str, schema: &str) -> QueryContextRef { + pub fn with(catalog: &str, schema: &str) -> QueryContext { QueryContextBuilder::default() .current_catalog(catalog.to_string()) .current_schema(schema.to_string()) .build() } - pub fn with_db_name(db_name: Option<&str>) -> QueryContextRef { + pub fn with_db_name(db_name: Option<&str>) -> QueryContext { let (catalog, schema) = db_name .map(|db| { let (catalog, schema) = parse_catalog_and_schema_from_db_string(db); @@ -172,15 +161,15 @@ impl QueryContext { } pub fn set_extension, S2: Into>(&mut self, key: S1, value: S2) { - self.extension.insert(key.into(), value.into()); + self.extensions.insert(key.into(), value.into()); } pub fn extension>(&self, key: S) -> Option<&str> { - self.extension.get(key.as_ref()).map(|v| v.as_str()) + self.extensions.get(key.as_ref()).map(|v| v.as_str()) } - pub fn to_extension(&self) -> HashMap { - self.extension.clone() + pub fn extensions(&self) -> HashMap { + self.extensions.clone() } /// SQL like `set variable` may change timezone or other info in `QueryContext`. @@ -209,8 +198,8 @@ impl QueryContext { } impl QueryContextBuilder { - pub fn build(self) -> QueryContextRef { - Arc::new(QueryContext { + pub fn build(self) -> QueryContext { + QueryContext { current_catalog: self .current_catalog .unwrap_or_else(|| DEFAULT_CATALOG_NAME.to_string()), @@ -226,13 +215,13 @@ impl QueryContextBuilder { sql_dialect: self .sql_dialect .unwrap_or_else(|| Arc::new(GreptimeDbDialect {})), - extension: self.extension.unwrap_or_default(), + extensions: self.extensions.unwrap_or_default(), configuration_parameter: self.configuration_parameter.unwrap_or_default(), - }) + } } pub fn set_extension(mut self, key: String, value: String) -> Self { - self.extension + self.extensions .get_or_insert_with(HashMap::new) .insert(key, value); self @@ -245,7 +234,7 @@ impl QueryContextBuilder { current_user: Some(context.current_user.load().clone().into()), timezone: Some(context.timezone.load().clone().into()), sql_dialect: Some(context.sql_dialect.clone()), - extension: Some(context.extension.clone()), + extensions: Some(context.extensions.clone()), configuration_parameter: Some(context.configuration_parameter.clone()), } } diff --git a/src/session/src/lib.rs b/src/session/src/lib.rs index e89a733553d9..627d01b6050e 100644 --- a/src/session/src/lib.rs +++ b/src/session/src/lib.rs @@ -70,6 +70,7 @@ impl Session { .configuration_parameter(self.configuration_variables.clone()) .timezone(self.timezone()) .build() + .into() } #[inline] diff --git a/tests-integration/src/otlp.rs b/tests-integration/src/otlp.rs index 637213239335..b90b07b273b4 100644 --- a/tests-integration/src/otlp.rs +++ b/tests-integration/src/otlp.rs @@ -52,7 +52,7 @@ mod test { async fn test_otlp(instance: &Arc) { let req = build_request(); let db = "otlp"; - let ctx = QueryContext::with(DEFAULT_CATALOG_NAME, db); + let ctx = Arc::new(QueryContext::with(DEFAULT_CATALOG_NAME, db)); assert!(SqlQueryHandler::do_query( instance.as_ref(), diff --git a/tests-integration/src/prom_store.rs b/tests-integration/src/prom_store.rs index dd6d1b9b1059..0850c258f5ac 100644 --- a/tests-integration/src/prom_store.rs +++ b/tests-integration/src/prom_store.rs @@ -90,7 +90,7 @@ mod tests { }; let db = "prometheus"; - let mut ctx = Arc::into_inner(QueryContext::with(DEFAULT_CATALOG_NAME, db)).unwrap(); + let mut ctx = Arc::into_inner(QueryContext::with(DEFAULT_CATALOG_NAME, db).into()).unwrap(); // set physical table if provided if let Some(physical_table) = &physical_table { diff --git a/tests-integration/src/tests/instance_kafka_wal_test.rs b/tests-integration/src/tests/instance_kafka_wal_test.rs index 031fc16bc310..b4c1d3ff1524 100644 --- a/tests-integration/src/tests/instance_kafka_wal_test.rs +++ b/tests-integration/src/tests/instance_kafka_wal_test.rs @@ -43,7 +43,7 @@ async fn test_create_database_and_insert_query( let output = execute_sql_with( &instance, "create database test", - QueryContext::with(DEFAULT_CATALOG_NAME, "test"), + QueryContext::with(DEFAULT_CATALOG_NAME, "test").into(), ) .await; assert_matches!(output.data, OutputData::AffectedRows(1)); @@ -57,7 +57,7 @@ async fn test_create_database_and_insert_query( ts timestamp, TIME INDEX(ts) )"#, - QueryContext::with(DEFAULT_CATALOG_NAME, "test"), + QueryContext::with(DEFAULT_CATALOG_NAME, "test").into(), ) .await; assert!(matches!(output.data, OutputData::AffectedRows(0))); @@ -68,7 +68,7 @@ async fn test_create_database_and_insert_query( ('host1', 66.6, 1024, 1655276557000), ('host2', 88.8, 333.3, 1655276558000) "#, - QueryContext::with(DEFAULT_CATALOG_NAME, "test"), + QueryContext::with(DEFAULT_CATALOG_NAME, "test").into(), ) .await; assert!(matches!(output.data, OutputData::AffectedRows(2))); @@ -76,7 +76,7 @@ async fn test_create_database_and_insert_query( let query_output = execute_sql_with( &instance, "select ts from test.demo order by ts limit 1", - QueryContext::with(DEFAULT_CATALOG_NAME, "test"), + QueryContext::with(DEFAULT_CATALOG_NAME, "test").into(), ) .await; match query_output.data { @@ -112,7 +112,7 @@ async fn test_replay(rebuildable_instance: Option, table_name: &str) -> Output { )"#, table_name ), - QueryContext::with(DEFAULT_CATALOG_NAME, "test"), + QueryContext::with(DEFAULT_CATALOG_NAME, "test").into(), ) .await } @@ -266,7 +266,7 @@ async fn do_alter(instance: &Arc, table_name: &str) -> Output { execute_sql_with( instance, &format!("alter table {} add column new_col STRING", table_name), - QueryContext::with(DEFAULT_CATALOG_NAME, "test"), + QueryContext::with(DEFAULT_CATALOG_NAME, "test").into(), ) .await } @@ -276,7 +276,7 @@ async fn do_insert(instance: &Arc, table_name: &str, row: String) -> O execute_sql_with( instance, &format!("insert into test.{table_name}(host, cpu, memory, ts) values {row}"), - QueryContext::with(DEFAULT_CATALOG_NAME, "test"), + QueryContext::with(DEFAULT_CATALOG_NAME, "test").into(), ) .await } @@ -286,7 +286,7 @@ async fn do_query(instance: &Arc, table_name: &str) -> Output { execute_sql_with( instance, &format!("select ts from test.{table_name} order by ts"), - QueryContext::with(DEFAULT_CATALOG_NAME, "test"), + QueryContext::with(DEFAULT_CATALOG_NAME, "test").into(), ) .await } diff --git a/tests-integration/src/tests/instance_test.rs b/tests-integration/src/tests/instance_test.rs index b5ba0f658b94..44d2dc5fb37f 100644 --- a/tests-integration/src/tests/instance_test.rs +++ b/tests-integration/src/tests/instance_test.rs @@ -1204,7 +1204,7 @@ async fn test_rename_table(instance: Arc) { let output = execute_sql(&instance, "create database db").await.data; assert!(matches!(output, OutputData::AffectedRows(1))); - let query_ctx = QueryContext::with(DEFAULT_CATALOG_NAME, "db"); + let query_ctx = Arc::new(QueryContext::with(DEFAULT_CATALOG_NAME, "db")); let output = execute_sql_with( &instance, "create table demo(host string, cpu double, memory double, ts timestamp, time index(ts))", @@ -1277,7 +1277,7 @@ async fn test_create_table_after_rename_table(instance: Arc) { // create test table let table_name = "demo"; - let query_ctx = QueryContext::with(DEFAULT_CATALOG_NAME, "db"); + let query_ctx = Arc::new(QueryContext::with(DEFAULT_CATALOG_NAME, "db")); let output = execute_sql_with( &instance, &format!("create table {table_name}(host string, cpu double, memory double, ts timestamp, time index(ts))"), @@ -1481,7 +1481,7 @@ async fn test_use_database(instance: Arc) { let output = execute_sql(&instance, "create database db1").await.data; assert!(matches!(output, OutputData::AffectedRows(1))); - let query_ctx = QueryContext::with(DEFAULT_CATALOG_NAME, "db1"); + let query_ctx = Arc::new(QueryContext::with(DEFAULT_CATALOG_NAME, "db1")); let output = execute_sql_with( &instance, "create table tb1(col_i32 int, ts timestamp, TIME INDEX(ts))", @@ -1845,7 +1845,7 @@ async fn test_information_schema_dot_tables(instance: Arc) { let instance = instance.frontend(); let sql = "create table another_table(i timestamp time index)"; - let query_ctx = QueryContext::with("another_catalog", "another_schema"); + let query_ctx = Arc::new(QueryContext::with("another_catalog", "another_schema")); let output = execute_sql_with(&instance, sql, query_ctx.clone()) .await .data; @@ -1885,7 +1885,7 @@ async fn test_information_schema_dot_columns(instance: Arc) { let instance = instance.frontend(); let sql = "create table another_table(i timestamp time index)"; - let query_ctx = QueryContext::with("another_catalog", "another_schema"); + let query_ctx = Arc::new(QueryContext::with("another_catalog", "another_schema")); let output = execute_sql_with(&instance, sql, query_ctx.clone()) .await .data; diff --git a/tests-integration/src/tests/promql_test.rs b/tests-integration/src/tests/promql_test.rs index 8f5c440fa78b..3764e63ddfaa 100644 --- a/tests-integration/src/tests/promql_test.rs +++ b/tests-integration/src/tests/promql_test.rs @@ -553,7 +553,7 @@ async fn cross_schema_query(instance: Arc) { ins.do_query( AGGREGATORS_CREATE_TABLE, - QueryContext::with_db_name(Some("greptime_private")), + QueryContext::with_db_name(Some("greptime_private")).into(), ) .await .into_iter() @@ -562,7 +562,7 @@ async fn cross_schema_query(instance: Arc) { }); ins.do_query( AGGREGATORS_INSERT_DATA, - QueryContext::with_db_name(Some("greptime_private")), + QueryContext::with_db_name(Some("greptime_private")).into(), ) .await .into_iter() @@ -617,7 +617,7 @@ async fn cross_schema_query(instance: Arc) { let query_output = promql_query( ins.clone(), r#"http_requests"#, - QueryContext::with_db_name(Some("greptime_private")), + QueryContext::with_db_name(Some("greptime_private")).into(), start, end, interval,