You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "mohsenify (via GitHub)" <gi...@apache.org> on 2025/03/26 11:28:01 UTC

[I] Exception on Subsequent Writes When Using Nessie or REST Catalog in Iceberg [iceberg]

mohsenify opened a new issue, #12652:
URL: https://github.com/apache/iceberg/issues/12652

   ### Apache Iceberg version
   
   1.7.1
   
   ### Query engine
   
   None
   
   ### Please describe the bug 🐞
   
   When writing data using Iceberg on local Minio with the Hadoop catalog, everything works fine. However, when switching to Nessie catalog or REST catalog, an exception occurs after the first write operation.
   Steps to Reproduce
   
   -     Write data using Iceberg with the Hadoop catalog (works fine).
   -     Switch to Nessie or REST catalog.
   -     Perform the first write (succeeds).
   -     Attempt a second write (fails with an exception).
   
   
   My code: 
   
   `  public void insert(List<Record> records, String tableName) {
   
       String fileName = UUID.randomUUID().toString();
       Table table = getTable(tableName);
   
       Map<String, List<Record>> partitionedRecords =
           records.stream().collect(Collectors.groupingBy(rec ->
               Objects.equals(table.spec(), PartitionSpec.unpartitioned()) ?
                   table.locationProvider().newDataLocation(fileName) :
                   table.locationProvider().newDataLocation(table.spec(), rec, fileName))
           );
   
       List<DataFile> dataFiles =
           partitionedRecords.entrySet().stream()
               .map(e -> writeRecordsToFile(e.getKey(), e.getValue(), table)).toList();
   
       addFilesToTable(dataFiles, table);
     }
   
     private void addFilesToTable(List<DataFile> dataFiles, Table table) {
       AppendFiles appendFiles = table.newAppend();
       dataFiles.forEach(appendFiles::appendFile);
       appendFiles.commit();
     }`
   
   Exception:
   
   `java.lang.IllegalStateException: Cannot create data file from unclosed writer`
   
   ### Willingness to contribute
   
   - [ ] I can contribute a fix for this bug independently
   - [x] I would be willing to contribute a fix for this bug with guidance from the Iceberg community
   - [ ] I cannot contribute a fix for this bug at this time


-- 
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: issues-unsubscribe@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Exception on Subsequent Writes When Using Nessie or REST Catalog in Iceberg [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #12652:
URL: https://github.com/apache/iceberg/issues/12652#issuecomment-3393759983

   This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Exception on Subsequent Writes When Using Nessie or REST Catalog in Iceberg [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #12652:
URL: https://github.com/apache/iceberg/issues/12652#issuecomment-3340852636

   This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Exception on Subsequent Writes When Using Nessie or REST Catalog in Iceberg [iceberg]

Posted by "mohsenify (via GitHub)" <gi...@apache.org>.
mohsenify commented on issue #12652:
URL: https://github.com/apache/iceberg/issues/12652#issuecomment-2764581395

   @nastra  Of course, here’s the writer code I forgot to send earlier:
   
   ```
     private DataFile writeRecordsToFile(String filePath, List<Record> records, Table table) {
   
       try (FileIO io = table.io();
            DataWriter<Record> dataWriter = Parquet.writeData(io.newOutputFile(filePath))
                .schema(table.schema())
                .createWriterFunc(GenericParquetWriter::buildWriter)
                .overwrite()
                .withSpec(table.spec())
                .build()) {
         try (dataWriter) {
           records.forEach(dataWriter::write);
         }
         return dataWriter.toDataFile();
       } catch (IOException e) {
   //
       }
     }
   
   ```


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Exception on Subsequent Writes When Using Nessie or REST Catalog in Iceberg [iceberg]

Posted by "nastra (via GitHub)" <gi...@apache.org>.
nastra commented on issue #12652:
URL: https://github.com/apache/iceberg/issues/12652#issuecomment-2754335817

   @mohsenify can you please share the full stack trace? Also how are you writing the records to the file? The exception is coming from https://github.com/apache/iceberg/blob/c6d38e35750724d3b6b8d318ea465561bec5fd4d/core/src/main/java/org/apache/iceberg/io/DataWriter.java#L98 and indicates that you're accessing `toDataFile()` before you closed the writer.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Exception on Subsequent Writes When Using Nessie or REST Catalog in Iceberg [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed issue #12652: Exception on Subsequent Writes When Using Nessie or REST Catalog in Iceberg
URL: https://github.com/apache/iceberg/issues/12652


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org