ProtectedapplyResolve the effective ordering: a caller-supplied ExternalViewParams.orderBy always wins (it was already screened). Otherwise, when the router supplied ExternalViewParams.defaultOrderByColumns (the entity's primary key, for deterministic offset paging), materialize them into an ORDER BY with each identifier QUOTED per this dialect — a bare mixed-case / reserved-word PK column would fail to resolve on a case-sensitive dialect. These names come from trusted MJ metadata, so they are not screened.
ProtectedassertSecure-transport gate for SQL-style drivers. Refuses to connect to a NON-LOCAL host over an
unencrypted connection unless the caller explicitly opted in via allowInsecureTransport.
Only explicit loopback literals (localhost / *.localhost / 127.0.0.0/8 / ::1) are treated as
local. It fails closed: an empty or unparseable host is NOT assumed local — that would be a
plaintext-leak hole (an unset host can still resolve to a remote default), so it is refused
unless TLS or the explicit opt-out is set. Detection is name-based (no DNS resolution), which is
a deliberate trade-off: a name that resolves to loopback but isn't a recognized literal is
refused rather than silently allowed. Drivers whose transport is always encrypted (e.g. Snowflake
HTTPS) don't call this.
ProtectedbuildBuild the COUNT(*) SQL for a paginated view — honoring BOTH the caller's filter AND the structured
incrementalSince bound via effectiveWhere, so totalRowCount is consistent with the rows the
matching SELECT returns. Centralized here (rather than each driver hand-rolling WHERE ${params.filter})
so a driver can't forget the incremental bound. The cnt alias reads back per-dialect case (Oracle /
Snowflake uppercase it to CNT).
ProtectedbuildRender the optional structured incremental lower-bound (ExternalViewParams.incrementalSince)
into a dialect WHERE fragment — <quotedField> >= <literal> — using THIS driver's own identifier
quoting, so an incremental-sync caller never hand-writes dialect SQL. Inclusive (>=). Returns
undefined when no incremental bound was supplied.
ProtectedbuildBuild a quoted, parameter-bound WHERE clause for a (possibly composite) primary key. Each key
identifier is quoted via quoteIdent (so mixed-case / reserved-word PK columns work on
case-sensitive dialects), and each value is returned separately for binding — never interpolated.
placeholder(i) supplies the dialect's bind token for the i-th value ($1 / ? / :1 / @pk0).
Returns the clause and the values in bind order.
ProtectedbuildBuild a parameter-free SELECT. The projection + filter are dialect-agnostic; ordering/paging is
delegated to orderAndPageClause (and an optional selectTopClause). The filter
and orderBy are dialect fragments — the same contract as MJ RunView's ExtraFilter/OrderBy —
and are re-screened HERE at the driver boundary (screenReadOnlyClause) before
interpolation: defense in depth, NOT relying on an upstream caller having screened them. A
structured ExternalViewParams.incrementalSince is ANDed in via effectiveWhere.
Drop + close all cached clients (graceful shutdown).
Public entry point to close (and evict) the cached connection/pool for a data source — used by ExternalDataSourceRouter.ClearCache so evicting a driver actually releases its live remote connections rather than orphaning the pool. Thin wrapper over the protected invalidateConnection; safe to call when nothing is cached for the id.
ProtectedeffectiveThe effective WHERE body: the caller's screened ExternalViewParams.filter combined (ANDed) with the driver-rendered incremental predicate. Either, both, or neither may be present. The caller's filter is screened by buildSelectSql; the incremental predicate is driver-built from a quoted identifier + escaped literal, so it needs no screening.
ProtectederrorRender an arbitrary thrown value as a human-readable message string. Shared by all drivers.
ProtectedformatFormat the incremental bound value as a dialect SQL literal. Default: a plain single-quoted string —
SQL Server / PostgreSQL / Snowflake implicitly parse an ISO-8601 timestamp string, so no wrapping is
needed. Dialects whose default parser rejects the ISO T/Z form override this (e.g. the Oracle
driver wraps an ISO timestamp in TO_TIMESTAMP with a matching format mask).
ProtectedgetOpen or reuse a connection/pool for the given data source. Drivers should
cache pools per ExternalDataSource.ID and lazily instantiate on first use.
OptionalcontextUser: UserInfoProtectedgroupGroup flat FK-column rows (normalized to ExternalFkRow) into one relationship per
constraint, keyed by referencing table. Composite-key aware: rows sharing a constraint_name
accumulate their column pairings into a single relationship.
Introspect the remote schema to assist Entity/EntityField generation.
schemaName narrows to a single schema/namespace when supplied.
OptionalcontextUser: UserInfoProtectedinvalidateEvict (and close) the cached connection/pool for a data source so the next operation re-resolves its credential and reconnects. Called by withConnectionRetry on an auth failure. Implementations must be safe to call when nothing is cached for the id.
expectedIdentity (when provided) is the exact cached handle the caller observed failing —
from peekConnection. Implementations MUST only evict if the currently-cached handle is
still that same identity; otherwise a concurrent request already replaced the pool with a fresh,
healthy one and evicting it would cause needless reconnect churn (the H1 identity race). When
expectedIdentity is undefined (explicit cache-clear, or a cold failure), evict unconditionally.
OptionalexpectedIdentity: unknownProtectedisDatabricks auth failures carry phrases/status the base isAuthError (PG/MySQL/SQL Server/Oracle) doesn't recognize. Without this override withConnectionRetry never self-heals a rotated PAT or an expired OAuth token. Match ONLY genuine AUTHENTICATION signals — HTTP 401 and the stable Databricks bad-credential phrases. Deliberately NOT 403 / PERMISSION_DENIED: those are AUTHORIZATION failures (valid credential, insufficient privilege) that a reconnect can't fix — retrying them just wastes a round-trip and needlessly evicts the shared client for other users. This mirrors the base's documented choice to drop the false-positive-prone 'password'/'permission denied' substrings. ('unauthorized' is likewise left to the base, which already matches the 'authoriz' substring.)
ProtectedisTrue when a host refers to the local machine (loopback) — the only case where a plaintext
connection is accepted by assertSecureTransport. Normalizes case and strips IPv6 brackets
([::1] → ::1). Shared so multi-address / multi-host connection strings (Oracle TNS descriptors,
MongoDB replica-set seed lists) can classify EACH host consistently with the single-host gate.
Load a single remote record by its primary key. Returns null when not found. Accepts the full (possibly composite) primary key as an ordered list; each driver quotes the key identifiers for its dialect and binds the values (never string-interpolates them).
OptionalcontextUser: UserInfoProtectedmapMap a dialect object-type token to MJ's external object type. Case-insensitive VIEW → view.
ProtectednormalizeNeutralize :name named-parameter markers to a literal 1 for STRUCTURE analysis ONLY (the original
SQL + named binds still execute). The ANSI/PostgreSQL screen grammar happens to accept :name, but we
still neutralize as belt-and-suspenders against any grammar edge case, matching the base's hook intent.
The (?<!:) negative lookbehind is important: it skips the SECOND colon of a Databricks :: type cast
(col::int), which the ANSI grammar parses fine — without it, col::int → col:1 and the fail-closed
screen would wrongly reject a legitimate cast. :name is only ever a bind marker in our usage (Spark
SQL uses ./[] for member access), so this never turns a write into a read. (Casts to Databricks-only
type names, e.g. col::string, are still rejected by the ANSI grammar regardless — use CAST(... AS ...)
in native queries for those; that's an inherent limitation of the shared ANSI read-only screen.)
ProtectednormalizeApply normalizeValue to every field of every row in place, returning the same array.
ProtectednormalizeNormalize a raw remote value into an MJ-safe primitive so it round-trips losslessly and matches the
type CodeGen assigns the field. Native DB drivers return values that don't survive the JS/JSON
boundary: high-precision numbers as lossy numbers, JSON/complex columns as JS objects, MongoDB
bson wrappers as objects. This converts:
BigInt → decimal string (never a lossy Number)Long/Decimal128 → their exact string; ObjectId → hex string; Binary → Buffer;
other bson scalars → their JS valuenvarchar(MAX) CodeGen maps json/variant/nested to)ProtectedorderDatabricks paging: ANSI ORDER BY + LIMIT/OFFSET (LIMIT ALL when only an offset is given).
ProtectedparseParse the non-secret ConnectionConfig JSON blob into a typed config object.
Returns an empty object when unset. Throws on malformed JSON so the failure
surfaces clearly rather than as a downstream undefined-property error.
ProtectedpeekReturn the currently-cached connection handle (the pooled promise) for identity-guarded eviction, or undefined if nothing is cached / the driver doesn't track connections. Overridden by drivers that maintain a per-data-source connection cache. See withConnectionRetry.
ProtectedqualifyResolve an object name to a quoted, schema-qualified reference.
ProtectedquoteDatabricks/Spark SQL identifier quoting: backticks (like MySQL), doubling embedded backticks.
ProtectedquoteQuote a string literal for safe inline use in a screened WHERE fragment (single-quote escaped).
ProtectedredactStrip credentials from any connection-string-like scheme://user:pass@host embedded in a message.
Driver SDKs (notably MongoDB) echo the connection URI in their errors; when a caller supplied a URI
with inline credentials (e.g. mongodb://user:pass@host) those secrets would otherwise leak into
logs and API error responses. Redacts the entire userinfo portion, leaving the host intact.
ProtectedresolveResolve and decrypt the credential bound to this data source via the Credential Engine. Returns null when the data source has no CredentialID (anonymous-capable drivers). Drivers that require auth should treat null as an error.
OptionalcontextUser: UserInfoSQL object-name resolution: schema-qualify a bare name with the entity's SchemaName so an object
in a NON-default schema (e.g. medallion bronze/silver/gold, or any multi-schema source) resolves
correctly — qualifyObject then splits on '.' and quotes each part. An already schema-qualified
name (contains '.') or an entity with no SchemaName is returned unchanged (qualifyObject falls back
to the source DefaultSchema for the bare case). SchemaName is the same value CodeGen used to
introspect the object, so the read path and introspection stay consistent. This override is why the
qualification never reaches a non-SQL driver (e.g. MongoDB), which treats the name as literal.
Execute a native-dialect query (used by MJ Queries that set ExternalDataSourceID),
enabling full multi-table joins and vendor-specific analytics authored in the
remote dialect. params are bound, not string-interpolated.
OptionalcontextUser: UserInfoRunView-equivalent paginated read against a single remote object.
OptionalcontextUser: UserInfoProtectedscreenRe-screen a caller-supplied WHERE / ORDER-BY fragment at the driver boundary (defense in depth) before it is interpolated into a SELECT — the engine does not rely on an upstream caller having screened it. Fail-closed; see assertReadOnlyClause.
ProtectedscreenEnforce the read-only contract on a native-query string before it executes. Concrete SQL
drivers MUST call this at the top of RunNativeQuery — EDS is read-only, but rendered Query
SQL runs verbatim on a read/write connection and is not covered by the provider-layer
Save/Delete backstop. Fail-closed: throws on stacked statements, unparseable SQL, or any
write/DDL. See assertReadOnlyNativeQuery.
ProtectedselectOptional leading clause placed immediately after SELECT (before the projection). Default ''.
T-SQL overrides this to emit TOP (n) for a non-paginated row cap.
ProtectedsqlParser dialect used to screen native-query text for read-only safety (see
screenReadOnlyNativeQuery). Defaults to 'ansi' (PostgreSQL grammar), which covers
PostgreSQL / MySQL / Oracle / Snowflake; the SQL Server driver overrides this to 'sqlserver'
so T-SQL specifics (brackets, TOP, @vars) parse correctly.
Probe connectivity + auth for the given data source without running a user query.
OptionalcontextUser: UserInfoProtectedwithRuns a read operation and, if it fails with what looks like an auth/credential error, evicts the cached connection (so the retry re-resolves the credential and reconnects) and retries exactly once. This self-heals the common "credential rotated / token expired while a pooled connection was cached" case without a process restart. Safe because external reads are idempotent; non-auth errors propagate immediately with no retry.
Databricks SQL Warehouse driver for External Data Sources. Read-only, live-proxied access to a Databricks SQL warehouse over Unity Catalog via the official
@databricks/sqlSDK. Structurally mirrors the Snowflake driver (the other "cloud warehouse behind an HTTPS SDK") — ANSI SQL,LIMIT/OFFSETpaging — but with backtick identifier quoting and Unity Cataloginformation_schemaintrospection including informational PK/FK constraints.One connected
DBSQLClientperExternalDataSource.ID(race-safe in-flight-promise cache); each statement opens a short-lived session so concurrent reads don't serialize. Auth is PAT (authType: 'access-token') or OAuth M2M service principal (authType: 'databricks-oauth') depending on the resolved credential. Numeric fidelity is handled SDK-side viapreserveBigNumericPrecision(DECIMAL → exact string, BIGINT → JS bigint), which the base normalizer then renders JSON-safe. Registered asDatabricksExternalDriver.