Skip to content

[Storage] Support Parquet in Quick query #15539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.8.0" />
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.6.0" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.6.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.6.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.10.0-beta.2" />
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.8.0-beta.2" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.8.0-beta.2" />
<PackageReference Include="Azure.Storage.Queues" Version="12.8.0-beta.2" />
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="22.0.0" />
</ItemGroup>

Expand Down
3 changes: 3 additions & 0 deletions src/Storage/Storage.Management/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
- `Enable-AzStorageBlobLastAccessTimeTracking`
- `Disable-AzStorageBlobLastAccessTimeTracking`
- `Add-AzStorageAccountManagementPolicyAction`
* Supported Parquest as input text config in blob quick query
- `New-AzStorageBlobQueryConfig`
- `Get-AzStorageBlobQueryResult`
* Made `Get-AzDataLakeGen2ChildItem` list all datalake gen2 items by default, instead of needing user to list chunk by chunk.
* Fixed BlobProperties is empty issue when using sas without prefix '?' [#15460]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ The **Get-AzStorageBlobQueryResult** cmdlet applies a simple Structured Query La

### Example 1: Query a blob
```powershell
PS C:\> $inputconfig = New-AzStorageBlobQueryConfig -AsCsv -HasHeader
PS C:\> $inputconfig = New-AzStorageBlobQueryConfig -AsParquet
PS C:\> $outputconfig = New-AzStorageBlobQueryConfig -AsJson
PS C:\> $outputconfig = New-AzStorageBlobQueryConfig -AsCsv -HasHeader
PS C:\> $queryString = "SELECT * FROM BlobStorage WHERE Name = 'a'"
Expand Down Expand Up @@ -387,7 +387,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ New-AzStorageBlobQueryConfig [-AsCsv] [-RecordSeparator <String>] [-ColumnSepara
New-AzStorageBlobQueryConfig [-AsJson] [-RecordSeparator <String>] [-AsJob] [<CommonParameters>]
```

### Parquet
```
New-AzStorageBlobQueryConfig [-AsParquet] [-AsJob] [<CommonParameters>]
```

## DESCRIPTION
The **New-AzStorageBlobQueryConfig** cmdlet creates a blob query configuration object, which can be used in Get-AzStorageBlobQueryResult.

Expand Down Expand Up @@ -94,6 +99,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -AsParquet
Indicate to create a Blob Query Configuration for Parquet.
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: Parquet
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -ColumnSeparator
Optional.
The string used to separate columns.
Expand Down Expand Up @@ -164,7 +184,7 @@ The string used to separate records.
```yaml
Type: System.String
Parameter Sets: (All)
Parameter Sets: Csv, Json
Aliases:

Required: False
Expand All @@ -175,7 +195,7 @@ Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
Expand Down
26 changes: 23 additions & 3 deletions src/Storage/Storage/Blob/Cmdlet/NewAzStorageBlobQueryConfig .cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public class NewAzStorageBlobQueryConfigCommand : AzureDataCmdlet
/// </summary>
private const string JsonParameterSet = "Json";

[Parameter(Mandatory = true,
/// <summary>
/// Parquet parameter set name
/// </summary>
private const string ParquetParameterSet = "Parquet";

[Parameter(Mandatory = true,
Position = 0,
HelpMessage = "Indicate to create a Blob Query Configuration for CSV.",
ParameterSetName = CsvParameterSet)]
Expand All @@ -41,11 +46,18 @@ public class NewAzStorageBlobQueryConfigCommand : AzureDataCmdlet

[Parameter(Mandatory = true,
Position = 0,
HelpMessage = "Indicate to create a Blob Query Configuration for Json.",
HelpMessage = "Indicate to create a Blob Query Configuration for Json.",
ParameterSetName = JsonParameterSet)]
[ValidateNotNullOrEmpty]
public SwitchParameter AsJson { get; set; }

[Parameter(Mandatory = true,
Position = 0,
HelpMessage = "Indicate to create a Blob Query Configuration for Parquet.",
ParameterSetName = ParquetParameterSet)]
[ValidateNotNullOrEmpty]
public SwitchParameter AsParquet { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Optional. The string used to separate records.", ParameterSetName = CsvParameterSet)]
[Parameter(Mandatory = false, HelpMessage = "Optional. The string used to separate records.", ParameterSetName = JsonParameterSet)]
public string RecordSeparator { get; set; }
Expand Down Expand Up @@ -114,7 +126,7 @@ public override void ExecuteCmdlet()
};
WriteObject(queryConfig);
}
else // Csv
else if (this.AsCsv.IsPresent) // Csv
{
PSBlobQueryTextConfiguration queryConfig = new PSBlobQueryCsvTextConfiguration()
{
Expand All @@ -127,6 +139,14 @@ public override void ExecuteCmdlet()
};
WriteObject(queryConfig);
}
else // Parquet
{
PSBlobQueryParquetTextOptions queryConfig = new PSBlobQueryParquetTextOptions()
{
Type = BlobQueryConfigType.Parquet
};
WriteObject(queryConfig);
}
}
}
}
34 changes: 31 additions & 3 deletions src/Storage/Storage/Common/BlobQueryTextConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel
public enum BlobQueryConfigType
{
Csv,
Json
Json,
Parquet
}

/// <summary>
Expand All @@ -32,7 +33,6 @@ public enum BlobQueryConfigType
public abstract class PSBlobQueryTextConfiguration
{
public BlobQueryConfigType Type { get; set; }
public string RecordSeparator { get; set; }

public BlobQueryTextOptions ParseBlobQueryTextConfiguration()
{
Expand All @@ -48,14 +48,18 @@ public BlobQueryTextOptions ParseBlobQueryTextConfiguration()
HasHeaders = csvconfig.HasHeaders
};
}
else //json
else if (this.Type == BlobQueryConfigType.Json) //json
{
PSBlobQueryJsonTextConfiguration jsonconfig = (PSBlobQueryJsonTextConfiguration)this;
return new BlobQueryJsonTextOptions()
{
RecordSeparator = jsonconfig.RecordSeparator
};
}
else //Parquet
{
return new BlobQueryParquetTextOptions();
}
}
}

Expand All @@ -64,6 +68,7 @@ public BlobQueryTextOptions ParseBlobQueryTextConfiguration()
/// </summary>
public class PSBlobQueryJsonTextConfiguration : PSBlobQueryTextConfiguration
{
public string RecordSeparator { get; set; }
public PSBlobQueryJsonTextConfiguration() { }

public PSBlobQueryJsonTextConfiguration(BlobQueryJsonTextOptions config)
Expand All @@ -86,6 +91,7 @@ public BlobQueryJsonTextOptions ParseBlobQueryJsonTextConfiguration()
/// </summary>
public class PSBlobQueryCsvTextConfiguration : PSBlobQueryTextConfiguration
{
public string RecordSeparator { get; set; }
public string ColumnSeparator { get; set; }
public char? QuotationCharacter { get; set; }
public char? EscapeCharacter { get; set; }
Expand Down Expand Up @@ -117,6 +123,28 @@ public BlobQueryCsvTextOptions ParseBlobQueryCsvTextConfiguration()
}
}


/// <summary>
/// Wrapper Class for BlobQueryParquetTextOptions
/// </summary>
public class PSBlobQueryParquetTextOptions : PSBlobQueryTextConfiguration
{
public PSBlobQueryParquetTextOptions()
{
this.Type = BlobQueryConfigType.Parquet;
}

public PSBlobQueryParquetTextOptions(BlobQueryParquetTextOptions config)
{
this.Type = BlobQueryConfigType.Parquet;
}

public BlobQueryParquetTextOptions ParseBlobQueryParquetTextOptions()
{
return new BlobQueryParquetTextOptions();
}
}

/// <summary>
/// Wrapper of BlobQueryError
/// </summary>
Expand Down
8 changes: 4 additions & 4 deletions src/Storage/Storage/Storage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.8.0" />
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.6.0" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.6.0" />
<PackageReference Include="Azure.Storage.Queues" Version="12.6.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.10.0-beta.2" />
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.8.0-beta.2" />
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.8.0-beta.2" />
<PackageReference Include="Azure.Storage.Queues" Version="12.8.0-beta.2" />
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.8" />
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.2.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
"Az.Storage","Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet.SetAzureStorageFileContent","Set-AzStorageFileContent","0","1050","The parameter set '__AllParameterSets' for cmdlet 'Set-AzStorageFileContent' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'Set-AzStorageFileContent'."
"Az.Storage","Microsoft.Azure.Commands.Management.Storage.NewAzureStorageAccountCommand","New-AzStorageAccount","0","2040","The validation set for parameter 'DefaultSharePermission' for cmdlet 'New-AzStorageAccount' no longer contains the value 'StorageFileDataSmbShareOwner'.","Add 'StorageFileDataSmbShareOwner' back to the validation set for 'DefaultSharePermission'."
"Az.Storage","Microsoft.Azure.Commands.Management.Storage.SetAzureStorageAccountCommand","Set-AzStorageAccount","0","2040","The validation set for parameter 'DefaultSharePermission' for cmdlet 'Set-AzStorageAccount' no longer contains the value 'StorageFileDataSmbShareOwner'.","Add 'StorageFileDataSmbShareOwner' back to the validation set for 'DefaultSharePermission'."
"Az.Storage","Microsoft.WindowsAzure.Commands.Storage.Blob.GetStorageAzureBlobQueryResultCommand","Get-AzStorageBlobQueryResult","0","3010","The property 'RecordSeparator' of type 'Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.PSBlobQueryTextConfiguration' has been removed.","Add the property 'RecordSeparator' back to type 'Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.PSBlobQueryTextConfiguration'."
"Az.Storage","Microsoft.WindowsAzure.Commands.Storage.Blob.GetStorageAzureBlobQueryResultCommand","Get-AzStorageBlobQueryResult","0","3010","The property 'RecordSeparator' of type 'Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.PSBlobQueryTextConfiguration' has been removed.","Add the property 'RecordSeparator' back to type 'Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.PSBlobQueryTextConfiguration'."
"Az.Storage","Microsoft.Azure.Commands.Management.Storage.NewAzStorageBlobQueryConfigCommand","New-AzStorageBlobQueryConfig","0","3010","The property 'RecordSeparator' of type 'Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.PSBlobQueryTextConfiguration' has been removed.","Add the property 'RecordSeparator' back to type 'Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.PSBlobQueryTextConfiguration'."