From 8d485e9be0da767db281af758de4859a20ffab0e Mon Sep 17 00:00:00 2001 From: Zhenchi Date: Tue, 15 Apr 2025 14:36:06 +0800 Subject: [PATCH] feat: support altering fulltext backend (#5896) * feat: add `greptime_index_type` to `information_schema.key_column_usage` Signed-off-by: Zhenchi * fix: show create Signed-off-by: Zhenchi --------- Signed-off-by: Zhenchi --- .../information_schema/key_column_usage.rs | 69 +++++++-- .../information_schema/table_constraints.rs | 6 +- src/datatypes/src/schema/column_schema.rs | 2 +- src/query/src/sql.rs | 34 +--- src/query/src/sql/show_create_table.rs | 10 +- src/store-api/src/metadata.rs | 16 +- src/table/src/metadata.rs | 16 +- tests-integration/tests/http.rs | 2 +- .../alter/change_col_fulltext_options.result | 146 +++++++++++++----- .../alter/change_col_fulltext_options.sql | 14 ++ .../common/create/create_with_fulltext.result | 74 ++++----- .../standalone/common/show/show_create.result | 28 ++-- .../standalone/common/show/show_index.result | 36 ++--- .../common/system/information_schema.result | 32 ++-- 14 files changed, 294 insertions(+), 191 deletions(-) diff --git a/src/catalog/src/system_schema/information_schema/key_column_usage.rs b/src/catalog/src/system_schema/information_schema/key_column_usage.rs index 9f08839303..ffcd5eaaa5 100644 --- a/src/catalog/src/system_schema/information_schema/key_column_usage.rs +++ b/src/catalog/src/system_schema/information_schema/key_column_usage.rs @@ -24,7 +24,7 @@ use datafusion::physical_plan::stream::RecordBatchStreamAdapter as DfRecordBatch use datafusion::physical_plan::streaming::PartitionStream as DfPartitionStream; use datafusion::physical_plan::SendableRecordBatchStream as DfSendableRecordBatchStream; use datatypes::prelude::{ConcreteDataType, MutableVector, ScalarVectorBuilder, VectorRef}; -use datatypes::schema::{ColumnSchema, Schema, SchemaRef}; +use datatypes::schema::{ColumnSchema, FulltextBackend, Schema, SchemaRef}; use datatypes::value::Value; use datatypes::vectors::{ConstantVector, StringVector, StringVectorBuilder, UInt32VectorBuilder}; use futures_util::TryStreamExt; @@ -47,20 +47,38 @@ pub const TABLE_SCHEMA: &str = "table_schema"; pub const TABLE_NAME: &str = "table_name"; pub const COLUMN_NAME: &str = "column_name"; pub const ORDINAL_POSITION: &str = "ordinal_position"; +/// The type of the index. +pub const GREPTIME_INDEX_TYPE: &str = "greptime_index_type"; const INIT_CAPACITY: usize = 42; -/// Primary key constraint name -pub(crate) const PRI_CONSTRAINT_NAME: &str = "PRIMARY"; /// Time index constraint name -pub(crate) const TIME_INDEX_CONSTRAINT_NAME: &str = "TIME INDEX"; +pub(crate) const CONSTRAINT_NAME_TIME_INDEX: &str = "TIME INDEX"; + +/// Primary key constraint name +pub(crate) const CONSTRAINT_NAME_PRI: &str = "PRIMARY"; +/// Primary key index type +pub(crate) const INDEX_TYPE_PRI: &str = "greptime-primary-key-v1"; + /// Inverted index constraint name -pub(crate) const INVERTED_INDEX_CONSTRAINT_NAME: &str = "INVERTED INDEX"; +pub(crate) const CONSTRAINT_NAME_INVERTED_INDEX: &str = "INVERTED INDEX"; +/// Inverted index type +pub(crate) const INDEX_TYPE_INVERTED_INDEX: &str = "greptime-inverted-index-v1"; + /// Fulltext index constraint name -pub(crate) const FULLTEXT_INDEX_CONSTRAINT_NAME: &str = "FULLTEXT INDEX"; +pub(crate) const CONSTRAINT_NAME_FULLTEXT_INDEX: &str = "FULLTEXT INDEX"; +/// Fulltext index v1 type +pub(crate) const INDEX_TYPE_FULLTEXT_TANTIVY: &str = "greptime-fulltext-index-v1"; +/// Fulltext index bloom type +pub(crate) const INDEX_TYPE_FULLTEXT_BLOOM: &str = "greptime-fulltext-index-bloom"; + /// Skipping index constraint name -pub(crate) const SKIPPING_INDEX_CONSTRAINT_NAME: &str = "SKIPPING INDEX"; +pub(crate) const CONSTRAINT_NAME_SKIPPING_INDEX: &str = "SKIPPING INDEX"; +/// Skipping index type +pub(crate) const INDEX_TYPE_SKIPPING_INDEX: &str = "greptime-bloom-filter-v1"; /// The virtual table implementation for `information_schema.KEY_COLUMN_USAGE`. +/// +/// Provides an extra column `greptime_index_type` for the index type of the key column. #[derive(Debug)] pub(super) struct InformationSchemaKeyColumnUsage { schema: SchemaRef, @@ -120,6 +138,11 @@ impl InformationSchemaKeyColumnUsage { ConcreteDataType::string_datatype(), true, ), + ColumnSchema::new( + GREPTIME_INDEX_TYPE, + ConcreteDataType::string_datatype(), + true, + ), ])) } @@ -184,6 +207,7 @@ struct InformationSchemaKeyColumnUsageBuilder { column_name: StringVectorBuilder, ordinal_position: UInt32VectorBuilder, position_in_unique_constraint: UInt32VectorBuilder, + greptime_index_type: StringVectorBuilder, } impl InformationSchemaKeyColumnUsageBuilder { @@ -206,6 +230,7 @@ impl InformationSchemaKeyColumnUsageBuilder { column_name: StringVectorBuilder::with_capacity(INIT_CAPACITY), ordinal_position: UInt32VectorBuilder::with_capacity(INIT_CAPACITY), position_in_unique_constraint: UInt32VectorBuilder::with_capacity(INIT_CAPACITY), + greptime_index_type: StringVectorBuilder::with_capacity(INIT_CAPACITY), } } @@ -229,34 +254,47 @@ impl InformationSchemaKeyColumnUsageBuilder { for (idx, column) in schema.column_schemas().iter().enumerate() { let mut constraints = vec![]; + let mut greptime_index_type = vec![]; if column.is_time_index() { self.add_key_column_usage( &predicates, &schema_name, - TIME_INDEX_CONSTRAINT_NAME, + CONSTRAINT_NAME_TIME_INDEX, &catalog_name, &schema_name, table_name, &column.name, 1, //always 1 for time index + "", ); } // TODO(dimbtp): foreign key constraint not supported yet if keys.contains(&idx) { - constraints.push(PRI_CONSTRAINT_NAME); + constraints.push(CONSTRAINT_NAME_PRI); + greptime_index_type.push(INDEX_TYPE_PRI); } if column.is_inverted_indexed() { - constraints.push(INVERTED_INDEX_CONSTRAINT_NAME); + constraints.push(CONSTRAINT_NAME_INVERTED_INDEX); + greptime_index_type.push(INDEX_TYPE_INVERTED_INDEX); } - if column.is_fulltext_indexed() { - constraints.push(FULLTEXT_INDEX_CONSTRAINT_NAME); + if let Ok(Some(options)) = column.fulltext_options() { + if options.enable { + constraints.push(CONSTRAINT_NAME_FULLTEXT_INDEX); + let index_type = match options.backend { + FulltextBackend::Bloom => INDEX_TYPE_FULLTEXT_BLOOM, + FulltextBackend::Tantivy => INDEX_TYPE_FULLTEXT_TANTIVY, + }; + greptime_index_type.push(index_type); + } } if column.is_skipping_indexed() { - constraints.push(SKIPPING_INDEX_CONSTRAINT_NAME); + constraints.push(CONSTRAINT_NAME_SKIPPING_INDEX); + greptime_index_type.push(INDEX_TYPE_SKIPPING_INDEX); } if !constraints.is_empty() { let aggregated_constraints = constraints.join(", "); + let aggregated_index_types = greptime_index_type.join(", "); self.add_key_column_usage( &predicates, &schema_name, @@ -266,6 +304,7 @@ impl InformationSchemaKeyColumnUsageBuilder { table_name, &column.name, idx as u32 + 1, + &aggregated_index_types, ); } } @@ -288,6 +327,7 @@ impl InformationSchemaKeyColumnUsageBuilder { table_name: &str, column_name: &str, ordinal_position: u32, + index_types: &str, ) { let row = [ (CONSTRAINT_SCHEMA, &Value::from(constraint_schema)), @@ -297,6 +337,7 @@ impl InformationSchemaKeyColumnUsageBuilder { (TABLE_NAME, &Value::from(table_name)), (COLUMN_NAME, &Value::from(column_name)), (ORDINAL_POSITION, &Value::from(ordinal_position)), + (GREPTIME_INDEX_TYPE, &Value::from(index_types)), ]; if !predicates.eval(&row) { @@ -313,6 +354,7 @@ impl InformationSchemaKeyColumnUsageBuilder { self.column_name.push(Some(column_name)); self.ordinal_position.push(Some(ordinal_position)); self.position_in_unique_constraint.push(None); + self.greptime_index_type.push(Some(index_types)); } fn finish(&mut self) -> Result { @@ -336,6 +378,7 @@ impl InformationSchemaKeyColumnUsageBuilder { null_string_vector.clone(), null_string_vector.clone(), null_string_vector, + Arc::new(self.greptime_index_type.finish()), ]; RecordBatch::new(self.schema.clone(), columns).context(CreateRecordBatchSnafu) } diff --git a/src/catalog/src/system_schema/information_schema/table_constraints.rs b/src/catalog/src/system_schema/information_schema/table_constraints.rs index a1f9d899f4..77ac93632f 100644 --- a/src/catalog/src/system_schema/information_schema/table_constraints.rs +++ b/src/catalog/src/system_schema/information_schema/table_constraints.rs @@ -36,7 +36,7 @@ use crate::error::{ CreateRecordBatchSnafu, InternalSnafu, Result, UpgradeWeakCatalogManagerRefSnafu, }; use crate::information_schema::key_column_usage::{ - PRI_CONSTRAINT_NAME, TIME_INDEX_CONSTRAINT_NAME, + CONSTRAINT_NAME_PRI, CONSTRAINT_NAME_TIME_INDEX, }; use crate::information_schema::Predicates; use crate::system_schema::information_schema::{InformationTable, TABLE_CONSTRAINTS}; @@ -188,7 +188,7 @@ impl InformationSchemaTableConstraintsBuilder { self.add_table_constraint( &predicates, &schema_name, - TIME_INDEX_CONSTRAINT_NAME, + CONSTRAINT_NAME_TIME_INDEX, &schema_name, &table.table_info().name, TIME_INDEX_CONSTRAINT_TYPE, @@ -199,7 +199,7 @@ impl InformationSchemaTableConstraintsBuilder { self.add_table_constraint( &predicates, &schema_name, - PRI_CONSTRAINT_NAME, + CONSTRAINT_NAME_PRI, &schema_name, &table.table_info().name, PRI_KEY_CONSTRAINT_TYPE, diff --git a/src/datatypes/src/schema/column_schema.rs b/src/datatypes/src/schema/column_schema.rs index 9a975c4008..376c9e6de0 100644 --- a/src/datatypes/src/schema/column_schema.rs +++ b/src/datatypes/src/schema/column_schema.rs @@ -537,8 +537,8 @@ impl fmt::Display for FulltextOptions { #[serde(rename_all = "kebab-case")] pub enum FulltextBackend { #[default] + Bloom, Tantivy, - Bloom, // TODO(zhongzc): when bloom is ready, use it as default } impl fmt::Display for FulltextBackend { diff --git a/src/query/src/sql.rs b/src/query/src/sql.rs index b62289fb6b..8f823fe809 100644 --- a/src/query/src/sql.rs +++ b/src/query/src/sql.rs @@ -40,7 +40,7 @@ use common_recordbatch::RecordBatches; use common_time::timezone::get_timezone; use common_time::Timestamp; use datafusion::common::ScalarValue; -use datafusion::prelude::{concat_ws, SessionContext}; +use datafusion::prelude::SessionContext; use datafusion_expr::expr::WildcardOptions; use datafusion_expr::{case, col, lit, Expr, SortExpr}; use datatypes::prelude::*; @@ -399,23 +399,6 @@ pub async fn show_index( query_ctx.current_schema() }; - let primary_key_expr = case(col("constraint_name").like(lit("%PRIMARY%"))) - .when(lit(true), lit("greptime-primary-key-v1")) - .otherwise(null()) - .context(error::PlanSqlSnafu)?; - let inverted_index_expr = case(col("constraint_name").like(lit("%INVERTED INDEX%"))) - .when(lit(true), lit("greptime-inverted-index-v1")) - .otherwise(null()) - .context(error::PlanSqlSnafu)?; - let fulltext_index_expr = case(col("constraint_name").like(lit("%FULLTEXT INDEX%"))) - .when(lit(true), lit("greptime-fulltext-index-v1")) - .otherwise(null()) - .context(error::PlanSqlSnafu)?; - let skipping_index_expr = case(col("constraint_name").like(lit("%SKIPPING INDEX%"))) - .when(lit(true), lit("greptime-bloom-filter-v1")) - .otherwise(null()) - .context(error::PlanSqlSnafu)?; - let select = vec![ // 1 as `Non_unique`: contain duplicates lit(1).alias(INDEX_NONT_UNIQUE_COLUMN), @@ -433,16 +416,6 @@ pub async fn show_index( .otherwise(lit(YES_STR)) .context(error::PlanSqlSnafu)? .alias(COLUMN_NULLABLE_COLUMN), - concat_ws( - lit(", "), - vec![ - primary_key_expr, - inverted_index_expr, - fulltext_index_expr, - skipping_index_expr, - ], - ) - .alias(INDEX_INDEX_TYPE_COLUMN), lit("").alias(COLUMN_COMMENT_COLUMN), lit("").alias(INDEX_COMMENT_COLUMN), lit(YES_STR).alias(INDEX_VISIBLE_COLUMN), @@ -467,7 +440,10 @@ pub async fn show_index( (INDEX_SUB_PART_COLUMN, INDEX_SUB_PART_COLUMN), (INDEX_PACKED_COLUMN, INDEX_PACKED_COLUMN), (COLUMN_NULLABLE_COLUMN, COLUMN_NULLABLE_COLUMN), - (INDEX_INDEX_TYPE_COLUMN, INDEX_INDEX_TYPE_COLUMN), + ( + key_column_usage::GREPTIME_INDEX_TYPE, + INDEX_INDEX_TYPE_COLUMN, + ), (COLUMN_COMMENT_COLUMN, COLUMN_COMMENT_COLUMN), (INDEX_COMMENT_COLUMN, INDEX_COMMENT_COLUMN), (INDEX_VISIBLE_COLUMN, INDEX_VISIBLE_COLUMN), diff --git a/src/query/src/sql/show_create_table.rs b/src/query/src/sql/show_create_table.rs index 3eebfbc03e..bc004f514e 100644 --- a/src/query/src/sql/show_create_table.rs +++ b/src/query/src/sql/show_create_table.rs @@ -19,8 +19,8 @@ use std::collections::HashMap; use common_meta::SchemaOptions; use datatypes::schema::{ ColumnDefaultConstraint, ColumnSchema, SchemaRef, COLUMN_FULLTEXT_OPT_KEY_ANALYZER, - COLUMN_FULLTEXT_OPT_KEY_CASE_SENSITIVE, COLUMN_SKIPPING_INDEX_OPT_KEY_GRANULARITY, - COLUMN_SKIPPING_INDEX_OPT_KEY_TYPE, COMMENT_KEY, + COLUMN_FULLTEXT_OPT_KEY_BACKEND, COLUMN_FULLTEXT_OPT_KEY_CASE_SENSITIVE, + COLUMN_SKIPPING_INDEX_OPT_KEY_GRANULARITY, COLUMN_SKIPPING_INDEX_OPT_KEY_TYPE, COMMENT_KEY, }; use snafu::ResultExt; use sql::ast::{ColumnDef, ColumnOption, ColumnOptionDef, Expr, Ident, ObjectName}; @@ -113,6 +113,10 @@ fn create_column(column_schema: &ColumnSchema, quote_style: char) -> Result, ) -> Result<()> { if let Some(current_options) = current_options { - ensure!( - !current_options.enable, - InvalidColumnOptionSnafu { - column_name, - msg: "FULLTEXT index already enabled".to_string(), - } - ); - ensure!( current_options.analyzer == options.analyzer && current_options.case_sensitive == options.case_sensitive, diff --git a/src/table/src/metadata.rs b/src/table/src/metadata.rs index a457afe107..4235588ff0 100644 --- a/src/table/src/metadata.rs +++ b/src/table/src/metadata.rs @@ -1149,6 +1149,14 @@ impl TryFrom for TableInfo { } } +/// Set column fulltext options if it passed the validation. +/// +/// Options allowed to modify: +/// * backend +/// +/// Options not allowed to modify: +/// * analyzer +/// * case_sensitive fn set_column_fulltext_options( column_schema: &mut ColumnSchema, column_name: &str, @@ -1156,14 +1164,6 @@ fn set_column_fulltext_options( current_options: Option, ) -> Result<()> { if let Some(current_options) = current_options { - ensure!( - !current_options.enable, - error::InvalidColumnOptionSnafu { - column_name, - msg: "FULLTEXT index already enabled", - } - ); - ensure!( current_options.analyzer == options.analyzer && current_options.case_sensitive == options.case_sensitive, diff --git a/tests-integration/tests/http.rs b/tests-integration/tests/http.rs index ffb74e1b16..6eb4d10562 100644 --- a/tests-integration/tests/http.rs +++ b/tests-integration/tests/http.rs @@ -1371,7 +1371,7 @@ transform: assert_eq!(res.status(), StatusCode::OK); // 3. check schema - let expected_schema = "[[\"logs1\",\"CREATE TABLE IF NOT EXISTS \\\"logs1\\\" (\\n \\\"id1\\\" INT NULL INVERTED INDEX,\\n \\\"id2\\\" INT NULL INVERTED INDEX,\\n \\\"logger\\\" STRING NULL,\\n \\\"type\\\" STRING NULL SKIPPING INDEX WITH(granularity = '10240', type = 'BLOOM'),\\n \\\"log\\\" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', case_sensitive = 'false'),\\n \\\"time\\\" TIMESTAMP(9) NOT NULL,\\n TIME INDEX (\\\"time\\\"),\\n PRIMARY KEY (\\\"type\\\", \\\"log\\\")\\n)\\n\\nENGINE=mito\\nWITH(\\n append_mode = 'true'\\n)\"]]"; + let expected_schema = "[[\"logs1\",\"CREATE TABLE IF NOT EXISTS \\\"logs1\\\" (\\n \\\"id1\\\" INT NULL INVERTED INDEX,\\n \\\"id2\\\" INT NULL INVERTED INDEX,\\n \\\"logger\\\" STRING NULL,\\n \\\"type\\\" STRING NULL SKIPPING INDEX WITH(granularity = '10240', type = 'BLOOM'),\\n \\\"log\\\" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', backend = 'bloom', case_sensitive = 'false'),\\n \\\"time\\\" TIMESTAMP(9) NOT NULL,\\n TIME INDEX (\\\"time\\\"),\\n PRIMARY KEY (\\\"type\\\", \\\"log\\\")\\n)\\n\\nENGINE=mito\\nWITH(\\n append_mode = 'true'\\n)\"]]"; validate_data( "pipeline_schema", &client, diff --git a/tests/cases/standalone/common/alter/change_col_fulltext_options.result b/tests/cases/standalone/common/alter/change_col_fulltext_options.result index ee400593cc..13202ae12c 100644 --- a/tests/cases/standalone/common/alter/change_col_fulltext_options.result +++ b/tests/cases/standalone/common/alter/change_col_fulltext_options.result @@ -79,29 +79,29 @@ SELECT * FROM test WHERE MATCHES(message, 'hello') ORDER BY message; -- SQLNESS ARG restart=true SHOW CREATE TABLE test; -+-------+---------------------------------------------------------------------------------------------+ -| Table | Create Table | -+-------+---------------------------------------------------------------------------------------------+ -| test | CREATE TABLE IF NOT EXISTS "test" ( | -| | "message" STRING NULL FULLTEXT INDEX WITH(analyzer = 'Chinese', case_sensitive = 'true'), | -| | "time" TIMESTAMP(3) NOT NULL, | -| | TIME INDEX ("time") | -| | ) | -| | | -| | ENGINE=mito | -| | WITH( | -| | append_mode = 'true' | -| | ) | -+-------+---------------------------------------------------------------------------------------------+ ++-------+----------------------------------------------------------------------------------------------------------------+ +| Table | Create Table | ++-------+----------------------------------------------------------------------------------------------------------------+ +| test | CREATE TABLE IF NOT EXISTS "test" ( | +| | "message" STRING NULL FULLTEXT INDEX WITH(analyzer = 'Chinese', backend = 'bloom', case_sensitive = 'true'), | +| | "time" TIMESTAMP(3) NOT NULL, | +| | TIME INDEX ("time") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | append_mode = 'true' | +| | ) | ++-------+----------------------------------------------------------------------------------------------------------------+ SHOW INDEX FROM test; -+-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ -| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | -+-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ -| test | 1 | FULLTEXT INDEX | 1 | message | A | | | | YES | greptime-fulltext-index-v1 | | | YES | | -| test | 1 | TIME INDEX | 1 | time | A | | | | NO | | | | YES | | -+-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ +| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ +| test | 1 | FULLTEXT INDEX | 1 | message | A | | | | YES | greptime-fulltext-index-bloom | | | YES | | +| test | 1 | TIME INDEX | 1 | time | A | | | | NO | | | | YES | | ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ ALTER TABLE test MODIFY COLUMN message UNSET FULLTEXT INDEX; @@ -138,33 +138,33 @@ Affected Rows: 0 SHOW CREATE TABLE test; -+-------+---------------------------------------------------------------------------------------------+ -| Table | Create Table | -+-------+---------------------------------------------------------------------------------------------+ -| test | CREATE TABLE IF NOT EXISTS "test" ( | -| | "message" STRING NULL FULLTEXT INDEX WITH(analyzer = 'Chinese', case_sensitive = 'true'), | -| | "time" TIMESTAMP(3) NOT NULL, | -| | TIME INDEX ("time") | -| | ) | -| | | -| | ENGINE=mito | -| | WITH( | -| | append_mode = 'true' | -| | ) | -+-------+---------------------------------------------------------------------------------------------+ ++-------+----------------------------------------------------------------------------------------------------------------+ +| Table | Create Table | ++-------+----------------------------------------------------------------------------------------------------------------+ +| test | CREATE TABLE IF NOT EXISTS "test" ( | +| | "message" STRING NULL FULLTEXT INDEX WITH(analyzer = 'Chinese', backend = 'bloom', case_sensitive = 'true'), | +| | "time" TIMESTAMP(3) NOT NULL, | +| | TIME INDEX ("time") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | append_mode = 'true' | +| | ) | ++-------+----------------------------------------------------------------------------------------------------------------+ SHOW INDEX FROM test; -+-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ -| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | -+-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ -| test | 1 | FULLTEXT INDEX | 1 | message | A | | | | YES | greptime-fulltext-index-v1 | | | YES | | -| test | 1 | TIME INDEX | 1 | time | A | | | | NO | | | | YES | | -+-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ +| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ +| test | 1 | FULLTEXT INDEX | 1 | message | A | | | | YES | greptime-fulltext-index-bloom | | | YES | | +| test | 1 | TIME INDEX | 1 | time | A | | | | NO | | | | YES | | ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Chinese', case_sensitive = 'false'); -Error: 1004(InvalidArguments), Invalid column option, column name: message, error: FULLTEXT index already enabled +Error: 1004(InvalidArguments), Invalid column option, column name: message, error: Cannot change analyzer or case_sensitive if FULLTEXT index is set before. Previous analyzer: Chinese, previous case_sensitive: true ALTER TABLE test MODIFY COLUMN message UNSET FULLTEXT INDEX; @@ -195,6 +195,66 @@ SHOW INDEX FROM test; | test | 1 | TIME INDEX | 1 | time | A | | | | NO | | | | YES | | +-------+------------+------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+---------+------------+ +ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Chinese', case_sensitive = 'true', backend = 'bloom'); + +Affected Rows: 0 + +SHOW CREATE TABLE test; + ++-------+----------------------------------------------------------------------------------------------------------------+ +| Table | Create Table | ++-------+----------------------------------------------------------------------------------------------------------------+ +| test | CREATE TABLE IF NOT EXISTS "test" ( | +| | "message" STRING NULL FULLTEXT INDEX WITH(analyzer = 'Chinese', backend = 'bloom', case_sensitive = 'true'), | +| | "time" TIMESTAMP(3) NOT NULL, | +| | TIME INDEX ("time") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | append_mode = 'true' | +| | ) | ++-------+----------------------------------------------------------------------------------------------------------------+ + +SHOW INDEX FROM test; + ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ +| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ +| test | 1 | FULLTEXT INDEX | 1 | message | A | | | | YES | greptime-fulltext-index-bloom | | | YES | | +| test | 1 | TIME INDEX | 1 | time | A | | | | NO | | | | YES | | ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+-------------------------------+---------+---------------+---------+------------+ + +ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Chinese', case_sensitive = 'true', backend = 'tantivy'); + +Affected Rows: 0 + +SHOW CREATE TABLE test; + ++-------+------------------------------------------------------------------------------------------------------------------+ +| Table | Create Table | ++-------+------------------------------------------------------------------------------------------------------------------+ +| test | CREATE TABLE IF NOT EXISTS "test" ( | +| | "message" STRING NULL FULLTEXT INDEX WITH(analyzer = 'Chinese', backend = 'tantivy', case_sensitive = 'true'), | +| | "time" TIMESTAMP(3) NOT NULL, | +| | TIME INDEX ("time") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | append_mode = 'true' | +| | ) | ++-------+------------------------------------------------------------------------------------------------------------------+ + +SHOW INDEX FROM test; + ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ +| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ +| test | 1 | FULLTEXT INDEX | 1 | message | A | | | | YES | greptime-fulltext-index-v1 | | | YES | | +| test | 1 | TIME INDEX | 1 | time | A | | | | NO | | | | YES | | ++-------+------------+----------------+--------------+-------------+-----------+-------------+----------+--------+------+----------------------------+---------+---------------+---------+------------+ + ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Chinglish', case_sensitive = 'false'); Error: 1002(Unexpected), Invalid fulltext option: Chinglish, expected: 'English' | 'Chinese' @@ -211,6 +271,10 @@ ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Engli Error: 1004(InvalidArguments), Invalid column option, column name: message, error: Cannot change analyzer or case_sensitive if FULLTEXT index is set before. Previous analyzer: Chinese, previous case_sensitive: true +ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(backend = 'xor'); + +Error: 1002(Unexpected), Invalid fulltext option: xor, expected: 'bloom' | 'tantivy' + DROP TABLE test; Affected Rows: 0 diff --git a/tests/cases/standalone/common/alter/change_col_fulltext_options.sql b/tests/cases/standalone/common/alter/change_col_fulltext_options.sql index b5ead6e610..df56e8179e 100644 --- a/tests/cases/standalone/common/alter/change_col_fulltext_options.sql +++ b/tests/cases/standalone/common/alter/change_col_fulltext_options.sql @@ -51,6 +51,18 @@ SHOW CREATE TABLE test; SHOW INDEX FROM test; +ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Chinese', case_sensitive = 'true', backend = 'bloom'); + +SHOW CREATE TABLE test; + +SHOW INDEX FROM test; + +ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Chinese', case_sensitive = 'true', backend = 'tantivy'); + +SHOW CREATE TABLE test; + +SHOW INDEX FROM test; + ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Chinglish', case_sensitive = 'false'); ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'Chinese', case_sensitive = 'no'); @@ -59,4 +71,6 @@ ALTER TABLE test MODIFY COLUMN time SET FULLTEXT INDEX WITH(analyzer = 'Chinese' ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(analyzer = 'English', case_sensitive = 'true'); +ALTER TABLE test MODIFY COLUMN message SET FULLTEXT INDEX WITH(backend = 'xor'); + DROP TABLE test; diff --git a/tests/cases/standalone/common/create/create_with_fulltext.result b/tests/cases/standalone/common/create/create_with_fulltext.result index 3ab0435780..d5ae9ee2dd 100644 --- a/tests/cases/standalone/common/create/create_with_fulltext.result +++ b/tests/cases/standalone/common/create/create_with_fulltext.result @@ -7,18 +7,18 @@ Affected Rows: 0 SHOW CREATE TABLE log; -+-------+------------------------------------------------------------------------------------------+ -| Table | Create Table | -+-------+------------------------------------------------------------------------------------------+ -| log | CREATE TABLE IF NOT EXISTS "log" ( | -| | "ts" TIMESTAMP(3) NOT NULL, | -| | "msg" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', case_sensitive = 'false'), | -| | TIME INDEX ("ts") | -| | ) | -| | | -| | ENGINE=mito | -| | | -+-------+------------------------------------------------------------------------------------------+ ++-------+-------------------------------------------------------------------------------------------------------------+ +| Table | Create Table | ++-------+-------------------------------------------------------------------------------------------------------------+ +| log | CREATE TABLE IF NOT EXISTS "log" ( | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "msg" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', backend = 'bloom', case_sensitive = 'false'), | +| | TIME INDEX ("ts") | +| | ) | +| | | +| | ENGINE=mito | +| | | ++-------+-------------------------------------------------------------------------------------------------------------+ DROP TABLE log; @@ -33,18 +33,18 @@ Affected Rows: 0 SHOW CREATE TABLE log_with_opts; -+---------------+-----------------------------------------------------------------------------------------+ -| Table | Create Table | -+---------------+-----------------------------------------------------------------------------------------+ -| log_with_opts | CREATE TABLE IF NOT EXISTS "log_with_opts" ( | -| | "ts" TIMESTAMP(3) NOT NULL, | -| | "msg" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', case_sensitive = 'true'), | -| | TIME INDEX ("ts") | -| | ) | -| | | -| | ENGINE=mito | -| | | -+---------------+-----------------------------------------------------------------------------------------+ ++---------------+------------------------------------------------------------------------------------------------------------+ +| Table | Create Table | ++---------------+------------------------------------------------------------------------------------------------------------+ +| log_with_opts | CREATE TABLE IF NOT EXISTS "log_with_opts" ( | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "msg" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', backend = 'bloom', case_sensitive = 'true'), | +| | TIME INDEX ("ts") | +| | ) | +| | | +| | ENGINE=mito | +| | | ++---------------+------------------------------------------------------------------------------------------------------------+ DROP TABLE log_with_opts; @@ -60,19 +60,19 @@ Affected Rows: 0 SHOW CREATE TABLE log_multi_fulltext_cols; -+-------------------------+-------------------------------------------------------------------------------------------+ -| Table | Create Table | -+-------------------------+-------------------------------------------------------------------------------------------+ -| log_multi_fulltext_cols | CREATE TABLE IF NOT EXISTS "log_multi_fulltext_cols" ( | -| | "ts" TIMESTAMP(3) NOT NULL, | -| | "msg" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', case_sensitive = 'false'), | -| | "msg2" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', case_sensitive = 'false'), | -| | TIME INDEX ("ts") | -| | ) | -| | | -| | ENGINE=mito | -| | | -+-------------------------+-------------------------------------------------------------------------------------------+ ++-------------------------+--------------------------------------------------------------------------------------------------------------+ +| Table | Create Table | ++-------------------------+--------------------------------------------------------------------------------------------------------------+ +| log_multi_fulltext_cols | CREATE TABLE IF NOT EXISTS "log_multi_fulltext_cols" ( | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | "msg" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', backend = 'bloom', case_sensitive = 'false'), | +| | "msg2" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', backend = 'bloom', case_sensitive = 'false'), | +| | TIME INDEX ("ts") | +| | ) | +| | | +| | ENGINE=mito | +| | | ++-------------------------+--------------------------------------------------------------------------------------------------------------+ DROP TABLE log_multi_fulltext_cols; diff --git a/tests/cases/standalone/common/show/show_create.result b/tests/cases/standalone/common/show/show_create.result index ddbdd4179a..5d7019265a 100644 --- a/tests/cases/standalone/common/show/show_create.result +++ b/tests/cases/standalone/common/show/show_create.result @@ -373,20 +373,20 @@ Affected Rows: 0 show create table test_column_constrain_composite_indexes; -+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| Table | Create Table | -+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -| test_column_constrain_composite_indexes | CREATE TABLE IF NOT EXISTS "test_column_constrain_composite_indexes" ( | -| | "id" INT NULL SKIPPING INDEX WITH(granularity = '10240', type = 'BLOOM') INVERTED INDEX, | -| | "host" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', case_sensitive = 'false') SKIPPING INDEX WITH(granularity = '10240', type = 'BLOOM') INVERTED INDEX, | -| | "ts" TIMESTAMP(3) NOT NULL, | -| | TIME INDEX ("ts"), | -| | PRIMARY KEY ("host") | -| | ) | -| | | -| | ENGINE=mito | -| | | -+-----------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ ++-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Table | Create Table | ++-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| test_column_constrain_composite_indexes | CREATE TABLE IF NOT EXISTS "test_column_constrain_composite_indexes" ( | +| | "id" INT NULL SKIPPING INDEX WITH(granularity = '10240', type = 'BLOOM') INVERTED INDEX, | +| | "host" STRING NULL FULLTEXT INDEX WITH(analyzer = 'English', backend = 'bloom', case_sensitive = 'false') SKIPPING INDEX WITH(granularity = '10240', type = 'BLOOM') INVERTED INDEX, | +| | "ts" TIMESTAMP(3) NOT NULL, | +| | TIME INDEX ("ts"), | +| | PRIMARY KEY ("host") | +| | ) | +| | | +| | ENGINE=mito | +| | | ++-----------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ drop table test_column_constrain_composite_indexes; diff --git a/tests/cases/standalone/common/show/show_index.result b/tests/cases/standalone/common/show/show_index.result index 0376443746..80010b5331 100644 --- a/tests/cases/standalone/common/show/show_index.result +++ b/tests/cases/standalone/common/show/show_index.result @@ -80,27 +80,27 @@ SHOW INDEX FROM test_no_inverted_index; SHOW INDEX FROM system_metrics; -+----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+---------------------------------------------------------------------------------+---------+---------------+---------+------------+ -| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | -+----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+---------------------------------------------------------------------------------+---------+---------------+---------+------------+ -| system_metrics | 1 | FULLTEXT INDEX | 7 | desc2 | A | | | | YES | greptime-fulltext-index-v1 | | | YES | | -| system_metrics | 1 | FULLTEXT INDEX | 8 | desc3 | A | | | | YES | greptime-fulltext-index-v1 | | | YES | | -| system_metrics | 1 | PRIMARY | 1 | host | A | | | | YES | greptime-primary-key-v1 | | | YES | | -| system_metrics | 1 | PRIMARY, INVERTED INDEX, FULLTEXT INDEX | 2 | idc | A | | | | YES | greptime-primary-key-v1, greptime-inverted-index-v1, greptime-fulltext-index-v1 | | | YES | | -| system_metrics | 1 | TIME INDEX | 1 | ts | A | | | | NO | | | | YES | | -+----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+---------------------------------------------------------------------------------+---------+---------------+---------+------------+ ++----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------------------------------------------------------------------------------+---------+---------------+---------+------------+ +| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | ++----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------------------------------------------------------------------------------+---------+---------------+---------+------------+ +| system_metrics | 1 | FULLTEXT INDEX | 7 | desc2 | A | | | | YES | greptime-fulltext-index-bloom | | | YES | | +| system_metrics | 1 | FULLTEXT INDEX | 8 | desc3 | A | | | | YES | greptime-fulltext-index-bloom | | | YES | | +| system_metrics | 1 | PRIMARY | 1 | host | A | | | | YES | greptime-primary-key-v1 | | | YES | | +| system_metrics | 1 | PRIMARY, INVERTED INDEX, FULLTEXT INDEX | 2 | idc | A | | | | YES | greptime-primary-key-v1, greptime-inverted-index-v1, greptime-fulltext-index-bloom | | | YES | | +| system_metrics | 1 | TIME INDEX | 1 | ts | A | | | | NO | | | | YES | | ++----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------------------------------------------------------------------------------+---------+---------------+---------+------------+ SHOW INDEX FROM system_metrics in public; -+----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+---------------------------------------------------------------------------------+---------+---------------+---------+------------+ -| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | -+----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+---------------------------------------------------------------------------------+---------+---------------+---------+------------+ -| system_metrics | 1 | FULLTEXT INDEX | 7 | desc2 | A | | | | YES | greptime-fulltext-index-v1 | | | YES | | -| system_metrics | 1 | FULLTEXT INDEX | 8 | desc3 | A | | | | YES | greptime-fulltext-index-v1 | | | YES | | -| system_metrics | 1 | PRIMARY | 1 | host | A | | | | YES | greptime-primary-key-v1 | | | YES | | -| system_metrics | 1 | PRIMARY, INVERTED INDEX, FULLTEXT INDEX | 2 | idc | A | | | | YES | greptime-primary-key-v1, greptime-inverted-index-v1, greptime-fulltext-index-v1 | | | YES | | -| system_metrics | 1 | TIME INDEX | 1 | ts | A | | | | NO | | | | YES | | -+----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+---------------------------------------------------------------------------------+---------+---------------+---------+------------+ ++----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------------------------------------------------------------------------------+---------+---------------+---------+------------+ +| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment | Visible | Expression | ++----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------------------------------------------------------------------------------+---------+---------------+---------+------------+ +| system_metrics | 1 | FULLTEXT INDEX | 7 | desc2 | A | | | | YES | greptime-fulltext-index-bloom | | | YES | | +| system_metrics | 1 | FULLTEXT INDEX | 8 | desc3 | A | | | | YES | greptime-fulltext-index-bloom | | | YES | | +| system_metrics | 1 | PRIMARY | 1 | host | A | | | | YES | greptime-primary-key-v1 | | | YES | | +| system_metrics | 1 | PRIMARY, INVERTED INDEX, FULLTEXT INDEX | 2 | idc | A | | | | YES | greptime-primary-key-v1, greptime-inverted-index-v1, greptime-fulltext-index-bloom | | | YES | | +| system_metrics | 1 | TIME INDEX | 1 | ts | A | | | | NO | | | | YES | | ++----------------+------------+-----------------------------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------------------------------------------------------------------------------+---------+---------------+---------+------------+ SHOW INDEX FROM system_metrics like '%util%'; diff --git a/tests/cases/standalone/common/system/information_schema.result b/tests/cases/standalone/common/system/information_schema.result index bfcf39b69e..a19e7944c0 100644 --- a/tests/cases/standalone/common/system/information_schema.result +++ b/tests/cases/standalone/common/system/information_schema.result @@ -208,6 +208,7 @@ select * from information_schema.columns order by table_schema, table_name, colu | greptime | information_schema | key_column_usage | constraint_catalog | 1 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | key_column_usage | constraint_name | 3 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | | greptime | information_schema | key_column_usage | constraint_schema | 2 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | +| greptime | information_schema | key_column_usage | greptime_index_type | 14 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | Yes | string | | | | greptime | information_schema | key_column_usage | ordinal_position | 9 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | No | int unsigned | | | | greptime | information_schema | key_column_usage | position_in_unique_constraint | 10 | | | 10 | 0 | | | | | | select,insert | | UInt32 | int unsigned | FIELD | | Yes | int unsigned | | | | greptime | information_schema | key_column_usage | real_table_catalog | 5 | 2147483647 | 2147483647 | | | | utf8 | utf8_bin | | | select,insert | | String | string | FIELD | | No | string | | | @@ -593,11 +594,11 @@ select * from KEY_COLUMN_USAGE where CONSTRAINT_NAME = 'TIME INDEX'; select * from KEY_COLUMN_USAGE where CONSTRAINT_NAME != 'TIME INDEX'; -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ -| constraint_catalog | constraint_schema | constraint_name | table_catalog | real_table_catalog | table_schema | table_name | column_name | ordinal_position | position_in_unique_constraint | referenced_table_schema | referenced_table_name | referenced_column_name | -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ -| def | public | PRIMARY | def | greptime | public | numbers | number | 1 | | | | | -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ +| constraint_catalog | constraint_schema | constraint_name | table_catalog | real_table_catalog | table_schema | table_name | column_name | ordinal_position | position_in_unique_constraint | referenced_table_schema | referenced_table_name | referenced_column_name | greptime_index_type | ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ +| def | public | PRIMARY | def | greptime | public | numbers | number | 1 | | | | | greptime-primary-key-v1 | ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ select * from KEY_COLUMN_USAGE where CONSTRAINT_NAME LIKE '%INDEX'; @@ -606,11 +607,11 @@ select * from KEY_COLUMN_USAGE where CONSTRAINT_NAME LIKE '%INDEX'; select * from KEY_COLUMN_USAGE where CONSTRAINT_NAME NOT LIKE '%INDEX'; -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ -| constraint_catalog | constraint_schema | constraint_name | table_catalog | real_table_catalog | table_schema | table_name | column_name | ordinal_position | position_in_unique_constraint | referenced_table_schema | referenced_table_name | referenced_column_name | -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ -| def | public | PRIMARY | def | greptime | public | numbers | number | 1 | | | | | -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ +| constraint_catalog | constraint_schema | constraint_name | table_catalog | real_table_catalog | table_schema | table_name | column_name | ordinal_position | position_in_unique_constraint | referenced_table_schema | referenced_table_name | referenced_column_name | greptime_index_type | ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ +| def | public | PRIMARY | def | greptime | public | numbers | number | 1 | | | | | greptime-primary-key-v1 | ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ select * from KEY_COLUMN_USAGE where CONSTRAINT_NAME == 'TIME INDEX' AND CONSTRAINT_SCHEMA != 'my_db'; @@ -688,15 +689,16 @@ desc table key_column_usage; | referenced_table_schema | String | | YES | | FIELD | | referenced_table_name | String | | YES | | FIELD | | referenced_column_name | String | | YES | | FIELD | +| greptime_index_type | String | | YES | | FIELD | +-------------------------------+--------+-----+------+---------+---------------+ select * from key_column_usage; -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ -| constraint_catalog | constraint_schema | constraint_name | table_catalog | real_table_catalog | table_schema | table_name | column_name | ordinal_position | position_in_unique_constraint | referenced_table_schema | referenced_table_name | referenced_column_name | -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ -| def | public | PRIMARY | def | greptime | public | numbers | number | 1 | | | | | -+--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+ ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ +| constraint_catalog | constraint_schema | constraint_name | table_catalog | real_table_catalog | table_schema | table_name | column_name | ordinal_position | position_in_unique_constraint | referenced_table_schema | referenced_table_name | referenced_column_name | greptime_index_type | ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ +| def | public | PRIMARY | def | greptime | public | numbers | number | 1 | | | | | greptime-primary-key-v1 | ++--------------------+-------------------+-----------------+---------------+--------------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+-------------------------+ -- tables not implemented DESC TABLE COLUMN_PRIVILEGES;