Index: trunk/ippTools/share/disttool_pendingcomponent.sql
===================================================================
--- trunk/ippTools/share/disttool_pendingcomponent.sql	(revision 23776)
+++ trunk/ippTools/share/disttool_pendingcomponent.sql	(revision 23777)
@@ -1,3 +1,4 @@
 SELECT * FROM (
+    -- raw stage
 SELECT
     distRun.dist_id,
@@ -8,5 +9,5 @@
     clean,
     rawExp.camera,
-    outroot,
+    CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
     rawImfile.uri as path_base,         -- change this once rawImfile has path_base
     chipProcessedImfile.path_base as chip_path_base,
@@ -41,8 +42,37 @@
 WHERE
     distRun.state = 'new'
+    AND distRun.clean = 0
     AND distRun.stage = 'raw'
     AND distComponent.dist_id IS NULL
     AND (rawExp.magicked OR distRun.no_magic)
     -- where hook 1 %s
+UNION
+    -- raw stage clean (dbinfo only)
+SELECT
+    distRun.dist_id,
+    distRun.label,
+    stage,
+    stage_id,
+    'exposure' AS component,
+    clean,
+    rawExp.camera,
+    CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
+    NULL,
+    NULL,
+    NULL as state,
+    NULL as data_state,
+    0 as quality,
+    distRun.no_magic,
+    rawExp.magicked
+FROM distRun
+JOIN rawExp ON exp_id = stage_id
+LEFT JOIN distComponent 
+    ON distRun.dist_id = distComponent.dist_id 
+WHERE
+    distRun.state = 'new'
+    AND distRun.stage = 'raw'
+    AND distRun.clean
+    AND distComponent.dist_id IS NULL
+    -- where hook 2 %s
 
 -- chip stage
@@ -56,5 +86,5 @@
     clean,
     rawExp.camera,
-    outroot,
+    CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
     chipProcessedImfile.path_base,
     chipProcessedImfile.path_base as chip_path_base,
@@ -77,5 +107,5 @@
     AND (distRun.clean OR chipRun.magicked OR distRun.no_magic)
     AND (chipRun.state = 'full' OR (distRun.clean AND chipRun.state = 'cleaned'))
-    -- where hook 2 %s
+    -- where hook 3 %s
 UNION
 SELECT
@@ -88,5 +118,5 @@
     clean,
     rawExp.camera,
-    outroot,
+    CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
     camProcessedExp.path_base,
     NULL as chip_path_base,
@@ -111,5 +141,5 @@
     AND (distRun.clean OR chipRun.magicked OR distRun.no_magic)
     AND (camRun.state = 'full' OR (distRun.clean AND camRun.state = 'cleaned'))
-    -- where hook 3 %s
+    -- where hook 4 %s
 UNION
 SELECT
@@ -121,5 +151,5 @@
     clean,
     rawExp.camera,
-    outroot,
+    CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
     fakeProcessedImfile.path_base,
     NULL,
@@ -142,5 +172,5 @@
     AND distRun.stage = 'fake'
     AND distComponent.dist_id IS NULL
-    -- where hook 4 %s
+    -- where hook 5 %s
 UNION
 SELECT
@@ -152,5 +182,5 @@
     clean,
     rawExp.camera,
-    outroot,
+    CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
     warpSkyfile.path_base,
     NULL as chip_path_base,
@@ -176,5 +206,5 @@
     AND (distRun.clean OR warpRun.magicked OR distRun.no_magic)
     AND (warpRun.state = 'full' OR (distRun.clean AND warpRun.state = 'cleaned'))
-    -- where hook 5 %s
+    -- where hook 6 %s
 UNION
 SELECT
@@ -186,5 +216,5 @@
     clean,
     rawExp.camera,
-    outroot,
+    CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
     diffSkyfile.path_base,
     NULL as chip_path_base,
@@ -209,5 +239,5 @@
     AND (distRun.clean OR diffRun.magicked OR distRun.no_magic)
     AND (diffRun.state = 'full' OR (distRun.clean AND diffRun.state = 'cleaned'))
-    -- where hook 6 %s
+    -- where hook 7 %s
 UNION
 SELECT DISTINCT
@@ -219,5 +249,5 @@
     clean,
     rawExp.camera,
-    outroot,
+    CONCAT_WS('.', outroot, CONVERT(distRun.dist_id, CHAR)) as outdir,
     stackSumSkyfile.path_base,
     NULL as chip_path_base,
@@ -258,4 +288,4 @@
     AND distComponent.dist_id IS NULL
     AND (stackRun.state = 'full' OR (distRun.clean AND stackRun.state = 'cleaned'))
-    -- where hook 7 %s
+    -- where hook 8 %s
 ) as Foo
Index: trunk/ippTools/share/disttool_toadvance.sql
===================================================================
--- trunk/ippTools/share/disttool_toadvance.sql	(revision 23776)
+++ trunk/ippTools/share/disttool_toadvance.sql	(revision 23777)
@@ -3,10 +3,10 @@
     stage,
     stage_id,
-    outroot,
+    CONCAT_WS('.', outroot, CONVERT(dist_id, CHAR)) as outdir,
     label,
     clean
 FROM
     (
--- raw stage
+-- raw stage not clean
 SELECT
     distRun.dist_id,
@@ -23,4 +23,5 @@
     WHERE
         distRun.state = 'new'
+        AND distRun.clean = 0
         AND distRun.fault = 0
         AND distRun.stage = 'raw'
@@ -31,4 +32,23 @@
         COUNT(rawImfile.class_id) = COUNT(distComponent.component)
         AND SUM(distComponent.fault) = 0
+UNION
+-- clean distribution of raw files (dbinfo only) only 1 component
+SELECT
+    distRun.dist_id,
+    stage,
+    stage_id,
+    outroot,
+    label,
+    clean
+    FROM distRun
+    LEFT JOIN distComponent
+        ON distRun.dist_id = distComponent.dist_id
+    WHERE
+        distRun.state = 'new'
+        AND distRun.clean
+        AND distRun.fault = 0
+        AND distRun.stage = 'raw'
+        AND distComponent.component IS NOT NULL
+        AND distComponent.fault = 0
 UNION
 -- chip stage
