class_docstr: A Shillelagh adapter for Superset tables.
  
  Shillelagh adapters are responsible for fetching data from a given resource,
  allowing it to be represented as a virtual table in SQLite. This one works
  as a proxy to Superset tables.
class_docstr_tok: ["A","Shillelagh","adapter","for","Superset","tables",".","Shillelagh","adapters","are","responsible","for","fetching","data","from","a","given","resource",",","allowing","it","to","be","represented","as","a","virtual","table","in","SQLite",".","This","one","works","as","a","proxy","to","Superset","tables","."]
docstr: Build SQLAlchemy query object.
docstr_tok: ["Build","SQLAlchemy","query","object","."]
code: def _build_sql(
      self,
      bounds: dict[str, Filter],
      order: list[tuple[str, RequestedOrder]],
      limit: int | None = None,
      offset: int | None = None,
  ) -> Select:
      """
      Build SQLAlchemy query object.
      """
      query = select([self._table])
  
      for column_name, filter_ in bounds.items():
          column = self._table.c[column_name]
          if isinstance(filter_, Equal):
              query = query.where(column == filter_.value)
          elif isinstance(filter_, Range):
              if filter_.start is not None:
                  op = (
                      operator.ge
                      if filter_.include_start
                      else operator.gt
                  )
                  query = query.where(op(column, filter_.start))
              if filter_.end is not None:
                  op = (
                      operator.le
                      if filter_.include_end
                      else operator.lt
                  )
                  query = query.where(op(column, filter_.end))
          else:
              raise ProgrammingError(f"Invalid filter: {filter_}")
  
      for column_name, requested_order in order:
          column = self._table.c[column_name]
          if requested_order == Order.DESCENDING:
              column = column.desc()
          query = query.order_by(column)
  
      if limit is not None:
          query = query.limit(limit)
      if offset is not None:
          query = query.offset(offset)
  
      return query
  
imports: from __future__ import annotations
  import datetime
  import decimal
  import operator
  import urllib.parse
  from collections.abc import Iterator
  from functools import partial, wraps
  from typing import Any, Callable, cast, TypeVar
  from flask import current_app
  from shillelagh.adapters.base import Adapter
  from shillelagh.backends.apsw.dialects.base import APSWDialect
  from shillelagh.exceptions import ProgrammingError
  from shillelagh.fields import Boolean, Date, DateTime, Field, Float, Integer, Order, String, Time
  from shillelagh.filters import Equal, Filter, Range
  from shillelagh.typing import RequestedOrder, Row
  from sqlalchemy import func, MetaData, Table
  from sqlalchemy.engine.url import URL
  from sqlalchemy.exc import NoSuchTableError
  from sqlalchemy.sql import Select, select
  from superset import db, feature_flag_manager, security_manager, sql_parse
label_desc: Use image node_id 7 for calling the SupersetShillelaghAdapter obj's underlying member method code with example usage: obj._build_sql(bounds, order, limit, offset) and returns: query