Skip to content

Commit

Permalink
Generated from 16f41ff45fce953fd50292dcd43b22e5c70df58f (#2531)
Browse files Browse the repository at this point in the history
[ADLA] - Catalog - Support table preview

* Retrieves a preview set of rows in given table

* Retrieves a preview set of rows in given partition
  • Loading branch information
AutorestCI authored May 8, 2018
1 parent 58cc56e commit 7f402a8
Show file tree
Hide file tree
Showing 4 changed files with 271 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from .entity_id_py3 import EntityId
from .external_table_py3 import ExternalTable
from .type_field_info_py3 import TypeFieldInfo
from .usql_table_preview_py3 import USqlTablePreview
from .usql_table_py3 import USqlTable
from .usql_table_fragment_py3 import USqlTableFragment
from .usql_table_type_py3 import USqlTableType
Expand Down Expand Up @@ -66,6 +67,7 @@
from .entity_id import EntityId
from .external_table import ExternalTable
from .type_field_info import TypeFieldInfo
from .usql_table_preview import USqlTablePreview
from .usql_table import USqlTable
from .usql_table_fragment import USqlTableFragment
from .usql_table_type import USqlTableType
Expand Down Expand Up @@ -125,6 +127,7 @@
'EntityId',
'ExternalTable',
'TypeFieldInfo',
'USqlTablePreview',
'USqlTable',
'USqlTableFragment',
'USqlTableType',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class USqlTablePreview(Model):
"""A Data Lake Analytics catalog table or partition preview rows item.
:param total_row_count: the total number of rows in the table or
partition.
:type total_row_count: long
:param total_column_count: the total number of columns in the table or
partition.
:type total_column_count: long
:param rows: the rows of the table or partition preview, where each row is
an array of string representations the row's values. Note: Byte arrays
will appear as base-64 encoded values, SqlMap and SqlArray objects will
appear as escaped JSON objects, and DateTime objects will appear as ISO
formatted UTC date-times.
:type rows: list[list[str]]
:param truncated: true if the amount of data in the response is less than
expected due to the preview operation's size limitations. This can occur
if the requested rows or row counts are too large.
:type truncated: bool
:param schema: the schema of the table or partition.
:type schema:
list[~azure.mgmt.datalake.analytics.catalog.models.USqlTableColumn]
"""

_attribute_map = {
'total_row_count': {'key': 'totalRowCount', 'type': 'long'},
'total_column_count': {'key': 'totalColumnCount', 'type': 'long'},
'rows': {'key': 'rows', 'type': '[[str]]'},
'truncated': {'key': 'truncated', 'type': 'bool'},
'schema': {'key': 'schema', 'type': '[USqlTableColumn]'},
}

def __init__(self, **kwargs):
super(USqlTablePreview, self).__init__(**kwargs)
self.total_row_count = kwargs.get('total_row_count', None)
self.total_column_count = kwargs.get('total_column_count', None)
self.rows = kwargs.get('rows', None)
self.truncated = kwargs.get('truncated', None)
self.schema = kwargs.get('schema', None)
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is
# regenerated.
# --------------------------------------------------------------------------

from msrest.serialization import Model


class USqlTablePreview(Model):
"""A Data Lake Analytics catalog table or partition preview rows item.
:param total_row_count: the total number of rows in the table or
partition.
:type total_row_count: long
:param total_column_count: the total number of columns in the table or
partition.
:type total_column_count: long
:param rows: the rows of the table or partition preview, where each row is
an array of string representations the row's values. Note: Byte arrays
will appear as base-64 encoded values, SqlMap and SqlArray objects will
appear as escaped JSON objects, and DateTime objects will appear as ISO
formatted UTC date-times.
:type rows: list[list[str]]
:param truncated: true if the amount of data in the response is less than
expected due to the preview operation's size limitations. This can occur
if the requested rows or row counts are too large.
:type truncated: bool
:param schema: the schema of the table or partition.
:type schema:
list[~azure.mgmt.datalake.analytics.catalog.models.USqlTableColumn]
"""

_attribute_map = {
'total_row_count': {'key': 'totalRowCount', 'type': 'long'},
'total_column_count': {'key': 'totalColumnCount', 'type': 'long'},
'rows': {'key': 'rows', 'type': '[[str]]'},
'truncated': {'key': 'truncated', 'type': 'bool'},
'schema': {'key': 'schema', 'type': '[USqlTableColumn]'},
}

def __init__(self, *, total_row_count: int=None, total_column_count: int=None, rows=None, truncated: bool=None, schema=None, **kwargs) -> None:
super(USqlTablePreview, self).__init__(**kwargs)
self.total_row_count = total_row_count
self.total_column_count = total_column_count
self.rows = rows
self.truncated = truncated
self.schema = schema
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,89 @@ def internal_paging(next_link=None, raw=False):
return deserialized
list_table_statistics.metadata = {'url': '/catalog/usql/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/statistics'}

def preview_table_partition(
self, account_name, database_name, schema_name, table_name, partition_name, max_rows=None, max_columns=None, custom_headers=None, raw=False, **operation_config):
"""Retrieves a preview set of rows in given partition.
:param account_name: The Azure Data Lake Analytics account upon which
to execute catalog operations.
:type account_name: str
:param database_name: The name of the database containing the
partition.
:type database_name: str
:param schema_name: The name of the schema containing the partition.
:type schema_name: str
:param table_name: The name of the table containing the partition.
:type table_name: str
:param partition_name: The name of the table partition.
:type partition_name: str
:param max_rows: 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.
:type max_rows: long
:param max_columns: The maximum number of columns to be retrieved.
:type max_columns: long
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: USqlTablePreview or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.datalake.analytics.catalog.models.USqlTablePreview
or ~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
# Construct URL
url = self.preview_table_partition.metadata['url']
path_format_arguments = {
'accountName': self._serialize.url("account_name", account_name, 'str', skip_quote=True),
'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True),
'databaseName': self._serialize.url("database_name", database_name, 'str'),
'schemaName': self._serialize.url("schema_name", schema_name, 'str'),
'tableName': self._serialize.url("table_name", table_name, 'str'),
'partitionName': self._serialize.url("partition_name", partition_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}
if max_rows is not None:
query_parameters['maxRows'] = self._serialize.query("max_rows", max_rows, 'long')
if max_columns is not None:
query_parameters['maxColumns'] = self._serialize.query("max_columns", max_columns, 'long')
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('USqlTablePreview', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized
preview_table_partition.metadata = {'url': '/catalog/usql/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/partitions/{partitionName}/previewrows'}

def get_table_partition(
self, account_name, database_name, schema_name, table_name, partition_name, custom_headers=None, raw=False, **operation_config):
"""Retrieves the specified table partition from the Data Lake Analytics
Expand Down Expand Up @@ -2331,6 +2414,85 @@ def get_table_partition(
return deserialized
get_table_partition.metadata = {'url': '/catalog/usql/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/partitions/{partitionName}'}

def preview_table(
self, account_name, database_name, schema_name, table_name, max_rows=None, max_columns=None, custom_headers=None, raw=False, **operation_config):
"""Retrieves a preview set of rows in given table.
:param account_name: The Azure Data Lake Analytics account upon which
to execute catalog operations.
:type account_name: str
:param database_name: The name of the database containing the table.
:type database_name: str
:param schema_name: The name of the schema containing the table.
:type schema_name: str
:param table_name: The name of the table.
:type table_name: str
:param max_rows: 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.
:type max_rows: long
:param max_columns: The maximum number of columns to be retrieved.
:type max_columns: long
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: USqlTablePreview or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.datalake.analytics.catalog.models.USqlTablePreview
or ~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
# Construct URL
url = self.preview_table.metadata['url']
path_format_arguments = {
'accountName': self._serialize.url("account_name", account_name, 'str', skip_quote=True),
'adlaCatalogDnsSuffix': self._serialize.url("self.config.adla_catalog_dns_suffix", self.config.adla_catalog_dns_suffix, 'str', skip_quote=True),
'databaseName': self._serialize.url("database_name", database_name, 'str'),
'schemaName': self._serialize.url("schema_name", schema_name, 'str'),
'tableName': self._serialize.url("table_name", table_name, 'str')
}
url = self._client.format_url(url, **path_format_arguments)

# Construct parameters
query_parameters = {}
if max_rows is not None:
query_parameters['maxRows'] = self._serialize.query("max_rows", max_rows, 'long')
if max_columns is not None:
query_parameters['maxColumns'] = self._serialize.query("max_columns", max_columns, 'long')
query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str')

# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')

# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, stream=False, **operation_config)

if response.status_code not in [200]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp

deserialized = None

if response.status_code == 200:
deserialized = self._deserialize('USqlTablePreview', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response

return deserialized
preview_table.metadata = {'url': '/catalog/usql/databases/{databaseName}/schemas/{schemaName}/tables/{tableName}/previewrows'}

def list_table_partitions(
self, account_name, database_name, schema_name, table_name, filter=None, top=None, skip=None, select=None, orderby=None, count=None, custom_headers=None, raw=False, **operation_config):
"""Retrieves the list of table partitions from the Data Lake Analytics
Expand Down

0 comments on commit 7f402a8

Please sign in to comment.