From 938d757523c89485aad10346f1aae95b54f7c46f Mon Sep 17 00:00:00 2001 From: Zhenchi Date: Mon, 20 Oct 2025 19:59:16 +0800 Subject: [PATCH] feat: expose SST index metadata via information schema (#7044) Signed-off-by: Zhenchi --- .../src/system_schema/information_schema.rs | 14 ++- .../system_schema/information_schema/ssts.rs | 63 ++++++++++++- .../information_schema/table_names.rs | 1 + src/common/catalog/src/consts.rs | 2 + src/datanode/src/region_server/catalog.rs | 27 +++++- src/store-api/src/sst_entry.rs | 9 ++ .../common/information_schema/ssts.result | 88 +++++++++++++++++-- .../common/information_schema/ssts.sql | 33 +++++-- .../common/show/show_databases_tables.result | 3 + .../common/system/information_schema.result | 17 ++++ .../standalone/common/view/create.result | 1 + 11 files changed, 238 insertions(+), 20 deletions(-) diff --git a/src/catalog/src/system_schema/information_schema.rs b/src/catalog/src/system_schema/information_schema.rs index fc9bafa604..3ffcf73631 100644 --- a/src/catalog/src/system_schema/information_schema.rs +++ b/src/catalog/src/system_schema/information_schema.rs @@ -48,7 +48,7 @@ use datatypes::schema::SchemaRef; use lazy_static::lazy_static; use paste::paste; use process_list::InformationSchemaProcessList; -use store_api::sst_entry::{ManifestSstEntry, StorageSstEntry}; +use store_api::sst_entry::{ManifestSstEntry, PuffinIndexMetaEntry, StorageSstEntry}; use store_api::storage::{ScanRequest, TableId}; use table::TableRef; use table::metadata::TableType; @@ -68,7 +68,7 @@ use crate::system_schema::information_schema::region_peers::InformationSchemaReg use crate::system_schema::information_schema::runtime_metrics::InformationSchemaMetrics; use crate::system_schema::information_schema::schemata::InformationSchemaSchemata; use crate::system_schema::information_schema::ssts::{ - InformationSchemaSstsManifest, InformationSchemaSstsStorage, + InformationSchemaSstsIndexMeta, InformationSchemaSstsManifest, InformationSchemaSstsStorage, }; use crate::system_schema::information_schema::table_constraints::InformationSchemaTableConstraints; use crate::system_schema::information_schema::tables::InformationSchemaTables; @@ -263,6 +263,9 @@ impl SystemSchemaProviderInner for InformationSchemaProvider { SSTS_STORAGE => Some(Arc::new(InformationSchemaSstsStorage::new( self.catalog_manager.clone(), )) as _), + SSTS_INDEX_META => Some(Arc::new(InformationSchemaSstsIndexMeta::new( + self.catalog_manager.clone(), + )) as _), _ => None, } } @@ -342,6 +345,10 @@ impl InformationSchemaProvider { SSTS_STORAGE.to_string(), self.build_table(SSTS_STORAGE).unwrap(), ); + tables.insert( + SSTS_INDEX_META.to_string(), + self.build_table(SSTS_INDEX_META).unwrap(), + ); } tables.insert(TABLES.to_string(), self.build_table(TABLES).unwrap()); @@ -456,6 +463,8 @@ pub enum DatanodeInspectKind { SstManifest, /// List SST entries discovered in storage layer SstStorage, + /// List index metadata collected from manifest + SstIndexMeta, } impl DatanodeInspectRequest { @@ -464,6 +473,7 @@ impl DatanodeInspectRequest { match self.kind { DatanodeInspectKind::SstManifest => ManifestSstEntry::build_plan(self.scan), DatanodeInspectKind::SstStorage => StorageSstEntry::build_plan(self.scan), + DatanodeInspectKind::SstIndexMeta => PuffinIndexMetaEntry::build_plan(self.scan), } } } diff --git a/src/catalog/src/system_schema/information_schema/ssts.rs b/src/catalog/src/system_schema/information_schema/ssts.rs index 9ac7380550..1c0d507a29 100644 --- a/src/catalog/src/system_schema/information_schema/ssts.rs +++ b/src/catalog/src/system_schema/information_schema/ssts.rs @@ -15,20 +15,22 @@ use std::sync::{Arc, Weak}; use common_catalog::consts::{ - INFORMATION_SCHEMA_SSTS_MANIFEST_TABLE_ID, INFORMATION_SCHEMA_SSTS_STORAGE_TABLE_ID, + INFORMATION_SCHEMA_SSTS_INDEX_META_TABLE_ID, INFORMATION_SCHEMA_SSTS_MANIFEST_TABLE_ID, + INFORMATION_SCHEMA_SSTS_STORAGE_TABLE_ID, }; use common_error::ext::BoxedError; use common_recordbatch::SendableRecordBatchStream; use common_recordbatch::adapter::AsyncRecordBatchStreamAdapter; use datatypes::schema::SchemaRef; use snafu::ResultExt; -use store_api::sst_entry::{ManifestSstEntry, StorageSstEntry}; +use store_api::sst_entry::{ManifestSstEntry, PuffinIndexMetaEntry, StorageSstEntry}; use store_api::storage::{ScanRequest, TableId}; use crate::CatalogManager; use crate::error::{ProjectSchemaSnafu, Result}; use crate::information_schema::{ - DatanodeInspectKind, DatanodeInspectRequest, InformationTable, SSTS_MANIFEST, SSTS_STORAGE, + DatanodeInspectKind, DatanodeInspectRequest, InformationTable, SSTS_INDEX_META, SSTS_MANIFEST, + SSTS_STORAGE, }; use crate::system_schema::utils; @@ -140,3 +142,58 @@ impl InformationTable for InformationSchemaSstsStorage { ))) } } + +/// Information schema table for index metadata. +pub struct InformationSchemaSstsIndexMeta { + schema: SchemaRef, + catalog_manager: Weak, +} + +impl InformationSchemaSstsIndexMeta { + pub(super) fn new(catalog_manager: Weak) -> Self { + Self { + schema: PuffinIndexMetaEntry::schema(), + catalog_manager, + } + } +} + +impl InformationTable for InformationSchemaSstsIndexMeta { + fn table_id(&self) -> TableId { + INFORMATION_SCHEMA_SSTS_INDEX_META_TABLE_ID + } + + fn table_name(&self) -> &'static str { + SSTS_INDEX_META + } + + fn schema(&self) -> SchemaRef { + self.schema.clone() + } + + fn to_stream(&self, request: ScanRequest) -> Result { + let schema = if let Some(p) = &request.projection { + Arc::new(self.schema.try_project(p).context(ProjectSchemaSnafu)?) + } else { + self.schema.clone() + }; + + let info_ext = utils::information_extension(&self.catalog_manager)?; + let req = DatanodeInspectRequest { + kind: DatanodeInspectKind::SstIndexMeta, + scan: request, + }; + + let future = async move { + info_ext + .inspect_datanode(req) + .await + .map_err(BoxedError::new) + .context(common_recordbatch::error::ExternalSnafu) + }; + Ok(Box::pin(AsyncRecordBatchStreamAdapter::new( + schema, + Box::pin(future), + ))) + } +} diff --git a/src/catalog/src/system_schema/information_schema/table_names.rs b/src/catalog/src/system_schema/information_schema/table_names.rs index 63ae8afcdc..23791425dc 100644 --- a/src/catalog/src/system_schema/information_schema/table_names.rs +++ b/src/catalog/src/system_schema/information_schema/table_names.rs @@ -50,3 +50,4 @@ pub const REGION_STATISTICS: &str = "region_statistics"; pub const PROCESS_LIST: &str = "process_list"; pub const SSTS_MANIFEST: &str = "ssts_manifest"; pub const SSTS_STORAGE: &str = "ssts_storage"; +pub const SSTS_INDEX_META: &str = "ssts_index_meta"; diff --git a/src/common/catalog/src/consts.rs b/src/common/catalog/src/consts.rs index 949cc6076a..2bc5db9824 100644 --- a/src/common/catalog/src/consts.rs +++ b/src/common/catalog/src/consts.rs @@ -108,6 +108,8 @@ pub const INFORMATION_SCHEMA_PROCESS_LIST_TABLE_ID: u32 = 36; pub const INFORMATION_SCHEMA_SSTS_MANIFEST_TABLE_ID: u32 = 37; /// id for information_schema.ssts_storage pub const INFORMATION_SCHEMA_SSTS_STORAGE_TABLE_ID: u32 = 38; +/// id for information_schema.ssts_index_meta +pub const INFORMATION_SCHEMA_SSTS_INDEX_META_TABLE_ID: u32 = 39; // ----- End of information_schema tables ----- diff --git a/src/datanode/src/region_server/catalog.rs b/src/datanode/src/region_server/catalog.rs index 0aaec7498c..1c0f48951f 100644 --- a/src/datanode/src/region_server/catalog.rs +++ b/src/datanode/src/region_server/catalog.rs @@ -27,7 +27,7 @@ use datafusion_expr::{LogicalPlan, TableSource}; use futures::TryStreamExt; use session::context::QueryContextRef; use snafu::{OptionExt, ResultExt}; -use store_api::sst_entry::{ManifestSstEntry, StorageSstEntry}; +use store_api::sst_entry::{ManifestSstEntry, PuffinIndexMetaEntry, StorageSstEntry}; use store_api::storage::RegionId; use crate::error::{DataFusionSnafu, ListStorageSstsSnafu, Result, UnexpectedSnafu}; @@ -35,10 +35,12 @@ use crate::region_server::RegionServer; /// Reserved internal table kinds used. /// These are recognized by reserved table names and mapped to providers. +#[allow(clippy::enum_variant_names)] #[derive(Clone, Debug, PartialEq, Eq, Hash, Copy)] enum InternalTableKind { InspectSstManifest, InspectSstStorage, + InspectSstIndexMeta, } impl InternalTableKind { @@ -50,6 +52,9 @@ impl InternalTableKind { if name.eq_ignore_ascii_case(StorageSstEntry::reserved_table_name_for_inspection()) { return Some(Self::InspectSstStorage); } + if name.eq_ignore_ascii_case(PuffinIndexMetaEntry::reserved_table_name_for_inspection()) { + return Some(Self::InspectSstIndexMeta); + } None } @@ -58,6 +63,7 @@ impl InternalTableKind { match self { Self::InspectSstManifest => server.inspect_sst_manifest_provider().await, Self::InspectSstStorage => server.inspect_sst_storage_provider().await, + Self::InspectSstIndexMeta => server.inspect_sst_index_meta_provider().await, } } } @@ -103,6 +109,25 @@ impl RegionServer { let table = MemTable::try_new(schema, vec![vec![batch]]).context(DataFusionSnafu)?; Ok(Arc::new(table)) } + + /// Expose index metadata across the engine as an in-memory table. + pub async fn inspect_sst_index_meta_provider(&self) -> Result> { + let mito = { + let guard = self.inner.mito_engine.read().unwrap(); + guard.as_ref().cloned().context(UnexpectedSnafu { + violated: "mito engine not available", + })? + }; + + let entries = mito.all_index_metas().await; + let schema = PuffinIndexMetaEntry::schema().arrow_schema().clone(); + let batch = PuffinIndexMetaEntry::to_record_batch(&entries) + .map_err(DataFusionError::from) + .context(DataFusionSnafu)?; + + let table = MemTable::try_new(schema, vec![vec![batch]]).context(DataFusionSnafu)?; + Ok(Arc::new(table)) + } } /// A catalog list that resolves `TableProvider` by table name: diff --git a/src/store-api/src/sst_entry.rs b/src/store-api/src/sst_entry.rs index 34e37de7ea..8330af7b2e 100644 --- a/src/store-api/src/sst_entry.rs +++ b/src/store-api/src/sst_entry.rs @@ -356,6 +356,15 @@ impl PuffinIndexMetaEntry { pub fn reserved_table_name_for_inspection() -> &'static str { "__inspect/__mito/__puffin_index_meta" } + + /// Builds a logical plan for scanning puffin index metadata entries. + pub fn build_plan(scan_request: ScanRequest) -> Result { + build_plan_helper( + scan_request, + Self::reserved_table_name_for_inspection(), + Self::schema(), + ) + } } fn build_plan_helper( diff --git a/tests/cases/standalone/common/information_schema/ssts.result b/tests/cases/standalone/common/information_schema/ssts.result index 61d51e8605..2c28e6e63c 100644 --- a/tests/cases/standalone/common/information_schema/ssts.result +++ b/tests/cases/standalone/common/information_schema/ssts.result @@ -36,9 +36,33 @@ DESC TABLE information_schema.ssts_storage; | node_id | UInt64 | | YES | | FIELD | +------------------+----------------------+-----+------+---------+---------------+ +DESC TABLE information_schema.ssts_index_meta; + ++-----------------+--------+-----+------+---------+---------------+ +| Column | Type | Key | Null | Default | Semantic Type | ++-----------------+--------+-----+------+---------+---------------+ +| table_dir | String | | NO | | FIELD | +| index_file_path | String | | NO | | FIELD | +| region_id | UInt64 | | NO | | FIELD | +| table_id | UInt32 | | NO | | FIELD | +| region_number | UInt32 | | NO | | FIELD | +| region_group | UInt8 | | NO | | FIELD | +| region_sequence | UInt32 | | NO | | FIELD | +| file_id | String | | NO | | FIELD | +| index_file_size | UInt64 | | YES | | FIELD | +| index_type | String | | NO | | FIELD | +| target_type | String | | NO | | FIELD | +| target_key | String | | NO | | FIELD | +| target_json | String | | NO | | FIELD | +| blob_size | UInt64 | | NO | | FIELD | +| meta_json | String | | YES | | FIELD | +| node_id | UInt64 | | YES | | FIELD | ++-----------------+--------+-----+------+---------+---------------+ + CREATE TABLE sst_case ( - a INT PRIMARY KEY, + a INT PRIMARY KEY INVERTED INDEX, b STRING SKIPPING INDEX, + c STRING FULLTEXT INDEX, ts TIMESTAMP TIME INDEX, ) PARTITION ON COLUMNS (a) ( @@ -50,9 +74,9 @@ PARTITION ON COLUMNS (a) ( Affected Rows: 0 INSERT INTO sst_case VALUES - (500, 'a', 1), - (1500, 'b', 2), - (2500, 'c', 3); + (500, 'a', 'a', 1), + (1500, 'b', 'b', 2), + (2500, 'c', 'c', 3); Affected Rows: 3 @@ -79,6 +103,28 @@ SELECT * FROM information_schema.ssts_manifest order by file_path; | data/greptime/public// |||||| || data/greptime/public//_/.parquet || data/greptime/public//_/index/.puffin |||| | |||| true | +----------------------------+---------------+----------+---------------+--------------+-----------------+--------------------------------------+-------+----------------------------------------------------------------------------------------+-----------+---------------------------------------------------------------------------------------------+-----------------+----------+----------------+-------------------------+-------------------------+----------+------------------+---------+---------+ +-- SQLNESS REPLACE (\s+\d+\s+) +-- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}) +-- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}) +-- SQLNESS REPLACE (/public/\d+/\d+_\d+/index/\.puffin) /public//_/index/.puffin +-- SQLNESS REPLACE (/public/\d+/\d+_\d+) /public//_ +-- SQLNESS REPLACE (/public/\d+) /public/ +SELECT * FROM information_schema.ssts_index_meta ORDER BY meta_json; + ++----------------------------+---------------------------------------------------------------------------------------------+---------------+----------+---------------+--------------+-----------------+--------------------------------------+-----------------+----------------+-------------+------------+--------------+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ +| table_dir | index_file_path | region_id | table_id | region_number | region_group | region_sequence | file_id | index_file_size | index_type | target_type | target_key | target_json | blob_size | meta_json | node_id | ++----------------------------+---------------------------------------------------------------------------------------------+---------------+----------+---------------+--------------+-----------------+--------------------------------------+-----------------+----------------+-------------+------------+--------------+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || fulltext_bloom | column || {"column":2} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1},"fulltext":{"analyzer":"English","case_sensitive":false}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || fulltext_bloom | column || {"column":2} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1},"fulltext":{"analyzer":"English","case_sensitive":false}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || fulltext_bloom | column || {"column":2} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1},"fulltext":{"analyzer":"English","case_sensitive":false}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || bloom_filter | column || {"column":1} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || bloom_filter | column || {"column":1} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || bloom_filter | column || {"column":1} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || inverted | column || {"column":0} || {"inverted":{"base_offset":0,"bitmap_type":"Roaring","fst_size":55,"inverted_index_size":81,"null_bitmap_size":8,"relative_fst_offset":26,"relative_null_bitmap_offset":0,"segment_row_count":1024,"total_row_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || inverted | column || {"column":0} || {"inverted":{"base_offset":0,"bitmap_type":"Roaring","fst_size":55,"inverted_index_size":81,"null_bitmap_size":8,"relative_fst_offset":26,"relative_null_bitmap_offset":0,"segment_row_count":1024,"total_row_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || inverted | column || {"column":0} || {"inverted":{"base_offset":0,"bitmap_type":"Roaring","fst_size":55,"inverted_index_size":81,"null_bitmap_size":8,"relative_fst_offset":26,"relative_null_bitmap_offset":0,"segment_row_count":1024,"total_row_count":1}} || ++----------------------------+---------------------------------------------------------------------------------------------+---------------+----------+---------------+--------------+-----------------+--------------------------------------+-----------------+----------------+-------------+------------+--------------+-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ + -- SQLNESS REPLACE (\s+\d+\s+) -- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}) -- SQLNESS REPLACE (/public/\d+/\d+_\d+) /public//_ @@ -96,9 +142,9 @@ SELECT * FROM information_schema.ssts_storage order by file_path; +---------------------------------------------------------------------------------------------+-----------+------------------+---------+ INSERT INTO sst_case VALUES - (24, 'foo', 100), - (124, 'bar', 200), - (1024, 'baz', 300); + (24, 'foo', 'foo', 100), + (124, 'bar', 'bar', 200), + (1024, 'baz', 'baz', 300); Affected Rows: 3 @@ -127,6 +173,34 @@ SELECT * FROM information_schema.ssts_manifest order by file_path; | data/greptime/public// |||||| || data/greptime/public//_/.parquet || data/greptime/public//_/index/.puffin |||| | |||| true | +----------------------------+---------------+----------+---------------+--------------+-----------------+--------------------------------------+-------+----------------------------------------------------------------------------------------+-----------+---------------------------------------------------------------------------------------------+-----------------+----------+----------------+-------------------------+-------------------------+----------+------------------+---------+---------+ +-- SQLNESS REPLACE (\s+\d+\s+) +-- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}) +-- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}) +-- SQLNESS REPLACE (/public/\d+/\d+_\d+/index/\.puffin) /public//_/index/.puffin +-- SQLNESS REPLACE (/public/\d+/\d+_\d+) /public//_ +-- SQLNESS REPLACE (/public/\d+) /public/ +SELECT * FROM information_schema.ssts_index_meta ORDER BY meta_json; + ++----------------------------+---------------------------------------------------------------------------------------------+---------------+----------+---------------+--------------+-----------------+--------------------------------------+-----------------+----------------+-------------+------------+--------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ +| table_dir | index_file_path | region_id | table_id | region_number | region_group | region_sequence | file_id | index_file_size | index_type | target_type | target_key | target_json | blob_size | meta_json | node_id | ++----------------------------+---------------------------------------------------------------------------------------------+---------------+----------+---------------+--------------+-----------------+--------------------------------------+-----------------+----------------+-------------+------------+--------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || fulltext_bloom | column || {"column":2} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1},"fulltext":{"analyzer":"English","case_sensitive":false}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || fulltext_bloom | column || {"column":2} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1},"fulltext":{"analyzer":"English","case_sensitive":false}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || fulltext_bloom | column || {"column":2} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1},"fulltext":{"analyzer":"English","case_sensitive":false}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || fulltext_bloom | column || {"column":2} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1},"fulltext":{"analyzer":"English","case_sensitive":false}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || bloom_filter | column || {"column":1} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || bloom_filter | column || {"column":1} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || bloom_filter | column || {"column":1} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || bloom_filter | column || {"column":1} || {"bloom":{"bloom_filter_size":64,"row_count":1,"rows_per_segment":10240,"segment_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || fulltext_bloom | column || {"column":2} || {"bloom":{"bloom_filter_size":64,"row_count":2,"rows_per_segment":10240,"segment_count":1},"fulltext":{"analyzer":"English","case_sensitive":false}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || bloom_filter | column || {"column":1} || {"bloom":{"bloom_filter_size":64,"row_count":2,"rows_per_segment":10240,"segment_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || inverted | column || {"column":0} || {"inverted":{"base_offset":0,"bitmap_type":"Roaring","fst_size":55,"inverted_index_size":81,"null_bitmap_size":8,"relative_fst_offset":26,"relative_null_bitmap_offset":0,"segment_row_count":1024,"total_row_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || inverted | column || {"column":0} || {"inverted":{"base_offset":0,"bitmap_type":"Roaring","fst_size":55,"inverted_index_size":81,"null_bitmap_size":8,"relative_fst_offset":26,"relative_null_bitmap_offset":0,"segment_row_count":1024,"total_row_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || inverted | column || {"column":0} || {"inverted":{"base_offset":0,"bitmap_type":"Roaring","fst_size":55,"inverted_index_size":81,"null_bitmap_size":8,"relative_fst_offset":26,"relative_null_bitmap_offset":0,"segment_row_count":1024,"total_row_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || inverted | column || {"column":0} || {"inverted":{"base_offset":0,"bitmap_type":"Roaring","fst_size":55,"inverted_index_size":81,"null_bitmap_size":8,"relative_fst_offset":26,"relative_null_bitmap_offset":0,"segment_row_count":1024,"total_row_count":1}} || +| data/greptime/public// | data/greptime/public//_/index/.puffin |||||| || inverted | column || {"column":0} || {"inverted":{"base_offset":0,"bitmap_type":"Roaring","fst_size":59,"inverted_index_size":103,"null_bitmap_size":8,"relative_fst_offset":44,"relative_null_bitmap_offset":0,"segment_row_count":1024,"total_row_count":2}} || ++----------------------------+---------------------------------------------------------------------------------------------+---------------+----------+---------------+--------------+-----------------+--------------------------------------+-----------------+----------------+-------------+------------+--------------+-----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------+ + -- SQLNESS REPLACE (\s+\d+\s+) -- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}) -- SQLNESS REPLACE (/public/\d+/\d+_\d+) /public//_ diff --git a/tests/cases/standalone/common/information_schema/ssts.sql b/tests/cases/standalone/common/information_schema/ssts.sql index 9febc456cd..f411c8f67a 100644 --- a/tests/cases/standalone/common/information_schema/ssts.sql +++ b/tests/cases/standalone/common/information_schema/ssts.sql @@ -2,9 +2,12 @@ DESC TABLE information_schema.ssts_manifest; DESC TABLE information_schema.ssts_storage; +DESC TABLE information_schema.ssts_index_meta; + CREATE TABLE sst_case ( - a INT PRIMARY KEY, + a INT PRIMARY KEY INVERTED INDEX, b STRING SKIPPING INDEX, + c STRING FULLTEXT INDEX, ts TIMESTAMP TIME INDEX, ) PARTITION ON COLUMNS (a) ( @@ -14,9 +17,9 @@ PARTITION ON COLUMNS (a) ( ); INSERT INTO sst_case VALUES - (500, 'a', 1), - (1500, 'b', 2), - (2500, 'c', 3); + (500, 'a', 'a', 1), + (1500, 'b', 'b', 2), + (2500, 'c', 'c', 3); ADMIN FLUSH_TABLE('sst_case'); @@ -27,15 +30,23 @@ ADMIN FLUSH_TABLE('sst_case'); -- SQLNESS REPLACE (/public/\d+) /public/ SELECT * FROM information_schema.ssts_manifest order by file_path; +-- SQLNESS REPLACE (\s+\d+\s+) +-- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}) +-- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}) +-- SQLNESS REPLACE (/public/\d+/\d+_\d+/index/\.puffin) /public//_/index/.puffin +-- SQLNESS REPLACE (/public/\d+/\d+_\d+) /public//_ +-- SQLNESS REPLACE (/public/\d+) /public/ +SELECT * FROM information_schema.ssts_index_meta ORDER BY meta_json; + -- SQLNESS REPLACE (\s+\d+\s+) -- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}) -- SQLNESS REPLACE (/public/\d+/\d+_\d+) /public//_ SELECT * FROM information_schema.ssts_storage order by file_path; INSERT INTO sst_case VALUES - (24, 'foo', 100), - (124, 'bar', 200), - (1024, 'baz', 300); + (24, 'foo', 'foo', 100), + (124, 'bar', 'bar', 200), + (1024, 'baz', 'baz', 300); ADMIN FLUSH_TABLE('sst_case'); @@ -46,6 +57,14 @@ ADMIN FLUSH_TABLE('sst_case'); -- SQLNESS REPLACE (/public/\d+) /public/ SELECT * FROM information_schema.ssts_manifest order by file_path; +-- SQLNESS REPLACE (\s+\d+\s+) +-- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}) +-- SQLNESS REPLACE (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3,9}) +-- SQLNESS REPLACE (/public/\d+/\d+_\d+/index/\.puffin) /public//_/index/.puffin +-- SQLNESS REPLACE (/public/\d+/\d+_\d+) /public//_ +-- SQLNESS REPLACE (/public/\d+) /public/ +SELECT * FROM information_schema.ssts_index_meta ORDER BY meta_json; + -- SQLNESS REPLACE (\s+\d+\s+) -- SQLNESS REPLACE ([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}) -- SQLNESS REPLACE (/public/\d+/\d+_\d+) /public//_ diff --git a/tests/cases/standalone/common/show/show_databases_tables.result b/tests/cases/standalone/common/show/show_databases_tables.result index 97e8588569..e9b97d53e5 100644 --- a/tests/cases/standalone/common/show/show_databases_tables.result +++ b/tests/cases/standalone/common/show/show_databases_tables.result @@ -56,6 +56,7 @@ SHOW TABLES; | schema_privileges | | schemata | | session_status | +| ssts_index_meta | | ssts_manifest | | ssts_storage | | table_constraints | @@ -107,6 +108,7 @@ SHOW FULL TABLES; | schema_privileges | LOCAL TEMPORARY | | schemata | LOCAL TEMPORARY | | session_status | LOCAL TEMPORARY | +| ssts_index_meta | LOCAL TEMPORARY | | ssts_manifest | LOCAL TEMPORARY | | ssts_storage | LOCAL TEMPORARY | | table_constraints | LOCAL TEMPORARY | @@ -152,6 +154,7 @@ SHOW TABLE STATUS; |schema_privileges||11|Fixed|0|0|0|0|0|0|0|DATETIME|DATETIME||utf8_bin|0||| |schemata||11|Fixed|0|0|0|0|0|0|0|DATETIME|DATETIME||utf8_bin|0||| |session_status||11|Fixed|0|0|0|0|0|0|0|DATETIME|DATETIME||utf8_bin|0||| +|ssts_index_meta||11|Fixed|0|0|0|0|0|0|0|DATETIME|DATETIME||utf8_bin|0||| |ssts_manifest||11|Fixed|0|0|0|0|0|0|0|DATETIME|DATETIME||utf8_bin|0||| |ssts_storage||11|Fixed|0|0|0|0|0|0|0|DATETIME|DATETIME||utf8_bin|0||| |table_constraints||11|Fixed|0|0|0|0|0|0|0|DATETIME|DATETIME||utf8_bin|0||| diff --git a/tests/cases/standalone/common/system/information_schema.result b/tests/cases/standalone/common/system/information_schema.result index 7da0520b3e..eef56b91b2 100644 --- a/tests/cases/standalone/common/system/information_schema.result +++ b/tests/cases/standalone/common/system/information_schema.result @@ -43,6 +43,7 @@ order by table_schema, table_name; |greptime|information_schema|schema_privileges|LOCALTEMPORARY|22|0|0|0|0|0||11|Fixed|0|0|0|DATETIME|DATETIME||utf8_bin|0|||Y| |greptime|information_schema|schemata|LOCALTEMPORARY|15|0|0|0|0|0||11|Fixed|0|0|0|DATETIME|DATETIME||utf8_bin|0|||Y| |greptime|information_schema|session_status|LOCALTEMPORARY|26|0|0|0|0|0||11|Fixed|0|0|0|DATETIME|DATETIME||utf8_bin|0|||Y| +|greptime|information_schema|ssts_index_meta|LOCALTEMPORARY|39|0|0|0|0|0||11|Fixed|0|0|0|DATETIME|DATETIME||utf8_bin|0|||Y| |greptime|information_schema|ssts_manifest|LOCALTEMPORARY|37|0|0|0|0|0||11|Fixed|0|0|0|DATETIME|DATETIME||utf8_bin|0|||Y| |greptime|information_schema|ssts_storage|LOCALTEMPORARY|38|0|0|0|0|0||11|Fixed|0|0|0|DATETIME|DATETIME||utf8_bin|0|||Y| |greptime|information_schema|table_constraints|LOCALTEMPORARY|30|0|0|0|0|0||11|Fixed|0|0|0|DATETIME|DATETIME||utf8_bin|0|||Y| @@ -386,6 +387,22 @@ select * from information_schema.columns order by table_schema, table_name, colu | greptime | information_schema | schemata | sql_path | 5 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | | greptime | information_schema | session_status | variable_name | 1 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | session_status | variable_value | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | ssts_index_meta | blob_size | 14 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | No | bigint unsigned | | | +| greptime | information_schema | ssts_index_meta | file_id | 8 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | ssts_index_meta | index_file_path | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | ssts_index_meta | index_file_size | 9 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | +| greptime | information_schema | ssts_index_meta | index_type | 10 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | ssts_index_meta | meta_json | 15 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | +| greptime | information_schema | ssts_index_meta | node_id | 16 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | Yes | bigint unsigned | | | +| greptime | information_schema | ssts_index_meta | region_group | 6 | | | 3 | 0 | | | | | | select,insert | | UInt8 | tinyint unsigned | FIELD | | No | tinyint unsigned | | | +| greptime | information_schema | ssts_index_meta | region_id | 3 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | No | bigint unsigned | | | +| greptime | information_schema | ssts_index_meta | region_number | 5 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | +| greptime | information_schema | ssts_index_meta | region_sequence | 7 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | +| greptime | information_schema | ssts_index_meta | table_dir | 1 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | ssts_index_meta | table_id | 4 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | +| greptime | information_schema | ssts_index_meta | target_json | 13 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | ssts_index_meta | target_key | 12 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | ssts_index_meta | target_type | 11 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | ssts_manifest | file_id | 7 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | ssts_manifest | file_path | 9 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | ssts_manifest | file_size | 10 | | | 20 | 0 | | | | | | select,insert | | UInt64 | bigint unsigned | FIELD | | No | bigint unsigned | | | diff --git a/tests/cases/standalone/common/view/create.result b/tests/cases/standalone/common/view/create.result index cdb4a80d99..f524ed1c05 100644 --- a/tests/cases/standalone/common/view/create.result +++ b/tests/cases/standalone/common/view/create.result @@ -117,6 +117,7 @@ SELECT * FROM INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME, TABLE_TYPE; |greptime|information_schema|schema_privileges|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME|DATETIME||utf8_bin|ID|||Y| |greptime|information_schema|schemata|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME|DATETIME||utf8_bin|ID|||Y| |greptime|information_schema|session_status|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME|DATETIME||utf8_bin|ID|||Y| +|greptime|information_schema|ssts_index_meta|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME|DATETIME||utf8_bin|ID|||Y| |greptime|information_schema|ssts_manifest|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME|DATETIME||utf8_bin|ID|||Y| |greptime|information_schema|ssts_storage|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME|DATETIME||utf8_bin|ID|||Y| |greptime|information_schema|table_constraints|LOCALTEMPORARY|ID|ID|ID|ID|ID|ID||ID|Fixed|ID|ID|ID|DATETIME|DATETIME||utf8_bin|ID|||Y|