Skip to content

Commit

Permalink
chore: move constants
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed Sep 16, 2023
1 parent 46e6dae commit 1a94a42
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/operator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ pub mod statement;
pub mod table;
#[cfg(test)]
pub(crate) mod tests;
pub const MAX_VALUE: &str = "MAXVALUE";
5 changes: 3 additions & 2 deletions src/operator/src/statement/ddl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use sql::ast::Value as SqlValue;
use sql::statements::alter::AlterTable;
use sql::statements::create::{CreateExternalTable, CreateTable, Partitions};
use sql::statements::sql_value_to_value;
use sql::MAXVALUE;
use table::dist_table::DistTable;
use table::metadata::{self, RawTableInfo, RawTableMeta, TableId, TableInfo, TableType};
use table::requests::{AlterTableRequest, TableOptions};
Expand All @@ -50,7 +51,7 @@ use crate::error::{
SchemaNotFoundSnafu, TableMetadataManagerSnafu, TableNotFoundSnafu,
UnrecognizedTableOptionSnafu,
};
use crate::{expr_factory, MAX_VALUE};
use crate::expr_factory;

impl StatementExecutor {
pub fn catalog_manager(&self) -> CatalogManagerRef {
Expand Down Expand Up @@ -519,7 +520,7 @@ fn find_partition_entries(
// indexing is safe here because we have checked that "value_list" and "column_list" are matched in size
let (column_name, data_type) = &column_name_and_type[i];
let v = match v {
SqlValue::Number(n, _) if n == MAX_VALUE => PartitionBound::MaxValue,
SqlValue::Number(n, _) if n == MAXVALUE => PartitionBound::MaxValue,
_ => PartitionBound::Value(
sql_value_to_value(column_name, data_type, v).context(ParseSqlSnafu)?,
),
Expand Down
5 changes: 2 additions & 3 deletions src/operator/src/statement/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ use partition::partition::PartitionBound;
use session::context::QueryContextRef;
use snafu::ResultExt;
use sql::ast::{Ident, Value as SqlValue};
use sql::statements;
use sql::statements::create::{PartitionEntry, Partitions};
use sql::statements::show::{ShowDatabases, ShowTables};
use sql::{statements, MAXVALUE};
use table::TableRef;

use crate::error::{self, ExecuteStatementSnafu, Result};
use crate::statement::StatementExecutor;
use crate::MAX_VALUE;

impl StatementExecutor {
pub(super) async fn show_databases(
Expand Down Expand Up @@ -93,7 +92,7 @@ fn create_partitions_stmt(partitions: Vec<PartitionInfo>) -> Result<Option<Parti
.map(|b| match b {
PartitionBound::Value(v) => statements::value_to_sql_value(v)
.with_context(|_| error::ConvertSqlValueSnafu { value: v.clone() }),
PartitionBound::MaxValue => Ok(SqlValue::Number(MAX_VALUE.to_string(), false)),
PartitionBound::MaxValue => Ok(SqlValue::Number(MAXVALUE.to_string(), false)),
})
.collect::<Result<Vec<_>>>()?;

Expand Down
4 changes: 4 additions & 0 deletions src/sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ pub mod parser;
pub mod parsers;
pub mod statements;
pub mod util;

pub use parsers::create_parser::{ENGINE, MAXVALUE};
pub use parsers::tql_parser::TQL;
pub use statements::create::TIME_INDEX;
4 changes: 2 additions & 2 deletions src/sql/src/parsers/create_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ use crate::statements::statement::Statement;
use crate::statements::{sql_data_type_to_concrete_data_type, sql_value_to_value};
use crate::util::parse_option_string;

const ENGINE: &str = "ENGINE";
const MAXVALUE: &str = "MAXVALUE";
pub const ENGINE: &str = "ENGINE";
pub const MAXVALUE: &str = "MAXVALUE";

static LESS: Lazy<Token> = Lazy::new(|| Token::make_keyword("LESS"));
static THAN: Lazy<Token> = Lazy::new(|| Token::make_keyword("THAN"));
Expand Down

0 comments on commit 1a94a42

Please sign in to comment.