Skip to content

Extend URI loading functionality to other file-loading commands #471

@apstndb

Description

@apstndb

Feature Request

Extend URI loading functionality to other commands that load files, such as the \. meta command.

Background

In #470, we implemented URI-based loading functionality that supports multiple schemes:

  • gs:// - Google Cloud Storage
  • file:// - Local file system
  • http:// / https:// - HTTP(S) downloads

This functionality is currently only used for --sample-database flag, but could be valuable for other file-loading operations.

Proposed Enhancement

1. Extend \. Meta Command

The \. command (LOAD) currently only supports local file paths. It could benefit from URI support:

-- Load from Google Cloud Storage
\. gs://my-bucket/scripts/setup.sql

-- Load from HTTP
\. https://raw.githubusercontent.com/example/repo/main/schema.sql

-- Explicit local file
\. file:///home/user/scripts/init.sql

2. Other Potential Applications

  • --file / -f flag for batch execution
  • --proto-descriptor-file for protobuf descriptors
  • Any future features that need to load external resources

Implementation Notes

The core URI loading functions (loadFromURI, loadFromGCS, loadFromHTTP) are already implemented in sample_databases.go. These could be:

  1. Moved to a separate package/file (e.g., uri_loader.go)
  2. Made more generic and reusable
  3. Extended with additional features like:
    • Progress indicators for large files
    • Caching support
    • Authentication for private resources

Benefits

  • Consistency: Same URI syntax across all file-loading operations
  • Flexibility: Users can load scripts from various sources without manual downloading
  • Cloud-native: Direct integration with GCS for Cloud Spanner users
  • Convenience: Load scripts directly from GitHub, documentation sites, etc.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions