Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 77 additions & 68 deletions crates/dbt-adapter/src/adapter/adapter_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ impl AdapterImpl {
Bigquery => &[Append],
Databricks => &[Append, Merge, InsertOverwrite, ReplaceWhere],
Redshift => &[Append, DeleteInsert, Merge, Microbatch],
Fabric => &[Append, DeleteInsert, Merge, Microbatch],
Fabric | SqlServer => &[Append, DeleteInsert, Merge, Microbatch],
Salesforce => &[Append, Merge],
ClickHouse => &[Append, DeleteInsert, InsertOverwrite, Microbatch, Legacy],
Spark => &[Append, Merge, InsertOverwrite, Microbatch],
Expand Down Expand Up @@ -963,14 +963,14 @@ impl AdapterImpl {
}
Replay(
adapter_type @ (Postgres | Redshift | Salesforce | DuckDB | Alt | Spark | Fabric
| ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion
| Dremio | Oracle),
| SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle),
_,
)
| Impl(
adapter_type @ (Postgres | Redshift | Salesforce | DuckDB | Alt | Spark | Fabric
| ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion
| Dremio | Oracle),
| SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle),
_,
) => Err(AdapterError::new(
AdapterErrorKind::Internal,
Expand Down Expand Up @@ -1001,8 +1001,8 @@ impl AdapterImpl {
self.list_schemas_via_adbc(state, database)
}
Snowflake | Databricks | Redshift | Spark | DuckDB | Postgres | Salesforce | Fabric
| ClickHouse | Exasol | Athena | Starburst | Trino | Datafusion | Dremio | Oracle
| Alt | Bigquery => {
| SqlServer | ClickHouse | Exasol | Athena | Starburst | Trino | Datafusion
| Dremio | Oracle | Alt | Bigquery => {
use crate::macro_exec::execute_macro_wrapper;
use minijinja::value::{Kwargs, Value};

Expand Down Expand Up @@ -1105,7 +1105,7 @@ impl AdapterImpl {
Postgres => "nspname",
DuckDB => "schema_name",
Alt => "schema_name",
Fabric => "schema",
Fabric | SqlServer => "schema",
// https://github.com/ClickHouse/dbt-clickhouse/blob/main/dbt/include/clickhouse/macros/adapters.sql
ClickHouse => "name",
Exasol => "name",
Expand Down Expand Up @@ -1388,8 +1388,8 @@ impl AdapterImpl {
)])))
}
Postgres | Bigquery | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
let err = format!(
"describe_dynamic_table is not supported by the {} adapter",
adapter_type
Expand Down Expand Up @@ -1806,14 +1806,13 @@ impl AdapterImpl {
// NOTE: This is the default behavior. If said adapter type does not
// have a get_columns_in_relation() macro, it will fail with a
// "macro does not exist" error
Athena | ClickHouse | Datafusion | Dremio | DuckDB | Alt | Exasol | Fabric | Oracle
| Postgres | Redshift | Salesforce | Snowflake | Spark | Starburst | Trino => {
execute_macro(
state,
&[RelationObject::new(relation.to_owned()).into_value()],
"get_columns_in_relation",
)
}
Athena | ClickHouse | Datafusion | Dremio | DuckDB | Alt | Exasol | Fabric
| SqlServer | Oracle | Postgres | Redshift | Salesforce | Snowflake | Spark
| Starburst | Trino => execute_macro(
state,
&[RelationObject::new(relation.to_owned()).into_value()],
"get_columns_in_relation",
),
};

macro_result
Expand Down Expand Up @@ -2071,8 +2070,8 @@ impl AdapterImpl {
}
Impl(
Snowflake | Databricks | Redshift | Salesforce | Postgres | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle,
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle,
_,
) => {
// downcast relation
Expand Down Expand Up @@ -2122,7 +2121,8 @@ impl AdapterImpl {
}
Impl(
Postgres | Bigquery | Databricks | Redshift | Spark | DuckDB | Alt | Fabric
| ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio | Oracle,
| SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion
| Dremio | Oracle,
_,
) => {
if quote_config.unwrap_or(true) {
Expand Down Expand Up @@ -2324,9 +2324,9 @@ impl AdapterImpl {

Ok(none_value())
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | Fabric | DuckDB
| Alt | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | Fabric
| SqlServer | DuckDB | Alt | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand All @@ -2341,8 +2341,8 @@ impl AdapterImpl {
) -> AdapterResult<Vec<String>> {
match self.adapter_type() {
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
let mut result = vec![];
for (_, column) in columns_map {
let col_name = if column.quote.unwrap_or(false) {
Expand Down Expand Up @@ -2535,6 +2535,14 @@ impl AdapterImpl {
(Fabric, ForeignKey) => Enforced,
(Fabric, Custom) => NotSupported,

// SqlServer
(SqlServer, Check) => Enforced,
(SqlServer, NotNull) => Enforced,
(SqlServer, Unique) => Enforced,
(SqlServer, PrimaryKey) => Enforced,
(SqlServer, ForeignKey) => Enforced,
(SqlServer, Custom) => NotSupported,

// Salesforce
(
Salesforce | Spark | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion
Expand Down Expand Up @@ -2645,7 +2653,7 @@ impl AdapterImpl {
}

match self.adapter_type() {
Postgres | Bigquery | DuckDB | Alt => {
Postgres | Bigquery | DuckDB | Alt | SqlServer => {
let grantee_cols = record_batch.column_values::<StringArray>("grantee")?;
let privilege_cols = record_batch.column_values::<StringArray>("privilege_type")?;

Expand Down Expand Up @@ -2869,8 +2877,8 @@ impl AdapterImpl {
Ok(AgateTable::from_record_batch(Arc::new(catalog)))
}
Snowflake | Bigquery | Databricks | Spark | DuckDB | Alt | Postgres | Salesforce
| Fabric | ClickHouse | Exasol | Athena | Starburst | Trino | Datafusion | Dremio
| Oracle => Err(AdapterError::new(
| Fabric | SqlServer | ClickHouse | Exasol | Athena | Starburst | Trino
| Datafusion | Dremio | Oracle => Err(AdapterError::new(
AdapterErrorKind::NotSupported,
"build_catalog_from_show_tables_and_svv_columns is only supported for Redshift",
)),
Expand All @@ -2885,8 +2893,8 @@ impl AdapterImpl {
match self.adapter_type() {
Bigquery => nest_column_data_types(columns, constraints),
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand Down Expand Up @@ -2924,8 +2932,8 @@ impl AdapterImpl {
match self.adapter_type() {
Bigquery => Ok(Value::from(render_struct_projection(col_name, data_type))),
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand Down Expand Up @@ -3022,8 +3030,8 @@ impl AdapterImpl {
Ok(none_value())
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand Down Expand Up @@ -3076,8 +3084,8 @@ impl AdapterImpl {
Self::parse_dataset_location(&batch)
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand Down Expand Up @@ -3134,8 +3142,8 @@ impl AdapterImpl {
Ok(none_value())
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand Down Expand Up @@ -3211,7 +3219,8 @@ impl AdapterImpl {
}
Salesforce => todo!("load_dataframe() for the Salesforce adapter"),
Postgres | Snowflake | Databricks | Redshift | Spark | DuckDB | Alt | Fabric
| ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio | Oracle => {
| SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion
| Dremio | Oracle => {
unimplemented!("only available with BigQuery or Salesforce adapter")
}
}
Expand Down Expand Up @@ -3272,8 +3281,8 @@ impl AdapterImpl {
Ok(none_value())
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand Down Expand Up @@ -3421,8 +3430,8 @@ impl AdapterImpl {
}
Impl(
adapter_type @ (Snowflake | Bigquery | Databricks | Salesforce | Spark | Fabric
| Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle),
| SqlServer | Exasol | Starburst | Athena | Trino | Datafusion
| Dremio | Oracle),
_,
) => {
unimplemented!(
Expand Down Expand Up @@ -3494,8 +3503,8 @@ impl AdapterImpl {
}
}
adapter_type @ (Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark
| DuckDB | Alt | Fabric | ClickHouse | Exasol | Starburst | Athena
| Trino | Datafusion | Dremio | Oracle) => {
| DuckDB | Alt | Fabric | SqlServer | ClickHouse | Exasol
| Starburst | Athena | Trino | Datafusion | Dremio | Oracle) => {
unimplemented!(
"is_replaceable is only available with BigQuery adapter, not {}",
adapter_type
Expand Down Expand Up @@ -3559,8 +3568,8 @@ impl AdapterImpl {
Ok(Value::from_object(validated_config))
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand All @@ -3583,8 +3592,8 @@ impl AdapterImpl {
adapter_type,
),
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand All @@ -3607,8 +3616,8 @@ impl AdapterImpl {
),
),
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand All @@ -3634,8 +3643,8 @@ impl AdapterImpl {
Ok(Value::from_serialize(options))
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => Err(minijinja::Error::new(
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => Err(minijinja::Error::new(
minijinja::ErrorKind::InvalidOperation,
"get_common_options is only available with BigQuery adapter",
)),
Expand Down Expand Up @@ -3676,8 +3685,8 @@ impl AdapterImpl {
Ok(Value::from(result))
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand Down Expand Up @@ -3863,8 +3872,8 @@ impl AdapterImpl {
Ok(Value::from(result))
}
Postgres | Snowflake | Bigquery | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with Databricksadapter")
}
}
Expand Down Expand Up @@ -4020,8 +4029,8 @@ impl AdapterImpl {
}

Postgres | Snowflake | Bigquery | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with Databricks adapter")
}
}
Expand Down Expand Up @@ -4098,8 +4107,8 @@ impl AdapterImpl {
Ok(())
}
Postgres | Snowflake | Bigquery | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with Databricks adapter")
}
}
Expand Down Expand Up @@ -4189,8 +4198,8 @@ impl AdapterImpl {
Ok(!use_managed_iceberg)
}
Postgres | Snowflake | Bigquery | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with Databricks adapter")
}
}
Expand Down Expand Up @@ -4531,8 +4540,8 @@ impl AdapterImpl {
Ok(())
}
Postgres | Snowflake | Databricks | Redshift | Salesforce | Spark | DuckDB | Alt
| Fabric | ClickHouse | Exasol | Starburst | Athena | Trino | Datafusion | Dremio
| Oracle => {
| Fabric | SqlServer | ClickHouse | Exasol | Starburst | Athena | Trino
| Datafusion | Dremio | Oracle => {
unimplemented!("only available with BigQuery adapter")
}
}
Expand Down Expand Up @@ -4911,8 +4920,8 @@ pub(crate) fn adapter_specific_behavior_flags(adapter_type: AdapterType) -> Vec<
);
vec![skip_autocommit_transaction_statements, grants_extended]
}
Postgres | Salesforce | Spark | DuckDB | Alt | ClickHouse | Exasol | Starburst | Athena
| Trino | Datafusion | Dremio | Oracle => vec![],
Postgres | Salesforce | Spark | DuckDB | Alt | SqlServer | ClickHouse | Exasol
| Starburst | Athena | Trino | Datafusion | Dremio | Oracle => vec![],
}
}

Expand Down