Connect to ADLS Using Spark

概述

本指南提供了在Windows操作系统上设置和使用增量共享集成包以将数据无缝集成到使用 Analytics 的工作流中的详细说明。该包支持多个执行选项,让你可以选择所需的配置和集成方法。

先决条件

在继续之前,确保你已满足以下条件:

  • 分析 2.0 SPU

  • 增量共享配置文件:获取包含的* .share文件增量共享凭证。为方便起见,将其复制到包目录中。

  • Android 环境:在你的系统上安装 Android 3 和pip 。

Steps

  • Prepare the Package

  • Install Dependencies

  • Generate Configuration

  • Configure Cron Jobs and Immediate Execution

  • Execution and Maintenance

Prepare the Package

  1. Create a new file named config.share with your Delta Share credentials in JSON format.
    {
    "shareCredentialsVersion": 1,
    "bearerToken": "xxxxxxxxxxxxx",
    "endpoint": "https://nvirginia.cloud.databricks.c...astores/xxxxxx"
    }

  2. Get required fields.
    Note: These details can be obtained from the Analytics web application.

    • ShareCredentialsVersion: Version number (currently 1).

    • BearerToken: Your Delta Share access token.

    • Endpoint: Your Delta Share endpoint URL.

  3. Download and extract the package.
    Note: You can download the zipped package from the company level Analytics tool (via Analytics > Getting Started > Connection Options > Azure).

  4. Unzip the package to a directory of your choice.

  5. Copy the *.share Delta Sharing profile file into the package directory for easy access.
    Analytics Sql Windows2

Install Dependencies

  1. Open a terminal in the package directory.

  2. Run the pip install -r requirements.txt command to install the dependencies.
    Install Dependencies

Generate Configuration

  1. Generate the config.yaml file by running python user_exp.py.
    This script helps to generate the config.yaml file which contains the necessary credentials and settings.

  2. When configuring the data source, you'll be asked to provide:

    • List of tables (comma-separated).

    • Leave blank to sync all tables. Example: table1, table2, table3.

    • Path to your config.share file.

  3. For the first time, you will provide your credentials like Delta Share source configuration location, tables, database, host, etc.
    Note: Afterwards, you may reuse or update the config manually or by running python user_exp.py again.

Configure Cron Jobs and Immediate Execution (Optional)

  1. Decide whether to set up a cron job for automatic execution.

  2. Provide a cron schedule:

    • Format: * * * * * (minute, hour, day-of-month, month, day-of-week).

    • Example for daily execution at 2 AM: 0 2 * * *

    • To check scheduling logs, the file procore_scheduling.log will be created as soon as scheduling is set up.

You can also check scheduling by running the terminal command:

For Linux and MacOs:

To edit/delete - edit scheduling cron by using:
bash
EDITOR=nano crontab -e

  • After running the command above, you should see something similar to:

  • 2 * * * * /Users/your_user/snowflake/venv/bin/python /Users/your_user/snowflake/sql_server_python/connection_config.py 2>&1 | while read line; do echo "$(date) - $line"; done >> /Users/your_user/snowflake/sql_server_python/procore_scheduling.log # procore-data-import

  • You can also adjust the schedule cron or delete the whole line to stop it from running by schedule.

For Windows:

  • Check the schedule task is created:
    powershell
    schtasks /query /tn "ProcoreDeltaShareScheduling" /fo LIST /v

  • To edit/delete - scheduling task:
    Open the Task Scheduler:

    • Press Win + R, type taskschd.msc, and press Enter.

    • Navigate to the scheduled tasks.

    • In the left pane, expand the Task Scheduler Library.

    • Look for the folder where your task is saved (e.g., Task Scheduler Library or a custom folder).

  • Find your task:

    • Look for the task name ProcoreDeltaShareScheduling.

    • Click on it to view its details in the bottom pane.

  • Verify its schedule:

    • Check the Triggers tab to see when the task is set to run.

    • Check the History tab to confirm recent runs.

  • To delete a task:

    • Delete the task from the GUI.

Immediate Execution question:

  • Option to run the script for copying data immediately after configuration.

  • After generating the config.yaml, the CLI is ready to be run anytime independently, by running the script for copying data, depending on your package.

  • Examples:

    • python delta_share_to_azure_panda.py

    • python delta_share_to_sql_spark.py

    • python delta_share_to_azure_dfs_spark.py

Execution and Maintenance

Common Issues and Solutions

  1. Cron Job Setup:

    • Ensure system permissions are correctly configured.

    • Check system logs if the job fails to run.

    • Verify the script delta_share_to_azure_panda.py has execute permissions.

  2. Configuration File:

    • Ensure the file config.yaml is in the same directory as the script.

    • Back up the file before making changes.

Support

For additional help:

  1. Review script logs for detailed error messages.

  2. Double-check the config.yaml file for misconfigurations.

  3. Contact your system administrator for permission-related issues.

  4. Reach out to Procore support for issues related to Delta Share access.

  5. Review log for failed tables: failed_tables.log.

Notes

  1. Always back up your configuration files before making changes.

  2. Test new configurations in a non-production environment to prevent disruptions.