0

I am trying to create a parquet file in an ALDS gen2 container but it is failing with below error

Status code 400, "{"error":{"code":"InvalidQueryParameterValue","message":"Value for one of the query parameters specified in the request URI is invalid.\nRequestId:0dec0224-c01f-0048-5227-36ecfc000000\nTime:2023-02-01T10:23:08.8603292Z"}}"

Below is the code snippet I am using to create a file:

public void uploadFile(File fileToUpload) {
    StorageSharedKeyCredential sharedKeyCredential = new StorageSharedKeyCredential("adlssynapse123","accountKey");

    DataLakeServiceClientBuilder builder = new DataLakeServiceClientBuilder();
    DataLakeServiceClient dataLakeServiceClient =
            builder.credential(sharedKeyCredential).endpoint(endpoint).buildClient(); 

    DataLakeFileSystemClient fileSystemClient = dataLakeServiceClient.getFileSystemClient("hdfs");

    DataLakeDirectoryClient directoryClient =fileSystemClient.getDirectoryClient("synapse/workspaces/adls-synapse/warehouse/adlstesting");

    DataLakeFileClient fileClient = directoryClient.createFile(fileToUpload.getName()); // This is where the execution fails

    fileClient.uploadFromFile(fileToUpload.getPath());
}

can some please help resolve this issue?

1 Answers1

0

Status code 400, "{"error":{"code":"InvalidQueryParameterValue","message":"Value for one of the query parameters specified in the request URI is invalid.\nRequestId:0dec0224-c01f-0048-5227 36ecfc000000\nTime:2023-02-01T10:23:08.8603292Z"}}"

The above error indicates one of the query parameters specified on the request URI is Invalid.

The issue is likely with the "fileToUpload.getName()" argument provided to the "createFile" method, as that is where the execution fails. Verify if the value of fileToUpload.getName() is a valid file name and identifies the API's requirements.

To create parquet file and upload in ADLS Gen 2 you can refer the below sample code:

Code:

 public static void main( String[] args )
    {
     StorageSharedKeyCredential sharedKeyCredential = new StorageSharedKeyCredential("Straccountname","<Account key>");
     DataLakeServiceClientBuilder builder = new DataLakeServiceClientBuilder();
     DataLakeServiceClient dataLakeServiceClient =builder
     .credential(sharedKeyCredential)
     .endpoint("https://Straccountname.dfs.core.windows.net")
     .buildClient(); 
     DataLakeFileSystemClient fileSystemClient = dataLakeServiceClient.getFileSystemClient("test");
     DataLakeDirectoryClient directoryClient =fileSystemClient.getDirectoryClient("synapse/workspaces");
     DataLakeFileClient fileClient = directoryClient.getFileClient("demo.parquet");
     fileClient.uploadFromFile("<filepath>");
  
    }

Console:

enter image description here

Portal:

enter image description here

Reference:

Use Java to manage data in Azure Data Lake Storage Gen2 - Azure Storage | Microsoft Learn

Venkatesan
  • 3,748
  • 1
  • 3
  • 15