Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/query/sql/src/planner/binder/ddl/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ impl Binder {
.map(|column_binding| {
Ok(TableField::new(
&column_binding.column_name,
infer_schema_type(&column_binding.data_type)?,
create_as_select_infer_schema_type(&column_binding.data_type)?,
))
})
.collect::<Result<Vec<_>>>()?;
Expand Down Expand Up @@ -1766,3 +1766,10 @@ async fn verify_external_location_privileges(dal: Operator) -> Result<()> {
.await
.expect("join must succeed")
}

fn create_as_select_infer_schema_type(data_type: &DataType) -> Result<TableDataType> {
match data_type {
DataType::Null => Ok(TableDataType::Nullable(Box::new(TableDataType::String))),
_ => infer_schema_type(data_type),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ create table t(a int, A int)
statement error Duplicated column name
create table t as select number, number from numbers(1)

statement error 1006
create table t as select 'a' as c1, null as c2;

statement error 4000
create table tb101 (id int ,c1 datetime) 's3://wubx/tb101' connection=(aws_key_id='minioadmin' aws_ssecret_key='minioadmin' endpoint_url='http://127.0.0.1:9900');

Expand Down Expand Up @@ -598,3 +595,25 @@ statement ok
alter table t_opt_retention set options(data_retention_period_in_hours = 2);


#issue 16794
statement ok
create or replace table b as select 123 as col1, null as col2;

query T
desc b;
----
col1 TINYINT UNSIGNED NO 0 (empty)
col2 VARCHAR YES NULL (empty)

query T
show create table b;
----
b CREATE TABLE b ( col1 TINYINT UNSIGNED NOT NULL, col2 VARCHAR NULL ) ENGINE=FUSE

query TT
select * from b;
----
123 NULL

statement ok
drop table if exists b;
Loading