Skip to main content

Core Python package for building Apache Superset backend extensions and integrations

Project description

apache-superset-core

PyPI version License Python 3.10+

The official core package for building Apache Superset backend extensions and integrations. This package provides essential building blocks including base classes, API utilities, type definitions, and decorators for both the host application and extensions.

📦 Installation

pip install apache-superset-core

🏗️ Architecture

The package is organized into logical modules, each providing specific functionality:

  • api - REST API base classes, models access, query utilities, and registration
  • api.models - Access to Superset's database models (datasets, databases, etc.)
  • api.query - Database query utilities and SQL dialect handling
  • api.rest_api - Extension API registration and management
  • api.types.rest_api - REST API base classes and type definitions

🚀 Quick Start

Basic Extension Structure

from flask import request, Response
from flask_appbuilder.api import expose, permission_name, protect, safe
from superset_core.api import models, query, rest_api
from superset_core.api.rest_api import RestApi

class DatasetReferencesAPI(RestApi):
    """Example extension API demonstrating core functionality."""

    resource_name = "dataset_references"
    openapi_spec_tag = "Dataset references"
    class_permission_name = "dataset_references"

    @expose("/metadata", methods=("POST",))
    @protect()
    @safe
    @permission_name("read")
    def metadata(self) -> Response:
        """Get dataset metadata for tables referenced in SQL."""
        sql: str = request.json.get("sql")
        database_id: int = request.json.get("databaseId")

        # Access Superset's models using core APIs
        databases = models.get_databases(id=database_id)
        if not databases:
            return self.response_404()

        database = databases[0]
        dialect = query.get_sqlglot_dialect(database)

        # Access datasets to get owner information
        datasets = models.get_datasets()
        owners_map = {
            dataset.table_name: [
                f"{owner.first_name} {owner.last_name}"
                for owner in dataset.owners
            ]
            for dataset in datasets
        }

        # Process SQL and return dataset metadata
        return self.response(200, result=owners_map)

# Register the extension API
rest_api.add_extension_api(DatasetReferencesAPI)

🤝 Contributing

We welcome contributions! Please see the Contributing Guide for details.

📄 License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

🔗 Links


Note: This package is currently in release candidate status. APIs may change before the 1.0.0 release. Please check the changelog for breaking changes between versions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apache_superset_core-0.0.1rc3.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apache_superset_core-0.0.1rc3-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file apache_superset_core-0.0.1rc3.tar.gz.

File metadata

  • Download URL: apache_superset_core-0.0.1rc3.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for apache_superset_core-0.0.1rc3.tar.gz
Algorithm Hash digest
SHA256 61265fa7bf3f9a3ee97c40e87f3a170a15b1545a82749157459ba76dd40dddc1
MD5 ee0bc0faa3a10d6979ad9f9aa5a5b25c
BLAKE2b-256 8f060ca7fb3418f0b2b085f1566edd68f60907f972bbc711c04b4edbe75878c2

See more details on using hashes here.

File details

Details for the file apache_superset_core-0.0.1rc3-py3-none-any.whl.

File metadata

File hashes

Hashes for apache_superset_core-0.0.1rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 82748aad80fbcf18c71098cf1b79d54cd61e0ab618afc05e4bdefeddde4895d8
MD5 90dd95c0de30c4881c365c7c8031847e
BLAKE2b-256 87770b5d225d748d63a789d768f83b7dbb0afb75f501c6fb0a60288208a5a114

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page