diff --git a/src/sql/resolver/dml/ob_select_resolver.cpp b/src/sql/resolver/dml/ob_select_resolver.cpp index 1e50085ac7f06ec968e2f0240daa70a7946c0039..2b8251e4a654919a25cb919406eff16f029c60ef 100644 --- a/src/sql/resolver/dml/ob_select_resolver.cpp +++ b/src/sql/resolver/dml/ob_select_resolver.cpp @@ -3015,7 +3015,10 @@ int ObSelectResolver::add_fake_schema(ObSelectStmt* left_stmt) ObColumnRefRawExpr* select_expr = static_cast(expr); ObColumnSchemaV2* new_col = static_cast(allocator_->alloc(sizeof(ObColumnSchemaV2))); new_col = new (new_col) ObColumnSchemaV2(allocator_); - new_col->set_column_name(saved_left_resolver->cte_ctx_.cte_col_names_.at(i)); + if (!OB_ISNULL(saved_left_resolver)) + new_col->set_column_name(saved_left_resolver->cte_ctx_.cte_col_names_.at(i)); + else + new_col->set_column_name(cte_ctx_.cte_col_names_.at(i)); new_col->set_tenant_id(tbl_schema->get_tenant_id()); new_col->set_table_id(magic_table_id); new_col->set_column_id(magic_col_id + i);