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

Class CreateSource

misc/python/materialize/zippy/source_actions.py:89–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87
88
89class CreateSource(Action):
90 def __init__(self, capabilities: Capabilities, source: SourceExists) -> None:
91 self.source = source
92 super().__init__(capabilities)
93
94 def run(self, c: Composition, state: State) -> None:
95 envelope = str(self.source.topic.envelope).split(".")[1]
96 kafka_connection_name = f"{self.source.name}_kafka_conn"
97 c.testdrive(
98 dedent(f"""
99 > CREATE CONNECTION IF NOT EXISTS {self.source.name}_csr_conn
100 TO CONFLUENT SCHEMA REGISTRY (URL '${{testdrive.schema-registry-url}}');
101
102 > CREATE CONNECTION IF NOT EXISTS {kafka_connection_name}
103 TO KAFKA (BROKER '${{testdrive.kafka-addr}}' {'USING SSH TUNNEL zippy_ssh' if self.source.uses_ssh_tunnel else ''}, SECURITY PROTOCOL PLAINTEXT);
104
105 > CREATE SOURCE {self.source.name}
106 IN CLUSTER {self.source.cluster_name}
107 FROM KAFKA CONNECTION {kafka_connection_name}
108 (TOPIC 'testdrive-{self.source.topic.name}-${{testdrive.seed}}')
109
110 > CREATE TABLE {self.source.get_name_for_query()} FROM SOURCE {self.source.name} (REFERENCE "testdrive-{self.source.topic.name}-${{testdrive.seed}}")
111 FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION {self.source.name}_csr_conn
112 ENVELOPE {envelope}
113 """),
114 mz_service=state.mz_service,
115 )
116
117 def provides(self) -> list[Capability]:
118 return [self.source]
119
120
121class AlterSourceConnection(Action):

Callers 15

plan_create_sourceFunction · 0.85
plan_create_subsourceFunction · 0.85
sequence_alter_sourceMethod · 0.85
parse_create_sourceMethod · 0.85
parse_main_statementFunction · 0.85
into_parser_statementMethod · 0.85
validate_single_variantFunction · 0.85
normalize_name_withMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected