diff --git a/Cargo.lock b/Cargo.lock
index 0f473d4e030..a389391ea90 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -977,12 +977,6 @@ dependencies = [
"syn 2.0.117",
]
-[[package]]
-name = "auto_ops"
-version = "0.3.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7460f7dd8e100147b82a63afca1a20eb6c231ee36b90ba7272e14951cb58af59"
-
[[package]]
name = "autocfg"
version = "1.5.0"
@@ -3744,7 +3738,7 @@ checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8"
[[package]]
name = "datafusion"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"arrow-schema 58.3.0",
@@ -3798,7 +3792,7 @@ dependencies = [
[[package]]
name = "datafusion-catalog"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"async-trait",
@@ -3822,7 +3816,7 @@ dependencies = [
[[package]]
name = "datafusion-catalog-listing"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"async-trait",
@@ -3844,7 +3838,7 @@ dependencies = [
[[package]]
name = "datafusion-common"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"ahash 0.8.12",
"arrow 58.3.0",
@@ -3868,7 +3862,7 @@ dependencies = [
[[package]]
name = "datafusion-common-runtime"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"futures",
"log",
@@ -3878,7 +3872,7 @@ dependencies = [
[[package]]
name = "datafusion-datasource"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"async-compression",
@@ -3912,7 +3906,7 @@ dependencies = [
[[package]]
name = "datafusion-datasource-arrow"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"arrow-ipc 58.3.0",
@@ -3935,7 +3929,7 @@ dependencies = [
[[package]]
name = "datafusion-datasource-csv"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"async-trait",
@@ -3957,7 +3951,7 @@ dependencies = [
[[package]]
name = "datafusion-datasource-json"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"async-trait",
@@ -3980,7 +3974,7 @@ dependencies = [
[[package]]
name = "datafusion-datasource-parquet"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"async-trait",
@@ -4009,12 +4003,12 @@ dependencies = [
[[package]]
name = "datafusion-doc"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
[[package]]
name = "datafusion-execution"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"arrow-buffer 58.3.0",
@@ -4036,7 +4030,7 @@ dependencies = [
[[package]]
name = "datafusion-expr"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"async-trait",
@@ -4058,7 +4052,7 @@ dependencies = [
[[package]]
name = "datafusion-expr-common"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"datafusion-common",
@@ -4070,7 +4064,7 @@ dependencies = [
[[package]]
name = "datafusion-functions"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"arrow-buffer 58.3.0",
@@ -4101,7 +4095,7 @@ dependencies = [
[[package]]
name = "datafusion-functions-aggregate"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"ahash 0.8.12",
"arrow 58.3.0",
@@ -4122,7 +4116,7 @@ dependencies = [
[[package]]
name = "datafusion-functions-aggregate-common"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"ahash 0.8.12",
"arrow 58.3.0",
@@ -4134,7 +4128,7 @@ dependencies = [
[[package]]
name = "datafusion-functions-nested"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"arrow-ord 58.3.0",
@@ -4158,7 +4152,7 @@ dependencies = [
[[package]]
name = "datafusion-functions-table"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"async-trait",
@@ -4173,7 +4167,7 @@ dependencies = [
[[package]]
name = "datafusion-functions-window"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"datafusion-common",
@@ -4190,7 +4184,7 @@ dependencies = [
[[package]]
name = "datafusion-functions-window-common"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"datafusion-common",
"datafusion-physical-expr-common",
@@ -4199,7 +4193,7 @@ dependencies = [
[[package]]
name = "datafusion-macros"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"datafusion-doc",
"quote",
@@ -4209,7 +4203,7 @@ dependencies = [
[[package]]
name = "datafusion-optimizer"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"chrono",
@@ -4258,7 +4252,7 @@ dependencies = [
[[package]]
name = "datafusion-physical-expr"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"ahash 0.8.12",
"arrow 58.3.0",
@@ -4281,7 +4275,7 @@ dependencies = [
[[package]]
name = "datafusion-physical-expr-adapter"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"datafusion-common",
@@ -4295,7 +4289,7 @@ dependencies = [
[[package]]
name = "datafusion-physical-expr-common"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"ahash 0.8.12",
"arrow 58.3.0",
@@ -4311,7 +4305,7 @@ dependencies = [
[[package]]
name = "datafusion-physical-optimizer"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"datafusion-common",
@@ -4329,7 +4323,7 @@ dependencies = [
[[package]]
name = "datafusion-physical-plan"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"ahash 0.8.12",
"arrow 58.3.0",
@@ -4360,7 +4354,7 @@ dependencies = [
[[package]]
name = "datafusion-proto"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"chrono",
@@ -4387,7 +4381,7 @@ dependencies = [
[[package]]
name = "datafusion-proto-common"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"datafusion-common",
@@ -4397,7 +4391,7 @@ dependencies = [
[[package]]
name = "datafusion-pruning"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"datafusion-common",
@@ -4413,7 +4407,7 @@ dependencies = [
[[package]]
name = "datafusion-session"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"async-trait",
"datafusion-common",
@@ -4426,7 +4420,7 @@ dependencies = [
[[package]]
name = "datafusion-sql"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"arrow 58.3.0",
"bigdecimal 0.4.8",
@@ -4444,7 +4438,7 @@ dependencies = [
[[package]]
name = "datafusion-substrait"
version = "53.1.0"
-source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=d705d4433d2fcbe2bead54e3f1d6cc59727857e1#d705d4433d2fcbe2bead54e3f1d6cc59727857e1"
+source = "git+https://github.com/GreptimeTeam/datafusion.git?rev=4c8a6bf28347b346348136247eb67dfb933f1147#4c8a6bf28347b346348136247eb67dfb933f1147"
dependencies = [
"async-recursion",
"async-trait",
@@ -4554,6 +4548,9 @@ dependencies = [
"num",
"num-traits",
"ordered-float 4.6.0",
+ "parquet-variant",
+ "parquet-variant-compute",
+ "parquet-variant-json",
"paste",
"regex",
"serde",
@@ -9799,17 +9796,6 @@ dependencies = [
"url",
]
-[[package]]
-name = "openmetrics-parser"
-version = "0.4.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e40a68c62e09c5dfec2f6472af3bd5e8ddf506fcf14c78ece23794ffbb874eca"
-dependencies = [
- "auto_ops",
- "pest",
- "pest_derive",
-]
-
[[package]]
name = "opensrv-mysql"
version = "0.8.0"
@@ -10259,6 +10245,53 @@ dependencies = [
"zstd",
]
+[[package]]
+name = "parquet-variant"
+version = "58.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "74c8db065291f088a2aad8ab831853eae1871c0d311c8d0b83bbc3b7e735d0fc"
+dependencies = [
+ "arrow 58.3.0",
+ "arrow-schema 58.3.0",
+ "chrono",
+ "half",
+ "indexmap 2.13.0",
+ "num-traits",
+ "simdutf8",
+ "uuid",
+]
+
+[[package]]
+name = "parquet-variant-compute"
+version = "58.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a530e8d5b5e14efcb39c9a6ec55432ad11f6afb7dc4455a79be0dc615fe3cc31"
+dependencies = [
+ "arrow 58.3.0",
+ "arrow-schema 58.3.0",
+ "chrono",
+ "half",
+ "indexmap 2.13.0",
+ "parquet-variant",
+ "parquet-variant-json",
+ "serde_json",
+ "uuid",
+]
+
+[[package]]
+name = "parquet-variant-json"
+version = "58.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "00ed89908289f67caa2ca078f9ff9aacd6229a313ec92b12bf4f48f613dc2b97"
+dependencies = [
+ "arrow-schema 58.3.0",
+ "base64 0.22.1",
+ "chrono",
+ "parquet-variant",
+ "serde_json",
+ "uuid",
+]
+
[[package]]
name = "parse-size"
version = "1.1.0"
@@ -13411,7 +13444,6 @@ dependencies = [
"notify",
"object-pool",
"once_cell",
- "openmetrics-parser",
"opensrv-mysql",
"opentelemetry-proto",
"operator",
diff --git a/Cargo.toml b/Cargo.toml
index daee1bd4090..e6b849a6cd0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -195,6 +195,9 @@ otel-arrow-rust = { git = "https://github.com/GreptimeTeam/otel-arrow", rev = "5
] }
parking_lot = "0.12"
parquet = { version = "58.3", default-features = false, features = ["arrow", "async", "object_store"] }
+parquet-variant = "58.3"
+parquet-variant-compute = "58.3"
+parquet-variant-json = "58.3"
paste = "1.0"
pin-project = "1.0"
pretty_assertions = "1.4.0"
@@ -348,21 +351,21 @@ git = "https://github.com/GreptimeTeam/greptime-meter.git"
rev = "5618e779cf2bb4755b499c630fba4c35e91898cb"
[patch.crates-io]
-datafusion = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-datasource = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-expr = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-expr-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-functions = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-functions-aggregate-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-functions-window-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-optimizer = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-physical-expr = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-physical-expr-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-physical-plan = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-proto = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-sql = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
-datafusion-substrait = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "d705d4433d2fcbe2bead54e3f1d6cc59727857e1" }
+datafusion = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-datasource = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-expr = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-expr-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-functions = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-functions-aggregate-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-functions-window-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-optimizer = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-physical-expr = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-physical-expr-common = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-physical-plan = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-proto = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-sql = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
+datafusion-substrait = { git = "https://github.com/GreptimeTeam/datafusion.git", rev = "4c8a6bf28347b346348136247eb67dfb933f1147" }
sqlparser = { git = "https://github.com/GreptimeTeam/sqlparser-rs.git", rev = "2aefa08a8d69c96eec2d6d6703598a009bba6e4c" } # on branch v0.61.x
[profile.release]
diff --git a/config/config.md b/config/config.md
index 14387741297..139077dd62c 100644
--- a/config/config.md
+++ b/config/config.md
@@ -25,7 +25,7 @@
| `runtime` | -- | -- | The runtime options. |
| `runtime.global_rt_size` | Integer | `8` | The number of threads to execute the runtime for global read operations. |
| `runtime.compact_rt_size` | Integer | `4` | The number of threads to execute compact operations. |
-| `runtime.compact_rt_max_blocking_threads` | Integer | `4` | The maximum number of blocking threads for compact operations.
Defaults to max(num_cpus / 2, 1). |
+| `runtime.compact_rt_max_blocking_threads` | Integer | `4` | The maximum number of blocking threads for compact operations.
Defaults to max(num_cpus / 2, 2). |
| `http` | -- | -- | The HTTP server options. |
| `http.addr` | String | `127.0.0.1:4000` | The address to bind the HTTP server. |
| `http.timeout` | String | `0s` | HTTP request timeout. Set to 0 to disable timeout.
When Prometheus pending-row batching is enabled, a nonzero timeout less than or equal to the
`prom_store.pending_rows_flush_interval` plus 1 second is adjusted to that value. |
@@ -256,7 +256,7 @@
| `runtime` | -- | -- | The runtime options. |
| `runtime.global_rt_size` | Integer | `8` | The number of threads to execute the runtime for global read operations. |
| `runtime.compact_rt_size` | Integer | `4` | The number of threads to execute compact operations. |
-| `runtime.compact_rt_max_blocking_threads` | Integer | `4` | The maximum number of blocking threads for compact operations.
Defaults to max(num_cpus / 2, 1). |
+| `runtime.compact_rt_max_blocking_threads` | Integer | `4` | The maximum number of blocking threads for compact operations.
Defaults to max(num_cpus / 2, 2). |
| `http` | -- | -- | The HTTP server options. |
| `http.addr` | String | `127.0.0.1:4000` | The address to bind the HTTP server. |
| `http.timeout` | String | `0s` | HTTP request timeout. Set to 0 to disable timeout.
When Prometheus pending-row batching is enabled, a nonzero timeout less than or equal to the
`prom_store.pending_rows_flush_interval` plus 1 second is adjusted to that value. |
@@ -400,7 +400,7 @@
| `runtime` | -- | -- | The runtime options. |
| `runtime.global_rt_size` | Integer | `8` | The number of threads to execute the runtime for global read operations. |
| `runtime.compact_rt_size` | Integer | `4` | The number of threads to execute compact operations. |
-| `runtime.compact_rt_max_blocking_threads` | Integer | `4` | The maximum number of blocking threads for compact operations.
Defaults to max(num_cpus / 2, 1). |
+| `runtime.compact_rt_max_blocking_threads` | Integer | `4` | The maximum number of blocking threads for compact operations.
Defaults to max(num_cpus / 2, 2). |
| `backend_tls` | -- | -- | TLS configuration for kv store backend (applicable for etcd, PostgreSQL, and MySQL backends)
When using etcd, PostgreSQL, or MySQL as metadata store, you can configure TLS here
Note: if TLS is configured in both this section and the `store_addrs` connection string, the
settings here will override the TLS settings in `store_addrs`. |
| `backend_tls.mode` | String | `prefer` | TLS mode, refer to https://www.postgresql.org/docs/current/libpq-ssl.html
- "disable" - No TLS
- "prefer" (default) - Try TLS, fallback to plain
- "require" - Require TLS
- "verify_ca" - Require TLS and verify CA
- "verify_full" - Require TLS and verify hostname |
| `backend_tls.cert_path` | String | `""` | Path to client certificate file (for client authentication)
Like "/path/to/client.crt" |
@@ -511,8 +511,8 @@
| `runtime` | -- | -- | The runtime options. |
| `runtime.global_rt_size` | Integer | `8` | The number of threads to execute the runtime for global read operations. |
| `runtime.compact_rt_size` | Integer | `4` | The number of threads to execute compact operations. |
-| `runtime.compact_rt_max_blocking_threads` | Integer | `4` | The maximum number of blocking threads for compact operations.
Defaults to max(num_cpus / 2, 1). |
-| `runtime.query_rt_size` | Integer | `7` | The number of threads to execute datanode query operations.
Defaults to max(num_cpus - 1, 1). |
+| `runtime.compact_rt_max_blocking_threads` | Integer | `4` | The maximum number of blocking threads for compact operations.
Defaults to max(num_cpus / 2, 2). |
+| `runtime.query_rt_size` | Integer | `7` | The number of threads to execute datanode query operations.
Defaults to max(num_cpus - 1, 2). |
| `runtime.ingest_rt_size` | Integer | `8` | The number of threads to execute datanode ingestion operations. |
| `meta_client` | -- | -- | The metasrv client options. |
| `meta_client.metasrv_addrs` | Array | -- | The addresses of the metasrv. |
diff --git a/config/datanode.example.toml b/config/datanode.example.toml
index 1f1377d91cc..5966405452a 100644
--- a/config/datanode.example.toml
+++ b/config/datanode.example.toml
@@ -84,10 +84,10 @@ watch = false
## The number of threads to execute compact operations.
#+ compact_rt_size = 4
## The maximum number of blocking threads for compact operations.
-## Defaults to max(num_cpus / 2, 1).
+## Defaults to max(num_cpus / 2, 2).
#+ compact_rt_max_blocking_threads = 4
## The number of threads to execute datanode query operations.
-## Defaults to max(num_cpus - 1, 1).
+## Defaults to max(num_cpus - 1, 2).
#+ query_rt_size = 7
## The number of threads to execute datanode ingestion operations.
#+ ingest_rt_size = 8
diff --git a/config/frontend.example.toml b/config/frontend.example.toml
index 42da7f81fe5..88f3bc3f50f 100644
--- a/config/frontend.example.toml
+++ b/config/frontend.example.toml
@@ -44,7 +44,7 @@ default_column_prefix = "greptime"
## The number of threads to execute compact operations.
#+ compact_rt_size = 4
## The maximum number of blocking threads for compact operations.
-## Defaults to max(num_cpus / 2, 1).
+## Defaults to max(num_cpus / 2, 2).
#+ compact_rt_max_blocking_threads = 4
## The HTTP server options.
diff --git a/config/metasrv.example.toml b/config/metasrv.example.toml
index f607211d636..6017bfcc49a 100644
--- a/config/metasrv.example.toml
+++ b/config/metasrv.example.toml
@@ -92,7 +92,7 @@ node_max_idle_time = "24hours"
## The number of threads to execute compact operations.
#+ compact_rt_size = 4
## The maximum number of blocking threads for compact operations.
-## Defaults to max(num_cpus / 2, 1).
+## Defaults to max(num_cpus / 2, 2).
#+ compact_rt_max_blocking_threads = 4
## TLS configuration for kv store backend (applicable for etcd, PostgreSQL, and MySQL backends)
diff --git a/config/standalone.example.toml b/config/standalone.example.toml
index 32ed0b12442..ab3c18712b6 100644
--- a/config/standalone.example.toml
+++ b/config/standalone.example.toml
@@ -57,7 +57,7 @@ max_concurrent_queries = 0
## The number of threads to execute compact operations.
#+ compact_rt_size = 4
## The maximum number of blocking threads for compact operations.
-## Defaults to max(num_cpus / 2, 1).
+## Defaults to max(num_cpus / 2, 2).
#+ compact_rt_max_blocking_threads = 4
## The HTTP server options.
diff --git a/src/cmd/src/datanode/builder.rs b/src/cmd/src/datanode/builder.rs
index afabcb85f10..3dfa03e52e5 100644
--- a/src/cmd/src/datanode/builder.rs
+++ b/src/cmd/src/datanode/builder.rs
@@ -61,9 +61,6 @@ impl InstanceBuilder {
}
async fn init(opts: &mut DatanodeOptions, plugins: &mut Plugins) -> Result> {
- common_runtime::init_global_runtimes(&opts.runtime);
- common_runtime::init_datanode_runtimes(&opts.runtime);
-
let dn_opts = &mut opts.component;
let guard = common_telemetry::init_global_logging(
APP_NAME,
@@ -73,6 +70,9 @@ impl InstanceBuilder {
None,
);
+ common_runtime::init_global_runtimes(&opts.runtime);
+ common_runtime::init_datanode_runtimes(&opts.runtime);
+
crate::options::flush_dropped_plugin_warnings();
log_versions(verbose_version(), short_version(), APP_NAME);
maybe_activate_heap_profile(&dn_opts.memory);
diff --git a/src/cmd/src/flownode.rs b/src/cmd/src/flownode.rs
index ee071875c3a..eccfaa63b07 100644
--- a/src/cmd/src/flownode.rs
+++ b/src/cmd/src/flownode.rs
@@ -248,8 +248,6 @@ impl StartCommand {
}
async fn build(&self, opts: FlownodeOptions) -> Result {
- common_runtime::init_global_runtimes(&opts.runtime);
-
let guard = common_telemetry::init_global_logging(
APP_NAME,
&opts.component.logging,
@@ -258,6 +256,8 @@ impl StartCommand {
None,
);
+ common_runtime::init_global_runtimes(&opts.runtime);
+
crate::options::flush_dropped_plugin_warnings();
log_versions(verbose_version(), short_version(), APP_NAME);
maybe_activate_heap_profile(&opts.component.memory);
diff --git a/src/cmd/src/frontend.rs b/src/cmd/src/frontend.rs
index 9d5d0bab1ee..e3737088e8d 100644
--- a/src/cmd/src/frontend.rs
+++ b/src/cmd/src/frontend.rs
@@ -330,8 +330,6 @@ impl StartCommand {
}
async fn build(&self, opts: FrontendOptions) -> Result {
- common_runtime::init_global_runtimes(&opts.runtime);
-
let guard = common_telemetry::init_global_logging(
APP_NAME,
&opts.component.logging,
@@ -340,6 +338,8 @@ impl StartCommand {
Some(&opts.component.slow_query),
);
+ common_runtime::init_global_runtimes(&opts.runtime);
+
crate::options::flush_dropped_plugin_warnings();
log_versions(verbose_version(), short_version(), APP_NAME);
maybe_activate_heap_profile(&opts.component.memory);
diff --git a/src/cmd/src/metasrv.rs b/src/cmd/src/metasrv.rs
index 791efeb6e86..369f5c428d1 100644
--- a/src/cmd/src/metasrv.rs
+++ b/src/cmd/src/metasrv.rs
@@ -318,8 +318,6 @@ impl StartCommand {
}
pub async fn build(&self, opts: MetasrvOptions) -> Result {
- common_runtime::init_global_runtimes(&opts.runtime);
-
let guard = common_telemetry::init_global_logging(
APP_NAME,
&opts.component.logging,
@@ -328,6 +326,8 @@ impl StartCommand {
None,
);
+ common_runtime::init_global_runtimes(&opts.runtime);
+
crate::options::flush_dropped_plugin_warnings();
log_versions(verbose_version(), short_version(), APP_NAME);
maybe_activate_heap_profile(&opts.component.memory);
diff --git a/src/cmd/src/standalone.rs b/src/cmd/src/standalone.rs
index 9f8155b9cc2..2ffcc5e729c 100644
--- a/src/cmd/src/standalone.rs
+++ b/src/cmd/src/standalone.rs
@@ -395,8 +395,6 @@ impl StartCommand {
#[allow(clippy::diverging_sub_expression)]
/// Build GreptimeDB instance with the loaded options.
pub async fn build(&self, opts: GreptimeOptions) -> Result {
- common_runtime::init_global_runtimes(&opts.runtime);
-
let guard = common_telemetry::init_global_logging(
APP_NAME,
&opts.component.logging,
@@ -405,6 +403,8 @@ impl StartCommand {
Some(&opts.component.slow_query),
);
+ common_runtime::init_global_runtimes(&opts.runtime);
+
crate::options::flush_dropped_plugin_warnings();
log_versions(verbose_version(), short_version(), APP_NAME);
maybe_activate_heap_profile(&opts.component.memory);
diff --git a/src/common/runtime/src/global.rs b/src/common/runtime/src/global.rs
index e28eaf61d15..827832fca22 100644
--- a/src/common/runtime/src/global.rs
+++ b/src/common/runtime/src/global.rs
@@ -27,6 +27,9 @@ use crate::{Builder, JoinHandle, Runtime};
const GLOBAL_WORKERS: usize = 8;
const COMPACT_WORKERS: usize = 4;
const HB_WORKERS: usize = 2;
+/// The minimum number of worker threads for runtimes sized by CPU count.
+/// A single-threaded runtime can easily deadlock in async code.
+const MIN_RUNTIME_THREADS: usize = 2;
/// The options for the global runtimes.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
@@ -44,19 +47,25 @@ pub struct RuntimeOptions {
pub ingest_rt_size: usize,
}
-impl Default for RuntimeOptions {
- fn default() -> Self {
- let cpus = num_cpus::get();
+impl RuntimeOptions {
+ fn with_num_cpus(cpus: usize) -> Self {
+ let cpus = usize::max(cpus, MIN_RUNTIME_THREADS);
Self {
global_rt_size: cpus,
- compact_rt_size: usize::max(cpus / 2, 1),
- compact_rt_max_blocking_threads: usize::max(cpus / 2, 1),
- query_rt_size: usize::max(cpus.saturating_sub(1), 1),
+ compact_rt_size: usize::max(cpus / 2, MIN_RUNTIME_THREADS),
+ compact_rt_max_blocking_threads: usize::max(cpus / 2, MIN_RUNTIME_THREADS),
+ query_rt_size: usize::max(cpus.saturating_sub(1), MIN_RUNTIME_THREADS),
ingest_rt_size: cpus,
}
}
}
+impl Default for RuntimeOptions {
+ fn default() -> Self {
+ Self::with_num_cpus(num_cpus::get())
+ }
+}
+
pub fn create_runtime(runtime_name: &str, thread_name: &str, worker_threads: usize) -> Runtime {
info!(
"Creating runtime with runtime_name: {runtime_name}, thread_name: {thread_name}, work_threads: {worker_threads}."
@@ -287,18 +296,56 @@ mod tests {
#[test]
fn test_datanode_runtime_options_default() {
let options = RuntimeOptions::default();
- let cpus = num_cpus::get();
+ let cpus = usize::max(num_cpus::get(), MIN_RUNTIME_THREADS);
assert_eq!(cpus, options.global_rt_size);
- assert_eq!(usize::max(cpus / 2, 1), options.compact_rt_size);
assert_eq!(
- usize::max(cpus / 2, 1),
+ usize::max(cpus / 2, MIN_RUNTIME_THREADS),
+ options.compact_rt_size
+ );
+ assert_eq!(
+ usize::max(cpus / 2, MIN_RUNTIME_THREADS),
options.compact_rt_max_blocking_threads
);
- assert_eq!(usize::max(cpus.saturating_sub(1), 1), options.query_rt_size);
+ assert_eq!(
+ usize::max(cpus.saturating_sub(1), MIN_RUNTIME_THREADS),
+ options.query_rt_size
+ );
assert_eq!(cpus, options.ingest_rt_size);
}
+ #[test]
+ fn test_runtime_options_min_threads() {
+ for cpus in [0, 1, 2] {
+ let options = RuntimeOptions::with_num_cpus(cpus);
+ assert!(
+ options.global_rt_size >= MIN_RUNTIME_THREADS,
+ "global_rt_size {} < {MIN_RUNTIME_THREADS} with {cpus} cpus",
+ options.global_rt_size
+ );
+ assert!(
+ options.compact_rt_size >= MIN_RUNTIME_THREADS,
+ "compact_rt_size {} < {MIN_RUNTIME_THREADS} with {cpus} cpus",
+ options.compact_rt_size
+ );
+ assert!(
+ options.compact_rt_max_blocking_threads >= MIN_RUNTIME_THREADS,
+ "compact_rt_max_blocking_threads {} < {MIN_RUNTIME_THREADS} with {cpus} cpus",
+ options.compact_rt_max_blocking_threads
+ );
+ assert!(
+ options.query_rt_size >= MIN_RUNTIME_THREADS,
+ "query_rt_size {} < {MIN_RUNTIME_THREADS} with {cpus} cpus",
+ options.query_rt_size
+ );
+ assert!(
+ options.ingest_rt_size >= MIN_RUNTIME_THREADS,
+ "ingest_rt_size {} < {MIN_RUNTIME_THREADS} with {cpus} cpus",
+ options.ingest_rt_size
+ );
+ }
+ }
+
#[test]
fn test_datanode_runtimes_fallback_to_global_runtime() {
let runtimes = GlobalRuntimes::new(
diff --git a/src/datatypes/Cargo.toml b/src/datatypes/Cargo.toml
index 3bf2a5d8eec..124b1e0ea64 100644
--- a/src/datatypes/Cargo.toml
+++ b/src/datatypes/Cargo.toml
@@ -27,6 +27,9 @@ jsonb.workspace = true
num = "0.4"
num-traits = "0.2"
ordered-float.workspace = true
+parquet-variant.workspace = true
+parquet-variant-compute.workspace = true
+parquet-variant-json.workspace = true
paste.workspace = true
regex.workspace = true
serde.workspace = true
diff --git a/src/datatypes/src/error.rs b/src/datatypes/src/error.rs
index cf76812c215..1def0d6be8d 100644
--- a/src/datatypes/src/error.rs
+++ b/src/datatypes/src/error.rs
@@ -77,6 +77,13 @@ pub enum Error {
location: Location,
},
+ #[snafu(display("Unimplemented: {feat}"))]
+ Unimplemented {
+ feat: String,
+ #[snafu(implicit)]
+ location: Location,
+ },
+
#[snafu(display("Failed to parse version in schema meta, value: {}", value))]
ParseSchemaVersion {
value: String,
@@ -196,6 +203,13 @@ pub enum Error {
location: Location,
},
+ #[snafu(display("Invalid JSON2 layout: {reason}"))]
+ InvalidJson2Layout {
+ reason: String,
+ #[snafu(implicit)]
+ location: Location,
+ },
+
#[snafu(display("Invalid Vector: {}", msg))]
InvalidVector {
msg: String,
@@ -305,6 +319,7 @@ impl ErrorExt for Error {
use Error::*;
match self {
UnsupportedOperation { .. }
+ | Unimplemented { .. }
| UnsupportedArrowType { .. }
| UnsupportedJsonType { .. }
| UnsupportedDefaultExpr { .. } => StatusCode::Unsupported,
@@ -318,6 +333,7 @@ impl ErrorExt for Error {
| InvalidTimestampPrecision { .. }
| InvalidPrecisionOrScale { .. }
| InvalidJson { .. }
+ | InvalidJson2Layout { .. }
| InvalidJsonb { .. }
| InvalidVector { .. }
| InvalidFulltextOption { .. }
diff --git a/src/datatypes/src/extension/json.rs b/src/datatypes/src/extension/json.rs
index 26d470641f5..ab4a138420e 100644
--- a/src/datatypes/src/extension/json.rs
+++ b/src/datatypes/src/extension/json.rs
@@ -18,30 +18,148 @@ use std::sync::Arc;
use arrow_schema::extension::{
EXTENSION_TYPE_METADATA_KEY, EXTENSION_TYPE_NAME_KEY, ExtensionType,
};
-use arrow_schema::{ArrowError, DataType, Field};
+use arrow_schema::{ArrowError, DataType, Field, FieldRef};
+use parquet_variant_compute::VariantType;
use serde::{Deserialize, Serialize};
-use snafu::ResultExt;
+use snafu::{ResultExt, ensure};
+use crate::error::InvalidJson2LayoutSnafu;
+pub use crate::json::JSON2_REMAINDER_FIELD_NAME;
use crate::json::JsonSettings;
const LEGACY_JSON_STRUCTURE_SETTINGS_KEY: &str = "json_structure_settings";
+const JSON2_LAYOUT_V1: u8 = 1;
+const JSON2_LAYOUT_V2: u8 = 2;
-#[derive(Debug, Clone, Serialize, Deserialize, Default)]
+/// Parsed physical layout of a JSON2 Arrow root field.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct Json2PhysicalLayout {
+ version: u8,
+}
+
+impl Json2PhysicalLayout {
+ /// Parses the JSON2 layout version from a root field.
+ ///
+ /// The version is read from the extension metadata; missing metadata
+ /// defaults to V1.
+ ///
+ /// Supported versions:
+ /// - V1
+ /// - V2
+ ///
+ /// Errors when the field is not a JSON2 extension or the version is not
+ /// one of the supported versions.
+ pub fn try_from_root(field: &Field) -> crate::error::Result {
+ ensure!(
+ is_json2_extension_type(field),
+ InvalidJson2LayoutSnafu {
+ reason: format!("field '{}' is not a JSON2 extension", field.name()),
+ }
+ );
+
+ let version = match field.extension_type_name() {
+ Some(Json2ExtensionType::NAME) => field
+ .metadata()
+ .get(EXTENSION_TYPE_METADATA_KEY)
+ .map(|x| parse_version(x))
+ .transpose()?
+ .flatten()
+ .unwrap_or(JSON2_LAYOUT_V1),
+ _ => JSON2_LAYOUT_V1,
+ };
+ ensure!(
+ matches!(version, JSON2_LAYOUT_V1 | JSON2_LAYOUT_V2),
+ InvalidJson2LayoutSnafu {
+ reason: format!("unsupported JSON2 layout version: {version}"),
+ }
+ );
+ Ok(Self { version })
+ }
+
+ /// Returns whether this is the JSON2 physical layout version 2.
+ pub fn is_version_2(&self) -> bool {
+ self.version == JSON2_LAYOUT_V2
+ }
+}
+
+fn parse_version(metadata: &str) -> crate::error::Result