You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by xi...@apache.org on 2026/03/04 21:07:43 UTC

(pinot) branch fix/adls-blob-soft-delete-support updated (6bbb0ebcd1f -> b07eda45d55)

This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a change to branch fix/adls-blob-soft-delete-support
in repository https://gitbox.apache.org/repos/asf/pinot.git


    omit 6bbb0ebcd1f Fix ADLS Gen2 plugin to support Azure Blob Soft Delete
     add 0038c06a6ab Fix MissingFormatArgumentException due to log (#17801)
     add 61b83649cec Make _pattern final to avoid unsafe initialization (#17804)
     add 83ae0eaf29f Bump org.checkerframework:checker-qual from 3.53.1 to 3.54.0 (#17802)
     add 68264d294de Enforce broker instance tags configuration at startup (#17786)
     add e483e467163 add PinotFS support for streamed untar segment download (#17586)
     add 51729e67a86 extend disk utilization check to offline segment upload (#17579)
     add ef36e829412 Fix resource tracking for gRPC ReceivingMailbox (#17797)
     add 5df2ffbdbc7  Add global pinot.md5.disabled switch and enforce MD5 guards (#17800)
     add 832c7d40378 Fixing routing table errors for multi-topic ingestion tables (#17810)
     add 7b89d1b4a83 [Bug fix] Fault-Domain-Aware Instance Assignment failing rebalance with minimize data movement (#17799)
     add 79a7a30ca2a Bump software.amazon.awssdk:bom from 2.42.4 to 2.42.5 (#17813)
     add c2de44ce9dd Bump org.jline:jline from 3.30.6 to 4.0.0 (#17814)
     add 4434eda332c Do not pass server metrics in PlanMaker (#17808)
     add 4633cf58866 Add checks to not update upsert / dedup configs after table creation (#17645)
     new b07eda45d55 Fix ADLS Gen2 plugin to support Azure Blob Soft Delete

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (6bbb0ebcd1f)
            \
             N -- N -- N   refs/heads/fix/adls-blob-soft-delete-support (b07eda45d55)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../broker/broker/helix/BaseBrokerStarter.java     |  10 +
 .../SegmentPartitionMetadataManager.java           |   2 +-
 .../SegmentPartitionMetadataManagerTest.java       |  21 +-
 ... TableConfigBackwardIncompatibleException.java} |   4 +-
 .../utils/fetcher/PinotFSSegmentFetcher.java       |  40 ++++
 .../pinot/common/utils/regex/JavaUtilPattern.java  |   2 +-
 .../utils/fetcher/PinotFSSegmentFetcherTest.java   | 229 +++++++++++++++++++++
 .../pinot/controller/BaseControllerStarter.java    |  19 +-
 .../apache/pinot/controller/ControllerConf.java    |  20 ++
 .../PinotSegmentUploadDownloadRestletResource.java |  26 +++
 .../api/resources/PinotTableRestletResource.java   |  12 +-
 .../api/resources/TableConfigsRestletResource.java |  13 +-
 .../helix/core/PinotHelixResourceManager.java      |  77 ++++++-
 .../instance/FDAwareInstancePartitionSelector.java |   8 +-
 .../RealtimeOffsetAutoResetKafkaHandler.java       |  14 +-
 .../controller/validation/UtilizationChecker.java  |   4 +-
 .../helix/LogicalTableMetadataCacheTest.java       |   2 +-
 .../instance/InstanceAssignmentTest.java           |  61 ++++++
 .../core/plan/maker/InstancePlanMakerImplV2.java   |   7 +-
 .../apache/pinot/core/plan/maker/PlanMaker.java    |  24 ++-
 .../query/executor/ServerQueryExecutorV1Impl.java  |   6 +-
 .../org/apache/pinot/queries/BaseQueriesTest.java  |   6 +-
 .../org/apache/pinot/minion/BaseMinionStarter.java |   3 +
 ...BenchmarkAggregateGroupByOrderByQueriesSSE.java |   6 +-
 .../pinot/plugin/filesystem/ADLSGen2PinotFS.java   |  13 +-
 .../filesystem/test/ADLSGen2PinotFSTest.java       |  32 +++
 .../apache/pinot/plugin/filesystem/S3Config.java   |   6 +
 .../pinot/plugin/filesystem/S3ConfigTest.java      |  13 ++
 .../pinot/query/mailbox/ReceivingMailbox.java      |  93 ++++++++-
 .../operator/BaseMailboxReceiveOperator.java       |   6 +-
 .../pinot/query/mailbox/ReceivingMailboxTest.java  |  71 +++++--
 .../pinot/segment/local/utils/HashUtils.java       |   6 +
 .../segment/local/utils/TableConfigUtils.java      | 158 +++++++++++++-
 .../pinot/segment/local/utils/HashUtilsTest.java   |  16 ++
 .../segment/local/utils/TableConfigUtilsTest.java  |  77 +++++++
 .../pinot/segment/spi/memory/EmptyIndexBuffer.java |  69 +++----
 .../server/starter/helix/BaseServerStarter.java    |   3 +
 .../java/org/apache/pinot/spi/data/Schema.java     |  12 ++
 .../apache/pinot/spi/utils/CommonConstants.java    |   6 +
 .../{ResourceUsageUtils.java => PinotMd5Mode.java} |  29 +--
 .../apache/pinot/spi/utils/PinotMd5ModeTest.java   |  60 ++++++
 pom.xml                                            |   6 +-
 42 files changed, 1152 insertions(+), 140 deletions(-)
 copy pinot-common/src/main/java/org/apache/pinot/common/exception/{SchemaBackwardIncompatibleException.java => TableConfigBackwardIncompatibleException.java} (86%)
 create mode 100644 pinot-common/src/test/java/org/apache/pinot/common/utils/fetcher/PinotFSSegmentFetcherTest.java
 copy pinot-spi/src/main/java/org/apache/pinot/spi/utils/{ResourceUsageUtils.java => PinotMd5Mode.java} (56%)
 create mode 100644 pinot-spi/src/test/java/org/apache/pinot/spi/utils/PinotMd5ModeTest.java


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


(pinot) 01/01: Fix ADLS Gen2 plugin to support Azure Blob Soft Delete

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch fix/adls-blob-soft-delete-support
in repository https://gitbox.apache.org/repos/asf/pinot.git

commit b07eda45d553cef20bd2010a1032a073f3475eb1
Author: Xiang Fu <xi...@startree.ai>
AuthorDate: Tue Mar 3 10:48:42 2026 -0800

    Fix ADLS Gen2 plugin to support Azure Blob Soft Delete
    
    The DFS (Data Lake) API endpoint does not support Azure Blob Soft Delete,
    causing 409 EndpointUnsupportedAccountFeatures errors when uploading
    segments to storage accounts with org-mandated Soft Delete policies.
    
    This change adds a BlobContainerClient alongside the existing
    DataLakeFileSystemClient, using the Blob API (*.blob.core.windows.net)
    for file uploads which is fully compatible with Soft Delete. The DFS API
    is retained for read/metadata operations (list, exists, open, etc.) and
    as a write fallback when the BlobContainerClient is not initialized.
    
    Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
 pinot-plugins/pinot-file-system/pinot-adls/pom.xml |  4 +
 .../pinot/plugin/filesystem/ADLSGen2PinotFS.java   | 94 ++++++++++++++++++----
 .../filesystem/test/ADLSGen2PinotFSTest.java       | 67 ++++++++++++++-
 3 files changed, 149 insertions(+), 16 deletions(-)

diff --git a/pinot-plugins/pinot-file-system/pinot-adls/pom.xml b/pinot-plugins/pinot-file-system/pinot-adls/pom.xml
index a95142cb367..da0b7e40f56 100644
--- a/pinot-plugins/pinot-file-system/pinot-adls/pom.xml
+++ b/pinot-plugins/pinot-file-system/pinot-adls/pom.xml
@@ -38,6 +38,10 @@
       <groupId>com.azure</groupId>
       <artifactId>azure-storage-file-datalake</artifactId>
     </dependency>
+    <dependency>
+      <groupId>com.azure</groupId>
+      <artifactId>azure-storage-blob</artifactId>
+    </dependency>
     <dependency>
       <groupId>com.azure</groupId>
       <artifactId>azure-identity</artifactId>
diff --git a/pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/ADLSGen2PinotFS.java b/pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/ADLSGen2PinotFS.java
index e3b3cc01baa..01bcbdba273 100644
--- a/pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/ADLSGen2PinotFS.java
+++ b/pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/ADLSGen2PinotFS.java
@@ -26,6 +26,12 @@ import com.azure.core.util.Context;
 import com.azure.identity.ClientSecretCredential;
 import com.azure.identity.ClientSecretCredentialBuilder;
 import com.azure.identity.DefaultAzureCredentialBuilder;
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.BlobServiceClient;
+import com.azure.storage.blob.BlobServiceClientBuilder;
+import com.azure.storage.blob.models.BlobHttpHeaders;
+import com.azure.storage.blob.models.BlobStorageException;
 import com.azure.storage.common.StorageSharedKeyCredential;
 import com.azure.storage.common.Utility;
 import com.azure.storage.file.datalake.DataLakeDirectoryClient;
@@ -112,6 +118,10 @@ public class ADLSGen2PinotFS extends BasePinotFS {
 
   private DataLakeFileSystemClient _fileSystemClient;
 
+  // Blob API client used for file uploads to support Azure storage accounts with Blob Soft Delete enabled.
+  // The DFS API (Data Lake) does not support Soft Delete, causing 409 EndpointUnsupportedAccountFeatures errors.
+  private BlobContainerClient _blobContainerClient;
+
   // If enabled, pinotFS implementation will guarantee that the bits you've read are the same as the ones you wrote.
   // However, there's some overhead in computing hash. (Adds roughly 3 seconds for 1GB file)
   private boolean _enableChecksum;
@@ -119,10 +129,17 @@ public class ADLSGen2PinotFS extends BasePinotFS {
   public ADLSGen2PinotFS() {
   }
 
+  @VisibleForTesting
   public ADLSGen2PinotFS(DataLakeFileSystemClient fileSystemClient) {
     _fileSystemClient = fileSystemClient;
   }
 
+  @VisibleForTesting
+  public ADLSGen2PinotFS(DataLakeFileSystemClient fileSystemClient, BlobContainerClient blobContainerClient) {
+    _fileSystemClient = fileSystemClient;
+    _blobContainerClient = blobContainerClient;
+  }
+
   @Override
   public void init(PinotConfiguration config) {
     boolean checksumEnabled = config.getProperty(ENABLE_CHECKSUM, false);
@@ -154,9 +171,12 @@ public class ADLSGen2PinotFS extends BasePinotFS {
     String sasToken = config.getProperty(SAS_TOKEN);
 
     String dfsServiceEndpointUrl = HTTPS_URL_PREFIX + accountName + AZURE_STORAGE_DNS_SUFFIX;
+    String blobServiceEndpointUrl = HTTPS_URL_PREFIX + accountName + AZURE_BLOB_DNS_SUFFIX;
 
     DataLakeServiceClientBuilder dataLakeServiceClientBuilder =
         new DataLakeServiceClientBuilder().endpoint(dfsServiceEndpointUrl);
+    BlobServiceClientBuilder blobServiceClientBuilder =
+        new BlobServiceClientBuilder().endpoint(blobServiceEndpointUrl);
 
     switch (authType) {
       case ACCESS_KEY: {
@@ -166,6 +186,7 @@ public class ADLSGen2PinotFS extends BasePinotFS {
 
         StorageSharedKeyCredential sharedKeyCredential = new StorageSharedKeyCredential(accountName, accessKey);
         dataLakeServiceClientBuilder.credential(sharedKeyCredential);
+        blobServiceClientBuilder.credential(sharedKeyCredential);
         break;
       }
       case SAS_TOKEN: {
@@ -175,6 +196,7 @@ public class ADLSGen2PinotFS extends BasePinotFS {
 
         AzureSasCredential azureSasCredential = new AzureSasCredential(sasToken);
         dataLakeServiceClientBuilder.credential(azureSasCredential);
+        blobServiceClientBuilder.credential(azureSasCredential);
         break;
       }
       case AZURE_AD: {
@@ -187,6 +209,7 @@ public class ADLSGen2PinotFS extends BasePinotFS {
             new ClientSecretCredentialBuilder().clientId(clientId).clientSecret(clientSecret).tenantId(tenantId)
                 .build();
         dataLakeServiceClientBuilder.credential(clientSecretCredential);
+        blobServiceClientBuilder.credential(clientSecretCredential);
         break;
       }
       case AZURE_AD_WITH_PROXY: {
@@ -207,7 +230,9 @@ public class ADLSGen2PinotFS extends BasePinotFS {
             new ClientSecretCredentialBuilder().clientId(clientId).clientSecret(clientSecret).tenantId(tenantId);
         clientSecretCredentialBuilder.httpClient(builder.build());
 
-        dataLakeServiceClientBuilder.credential(clientSecretCredentialBuilder.build());
+        ClientSecretCredential credential = clientSecretCredentialBuilder.build();
+        dataLakeServiceClientBuilder.credential(credential);
+        blobServiceClientBuilder.credential(credential);
         break;
       }
       case DEFAULT: {
@@ -226,6 +251,7 @@ public class ADLSGen2PinotFS extends BasePinotFS {
           defaultAzureCredentialBuilder.authorityHost(authorityHost);
         }
         dataLakeServiceClientBuilder.credential(defaultAzureCredentialBuilder.build());
+        blobServiceClientBuilder.credential(defaultAzureCredentialBuilder.build());
         break;
       }
       case ANONYMOUS_ACCESS: {
@@ -241,8 +267,12 @@ public class ADLSGen2PinotFS extends BasePinotFS {
     DataLakeServiceClient serviceClient = dataLakeServiceClientBuilder.buildClient();
     _fileSystemClient = getOrCreateClientWithFileSystem(serviceClient, fileSystemName);
 
+    BlobServiceClient blobServiceClient = blobServiceClientBuilder.buildClient();
+    _blobContainerClient = blobServiceClient.getBlobContainerClient(fileSystemName);
+
     LOGGER.info("ADLSGen2PinotFS is initialized (accountName={}, fileSystemName={}, dfsServiceEndpointUrl={}, "
-        + "enableChecksum={})", accountName, fileSystemName, dfsServiceEndpointUrl, _enableChecksum);
+        + "blobServiceEndpointUrl={}, enableChecksum={})", accountName, fileSystemName, dfsServiceEndpointUrl,
+        blobServiceEndpointUrl, _enableChecksum);
   }
 
   /**
@@ -550,7 +580,7 @@ public class ADLSGen2PinotFS extends BasePinotFS {
     LOGGER.debug("copyFromLocalFile is called with srcFile='{}', dstUri='{}'", srcFile, dstUri);
     byte[] contentMd5 = _enableChecksum ? computeContentMd5(srcFile) : null;
     try (InputStream fileInputStream = new FileInputStream(srcFile)) {
-      copyInputStreamToDst(fileInputStream, dstUri, contentMd5);
+      copyInputStreamToDst(fileInputStream, dstUri, contentMd5, srcFile.length());
     }
   }
 
@@ -637,34 +667,73 @@ public class ADLSGen2PinotFS extends BasePinotFS {
     PathProperties pathProperties =
         _fileSystemClient.getFileClient(AzurePinotFSUtil.convertUriToAzureStylePath(srcUri)).getProperties();
     try (InputStream inputStream = open(srcUri)) {
-      return copyInputStreamToDst(inputStream, dstUri, pathProperties.getContentMd5());
+      return copyInputStreamToDst(inputStream, dstUri, pathProperties.getContentMd5(),
+          pathProperties.getFileSize());
     }
   }
 
   /**
    * Helper function to copy input stream to destination URI.
    *
+   * <p>Uses the Azure Blob API for uploads, which is compatible with storage accounts that have Blob Soft Delete
+   * enabled. The DFS (Data Lake) API does not support Soft Delete and will fail with 409
+   * EndpointUnsupportedAccountFeatures on such accounts.</p>
+   *
    * NOTE: the caller has to close the input stream.
    *
    * @param inputStream input stream that will be written to dstUri
    * @param dstUri destination URI
+   * @param contentMd5 optional MD5 hash of the content
+   * @param contentLength length of the content in bytes
    * @return true if the copy succeeds
    */
-  private boolean copyInputStreamToDst(InputStream inputStream, URI dstUri, byte[] contentMd5)
+  private boolean copyInputStreamToDst(InputStream inputStream, URI dstUri, byte[] contentMd5, long contentLength)
+      throws IOException {
+    String path = AzurePinotFSUtil.convertUriToAzureStylePath(dstUri);
+
+    if (_blobContainerClient != null) {
+      return copyInputStreamToDstViaBlob(inputStream, dstUri, path, contentMd5, contentLength);
+    }
+    return copyInputStreamToDstViaDfs(inputStream, dstUri, path, contentMd5);
+  }
+
+  /**
+   * Upload via Azure Blob API. Compatible with Blob Soft Delete.
+   */
+  private boolean copyInputStreamToDstViaBlob(InputStream inputStream, URI dstUri, String path, byte[] contentMd5,
+      long contentLength)
+      throws IOException {
+    try {
+      BlobClient blobClient = _blobContainerClient.getBlobClient(path);
+      blobClient.upload(inputStream, contentLength, true);
+
+      if (contentMd5 != null) {
+        blobClient.setHttpHeaders(new BlobHttpHeaders().setContentMd5(contentMd5));
+      }
+      return true;
+    } catch (BlobStorageException e) {
+      LOGGER.error("Exception thrown while uploading to destination via Blob API (dstUri={}, errorStatus={})", dstUri,
+          e.getStatusCode(), e);
+      throw new IOException(e);
+    }
+  }
+
+  /**
+   * Upload via DFS (Data Lake) API. Does NOT support Blob Soft Delete.
+   * Kept as fallback for backward compatibility when BlobContainerClient is not initialized.
+   */
+  private boolean copyInputStreamToDstViaDfs(InputStream inputStream, URI dstUri, String path, byte[] contentMd5)
       throws IOException {
     int bytesRead;
     long totalBytesRead = 0;
     byte[] buffer = new byte[BUFFER_SIZE];
-    // TODO: the newer client now has the API 'uploadFromFile' that directly takes the file as an input. We can replace
-    // this upload logic with the 'uploadFromFile'/
     DataLakeFileClient fileClient;
     try {
-      fileClient = _fileSystemClient.createFile(AzurePinotFSUtil.convertUriToAzureStylePath(dstUri));
+      fileClient = _fileSystemClient.createFile(path);
     } catch (DataLakeStorageException e) {
-      // If the path already exists, doing nothing and return true
       if (e.getStatusCode() == ALREADY_EXISTS_STATUS_CODE && e.getErrorCode().equals(PATH_ALREADY_EXISTS_ERROR_CODE)) {
         LOGGER.info("The destination path already exists and we are overwriting the file (dstUri={})", dstUri);
-        fileClient = _fileSystemClient.createFile(AzurePinotFSUtil.convertUriToAzureStylePath(dstUri), true);
+        fileClient = _fileSystemClient.createFile(path, true);
       } else {
         LOGGER.error("Exception thrown while calling copy stream to destination (dstUri={}, errorStatus ={})", dstUri,
             e.getStatusCode(), e);
@@ -672,7 +741,6 @@ public class ADLSGen2PinotFS extends BasePinotFS {
       }
     }
 
-    // Update MD5 metadata
     if (contentMd5 != null) {
       PathHttpHeaders pathHttpHeaders = getPathHttpHeaders(fileClient.getProperties());
       pathHttpHeaders.setContentMd5(contentMd5);
@@ -683,21 +751,17 @@ public class ADLSGen2PinotFS extends BasePinotFS {
       while ((bytesRead = inputStream.read(buffer)) != -1) {
         byte[] md5BlockHash = null;
         if (_enableChecksum) {
-          // Compute md5 for the current block
           MessageDigest md5Block = MessageDigest.getInstance("MD5");
           md5Block.update(buffer, 0, bytesRead);
           md5BlockHash = md5Block.digest();
         }
-        // Upload 4MB at a time since Azure's limit for each append call is 4MB.
         ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer, 0, bytesRead);
         fileClient.appendWithResponse(byteArrayInputStream, totalBytesRead, bytesRead, md5BlockHash, null, null,
             Context.NONE);
         byteArrayInputStream.close();
         totalBytesRead += bytesRead;
       }
-      // Call flush on ADLS Gen 2
       fileClient.flush(totalBytesRead, true);
-
       return true;
     } catch (DataLakeStorageException | NoSuchAlgorithmException e) {
       throw new IOException(e);
diff --git a/pinot-plugins/pinot-file-system/pinot-adls/src/test/java/org/apache/pinot/plugin/filesystem/test/ADLSGen2PinotFSTest.java b/pinot-plugins/pinot-file-system/pinot-adls/src/test/java/org/apache/pinot/plugin/filesystem/test/ADLSGen2PinotFSTest.java
index c7823006520..fa178a8f22e 100644
--- a/pinot-plugins/pinot-file-system/pinot-adls/src/test/java/org/apache/pinot/plugin/filesystem/test/ADLSGen2PinotFSTest.java
+++ b/pinot-plugins/pinot-file-system/pinot-adls/src/test/java/org/apache/pinot/plugin/filesystem/test/ADLSGen2PinotFSTest.java
@@ -21,6 +21,10 @@ package org.apache.pinot.plugin.filesystem.test;
 import com.azure.core.http.rest.PagedIterable;
 import com.azure.core.http.rest.SimpleResponse;
 import com.azure.core.util.Context;
+import com.azure.storage.blob.BlobClient;
+import com.azure.storage.blob.BlobContainerClient;
+import com.azure.storage.blob.models.BlobHttpHeaders;
+import com.azure.storage.blob.models.BlobStorageException;
 import com.azure.storage.file.datalake.DataLakeDirectoryClient;
 import com.azure.storage.file.datalake.DataLakeFileClient;
 import com.azure.storage.file.datalake.DataLakeFileSystemClient;
@@ -89,6 +93,10 @@ public class ADLSGen2PinotFSTest {
   private PagedIterable _mockPagedIterable;
   @Mock
   private PathItem _mockPathItem;
+  @Mock
+  private BlobContainerClient _mockBlobContainerClient;
+  @Mock
+  private BlobClient _mockBlobClient;
 
   private URI _mockURI;
   private ADLSGen2PinotFS _adlsGen2PinotFsUnderTest;
@@ -107,7 +115,7 @@ public class ADLSGen2PinotFSTest {
   public void tearDown() {
     verifyNoMoreInteractions(_mockDataLakeStorageException, _mockServiceClient, _mockFileSystemClient,
         _mockSimpleResponse, _mockDirectoryClient, _mockPathItem, _mockPagedIterable, _mockPathProperties,
-        _mockFileClient, _mockFileOpenInputStreamResult, _mockInputStream);
+        _mockFileClient, _mockFileOpenInputStreamResult, _mockInputStream, _mockBlobContainerClient, _mockBlobClient);
   }
 
   @Test(expectedExceptions = NullPointerException.class)
@@ -642,4 +650,61 @@ public class ADLSGen2PinotFSTest {
       }
     }
   }
+
+  @Test
+  public void testCopyFromLocalFileViaBlobApi() throws Exception {
+    // Create a test instance with Blob API support
+    ADLSGen2PinotFS blobEnabledFs = new ADLSGen2PinotFS(_mockFileSystemClient, _mockBlobContainerClient);
+
+    // Create a temporary file with test data
+    File tempFile = File.createTempFile("pinot_blob_test", ".tmp");
+    byte[] testData = "test segment data".getBytes();
+    Files.write(tempFile.toPath(), testData);
+
+    URI dstUri = new URI("adl2://account/container/test_segment");
+    String expectedPath = AzurePinotFSUtil.convertUriToAzureStylePath(dstUri);
+
+    when(_mockBlobContainerClient.getBlobClient(expectedPath)).thenReturn(_mockBlobClient);
+    doNothing().when(_mockBlobClient).upload(any(InputStream.class), eq((long) testData.length), eq(true));
+
+    try {
+      blobEnabledFs.copyFromLocalFile(tempFile, dstUri);
+
+      verify(_mockBlobContainerClient).getBlobClient(expectedPath);
+      verify(_mockBlobClient).upload(any(InputStream.class), eq((long) testData.length), eq(true));
+      // copyFromLocalFile always computes MD5, so setHttpHeaders is always called
+      verify(_mockBlobClient).setHttpHeaders(any(BlobHttpHeaders.class));
+    } finally {
+      FileUtils.deleteQuietly(tempFile);
+    }
+  }
+
+  @Test
+  public void testCopyFromLocalFileViaBlobApiWithException() throws Exception {
+    // Create a test instance with Blob API support
+    ADLSGen2PinotFS blobEnabledFs = new ADLSGen2PinotFS(_mockFileSystemClient, _mockBlobContainerClient);
+
+    // Create a temporary file with test data
+    File tempFile = File.createTempFile("pinot_blob_test", ".tmp");
+    byte[] testData = "test segment data".getBytes();
+    Files.write(tempFile.toPath(), testData);
+
+    URI dstUri = new URI("adl2://account/container/test_segment");
+    String expectedPath = AzurePinotFSUtil.convertUriToAzureStylePath(dstUri);
+
+    BlobStorageException blobException = mock(BlobStorageException.class);
+    when(blobException.getStatusCode()).thenReturn(500);
+    when(_mockBlobContainerClient.getBlobClient(expectedPath)).thenReturn(_mockBlobClient);
+    doThrow(blobException).when(_mockBlobClient).upload(any(InputStream.class), eq((long) testData.length), eq(true));
+
+    try {
+      expectThrows(IOException.class, () -> blobEnabledFs.copyFromLocalFile(tempFile, dstUri));
+
+      verify(_mockBlobContainerClient).getBlobClient(expectedPath);
+      verify(_mockBlobClient).upload(any(InputStream.class), eq((long) testData.length), eq(true));
+      verify(blobException).getStatusCode();
+    } finally {
+      FileUtils.deleteQuietly(tempFile);
+    }
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org