diff --git a/pkg/planner/core/planbuilder.go b/pkg/planner/core/planbuilder.go index 0c0f35862fac0..e37559b0f3669 100644 --- a/pkg/planner/core/planbuilder.go +++ b/pkg/planner/core/planbuilder.go @@ -4389,6 +4389,11 @@ func (b *PlanBuilder) buildImportInto(ctx context.Context, ld *ast.ImportIntoStm } tnW := b.resolveCtx.GetTableName(ld.Table) + if tnW.TableInfo.TempTableType != model.TempTableNone { + return nil, errors.Errorf("IMPORT INTO does not support temporary table") + } else if tnW.TableInfo.TableCacheStatusType != model.TableCacheStatusDisable { + return nil, errors.Errorf("IMPORT INTO does not support cached table") + } p := ImportInto{ Path: ld.Path, Format: ld.Format, diff --git a/tests/integrationtest/r/executor/import_into.result b/tests/integrationtest/r/executor/import_into.result index 5c5250765c6c9..77246505cd4a0 100644 --- a/tests/integrationtest/r/executor/import_into.result +++ b/tests/integrationtest/r/executor/import_into.result @@ -170,3 +170,16 @@ import into t from ''; Error 8156 (HY000): The value of INFILE must not be empty when LOAD DATA from LOCAL import into t from '/a.csv' format 'xx'; Error 8157 (HY000): The FORMAT 'xx' is not supported +drop table if exists temp; +create temporary table temp (id int); +import into temp from '/file.csv'; +Error 1105 (HY000): IMPORT INTO does not support temporary table +drop table if exists gtemp; +create global temporary table gtemp (id int) on commit delete rows; +import into gtemp from '/file.csv'; +Error 1105 (HY000): IMPORT INTO does not support temporary table +drop table if exists cachetbl; +create table cachetbl (id int); +alter table cachetbl cache; +import into cachetbl from '/file.csv'; +Error 1105 (HY000): IMPORT INTO does not support cached table diff --git a/tests/integrationtest/t/executor/import_into.test b/tests/integrationtest/t/executor/import_into.test index 68b3a4fa679b2..2d6c803eb1164 100644 --- a/tests/integrationtest/t/executor/import_into.test +++ b/tests/integrationtest/t/executor/import_into.test @@ -174,3 +174,19 @@ import into t from ''; -- error 8157 import into t from '/a.csv' format 'xx'; +# import into temporary or cached table is not supported +drop table if exists temp; +create temporary table temp (id int); +-- error 1105 +import into temp from '/file.csv'; + +drop table if exists gtemp; +create global temporary table gtemp (id int) on commit delete rows; +-- error 1105 +import into gtemp from '/file.csv'; + +drop table if exists cachetbl; +create table cachetbl (id int); +alter table cachetbl cache; +-- error 1105 +import into cachetbl from '/file.csv';