kriti-sc commented on code in PR #2783:
URL: https://github.com/apache/iggy/pull/2783#discussion_r2867717034


##########
core/connectors/sinks/delta_sink/src/sink.rs:
##########
@@ -0,0 +1,197 @@
+/* Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+use crate::DeltaSink;
+use crate::SinkState;
+use crate::coercions::{coerce, create_coercion_tree};
+use crate::storage::build_storage_options;
+use crate::utils::parse_schema;
+use async_trait::async_trait;
+use deltalake::DeltaTable;
+use deltalake::operations::create::CreateBuilder;
+use deltalake::writer::{DeltaWriter, JsonWriter};
+use iggy_connector_sdk::{ConsumedMessage, Error, MessagesMetadata, Payload, 
Sink, TopicMetadata};
+use std::collections::HashMap;
+use tracing::{debug, error, info};
+
+#[async_trait]
+impl Sink for DeltaSink {
+    async fn open(&mut self) -> Result<(), Error> {
+        info!(
+            "Opening Delta Lake sink connector with ID: {} for table: {}",
+            self.id, self.config.table_uri
+        );
+
+        let table_url = url::Url::parse(&self.config.table_uri).map_err(|e| {
+            error!("Failed to parse table URI '{}': {e}", 
self.config.table_uri);
+            Error::InitError(format!("Invalid table URI: {e}"))
+        })?;
+
+        info!("Parsed table URI: {}", table_url);
+
+        let storage_options = build_storage_options(&self.config).map_err(|e| {
+            error!("Invalid storage configuration: {e}");
+            Error::InitError(format!("Invalid storage configuration: {e}"))
+        })?;
+
+        let table =
+            match deltalake::open_table_with_storage_options(table_url, 
storage_options.clone())
+                .await
+            {
+                Ok(table) => table,
+                Err(_) if !self.config.schema.is_empty() => {
+                    info!("Table does not exist, creating from configured 
schema...");
+                    create_table(&self.config.table_uri, storage_options, 
&self.config.schema)
+                        .await?
+                }

Review Comment:
   Fixed, now matching on `deltalake::DeltaTableError::NotATable(_)`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to