jonathanc-n commented on code in PR #17580:
URL: https://github.com/apache/datafusion/pull/17580#discussion_r2353167177


##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -790,9 +790,26 @@ impl SessionContext {
         }
 
         if exist {
-            match cmd.if_not_exists {
-                true => return self.return_empty_dataframe(),
-                false => {
+            match (cmd.if_not_exists, cmd.or_replace) {
+                (true, false) => return self.return_empty_dataframe(),
+                (false, true) => {
+                    let result = self
+                        .find_and_deregister(cmd.name.clone(), TableType::Base)
+                        .await;
+                    match result {
+                        Ok(true) => {
+                            let table_provider: Arc<dyn TableProvider> =
+                                self.create_custom_table(cmd).await?;
+                            self.register_table(cmd.name.clone(), 
table_provider)?;
+                            return self.return_empty_dataframe();
+                        }
+                        _ => return exec_err!("View '{}' doesn't exist.", 
cmd.name),

Review Comment:
   I added the full code to make it more clear



##########
datafusion/core/src/execution/context/mod.rs:
##########
@@ -790,9 +790,26 @@ impl SessionContext {
         }
 
         if exist {
-            match cmd.if_not_exists {
-                true => return self.return_empty_dataframe(),
-                false => {
+            match (cmd.if_not_exists, cmd.or_replace) {
+                (true, false) => return self.return_empty_dataframe(),
+                (false, true) => {
+                    let result = self
+                        .find_and_deregister(cmd.name.clone(), TableType::Base)
+                        .await;
+                    match result {
+                        Ok(true) => {
+                            let table_provider: Arc<dyn TableProvider> =
+                                self.create_custom_table(cmd).await?;
+                            self.register_table(cmd.name.clone(), 
table_provider)?;
+                            return self.return_empty_dataframe();
+                        }
+                        _ => return exec_err!("View '{}' doesn't exist.", 
cmd.name),

Review Comment:
   I added the full code functionality for each branch to make it more clear



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to