CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-superset-ui--generator-superset

Yeoman generator that scaffolds Superset visualization plugins and packages with proper structure and boilerplate code

63

1.21x
Overview
Eval results
Files

task.mdevals/scenario-1/

SQL Query Executor

Build a Python utility that executes SQL queries using Apache Superset's SQL Lab functionality, with support for query history tracking.

Capabilities

Execute SQL queries programmatically

  • Execute a simple SELECT query against a database and return the results as a list of dictionaries @test
  • Execute a query with multiple columns and verify all column names are present in the results @test
  • Handle queries that return empty result sets without errors @test

Track query execution history

  • Record query execution metadata including query text and timestamp @test
  • Retrieve the most recent query from history @test

Implementation

@generates

API

from typing import List, Dict, Any, Optional
from datetime import datetime

class SQLExecutor:
    """
    A utility class for executing SQL queries using Apache Superset's SQL Lab.
    """

    def __init__(self, database_id: int):
        """
        Initialize the SQL executor with a database connection.

        Args:
            database_id: The ID of the Superset database to query against
        """
        pass

    def execute_query(self, sql: str) -> List[Dict[str, Any]]:
        """
        Execute a SQL query and return results.

        Args:
            sql: The SQL query string to execute

        Returns:
            A list of dictionaries, where each dictionary represents a row
            with column names as keys

        Raises:
            ValueError: If the SQL query is empty or invalid
        """
        pass

    def get_query_history(self) -> List[Dict[str, Any]]:
        """
        Retrieve the history of executed queries.

        Returns:
            A list of dictionaries containing query metadata, including:
            - 'sql': The query text
            - 'executed_at': Timestamp of execution
        """
        pass

    def get_latest_query(self) -> Optional[Dict[str, Any]]:
        """
        Get the most recently executed query from history.

        Returns:
            A dictionary with query metadata, or None if no queries have been executed
        """
        pass

Dependencies { .dependencies }

apache-superset { .dependency }

Provides SQL Lab functionality for executing SQL queries programmatically, including query execution, result handling, and query history tracking.

Install with Tessl CLI

npx tessl i tessl/npm-superset-ui--generator-superset

tile.json