From 1a9bf17a872c912e7c5c1f488db1b355970c8310 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 4 May 2018 02:16:57 +0000 Subject: [PATCH] Generated from 16f41ff45fce953fd50292dcd43b22e5c70df58f [ADLA] - Catalog - Support table preview * Retrieves a preview set of rows in given table * Retrieves a preview set of rows in given partition --- .../analytics/catalog/models/__init__.py | 3 + .../catalog/models/usql_table_preview.py | 53 ++++++ .../catalog/models/usql_table_preview_py3.py | 53 ++++++ .../catalog/operations/catalog_operations.py | 162 ++++++++++++++++++ 4 files changed, 271 insertions(+) create mode 100644 azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/usql_table_preview.py create mode 100644 azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/usql_table_preview_py3.py diff --git a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/__init__.py b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/__init__.py index b10c0c1928b2..031c65b77ffa 100644 --- a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/__init__.py +++ b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/__init__.py @@ -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 @@ -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 @@ -125,6 +127,7 @@ 'EntityId', 'ExternalTable', 'TypeFieldInfo', + 'USqlTablePreview', 'USqlTable', 'USqlTableFragment', 'USqlTableType', diff --git a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/usql_table_preview.py b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/usql_table_preview.py new file mode 100644 index 000000000000..9962446d2e32 --- /dev/null +++ b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/usql_table_preview.py @@ -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) diff --git a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/usql_table_preview_py3.py b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/usql_table_preview_py3.py new file mode 100644 index 000000000000..972044d66119 --- /dev/null +++ b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/models/usql_table_preview_py3.py @@ -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 diff --git a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/operations/catalog_operations.py b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/operations/catalog_operations.py index a59096fb5794..f0df58d8f79a 100644 --- a/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/operations/catalog_operations.py +++ b/azure-mgmt-datalake-analytics/azure/mgmt/datalake/analytics/catalog/operations/catalog_operations.py @@ -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`. + :return: USqlTablePreview or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.datalake.analytics.catalog.models.USqlTablePreview + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`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 @@ -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`. + :return: USqlTablePreview or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.datalake.analytics.catalog.models.USqlTablePreview + or ~msrest.pipeline.ClientRawResponse + :raises: :class:`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