Skip to content

Commit f615cc7

Browse files
mikebridgeMike Bridgesadpandajoe
authored
docs(semantic-layer): define SDK surface and release policy (#45906)
Co-authored-by: Mike Bridge <michael.bridge@ext.preset.io> Co-authored-by: Joe Li <joe@preset.io>
1 parent 33d6c41 commit f615cc7

9 files changed

Lines changed: 222 additions & 41 deletions

File tree

‎UPDATING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ reattached to a reachable container by layout repair.
587587
enforcing completeness should raise the public
588588
`superset_core.semantic_layers.errors.SemanticResultCompletenessError` when
589589
results are incomplete or cannot be verified (an additive `apache-superset-core`
590-
API, available from 0.2.0; import it from `superset_core.semantic_layers.errors`,
590+
API added after 0.2.0; import it from `superset_core.semantic_layers.errors`,
591591
not the same-named host class in `superset.exceptions`); the host converts it to
592592
its client error, and these
593593
failures do not publish a successful async result cache key. A provider raising

‎docs/developer_docs/extensions/dependencies.md‎

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,45 @@ This guide explains how to manage dependencies in your Superset extensions, incl
3030

3131
Extensions run in the same context as Superset during runtime. This means extension developers can technically import any module from the Superset codebase, not just the public APIs. Understanding the distinction between public and internal code is critical for building maintainable extensions.
3232

33-
### Public APIs (Stable)
33+
### Documented APIs
3434

35-
The core packages follow [semantic versioning](https://semver.org/) and provide stable, documented APIs:
35+
The core packages use [semantic versioning](https://semver.org/). A package name alone does not make every import in it a supported API. Use the documented imports for your audience:
3636

37-
| Package | Language | Description |
38-
| ----------------------- | --------------------- | -------------------------------------------------- |
39-
| `@apache-superset/core` | JavaScript/TypeScript | Frontend APIs, UI components, hooks, and utilities |
40-
| `apache-superset-core` | Python | Backend APIs, models, DAOs, and utilities |
37+
| Package | Audience | Supported use |
38+
| ----------------------- | --------------------- | ------------------------------------------------- |
39+
| `@apache-superset/core` | Frontend extensions | Documented frontend APIs, components, and hooks |
40+
| `apache-superset-core` | Semantic providers | Provider contracts listed below |
41+
| `apache-superset-core` | Backend host extensions | Documented host-bound APIs, including models and DAOs |
4142

42-
**Benefits of using core packages:**
43+
The `apache-superset-core` provider contract is imported from these explicit modules. The `superset_core.semantic_layers` package root also re-exports `SemanticCredentialReadiness`, `SemanticBackendError`, and the transport types; prefer the module paths below:
4344

44-
- **Semantic versioning**: Breaking changes are communicated through version numbers
45-
- **Documentation**: APIs are documented with clear usage examples
46-
- **Stability commitment**: We strive to maintain backward compatibility
47-
- **Type safety**: Full TypeScript and Python type definitions
45+
| Module | Supported provider symbols |
46+
| ------ | -------------------------- |
47+
| `semantic_layers.decorators` | `semantic_layer` |
48+
| `semantic_layers.layer` | `SemanticLayer`, `SemanticCacheResponsibility`, `SemanticCacheScope`, `SemanticCacheCapabilities`, `SemanticCacheExecutionContext`, `SemanticCacheIdentityMaterial` |
49+
| `semantic_layers.view` | `SemanticView`, `SemanticViewFeature` |
50+
| `semantic_layers.context` | `ExecutionOrigin`, `ExecutionMethod`, `SemanticExecutionContext`, `SemanticCredentials` |
51+
| `semantic_layers.types` | `Grain`, `Grains`, `Dimension`, `Metric`, `AdhocExpression`, `AggregationType`, `Operator`, `PredicateType`, `FilterValues`, `Filter`, `OrFilter`, `FilterExpression`, `OrderDirection`, `OrderTuple`, `GroupLimit`, `SemanticRequest`, `SemanticResult`, `SemanticQuery` |
52+
| `semantic_layers.config` | `build_configuration_schema`, `check_dependencies`, `SemanticCredentialReadiness` |
53+
| `semantic_layers.errors` | `SemanticQueryErrorCode`, `SemanticQueryRejectedError`, `SemanticResultCompletenessError`, `SemanticResultCompletenessReason`, `SemanticBackendError` |
54+
| `semantic_layers.transport` | `ProviderTransport`, `ProviderResponse`, `ProviderRequestError`, `ProviderRequestFailure`, `RequestBudget` |
55+
| `semantic_layers.testing` | `SemanticProviderConformance` and the documented pytest fixtures |
56+
57+
Prefix each module with `superset_core.` in Python imports. The list covers provider-facing symbols; a type being supported does not imply every feature or enum value is supported by every host version. Check the [semantic-layer provider guide](./extension-points/semantic-layers.md) for usage and the [provider testing guide](../semantic-layer-provider-testing.md) for the test kit.
58+
59+
`SemanticCredentials` is a reserved channel for future non-connection credentials; providers must not treat it as cache identity. The host supplies `ExecutionOrigin.REQUEST` during a request and `ExecutionOrigin.BACKGROUND` outside one. For authenticated users, async chart queries and MCP calls outside a Flask request context use `BACKGROUND` while retaining the user's principal. `MCP`, `ASYNC_QUERY`, and `EXPORT` are defined but explicit binders are not yet installed; `CONFIG` is reserved. Providers should handle the origins the host supplies and reject unknown ones.
60+
61+
The two context types are both supported and are not interchangeable. `SemanticLayer.from_configuration` receives `SemanticExecutionContext`, the binding identity; `SemanticLayer.get_semantic_cache_context_identity` receives `SemanticCacheExecutionContext`, the containment-cache identity. Rely on each only in the hook that receives it. Merging them would be a breaking change and would be announced in the package changelog.
62+
63+
Host extensions are a separate audience. `superset_core.semantic_layers.models.SemanticLayerModel` and `SemanticViewModel`, and `superset_core.semantic_layers.daos.AbstractSemanticLayerDAO` and `AbstractSemanticViewDAO`, are host-bound persistence interfaces. They depend on the Superset host and its Flask-AppBuilder/SQLAlchemy environment; a standalone semantic provider does not need to import them. Other host-extension APIs are supported where their extension-point documentation names the import path.
4864

4965
### Internal Code (Unstable)
5066

51-
Any code that is not exported through the core packages is considered internal. This includes:
67+
Code outside the documented API for the relevant audience is internal. This includes:
5268

5369
- Direct imports from `superset-frontend/src/` modules
5470
- Direct imports from `superset/` Python modules (outside of `superset_core`)
55-
- Undocumented functions, classes, or utilities
71+
- Undocumented functions, classes, or utilities inside a core package
5672

5773
:::warning Use at Your Own Risk
5874
Internal code can change at any time without notice. If you depend on internal modules, your extension may break when Superset is upgraded. There is no guarantee of backward compatibility for internal code.
@@ -79,7 +95,11 @@ from superset.views.core import SomeInternalClass
7995

8096
## API Evolution
8197

82-
The core packages are still evolving. While we follow semantic versioning, the APIs may change as we add new extension points and refine existing ones based on community feedback.
98+
The core packages are still evolving. For `apache-superset-core`, `0.x` minor releases may change documented contracts; patch releases should preserve them except for necessary correctness or security fixes. At `1.0` and later, incompatible documented API changes require a major release, compatible additions a minor release, and fixes a patch release. The package version is the contract version; there is no separate semantic-layer contract number.
99+
100+
An unreleased changelog entry describes the next package release without changing the installed version. Version metadata for `apache-superset-core`, `apache-superset-extensions-cli`, and `@apache-superset/core` is bumped together as part of the release process.
101+
102+
Before removing or changing a documented Python API, we normally mark it deprecated in documentation and the [package changelog](https://github.com/apache/superset/blob/master/superset-core/CHANGELOG.md), provide a migration path, and emit `DeprecationWarning` where a runtime warning is practical. Keep the deprecated path for at least one minor release when feasible. A security or correctness fix may require a shorter transition; its release note must describe the impact. The changelog records additions, deprecations, removals, and behavior changes starting with the next package release. An unreleased entry is not an installable version.
83103

84104
**What this means for extension developers:**
85105

@@ -135,14 +155,14 @@ When Superset upgrades its core dependencies (e.g., a new major version of Ant D
135155

136156
## API Versioning and Changelog
137157

138-
Once the extensions API reaches **v1**, we will maintain a dedicated `CHANGELOG.md` file to track all changes to the public APIs. This will include:
158+
The Python package has its own [changelog](https://github.com/apache/superset/blob/master/superset-core/CHANGELOG.md) before v1. Each published version records changes to documented APIs, including:
139159

140160
- New APIs and features
141161
- Deprecation notices
142162
- Breaking changes with migration guides
143163
- Bug fixes affecting API behavior
144164

145-
Until then, monitor the Superset release notes and test your extensions with each new release.
165+
For frontend APIs, monitor the Superset release notes. For either package, test your extension against each target Superset release before deploying it.
146166

147167
## Best Practices
148168

‎docs/developer_docs/extensions/extension-points/semantic-layers.md‎

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ class MySemanticLayer(SemanticLayer[MyConfig, MySemanticView]):
100100

101101
The decorator registers the class in the semantic layers registry, making it available in the UI for users to create connections. The `configuration_class` should be a Pydantic model that defines the fields needed to connect (credentials, project, database, etc.). Superset uses the model's JSON schema to render the configuration form dynamically.
102102

103+
## API permissions and runtime availability
104+
105+
The semantic APIs check endpoint permissions before evaluating `SEMANTIC_LAYERS` through the feature flag manager. See [runtime semantic-layer availability](/admin-docs/configuration/feature-flags#runtime-semantic-layer-availability) for permission, Public-role, `OPTIONS`, and `IS_FEATURE_ENABLED_FUNC` behavior.
106+
103107
## Provider obligations and isolated tests
104108

105109
Store the parsed configuration instance on the writable `self.configuration`
@@ -249,8 +253,11 @@ includes an effective-role derivation marker, so context-scoped containment keys
249253
change even when the role list is empty. This
250254
prevents reuse of direct-only identities after group grants are revoked and causes
251255
a cold context-scoped containment cache; connection-scoped keys are unchanged.
252-
The SDK `identity_digest` is unchanged. The two SDK context types coexist and
253-
will be unified before any `superset-core` release.
256+
The SDK `identity_digest` is unchanged. The two SDK context types coexist:
257+
`from_configuration` receives `SemanticExecutionContext`, and
258+
`get_semantic_cache_context_identity` receives `SemanticCacheExecutionContext`.
259+
A future merge of the two would be a breaking change announced in the package
260+
changelog.
254261
`get_configuration_schema` and `get_runtime_schema` remain class methods outside
255262
this instance-binding contract.
256263

@@ -342,16 +349,17 @@ from superset_core.semantic_layers.view import SemanticView, SemanticViewFeature
342349
class MySemanticView(SemanticView):
343350
features = frozenset(
344351
{
345-
# The backend accepts simple/custom-SQL column expressions built
346-
# in Explore. Omit this member if it only accepts the view's own
347-
# dimensions.
348-
SemanticViewFeature.ADHOC_COLUMN_EXPRESSIONS,
349352
SemanticViewFeature.GROUP_LIMIT,
350353
}
351354
)
352355
```
353356

354-
The declared members are serialized to the Explore datasource payload as
357+
Only recognized, non-reserved SDK enum members grant capabilities. Raw strings,
358+
unknown values and malformed declarations are ignored rather than normalized.
359+
`ADHOC_COLUMN_EXPRESSIONS` remains importable but is reserved: the SDK has no
360+
supported adhoc column query shape, so declaring it grants nothing.
361+
362+
The supported members are serialized to the Explore datasource payload as
355363
`semantic_view_features` (their stable string values). The provider's registry
356364
key is deliberately **not** sent: because the `@semantic_layer` decorator
357365
prefixes extension IDs, no stable bare key exists to publish, and behavior
@@ -366,11 +374,12 @@ components consume capabilities and must not read `semantic_view_features`, a
366374
registry key, or a user-editable display name. New provider-specific behavior
367375
belongs in a capability, not in a comparison inside a picker component.
368376

369-
A view that does not declare `ADHOC_COLUMN_EXPRESSIONS` gets a Saved-only
370-
column picker: its dimensions are listed as Saved options and the Simple and
371-
Custom SQL modes are visible but disabled, so users cannot build an expression
372-
the backend would reject. Unknown feature strings and payloads with no
373-
`semantic_view_features` field are ignored, preserving existing behavior.
377+
All semantic views get Saved-only column pickers: their dimensions are listed
378+
as Saved options, with Simple and Custom SQL disabled. This also applies to old
379+
payloads missing `semantic_view_features` and stale payloads containing the
380+
reserved member. Existing unsupported expressions are not converted or saved
381+
automatically; choose a saved dimension instead. Ordinary SQL datasets retain
382+
their expression modes.
374383

375384
## Server pagination
376385

@@ -550,19 +559,38 @@ rollback because disabled processes do not read or write it.
550559

551560
## Choosing a default time dimension
552561

553-
A semantic view may set `preferred_temporal_dimension` to the name of a temporal
554-
dimension it exposes. Superset publishes that name as `main_dttm_col`, which
555-
Explore uses for the default time filter on new charts. The declaration is
556-
ignored if the name is absent or does not identify a temporal dimension.
562+
A semantic view may set `preferred_temporal_dimension: str | None = None` to an
563+
exact exposed temporal `Dimension.name`, including its qualification and case.
564+
Use the selection name, not a provider-private ID or display label. Superset
565+
publishes the validated name as `main_dttm_col`; `granularity_sqla` continues to
566+
list the available temporal choices. Explore uses the default when initializing
567+
a missing time filter. Unknown, non-temporal, or malformed declarations are
568+
ignored with an operator warning. `None` preserves fallback without a warning.
557569

558570
```python
559571
class MySemanticView(SemanticView):
560-
preferred_temporal_dimension = "metric_time"
572+
preferred_temporal_dimension: str | None = "metric_time"
561573
```
562574

575+
The provider owns the selection policy; the host does not infer business meaning
576+
from dimension names or grain suffixes. Grain variants sharing one name are not
577+
competing defaults. The conformance kit checks that a non-None declaration names
578+
an exposed Arrow date, timestamp, or time dimension and remains unchanged when
579+
the same catalog is reloaded. For names with multiple variants, the selected
580+
variant must be temporal: raw first, then the finest known grain, then lexical
581+
grain representation, as documented on `Grains`. A temporal sibling does not
582+
make a non-temporal selected variant eligible. It uses the existing `semantic_view` and
583+
`semantic_reloaded_view` fixtures; providers need no new method or fixture.
584+
563585
Providers that omit the declaration retain Explore's existing first temporal
564-
column fallback. This preference does not change the time dimension already
565-
selected on a saved chart.
586+
column fallback. Explicit saved time bindings remain authoritative. However,
587+
saved charts with an omitted binding may adopt a provider's new default and
588+
change results **without saving the chart**. This includes a query with an
589+
explicit temporal filter but omitted granularity: the filter stays explicit,
590+
while an independently supplied time range can add bounds on the preferred date.
591+
There is no chart migration or compatibility shim. A deliberately different axis
592+
or an existing axis/filter mismatch still requires the author's decision; the
593+
default does not silently repair it.
566594

567595
Dashboard chart pagination and empty filter resets do not contribute semantic
568596
member selections to other charts. Cross-filters that select members still carry
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: Version history footer
3+
---
4+
5+
<!--
6+
Licensed to the Apache Software Foundation (ASF) under one
7+
or more contributor license agreements. See the NOTICE file
8+
distributed with this work for additional information
9+
regarding copyright ownership. The ASF licenses this file
10+
to you under the Apache License, Version 2.0 (the
11+
"License"); you may not use this file except in compliance
12+
with the License. You may obtain a copy of the License at
13+
14+
http://www.apache.org/licenses/LICENSE-2.0
15+
16+
Unless required by applicable law or agreed to in writing,
17+
software distributed under the License is distributed on an
18+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19+
KIND, either express or implied. See the License for the
20+
specific language governing permissions and limitations
21+
under the License.
22+
-->
23+
24+
This extension point is a UI override, not a `.supx` contribution.
25+
26+
The optional `versionHistory.panel.footer` UI override adds content at the bottom
27+
of the chart and dashboard version history panel, after its history, empty state,
28+
pagination, and truncation notice. Without a registered component the panel is
29+
unchanged. The component receives `entityType: 'chart' | 'dashboard'` and may
30+
return `null` when it has nothing to display. The slot's padding is still
31+
rendered whenever a component is registered, even if it returns `null`. The
32+
footer also centers its content with `text-align: center`.
33+
34+
Register the component through `getExtensionsRegistry()` from `@superset-ui/core`
35+
in the deployment's own frontend build, for example in
36+
`src/setup/setupCodeOverrides.ts`, before the panel renders. This is a build-time
37+
UI override, not a registration API for separately loaded `.supx` extensions. The
38+
registry is module-local, and `@superset-ui/core` is not shared through module
39+
federation; importing it in a `.supx` extension does not reach the host registry.
40+
41+
The slot does not change access to history or retention settings. Deployments
42+
are responsible for deciding when their footer content is suitable. It is
43+
available only in builds containing this slot and where the version history
44+
panel renders: `VERSION_HISTORY` must be enabled, and embedded dashboards do
45+
not show it.

‎docs/developer_docs/semantic-result-completeness.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ under the License.
2222
Providers reject incomplete or unverifiable results from `get_table`,
2323
`get_values` and `get_row_count` by raising the public
2424
`superset_core.semantic_layers.errors.SemanticResultCompletenessError("incomplete")`
25-
or `SemanticResultCompletenessError("unverified")`, available from
26-
`apache-superset-core` 0.2.0. It is a plain exception that carries only the
25+
or `SemanticResultCompletenessError("unverified")`, added to
26+
`apache-superset-core` after 0.2.0 (see the package changelog's Unreleased
27+
entry). It is a plain exception that carries only the
2728
closed reason code, so providers need no `superset` import. Import it from
2829
`superset_core.semantic_layers.errors`, not from `superset.exceptions`.
2930

‎docs/developer_docs/sidebars.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module.exports = {
5050
'extensions/extension-points/editors',
5151
'extensions/extension-points/chat',
5252
'extensions/extension-points/semantic-layers',
53+
'extensions/extension-points/version-history',
5354
],
5455
},
5556
'extensions/development',

‎docs/sidebarTutorials.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const sidebars = {
8686
'extensions/extension-points/editors',
8787
'extensions/extension-points/chat',
8888
'extensions/extension-points/semantic-layers',
89+
'extensions/extension-points/version-history',
8990
],
9091
},
9192
'extensions/semantic-provider-transport',

0 commit comments

Comments
 (0)