Skip to content
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

[ADLA] - Support table preview #4443

Merged
merged 2 commits into from
Jun 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -115,6 +115,22 @@ public void GetCatalogItemsTest()
Assert.True(tableListResponse.Count() >= 1);
Assert.True(tableListResponse.ElementAt(0).ColumnList == null || tableListResponse.ElementAt(0).ColumnList.Count() == 0);

// Get preview of the specific table
var tablePreviewGetResponse =
clientToUse.Catalog.PreviewTable(
commonData.SecondDataLakeAnalyticsAccountName,
commonData.DatabaseName,
CommonTestFixture.SchemaName,
commonData.TableName
);

Assert.True(tablePreviewGetResponse.TotalRowCount > 0);
Assert.True(tablePreviewGetResponse.TotalColumnCount > 0);
Assert.True(tablePreviewGetResponse.Rows != null && tablePreviewGetResponse.Rows.Count() > 0);
Assert.True(tablePreviewGetResponse.Schema != null && tablePreviewGetResponse.Schema.Count() > 0);
Assert.NotNull(tablePreviewGetResponse.Schema[0].Name);
Assert.NotNull(tablePreviewGetResponse.Schema[0].Type);

// Get the specific table as well
var tableGetResponse =
clientToUse.Catalog.GetTable(
Expand Down Expand Up @@ -234,6 +250,23 @@ public void GetCatalogItemsTest()
Assert.True(partitionList.Count() >= 1);

var specificPartition = partitionList.First();

// Get preview of the specific partition
var partitionPreviewGetResponse =
clientToUse.Catalog.PreviewTablePartition(
commonData.SecondDataLakeAnalyticsAccountName,
commonData.DatabaseName,
CommonTestFixture.SchemaName,
commonData.TableName,
specificPartition.Name
);

Assert.True(partitionPreviewGetResponse.TotalRowCount > 0);
Assert.True(partitionPreviewGetResponse.TotalColumnCount > 0);
Assert.True(partitionPreviewGetResponse.Rows != null && partitionPreviewGetResponse.Rows.Count() > 0);
Assert.True(partitionPreviewGetResponse.Schema != null && partitionPreviewGetResponse.Schema.Count() > 0);
Assert.NotNull(tablePreviewGetResponse.Schema[0].Name);
Assert.NotNull(tablePreviewGetResponse.Schema[0].Type);

// Get the specific partition as well
var partitionGetResponse =
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal static class DataLakeAnalyticsCustomizationHelper
/// This constant is used as the default package version to place in the user agent.
/// It should mirror the package version in the project.json file.
/// </summary>
internal const string PackageVersion = "3.4.0-preview";
internal const string PackageVersion = "3.5.0-preview";

internal const string DefaultAdlaDnsSuffix = "azuredatalakeanalytics.net";

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,82 @@ public static USqlTableStatistics GetTableStatistic(this ICatalogOperations oper
}
}

/// <summary>
/// Retrieves a preview set of rows in given partition.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='accountName'>
/// The Azure Data Lake Analytics account upon which to execute catalog
/// operations.
/// </param>
/// <param name='databaseName'>
/// The name of the database containing the partition.
/// </param>
/// <param name='schemaName'>
/// The name of the schema containing the partition.
/// </param>
/// <param name='tableName'>
/// The name of the table containing the partition.
/// </param>
/// <param name='partitionName'>
/// The name of the table partition.
/// </param>
/// <param name='maxRows'>
/// The maximum number of preview rows to be retrieved.Rows returned may be
/// less than or equal to this number depending on row sizes and number of rows
/// in the partition.
/// </param>
/// <param name='maxColumns'>
/// The maximum number of columns to be retrieved.
/// </param>
public static USqlTablePreview PreviewTablePartition(this ICatalogOperations operations, string accountName, string databaseName, string schemaName, string tableName, string partitionName, long? maxRows = default(long?), long? maxColumns = default(long?))
{
return operations.PreviewTablePartitionAsync(accountName, databaseName, schemaName, tableName, partitionName, maxRows, maxColumns).GetAwaiter().GetResult();
}

/// <summary>
/// Retrieves a preview set of rows in given partition.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='accountName'>
/// The Azure Data Lake Analytics account upon which to execute catalog
/// operations.
/// </param>
/// <param name='databaseName'>
/// The name of the database containing the partition.
/// </param>
/// <param name='schemaName'>
/// The name of the schema containing the partition.
/// </param>
/// <param name='tableName'>
/// The name of the table containing the partition.
/// </param>
/// <param name='partitionName'>
/// The name of the table partition.
/// </param>
/// <param name='maxRows'>
/// The maximum number of preview rows to be retrieved.Rows returned may be
/// less than or equal to this number depending on row sizes and number of rows
/// in the partition.
/// </param>
/// <param name='maxColumns'>
/// The maximum number of columns to be retrieved.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<USqlTablePreview> PreviewTablePartitionAsync(this ICatalogOperations operations, string accountName, string databaseName, string schemaName, string tableName, string partitionName, long? maxRows = default(long?), long? maxColumns = default(long?), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.PreviewTablePartitionWithHttpMessagesAsync(accountName, databaseName, schemaName, tableName, partitionName, maxRows, maxColumns, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}

/// <summary>
/// Retrieves the specified table partition from the Data Lake Analytics
/// catalog.
Expand Down Expand Up @@ -1687,6 +1763,76 @@ public static USqlTablePartition GetTablePartition(this ICatalogOperations opera
}
}

/// <summary>
/// Retrieves a preview set of rows in given table.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='accountName'>
/// The Azure Data Lake Analytics account upon which to execute catalog
/// operations.
/// </param>
/// <param name='databaseName'>
/// The name of the database containing the table.
/// </param>
/// <param name='schemaName'>
/// The name of the schema containing the table.
/// </param>
/// <param name='tableName'>
/// The name of the table.
/// </param>
/// <param name='maxRows'>
/// The maximum number of preview rows to be retrieved. Rows returned may be
/// less than or equal to this number depending on row sizes and number of rows
/// in the table.
/// </param>
/// <param name='maxColumns'>
/// The maximum number of columns to be retrieved.
/// </param>
public static USqlTablePreview PreviewTable(this ICatalogOperations operations, string accountName, string databaseName, string schemaName, string tableName, long? maxRows = default(long?), long? maxColumns = default(long?))
{
return operations.PreviewTableAsync(accountName, databaseName, schemaName, tableName, maxRows, maxColumns).GetAwaiter().GetResult();
}

/// <summary>
/// Retrieves a preview set of rows in given table.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='accountName'>
/// The Azure Data Lake Analytics account upon which to execute catalog
/// operations.
/// </param>
/// <param name='databaseName'>
/// The name of the database containing the table.
/// </param>
/// <param name='schemaName'>
/// The name of the schema containing the table.
/// </param>
/// <param name='tableName'>
/// The name of the table.
/// </param>
/// <param name='maxRows'>
/// The maximum number of preview rows to be retrieved. Rows returned may be
/// less than or equal to this number depending on row sizes and number of rows
/// in the table.
/// </param>
/// <param name='maxColumns'>
/// The maximum number of columns to be retrieved.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<USqlTablePreview> PreviewTableAsync(this ICatalogOperations operations, string accountName, string databaseName, string schemaName, string tableName, long? maxRows = default(long?), long? maxColumns = default(long?), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.PreviewTableWithHttpMessagesAsync(accountName, databaseName, schemaName, tableName, maxRows, maxColumns, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}

/// <summary>
/// Retrieves the list of table partitions from the Data Lake Analytics
/// catalog.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,49 @@ public partial interface ICatalogOperations
/// </exception>
Task<AzureOperationResponse<IPage<USqlTableStatistics>>> ListTableStatisticsWithHttpMessagesAsync(string accountName, string databaseName, string schemaName, string tableName, ODataQuery<USqlTableStatistics> odataQuery = default(ODataQuery<USqlTableStatistics>), string select = default(string), bool? count = default(bool?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves a preview set of rows in given partition.
/// </summary>
/// <param name='accountName'>
/// The Azure Data Lake Analytics account upon which to execute catalog
/// operations.
/// </param>
/// <param name='databaseName'>
/// The name of the database containing the partition.
/// </param>
/// <param name='schemaName'>
/// The name of the schema containing the partition.
/// </param>
/// <param name='tableName'>
/// The name of the table containing the partition.
/// </param>
/// <param name='partitionName'>
/// The name of the table partition.
/// </param>
/// <param name='maxRows'>
/// The maximum number of preview rows to be retrieved.Rows returned
/// may be less than or equal to this number depending on row sizes and
/// number of rows in the partition.
/// </param>
/// <param name='maxColumns'>
/// The maximum number of columns to be retrieved.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.Azure.CloudException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<AzureOperationResponse<USqlTablePreview>> PreviewTablePartitionWithHttpMessagesAsync(string accountName, string databaseName, string schemaName, string tableName, string partitionName, long? maxRows = default(long?), long? maxColumns = default(long?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves the specified table partition from the Data Lake
/// Analytics catalog.
/// </summary>
Expand Down Expand Up @@ -1006,6 +1049,46 @@ public partial interface ICatalogOperations
/// </exception>
Task<AzureOperationResponse<USqlTablePartition>> GetTablePartitionWithHttpMessagesAsync(string accountName, string databaseName, string schemaName, string tableName, string partitionName, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves a preview set of rows in given table.
/// </summary>
/// <param name='accountName'>
/// The Azure Data Lake Analytics account upon which to execute catalog
/// operations.
/// </param>
/// <param name='databaseName'>
/// The name of the database containing the table.
/// </param>
/// <param name='schemaName'>
/// The name of the schema containing the table.
/// </param>
/// <param name='tableName'>
/// The name of the table.
/// </param>
/// <param name='maxRows'>
/// The maximum number of preview rows to be retrieved. Rows returned
/// may be less than or equal to this number depending on row sizes and
/// number of rows in the table.
/// </param>
/// <param name='maxColumns'>
/// The maximum number of columns to be retrieved.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.Azure.CloudException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
/// Thrown when unable to deserialize the response
/// </exception>
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<AzureOperationResponse<USqlTablePreview>> PreviewTableWithHttpMessagesAsync(string accountName, string databaseName, string schemaName, string tableName, long? maxRows = default(long?), long? maxColumns = default(long?), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Retrieves the list of table partitions from the Data Lake Analytics
/// catalog.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Microsoft.Azure.Management.DataLake.Analytics.Models
{
using Newtonsoft.Json;
using System;
using System.Linq;

/// <summary>
Expand Down Expand Up @@ -57,5 +58,28 @@ public USqlTableColumn()
[JsonProperty(PropertyName = "type")]
public string Type { get; set; }


/// <summary>
/// Gets or sets the name of the column in the table.
/// </summary>
[Obsolete("This property is only used for compability. It will be removed in the future. Use Name instead")]
[JsonProperty(PropertyName = "columnName")]
internal string ColumnName
{
get { return this.Name; }
set { this.Name = value; }
}

/// <summary>
/// Gets or sets the object type of the specified column (such as
/// System.String).
/// </summary>
[Obsolete("This property is only used for compability. It will be removed in the future. Use Type instead")]
[JsonProperty(PropertyName = "datatype")]
internal string DataType
{
get { return this.Type; }
set { this.Type = value; }
}
}
}
Loading