Index: java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
===================================================================
--- java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java	(revision 473203)
+++ java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java	(working copy)
@@ -2868,7 +2868,14 @@
 		{
 			ResultColumn rc = (ResultColumn) elementAt(index);
 
-			rc.setExpression(rc.getExpression().remapColumnReferencesToExpressions());
+			// The expression may be null if this column is an identity
+			// column generated always. If the expression is not null, it
+			// is a ColumnReference; we call through to the ColumnReference
+			// to give it a chance to remap itself from the outer query
+			// node to this one.
+			if (rc.getExpression() != null)
+			    rc.setExpression(
+				    rc.getExpression().remapColumnReferencesToExpressions());
 		}
 	}
 
Index: java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql
===================================================================
--- java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql	(revision 473203)
+++ java/testing/org/apache/derbyTesting/functionTests/tests/lang/joins.sql	(working copy)
@@ -186,6 +186,21 @@
   from D join ((B join C on b2=c2) right outer join A on a1=b1) 
     on d3=b3 and d1=a2;
 
+-- JIRA 1089: demonstrate that a table with an identity column generated
+-- always can be used as the target of an insert-as-select join:
+create table j1089_source (source_id int);
+insert into j1089_source values (0);
+create table j1089_dest (
+    dest_id int not null primary key generated always as identity,
+    source_id_1 int not null,
+    source_id_2 int not null);
+
+insert into j1089_dest (source_id_1, source_id_2)
+    select s1.source_id, s2.source_id
+        from j1089_source as s1
+            join j1089_source as s2 on 1 = 1;
+select * from j1089_dest;
+
 -----------------------------------
 -- clean up
 ----------------------------------
@@ -200,3 +215,5 @@
 drop table instab;
 drop table x;
 drop table y;
+drop table j1089_source;
+drop table j1089_dest;
Index: java/testing/org/apache/derbyTesting/functionTests/master/joins.out
===================================================================
--- java/testing/org/apache/derbyTesting/functionTests/master/joins.out	(revision 473203)
+++ java/testing/org/apache/derbyTesting/functionTests/master/joins.out	(working copy)
@@ -386,6 +386,26 @@
 -----------------------------------------------------------------------
 1          |1          |1          |1          |1          |2          
 7          |7          |8          |9          |1          |3          
+ij> -- JIRA 1089: demonstrate that a table with an identity column generated
+-- always can be used as the target of an insert-as-select join:
+create table j1089_source (source_id int);
+0 rows inserted/updated/deleted
+ij> insert into j1089_source values (0);
+1 row inserted/updated/deleted
+ij> create table j1089_dest (
+    dest_id int not null primary key generated always as identity,
+    source_id_1 int not null,
+    source_id_2 int not null);
+0 rows inserted/updated/deleted
+ij> insert into j1089_dest (source_id_1, source_id_2)
+    select s1.source_id, s2.source_id
+        from j1089_source as s1
+            join j1089_source as s2 on 1 = 1;
+1 row inserted/updated/deleted
+ij> select * from j1089_dest;
+DEST_ID    |SOURCE_ID_1|SOURCE_ID_2
+-----------------------------------
+1          |0          |0          
 ij> -----------------------------------
 -- clean up
 ----------------------------------
@@ -411,4 +431,8 @@
 0 rows inserted/updated/deleted
 ij> drop table y;
 0 rows inserted/updated/deleted
+ij> drop table j1089_source;
+0 rows inserted/updated/deleted
+ij> drop table j1089_dest;
+0 rows inserted/updated/deleted
 ij> 
