fix: incorrect show create table output (#1514)

* fix: incorrect show create table output

* feat: change CreateTable's Display if table is external

* feat: change CreateTable's Display if table is external
This commit is contained in:
Niwaka
2023-05-05 12:29:09 +09:00
committed by GitHub
parent c8301feed7
commit d86b3386dc
3 changed files with 87 additions and 6 deletions

View File

@@ -15,6 +15,7 @@
use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use common_catalog::consts::IMMUTABLE_FILE_ENGINE;
use itertools::Itertools;
use crate::ast::{ColumnDef, Ident, ObjectName, SqlOption, TableConstraint, Value as SqlValue};
@@ -110,7 +111,8 @@ impl CreateTable {
if self.options.is_empty() {
"".to_string()
} else {
let options = format_list_indent!(self.options);
let options: Vec<&SqlOption> = self.options.iter().sorted().collect();
let options = format_list_indent!(options);
format!(
r#"WITH(
{options}
@@ -165,10 +167,14 @@ impl Display for CreateTable {
let partitions = self.format_partitions();
let engine = &self.engine;
let options = self.format_options();
let maybe_external = if self.engine == IMMUTABLE_FILE_ENGINE {
"EXTERNAL "
} else {
""
};
write!(
f,
r#"CREATE TABLE {if_not_exists} {name} (
r#"CREATE {maybe_external}TABLE {if_not_exists} {name} (
{columns},
{constraints}
)