Skip to content

Instantly share code, notes, and snippets.

@trungv0
Created October 13, 2023 15:40
Show Gist options
  • Save trungv0/e9780cf82613393c9641719dda3527d4 to your computer and use it in GitHub Desktop.
Save trungv0/e9780cf82613393c9641719dda3527d4 to your computer and use it in GitHub Desktop.
frosty friday w066
# https://frostyfriday.org/blog/2023/10/06/week-66-intermediate/
import snowflake.snowpark as snowpark
from snowflake.snowpark import functions as F
def main(session: snowpark.Session):
tableName = 'snowflake.account_usage.tables'
dataframe = (
session.table(tableName)
.filter(
(F.col('row_count') > 0)
& (~F.col('is_transient'))
& F.col('deleted').is_null()
)
.select(F.col('table_catalog').as_('database'))
.group_by(F.col('database'))
.agg(F.count('*').as_('tables'))
)
return dataframe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment