Skip to content

Commit 059bcc1

Browse files
authored
Merge branch 'trunk' into peasee/260218-refactor-duplicated-s3-sources
2 parents df38e0c + 1700e1a commit 059bcc1

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

  • system-adapters/databricks/src

system-adapters/databricks/src/main.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
use std::{collections::HashMap, fmt::Write, time::Duration};
17+
use std::{collections::HashMap, time::Duration};
1818

1919
use anyhow::{Result, anyhow};
2020
use async_trait::async_trait;
@@ -362,17 +362,24 @@ impl Handler for DatabricksAdapter {
362362
.map_err(|e| format!("Invalid dataset '{dataset_name}' config: {e}"))?;
363363

364364
let table_name = dataset_name;
365-
let mut sql = String::new();
366-
let _ = write!(
367-
sql,
368-
"CREATE OR REPLACE TABLE {}.{}.{} USING PARQUET LOCATION {}",
365+
let fqn = format!(
366+
"{}.{}.{}",
369367
Self::quoted_identifier(&self.config.catalog),
370368
Self::quoted_identifier(&self.config.schema),
371369
Self::quoted_identifier(&table_name),
370+
);
371+
372+
let drop_sql = format!("DROP TABLE IF EXISTS {fqn}");
373+
self.execute_sql(&drop_sql)
374+
.await
375+
.map_err(|e| format!("Failed to drop existing table '{table_name}': {e}"))?;
376+
377+
let create_sql = format!(
378+
"CREATE TABLE {fqn} USING PARQUET LOCATION {}",
372379
Self::sql_string_literal(&location)
373380
);
374381

375-
self.execute_sql(&sql)
382+
self.execute_sql(&create_sql)
376383
.await
377384
.map_err(|e| format!("Failed to create table '{table_name}': {e}"))?;
378385

0 commit comments

Comments
 (0)