@@ -290,7 +290,7 @@ func (s *Stage) saveQueryJsonFile(result *QueryResult) {
290290 querySourceStr := s .querySourceString (result )
291291 {
292292 queryJsonFile , err := os .OpenFile (
293- filepath .Join (s .States . OutputPath , querySourceStr )+ ".json" ,
293+ filepath .Join (s .OutputPath , querySourceStr )+ ".json" ,
294294 utils .OpenNewFileFlags , 0644 )
295295 checkErr (err )
296296 if err == nil {
@@ -302,7 +302,7 @@ func (s *Stage) saveQueryJsonFile(result *QueryResult) {
302302 }
303303 if result .QueryError != nil {
304304 queryErrorFile , err := os .OpenFile (
305- filepath .Join (s .States . OutputPath , querySourceStr )+ ".error.json" ,
305+ filepath .Join (s .OutputPath , querySourceStr )+ ".error.json" ,
306306 utils .OpenNewFileFlags , 0644 )
307307 checkErr (err )
308308 if err == nil {
@@ -332,7 +332,7 @@ func (s *Stage) saveColumnMetadataFile(qr *presto.QueryResults, result *QueryRes
332332 }
333333 }()
334334 columnMetadataFile , ioErr := os .OpenFile (
335- filepath .Join (s .States . OutputPath , querySourceStr )+ ".cols.json" ,
335+ filepath .Join (s .OutputPath , querySourceStr )+ ".cols.json" ,
336336 utils .OpenNewFileFlags , 0644 )
337337 if ioErr != nil {
338338 return ioErr
@@ -372,3 +372,20 @@ func (s *Stage) querySourceString(result *QueryResult) (sourceStr string) {
372372 }
373373 return
374374}
375+
376+ func (s * Stage ) createNextStagesOutputDirectories () {
377+ for _ , nextStage := range s .NextStages {
378+ if (s .Id == nextStage .Id ) {
379+ continue
380+ }
381+ // Construct the output directory path
382+ stageOutputPath := filepath .Join (s .OutputPath , nextStage .Id )
383+ nextStage .OutputPath = stageOutputPath
384+
385+ // Create the directory
386+ utils .PrepareOutputDirectory (stageOutputPath )
387+
388+ // Recursively call the function on the child stage
389+ nextStage .createNextStagesOutputDirectories ()
390+ }
391+ }
0 commit comments