HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/surface/dataflow/sql/__pycache__/query.cpython-312.pyc
�

�����8�dZddlmZddlmZddlmZddlmZddlZddlmZddlm	Z	dd	l
mZdd
lm
Z
ddlmZddlmZd
dd�Zej$ej&j(ej&j*�Gd�dej,��Zy)z6Implementation of `gcloud dataflow sql query` command.�)�absolute_import)�division)�print_function)�unicode_literalsN)�apis)�sql_query_parameters)�base)�
dataflow_util)�sql_util)�
propertiesz�Execute the user-specified SQL query on Dataflow. Queries must comply to the ZetaSQL dialect (https://github.com/google/zetasql). Results may be written to either BigQuery or Cloud Pub/Sub.a�      To execute a simple SQL query on Dataflow that reads from and writes to BigQuery, run:

        $ {command} 'SELECT word FROM bigquery.table.`my-project`.input_dataset.input_table where count > 3' --job-name=my-job --region=us-west1 --bigquery-dataset=my_output_dataset --bigquery-table=my_output_table

      To execute a simple SQL query on Dataflow that reads from and writes to Cloud
      Pub/Sub, run:

        $ {command} 'SELECT word FROM pubsub.topic.`my-project`.input_topic where count > 3' --job-name=my-job --region=us-west1 --pubsub-topic=my_output_topic

      To join data from BigQuery and Cloud Pub/Sub and write the result to Cloud
      Pub/Sub, run:

        $ {command} 'SELECT bq.name AS name FROM pubsub.topic.`my-project`.input_topic p INNER JOIN bigquery.table.`my-project`.input_dataset.input_table bq ON p.id = bq.id' --job-name=my-job --region=us-west1 --pubsub-topic=my_output_topic

      To execute a parameterized SQL query that reads from and writes to BigQuery, run:

        $ {command} 'SELECT word FROM bigquery.table.`my-project`.input_dataset.input_table where count > @threshold' --parameter=threshold:INT64:5 --job-name=my-job --region=us-west1 --bigquery-dataset=my_output_dataset --bigquery-table=my_output_table

    )�DESCRIPTION�EXAMPLESc�*�eZdZdZeZed��Zd�Zy)�Queryz1Execute the user-specified SQL query on Dataflow.c�.�tj|�y)zrRegister flags for this command.

    Args:
      parser: argparse.ArgumentParser to register arguments with.
    N)r�ArgsForSqlQuery)�parsers �!lib/surface/dataflow/sql/query.py�Argsz
Query.ArgsBs��
���V�$�c��|jdk(}tj|�}|jr
|j}n|rd}nd}dj	||�}|j
r t
j|j
�}n.|jr t
j|j�}nd}tjd|jrdndfd	tj|�fd
|fd|jfg�}t!j"didt$j&j(j*j-��d
|�d|j.�d|�d|j0�d|j2�dt$j&j4j6j9��d|�d|j:�d|j<�d|j>�d|j@�d|jB�d|jD�d|jF�d|jH��}|rt jJjM|�St jJjO|�S)N�dynamic�sql_launcher_template�sql_launcher_flex_templatez(gs://dataflow-sql-templates-{}/latest/{}z[]�dryRun�true�false�outputs�queryParameters�queryString�
project_id�	region_id�job_name�gcs_location�zone�max_workers�disable_public_ips�
parameters�service_account_email�kms_key_name�num_workers�network�
subnetwork�worker_machine_type�
worker_region�worker_zone�)(�sql_launcher_template_enginer
�	GetRegionr�format�parameters_filer�ParseParametersFile�	parameter�ParseParametersList�collections�OrderedDict�dry_runr�ExtractOutputs�queryr�TemplateArgumentsr�VALUES�core�project�	GetOrFailr#r%r&�dataflowr'�GetBoolr)�dataflow_kms_keyr+r,r-r.r/r0�	Templates�LaunchDynamicTemplate�CreateJobFromFlexTemplate)	�self�args�use_dynamic_engine�regionr$�suffix�query_parameters�template_parameters�	argumentss	         r�Runz	Query.RunKs<���;�;�y�H��
�
$�
$�T�
*�F��!�!��/�/�l�	�(��-��?�F�F�
�&��l����-�A�A�
�
�
� ��	
���-�A�A�
�.�.�����%�1�1�	�T�\�\�6�w�7�	�H�+�+�D�1�2�	�,�-�	��
�
�#�	3����&�&�&��$�$�)�)�1�1�;�;�=�&��&����&�"�	&�
�Y�Y�&��$�$�
&�&�,�,�5�5�H�H�	���&�'�&�#�8�8�&��*�*�&��$�$�&����&��?�?�&�!�4�4�&� �(�(�!&�"�$�$�#&�I�$�
�^�^�
1�
1�)�
<�<��>�>�3�3�I�>�>rN)	�__name__�
__module__�__qualname__�__doc__�
DETAILED_HELP�
detailed_help�staticmethodrrQr1rrrr<s!��9��-��%��%�.?rr)rU�
__future__rrrrr9�googlecloudsdk.api_lib.dataflowrr�googlecloudsdk.callioper	�#googlecloudsdk.command_lib.dataflowr
r�googlecloudsdk.corerrV�
ReleaseTracks�ReleaseTrack�BETA�GA�Commandrr1rr�<module>rcs���=�&��%�'��0�@�(�=�8�*�	F�	�
�
�:����D�%�%�*�*�D�,=�,=�,@�,@�A�<?�D�L�L�<?�B�<?r