Skip to content

Conversation

@amol-patel
Copy link
Collaborator

@amol-patel amol-patel commented Dec 22, 2025

This pull request adds support for specifying a role in the Snowflake command context, ensuring that the role is propagated through configuration, runtime, and documentation. This enhancement allows users to set the Snowflake role directly in their configuration files and ensures it is used during command execution.

Enhancement: Snowflake role support

  • Added a new Role field to the clusterContext struct in snowflake.go to allow specifying a Snowflake role in the configuration.
  • Updated the handler in snowflake.go to pass the Role value from the context to the Snowflake connection configuration.
  • The role field is optional. If not specified, Snowflake will use the default role assigned to the user.

Documentation update

  • Updated the example in plugins/snowflake/README.md to document the new role field in the configuration.

- Added 'Role' field to clusterContext struct in snowflake.go.
- Updated README to include 'role' configuration example for Snowflake plugin.
Copilot AI review requested due to automatic review settings December 22, 2025 05:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for specifying a Snowflake role in the cluster configuration, allowing users to explicitly set which role should be used when connecting to Snowflake. If not specified, Snowflake will use the default role assigned to the user.

Key changes:

  • Added Role field to the Snowflake cluster configuration struct
  • Updated connection configuration to pass the role to the Snowflake driver
  • Documented the new role field in the README example

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/pkg/object/command/snowflake/snowflake.go Added Role field to clusterContext struct and passed it to the Snowflake connection configuration
plugins/snowflake/README.md Added role: MY_ROLE to the cluster configuration example

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sanketjadhavSF
sanketjadhavSF previously approved these changes Dec 22, 2025
Copy link
Contributor

@hladush hladush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix comment and add testing description before merge

- Fixed typo in error message for invalid key type.
- Added 'Role' field to commandContext struct for command-level role configuration.
- Updated New function to parse command context from YAML config.
- Revised README to clarify role configuration and its separation from cluster settings.
@amol-patel
Copy link
Collaborator Author

Testing Summary

Changes Tested

  • Added Snowflake role support in connection configuration
  • Role is configured at the command context level for security (requires PR to change)
  • Backward compatibility maintained when no role is specified

Test Environment

  • Local Docker environment using docker-compose
  • Snowflake connection with JWT/key-pair authentication

Test Cases

# Scenario Configuration Expected Result Actual Result Status
1 Role specified in command context context.role: DATA_ENGINEER_ROLE Uses DATA_ENGINEER_ROLE DATA_ENGINEER_ROLE ✅ Pass
2 No role specified (backward compatibility) No role in command context Uses user's default role HEIMDALL__APP_ROLE ✅ Pass

How to Reproduce

# Build and start
cd heimdall
docker-compose up --build -d

# Test Case 1: With role specified
curl -X POST http://localhost:9090/api/v1/job \
  -H "Content-Type: application/json" \
  -H "X-Heimdall-User: test-user" \
  -d '{
    "name": "test-with-role",
    "command_criteria": ["type:snowflake_copy"],
    "cluster_criteria": ["type:snowflake"],
    "context": {"query": "SELECT CURRENT_ROLE() as current_role"}
  }'

# Test Case 2: Without role (default)
curl -X POST http://localhost:9090/api/v1/job \
  -H "Content-Type: application/json" \
  -H "X-Heimdall-User: test-user" \
  -d '{
    "name": "test-default-role",
    "command_criteria": ["type:snowflake_default"],
    "cluster_criteria": ["type:snowflake"],
    "context": {"query": "SELECT CURRENT_ROLE() as current_role"}
  }'

# Check results
curl http://localhost:9090/api/v1/job/{job_id}/result

Configuration Example

commands:
  - name: snowflake_copy
    plugin: snowflake
    context:
      role: DATA_ENGINEER_ROLE  # Explicit role
    tags:
      - type:snowflake_copy

  - name: snowflake_default_role
    plugin: snowflake
    # No role = uses user's default role (backward compatible)
    tags:
      - type:snowflake_default

Files Changed

  • plugins/snowflake/snowflake.go - Fixed context passthrough to internal handler
  • internal/pkg/object/command/snowflake/snowflake.go - Added Role field to commandContext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants