### Basic CLI Setup and Translation Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md This sequence demonstrates the initial setup for translating SQL files. It involves copying example files, creating a virtual environment, installing the client, and preparing the input directory. ```shell # Copy the example project directory to a project directory of your own # (preferably outside of the source tree to make pulling source updates easier). cp -R dwh-migration-tools/client/examples/teradata/sql # Change directory to your project directory. cd # Create a virtualenv and install the Python CLI. python3 -m venv venv source venv/bin/activate pip install ../dwh-migration-tools/client # Remove the example input files from the input directory. rm -rf input/* # Copy the files you would like to translate into the input directory. cp input/ # Edit the config/config.yaml file appropriately as described in the # "config.yaml" section below. # Set the appropriate environment variables as described in the ``` -------------------------------- ### Example Oracle Connection String Source: https://github.com/google/dwh-migration-tools/blob/main/migration-discovery-scripts/oracle/README.md An example of how to format the Oracle connection string for the discovery script. This includes the username, password, hostname, port, and service name. ```bash ./tco_discovery.sh system/PASSWORD@localhost:1521/ORCLCDB ``` -------------------------------- ### Install Client with ICU Support Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Use this command to install the Python CLI if your input files require support for encodings other than UTF-8. Ensure you have the necessary system dependencies installed first. ```shell pip install ../dwh-migration-tools/client[icu] ``` -------------------------------- ### Install Project Dependencies with Poetry Source: https://github.com/google/dwh-migration-tools/blob/main/client/CONTRIBUTING.md Installs all project dependencies, including extras, using Poetry. ```shell poetry install --all-extras ``` -------------------------------- ### Directory Structure for Examples Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md This is a recommended directory structure for using the CLI with the `run.sh` script, organizing configuration, input files, and scripts. ```tree . ├── clean.sh ├── config │ ├── config.yaml │ ├── macros_mapping.yaml │ └── object_name_mapping.json ├── deprovision.sh ├── input │ ├── case-sensitivity.sql │ ├── create-procedures.sql │ ... │ ├── metadata │ │ └── compilerworks-teradata-metadata.zip │ ├── subdir │ │ ├── test0.sql │ │ ... | ... ├── provision.sh └── run.sh ``` -------------------------------- ### Provision Cloud Run Resources Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Example execution of the provision.sh script to set up GCP resources for Cloud Run. This includes setting environment variables for project, GCS bucket, and service account. ```shell export BQMS_PROJECT="" export BQMS_DEVELOPER_EMAIL="" export BQMS_GCS_BUCKET="" export BQMS_GCS_BUCKET_LOCATION="" export BQMS_CLOUD_RUN_SERVICE_ACCOUNT_NAME="" export BQMS_ARTIFACT_PROJECT="" ./provision.sh ``` -------------------------------- ### Build Gcsync Client Source: https://github.com/google/dwh-migration-tools/blob/main/dbsync/README.md Build the Gcsync client using Gradle. You might need to install protobuf-compiler. ```bash ./gradlew :dbsync:gcsync:build ``` -------------------------------- ### Install Requirements for Terraform Generator Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/terraform/README.md Use these commands to install necessary Python libraries if encountering errors during the initial requirements installation. ```bash pip install "cython<3.0.0" wheel pip install "pyyaml==5.4.1" --no-build-isolation pip install -r requirements.txt ``` -------------------------------- ### SQL Script with Macro Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md An example SQL script containing a template variable that will be replaced during preprocessing based on the provided macro mapping. ```sql select ${MACRO_1} from foo ``` -------------------------------- ### Example config.yaml for Translation Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md This YAML file configures the translation type, region, and default database/schema settings for unqualified references. It is used by the `run.sh` script or when `bqms-run` requires a config path. ```yaml # The type of translation to perform e.g. Teradata to BigQuery. Doc: # https://cloud.google.com/bigquery/docs/reference/migration/rest/v2/projects.locations.workflows#migrationtask translation_type: Translation_Teradata2BQ # The region where the translation job will run. location: 'us' # Default database and schemas to use when looking up unqualified references: # https://cloud.google.com/bigquery/docs/output-name-mapping#default_database default_database: default_db # https://cloud.google.com/bigquery/docs/output-name-mapping#default_schema schema_search_path: - library - foo ``` -------------------------------- ### Execute Cloud Run Job Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Example execution of the run.sh script to sync files, create and run a Cloud Run job, and retrieve logs. This involves setting various environment variables related to the job configuration. ```shell export BQMS_VERBOSE="False" export BQMS_MULTITHREADED="True" export BQMS_PROJECT="" export BQMS_GCS_BUCKET="" export BQMS_CLOUD_RUN_REGION="" export BQMS_CLOUD_RUN_SERVICE_ACCOUNT_NAME="" export BQMS_CLOUD_RUN_JOB_NAME=" ``` -------------------------------- ### Clone Repository and Compile Dumper Source: https://github.com/google/dwh-migration-tools/blob/main/dumper/CONTRIBUTING.md Use these commands to clone the dumper repository and compile the application using Gradle. ```bash git clone https://github.com/google/dwh-migration-tools.git cd dwh-migration-tools/ ./gradlew :dumper:app:installDist ``` -------------------------------- ### Snowflake Logs Tool Options Source: https://github.com/google/dwh-migration-tools/wiki/Snowflake-Assessment Lists the available command-line arguments for the `snowflake-logs` tool, including connection parameters and log dumping configurations. ```bash --driver The vendor-supplied driver JARs to use for this connector. --host (default: localhost) The hostname of the database server. (Required if --url is not specified.) --user The username for the database connection. (Required on most systems.) --password The password for the database connection. (Required If not specified as an argument, will use a secure prompt..) --private-key-password Private Key file password. (Required If the private key file is encrypted..) --private-key-file Path to the Private Key file used for authentication. (Required If the database user uses keypair authentication..) --role The Snowflake role to use for authorization. --warehouse The Snowflake warehouse to use for processing metadata queries. --database The name of the database to connect to for making queries. --url Overrides the generated JDBC URI for the database connection. (Required only for complex installations.) --query-log-start Start date for query history to dump --query-log-days The number of days of query history to dump. --query-log-end End date for query history to dump -Dsnowflake.logs.query=value Custom query for log dump. -Dsnowflake.logs.where=value Custom where condition to append to query for log dump. -Dsnowflake.warehouse_events_history.query=value Custom query for warehouse events history dump -Dsnowflake.automatic_clustering_history.query=value Custom query for automatic clustering history dump -Dsnowflake.copy_history.query=value Custom query for copy history dump -Dsnowflake.database_replication_usage_history.query=value Custom query for database replication usage history dump -Dsnowflake.login_history.query=value Custom query for login history dump -Dsnowflake.metering_daily_history.query=value Custom query for metering daily history dump -Dsnowflake.pipe_usage_history.query=value Custom query for pipe usage history dump -Dsnowflake.query_acceleration_history.query=value Custom query for query acceleration history dump -Dsnowflake.replication_group_usage_history.query=value Custom query for replication group usage history dump -Dsnowflake.serverless_task_history.query=value Custom query for serverless task history dump -Dsnowflake.task_history.query=value Custom query for task history dump -Dsnowflake.warehouse_load_history.query=value Custom query for warehouse load history dump -Dsnowflake.warehouse_metering_history.query=value Custom query for warehouse metering history dump ``` -------------------------------- ### Build Dumper Application (No Tests) Source: https://github.com/google/dwh-migration-tools/blob/main/AGENTS.md Executes a build of the Dumper application module, skipping all tests. ```bash ./gradlew :dumper:app:build -x test ``` -------------------------------- ### Format Java Code Source: https://github.com/google/dwh-migration-tools/blob/main/dbsync/README.md Run the formatter on all Java files in the dbsync directory. ```bash java -jar dbsync/google-java-format-1.7-all-deps.jar -i $(git ls-files dbsync | grep '\.java$') ``` -------------------------------- ### Map Permissions using dwh-permissions-migration Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/README.md Use this command to map permissions based on rulesets, tables, principals, and dumper outputs. Requires a migration bucket. ```bash ./dwh-permissions-migration build \ --permissions-ruleset gs://MIGRATION_BUCKET/permissions-config.yaml \ --tables gs://MIGRATION_BUCKET/tables/ \ --principals gs://MIGRATION_BUCKET/principals.yaml \ --ranger-dumper-output gs://MIGRATION_BUCKET/ranger-dumper-output.zip \ --hdfs-dumper-output gs://MIGRATION_BUCKET/hdfs-dumper-output.zip \ --output-permissions gs://MIGRATION_BUCKET/permissions.yaml ``` -------------------------------- ### Run All Tests (Unit and Integration) with Custom Environment Variables Source: https://github.com/google/dwh-migration-tools/blob/main/client/CONTRIBUTING.md Activates the Poetry shell and runs all tests (unit and integration) using Nox. Requires setting environment variables for project, bucket, and verbosity. ```shell poetry shell BQMS_VERBOSE="False" \ BQMS_MULTITHREADED="True" \ BQMS_PROJECT="" \ BQMS_GCS_BUCKET="" \ nox -s tests ``` -------------------------------- ### Run Gcsync Client Source: https://github.com/google/dwh-migration-tools/blob/main/dbsync/README.md Run the Gcsync client after successful compilation. Specify target bucket, temporary bucket, project ID, location, source directory, task timeout, and number of concurrent tasks. ```bash java -jar gcsync-all.jar --target_bucket --tmp_bucket --project --location --source_directory --task_timeout –num_concurrent_tasks ``` -------------------------------- ### Activate Poetry Shell and Run Unit Tests Source: https://github.com/google/dwh-migration-tools/blob/main/client/CONTRIBUTING.md Activates the Poetry shell and runs unit tests using Nox. ```shell poetry shell nox -s tests -- unit ``` -------------------------------- ### Build Project Without Tests Source: https://github.com/google/dwh-migration-tools/blob/main/AGENTS.md Executes a build of the project, skipping all tests. ```bash ./gradlew build -x test ``` -------------------------------- ### Generate Licenses Report Source: https://github.com/google/dwh-migration-tools/blob/main/AGENTS.md Generates a report detailing the project's licenses. ```bash ./gradlew checkLicense ``` -------------------------------- ### Build DWH Dumper Module with Gradle Source: https://github.com/google/dwh-migration-tools/blob/main/README.md Use this command to build only the DWH Dumper module. Requires JDK 8 or higher. ```bash ./gradlew :dumper:app:build ``` -------------------------------- ### Check Code Formatting Source: https://github.com/google/dwh-migration-tools/blob/main/AGENTS.md Checks if the project code adheres to the defined formatting rules. ```bash ./gradlew spotlessCheck ``` -------------------------------- ### Generate Terraform Template Locally Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/terraform/README.md Run this command after setting up requirements and adding a permissions.yaml file to generate the Terraform template from your local environment. ```bash python tf_generator data/permissions.yaml ``` -------------------------------- ### Run Integration Tests with Custom Environment Variables Source: https://github.com/google/dwh-migration-tools/blob/main/client/CONTRIBUTING.md Activates the Poetry shell and runs integration tests using Nox. Requires setting environment variables for project, bucket, and verbosity. ```shell poetry shell BQMS_VERBOSE="False" \ BQMS_MULTITHREADED="True" \ BQMS_PROJECT="" \ BQMS_GCS_BUCKET="" \ nox -s tests -- integration ``` -------------------------------- ### Activate Poetry Shell and Run Analyze Source: https://github.com/google/dwh-migration-tools/blob/main/client/CONTRIBUTING.md Activates the Poetry shell and runs the 'analyze' Nox target for formatting, linting, and type checking. ```shell poetry shell nox -t analyze ``` -------------------------------- ### Build and Submit Container Image to Artifact Registry Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Command to build and submit a container image to Google Artifact Registry. This is a prerequisite for deploying to Cloud Run. ```shell gcloud --project="${BQMS_ARTIFACT_PROJECT}" builds submit \ -t "${BQMS_ARTIFACT_TAG}" ``` -------------------------------- ### Apply Permissions using dwh-permissions-migration Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/README.md Use this command to apply the generated permissions to GCP. Requires GCP connection and appropriate roles, or use the Python script for Terraform generation. ```bash ./dwh-permissions-migration apply \ --permissions gs://MIGRATION_BUCKET/permissions.yaml ``` -------------------------------- ### Build Docker Image for Testing Generated Terraform Template Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/terraform/README.md Build the Docker image used for testing the generated Terraform template. This image is based on the Dockerfile in the test directory. ```bash docker build -t tf-permission-builder . ``` -------------------------------- ### Format Code Source: https://github.com/google/dwh-migration-tools/blob/main/AGENTS.md Applies code formatting rules to the entire project. ```bash ./gradlew spotlessApply ``` -------------------------------- ### Build DWH Dumper Module Source: https://github.com/google/dwh-migration-tools/wiki/Home Builds the DWH Dumper application module specifically. Requires JDK 8 or higher. ```bash ./gradlew :dumper:app:build ``` -------------------------------- ### CPU Information Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Provides detailed CPU specifications, including architecture, core count, clock speed, and supported features. Helps in understanding the processing power used for benchmarks. ```shell > lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 46 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 24 On-line CPU(s) list: 0-23 Vendor ID: GenuineIntel Model name: Intel(R) Xeon(R) CPU @ 2.20GHz CPU family: 6 Model: 79 Thread(s) per core: 2 Core(s) per socket: 12 Socket(s): 1 Stepping: 0 BogoMIPS: 4400.41 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti ssbd ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat md_clear arch_capabilities Virtualization features: Hypervisor vendor: KVM Virtualization type: full Caches (sum of all): L1d: 384 KiB (12 instances) L1i: 384 KiB (12 instances) L2: 3 MiB (12 instances) L3: 55 MiB (1 instance) NUMA: NUMA node(s): 1 NUMA node0 CPU(s): 0-23 ``` -------------------------------- ### Map Principals using dwh-permissions-migration Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/README.md Use this command to map principals from HDFS and Ranger. Ensure you have a migration bucket configured. ```bash ./dwh-permissions-migration expand \ --principal-ruleset gs://MIGRATION_BUCKET/principals-ruleset.yaml \ --hdfs-dumper-output gs://MIGRATION_BUCKET/hdfs-dumper-output.zip \ --ranger-dumper-output gs://MIGRATION_BUCKET/ranger-dumper-output.zip \ --output-principals gs://MIGRATION_BUCKET/principals.yaml ``` -------------------------------- ### Run Tests with Verbose Logging Source: https://github.com/google/dwh-migration-tools/blob/main/client/CONTRIBUTING.md Activates the Poetry shell and runs tests with verbose logging enabled using Nox. ```shell poetry shell nox -s tests --verbose -- unit pytest_verbose ``` -------------------------------- ### Build Docker Image for Terraform Template Builder Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/terraform/README.md Build the Docker image required for generating Terraform templates using the Dockerfile. ```bash docker build -t tf-template-builder . ``` -------------------------------- ### Environment Variables for run.sh Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Set these environment variables before running the `run.sh` script for translation. `BQMS_PROJECT` and `BQMS_GCS_BUCKET` are required. ```shell export BQMS_VERBOSE="False" export BQMS_MULTITHREADED="True" export BQMS_PROJECT="" export BQMS_GCS_BUCKET="" ``` -------------------------------- ### Generate Hive Metastore Thrift Files Source: https://github.com/google/dwh-migration-tools/blob/main/dumper/lib-ext-hive-metastore/README.md Run this Gradle task to regenerate Java source files from Thrift definitions. Commit the generated files along with any changes to the Thrift files. ```bash ./gradlew :dumper:lib-ext-hive-metastore:generateThrift ``` -------------------------------- ### Run Multi-Threaded Migration Test Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Execute integration tests for Teradata migration in a multi-threaded mode. Ensure BQMS_MULTITHREADED is set to 'True'. ```shell BQMS_VERBOSE="True" \ BQMS_MULTITHREADED="True" \ BQMS_PROJECT="" \ BQMS_GCS_BUCKET="" \ pytest \ -vv \ --log-cli-level=DEBUG \ --log-cli-format="%(asctime)s: %(levelname)s: %(threadName)s: %(filename)s:%(lineno)s: %(message)s" \ -k "test_teradata_local[100000]" \ --performance \ tests/integration ``` -------------------------------- ### Run Single-Threaded Migration Test Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Execute integration tests for Teradata migration in a single-threaded mode. Ensure BQMS_MULTITHREADED is set to 'False'. ```shell BQMS_VERBOSE="True" \ BQMS_MULTITHREADED="False" \ BQMS_PROJECT="" \ BQMS_GCS_BUCKET="" \ pytest \ -vv \ --log-cli-level=DEBUG \ --log-cli-format="%(asctime)s: %(levelname)s: %(threadName)s: %(filename)s:%(lineno)s: %(message)s" \ -k "test_teradata_local[100000]" \ --performance \ tests/integration ``` -------------------------------- ### Preprocess KSH to SQL Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md The result of preprocessing the KSH script above, showing the extracted SQL statement. ```sql SELECT 123, 'foo', 456 from bar; ``` -------------------------------- ### Multi-threaded Performance Test Command Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Command to run the Teradata local integration test in a multi-threaded mode for performance evaluation. Ensure BQMS_PROJECT and BQMS_GCS_BUCKET are set. ```shell BQMS_VERBOSE="True" \ BQMS_MULTITHREADED="True" \ BQMS_PROJECT="" \ BQMS_GCS_BUCKET="" \ pytest \ -vv \ --log-cli-level=DEBUG \ --log-cli-format="%(asctime)s: %(levelname)s: %(threadName)s: %(filename)s:%(lineno)s: %(message)s" \ -k "test_teradata_local[10000]" \ --performance \ tests/integration ``` -------------------------------- ### Single-threaded Performance Test Command Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Command to run the Teradata local integration test in a single-threaded mode for performance evaluation. Ensure BQMS_PROJECT and BQMS_GCS_BUCKET are set. ```shell BQMS_VERBOSE="True" \ BQMS_MULTITHREADED="False" \ BQMS_PROJECT="" \ BQMS_GCS_BUCKET="" \ pytest \ -vv \ --log-cli-level=DEBUG \ --log-cli-format="%(asctime)s: %(levelname)s: %(threadName)s: %(filename)s:%(lineno)s: %(message)s" \ -k "test_teradata_local[10000]" \ --performance \ tests/integration ``` -------------------------------- ### Run Docker Container to Generate Terraform Template Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/terraform/README.md Execute the Docker container to generate GCS permissions. Ensure the source path for the volume mount is correctly set to your Terraform output folder. ```bash docker run -it --rm --mount type=bind,source=/terraform/out,target=/app/out tf-template-builder bash ``` -------------------------------- ### Extract Heredoc SQL from KSH Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md This snippet shows how KSH heredoc SQL statements are extracted during preprocessing. Input files ending in .ksh are scanned for SQL within heredoc blocks. ```shell #!/bin/ksh ## A Very simple test. bteq < free -hm total used free shared buff/cache available Mem: 94Gi 10Gi 63Gi 146Mi 20Gi 82Gi Swap: 1.9Gi 32Mi 1.8Gi ``` -------------------------------- ### Python Preprocess Function for nzsql Slash Commands Source: https://github.com/google/dwh-migration-tools/blob/main/client/README.md Custom preprocessing logic using a Python function to comment out Netezza nzsql slash commands. This function is called for each input script before translation. ```python def preprocess(path: Path, text: str) -> str: """Preprocesses input via user-defined code before submitting it to BQMS. Args: path: A bqms_run.paths.Path representing the relative path of the input to be preprocessed. text: A string representing the contents of the input to be preprocessed. Returns: A string representing the preprocesssed input. """ return re.sub(r'^\\', r'--\\', text) ``` -------------------------------- ### Snowflake Metadata Extraction Command Source: https://github.com/google/dwh-migration-tools/wiki/Snowflake-Assessment Use this command template to extract metadata from Snowflake. Ensure all placeholder values are correctly provided. ```bash EXECUTABLE \ --assessment \ --connector snowflake \ --host HOST_NAME \ --user USER_NAME \ --role ROLE_NAME \ --warehouse WAREHOUSE \ --private-key-file PRIVATE_KEY_PATH \ --private-key-password PRIVATE_KEY_PASSWORD ``` -------------------------------- ### Run Docker Container for Testing Terraform Template Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/terraform/README.md Execute the Docker container to test the generated Terraform template. This command mounts your GCS credentials and allows you to run Terraform commands within the container. ```bash docker run -it --rm -v gcloud-cred:/root/.config/gcloud tf-permission-builder bash ``` -------------------------------- ### Snowflake Query Logs and Time Series Data Extraction Command Source: https://github.com/google/dwh-migration-tools/wiki/Snowflake-Assessment Execute this command to extract query logs and time series data from Snowflake. Specify the date range for the query logs. ```bash EXECUTABLE \ --assessment \ --connector snowflake-logs \ --host HOST_NAME \ --user USER_NAME \ --role ROLE_NAME \ --warehouse WAREHOUSE \ --query-log-start STARTING_DATE \ --query-log-end ENDING_DATE \ --private-key-file PRIVATE_KEY_PATH \ --private-key-password PRIVATE_KEY_PASSWORD ``` -------------------------------- ### Login to GCP Account Inside Container Source: https://github.com/google/dwh-migration-tools/blob/main/permissions-migration/terraform/README.md Authenticate your GCP account within the running Docker container to allow Terraform commands to interact with your cloud resources. ```bash gcloud auth application-default login ``` -------------------------------- ### Format Dumper Code Source: https://github.com/google/dwh-migration-tools/blob/main/AGENTS.md Applies code formatting rules specifically to the Dumper application module. ```bash ./gradlew :dumper:app:spotlessApply ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.