Skip to content

Commit 66d4c81

Browse files
committed
fix: stage and file format fqn
1 parent 7c59e94 commit 66d4c81

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

snowflake_utils/models/table.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def temporary_stage(self) -> str:
6060
@property
6161
def temporary_file_format(self) -> FileFormat:
6262
return FileFormat(
63-
schema=self.schema_name,
63+
database=self.database,
64+
schema_name=self.schema_name,
6465
name=f"tmp_file_format_{self.schema_name}_{self.name}".upper(),
6566
)
6667

@@ -69,7 +70,7 @@ def get_create_temporary_file_format_statement(self, file_format: str) -> str:
6970
Creates a temporary file format with the inline arguments
7071
"""
7172
file_format_statement = f"""
72-
CREATE OR REPLACE TEMPORARY FILE FORMAT {self.schema_name}.{self.temporary_file_format}
73+
CREATE OR REPLACE TEMPORARY FILE FORMAT {self.temporary_file_format}
7374
{file_format}
7475
"""
7576
return file_format_statement
@@ -83,8 +84,14 @@ def get_create_temporary_external_stage(
8384
self, path: str, storage_integration: str
8485
) -> str:
8586
logging.debug(f"Creating temporate stage at path: {path}")
87+
# Create a temporary stage with proper FQN
88+
stage_fqn = (
89+
f"{self.database}.{self.schema_name}.{self.temporary_stage}"
90+
if self.database
91+
else f"{self.schema_name}.{self.temporary_stage}"
92+
)
8693
return f"""
87-
CREATE OR REPLACE TEMPORARY STAGE {self.schema_name}.{self.temporary_stage}
94+
CREATE OR REPLACE TEMPORARY STAGE {stage_fqn}
8895
URL='{path}'
8996
STORAGE_INTEGRATION = {storage_integration}
9097
"""

0 commit comments

Comments
 (0)