:doc:`Athena <../../athena>` / Client / get_query_results

*****************
get_query_results
*****************



.. py:method:: Athena.Client.get_query_results(**kwargs)

  

  Streams the results of a single query execution specified by ``QueryExecutionId`` from the Athena query results location in Amazon S3. For more information, see `Working with query results, recent queries, and output files <https://docs.aws.amazon.com/athena/latest/ug/querying.html>`__ in the *Amazon Athena User Guide*. This request does not execute the query but returns results. Use  StartQueryExecution to run a query.

   

  To stream query results successfully, the IAM principal with permission to call ``GetQueryResults`` also must have permissions to the Amazon S3 ``GetObject`` action for the Athena query results location.

   

  .. warning::

     

    IAM principals with permission to the Amazon S3 ``GetObject`` action for the query results location are able to retrieve query results from Amazon S3 even if permission to the ``GetQueryResults`` action is denied. To restrict user or role access, ensure that Amazon S3 permissions to the Athena query location are denied.

    

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/athena-2017-05-18/GetQueryResults>`_  


  **Request Syntax**
  ::

    response = client.get_query_results(
        QueryExecutionId='string',
        NextToken='string',
        MaxResults=123,
        QueryResultType='DATA_MANIFEST'|'DATA_ROWS'
    )
    
  :type QueryExecutionId: string
  :param QueryExecutionId: **[REQUIRED]** 

    The unique ID of the query execution.

    

  
  :type NextToken: string
  :param NextToken: 

    A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the ``NextToken`` from the response object of the previous page call.

    

  
  :type MaxResults: integer
  :param MaxResults: 

    The maximum number of results (rows) to return in this request.

    

  
  :type QueryResultType: string
  :param QueryResultType: 

    When you set this to ``DATA_ROWS`` or empty, ``GetQueryResults`` returns the query results in rows. If set to ``DATA_MANIFEST``, it returns the manifest file in rows. Only the query types ``CREATE TABLE AS SELECT``, ``UNLOAD``, and ``INSERT`` can generate a manifest file. If you use ``DATA_MANIFEST`` for other query types, the query will fail.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'UpdateCount': 123,
          'ResultSet': {
              'Rows': [
                  {
                      'Data': [
                          {
                              'VarCharValue': 'string'
                          },
                      ]
                  },
              ],
              'ResultSetMetadata': {
                  'ColumnInfo': [
                      {
                          'CatalogName': 'string',
                          'SchemaName': 'string',
                          'TableName': 'string',
                          'Name': 'string',
                          'Label': 'string',
                          'Type': 'string',
                          'Precision': 123,
                          'Scale': 123,
                          'Nullable': 'NOT_NULL'|'NULLABLE'|'UNKNOWN',
                          'CaseSensitive': True|False
                      },
                  ]
              }
          },
          'NextToken': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **UpdateCount** *(integer) --* 

        The number of rows inserted with a ``CREATE TABLE AS SELECT``, ``INSERT INTO``, or ``UPDATE`` statement.

        
      

      - **ResultSet** *(dict) --* 

        The results of the query execution.

        
        

        - **Rows** *(list) --* 

          The rows in the table.

          
          

          - *(dict) --* 

            The rows that make up a query result table.

            
            

            - **Data** *(list) --* 

              The data that populates a row in a query result table.

              
              

              - *(dict) --* 

                A piece of data (a field in the table).

                
                

                - **VarCharValue** *(string) --* 

                  The value of the datum.

                  
            
          
        
      
        

        - **ResultSetMetadata** *(dict) --* 

          The metadata that describes the column structure and data types of a table of query results.

          
          

          - **ColumnInfo** *(list) --* 

            Information about the columns returned in a query result metadata.

            
            

            - *(dict) --* 

              Information about the columns in a query execution result.

              
              

              - **CatalogName** *(string) --* 

                The catalog to which the query results belong.

                
              

              - **SchemaName** *(string) --* 

                The schema name (database name) to which the query results belong.

                
              

              - **TableName** *(string) --* 

                The table name for the query results.

                
              

              - **Name** *(string) --* 

                The name of the column.

                
              

              - **Label** *(string) --* 

                A column label.

                
              

              - **Type** *(string) --* 

                The data type of the column.

                
              

              - **Precision** *(integer) --* 

                For ``DECIMAL`` data types, specifies the total number of digits, up to 38. For performance reasons, we recommend up to 18 digits.

                
              

              - **Scale** *(integer) --* 

                For ``DECIMAL`` data types, specifies the total number of digits in the fractional part of the value. Defaults to 0.

                
              

              - **Nullable** *(string) --* 

                Unsupported constraint. This value always shows as ``UNKNOWN``.

                
              

              - **CaseSensitive** *(boolean) --* 

                Indicates whether values in the column are case-sensitive.

                
          
        
      
    
      

      - **NextToken** *(string) --* 

        A token generated by the Athena service that specifies where to continue pagination if a previous request was truncated. To obtain the next set of pages, pass in the ``NextToken`` from the response object of the previous page call.

        
  
  **Exceptions**
  
  *   :py:class:`Athena.Client.exceptions.InternalServerException`

  
  *   :py:class:`Athena.Client.exceptions.InvalidRequestException`

  
  *   :py:class:`Athena.Client.exceptions.TooManyRequestsException`

  