alamb commented on issue #7744:
URL: 
https://github.com/apache/arrow-datafusion/issues/7744#issuecomment-1749435395

   I am not sure about extending the `RecordBatchStream` -- given we don't know 
what partition column values are in the input it will not be possible to know 
how many output files (one for each partition that has data) are needed before 
the plan is run.
   
   I think actually writing to a partitioned datasource will require a more 
dynamic approach, with something similar to a `RepartitionExec` that 
dynamically creates a FileSink whenever new values are seen. I tried to sketch 
out what this might look like here:
   
   ```
                                                               rows from the 
input batch                       
                                                              that belong to 
partition 1  ─ ─ ─ ─ ─ ┐          
                                                                                
                               
                                                                                
                    │          
                                                                                
                    ▼          
                                                                               
┌──────┐        Partition 1     
                                                                       
┌──────▶│Batch │     (date=2023-10-01)  
                                                                       │       
└──────┘                        
                                                                       │       
┌──────┐                        
                                                   ┌────────────┐      
├──────▶│Batch │        Partition 2     
   ┌───────────┐            ┌────────────┐         │            │▒     │       
└──────┘     (date=2023-10-02)  
   │  batch N  │────▶...────▶  Batch 1   │────────▶│  Demux ?   │──────┤ ...    
                               
   └───────────┘            └────────────┘         │            │▒     │        
                               
                                                   └────────────┘▒     └──────▶ 
   ▲                           
                                                    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒              
                               
                                                                                
   └ ─ ─ ─ ─ ─                 
                                                                                
              │                
                                                                                
                               
                                      Input batches are repartitioned           
              │                
                                      according to partition column's           
 As new partition values are   
                                    values with a "Demux" operator (like        
seen, new output streams are   
                                              RepartitionExec)                  
                               
                                                                                
                               
                                                                                
                               
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to