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

[GitHub] [iceberg] RussellSpitzer opened a new issue, #6685: StructCopy does not correctly Copy Fixed Data Type

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

   ### Apache Iceberg version
   
   None
   
   ### Query engine
   
   None
   
   ### Please describe the bug 🐞
   
   Fanout writer, and several other pieces of code. Use StructCopy to copy partition data. The implementation accidentally copies Array references for Fixed data types which will lead to errors when containers are re-used and a Fixed type column is in use.
   
   Discovered while reviewing #6680 
   
   The underlying issue PartitionData should be copied like
   
   ```java
             case FIXED:
               byte[] buffer = (byte[]) data[i];
               copy[i] = Arrays.copyOf(buffer, buffer.length);
               break;
    ```
   but instead the StructCopy code always does this
   ```java
         if (value instanceof StructLike) {
           values[i] = copy((StructLike) value);
         } else {
           values[i] = value;
         }
   ```
   
   Here is a reproduction
   
   ```java
       public void testCopyFixed() {
           Types.StructType fixed = Types.StructType.of(Types.NestedField.required(0, "fix", Types.FixedType.ofLength(4)));
           byte[] originalBytes = "2468".getBytes();
           PartitionData p = new PartitionData(fixed);
           p.set(0, originalBytes);
   
           PartitionData pdCopy = p.copy();
           StructLike sLcopy = StructCopy.copy(p);
           Assert.assertArrayEquals(
                   pdCopy.get(0, ByteBuffer.class).array(),
                   sLcopy.get(0, ByteBuffer.class).array());
   
           originalBytes[0] = '8';
   
           Assert.assertArrayEquals(
                   pdCopy.get(0, ByteBuffer.class).array(),
                   "2468".getBytes()
           );
   
           // Fails because the sLCopy incorrectly refers to the originalBytes object which was modified.
           Assert.assertArrayEquals(
                           pdCopy.get(0, ByteBuffer.class).array(),
                           sLcopy.get(0, ByteBuffer.class).array());
       }
   
   ```
         
   


-- 
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


[GitHub] [iceberg] github-actions[bot] commented on issue #6685: StructCopy does not correctly Copy Fixed Data Type

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

   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