MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / purify_source_exports

Function purify_source_exports

src/sql/src/pure/sql_server.rs:55–332  ·  view source on GitHub ↗
(
    database: &str,
    client: &mut mz_sql_server_util::Client,
    retrieved_references: &RetrievedSourceReferences,
    requested_references: &Option<ExternalReferences>,
    text_columns: &[Unre

Source from the content-addressed store, hash-verified

53/// [`RetrievedSourceReferences`].
54#[allow(clippy::unused_async)]
55pub(super) async fn purify_source_exports(
56 database: &str,
57 client: &mut mz_sql_server_util::Client,
58 retrieved_references: &RetrievedSourceReferences,
59 requested_references: &Option<ExternalReferences>,
60 text_columns: &[UnresolvedItemName],
61 excl_columns: &[UnresolvedItemName],
62 unresolved_source_name: &UnresolvedItemName,
63 timeout: Duration,
64 reference_policy: &SourceReferencePolicy,
65) -> Result<PurifiedSourceExports, PlanError> {
66 let requested_exports = match requested_references.as_ref() {
67 Some(requested) => {
68 if *reference_policy == SourceReferencePolicy::NotAllowed {
69 return Err(PlanError::UseTablesForSources(requested.to_string()));
70 } else {
71 let exports = retrieved_references
72 .requested_source_exports(Some(requested), unresolved_source_name)?;
73 exports
74 }
75 }
76 None => {
77 if *reference_policy == SourceReferencePolicy::Required {
78 return Err(SqlServerSourcePurificationError::RequiresExternalReferences.into());
79 }
80
81 // If no external reference is specified, it does not make sense to include
82 // or text or exclude columns.
83 if !text_columns.is_empty() {
84 Err(
85 SqlServerSourcePurificationError::UnnecessaryOptionsWithoutReferences(
86 "TEXT COLUMNS".to_string(),
87 ),
88 )?
89 }
90 if !excl_columns.is_empty() {
91 Err(
92 SqlServerSourcePurificationError::UnnecessaryOptionsWithoutReferences(
93 "EXCLUDE COLUMNS".to_string(),
94 ),
95 )?
96 }
97
98 return Ok(PurifiedSourceExports {
99 source_exports: BTreeMap::default(),
100 normalized_text_columns: Vec::default(),
101 normalized_excl_columns: Vec::default(),
102 });
103 }
104 };
105
106 if requested_exports.is_empty() {
107 sql_bail!(
108 "SQL Server source must ingest at least one table, but {} matched none",
109 requested_references
110 .as_ref()
111 .expect("checked above")
112 .to_ast_string_simple()

Callers

nothing calls this directly

Calls 15

get_cdc_table_columnsFunction · 0.85
cloneFunction · 0.85
get_min_lsnsFunction · 0.85
get_max_lsn_retryFunction · 0.85
expectMethod · 0.80
sql_server_tableMethod · 0.80
qualified_nameMethod · 0.80
values_mutMethod · 0.80
apply_text_columnsMethod · 0.80

Tested by

no test coverage detected