Skip to content

Commit

Permalink
Print warnings on CREATE or UPGRADE
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-cgorrie committed Aug 20, 2024
1 parent 18839dc commit e590014
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/snowflake/cli/_plugins/nativeapp/run_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@
}


def print_warnings(create_or_upgrade_cursor: DictCursor):
"""
Shows warnings in the console returned by the CREATE or UPGRADE
APPLICATION command.
"""
messages = [row["status"] for row in create_or_upgrade_cursor.fetchall()]
warnings = [m for m in messages if m.lower().startswith("warning:")]
if warnings:
for warning in warnings:
cc.warning(warning)
cc.message("")


class SameAccountInstallMethod:
_requires_created_by_cli: bool
_from_release_directive: bool
Expand Down Expand Up @@ -252,9 +265,11 @@ def create_or_upgrade_app(
f"Upgrading existing application object {self.app_name}."
)
using_clause = install_method.using_clause(self._na_project)
self._execute_query(
f"alter application {self.app_name} upgrade {using_clause}"
upgrade_cursor = self._execute_query(
f"alter application {self.app_name} upgrade {using_clause}",
cursor_class=DictCursor,
)
print_warnings(upgrade_cursor)

if install_method.is_dev_mode:
# if debug_mode is present (controlled), ensure it is up-to-date
Expand Down Expand Up @@ -300,15 +315,17 @@ def create_or_upgrade_app(
debug_mode_clause = f"debug_mode = {initial_debug_mode}"

using_clause = install_method.using_clause(self._na_project)
self._execute_query(
create_cursor = self._execute_query(
dedent(
f"""\
create application {self.app_name}
from application package {self.package_name} {using_clause} {debug_mode_clause}
comment = {SPECIAL_COMMENT}
"""
)
),
cursor_class=DictCursor,
)
print_warnings(create_cursor)

# hooks always executed after a create or upgrade
self.execute_app_post_deploy_hooks()
Expand Down

0 comments on commit e590014

Please sign in to comment.