@@ -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,19 @@ func (s *Stage) querySourceString(result *QueryResult) (sourceStr string) {
372372 }
373373 return
374374}
375+
376+ func (s * Stage ) createNextStagesOutputDirectories () {
377+ // Create parent stage id file path
378+ utils .PrepareOutputDirectory (s .OutputPath )
379+ for _ , nextStage := range s .NextStages {
380+ // Construct the output directory path
381+ stageOutputPath := filepath .Join (s .OutputPath , nextStage .Id )
382+ nextStage .OutputPath = stageOutputPath
383+
384+ // Create the directory
385+ utils .PrepareOutputDirectory (stageOutputPath )
386+
387+ // Recursively call the function on the child stage
388+ nextStage .createNextStagesOutputDirectories ()
389+ }
390+ }
0 commit comments